xenia/src/alloy/backend/x64/x64_backend.cc

66 lines
2 KiB
C++
Raw Normal View History

2013-12-30 04:54:17 +01:00
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
2015-02-01 07:49:47 +01:00
#include "alloy/backend/x64/x64_backend.h"
2013-12-30 04:54:17 +01:00
2015-02-01 07:49:47 +01:00
#include "alloy/backend/x64/x64_assembler.h"
#include "alloy/backend/x64/x64_code_cache.h"
#include "alloy/backend/x64/x64_sequences.h"
#include "alloy/backend/x64/x64_thunk_emitter.h"
2013-12-30 04:54:17 +01:00
namespace alloy {
namespace backend {
namespace x64 {
2013-12-30 04:54:17 +01:00
using alloy::runtime::Runtime;
2013-12-30 04:54:17 +01:00
X64Backend::X64Backend(Runtime* runtime) : Backend(runtime), code_cache_(0) {}
2013-12-30 04:54:17 +01:00
X64Backend::~X64Backend() { delete code_cache_; }
2013-12-30 04:54:17 +01:00
int X64Backend::Initialize() {
int result = Backend::Initialize();
if (result) {
return result;
}
RegisterSequences();
2014-02-09 07:00:21 +01:00
machine_info_.register_sets[0] = {
0, "gpr", MachineInfo::RegisterSet::INT_TYPES, X64Emitter::GPR_COUNT,
2014-02-09 07:00:21 +01:00
};
machine_info_.register_sets[1] = {
1, "xmm", MachineInfo::RegisterSet::FLOAT_TYPES |
MachineInfo::RegisterSet::VEC_TYPES,
X64Emitter::XMM_COUNT,
2014-02-09 07:00:21 +01:00
};
2014-01-03 05:41:13 +01:00
code_cache_ = new X64CodeCache();
result = code_cache_->Initialize();
if (result) {
return result;
}
2014-07-14 07:28:00 +02:00
// Generate thunks used to transition between jitted code and host code.
auto allocator = std::make_unique<XbyakAllocator>();
auto thunk_emitter = std::make_unique<X64ThunkEmitter>(this, allocator.get());
host_to_guest_thunk_ = thunk_emitter->EmitHostToGuestThunk();
guest_to_host_thunk_ = thunk_emitter->EmitGuestToHostThunk();
2013-12-30 04:54:17 +01:00
return result;
}
2014-07-14 07:28:00 +02:00
std::unique_ptr<Assembler> X64Backend::CreateAssembler() {
return std::make_unique<X64Assembler>(this);
}
} // namespace x64
} // namespace backend
} // namespace alloy