dynarmic/src/backend_x64/emit_x64.h

70 lines
2.5 KiB
C
Raw Normal View History

2016-07-01 15:01:06 +02:00
/* This file is part of the dynarmic project.
* Copyright (c) 2016 MerryMage
* This software may be used and distributed according to the terms of the GNU
* General Public License version 2 or any later version.
*/
#pragma once
#include <set>
#include <unordered_map>
2016-07-01 15:01:06 +02:00
#include "backend_x64/reg_alloc.h"
#include "backend_x64/routines.h"
#include "common/x64/emitter.h"
#include "frontend/ir/ir.h"
2016-07-01 15:01:06 +02:00
#include "interface/interface.h"
namespace Dynarmic {
namespace BackendX64 {
class EmitX64 final {
public:
2016-07-07 11:53:09 +02:00
EmitX64(Gen::XEmitter* code, Routines* routines, UserCallbacks cb, Jit* jit_interface)
: reg_alloc(code), code(code), routines(routines), cb(cb), jit_interface(jit_interface) {}
2016-07-01 15:01:06 +02:00
2016-07-23 00:55:00 +02:00
CodePtr Emit(const Arm::LocationDescriptor descriptor, IR::Block& ir);
CodePtr GetBasicBlock(Arm::LocationDescriptor descriptor) {
auto iter = basic_blocks.find(descriptor);
return iter != basic_blocks.end() ? iter->second : nullptr;
}
2016-07-01 15:01:06 +02:00
void ClearCache();
private:
// Microinstruction emitters
2016-07-31 15:52:28 +02:00
#define OPCODE(name, type, ...) void Emit##name(IR::Block& block, IR::Inst* inst);
#include "frontend/ir/opcodes.inc"
#undef OPCODE
2016-07-01 15:01:06 +02:00
// Helpers
void EmitAddCycles(size_t cycles);
void EmitCondPrelude(Arm::Cond cond,
boost::optional<Arm::LocationDescriptor> cond_failed,
Arm::LocationDescriptor current_location);
2016-07-07 11:53:09 +02:00
// Terminal instruction emitters
2016-07-07 11:53:09 +02:00
void EmitTerminal(IR::Terminal terminal, Arm::LocationDescriptor initial_location);
void EmitTerminalInterpret(IR::Term::Interpret terminal, Arm::LocationDescriptor initial_location);
void EmitTerminalReturnToDispatch(IR::Term::ReturnToDispatch terminal, Arm::LocationDescriptor initial_location);
void EmitTerminalLinkBlock(IR::Term::LinkBlock terminal, Arm::LocationDescriptor initial_location);
void EmitTerminalLinkBlockFast(IR::Term::LinkBlockFast terminal, Arm::LocationDescriptor initial_location);
void EmitTerminalPopRSBHint(IR::Term::PopRSBHint terminal, Arm::LocationDescriptor initial_location);
void EmitTerminalIf(IR::Term::If terminal, Arm::LocationDescriptor initial_location);
2016-07-01 15:01:06 +02:00
// Per-block state
2016-07-01 15:01:06 +02:00
std::set<IR::Value*> inhibit_emission;
RegAlloc reg_alloc;
// State
Gen::XEmitter* code;
2016-07-01 15:01:06 +02:00
Routines* routines;
UserCallbacks cb;
2016-07-07 11:53:09 +02:00
Jit* jit_interface;
std::unordered_map<Arm::LocationDescriptor, CodePtr, Arm::LocationDescriptorHash> basic_blocks;
2016-07-01 15:01:06 +02:00
};
} // namespace BackendX64
} // namespace Dynarmic