15f210c2aSfgsch /* cris.h -- Header file for CRIS opcode and register tables. 25f210c2aSfgsch Copyright (C) 2000, 2001 Free Software Foundation, Inc. 35f210c2aSfgsch Contributed by Axis Communications AB, Lund, Sweden. 45f210c2aSfgsch Originally written for GAS 1.38.1 by Mikael Asker. 55f210c2aSfgsch Updated, BFDized and GNUified by Hans-Peter Nilsson. 65f210c2aSfgsch 75f210c2aSfgsch This file is part of GAS, GDB and the GNU binutils. 85f210c2aSfgsch 95f210c2aSfgsch GAS, GDB, and GNU binutils is free software; you can redistribute it 105f210c2aSfgsch and/or modify it under the terms of the GNU General Public License as 115f210c2aSfgsch published by the Free Software Foundation; either version 2, or (at your 125f210c2aSfgsch option) any later version. 135f210c2aSfgsch 145f210c2aSfgsch GAS, GDB, and GNU binutils are distributed in the hope that they will be 155f210c2aSfgsch useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 165f210c2aSfgsch MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 175f210c2aSfgsch GNU General Public License for more details. 185f210c2aSfgsch 195f210c2aSfgsch You should have received a copy of the GNU General Public License 205f210c2aSfgsch along with this program; if not, write to the Free Software 215f210c2aSfgsch Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 225f210c2aSfgsch 235f210c2aSfgsch #ifndef __CRIS_H_INCLUDED_ 245f210c2aSfgsch #define __CRIS_H_INCLUDED_ 255f210c2aSfgsch 265f210c2aSfgsch #if !defined(__STDC__) && !defined(const) 275f210c2aSfgsch #define const 285f210c2aSfgsch #endif 295f210c2aSfgsch 305f210c2aSfgsch 315f210c2aSfgsch /* Registers. */ 325f210c2aSfgsch #define MAX_REG (15) 335f210c2aSfgsch #define REG_SP (14) 345f210c2aSfgsch #define REG_PC (15) 355f210c2aSfgsch 365f210c2aSfgsch /* CPU version control of disassembly and assembly of instructions. 375f210c2aSfgsch May affect how the instruction is assembled, at least the size of 385f210c2aSfgsch immediate operands. */ 395f210c2aSfgsch enum cris_insn_version_usage 405f210c2aSfgsch { 415f210c2aSfgsch /* Any version. */ 425f210c2aSfgsch cris_ver_version_all=0, 435f210c2aSfgsch 445f210c2aSfgsch /* Indeterminate (intended for disassembly only, or obsolete). */ 455f210c2aSfgsch cris_ver_warning, 465f210c2aSfgsch 475f210c2aSfgsch /* Simulator only (reserved). */ 485f210c2aSfgsch cris_ver_sim, 495f210c2aSfgsch 505f210c2aSfgsch /* Only for v0..3 (Etrax 1..4). */ 515f210c2aSfgsch cris_ver_v0_3, 525f210c2aSfgsch 53*d2201f2fSdrahn /* Only for v3 or higher (ETRAX 4 and beyond). */ 545f210c2aSfgsch cris_ver_v3p, 555f210c2aSfgsch 565f210c2aSfgsch /* Only for v8 (Etrax 100). */ 575f210c2aSfgsch cris_ver_v8, 585f210c2aSfgsch 595f210c2aSfgsch /* Only for v8 or higher (ETRAX 100, ETRAX 100 LX). */ 605f210c2aSfgsch cris_ver_v8p, 615f210c2aSfgsch 625f210c2aSfgsch /* Only for v10 or higher (ETRAX 100 LX). 635f210c2aSfgsch Of course some or all these of may change to cris_ver_v10p if/when 645f210c2aSfgsch there's a new revision. */ 655f210c2aSfgsch cris_ver_v10p 665f210c2aSfgsch }; 675f210c2aSfgsch 685f210c2aSfgsch 695f210c2aSfgsch /* Special registers. */ 705f210c2aSfgsch struct cris_spec_reg 715f210c2aSfgsch { 725f210c2aSfgsch const char *const name; 735f210c2aSfgsch unsigned int number; 745f210c2aSfgsch 755f210c2aSfgsch /* The size of the register. */ 765f210c2aSfgsch unsigned int reg_size; 775f210c2aSfgsch 785f210c2aSfgsch /* What CPU version the special register of that name is implemented 795f210c2aSfgsch in. If cris_ver_warning, emit an unimplemented-warning. */ 805f210c2aSfgsch enum cris_insn_version_usage applicable_version; 815f210c2aSfgsch 825f210c2aSfgsch /* There might be a specific warning for using a special register 835f210c2aSfgsch here. */ 845f210c2aSfgsch const char *const warning; 855f210c2aSfgsch }; 865f210c2aSfgsch extern const struct cris_spec_reg cris_spec_regs[]; 875f210c2aSfgsch 885f210c2aSfgsch /* Opcode-dependent constants. */ 895f210c2aSfgsch #define AUTOINCR_BIT (0x04) 905f210c2aSfgsch 915f210c2aSfgsch /* Prefixes. */ 925f210c2aSfgsch #define BDAP_QUICK_OPCODE (0x0100) 935f210c2aSfgsch #define BDAP_QUICK_Z_BITS (0x0e00) 945f210c2aSfgsch 955f210c2aSfgsch #define BIAP_OPCODE (0x0540) 965f210c2aSfgsch #define BIAP_Z_BITS (0x0a80) 975f210c2aSfgsch 985f210c2aSfgsch #define DIP_OPCODE (0x0970) 995f210c2aSfgsch #define DIP_Z_BITS (0xf280) 1005f210c2aSfgsch 1015f210c2aSfgsch #define BDAP_INDIR_LOW (0x40) 1025f210c2aSfgsch #define BDAP_INDIR_LOW_Z (0x80) 1035f210c2aSfgsch #define BDAP_INDIR_HIGH (0x09) 1045f210c2aSfgsch #define BDAP_INDIR_HIGH_Z (0x02) 1055f210c2aSfgsch 1065f210c2aSfgsch #define BDAP_INDIR_OPCODE (BDAP_INDIR_HIGH * 0x0100 + BDAP_INDIR_LOW) 1075f210c2aSfgsch #define BDAP_INDIR_Z_BITS (BDAP_INDIR_HIGH_Z * 0x100 + BDAP_INDIR_LOW_Z) 1085f210c2aSfgsch #define BDAP_PC_LOW (BDAP_INDIR_LOW + REG_PC) 1095f210c2aSfgsch #define BDAP_INCR_HIGH (BDAP_INDIR_HIGH + AUTOINCR_BIT) 1105f210c2aSfgsch 1115f210c2aSfgsch /* No prefix must have this code for its "match" bits in the 1125f210c2aSfgsch opcode-table. "BCC .+2" will do nicely. */ 1135f210c2aSfgsch #define NO_CRIS_PREFIX 0 1145f210c2aSfgsch 1155f210c2aSfgsch /* Definitions for condition codes. */ 1165f210c2aSfgsch #define CC_CC 0x0 1175f210c2aSfgsch #define CC_HS 0x0 1185f210c2aSfgsch #define CC_CS 0x1 1195f210c2aSfgsch #define CC_LO 0x1 1205f210c2aSfgsch #define CC_NE 0x2 1215f210c2aSfgsch #define CC_EQ 0x3 1225f210c2aSfgsch #define CC_VC 0x4 1235f210c2aSfgsch #define CC_VS 0x5 1245f210c2aSfgsch #define CC_PL 0x6 1255f210c2aSfgsch #define CC_MI 0x7 1265f210c2aSfgsch #define CC_LS 0x8 1275f210c2aSfgsch #define CC_HI 0x9 1285f210c2aSfgsch #define CC_GE 0xA 1295f210c2aSfgsch #define CC_LT 0xB 1305f210c2aSfgsch #define CC_GT 0xC 1315f210c2aSfgsch #define CC_LE 0xD 1325f210c2aSfgsch #define CC_A 0xE 1335f210c2aSfgsch #define CC_EXT 0xF 1345f210c2aSfgsch 1355f210c2aSfgsch /* A table of strings "cc", "cs"... indexed with condition code 1365f210c2aSfgsch values as above. */ 1375f210c2aSfgsch extern const char *const cris_cc_strings[]; 1385f210c2aSfgsch 1395f210c2aSfgsch /* Bcc quick. */ 1405f210c2aSfgsch #define BRANCH_QUICK_LOW (0) 1415f210c2aSfgsch #define BRANCH_QUICK_HIGH (0) 1425f210c2aSfgsch #define BRANCH_QUICK_OPCODE (BRANCH_QUICK_HIGH * 0x0100 + BRANCH_QUICK_LOW) 1435f210c2aSfgsch #define BRANCH_QUICK_Z_BITS (0x0F00) 1445f210c2aSfgsch 1455f210c2aSfgsch /* BA quick. */ 1465f210c2aSfgsch #define BA_QUICK_HIGH (BRANCH_QUICK_HIGH + CC_A * 0x10) 1475f210c2aSfgsch #define BA_QUICK_OPCODE (BA_QUICK_HIGH * 0x100 + BRANCH_QUICK_LOW) 1485f210c2aSfgsch 1495f210c2aSfgsch /* Bcc [PC+]. */ 1505f210c2aSfgsch #define BRANCH_PC_LOW (0xFF) 1515f210c2aSfgsch #define BRANCH_INCR_HIGH (0x0D) 1525f210c2aSfgsch #define BA_PC_INCR_OPCODE \ 1535f210c2aSfgsch ((BRANCH_INCR_HIGH + CC_A * 0x10) * 0x0100 + BRANCH_PC_LOW) 1545f210c2aSfgsch 1555f210c2aSfgsch /* Jump. */ 1565f210c2aSfgsch /* Note that old versions generated special register 8 (in high bits) 1575f210c2aSfgsch and not-that-old versions recognized it as a jump-instruction. 1585f210c2aSfgsch That opcode now belongs to JUMPU. */ 1595f210c2aSfgsch #define JUMP_INDIR_OPCODE (0x0930) 1605f210c2aSfgsch #define JUMP_INDIR_Z_BITS (0xf2c0) 1615f210c2aSfgsch #define JUMP_PC_INCR_OPCODE \ 1625f210c2aSfgsch (JUMP_INDIR_OPCODE + AUTOINCR_BIT * 0x0100 + REG_PC) 163*d2201f2fSdrahn #define ADD_PC_INCR_OPCODE \ 164*d2201f2fSdrahn (0xfa00 + (2 << 4) + AUTOINCR_BIT * 0x0100 + REG_PC) 1655f210c2aSfgsch 1665f210c2aSfgsch /* Nop. */ 1675f210c2aSfgsch #define NOP_OPCODE (0x050F) 1685f210c2aSfgsch #define NOP_Z_BITS (0xFAF0) 1695f210c2aSfgsch 1705f210c2aSfgsch /* Structure of an opcode table entry. */ 1715f210c2aSfgsch enum cris_imm_oprnd_size_type 1725f210c2aSfgsch { 1735f210c2aSfgsch /* No size is applicable. */ 1745f210c2aSfgsch SIZE_NONE, 1755f210c2aSfgsch 1765f210c2aSfgsch /* Always 32 bits. */ 1775f210c2aSfgsch SIZE_FIX_32, 1785f210c2aSfgsch 1795f210c2aSfgsch /* Indicated by size of special register. */ 1805f210c2aSfgsch SIZE_SPEC_REG, 1815f210c2aSfgsch 1825f210c2aSfgsch /* Indicated by size field. */ 1835f210c2aSfgsch SIZE_FIELD 1845f210c2aSfgsch }; 1855f210c2aSfgsch 1865f210c2aSfgsch /* For GDB. FIXME: Is this the best way to handle opcode 1875f210c2aSfgsch interpretation? */ 1885f210c2aSfgsch enum cris_op_type 1895f210c2aSfgsch { 1905f210c2aSfgsch cris_not_implemented_op = 0, 1915f210c2aSfgsch cris_abs_op, 1925f210c2aSfgsch cris_addi_op, 1935f210c2aSfgsch cris_asr_op, 1945f210c2aSfgsch cris_asrq_op, 1955f210c2aSfgsch cris_ax_ei_setf_op, 1965f210c2aSfgsch cris_bdap_prefix, 1975f210c2aSfgsch cris_biap_prefix, 1985f210c2aSfgsch cris_break_op, 1995f210c2aSfgsch cris_btst_nop_op, 2005f210c2aSfgsch cris_clearf_di_op, 2015f210c2aSfgsch cris_dip_prefix, 2025f210c2aSfgsch cris_dstep_logshift_mstep_neg_not_op, 2035f210c2aSfgsch cris_eight_bit_offset_branch_op, 2045f210c2aSfgsch cris_move_mem_to_reg_movem_op, 2055f210c2aSfgsch cris_move_reg_to_mem_movem_op, 2065f210c2aSfgsch cris_move_to_preg_op, 2075f210c2aSfgsch cris_muls_op, 2085f210c2aSfgsch cris_mulu_op, 2095f210c2aSfgsch cris_none_reg_mode_add_sub_cmp_and_or_move_op, 2105f210c2aSfgsch cris_none_reg_mode_clear_test_op, 2115f210c2aSfgsch cris_none_reg_mode_jump_op, 2125f210c2aSfgsch cris_none_reg_mode_move_from_preg_op, 2135f210c2aSfgsch cris_quick_mode_add_sub_op, 2145f210c2aSfgsch cris_quick_mode_and_cmp_move_or_op, 2155f210c2aSfgsch cris_quick_mode_bdap_prefix, 2165f210c2aSfgsch cris_reg_mode_add_sub_cmp_and_or_move_op, 2175f210c2aSfgsch cris_reg_mode_clear_op, 2185f210c2aSfgsch cris_reg_mode_jump_op, 2195f210c2aSfgsch cris_reg_mode_move_from_preg_op, 2205f210c2aSfgsch cris_reg_mode_test_op, 2215f210c2aSfgsch cris_scc_op, 2225f210c2aSfgsch cris_sixteen_bit_offset_branch_op, 2235f210c2aSfgsch cris_three_operand_add_sub_cmp_and_or_op, 2245f210c2aSfgsch cris_three_operand_bound_op, 2255f210c2aSfgsch cris_two_operand_bound_op, 2265f210c2aSfgsch cris_xor_op 2275f210c2aSfgsch }; 2285f210c2aSfgsch 2295f210c2aSfgsch struct cris_opcode 2305f210c2aSfgsch { 2315f210c2aSfgsch /* The name of the insn. */ 2325f210c2aSfgsch const char *name; 2335f210c2aSfgsch 2345f210c2aSfgsch /* Bits that must be 1 for a match. */ 2355f210c2aSfgsch unsigned int match; 2365f210c2aSfgsch 2375f210c2aSfgsch /* Bits that must be 0 for a match. */ 2385f210c2aSfgsch unsigned int lose; 2395f210c2aSfgsch 2405f210c2aSfgsch /* See the table in "opcodes/cris-opc.c". */ 2415f210c2aSfgsch const char *args; 2425f210c2aSfgsch 2435f210c2aSfgsch /* Nonzero if this is a delayed branch instruction. */ 2445f210c2aSfgsch char delayed; 2455f210c2aSfgsch 2465f210c2aSfgsch /* Size of immediate operands. */ 2475f210c2aSfgsch enum cris_imm_oprnd_size_type imm_oprnd_size; 2485f210c2aSfgsch 2495f210c2aSfgsch /* Indicates which version this insn was first implemented in. */ 2505f210c2aSfgsch enum cris_insn_version_usage applicable_version; 2515f210c2aSfgsch 2525f210c2aSfgsch /* What kind of operation this is. */ 2535f210c2aSfgsch enum cris_op_type op; 2545f210c2aSfgsch }; 2555f210c2aSfgsch extern const struct cris_opcode cris_opcodes[]; 2565f210c2aSfgsch 2575f210c2aSfgsch 2585f210c2aSfgsch /* These macros are for the target-specific flags in disassemble_info 2595f210c2aSfgsch used at disassembly. */ 2605f210c2aSfgsch 2615f210c2aSfgsch /* This insn accesses memory. This flag is more trustworthy than 2625f210c2aSfgsch checking insn_type for "dis_dref" which does not work for 2635f210c2aSfgsch e.g. "JSR [foo]". */ 2645f210c2aSfgsch #define CRIS_DIS_FLAG_MEMREF (1 << 0) 2655f210c2aSfgsch 2665f210c2aSfgsch /* The "target" field holds a register number. */ 2675f210c2aSfgsch #define CRIS_DIS_FLAG_MEM_TARGET_IS_REG (1 << 1) 2685f210c2aSfgsch 2695f210c2aSfgsch /* The "target2" field holds a register number; add it to "target". */ 2705f210c2aSfgsch #define CRIS_DIS_FLAG_MEM_TARGET2_IS_REG (1 << 2) 2715f210c2aSfgsch 2725f210c2aSfgsch /* Yet another add-on: the register in "target2" must be multiplied 2735f210c2aSfgsch by 2 before adding to "target". */ 2745f210c2aSfgsch #define CRIS_DIS_FLAG_MEM_TARGET2_MULT2 (1 << 3) 2755f210c2aSfgsch 2765f210c2aSfgsch /* Yet another add-on: the register in "target2" must be multiplied 2775f210c2aSfgsch by 4 (mutually exclusive with .._MULT2). */ 2785f210c2aSfgsch #define CRIS_DIS_FLAG_MEM_TARGET2_MULT4 (1 << 4) 2795f210c2aSfgsch 2805f210c2aSfgsch /* The register in "target2" is an indirect memory reference (of the 2815f210c2aSfgsch register there), add to "target". Assumed size is dword (mutually 2825f210c2aSfgsch exclusive with .._MULT[24]). */ 2835f210c2aSfgsch #define CRIS_DIS_FLAG_MEM_TARGET2_MEM (1 << 5) 2845f210c2aSfgsch 2855f210c2aSfgsch /* Add-on to CRIS_DIS_FLAG_MEM_TARGET2_MEM; the memory access is "byte"; 2865f210c2aSfgsch sign-extended before adding to "target". */ 2875f210c2aSfgsch #define CRIS_DIS_FLAG_MEM_TARGET2_MEM_BYTE (1 << 6) 2885f210c2aSfgsch 2895f210c2aSfgsch /* Add-on to CRIS_DIS_FLAG_MEM_TARGET2_MEM; the memory access is "word"; 2905f210c2aSfgsch sign-extended before adding to "target". */ 2915f210c2aSfgsch #define CRIS_DIS_FLAG_MEM_TARGET2_MEM_WORD (1 << 7) 2925f210c2aSfgsch 2935f210c2aSfgsch #endif /* __CRIS_H_INCLUDED_ */ 2945f210c2aSfgsch 2955f210c2aSfgsch /* 2965f210c2aSfgsch * Local variables: 2975f210c2aSfgsch * eval: (c-set-style "gnu") 2985f210c2aSfgsch * indent-tabs-mode: t 2995f210c2aSfgsch * End: 3005f210c2aSfgsch */ 301