Copyright (C) 2004-2023 Free Software Foundation, Inc.
Contributed by Tomer Levi, NSC, Israel.
Originally written for GAS 2.12 by Tomer Levi, NSC, Israel.
Updates, BFDizing, GNUifying and ELF support by Tomer Levi.
This file is part of GAS, GDB and the GNU binutils.
GAS, GDB, and GNU binutils is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or (at your
option) any later version.
GAS, GDB, and GNU binutils are distributed in the hope that they will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
#ifndef _CRX_H_
#define _CRX_H_
The enums are used as indices to CRX registers table (crx_regtab).
Therefore, order MUST be preserved. */
typedef enum
{
r0, r1, r2, r3, r4, r5, r6, r7, r8, r9,
r10, r11, r12, r13, r14, r15, ra, sp,
u0, u1, u2, u3, u4, u5, u6, u7, u8, u9,
u10, u11, u12, u13, u14, u15, ura, usp,
hi, lo,
uhi, ulo,
psr,
intbase,
isp,
cfg,
cpcfg,
cen,
nullregister,
MAX_REG
}
reg;
The enums are used as indices to CRX coprocessor registers table
(crx_copregtab). Therefore, order MUST be preserved. */
typedef enum
{
c0 = MAX_REG, c1, c2, c3, c4, c5, c6, c7, c8,
c9, c10, c11, c12, c13, c14, c15,
cs0, cs1 ,cs2, cs3, cs4, cs5, cs6, cs7, cs8,
cs9, cs10, cs11, cs12, cs13, cs14, cs15,
nullcopregister,
MAX_COPREG
}
copreg;
typedef enum
{
CRX_R_REGTYPE,
CRX_U_REGTYPE,
CRX_C_REGTYPE,
CRX_CS_REGTYPE,
CRX_CFG_REGTYPE
}
reg_type;
The argument types correspond to instructions operands
Argument types :
r - register
c - constant
i - immediate
idxr - index register
rbase - register base
s - star ('*')
copr - coprocessor register
copsr - coprocessor special register. */
typedef enum
{
arg_r, arg_c, arg_cr, arg_ic, arg_icr, arg_sc,
arg_idxr, arg_rbase, arg_copr, arg_copsr,
nullargs
}
argtype;
The operand types correspond to instructions operands. */
typedef enum
{
dummy,
cst4,
i16, i32,
ui3, ui4, ui5, ui16,
disps9, disps17, disps25, disps32,
dispu5,
dispe9,
abs16, abs32,
rbase, rbase_dispu4,
rbase_disps12, rbase_disps16, rbase_disps28, rbase_disps32,
rindex_disps6, rindex_disps22,
regr,
regr8,
copregr,
copsregr,
nulloperand,
MAX_OPRD
}
operand_type;
#define NO_TYPE_INS 0
#define ARITH_INS 1
#define LD_STOR_INS 2
#define BRANCH_INS 3
#define ARITH_BYTE_INS 4
#define CMPBR_INS 5
#define SHIFT_INS 6
#define BRANCH_NEQ_INS 7
#define LD_STOR_INS_INC 8
#define STOR_IMM_INS 9
#define CSTBIT_INS 10
#define COP_BRANCH_INS 11
#define COP_REG_INS 12
#define COPS_REG_INS 13
#define DCR_BRANCH_INS 14
#define CRX_INS_MAX (1 << 4)
#define CRX_INS_MASK (CRX_INS_MAX - 1)
#define CRX_INS_TYPE(attr) ((attr) & CRX_INS_MASK)
#define REG_LIST CRX_INS_MAX
load - (REVERSE_MATCH)/store - (! REVERSE_MATCH). */
#define REVERSE_MATCH (1 << 5)
#define DISPUB4 (1 << 6)
#define DISPUW4 (1 << 7)
#define DISPUD4 (1 << 8)
#define DISPU4MAP (DISPUB4 | DISPUW4 | DISPUD4)
#define FMT_1 (1 << 9) /* 0xF0F00000 */
#define FMT_2 (1 << 10) /* 0xFFF0FF00 */
#define FMT_3 (1 << 11) /* 0xFFF00F00 */
#define FMT_4 (1 << 12) /* 0xFFF0F000 */
#define FMT_5 (1 << 13) /* 0xFFF0FFF0 */
#define FMT_CRX (FMT_1 | FMT_2 | FMT_3 | FMT_4 | FMT_5)
#define RELAXABLE (1 << 14)
general-purpose registers) as operands. */
#define USER_REG (1 << 15)
#define CST4MAP (1 << 16)
#define NO_SP (1 << 17)
#define NO_RPTR (1 << 18)
#define MAX_OPERANDS 5
#define MAX_REGNAME_LEN 10
#define MAX_INST_LEN 256
#define OP_UNSIGNED (1 << 0)
#define OP_SIGNED (1 << 1)
#define OP_CST4 (1 << 2)
#define OP_DISPU4 (1 << 3)
#define OP_EVEN (1 << 4)
#define OP_SHIFT (1 << 5)
#define OP_SHIFT_DEC (1 << 6)
#define OP_ESC (1 << 7)
#define OP_UPPER_64KB (1 << 8)
typedef struct
{
operand_type op_type;
unsigned int shift;
}
operand_desc;
typedef struct
{
const char *mnemonic;
unsigned int size;
unsigned int match;
int match_bits;
unsigned int flags;
operand_desc operands[MAX_OPERANDS];
}
inst;
typedef struct
{
reg r;
reg i_r;
copreg cr;
long constant;
unsigned int scale;
argtype type;
int size;
unsigned char X_op;
}
argument;
corresponding to the current assembling instruction. */
typedef struct
{
int nargs;
argument arg[MAX_OPERANDS];
#ifdef TC_CRX
expressionS exp;
bfd_reloc_code_real_type rtype;
#endif
int size;
}
ins;
typedef struct
{
unsigned int bit_size;
argtype arg_type;
int flags;
}
operand_entry;
typedef struct
{
char *name;
unsigned int entry;
}
trap_entry;
typedef struct
{
char *name;
union
{
reg reg_val;
copreg copreg_val;
} value;
int image;
reg_type type;
}
reg_entry;
extern const inst crx_instruction[];
extern const int crx_num_opcodes;
#define NUMOPCODES crx_num_opcodes
extern const operand_entry crx_optab[];
extern const reg_entry crx_regtab[];
extern const int crx_num_regs;
#define NUMREGS crx_num_regs
extern const reg_entry crx_copregtab[];
extern const int crx_num_copregs;
#define NUMCOPREGS crx_num_copregs
extern const trap_entry crx_traps[];
extern const int crx_num_traps;
#define NUMTRAPS crx_num_traps
extern const int crx_cst4_map[];
extern const int crx_cst4_maps;
extern const char* crx_no_op_insn[];
the FIXED part of the instruction. The "constant" opcode is represented
as a 32-bit unsigned long, where OPC is expanded (by a left SHIFT)
over that range. */
#define BIN(OPC,SHIFT) (OPC << SHIFT)
#define IS_INSN_TYPE(TYPE) \
(CRX_INS_TYPE(instruction->flags) == TYPE)
#define IS_INSN_MNEMONIC(MNEMONIC) \
(strcmp(instruction->mnemonic,MNEMONIC) == 0)
#define INST_HAS_REG_LIST \
(instruction->flags & REG_LIST)
typedef long long int LONGLONG;
typedef unsigned long long ULONGLONG;
#endif