[x64] Factor out a lot of the opcode handling code

This commit is contained in:
Dr. Chat
2018-11-17 15:32:11 -06:00
parent 696c3cd439
commit 6861cce492
3 changed files with 651 additions and 613 deletions

View File

@@ -12,6 +12,8 @@
#include "xenia/cpu/hir/instr.h"
#include <unordered_map>
namespace xe {
namespace cpu {
namespace backend {
@@ -19,6 +21,25 @@ namespace x64 {
class X64Emitter;
typedef bool (*SequenceSelectFn)(X64Emitter&, const hir::Instr*);
extern std::unordered_map<uint32_t, SequenceSelectFn> sequence_table;
template <typename T>
bool Register() {
sequence_table.insert({T::head_key(), T::Select});
return true;
}
template <typename T, typename Tn, typename... Ts>
static bool Register() {
bool b = true;
b = b && Register<T>(); // Call the above function
b = b && Register<Tn, Ts...>(); // Call ourself again (recursively)
return b;
}
#define EMITTER_OPCODE_TABLE(name, ...) \
const auto X64_INSTR_##name = Register<__VA_ARGS__>();
void RegisterSequences();
bool SelectSequence(X64Emitter* e, const hir::Instr* i,
const hir::Instr** new_tail);