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. *
|
|
|
|
|
******************************************************************************
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <alloy/backend/x64/x64_backend.h>
|
|
|
|
|
|
|
|
|
|
#include <alloy/backend/x64/tracing.h>
|
|
|
|
|
#include <alloy/backend/x64/x64_assembler.h>
|
2014-01-03 05:41:13 +01:00
|
|
|
#include <alloy/backend/x64/x64_code_cache.h>
|
2014-02-01 07:16:05 +01:00
|
|
|
#include <alloy/backend/x64/x64_thunk_emitter.h>
|
2013-12-30 07:05:41 +01:00
|
|
|
#include <alloy/backend/x64/lowering/lowering_table.h>
|
2014-01-02 09:00:14 +01:00
|
|
|
#include <alloy/backend/x64/lowering/lowering_sequences.h>
|
2013-12-30 04:54:17 +01:00
|
|
|
|
|
|
|
|
using namespace alloy;
|
|
|
|
|
using namespace alloy::backend;
|
|
|
|
|
using namespace alloy::backend::x64;
|
2013-12-30 07:05:41 +01:00
|
|
|
using namespace alloy::backend::x64::lowering;
|
2013-12-30 04:54:17 +01:00
|
|
|
using namespace alloy::runtime;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
X64Backend::X64Backend(Runtime* runtime) :
|
2014-01-03 05:41:13 +01:00
|
|
|
code_cache_(0), lowering_table_(0),
|
2013-12-30 04:54:17 +01:00
|
|
|
Backend(runtime) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
X64Backend::~X64Backend() {
|
|
|
|
|
alloy::tracing::WriteEvent(EventType::Deinit({
|
|
|
|
|
}));
|
2013-12-30 07:05:41 +01:00
|
|
|
delete lowering_table_;
|
2014-01-03 05:41:13 +01:00
|
|
|
delete code_cache_;
|
2013-12-30 04:54:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int X64Backend::Initialize() {
|
|
|
|
|
int result = Backend::Initialize();
|
|
|
|
|
if (result) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-09 07:00:21 +01:00
|
|
|
machine_info_.register_sets[0] = {
|
|
|
|
|
0,
|
|
|
|
|
"gpr",
|
|
|
|
|
MachineInfo::RegisterSet::INT_TYPES,
|
|
|
|
|
10,
|
|
|
|
|
};
|
|
|
|
|
machine_info_.register_sets[1] = {
|
|
|
|
|
1,
|
|
|
|
|
"xmm",
|
|
|
|
|
MachineInfo::RegisterSet::FLOAT_TYPES |
|
|
|
|
|
MachineInfo::RegisterSet::VEC_TYPES,
|
|
|
|
|
10,
|
|
|
|
|
};
|
|
|
|
|
|
2014-01-03 05:41:13 +01:00
|
|
|
code_cache_ = new X64CodeCache();
|
|
|
|
|
result = code_cache_->Initialize();
|
|
|
|
|
if (result) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-01 07:16:05 +01:00
|
|
|
auto allocator = new XbyakAllocator();
|
|
|
|
|
auto thunk_emitter = new X64ThunkEmitter(this, allocator);
|
|
|
|
|
host_to_guest_thunk_ = thunk_emitter->EmitHostToGuestThunk();
|
|
|
|
|
guest_to_host_thunk_ = thunk_emitter->EmitGuestToHostThunk();
|
|
|
|
|
delete thunk_emitter;
|
|
|
|
|
delete allocator;
|
|
|
|
|
|
2013-12-30 07:05:41 +01:00
|
|
|
lowering_table_ = new LoweringTable(this);
|
2014-01-02 09:00:14 +01:00
|
|
|
RegisterSequences(lowering_table_);
|
2013-12-30 07:05:41 +01:00
|
|
|
|
2013-12-30 04:54:17 +01:00
|
|
|
alloy::tracing::WriteEvent(EventType::Init({
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assembler* X64Backend::CreateAssembler() {
|
|
|
|
|
return new X64Assembler(this);
|
|
|
|
|
}
|