179 |
|
|
180 |
typedef struct opcode_t { |
typedef struct opcode_t { |
181 |
unsigned char opc1, opc2, opc3; |
unsigned char opc1, opc2, opc3; |
182 |
|
#if HOST_LONG_BITS == 64 /* Explicitely align to 64 bits */ |
183 |
|
unsigned char pad[5]; |
184 |
|
#else |
185 |
|
unsigned char pad[1]; |
186 |
|
#endif |
187 |
opc_handler_t handler; |
opc_handler_t handler; |
188 |
} opcode_t; |
} opcode_t; |
189 |
|
|
197 |
#define EXTRACT_SHELPER(name, shift, nb) \ |
#define EXTRACT_SHELPER(name, shift, nb) \ |
198 |
static inline int32_t name (uint32_t opcode) \ |
static inline int32_t name (uint32_t opcode) \ |
199 |
{ \ |
{ \ |
200 |
return s_ext16((opcode >> (shift)) & ((1 << (nb)) - 1)); \ |
return (int16_t)((opcode >> (shift)) & ((1 << (nb)) - 1)); \ |
201 |
} |
} |
202 |
|
|
203 |
/* Opcode part 1 */ |
/* Opcode part 1 */ |
290 |
#endif |
#endif |
291 |
|
|
292 |
#define GEN_OPCODE(name, op1, op2, op3, invl, _typ) \ |
#define GEN_OPCODE(name, op1, op2, op3, invl, _typ) \ |
293 |
OPCODES_SECTION static opcode_t opc_##name = { \ |
OPCODES_SECTION opcode_t opc_##name = { \ |
294 |
.opc1 = op1, \ |
.opc1 = op1, \ |
295 |
.opc2 = op2, \ |
.opc2 = op2, \ |
296 |
.opc3 = op3, \ |
.opc3 = op3, \ |
297 |
|
.pad = { 0, }, \ |
298 |
.handler = { \ |
.handler = { \ |
299 |
.inval = invl, \ |
.inval = invl, \ |
300 |
.type = _typ, \ |
.type = _typ, \ |
303 |
} |
} |
304 |
|
|
305 |
#define GEN_OPCODE_MARK(name) \ |
#define GEN_OPCODE_MARK(name) \ |
306 |
OPCODES_SECTION static opcode_t opc_##name = { \ |
OPCODES_SECTION opcode_t opc_##name = { \ |
307 |
.opc1 = 0xFF, \ |
.opc1 = 0xFF, \ |
308 |
.opc2 = 0xFF, \ |
.opc2 = 0xFF, \ |
309 |
.opc3 = 0xFF, \ |
.opc3 = 0xFF, \ |
310 |
|
.pad = { 0, }, \ |
311 |
.handler = { \ |
.handler = { \ |
312 |
.inval = 0x00000000, \ |
.inval = 0x00000000, \ |
313 |
.type = 0x00, \ |
.type = 0x00, \ |
368 |
gen_op_load_gpr_T1(rB(ctx->opcode)); \ |
gen_op_load_gpr_T1(rB(ctx->opcode)); \ |
369 |
gen_op_##name(); \ |
gen_op_##name(); \ |
370 |
if (Rc(ctx->opcode) != 0) \ |
if (Rc(ctx->opcode) != 0) \ |
371 |
gen_op_set_Rc0_ov(); \ |
gen_op_set_Rc0(); \ |
372 |
gen_op_store_T0_gpr(rD(ctx->opcode)); \ |
gen_op_store_T0_gpr(rD(ctx->opcode)); \ |
373 |
} |
} |
374 |
|
|
387 |
gen_op_load_gpr_T0(rA(ctx->opcode)); \ |
gen_op_load_gpr_T0(rA(ctx->opcode)); \ |
388 |
gen_op_##name(); \ |
gen_op_##name(); \ |
389 |
if (Rc(ctx->opcode) != 0) \ |
if (Rc(ctx->opcode) != 0) \ |
390 |
gen_op_set_Rc0_ov(); \ |
gen_op_set_Rc0(); \ |
391 |
gen_op_store_T0_gpr(rD(ctx->opcode)); \ |
gen_op_store_T0_gpr(rD(ctx->opcode)); \ |
392 |
} |
} |
393 |
|
|
1565 |
gen_op_dec_ctr(); |
gen_op_dec_ctr(); |
1566 |
switch(type) { |
switch(type) { |
1567 |
case BCOND_IM: |
case BCOND_IM: |
1568 |
li = s_ext16(BD(ctx->opcode)); |
li = (int32_t)((int16_t)(BD(ctx->opcode))); |
1569 |
if (AA(ctx->opcode) == 0) { |
if (AA(ctx->opcode) == 0) { |
1570 |
target = ctx->nip + li - 4; |
target = ctx->nip + li - 4; |
1571 |
} else { |
} else { |
2167 |
case DECR: |
case DECR: |
2168 |
gen_op_store_decr(); |
gen_op_store_decr(); |
2169 |
break; |
break; |
|
#if 0 |
|
|
case HID0: |
|
|
gen_op_store_hid0(); |
|
|
break; |
|
|
#endif |
|
2170 |
default: |
default: |
2171 |
gen_op_store_spr(sprn); |
gen_op_store_spr(sprn); |
2172 |
break; |
break; |
2896 |
|
|
2897 |
static int create_ppc_proc (opc_handler_t **ppc_opcodes, unsigned long pvr) |
static int create_ppc_proc (opc_handler_t **ppc_opcodes, unsigned long pvr) |
2898 |
{ |
{ |
2899 |
opcode_t *opc; |
opcode_t *opc, *start, *end; |
2900 |
int i, flags; |
int i, flags; |
2901 |
|
|
2902 |
fill_new_table(ppc_opcodes, 0x40); |
fill_new_table(ppc_opcodes, 0x40); |
2908 |
} |
} |
2909 |
} |
} |
2910 |
|
|
2911 |
for (opc = &opc_start + 1; opc != &opc_end; opc++) { |
if (&opc_start < &opc_end) { |
2912 |
|
start = &opc_start; |
2913 |
|
end = &opc_end; |
2914 |
|
} else { |
2915 |
|
start = &opc_end; |
2916 |
|
end = &opc_start; |
2917 |
|
} |
2918 |
|
for (opc = start + 1; opc != end; opc++) { |
2919 |
if ((opc->handler.type & flags) != 0) |
if ((opc->handler.type & flags) != 0) |
2920 |
if (register_insn(ppc_opcodes, opc) < 0) { |
if (register_insn(ppc_opcodes, opc) < 0) { |
2921 |
printf("*** ERROR initializing PPC instruction " |
printf("*** ERROR initializing PPC instruction " |