From 6a16edc0fb2d778e516641b8c6948c47d0d99423 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 4 Dec 2016 23:22:56 -0500 Subject: [PATCH] emit_x64: Move implementations into the cpp file Prevents needing to rebuild everything including the emitter if any details ever change. --- src/backend_x64/emit_x64.cpp | 11 +++++++++++ src/backend_x64/emit_x64.h | 12 +++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/backend_x64/emit_x64.cpp b/src/backend_x64/emit_x64.cpp index c8354778..f2afbc1a 100644 --- a/src/backend_x64/emit_x64.cpp +++ b/src/backend_x64/emit_x64.cpp @@ -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::GetBasicBlock(IR::LocationDescriptor descriptor) { + auto iter = basic_blocks.find(descriptor); + if (iter == basic_blocks.end()) + return boost::none; + return boost::make_optional(iter->second); +} + void EmitX64::EmitBreakpoint(IR::Block&, IR::Inst*) { code->int3(); } diff --git a/src/backend_x64/emit_x64.h b/src/backend_x64/emit_x64.h index 10ef7745..f4585a6d 100644 --- a/src/backend_x64/emit_x64.h +++ b/src/backend_x64/emit_x64.h @@ -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 GetBasicBlock(IR::LocationDescriptor descriptor) { - auto iter = basic_blocks.find(descriptor); - if (iter == basic_blocks.end()) - return boost::none; - return boost::make_optional(iter->second); - } + boost::optional GetBasicBlock(IR::LocationDescriptor descriptor); /// Empties the cache. void ClearCache();