From fcb66660c03534ebafcab9969f31a75db3c8f02a Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Wed, 22 May 2013 21:53:21 -0700 Subject: [PATCH] (partial) addx and logging compiled addresses. --- src/xenia/cpu/libjit/libjit_emit_alu.cc | 61 ++++++++++++------------- src/xenia/cpu/libjit/libjit_emitter.cc | 8 ++++ 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/xenia/cpu/libjit/libjit_emit_alu.cc b/src/xenia/cpu/libjit/libjit_emit_alu.cc index f4c3652ac..a1ebc56a9 100644 --- a/src/xenia/cpu/libjit/libjit_emit_alu.cc +++ b/src/xenia/cpu/libjit/libjit_emit_alu.cc @@ -21,41 +21,38 @@ namespace libjit { // Integer arithmetic (A-3) -// XEEMITTER(addx, 0x7C000214, XO )(LibjitEmitter& e, jit_function_t f, InstrData& i) { -// // RD <- (RA) + (RB) +XEEMITTER(addx, 0x7C000214, XO )(LibjitEmitter& e, jit_function_t f, InstrData& i) { + // RD <- (RA) + (RB) -// if (i.XO.OE) { -// // With XER update. -// // This is a different codepath as we need to use llvm.sadd.with.overflow. + if (i.XO.OE) { + // With XER update. + // This is a different codepath as we need to use llvm.sadd.with.overflow. -// Function* sadd_with_overflow = Intrinsic::getDeclaration( -// e.gen_module(), Intrinsic::sadd_with_overflow, jit_type_nint); -// jit_value_t v = b.CreateCall2(sadd_with_overflow, -// e.gpr_value(i.XO.RA), e.gpr_value(i.XO.RB)); -// jit_value_t v0 = b.CreateExtractValue(v, 0); -// e.update_gpr_value(i.XO.RT, v0); -// e.update_xer_with_overflow(b.CreateExtractValue(v, 1)); + // TODO(benvanik): handle overflow exception. + jit_value_t v = jit_insn_add_ovf(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); + //e.update_xer_with_overflow(b.CreateExtractValue(v, 1)); -// if (i.XO.Rc) { -// // With cr0 update. -// e.update_cr_with_cond(0, v0, e.get_int64(0), true); -// } + if (i.XO.Rc) { + // With cr0 update. + 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; -// } else { -// // No OE bit setting. -// 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); - -// if (i.XO.Rc) { -// // With cr0 update. -// e.update_cr_with_cond(0, v, e.get_int64(0), true); -// } - -// return 0; -// } -// return 0; -// } + if (i.XO.Rc) { + // With cr0 update. + e.update_cr_with_cond(0, v, e.get_int64(0), true); + } + } + return 0; +} XEEMITTER(addcx, 0x7C000014, XO )(LibjitEmitter& e, jit_function_t f, InstrData& i) { XEINSTRNOTIMPLEMENTED(); @@ -1019,7 +1016,7 @@ XEEMITTER(srwx, 0x7C000430, X )(LibjitEmitter& e, jit_function_t f, Ins void LibjitRegisterEmitCategoryALU() { - //XEREGISTERINSTR(addx, 0x7C000214); + XEREGISTERINSTR(addx, 0x7C000214); XEREGISTERINSTR(addcx, 0X7C000014); XEREGISTERINSTR(addex, 0x7C000114); XEREGISTERINSTR(addi, 0x38000000); diff --git a/src/xenia/cpu/libjit/libjit_emitter.cc b/src/xenia/cpu/libjit/libjit_emitter.cc index d4d05c760..fb42381e3 100644 --- a/src/xenia/cpu/libjit/libjit_emitter.cc +++ b/src/xenia/cpu/libjit/libjit_emitter.cc @@ -218,6 +218,14 @@ int LibjitEmitter::MakeFunction(FunctionSymbol* symbol, jit_function_t fn) { jit_function_compile(fn_); // post 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;