]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gas/config/bfin-defs.h
opcodes/gas: blackfin: handle more ASTAT flags
[thirdparty/binutils-gdb.git] / gas / config / bfin-defs.h
CommitLineData
07c1b327 1/* bfin-defs.h ADI Blackfin gas header file
22215ae0 2 Copyright 2005, 2006, 2007, 2009, 2010
07c1b327
CM
3 Free Software Foundation, Inc.
4
5 This file is part of GAS, the GNU Assembler.
6
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
ec2655a6 9 the Free Software Foundation; either version 3, or (at your option)
07c1b327
CM
10 any later version.
11
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20 02110-1301, USA. */
21
22#ifndef BFIN_PARSE_H
ee9e7c78 23#define BFIN_PARSE_H
07c1b327 24
07c1b327 25#define PCREL 1
ee9e7c78 26#define CODE_FRAG_SIZE 4096 /* 1 page. */
07c1b327
CM
27
28
29/* Definition for all status bits. */
30typedef enum
31{
32 c_0,
33 c_1,
34 c_4,
35 c_2,
36 c_uimm2,
37 c_uimm3,
38 c_imm3,
ee9e7c78 39 c_pcrel4,
07c1b327
CM
40 c_imm4,
41 c_uimm4s4,
42 c_uimm4,
43 c_uimm4s2,
44 c_negimm5s4,
45 c_imm5,
46 c_uimm5,
ee9e7c78 47 c_imm6,
07c1b327
CM
48 c_imm7,
49 c_imm8,
50 c_uimm8,
51 c_pcrel8,
52 c_uimm8s4,
53 c_pcrel8s4,
54 c_lppcrel10,
ee9e7c78 55 c_pcrel10,
07c1b327
CM
56 c_pcrel12,
57 c_imm16s4,
58 c_luimm16,
59 c_imm16,
60 c_huimm16,
61 c_rimm16,
62 c_imm16s2,
ee9e7c78 63 c_uimm16s4,
07c1b327 64 c_uimm16,
ee9e7c78 65 c_pcrel24
07c1b327
CM
66} const_forms_t;
67
68
69/* High-Nibble: group code, low nibble: register code. */
70
71
72#define T_REG_R 0x00
73#define T_REG_P 0x10
74#define T_REG_I 0x20
75#define T_REG_B 0x30
76#define T_REG_L 0x34
77#define T_REG_M 0x24
78#define T_REG_A 0x40
79
80/* All registers above this value don't
81 belong to a usuable register group. */
82#define T_NOGROUP 0xa0
83
84/* Flags. */
f31bf2c6
JZ
85#define F_REG_NONE 0
86#define F_REG_HIGH 1
87#define F_REG_LOW 2
07c1b327
CM
88
89enum machine_registers
90{
ee9e7c78 91 REG_R0 = T_REG_R, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
07c1b327
CM
92 REG_P0 = T_REG_P, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
93 REG_I0 = T_REG_I, REG_I1, REG_I2, REG_I3,
ee9e7c78 94 REG_M0 = T_REG_M, REG_M1, REG_M2, REG_M3,
07c1b327 95 REG_B0 = T_REG_B, REG_B1, REG_B2, REG_B3,
ee9e7c78 96 REG_L0 = T_REG_L, REG_L1, REG_L2, REG_L3,
07c1b327
CM
97 REG_A0x = T_REG_A, REG_A0w, REG_A1x, REG_A1w,
98 REG_ASTAT = 0x46,
99 REG_RETS = 0x47,
100 REG_LC0 = 0x60, REG_LT0, REG_LB0, REG_LC1, REG_LT1, REG_LB1,
101 REG_CYCLES, REG_CYCLES2,
102 REG_USP = 0x70, REG_SEQSTAT, REG_SYSCFG,
ee9e7c78 103 REG_RETI, REG_RETX, REG_RETN, REG_RETE, REG_EMUDAT,
07c1b327
CM
104
105/* These don't have groups. */
106 REG_sftreset = T_NOGROUP, REG_omode, REG_excause, REG_emucause,
107 REG_idle_req, REG_hwerrcause,
108 REG_A0 = 0xc0, REG_A1, REG_CC,
109/* Pseudo registers, used only for distinction from symbols. */
110 REG_RL0, REG_RL1, REG_RL2, REG_RL3,
ee9e7c78 111 REG_RL4, REG_RL5, REG_RL6, REG_RL7,
07c1b327 112 REG_RH0, REG_RH1, REG_RH2, REG_RH3,
ee9e7c78 113 REG_RH4, REG_RH5, REG_RH6, REG_RH7,
07c1b327
CM
114 REG_LASTREG
115};
116
117/* Status register flags. */
118
119enum statusflags
120{
121 S_AZ = 0,
122 S_AN,
22215ae0
MF
123 S_AC0_COPY,
124 S_V_COPY,
07c1b327 125 S_AQ = 6,
22215ae0 126 S_RND_MOD = 8,
07c1b327
CM
127 S_AC0 = 12,
128 S_AC1,
129 S_AV0 = 16,
130 S_AV0S,
131 S_AV1,
132 S_AV1S,
133 S_V = 24,
134 S_VS = 25
ee9e7c78 135};
07c1b327
CM
136
137
138enum reg_class
139{
140 rc_dregs_lo,
141 rc_dregs_hi,
142 rc_dregs,
143 rc_dregs_pair,
144 rc_pregs,
145 rc_spfp,
146 rc_dregs_hilo,
147 rc_accum_ext,
148 rc_accum_word,
149 rc_accum,
150 rc_iregs,
151 rc_mregs,
152 rc_bregs,
153 rc_lregs,
154 rc_dpregs,
155 rc_gregs,
156 rc_regs,
157 rc_statbits,
158 rc_ignore_bits,
159 rc_ccstat,
160 rc_counters,
161 rc_dregs2_sysregs1,
162 rc_open,
163 rc_sysregs2,
164 rc_sysregs3,
165 rc_allregs,
166 LIM_REG_CLASSES
167};
168
169/* mmod field. */
170#define M_S2RND 1
171#define M_T 2
172#define M_W32 3
173#define M_FU 4
174#define M_TFU 6
175#define M_IS 8
176#define M_ISS2 9
177#define M_IH 11
178#define M_IU 12
179
180/* Register type checking macros. */
181
182#define CODE_MASK 0x07
183#define CLASS_MASK 0xf0
184
185#define REG_SAME(a, b) ((a).regno == (b).regno)
186#define REG_EQUAL(a, b) (((a).regno & CODE_MASK) == ((b).regno & CODE_MASK))
f31bf2c6 187#define REG_CLASS(a) ((a).regno & 0xf0)
07c1b327 188#define IS_A1(a) ((a).regno == REG_A1)
f31bf2c6
JZ
189#define IS_H(a) ((a).flags & F_REG_HIGH ? 1: 0)
190#define IS_EVEN(r) ((r).regno % 2 == 0)
07c1b327 191#define IS_HCOMPL(a, b) (REG_EQUAL(a, b) && \
f31bf2c6 192 ((a).flags & F_REG_HIGH) != ((b).flags & F_REG_HIGH))
07c1b327
CM
193
194/* register type checking. */
195#define _TYPECHECK(r, x) (((r).regno & CLASS_MASK) == T_REG_##x)
196
197#define IS_DREG(r) _TYPECHECK(r, R)
198#define IS_DREG_H(r) (_TYPECHECK(r, R) && IS_H(r))
199#define IS_DREG_L(r) (_TYPECHECK(r, R) && !IS_H(r))
200#define IS_PREG(r) _TYPECHECK(r, P)
201#define IS_IREG(r) (((r).regno & 0xf4) == T_REG_I)
202#define IS_MREG(r) (((r).regno & 0xf4) == T_REG_M)
73562ad0
JZ
203#define IS_BREG(r) (((r).regno & 0xf4) == T_REG_B)
204#define IS_LREG(r) (((r).regno & 0xf4) == T_REG_L)
07c1b327
CM
205#define IS_CREG(r) ((r).regno == REG_LC0 || (r).regno == REG_LC1)
206#define IS_ALLREG(r) ((r).regno < T_NOGROUP)
207
c958a8a8
JZ
208#define IS_GENREG(r) \
209 (IS_DREG (r) || IS_PREG (r) \
210 || (r).regno == REG_A0x || (r).regno == REG_A0w \
211 || (r).regno == REG_A1x || (r).regno == REG_A1w)
212
213#define IS_DAGREG(r) \
214 (IS_IREG (r) || IS_MREG (r) || IS_BREG (r) || IS_LREG (r))
215
216#define IS_SYSREG(r) \
217 ((r).regno == REG_ASTAT || (r).regno == REG_SEQSTAT \
218 || (r).regno == REG_SYSCFG || (r).regno == REG_RETI \
219 || (r).regno == REG_RETX || (r).regno == REG_RETN \
220 || (r).regno == REG_RETE || (r).regno == REG_RETS \
221 || (r).regno == REG_LC0 || (r).regno == REG_LC1 \
222 || (r).regno == REG_LT0 || (r).regno == REG_LT1 \
223 || (r).regno == REG_LB0 || (r).regno == REG_LB1 \
224 || (r).regno == REG_CYCLES || (r).regno == REG_CYCLES2 \
225 || (r).regno == REG_EMUDAT)
226
07c1b327
CM
227/* Expression value macros. */
228
229typedef enum
ee9e7c78 230{
07c1b327
CM
231 ones_compl,
232 twos_compl,
233 mult,
234 divide,
235 mod,
236 add,
237 sub,
238 lsh,
239 rsh,
240 logand,
241 logior,
242 logxor
243} expr_opcodes_t;
244
245struct expressionS;
246
247#define SYMBOL_T symbolS*
ee9e7c78 248
07c1b327
CM
249struct expression_cell
250{
251 int value;
252 SYMBOL_T symbol;
253};
254
255/* User Type Definitions. */
256struct bfin_insn
257{
258 unsigned long value;
259 struct bfin_insn *next;
260 struct expression_cell *exp;
261 int pcrel;
262 int reloc;
263};
ee9e7c78 264
07c1b327 265#define INSTR_T struct bfin_insn*
ee9e7c78 266#define EXPR_T struct expression_cell*
07c1b327
CM
267
268typedef struct expr_node_struct Expr_Node;
ee9e7c78 269
07c1b327 270extern INSTR_T gencode (unsigned long x);
ee9e7c78 271extern INSTR_T conscode (INSTR_T head, INSTR_T tail);
07c1b327
CM
272extern INSTR_T conctcode (INSTR_T head, INSTR_T tail);
273extern INSTR_T note_reloc
274 (INSTR_T code, Expr_Node *, int reloc,int pcrel);
275extern INSTR_T note_reloc1
276 (INSTR_T code, const char * sym, int reloc, int pcrel);
277extern INSTR_T note_reloc2
278 (INSTR_T code, const char *symbol, int reloc, int value, int pcrel);
ee9e7c78 279
07c1b327 280/* Types of expressions. */
ee9e7c78 281typedef enum
07c1b327
CM
282{
283 Expr_Node_Binop, /* Binary operator. */
284 Expr_Node_Unop, /* Unary operator. */
285 Expr_Node_Reloc, /* Symbol to be relocated. */
1ac4baed 286 Expr_Node_GOT_Reloc, /* Symbol to be relocated using the GOT. */
07c1b327
CM
287 Expr_Node_Constant /* Constant. */
288} Expr_Node_Type;
289
290/* Types of operators. */
ee9e7c78 291typedef enum
07c1b327
CM
292{
293 Expr_Op_Type_Add,
294 Expr_Op_Type_Sub,
295 Expr_Op_Type_Mult,
296 Expr_Op_Type_Div,
297 Expr_Op_Type_Mod,
298 Expr_Op_Type_Lshift,
299 Expr_Op_Type_Rshift,
300 Expr_Op_Type_BAND, /* Bitwise AND. */
301 Expr_Op_Type_BOR, /* Bitwise OR. */
302 Expr_Op_Type_BXOR, /* Bitwise exclusive OR. */
303 Expr_Op_Type_LAND, /* Logical AND. */
304 Expr_Op_Type_LOR, /* Logical OR. */
305 Expr_Op_Type_NEG,
306 Expr_Op_Type_COMP /* Complement. */
307} Expr_Op_Type;
308
309/* The value that can be stored ... depends on type. */
310typedef union
311{
312 const char *s_value; /* if relocation symbol, the text. */
958cff2f 313 long long i_value; /* if constant, the value. */
07c1b327
CM
314 Expr_Op_Type op_value; /* if operator, the value. */
315} Expr_Node_Value;
316
317/* The expression node. */
318struct expr_node_struct
319{
320 Expr_Node_Type type;
321 Expr_Node_Value value;
322 Expr_Node *Left_Child;
323 Expr_Node *Right_Child;
324};
325
326
327/* Operations on the expression node. */
ee9e7c78
MF
328Expr_Node *Expr_Node_Create (Expr_Node_Type type,
329 Expr_Node_Value value,
330 Expr_Node *Left_Child,
07c1b327
CM
331 Expr_Node *Right_Child);
332
333/* Generate the reloc structure as a series of instructions. */
334INSTR_T Expr_Node_Gen_Reloc (Expr_Node *head, int parent_reloc);
ee9e7c78 335
07c1b327
CM
336#define MKREF(x) mkexpr (0,x)
337#define ALLOCATE(x) malloc (x)
ee9e7c78 338
07c1b327
CM
339#define NULL_CODE ((INSTR_T) 0)
340
341#ifndef EXPR_VALUE
342#define EXPR_VALUE(x) (((x)->type == Expr_Node_Constant) ? ((x)->value.i_value) : 0)
343#endif
344#ifndef EXPR_SYMBOL
345#define EXPR_SYMBOL(x) ((x)->symbol)
346#endif
347
348
349typedef long reg_t;
350
351
352typedef struct _register
353{
354 reg_t regno; /* Register ID as defined in machine_registers. */
355 int flags;
356} Register;
357
358
359typedef struct _macfunc
360{
361 char n;
362 char op;
363 char w;
364 char P;
365 Register dst;
366 Register s0;
367 Register s1;
368} Macfunc;
369
370typedef struct _opt_mode
371{
372 int MM;
373 int mod;
374} Opt_mode;
375
376typedef enum
377{
378 SEMANTIC_ERROR,
379 NO_INSN_GENERATED,
380 INSN_GENERATED
381} parse_state;
382
383
384#ifdef __cplusplus
385extern "C" {
386#endif
387
388extern int debug_codeselection;
389
390void error (char *format, ...);
391void warn (char *format, ...);
392int semantic_error (char *syntax);
393void semantic_error_2 (char *syntax);
394
395EXPR_T mkexpr (int, SYMBOL_T);
396
07c1b327
CM
397/* Defined in bfin-lex.l. */
398void set_start_state (void);
399
d55cb1c5 400extern int insn_regmask (int, int);
07c1b327
CM
401#ifdef __cplusplus
402}
403#endif
404
405#endif /* BFIN_PARSE_H */
406