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); 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) { EmitX64::BlockDescriptor EmitX64::Emit(IR::Block& block) {
const IR::LocationDescriptor descriptor = block.Location(); const IR::LocationDescriptor descriptor = block.Location();
@ -95,6 +99,13 @@ EmitX64::BlockDescriptor EmitX64::Emit(IR::Block& block) {
return basic_blocks[descriptor]; 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*) { void EmitX64::EmitBreakpoint(IR::Block&, IR::Inst*) {
code->int3(); code->int3();
} }

View file

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