1 /* bfin-defs.h ADI Blackfin gas header file
2 Copyright (C) 2005-2018 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to the Free
18 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
24 #include "opcode/bfin.h"
27 #define CODE_FRAG_SIZE 4096 /* 1 page. */
30 /* Definition for all status bits. */
70 /* High-Nibble: group code, low nibble: register code. */
81 /* All registers above this value don't
82 belong to a usable register group. */
83 #define T_NOGROUP 0xa0
90 enum machine_registers
92 REG_R0 = T_REG_R, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
93 REG_P0 = T_REG_P, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
94 REG_I0 = T_REG_I, REG_I1, REG_I2, REG_I3,
95 REG_M0 = T_REG_M, REG_M1, REG_M2, REG_M3,
96 REG_B0 = T_REG_B, REG_B1, REG_B2, REG_B3,
97 REG_L0 = T_REG_L, REG_L1, REG_L2, REG_L3,
98 REG_A0x = T_REG_A, REG_A0w, REG_A1x, REG_A1w,
101 REG_LC0 = 0x60, REG_LT0, REG_LB0, REG_LC1, REG_LT1, REG_LB1,
102 REG_CYCLES, REG_CYCLES2,
103 REG_USP = 0x70, REG_SEQSTAT, REG_SYSCFG,
104 REG_RETI, REG_RETX, REG_RETN, REG_RETE, REG_EMUDAT,
106 /* These don't have groups. */
107 REG_sftreset = T_NOGROUP, REG_omode, REG_excause, REG_emucause,
108 REG_idle_req, REG_hwerrcause,
109 REG_A0 = 0xc0, REG_A1, REG_CC,
110 /* Pseudo registers, used only for distinction from symbols. */
111 REG_RL0, REG_RL1, REG_RL2, REG_RL3,
112 REG_RL4, REG_RL5, REG_RL6, REG_RL7,
113 REG_RH0, REG_RH1, REG_RH2, REG_RH3,
114 REG_RH4, REG_RH5, REG_RH6, REG_RH7,
118 /* Status register flags. */
170 /* Register type checking macros. */
172 #define CODE_MASK 0x07
173 #define CLASS_MASK 0xf0
175 #define REG_SAME(a, b) ((a).regno == (b).regno)
176 #define REG_EQUAL(a, b) (((a).regno & CODE_MASK) == ((b).regno & CODE_MASK))
177 #define REG_CLASS(a) ((a).regno & 0xf0)
178 #define IS_A1(a) ((a).regno == REG_A1)
179 #define IS_H(a) ((a).flags & F_REG_HIGH ? 1: 0)
180 #define IS_EVEN(r) ((r).regno % 2 == 0)
181 #define IS_HCOMPL(a, b) (REG_EQUAL(a, b) && \
182 ((a).flags & F_REG_HIGH) != ((b).flags & F_REG_HIGH))
184 /* register type checking. */
185 #define _TYPECHECK(r, x) (((r).regno & CLASS_MASK) == T_REG_##x)
187 #define IS_DREG(r) _TYPECHECK(r, R)
188 #define IS_DREG_H(r) (_TYPECHECK(r, R) && IS_H(r))
189 #define IS_DREG_L(r) (_TYPECHECK(r, R) && !IS_H(r))
190 #define IS_PREG(r) _TYPECHECK(r, P)
191 #define IS_IREG(r) (((r).regno & 0xf4) == T_REG_I)
192 #define IS_MREG(r) (((r).regno & 0xf4) == T_REG_M)
193 #define IS_BREG(r) (((r).regno & 0xf4) == T_REG_B)
194 #define IS_LREG(r) (((r).regno & 0xf4) == T_REG_L)
195 #define IS_CREG(r) ((r).regno == REG_LC0 || (r).regno == REG_LC1)
196 #define IS_EMUDAT(r) ((r).regno == REG_EMUDAT)
197 #define IS_ALLREG(r) ((r).regno < T_NOGROUP)
199 #define IS_GENREG(r) \
200 (IS_DREG (r) || IS_PREG (r) \
201 || (r).regno == REG_A0x || (r).regno == REG_A0w \
202 || (r).regno == REG_A1x || (r).regno == REG_A1w)
204 #define IS_DAGREG(r) \
205 (IS_IREG (r) || IS_MREG (r) || IS_BREG (r) || IS_LREG (r))
207 #define IS_SYSREG(r) \
208 ((r).regno == REG_ASTAT || (r).regno == REG_SEQSTAT \
209 || (r).regno == REG_SYSCFG || (r).regno == REG_RETI \
210 || (r).regno == REG_RETX || (r).regno == REG_RETN \
211 || (r).regno == REG_RETE || (r).regno == REG_RETS \
212 || (r).regno == REG_LC0 || (r).regno == REG_LC1 \
213 || (r).regno == REG_LT0 || (r).regno == REG_LT1 \
214 || (r).regno == REG_LB0 || (r).regno == REG_LB1 \
215 || (r).regno == REG_CYCLES || (r).regno == REG_CYCLES2 \
216 || (r).regno == REG_EMUDAT)
218 /* Expression value macros. */
238 #define SYMBOL_T symbolS*
240 struct expression_cell
246 /* User Type Definitions. */
250 struct bfin_insn *next;
251 struct expression_cell *exp;
256 #define INSTR_T struct bfin_insn*
257 #define EXPR_T struct expression_cell*
259 typedef struct expr_node_struct Expr_Node;
261 extern INSTR_T gencode (unsigned long x);
262 extern INSTR_T conscode (INSTR_T head, INSTR_T tail);
263 extern INSTR_T conctcode (INSTR_T head, INSTR_T tail);
264 extern INSTR_T note_reloc
265 (INSTR_T code, Expr_Node *, int reloc,int pcrel);
266 extern INSTR_T note_reloc1
267 (INSTR_T code, const char * sym, int reloc, int pcrel);
268 extern INSTR_T note_reloc2
269 (INSTR_T code, const char *symbol, int reloc, int value, int pcrel);
271 /* Types of expressions. */
274 Expr_Node_Binop, /* Binary operator. */
275 Expr_Node_Unop, /* Unary operator. */
276 Expr_Node_Reloc, /* Symbol to be relocated. */
277 Expr_Node_GOT_Reloc, /* Symbol to be relocated using the GOT. */
278 Expr_Node_Constant /* Constant. */
281 /* Types of operators. */
291 Expr_Op_Type_BAND, /* Bitwise AND. */
292 Expr_Op_Type_BOR, /* Bitwise OR. */
293 Expr_Op_Type_BXOR, /* Bitwise exclusive OR. */
294 Expr_Op_Type_LAND, /* Logical AND. */
295 Expr_Op_Type_LOR, /* Logical OR. */
297 Expr_Op_Type_COMP /* Complement. */
300 /* The value that can be stored ... depends on type. */
303 const char *s_value; /* if relocation symbol, the text. */
304 long long i_value; /* if constant, the value. */
305 Expr_Op_Type op_value; /* if operator, the value. */
308 /* The expression node. */
309 struct expr_node_struct
312 Expr_Node_Value value;
313 Expr_Node *Left_Child;
314 Expr_Node *Right_Child;
318 /* Operations on the expression node. */
319 Expr_Node *Expr_Node_Create (Expr_Node_Type type,
320 Expr_Node_Value value,
321 Expr_Node *Left_Child,
322 Expr_Node *Right_Child);
324 /* Generate the reloc structure as a series of instructions. */
325 INSTR_T Expr_Node_Gen_Reloc (Expr_Node *head, int parent_reloc);
327 #define MKREF(x) mkexpr (0,x)
329 #define NULL_CODE ((INSTR_T) 0)
332 #define EXPR_VALUE(x) (((x)->type == Expr_Node_Constant) ? ((x)->value.i_value) : 0)
335 #define EXPR_SYMBOL(x) ((x)->symbol)
342 typedef struct _register
344 reg_t regno; /* Register ID as defined in machine_registers. */
349 typedef struct _macfunc
360 typedef struct _opt_mode
378 extern int debug_codeselection;
380 void error (const char *format, ...);
381 void warn (char *format, ...);
382 int semantic_error (char *syntax);
383 void semantic_error_2 (char *syntax);
385 EXPR_T mkexpr (int, SYMBOL_T);
387 /* Defined in bfin-lex.l. */
388 void set_start_state (void);
390 extern int insn_regmask (int, int);
395 #endif /* BFIN_PARSE_H */