From 19901c4759dff5fdc9ba5e8e36c40d4c71253d7e Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Wed, 29 Jul 2015 18:58:45 -0700 Subject: [PATCH] Replacing a use of strings for xbyak labels. --- src/xenia/cpu/backend/x64/x64_emitter.cc | 8 ++++++-- src/xenia/cpu/backend/x64/x64_emitter.h | 4 ++++ src/xenia/cpu/backend/x64/x64_sequences.cc | 14 +++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/xenia/cpu/backend/x64/x64_emitter.cc b/src/xenia/cpu/backend/x64/x64_emitter.cc index 0b1d9d32c..1086f1491 100644 --- a/src/xenia/cpu/backend/x64/x64_emitter.cc +++ b/src/xenia/cpu/backend/x64/x64_emitter.cc @@ -146,6 +146,9 @@ void* X64Emitter::Emplace(size_t stack_size, FunctionInfo* function_info) { } bool X64Emitter::Emit(HIRBuilder* builder, size_t& out_stack_size) { + Xbyak::Label epilog_label; + epilog_label_ = &epilog_label; + // Calculate stack size. We need to align things to their natural sizes. // This could be much better (sort by type/etc). auto locals = builder->locals(); @@ -240,7 +243,8 @@ bool X64Emitter::Emit(HIRBuilder* builder, size_t& out_stack_size) { } // Function epilog. - L("epilog"); + L(epilog_label); + epilog_label_ = nullptr; EmitTraceUserCallReturn(); mov(rcx, qword[rsp + StackLayout::GUEST_RCX_HOME]); add(rsp, (uint32_t)stack_size); @@ -397,7 +401,7 @@ void X64Emitter::CallIndirect(const hir::Instr* instr, const Reg64& reg) { // Check if return. if (instr->flags & CALL_POSSIBLE_RETURN) { cmp(reg.cvt32(), dword[rsp + StackLayout::GUEST_RET_ADDR]); - je("epilog", CodeGenerator::T_NEAR); + je(epilog_label(), CodeGenerator::T_NEAR); } // Load the pointer to the indirection table maintained in X64CodeCache. diff --git a/src/xenia/cpu/backend/x64/x64_emitter.h b/src/xenia/cpu/backend/x64/x64_emitter.h index dd45c8a5a..4614bd021 100644 --- a/src/xenia/cpu/backend/x64/x64_emitter.h +++ b/src/xenia/cpu/backend/x64/x64_emitter.h @@ -151,6 +151,8 @@ class X64Emitter : public Xbyak::CodeGenerator { r = Xbyak::Xmm(idx); } + Xbyak::Label& epilog_label() { return *epilog_label_; } + void MarkSourceOffset(const hir::Instr* i); void DebugBreak(); @@ -206,6 +208,8 @@ class X64Emitter : public Xbyak::CodeGenerator { Xbyak::util::Cpu cpu_; uint32_t feature_flags_; + Xbyak::Label* epilog_label_ = nullptr; + hir::Instr* current_instr_; DebugInfo* debug_info_; diff --git a/src/xenia/cpu/backend/x64/x64_sequences.cc b/src/xenia/cpu/backend/x64/x64_sequences.cc index de6832a19..3d0fa8871 100644 --- a/src/xenia/cpu/backend/x64/x64_sequences.cc +++ b/src/xenia/cpu/backend/x64/x64_sequences.cc @@ -1032,7 +1032,7 @@ struct RETURN : Sequence> { // If this is the last instruction in the last block, just let us // fall through. if (i.instr->next || i.instr->block->next) { - e.jmp("epilog", CodeGenerator::T_NEAR); + e.jmp(e.epilog_label(), CodeGenerator::T_NEAR); } } }; @@ -1045,42 +1045,42 @@ struct RETURN_TRUE_I8 : Sequence> { static void Emit(X64Emitter& e, const EmitArgType& i) { e.test(i.src1, i.src1); - e.jnz("epilog", CodeGenerator::T_NEAR); + e.jnz(e.epilog_label(), CodeGenerator::T_NEAR); } }; struct RETURN_TRUE_I16 : Sequence> { static void Emit(X64Emitter& e, const EmitArgType& i) { e.test(i.src1, i.src1); - e.jnz("epilog", CodeGenerator::T_NEAR); + e.jnz(e.epilog_label(), CodeGenerator::T_NEAR); } }; struct RETURN_TRUE_I32 : Sequence> { static void Emit(X64Emitter& e, const EmitArgType& i) { e.test(i.src1, i.src1); - e.jnz("epilog", CodeGenerator::T_NEAR); + e.jnz(e.epilog_label(), CodeGenerator::T_NEAR); } }; struct RETURN_TRUE_I64 : Sequence> { static void Emit(X64Emitter& e, const EmitArgType& i) { e.test(i.src1, i.src1); - e.jnz("epilog", CodeGenerator::T_NEAR); + e.jnz(e.epilog_label(), CodeGenerator::T_NEAR); } }; struct RETURN_TRUE_F32 : Sequence> { static void Emit(X64Emitter& e, const EmitArgType& i) { e.vptest(i.src1, i.src1); - e.jnz("epilog", CodeGenerator::T_NEAR); + e.jnz(e.epilog_label(), CodeGenerator::T_NEAR); } }; struct RETURN_TRUE_F64 : Sequence> { static void Emit(X64Emitter& e, const EmitArgType& i) { e.vptest(i.src1, i.src1); - e.jnz("epilog", CodeGenerator::T_NEAR); + e.jnz(e.epilog_label(), CodeGenerator::T_NEAR); } }; EMITTER_OPCODE_TABLE(OPCODE_RETURN_TRUE, RETURN_TRUE_I8, RETURN_TRUE_I16,