OSDN Git Service

4731d07e853abf1d69bb907f7f103dac37b5357a
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / cgen-cpu / arm7t / thumb-decode.h
1 /* Decode header for thumb.
2
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
4
5 Copyright (C) 2000-2009 Red Hat, Inc.
6
7 This file is part of the Red Hat simulators.
8
9
10 */
11
12 #ifndef THUMB_DECODE_H
13 #define THUMB_DECODE_H
14
15 namespace arm7f {
16
17 using namespace cgen;
18 using namespace arm;
19
20 typedef UINT thumb_insn_word;
21
22 /* Enum declaration for instructions in cpu family thumb.  */
23 typedef enum thumb_insn_type {
24   THUMB_INSN_X_AFTER, THUMB_INSN_X_BEFORE, THUMB_INSN_X_CTI_CHAIN, THUMB_INSN_X_CHAIN
25  , THUMB_INSN_X_BEGIN, THUMB_INSN_X_INVALID, THUMB_INSN_LSL, THUMB_INSN_LSR
26  , THUMB_INSN_ASR, THUMB_INSN_ADD, THUMB_INSN_ADDI, THUMB_INSN_SUB
27  , THUMB_INSN_SUBI, THUMB_INSN_MOV, THUMB_INSN_CMP, THUMB_INSN_ADDI8
28  , THUMB_INSN_SUBI8, THUMB_INSN_ALU_AND, THUMB_INSN_ALU_EOR, THUMB_INSN_ALU_LSL
29  , THUMB_INSN_ALU_LSR, THUMB_INSN_ALU_ASR, THUMB_INSN_ALU_ROR, THUMB_INSN_ALU_ADC
30  , THUMB_INSN_ALU_SBC, THUMB_INSN_ALU_TST, THUMB_INSN_ALU_NEG, THUMB_INSN_ALU_CMP
31  , THUMB_INSN_ALU_CMN, THUMB_INSN_ALU_ORR, THUMB_INSN_ALU_MUL, THUMB_INSN_ALU_BIC
32  , THUMB_INSN_ALU_MVN, THUMB_INSN_ADD_RD_HS, THUMB_INSN_ADD_HD_RS, THUMB_INSN_ADD_HD_HS
33  , THUMB_INSN_CMP_RD_HS, THUMB_INSN_CMP_HD_RS, THUMB_INSN_CMP_HD_HS, THUMB_INSN_MOV_RD_HS
34  , THUMB_INSN_MOV_HD_RS, THUMB_INSN_MOV_HD_HS, THUMB_INSN_BX_RS, THUMB_INSN_BX_HS
35  , THUMB_INSN_LDR_PC, THUMB_INSN_STR, THUMB_INSN_STRB, THUMB_INSN_LDR
36  , THUMB_INSN_LDRB, THUMB_INSN_STRH, THUMB_INSN_LDRH, THUMB_INSN_LDSB
37  , THUMB_INSN_LDSH, THUMB_INSN_STR_IMM, THUMB_INSN_LDR_IMM, THUMB_INSN_STRB_IMM
38  , THUMB_INSN_LDRB_IMM, THUMB_INSN_STRH_IMM, THUMB_INSN_LDRH_IMM, THUMB_INSN_STR_SPREL
39  , THUMB_INSN_LDR_SPREL, THUMB_INSN_LDA_PC, THUMB_INSN_LDA_SP, THUMB_INSN_ADD_SP
40  , THUMB_INSN_SUB_SP, THUMB_INSN_PUSH, THUMB_INSN_PUSH_LR, THUMB_INSN_POP
41  , THUMB_INSN_POP_PC, THUMB_INSN_STMIA, THUMB_INSN_LDMIA, THUMB_INSN_BEQ
42  , THUMB_INSN_BNE, THUMB_INSN_BCS, THUMB_INSN_BCC, THUMB_INSN_BMI
43  , THUMB_INSN_BPL, THUMB_INSN_BVS, THUMB_INSN_BVC, THUMB_INSN_BHI
44  , THUMB_INSN_BLS, THUMB_INSN_BGE, THUMB_INSN_BLT, THUMB_INSN_BGT
45  , THUMB_INSN_BLE, THUMB_INSN_SWI, THUMB_INSN_B, THUMB_INSN_BL_HI
46  , THUMB_INSN_BL_LO
47 } THUMB_INSN_TYPE;
48
49
50 // Forward decls.
51 struct arm7f_cpu;
52 struct thumb_scache;
53 typedef sem_status (thumb_sem_fn) (arm7f_cpu* cpu, thumb_scache* sem);
54
55
56 // Instruction descriptor.
57
58 struct thumb_idesc {
59
60   // computed-goto label pointer (pbb engine)
61   // FIXME: frag case to be redone (should instead point to usage table).
62   cgoto_label cgoto;
63
64   // scache engine executor for this insn
65   thumb_sem_fn* execute;
66
67   const char* insn_name;
68   enum thumb_insn_type sem_index;
69   arm_insn_attr attrs;
70
71   // idesc table: indexed by sem_index
72   static thumb_idesc idesc_table[];
73
74   // semantic label pointers filled_in?
75   static bool idesc_table_initialized_p;
76
77   static thumb_insn_type lookup_virtual (virtual_insn_type vit);
78 };
79
80 // Instruction argument buffer.
81
82 union thumb_sem_fields {
83   struct { /* no operands */
84     int empty;
85   } fmt_empty;
86   struct { /*  */
87     UINT f_lbwl_lo;
88   } sfmt_bl_lo;
89   struct { /*  */
90     INT f_lbwl_hi;
91   } sfmt_bl_hi;
92   struct { /*  */
93     IADDR i_offset11;
94   } sfmt_b;
95   struct { /*  */
96     UINT f_value8;
97   } sfmt_swi;
98   struct { /*  */
99     IADDR i_soffset8;
100   } sfmt_beq;
101   struct { /*  */
102     SI f_sword7;
103   } sfmt_add_sp;
104   struct { /*  */
105     UINT f_bit10_rb;
106     UINT f_rlist;
107   } sfmt_stmia;
108   struct { /*  */
109     SI f_word8;
110     UINT f_bit10_rd;
111   } sfmt_ldr_pc;
112   struct { /*  */
113     UINT f_bit10_rd;
114     UINT f_offset8;
115   } sfmt_mov;
116   struct { /*  */
117     SI f_offset5_6;
118     UINT f_rb;
119     UINT f_rd;
120   } sfmt_strh_imm;
121   struct { /*  */
122     UINT f_offset5;
123     UINT f_rb;
124     UINT f_rd;
125   } sfmt_strb_imm;
126   struct { /*  */
127     SI f_offset5_7;
128     UINT f_rb;
129     UINT f_rd;
130   } sfmt_str_imm;
131   struct { /*  */
132     UINT f_rb;
133     UINT f_rd;
134     UINT f_ro;
135   } sfmt_str;
136   struct { /*  */
137     UINT f_offset3;
138     UINT f_rd;
139     UINT f_rs;
140   } sfmt_addi;
141   struct { /*  */
142     UINT f_rd;
143     UINT f_rn;
144     UINT f_rs;
145   } sfmt_add;
146   struct { /*  */
147     UINT f_offset5;
148     UINT f_rd;
149     UINT f_rs;
150   } sfmt_lsl;
151   // This one is for chain/cti-chain virtual insns.
152   struct {
153     // Number of insns in pbb.
154     unsigned insn_count;
155     // This is used by chain insns and by untaken conditional branches.
156     thumb_scache* next;
157     thumb_scache* branch_target;
158   } chain;
159   // This one is for `before' virtual insns.
160   struct {
161     // The cache entry of the real insn.
162     thumb_scache* insn;
163   } before;
164 };
165
166 // Simulator instruction cache.
167
168 struct thumb_scache {
169   // executor
170   union {
171     cgoto_label cgoto;
172     thumb_sem_fn* fn;
173   } execute;
174
175   // PC of this instruction.
176   PCADDR addr;
177
178   // instruction class
179   thumb_idesc* idesc;
180
181   // argument buffer
182   thumb_sem_fields fields;
183
184
185
186   // decode given instruction
187   void decode (arm7f_cpu* current_cpu, PCADDR pc, thumb_insn_word base_insn, thumb_insn_word entire_insn);
188 };
189
190 } // end arm7f namespace
191
192 // Decls of each semantic fn.
193
194 using arm7f::thumb_sem_fn;
195 extern thumb_sem_fn thumb_sem_x_invalid;
196 extern thumb_sem_fn thumb_sem_lsl;
197 extern thumb_sem_fn thumb_sem_lsr;
198 extern thumb_sem_fn thumb_sem_asr;
199 extern thumb_sem_fn thumb_sem_add;
200 extern thumb_sem_fn thumb_sem_addi;
201 extern thumb_sem_fn thumb_sem_sub;
202 extern thumb_sem_fn thumb_sem_subi;
203 extern thumb_sem_fn thumb_sem_mov;
204 extern thumb_sem_fn thumb_sem_cmp;
205 extern thumb_sem_fn thumb_sem_addi8;
206 extern thumb_sem_fn thumb_sem_subi8;
207 extern thumb_sem_fn thumb_sem_alu_and;
208 extern thumb_sem_fn thumb_sem_alu_eor;
209 extern thumb_sem_fn thumb_sem_alu_lsl;
210 extern thumb_sem_fn thumb_sem_alu_lsr;
211 extern thumb_sem_fn thumb_sem_alu_asr;
212 extern thumb_sem_fn thumb_sem_alu_ror;
213 extern thumb_sem_fn thumb_sem_alu_adc;
214 extern thumb_sem_fn thumb_sem_alu_sbc;
215 extern thumb_sem_fn thumb_sem_alu_tst;
216 extern thumb_sem_fn thumb_sem_alu_neg;
217 extern thumb_sem_fn thumb_sem_alu_cmp;
218 extern thumb_sem_fn thumb_sem_alu_cmn;
219 extern thumb_sem_fn thumb_sem_alu_orr;
220 extern thumb_sem_fn thumb_sem_alu_mul;
221 extern thumb_sem_fn thumb_sem_alu_bic;
222 extern thumb_sem_fn thumb_sem_alu_mvn;
223 extern thumb_sem_fn thumb_sem_add_rd_hs;
224 extern thumb_sem_fn thumb_sem_add_hd_rs;
225 extern thumb_sem_fn thumb_sem_add_hd_hs;
226 extern thumb_sem_fn thumb_sem_cmp_rd_hs;
227 extern thumb_sem_fn thumb_sem_cmp_hd_rs;
228 extern thumb_sem_fn thumb_sem_cmp_hd_hs;
229 extern thumb_sem_fn thumb_sem_mov_rd_hs;
230 extern thumb_sem_fn thumb_sem_mov_hd_rs;
231 extern thumb_sem_fn thumb_sem_mov_hd_hs;
232 extern thumb_sem_fn thumb_sem_bx_rs;
233 extern thumb_sem_fn thumb_sem_bx_hs;
234 extern thumb_sem_fn thumb_sem_ldr_pc;
235 extern thumb_sem_fn thumb_sem_str;
236 extern thumb_sem_fn thumb_sem_strb;
237 extern thumb_sem_fn thumb_sem_ldr;
238 extern thumb_sem_fn thumb_sem_ldrb;
239 extern thumb_sem_fn thumb_sem_strh;
240 extern thumb_sem_fn thumb_sem_ldrh;
241 extern thumb_sem_fn thumb_sem_ldsb;
242 extern thumb_sem_fn thumb_sem_ldsh;
243 extern thumb_sem_fn thumb_sem_str_imm;
244 extern thumb_sem_fn thumb_sem_ldr_imm;
245 extern thumb_sem_fn thumb_sem_strb_imm;
246 extern thumb_sem_fn thumb_sem_ldrb_imm;
247 extern thumb_sem_fn thumb_sem_strh_imm;
248 extern thumb_sem_fn thumb_sem_ldrh_imm;
249 extern thumb_sem_fn thumb_sem_str_sprel;
250 extern thumb_sem_fn thumb_sem_ldr_sprel;
251 extern thumb_sem_fn thumb_sem_lda_pc;
252 extern thumb_sem_fn thumb_sem_lda_sp;
253 extern thumb_sem_fn thumb_sem_add_sp;
254 extern thumb_sem_fn thumb_sem_sub_sp;
255 extern thumb_sem_fn thumb_sem_push;
256 extern thumb_sem_fn thumb_sem_push_lr;
257 extern thumb_sem_fn thumb_sem_pop;
258 extern thumb_sem_fn thumb_sem_pop_pc;
259 extern thumb_sem_fn thumb_sem_stmia;
260 extern thumb_sem_fn thumb_sem_ldmia;
261 extern thumb_sem_fn thumb_sem_beq;
262 extern thumb_sem_fn thumb_sem_bne;
263 extern thumb_sem_fn thumb_sem_bcs;
264 extern thumb_sem_fn thumb_sem_bcc;
265 extern thumb_sem_fn thumb_sem_bmi;
266 extern thumb_sem_fn thumb_sem_bpl;
267 extern thumb_sem_fn thumb_sem_bvs;
268 extern thumb_sem_fn thumb_sem_bvc;
269 extern thumb_sem_fn thumb_sem_bhi;
270 extern thumb_sem_fn thumb_sem_bls;
271 extern thumb_sem_fn thumb_sem_bge;
272 extern thumb_sem_fn thumb_sem_blt;
273 extern thumb_sem_fn thumb_sem_bgt;
274 extern thumb_sem_fn thumb_sem_ble;
275 extern thumb_sem_fn thumb_sem_swi;
276 extern thumb_sem_fn thumb_sem_b;
277 extern thumb_sem_fn thumb_sem_bl_hi;
278 extern thumb_sem_fn thumb_sem_bl_lo;
279
280 #endif /* THUMB_DECODE_H */