1 /* Decode header for thumb.
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
5 Copyright (C) 2000-2009 Red Hat, Inc.
7 This file is part of the Red Hat simulators.
12 #ifndef THUMB_DECODE_H
13 #define THUMB_DECODE_H
20 typedef UINT thumb_insn_word;
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
53 typedef sem_status (thumb_sem_fn) (arm7f_cpu* cpu, thumb_scache* sem);
56 // Instruction descriptor.
60 // computed-goto label pointer (pbb engine)
61 // FIXME: frag case to be redone (should instead point to usage table).
64 // scache engine executor for this insn
65 thumb_sem_fn* execute;
67 const char* insn_name;
68 enum thumb_insn_type sem_index;
71 // idesc table: indexed by sem_index
72 static thumb_idesc idesc_table[];
74 // semantic label pointers filled_in?
75 static bool idesc_table_initialized_p;
77 static thumb_insn_type lookup_virtual (virtual_insn_type vit);
80 // Instruction argument buffer.
82 union thumb_sem_fields {
83 struct { /* no operands */
151 // This one is for chain/cti-chain virtual insns.
153 // Number of insns in pbb.
155 // This is used by chain insns and by untaken conditional branches.
157 thumb_scache* branch_target;
159 // This one is for `before' virtual insns.
161 // The cache entry of the real insn.
166 // Simulator instruction cache.
168 struct thumb_scache {
175 // PC of this instruction.
182 thumb_sem_fields fields;
186 // decode given instruction
187 void decode (arm7f_cpu* current_cpu, PCADDR pc, thumb_insn_word base_insn, thumb_insn_word entire_insn);
190 } // end arm7f namespace
192 // Decls of each semantic fn.
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;
280 #endif /* THUMB_DECODE_H */