00001 /* 00002 * Copyright 2003, 2004, 2005, 2006 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* Interface definition for configurable Xtensa ISA support. 00006 Copyright 2003, 2004, 2005 Free Software Foundation, Inc. 00007 00008 This file is part of BFD, the Binary File Descriptor library. 00009 00010 This program is free software; you can redistribute it and/or modify 00011 it under the terms of the GNU General Public License as published by 00012 the Free Software Foundation; either version 2 of the License, or 00013 (at your option) any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 00023 00024 #ifndef XTENSA_LIBISA_H 00025 #define XTENSA_LIBISA_H 00026 00027 #ifdef __cplusplus 00028 extern "C" { 00029 #endif 00030 00031 /* Use the statically-linked version for the GNU tools. */ 00032 #define STATIC_LIBISA 1 00033 00034 /* Version number: This is intended to help support code that works with 00035 versions of this library from multiple Xtensa releases. */ 00036 00037 #define XTENSA_ISA_VERSION 7000 00038 00039 #ifndef uint32 00040 #define uint32 unsigned int 00041 #endif 00042 00043 /* This file defines the interface to the Xtensa ISA library. This 00044 library contains most of the ISA-specific information for a 00045 particular Xtensa processor. For example, the set of valid 00046 instructions, their opcode encodings and operand fields are all 00047 included here. 00048 00049 This interface basically defines a number of abstract data types. 00050 00051 . an instruction buffer - for holding the raw instruction bits 00052 . ISA info - information about the ISA as a whole 00053 . instruction formats - instruction size and slot structure 00054 . opcodes - information about individual instructions 00055 . operands - information about register and immediate instruction operands 00056 . stateOperands - information about processor state instruction operands 00057 . interfaceOperands - information about interface instruction operands 00058 . register files - register file information 00059 . processor states - internal processor state information 00060 . system registers - "special registers" and "user registers" 00061 . interfaces - TIE interfaces that are external to the processor 00062 . functional units - TIE shared functions 00063 00064 The interface defines a set of functions to access each data type. 00065 With the exception of the instruction buffer, the internal 00066 representations of the data structures are hidden. All accesses must 00067 be made through the functions defined here. */ 00068 00069 typedef struct xtensa_isa_opaque { int unused; } *xtensa_isa; 00070 00071 00072 /* Most of the Xtensa ISA entities (e.g., opcodes, regfiles, etc.) are 00073 represented here using sequential integers beginning with 0. The 00074 specific values are only fixed for a particular instantiation of an 00075 xtensa_isa structure, so these values should only be used 00076 internally. */ 00077 00078 typedef int xtensa_opcode; 00079 typedef int xtensa_format; 00080 typedef int xtensa_regfile; 00081 typedef int xtensa_state; 00082 typedef int xtensa_sysreg; 00083 typedef int xtensa_interface; 00084 typedef int xtensa_funcUnit; 00085 00086 00087 /* Define a unique value for undefined items. */ 00088 00089 #define XTENSA_UNDEFINED -1 00090 00091 00092 /* Overview of using this interface to decode/encode instructions: 00093 00094 Each Xtensa instruction is associated with a particular instruction 00095 format, where the format defines a fixed number of slots for 00096 operations. The formats for the core Xtensa ISA have only one slot, 00097 but FLIX instructions may have multiple slots. Within each slot, 00098 there is a single opcode and some number of associated operands. 00099 00100 The encoding and decoding functions operate on instruction buffers, 00101 not on the raw bytes of the instructions. The same instruction 00102 buffer data structure is used for both entire instructions and 00103 individual slots in those instructions -- the contents of a slot need 00104 to be extracted from or inserted into the buffer for the instruction 00105 as a whole. 00106 00107 Decoding an instruction involves first finding the format, which 00108 identifies the number of slots, and then decoding each slot 00109 separately. A slot is decoded by finding the opcode and then using 00110 the opcode to determine how many operands there are. For example: 00111 00112 xtensa_insnbuf_from_chars 00113 xtensa_format_decode 00114 for each slot { 00115 xtensa_format_get_slot 00116 xtensa_opcode_decode 00117 for each operand { 00118 xtensa_operand_get_field 00119 xtensa_operand_decode 00120 } 00121 } 00122 00123 Encoding an instruction is roughly the same procedure in reverse: 00124 00125 xtensa_format_encode 00126 for each slot { 00127 xtensa_opcode_encode 00128 for each operand { 00129 xtensa_operand_encode 00130 xtensa_operand_set_field 00131 } 00132 xtensa_format_set_slot 00133 } 00134 xtensa_insnbuf_to_chars 00135 */ 00136 00137 00138 /* Error handling. */ 00139 00140 /* Error codes. The code for the most recent error condition can be 00141 retrieved with the "errno" function. For any result other than 00142 xtensa_isa_ok, an error message containing additional information 00143 about the problem can be retrieved using the "error_msg" function. 00144 The error messages are stored in an internal buffer, which should not 00145 should be freed and may be overwritten by subsequent operations. */ 00146 00147 typedef enum xtensa_isa_status_enum 00148 { 00149 xtensa_isa_ok = 0, 00150 xtensa_isa_bad_format, 00151 xtensa_isa_bad_slot, 00152 xtensa_isa_bad_opcode, 00153 xtensa_isa_bad_operand, 00154 xtensa_isa_bad_field, 00155 xtensa_isa_bad_iclass, 00156 xtensa_isa_bad_regfile, 00157 xtensa_isa_bad_sysreg, 00158 xtensa_isa_bad_state, 00159 xtensa_isa_bad_interface, 00160 xtensa_isa_bad_funcUnit, 00161 xtensa_isa_wrong_slot, 00162 xtensa_isa_no_field, 00163 xtensa_isa_out_of_memory, 00164 xtensa_isa_buffer_overflow, 00165 xtensa_isa_internal_error, 00166 xtensa_isa_bad_value 00167 } xtensa_isa_status; 00168 00169 extern xtensa_isa_status 00170 xtensa_isa_errno (xtensa_isa isa); 00171 00172 extern char * 00173 xtensa_isa_error_msg (xtensa_isa isa); 00174 00175 00176 00177 /* Instruction buffers. */ 00178 00179 typedef uint32 xtensa_insnbuf_word; 00180 typedef xtensa_insnbuf_word *xtensa_insnbuf; 00181 00182 00183 /* Get the size in "insnbuf_words" of the xtensa_insnbuf array. */ 00184 00185 extern int 00186 xtensa_insnbuf_size (xtensa_isa isa); 00187 00188 00189 /* Allocate an xtensa_insnbuf of the right size. */ 00190 00191 extern xtensa_insnbuf 00192 xtensa_insnbuf_alloc (xtensa_isa isa); 00193 00194 00195 /* Release an xtensa_insnbuf. */ 00196 00197 extern void 00198 xtensa_insnbuf_free (xtensa_isa isa, xtensa_insnbuf buf); 00199 00200 00201 /* Conversion between raw memory (char arrays) and our internal 00202 instruction representation. This is complicated by the Xtensa ISA's 00203 variable instruction lengths. When converting to chars, the buffer 00204 must contain a valid instruction so we know how many bytes to copy; 00205 thus, the "to_chars" function returns the number of bytes copied or 00206 XTENSA_UNDEFINED on error. The "from_chars" function first reads the 00207 minimal number of bytes required to decode the instruction length and 00208 then proceeds to copy the entire instruction into the buffer; if the 00209 memory does not contain a valid instruction, it copies the maximum 00210 number of bytes required for the longest Xtensa instruction. The 00211 "num_chars" argument may be used to limit the number of bytes that 00212 can be read or written. Otherwise, if "num_chars" is zero, the 00213 functions may read or write past the end of the code. */ 00214 00215 extern int 00216 xtensa_insnbuf_to_chars (xtensa_isa isa, const xtensa_insnbuf insn, 00217 unsigned char *cp, int num_chars); 00218 00219 extern void 00220 xtensa_insnbuf_from_chars (xtensa_isa isa, xtensa_insnbuf insn, 00221 const unsigned char *cp, int num_chars); 00222 00223 00224 00225 /* ISA information. */ 00226 00227 /* Initialize the ISA information. */ 00228 00229 extern xtensa_isa 00230 xtensa_isa_init (xtensa_isa_status *errno_p, char **error_msg_p); 00231 00232 00233 /* Deallocate an xtensa_isa structure. */ 00234 00235 extern void 00236 xtensa_isa_free (xtensa_isa isa); 00237 00238 00239 /* Get the maximum instruction size in bytes. */ 00240 00241 extern int 00242 xtensa_isa_maxlength (xtensa_isa isa); 00243 00244 00245 /* Decode the length in bytes of an instruction in raw memory (not an 00246 insnbuf). This function reads only the minimal number of bytes 00247 required to decode the instruction length. Returns 00248 XTENSA_UNDEFINED on error. */ 00249 00250 extern int 00251 xtensa_isa_length_from_chars (xtensa_isa isa, const unsigned char *cp); 00252 00253 00254 /* Get the number of stages in the processor's pipeline. The pipeline 00255 stage values returned by other functions in this library will range 00256 from 0 to N-1, where N is the value returned by this function. 00257 Note that the stage numbers used here may not correspond to the 00258 actual processor hardware, e.g., the hardware may have additional 00259 stages before stage 0. Returns XTENSA_UNDEFINED on error. */ 00260 00261 extern int 00262 xtensa_isa_num_pipe_stages (xtensa_isa isa); 00263 00264 00265 /* Get the number of various entities that are defined for this processor. */ 00266 00267 extern int 00268 xtensa_isa_num_formats (xtensa_isa isa); 00269 00270 extern int 00271 xtensa_isa_num_opcodes (xtensa_isa isa); 00272 00273 extern int 00274 xtensa_isa_num_regfiles (xtensa_isa isa); 00275 00276 extern int 00277 xtensa_isa_num_states (xtensa_isa isa); 00278 00279 extern int 00280 xtensa_isa_num_sysregs (xtensa_isa isa); 00281 00282 extern int 00283 xtensa_isa_num_interfaces (xtensa_isa isa); 00284 00285 extern int 00286 xtensa_isa_num_funcUnits (xtensa_isa isa); 00287 00288 00289 00290 /* Instruction formats. */ 00291 00292 /* Get the name of a format. Returns null on error. */ 00293 00294 extern const char * 00295 xtensa_format_name (xtensa_isa isa, xtensa_format fmt); 00296 00297 00298 /* Given a format name, return the format number. Returns 00299 XTENSA_UNDEFINED if the name is not a valid format. */ 00300 00301 extern xtensa_format 00302 xtensa_format_lookup (xtensa_isa isa, const char *fmtname); 00303 00304 00305 /* Decode the instruction format from a binary instruction buffer. 00306 Returns XTENSA_UNDEFINED if the format is not recognized. */ 00307 00308 extern xtensa_format 00309 xtensa_format_decode (xtensa_isa isa, const xtensa_insnbuf insn); 00310 00311 00312 /* Set the instruction format field(s) in a binary instruction buffer. 00313 All the other fields are set to zero. Returns non-zero on error. */ 00314 00315 extern int 00316 xtensa_format_encode (xtensa_isa isa, xtensa_format fmt, xtensa_insnbuf insn); 00317 00318 00319 /* Find the length (in bytes) of an instruction. Returns 00320 XTENSA_UNDEFINED on error. */ 00321 00322 extern int 00323 xtensa_format_length (xtensa_isa isa, xtensa_format fmt); 00324 00325 00326 /* Get the number of slots in an instruction. Returns XTENSA_UNDEFINED 00327 on error. */ 00328 00329 extern int 00330 xtensa_format_num_slots (xtensa_isa isa, xtensa_format fmt); 00331 00332 00333 /* Get the opcode for a no-op in a particular slot. 00334 Returns XTENSA_UNDEFINED on error. */ 00335 00336 extern xtensa_opcode 00337 xtensa_format_slot_nop_opcode (xtensa_isa isa, xtensa_format fmt, int slot); 00338 00339 00340 /* Get the bits for a specified slot out of an insnbuf for the 00341 instruction as a whole and put them into an insnbuf for that one 00342 slot, and do the opposite to set a slot. Return non-zero on error. */ 00343 00344 extern int 00345 xtensa_format_get_slot (xtensa_isa isa, xtensa_format fmt, int slot, 00346 const xtensa_insnbuf insn, xtensa_insnbuf slotbuf); 00347 00348 extern int 00349 xtensa_format_set_slot (xtensa_isa isa, xtensa_format fmt, int slot, 00350 xtensa_insnbuf insn, const xtensa_insnbuf slotbuf); 00351 00352 00353 00354 /* Opcode information. */ 00355 00356 /* Translate a mnemonic name to an opcode. Returns XTENSA_UNDEFINED if 00357 the name is not a valid opcode mnemonic. */ 00358 00359 extern xtensa_opcode 00360 xtensa_opcode_lookup (xtensa_isa isa, const char *opname); 00361 00362 00363 /* Decode the opcode for one instruction slot from a binary instruction 00364 buffer. Returns the opcode or XTENSA_UNDEFINED if the opcode is 00365 illegal. */ 00366 00367 extern xtensa_opcode 00368 xtensa_opcode_decode (xtensa_isa isa, xtensa_format fmt, int slot, 00369 const xtensa_insnbuf slotbuf); 00370 00371 00372 /* Set the opcode field(s) for an instruction slot. All other fields 00373 in the slot are set to zero. Returns non-zero if the opcode cannot 00374 be encoded. */ 00375 00376 extern int 00377 xtensa_opcode_encode (xtensa_isa isa, xtensa_format fmt, int slot, 00378 xtensa_insnbuf slotbuf, xtensa_opcode opc); 00379 00380 00381 /* Get the mnemonic name for an opcode. Returns null on error. */ 00382 00383 extern const char * 00384 xtensa_opcode_name (xtensa_isa isa, xtensa_opcode opc); 00385 00386 00387 /* Check various properties of opcodes. These functions return 0 if 00388 the condition is false, 1 if the condition is true, and 00389 XTENSA_UNDEFINED on error. The instructions are classified as 00390 follows: 00391 00392 branch: conditional branch; may fall through to next instruction (B*) 00393 jump: unconditional branch (J, JX, RET*, RF*) 00394 loop: zero-overhead loop (LOOP*) 00395 call: unconditional call; control returns to next instruction (CALL*) 00396 00397 For the opcodes that affect control flow in some way, the branch 00398 target may be specified by an immediate operand or it may be an 00399 address stored in a register. You can distinguish these by 00400 checking if the instruction has a PC-relative immediate 00401 operand. */ 00402 00403 extern int 00404 xtensa_opcode_is_branch (xtensa_isa isa, xtensa_opcode opc); 00405 00406 extern int 00407 xtensa_opcode_is_jump (xtensa_isa isa, xtensa_opcode opc); 00408 00409 extern int 00410 xtensa_opcode_is_loop (xtensa_isa isa, xtensa_opcode opc); 00411 00412 extern int 00413 xtensa_opcode_is_call (xtensa_isa isa, xtensa_opcode opc); 00414 00415 00416 /* Find the number of ordinary operands, state operands, and interface 00417 operands for an instruction. These return XTENSA_UNDEFINED on 00418 error. */ 00419 00420 extern int 00421 xtensa_opcode_num_operands (xtensa_isa isa, xtensa_opcode opc); 00422 00423 extern int 00424 xtensa_opcode_num_stateOperands (xtensa_isa isa, xtensa_opcode opc); 00425 00426 extern int 00427 xtensa_opcode_num_interfaceOperands (xtensa_isa isa, xtensa_opcode opc); 00428 00429 00430 /* Get functional unit usage requirements for an opcode. Each "use" 00431 is identified by a <functional unit, pipeline stage> pair. The 00432 "num_funcUnit_uses" function returns the number of these "uses" or 00433 XTENSA_UNDEFINED on error. The "funcUnit_use" function returns 00434 a pointer to a "use" pair or null on error. */ 00435 00436 typedef struct xtensa_funcUnit_use_struct 00437 { 00438 xtensa_funcUnit unit; 00439 int stage; 00440 } xtensa_funcUnit_use; 00441 00442 extern int 00443 xtensa_opcode_num_funcUnit_uses (xtensa_isa isa, xtensa_opcode opc); 00444 00445 extern xtensa_funcUnit_use * 00446 xtensa_opcode_funcUnit_use (xtensa_isa isa, xtensa_opcode opc, int u); 00447 00448 00449 00450 /* Operand information. */ 00451 00452 /* Get the name of an operand. Returns null on error. */ 00453 00454 extern const char * 00455 xtensa_operand_name (xtensa_isa isa, xtensa_opcode opc, int opnd); 00456 00457 00458 /* Some operands are "invisible", i.e., not explicitly specified in 00459 assembly language. When assembling an instruction, you need not set 00460 the values of invisible operands, since they are either hardwired or 00461 derived from other field values. The values of invisible operands 00462 can be examined in the same way as other operands, but remember that 00463 an invisible operand may get its value from another visible one, so 00464 the entire instruction must be available before examining the 00465 invisible operand values. This function returns 1 if an operand is 00466 visible, 0 if it is invisible, or XTENSA_UNDEFINED on error. Note 00467 that whether an operand is visible is orthogonal to whether it is 00468 "implicit", i.e., whether it is encoded in a field in the 00469 instruction. */ 00470 00471 extern int 00472 xtensa_operand_is_visible (xtensa_isa isa, xtensa_opcode opc, int opnd); 00473 00474 00475 /* Check if an operand is an input ('i'), output ('o'), or inout ('m') 00476 operand. Note: The output operand of a conditional assignment 00477 (e.g., movnez) appears here as an inout ('m') even if it is declared 00478 in the TIE code as an output ('o'); this allows the compiler to 00479 properly handle register allocation for conditional assignments. 00480 Returns 0 on error. */ 00481 00482 extern char 00483 xtensa_operand_inout (xtensa_isa isa, xtensa_opcode opc, int opnd); 00484 00485 00486 /* Get and set the raw (encoded) value of the field for the specified 00487 operand. The "set" function does not check if the value fits in the 00488 field; that is done by the "encode" function below. Both of these 00489 functions return non-zero on error, e.g., if the field is not defined 00490 for the specified slot. */ 00491 00492 extern int 00493 xtensa_operand_get_field (xtensa_isa isa, xtensa_opcode opc, int opnd, 00494 xtensa_format fmt, int slot, 00495 const xtensa_insnbuf slotbuf, uint32 *valp); 00496 00497 extern int 00498 xtensa_operand_set_field (xtensa_isa isa, xtensa_opcode opc, int opnd, 00499 xtensa_format fmt, int slot, 00500 xtensa_insnbuf slotbuf, uint32 val); 00501 00502 00503 /* Encode and decode operands. The raw bits in the operand field may 00504 be encoded in a variety of different ways. These functions hide 00505 the details of that encoding. The result values are returned through 00506 the argument pointer. The return value is non-zero on error. */ 00507 00508 extern int 00509 xtensa_operand_encode (xtensa_isa isa, xtensa_opcode opc, int opnd, 00510 uint32 *valp); 00511 00512 extern int 00513 xtensa_operand_decode (xtensa_isa isa, xtensa_opcode opc, int opnd, 00514 uint32 *valp); 00515 00516 00517 /* An operand may be either a register operand or an immediate of some 00518 sort (e.g., PC-relative or not). The "is_register" function returns 00519 0 if the operand is an immediate, 1 if it is a register, and 00520 XTENSA_UNDEFINED on error. The "regfile" function returns the 00521 regfile for a register operand, or XTENSA_UNDEFINED on error. */ 00522 00523 extern int 00524 xtensa_operand_is_register (xtensa_isa isa, xtensa_opcode opc, int opnd); 00525 00526 extern xtensa_regfile 00527 xtensa_operand_regfile (xtensa_isa isa, xtensa_opcode opc, int opnd); 00528 00529 00530 /* Register operands may span multiple consecutive registers, e.g., a 00531 64-bit data type may occupy two 32-bit registers. Only the first 00532 register is encoded in the operand field. This function specifies 00533 the number of consecutive registers occupied by this operand. For 00534 non-register operands, the return value is undefined. Returns 00535 XTENSA_UNDEFINED on error. */ 00536 00537 extern int 00538 xtensa_operand_num_regs (xtensa_isa isa, xtensa_opcode opc, int opnd); 00539 00540 00541 /* Some register operands do not completely identify the register being 00542 accessed. For example, the operand value may be added to an internal 00543 state value. By definition, this implies that the corresponding 00544 regfile is not allocatable. Unknown registers should generally be 00545 treated with worst-case assumptions. The function returns 0 if the 00546 register value is unknown, 1 if known, and XTENSA_UNDEFINED on 00547 error. */ 00548 00549 extern int 00550 xtensa_operand_is_known_reg (xtensa_isa isa, xtensa_opcode opc, int opnd); 00551 00552 00553 /* Check if an immediate operand is PC-relative. Returns 0 for register 00554 operands and non-PC-relative immediates, 1 for PC-relative 00555 immediates, and XTENSA_UNDEFINED on error. */ 00556 00557 extern int 00558 xtensa_operand_is_PCrelative (xtensa_isa isa, xtensa_opcode opc, int opnd); 00559 00560 00561 /* For PC-relative offset operands, the interpretation of the offset may 00562 vary between opcodes, e.g., is it relative to the current PC or that 00563 of the next instruction? The following functions are defined to 00564 perform PC-relative relocations and to undo them (as in the 00565 disassembler). The "do_reloc" function takes the desired address 00566 value and the PC of the current instruction and sets the value to the 00567 corresponding PC-relative offset (which can then be encoded and 00568 stored into the operand field). The "undo_reloc" function takes the 00569 unencoded offset value and the current PC and sets the value to the 00570 appropriate address. The return values are non-zero on error. Note 00571 that these functions do not replace the encode/decode functions; the 00572 operands must be encoded/decoded separately and the encode functions 00573 are responsible for detecting invalid operand values. */ 00574 00575 extern int 00576 xtensa_operand_do_reloc (xtensa_isa isa, xtensa_opcode opc, int opnd, 00577 uint32 *valp, uint32 pc); 00578 00579 extern int 00580 xtensa_operand_undo_reloc (xtensa_isa isa, xtensa_opcode opc, int opnd, 00581 uint32 *valp, uint32 pc); 00582 00583 00584 00585 /* State Operands. */ 00586 00587 /* Get the state accessed by a state operand. Returns XTENSA_UNDEFINED 00588 on error. */ 00589 00590 extern xtensa_state 00591 xtensa_stateOperand_state (xtensa_isa isa, xtensa_opcode opc, int stOp); 00592 00593 00594 /* Check if a state operand is an input ('i'), output ('o'), or inout 00595 ('m') operand. Returns 0 on error. */ 00596 00597 extern char 00598 xtensa_stateOperand_inout (xtensa_isa isa, xtensa_opcode opc, int stOp); 00599 00600 00601 00602 /* Interface Operands. */ 00603 00604 /* Get the external interface accessed by an interface operand. 00605 Returns XTENSA_UNDEFINED on error. */ 00606 00607 extern xtensa_interface 00608 xtensa_interfaceOperand_interface (xtensa_isa isa, xtensa_opcode opc, 00609 int ifOp); 00610 00611 00612 00613 /* Register Files. */ 00614 00615 /* Regfiles include both "real" regfiles and "views", where a view 00616 allows a group of adjacent registers in a real "parent" regfile to be 00617 viewed as a single register. A regfile view has all the same 00618 properties as its parent except for its (long) name, bit width, number 00619 of entries, and default ctype. You can use the parent function to 00620 distinguish these two classes. */ 00621 00622 /* Look up a regfile by either its name or its abbreviated "short name". 00623 Returns XTENSA_UNDEFINED on error. The "lookup_shortname" function 00624 ignores "view" regfiles since they always have the same shortname as 00625 their parents. */ 00626 00627 extern xtensa_regfile 00628 xtensa_regfile_lookup (xtensa_isa isa, const char *name); 00629 00630 extern xtensa_regfile 00631 xtensa_regfile_lookup_shortname (xtensa_isa isa, const char *shortname); 00632 00633 00634 /* Get the name or abbreviated "short name" of a regfile. 00635 Returns null on error. */ 00636 00637 extern const char * 00638 xtensa_regfile_name (xtensa_isa isa, xtensa_regfile rf); 00639 00640 extern const char * 00641 xtensa_regfile_shortname (xtensa_isa isa, xtensa_regfile rf); 00642 00643 00644 /* Get the parent regfile of a "view" regfile. If the regfile is not a 00645 view, the result is the same as the input parameter. Returns 00646 XTENSA_UNDEFINED on error. */ 00647 00648 extern xtensa_regfile 00649 xtensa_regfile_view_parent (xtensa_isa isa, xtensa_regfile rf); 00650 00651 00652 /* Get the bit width of a regfile or regfile view. 00653 Returns XTENSA_UNDEFINED on error. */ 00654 00655 extern int 00656 xtensa_regfile_num_bits (xtensa_isa isa, xtensa_regfile rf); 00657 00658 00659 /* Get the number of regfile entries. Returns XTENSA_UNDEFINED on 00660 error. */ 00661 00662 extern int 00663 xtensa_regfile_num_entries (xtensa_isa isa, xtensa_regfile rf); 00664 00665 00666 00667 /* Processor States. */ 00668 00669 /* Look up a state by name. Returns XTENSA_UNDEFINED on error. */ 00670 00671 extern xtensa_state 00672 xtensa_state_lookup (xtensa_isa isa, const char *name); 00673 00674 00675 /* Get the name for a processor state. Returns null on error. */ 00676 00677 extern const char * 00678 xtensa_state_name (xtensa_isa isa, xtensa_state st); 00679 00680 00681 /* Get the bit width for a processor state. 00682 Returns XTENSA_UNDEFINED on error. */ 00683 00684 extern int 00685 xtensa_state_num_bits (xtensa_isa isa, xtensa_state st); 00686 00687 00688 /* Check if a state is exported from the processor core. Returns 0 if 00689 the condition is false, 1 if the condition is true, and 00690 XTENSA_UNDEFINED on error. */ 00691 00692 extern int 00693 xtensa_state_is_exported (xtensa_isa isa, xtensa_state st); 00694 00695 00696 00697 /* Sysregs ("special registers" and "user registers"). */ 00698 00699 /* Look up a register by its number and whether it is a "user register" 00700 or a "special register". Returns XTENSA_UNDEFINED if the sysreg does 00701 not exist. */ 00702 00703 extern xtensa_sysreg 00704 xtensa_sysreg_lookup (xtensa_isa isa, int num, int is_user); 00705 00706 00707 /* Check if there exists a sysreg with a given name. 00708 If not, this function returns XTENSA_UNDEFINED. */ 00709 00710 extern xtensa_sysreg 00711 xtensa_sysreg_lookup_name (xtensa_isa isa, const char *name); 00712 00713 00714 /* Get the name of a sysreg. Returns null on error. */ 00715 00716 extern const char * 00717 xtensa_sysreg_name (xtensa_isa isa, xtensa_sysreg sysreg); 00718 00719 00720 /* Get the register number. Returns XTENSA_UNDEFINED on error. */ 00721 00722 extern int 00723 xtensa_sysreg_number (xtensa_isa isa, xtensa_sysreg sysreg); 00724 00725 00726 /* Check if a sysreg is a "special register" or a "user register". 00727 Returns 0 for special registers, 1 for user registers and 00728 XTENSA_UNDEFINED on error. */ 00729 00730 extern int 00731 xtensa_sysreg_is_user (xtensa_isa isa, xtensa_sysreg sysreg); 00732 00733 00734 00735 /* Interfaces. */ 00736 00737 /* Find an interface by name. The return value is XTENSA_UNDEFINED if 00738 the specified interface is not found. */ 00739 00740 extern xtensa_interface 00741 xtensa_interface_lookup (xtensa_isa isa, const char *ifname); 00742 00743 00744 /* Get the name of an interface. Returns null on error. */ 00745 00746 extern const char * 00747 xtensa_interface_name (xtensa_isa isa, xtensa_interface intf); 00748 00749 00750 /* Get the bit width for an interface. 00751 Returns XTENSA_UNDEFINED on error. */ 00752 00753 extern int 00754 xtensa_interface_num_bits (xtensa_isa isa, xtensa_interface intf); 00755 00756 00757 /* Check if an interface is an input ('i') or output ('o') with respect 00758 to the Xtensa processor core. Returns 0 on error. */ 00759 00760 extern char 00761 xtensa_interface_inout (xtensa_isa isa, xtensa_interface intf); 00762 00763 00764 /* Check if accessing an interface has potential side effects. 00765 Currently "data" interfaces have side effects and "control" 00766 interfaces do not. Returns 1 if there are side effects, 0 if not, 00767 and XTENSA_UNDEFINED on error. */ 00768 00769 extern int 00770 xtensa_interface_has_side_effect (xtensa_isa isa, xtensa_interface intf); 00771 00772 00773 /* Some interfaces may be related such that accessing one interface 00774 has side effects on a set of related interfaces. The interfaces 00775 are partitioned into equivalence classes of related interfaces, and 00776 each class is assigned a unique identifier number. This function 00777 returns the class identifier for an interface, or XTENSA_UNDEFINED 00778 on error. These identifiers can be compared to determine if two 00779 interfaces are related; the specific values of the identifiers have 00780 no particular meaning otherwise. */ 00781 00782 extern int 00783 xtensa_interface_class_id (xtensa_isa isa, xtensa_interface intf); 00784 00785 00786 00787 /* Functional Units. */ 00788 00789 /* Find a functional unit by name. The return value is XTENSA_UNDEFINED if 00790 the specified unit is not found. */ 00791 00792 extern xtensa_funcUnit 00793 xtensa_funcUnit_lookup (xtensa_isa isa, const char *fname); 00794 00795 00796 /* Get the name of a functional unit. Returns null on error. */ 00797 00798 extern const char * 00799 xtensa_funcUnit_name (xtensa_isa isa, xtensa_funcUnit fun); 00800 00801 00802 /* Functional units may be replicated. See how many instances of a 00803 particular function unit exist. Returns XTENSA_UNDEFINED on error. */ 00804 00805 extern int 00806 xtensa_funcUnit_num_copies (xtensa_isa isa, xtensa_funcUnit fun); 00807 00808 00809 #ifdef __cplusplus 00810 } 00811 #endif 00812 #endif /* XTENSA_LIBISA_H */
1.5.6