Deleting LIR and such, wiring up for HIR->x64.
This commit is contained in:
@@ -9,28 +9,42 @@
|
||||
|
||||
#include <alloy/backend/x64/lowering/lowering_sequences.h>
|
||||
|
||||
#include <alloy/backend/x64/x64_emitter.h>
|
||||
#include <alloy/backend/x64/lowering/lowering_table.h>
|
||||
|
||||
using namespace alloy;
|
||||
using namespace alloy::backend::x64;
|
||||
using namespace alloy::backend::x64::lir;
|
||||
using namespace alloy::backend::x64::lowering;
|
||||
using namespace alloy::hir;
|
||||
|
||||
using namespace Xbyak;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
#define UNIMPLEMENTED_SEQ()
|
||||
|
||||
// TODO(benvanik): emit traces/printfs/etc
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
void alloy::backend::x64::lowering::RegisterSequences(LoweringTable* table) {
|
||||
// --------------------------------------------------------------------------
|
||||
// General
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
table->AddSequence(OPCODE_COMMENT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
char* str = (char*)instr->src1.offset;
|
||||
lb.Comment(str);
|
||||
table->AddSequence(OPCODE_COMMENT, [](X64Emitter& e, Instr*& instr) {
|
||||
//char* str = (char*)instr->src1.offset;
|
||||
//lb.Comment(str);
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_NOP, [](LIRBuilder& lb, Instr*& instr) {
|
||||
lb.Nop();
|
||||
table->AddSequence(OPCODE_NOP, [](X64Emitter& e, Instr*& instr) {
|
||||
// If we got this, chances are we want it.
|
||||
e.nop();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
@@ -39,42 +53,53 @@ void alloy::backend::x64::lowering::RegisterSequences(LoweringTable* table) {
|
||||
// Debugging
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
table->AddSequence(OPCODE_SOURCE_OFFSET, [](LIRBuilder& lb, Instr*& instr) {
|
||||
table->AddSequence(OPCODE_SOURCE_OFFSET, [](X64Emitter& e, Instr*& instr) {
|
||||
// TODO(benvanik): translate source offsets for mapping? We're just passing
|
||||
// down the original offset - it may be nice to have two.
|
||||
lb.SourceOffset(instr->src1.offset);
|
||||
//lb.SourceOffset(instr->src1.offset);
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_DEBUG_BREAK, [](LIRBuilder& lb, Instr*& instr) {
|
||||
lb.DebugBreak();
|
||||
table->AddSequence(OPCODE_DEBUG_BREAK, [](X64Emitter& e, Instr*& instr) {
|
||||
// TODO(benvanik): insert a call to the debug break function to let the
|
||||
// debugger know.
|
||||
e.db(0xCC);
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_DEBUG_BREAK_TRUE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
auto skip_label = lb.NewLocalLabel();
|
||||
lb.Test(instr->src1.value, instr->src1.value);
|
||||
lb.JumpNE(skip_label);
|
||||
lb.DebugBreak();
|
||||
lb.MarkLabel(skip_label);
|
||||
table->AddSequence(OPCODE_DEBUG_BREAK_TRUE, [](X64Emitter& e, Instr*& instr) {
|
||||
e.inLocalLabel();
|
||||
//e.test(e.rax, e.rax);
|
||||
e.jne(".x");
|
||||
// TODO(benvanik): insert a call to the debug break function to let the
|
||||
// debugger know.
|
||||
e.db(0xCC);
|
||||
e.L(".x");
|
||||
e.outLocalLabel();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_TRAP, [](LIRBuilder& lb, Instr*& instr) {
|
||||
lb.Trap();
|
||||
table->AddSequence(OPCODE_TRAP, [](X64Emitter& e, Instr*& instr) {
|
||||
// TODO(benvanik): insert a call to the trap function to let the
|
||||
// debugger know.
|
||||
e.db(0xCC);
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_TRAP_TRUE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
auto skip_label = lb.NewLocalLabel();
|
||||
lb.Test(instr->src1.value, instr->src1.value);
|
||||
lb.JumpNE(skip_label);
|
||||
lb.Trap();
|
||||
lb.MarkLabel(skip_label);
|
||||
table->AddSequence(OPCODE_TRAP_TRUE, [](X64Emitter& e, Instr*& instr) {
|
||||
e.inLocalLabel();
|
||||
//e.test(rax, rax);
|
||||
e.jne(".x");
|
||||
// TODO(benvanik): insert a call to the trap function to let the
|
||||
// debugger know.
|
||||
e.db(0xCC);
|
||||
e.L(".x");
|
||||
e.outLocalLabel();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
@@ -83,46 +108,48 @@ void alloy::backend::x64::lowering::RegisterSequences(LoweringTable* table) {
|
||||
// Calls
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
table->AddSequence(OPCODE_CALL, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_CALL, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_CALL_TRUE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
auto skip_label = lb.NewLocalLabel();
|
||||
lb.Test(instr->src1.value, instr->src1.value);
|
||||
lb.JumpNE(skip_label);
|
||||
// TODO
|
||||
lb.MarkLabel(skip_label);
|
||||
table->AddSequence(OPCODE_CALL_TRUE, [](X64Emitter& e, Instr*& instr) {
|
||||
//auto skip_label = lb.NewLocalLabel();
|
||||
//lb.Test(instr->src1.value, instr->src1.value);
|
||||
//lb.JumpNE(skip_label);
|
||||
//// TODO
|
||||
//lb.MarkLabel(skip_label);
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_CALL_INDIRECT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_CALL_INDIRECT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_CALL_INDIRECT_TRUE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
auto skip_label = lb.NewLocalLabel();
|
||||
lb.Test(instr->src1.value, instr->src1.value);
|
||||
lb.JumpNE(skip_label);
|
||||
// TODO
|
||||
lb.MarkLabel(skip_label);
|
||||
table->AddSequence(OPCODE_CALL_INDIRECT_TRUE, [](X64Emitter& e, Instr*& instr) {
|
||||
//auto skip_label = lb.NewLocalLabel();
|
||||
//lb.Test(instr->src1.value, instr->src1.value);
|
||||
//lb.JumpNE(skip_label);
|
||||
//UNIMPLEMENTED_SEQ();
|
||||
//lb.MarkLabel(skip_label);
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_RETURN, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_RETURN, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_SET_RETURN_ADDRESS, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_SET_RETURN_ADDRESS, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
@@ -131,25 +158,28 @@ void alloy::backend::x64::lowering::RegisterSequences(LoweringTable* table) {
|
||||
// Branches
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
table->AddSequence(OPCODE_BRANCH, [](LIRBuilder& lb, Instr*& instr) {
|
||||
auto target = (LIRLabel*)instr->src1.label->tag;
|
||||
lb.Jump(target);
|
||||
table->AddSequence(OPCODE_BRANCH, [](X64Emitter& e, Instr*& instr) {
|
||||
/*auto target = (LIRLabel*)instr->src1.label->tag;
|
||||
lb.Jump(target);*/
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_BRANCH_TRUE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
lb.Test(instr->src1.value, instr->src1.value);
|
||||
table->AddSequence(OPCODE_BRANCH_TRUE, [](X64Emitter& e, Instr*& instr) {
|
||||
/*lb.Test(instr->src1.value, instr->src1.value);
|
||||
auto target = (LIRLabel*)instr->src2.label->tag;
|
||||
lb.JumpEQ(target);
|
||||
lb.JumpEQ(target);*/
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_BRANCH_FALSE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
lb.Test(instr->src1.value, instr->src1.value);
|
||||
table->AddSequence(OPCODE_BRANCH_FALSE, [](X64Emitter& e, Instr*& instr) {
|
||||
/*lb.Test(instr->src1.value, instr->src1.value);
|
||||
auto target = (LIRLabel*)instr->src2.label->tag;
|
||||
lb.JumpNE(target);
|
||||
lb.JumpNE(target);*/
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
@@ -158,56 +188,61 @@ void alloy::backend::x64::lowering::RegisterSequences(LoweringTable* table) {
|
||||
// Types
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
table->AddSequence(OPCODE_ASSIGN, [](LIRBuilder& lb, Instr*& instr) {
|
||||
lb.Mov(instr->dest, instr->src1.value);
|
||||
table->AddSequence(OPCODE_ASSIGN, [](X64Emitter& e, Instr*& instr) {
|
||||
//lb.Mov(instr->dest, instr->src1.value);
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_CAST, [](LIRBuilder& lb, Instr*& instr) {
|
||||
lb.Mov(instr->dest, instr->src1.value);
|
||||
table->AddSequence(OPCODE_CAST, [](X64Emitter& e, Instr*& instr) {
|
||||
//lb.Mov(instr->dest, instr->src1.value);
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_ZERO_EXTEND, [](LIRBuilder& lb, Instr*& instr) {
|
||||
lb.MovZX(instr->dest, instr->src1.value);
|
||||
table->AddSequence(OPCODE_ZERO_EXTEND, [](X64Emitter& e, Instr*& instr) {
|
||||
//lb.MovZX(instr->dest, instr->src1.value);
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_SIGN_EXTEND, [](LIRBuilder& lb, Instr*& instr) {
|
||||
lb.MovSX(instr->dest, instr->src1.value);
|
||||
table->AddSequence(OPCODE_SIGN_EXTEND, [](X64Emitter& e, Instr*& instr) {
|
||||
//lb.MovSX(instr->dest, instr->src1.value);
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_TRUNCATE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
lb.Mov(instr->dest, instr->src1.value);
|
||||
table->AddSequence(OPCODE_TRUNCATE, [](X64Emitter& e, Instr*& instr) {
|
||||
//lb.Mov(instr->dest, instr->src1.value);
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_CONVERT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_CONVERT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_ROUND, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_ROUND, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_VECTOR_CONVERT_I2F, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_VECTOR_CONVERT_I2F, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_VECTOR_CONVERT_F2I, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_VECTOR_CONVERT_F2I, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
@@ -218,20 +253,20 @@ void alloy::backend::x64::lowering::RegisterSequences(LoweringTable* table) {
|
||||
|
||||
// specials for zeroing/etc (xor/etc)
|
||||
|
||||
table->AddSequence(OPCODE_LOAD_VECTOR_SHL, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_LOAD_VECTOR_SHL, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_LOAD_VECTOR_SHR, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_LOAD_VECTOR_SHR, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_LOAD_CLOCK, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_LOAD_CLOCK, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
@@ -240,20 +275,22 @@ void alloy::backend::x64::lowering::RegisterSequences(LoweringTable* table) {
|
||||
// Context
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
table->AddSequence(OPCODE_LOAD_CONTEXT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
lb.Mov(
|
||||
table->AddSequence(OPCODE_LOAD_CONTEXT, [](X64Emitter& e, Instr*& instr) {
|
||||
/*lb.Mov(
|
||||
instr->dest,
|
||||
LIRRegister(LIRRegisterType::REG64, LIRRegisterName::RCX),
|
||||
instr->src1.offset);
|
||||
instr->src1.offset);*/
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_STORE_CONTEXT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
lb.Mov(
|
||||
table->AddSequence(OPCODE_STORE_CONTEXT, [](X64Emitter& e, Instr*& instr) {
|
||||
/*lb.Mov(
|
||||
LIRRegister(LIRRegisterType::REG64, LIRRegisterName::RCX),
|
||||
instr->src1.offset,
|
||||
instr->src2.value);
|
||||
instr->src2.value);*/
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
@@ -262,24 +299,26 @@ void alloy::backend::x64::lowering::RegisterSequences(LoweringTable* table) {
|
||||
// Memory
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
table->AddSequence(OPCODE_LOAD, [](LIRBuilder& lb, Instr*& instr) {
|
||||
table->AddSequence(OPCODE_LOAD, [](X64Emitter& e, Instr*& instr) {
|
||||
// TODO(benvanik): dynamic register access check
|
||||
// mov reg, [membase + address.32]
|
||||
// TODO(benvanik): special for f32/f64/v128
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_STORE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
table->AddSequence(OPCODE_STORE, [](X64Emitter& e, Instr*& instr) {
|
||||
// TODO(benvanik): dynamic register access check
|
||||
// mov [membase + address.32], reg
|
||||
// TODO(benvanik): special for f32/f64/v128
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_PREFETCH, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_PREFETCH, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
@@ -288,134 +327,140 @@ void alloy::backend::x64::lowering::RegisterSequences(LoweringTable* table) {
|
||||
// Comparisons
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
table->AddSequence(OPCODE_MAX, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_MAX, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_MIN, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_MIN, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_SELECT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_SELECT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_IS_TRUE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_IS_TRUE, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_IS_FALSE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_IS_FALSE, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_COMPARE_EQ, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_COMPARE_EQ, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_COMPARE_NE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_COMPARE_NE, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_COMPARE_SLT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_COMPARE_SLT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_COMPARE_SLE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_COMPARE_SLE, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_COMPARE_SGT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_COMPARE_SGT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_COMPARE_SGE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_COMPARE_SGE, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_COMPARE_ULT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_COMPARE_ULT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_COMPARE_ULE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_COMPARE_ULE, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_COMPARE_UGT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_COMPARE_UGT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_COMPARE_UGE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_COMPARE_UGE, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_DID_CARRY, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_DID_CARRY, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_DID_OVERFLOW, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_DID_OVERFLOW, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_VECTOR_COMPARE_EQ, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_DID_SATURATE, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_VECTOR_COMPARE_SGT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_VECTOR_COMPARE_EQ, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_VECTOR_COMPARE_SGE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_VECTOR_COMPARE_SGT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_VECTOR_COMPARE_UGT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_VECTOR_COMPARE_SGE, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_VECTOR_COMPARE_UGE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_VECTOR_COMPARE_UGT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_VECTOR_COMPARE_UGE, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
@@ -424,200 +469,218 @@ void alloy::backend::x64::lowering::RegisterSequences(LoweringTable* table) {
|
||||
// Math
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
table->AddSequence(OPCODE_ADD, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_ADD, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_ADD_CARRY, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_ADD_CARRY, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_SUB, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_SUB, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_MUL, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_MUL, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_DIV, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_MUL_HI, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_MUL_ADD, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_DIV, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_MUL_SUB, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_MUL_ADD, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_NEG, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_MUL_SUB, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_ABS, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_NEG, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_SQRT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_ABS, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_RSQRT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_SQRT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_POW2, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_RSQRT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_LOG2, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_POW2, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_DOT_PRODUCT_3, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_LOG2, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_DOT_PRODUCT_4, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_DOT_PRODUCT_3, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_AND, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_DOT_PRODUCT_4, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_OR, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_AND, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_XOR, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_OR, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_NOT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_XOR, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_SHL, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_NOT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_VECTOR_SHL, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_SHL, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_SHR, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_VECTOR_SHL, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_VECTOR_SHR, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_SHR, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_SHA, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_VECTOR_SHR, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_VECTOR_SHA, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_SHA, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_ROTATE_LEFT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_VECTOR_SHA, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_BYTE_SWAP, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_ROTATE_LEFT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_CNTLZ, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_BYTE_SWAP, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_INSERT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_CNTLZ, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_EXTRACT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_INSERT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_SPLAT, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_EXTRACT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_PERMUTE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_SPLAT, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_SWIZZLE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_PERMUTE, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_SWIZZLE, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_PACK, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_UNPACK, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
@@ -626,26 +689,26 @@ void alloy::backend::x64::lowering::RegisterSequences(LoweringTable* table) {
|
||||
// Atomic
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
table->AddSequence(OPCODE_COMPARE_EXCHANGE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_COMPARE_EXCHANGE, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_ATOMIC_EXCHANGE, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_ATOMIC_EXCHANGE, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_ATOMIC_ADD, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_ATOMIC_ADD, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
table->AddSequence(OPCODE_ATOMIC_SUB, [](LIRBuilder& lb, Instr*& instr) {
|
||||
// TODO
|
||||
table->AddSequence(OPCODE_ATOMIC_SUB, [](X64Emitter& e, Instr*& instr) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
instr = instr->next;
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -45,59 +45,25 @@ void LoweringTable::AddSequence(hir::Opcode starting_opcode, sequence_fn_t fn) {
|
||||
lookup_[starting_opcode] = new_entry;
|
||||
}
|
||||
|
||||
int LoweringTable::Process(
|
||||
hir::HIRBuilder* hir_builder, lir::LIRBuilder* lir_builder) {
|
||||
lir_builder->EndBlock();
|
||||
|
||||
// Translate all labels ahead of time.
|
||||
// We stash them on tags to make things easier later on.
|
||||
auto hir_block = hir_builder->first_block();
|
||||
while (hir_block) {
|
||||
auto hir_label = hir_block->label_head;
|
||||
while (hir_label) {
|
||||
auto lir_label = lir_builder->NewLabel(hir_label->name);
|
||||
hir_label->tag = lir_label;
|
||||
hir_label = hir_label->next;
|
||||
}
|
||||
hir_block = hir_block->next;
|
||||
}
|
||||
|
||||
// Process each block.
|
||||
hir_block = hir_builder->first_block();
|
||||
while (hir_block) {
|
||||
// Force a new block.
|
||||
lir_builder->AppendBlock();
|
||||
|
||||
// Mark labels.
|
||||
auto hir_label = hir_block->label_head;
|
||||
while (hir_label) {
|
||||
auto lir_label = (lir::LIRLabel*)hir_label->tag;
|
||||
lir_builder->MarkLabel(lir_label);
|
||||
hir_label = hir_label->next;
|
||||
}
|
||||
|
||||
// Process instructions.
|
||||
auto hir_instr = hir_block->instr_head;
|
||||
while (hir_instr) {
|
||||
bool processed = false;
|
||||
auto entry = lookup_[hir_instr->opcode->num];
|
||||
while (entry) {
|
||||
if ((*entry->fn)(*lir_builder, hir_instr)) {
|
||||
processed = true;
|
||||
break;
|
||||
}
|
||||
entry = entry->next;
|
||||
}
|
||||
if (!processed) {
|
||||
// No sequence found!
|
||||
XELOGE("Unable to process HIR opcode %s", hir_instr->opcode->name);
|
||||
return 1;
|
||||
hir_instr = hir_instr->next;
|
||||
int LoweringTable::ProcessBlock(X64Emitter& e, hir::Block* block) {
|
||||
// Process instructions.
|
||||
auto instr = block->instr_head;
|
||||
while (instr) {
|
||||
bool processed = false;
|
||||
auto entry = lookup_[instr->opcode->num];
|
||||
while (entry) {
|
||||
if ((*entry->fn)(e, instr)) {
|
||||
processed = true;
|
||||
break;
|
||||
}
|
||||
entry = entry->next;
|
||||
}
|
||||
if (!processed) {
|
||||
// No sequence found!
|
||||
XELOGE("Unable to process HIR opcode %s", instr->opcode->name);
|
||||
return 1;
|
||||
instr = instr->next;
|
||||
}
|
||||
|
||||
lir_builder->EndBlock();
|
||||
hir_block = hir_block->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
#define ALLOY_BACKEND_X64_X64_LOWERING_LOWERING_TABLE_H_
|
||||
|
||||
#include <alloy/core.h>
|
||||
#include <alloy/backend/x64/lir/lir_builder.h>
|
||||
#include <alloy/backend/x64/lir/lir_instr.h>
|
||||
#include <alloy/hir/hir_builder.h>
|
||||
|
||||
|
||||
@@ -20,6 +18,7 @@ namespace alloy {
|
||||
namespace backend {
|
||||
namespace x64 {
|
||||
class X64Backend;
|
||||
class X64Emitter;
|
||||
namespace lowering {
|
||||
|
||||
|
||||
@@ -30,10 +29,10 @@ public:
|
||||
|
||||
int Initialize();
|
||||
|
||||
int Process(hir::HIRBuilder* hir_builder, lir::LIRBuilder* lir_builder);
|
||||
int ProcessBlock(X64Emitter& e, hir::Block* block);
|
||||
|
||||
public:
|
||||
typedef bool(*sequence_fn_t)(lir::LIRBuilder& lb, hir::Instr*& instr);
|
||||
typedef bool(*sequence_fn_t)(X64Emitter& e, hir::Instr*& instr);
|
||||
void AddSequence(hir::Opcode starting_opcode, sequence_fn_t fn);
|
||||
|
||||
private:
|
||||
@@ -43,6 +42,8 @@ private:
|
||||
sequence_fn_entry_t* next;
|
||||
};
|
||||
|
||||
// NOTE: this class is shared by multiple threads and is not thread safe.
|
||||
// Do not modify anything after init.
|
||||
X64Backend* backend_;
|
||||
sequence_fn_entry_t* lookup_[hir::__OPCODE_MAX_VALUE];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user