Replacing a use of strings for xbyak labels.
This commit is contained in:
parent
40e98eab7c
commit
19901c4759
|
@ -146,6 +146,9 @@ void* X64Emitter::Emplace(size_t stack_size, FunctionInfo* function_info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool X64Emitter::Emit(HIRBuilder* builder, size_t& out_stack_size) {
|
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.
|
// Calculate stack size. We need to align things to their natural sizes.
|
||||||
// This could be much better (sort by type/etc).
|
// This could be much better (sort by type/etc).
|
||||||
auto locals = builder->locals();
|
auto locals = builder->locals();
|
||||||
|
@ -240,7 +243,8 @@ bool X64Emitter::Emit(HIRBuilder* builder, size_t& out_stack_size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function epilog.
|
// Function epilog.
|
||||||
L("epilog");
|
L(epilog_label);
|
||||||
|
epilog_label_ = nullptr;
|
||||||
EmitTraceUserCallReturn();
|
EmitTraceUserCallReturn();
|
||||||
mov(rcx, qword[rsp + StackLayout::GUEST_RCX_HOME]);
|
mov(rcx, qword[rsp + StackLayout::GUEST_RCX_HOME]);
|
||||||
add(rsp, (uint32_t)stack_size);
|
add(rsp, (uint32_t)stack_size);
|
||||||
|
@ -397,7 +401,7 @@ void X64Emitter::CallIndirect(const hir::Instr* instr, const Reg64& reg) {
|
||||||
// Check if return.
|
// Check if return.
|
||||||
if (instr->flags & CALL_POSSIBLE_RETURN) {
|
if (instr->flags & CALL_POSSIBLE_RETURN) {
|
||||||
cmp(reg.cvt32(), dword[rsp + StackLayout::GUEST_RET_ADDR]);
|
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.
|
// Load the pointer to the indirection table maintained in X64CodeCache.
|
||||||
|
|
|
@ -151,6 +151,8 @@ class X64Emitter : public Xbyak::CodeGenerator {
|
||||||
r = Xbyak::Xmm(idx);
|
r = Xbyak::Xmm(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Xbyak::Label& epilog_label() { return *epilog_label_; }
|
||||||
|
|
||||||
void MarkSourceOffset(const hir::Instr* i);
|
void MarkSourceOffset(const hir::Instr* i);
|
||||||
|
|
||||||
void DebugBreak();
|
void DebugBreak();
|
||||||
|
@ -206,6 +208,8 @@ class X64Emitter : public Xbyak::CodeGenerator {
|
||||||
Xbyak::util::Cpu cpu_;
|
Xbyak::util::Cpu cpu_;
|
||||||
uint32_t feature_flags_;
|
uint32_t feature_flags_;
|
||||||
|
|
||||||
|
Xbyak::Label* epilog_label_ = nullptr;
|
||||||
|
|
||||||
hir::Instr* current_instr_;
|
hir::Instr* current_instr_;
|
||||||
|
|
||||||
DebugInfo* debug_info_;
|
DebugInfo* debug_info_;
|
||||||
|
|
|
@ -1032,7 +1032,7 @@ struct RETURN : Sequence<RETURN, I<OPCODE_RETURN, VoidOp>> {
|
||||||
// If this is the last instruction in the last block, just let us
|
// If this is the last instruction in the last block, just let us
|
||||||
// fall through.
|
// fall through.
|
||||||
if (i.instr->next || i.instr->block->next) {
|
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<RETURN_TRUE_I8, I<OPCODE_RETURN_TRUE, VoidOp, I8Op>> {
|
: Sequence<RETURN_TRUE_I8, I<OPCODE_RETURN_TRUE, VoidOp, I8Op>> {
|
||||||
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
||||||
e.test(i.src1, i.src1);
|
e.test(i.src1, i.src1);
|
||||||
e.jnz("epilog", CodeGenerator::T_NEAR);
|
e.jnz(e.epilog_label(), CodeGenerator::T_NEAR);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct RETURN_TRUE_I16
|
struct RETURN_TRUE_I16
|
||||||
: Sequence<RETURN_TRUE_I16, I<OPCODE_RETURN_TRUE, VoidOp, I16Op>> {
|
: Sequence<RETURN_TRUE_I16, I<OPCODE_RETURN_TRUE, VoidOp, I16Op>> {
|
||||||
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
||||||
e.test(i.src1, i.src1);
|
e.test(i.src1, i.src1);
|
||||||
e.jnz("epilog", CodeGenerator::T_NEAR);
|
e.jnz(e.epilog_label(), CodeGenerator::T_NEAR);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct RETURN_TRUE_I32
|
struct RETURN_TRUE_I32
|
||||||
: Sequence<RETURN_TRUE_I32, I<OPCODE_RETURN_TRUE, VoidOp, I32Op>> {
|
: Sequence<RETURN_TRUE_I32, I<OPCODE_RETURN_TRUE, VoidOp, I32Op>> {
|
||||||
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
||||||
e.test(i.src1, i.src1);
|
e.test(i.src1, i.src1);
|
||||||
e.jnz("epilog", CodeGenerator::T_NEAR);
|
e.jnz(e.epilog_label(), CodeGenerator::T_NEAR);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct RETURN_TRUE_I64
|
struct RETURN_TRUE_I64
|
||||||
: Sequence<RETURN_TRUE_I64, I<OPCODE_RETURN_TRUE, VoidOp, I64Op>> {
|
: Sequence<RETURN_TRUE_I64, I<OPCODE_RETURN_TRUE, VoidOp, I64Op>> {
|
||||||
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
||||||
e.test(i.src1, i.src1);
|
e.test(i.src1, i.src1);
|
||||||
e.jnz("epilog", CodeGenerator::T_NEAR);
|
e.jnz(e.epilog_label(), CodeGenerator::T_NEAR);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct RETURN_TRUE_F32
|
struct RETURN_TRUE_F32
|
||||||
: Sequence<RETURN_TRUE_F32, I<OPCODE_RETURN_TRUE, VoidOp, F32Op>> {
|
: Sequence<RETURN_TRUE_F32, I<OPCODE_RETURN_TRUE, VoidOp, F32Op>> {
|
||||||
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
||||||
e.vptest(i.src1, i.src1);
|
e.vptest(i.src1, i.src1);
|
||||||
e.jnz("epilog", CodeGenerator::T_NEAR);
|
e.jnz(e.epilog_label(), CodeGenerator::T_NEAR);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct RETURN_TRUE_F64
|
struct RETURN_TRUE_F64
|
||||||
: Sequence<RETURN_TRUE_F64, I<OPCODE_RETURN_TRUE, VoidOp, F64Op>> {
|
: Sequence<RETURN_TRUE_F64, I<OPCODE_RETURN_TRUE, VoidOp, F64Op>> {
|
||||||
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
||||||
e.vptest(i.src1, i.src1);
|
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,
|
EMITTER_OPCODE_TABLE(OPCODE_RETURN_TRUE, RETURN_TRUE_I8, RETURN_TRUE_I16,
|
||||||
|
|
Loading…
Reference in New Issue