(partial) addx and logging compiled addresses.

This commit is contained in:
Ben Vanik 2013-05-22 21:53:21 -07:00
parent 5cb8cf2630
commit fcb66660c0
2 changed files with 37 additions and 32 deletions

View File

@ -21,41 +21,38 @@ namespace libjit {
// Integer arithmetic (A-3) // Integer arithmetic (A-3)
// XEEMITTER(addx, 0x7C000214, XO )(LibjitEmitter& e, jit_function_t f, InstrData& i) { XEEMITTER(addx, 0x7C000214, XO )(LibjitEmitter& e, jit_function_t f, InstrData& i) {
// // RD <- (RA) + (RB) // RD <- (RA) + (RB)
// if (i.XO.OE) { if (i.XO.OE) {
// // With XER update. // With XER update.
// // This is a different codepath as we need to use llvm.sadd.with.overflow. // This is a different codepath as we need to use llvm.sadd.with.overflow.
// Function* sadd_with_overflow = Intrinsic::getDeclaration( // TODO(benvanik): handle overflow exception.
// e.gen_module(), Intrinsic::sadd_with_overflow, jit_type_nint); jit_value_t v = jit_insn_add_ovf(f,
// jit_value_t v = b.CreateCall2(sadd_with_overflow, e.make_signed(e.gpr_value(i.XO.RA)),
// e.gpr_value(i.XO.RA), e.gpr_value(i.XO.RB)); e.make_signed(e.gpr_value(i.XO.RB)));
// jit_value_t v0 = b.CreateExtractValue(v, 0); e.update_gpr_value(i.XO.RT, v);
// e.update_gpr_value(i.XO.RT, v0);
//e.update_xer_with_overflow(b.CreateExtractValue(v, 1)); //e.update_xer_with_overflow(b.CreateExtractValue(v, 1));
// if (i.XO.Rc) { if (i.XO.Rc) {
// // With cr0 update. // With cr0 update.
// e.update_cr_with_cond(0, v0, e.get_int64(0), true); e.update_cr_with_cond(0, v, e.get_int64(0), true);
// } }
} else {
// No OE bit setting.
jit_value_t v = jit_insn_add(f,
e.make_signed(e.gpr_value(i.XO.RA)),
e.make_signed(e.gpr_value(i.XO.RB)));
e.update_gpr_value(i.XO.RT, v);
// return 0; if (i.XO.Rc) {
// } else { // With cr0 update.
// // No OE bit setting. e.update_cr_with_cond(0, v, e.get_int64(0), true);
// jit_value_t v = b.CreateAdd(e.gpr_value(i.XO.RA), e.gpr_value(i.XO.RB)); }
// e.update_gpr_value(i.XO.RT, v); }
return 0;
// if (i.XO.Rc) { }
// // With cr0 update.
// e.update_cr_with_cond(0, v, e.get_int64(0), true);
// }
// return 0;
// }
// return 0;
// }
XEEMITTER(addcx, 0x7C000014, XO )(LibjitEmitter& e, jit_function_t f, InstrData& i) { XEEMITTER(addcx, 0x7C000014, XO )(LibjitEmitter& e, jit_function_t f, InstrData& i) {
XEINSTRNOTIMPLEMENTED(); XEINSTRNOTIMPLEMENTED();
@ -1019,7 +1016,7 @@ XEEMITTER(srwx, 0x7C000430, X )(LibjitEmitter& e, jit_function_t f, Ins
void LibjitRegisterEmitCategoryALU() { void LibjitRegisterEmitCategoryALU() {
//XEREGISTERINSTR(addx, 0x7C000214); XEREGISTERINSTR(addx, 0x7C000214);
XEREGISTERINSTR(addcx, 0X7C000014); XEREGISTERINSTR(addcx, 0X7C000014);
XEREGISTERINSTR(addex, 0x7C000114); XEREGISTERINSTR(addex, 0x7C000114);
XEREGISTERINSTR(addi, 0x38000000); XEREGISTERINSTR(addi, 0x38000000);

View File

@ -218,6 +218,14 @@ int LibjitEmitter::MakeFunction(FunctionSymbol* symbol, jit_function_t fn) {
jit_function_compile(fn_); jit_function_compile(fn_);
// post // post
jit_dump_function(stdout, fn_, symbol->name()); jit_dump_function(stdout, fn_, symbol->name());
XELOGE("Compile(%s): compiled to 0x%p - 0x%p (%db)",
symbol->name(),
jit_function_get_code_start_address(fn_),
jit_function_get_code_end_address(fn_),
(uint32_t)(
(intptr_t)jit_function_get_code_end_address(fn_) -
(intptr_t)jit_function_get_code_start_address(fn_)));
} }
return result_code; return result_code;