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();