13 |
#include <fcntl.h> |
#include <fcntl.h> |
14 |
|
|
15 |
#include "cpu.h" |
#include "cpu.h" |
16 |
|
#include "jit_op.h" |
17 |
#include "ppc32_jit.h" |
#include "ppc32_jit.h" |
18 |
#include "ppc32_amd64_trans.h" |
#include "ppc32_amd64_trans.h" |
19 |
#include "memory.h" |
#include "memory.h" |
99 |
}; |
}; |
100 |
|
|
101 |
/* Load a 32 bit immediate value */ |
/* Load a 32 bit immediate value */ |
102 |
static inline void ppc32_load_imm(ppc32_jit_tcb_t *b,u_int reg,m_uint32_t val) |
static inline void ppc32_load_imm(u_char **ptr,u_int reg,m_uint32_t val) |
103 |
{ |
{ |
104 |
if (val) |
if (val) |
105 |
amd64_mov_reg_imm_size(b->jit_ptr,reg,val,4); |
amd64_mov_reg_imm_size(*ptr,reg,val,4); |
106 |
else |
else |
107 |
amd64_alu_reg_reg_size(b->jit_ptr,X86_XOR,reg,reg,4); |
amd64_alu_reg_reg_size(*ptr,X86_XOR,reg,reg,4); |
108 |
} |
} |
109 |
|
|
110 |
/* Set the Instruction Address (IA) register */ |
/* Set the Instruction Address (IA) register */ |
111 |
void ppc32_set_ia(ppc32_jit_tcb_t *b,m_uint32_t new_ia) |
void ppc32_set_ia(u_char **ptr,m_uint32_t new_ia) |
112 |
{ |
{ |
113 |
amd64_mov_membase_imm(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,ia),new_ia,4); |
amd64_mov_membase_imm(*ptr,AMD64_R15,OFFSET(cpu_ppc_t,ia),new_ia,4); |
114 |
} |
} |
115 |
|
|
116 |
/* Set the Link Register (LR) */ |
/* Set the Link Register (LR) */ |
117 |
void ppc32_set_lr(ppc32_jit_tcb_t *b,m_uint32_t new_lr) |
static void ppc32_set_lr(jit_op_t *iop,m_uint32_t new_lr) |
118 |
{ |
{ |
119 |
amd64_mov_membase_imm(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,lr),new_lr,4); |
amd64_mov_membase_imm(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,lr),new_lr,4); |
120 |
} |
} |
121 |
|
|
122 |
/* |
/* |
123 |
* Try to branch directly to the specified JIT block without returning to |
* Try to branch directly to the specified JIT block without returning to |
124 |
* main loop. |
* main loop. |
125 |
*/ |
*/ |
126 |
static void ppc32_try_direct_far_jump(cpu_ppc_t *cpu,ppc32_jit_tcb_t *b, |
static void ppc32_try_direct_far_jump(cpu_ppc_t *cpu,jit_op_t *iop, |
127 |
m_uint32_t new_ia) |
m_uint32_t new_ia) |
128 |
{ |
{ |
129 |
m_uint32_t new_page,ia_hash,ia_offset; |
m_uint32_t new_page,ia_hash,ia_offset; |
130 |
u_char *test1,*test2,*test3; |
u_char *test1,*test2,*test3; |
131 |
|
|
132 |
|
/* Indicate that we throw %rbx, %rdx */ |
133 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RBX); |
134 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
135 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RSI); |
136 |
|
|
137 |
new_page = new_ia & PPC32_MIN_PAGE_MASK; |
new_page = new_ia & PPC32_MIN_PAGE_MASK; |
138 |
ia_offset = (new_ia & PPC32_MIN_PAGE_IMASK) >> 2; |
ia_offset = (new_ia & PPC32_MIN_PAGE_IMASK) >> 2; |
139 |
ia_hash = ppc32_jit_get_ia_hash(new_ia); |
ia_hash = ppc32_jit_get_ia_hash(new_ia); |
140 |
|
|
141 |
/* Get JIT block info in %rdx */ |
/* Get JIT block info in %rdx */ |
142 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RBX, |
amd64_mov_reg_membase(iop->ob_ptr,AMD64_RBX, |
143 |
AMD64_R15,OFFSET(cpu_ppc_t,exec_blk_map),8); |
AMD64_R15,OFFSET(cpu_ppc_t,exec_blk_map),8); |
144 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RDX, |
amd64_mov_reg_membase(iop->ob_ptr,AMD64_RDX, |
145 |
AMD64_RBX,ia_hash*sizeof(void *),8); |
AMD64_RBX,ia_hash*sizeof(void *),8); |
146 |
|
|
147 |
/* no JIT block found ? */ |
/* no JIT block found ? */ |
148 |
amd64_test_reg_reg(b->jit_ptr,AMD64_RDX,AMD64_RDX); |
amd64_test_reg_reg(iop->ob_ptr,AMD64_RDX,AMD64_RDX); |
149 |
test1 = b->jit_ptr; |
test1 = iop->ob_ptr; |
150 |
amd64_branch8(b->jit_ptr, X86_CC_Z, 0, 1); |
amd64_branch8(iop->ob_ptr, X86_CC_Z, 0, 1); |
151 |
|
|
152 |
/* Check block IA */ |
/* Check block IA */ |
153 |
ppc32_load_imm(b,AMD64_RAX,new_page); |
ppc32_load_imm(&iop->ob_ptr,AMD64_RSI,new_page); |
154 |
amd64_alu_reg_membase_size(b->jit_ptr,X86_CMP,X86_EAX,AMD64_RDX, |
amd64_alu_reg_membase_size(iop->ob_ptr,X86_CMP,AMD64_RAX,AMD64_RDX, |
155 |
OFFSET(ppc32_jit_tcb_t,start_ia),4); |
OFFSET(ppc32_jit_tcb_t,start_ia),4); |
156 |
test2 = b->jit_ptr; |
test2 = iop->ob_ptr; |
157 |
amd64_branch8(b->jit_ptr, X86_CC_NE, 0, 1); |
amd64_branch8(iop->ob_ptr, X86_CC_NE, 0, 1); |
158 |
|
|
159 |
/* Jump to the code */ |
/* Jump to the code */ |
160 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RSI, |
amd64_mov_reg_membase(iop->ob_ptr,AMD64_RSI, |
161 |
AMD64_RDX,OFFSET(ppc32_jit_tcb_t,jit_insn_ptr),8); |
AMD64_RDX,OFFSET(ppc32_jit_tcb_t,jit_insn_ptr),8); |
162 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RBX, |
amd64_mov_reg_membase(iop->ob_ptr,AMD64_RBX, |
163 |
AMD64_RSI,ia_offset * sizeof(void *),8); |
AMD64_RSI,ia_offset * sizeof(void *),8); |
164 |
|
|
165 |
amd64_test_reg_reg(b->jit_ptr,AMD64_RBX,AMD64_RBX); |
amd64_test_reg_reg(iop->ob_ptr,AMD64_RBX,AMD64_RBX); |
166 |
test3 = b->jit_ptr; |
test3 = iop->ob_ptr; |
167 |
amd64_branch8(b->jit_ptr, X86_CC_Z, 0, 1); |
amd64_branch8(iop->ob_ptr, X86_CC_Z, 0, 1); |
168 |
amd64_jump_reg(b->jit_ptr,AMD64_RBX); |
amd64_jump_reg(iop->ob_ptr,AMD64_RBX); |
169 |
|
|
170 |
/* Returns to caller... */ |
/* Returns to caller... */ |
171 |
amd64_patch(test1,b->jit_ptr); |
amd64_patch(test1,iop->ob_ptr); |
172 |
amd64_patch(test2,b->jit_ptr); |
amd64_patch(test2,iop->ob_ptr); |
173 |
amd64_patch(test3,b->jit_ptr); |
amd64_patch(test3,iop->ob_ptr); |
174 |
|
|
175 |
ppc32_set_ia(b,new_ia); |
ppc32_set_ia(&iop->ob_ptr,new_ia); |
176 |
ppc32_jit_tcb_push_epilog(b); |
ppc32_jit_tcb_push_epilog(&iop->ob_ptr); |
177 |
} |
} |
178 |
|
|
179 |
/* Set Jump */ |
/* Set Jump */ |
180 |
static void ppc32_set_jump(cpu_ppc_t *cpu,ppc32_jit_tcb_t *b, |
static void ppc32_set_jump(cpu_ppc_t *cpu,ppc32_jit_tcb_t *b,jit_op_t *iop, |
181 |
m_uint32_t new_ia,int local_jump) |
m_uint32_t new_ia,int local_jump) |
182 |
{ |
{ |
183 |
int return_to_caller = FALSE; |
int return_to_caller = FALSE; |
189 |
#endif |
#endif |
190 |
|
|
191 |
if (!return_to_caller && ppc32_jit_tcb_local_addr(b,new_ia,&jump_ptr)) { |
if (!return_to_caller && ppc32_jit_tcb_local_addr(b,new_ia,&jump_ptr)) { |
192 |
if (jump_ptr) { |
ppc32_jit_tcb_record_patch(b,iop,iop->ob_ptr,new_ia); |
193 |
amd64_jump_code(b->jit_ptr,jump_ptr); |
amd64_jump32(iop->ob_ptr,0); |
|
} else { |
|
|
ppc32_jit_tcb_record_patch(b,b->jit_ptr,new_ia); |
|
|
amd64_jump32(b->jit_ptr,0); |
|
|
} |
|
194 |
} else { |
} else { |
195 |
if (cpu->exec_blk_direct_jump) { |
if (cpu->exec_blk_direct_jump) { |
196 |
/* Block lookup optimization */ |
/* Block lookup optimization */ |
197 |
ppc32_try_direct_far_jump(cpu,b,new_ia); |
ppc32_try_direct_far_jump(cpu,iop,new_ia); |
198 |
} else { |
} else { |
199 |
ppc32_set_ia(b,new_ia); |
ppc32_set_ia(&iop->ob_ptr,new_ia); |
200 |
ppc32_jit_tcb_push_epilog(b); |
ppc32_jit_tcb_push_epilog(&iop->ob_ptr); |
201 |
} |
} |
202 |
} |
} |
203 |
} |
} |
204 |
|
|
205 |
|
/* Jump to the next page */ |
206 |
|
void ppc32_set_page_jump(cpu_ppc_t *cpu,ppc32_jit_tcb_t *b) |
207 |
|
{ |
208 |
|
jit_op_t *iop,*op_list = NULL; |
209 |
|
|
210 |
|
cpu->gen->jit_op_current = &op_list; |
211 |
|
|
212 |
|
iop = ppc32_op_emit_insn_output(cpu,4,"set_page_jump"); |
213 |
|
ppc32_set_jump(cpu,b,iop,b->start_ia + PPC32_MIN_PAGE_SIZE,FALSE); |
214 |
|
ppc32_op_insn_output(b,iop); |
215 |
|
|
216 |
|
jit_op_free_list(cpu->gen,op_list); |
217 |
|
cpu->gen->jit_op_current = NULL; |
218 |
|
} |
219 |
|
|
220 |
/* Load a GPR into the specified host register */ |
/* Load a GPR into the specified host register */ |
221 |
static forced_inline void ppc32_load_gpr(ppc32_jit_tcb_t *b,u_int host_reg, |
static forced_inline void ppc32_load_gpr(u_char **ptr,u_int host_reg, |
222 |
u_int ppc_reg) |
u_int ppc_reg) |
223 |
{ |
{ |
224 |
amd64_mov_reg_membase(b->jit_ptr,host_reg,AMD64_R15,REG_OFFSET(ppc_reg),4); |
amd64_mov_reg_membase(*ptr,host_reg,AMD64_R15,REG_OFFSET(ppc_reg),4); |
225 |
} |
} |
226 |
|
|
227 |
/* Store contents for a host register into a GPR register */ |
/* Store contents for a host register into a GPR register */ |
228 |
static forced_inline void ppc32_store_gpr(ppc32_jit_tcb_t *b,u_int ppc_reg, |
static forced_inline void ppc32_store_gpr(u_char **ptr,u_int ppc_reg, |
229 |
u_int host_reg) |
u_int host_reg) |
230 |
{ |
{ |
231 |
amd64_mov_membase_reg(b->jit_ptr,AMD64_R15,REG_OFFSET(ppc_reg),host_reg,4); |
amd64_mov_membase_reg(*ptr,AMD64_R15,REG_OFFSET(ppc_reg),host_reg,4); |
232 |
} |
} |
233 |
|
|
234 |
/* Apply an ALU operation on a GPR register and a host register */ |
/* Apply an ALU operation on a GPR register and a host register */ |
235 |
static forced_inline void ppc32_alu_gpr(ppc32_jit_tcb_t *b,u_int op, |
static forced_inline void ppc32_alu_gpr(u_char **ptr,u_int op, |
236 |
u_int host_reg,u_int ppc_reg) |
u_int host_reg,u_int ppc_reg) |
237 |
{ |
{ |
238 |
amd64_alu_reg_membase_size(b->jit_ptr,op,host_reg, |
amd64_alu_reg_membase_size(*ptr,op,host_reg, |
239 |
AMD64_R15,REG_OFFSET(ppc_reg),4); |
AMD64_R15,REG_OFFSET(ppc_reg),4); |
240 |
} |
} |
241 |
|
|
280 |
ppc32_update_cr(b,0,TRUE); |
ppc32_update_cr(b,0,TRUE); |
281 |
} |
} |
282 |
|
|
283 |
|
/* Indicate registers modified by ppc32_update_cr() functions */ |
284 |
|
void ppc32_update_cr_set_altered_hreg(cpu_ppc_t *cpu) |
285 |
|
{ |
286 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RAX); |
287 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
288 |
|
} |
289 |
|
|
290 |
/* Basic C call */ |
/* Basic C call */ |
291 |
static forced_inline void ppc32_emit_basic_c_call(ppc32_jit_tcb_t *b,void *f) |
static forced_inline void ppc32_emit_basic_c_call(u_char **ptr,void *f) |
292 |
{ |
{ |
293 |
amd64_mov_reg_imm(b->jit_ptr,AMD64_RCX,f); |
amd64_mov_reg_imm(*ptr,AMD64_RBX,f); |
294 |
amd64_call_reg(b->jit_ptr,AMD64_RCX); |
amd64_call_reg(*ptr,AMD64_RBX); |
295 |
} |
} |
296 |
|
|
297 |
/* Emit a simple call to a C function without any parameter */ |
/* Emit a simple call to a C function without any parameter */ |
298 |
static void ppc32_emit_c_call(ppc32_jit_tcb_t *b,void *f) |
static void ppc32_emit_c_call(ppc32_jit_tcb_t *b,jit_op_t *iop,void *f) |
299 |
{ |
{ |
300 |
ppc32_set_ia(b,b->start_ia+((b->ppc_trans_pos-1)<<2)); |
ppc32_set_ia(&iop->ob_ptr,b->start_ia+(b->ppc_trans_pos << 2)); |
301 |
ppc32_emit_basic_c_call(b,f); |
ppc32_emit_basic_c_call(&iop->ob_ptr,f); |
302 |
|
} |
303 |
|
|
304 |
|
/* ======================================================================== */ |
305 |
|
|
306 |
|
/* Initialize register mapping */ |
307 |
|
void ppc32_jit_init_hreg_mapping(cpu_ppc_t *cpu) |
308 |
|
{ |
309 |
|
int avail_hregs[] = { AMD64_RSI, AMD64_RAX, AMD64_RCX, AMD64_RDX, |
310 |
|
AMD64_R13, AMD64_R14, AMD64_RDI, -1 }; |
311 |
|
struct hreg_map *map; |
312 |
|
int i,hreg; |
313 |
|
|
314 |
|
cpu->hreg_map_list = cpu->hreg_lru = NULL; |
315 |
|
|
316 |
|
/* Add the available registers to the map list */ |
317 |
|
for(i=0;avail_hregs[i]!=-1;i++) { |
318 |
|
hreg = avail_hregs[i]; |
319 |
|
map = &cpu->hreg_map[hreg]; |
320 |
|
|
321 |
|
/* Initialize mapping. At the beginning, no PPC reg is mapped */ |
322 |
|
map->flags = 0; |
323 |
|
map->hreg = hreg; |
324 |
|
map->vreg = -1; |
325 |
|
ppc32_jit_insert_hreg_mru(cpu,map); |
326 |
|
} |
327 |
|
|
328 |
|
/* Clear PPC registers mapping */ |
329 |
|
for(i=0;i<PPC32_GPR_NR;i++) |
330 |
|
cpu->ppc_reg_map[i] = -1; |
331 |
|
} |
332 |
|
|
333 |
|
/* Allocate a specific temp register */ |
334 |
|
static int ppc32_jit_get_tmp_hreg(cpu_ppc_t *cpu) |
335 |
|
{ |
336 |
|
return(AMD64_RBX); |
337 |
|
} |
338 |
|
|
339 |
|
/* ======================================================================== */ |
340 |
|
/* JIT operations (specific to target CPU). */ |
341 |
|
/* ======================================================================== */ |
342 |
|
|
343 |
|
/* INSN_OUTPUT */ |
344 |
|
void ppc32_op_insn_output(ppc32_jit_tcb_t *b,jit_op_t *op) |
345 |
|
{ |
346 |
|
op->ob_final = b->jit_ptr; |
347 |
|
memcpy(b->jit_ptr,op->ob_data,op->ob_ptr - op->ob_data); |
348 |
|
b->jit_ptr += op->ob_ptr - op->ob_data; |
349 |
|
} |
350 |
|
|
351 |
|
/* LOAD_GPR: p[0] = %host_reg, p[1] = %ppc_reg */ |
352 |
|
void ppc32_op_load_gpr(ppc32_jit_tcb_t *b,jit_op_t *op) |
353 |
|
{ |
354 |
|
if (op->param[0] != JIT_OP_INV_REG) |
355 |
|
ppc32_load_gpr(&b->jit_ptr,op->param[0],op->param[1]); |
356 |
} |
} |
357 |
|
|
358 |
|
/* STORE_GPR: p[0] = %host_reg, p[1] = %ppc_reg */ |
359 |
|
void ppc32_op_store_gpr(ppc32_jit_tcb_t *b,jit_op_t *op) |
360 |
|
{ |
361 |
|
if (op->param[0] != JIT_OP_INV_REG) |
362 |
|
ppc32_store_gpr(&b->jit_ptr,op->param[1],op->param[0]); |
363 |
|
} |
364 |
|
|
365 |
|
/* UPDATE_FLAGS: p[0] = cr_field, p[1] = is_signed */ |
366 |
|
void ppc32_op_update_flags(ppc32_jit_tcb_t *b,jit_op_t *op) |
367 |
|
{ |
368 |
|
if (op->param[0] != JIT_OP_INV_REG) |
369 |
|
ppc32_update_cr(b,op->param[0],op->param[1]); |
370 |
|
} |
371 |
|
|
372 |
|
/* MOVE_HOST_REG: p[0] = %host_dst_reg, p[1] = %host_src_reg */ |
373 |
|
void ppc32_op_move_host_reg(ppc32_jit_tcb_t *b,jit_op_t *op) |
374 |
|
{ |
375 |
|
if ((op->param[0] != JIT_OP_INV_REG) && (op->param[1] != JIT_OP_INV_REG)) |
376 |
|
amd64_mov_reg_reg(b->jit_ptr,op->param[0],op->param[1],4); |
377 |
|
} |
378 |
|
|
379 |
|
/* SET_HOST_REG_IMM32: p[0] = %host_reg, p[1] = imm32 */ |
380 |
|
void ppc32_op_set_host_reg_imm32(ppc32_jit_tcb_t *b,jit_op_t *op) |
381 |
|
{ |
382 |
|
if (op->param[0] != JIT_OP_INV_REG) |
383 |
|
ppc32_load_imm(&b->jit_ptr,op->param[0],op->param[1]); |
384 |
|
} |
385 |
|
|
386 |
|
/* ======================================================================== */ |
387 |
|
|
388 |
/* Memory operation */ |
/* Memory operation */ |
389 |
static void ppc32_emit_memop(ppc32_jit_tcb_t *b,int op,int base,int offset, |
static void ppc32_emit_memop(cpu_ppc_t *cpu,ppc32_jit_tcb_t *b, |
390 |
int target,int update) |
int op,int base,int offset,int target,int update) |
391 |
{ |
{ |
392 |
m_uint32_t val = sign_extend(offset,16); |
m_uint32_t val = sign_extend(offset,16); |
393 |
u_char *test1; |
u_char *test1; |
394 |
|
jit_op_t *iop; |
395 |
|
|
396 |
|
/* |
397 |
|
* Since an exception can be triggered, clear JIT state. This allows |
398 |
|
* to use branch target tag (we can directly branch on this instruction). |
399 |
|
*/ |
400 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_BRANCH_TARGET); |
401 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_EOB); |
402 |
|
|
403 |
|
iop = ppc32_op_emit_insn_output(cpu,5,"memop"); |
404 |
|
|
405 |
/* Save PC for exception handling */ |
/* Save PC for exception handling */ |
406 |
ppc32_set_ia(b,b->start_ia+((b->ppc_trans_pos-1)<<2)); |
ppc32_set_ia(&iop->ob_ptr,b->start_ia+(b->ppc_trans_pos << 2)); |
407 |
|
|
408 |
/* RSI = sign-extended offset */ |
/* RSI = sign-extended offset */ |
409 |
ppc32_load_imm(b,AMD64_RSI,val); |
ppc32_load_imm(&iop->ob_ptr,AMD64_RSI,val); |
410 |
|
|
411 |
/* RSI = GPR[base] + sign-extended offset */ |
/* RSI = GPR[base] + sign-extended offset */ |
412 |
if (update || (base != 0)) |
if (update || (base != 0)) |
413 |
ppc32_alu_gpr(b,X86_ADD,AMD64_RSI,base); |
ppc32_alu_gpr(&iop->ob_ptr,X86_ADD,AMD64_RSI,base); |
414 |
|
|
415 |
if (update) |
if (update) |
416 |
amd64_mov_reg_reg(b->jit_ptr,AMD64_R14,AMD64_RSI,4); |
amd64_mov_reg_reg(iop->ob_ptr,AMD64_R14,AMD64_RSI,4); |
417 |
|
|
418 |
/* RDX = target register */ |
/* RDX = target register */ |
419 |
amd64_mov_reg_imm(b->jit_ptr,AMD64_RDX,target); |
amd64_mov_reg_imm(iop->ob_ptr,AMD64_RDX,target); |
420 |
|
|
421 |
/* RDI = CPU instance pointer */ |
/* RDI = CPU instance pointer */ |
422 |
amd64_mov_reg_reg(b->jit_ptr,AMD64_RDI,AMD64_R15,8); |
amd64_mov_reg_reg(iop->ob_ptr,AMD64_RDI,AMD64_R15,8); |
423 |
|
|
424 |
/* Call memory function */ |
/* Call memory function */ |
425 |
amd64_call_membase(b->jit_ptr,AMD64_R15,MEMOP_OFFSET(op)); |
amd64_call_membase(iop->ob_ptr,AMD64_R15,MEMOP_OFFSET(op)); |
426 |
|
|
427 |
/* Exception ? */ |
/* Exception ? */ |
428 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RAX,AMD64_RAX,4); |
amd64_test_reg_reg_size(iop->ob_ptr,AMD64_RAX,AMD64_RAX,4); |
429 |
test1 = b->jit_ptr; |
test1 = iop->ob_ptr; |
430 |
amd64_branch8(b->jit_ptr, X86_CC_Z, 0, 1); |
amd64_branch8(iop->ob_ptr, X86_CC_Z, 0, 1); |
431 |
ppc32_jit_tcb_push_epilog(b); |
ppc32_jit_tcb_push_epilog(&iop->ob_ptr); |
432 |
amd64_patch(test1,b->jit_ptr); |
amd64_patch(test1,iop->ob_ptr); |
433 |
|
|
434 |
if (update) |
if (update) |
435 |
ppc32_store_gpr(b,base,AMD64_R14); |
ppc32_store_gpr(&iop->ob_ptr,base,AMD64_R14); |
436 |
} |
} |
437 |
|
|
438 |
/* Memory operation (indexed) */ |
/* Memory operation (indexed) */ |
439 |
static void ppc32_emit_memop_idx(ppc32_jit_tcb_t *b,int op,int ra,int rb, |
static void ppc32_emit_memop_idx(cpu_ppc_t *cpu,ppc32_jit_tcb_t *b, |
440 |
int target,int update) |
int op,int ra,int rb,int target,int update) |
441 |
{ |
{ |
442 |
u_char *test1; |
u_char *test1; |
443 |
|
jit_op_t *iop; |
444 |
|
|
445 |
|
/* |
446 |
|
* Since an exception can be triggered, clear JIT state. This allows |
447 |
|
* to use branch target tag (we can directly branch on this instruction). |
448 |
|
*/ |
449 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_BRANCH_TARGET); |
450 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_EOB); |
451 |
|
|
452 |
|
iop = ppc32_op_emit_insn_output(cpu,5,"memop_idx"); |
453 |
|
|
454 |
/* Save PC for exception handling */ |
/* Save PC for exception handling */ |
455 |
ppc32_set_ia(b,b->start_ia+((b->ppc_trans_pos-1)<<2)); |
ppc32_set_ia(&iop->ob_ptr,b->start_ia+(b->ppc_trans_pos << 2)); |
456 |
|
|
457 |
/* RSI = $rb */ |
/* RSI = $rb */ |
458 |
ppc32_load_gpr(b,AMD64_RSI,rb); |
ppc32_load_gpr(&iop->ob_ptr,AMD64_RSI,rb); |
459 |
|
|
460 |
/* RSI = GPR[base] + sign-extended offset */ |
/* RSI = GPR[base] + sign-extended offset */ |
461 |
if (update || (ra != 0)) |
if (update || (ra != 0)) |
462 |
ppc32_alu_gpr(b,X86_ADD,AMD64_RSI,ra); |
ppc32_alu_gpr(&iop->ob_ptr,X86_ADD,AMD64_RSI,ra); |
463 |
|
|
464 |
if (update) |
if (update) |
465 |
amd64_mov_reg_reg(b->jit_ptr,AMD64_R14,AMD64_RSI,4); |
amd64_mov_reg_reg(iop->ob_ptr,AMD64_R14,AMD64_RSI,4); |
466 |
|
|
467 |
/* RDX = target register */ |
/* RDX = target register */ |
468 |
amd64_mov_reg_imm(b->jit_ptr,AMD64_RDX,target); |
amd64_mov_reg_imm(iop->ob_ptr,AMD64_RDX,target); |
469 |
|
|
470 |
/* RDI = CPU instance pointer */ |
/* RDI = CPU instance pointer */ |
471 |
amd64_mov_reg_reg(b->jit_ptr,AMD64_RDI,AMD64_R15,8); |
amd64_mov_reg_reg(iop->ob_ptr,AMD64_RDI,AMD64_R15,8); |
472 |
|
|
473 |
/* Call memory function */ |
/* Call memory function */ |
474 |
amd64_call_membase(b->jit_ptr,AMD64_R15,MEMOP_OFFSET(op)); |
amd64_call_membase(iop->ob_ptr,AMD64_R15,MEMOP_OFFSET(op)); |
475 |
|
|
476 |
/* Exception ? */ |
/* Exception ? */ |
477 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RAX,AMD64_RAX,4); |
amd64_test_reg_reg_size(iop->ob_ptr,AMD64_RAX,AMD64_RAX,4); |
478 |
test1 = b->jit_ptr; |
test1 = iop->ob_ptr; |
479 |
amd64_branch8(b->jit_ptr, X86_CC_Z, 0, 1); |
amd64_branch8(iop->ob_ptr, X86_CC_Z, 0, 1); |
480 |
ppc32_jit_tcb_push_epilog(b); |
ppc32_jit_tcb_push_epilog(&iop->ob_ptr); |
481 |
amd64_patch(test1,b->jit_ptr); |
amd64_patch(test1,iop->ob_ptr); |
482 |
|
|
483 |
if (update) |
if (update) |
484 |
ppc32_store_gpr(b,ra,AMD64_R14); |
ppc32_store_gpr(&iop->ob_ptr,ra,AMD64_R14); |
485 |
} |
} |
486 |
|
|
487 |
typedef void (*memop_fast_access)(ppc32_jit_tcb_t *b,int target); |
typedef void (*memop_fast_access)(jit_op_t *iop,int target); |
488 |
|
|
489 |
/* Fast LBZ */ |
/* Fast LBZ */ |
490 |
static void ppc32_memop_fast_lbz(ppc32_jit_tcb_t *b,int target) |
static void ppc32_memop_fast_lbz(jit_op_t *iop,int target) |
491 |
{ |
{ |
492 |
amd64_clear_reg(b->jit_ptr,AMD64_RCX); |
amd64_clear_reg(iop->ob_ptr,AMD64_RCX); |
493 |
amd64_mov_reg_memindex(b->jit_ptr,AMD64_RCX,AMD64_RBX,0,AMD64_RSI,0,1); |
amd64_mov_reg_memindex(iop->ob_ptr,AMD64_RCX,AMD64_RBX,0,AMD64_RSI,0,1); |
494 |
ppc32_store_gpr(b,target,AMD64_RCX); |
ppc32_store_gpr(&iop->ob_ptr,target,AMD64_RCX); |
495 |
} |
} |
496 |
|
|
497 |
/* Fast STB */ |
/* Fast STB */ |
498 |
static void ppc32_memop_fast_stb(ppc32_jit_tcb_t *b,int target) |
static void ppc32_memop_fast_stb(jit_op_t *iop,int target) |
499 |
{ |
{ |
500 |
ppc32_load_gpr(b,AMD64_RDX,target); |
ppc32_load_gpr(&iop->ob_ptr,AMD64_RDX,target); |
501 |
amd64_mov_memindex_reg(b->jit_ptr,AMD64_RBX,0,AMD64_RSI,0,AMD64_RDX,1); |
amd64_mov_memindex_reg(iop->ob_ptr,AMD64_RBX,0,AMD64_RSI,0,AMD64_RDX,1); |
502 |
} |
} |
503 |
|
|
504 |
/* Fast LWZ */ |
/* Fast LWZ */ |
505 |
static void ppc32_memop_fast_lwz(ppc32_jit_tcb_t *b,int target) |
static void ppc32_memop_fast_lwz(jit_op_t *iop,int target) |
506 |
{ |
{ |
507 |
amd64_mov_reg_memindex(b->jit_ptr,AMD64_RAX,AMD64_RBX,0,AMD64_RSI,0,4); |
amd64_mov_reg_memindex(iop->ob_ptr,AMD64_RAX,AMD64_RBX,0,AMD64_RSI,0,4); |
508 |
amd64_bswap32(b->jit_ptr,AMD64_RAX); |
amd64_bswap32(iop->ob_ptr,AMD64_RAX); |
509 |
ppc32_store_gpr(b,target,AMD64_RAX); |
ppc32_store_gpr(&iop->ob_ptr,target,AMD64_RAX); |
510 |
} |
} |
511 |
|
|
512 |
/* Fast STW */ |
/* Fast STW */ |
513 |
static void ppc32_memop_fast_stw(ppc32_jit_tcb_t *b,int target) |
static void ppc32_memop_fast_stw(jit_op_t *iop,int target) |
514 |
{ |
{ |
515 |
ppc32_load_gpr(b,AMD64_RDX,target); |
ppc32_load_gpr(&iop->ob_ptr,AMD64_RDX,target); |
516 |
amd64_bswap32(b->jit_ptr,AMD64_RDX); |
amd64_bswap32(iop->ob_ptr,AMD64_RDX); |
517 |
amd64_mov_memindex_reg(b->jit_ptr,AMD64_RBX,0,AMD64_RSI,0,AMD64_RDX,4); |
amd64_mov_memindex_reg(iop->ob_ptr,AMD64_RBX,0,AMD64_RSI,0,AMD64_RDX,4); |
518 |
} |
} |
519 |
|
|
520 |
/* Fast memory operation */ |
/* Fast memory operation */ |
521 |
static void ppc32_emit_memop_fast(ppc32_jit_tcb_t *b,int write_op, |
static void ppc32_emit_memop_fast(cpu_ppc_t *cpu,ppc32_jit_tcb_t *b, |
522 |
int opcode,int base,int offset,int target, |
int write_op,int opcode, |
523 |
|
int base,int offset,int target, |
524 |
memop_fast_access op_handler) |
memop_fast_access op_handler) |
525 |
{ |
{ |
526 |
m_uint32_t val = sign_extend(offset,16); |
m_uint32_t val = sign_extend(offset,16); |
527 |
u_char *test1,*test2,*p_exception,*p_exit; |
u_char *test1,*test2,*p_exception,*p_exit; |
528 |
|
jit_op_t *iop; |
529 |
|
|
530 |
|
/* |
531 |
|
* Since an exception can be triggered, clear JIT state. This allows |
532 |
|
* to use branch target tag (we can directly branch on this instruction). |
533 |
|
*/ |
534 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_BRANCH_TARGET); |
535 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_EOB); |
536 |
|
|
537 |
|
iop = ppc32_op_emit_insn_output(cpu,5,"memop_fast"); |
538 |
|
|
539 |
test2 = NULL; |
test2 = NULL; |
540 |
|
|
541 |
/* RSI = GPR[base] + sign-extended offset */ |
/* RSI = GPR[base] + sign-extended offset */ |
542 |
ppc32_load_imm(b,AMD64_RSI,val); |
ppc32_load_imm(&iop->ob_ptr,AMD64_RSI,val); |
543 |
if (base != 0) |
if (base != 0) |
544 |
ppc32_alu_gpr(b,X86_ADD,AMD64_RSI,base); |
ppc32_alu_gpr(&iop->ob_ptr,X86_ADD,AMD64_RSI,base); |
545 |
|
|
546 |
/* RBX = mts32_entry index */ |
/* RBX = mts32_entry index */ |
547 |
amd64_mov_reg_reg_size(b->jit_ptr,X86_EBX,X86_ESI,4); |
amd64_mov_reg_reg_size(iop->ob_ptr,X86_EBX,X86_ESI,4); |
548 |
amd64_shift_reg_imm_size(b->jit_ptr,X86_SHR,X86_EBX,MTS32_HASH_SHIFT,4); |
amd64_shift_reg_imm_size(iop->ob_ptr,X86_SHR,X86_EBX,MTS32_HASH_SHIFT,4); |
549 |
amd64_alu_reg_imm_size(b->jit_ptr,X86_AND,X86_EBX,MTS32_HASH_MASK,4); |
amd64_alu_reg_imm_size(iop->ob_ptr,X86_AND,X86_EBX,MTS32_HASH_MASK,4); |
550 |
|
|
551 |
/* RCX = mts32 entry */ |
/* RCX = mts32 entry */ |
552 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RCX, |
amd64_mov_reg_membase(iop->ob_ptr,AMD64_RCX, |
553 |
AMD64_R15, |
AMD64_R15, |
554 |
OFFSET(cpu_ppc_t,mts_cache[PPC32_MTS_DCACHE]),8); |
OFFSET(cpu_ppc_t,mts_cache[PPC32_MTS_DCACHE]),8); |
555 |
amd64_shift_reg_imm(b->jit_ptr,X86_SHL,AMD64_RBX,5); /* TO FIX */ |
amd64_shift_reg_imm(iop->ob_ptr,X86_SHL,AMD64_RBX,5); /* TO FIX */ |
556 |
amd64_alu_reg_reg(b->jit_ptr,X86_ADD,AMD64_RCX,AMD64_RBX); |
amd64_alu_reg_reg(iop->ob_ptr,X86_ADD,AMD64_RCX,AMD64_RBX); |
557 |
|
|
558 |
/* Compare virtual page address (EAX = vpage) */ |
/* Compare virtual page address (EAX = vpage) */ |
559 |
amd64_mov_reg_reg(b->jit_ptr,X86_EAX,X86_ESI,4); |
amd64_mov_reg_reg(iop->ob_ptr,X86_EAX,X86_ESI,4); |
560 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,X86_EAX,PPC32_MIN_PAGE_MASK); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,X86_EAX,PPC32_MIN_PAGE_MASK); |
561 |
|
|
562 |
amd64_alu_reg_membase_size(b->jit_ptr,X86_CMP,X86_EAX,AMD64_RCX, |
amd64_alu_reg_membase_size(iop->ob_ptr,X86_CMP,X86_EAX,AMD64_RCX, |
563 |
OFFSET(mts32_entry_t,gvpa),4); |
OFFSET(mts32_entry_t,gvpa),4); |
564 |
test1 = b->jit_ptr; |
test1 = iop->ob_ptr; |
565 |
x86_branch8(b->jit_ptr, X86_CC_NZ, 0, 1); |
amd64_branch8(iop->ob_ptr, X86_CC_NZ, 0, 1); |
566 |
|
|
567 |
/* Test if we are writing to a COW page */ |
/* Test if we are writing to a COW page */ |
568 |
if (write_op) { |
if (write_op) { |
569 |
amd64_test_membase_imm_size(b->jit_ptr, |
amd64_test_membase_imm_size(iop->ob_ptr, |
570 |
AMD64_RCX,OFFSET(mts32_entry_t,flags), |
AMD64_RCX,OFFSET(mts32_entry_t,flags), |
571 |
MTS_FLAG_COW|MTS_FLAG_EXEC,4); |
MTS_FLAG_COW|MTS_FLAG_EXEC,4); |
572 |
test2 = b->jit_ptr; |
test2 = iop->ob_ptr; |
573 |
amd64_branch8(b->jit_ptr, X86_CC_NZ, 0, 1); |
amd64_branch8(iop->ob_ptr, X86_CC_NZ, 0, 1); |
574 |
} |
} |
575 |
|
|
576 |
/* ESI = offset in page, RBX = Host Page Address */ |
/* ESI = offset in page, RBX = Host Page Address */ |
577 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,X86_ESI,PPC32_MIN_PAGE_IMASK); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,X86_ESI,PPC32_MIN_PAGE_IMASK); |
578 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RBX, |
amd64_mov_reg_membase(iop->ob_ptr,AMD64_RBX, |
579 |
AMD64_RCX,OFFSET(mts32_entry_t,hpa),8); |
AMD64_RCX,OFFSET(mts32_entry_t,hpa),8); |
580 |
|
|
581 |
/* Memory access */ |
/* Memory access */ |
582 |
op_handler(b,target); |
op_handler(iop,target); |
583 |
|
|
584 |
p_exit = b->jit_ptr; |
p_exit = iop->ob_ptr; |
585 |
amd64_jump8(b->jit_ptr,0); |
amd64_jump8(iop->ob_ptr,0); |
586 |
|
|
587 |
/* === Slow lookup === */ |
/* === Slow lookup === */ |
588 |
amd64_patch(test1,b->jit_ptr); |
amd64_patch(test1,iop->ob_ptr); |
589 |
if (test2) |
if (test2) |
590 |
amd64_patch(test2,b->jit_ptr); |
amd64_patch(test2,iop->ob_ptr); |
591 |
|
|
592 |
/* Save IA for exception handling */ |
/* Save IA for exception handling */ |
593 |
ppc32_set_ia(b,b->start_ia+((b->ppc_trans_pos-1)<<2)); |
ppc32_set_ia(&iop->ob_ptr,b->start_ia+(b->ppc_trans_pos << 2)); |
594 |
|
|
595 |
/* RDX = target register */ |
/* RDX = target register */ |
596 |
amd64_mov_reg_imm(b->jit_ptr,AMD64_RDX,target); |
amd64_mov_reg_imm(iop->ob_ptr,AMD64_RDX,target); |
597 |
|
|
598 |
/* RDI = CPU instance */ |
/* RDI = CPU instance */ |
599 |
amd64_mov_reg_reg(b->jit_ptr,AMD64_RDI,AMD64_R15,8); |
amd64_mov_reg_reg(iop->ob_ptr,AMD64_RDI,AMD64_R15,8); |
600 |
|
|
601 |
/* Call memory access function */ |
/* Call memory access function */ |
602 |
amd64_call_membase(b->jit_ptr,AMD64_R15,MEMOP_OFFSET(opcode)); |
amd64_call_membase(iop->ob_ptr,AMD64_R15,MEMOP_OFFSET(opcode)); |
603 |
|
|
604 |
/* Exception ? */ |
/* Exception ? */ |
605 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RAX,AMD64_RAX,4); |
amd64_test_reg_reg_size(iop->ob_ptr,AMD64_RAX,AMD64_RAX,4); |
606 |
p_exception = b->jit_ptr; |
p_exception = iop->ob_ptr; |
607 |
amd64_branch8(b->jit_ptr, X86_CC_Z, 0, 1); |
amd64_branch8(iop->ob_ptr, X86_CC_Z, 0, 1); |
608 |
ppc32_jit_tcb_push_epilog(b); |
ppc32_jit_tcb_push_epilog(&iop->ob_ptr); |
|
|
|
|
amd64_patch(p_exit,b->jit_ptr); |
|
|
amd64_patch(p_exception,b->jit_ptr); |
|
|
} |
|
609 |
|
|
610 |
/* Virtual Breakpoint */ |
amd64_patch(p_exit,iop->ob_ptr); |
611 |
void ppc32_emit_breakpoint(ppc32_jit_tcb_t *b) |
amd64_patch(p_exception,iop->ob_ptr); |
|
{ |
|
|
amd64_mov_reg_reg(b->jit_ptr,AMD64_RDI,AMD64_R15,8); |
|
|
ppc32_emit_c_call(b,ppc32_run_breakpoint); |
|
612 |
} |
} |
613 |
|
|
614 |
/* Emit unhandled instruction code */ |
/* Emit unhandled instruction code */ |
616 |
ppc_insn_t opcode) |
ppc_insn_t opcode) |
617 |
{ |
{ |
618 |
u_char *test1; |
u_char *test1; |
619 |
|
jit_op_t *iop; |
620 |
|
|
621 |
#if 0 |
iop = ppc32_op_emit_insn_output(cpu,3,"unknown"); |
622 |
x86_mov_reg_imm(b->jit_ptr,X86_EAX,opcode); |
|
623 |
x86_alu_reg_imm(b->jit_ptr,X86_SUB,X86_ESP,4); |
/* Update IA */ |
624 |
x86_push_reg(b->jit_ptr,X86_EAX); |
ppc32_set_ia(&iop->ob_ptr,b->start_ia+(b->ppc_trans_pos << 2)); |
|
x86_push_reg(b->jit_ptr,X86_EDI); |
|
|
ppc32_emit_c_call(b,ppc32_unknown_opcode); |
|
|
x86_alu_reg_imm(b->jit_ptr,X86_ADD,X86_ESP,12); |
|
|
#endif |
|
625 |
|
|
626 |
/* Fallback to non-JIT mode */ |
/* Fallback to non-JIT mode */ |
627 |
amd64_mov_reg_reg(b->jit_ptr,AMD64_RDI,AMD64_R15,8); |
amd64_mov_reg_reg(iop->ob_ptr,AMD64_RDI,AMD64_R15,8); |
628 |
amd64_mov_reg_imm(b->jit_ptr,AMD64_RSI,opcode); |
amd64_mov_reg_imm(iop->ob_ptr,AMD64_RSI,opcode); |
629 |
|
|
630 |
|
ppc32_emit_c_call(b,iop,ppc32_exec_single_insn_ext); |
631 |
|
amd64_test_reg_reg_size(iop->ob_ptr,AMD64_RAX,AMD64_RAX,4); |
632 |
|
test1 = iop->ob_ptr; |
633 |
|
amd64_branch8(iop->ob_ptr, X86_CC_Z, 0, 1); |
634 |
|
ppc32_jit_tcb_push_epilog(&iop->ob_ptr); |
635 |
|
|
636 |
ppc32_emit_c_call(b,ppc32_exec_single_insn_ext); |
amd64_patch(test1,iop->ob_ptr); |
|
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RAX,AMD64_RAX,4); |
|
|
test1 = b->jit_ptr; |
|
|
amd64_branch8(b->jit_ptr, X86_CC_Z, 0, 1); |
|
|
ppc32_jit_tcb_push_epilog(b); |
|
637 |
|
|
638 |
amd64_patch(test1,b->jit_ptr); |
/* Signal this as an EOB to reset JIT state */ |
639 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_EOB); |
640 |
return(0); |
return(0); |
641 |
} |
} |
642 |
|
|
643 |
|
/* Virtual Breakpoint */ |
644 |
|
void ppc32_emit_breakpoint(cpu_ppc_t *cpu,ppc32_jit_tcb_t *b) |
645 |
|
{ |
646 |
|
jit_op_t *iop; |
647 |
|
|
648 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"breakpoint"); |
649 |
|
|
650 |
|
amd64_mov_reg_reg(iop->ob_ptr,AMD64_RDI,AMD64_R15,8); |
651 |
|
ppc32_emit_c_call(b,iop,ppc32_run_breakpoint); |
652 |
|
|
653 |
|
/* Signal this as an EOB to to reset JIT state */ |
654 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_EOB); |
655 |
|
} |
656 |
|
|
657 |
/* Increment the number of executed instructions (performance debugging) */ |
/* Increment the number of executed instructions (performance debugging) */ |
658 |
void ppc32_inc_perf_counter(ppc32_jit_tcb_t *b) |
void ppc32_inc_perf_counter(ppc32_jit_tcb_t *b) |
659 |
{ |
{ |
665 |
/* BLR - Branch to Link Register */ |
/* BLR - Branch to Link Register */ |
666 |
DECLARE_INSN(BLR) |
DECLARE_INSN(BLR) |
667 |
{ |
{ |
668 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RDX, |
jit_op_t *iop; |
669 |
AMD64_R15,OFFSET(cpu_ppc_t,lr),4); |
int hreg; |
670 |
amd64_mov_membase_reg(b->jit_ptr, |
|
671 |
AMD64_R15,OFFSET(cpu_ppc_t,ia),AMD64_RDX,4); |
ppc32_jit_start_hreg_seq(cpu,"blr"); |
672 |
|
hreg = ppc32_jit_alloc_hreg(cpu,-1); |
673 |
|
ppc32_op_emit_alter_host_reg(cpu,hreg); |
674 |
|
|
675 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"blr"); |
676 |
|
|
677 |
|
amd64_mov_reg_membase(iop->ob_ptr,hreg,AMD64_R15,OFFSET(cpu_ppc_t,lr),4); |
678 |
|
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,ia),hreg,4); |
679 |
|
|
680 |
/* set the return address */ |
/* set the return address */ |
681 |
if (insn & 1) |
if (insn & 1) |
682 |
ppc32_set_lr(b,b->start_ia + (b->ppc_trans_pos << 2)); |
ppc32_set_lr(iop,b->start_ia + ((b->ppc_trans_pos+1) << 2)); |
683 |
|
|
684 |
|
ppc32_jit_tcb_push_epilog(&iop->ob_ptr); |
685 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_EOB); |
686 |
|
ppc32_op_emit_branch_target(cpu,b,b->start_ia+((b->ppc_trans_pos+1) << 2)); |
687 |
|
|
688 |
ppc32_jit_tcb_push_epilog(b); |
ppc32_jit_close_hreg_seq(cpu); |
689 |
return(0); |
return(0); |
690 |
} |
} |
691 |
|
|
692 |
/* BCTR - Branch to Count Register */ |
/* BCTR - Branch to Count Register */ |
693 |
DECLARE_INSN(BCTR) |
DECLARE_INSN(BCTR) |
694 |
{ |
{ |
695 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RDX, |
jit_op_t *iop; |
696 |
AMD64_R15,OFFSET(cpu_ppc_t,ctr),4); |
int hreg; |
697 |
amd64_mov_membase_reg(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,ia), |
|
698 |
AMD64_RDX,4); |
ppc32_jit_start_hreg_seq(cpu,"bctr"); |
699 |
|
hreg = ppc32_jit_alloc_hreg(cpu,-1); |
700 |
|
ppc32_op_emit_alter_host_reg(cpu,hreg); |
701 |
|
|
702 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"bctr"); |
703 |
|
|
704 |
|
amd64_mov_reg_membase(iop->ob_ptr,hreg,AMD64_R15,OFFSET(cpu_ppc_t,ctr),4); |
705 |
|
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,ia),hreg,4); |
706 |
|
|
707 |
/* set the return address */ |
/* set the return address */ |
708 |
if (insn & 1) |
if (insn & 1) |
709 |
ppc32_set_lr(b,b->start_ia + (b->ppc_trans_pos << 2)); |
ppc32_set_lr(iop,b->start_ia + (b->ppc_trans_pos << 2)); |
710 |
|
|
711 |
ppc32_jit_tcb_push_epilog(b); |
ppc32_jit_tcb_push_epilog(&iop->ob_ptr); |
712 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_EOB); |
713 |
|
ppc32_op_emit_branch_target(cpu,b,b->start_ia+((b->ppc_trans_pos+1) << 2)); |
714 |
|
|
715 |
|
ppc32_jit_close_hreg_seq(cpu); |
716 |
return(0); |
return(0); |
717 |
} |
} |
718 |
|
|
720 |
DECLARE_INSN(MFLR) |
DECLARE_INSN(MFLR) |
721 |
{ |
{ |
722 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
723 |
|
int hreg_rd; |
724 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RDX, |
jit_op_t *iop; |
725 |
AMD64_R15,OFFSET(cpu_ppc_t,lr),4); |
|
726 |
ppc32_store_gpr(b,rd,X86_EDX); |
ppc32_jit_start_hreg_seq(cpu,"mflr"); |
727 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
728 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"mflr"); |
729 |
|
|
730 |
|
amd64_mov_reg_membase(iop->ob_ptr,hreg_rd,AMD64_R15,OFFSET(cpu_ppc_t,lr),4); |
731 |
|
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
732 |
|
|
733 |
|
ppc32_jit_close_hreg_seq(cpu); |
734 |
return(0); |
return(0); |
735 |
} |
} |
736 |
|
|
738 |
DECLARE_INSN(MTLR) |
DECLARE_INSN(MTLR) |
739 |
{ |
{ |
740 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
741 |
|
int hreg_rs; |
742 |
|
jit_op_t *iop; |
743 |
|
|
744 |
|
ppc32_jit_start_hreg_seq(cpu,"mtlr"); |
745 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
746 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
747 |
|
|
748 |
ppc32_load_gpr(b,X86_EDX,rs); |
iop = ppc32_op_emit_insn_output(cpu,1,"mtlr"); |
749 |
amd64_mov_membase_reg(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,lr), |
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,lr),hreg_rs,4); |
|
AMD64_RDX,4); |
|
750 |
return(0); |
return(0); |
751 |
} |
} |
752 |
|
|
754 |
DECLARE_INSN(MFCTR) |
DECLARE_INSN(MFCTR) |
755 |
{ |
{ |
756 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
757 |
|
int hreg_rd; |
758 |
|
jit_op_t *iop; |
759 |
|
|
760 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RDX, |
ppc32_jit_start_hreg_seq(cpu,"mfctr"); |
761 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
762 |
|
|
763 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"mfctr"); |
764 |
|
|
765 |
|
amd64_mov_reg_membase(iop->ob_ptr,hreg_rd, |
766 |
AMD64_R15,OFFSET(cpu_ppc_t,ctr),4); |
AMD64_R15,OFFSET(cpu_ppc_t,ctr),4); |
767 |
ppc32_store_gpr(b,rd,AMD64_RDX); |
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
768 |
|
|
769 |
|
ppc32_jit_close_hreg_seq(cpu); |
770 |
return(0); |
return(0); |
771 |
} |
} |
772 |
|
|
774 |
DECLARE_INSN(MTCTR) |
DECLARE_INSN(MTCTR) |
775 |
{ |
{ |
776 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
777 |
|
int hreg_rs; |
778 |
|
jit_op_t *iop; |
779 |
|
|
780 |
|
ppc32_jit_start_hreg_seq(cpu,"mtctr"); |
781 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
782 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
783 |
|
|
784 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"mtctr"); |
785 |
|
|
786 |
|
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,ctr), |
787 |
|
hreg_rs,4); |
788 |
|
|
789 |
ppc32_load_gpr(b,AMD64_RDX,rs); |
ppc32_jit_close_hreg_seq(cpu); |
|
amd64_mov_membase_reg(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,ctr), |
|
|
AMD64_RDX,4); |
|
790 |
return(0); |
return(0); |
791 |
} |
} |
792 |
|
|
794 |
DECLARE_INSN(MFTBU) |
DECLARE_INSN(MFTBU) |
795 |
{ |
{ |
796 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
797 |
|
int hreg_rd; |
798 |
|
jit_op_t *iop; |
799 |
|
|
800 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RDX, |
ppc32_jit_start_hreg_seq(cpu,"mftbu"); |
801 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
802 |
|
|
803 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"mftbu"); |
804 |
|
|
805 |
|
amd64_mov_reg_membase(iop->ob_ptr,hreg_rd, |
806 |
AMD64_R15,OFFSET(cpu_ppc_t,tb)+4,4); |
AMD64_R15,OFFSET(cpu_ppc_t,tb)+4,4); |
807 |
ppc32_store_gpr(b,rd,AMD64_RDX); |
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
808 |
|
|
809 |
|
ppc32_jit_close_hreg_seq(cpu); |
810 |
return(0); |
return(0); |
811 |
} |
} |
812 |
|
|
816 |
DECLARE_INSN(MFTBL) |
DECLARE_INSN(MFTBL) |
817 |
{ |
{ |
818 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
819 |
|
int hreg_rd; |
820 |
|
jit_op_t *iop; |
821 |
|
|
822 |
|
ppc32_jit_start_hreg_seq(cpu,"mftbl"); |
823 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
824 |
|
|
825 |
/* Increment the time base register */ |
iop = ppc32_op_emit_insn_output(cpu,3,"mftbl"); |
826 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RDX, |
|
827 |
|
amd64_mov_reg_membase(iop->ob_ptr,hreg_rd, |
828 |
AMD64_R15,OFFSET(cpu_ppc_t,tb),8); |
AMD64_R15,OFFSET(cpu_ppc_t,tb),8); |
829 |
amd64_alu_reg_imm(b->jit_ptr,X86_ADD,AMD64_RDX,PPC32_TB_INCREMENT); |
amd64_alu_reg_imm(iop->ob_ptr,X86_ADD,hreg_rd,PPC32_TB_INCREMENT); |
830 |
amd64_mov_membase_reg(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,tb), |
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,tb), |
831 |
AMD64_RDX,8); |
hreg_rd,8); |
832 |
|
|
833 |
|
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
834 |
|
|
835 |
ppc32_store_gpr(b,rd,AMD64_RDX); |
ppc32_jit_close_hreg_seq(cpu); |
836 |
return(0); |
return(0); |
837 |
} |
} |
838 |
|
|
842 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
843 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
844 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
845 |
|
int hreg_rd,hreg_ra,hreg_rb; |
846 |
|
jit_op_t *iop; |
847 |
|
|
848 |
/* $rd = $ra + $rb */ |
/* $rd = $ra + $rb */ |
849 |
ppc32_load_gpr(b,AMD64_RBX,ra); |
ppc32_jit_start_hreg_seq(cpu,"add"); |
850 |
ppc32_alu_gpr(b,X86_ADD,AMD64_RBX,rb); |
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
851 |
ppc32_store_gpr(b,rd,AMD64_RBX); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
852 |
|
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
853 |
|
|
854 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
855 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
856 |
|
|
857 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"add"); |
858 |
|
|
859 |
|
if (rd == ra) |
860 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_ADD,hreg_rd,hreg_rb,4); |
861 |
|
else if (rd == rb) |
862 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_ADD,hreg_rd,hreg_ra,4); |
863 |
|
else { |
864 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_rd,hreg_ra,4); |
865 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_ADD,hreg_rd,hreg_rb,4); |
866 |
|
} |
867 |
|
|
868 |
|
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
869 |
|
|
870 |
if (insn & 1) |
if (insn & 1) |
871 |
ppc32_update_cr0(b); |
ppc32_op_emit_update_flags(cpu,0,TRUE); |
872 |
|
|
873 |
|
ppc32_jit_close_hreg_seq(cpu); |
874 |
return(0); |
return(0); |
875 |
} |
} |
876 |
|
|
880 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
881 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
882 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
883 |
|
int hreg_rd,hreg_ra,hreg_rb,hreg_t0; |
884 |
|
jit_op_t *iop; |
885 |
|
|
886 |
/* $rd = $ra + $rb */ |
/* $rd = $ra + $rb */ |
887 |
ppc32_load_gpr(b,AMD64_RBX,ra); |
ppc32_jit_start_hreg_seq(cpu,"addc"); |
888 |
ppc32_alu_gpr(b,X86_ADD,AMD64_RBX,rb); |
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
889 |
ppc32_store_gpr(b,rd,AMD64_RBX); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
890 |
|
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
891 |
|
|
892 |
/* store the carry flag */ |
/* store the carry flag */ |
893 |
amd64_set_reg(b->jit_ptr,X86_CC_C,AMD64_RAX,FALSE); |
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
894 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RAX,0x1); |
|
895 |
amd64_mov_membase_reg(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
896 |
AMD64_RAX,4); |
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
897 |
|
|
898 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"addc"); |
899 |
|
|
900 |
|
if (rd == ra) |
901 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_ADD,hreg_rd,hreg_rb,4); |
902 |
|
else if (rd == rb) |
903 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_ADD,hreg_rd,hreg_ra,4); |
904 |
|
else { |
905 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_rd,hreg_ra,4); |
906 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_ADD,hreg_rd,hreg_rb,4); |
907 |
|
} |
908 |
|
|
909 |
|
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
910 |
|
|
911 |
|
/* store the carry flag */ |
912 |
|
amd64_set_reg(iop->ob_ptr,X86_CC_C,hreg_t0,FALSE); |
913 |
|
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,0x1); |
914 |
|
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
915 |
|
hreg_t0,4); |
916 |
|
|
917 |
if (insn & 1) { |
if (insn & 1) { |
918 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RBX,AMD64_RBX,4); |
amd64_test_reg_reg_size(iop->ob_ptr,hreg_rd,hreg_rd,4); |
919 |
ppc32_update_cr0(b); |
ppc32_op_emit_update_flags(cpu,0,TRUE); |
920 |
} |
} |
921 |
|
|
922 |
|
ppc32_jit_close_hreg_seq(cpu); |
923 |
return(0); |
return(0); |
924 |
} |
} |
925 |
|
|
929 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
930 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
931 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
932 |
|
int hreg_ra,hreg_rb,hreg_rd,hreg_t0,hreg_t1; |
933 |
|
jit_op_t *iop; |
934 |
|
|
935 |
/* $ra + carry */ |
ppc32_jit_start_hreg_seq(cpu,"adde"); |
936 |
ppc32_load_gpr(b,AMD64_RSI,ra); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
937 |
amd64_alu_reg_membase_size(b->jit_ptr,X86_ADD,AMD64_RSI, |
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
938 |
AMD64_R15,OFFSET(cpu_ppc_t,xer_ca),4); |
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
|
amd64_set_reg(b->jit_ptr,X86_CC_C,AMD64_RAX,FALSE); |
|
939 |
|
|
940 |
/* add $rb */ |
hreg_t0 = ppc32_jit_alloc_hreg(cpu,-1); |
941 |
ppc32_alu_gpr(b,X86_ADD,AMD64_RSI,rb); |
hreg_t1 = ppc32_jit_get_tmp_hreg(cpu); |
|
amd64_set_reg(b->jit_ptr,X86_CC_C,AMD64_RCX,FALSE); |
|
942 |
|
|
943 |
ppc32_store_gpr(b,rd,AMD64_RSI); |
ppc32_op_emit_alter_host_reg(cpu,hreg_t0); |
944 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
945 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
946 |
|
|
947 |
/* store the carry flag */ |
iop = ppc32_op_emit_insn_output(cpu,3,"adde"); |
|
amd64_alu_reg_reg(b->jit_ptr,X86_OR,AMD64_RAX,AMD64_RCX); |
|
|
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RAX,0x1); |
|
948 |
|
|
949 |
amd64_mov_membase_reg(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
/* $t0 = $ra + carry */ |
950 |
AMD64_RAX,4); |
amd64_alu_reg_reg(iop->ob_ptr,X86_XOR,hreg_t1,hreg_t1); |
951 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_t0,hreg_ra,4); |
952 |
|
|
953 |
|
amd64_alu_reg_membase_size(iop->ob_ptr,X86_ADD,hreg_t0, |
954 |
|
AMD64_R15,OFFSET(cpu_ppc_t,xer_ca),4); |
955 |
|
amd64_set_reg(iop->ob_ptr,X86_CC_C,hreg_t1,FALSE); |
956 |
|
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
957 |
|
hreg_t1,4); |
958 |
|
|
959 |
|
/* $t0 += $rb */ |
960 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_ADD,hreg_t0,hreg_rb,4); |
961 |
|
amd64_set_reg(iop->ob_ptr,X86_CC_C,hreg_t1,FALSE); |
962 |
|
amd64_alu_membase_reg_size(iop->ob_ptr,X86_OR, |
963 |
|
AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
964 |
|
hreg_t1,4); |
965 |
|
|
966 |
/* update cr0 */ |
/* update cr0 */ |
967 |
if (insn & 1) { |
if (insn & 1) |
968 |
x86_test_reg_reg(b->jit_ptr,AMD64_RSI,AMD64_RSI); |
amd64_test_reg_reg_size(iop->ob_ptr,hreg_t0,hreg_t0,4); |
969 |
ppc32_update_cr0(b); |
|
970 |
} |
amd64_mov_reg_reg(iop->ob_ptr,hreg_rd,hreg_t0,4); |
971 |
|
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
972 |
|
|
973 |
|
if (insn & 1) |
974 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
975 |
|
|
976 |
|
ppc32_jit_close_hreg_seq(cpu); |
977 |
return(0); |
return(0); |
978 |
} |
} |
979 |
|
|
984 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
985 |
int imm = bits(insn,0,15); |
int imm = bits(insn,0,15); |
986 |
m_uint32_t tmp = sign_extend_32(imm,16); |
m_uint32_t tmp = sign_extend_32(imm,16); |
987 |
|
int hreg_rd,hreg_ra; |
988 |
|
jit_op_t *iop; |
989 |
|
|
990 |
|
/* $rd = $ra + imm */ |
991 |
|
ppc32_jit_start_hreg_seq(cpu,"addi"); |
992 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
993 |
|
|
994 |
|
if (ra != 0) { |
995 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
996 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
997 |
|
|
998 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"addi"); |
999 |
|
|
1000 |
|
if (rd != ra) |
1001 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_rd,hreg_ra,4); |
1002 |
|
|
1003 |
ppc32_load_imm(b,AMD64_RBX,tmp); |
amd64_alu_reg_imm_size(iop->ob_ptr,X86_ADD,hreg_rd,tmp,4); |
1004 |
|
} else { |
1005 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"addi"); |
1006 |
|
ppc32_load_imm(&iop->ob_ptr,hreg_rd,tmp); |
1007 |
|
} |
1008 |
|
|
1009 |
if (ra != 0) |
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
|
amd64_alu_reg_membase_size(b->jit_ptr,X86_ADD,AMD64_RBX, |
|
|
AMD64_R15,REG_OFFSET(ra),4); |
|
1010 |
|
|
1011 |
ppc32_store_gpr(b,rd,AMD64_RBX); |
ppc32_jit_close_hreg_seq(cpu); |
1012 |
return(0); |
return(0); |
1013 |
} |
} |
1014 |
|
|
1019 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
1020 |
int imm = bits(insn,0,15); |
int imm = bits(insn,0,15); |
1021 |
m_uint32_t tmp = sign_extend_32(imm,16); |
m_uint32_t tmp = sign_extend_32(imm,16); |
1022 |
|
int hreg_rd,hreg_ra; |
1023 |
|
jit_op_t *iop; |
1024 |
|
|
1025 |
|
/* $rd = $ra + imm */ |
1026 |
|
ppc32_jit_start_hreg_seq(cpu,"addic"); |
1027 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
1028 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
1029 |
|
|
1030 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
1031 |
|
|
1032 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"addic"); |
1033 |
|
|
1034 |
|
if (rd != ra) |
1035 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_rd,hreg_ra,4); |
1036 |
|
|
1037 |
ppc32_load_imm(b,AMD64_RAX,tmp); |
amd64_alu_reg_imm_size(iop->ob_ptr,X86_ADD,hreg_rd,tmp,4); |
1038 |
ppc32_alu_gpr(b,X86_ADD,AMD64_RAX,ra); |
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
1039 |
ppc32_store_gpr(b,rd,AMD64_RAX); |
|
1040 |
amd64_set_membase_size(b->jit_ptr,X86_CC_C, |
amd64_set_membase(iop->ob_ptr,X86_CC_C, |
1041 |
AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
AMD64_R15,OFFSET(cpu_ppc_t,xer_ca),FALSE); |
1042 |
FALSE,4); |
|
1043 |
|
ppc32_jit_close_hreg_seq(cpu); |
1044 |
return(0); |
return(0); |
1045 |
} |
} |
1046 |
|
|
1051 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
1052 |
int imm = bits(insn,0,15); |
int imm = bits(insn,0,15); |
1053 |
m_uint32_t tmp = sign_extend_32(imm,16); |
m_uint32_t tmp = sign_extend_32(imm,16); |
1054 |
|
int hreg_rd,hreg_ra; |
1055 |
|
jit_op_t *iop; |
1056 |
|
|
1057 |
|
/* $rd = $ra + imm */ |
1058 |
|
ppc32_jit_start_hreg_seq(cpu,"addic."); |
1059 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
1060 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
1061 |
|
|
1062 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
1063 |
|
|
1064 |
ppc32_load_imm(b,AMD64_RAX,tmp); |
iop = ppc32_op_emit_insn_output(cpu,1,"addic."); |
|
ppc32_alu_gpr(b,X86_ADD,AMD64_RAX,ra); |
|
|
ppc32_store_gpr(b,rd,AMD64_RAX); |
|
|
amd64_set_membase_size(b->jit_ptr,X86_CC_C, |
|
|
AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
|
|
FALSE,4); |
|
1065 |
|
|
1066 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RAX,AMD64_RAX,4); |
if (rd != ra) |
1067 |
ppc32_update_cr0(b); |
amd64_mov_reg_reg(iop->ob_ptr,hreg_rd,hreg_ra,4); |
1068 |
|
|
1069 |
|
amd64_alu_reg_imm_size(iop->ob_ptr,X86_ADD,hreg_rd,tmp,4); |
1070 |
|
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
1071 |
|
|
1072 |
|
amd64_set_membase(iop->ob_ptr,X86_CC_C, |
1073 |
|
AMD64_R15,OFFSET(cpu_ppc_t,xer_ca),FALSE); |
1074 |
|
|
1075 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
1076 |
|
|
1077 |
|
ppc32_jit_close_hreg_seq(cpu); |
1078 |
return(0); |
return(0); |
1079 |
} |
} |
1080 |
|
|
1084 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
1085 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
1086 |
m_uint32_t imm = bits(insn,0,15); |
m_uint32_t imm = bits(insn,0,15); |
1087 |
|
m_uint32_t tmp = imm << 16; |
1088 |
|
int hreg_rd,hreg_ra; |
1089 |
|
jit_op_t *iop; |
1090 |
|
|
1091 |
|
/* $rd = $ra + (imm << 16) */ |
1092 |
|
ppc32_jit_start_hreg_seq(cpu,"addis"); |
1093 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
1094 |
|
|
1095 |
|
if (ra != 0) { |
1096 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
1097 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
1098 |
|
|
1099 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"addis"); |
1100 |
|
|
1101 |
|
if (rd != ra) |
1102 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_rd,hreg_ra,4); |
1103 |
|
|
1104 |
|
amd64_alu_reg_imm_size(iop->ob_ptr,X86_ADD,hreg_rd,tmp,4); |
1105 |
|
} else { |
1106 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"addis"); |
1107 |
|
amd64_mov_reg_imm(iop->ob_ptr,hreg_rd,tmp); |
1108 |
|
} |
1109 |
|
|
1110 |
|
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
1111 |
|
|
1112 |
|
ppc32_jit_close_hreg_seq(cpu); |
1113 |
|
return(0); |
1114 |
|
} |
1115 |
|
|
1116 |
|
/* ADDZE */ |
1117 |
|
DECLARE_INSN(ADDZE) |
1118 |
|
{ |
1119 |
|
int rd = bits(insn,21,25); |
1120 |
|
int ra = bits(insn,16,20); |
1121 |
|
int hreg_rd,hreg_ra,hreg_t0; |
1122 |
|
jit_op_t *iop; |
1123 |
|
|
1124 |
|
/* $rd = $ra + xer_ca + set_carry */ |
1125 |
|
ppc32_jit_start_hreg_seq(cpu,"addze"); |
1126 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
1127 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
1128 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
1129 |
|
|
1130 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
1131 |
|
|
1132 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"addze"); |
1133 |
|
|
1134 |
|
amd64_alu_reg_reg(iop->ob_ptr,X86_XOR,hreg_t0,hreg_t0); |
1135 |
|
|
1136 |
|
if (rd != ra) |
1137 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_rd,hreg_ra,4); |
1138 |
|
|
1139 |
|
amd64_alu_reg_membase_size(iop->ob_ptr,X86_ADD,hreg_rd, |
1140 |
|
AMD64_R15,OFFSET(cpu_ppc_t,xer_ca),4); |
1141 |
|
|
1142 |
|
amd64_set_reg(iop->ob_ptr,X86_CC_C,hreg_t0,FALSE); |
1143 |
|
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
1144 |
|
hreg_t0,4); |
1145 |
|
|
1146 |
ppc32_load_imm(b,AMD64_RBX,imm << 16); |
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
1147 |
|
|
1148 |
if (ra != 0) |
if (insn & 1) |
1149 |
amd64_alu_reg_membase_size(b->jit_ptr,X86_ADD,AMD64_RBX, |
ppc32_op_emit_update_flags(cpu,0,TRUE); |
|
AMD64_R15,REG_OFFSET(ra),4); |
|
1150 |
|
|
1151 |
ppc32_store_gpr(b,rd,AMD64_RBX); |
ppc32_jit_close_hreg_seq(cpu); |
1152 |
return(0); |
return(0); |
1153 |
} |
} |
1154 |
|
|
1158 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
1159 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
1160 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
1161 |
|
int hreg_rs,hreg_ra,hreg_rb; |
1162 |
|
jit_op_t *iop; |
1163 |
|
|
1164 |
|
/* $ra = $rs & $rb */ |
1165 |
|
ppc32_jit_start_hreg_seq(cpu,"and"); |
1166 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
1167 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
1168 |
|
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
1169 |
|
|
1170 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
1171 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
1172 |
|
|
1173 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"and"); |
1174 |
|
|
1175 |
|
if (ra == rs) |
1176 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_AND,hreg_ra,hreg_rb,4); |
1177 |
|
else if (ra == rb) |
1178 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_AND,hreg_ra,hreg_rs,4); |
1179 |
|
else { |
1180 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
1181 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_AND,hreg_ra,hreg_rb,4); |
1182 |
|
} |
1183 |
|
|
1184 |
ppc32_load_gpr(b,AMD64_RBX,rs); |
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
|
ppc32_alu_gpr(b,X86_AND,AMD64_RBX,rb); |
|
|
ppc32_store_gpr(b,ra,AMD64_RBX); |
|
1185 |
|
|
1186 |
if (insn & 1) |
if (insn & 1) |
1187 |
ppc32_update_cr0(b); |
ppc32_op_emit_update_flags(cpu,0,TRUE); |
1188 |
|
|
1189 |
|
ppc32_jit_close_hreg_seq(cpu); |
1190 |
return(0); |
return(0); |
1191 |
} |
} |
1192 |
|
|
1196 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
1197 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
1198 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
1199 |
|
int hreg_rs,hreg_ra,hreg_rb,hreg_t0; |
1200 |
|
jit_op_t *iop; |
1201 |
|
|
1202 |
/* $ra = $rs & ~$rb */ |
/* $ra = $rs & ~$rb */ |
1203 |
ppc32_load_gpr(b,AMD64_RBX,rb); |
ppc32_jit_start_hreg_seq(cpu,"andc"); |
1204 |
x86_not_reg(b->jit_ptr,AMD64_RBX); |
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
1205 |
ppc32_alu_gpr(b,X86_AND,AMD64_RBX,rs); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
1206 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
1207 |
|
|
1208 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
1209 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
1210 |
|
|
1211 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"andc"); |
1212 |
|
|
1213 |
|
/* $t0 = ~$rb */ |
1214 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
1215 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_t0,hreg_rb,4); |
1216 |
|
amd64_not_reg(iop->ob_ptr,hreg_t0); |
1217 |
|
|
1218 |
|
/* $ra = $rs & $t0 */ |
1219 |
|
if (ra == rs) |
1220 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_AND,hreg_ra,hreg_t0,4); |
1221 |
|
else { |
1222 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_AND,hreg_t0,hreg_rs,4); |
1223 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_t0,4); |
1224 |
|
} |
1225 |
|
|
1226 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
1227 |
|
|
1228 |
if (insn & 1) |
if (insn & 1) |
1229 |
ppc32_update_cr0(b); |
ppc32_op_emit_update_flags(cpu,0,TRUE); |
1230 |
|
|
1231 |
|
ppc32_jit_close_hreg_seq(cpu); |
1232 |
return(0); |
return(0); |
1233 |
} |
} |
1234 |
|
|
1238 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
1239 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
1240 |
m_uint16_t imm = bits(insn,0,15); |
m_uint16_t imm = bits(insn,0,15); |
1241 |
|
m_uint32_t tmp = imm; |
1242 |
|
int hreg_rs,hreg_ra; |
1243 |
|
jit_op_t *iop; |
1244 |
|
|
1245 |
/* $ra = $rs & imm */ |
/* $ra = $rs & imm */ |
1246 |
ppc32_load_imm(b,AMD64_RBX,imm); |
ppc32_jit_start_hreg_seq(cpu,"andi"); |
1247 |
ppc32_alu_gpr(b,X86_AND,AMD64_RBX,rs); |
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
1248 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
1249 |
|
|
1250 |
ppc32_update_cr0(b); |
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
1251 |
|
|
1252 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"andi"); |
1253 |
|
|
1254 |
|
if (ra != rs) |
1255 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
1256 |
|
|
1257 |
|
amd64_alu_reg_imm_size(iop->ob_ptr,X86_AND,hreg_ra,tmp,4); |
1258 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
1259 |
|
|
1260 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
1261 |
|
|
1262 |
|
ppc32_jit_close_hreg_seq(cpu); |
1263 |
return(0); |
return(0); |
1264 |
} |
} |
1265 |
|
|
1269 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
1270 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
1271 |
m_uint32_t imm = bits(insn,0,15); |
m_uint32_t imm = bits(insn,0,15); |
1272 |
|
m_uint32_t tmp = imm << 16; |
1273 |
|
int hreg_rs,hreg_ra; |
1274 |
|
jit_op_t *iop; |
1275 |
|
|
1276 |
/* $ra = $rs & imm */ |
/* $ra = $rs & imm */ |
1277 |
ppc32_load_imm(b,AMD64_RBX,imm << 16); |
ppc32_jit_start_hreg_seq(cpu,"andis"); |
1278 |
ppc32_alu_gpr(b,X86_AND,AMD64_RBX,rs); |
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
1279 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
1280 |
|
|
1281 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
1282 |
|
|
1283 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"andis"); |
1284 |
|
|
1285 |
|
if (ra != rs) |
1286 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
1287 |
|
|
1288 |
ppc32_update_cr0(b); |
amd64_alu_reg_imm_size(iop->ob_ptr,X86_AND,hreg_ra,tmp,4); |
1289 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
1290 |
|
|
1291 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
1292 |
|
|
1293 |
|
ppc32_jit_close_hreg_seq(cpu); |
1294 |
return(0); |
return(0); |
1295 |
} |
} |
1296 |
|
|
1298 |
DECLARE_INSN(B) |
DECLARE_INSN(B) |
1299 |
{ |
{ |
1300 |
m_uint32_t offset = bits(insn,2,25); |
m_uint32_t offset = bits(insn,2,25); |
1301 |
m_uint64_t new_ia; |
m_uint32_t new_ia; |
1302 |
|
jit_op_t *iop; |
1303 |
|
|
1304 |
|
iop = ppc32_op_emit_insn_output(cpu,4,"b"); |
1305 |
|
|
1306 |
/* compute the new ia */ |
/* compute the new ia */ |
1307 |
new_ia = b->start_ia + ((b->ppc_trans_pos-1) << 2); |
new_ia = b->start_ia + (b->ppc_trans_pos << 2); |
1308 |
new_ia += sign_extend(offset << 2,26); |
new_ia += sign_extend(offset << 2,26); |
1309 |
ppc32_set_jump(cpu,b,new_ia,1); |
ppc32_set_jump(cpu,b,iop,new_ia,TRUE); |
1310 |
|
|
1311 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_EOB); |
1312 |
|
ppc32_op_emit_branch_target(cpu,b,new_ia); |
1313 |
|
ppc32_op_emit_branch_target(cpu,b,b->start_ia+((b->ppc_trans_pos+1) << 2)); |
1314 |
return(0); |
return(0); |
1315 |
} |
} |
1316 |
|
|
1318 |
DECLARE_INSN(BA) |
DECLARE_INSN(BA) |
1319 |
{ |
{ |
1320 |
m_uint32_t offset = bits(insn,2,25); |
m_uint32_t offset = bits(insn,2,25); |
1321 |
m_uint64_t new_ia; |
m_uint32_t new_ia; |
1322 |
|
jit_op_t *iop; |
1323 |
|
|
1324 |
|
iop = ppc32_op_emit_insn_output(cpu,4,"ba"); |
1325 |
|
|
1326 |
/* compute the new ia */ |
/* compute the new ia */ |
1327 |
new_ia = sign_extend(offset << 2,26); |
new_ia = sign_extend(offset << 2,26); |
1328 |
ppc32_set_jump(cpu,b,new_ia,1); |
ppc32_set_jump(cpu,b,iop,new_ia,TRUE); |
1329 |
|
|
1330 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_EOB); |
1331 |
|
ppc32_op_emit_branch_target(cpu,b,new_ia); |
1332 |
|
ppc32_op_emit_branch_target(cpu,b,b->start_ia+((b->ppc_trans_pos+1) << 2)); |
1333 |
return(0); |
return(0); |
1334 |
} |
} |
1335 |
|
|
1337 |
DECLARE_INSN(BL) |
DECLARE_INSN(BL) |
1338 |
{ |
{ |
1339 |
m_uint32_t offset = bits(insn,2,25); |
m_uint32_t offset = bits(insn,2,25); |
1340 |
m_uint64_t new_ia; |
m_uint32_t new_ia; |
1341 |
|
jit_op_t *iop; |
1342 |
|
|
1343 |
|
iop = ppc32_op_emit_insn_output(cpu,4,"bl"); |
1344 |
|
|
1345 |
/* compute the new ia */ |
/* compute the new ia */ |
1346 |
new_ia = b->start_ia + ((b->ppc_trans_pos-1) << 2); |
new_ia = b->start_ia + (b->ppc_trans_pos << 2); |
1347 |
new_ia += sign_extend(offset << 2,26); |
new_ia += sign_extend(offset << 2,26); |
1348 |
|
|
1349 |
/* set the return address */ |
/* set the return address */ |
1350 |
ppc32_set_lr(b,b->start_ia + (b->ppc_trans_pos << 2)); |
ppc32_set_lr(iop,b->start_ia + ((b->ppc_trans_pos+1) << 2)); |
1351 |
|
ppc32_set_jump(cpu,b,iop,new_ia,TRUE); |
1352 |
|
|
1353 |
ppc32_set_jump(cpu,b,new_ia,1); |
ppc32_op_emit_basic_opcode(cpu,JIT_OP_EOB); |
1354 |
|
ppc32_op_emit_branch_target(cpu,b,new_ia); |
1355 |
|
ppc32_op_emit_branch_target(cpu,b,b->start_ia+((b->ppc_trans_pos+1) << 2)); |
1356 |
return(0); |
return(0); |
1357 |
} |
} |
1358 |
|
|
1360 |
DECLARE_INSN(BLA) |
DECLARE_INSN(BLA) |
1361 |
{ |
{ |
1362 |
m_uint32_t offset = bits(insn,2,25); |
m_uint32_t offset = bits(insn,2,25); |
1363 |
m_uint64_t new_ia; |
m_uint32_t new_ia; |
1364 |
|
jit_op_t *iop; |
1365 |
|
|
1366 |
|
iop = ppc32_op_emit_insn_output(cpu,4,"bla"); |
1367 |
|
|
1368 |
/* compute the new ia */ |
/* compute the new ia */ |
1369 |
new_ia = sign_extend(offset << 2,26); |
new_ia = sign_extend(offset << 2,26); |
1370 |
|
|
1371 |
/* set the return address */ |
/* set the return address */ |
1372 |
ppc32_set_lr(b,b->start_ia + (b->ppc_trans_pos << 2)); |
ppc32_set_lr(iop,b->start_ia + ((b->ppc_trans_pos+1) << 2)); |
1373 |
|
ppc32_set_jump(cpu,b,iop,new_ia,TRUE); |
1374 |
|
|
1375 |
ppc32_set_jump(cpu,b,new_ia,1); |
ppc32_op_emit_basic_opcode(cpu,JIT_OP_EOB); |
1376 |
|
ppc32_op_emit_branch_target(cpu,b,new_ia); |
1377 |
|
ppc32_op_emit_branch_target(cpu,b,b->start_ia+((b->ppc_trans_pos+1) << 2)); |
1378 |
return(0); |
return(0); |
1379 |
} |
} |
1380 |
|
|
1384 |
int bo = bits(insn,21,25); |
int bo = bits(insn,21,25); |
1385 |
int bi = bits(insn,16,20); |
int bi = bits(insn,16,20); |
1386 |
int bd = bits(insn,2,15); |
int bd = bits(insn,2,15); |
1387 |
|
jit_op_t *iop; |
1388 |
u_int cr_field,cr_bit; |
u_int cr_field,cr_bit; |
1389 |
m_uint32_t new_ia; |
m_uint32_t new_ia; |
1390 |
u_char *jump_ptr; |
u_char *jump_ptr; |
1391 |
int local_jump; |
int local_jump; |
1392 |
int cond; |
int cond; |
1393 |
|
|
1394 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_BRANCH_JUMP); |
1395 |
|
|
1396 |
|
iop = ppc32_op_emit_insn_output(cpu,5,"bcc"); |
1397 |
|
|
1398 |
/* Get the wanted value for the condition bit */ |
/* Get the wanted value for the condition bit */ |
1399 |
cond = (bo >> 3) & 0x1; |
cond = (bo >> 3) & 0x1; |
1400 |
|
|
1401 |
/* Set the return address */ |
/* Set the return address */ |
1402 |
if (insn & 1) |
if (insn & 1) { |
1403 |
ppc32_set_lr(b,b->start_ia + (b->ppc_trans_pos << 2)); |
ppc32_set_lr(iop,b->start_ia + ((b->ppc_trans_pos+1) << 2)); |
1404 |
|
ppc32_op_emit_branch_target(cpu,b,b->start_ia+((b->ppc_trans_pos+1)<<2)); |
1405 |
|
} |
1406 |
|
|
1407 |
/* Compute the new ia */ |
/* Compute the new ia */ |
1408 |
new_ia = sign_extend_32(bd << 2,16); |
new_ia = sign_extend_32(bd << 2,16); |
1409 |
if (!(insn & 0x02)) |
if (!(insn & 0x02)) |
1410 |
new_ia += b->start_ia + ((b->ppc_trans_pos-1) << 2); |
new_ia += b->start_ia + (b->ppc_trans_pos << 2); |
1411 |
|
|
1412 |
/* Test the condition bit */ |
/* Test the condition bit */ |
1413 |
cr_field = ppc32_get_cr_field(bi); |
cr_field = ppc32_get_cr_field(bi); |
1414 |
cr_bit = ppc32_get_cr_bit(bi); |
cr_bit = ppc32_get_cr_bit(bi); |
1415 |
|
|
1416 |
amd64_test_membase_imm_size(b->jit_ptr, |
ppc32_op_emit_require_flags(cpu,cr_field); |
1417 |
|
|
1418 |
|
amd64_test_membase_imm_size(iop->ob_ptr, |
1419 |
AMD64_R15,PPC32_CR_FIELD_OFFSET(cr_field), |
AMD64_R15,PPC32_CR_FIELD_OFFSET(cr_field), |
1420 |
(1 << cr_bit),4); |
(1 << cr_bit),4); |
1421 |
|
|
1426 |
* page or not. |
* page or not. |
1427 |
*/ |
*/ |
1428 |
if (local_jump) { |
if (local_jump) { |
1429 |
if (jump_ptr) { |
ppc32_jit_tcb_record_patch(b,iop,iop->ob_ptr,new_ia); |
1430 |
amd64_branch(b->jit_ptr,(cond) ? X86_CC_NZ : X86_CC_Z,jump_ptr,FALSE); |
amd64_branch32(iop->ob_ptr,(cond) ? X86_CC_NZ : X86_CC_Z,0,FALSE); |
|
} else { |
|
|
ppc32_jit_tcb_record_patch(b,b->jit_ptr,new_ia); |
|
|
amd64_branch32(b->jit_ptr,(cond) ? X86_CC_NZ : X86_CC_Z,0,FALSE); |
|
|
} |
|
1431 |
} else { |
} else { |
1432 |
jump_ptr = b->jit_ptr; |
jump_ptr = iop->ob_ptr; |
1433 |
amd64_branch32(b->jit_ptr,(cond) ? X86_CC_Z : X86_CC_NZ,0,FALSE); |
amd64_branch32(iop->ob_ptr,(cond) ? X86_CC_Z : X86_CC_NZ,0,FALSE); |
1434 |
ppc32_set_jump(cpu,b,new_ia,TRUE); |
ppc32_set_jump(cpu,b,iop,new_ia,TRUE); |
1435 |
amd64_patch(jump_ptr,b->jit_ptr); |
amd64_patch(jump_ptr,iop->ob_ptr); |
1436 |
} |
} |
1437 |
|
|
1438 |
|
ppc32_op_emit_branch_target(cpu,b,new_ia); |
1439 |
return(0); |
return(0); |
1440 |
} |
} |
1441 |
|
|
1442 |
/* BC - Branch Conditional */ |
/* BC - Branch Conditional */ |
1443 |
DECLARE_INSN(BC) |
DECLARE_INSN(BC) |
1444 |
{ |
{ |
1445 |
int bo = bits(insn,21,25); |
int bo = bits(insn,21,25); |
1446 |
int bi = bits(insn,16,20); |
int bi = bits(insn,16,20); |
1447 |
int bd = bits(insn,2,15); |
int bd = bits(insn,2,15); |
1448 |
|
int hreg_t0,hreg_t1; |
1449 |
|
jit_op_t *iop; |
1450 |
u_int cr_field,cr_bit; |
u_int cr_field,cr_bit; |
1451 |
m_uint32_t new_ia; |
m_uint32_t new_ia; |
1452 |
u_char *jump_ptr; |
u_char *jump_ptr; |
1453 |
int local_jump; |
int local_jump; |
1454 |
int cond,ctr; |
int cond,ctr; |
1455 |
|
|
1456 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_BRANCH_JUMP); |
1457 |
|
|
1458 |
|
iop = ppc32_op_emit_insn_output(cpu,5,"bc"); |
1459 |
|
|
1460 |
|
ppc32_jit_start_hreg_seq(cpu,"bc"); |
1461 |
|
hreg_t0 = ppc32_jit_alloc_hreg(cpu,-1); |
1462 |
|
hreg_t1 = ppc32_jit_get_tmp_hreg(cpu); |
1463 |
|
|
1464 |
|
ppc32_op_emit_alter_host_reg(cpu,hreg_t0); |
1465 |
|
|
1466 |
/* Get the wanted value for the condition bit and CTR value */ |
/* Get the wanted value for the condition bit and CTR value */ |
1467 |
cond = (bo >> 3) & 0x1; |
cond = (bo >> 3) & 0x1; |
1468 |
ctr = (bo >> 1) & 0x1; |
ctr = (bo >> 1) & 0x1; |
1469 |
|
|
1470 |
/* Set the return address */ |
/* Set the return address */ |
1471 |
if (insn & 1) |
if (insn & 1) { |
1472 |
ppc32_set_lr(b,b->start_ia + (b->ppc_trans_pos << 2)); |
ppc32_set_lr(iop,b->start_ia + ((b->ppc_trans_pos+1) << 2)); |
1473 |
|
ppc32_op_emit_branch_target(cpu,b,b->start_ia+((b->ppc_trans_pos+1)<<2)); |
1474 |
|
} |
1475 |
|
|
1476 |
/* Compute the new ia */ |
/* Compute the new ia */ |
1477 |
new_ia = sign_extend_32(bd << 2,16); |
new_ia = sign_extend_32(bd << 2,16); |
1478 |
if (!(insn & 0x02)) |
if (!(insn & 0x02)) |
1479 |
new_ia += b->start_ia + ((b->ppc_trans_pos-1) << 2); |
new_ia += b->start_ia + (b->ppc_trans_pos << 2); |
1480 |
|
|
1481 |
ppc32_load_imm(b,AMD64_RAX,1); |
amd64_mov_reg_imm(iop->ob_ptr,hreg_t0,1); |
1482 |
|
|
1483 |
/* Decrement the count register */ |
/* Decrement the count register */ |
1484 |
if (!(bo & 0x04)) { |
if (!(bo & 0x04)) { |
1485 |
amd64_dec_membase_size(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,ctr),4); |
amd64_dec_membase_size(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,ctr),4); |
1486 |
amd64_set_reg(b->jit_ptr,(ctr) ? X86_CC_Z : X86_CC_NZ,AMD64_RBX,FALSE); |
amd64_set_reg(iop->ob_ptr,(ctr) ? X86_CC_Z : X86_CC_NZ,hreg_t1,FALSE); |
1487 |
amd64_alu_reg_reg(b->jit_ptr,X86_AND,AMD64_RAX,AMD64_RBX); |
amd64_alu_reg_reg(iop->ob_ptr,X86_AND,hreg_t0,hreg_t1); |
1488 |
} |
} |
1489 |
|
|
1490 |
/* Test the condition bit */ |
/* Test the condition bit */ |
1492 |
cr_field = ppc32_get_cr_field(bi); |
cr_field = ppc32_get_cr_field(bi); |
1493 |
cr_bit = ppc32_get_cr_bit(bi); |
cr_bit = ppc32_get_cr_bit(bi); |
1494 |
|
|
1495 |
amd64_test_membase_imm_size(b->jit_ptr, |
ppc32_op_emit_require_flags(cpu,cr_field); |
1496 |
|
|
1497 |
|
amd64_test_membase_imm_size(iop->ob_ptr, |
1498 |
AMD64_R15,PPC32_CR_FIELD_OFFSET(cr_field), |
AMD64_R15,PPC32_CR_FIELD_OFFSET(cr_field), |
1499 |
(1 << cr_bit),4); |
(1 << cr_bit),4); |
1500 |
|
|
1501 |
amd64_set_reg(b->jit_ptr,(cond) ? X86_CC_NZ : X86_CC_Z,AMD64_RCX,FALSE); |
amd64_set_reg(iop->ob_ptr,(cond) ? X86_CC_NZ : X86_CC_Z,hreg_t1,FALSE); |
1502 |
amd64_alu_reg_reg(b->jit_ptr,X86_AND,AMD64_RAX,AMD64_RCX); |
amd64_alu_reg_reg(iop->ob_ptr,X86_AND,hreg_t0,hreg_t1); |
1503 |
} |
} |
1504 |
|
|
1505 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RAX,0x01); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,0x01); |
1506 |
|
|
1507 |
local_jump = ppc32_jit_tcb_local_addr(b,new_ia,&jump_ptr); |
local_jump = ppc32_jit_tcb_local_addr(b,new_ia,&jump_ptr); |
1508 |
|
|
1511 |
* page or not. |
* page or not. |
1512 |
*/ |
*/ |
1513 |
if (local_jump) { |
if (local_jump) { |
1514 |
if (jump_ptr) { |
ppc32_jit_tcb_record_patch(b,iop,iop->ob_ptr,new_ia); |
1515 |
amd64_branch(b->jit_ptr,X86_CC_NZ,jump_ptr,FALSE); |
amd64_branch32(iop->ob_ptr,X86_CC_NZ,0,FALSE); |
|
} else { |
|
|
ppc32_jit_tcb_record_patch(b,b->jit_ptr,new_ia); |
|
|
amd64_branch32(b->jit_ptr,X86_CC_NZ,0,FALSE); |
|
|
} |
|
1516 |
} else { |
} else { |
1517 |
jump_ptr = b->jit_ptr; |
jump_ptr = iop->ob_ptr; |
1518 |
amd64_branch32(b->jit_ptr,X86_CC_Z,0,FALSE); |
amd64_branch32(iop->ob_ptr,X86_CC_Z,0,FALSE); |
1519 |
ppc32_set_jump(cpu,b,new_ia,TRUE); |
ppc32_set_jump(cpu,b,iop,new_ia,TRUE); |
1520 |
amd64_patch(jump_ptr,b->jit_ptr); |
amd64_patch(jump_ptr,iop->ob_ptr); |
1521 |
} |
} |
1522 |
|
|
1523 |
|
ppc32_op_emit_branch_target(cpu,b,new_ia); |
1524 |
|
|
1525 |
|
ppc32_jit_close_hreg_seq(cpu); |
1526 |
return(0); |
return(0); |
1527 |
} |
} |
1528 |
|
|
1532 |
int bo = bits(insn,21,25); |
int bo = bits(insn,21,25); |
1533 |
int bi = bits(insn,16,20); |
int bi = bits(insn,16,20); |
1534 |
int bd = bits(insn,2,15); |
int bd = bits(insn,2,15); |
1535 |
|
int hreg_t0,hreg_t1; |
1536 |
|
jit_op_t *iop; |
1537 |
u_int cr_field,cr_bit; |
u_int cr_field,cr_bit; |
1538 |
m_uint32_t new_ia; |
m_uint32_t new_ia; |
1539 |
u_char *jump_ptr; |
u_char *jump_ptr; |
1540 |
int cond,ctr; |
int cond,ctr; |
1541 |
|
|
1542 |
|
ppc32_jit_start_hreg_seq(cpu,"bclr"); |
1543 |
|
hreg_t0 = ppc32_jit_alloc_hreg(cpu,-1); |
1544 |
|
hreg_t1 = ppc32_jit_get_tmp_hreg(cpu); |
1545 |
|
|
1546 |
|
ppc32_op_emit_alter_host_reg(cpu,hreg_t0); |
1547 |
|
|
1548 |
|
iop = ppc32_op_emit_insn_output(cpu,5,"bclr"); |
1549 |
|
|
1550 |
/* Get the wanted value for the condition bit and CTR value */ |
/* Get the wanted value for the condition bit and CTR value */ |
1551 |
cond = (bo >> 3) & 0x1; |
cond = (bo >> 3) & 0x1; |
1552 |
ctr = (bo >> 1) & 0x1; |
ctr = (bo >> 1) & 0x1; |
1554 |
/* Compute the new ia */ |
/* Compute the new ia */ |
1555 |
new_ia = sign_extend_32(bd << 2,16); |
new_ia = sign_extend_32(bd << 2,16); |
1556 |
if (!(insn & 0x02)) |
if (!(insn & 0x02)) |
1557 |
new_ia += b->start_ia + ((b->ppc_trans_pos-1) << 2); |
new_ia += b->start_ia + (b->ppc_trans_pos << 2); |
1558 |
|
|
1559 |
ppc32_load_imm(b,AMD64_RAX,1); |
amd64_mov_reg_imm(iop->ob_ptr,hreg_t0,1); |
1560 |
|
|
1561 |
/* Decrement the count register */ |
/* Decrement the count register */ |
1562 |
if (!(bo & 0x04)) { |
if (!(bo & 0x04)) { |
1563 |
amd64_dec_membase_size(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,ctr),4); |
amd64_dec_membase_size(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,ctr),4); |
1564 |
amd64_set_reg(b->jit_ptr,(ctr) ? X86_CC_Z : X86_CC_NZ,AMD64_RBX,FALSE); |
amd64_set_reg(iop->ob_ptr,(ctr) ? X86_CC_Z : X86_CC_NZ,hreg_t1,FALSE); |
1565 |
amd64_alu_reg_reg(b->jit_ptr,X86_AND,AMD64_RAX,AMD64_RBX); |
amd64_alu_reg_reg(iop->ob_ptr,X86_AND,hreg_t0,hreg_t1); |
1566 |
} |
} |
1567 |
|
|
1568 |
/* Test the condition bit */ |
/* Test the condition bit */ |
1570 |
cr_field = ppc32_get_cr_field(bi); |
cr_field = ppc32_get_cr_field(bi); |
1571 |
cr_bit = ppc32_get_cr_bit(bi); |
cr_bit = ppc32_get_cr_bit(bi); |
1572 |
|
|
1573 |
amd64_test_membase_imm_size(b->jit_ptr, |
ppc32_op_emit_require_flags(cpu,cr_field); |
1574 |
|
|
1575 |
|
amd64_test_membase_imm_size(iop->ob_ptr, |
1576 |
AMD64_R15,PPC32_CR_FIELD_OFFSET(cr_field), |
AMD64_R15,PPC32_CR_FIELD_OFFSET(cr_field), |
1577 |
(1 << cr_bit),4); |
(1 << cr_bit),4); |
1578 |
|
|
1579 |
amd64_set_reg(b->jit_ptr,(cond) ? X86_CC_NZ : X86_CC_Z,AMD64_RCX,FALSE); |
amd64_set_reg(iop->ob_ptr,(cond) ? X86_CC_NZ : X86_CC_Z,hreg_t1,FALSE); |
1580 |
amd64_alu_reg_reg(b->jit_ptr,X86_AND,AMD64_RAX,AMD64_RCX); |
amd64_alu_reg_reg(iop->ob_ptr,X86_AND,hreg_t0,hreg_t1); |
1581 |
} |
} |
1582 |
|
|
1583 |
/* Set the return address */ |
/* Set the return address */ |
1584 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RDX, |
amd64_mov_reg_membase(iop->ob_ptr,hreg_t1,AMD64_R15,OFFSET(cpu_ppc_t,lr),4); |
|
AMD64_R15,OFFSET(cpu_ppc_t,lr),4); |
|
1585 |
|
|
1586 |
if (insn & 1) |
if (insn & 1) { |
1587 |
ppc32_set_lr(b,b->start_ia + (b->ppc_trans_pos << 2)); |
ppc32_set_lr(iop,b->start_ia + ((b->ppc_trans_pos+1) << 2)); |
1588 |
|
ppc32_op_emit_branch_target(cpu,b,b->start_ia+((b->ppc_trans_pos+1)<<2)); |
1589 |
|
} |
1590 |
|
|
1591 |
/* Branching */ |
/* Branching */ |
1592 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RAX,0x01); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,0x01); |
1593 |
|
|
1594 |
|
jump_ptr = iop->ob_ptr; |
1595 |
|
amd64_branch32(iop->ob_ptr,X86_CC_Z,0,FALSE); |
1596 |
|
|
1597 |
jump_ptr = b->jit_ptr; |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t1,0xFFFFFFFC); |
1598 |
amd64_branch32(b->jit_ptr,X86_CC_Z,0,FALSE); |
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,ia),hreg_t1,4); |
1599 |
|
ppc32_jit_tcb_push_epilog(&iop->ob_ptr); |
1600 |
|
|
1601 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RDX,0xFFFFFFFC); |
amd64_patch(jump_ptr,iop->ob_ptr); |
|
amd64_mov_membase_reg(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,ia), |
|
|
AMD64_RDX,4); |
|
|
ppc32_jit_tcb_push_epilog(b); |
|
1602 |
|
|
1603 |
amd64_patch(jump_ptr,b->jit_ptr); |
ppc32_op_emit_basic_opcode(cpu,JIT_OP_EOB); |
1604 |
|
|
1605 |
|
ppc32_jit_close_hreg_seq(cpu); |
1606 |
return(0); |
return(0); |
1607 |
} |
} |
1608 |
|
|
1612 |
int rd = bits(insn,23,25); |
int rd = bits(insn,23,25); |
1613 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
1614 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
1615 |
|
int hreg_ra,hreg_rb; |
1616 |
|
jit_op_t *iop; |
1617 |
|
|
1618 |
|
ppc32_jit_start_hreg_seq(cpu,"cmp"); |
1619 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
1620 |
|
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
1621 |
|
|
1622 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
1623 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
1624 |
|
|
1625 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"cmp"); |
1626 |
|
|
1627 |
ppc32_load_gpr(b,AMD64_RBX,ra); |
amd64_alu_reg_reg_size(iop->ob_ptr,X86_CMP,hreg_ra,hreg_rb,4); |
1628 |
ppc32_alu_gpr(b,X86_CMP,AMD64_RBX,rb); |
ppc32_op_emit_update_flags(cpu,rd,TRUE); |
1629 |
ppc32_update_cr(b,rd,TRUE); |
|
1630 |
|
ppc32_jit_close_hreg_seq(cpu); |
1631 |
return(0); |
return(0); |
1632 |
} |
} |
1633 |
|
|
1638 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
1639 |
m_uint16_t imm = bits(insn,0,15); |
m_uint16_t imm = bits(insn,0,15); |
1640 |
m_uint32_t tmp = sign_extend_32(imm,16); |
m_uint32_t tmp = sign_extend_32(imm,16); |
1641 |
|
int hreg_ra; |
1642 |
|
jit_op_t *iop; |
1643 |
|
|
1644 |
|
ppc32_jit_start_hreg_seq(cpu,"cmpi"); |
1645 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
1646 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
1647 |
|
|
1648 |
ppc32_load_imm(b,AMD64_RBX,tmp); |
iop = ppc32_op_emit_insn_output(cpu,1,"cmpi"); |
|
ppc32_load_gpr(b,AMD64_RSI,ra); |
|
|
amd64_alu_reg_reg_size(b->jit_ptr,X86_CMP,AMD64_RSI,AMD64_RBX,4); |
|
1649 |
|
|
1650 |
ppc32_update_cr(b,rd,TRUE); |
amd64_alu_reg_imm_size(iop->ob_ptr,X86_CMP,hreg_ra,tmp,4); |
1651 |
|
ppc32_op_emit_update_flags(cpu,rd,TRUE); |
1652 |
|
|
1653 |
|
ppc32_jit_close_hreg_seq(cpu); |
1654 |
return(0); |
return(0); |
1655 |
} |
} |
1656 |
|
|
1660 |
int rd = bits(insn,23,25); |
int rd = bits(insn,23,25); |
1661 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
1662 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
1663 |
|
int hreg_ra,hreg_rb; |
1664 |
|
jit_op_t *iop; |
1665 |
|
|
1666 |
|
ppc32_jit_start_hreg_seq(cpu,"cmpl"); |
1667 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
1668 |
|
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
1669 |
|
|
1670 |
ppc32_load_gpr(b,AMD64_RAX,ra); |
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
1671 |
ppc32_alu_gpr(b,X86_CMP,AMD64_RAX,rb); |
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
1672 |
ppc32_update_cr(b,rd,FALSE); |
|
1673 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"cmpl"); |
1674 |
|
|
1675 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_CMP,hreg_ra,hreg_rb,4); |
1676 |
|
ppc32_op_emit_update_flags(cpu,rd,FALSE); |
1677 |
|
|
1678 |
|
ppc32_jit_close_hreg_seq(cpu); |
1679 |
return(0); |
return(0); |
1680 |
} |
} |
1681 |
|
|
1684 |
{ |
{ |
1685 |
int rd = bits(insn,23,25); |
int rd = bits(insn,23,25); |
1686 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
1687 |
m_uint16_t imm = bits(insn,0,15); |
m_uint32_t imm = bits(insn,0,15); |
1688 |
|
int hreg_ra; |
1689 |
|
jit_op_t *iop; |
1690 |
|
|
1691 |
|
ppc32_jit_start_hreg_seq(cpu,"cmpli"); |
1692 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
1693 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
1694 |
|
|
1695 |
ppc32_load_imm(b,AMD64_RBX,imm); |
iop = ppc32_op_emit_insn_output(cpu,1,"cmpli"); |
|
ppc32_load_gpr(b,AMD64_RSI,ra); |
|
|
amd64_alu_reg_reg_size(b->jit_ptr,X86_CMP,AMD64_RSI,AMD64_RBX,4); |
|
1696 |
|
|
1697 |
ppc32_update_cr(b,rd,FALSE); |
amd64_alu_reg_imm_size(iop->ob_ptr,X86_CMP,hreg_ra,imm,4); |
1698 |
|
ppc32_op_emit_update_flags(cpu,rd,FALSE); |
1699 |
|
|
1700 |
|
ppc32_jit_close_hreg_seq(cpu); |
1701 |
return(0); |
return(0); |
1702 |
} |
} |
1703 |
|
|
1707 |
int bd = bits(insn,21,25); |
int bd = bits(insn,21,25); |
1708 |
int bb = bits(insn,16,20); |
int bb = bits(insn,16,20); |
1709 |
int ba = bits(insn,11,15); |
int ba = bits(insn,11,15); |
1710 |
|
int hreg_t0; |
1711 |
|
jit_op_t *iop; |
1712 |
|
|
1713 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
1714 |
|
|
1715 |
|
ppc32_jit_start_hreg_seq(cpu,"crand"); |
1716 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
1717 |
|
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RDX); |
1718 |
|
|
1719 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(ba)); |
1720 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bb)); |
1721 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bd)); |
1722 |
|
|
1723 |
|
iop = ppc32_op_emit_insn_output(cpu,3,"crand"); |
1724 |
|
|
1725 |
/* test $ba bit */ |
/* test $ba bit */ |
1726 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
1727 |
AMD64_R15, |
AMD64_R15, |
1728 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
1729 |
(1 << ppc32_get_cr_bit(ba))); |
(1 << ppc32_get_cr_bit(ba))); |
1730 |
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RAX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_NZ,AMD64_RDX,FALSE); |
1731 |
|
|
1732 |
/* test $bb bit */ |
/* test $bb bit */ |
1733 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
1734 |
AMD64_R15, |
AMD64_R15, |
1735 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
1736 |
(1 << ppc32_get_cr_bit(bb))); |
(1 << ppc32_get_cr_bit(bb))); |
1737 |
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RBX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_NZ,hreg_t0,FALSE); |
1738 |
|
|
1739 |
/* result of AND between $ba and $bb */ |
/* result of AND between $ba and $bb */ |
1740 |
amd64_alu_reg_reg(b->jit_ptr,X86_AND,AMD64_RBX,AMD64_RAX); |
amd64_alu_reg_reg(iop->ob_ptr,X86_AND,hreg_t0,AMD64_RDX); |
1741 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RBX,0x01); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,0x01); |
1742 |
|
|
1743 |
/* set/clear $bd bit depending on the result */ |
/* set/clear $bd bit depending on the result */ |
1744 |
amd64_alu_membase_imm_size(b->jit_ptr,X86_AND, |
amd64_alu_membase_imm_size(iop->ob_ptr,X86_AND, |
1745 |
AMD64_R15, |
AMD64_R15, |
1746 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
1747 |
~(1 << ppc32_get_cr_bit(bd)),4); |
~(1 << ppc32_get_cr_bit(bd)),4); |
1748 |
|
|
1749 |
amd64_shift_reg_imm(b->jit_ptr,X86_SHL,AMD64_RBX,ppc32_get_cr_bit(bd)); |
amd64_shift_reg_imm(iop->ob_ptr,X86_SHL,hreg_t0,ppc32_get_cr_bit(bd)); |
1750 |
amd64_alu_membase_reg_size(b->jit_ptr,X86_OR, |
amd64_alu_membase_reg_size(iop->ob_ptr,X86_OR, |
1751 |
AMD64_R15, |
AMD64_R15, |
1752 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
1753 |
AMD64_RBX,4); |
hreg_t0,4); |
1754 |
|
|
1755 |
|
ppc32_jit_close_hreg_seq(cpu); |
1756 |
return(0); |
return(0); |
1757 |
} |
} |
1758 |
|
|
1762 |
int bd = bits(insn,21,25); |
int bd = bits(insn,21,25); |
1763 |
int bb = bits(insn,16,20); |
int bb = bits(insn,16,20); |
1764 |
int ba = bits(insn,11,15); |
int ba = bits(insn,11,15); |
1765 |
|
int hreg_t0; |
1766 |
|
jit_op_t *iop; |
1767 |
|
|
1768 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
1769 |
|
|
1770 |
|
ppc32_jit_start_hreg_seq(cpu,"crandc"); |
1771 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
1772 |
|
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RDX); |
1773 |
|
|
1774 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(ba)); |
1775 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bb)); |
1776 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bd)); |
1777 |
|
|
1778 |
|
iop = ppc32_op_emit_insn_output(cpu,3,"crandc"); |
1779 |
|
|
1780 |
/* test $ba bit */ |
/* test $ba bit */ |
1781 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
1782 |
AMD64_R15, |
AMD64_R15, |
1783 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
1784 |
(1 << ppc32_get_cr_bit(ba))); |
(1 << ppc32_get_cr_bit(ba))); |
1785 |
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RAX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_NZ,AMD64_RDX,FALSE); |
1786 |
|
|
1787 |
/* test $bb bit */ |
/* test $bb bit */ |
1788 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
1789 |
AMD64_R15, |
AMD64_R15, |
1790 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
1791 |
(1 << ppc32_get_cr_bit(bb))); |
(1 << ppc32_get_cr_bit(bb))); |
1792 |
amd64_set_reg(b->jit_ptr,X86_CC_Z,AMD64_RBX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_Z,hreg_t0,FALSE); |
1793 |
|
|
1794 |
/* result of AND between $ba and $bb */ |
/* result of AND between $ba and $bb */ |
1795 |
amd64_alu_reg_reg(b->jit_ptr,X86_AND,AMD64_RBX,AMD64_RAX); |
amd64_alu_reg_reg(iop->ob_ptr,X86_AND,hreg_t0,AMD64_RDX); |
1796 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RBX,0x01); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,0x01); |
1797 |
|
|
1798 |
/* set/clear $bd bit depending on the result */ |
/* set/clear $bd bit depending on the result */ |
1799 |
amd64_alu_membase_imm_size(b->jit_ptr,X86_AND, |
amd64_alu_membase_imm_size(iop->ob_ptr,X86_AND, |
1800 |
AMD64_R15, |
AMD64_R15, |
1801 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
1802 |
~(1 << ppc32_get_cr_bit(bd)),4); |
~(1 << ppc32_get_cr_bit(bd)),4); |
1803 |
|
|
1804 |
amd64_shift_reg_imm(b->jit_ptr,X86_SHL,AMD64_RBX,ppc32_get_cr_bit(bd)); |
amd64_shift_reg_imm(iop->ob_ptr,X86_SHL,hreg_t0,ppc32_get_cr_bit(bd)); |
1805 |
amd64_alu_membase_reg_size(b->jit_ptr,X86_OR, |
amd64_alu_membase_reg_size(iop->ob_ptr,X86_OR, |
1806 |
AMD64_R15, |
AMD64_R15, |
1807 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
1808 |
AMD64_RBX,4); |
hreg_t0,4); |
1809 |
|
|
1810 |
|
ppc32_jit_close_hreg_seq(cpu); |
1811 |
return(0); |
return(0); |
1812 |
} |
} |
1813 |
|
|
1817 |
int bd = bits(insn,21,25); |
int bd = bits(insn,21,25); |
1818 |
int bb = bits(insn,16,20); |
int bb = bits(insn,16,20); |
1819 |
int ba = bits(insn,11,15); |
int ba = bits(insn,11,15); |
1820 |
|
int hreg_t0; |
1821 |
|
jit_op_t *iop; |
1822 |
|
|
1823 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
1824 |
|
|
1825 |
|
ppc32_jit_start_hreg_seq(cpu,"creqv"); |
1826 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
1827 |
|
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RDX); |
1828 |
|
|
1829 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(ba)); |
1830 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bb)); |
1831 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bd)); |
1832 |
|
|
1833 |
|
iop = ppc32_op_emit_insn_output(cpu,3,"creqv"); |
1834 |
|
|
1835 |
/* test $ba bit */ |
/* test $ba bit */ |
1836 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
1837 |
AMD64_R15, |
AMD64_R15, |
1838 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
1839 |
(1 << ppc32_get_cr_bit(ba))); |
(1 << ppc32_get_cr_bit(ba))); |
1840 |
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RAX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_NZ,AMD64_RDX,FALSE); |
1841 |
|
|
1842 |
/* test $bb bit */ |
/* test $bb bit */ |
1843 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
1844 |
AMD64_R15, |
AMD64_R15, |
1845 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
1846 |
(1 << ppc32_get_cr_bit(bb))); |
(1 << ppc32_get_cr_bit(bb))); |
1847 |
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RBX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_NZ,hreg_t0,FALSE); |
1848 |
|
|
1849 |
/* result of XOR between $ba and $bb */ |
/* result of XOR between $ba and $bb */ |
1850 |
amd64_alu_reg_reg(b->jit_ptr,X86_XOR,AMD64_RBX,AMD64_RAX); |
amd64_alu_reg_reg(iop->ob_ptr,X86_XOR,hreg_t0,AMD64_RDX); |
1851 |
amd64_not_reg(b->jit_ptr,AMD64_RBX); |
amd64_not_reg(iop->ob_ptr,hreg_t0); |
1852 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RBX,0x01); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,0x01); |
1853 |
|
|
1854 |
/* set/clear $bd bit depending on the result */ |
/* set/clear $bd bit depending on the result */ |
1855 |
amd64_alu_membase_imm_size(b->jit_ptr,X86_AND, |
amd64_alu_membase_imm_size(iop->ob_ptr,X86_AND, |
1856 |
AMD64_R15, |
AMD64_R15, |
1857 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
1858 |
~(1 << ppc32_get_cr_bit(bd)),4); |
~(1 << ppc32_get_cr_bit(bd)),4); |
1859 |
|
|
1860 |
amd64_shift_reg_imm(b->jit_ptr,X86_SHL,AMD64_RBX,ppc32_get_cr_bit(bd)); |
amd64_shift_reg_imm(iop->ob_ptr,X86_SHL,hreg_t0,ppc32_get_cr_bit(bd)); |
1861 |
amd64_alu_membase_reg_size(b->jit_ptr,X86_OR, |
amd64_alu_membase_reg_size(iop->ob_ptr,X86_OR, |
1862 |
AMD64_R15, |
AMD64_R15, |
1863 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
1864 |
AMD64_RBX,4); |
hreg_t0,4); |
1865 |
|
|
1866 |
|
ppc32_jit_close_hreg_seq(cpu); |
1867 |
return(0); |
return(0); |
1868 |
} |
} |
1869 |
|
|
1873 |
int bd = bits(insn,21,25); |
int bd = bits(insn,21,25); |
1874 |
int bb = bits(insn,16,20); |
int bb = bits(insn,16,20); |
1875 |
int ba = bits(insn,11,15); |
int ba = bits(insn,11,15); |
1876 |
|
int hreg_t0; |
1877 |
|
jit_op_t *iop; |
1878 |
|
|
1879 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
1880 |
|
|
1881 |
|
ppc32_jit_start_hreg_seq(cpu,"crnand"); |
1882 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
1883 |
|
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RDX); |
1884 |
|
|
1885 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(ba)); |
1886 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bb)); |
1887 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bd)); |
1888 |
|
|
1889 |
|
iop = ppc32_op_emit_insn_output(cpu,3,"crnand"); |
1890 |
|
|
1891 |
/* test $ba bit */ |
/* test $ba bit */ |
1892 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
1893 |
AMD64_R15, |
AMD64_R15, |
1894 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
1895 |
(1 << ppc32_get_cr_bit(ba))); |
(1 << ppc32_get_cr_bit(ba))); |
1896 |
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RAX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_NZ,AMD64_RDX,FALSE); |
1897 |
|
|
1898 |
/* test $bb bit */ |
/* test $bb bit */ |
1899 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
1900 |
AMD64_R15, |
AMD64_R15, |
1901 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
1902 |
(1 << ppc32_get_cr_bit(bb))); |
(1 << ppc32_get_cr_bit(bb))); |
1903 |
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RBX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_NZ,hreg_t0,FALSE); |
1904 |
|
|
1905 |
/* result of NAND between $ba and $bb */ |
/* result of NAND between $ba and $bb */ |
1906 |
amd64_alu_reg_reg(b->jit_ptr,X86_AND,AMD64_RBX,AMD64_RAX); |
amd64_alu_reg_reg(iop->ob_ptr,X86_AND,hreg_t0,AMD64_RDX); |
1907 |
amd64_not_reg(b->jit_ptr,AMD64_RBX); |
amd64_not_reg(iop->ob_ptr,hreg_t0); |
1908 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RBX,0x01); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,0x01); |
1909 |
|
|
1910 |
/* set/clear $bd bit depending on the result */ |
/* set/clear $bd bit depending on the result */ |
1911 |
amd64_alu_membase_imm_size(b->jit_ptr,X86_AND, |
amd64_alu_membase_imm_size(iop->ob_ptr,X86_AND, |
1912 |
AMD64_R15, |
AMD64_R15, |
1913 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
1914 |
~(1 << ppc32_get_cr_bit(bd)),4); |
~(1 << ppc32_get_cr_bit(bd)),4); |
1915 |
|
|
1916 |
amd64_shift_reg_imm(b->jit_ptr,X86_SHL,AMD64_RBX,ppc32_get_cr_bit(bd)); |
amd64_shift_reg_imm(iop->ob_ptr,X86_SHL,hreg_t0,ppc32_get_cr_bit(bd)); |
1917 |
amd64_alu_membase_reg_size(b->jit_ptr,X86_OR, |
amd64_alu_membase_reg_size(iop->ob_ptr,X86_OR, |
1918 |
AMD64_R15, |
AMD64_R15, |
1919 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
1920 |
AMD64_RBX,4); |
hreg_t0,4); |
1921 |
|
|
1922 |
|
ppc32_jit_close_hreg_seq(cpu); |
1923 |
return(0); |
return(0); |
1924 |
} |
} |
1925 |
|
|
1929 |
int bd = bits(insn,21,25); |
int bd = bits(insn,21,25); |
1930 |
int bb = bits(insn,16,20); |
int bb = bits(insn,16,20); |
1931 |
int ba = bits(insn,11,15); |
int ba = bits(insn,11,15); |
1932 |
|
int hreg_t0; |
1933 |
|
jit_op_t *iop; |
1934 |
|
|
1935 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
1936 |
|
|
1937 |
|
ppc32_jit_start_hreg_seq(cpu,"crnor"); |
1938 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
1939 |
|
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RDX); |
1940 |
|
|
1941 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(ba)); |
1942 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bb)); |
1943 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bd)); |
1944 |
|
|
1945 |
|
iop = ppc32_op_emit_insn_output(cpu,3,"crnor"); |
1946 |
|
|
1947 |
/* test $ba bit */ |
/* test $ba bit */ |
1948 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
1949 |
AMD64_R15, |
AMD64_R15, |
1950 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
1951 |
(1 << ppc32_get_cr_bit(ba))); |
(1 << ppc32_get_cr_bit(ba))); |
1952 |
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RAX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_NZ,AMD64_RDX,FALSE); |
1953 |
|
|
1954 |
/* test $bb bit */ |
/* test $bb bit */ |
1955 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
1956 |
AMD64_R15, |
AMD64_R15, |
1957 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
1958 |
(1 << ppc32_get_cr_bit(bb))); |
(1 << ppc32_get_cr_bit(bb))); |
1959 |
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RBX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_NZ,hreg_t0,FALSE); |
1960 |
|
|
1961 |
/* result of NOR between $ba and $bb */ |
/* result of NOR between $ba and $bb */ |
1962 |
amd64_alu_reg_reg(b->jit_ptr,X86_OR,AMD64_RBX,AMD64_RAX); |
amd64_alu_reg_reg(iop->ob_ptr,X86_OR,hreg_t0,AMD64_RDX); |
1963 |
amd64_not_reg(b->jit_ptr,AMD64_RBX); |
amd64_not_reg(iop->ob_ptr,hreg_t0); |
1964 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RBX,0x01); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,0x01); |
1965 |
|
|
1966 |
/* set/clear $bd bit depending on the result */ |
/* set/clear $bd bit depending on the result */ |
1967 |
amd64_alu_membase_imm_size(b->jit_ptr,X86_AND, |
amd64_alu_membase_imm_size(iop->ob_ptr,X86_AND, |
1968 |
AMD64_R15, |
AMD64_R15, |
1969 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
1970 |
~(1 << ppc32_get_cr_bit(bd)),4); |
~(1 << ppc32_get_cr_bit(bd)),4); |
1971 |
|
|
1972 |
amd64_shift_reg_imm(b->jit_ptr,X86_SHL,AMD64_RBX,ppc32_get_cr_bit(bd)); |
amd64_shift_reg_imm(iop->ob_ptr,X86_SHL,hreg_t0,ppc32_get_cr_bit(bd)); |
1973 |
amd64_alu_membase_reg_size(b->jit_ptr,X86_OR, |
amd64_alu_membase_reg_size(iop->ob_ptr,X86_OR, |
1974 |
AMD64_R15, |
AMD64_R15, |
1975 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
1976 |
AMD64_RBX,4); |
hreg_t0,4); |
1977 |
|
|
1978 |
|
ppc32_jit_close_hreg_seq(cpu); |
1979 |
return(0); |
return(0); |
1980 |
} |
} |
1981 |
|
|
1985 |
int bd = bits(insn,21,25); |
int bd = bits(insn,21,25); |
1986 |
int bb = bits(insn,16,20); |
int bb = bits(insn,16,20); |
1987 |
int ba = bits(insn,11,15); |
int ba = bits(insn,11,15); |
1988 |
|
int hreg_t0; |
1989 |
|
jit_op_t *iop; |
1990 |
|
|
1991 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
1992 |
|
|
1993 |
|
ppc32_jit_start_hreg_seq(cpu,"cror"); |
1994 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
1995 |
|
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RDX); |
1996 |
|
|
1997 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(ba)); |
1998 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bb)); |
1999 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bd)); |
2000 |
|
|
2001 |
|
iop = ppc32_op_emit_insn_output(cpu,3,"cror"); |
2002 |
|
|
2003 |
/* test $ba bit */ |
/* test $ba bit */ |
2004 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
2005 |
AMD64_R15, |
AMD64_R15, |
2006 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
2007 |
(1 << ppc32_get_cr_bit(ba))); |
(1 << ppc32_get_cr_bit(ba))); |
2008 |
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RAX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_NZ,AMD64_RDX,FALSE); |
2009 |
|
|
2010 |
/* test $bb bit */ |
/* test $bb bit */ |
2011 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
2012 |
AMD64_R15, |
AMD64_R15, |
2013 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
2014 |
(1 << ppc32_get_cr_bit(bb))); |
(1 << ppc32_get_cr_bit(bb))); |
2015 |
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RBX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_NZ,hreg_t0,FALSE); |
2016 |
|
|
2017 |
/* result of NOR between $ba and $bb */ |
/* result of NOR between $ba and $bb */ |
2018 |
amd64_alu_reg_reg(b->jit_ptr,X86_OR,AMD64_RBX,AMD64_RAX); |
amd64_alu_reg_reg(iop->ob_ptr,X86_OR,hreg_t0,AMD64_RDX); |
2019 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RBX,0x01); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,0x01); |
2020 |
|
|
2021 |
/* set/clear $bd bit depending on the result */ |
/* set/clear $bd bit depending on the result */ |
2022 |
amd64_alu_membase_imm_size(b->jit_ptr,X86_AND, |
amd64_alu_membase_imm_size(iop->ob_ptr,X86_AND, |
2023 |
AMD64_R15, |
AMD64_R15, |
2024 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
2025 |
~(1 << ppc32_get_cr_bit(bd)),4); |
~(1 << ppc32_get_cr_bit(bd)),4); |
2026 |
|
|
2027 |
amd64_shift_reg_imm(b->jit_ptr,X86_SHL,AMD64_RBX,ppc32_get_cr_bit(bd)); |
amd64_shift_reg_imm(iop->ob_ptr,X86_SHL,hreg_t0,ppc32_get_cr_bit(bd)); |
2028 |
amd64_alu_membase_reg_size(b->jit_ptr,X86_OR, |
amd64_alu_membase_reg_size(iop->ob_ptr,X86_OR, |
2029 |
AMD64_R15, |
AMD64_R15, |
2030 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
2031 |
AMD64_RBX,4); |
hreg_t0,4); |
2032 |
|
|
2033 |
|
ppc32_jit_close_hreg_seq(cpu); |
2034 |
return(0); |
return(0); |
2035 |
} |
} |
2036 |
|
|
2040 |
int bd = bits(insn,21,25); |
int bd = bits(insn,21,25); |
2041 |
int bb = bits(insn,16,20); |
int bb = bits(insn,16,20); |
2042 |
int ba = bits(insn,11,15); |
int ba = bits(insn,11,15); |
2043 |
|
int hreg_t0; |
2044 |
|
jit_op_t *iop; |
2045 |
|
|
2046 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
2047 |
|
|
2048 |
|
ppc32_jit_start_hreg_seq(cpu,"crorc"); |
2049 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
2050 |
|
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RDX); |
2051 |
|
|
2052 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(ba)); |
2053 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bb)); |
2054 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bd)); |
2055 |
|
|
2056 |
|
iop = ppc32_op_emit_insn_output(cpu,3,"crorc"); |
2057 |
|
|
2058 |
/* test $ba bit */ |
/* test $ba bit */ |
2059 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
2060 |
AMD64_R15, |
AMD64_R15, |
2061 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
2062 |
(1 << ppc32_get_cr_bit(ba))); |
(1 << ppc32_get_cr_bit(ba))); |
2063 |
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RAX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_NZ,AMD64_RDX,FALSE); |
2064 |
|
|
2065 |
/* test $bb bit */ |
/* test $bb bit */ |
2066 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
2067 |
AMD64_R15, |
AMD64_R15, |
2068 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
2069 |
(1 << ppc32_get_cr_bit(bb))); |
(1 << ppc32_get_cr_bit(bb))); |
2070 |
amd64_set_reg(b->jit_ptr,X86_CC_Z,AMD64_RBX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_Z,hreg_t0,FALSE); |
2071 |
|
|
2072 |
/* result of ORC between $ba and $bb */ |
/* result of ORC between $ba and $bb */ |
2073 |
amd64_alu_reg_reg(b->jit_ptr,X86_OR,AMD64_RBX,AMD64_RAX); |
amd64_alu_reg_reg(iop->ob_ptr,X86_OR,hreg_t0,AMD64_RDX); |
2074 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RBX,0x01); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,0x01); |
2075 |
|
|
2076 |
/* set/clear $bd bit depending on the result */ |
/* set/clear $bd bit depending on the result */ |
2077 |
amd64_alu_membase_imm_size(b->jit_ptr,X86_AND, |
amd64_alu_membase_imm_size(iop->ob_ptr,X86_AND, |
2078 |
AMD64_R15, |
AMD64_R15, |
2079 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
2080 |
~(1 << ppc32_get_cr_bit(bd)),4); |
~(1 << ppc32_get_cr_bit(bd)),4); |
2081 |
|
|
2082 |
amd64_shift_reg_imm(b->jit_ptr,X86_SHL,AMD64_RBX,ppc32_get_cr_bit(bd)); |
amd64_shift_reg_imm(iop->ob_ptr,X86_SHL,hreg_t0,ppc32_get_cr_bit(bd)); |
2083 |
amd64_alu_membase_reg_size(b->jit_ptr,X86_OR, |
amd64_alu_membase_reg_size(iop->ob_ptr,X86_OR, |
2084 |
AMD64_R15, |
AMD64_R15, |
2085 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
2086 |
AMD64_RBX,4); |
hreg_t0,4); |
2087 |
|
|
2088 |
|
ppc32_jit_close_hreg_seq(cpu); |
2089 |
return(0); |
return(0); |
2090 |
} |
} |
2091 |
|
|
2095 |
int bd = bits(insn,21,25); |
int bd = bits(insn,21,25); |
2096 |
int bb = bits(insn,16,20); |
int bb = bits(insn,16,20); |
2097 |
int ba = bits(insn,11,15); |
int ba = bits(insn,11,15); |
2098 |
|
int hreg_t0; |
2099 |
|
jit_op_t *iop; |
2100 |
|
|
2101 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
2102 |
|
|
2103 |
|
ppc32_jit_start_hreg_seq(cpu,"crxor"); |
2104 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
2105 |
|
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RDX); |
2106 |
|
|
2107 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(ba)); |
2108 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bb)); |
2109 |
|
ppc32_op_emit_require_flags(cpu,ppc32_get_cr_field(bd)); |
2110 |
|
|
2111 |
|
iop = ppc32_op_emit_insn_output(cpu,3,"crxor"); |
2112 |
|
|
2113 |
/* test $ba bit */ |
/* test $ba bit */ |
2114 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
2115 |
AMD64_R15, |
AMD64_R15, |
2116 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(ba)), |
2117 |
(1 << ppc32_get_cr_bit(ba))); |
(1 << ppc32_get_cr_bit(ba))); |
2118 |
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RAX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_NZ,AMD64_RDX,FALSE); |
2119 |
|
|
2120 |
/* test $bb bit */ |
/* test $bb bit */ |
2121 |
amd64_test_membase_imm(b->jit_ptr, |
amd64_test_membase_imm(iop->ob_ptr, |
2122 |
AMD64_R15, |
AMD64_R15, |
2123 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bb)), |
2124 |
(1 << ppc32_get_cr_bit(bb))); |
(1 << ppc32_get_cr_bit(bb))); |
2125 |
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RBX,FALSE); |
amd64_set_reg(iop->ob_ptr,X86_CC_NZ,hreg_t0,FALSE); |
2126 |
|
|
2127 |
/* result of XOR between $ba and $bb */ |
/* result of XOR between $ba and $bb */ |
2128 |
amd64_alu_reg_reg(b->jit_ptr,X86_XOR,AMD64_RBX,AMD64_RAX); |
amd64_alu_reg_reg(iop->ob_ptr,X86_XOR,hreg_t0,AMD64_RDX); |
2129 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RBX,0x01); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,0x01); |
2130 |
|
|
2131 |
/* set/clear $bd bit depending on the result */ |
/* set/clear $bd bit depending on the result */ |
2132 |
amd64_alu_membase_imm_size(b->jit_ptr,X86_AND, |
amd64_alu_membase_imm_size(iop->ob_ptr,X86_AND, |
2133 |
AMD64_R15, |
AMD64_R15, |
2134 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
2135 |
~(1 << ppc32_get_cr_bit(bd)),4); |
~(1 << ppc32_get_cr_bit(bd)),4); |
2136 |
|
|
2137 |
amd64_shift_reg_imm(b->jit_ptr,X86_SHL,AMD64_RBX,ppc32_get_cr_bit(bd)); |
amd64_shift_reg_imm(iop->ob_ptr,X86_SHL,hreg_t0,ppc32_get_cr_bit(bd)); |
2138 |
amd64_alu_membase_reg_size(b->jit_ptr,X86_OR, |
amd64_alu_membase_reg_size(iop->ob_ptr,X86_OR, |
2139 |
AMD64_R15, |
AMD64_R15, |
2140 |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
PPC32_CR_FIELD_OFFSET(ppc32_get_cr_field(bd)), |
2141 |
AMD64_RBX,4); |
hreg_t0,4); |
2142 |
|
|
2143 |
|
ppc32_jit_close_hreg_seq(cpu); |
2144 |
return(0); |
return(0); |
2145 |
} |
} |
2146 |
|
|
2150 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
2151 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2152 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2153 |
|
int hreg_rb; |
2154 |
|
jit_op_t *iop; |
2155 |
|
|
2156 |
ppc32_load_gpr(b,AMD64_RAX,ra); |
ppc32_jit_start_hreg_seq(cpu,"divwu"); |
2157 |
ppc32_load_gpr(b,AMD64_RBX,rb); |
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RAX); |
2158 |
ppc32_load_imm(b,AMD64_RDX,0); |
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RDX); |
2159 |
|
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
2160 |
|
|
2161 |
|
/* $rd = $ra / $rb */ |
2162 |
|
ppc32_op_emit_load_gpr(cpu,AMD64_RAX,ra); |
2163 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
2164 |
|
|
2165 |
amd64_div_reg_size(b->jit_ptr,AMD64_RBX,0,4); |
iop = ppc32_op_emit_insn_output(cpu,2,"divwu"); |
2166 |
ppc32_store_gpr(b,rd,AMD64_RAX); |
ppc32_load_imm(&iop->ob_ptr,AMD64_RDX,0); |
2167 |
|
|
2168 |
if (insn & 1) { |
amd64_div_reg_size(iop->ob_ptr,hreg_rb,0,4); |
2169 |
amd64_test_reg_reg(b->jit_ptr,AMD64_RAX,AMD64_RAX); |
|
2170 |
ppc32_update_cr0(b); |
if (insn & 1) |
2171 |
} |
amd64_test_reg_reg_size(iop->ob_ptr,AMD64_RAX,AMD64_RAX,4); |
2172 |
|
|
2173 |
|
ppc32_op_emit_store_gpr(cpu,rd,AMD64_RAX); |
2174 |
|
|
2175 |
|
if (insn & 1) |
2176 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
2177 |
|
|
2178 |
|
/* edx:eax are directly modified: throw them */ |
2179 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RAX); |
2180 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
2181 |
|
|
2182 |
|
ppc32_jit_close_hreg_seq(cpu); |
2183 |
return(0); |
return(0); |
2184 |
} |
} |
2185 |
|
|
2189 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
2190 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2191 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2192 |
|
int hreg_rs,hreg_ra,hreg_rb; |
2193 |
|
jit_op_t *iop; |
2194 |
|
|
2195 |
/* $ra = ~($rs ^ $rb) */ |
/* $ra = ~($rs ^ $rb) */ |
2196 |
ppc32_load_gpr(b,AMD64_RBX,rs); |
ppc32_jit_start_hreg_seq(cpu,"eqv"); |
2197 |
ppc32_alu_gpr(b,X86_XOR,AMD64_RBX,rb); |
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
2198 |
amd64_not_reg(b->jit_ptr,AMD64_RBX); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
2199 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
2200 |
|
|
2201 |
if (insn & 1) { |
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
2202 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RBX,AMD64_RBX,4); |
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
2203 |
ppc32_update_cr0(b); |
|
2204 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"eqv"); |
2205 |
|
|
2206 |
|
if (ra == rs) |
2207 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_XOR,hreg_ra,hreg_rb,4); |
2208 |
|
else if (ra == rb) |
2209 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_XOR,hreg_ra,hreg_rs,4); |
2210 |
|
else { |
2211 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
2212 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_XOR,hreg_ra,hreg_rb,4); |
2213 |
} |
} |
2214 |
|
|
2215 |
|
amd64_not_reg(iop->ob_ptr,hreg_ra); |
2216 |
|
|
2217 |
|
if (insn & 1) |
2218 |
|
amd64_test_reg_reg_size(iop->ob_ptr,hreg_ra,hreg_ra,4); |
2219 |
|
|
2220 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
2221 |
|
|
2222 |
|
if (insn & 1) |
2223 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
2224 |
|
|
2225 |
|
ppc32_jit_close_hreg_seq(cpu); |
2226 |
return(0); |
return(0); |
2227 |
} |
} |
2228 |
|
|
2231 |
{ |
{ |
2232 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
2233 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2234 |
|
int hreg_rs,hreg_ra; |
2235 |
|
jit_op_t *iop; |
2236 |
|
|
2237 |
ppc32_load_gpr(b,AMD64_RBX,rs); |
/* $ra = extsb($rs) */ |
2238 |
amd64_shift_reg_imm_size(b->jit_ptr,X86_SHL,AMD64_RBX,24,4); |
ppc32_jit_start_hreg_seq(cpu,"extsb"); |
2239 |
amd64_shift_reg_imm_size(b->jit_ptr,X86_SAR,AMD64_RBX,24,4); |
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
2240 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
2241 |
|
|
2242 |
if (insn & 1) { |
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
|
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RBX,AMD64_RBX,4); |
|
|
ppc32_update_cr0(b); |
|
|
} |
|
2243 |
|
|
2244 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"extsb"); |
2245 |
|
|
2246 |
|
if (rs != ra) |
2247 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
2248 |
|
|
2249 |
|
amd64_shift_reg_imm_size(iop->ob_ptr,X86_SHL,hreg_ra,24,4); |
2250 |
|
amd64_shift_reg_imm_size(iop->ob_ptr,X86_SAR,hreg_ra,24,4); |
2251 |
|
|
2252 |
|
if (insn & 1) |
2253 |
|
amd64_test_reg_reg_size(iop->ob_ptr,hreg_ra,hreg_ra,4); |
2254 |
|
|
2255 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
2256 |
|
|
2257 |
|
if (insn & 1) |
2258 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
2259 |
|
|
2260 |
|
ppc32_jit_close_hreg_seq(cpu); |
2261 |
return(0); |
return(0); |
2262 |
} |
} |
2263 |
|
|
2266 |
{ |
{ |
2267 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
2268 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2269 |
|
int hreg_rs,hreg_ra; |
2270 |
|
jit_op_t *iop; |
2271 |
|
|
2272 |
ppc32_load_gpr(b,AMD64_RBX,rs); |
/* $ra = extsh($rs) */ |
2273 |
amd64_shift_reg_imm_size(b->jit_ptr,X86_SHL,AMD64_RBX,16,4); |
ppc32_jit_start_hreg_seq(cpu,"extsh"); |
2274 |
amd64_shift_reg_imm_size(b->jit_ptr,X86_SAR,AMD64_RBX,16,4); |
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
2275 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
2276 |
|
|
2277 |
if (insn & 1) { |
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
2278 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RBX,AMD64_RBX,4); |
|
2279 |
ppc32_update_cr0(b); |
iop = ppc32_op_emit_insn_output(cpu,2,"extsh"); |
|
} |
|
2280 |
|
|
2281 |
|
if (rs != ra) |
2282 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
2283 |
|
|
2284 |
|
amd64_shift_reg_imm_size(iop->ob_ptr,X86_SHL,hreg_ra,16,4); |
2285 |
|
amd64_shift_reg_imm_size(iop->ob_ptr,X86_SAR,hreg_ra,16,4); |
2286 |
|
|
2287 |
|
if (insn & 1) |
2288 |
|
amd64_test_reg_reg_size(iop->ob_ptr,hreg_ra,hreg_ra,4); |
2289 |
|
|
2290 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
2291 |
|
|
2292 |
|
if (insn & 1) |
2293 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
2294 |
|
|
2295 |
|
ppc32_jit_close_hreg_seq(cpu); |
2296 |
return(0); |
return(0); |
2297 |
} |
} |
2298 |
|
|
2304 |
m_uint16_t offset = bits(insn,0,15); |
m_uint16_t offset = bits(insn,0,15); |
2305 |
|
|
2306 |
//ppc32_emit_memop(b,PPC_MEMOP_LBZ,ra,offset,rs,0); |
//ppc32_emit_memop(b,PPC_MEMOP_LBZ,ra,offset,rs,0); |
2307 |
ppc32_emit_memop_fast(b,0,PPC_MEMOP_LBZ,ra,offset,rs,ppc32_memop_fast_lbz); |
ppc32_emit_memop_fast(cpu,b,0,PPC_MEMOP_LBZ,ra,offset,rs, |
2308 |
|
ppc32_memop_fast_lbz); |
2309 |
return(0); |
return(0); |
2310 |
} |
} |
2311 |
|
|
2316 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2317 |
m_uint16_t offset = bits(insn,0,15); |
m_uint16_t offset = bits(insn,0,15); |
2318 |
|
|
2319 |
ppc32_emit_memop(b,PPC_MEMOP_LBZ,ra,offset,rs,1); |
ppc32_emit_memop(cpu,b,PPC_MEMOP_LBZ,ra,offset,rs,1); |
2320 |
return(0); |
return(0); |
2321 |
} |
} |
2322 |
|
|
2327 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2328 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2329 |
|
|
2330 |
ppc32_emit_memop_idx(b,PPC_MEMOP_LBZ,ra,rb,rs,1); |
ppc32_emit_memop_idx(cpu,b,PPC_MEMOP_LBZ,ra,rb,rs,1); |
2331 |
return(0); |
return(0); |
2332 |
} |
} |
2333 |
|
|
2338 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2339 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2340 |
|
|
2341 |
ppc32_emit_memop_idx(b,PPC_MEMOP_LBZ,ra,rb,rs,0); |
ppc32_emit_memop_idx(cpu,b,PPC_MEMOP_LBZ,ra,rb,rs,0); |
2342 |
return(0); |
return(0); |
2343 |
} |
} |
2344 |
|
|
2349 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2350 |
m_uint16_t offset = bits(insn,0,15); |
m_uint16_t offset = bits(insn,0,15); |
2351 |
|
|
2352 |
ppc32_emit_memop(b,PPC_MEMOP_LHA,ra,offset,rs,0); |
ppc32_emit_memop(cpu,b,PPC_MEMOP_LHA,ra,offset,rs,0); |
2353 |
return(0); |
return(0); |
2354 |
} |
} |
2355 |
|
|
2360 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2361 |
m_uint16_t offset = bits(insn,0,15); |
m_uint16_t offset = bits(insn,0,15); |
2362 |
|
|
2363 |
ppc32_emit_memop(b,PPC_MEMOP_LHA,ra,offset,rs,1); |
ppc32_emit_memop(cpu,b,PPC_MEMOP_LHA,ra,offset,rs,1); |
2364 |
return(0); |
return(0); |
2365 |
} |
} |
2366 |
|
|
2371 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2372 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2373 |
|
|
2374 |
ppc32_emit_memop_idx(b,PPC_MEMOP_LHA,ra,rb,rs,1); |
ppc32_emit_memop_idx(cpu,b,PPC_MEMOP_LHA,ra,rb,rs,1); |
2375 |
return(0); |
return(0); |
2376 |
} |
} |
2377 |
|
|
2382 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2383 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2384 |
|
|
2385 |
ppc32_emit_memop_idx(b,PPC_MEMOP_LHA,ra,rb,rs,0); |
ppc32_emit_memop_idx(cpu,b,PPC_MEMOP_LHA,ra,rb,rs,0); |
2386 |
return(0); |
return(0); |
2387 |
} |
} |
2388 |
|
|
2393 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2394 |
m_uint16_t offset = bits(insn,0,15); |
m_uint16_t offset = bits(insn,0,15); |
2395 |
|
|
2396 |
ppc32_emit_memop(b,PPC_MEMOP_LHZ,ra,offset,rs,0); |
ppc32_emit_memop(cpu,b,PPC_MEMOP_LHZ,ra,offset,rs,0); |
2397 |
return(0); |
return(0); |
2398 |
} |
} |
2399 |
|
|
2404 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2405 |
m_uint16_t offset = bits(insn,0,15); |
m_uint16_t offset = bits(insn,0,15); |
2406 |
|
|
2407 |
ppc32_emit_memop(b,PPC_MEMOP_LHZ,ra,offset,rs,1); |
ppc32_emit_memop(cpu,b,PPC_MEMOP_LHZ,ra,offset,rs,1); |
2408 |
return(0); |
return(0); |
2409 |
} |
} |
2410 |
|
|
2415 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2416 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2417 |
|
|
2418 |
ppc32_emit_memop_idx(b,PPC_MEMOP_LHZ,ra,rb,rs,1); |
ppc32_emit_memop_idx(cpu,b,PPC_MEMOP_LHZ,ra,rb,rs,1); |
2419 |
return(0); |
return(0); |
2420 |
} |
} |
2421 |
|
|
2426 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2427 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2428 |
|
|
2429 |
ppc32_emit_memop_idx(b,PPC_MEMOP_LHZ,ra,rb,rs,0); |
ppc32_emit_memop_idx(cpu,b,PPC_MEMOP_LHZ,ra,rb,rs,0); |
2430 |
return(0); |
return(0); |
2431 |
} |
} |
2432 |
|
|
2438 |
m_uint16_t offset = bits(insn,0,15); |
m_uint16_t offset = bits(insn,0,15); |
2439 |
|
|
2440 |
//ppc32_emit_memop(b,PPC_MEMOP_LWZ,ra,offset,rs,0); |
//ppc32_emit_memop(b,PPC_MEMOP_LWZ,ra,offset,rs,0); |
2441 |
ppc32_emit_memop_fast(b,0,PPC_MEMOP_LWZ,ra,offset,rs,ppc32_memop_fast_lwz); |
ppc32_emit_memop_fast(cpu,b,0,PPC_MEMOP_LWZ,ra,offset,rs, |
2442 |
|
ppc32_memop_fast_lwz); |
2443 |
return(0); |
return(0); |
2444 |
} |
} |
2445 |
|
|
2450 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2451 |
m_uint16_t offset = bits(insn,0,15); |
m_uint16_t offset = bits(insn,0,15); |
2452 |
|
|
2453 |
ppc32_emit_memop(b,PPC_MEMOP_LWZ,ra,offset,rs,1); |
ppc32_emit_memop(cpu,b,PPC_MEMOP_LWZ,ra,offset,rs,1); |
2454 |
return(0); |
return(0); |
2455 |
} |
} |
2456 |
|
|
2461 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2462 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2463 |
|
|
2464 |
ppc32_emit_memop_idx(b,PPC_MEMOP_LWZ,ra,rb,rs,1); |
ppc32_emit_memop_idx(cpu,b,PPC_MEMOP_LWZ,ra,rb,rs,1); |
2465 |
return(0); |
return(0); |
2466 |
} |
} |
2467 |
|
|
2472 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2473 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2474 |
|
|
2475 |
ppc32_emit_memop_idx(b,PPC_MEMOP_LWZ,ra,rb,rs,0); |
ppc32_emit_memop_idx(cpu,b,PPC_MEMOP_LWZ,ra,rb,rs,0); |
2476 |
return(0); |
return(0); |
2477 |
} |
} |
2478 |
|
|
2481 |
{ |
{ |
2482 |
int rd = bits(insn,23,25); |
int rd = bits(insn,23,25); |
2483 |
int rs = bits(insn,18,20); |
int rs = bits(insn,18,20); |
2484 |
|
int hreg_t0; |
2485 |
|
jit_op_t *iop; |
2486 |
|
|
2487 |
|
ppc32_jit_start_hreg_seq(cpu,"mcrf"); |
2488 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
2489 |
|
ppc32_op_emit_require_flags(cpu,rs); |
2490 |
|
|
2491 |
/* Load "rs" field in %rdx */ |
iop = ppc32_op_emit_insn_output(cpu,1,"mcrf"); |
2492 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RDX, |
|
2493 |
|
/* Load "rs" field in %edx */ |
2494 |
|
amd64_mov_reg_membase(iop->ob_ptr,hreg_t0, |
2495 |
AMD64_R15,PPC32_CR_FIELD_OFFSET(rs),4); |
AMD64_R15,PPC32_CR_FIELD_OFFSET(rs),4); |
2496 |
|
|
2497 |
/* Store it in "rd" field */ |
/* Store it in "rd" field */ |
2498 |
amd64_mov_membase_reg(b->jit_ptr,AMD64_R15,PPC32_CR_FIELD_OFFSET(rd), |
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,PPC32_CR_FIELD_OFFSET(rd), |
2499 |
AMD64_RDX,4); |
hreg_t0,4); |
2500 |
|
|
2501 |
|
ppc32_jit_close_hreg_seq(cpu); |
2502 |
return(0); |
return(0); |
2503 |
} |
} |
2504 |
|
|
2506 |
DECLARE_INSN(MFCR) |
DECLARE_INSN(MFCR) |
2507 |
{ |
{ |
2508 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
2509 |
|
int hreg_rd,hreg_t0; |
2510 |
|
jit_op_t *iop; |
2511 |
int i; |
int i; |
2512 |
|
|
2513 |
amd64_alu_reg_reg(b->jit_ptr,X86_XOR,AMD64_RAX,AMD64_RAX); |
ppc32_jit_start_hreg_seq(cpu,"mfcr"); |
2514 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
2515 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
2516 |
|
ppc32_op_emit_require_flags(cpu,JIT_OP_PPC_ALL_FLAGS); |
2517 |
|
|
2518 |
|
iop = ppc32_op_emit_insn_output(cpu,3,"mfcr"); |
2519 |
|
|
2520 |
|
amd64_alu_reg_reg(iop->ob_ptr,X86_XOR,hreg_rd,hreg_rd); |
2521 |
|
|
2522 |
for(i=0;i<8;i++) { |
for(i=0;i<8;i++) { |
2523 |
/* load field in %rdx */ |
/* load field in %edx */ |
2524 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RDX, |
amd64_mov_reg_membase(iop->ob_ptr,hreg_t0, |
2525 |
AMD64_R15,PPC32_CR_FIELD_OFFSET(i),4); |
AMD64_R15,PPC32_CR_FIELD_OFFSET(i),4); |
2526 |
amd64_shift_reg_imm(b->jit_ptr,X86_SHL,AMD64_RAX,4); |
amd64_shift_reg_imm(iop->ob_ptr,X86_SHL,hreg_rd,4); |
2527 |
amd64_alu_reg_reg(b->jit_ptr,X86_OR,AMD64_RAX,AMD64_RDX); |
amd64_alu_reg_reg(iop->ob_ptr,X86_OR,hreg_rd,hreg_t0); |
2528 |
} |
} |
2529 |
|
|
2530 |
ppc32_store_gpr(b,rd,AMD64_RAX); |
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
2531 |
|
|
2532 |
|
ppc32_jit_close_hreg_seq(cpu); |
2533 |
return(0); |
return(0); |
2534 |
} |
} |
2535 |
|
|
2537 |
DECLARE_INSN(MFMSR) |
DECLARE_INSN(MFMSR) |
2538 |
{ |
{ |
2539 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
2540 |
|
int hreg_rd; |
2541 |
|
jit_op_t *iop; |
2542 |
|
|
2543 |
|
ppc32_jit_start_hreg_seq(cpu,"mfmsr"); |
2544 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
2545 |
|
|
2546 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RAX, |
iop = ppc32_op_emit_insn_output(cpu,1,"mfmsr"); |
2547 |
|
amd64_mov_reg_membase(iop->ob_ptr,hreg_rd, |
2548 |
AMD64_R15,OFFSET(cpu_ppc_t,msr),4); |
AMD64_R15,OFFSET(cpu_ppc_t,msr),4); |
2549 |
ppc32_store_gpr(b,rd,AMD64_RAX); |
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
2550 |
|
|
2551 |
|
ppc32_jit_close_hreg_seq(cpu); |
2552 |
return(0); |
return(0); |
2553 |
} |
} |
2554 |
|
|
2557 |
{ |
{ |
2558 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
2559 |
int sr = bits(insn,16,19); |
int sr = bits(insn,16,19); |
2560 |
|
int hreg_rd; |
2561 |
|
jit_op_t *iop; |
2562 |
|
|
2563 |
|
ppc32_jit_start_hreg_seq(cpu,"mfsr"); |
2564 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
2565 |
|
|
2566 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"mfsr"); |
2567 |
|
|
2568 |
amd64_mov_reg_membase(b->jit_ptr,AMD64_RAX, |
amd64_mov_reg_membase(iop->ob_ptr,hreg_rd, |
2569 |
AMD64_R15,(OFFSET(cpu_ppc_t,sr) + (sr << 2)),4); |
AMD64_R15,(OFFSET(cpu_ppc_t,sr) + (sr << 2)),4); |
2570 |
ppc32_store_gpr(b,rd,AMD64_RAX); |
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
2571 |
|
|
2572 |
|
ppc32_jit_close_hreg_seq(cpu); |
2573 |
return(0); |
return(0); |
2574 |
} |
} |
2575 |
|
|
2578 |
{ |
{ |
2579 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
2580 |
int crm = bits(insn,12,19); |
int crm = bits(insn,12,19); |
2581 |
|
int hreg_rs,hreg_t0; |
2582 |
|
jit_op_t *iop; |
2583 |
int i; |
int i; |
2584 |
|
|
2585 |
ppc32_load_gpr(b,AMD64_RDX,rs); |
ppc32_jit_start_hreg_seq(cpu,"mtcrf"); |
2586 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
2587 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
2588 |
|
|
2589 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
2590 |
|
|
2591 |
|
iop = ppc32_op_emit_insn_output(cpu,3,"mtcrf"); |
2592 |
|
|
2593 |
for(i=0;i<8;i++) |
for(i=0;i<8;i++) |
2594 |
if (crm & (1 << (7 - i))) { |
if (crm & (1 << (7 - i))) { |
2595 |
amd64_mov_reg_reg(b->jit_ptr,AMD64_RAX,AMD64_RDX,8); |
amd64_mov_reg_reg(iop->ob_ptr,hreg_t0,hreg_rs,4); |
2596 |
|
|
2597 |
if (i != 7) |
if (i != 7) |
2598 |
amd64_shift_reg_imm(b->jit_ptr,X86_SHR,AMD64_RAX,28 - (i << 2)); |
amd64_shift_reg_imm(iop->ob_ptr,X86_SHR,hreg_t0,28 - (i << 2)); |
2599 |
|
|
2600 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RAX,0x0F); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,0x0F); |
2601 |
amd64_mov_membase_reg(b->jit_ptr,AMD64_R15,PPC32_CR_FIELD_OFFSET(i), |
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,PPC32_CR_FIELD_OFFSET(i), |
2602 |
AMD64_RAX,4); |
hreg_t0,4); |
2603 |
} |
} |
2604 |
|
|
2605 |
|
ppc32_op_emit_basic_opcode(cpu,JIT_OP_TRASH_FLAGS); |
2606 |
|
|
2607 |
|
ppc32_jit_close_hreg_seq(cpu); |
2608 |
return(0); |
return(0); |
2609 |
} |
} |
2610 |
|
|
2614 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
2615 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2616 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2617 |
|
int hreg_rb; |
2618 |
|
jit_op_t *iop; |
2619 |
|
|
2620 |
ppc32_load_gpr(b,AMD64_RAX,ra); |
ppc32_jit_start_hreg_seq(cpu,"mulhw"); |
2621 |
ppc32_load_gpr(b,AMD64_RBX,rb); |
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RAX); |
2622 |
amd64_mul_reg_size(b->jit_ptr,AMD64_RBX,1,4); |
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RDX); |
2623 |
ppc32_store_gpr(b,rd,AMD64_RDX); |
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
2624 |
|
|
2625 |
|
ppc32_op_emit_load_gpr(cpu,AMD64_RAX,ra); |
2626 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
2627 |
|
|
2628 |
|
/* rd = hi(ra * rb) */ |
2629 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"mulhw"); |
2630 |
|
amd64_mul_reg_size(iop->ob_ptr,hreg_rb,1,4); |
2631 |
|
|
2632 |
if (insn & 1) { |
if (insn & 1) |
2633 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RDX,AMD64_RDX,4); |
amd64_test_reg_reg_size(iop->ob_ptr,AMD64_RDX,AMD64_RDX,4); |
2634 |
ppc32_update_cr0(b); |
|
2635 |
} |
ppc32_op_emit_store_gpr(cpu,rd,AMD64_RDX); |
2636 |
|
|
2637 |
|
if (insn & 1) |
2638 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
2639 |
|
|
2640 |
|
/* edx:eax are directly modified: throw them */ |
2641 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RAX); |
2642 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
2643 |
|
|
2644 |
|
ppc32_jit_close_hreg_seq(cpu); |
2645 |
return(0); |
return(0); |
2646 |
} |
} |
2647 |
|
|
2651 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
2652 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2653 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2654 |
|
int hreg_rb; |
2655 |
|
jit_op_t *iop; |
2656 |
|
|
2657 |
ppc32_load_gpr(b,AMD64_RAX,ra); |
ppc32_jit_start_hreg_seq(cpu,"mulhwu"); |
2658 |
ppc32_load_gpr(b,AMD64_RBX,rb); |
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RAX); |
2659 |
amd64_mul_reg_size(b->jit_ptr,AMD64_RBX,0,4); |
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RDX); |
2660 |
ppc32_store_gpr(b,rd,AMD64_RDX); |
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
2661 |
|
|
2662 |
|
ppc32_op_emit_load_gpr(cpu,AMD64_RAX,ra); |
2663 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
2664 |
|
|
2665 |
|
/* rd = hi(ra * rb) */ |
2666 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"mulhwu"); |
2667 |
|
amd64_mul_reg_size(iop->ob_ptr,hreg_rb,0,4); |
2668 |
|
|
2669 |
if (insn & 1) { |
if (insn & 1) |
2670 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RDX,AMD64_RDX,4); |
amd64_test_reg_reg_size(iop->ob_ptr,AMD64_RDX,AMD64_RDX,4); |
2671 |
ppc32_update_cr0(b); |
|
2672 |
} |
ppc32_op_emit_store_gpr(cpu,rd,AMD64_RDX); |
2673 |
|
|
2674 |
|
if (insn & 1) |
2675 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
2676 |
|
|
2677 |
|
/* edx:eax are directly modified: throw them */ |
2678 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RAX); |
2679 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
2680 |
|
|
2681 |
|
ppc32_jit_close_hreg_seq(cpu); |
2682 |
return(0); |
return(0); |
2683 |
} |
} |
2684 |
|
|
2688 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
2689 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2690 |
m_uint32_t imm = bits(insn,0,15); |
m_uint32_t imm = bits(insn,0,15); |
2691 |
|
int hreg_t0; |
2692 |
|
jit_op_t *iop; |
2693 |
|
|
2694 |
|
ppc32_jit_start_hreg_seq(cpu,"mulli"); |
2695 |
|
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RAX); |
2696 |
|
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RDX); |
2697 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
2698 |
|
|
2699 |
|
ppc32_op_emit_load_gpr(cpu,AMD64_RAX,ra); |
2700 |
|
|
2701 |
ppc32_load_gpr(b,AMD64_RAX,ra); |
/* rd = lo(ra * imm) */ |
2702 |
ppc32_load_imm(b,AMD64_RBX,sign_extend_32(imm,16)); |
iop = ppc32_op_emit_insn_output(cpu,2,"mulli"); |
2703 |
|
|
2704 |
amd64_mul_reg_size(b->jit_ptr,AMD64_RBX,1,4); |
ppc32_load_imm(&iop->ob_ptr,hreg_t0,sign_extend_32(imm,16)); |
2705 |
ppc32_store_gpr(b,rd,X86_EAX); |
amd64_mul_reg_size(iop->ob_ptr,hreg_t0,1,4); |
2706 |
|
ppc32_op_emit_store_gpr(cpu,rd,AMD64_RAX); |
2707 |
|
|
2708 |
|
/* edx:eax are directly modified: throw them */ |
2709 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RAX); |
2710 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
2711 |
|
|
2712 |
|
ppc32_jit_close_hreg_seq(cpu); |
2713 |
return(0); |
return(0); |
2714 |
} |
} |
2715 |
|
|
2719 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
2720 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2721 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2722 |
|
int hreg_rb; |
2723 |
|
jit_op_t *iop; |
2724 |
|
|
2725 |
ppc32_load_gpr(b,AMD64_RAX,ra); |
ppc32_jit_start_hreg_seq(cpu,"mullw"); |
2726 |
ppc32_load_gpr(b,AMD64_RBX,rb); |
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RAX); |
2727 |
amd64_mul_reg_size(b->jit_ptr,AMD64_RBX,1,4); |
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RDX); |
2728 |
ppc32_store_gpr(b,rd,AMD64_RAX); |
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
2729 |
|
|
2730 |
|
ppc32_op_emit_load_gpr(cpu,AMD64_RAX,ra); |
2731 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
2732 |
|
|
2733 |
|
/* rd = lo(ra * rb) */ |
2734 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"mullw"); |
2735 |
|
amd64_mul_reg_size(iop->ob_ptr,hreg_rb,1,4); |
2736 |
|
|
2737 |
if (insn & 1) { |
if (insn & 1) |
2738 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RAX,AMD64_RAX,4); |
amd64_test_reg_reg_size(iop->ob_ptr,AMD64_RAX,AMD64_RAX,4); |
|
ppc32_update_cr0(b); |
|
|
} |
|
2739 |
|
|
2740 |
|
ppc32_op_emit_store_gpr(cpu,rd,AMD64_RAX); |
2741 |
|
|
2742 |
|
if (insn & 1) |
2743 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
2744 |
|
|
2745 |
|
/* edx:eax are directly modified: throw them */ |
2746 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RAX); |
2747 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RDX); |
2748 |
|
|
2749 |
|
ppc32_jit_close_hreg_seq(cpu); |
2750 |
return(0); |
return(0); |
2751 |
} |
} |
2752 |
|
|
2756 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
2757 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2758 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2759 |
|
int hreg_rs,hreg_ra,hreg_rb; |
2760 |
|
jit_op_t *iop; |
2761 |
|
|
2762 |
/* $ra = ~($rs & $rb) */ |
/* $ra = ~($rs & $rb) */ |
2763 |
ppc32_load_gpr(b,AMD64_RBX,rs); |
ppc32_jit_start_hreg_seq(cpu,"nand"); |
2764 |
ppc32_alu_gpr(b,X86_AND,AMD64_RBX,rb); |
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
2765 |
amd64_not_reg(b->jit_ptr,AMD64_RBX); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
2766 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
2767 |
|
|
2768 |
if (insn & 1) { |
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
2769 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RBX,AMD64_RBX,4); |
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
2770 |
ppc32_update_cr0(b); |
|
2771 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"nand"); |
2772 |
|
|
2773 |
|
if (ra == rs) |
2774 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_AND,hreg_ra,hreg_rb,4); |
2775 |
|
else if (ra == rb) |
2776 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_AND,hreg_ra,hreg_rs,4); |
2777 |
|
else { |
2778 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
2779 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_AND,hreg_ra,hreg_rb,4); |
2780 |
} |
} |
2781 |
|
|
2782 |
|
amd64_not_reg(iop->ob_ptr,hreg_ra); |
2783 |
|
|
2784 |
|
if (insn & 1) |
2785 |
|
amd64_test_reg_reg_size(iop->ob_ptr,hreg_ra,hreg_ra,4); |
2786 |
|
|
2787 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
2788 |
|
|
2789 |
|
if (insn & 1) |
2790 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
2791 |
|
|
2792 |
|
ppc32_jit_close_hreg_seq(cpu); |
2793 |
return(0); |
return(0); |
2794 |
} |
} |
2795 |
|
|
2798 |
{ |
{ |
2799 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
2800 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2801 |
|
int hreg_rd,hreg_ra; |
2802 |
|
jit_op_t *iop; |
2803 |
|
|
2804 |
ppc32_load_gpr(b,AMD64_RBX,ra); |
/* $rd = neg($ra) */ |
2805 |
amd64_neg_reg(b->jit_ptr,AMD64_RBX); |
ppc32_jit_start_hreg_seq(cpu,"neg"); |
2806 |
ppc32_store_gpr(b,rd,AMD64_RBX); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
2807 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
2808 |
|
|
2809 |
if (insn & 1) { |
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
2810 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RBX,AMD64_RBX,4); |
|
2811 |
ppc32_update_cr0(b); |
iop = ppc32_op_emit_insn_output(cpu,1,"neg"); |
2812 |
} |
|
2813 |
|
if (rd != ra) |
2814 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_rd,hreg_ra,4); |
2815 |
|
|
2816 |
|
amd64_neg_reg(iop->ob_ptr,hreg_rd); |
2817 |
|
|
2818 |
|
if (insn & 1) |
2819 |
|
amd64_test_reg_reg_size(iop->ob_ptr,hreg_rd,hreg_rd,4); |
2820 |
|
|
2821 |
|
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
2822 |
|
|
2823 |
|
if (insn & 1) |
2824 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
2825 |
|
|
2826 |
|
ppc32_jit_close_hreg_seq(cpu); |
2827 |
return(0); |
return(0); |
2828 |
} |
} |
2829 |
|
|
2833 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
2834 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2835 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2836 |
|
int hreg_rs,hreg_ra,hreg_rb; |
2837 |
|
jit_op_t *iop; |
2838 |
|
|
2839 |
/* $ra = ~($rs | $rb) */ |
/* $ra = ~($rs | $rb) */ |
2840 |
ppc32_load_gpr(b,AMD64_RBX,rs); |
ppc32_jit_start_hreg_seq(cpu,"nor"); |
2841 |
ppc32_alu_gpr(b,X86_OR,AMD64_RBX,rb); |
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
2842 |
amd64_not_reg(b->jit_ptr,AMD64_RBX); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
2843 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
2844 |
|
|
2845 |
if (insn & 1) { |
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
2846 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RBX,AMD64_RBX,4); |
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
2847 |
ppc32_update_cr0(b); |
|
2848 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"nor"); |
2849 |
|
|
2850 |
|
if (ra == rs) |
2851 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_OR,hreg_ra,hreg_rb,4); |
2852 |
|
else if (ra == rb) |
2853 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_OR,hreg_ra,hreg_rs,4); |
2854 |
|
else { |
2855 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
2856 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_OR,hreg_ra,hreg_rb,4); |
2857 |
} |
} |
2858 |
|
|
2859 |
|
amd64_not_reg(iop->ob_ptr,hreg_ra); |
2860 |
|
|
2861 |
|
if (insn & 1) |
2862 |
|
amd64_test_reg_reg_size(iop->ob_ptr,hreg_ra,hreg_ra,4); |
2863 |
|
|
2864 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
2865 |
|
|
2866 |
|
if (insn & 1) |
2867 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
2868 |
|
|
2869 |
|
ppc32_jit_close_hreg_seq(cpu); |
2870 |
return(0); |
return(0); |
2871 |
} |
} |
2872 |
|
|
2876 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
2877 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2878 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2879 |
|
int hreg_rs,hreg_ra,hreg_rb; |
2880 |
|
jit_op_t *iop; |
2881 |
|
|
2882 |
ppc32_load_gpr(b,AMD64_RCX,rs); |
/* $ra = $rs | $rb */ |
2883 |
|
ppc32_jit_start_hreg_seq(cpu,"or"); |
2884 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
2885 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
2886 |
|
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
2887 |
|
|
2888 |
if (rs != rb) |
/* special optimization for move/nop operation */ |
2889 |
ppc32_alu_gpr(b,X86_OR,AMD64_RCX,rb); |
if (rs == rb) { |
2890 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
2891 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"or"); |
2892 |
|
|
2893 |
ppc32_store_gpr(b,ra,AMD64_RCX); |
if (ra != rs) |
2894 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
2895 |
|
|
2896 |
if (insn & 1) { |
if (insn & 1) |
2897 |
if (rs == rb) |
amd64_test_reg_reg_size(iop->ob_ptr,hreg_ra,hreg_ra,4); |
2898 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RCX,AMD64_RCX,4); |
|
2899 |
ppc32_update_cr0(b); |
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
2900 |
|
|
2901 |
|
if (insn & 1) |
2902 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
2903 |
|
|
2904 |
|
ppc32_jit_close_hreg_seq(cpu); |
2905 |
|
return(0); |
2906 |
} |
} |
2907 |
|
|
2908 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
2909 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
2910 |
|
|
2911 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"or"); |
2912 |
|
|
2913 |
|
if (ra == rs) { |
2914 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_OR,hreg_ra,hreg_rb,4); |
2915 |
|
} else if (ra == rb) |
2916 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_OR,hreg_ra,hreg_rs,4); |
2917 |
|
else { |
2918 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
2919 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_OR,hreg_ra,hreg_rb,4); |
2920 |
|
} |
2921 |
|
|
2922 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
2923 |
|
|
2924 |
|
if (insn & 1) |
2925 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
2926 |
|
|
2927 |
|
ppc32_jit_close_hreg_seq(cpu); |
2928 |
return(0); |
return(0); |
2929 |
} |
} |
2930 |
|
|
2934 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
2935 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2936 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
2937 |
|
int hreg_rs,hreg_ra,hreg_rb,hreg_t0; |
2938 |
|
jit_op_t *iop; |
2939 |
|
|
2940 |
|
/* $ra = $rs & ~$rb */ |
2941 |
|
ppc32_jit_start_hreg_seq(cpu,"orc"); |
2942 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
2943 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
2944 |
|
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
2945 |
|
|
2946 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
2947 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
2948 |
|
|
2949 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"orc"); |
2950 |
|
|
2951 |
|
/* $t0 = ~$rb */ |
2952 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
2953 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_t0,hreg_rb,4); |
2954 |
|
amd64_not_reg(iop->ob_ptr,hreg_t0); |
2955 |
|
|
2956 |
|
/* $ra = $rs | $t0 */ |
2957 |
|
if (ra == rs) |
2958 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_OR,hreg_ra,hreg_t0,4); |
2959 |
|
else { |
2960 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_OR,hreg_t0,hreg_rs,4); |
2961 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_t0,4); |
2962 |
|
} |
2963 |
|
|
2964 |
/* $ra = $rs | ~$rb */ |
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
|
ppc32_load_gpr(b,AMD64_RBX,rb); |
|
|
amd64_not_reg(b->jit_ptr,AMD64_RBX); |
|
|
ppc32_alu_gpr(b,X86_OR,AMD64_RBX,rs); |
|
|
ppc32_store_gpr(b,ra,AMD64_RBX); |
|
2965 |
|
|
2966 |
if (insn & 1) |
if (insn & 1) |
2967 |
ppc32_update_cr0(b); |
ppc32_op_emit_update_flags(cpu,0,TRUE); |
2968 |
|
|
2969 |
|
ppc32_jit_close_hreg_seq(cpu); |
2970 |
return(0); |
return(0); |
2971 |
} |
} |
2972 |
|
|
2976 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
2977 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
2978 |
m_uint16_t imm = bits(insn,0,15); |
m_uint16_t imm = bits(insn,0,15); |
2979 |
|
m_uint32_t tmp = imm; |
2980 |
|
int hreg_rs,hreg_ra; |
2981 |
|
jit_op_t *iop; |
2982 |
|
|
2983 |
/* $ra = $rs | imm */ |
/* $ra = $rs | imm */ |
2984 |
ppc32_load_imm(b,AMD64_RBX,imm); |
ppc32_jit_start_hreg_seq(cpu,"ori"); |
2985 |
ppc32_alu_gpr(b,X86_OR,AMD64_RBX,rs); |
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
2986 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
2987 |
return(0); |
|
2988 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
2989 |
|
|
2990 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"ori"); |
2991 |
|
|
2992 |
|
if (ra != rs) |
2993 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
2994 |
|
|
2995 |
|
amd64_alu_reg_imm_size(iop->ob_ptr,X86_OR,hreg_ra,tmp,4); |
2996 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
2997 |
|
|
2998 |
|
ppc32_jit_close_hreg_seq(cpu); |
2999 |
|
return(0); |
3000 |
} |
} |
3001 |
|
|
3002 |
/* OR Immediate Shifted */ |
/* OR Immediate Shifted */ |
3004 |
{ |
{ |
3005 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
3006 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3007 |
m_uint32_t imm = bits(insn,0,15); |
m_uint16_t imm = bits(insn,0,15); |
3008 |
|
m_uint32_t tmp = imm << 16; |
3009 |
|
int hreg_rs,hreg_ra; |
3010 |
|
jit_op_t *iop; |
3011 |
|
|
3012 |
|
/* $ra = $rs | imm */ |
3013 |
|
ppc32_jit_start_hreg_seq(cpu,"oris"); |
3014 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
3015 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
3016 |
|
|
3017 |
/* $ra = $rs | (imm << 16) */ |
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
3018 |
ppc32_load_imm(b,AMD64_RBX,imm << 16); |
|
3019 |
ppc32_alu_gpr(b,X86_OR,AMD64_RBX,rs); |
iop = ppc32_op_emit_insn_output(cpu,1,"oris"); |
3020 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
|
3021 |
|
if (ra != rs) |
3022 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
3023 |
|
|
3024 |
|
amd64_alu_reg_imm_size(iop->ob_ptr,X86_OR,hreg_ra,tmp,4); |
3025 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
3026 |
|
|
3027 |
|
ppc32_jit_close_hreg_seq(cpu); |
3028 |
return(0); |
return(0); |
3029 |
} |
} |
3030 |
|
|
3037 |
int mb = bits(insn,6,10); |
int mb = bits(insn,6,10); |
3038 |
int me = bits(insn,1,5); |
int me = bits(insn,1,5); |
3039 |
register m_uint32_t mask; |
register m_uint32_t mask; |
3040 |
|
int hreg_rs,hreg_ra,hreg_t0; |
3041 |
|
jit_op_t *iop; |
3042 |
|
|
3043 |
|
ppc32_jit_start_hreg_seq(cpu,"rlwimi"); |
3044 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
3045 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
3046 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
3047 |
|
|
3048 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
3049 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
3050 |
|
|
3051 |
mask = ppc32_rotate_mask(mb,me); |
mask = ppc32_rotate_mask(mb,me); |
3052 |
|
|
3053 |
/* Apply inverse mask to %eax "ra" */ |
iop = ppc32_op_emit_insn_output(cpu,2,"rlwimi"); |
3054 |
ppc32_load_gpr(b,AMD64_RAX,ra); |
|
3055 |
|
/* Apply inverse mask to $ra */ |
3056 |
if (mask != 0) |
if (mask != 0) |
3057 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RAX,~mask); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_ra,~mask); |
3058 |
|
|
3059 |
/* Rotate %ebx ("rs") of "sh" bits and apply the mask */ |
/* Rotate $rs of "sh" bits and apply the mask */ |
3060 |
ppc32_load_gpr(b,AMD64_RBX,rs); |
amd64_mov_reg_reg(iop->ob_ptr,hreg_t0,hreg_rs,4); |
3061 |
|
|
3062 |
if (sh != 0) |
if (sh != 0) |
3063 |
amd64_shift_reg_imm_size(b->jit_ptr,X86_ROL,AMD64_RBX,sh,4); |
amd64_shift_reg_imm_size(iop->ob_ptr,X86_ROL,hreg_t0,sh,4); |
3064 |
|
|
3065 |
if (mask != 0xFFFFFFFF) |
if (mask != 0xFFFFFFFF) |
3066 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RBX,mask); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,mask); |
3067 |
|
|
3068 |
/* Store the result */ |
/* Store the result */ |
3069 |
amd64_alu_reg_reg_size(b->jit_ptr,X86_OR,AMD64_RBX,AMD64_RAX,4); |
amd64_alu_reg_reg_size(iop->ob_ptr,X86_OR,hreg_ra,hreg_t0,4); |
3070 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
3071 |
|
|
3072 |
if (insn & 1) |
if (insn & 1) |
3073 |
ppc32_update_cr0(b); |
ppc32_op_emit_update_flags(cpu,0,TRUE); |
3074 |
|
|
3075 |
|
ppc32_jit_close_hreg_seq(cpu); |
3076 |
return(0); |
return(0); |
3077 |
} |
} |
3078 |
|
|
3085 |
int mb = bits(insn,6,10); |
int mb = bits(insn,6,10); |
3086 |
int me = bits(insn,1,5); |
int me = bits(insn,1,5); |
3087 |
register m_uint32_t mask; |
register m_uint32_t mask; |
3088 |
|
int hreg_rs,hreg_ra; |
3089 |
|
jit_op_t *iop; |
3090 |
|
|
3091 |
|
ppc32_jit_start_hreg_seq(cpu,"rlwinm"); |
3092 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
3093 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
3094 |
|
|
3095 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
3096 |
|
|
3097 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"rlwinm"); |
3098 |
|
|
3099 |
|
/* Rotate $rs of "sh" bits and apply the mask */ |
3100 |
mask = ppc32_rotate_mask(mb,me); |
mask = ppc32_rotate_mask(mb,me); |
3101 |
|
|
3102 |
/* Rotate %ebx ("rs") of "sh" bits and apply the mask */ |
if (rs != ra) |
3103 |
ppc32_load_gpr(b,AMD64_RBX,rs); |
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
3104 |
|
|
3105 |
if (sh != 0) |
if (sh != 0) |
3106 |
amd64_shift_reg_imm_size(b->jit_ptr,X86_ROL,AMD64_RBX,sh,4); |
amd64_shift_reg_imm_size(iop->ob_ptr,X86_ROL,hreg_ra,sh,4); |
3107 |
|
|
3108 |
if (mask != 0xFFFFFFFF) |
if (mask != 0xFFFFFFFF) |
3109 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RBX,mask); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_ra,mask); |
3110 |
|
|
3111 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
if (insn & 1) |
3112 |
|
amd64_test_reg_reg_size(iop->ob_ptr,hreg_ra,hreg_ra,4); |
3113 |
|
|
3114 |
if (insn & 1) { |
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
|
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RBX,AMD64_RBX,4); |
|
|
ppc32_update_cr0(b); |
|
|
} |
|
3115 |
|
|
3116 |
|
if (insn & 1) |
3117 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
3118 |
|
|
3119 |
|
ppc32_jit_close_hreg_seq(cpu); |
3120 |
return(0); |
return(0); |
3121 |
} |
} |
3122 |
|
|
3129 |
int mb = bits(insn,6,10); |
int mb = bits(insn,6,10); |
3130 |
int me = bits(insn,1,5); |
int me = bits(insn,1,5); |
3131 |
register m_uint32_t mask; |
register m_uint32_t mask; |
3132 |
|
int hreg_rs,hreg_ra,hreg_t0; |
3133 |
|
jit_op_t *iop; |
3134 |
|
|
3135 |
mask = ppc32_rotate_mask(mb,me); |
/* ecx is directly modified: throw it */ |
3136 |
|
ppc32_op_emit_alter_host_reg(cpu,AMD64_RCX); |
3137 |
|
|
3138 |
|
ppc32_jit_start_hreg_seq(cpu,"rlwnm"); |
3139 |
|
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RCX); |
3140 |
|
|
3141 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
3142 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
3143 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
3144 |
|
|
3145 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
3146 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
3147 |
|
ppc32_op_emit_load_gpr(cpu,AMD64_RCX,rb); |
3148 |
|
|
3149 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"rlwnm"); |
3150 |
|
|
3151 |
/* Load the shift register ("sh") */ |
/* Load the shift register ("sh") */ |
3152 |
ppc32_load_gpr(b,AMD64_RCX,rb); |
mask = ppc32_rotate_mask(mb,me); |
3153 |
|
|
3154 |
/* Rotate %ebx ("rs") and apply the mask */ |
/* Rotate $rs and apply the mask */ |
3155 |
ppc32_load_gpr(b,AMD64_RBX,rs); |
amd64_mov_reg_reg(iop->ob_ptr,hreg_t0,hreg_rs,4); |
3156 |
amd64_shift_reg_size(b->jit_ptr,X86_ROL,AMD64_RBX,4); |
|
3157 |
|
amd64_shift_reg_size(iop->ob_ptr,X86_ROL,hreg_t0,4); |
3158 |
|
|
3159 |
if (mask != 0xFFFFFFFF) |
if (mask != 0xFFFFFFFF) |
3160 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RBX,mask); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,mask); |
3161 |
|
|
3162 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_t0,4); |
3163 |
|
|
3164 |
if (insn & 1) { |
if (insn & 1) |
3165 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RBX,AMD64_RBX,4); |
amd64_test_reg_reg_size(iop->ob_ptr,hreg_ra,hreg_ra,4); |
3166 |
ppc32_update_cr0(b); |
|
3167 |
} |
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
3168 |
|
|
3169 |
|
if (insn & 1) |
3170 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
3171 |
|
|
3172 |
|
ppc32_jit_close_hreg_seq(cpu); |
3173 |
return(0); |
return(0); |
3174 |
} |
} |
3175 |
|
|
3179 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
3180 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3181 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
3182 |
|
int hreg_rs,hreg_ra; |
3183 |
|
jit_op_t *iop; |
3184 |
|
|
3185 |
/* If count >= 32, then null result */ |
/* ecx is directly modified: throw it */ |
3186 |
ppc32_load_gpr(b,AMD64_RCX,rb); |
ppc32_op_emit_alter_host_reg(cpu,AMD64_RCX); |
|
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RCX,0x3f); |
|
3187 |
|
|
3188 |
ppc32_load_gpr(b,AMD64_RBX,rs); |
ppc32_jit_start_hreg_seq(cpu,"slw"); |
3189 |
amd64_shift_reg(b->jit_ptr,X86_SHL,AMD64_RBX); |
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RCX); |
3190 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
3191 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
3192 |
|
|
3193 |
/* Store the result */ |
/* $ra = $rs << $rb. If count >= 32, then null result */ |
3194 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
3195 |
|
ppc32_op_emit_load_gpr(cpu,AMD64_RCX,rb); |
3196 |
|
|
3197 |
if (insn & 1) { |
iop = ppc32_op_emit_insn_output(cpu,3,"slw"); |
3198 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RBX,AMD64_RBX,4); |
|
3199 |
ppc32_update_cr0(b); |
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,AMD64_RCX,0x3f); |
3200 |
} |
|
3201 |
|
if (ra != rs) |
3202 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
3203 |
|
|
3204 |
|
amd64_shift_reg(iop->ob_ptr,X86_SHL,hreg_ra); |
3205 |
|
|
3206 |
|
/* store the result */ |
3207 |
|
if (insn & 1) |
3208 |
|
amd64_test_reg_reg_size(iop->ob_ptr,hreg_ra,hreg_ra,4); |
3209 |
|
|
3210 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
3211 |
|
|
3212 |
|
if (insn & 1) |
3213 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
3214 |
|
|
3215 |
|
ppc32_jit_close_hreg_seq(cpu); |
3216 |
return(0); |
return(0); |
3217 |
} |
} |
3218 |
|
|
3223 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3224 |
int sh = bits(insn,11,15); |
int sh = bits(insn,11,15); |
3225 |
register m_uint32_t mask; |
register m_uint32_t mask; |
3226 |
|
int hreg_rs,hreg_ra,hreg_t0; |
3227 |
|
jit_op_t *iop; |
3228 |
|
|
3229 |
mask = ~(0xFFFFFFFFU << sh); |
ppc32_jit_start_hreg_seq(cpu,"srawi"); |
3230 |
|
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
3231 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
3232 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
3233 |
|
|
3234 |
/* $ra = (int32)$rs >> sh */ |
/* $ra = (int32)$rs >> sh */ |
3235 |
ppc32_load_gpr(b,AMD64_RBX,rs); |
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
|
amd64_mov_reg_reg(b->jit_ptr,AMD64_RSI,AMD64_RBX,4); |
|
|
amd64_shift_reg_imm_size(b->jit_ptr,X86_SAR,AMD64_RBX,sh,4); |
|
|
ppc32_store_gpr(b,ra,AMD64_RBX); |
|
|
|
|
|
/* test the sign-bit of gpr[rs] */ |
|
|
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RSI,AMD64_RSI,4); |
|
|
amd64_set_reg(b->jit_ptr,X86_CC_LT,AMD64_RAX,TRUE); |
|
|
|
|
|
amd64_alu_reg_imm_size(b->jit_ptr,X86_AND,AMD64_RSI,mask,4); |
|
|
amd64_set_reg(b->jit_ptr,X86_CC_NZ,AMD64_RCX,TRUE); |
|
|
|
|
|
amd64_alu_reg_reg(b->jit_ptr,X86_OR,AMD64_RCX,AMD64_RAX); |
|
|
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RCX,0x1); |
|
|
amd64_mov_membase_reg(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
|
|
AMD64_RCX,4); |
|
3236 |
|
|
3237 |
if (insn & 1) { |
iop = ppc32_op_emit_insn_output(cpu,3,"srawi"); |
3238 |
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RBX,AMD64_RBX,4); |
amd64_mov_reg_reg(iop->ob_ptr,hreg_t0,hreg_rs,4); |
3239 |
ppc32_update_cr0(b); |
|
3240 |
} |
if (ra != rs) |
3241 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
3242 |
|
amd64_shift_reg_imm_size(iop->ob_ptr,X86_SAR,hreg_ra,sh,4); |
3243 |
|
|
3244 |
|
/* set XER_CA depending on the result */ |
3245 |
|
mask = ~(0xFFFFFFFFU << sh) | 0x80000000; |
3246 |
|
|
3247 |
|
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,mask); |
3248 |
|
amd64_alu_reg_imm_size(iop->ob_ptr,X86_CMP,hreg_t0,0x80000000,4); |
3249 |
|
amd64_set_reg(iop->ob_ptr,X86_CC_A,hreg_t0,FALSE); |
3250 |
|
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,hreg_t0,0x1); |
3251 |
|
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
3252 |
|
hreg_t0,4); |
3253 |
|
|
3254 |
|
if (insn & 1) |
3255 |
|
amd64_test_reg_reg_size(iop->ob_ptr,hreg_ra,hreg_ra,4); |
3256 |
|
|
3257 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
3258 |
|
|
3259 |
|
if (insn & 1) |
3260 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
3261 |
|
|
3262 |
|
ppc32_jit_close_hreg_seq(cpu); |
3263 |
return(0); |
return(0); |
3264 |
} |
} |
3265 |
|
|
3269 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
3270 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3271 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
3272 |
|
int hreg_rs,hreg_ra; |
3273 |
|
jit_op_t *iop; |
3274 |
|
|
3275 |
/* If count >= 32, then null result */ |
/* ecx is directly modified: throw it */ |
3276 |
ppc32_load_gpr(b,AMD64_RCX,rb); |
ppc32_op_emit_alter_host_reg(cpu,AMD64_RCX); |
|
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RCX,0x3f); |
|
3277 |
|
|
3278 |
ppc32_load_gpr(b,AMD64_RBX,rs); |
ppc32_jit_start_hreg_seq(cpu,"srw"); |
3279 |
amd64_shift_reg(b->jit_ptr,X86_SHR,AMD64_RBX); |
ppc32_jit_alloc_hreg_forced(cpu,AMD64_RCX); |
3280 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
3281 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
3282 |
|
|
3283 |
/* Store the result */ |
/* $ra = $rs >> $rb. If count >= 32, then null result */ |
3284 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
3285 |
|
ppc32_op_emit_load_gpr(cpu,AMD64_RCX,rb); |
3286 |
|
|
3287 |
if (insn & 1) { |
iop = ppc32_op_emit_insn_output(cpu,3,"srw"); |
|
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RBX,AMD64_RBX,4); |
|
|
ppc32_update_cr0(b); |
|
|
} |
|
3288 |
|
|
3289 |
|
amd64_alu_reg_imm(iop->ob_ptr,X86_AND,AMD64_RCX,0x3f); |
3290 |
|
|
3291 |
|
if (ra != rs) |
3292 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
3293 |
|
|
3294 |
|
amd64_shift_reg(iop->ob_ptr,X86_SHR,hreg_ra); |
3295 |
|
|
3296 |
|
/* store the result */ |
3297 |
|
if (insn & 1) |
3298 |
|
amd64_test_reg_reg_size(iop->ob_ptr,hreg_ra,hreg_ra,4); |
3299 |
|
|
3300 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
3301 |
|
|
3302 |
|
if (insn & 1) |
3303 |
|
ppc32_op_emit_update_flags(cpu,0,TRUE); |
3304 |
|
|
3305 |
|
ppc32_jit_close_hreg_seq(cpu); |
3306 |
return(0); |
return(0); |
3307 |
} |
} |
3308 |
|
|
3314 |
m_uint16_t offset = bits(insn,0,15); |
m_uint16_t offset = bits(insn,0,15); |
3315 |
|
|
3316 |
//ppc32_emit_memop(b,PPC_MEMOP_STB,ra,offset,rs,0); |
//ppc32_emit_memop(b,PPC_MEMOP_STB,ra,offset,rs,0); |
3317 |
ppc32_emit_memop_fast(b,1,PPC_MEMOP_STB,ra,offset,rs,ppc32_memop_fast_stb); |
ppc32_emit_memop_fast(cpu,b,1,PPC_MEMOP_STB,ra,offset,rs, |
3318 |
|
ppc32_memop_fast_stb); |
3319 |
return(0); |
return(0); |
3320 |
} |
} |
3321 |
|
|
3326 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3327 |
m_uint16_t offset = bits(insn,0,15); |
m_uint16_t offset = bits(insn,0,15); |
3328 |
|
|
3329 |
ppc32_emit_memop(b,PPC_MEMOP_STB,ra,offset,rs,1); |
ppc32_emit_memop(cpu,b,PPC_MEMOP_STB,ra,offset,rs,1); |
3330 |
return(0); |
return(0); |
3331 |
} |
} |
3332 |
|
|
3337 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3338 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
3339 |
|
|
3340 |
ppc32_emit_memop_idx(b,PPC_MEMOP_STB,ra,rb,rs,1); |
ppc32_emit_memop_idx(cpu,b,PPC_MEMOP_STB,ra,rb,rs,1); |
3341 |
return(0); |
return(0); |
3342 |
} |
} |
3343 |
|
|
3348 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3349 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
3350 |
|
|
3351 |
ppc32_emit_memop_idx(b,PPC_MEMOP_STB,ra,rb,rs,0); |
ppc32_emit_memop_idx(cpu,b,PPC_MEMOP_STB,ra,rb,rs,0); |
3352 |
return(0); |
return(0); |
3353 |
} |
} |
3354 |
|
|
3359 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3360 |
m_uint16_t offset = bits(insn,0,15); |
m_uint16_t offset = bits(insn,0,15); |
3361 |
|
|
3362 |
ppc32_emit_memop(b,PPC_MEMOP_STH,ra,offset,rs,0); |
ppc32_emit_memop(cpu,b,PPC_MEMOP_STH,ra,offset,rs,0); |
3363 |
return(0); |
return(0); |
3364 |
} |
} |
3365 |
|
|
3370 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3371 |
m_uint16_t offset = bits(insn,0,15); |
m_uint16_t offset = bits(insn,0,15); |
3372 |
|
|
3373 |
ppc32_emit_memop(b,PPC_MEMOP_STH,ra,offset,rs,1); |
ppc32_emit_memop(cpu,b,PPC_MEMOP_STH,ra,offset,rs,1); |
3374 |
return(0); |
return(0); |
3375 |
} |
} |
3376 |
|
|
3381 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3382 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
3383 |
|
|
3384 |
ppc32_emit_memop_idx(b,PPC_MEMOP_STH,ra,rb,rs,1); |
ppc32_emit_memop_idx(cpu,b,PPC_MEMOP_STH,ra,rb,rs,1); |
3385 |
return(0); |
return(0); |
3386 |
} |
} |
3387 |
|
|
3392 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3393 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
3394 |
|
|
3395 |
ppc32_emit_memop_idx(b,PPC_MEMOP_STH,ra,rb,rs,0); |
ppc32_emit_memop_idx(cpu,b,PPC_MEMOP_STH,ra,rb,rs,0); |
3396 |
return(0); |
return(0); |
3397 |
} |
} |
3398 |
|
|
3404 |
m_uint16_t offset = bits(insn,0,15); |
m_uint16_t offset = bits(insn,0,15); |
3405 |
|
|
3406 |
//ppc32_emit_memop(b,PPC_MEMOP_STW,ra,offset,rs,0); |
//ppc32_emit_memop(b,PPC_MEMOP_STW,ra,offset,rs,0); |
3407 |
ppc32_emit_memop_fast(b,1,PPC_MEMOP_STW,ra,offset,rs,ppc32_memop_fast_stw); |
ppc32_emit_memop_fast(cpu,b,1,PPC_MEMOP_STW,ra,offset,rs, |
3408 |
|
ppc32_memop_fast_stw); |
3409 |
return(0); |
return(0); |
3410 |
} |
} |
3411 |
|
|
3416 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3417 |
m_uint16_t offset = bits(insn,0,15); |
m_uint16_t offset = bits(insn,0,15); |
3418 |
|
|
3419 |
ppc32_emit_memop(b,PPC_MEMOP_STW,ra,offset,rs,1); |
ppc32_emit_memop(cpu,b,PPC_MEMOP_STW,ra,offset,rs,1); |
3420 |
return(0); |
return(0); |
3421 |
} |
} |
3422 |
|
|
3427 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3428 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
3429 |
|
|
3430 |
ppc32_emit_memop_idx(b,PPC_MEMOP_STW,ra,rb,rs,1); |
ppc32_emit_memop_idx(cpu,b,PPC_MEMOP_STW,ra,rb,rs,1); |
3431 |
return(0); |
return(0); |
3432 |
} |
} |
3433 |
|
|
3438 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3439 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
3440 |
|
|
3441 |
ppc32_emit_memop_idx(b,PPC_MEMOP_STW,ra,rb,rs,0); |
ppc32_emit_memop_idx(cpu,b,PPC_MEMOP_STW,ra,rb,rs,0); |
3442 |
return(0); |
return(0); |
3443 |
} |
} |
3444 |
|
|
3448 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
3449 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3450 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
3451 |
|
int hreg_rd,hreg_ra,hreg_rb,hreg_t0; |
3452 |
|
jit_op_t *iop; |
3453 |
|
|
3454 |
/* $rd = $rb - $rb */ |
/* $rd = $rb - $ra */ |
3455 |
ppc32_load_gpr(b,AMD64_RBX,rb); |
ppc32_jit_start_hreg_seq(cpu,"subf"); |
3456 |
ppc32_alu_gpr(b,X86_SUB,AMD64_RBX,ra); |
hreg_t0 = ppc32_jit_get_tmp_hreg(cpu); |
3457 |
ppc32_store_gpr(b,rd,AMD64_RBX); |
|
3458 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
3459 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
3460 |
|
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
3461 |
|
|
3462 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
3463 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
3464 |
|
|
3465 |
|
iop = ppc32_op_emit_insn_output(cpu,2,"subf"); |
3466 |
|
|
3467 |
|
if (rd == rb) |
3468 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_SUB,hreg_rd,hreg_ra,4); |
3469 |
|
else if (rd == ra) { |
3470 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_t0,hreg_rb,4); |
3471 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_SUB,hreg_t0,hreg_ra,4); |
3472 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_rd,hreg_t0,4); |
3473 |
|
} else { |
3474 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_rd,hreg_rb,4); |
3475 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_SUB,hreg_rd,hreg_ra,4); |
3476 |
|
} |
3477 |
|
|
3478 |
|
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
3479 |
|
|
3480 |
if (insn & 1) |
if (insn & 1) |
3481 |
ppc32_update_cr0(b); |
ppc32_op_emit_update_flags(cpu,0,TRUE); |
3482 |
|
|
3483 |
|
ppc32_jit_close_hreg_seq(cpu); |
3484 |
return(0); |
return(0); |
3485 |
} |
} |
3486 |
|
|
3490 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
3491 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3492 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
3493 |
|
int hreg_ra,hreg_rb,hreg_rd,hreg_t0,hreg_t1; |
3494 |
|
jit_op_t *iop; |
3495 |
|
|
3496 |
/* ~$ra + 1 */ |
/* $rd = ~$ra + 1 + $rb */ |
3497 |
ppc32_load_gpr(b,AMD64_RSI,ra); |
ppc32_jit_start_hreg_seq(cpu,"subfc"); |
3498 |
amd64_not_reg(b->jit_ptr,AMD64_RSI); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
3499 |
amd64_alu_reg_imm_size(b->jit_ptr,X86_ADD,AMD64_RSI,1,4); |
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
3500 |
amd64_set_reg(b->jit_ptr,X86_CC_C,AMD64_RAX,FALSE); |
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
3501 |
|
|
3502 |
/* add $rb */ |
hreg_t0 = ppc32_jit_alloc_hreg(cpu,-1); |
3503 |
ppc32_alu_gpr(b,X86_ADD,AMD64_RSI,rb); |
hreg_t1 = ppc32_jit_get_tmp_hreg(cpu); |
3504 |
amd64_set_reg(b->jit_ptr,X86_CC_C,AMD64_RCX,FALSE); |
|
3505 |
|
ppc32_op_emit_alter_host_reg(cpu,hreg_t0); |
3506 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
3507 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
3508 |
|
|
3509 |
|
iop = ppc32_op_emit_insn_output(cpu,3,"subfc"); |
3510 |
|
|
3511 |
|
amd64_alu_reg_reg(iop->ob_ptr,X86_XOR,hreg_t1,hreg_t1); |
3512 |
|
|
3513 |
|
/* $t0 = ~$ra + 1 */ |
3514 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_t0,hreg_ra,4); |
3515 |
|
amd64_not_reg(iop->ob_ptr,hreg_t0); |
3516 |
|
amd64_alu_reg_imm_size(iop->ob_ptr,X86_ADD,hreg_t0,1,4); |
3517 |
|
amd64_set_reg(iop->ob_ptr,X86_CC_C,hreg_t1,FALSE); |
3518 |
|
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
3519 |
|
hreg_t1,4); |
3520 |
|
|
3521 |
|
/* $t0 += $rb */ |
3522 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_ADD,hreg_t0,hreg_rb,4); |
3523 |
|
amd64_set_reg(iop->ob_ptr,X86_CC_C,hreg_t1,FALSE); |
3524 |
|
amd64_alu_membase_reg_size(iop->ob_ptr,X86_OR, |
3525 |
|
AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
3526 |
|
hreg_t1,4); |
3527 |
|
|
3528 |
ppc32_store_gpr(b,rd,AMD64_RSI); |
amd64_mov_reg_reg(iop->ob_ptr,hreg_rd,hreg_t0,4); |
3529 |
|
|
3530 |
/* store the carry flag */ |
if (insn & 1) |
3531 |
amd64_alu_reg_reg(b->jit_ptr,X86_OR,AMD64_RAX,AMD64_RCX); |
amd64_test_reg_reg_size(iop->ob_ptr,hreg_rd,hreg_rd,4); |
|
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RAX,0x1); |
|
3532 |
|
|
3533 |
amd64_mov_membase_reg(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
|
AMD64_RAX,4); |
|
3534 |
|
|
3535 |
/* update cr0 */ |
/* update cr0 */ |
3536 |
if (insn & 1) { |
if (insn & 1) |
|
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RSI,AMD64_RSI,4); |
|
3537 |
ppc32_update_cr0(b); |
ppc32_update_cr0(b); |
|
} |
|
3538 |
|
|
3539 |
|
ppc32_jit_close_hreg_seq(cpu); |
3540 |
return(0); |
return(0); |
3541 |
} |
} |
3542 |
|
|
3546 |
int rd = bits(insn,21,25); |
int rd = bits(insn,21,25); |
3547 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3548 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
3549 |
|
int hreg_ra,hreg_rb,hreg_rd,hreg_t0,hreg_t1; |
3550 |
|
jit_op_t *iop; |
3551 |
|
|
3552 |
/* ~$ra + carry */ |
/* $rd = ~$ra + $carry (xer_ca) + $rb */ |
3553 |
ppc32_load_gpr(b,AMD64_RSI,ra); |
ppc32_jit_start_hreg_seq(cpu,"subfe"); |
3554 |
amd64_not_reg(b->jit_ptr,AMD64_RSI); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
3555 |
amd64_alu_reg_membase_size(b->jit_ptr,X86_ADD,AMD64_RSI, |
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
3556 |
|
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
3557 |
|
|
3558 |
|
hreg_t0 = ppc32_jit_alloc_hreg(cpu,-1); |
3559 |
|
hreg_t1 = ppc32_jit_get_tmp_hreg(cpu); |
3560 |
|
|
3561 |
|
ppc32_op_emit_alter_host_reg(cpu,hreg_t0); |
3562 |
|
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
3563 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
3564 |
|
|
3565 |
|
iop = ppc32_op_emit_insn_output(cpu,3,"subfe"); |
3566 |
|
|
3567 |
|
amd64_alu_reg_reg(iop->ob_ptr,X86_XOR,hreg_t1,hreg_t1); |
3568 |
|
|
3569 |
|
/* $t0 = ~$ra + $carry */ |
3570 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_t0,hreg_ra,4); |
3571 |
|
amd64_not_reg(iop->ob_ptr,hreg_t0); |
3572 |
|
amd64_alu_reg_membase_size(iop->ob_ptr,X86_ADD,hreg_t0, |
3573 |
AMD64_R15,OFFSET(cpu_ppc_t,xer_ca),4); |
AMD64_R15,OFFSET(cpu_ppc_t,xer_ca),4); |
|
amd64_set_reg(b->jit_ptr,X86_CC_C,AMD64_RAX,FALSE); |
|
3574 |
|
|
3575 |
/* add $rb */ |
amd64_set_reg(iop->ob_ptr,X86_CC_C,hreg_t1,FALSE); |
3576 |
ppc32_alu_gpr(b,X86_ADD,AMD64_RSI,rb); |
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
3577 |
amd64_set_reg(b->jit_ptr,X86_CC_C,AMD64_RCX,FALSE); |
hreg_t1,4); |
3578 |
|
|
3579 |
|
/* $t0 += $rb */ |
3580 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_ADD,hreg_t0,hreg_rb,4); |
3581 |
|
amd64_set_reg(iop->ob_ptr,X86_CC_C,hreg_t1,FALSE); |
3582 |
|
amd64_alu_membase_reg_size(iop->ob_ptr,X86_OR, |
3583 |
|
AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
3584 |
|
hreg_t1,4); |
3585 |
|
|
3586 |
ppc32_store_gpr(b,rd,AMD64_RSI); |
amd64_mov_reg_reg(iop->ob_ptr,hreg_rd,hreg_t0,4); |
3587 |
|
|
3588 |
/* store the carry flag */ |
if (insn & 1) |
3589 |
amd64_alu_reg_reg(b->jit_ptr,X86_OR,AMD64_RAX,AMD64_RCX); |
amd64_test_reg_reg_size(iop->ob_ptr,hreg_rd,hreg_rd,4); |
3590 |
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RAX,0x1); |
|
3591 |
amd64_mov_membase_reg(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
|
AMD64_RAX,4); |
|
3592 |
|
|
3593 |
/* update cr0 */ |
/* update cr0 */ |
3594 |
if (insn & 1) { |
if (insn & 1) |
|
amd64_test_reg_reg_size(b->jit_ptr,AMD64_RSI,AMD64_RSI,4); |
|
3595 |
ppc32_update_cr0(b); |
ppc32_update_cr0(b); |
|
} |
|
3596 |
|
|
3597 |
|
ppc32_jit_close_hreg_seq(cpu); |
3598 |
return(0); |
return(0); |
3599 |
} |
} |
3600 |
|
|
3605 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3606 |
m_uint16_t imm = bits(insn,0,15); |
m_uint16_t imm = bits(insn,0,15); |
3607 |
m_uint32_t tmp = sign_extend_32(imm,16); |
m_uint32_t tmp = sign_extend_32(imm,16); |
3608 |
|
int hreg_ra,hreg_rd,hreg_t0,hreg_t1; |
3609 |
|
jit_op_t *iop; |
3610 |
|
|
3611 |
/* ~$ra + 1 */ |
/* $rd = ~$ra + 1 + sign_extend(imm,16) */ |
3612 |
ppc32_load_gpr(b,AMD64_RSI,ra); |
ppc32_jit_start_hreg_seq(cpu,"subfic"); |
3613 |
amd64_not_reg(b->jit_ptr,AMD64_RSI); |
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
3614 |
amd64_alu_reg_imm_size(b->jit_ptr,X86_ADD,AMD64_RSI,1,4); |
hreg_rd = ppc32_jit_alloc_hreg(cpu,rd); |
|
amd64_set_reg(b->jit_ptr,X86_CC_C,AMD64_RAX,FALSE); |
|
|
|
|
|
/* add sign-extended $immediate */ |
|
|
amd64_alu_reg_imm_size(b->jit_ptr,X86_ADD,AMD64_RSI,tmp,4); |
|
|
amd64_set_reg(b->jit_ptr,X86_CC_C,AMD64_RCX,FALSE); |
|
3615 |
|
|
3616 |
ppc32_store_gpr(b,rd,AMD64_RSI); |
hreg_t0 = ppc32_jit_alloc_hreg(cpu,-1); |
3617 |
|
hreg_t1 = ppc32_jit_get_tmp_hreg(cpu); |
3618 |
|
|
3619 |
/* store the carry flag */ |
ppc32_op_emit_alter_host_reg(cpu,hreg_t0); |
3620 |
amd64_alu_reg_reg(b->jit_ptr,X86_OR,AMD64_RAX,AMD64_RCX); |
ppc32_op_emit_load_gpr(cpu,hreg_ra,ra); |
|
amd64_alu_reg_imm(b->jit_ptr,X86_AND,AMD64_RAX,0x1); |
|
3621 |
|
|
3622 |
amd64_mov_membase_reg(b->jit_ptr,AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
iop = ppc32_op_emit_insn_output(cpu,3,"subfic"); |
3623 |
AMD64_RAX,4); |
|
3624 |
|
amd64_alu_reg_reg(iop->ob_ptr,X86_XOR,hreg_t1,hreg_t1); |
3625 |
|
|
3626 |
|
/* $t0 = ~$ra + 1 */ |
3627 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_t0,hreg_ra,4); |
3628 |
|
amd64_not_reg(iop->ob_ptr,hreg_t0); |
3629 |
|
amd64_alu_reg_imm_size(iop->ob_ptr,X86_ADD,hreg_t0,1,4); |
3630 |
|
|
3631 |
|
amd64_set_reg(iop->ob_ptr,X86_CC_C,hreg_t1,FALSE); |
3632 |
|
amd64_mov_membase_reg(iop->ob_ptr,AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
3633 |
|
hreg_t1,4); |
3634 |
|
|
3635 |
|
/* $t0 += sign_extend(imm,16) */ |
3636 |
|
amd64_alu_reg_imm_size(iop->ob_ptr,X86_ADD,hreg_t0,tmp,4); |
3637 |
|
amd64_set_reg(iop->ob_ptr,X86_CC_C,hreg_t1,FALSE); |
3638 |
|
amd64_alu_membase_reg_size(iop->ob_ptr,X86_OR, |
3639 |
|
AMD64_R15,OFFSET(cpu_ppc_t,xer_ca), |
3640 |
|
hreg_t1,4); |
3641 |
|
|
3642 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_rd,hreg_t0,4); |
3643 |
|
ppc32_op_emit_store_gpr(cpu,rd,hreg_rd); |
3644 |
|
|
3645 |
|
ppc32_jit_close_hreg_seq(cpu); |
3646 |
return(0); |
return(0); |
3647 |
} |
} |
3648 |
|
|
3658 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
3659 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3660 |
int rb = bits(insn,11,15); |
int rb = bits(insn,11,15); |
3661 |
|
int hreg_rs,hreg_ra,hreg_rb; |
3662 |
|
jit_op_t *iop; |
3663 |
|
|
3664 |
|
/* $ra = $rs ^ $rb */ |
3665 |
|
ppc32_jit_start_hreg_seq(cpu,"xor"); |
3666 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
3667 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
3668 |
|
hreg_rb = ppc32_jit_alloc_hreg(cpu,rb); |
3669 |
|
|
3670 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
3671 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rb,rb); |
3672 |
|
|
3673 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"xor"); |
3674 |
|
|
3675 |
|
if (ra == rs) |
3676 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_XOR,hreg_ra,hreg_rb,4); |
3677 |
|
else if (ra == rb) |
3678 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_XOR,hreg_ra,hreg_rs,4); |
3679 |
|
else { |
3680 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
3681 |
|
amd64_alu_reg_reg_size(iop->ob_ptr,X86_XOR,hreg_ra,hreg_rb,4); |
3682 |
|
} |
3683 |
|
|
3684 |
ppc32_load_gpr(b,AMD64_RBX,rs); |
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
|
ppc32_alu_gpr(b,X86_XOR,AMD64_RBX,rb); |
|
|
ppc32_store_gpr(b,ra,AMD64_RBX); |
|
3685 |
|
|
3686 |
if (insn & 1) |
if (insn & 1) |
3687 |
ppc32_update_cr0(b); |
ppc32_op_emit_update_flags(cpu,0,TRUE); |
3688 |
|
|
3689 |
|
ppc32_jit_close_hreg_seq(cpu); |
3690 |
return(0); |
return(0); |
3691 |
} |
} |
3692 |
|
|
3696 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
3697 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3698 |
m_uint32_t imm = bits(insn,0,15); |
m_uint32_t imm = bits(insn,0,15); |
3699 |
|
int hreg_rs,hreg_ra; |
3700 |
|
jit_op_t *iop; |
3701 |
|
|
3702 |
|
/* $ra = $rs ^ imm */ |
3703 |
|
ppc32_jit_start_hreg_seq(cpu,"xori"); |
3704 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
3705 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
3706 |
|
|
3707 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
3708 |
|
|
3709 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"xori"); |
3710 |
|
|
3711 |
|
if (ra != rs) |
3712 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
3713 |
|
|
3714 |
ppc32_load_imm(b,AMD64_RBX,imm); |
amd64_alu_reg_imm(iop->ob_ptr,X86_XOR,hreg_ra,imm); |
3715 |
ppc32_alu_gpr(b,X86_XOR,AMD64_RBX,rs); |
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
3716 |
ppc32_store_gpr(b,ra,AMD64_RBX); |
|
3717 |
|
ppc32_jit_close_hreg_seq(cpu); |
3718 |
return(0); |
return(0); |
3719 |
} |
} |
3720 |
|
|
3723 |
{ |
{ |
3724 |
int rs = bits(insn,21,25); |
int rs = bits(insn,21,25); |
3725 |
int ra = bits(insn,16,20); |
int ra = bits(insn,16,20); |
3726 |
m_uint32_t imm = bits(insn,0,15); |
m_uint16_t imm = bits(insn,0,15); |
3727 |
|
m_uint32_t tmp = imm << 16; |
3728 |
|
int hreg_rs,hreg_ra; |
3729 |
|
jit_op_t *iop; |
3730 |
|
|
3731 |
|
/* $ra = $rs ^ (imm << 16) */ |
3732 |
|
ppc32_jit_start_hreg_seq(cpu,"xoris"); |
3733 |
|
hreg_rs = ppc32_jit_alloc_hreg(cpu,rs); |
3734 |
|
hreg_ra = ppc32_jit_alloc_hreg(cpu,ra); |
3735 |
|
|
3736 |
|
ppc32_op_emit_load_gpr(cpu,hreg_rs,rs); |
3737 |
|
|
3738 |
|
iop = ppc32_op_emit_insn_output(cpu,1,"xoris"); |
3739 |
|
|
3740 |
|
if (ra != rs) |
3741 |
|
amd64_mov_reg_reg(iop->ob_ptr,hreg_ra,hreg_rs,4); |
3742 |
|
|
3743 |
|
amd64_alu_reg_imm(iop->ob_ptr,X86_XOR,hreg_ra,tmp); |
3744 |
|
ppc32_op_emit_store_gpr(cpu,ra,hreg_ra); |
3745 |
|
|
3746 |
ppc32_load_imm(b,AMD64_RBX,imm << 16); |
ppc32_jit_close_hreg_seq(cpu); |
|
ppc32_alu_gpr(b,X86_XOR,AMD64_RBX,rs); |
|
|
ppc32_store_gpr(b,ra,AMD64_RBX); |
|
3747 |
return(0); |
return(0); |
3748 |
} |
} |
3749 |
|
|
3764 |
{ ppc32_emit_ADDIC , 0xfc000000 , 0x30000000 }, |
{ ppc32_emit_ADDIC , 0xfc000000 , 0x30000000 }, |
3765 |
{ ppc32_emit_ADDIC_dot , 0xfc000000 , 0x34000000 }, |
{ ppc32_emit_ADDIC_dot , 0xfc000000 , 0x34000000 }, |
3766 |
{ ppc32_emit_ADDIS , 0xfc000000 , 0x3c000000 }, |
{ ppc32_emit_ADDIS , 0xfc000000 , 0x3c000000 }, |
3767 |
|
{ ppc32_emit_ADDZE , 0xfc00fffe , 0x7c000194 }, |
3768 |
{ ppc32_emit_AND , 0xfc0007fe , 0x7c000038 }, |
{ ppc32_emit_AND , 0xfc0007fe , 0x7c000038 }, |
3769 |
{ ppc32_emit_ANDC , 0xfc0007fe , 0x7c000078 }, |
{ ppc32_emit_ANDC , 0xfc0007fe , 0x7c000078 }, |
3770 |
{ ppc32_emit_ANDI , 0xfc000000 , 0x70000000 }, |
{ ppc32_emit_ANDI , 0xfc000000 , 0x70000000 }, |