Copyright 2007, 2008 Free Software Foundation, Inc.
Contributed by M R Swami Reddy
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 2, 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 _CR16_H_
#define _CR16_H_
The enums are used as indices to CR16 registers table (cr16_regtab).
Therefore, order MUST be preserved. */
typedef enum
{
r0, r1, r2, r3,
r4, r5, r6, r7,
r8, r9, r10, r11,
r12_L = 12, r13_L = 13, ra = 14, sp_L = 15,
r12 = 12, r13 = 13, r14 = 14, r15 = 15,
era = 14, sp = 15, RA,
nullregister,
MAX_REG
}
reg;
The enums are used as indices to CR16 processor registers table
(cr16_pregtab). Therefore, order MUST be preserved. */
typedef enum
{
dbs = MAX_REG,
dsr, dcrl, dcrh,
car0l, car0h, car1l, car1h,
cfg, psr, intbasel, intbaseh,
ispl, isph, uspl, usph,
dcr = dcrl,
car0 = car0l,
car1 = car1l,
intbase = intbasel,
isp = ispl,
usp = uspl,
nullpregister = usph + 1,
MAX_PREG
}
preg;
typedef enum
{
CR16_R_REGTYPE,
CR16_RP_REGTYPE,
CR16_P_REGTYPE
}
reg_type;
The argument types correspond to instructions operands
Argument types :
r - register
rp - register pair
c - constant
i - immediate
idxr - index with register
idxrp - index with register pair
rbase - register base
rpbase - register pair base
pr - processor register */
typedef enum
{
arg_r,
arg_c,
arg_cr,
arg_crp,
arg_ic,
arg_icr,
arg_idxr,
arg_idxrp,
arg_rbase,
arg_rpbase,
arg_rp,
arg_pr,
arg_prp,
arg_cc,
arg_ra,
nullargs
}
argtype;
typedef enum
{
dummy,
imm3, imm4, imm5, imm6, imm16, imm20, imm32,
uimm3, uimm3_1, uimm4, uimm4_1, uimm5, uimm16, uimm20, uimm32,
disps5, disps17, disps25,
dispe9,
abs20, abs24,
rra, rbase, rbase_disps20, rbase_dispe20,
rpbase_disps0, rpbase_dispe4, rpbase_disps4, rpbase_disps16,
rpbase_disps20, rpbase_dispe20,
rindex7_abs20, rindex8_abs20,
rpindex_disps0, rpindex_disps14, rpindex_disps20,
regr,
regp,
pregr,
pregrp,
cc,
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 SHIFT_INS 5
#define BRANCH_NEQ_INS 6
#define LD_STOR_INS_INC 7
#define STOR_IMM_INS 8
#define CSTBIT_INS 9
#define CR16_INS_MAX (1 << 4)
#define CR16_INS_MASK (CR16_INS_MAX - 1)
#define CR16_INS_TYPE(attr) ((attr) & CR16_INS_MASK)
#define REG_LIST CR16_INS_MAX
load - (REVERSE_MATCH)/store - (! REVERSE_MATCH). */
#define REVERSE_MATCH (1 << 5)
#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_CR16 (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 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_NEG (1 << 2)
#define OP_DEC (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_ABS20 (1 << 8)
#define OP_ABS24 (1 << 9)
#define OP_ESC1 (1 << 10)
typedef struct
{
operand_type op_type;
unsigned int shift;
}
operand_desc;
typedef struct
{
const char *mnemonic;
unsigned int size;
unsigned long match;
int match_bits;
unsigned int flags;
operand_desc operands[MAX_OPERANDS];
}
inst;
typedef struct
{
reg r;
reg rp;
reg i_r;
preg pr;
preg prp;
long constant;
unsigned int cc;
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_CR16
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;
preg preg_val;
} value;
int image;
reg_type type;
}
reg_entry;
extern const inst cr16_instruction[];
extern const unsigned int cr16_num_opcodes;
#define NUMOPCODES cr16_num_opcodes
extern const operand_entry cr16_optab[];
extern const unsigned int cr16_num_optab;
extern const reg_entry cr16_regtab[];
extern const unsigned int cr16_num_regs;
#define NUMREGS cr16_num_regs
extern const reg_entry cr16_regptab[];
extern const unsigned int cr16_num_regps;
#define NUMREGPS cr16_num_regps
extern const reg_entry cr16_pregtab[];
extern const unsigned int cr16_num_pregs;
#define NUMPREGS cr16_num_pregs
extern const reg_entry cr16_pregptab[];
extern const unsigned int cr16_num_pregps;
#define NUMPREGPS cr16_num_pregps
extern const trap_entry cr16_traps[];
extern const unsigned int cr16_num_traps;
#define NUMTRAPS cr16_num_traps
extern const char * cr16_b_cond_tab[];
extern const unsigned int cr16_num_cc;
#define NUMCC cr16_num_cc;
extern const char * cr16_no_op_insn[];
extern const inst *instruction;
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) \
(CR16_INS_TYPE (instruction->flags) == TYPE)
#define IS_INSN_MNEMONIC(MNEMONIC) \
(strcmp (instruction->mnemonic, MNEMONIC) == 0)
#define INST_HAS_REG_LIST \
(instruction->flags & REG_LIST)
#define streq(a, b) (strcmp (a, b) == 0)
#define strneq(a, b, c) (strncmp (a, b, c) == 0)
typedef long long int LONGLONG;
typedef unsigned long long ULONGLONG;
#endif