xtensa-isa.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. /* Interface definition for configurable Xtensa ISA support.
  2. Copyright (C) 2003-2022 Free Software Foundation, Inc.
  3. This file is part of BFD, the Binary File Descriptor library.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
  15. USA. */
  16. #ifndef XTENSA_LIBISA_H
  17. #define XTENSA_LIBISA_H
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /* Version number: This is intended to help support code that works with
  22. versions of this library from multiple Xtensa releases. */
  23. #define XTENSA_ISA_VERSION 7000
  24. #ifndef uint32
  25. #define uint32 unsigned int
  26. #endif
  27. /* This file defines the interface to the Xtensa ISA library. This
  28. library contains most of the ISA-specific information for a
  29. particular Xtensa processor. For example, the set of valid
  30. instructions, their opcode encodings and operand fields are all
  31. included here.
  32. This interface basically defines a number of abstract data types.
  33. . an instruction buffer - for holding the raw instruction bits
  34. . ISA info - information about the ISA as a whole
  35. . instruction formats - instruction size and slot structure
  36. . opcodes - information about individual instructions
  37. . operands - information about register and immediate instruction operands
  38. . stateOperands - information about processor state instruction operands
  39. . interfaceOperands - information about interface instruction operands
  40. . register files - register file information
  41. . processor states - internal processor state information
  42. . system registers - "special registers" and "user registers"
  43. . interfaces - TIE interfaces that are external to the processor
  44. . functional units - TIE shared functions
  45. The interface defines a set of functions to access each data type.
  46. With the exception of the instruction buffer, the internal
  47. representations of the data structures are hidden. All accesses must
  48. be made through the functions defined here. */
  49. typedef struct xtensa_isa_opaque { int unused; } *xtensa_isa;
  50. /* Most of the Xtensa ISA entities (e.g., opcodes, regfiles, etc.) are
  51. represented here using sequential integers beginning with 0. The
  52. specific values are only fixed for a particular instantiation of an
  53. xtensa_isa structure, so these values should only be used
  54. internally. */
  55. typedef int xtensa_opcode;
  56. typedef int xtensa_format;
  57. typedef int xtensa_regfile;
  58. typedef int xtensa_state;
  59. typedef int xtensa_sysreg;
  60. typedef int xtensa_interface;
  61. typedef int xtensa_funcUnit;
  62. /* Define a unique value for undefined items. */
  63. #define XTENSA_UNDEFINED -1
  64. /* Overview of using this interface to decode/encode instructions:
  65. Each Xtensa instruction is associated with a particular instruction
  66. format, where the format defines a fixed number of slots for
  67. operations. The formats for the core Xtensa ISA have only one slot,
  68. but FLIX instructions may have multiple slots. Within each slot,
  69. there is a single opcode and some number of associated operands.
  70. The encoding and decoding functions operate on instruction buffers,
  71. not on the raw bytes of the instructions. The same instruction
  72. buffer data structure is used for both entire instructions and
  73. individual slots in those instructions -- the contents of a slot need
  74. to be extracted from or inserted into the buffer for the instruction
  75. as a whole.
  76. Decoding an instruction involves first finding the format, which
  77. identifies the number of slots, and then decoding each slot
  78. separately. A slot is decoded by finding the opcode and then using
  79. the opcode to determine how many operands there are. For example:
  80. xtensa_insnbuf_from_chars
  81. xtensa_format_decode
  82. for each slot {
  83. xtensa_format_get_slot
  84. xtensa_opcode_decode
  85. for each operand {
  86. xtensa_operand_get_field
  87. xtensa_operand_decode
  88. }
  89. }
  90. Encoding an instruction is roughly the same procedure in reverse:
  91. xtensa_format_encode
  92. for each slot {
  93. xtensa_opcode_encode
  94. for each operand {
  95. xtensa_operand_encode
  96. xtensa_operand_set_field
  97. }
  98. xtensa_format_set_slot
  99. }
  100. xtensa_insnbuf_to_chars
  101. */
  102. /* Error handling. */
  103. /* Error codes. The code for the most recent error condition can be
  104. retrieved with the "errno" function. For any result other than
  105. xtensa_isa_ok, an error message containing additional information
  106. about the problem can be retrieved using the "error_msg" function.
  107. The error messages are stored in an internal buffer, which should
  108. not be freed and may be overwritten by subsequent operations. */
  109. typedef enum xtensa_isa_status_enum
  110. {
  111. xtensa_isa_ok = 0,
  112. xtensa_isa_bad_format,
  113. xtensa_isa_bad_slot,
  114. xtensa_isa_bad_opcode,
  115. xtensa_isa_bad_operand,
  116. xtensa_isa_bad_field,
  117. xtensa_isa_bad_iclass,
  118. xtensa_isa_bad_regfile,
  119. xtensa_isa_bad_sysreg,
  120. xtensa_isa_bad_state,
  121. xtensa_isa_bad_interface,
  122. xtensa_isa_bad_funcUnit,
  123. xtensa_isa_wrong_slot,
  124. xtensa_isa_no_field,
  125. xtensa_isa_out_of_memory,
  126. xtensa_isa_buffer_overflow,
  127. xtensa_isa_internal_error,
  128. xtensa_isa_bad_value
  129. } xtensa_isa_status;
  130. extern xtensa_isa_status
  131. xtensa_isa_errno (xtensa_isa isa);
  132. extern char *
  133. xtensa_isa_error_msg (xtensa_isa isa);
  134. /* Instruction buffers. */
  135. typedef uint32 xtensa_insnbuf_word;
  136. typedef xtensa_insnbuf_word *xtensa_insnbuf;
  137. /* Get the size in "insnbuf_words" of the xtensa_insnbuf array. */
  138. extern int
  139. xtensa_insnbuf_size (xtensa_isa isa);
  140. /* Allocate an xtensa_insnbuf of the right size. */
  141. extern xtensa_insnbuf
  142. xtensa_insnbuf_alloc (xtensa_isa isa);
  143. /* Release an xtensa_insnbuf. */
  144. extern void
  145. xtensa_insnbuf_free (xtensa_isa isa, xtensa_insnbuf buf);
  146. /* Conversion between raw memory (char arrays) and our internal
  147. instruction representation. This is complicated by the Xtensa ISA's
  148. variable instruction lengths. When converting to chars, the buffer
  149. must contain a valid instruction so we know how many bytes to copy;
  150. thus, the "to_chars" function returns the number of bytes copied or
  151. XTENSA_UNDEFINED on error. The "from_chars" function first reads the
  152. minimal number of bytes required to decode the instruction length and
  153. then proceeds to copy the entire instruction into the buffer; if the
  154. memory does not contain a valid instruction, it copies the maximum
  155. number of bytes required for the longest Xtensa instruction. The
  156. "num_chars" argument may be used to limit the number of bytes that
  157. can be read or written. Otherwise, if "num_chars" is zero, the
  158. functions may read or write past the end of the code. */
  159. extern int
  160. xtensa_insnbuf_to_chars (xtensa_isa isa, const xtensa_insnbuf insn,
  161. unsigned char *cp, int num_chars);
  162. extern void
  163. xtensa_insnbuf_from_chars (xtensa_isa isa, xtensa_insnbuf insn,
  164. const unsigned char *cp, int num_chars);
  165. /* ISA information. */
  166. /* Initialize the ISA information. */
  167. extern xtensa_isa
  168. xtensa_isa_init (xtensa_isa_status *errno_p, char **error_msg_p);
  169. /* Deallocate an xtensa_isa structure. */
  170. extern void
  171. xtensa_isa_free (xtensa_isa isa);
  172. /* Get the maximum instruction size in bytes. */
  173. extern int
  174. xtensa_isa_maxlength (xtensa_isa isa);
  175. /* Decode the length in bytes of an instruction in raw memory (not an
  176. insnbuf). This function reads only the minimal number of bytes
  177. required to decode the instruction length. Returns
  178. XTENSA_UNDEFINED on error. */
  179. extern int
  180. xtensa_isa_length_from_chars (xtensa_isa isa, const unsigned char *cp);
  181. /* Get the number of stages in the processor's pipeline. The pipeline
  182. stage values returned by other functions in this library will range
  183. from 0 to N-1, where N is the value returned by this function.
  184. Note that the stage numbers used here may not correspond to the
  185. actual processor hardware, e.g., the hardware may have additional
  186. stages before stage 0. Returns XTENSA_UNDEFINED on error. */
  187. extern int
  188. xtensa_isa_num_pipe_stages (xtensa_isa isa);
  189. /* Get the number of various entities that are defined for this processor. */
  190. extern int
  191. xtensa_isa_num_formats (xtensa_isa isa);
  192. extern int
  193. xtensa_isa_num_opcodes (xtensa_isa isa);
  194. extern int
  195. xtensa_isa_num_regfiles (xtensa_isa isa);
  196. extern int
  197. xtensa_isa_num_states (xtensa_isa isa);
  198. extern int
  199. xtensa_isa_num_sysregs (xtensa_isa isa);
  200. extern int
  201. xtensa_isa_num_interfaces (xtensa_isa isa);
  202. extern int
  203. xtensa_isa_num_funcUnits (xtensa_isa isa);
  204. /* Instruction formats. */
  205. /* Get the name of a format. Returns null on error. */
  206. extern const char *
  207. xtensa_format_name (xtensa_isa isa, xtensa_format fmt);
  208. /* Given a format name, return the format number. Returns
  209. XTENSA_UNDEFINED if the name is not a valid format. */
  210. extern xtensa_format
  211. xtensa_format_lookup (xtensa_isa isa, const char *fmtname);
  212. /* Decode the instruction format from a binary instruction buffer.
  213. Returns XTENSA_UNDEFINED if the format is not recognized. */
  214. extern xtensa_format
  215. xtensa_format_decode (xtensa_isa isa, const xtensa_insnbuf insn);
  216. /* Set the instruction format field(s) in a binary instruction buffer.
  217. All the other fields are set to zero. Returns non-zero on error. */
  218. extern int
  219. xtensa_format_encode (xtensa_isa isa, xtensa_format fmt, xtensa_insnbuf insn);
  220. /* Find the length (in bytes) of an instruction. Returns
  221. XTENSA_UNDEFINED on error. */
  222. extern int
  223. xtensa_format_length (xtensa_isa isa, xtensa_format fmt);
  224. /* Get the number of slots in an instruction. Returns XTENSA_UNDEFINED
  225. on error. */
  226. extern int
  227. xtensa_format_num_slots (xtensa_isa isa, xtensa_format fmt);
  228. /* Get the opcode for a no-op in a particular slot.
  229. Returns XTENSA_UNDEFINED on error. */
  230. extern xtensa_opcode
  231. xtensa_format_slot_nop_opcode (xtensa_isa isa, xtensa_format fmt, int slot);
  232. /* Get the bits for a specified slot out of an insnbuf for the
  233. instruction as a whole and put them into an insnbuf for that one
  234. slot, and do the opposite to set a slot. Return non-zero on error. */
  235. extern int
  236. xtensa_format_get_slot (xtensa_isa isa, xtensa_format fmt, int slot,
  237. const xtensa_insnbuf insn, xtensa_insnbuf slotbuf);
  238. extern int
  239. xtensa_format_set_slot (xtensa_isa isa, xtensa_format fmt, int slot,
  240. xtensa_insnbuf insn, const xtensa_insnbuf slotbuf);
  241. /* Opcode information. */
  242. /* Translate a mnemonic name to an opcode. Returns XTENSA_UNDEFINED if
  243. the name is not a valid opcode mnemonic. */
  244. extern xtensa_opcode
  245. xtensa_opcode_lookup (xtensa_isa isa, const char *opname);
  246. /* Decode the opcode for one instruction slot from a binary instruction
  247. buffer. Returns the opcode or XTENSA_UNDEFINED if the opcode is
  248. illegal. */
  249. extern xtensa_opcode
  250. xtensa_opcode_decode (xtensa_isa isa, xtensa_format fmt, int slot,
  251. const xtensa_insnbuf slotbuf);
  252. /* Set the opcode field(s) for an instruction slot. All other fields
  253. in the slot are set to zero. Returns non-zero if the opcode cannot
  254. be encoded. */
  255. extern int
  256. xtensa_opcode_encode (xtensa_isa isa, xtensa_format fmt, int slot,
  257. xtensa_insnbuf slotbuf, xtensa_opcode opc);
  258. /* Get the mnemonic name for an opcode. Returns null on error. */
  259. extern const char *
  260. xtensa_opcode_name (xtensa_isa isa, xtensa_opcode opc);
  261. /* Check various properties of opcodes. These functions return 0 if
  262. the condition is false, 1 if the condition is true, and
  263. XTENSA_UNDEFINED on error. The instructions are classified as
  264. follows:
  265. branch: conditional branch; may fall through to next instruction (B*)
  266. jump: unconditional branch (J, JX, RET*, RF*)
  267. loop: zero-overhead loop (LOOP*)
  268. call: unconditional call; control returns to next instruction (CALL*)
  269. For the opcodes that affect control flow in some way, the branch
  270. target may be specified by an immediate operand or it may be an
  271. address stored in a register. You can distinguish these by
  272. checking if the instruction has a PC-relative immediate
  273. operand. */
  274. extern int
  275. xtensa_opcode_is_branch (xtensa_isa isa, xtensa_opcode opc);
  276. extern int
  277. xtensa_opcode_is_jump (xtensa_isa isa, xtensa_opcode opc);
  278. extern int
  279. xtensa_opcode_is_loop (xtensa_isa isa, xtensa_opcode opc);
  280. extern int
  281. xtensa_opcode_is_call (xtensa_isa isa, xtensa_opcode opc);
  282. /* Find the number of ordinary operands, state operands, and interface
  283. operands for an instruction. These return XTENSA_UNDEFINED on
  284. error. */
  285. extern int
  286. xtensa_opcode_num_operands (xtensa_isa isa, xtensa_opcode opc);
  287. extern int
  288. xtensa_opcode_num_stateOperands (xtensa_isa isa, xtensa_opcode opc);
  289. extern int
  290. xtensa_opcode_num_interfaceOperands (xtensa_isa isa, xtensa_opcode opc);
  291. /* Get functional unit usage requirements for an opcode. Each "use"
  292. is identified by a <functional unit, pipeline stage> pair. The
  293. "num_funcUnit_uses" function returns the number of these "uses" or
  294. XTENSA_UNDEFINED on error. The "funcUnit_use" function returns
  295. a pointer to a "use" pair or null on error. */
  296. typedef struct xtensa_funcUnit_use_struct
  297. {
  298. xtensa_funcUnit unit;
  299. int stage;
  300. } xtensa_funcUnit_use;
  301. extern int
  302. xtensa_opcode_num_funcUnit_uses (xtensa_isa isa, xtensa_opcode opc);
  303. extern xtensa_funcUnit_use *
  304. xtensa_opcode_funcUnit_use (xtensa_isa isa, xtensa_opcode opc, int u);
  305. /* Operand information. */
  306. /* Get the name of an operand. Returns null on error. */
  307. extern const char *
  308. xtensa_operand_name (xtensa_isa isa, xtensa_opcode opc, int opnd);
  309. /* Some operands are "invisible", i.e., not explicitly specified in
  310. assembly language. When assembling an instruction, you need not set
  311. the values of invisible operands, since they are either hardwired or
  312. derived from other field values. The values of invisible operands
  313. can be examined in the same way as other operands, but remember that
  314. an invisible operand may get its value from another visible one, so
  315. the entire instruction must be available before examining the
  316. invisible operand values. This function returns 1 if an operand is
  317. visible, 0 if it is invisible, or XTENSA_UNDEFINED on error. Note
  318. that whether an operand is visible is orthogonal to whether it is
  319. "implicit", i.e., whether it is encoded in a field in the
  320. instruction. */
  321. extern int
  322. xtensa_operand_is_visible (xtensa_isa isa, xtensa_opcode opc, int opnd);
  323. /* Check if an operand is an input ('i'), output ('o'), or inout ('m')
  324. operand. Note: The output operand of a conditional assignment
  325. (e.g., movnez) appears here as an inout ('m') even if it is declared
  326. in the TIE code as an output ('o'); this allows the compiler to
  327. properly handle register allocation for conditional assignments.
  328. Returns 0 on error. */
  329. extern char
  330. xtensa_operand_inout (xtensa_isa isa, xtensa_opcode opc, int opnd);
  331. /* Get and set the raw (encoded) value of the field for the specified
  332. operand. The "set" function does not check if the value fits in the
  333. field; that is done by the "encode" function below. Both of these
  334. functions return non-zero on error, e.g., if the field is not defined
  335. for the specified slot. */
  336. extern int
  337. xtensa_operand_get_field (xtensa_isa isa, xtensa_opcode opc, int opnd,
  338. xtensa_format fmt, int slot,
  339. const xtensa_insnbuf slotbuf, uint32 *valp);
  340. extern int
  341. xtensa_operand_set_field (xtensa_isa isa, xtensa_opcode opc, int opnd,
  342. xtensa_format fmt, int slot,
  343. xtensa_insnbuf slotbuf, uint32 val);
  344. /* Encode and decode operands. The raw bits in the operand field may
  345. be encoded in a variety of different ways. These functions hide
  346. the details of that encoding. The result values are returned through
  347. the argument pointer. The return value is non-zero on error. */
  348. extern int
  349. xtensa_operand_encode (xtensa_isa isa, xtensa_opcode opc, int opnd,
  350. uint32 *valp);
  351. extern int
  352. xtensa_operand_decode (xtensa_isa isa, xtensa_opcode opc, int opnd,
  353. uint32 *valp);
  354. /* An operand may be either a register operand or an immediate of some
  355. sort (e.g., PC-relative or not). The "is_register" function returns
  356. 0 if the operand is an immediate, 1 if it is a register, and
  357. XTENSA_UNDEFINED on error. The "regfile" function returns the
  358. regfile for a register operand, or XTENSA_UNDEFINED on error. */
  359. extern int
  360. xtensa_operand_is_register (xtensa_isa isa, xtensa_opcode opc, int opnd);
  361. extern xtensa_regfile
  362. xtensa_operand_regfile (xtensa_isa isa, xtensa_opcode opc, int opnd);
  363. /* Register operands may span multiple consecutive registers, e.g., a
  364. 64-bit data type may occupy two 32-bit registers. Only the first
  365. register is encoded in the operand field. This function specifies
  366. the number of consecutive registers occupied by this operand. For
  367. non-register operands, the return value is undefined. Returns
  368. XTENSA_UNDEFINED on error. */
  369. extern int
  370. xtensa_operand_num_regs (xtensa_isa isa, xtensa_opcode opc, int opnd);
  371. /* Some register operands do not completely identify the register being
  372. accessed. For example, the operand value may be added to an internal
  373. state value. By definition, this implies that the corresponding
  374. regfile is not allocatable. Unknown registers should generally be
  375. treated with worst-case assumptions. The function returns 0 if the
  376. register value is unknown, 1 if known, and XTENSA_UNDEFINED on
  377. error. */
  378. extern int
  379. xtensa_operand_is_known_reg (xtensa_isa isa, xtensa_opcode opc, int opnd);
  380. /* Check if an immediate operand is PC-relative. Returns 0 for register
  381. operands and non-PC-relative immediates, 1 for PC-relative
  382. immediates, and XTENSA_UNDEFINED on error. */
  383. extern int
  384. xtensa_operand_is_PCrelative (xtensa_isa isa, xtensa_opcode opc, int opnd);
  385. /* For PC-relative offset operands, the interpretation of the offset may
  386. vary between opcodes, e.g., is it relative to the current PC or that
  387. of the next instruction? The following functions are defined to
  388. perform PC-relative relocations and to undo them (as in the
  389. disassembler). The "do_reloc" function takes the desired address
  390. value and the PC of the current instruction and sets the value to the
  391. corresponding PC-relative offset (which can then be encoded and
  392. stored into the operand field). The "undo_reloc" function takes the
  393. unencoded offset value and the current PC and sets the value to the
  394. appropriate address. The return values are non-zero on error. Note
  395. that these functions do not replace the encode/decode functions; the
  396. operands must be encoded/decoded separately and the encode functions
  397. are responsible for detecting invalid operand values. */
  398. extern int
  399. xtensa_operand_do_reloc (xtensa_isa isa, xtensa_opcode opc, int opnd,
  400. uint32 *valp, uint32 pc);
  401. extern int
  402. xtensa_operand_undo_reloc (xtensa_isa isa, xtensa_opcode opc, int opnd,
  403. uint32 *valp, uint32 pc);
  404. /* State Operands. */
  405. /* Get the state accessed by a state operand. Returns XTENSA_UNDEFINED
  406. on error. */
  407. extern xtensa_state
  408. xtensa_stateOperand_state (xtensa_isa isa, xtensa_opcode opc, int stOp);
  409. /* Check if a state operand is an input ('i'), output ('o'), or inout
  410. ('m') operand. Returns 0 on error. */
  411. extern char
  412. xtensa_stateOperand_inout (xtensa_isa isa, xtensa_opcode opc, int stOp);
  413. /* Interface Operands. */
  414. /* Get the external interface accessed by an interface operand.
  415. Returns XTENSA_UNDEFINED on error. */
  416. extern xtensa_interface
  417. xtensa_interfaceOperand_interface (xtensa_isa isa, xtensa_opcode opc,
  418. int ifOp);
  419. /* Register Files. */
  420. /* Regfiles include both "real" regfiles and "views", where a view
  421. allows a group of adjacent registers in a real "parent" regfile to be
  422. viewed as a single register. A regfile view has all the same
  423. properties as its parent except for its (long) name, bit width, number
  424. of entries, and default ctype. You can use the parent function to
  425. distinguish these two classes. */
  426. /* Look up a regfile by either its name or its abbreviated "short name".
  427. Returns XTENSA_UNDEFINED on error. The "lookup_shortname" function
  428. ignores "view" regfiles since they always have the same shortname as
  429. their parents. */
  430. extern xtensa_regfile
  431. xtensa_regfile_lookup (xtensa_isa isa, const char *name);
  432. extern xtensa_regfile
  433. xtensa_regfile_lookup_shortname (xtensa_isa isa, const char *shortname);
  434. /* Get the name or abbreviated "short name" of a regfile.
  435. Returns null on error. */
  436. extern const char *
  437. xtensa_regfile_name (xtensa_isa isa, xtensa_regfile rf);
  438. extern const char *
  439. xtensa_regfile_shortname (xtensa_isa isa, xtensa_regfile rf);
  440. /* Get the parent regfile of a "view" regfile. If the regfile is not a
  441. view, the result is the same as the input parameter. Returns
  442. XTENSA_UNDEFINED on error. */
  443. extern xtensa_regfile
  444. xtensa_regfile_view_parent (xtensa_isa isa, xtensa_regfile rf);
  445. /* Get the bit width of a regfile or regfile view.
  446. Returns XTENSA_UNDEFINED on error. */
  447. extern int
  448. xtensa_regfile_num_bits (xtensa_isa isa, xtensa_regfile rf);
  449. /* Get the number of regfile entries. Returns XTENSA_UNDEFINED on
  450. error. */
  451. extern int
  452. xtensa_regfile_num_entries (xtensa_isa isa, xtensa_regfile rf);
  453. /* Processor States. */
  454. /* Look up a state by name. Returns XTENSA_UNDEFINED on error. */
  455. extern xtensa_state
  456. xtensa_state_lookup (xtensa_isa isa, const char *name);
  457. /* Get the name for a processor state. Returns null on error. */
  458. extern const char *
  459. xtensa_state_name (xtensa_isa isa, xtensa_state st);
  460. /* Get the bit width for a processor state.
  461. Returns XTENSA_UNDEFINED on error. */
  462. extern int
  463. xtensa_state_num_bits (xtensa_isa isa, xtensa_state st);
  464. /* Check if a state is exported from the processor core. Returns 0 if
  465. the condition is false, 1 if the condition is true, and
  466. XTENSA_UNDEFINED on error. */
  467. extern int
  468. xtensa_state_is_exported (xtensa_isa isa, xtensa_state st);
  469. /* Check for a "shared_or" state. Returns 0 if the condition is false,
  470. 1 if the condition is true, and XTENSA_UNDEFINED on error. */
  471. extern int
  472. xtensa_state_is_shared_or (xtensa_isa isa, xtensa_state st);
  473. /* Sysregs ("special registers" and "user registers"). */
  474. /* Look up a register by its number and whether it is a "user register"
  475. or a "special register". Returns XTENSA_UNDEFINED if the sysreg does
  476. not exist. */
  477. extern xtensa_sysreg
  478. xtensa_sysreg_lookup (xtensa_isa isa, int num, int is_user);
  479. /* Check if there exists a sysreg with a given name.
  480. If not, this function returns XTENSA_UNDEFINED. */
  481. extern xtensa_sysreg
  482. xtensa_sysreg_lookup_name (xtensa_isa isa, const char *name);
  483. /* Get the name of a sysreg. Returns null on error. */
  484. extern const char *
  485. xtensa_sysreg_name (xtensa_isa isa, xtensa_sysreg sysreg);
  486. /* Get the register number. Returns XTENSA_UNDEFINED on error. */
  487. extern int
  488. xtensa_sysreg_number (xtensa_isa isa, xtensa_sysreg sysreg);
  489. /* Check if a sysreg is a "special register" or a "user register".
  490. Returns 0 for special registers, 1 for user registers and
  491. XTENSA_UNDEFINED on error. */
  492. extern int
  493. xtensa_sysreg_is_user (xtensa_isa isa, xtensa_sysreg sysreg);
  494. /* Interfaces. */
  495. /* Find an interface by name. The return value is XTENSA_UNDEFINED if
  496. the specified interface is not found. */
  497. extern xtensa_interface
  498. xtensa_interface_lookup (xtensa_isa isa, const char *ifname);
  499. /* Get the name of an interface. Returns null on error. */
  500. extern const char *
  501. xtensa_interface_name (xtensa_isa isa, xtensa_interface intf);
  502. /* Get the bit width for an interface.
  503. Returns XTENSA_UNDEFINED on error. */
  504. extern int
  505. xtensa_interface_num_bits (xtensa_isa isa, xtensa_interface intf);
  506. /* Check if an interface is an input ('i') or output ('o') with respect
  507. to the Xtensa processor core. Returns 0 on error. */
  508. extern char
  509. xtensa_interface_inout (xtensa_isa isa, xtensa_interface intf);
  510. /* Check if accessing an interface has potential side effects.
  511. Currently "data" interfaces have side effects and "control"
  512. interfaces do not. Returns 1 if there are side effects, 0 if not,
  513. and XTENSA_UNDEFINED on error. */
  514. extern int
  515. xtensa_interface_has_side_effect (xtensa_isa isa, xtensa_interface intf);
  516. /* Some interfaces may be related such that accessing one interface
  517. has side effects on a set of related interfaces. The interfaces
  518. are partitioned into equivalence classes of related interfaces, and
  519. each class is assigned a unique identifier number. This function
  520. returns the class identifier for an interface, or XTENSA_UNDEFINED
  521. on error. These identifiers can be compared to determine if two
  522. interfaces are related; the specific values of the identifiers have
  523. no particular meaning otherwise. */
  524. extern int
  525. xtensa_interface_class_id (xtensa_isa isa, xtensa_interface intf);
  526. /* Functional Units. */
  527. /* Find a functional unit by name. The return value is XTENSA_UNDEFINED if
  528. the specified unit is not found. */
  529. extern xtensa_funcUnit
  530. xtensa_funcUnit_lookup (xtensa_isa isa, const char *fname);
  531. /* Get the name of a functional unit. Returns null on error. */
  532. extern const char *
  533. xtensa_funcUnit_name (xtensa_isa isa, xtensa_funcUnit fun);
  534. /* Functional units may be replicated. See how many instances of a
  535. particular function unit exist. Returns XTENSA_UNDEFINED on error. */
  536. extern int
  537. xtensa_funcUnit_num_copies (xtensa_isa isa, xtensa_funcUnit fun);
  538. #ifdef __cplusplus
  539. }
  540. #endif
  541. #endif /* XTENSA_LIBISA_H */