emit_x64: Move implementations into the cpp file

Prevents needing to rebuild everything including the emitter if any
details ever change.
This commit is contained in:
Lioncash 2016-12-04 23:22:56 -05:00 committed by Merry
parent 282029f60a
commit 6a16edc0fb
2 changed files with 14 additions and 9 deletions

View file

@ -51,6 +51,10 @@ static void EraseInstruction(IR::Block& block, IR::Inst* inst) {
block.Instructions().erase(inst);
}
EmitX64::EmitX64(BlockOfCode* code, UserCallbacks cb, Jit* jit_interface)
: reg_alloc(code), code(code), cb(cb), jit_interface(jit_interface) {
}
EmitX64::BlockDescriptor EmitX64::Emit(IR::Block& block) {
const IR::LocationDescriptor descriptor = block.Location();
@ -95,6 +99,13 @@ EmitX64::BlockDescriptor EmitX64::Emit(IR::Block& block) {
return basic_blocks[descriptor];
}
boost::optional<EmitX64::BlockDescriptor> EmitX64::GetBasicBlock(IR::LocationDescriptor descriptor) {
auto iter = basic_blocks.find(descriptor);
if (iter == basic_blocks.end())
return boost::none;
return boost::make_optional<BlockDescriptor>(iter->second);
}
void EmitX64::EmitBreakpoint(IR::Block&, IR::Inst*) {
code->int3();
}

View file

@ -33,14 +33,13 @@ class BlockOfCode;
class EmitX64 final {
public:
EmitX64(BlockOfCode* code, UserCallbacks cb, Jit* jit_interface)
: reg_alloc(code), code(code), cb(cb), jit_interface(jit_interface) {}
struct BlockDescriptor {
CodePtr code_ptr; ///< Entrypoint of emitted code
size_t size; ///< Length in bytes of emitted code
};
EmitX64(BlockOfCode* code, UserCallbacks cb, Jit* jit_interface);
/**
* Emit host machine code for a basic block with intermediate representation `ir`.
* @note ir is modified.
@ -48,12 +47,7 @@ public:
BlockDescriptor Emit(IR::Block& ir);
/// Looks up an emitted host block in the cache.
boost::optional<BlockDescriptor> GetBasicBlock(IR::LocationDescriptor descriptor) {
auto iter = basic_blocks.find(descriptor);
if (iter == basic_blocks.end())
return boost::none;
return boost::make_optional<BlockDescriptor>(iter->second);
}
boost::optional<BlockDescriptor> GetBasicBlock(IR::LocationDescriptor descriptor);
/// Empties the cache.
void ClearCache();