xref: /openbmc/qemu/include/hw/xtensa/xtensa-isa.h (revision 01807c8b0e9f5da6981c2e62a3c1d8f661fb178e)
17f709ce7SMax Filippov /* Interface definition for configurable Xtensa ISA support.
27f709ce7SMax Filippov  *
37f709ce7SMax Filippov  * Copyright (c) 2001-2013 Tensilica Inc.
47f709ce7SMax Filippov  *
57f709ce7SMax Filippov  * Permission is hereby granted, free of charge, to any person obtaining
67f709ce7SMax Filippov  * a copy of this software and associated documentation files (the
77f709ce7SMax Filippov  * "Software"), to deal in the Software without restriction, including
87f709ce7SMax Filippov  * without limitation the rights to use, copy, modify, merge, publish,
97f709ce7SMax Filippov  * distribute, sublicense, and/or sell copies of the Software, and to
107f709ce7SMax Filippov  * permit persons to whom the Software is furnished to do so, subject to
117f709ce7SMax Filippov  * the following conditions:
127f709ce7SMax Filippov  *
137f709ce7SMax Filippov  * The above copyright notice and this permission notice shall be included
147f709ce7SMax Filippov  * in all copies or substantial portions of the Software.
157f709ce7SMax Filippov  *
167f709ce7SMax Filippov  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
177f709ce7SMax Filippov  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
187f709ce7SMax Filippov  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
197f709ce7SMax Filippov  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
207f709ce7SMax Filippov  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
217f709ce7SMax Filippov  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
227f709ce7SMax Filippov  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
237f709ce7SMax Filippov  */
247f709ce7SMax Filippov 
25*58ea30f5SMarkus Armbruster #ifndef HW_XTENSA_XTENSA_ISA_H
26*58ea30f5SMarkus Armbruster #define HW_XTENSA_XTENSA_ISA_H
277f709ce7SMax Filippov 
287f709ce7SMax Filippov #ifdef __cplusplus
297f709ce7SMax Filippov extern "C" {
307f709ce7SMax Filippov #endif
317f709ce7SMax Filippov 
327f709ce7SMax Filippov /*
337f709ce7SMax Filippov  * Version number: This is intended to help support code that works with
347f709ce7SMax Filippov  * versions of this library from multiple Xtensa releases.
357f709ce7SMax Filippov  */
367f709ce7SMax Filippov 
377f709ce7SMax Filippov #define XTENSA_ISA_VERSION 7000
387f709ce7SMax Filippov 
397f709ce7SMax Filippov /*
407f709ce7SMax Filippov  * This file defines the interface to the Xtensa ISA library. This
417f709ce7SMax Filippov  * library contains most of the ISA-specific information for a
427f709ce7SMax Filippov  * particular Xtensa processor. For example, the set of valid
437f709ce7SMax Filippov  * instructions, their opcode encodings and operand fields are all
447f709ce7SMax Filippov  * included here.
457f709ce7SMax Filippov  *
467f709ce7SMax Filippov  * This interface basically defines a number of abstract data types.
477f709ce7SMax Filippov  *
487f709ce7SMax Filippov  * . an instruction buffer - for holding the raw instruction bits
497f709ce7SMax Filippov  * . ISA info - information about the ISA as a whole
507f709ce7SMax Filippov  * . instruction formats - instruction size and slot structure
517f709ce7SMax Filippov  * . opcodes - information about individual instructions
527f709ce7SMax Filippov  * . operands - information about register and immediate instruction operands
537f709ce7SMax Filippov  * . stateOperands - information about processor state instruction operands
547f709ce7SMax Filippov  * . interfaceOperands - information about interface instruction operands
557f709ce7SMax Filippov  * . register files - register file information
567f709ce7SMax Filippov  * . processor states - internal processor state information
577f709ce7SMax Filippov  * . system registers - "special registers" and "user registers"
587f709ce7SMax Filippov  * . interfaces - TIE interfaces that are external to the processor
597f709ce7SMax Filippov  * . functional units - TIE shared functions
607f709ce7SMax Filippov  *
617f709ce7SMax Filippov  * The interface defines a set of functions to access each data type.
627f709ce7SMax Filippov  * With the exception of the instruction buffer, the internal
637f709ce7SMax Filippov  * representations of the data structures are hidden. All accesses must
647f709ce7SMax Filippov  * be made through the functions defined here.
657f709ce7SMax Filippov  */
667f709ce7SMax Filippov 
677f709ce7SMax Filippov typedef struct xtensa_isa_opaque { int unused; } *xtensa_isa;
687f709ce7SMax Filippov 
697f709ce7SMax Filippov 
707f709ce7SMax Filippov /*
717f709ce7SMax Filippov  * Most of the Xtensa ISA entities (e.g., opcodes, regfiles, etc.) are
727f709ce7SMax Filippov  * represented here using sequential integers beginning with 0. The
737f709ce7SMax Filippov  * specific values are only fixed for a particular instantiation of an
747f709ce7SMax Filippov  * xtensa_isa structure, so these values should only be used
757f709ce7SMax Filippov  * internally.
767f709ce7SMax Filippov  */
777f709ce7SMax Filippov 
787f709ce7SMax Filippov typedef int xtensa_opcode;
797f709ce7SMax Filippov typedef int xtensa_format;
807f709ce7SMax Filippov typedef int xtensa_regfile;
817f709ce7SMax Filippov typedef int xtensa_state;
827f709ce7SMax Filippov typedef int xtensa_sysreg;
837f709ce7SMax Filippov typedef int xtensa_interface;
847f709ce7SMax Filippov typedef int xtensa_funcUnit;
857f709ce7SMax Filippov 
867f709ce7SMax Filippov 
877f709ce7SMax Filippov /* Define a unique value for undefined items. */
887f709ce7SMax Filippov 
897f709ce7SMax Filippov #define XTENSA_UNDEFINED -1
907f709ce7SMax Filippov 
917f709ce7SMax Filippov 
927f709ce7SMax Filippov /*
937f709ce7SMax Filippov  * Overview of using this interface to decode/encode instructions:
947f709ce7SMax Filippov  *
957f709ce7SMax Filippov  * Each Xtensa instruction is associated with a particular instruction
967f709ce7SMax Filippov  * format, where the format defines a fixed number of slots for
977f709ce7SMax Filippov  * operations. The formats for the core Xtensa ISA have only one slot,
987f709ce7SMax Filippov  * but FLIX instructions may have multiple slots. Within each slot,
997f709ce7SMax Filippov  * there is a single opcode and some number of associated operands.
1007f709ce7SMax Filippov  *
1017f709ce7SMax Filippov  * The encoding and decoding functions operate on instruction buffers,
1027f709ce7SMax Filippov  * not on the raw bytes of the instructions. The same instruction
1037f709ce7SMax Filippov  * buffer data structure is used for both entire instructions and
1047f709ce7SMax Filippov  * individual slots in those instructions -- the contents of a slot need
1057f709ce7SMax Filippov  * to be extracted from or inserted into the buffer for the instruction
1067f709ce7SMax Filippov  * as a whole.
1077f709ce7SMax Filippov  *
1087f709ce7SMax Filippov  * Decoding an instruction involves first finding the format, which
1097f709ce7SMax Filippov  * identifies the number of slots, and then decoding each slot
1107f709ce7SMax Filippov  * separately. A slot is decoded by finding the opcode and then using
1117f709ce7SMax Filippov  * the opcode to determine how many operands there are. For example:
1127f709ce7SMax Filippov  *
1137f709ce7SMax Filippov  * xtensa_insnbuf_from_chars
1147f709ce7SMax Filippov  * xtensa_format_decode
1157f709ce7SMax Filippov  * for each slot {
1167f709ce7SMax Filippov  *   xtensa_format_get_slot
1177f709ce7SMax Filippov  *   xtensa_opcode_decode
1187f709ce7SMax Filippov  *   for each operand {
1197f709ce7SMax Filippov  *     xtensa_operand_get_field
1207f709ce7SMax Filippov  *     xtensa_operand_decode
1217f709ce7SMax Filippov  *   }
1227f709ce7SMax Filippov  * }
1237f709ce7SMax Filippov  *
1247f709ce7SMax Filippov  * Encoding an instruction is roughly the same procedure in reverse:
1257f709ce7SMax Filippov  *
1267f709ce7SMax Filippov  * xtensa_format_encode
1277f709ce7SMax Filippov  * for each slot {
1287f709ce7SMax Filippov  *   xtensa_opcode_encode
1297f709ce7SMax Filippov  *   for each operand {
1307f709ce7SMax Filippov  *     xtensa_operand_encode
1317f709ce7SMax Filippov  *     xtensa_operand_set_field
1327f709ce7SMax Filippov  *   }
1337f709ce7SMax Filippov  *   xtensa_format_set_slot
1347f709ce7SMax Filippov  * }
1357f709ce7SMax Filippov  * xtensa_insnbuf_to_chars
1367f709ce7SMax Filippov  */
1377f709ce7SMax Filippov 
1387f709ce7SMax Filippov 
1397f709ce7SMax Filippov /* Error handling. */
1407f709ce7SMax Filippov 
1417f709ce7SMax Filippov /*
1427f709ce7SMax Filippov  * Error codes. The code for the most recent error condition can be
1437f709ce7SMax Filippov  * retrieved with the "errno" function. For any result other than
1447f709ce7SMax Filippov  * xtensa_isa_ok, an error message containing additional information
1457f709ce7SMax Filippov  * about the problem can be retrieved using the "error_msg" function.
1467f709ce7SMax Filippov  * The error messages are stored in an internal buffer, which should
1477f709ce7SMax Filippov  * not be freed and may be overwritten by subsequent operations.
1487f709ce7SMax Filippov  */
1497f709ce7SMax Filippov 
1507f709ce7SMax Filippov typedef enum xtensa_isa_status_enum {
1517f709ce7SMax Filippov     xtensa_isa_ok = 0,
1527f709ce7SMax Filippov     xtensa_isa_bad_format,
1537f709ce7SMax Filippov     xtensa_isa_bad_slot,
1547f709ce7SMax Filippov     xtensa_isa_bad_opcode,
1557f709ce7SMax Filippov     xtensa_isa_bad_operand,
1567f709ce7SMax Filippov     xtensa_isa_bad_field,
1577f709ce7SMax Filippov     xtensa_isa_bad_iclass,
1587f709ce7SMax Filippov     xtensa_isa_bad_regfile,
1597f709ce7SMax Filippov     xtensa_isa_bad_sysreg,
1607f709ce7SMax Filippov     xtensa_isa_bad_state,
1617f709ce7SMax Filippov     xtensa_isa_bad_interface,
1627f709ce7SMax Filippov     xtensa_isa_bad_funcUnit,
1637f709ce7SMax Filippov     xtensa_isa_wrong_slot,
1647f709ce7SMax Filippov     xtensa_isa_no_field,
1657f709ce7SMax Filippov     xtensa_isa_out_of_memory,
1667f709ce7SMax Filippov     xtensa_isa_buffer_overflow,
1677f709ce7SMax Filippov     xtensa_isa_internal_error,
1687f709ce7SMax Filippov     xtensa_isa_bad_value
1697f709ce7SMax Filippov } xtensa_isa_status;
1707f709ce7SMax Filippov 
1717f709ce7SMax Filippov xtensa_isa_status xtensa_isa_errno(xtensa_isa isa);
1727f709ce7SMax Filippov 
1737f709ce7SMax Filippov char *xtensa_isa_error_msg(xtensa_isa isa);
1747f709ce7SMax Filippov 
1757f709ce7SMax Filippov 
1767f709ce7SMax Filippov 
1777f709ce7SMax Filippov /* Instruction buffers. */
1787f709ce7SMax Filippov 
1797f709ce7SMax Filippov typedef uint32_t xtensa_insnbuf_word;
1807f709ce7SMax Filippov typedef xtensa_insnbuf_word *xtensa_insnbuf;
1817f709ce7SMax Filippov 
1827f709ce7SMax Filippov 
1837f709ce7SMax Filippov /* Get the size in "insnbuf_words" of the xtensa_insnbuf array. */
1847f709ce7SMax Filippov 
1857f709ce7SMax Filippov int xtensa_insnbuf_size(xtensa_isa isa);
1867f709ce7SMax Filippov 
1877f709ce7SMax Filippov 
1887f709ce7SMax Filippov /* Allocate an xtensa_insnbuf of the right size. */
1897f709ce7SMax Filippov 
1907f709ce7SMax Filippov xtensa_insnbuf xtensa_insnbuf_alloc(xtensa_isa isa);
1917f709ce7SMax Filippov 
1927f709ce7SMax Filippov 
1937f709ce7SMax Filippov /* Release an xtensa_insnbuf. */
1947f709ce7SMax Filippov 
1957f709ce7SMax Filippov void xtensa_insnbuf_free(xtensa_isa isa, xtensa_insnbuf buf);
1967f709ce7SMax Filippov 
1977f709ce7SMax Filippov 
1987f709ce7SMax Filippov /*
1997f709ce7SMax Filippov  * Conversion between raw memory (char arrays) and our internal
2007f709ce7SMax Filippov  * instruction representation. This is complicated by the Xtensa ISA's
2017f709ce7SMax Filippov  * variable instruction lengths. When converting to chars, the buffer
2027f709ce7SMax Filippov  * must contain a valid instruction so we know how many bytes to copy;
2037f709ce7SMax Filippov  * thus, the "to_chars" function returns the number of bytes copied or
2047f709ce7SMax Filippov  * XTENSA_UNDEFINED on error. The "from_chars" function first reads the
2057f709ce7SMax Filippov  * minimal number of bytes required to decode the instruction length and
2067f709ce7SMax Filippov  * then proceeds to copy the entire instruction into the buffer; if the
2077f709ce7SMax Filippov  * memory does not contain a valid instruction, it copies the maximum
2087f709ce7SMax Filippov  * number of bytes required for the longest Xtensa instruction. The
2097f709ce7SMax Filippov  * "num_chars" argument may be used to limit the number of bytes that
2107f709ce7SMax Filippov  * can be read or written. Otherwise, if "num_chars" is zero, the
2117f709ce7SMax Filippov  * functions may read or write past the end of the code.
2127f709ce7SMax Filippov  */
2137f709ce7SMax Filippov 
2147f709ce7SMax Filippov int xtensa_insnbuf_to_chars(xtensa_isa isa, const xtensa_insnbuf insn,
2157f709ce7SMax Filippov                             unsigned char *cp, int num_chars);
2167f709ce7SMax Filippov 
2177f709ce7SMax Filippov void xtensa_insnbuf_from_chars(xtensa_isa isa, xtensa_insnbuf insn,
2187f709ce7SMax Filippov                                const unsigned char *cp, int num_chars);
2197f709ce7SMax Filippov 
2207f709ce7SMax Filippov 
2217f709ce7SMax Filippov 
2227f709ce7SMax Filippov /* ISA information. */
2237f709ce7SMax Filippov 
2247f709ce7SMax Filippov /* Initialize the ISA information. */
2257f709ce7SMax Filippov 
2267f709ce7SMax Filippov xtensa_isa xtensa_isa_init(void *xtensa_modules, xtensa_isa_status *errno_p,
2277f709ce7SMax Filippov                            char **error_msg_p);
2287f709ce7SMax Filippov 
2297f709ce7SMax Filippov 
2307f709ce7SMax Filippov /* Deallocate an xtensa_isa structure. */
2317f709ce7SMax Filippov 
2327f709ce7SMax Filippov void xtensa_isa_free(xtensa_isa isa);
2337f709ce7SMax Filippov 
2347f709ce7SMax Filippov 
2357f709ce7SMax Filippov /* Get the maximum instruction size in bytes. */
2367f709ce7SMax Filippov 
2377f709ce7SMax Filippov int xtensa_isa_maxlength(xtensa_isa isa);
2387f709ce7SMax Filippov 
2397f709ce7SMax Filippov 
2407f709ce7SMax Filippov /*
2417f709ce7SMax Filippov  * Decode the length in bytes of an instruction in raw memory (not an
2427f709ce7SMax Filippov  * insnbuf). This function reads only the minimal number of bytes
2437f709ce7SMax Filippov  * required to decode the instruction length. Returns
2447f709ce7SMax Filippov  * XTENSA_UNDEFINED on error.
2457f709ce7SMax Filippov  */
2467f709ce7SMax Filippov 
2477f709ce7SMax Filippov int xtensa_isa_length_from_chars(xtensa_isa isa, const unsigned char *cp);
2487f709ce7SMax Filippov 
2497f709ce7SMax Filippov 
2507f709ce7SMax Filippov /*
2517f709ce7SMax Filippov  * Get the number of stages in the processor's pipeline. The pipeline
2527f709ce7SMax Filippov  * stage values returned by other functions in this library will range
2537f709ce7SMax Filippov  * from 0 to N-1, where N is the value returned by this function.
2547f709ce7SMax Filippov  * Note that the stage numbers used here may not correspond to the
2557f709ce7SMax Filippov  * actual processor hardware, e.g., the hardware may have additional
2567f709ce7SMax Filippov  * stages before stage 0. Returns XTENSA_UNDEFINED on error.
2577f709ce7SMax Filippov  */
2587f709ce7SMax Filippov 
2597f709ce7SMax Filippov int xtensa_isa_num_pipe_stages(xtensa_isa isa);
2607f709ce7SMax Filippov 
2617f709ce7SMax Filippov 
2627f709ce7SMax Filippov /* Get the number of various entities that are defined for this processor. */
2637f709ce7SMax Filippov 
2647f709ce7SMax Filippov int xtensa_isa_num_formats(xtensa_isa isa);
2657f709ce7SMax Filippov 
2667f709ce7SMax Filippov int xtensa_isa_num_opcodes(xtensa_isa isa);
2677f709ce7SMax Filippov 
2687f709ce7SMax Filippov int xtensa_isa_num_regfiles(xtensa_isa isa);
2697f709ce7SMax Filippov 
2707f709ce7SMax Filippov int xtensa_isa_num_states(xtensa_isa isa);
2717f709ce7SMax Filippov 
2727f709ce7SMax Filippov int xtensa_isa_num_sysregs(xtensa_isa isa);
2737f709ce7SMax Filippov 
2747f709ce7SMax Filippov int xtensa_isa_num_interfaces(xtensa_isa isa);
2757f709ce7SMax Filippov 
2767f709ce7SMax Filippov int xtensa_isa_num_funcUnits(xtensa_isa isa);
2777f709ce7SMax Filippov 
2787f709ce7SMax Filippov 
2797f709ce7SMax Filippov 
2807f709ce7SMax Filippov /* Instruction formats. */
2817f709ce7SMax Filippov 
2827f709ce7SMax Filippov /* Get the name of a format. Returns null on error. */
2837f709ce7SMax Filippov 
2847f709ce7SMax Filippov const char *xtensa_format_name(xtensa_isa isa, xtensa_format fmt);
2857f709ce7SMax Filippov 
2867f709ce7SMax Filippov 
2877f709ce7SMax Filippov /*
2887f709ce7SMax Filippov  * Given a format name, return the format number. Returns
2897f709ce7SMax Filippov  * XTENSA_UNDEFINED if the name is not a valid format.
2907f709ce7SMax Filippov  */
2917f709ce7SMax Filippov 
2927f709ce7SMax Filippov xtensa_format xtensa_format_lookup(xtensa_isa isa, const char *fmtname);
2937f709ce7SMax Filippov 
2947f709ce7SMax Filippov 
2957f709ce7SMax Filippov /*
2967f709ce7SMax Filippov  * Decode the instruction format from a binary instruction buffer.
2977f709ce7SMax Filippov  * Returns XTENSA_UNDEFINED if the format is not recognized.
2987f709ce7SMax Filippov  */
2997f709ce7SMax Filippov 
3007f709ce7SMax Filippov xtensa_format xtensa_format_decode(xtensa_isa isa, const xtensa_insnbuf insn);
3017f709ce7SMax Filippov 
3027f709ce7SMax Filippov 
3037f709ce7SMax Filippov /*
3047f709ce7SMax Filippov  * Set the instruction format field(s) in a binary instruction buffer.
3057f709ce7SMax Filippov  * All the other fields are set to zero. Returns non-zero on error.
3067f709ce7SMax Filippov  */
3077f709ce7SMax Filippov 
3087f709ce7SMax Filippov int xtensa_format_encode(xtensa_isa isa, xtensa_format fmt,
3097f709ce7SMax Filippov                          xtensa_insnbuf insn);
3107f709ce7SMax Filippov 
3117f709ce7SMax Filippov 
3127f709ce7SMax Filippov /*
3137f709ce7SMax Filippov  * Find the length (in bytes) of an instruction. Returns
3147f709ce7SMax Filippov  * XTENSA_UNDEFINED on error.
3157f709ce7SMax Filippov  */
3167f709ce7SMax Filippov 
3177f709ce7SMax Filippov int xtensa_format_length(xtensa_isa isa, xtensa_format fmt);
3187f709ce7SMax Filippov 
3197f709ce7SMax Filippov 
3207f709ce7SMax Filippov /*
3217f709ce7SMax Filippov  * Get the number of slots in an instruction. Returns XTENSA_UNDEFINED
3227f709ce7SMax Filippov  * on error.
3237f709ce7SMax Filippov  */
3247f709ce7SMax Filippov 
3257f709ce7SMax Filippov int xtensa_format_num_slots(xtensa_isa isa, xtensa_format fmt);
3267f709ce7SMax Filippov 
3277f709ce7SMax Filippov 
3287f709ce7SMax Filippov /*
3297f709ce7SMax Filippov  * Get the opcode for a no-op in a particular slot.
3307f709ce7SMax Filippov  * Returns XTENSA_UNDEFINED on error.
3317f709ce7SMax Filippov  */
3327f709ce7SMax Filippov 
3337f709ce7SMax Filippov xtensa_opcode xtensa_format_slot_nop_opcode(xtensa_isa isa, xtensa_format fmt,
3347f709ce7SMax Filippov                                             int slot);
3357f709ce7SMax Filippov 
3367f709ce7SMax Filippov 
3377f709ce7SMax Filippov /*
3387f709ce7SMax Filippov  * Get the bits for a specified slot out of an insnbuf for the
3397f709ce7SMax Filippov  * instruction as a whole and put them into an insnbuf for that one
3407f709ce7SMax Filippov  * slot, and do the opposite to set a slot. Return non-zero on error.
3417f709ce7SMax Filippov  */
3427f709ce7SMax Filippov 
3437f709ce7SMax Filippov int xtensa_format_get_slot(xtensa_isa isa, xtensa_format fmt, int slot,
3447f709ce7SMax Filippov                            const xtensa_insnbuf insn, xtensa_insnbuf slotbuf);
3457f709ce7SMax Filippov 
3467f709ce7SMax Filippov int xtensa_format_set_slot(xtensa_isa isa, xtensa_format fmt, int slot,
3477f709ce7SMax Filippov                            xtensa_insnbuf insn, const xtensa_insnbuf slotbuf);
3487f709ce7SMax Filippov 
3497f709ce7SMax Filippov 
3507f709ce7SMax Filippov 
3517f709ce7SMax Filippov /* Opcode information. */
3527f709ce7SMax Filippov 
3537f709ce7SMax Filippov /*
3547f709ce7SMax Filippov  * Translate a mnemonic name to an opcode. Returns XTENSA_UNDEFINED if
3557f709ce7SMax Filippov  * the name is not a valid opcode mnemonic.
3567f709ce7SMax Filippov  */
3577f709ce7SMax Filippov 
3587f709ce7SMax Filippov xtensa_opcode xtensa_opcode_lookup(xtensa_isa isa, const char *opname);
3597f709ce7SMax Filippov 
3607f709ce7SMax Filippov 
3617f709ce7SMax Filippov /*
3627f709ce7SMax Filippov  * Decode the opcode for one instruction slot from a binary instruction
3637f709ce7SMax Filippov  * buffer. Returns the opcode or XTENSA_UNDEFINED if the opcode is
3647f709ce7SMax Filippov  * illegal.
3657f709ce7SMax Filippov  */
3667f709ce7SMax Filippov 
3677f709ce7SMax Filippov xtensa_opcode xtensa_opcode_decode(xtensa_isa isa, xtensa_format fmt, int slot,
3687f709ce7SMax Filippov                                    const xtensa_insnbuf slotbuf);
3697f709ce7SMax Filippov 
3707f709ce7SMax Filippov 
3717f709ce7SMax Filippov /*
3727f709ce7SMax Filippov  * Set the opcode field(s) for an instruction slot. All other fields
3737f709ce7SMax Filippov  * in the slot are set to zero. Returns non-zero if the opcode cannot
3747f709ce7SMax Filippov  * be encoded.
3757f709ce7SMax Filippov  */
3767f709ce7SMax Filippov 
3777f709ce7SMax Filippov int xtensa_opcode_encode(xtensa_isa isa, xtensa_format fmt, int slot,
3787f709ce7SMax Filippov                          xtensa_insnbuf slotbuf, xtensa_opcode opc);
3797f709ce7SMax Filippov 
3807f709ce7SMax Filippov 
3817f709ce7SMax Filippov /* Get the mnemonic name for an opcode. Returns null on error. */
3827f709ce7SMax Filippov 
3837f709ce7SMax Filippov const char *xtensa_opcode_name(xtensa_isa isa, xtensa_opcode opc);
3847f709ce7SMax Filippov 
3857f709ce7SMax Filippov 
3867f709ce7SMax Filippov /* Check various properties of opcodes. These functions return 0 if
3877f709ce7SMax Filippov  * the condition is false, 1 if the condition is true, and
3887f709ce7SMax Filippov  * XTENSA_UNDEFINED on error. The instructions are classified as
3897f709ce7SMax Filippov  * follows:
3907f709ce7SMax Filippov  *
3917f709ce7SMax Filippov  * branch: conditional branch; may fall through to next instruction (B*)
3927f709ce7SMax Filippov  * jump: unconditional branch (J, JX, RET*, RF*)
3937f709ce7SMax Filippov  * loop: zero-overhead loop (LOOP*)
3947f709ce7SMax Filippov  * call: unconditional call; control returns to next instruction (CALL*)
3957f709ce7SMax Filippov  *
3967f709ce7SMax Filippov  * For the opcodes that affect control flow in some way, the branch
3977f709ce7SMax Filippov  * target may be specified by an immediate operand or it may be an
3987f709ce7SMax Filippov  * address stored in a register. You can distinguish these by
3997f709ce7SMax Filippov  * checking if the instruction has a PC-relative immediate
4007f709ce7SMax Filippov  * operand.
4017f709ce7SMax Filippov  */
4027f709ce7SMax Filippov 
4037f709ce7SMax Filippov int xtensa_opcode_is_branch(xtensa_isa isa, xtensa_opcode opc);
4047f709ce7SMax Filippov 
4057f709ce7SMax Filippov int xtensa_opcode_is_jump(xtensa_isa isa, xtensa_opcode opc);
4067f709ce7SMax Filippov 
4077f709ce7SMax Filippov int xtensa_opcode_is_loop(xtensa_isa isa, xtensa_opcode opc);
4087f709ce7SMax Filippov 
4097f709ce7SMax Filippov int xtensa_opcode_is_call(xtensa_isa isa, xtensa_opcode opc);
4107f709ce7SMax Filippov 
4117f709ce7SMax Filippov 
4127f709ce7SMax Filippov /*
4137f709ce7SMax Filippov  * Find the number of ordinary operands, state operands, and interface
4147f709ce7SMax Filippov  * operands for an instruction. These return XTENSA_UNDEFINED on
4157f709ce7SMax Filippov  * error.
4167f709ce7SMax Filippov  */
4177f709ce7SMax Filippov 
4187f709ce7SMax Filippov int xtensa_opcode_num_operands(xtensa_isa isa, xtensa_opcode opc);
4197f709ce7SMax Filippov 
4207f709ce7SMax Filippov int xtensa_opcode_num_stateOperands(xtensa_isa isa, xtensa_opcode opc);
4217f709ce7SMax Filippov 
4227f709ce7SMax Filippov int xtensa_opcode_num_interfaceOperands(xtensa_isa isa, xtensa_opcode opc);
4237f709ce7SMax Filippov 
4247f709ce7SMax Filippov 
4257f709ce7SMax Filippov /*
4267f709ce7SMax Filippov  * Get functional unit usage requirements for an opcode. Each "use"
4277f709ce7SMax Filippov  * is identified by a <functional unit, pipeline stage> pair. The
4287f709ce7SMax Filippov  * "num_funcUnit_uses" function returns the number of these "uses" or
4297f709ce7SMax Filippov  * XTENSA_UNDEFINED on error. The "funcUnit_use" function returns
4307f709ce7SMax Filippov  * a pointer to a "use" pair or null on error.
4317f709ce7SMax Filippov  */
4327f709ce7SMax Filippov 
4337f709ce7SMax Filippov typedef struct xtensa_funcUnit_use_struct {
4347f709ce7SMax Filippov     xtensa_funcUnit unit;
4357f709ce7SMax Filippov     int stage;
4367f709ce7SMax Filippov } xtensa_funcUnit_use;
4377f709ce7SMax Filippov 
4387f709ce7SMax Filippov int xtensa_opcode_num_funcUnit_uses(xtensa_isa isa, xtensa_opcode opc);
4397f709ce7SMax Filippov 
4407f709ce7SMax Filippov xtensa_funcUnit_use *xtensa_opcode_funcUnit_use(xtensa_isa isa,
4417f709ce7SMax Filippov                                                 xtensa_opcode opc, int u);
4427f709ce7SMax Filippov 
4437f709ce7SMax Filippov 
4447f709ce7SMax Filippov 
4457f709ce7SMax Filippov /* Operand information. */
4467f709ce7SMax Filippov 
4477f709ce7SMax Filippov /* Get the name of an operand. Returns null on error. */
4487f709ce7SMax Filippov 
4497f709ce7SMax Filippov const char *xtensa_operand_name(xtensa_isa isa, xtensa_opcode opc, int opnd);
4507f709ce7SMax Filippov 
4517f709ce7SMax Filippov 
4527f709ce7SMax Filippov /*
4537f709ce7SMax Filippov  * Some operands are "invisible", i.e., not explicitly specified in
4547f709ce7SMax Filippov  * assembly language. When assembling an instruction, you need not set
4557f709ce7SMax Filippov  * the values of invisible operands, since they are either hardwired or
4567f709ce7SMax Filippov  * derived from other field values. The values of invisible operands
4577f709ce7SMax Filippov  * can be examined in the same way as other operands, but remember that
4587f709ce7SMax Filippov  * an invisible operand may get its value from another visible one, so
4597f709ce7SMax Filippov  * the entire instruction must be available before examining the
4607f709ce7SMax Filippov  * invisible operand values. This function returns 1 if an operand is
4617f709ce7SMax Filippov  * visible, 0 if it is invisible, or XTENSA_UNDEFINED on error. Note
4627f709ce7SMax Filippov  * that whether an operand is visible is orthogonal to whether it is
4637f709ce7SMax Filippov  * "implicit", i.e., whether it is encoded in a field in the
4647f709ce7SMax Filippov  * instruction.
4657f709ce7SMax Filippov  */
4667f709ce7SMax Filippov 
4677f709ce7SMax Filippov int xtensa_operand_is_visible(xtensa_isa isa, xtensa_opcode opc, int opnd);
4687f709ce7SMax Filippov 
4697f709ce7SMax Filippov 
4707f709ce7SMax Filippov /*
4717f709ce7SMax Filippov  * Check if an operand is an input ('i'), output ('o'), or inout ('m')
4727f709ce7SMax Filippov  * operand. Note: The output operand of a conditional assignment
4737f709ce7SMax Filippov  * (e.g., movnez) appears here as an inout ('m') even if it is declared
4747f709ce7SMax Filippov  * in the TIE code as an output ('o'); this allows the compiler to
4757f709ce7SMax Filippov  * properly handle register allocation for conditional assignments.
4767f709ce7SMax Filippov  * Returns 0 on error.
4777f709ce7SMax Filippov  */
4787f709ce7SMax Filippov 
4797f709ce7SMax Filippov char xtensa_operand_inout(xtensa_isa isa, xtensa_opcode opc, int opnd);
4807f709ce7SMax Filippov 
4817f709ce7SMax Filippov 
4827f709ce7SMax Filippov /*
4837f709ce7SMax Filippov  * Get and set the raw (encoded) value of the field for the specified
4847f709ce7SMax Filippov  * operand. The "set" function does not check if the value fits in the
4857f709ce7SMax Filippov  * field; that is done by the "encode" function below. Both of these
4867f709ce7SMax Filippov  * functions return non-zero on error, e.g., if the field is not defined
4877f709ce7SMax Filippov  * for the specified slot.
4887f709ce7SMax Filippov  */
4897f709ce7SMax Filippov 
4907f709ce7SMax Filippov int xtensa_operand_get_field(xtensa_isa isa, xtensa_opcode opc, int opnd,
4917f709ce7SMax Filippov                              xtensa_format fmt, int slot,
4927f709ce7SMax Filippov                              const xtensa_insnbuf slotbuf, uint32_t *valp);
4937f709ce7SMax Filippov 
4947f709ce7SMax Filippov int xtensa_operand_set_field(xtensa_isa isa, xtensa_opcode opc, int opnd,
4957f709ce7SMax Filippov                              xtensa_format fmt, int slot,
4967f709ce7SMax Filippov                              xtensa_insnbuf slotbuf, uint32_t val);
4977f709ce7SMax Filippov 
4987f709ce7SMax Filippov 
4997f709ce7SMax Filippov /*
5007f709ce7SMax Filippov  * Encode and decode operands. The raw bits in the operand field may
5017f709ce7SMax Filippov  * be encoded in a variety of different ways. These functions hide
5027f709ce7SMax Filippov  * the details of that encoding. The result values are returned through
5037f709ce7SMax Filippov  * the argument pointer. The return value is non-zero on error.
5047f709ce7SMax Filippov  */
5057f709ce7SMax Filippov 
5067f709ce7SMax Filippov int xtensa_operand_encode(xtensa_isa isa, xtensa_opcode opc, int opnd,
5077f709ce7SMax Filippov                           uint32_t *valp);
5087f709ce7SMax Filippov 
5097f709ce7SMax Filippov int xtensa_operand_decode(xtensa_isa isa, xtensa_opcode opc, int opnd,
5107f709ce7SMax Filippov                           uint32_t *valp);
5117f709ce7SMax Filippov 
5127f709ce7SMax Filippov 
5137f709ce7SMax Filippov /*
5147f709ce7SMax Filippov  * An operand may be either a register operand or an immediate of some
5157f709ce7SMax Filippov  * sort (e.g., PC-relative or not). The "is_register" function returns
5167f709ce7SMax Filippov  * 0 if the operand is an immediate, 1 if it is a register, and
5177f709ce7SMax Filippov  * XTENSA_UNDEFINED on error. The "regfile" function returns the
5187f709ce7SMax Filippov  * regfile for a register operand, or XTENSA_UNDEFINED on error.
5197f709ce7SMax Filippov  */
5207f709ce7SMax Filippov 
5217f709ce7SMax Filippov int xtensa_operand_is_register(xtensa_isa isa, xtensa_opcode opc, int opnd);
5227f709ce7SMax Filippov 
5237f709ce7SMax Filippov xtensa_regfile xtensa_operand_regfile(xtensa_isa isa, xtensa_opcode opc,
5247f709ce7SMax Filippov                                       int opnd);
5257f709ce7SMax Filippov 
5267f709ce7SMax Filippov 
5277f709ce7SMax Filippov /*
5287f709ce7SMax Filippov  * Register operands may span multiple consecutive registers, e.g., a
5297f709ce7SMax Filippov  * 64-bit data type may occupy two 32-bit registers. Only the first
5307f709ce7SMax Filippov  * register is encoded in the operand field. This function specifies
5317f709ce7SMax Filippov  * the number of consecutive registers occupied by this operand. For
5327f709ce7SMax Filippov  * non-register operands, the return value is undefined. Returns
5337f709ce7SMax Filippov  * XTENSA_UNDEFINED on error.
5347f709ce7SMax Filippov  */
5357f709ce7SMax Filippov 
5367f709ce7SMax Filippov int xtensa_operand_num_regs(xtensa_isa isa, xtensa_opcode opc, int opnd);
5377f709ce7SMax Filippov 
5387f709ce7SMax Filippov 
5397f709ce7SMax Filippov /*
5407f709ce7SMax Filippov  * Some register operands do not completely identify the register being
5417f709ce7SMax Filippov  * accessed. For example, the operand value may be added to an internal
5427f709ce7SMax Filippov  * state value. By definition, this implies that the corresponding
5437f709ce7SMax Filippov  * regfile is not allocatable. Unknown registers should generally be
5447f709ce7SMax Filippov  * treated with worst-case assumptions. The function returns 0 if the
5457f709ce7SMax Filippov  * register value is unknown, 1 if known, and XTENSA_UNDEFINED on
5467f709ce7SMax Filippov  * error.
5477f709ce7SMax Filippov  */
5487f709ce7SMax Filippov 
5497f709ce7SMax Filippov int xtensa_operand_is_known_reg(xtensa_isa isa, xtensa_opcode opc, int opnd);
5507f709ce7SMax Filippov 
5517f709ce7SMax Filippov 
5527f709ce7SMax Filippov /*
5537f709ce7SMax Filippov  * Check if an immediate operand is PC-relative. Returns 0 for register
5547f709ce7SMax Filippov  * operands and non-PC-relative immediates, 1 for PC-relative
5557f709ce7SMax Filippov  * immediates, and XTENSA_UNDEFINED on error.
5567f709ce7SMax Filippov  */
5577f709ce7SMax Filippov 
5587f709ce7SMax Filippov int xtensa_operand_is_PCrelative(xtensa_isa isa, xtensa_opcode opc, int opnd);
5597f709ce7SMax Filippov 
5607f709ce7SMax Filippov 
5617f709ce7SMax Filippov /*
5627f709ce7SMax Filippov  * For PC-relative offset operands, the interpretation of the offset may
5637f709ce7SMax Filippov  * vary between opcodes, e.g., is it relative to the current PC or that
5647f709ce7SMax Filippov  * of the next instruction?  The following functions are defined to
5657f709ce7SMax Filippov  * perform PC-relative relocations and to undo them (as in the
5667f709ce7SMax Filippov  * disassembler). The "do_reloc" function takes the desired address
5677f709ce7SMax Filippov  * value and the PC of the current instruction and sets the value to the
5687f709ce7SMax Filippov  * corresponding PC-relative offset (which can then be encoded and
5697f709ce7SMax Filippov  * stored into the operand field). The "undo_reloc" function takes the
5707f709ce7SMax Filippov  * unencoded offset value and the current PC and sets the value to the
5717f709ce7SMax Filippov  * appropriate address. The return values are non-zero on error. Note
5727f709ce7SMax Filippov  * that these functions do not replace the encode/decode functions; the
5737f709ce7SMax Filippov  * operands must be encoded/decoded separately and the encode functions
5747f709ce7SMax Filippov  * are responsible for detecting invalid operand values.
5757f709ce7SMax Filippov  */
5767f709ce7SMax Filippov 
5777f709ce7SMax Filippov int xtensa_operand_do_reloc(xtensa_isa isa, xtensa_opcode opc, int opnd,
5787f709ce7SMax Filippov                             uint32_t *valp, uint32_t pc);
5797f709ce7SMax Filippov 
5807f709ce7SMax Filippov int xtensa_operand_undo_reloc(xtensa_isa isa, xtensa_opcode opc, int opnd,
5817f709ce7SMax Filippov                               uint32_t *valp, uint32_t pc);
5827f709ce7SMax Filippov 
5837f709ce7SMax Filippov 
5847f709ce7SMax Filippov 
5857f709ce7SMax Filippov /* State Operands. */
5867f709ce7SMax Filippov 
5877f709ce7SMax Filippov /*
5887f709ce7SMax Filippov  * Get the state accessed by a state operand. Returns XTENSA_UNDEFINED
5897f709ce7SMax Filippov  * on error.
5907f709ce7SMax Filippov  */
5917f709ce7SMax Filippov 
5927f709ce7SMax Filippov xtensa_state xtensa_stateOperand_state(xtensa_isa isa, xtensa_opcode opc,
5937f709ce7SMax Filippov                                        int stOp);
5947f709ce7SMax Filippov 
5957f709ce7SMax Filippov 
5967f709ce7SMax Filippov /*
5977f709ce7SMax Filippov  * Check if a state operand is an input ('i'), output ('o'), or inout
5987f709ce7SMax Filippov  * ('m') operand. Returns 0 on error.
5997f709ce7SMax Filippov  */
6007f709ce7SMax Filippov 
6017f709ce7SMax Filippov char xtensa_stateOperand_inout(xtensa_isa isa, xtensa_opcode opc, int stOp);
6027f709ce7SMax Filippov 
6037f709ce7SMax Filippov 
6047f709ce7SMax Filippov 
6057f709ce7SMax Filippov /* Interface Operands. */
6067f709ce7SMax Filippov 
6077f709ce7SMax Filippov /*
6087f709ce7SMax Filippov  * Get the external interface accessed by an interface operand.
6097f709ce7SMax Filippov  * Returns XTENSA_UNDEFINED on error.
6107f709ce7SMax Filippov  */
6117f709ce7SMax Filippov 
6127f709ce7SMax Filippov xtensa_interface xtensa_interfaceOperand_interface(xtensa_isa isa,
6137f709ce7SMax Filippov                                                    xtensa_opcode opc,
6147f709ce7SMax Filippov                                                    int ifOp);
6157f709ce7SMax Filippov 
6167f709ce7SMax Filippov 
6177f709ce7SMax Filippov 
6187f709ce7SMax Filippov /* Register Files. */
6197f709ce7SMax Filippov 
6207f709ce7SMax Filippov /*
6217f709ce7SMax Filippov  * Regfiles include both "real" regfiles and "views", where a view
6227f709ce7SMax Filippov  * allows a group of adjacent registers in a real "parent" regfile to be
6237f709ce7SMax Filippov  * viewed as a single register. A regfile view has all the same
6247f709ce7SMax Filippov  * properties as its parent except for its (long) name, bit width, number
6257f709ce7SMax Filippov  * of entries, and default ctype. You can use the parent function to
6267f709ce7SMax Filippov  * distinguish these two classes.
6277f709ce7SMax Filippov  */
6287f709ce7SMax Filippov 
6297f709ce7SMax Filippov /*
6307f709ce7SMax Filippov  * Look up a regfile by either its name or its abbreviated "short name".
6317f709ce7SMax Filippov  * Returns XTENSA_UNDEFINED on error. The "lookup_shortname" function
6327f709ce7SMax Filippov  * ignores "view" regfiles since they always have the same shortname as
6337f709ce7SMax Filippov  * their parents.
6347f709ce7SMax Filippov  */
6357f709ce7SMax Filippov 
6367f709ce7SMax Filippov xtensa_regfile xtensa_regfile_lookup(xtensa_isa isa, const char *name);
6377f709ce7SMax Filippov 
6387f709ce7SMax Filippov xtensa_regfile xtensa_regfile_lookup_shortname(xtensa_isa isa,
6397f709ce7SMax Filippov                                                const char *shortname);
6407f709ce7SMax Filippov 
6417f709ce7SMax Filippov 
6427f709ce7SMax Filippov /*
6437f709ce7SMax Filippov  * Get the name or abbreviated "short name" of a regfile.
6447f709ce7SMax Filippov  * Returns null on error.
6457f709ce7SMax Filippov  */
6467f709ce7SMax Filippov 
6477f709ce7SMax Filippov const char *xtensa_regfile_name(xtensa_isa isa, xtensa_regfile rf);
6487f709ce7SMax Filippov 
6497f709ce7SMax Filippov const char *xtensa_regfile_shortname(xtensa_isa isa, xtensa_regfile rf);
6507f709ce7SMax Filippov 
6517f709ce7SMax Filippov 
6527f709ce7SMax Filippov /*
6537f709ce7SMax Filippov  * Get the parent regfile of a "view" regfile. If the regfile is not a
6547f709ce7SMax Filippov  * view, the result is the same as the input parameter. Returns
6557f709ce7SMax Filippov  * XTENSA_UNDEFINED on error.
6567f709ce7SMax Filippov  */
6577f709ce7SMax Filippov 
6587f709ce7SMax Filippov xtensa_regfile xtensa_regfile_view_parent(xtensa_isa isa, xtensa_regfile rf);
6597f709ce7SMax Filippov 
6607f709ce7SMax Filippov 
6617f709ce7SMax Filippov /*
6627f709ce7SMax Filippov  * Get the bit width of a regfile or regfile view.
6637f709ce7SMax Filippov  * Returns XTENSA_UNDEFINED on error.
6647f709ce7SMax Filippov  */
6657f709ce7SMax Filippov 
6667f709ce7SMax Filippov int xtensa_regfile_num_bits(xtensa_isa isa, xtensa_regfile rf);
6677f709ce7SMax Filippov 
6687f709ce7SMax Filippov 
6697f709ce7SMax Filippov /*
6707f709ce7SMax Filippov  * Get the number of regfile entries. Returns XTENSA_UNDEFINED on
6717f709ce7SMax Filippov  * error.
6727f709ce7SMax Filippov  */
6737f709ce7SMax Filippov 
6747f709ce7SMax Filippov int xtensa_regfile_num_entries(xtensa_isa isa, xtensa_regfile rf);
6757f709ce7SMax Filippov 
6767f709ce7SMax Filippov 
6777f709ce7SMax Filippov 
6787f709ce7SMax Filippov /* Processor States. */
6797f709ce7SMax Filippov 
6807f709ce7SMax Filippov /* Look up a state by name. Returns XTENSA_UNDEFINED on error. */
6817f709ce7SMax Filippov 
6827f709ce7SMax Filippov xtensa_state xtensa_state_lookup(xtensa_isa isa, const char *name);
6837f709ce7SMax Filippov 
6847f709ce7SMax Filippov 
6857f709ce7SMax Filippov /* Get the name for a processor state. Returns null on error. */
6867f709ce7SMax Filippov 
6877f709ce7SMax Filippov const char *xtensa_state_name(xtensa_isa isa, xtensa_state st);
6887f709ce7SMax Filippov 
6897f709ce7SMax Filippov 
6907f709ce7SMax Filippov /*
6917f709ce7SMax Filippov  * Get the bit width for a processor state.
6927f709ce7SMax Filippov  * Returns XTENSA_UNDEFINED on error.
6937f709ce7SMax Filippov  */
6947f709ce7SMax Filippov 
6957f709ce7SMax Filippov int xtensa_state_num_bits(xtensa_isa isa, xtensa_state st);
6967f709ce7SMax Filippov 
6977f709ce7SMax Filippov 
6987f709ce7SMax Filippov /*
6997f709ce7SMax Filippov  * Check if a state is exported from the processor core. Returns 0 if
7007f709ce7SMax Filippov  * the condition is false, 1 if the condition is true, and
7017f709ce7SMax Filippov  * XTENSA_UNDEFINED on error.
7027f709ce7SMax Filippov  */
7037f709ce7SMax Filippov 
7047f709ce7SMax Filippov int xtensa_state_is_exported(xtensa_isa isa, xtensa_state st);
7057f709ce7SMax Filippov 
7067f709ce7SMax Filippov 
7077f709ce7SMax Filippov /*
7087f709ce7SMax Filippov  * Check for a "shared_or" state. Returns 0 if the condition is false,
7097f709ce7SMax Filippov  * 1 if the condition is true, and XTENSA_UNDEFINED on error.
7107f709ce7SMax Filippov  */
7117f709ce7SMax Filippov 
7127f709ce7SMax Filippov int xtensa_state_is_shared_or(xtensa_isa isa, xtensa_state st);
7137f709ce7SMax Filippov 
7147f709ce7SMax Filippov 
7157f709ce7SMax Filippov 
7167f709ce7SMax Filippov /* Sysregs ("special registers" and "user registers"). */
7177f709ce7SMax Filippov 
7187f709ce7SMax Filippov /*
7197f709ce7SMax Filippov  * Look up a register by its number and whether it is a "user register"
7207f709ce7SMax Filippov  * or a "special register". Returns XTENSA_UNDEFINED if the sysreg does
7217f709ce7SMax Filippov  * not exist.
7227f709ce7SMax Filippov  */
7237f709ce7SMax Filippov 
7247f709ce7SMax Filippov xtensa_sysreg xtensa_sysreg_lookup(xtensa_isa isa, int num, int is_user);
7257f709ce7SMax Filippov 
7267f709ce7SMax Filippov 
7277f709ce7SMax Filippov /*
7287f709ce7SMax Filippov  * Check if there exists a sysreg with a given name.
7297f709ce7SMax Filippov  * If not, this function returns XTENSA_UNDEFINED.
7307f709ce7SMax Filippov  */
7317f709ce7SMax Filippov 
7327f709ce7SMax Filippov xtensa_sysreg xtensa_sysreg_lookup_name(xtensa_isa isa, const char *name);
7337f709ce7SMax Filippov 
7347f709ce7SMax Filippov 
7357f709ce7SMax Filippov /* Get the name of a sysreg. Returns null on error. */
7367f709ce7SMax Filippov 
7377f709ce7SMax Filippov const char *xtensa_sysreg_name(xtensa_isa isa, xtensa_sysreg sysreg);
7387f709ce7SMax Filippov 
7397f709ce7SMax Filippov 
7407f709ce7SMax Filippov /* Get the register number. Returns XTENSA_UNDEFINED on error. */
7417f709ce7SMax Filippov 
7427f709ce7SMax Filippov int xtensa_sysreg_number(xtensa_isa isa, xtensa_sysreg sysreg);
7437f709ce7SMax Filippov 
7447f709ce7SMax Filippov 
7457f709ce7SMax Filippov /*
7467f709ce7SMax Filippov  * Check if a sysreg is a "special register" or a "user register".
7477f709ce7SMax Filippov  * Returns 0 for special registers, 1 for user registers and
7487f709ce7SMax Filippov  * XTENSA_UNDEFINED on error.
7497f709ce7SMax Filippov  */
7507f709ce7SMax Filippov 
7517f709ce7SMax Filippov int xtensa_sysreg_is_user(xtensa_isa isa, xtensa_sysreg sysreg);
7527f709ce7SMax Filippov 
7537f709ce7SMax Filippov 
7547f709ce7SMax Filippov 
7557f709ce7SMax Filippov /* Interfaces. */
7567f709ce7SMax Filippov 
7577f709ce7SMax Filippov /*
7587f709ce7SMax Filippov  * Find an interface by name. The return value is XTENSA_UNDEFINED if
7597f709ce7SMax Filippov  * the specified interface is not found.
7607f709ce7SMax Filippov  */
7617f709ce7SMax Filippov 
7627f709ce7SMax Filippov xtensa_interface xtensa_interface_lookup(xtensa_isa isa, const char *ifname);
7637f709ce7SMax Filippov 
7647f709ce7SMax Filippov 
7657f709ce7SMax Filippov /* Get the name of an interface. Returns null on error. */
7667f709ce7SMax Filippov 
7677f709ce7SMax Filippov const char *xtensa_interface_name(xtensa_isa isa, xtensa_interface intf);
7687f709ce7SMax Filippov 
7697f709ce7SMax Filippov 
7707f709ce7SMax Filippov /*
7717f709ce7SMax Filippov  * Get the bit width for an interface.
7727f709ce7SMax Filippov  * Returns XTENSA_UNDEFINED on error.
7737f709ce7SMax Filippov  */
7747f709ce7SMax Filippov 
7757f709ce7SMax Filippov int xtensa_interface_num_bits(xtensa_isa isa, xtensa_interface intf);
7767f709ce7SMax Filippov 
7777f709ce7SMax Filippov 
7787f709ce7SMax Filippov /*
7797f709ce7SMax Filippov  * Check if an interface is an input ('i') or output ('o') with respect
7807f709ce7SMax Filippov  * to the Xtensa processor core. Returns 0 on error.
7817f709ce7SMax Filippov  */
7827f709ce7SMax Filippov 
7837f709ce7SMax Filippov char xtensa_interface_inout(xtensa_isa isa, xtensa_interface intf);
7847f709ce7SMax Filippov 
7857f709ce7SMax Filippov 
7867f709ce7SMax Filippov /*
7877f709ce7SMax Filippov  * Check if accessing an interface has potential side effects.
7887f709ce7SMax Filippov  * Currently "data" interfaces have side effects and "control"
7897f709ce7SMax Filippov  * interfaces do not. Returns 1 if there are side effects, 0 if not,
7907f709ce7SMax Filippov  * and XTENSA_UNDEFINED on error.
7917f709ce7SMax Filippov  */
7927f709ce7SMax Filippov 
7937f709ce7SMax Filippov int xtensa_interface_has_side_effect(xtensa_isa isa, xtensa_interface intf);
7947f709ce7SMax Filippov 
7957f709ce7SMax Filippov 
7967f709ce7SMax Filippov /*
7977f709ce7SMax Filippov  * Some interfaces may be related such that accessing one interface
7987f709ce7SMax Filippov  * has side effects on a set of related interfaces. The interfaces
7997f709ce7SMax Filippov  * are partitioned into equivalence classes of related interfaces, and
8007f709ce7SMax Filippov  * each class is assigned a unique identifier number. This function
8017f709ce7SMax Filippov  * returns the class identifier for an interface, or XTENSA_UNDEFINED
8027f709ce7SMax Filippov  * on error. These identifiers can be compared to determine if two
8037f709ce7SMax Filippov  * interfaces are related; the specific values of the identifiers have
8047f709ce7SMax Filippov  * no particular meaning otherwise.
8057f709ce7SMax Filippov  */
8067f709ce7SMax Filippov 
8077f709ce7SMax Filippov int xtensa_interface_class_id(xtensa_isa isa, xtensa_interface intf);
8087f709ce7SMax Filippov 
8097f709ce7SMax Filippov 
8107f709ce7SMax Filippov /* Functional Units. */
8117f709ce7SMax Filippov 
8127f709ce7SMax Filippov /*
8137f709ce7SMax Filippov  * Find a functional unit by name. The return value is XTENSA_UNDEFINED if
8147f709ce7SMax Filippov  * the specified unit is not found.
8157f709ce7SMax Filippov  */
8167f709ce7SMax Filippov 
8177f709ce7SMax Filippov xtensa_funcUnit xtensa_funcUnit_lookup(xtensa_isa isa, const char *fname);
8187f709ce7SMax Filippov 
8197f709ce7SMax Filippov 
8207f709ce7SMax Filippov /* Get the name of a functional unit. Returns null on error. */
8217f709ce7SMax Filippov 
8227f709ce7SMax Filippov const char *xtensa_funcUnit_name(xtensa_isa isa, xtensa_funcUnit fun);
8237f709ce7SMax Filippov 
8247f709ce7SMax Filippov 
8257f709ce7SMax Filippov /*
8267f709ce7SMax Filippov  * Functional units may be replicated. See how many instances of a
8277f709ce7SMax Filippov  * particular function unit exist. Returns XTENSA_UNDEFINED on error.
8287f709ce7SMax Filippov  */
8297f709ce7SMax Filippov 
8307f709ce7SMax Filippov int xtensa_funcUnit_num_copies(xtensa_isa isa, xtensa_funcUnit fun);
8317f709ce7SMax Filippov 
8327f709ce7SMax Filippov 
8337f709ce7SMax Filippov #ifdef __cplusplus
8347f709ce7SMax Filippov }
8357f709ce7SMax Filippov #endif
836*58ea30f5SMarkus Armbruster #endif /* HW_XTENSA_XTENSA_ISA_H */
837