Moving cpu/runtime/ to cpu/.
This commit is contained in:
@@ -9,13 +9,13 @@
|
||||
|
||||
#include "xenia/cpu/frontend/frontend.h"
|
||||
|
||||
#include "xenia/cpu/runtime/runtime.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
namespace frontend {
|
||||
|
||||
Frontend::Frontend(runtime::Runtime* runtime) : runtime_(runtime) {}
|
||||
Frontend::Frontend(Runtime* runtime) : runtime_(runtime) {}
|
||||
|
||||
Frontend::~Frontend() = default;
|
||||
|
||||
|
||||
@@ -14,14 +14,12 @@
|
||||
|
||||
#include "xenia/cpu/frontend/context_info.h"
|
||||
#include "xenia/memory.h"
|
||||
#include "xenia/cpu/runtime/function.h"
|
||||
#include "xenia/cpu/runtime/symbol_info.h"
|
||||
#include "xenia/cpu/function.h"
|
||||
#include "xenia/cpu/symbol_info.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
namespace runtime {
|
||||
class Runtime;
|
||||
} // namespace runtime
|
||||
} // namespace cpu
|
||||
} // namespace xe
|
||||
|
||||
@@ -31,22 +29,22 @@ namespace frontend {
|
||||
|
||||
class Frontend {
|
||||
public:
|
||||
Frontend(runtime::Runtime* runtime);
|
||||
Frontend(Runtime* runtime);
|
||||
virtual ~Frontend();
|
||||
|
||||
runtime::Runtime* runtime() const { return runtime_; }
|
||||
Runtime* runtime() const { return runtime_; }
|
||||
Memory* memory() const;
|
||||
ContextInfo* context_info() const { return context_info_.get(); }
|
||||
|
||||
virtual int Initialize();
|
||||
|
||||
virtual int DeclareFunction(runtime::FunctionInfo* symbol_info) = 0;
|
||||
virtual int DefineFunction(runtime::FunctionInfo* symbol_info,
|
||||
virtual int DeclareFunction(FunctionInfo* symbol_info) = 0;
|
||||
virtual int DefineFunction(FunctionInfo* symbol_info,
|
||||
uint32_t debug_info_flags, uint32_t trace_flags,
|
||||
runtime::Function** out_function) = 0;
|
||||
Function** out_function) = 0;
|
||||
|
||||
protected:
|
||||
runtime::Runtime* runtime_;
|
||||
Runtime* runtime_;
|
||||
std::unique_ptr<ContextInfo> context_info_;
|
||||
};
|
||||
|
||||
|
||||
@@ -15,10 +15,8 @@
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
namespace runtime {
|
||||
class Runtime;
|
||||
class ThreadState;
|
||||
} // namespace runtime
|
||||
} // namespace cpu
|
||||
} // namespace xe
|
||||
|
||||
@@ -45,7 +43,7 @@ using vec128_t = poly::vec128_t;
|
||||
typedef struct alignas(64) PPCContext_s {
|
||||
// Must be stored at 0x0 for now.
|
||||
// TODO(benvanik): find a nice way to describe this to the JIT.
|
||||
runtime::ThreadState* thread_state;
|
||||
ThreadState* thread_state;
|
||||
// TODO(benvanik): this is getting nasty. Must be here.
|
||||
uint8_t* membase;
|
||||
|
||||
@@ -211,7 +209,7 @@ typedef struct alignas(64) PPCContext_s {
|
||||
|
||||
// Runtime-specific data pointer. Used on callbacks to get access to the
|
||||
// current runtime and its data.
|
||||
runtime::Runtime* runtime;
|
||||
Runtime* runtime;
|
||||
|
||||
void SetRegFromString(const char* name, const char* value);
|
||||
bool CompareRegWithString(const char* name, const char* value,
|
||||
|
||||
@@ -13,16 +13,14 @@
|
||||
#include "xenia/cpu/frontend/ppc/ppc_disasm.h"
|
||||
#include "xenia/cpu/frontend/ppc/ppc_emit.h"
|
||||
#include "xenia/cpu/frontend/ppc/ppc_translator.h"
|
||||
#include "xenia/cpu/runtime/runtime.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
namespace frontend {
|
||||
namespace ppc {
|
||||
|
||||
using xe::cpu::runtime::Function;
|
||||
using xe::cpu::runtime::FunctionInfo;
|
||||
using xe::cpu::runtime::Runtime;
|
||||
using xe::cpu::Runtime;
|
||||
|
||||
void InitializeIfNeeded();
|
||||
void CleanupOnShutdown();
|
||||
|
||||
@@ -25,23 +25,22 @@ class PPCTranslator;
|
||||
struct PPCBuiltins {
|
||||
std::mutex global_lock;
|
||||
bool global_lock_taken;
|
||||
runtime::FunctionInfo* check_global_lock;
|
||||
runtime::FunctionInfo* handle_global_lock;
|
||||
FunctionInfo* check_global_lock;
|
||||
FunctionInfo* handle_global_lock;
|
||||
};
|
||||
|
||||
class PPCFrontend : public Frontend {
|
||||
public:
|
||||
PPCFrontend(runtime::Runtime* runtime);
|
||||
PPCFrontend(Runtime* runtime);
|
||||
~PPCFrontend() override;
|
||||
|
||||
int Initialize() override;
|
||||
|
||||
PPCBuiltins* builtins() { return &builtins_; }
|
||||
|
||||
int DeclareFunction(runtime::FunctionInfo* symbol_info) override;
|
||||
int DefineFunction(runtime::FunctionInfo* symbol_info,
|
||||
uint32_t debug_info_flags, uint32_t trace_flags,
|
||||
runtime::Function** out_function) override;
|
||||
int DeclareFunction(FunctionInfo* symbol_info) override;
|
||||
int DefineFunction(FunctionInfo* symbol_info, uint32_t debug_info_flags,
|
||||
uint32_t trace_flags, Function** out_function) override;
|
||||
|
||||
private:
|
||||
poly::TypePool<PPCTranslator, PPCFrontend*> translator_pool_;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "xenia/cpu/frontend/ppc/ppc_frontend.h"
|
||||
#include "xenia/cpu/frontend/ppc/ppc_instr.h"
|
||||
#include "xenia/cpu/hir/label.h"
|
||||
#include "xenia/cpu/runtime/runtime.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
namespace xe {
|
||||
@@ -29,8 +29,6 @@ using namespace xe::cpu::hir;
|
||||
using xe::cpu::hir::Label;
|
||||
using xe::cpu::hir::TypeName;
|
||||
using xe::cpu::hir::Value;
|
||||
using xe::cpu::runtime::Runtime;
|
||||
using xe::cpu::runtime::FunctionInfo;
|
||||
|
||||
PPCHIRBuilder::PPCHIRBuilder(PPCFrontend* frontend)
|
||||
: HIRBuilder(), frontend_(frontend), comment_buffer_(4096) {}
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#define XENIA_FRONTEND_PPC_PPC_HIR_BUILDER_H_
|
||||
|
||||
#include "xenia/cpu/hir/hir_builder.h"
|
||||
#include "xenia/cpu/runtime/function.h"
|
||||
#include "xenia/cpu/runtime/symbol_info.h"
|
||||
#include "xenia/cpu/function.h"
|
||||
#include "xenia/cpu/symbol_info.h"
|
||||
#include "poly/string_buffer.h"
|
||||
|
||||
namespace xe {
|
||||
@@ -41,10 +41,10 @@ class PPCHIRBuilder : public hir::HIRBuilder {
|
||||
// Emit TraceSource nodes with the resulting values of the operations.
|
||||
EMIT_TRACE_SOURCE_VALUES = EMIT_TRACE_SOURCE | (1 << 2),
|
||||
};
|
||||
int Emit(runtime::FunctionInfo* symbol_info, uint32_t flags);
|
||||
int Emit(FunctionInfo* symbol_info, uint32_t flags);
|
||||
|
||||
runtime::FunctionInfo* symbol_info() const { return symbol_info_; }
|
||||
runtime::FunctionInfo* LookupFunction(uint64_t address);
|
||||
FunctionInfo* symbol_info() const { return symbol_info_; }
|
||||
FunctionInfo* LookupFunction(uint64_t address);
|
||||
Label* LookupLabel(uint64_t address);
|
||||
|
||||
Value* LoadLR();
|
||||
@@ -96,7 +96,7 @@ class PPCHIRBuilder : public hir::HIRBuilder {
|
||||
|
||||
// Reset each Emit:
|
||||
bool with_debug_info_;
|
||||
runtime::FunctionInfo* symbol_info_;
|
||||
FunctionInfo* symbol_info_;
|
||||
uint64_t start_address_;
|
||||
uint64_t instr_count_;
|
||||
Instr** instr_offset_list_;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "xenia/cpu/frontend/ppc/ppc_frontend.h"
|
||||
#include "xenia/cpu/frontend/ppc/ppc_instr.h"
|
||||
#include "xenia/cpu/runtime/runtime.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "poly/logging.h"
|
||||
#include "poly/memory.h"
|
||||
#include "xenia/profiling.h"
|
||||
@@ -30,8 +30,6 @@ namespace cpu {
|
||||
namespace frontend {
|
||||
namespace ppc {
|
||||
|
||||
using xe::cpu::runtime::FunctionInfo;
|
||||
|
||||
PPCScanner::PPCScanner(PPCFrontend* frontend) : frontend_(frontend) {}
|
||||
|
||||
PPCScanner::~PPCScanner() {}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/cpu/runtime/symbol_info.h"
|
||||
#include "xenia/cpu/symbol_info.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
@@ -31,9 +31,9 @@ class PPCScanner {
|
||||
PPCScanner(PPCFrontend* frontend);
|
||||
~PPCScanner();
|
||||
|
||||
int FindExtents(runtime::FunctionInfo* symbol_info);
|
||||
int FindExtents(FunctionInfo* symbol_info);
|
||||
|
||||
std::vector<BlockInfo> FindBlocks(runtime::FunctionInfo* symbol_info);
|
||||
std::vector<BlockInfo> FindBlocks(FunctionInfo* symbol_info);
|
||||
|
||||
private:
|
||||
bool IsRestGprLr(uint64_t address);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "xenia/cpu/frontend/ppc/ppc_hir_builder.h"
|
||||
#include "xenia/cpu/frontend/ppc/ppc_instr.h"
|
||||
#include "xenia/cpu/frontend/ppc/ppc_scanner.h"
|
||||
#include "xenia/cpu/runtime/runtime.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "poly/reset_scope.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
@@ -26,12 +26,10 @@ namespace frontend {
|
||||
namespace ppc {
|
||||
|
||||
// TODO(benvanik): remove when enums redefined.
|
||||
using namespace xe::cpu::runtime;
|
||||
using namespace xe::cpu;
|
||||
|
||||
using xe::cpu::backend::Backend;
|
||||
using xe::cpu::compiler::Compiler;
|
||||
using xe::cpu::runtime::Function;
|
||||
using xe::cpu::runtime::FunctionInfo;
|
||||
namespace passes = xe::cpu::compiler::passes;
|
||||
|
||||
PPCTranslator::PPCTranslator(PPCFrontend* frontend) : frontend_(frontend) {
|
||||
@@ -175,7 +173,7 @@ int PPCTranslator::Translate(FunctionInfo* symbol_info,
|
||||
return 0;
|
||||
};
|
||||
|
||||
void PPCTranslator::DumpSource(runtime::FunctionInfo* symbol_info,
|
||||
void PPCTranslator::DumpSource(FunctionInfo* symbol_info,
|
||||
poly::StringBuffer* string_buffer) {
|
||||
Memory* memory = frontend_->memory();
|
||||
const uint8_t* p = memory->membase();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "xenia/cpu/backend/assembler.h"
|
||||
#include "xenia/cpu/compiler/compiler.h"
|
||||
#include "xenia/cpu/runtime/symbol_info.h"
|
||||
#include "xenia/cpu/symbol_info.h"
|
||||
#include "poly/string_buffer.h"
|
||||
|
||||
namespace xe {
|
||||
@@ -31,12 +31,11 @@ class PPCTranslator {
|
||||
PPCTranslator(PPCFrontend* frontend);
|
||||
~PPCTranslator();
|
||||
|
||||
int Translate(runtime::FunctionInfo* symbol_info, uint32_t debug_info_flags,
|
||||
uint32_t trace_flags, runtime::Function** out_function);
|
||||
int Translate(FunctionInfo* symbol_info, uint32_t debug_info_flags,
|
||||
uint32_t trace_flags, Function** out_function);
|
||||
|
||||
private:
|
||||
void DumpSource(runtime::FunctionInfo* symbol_info,
|
||||
poly::StringBuffer* string_buffer);
|
||||
void DumpSource(FunctionInfo* symbol_info, poly::StringBuffer* string_buffer);
|
||||
|
||||
private:
|
||||
PPCFrontend* frontend_;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "xenia/cpu/backend/x64/x64_backend.h"
|
||||
#include "xenia/cpu/frontend/ppc/ppc_context.h"
|
||||
#include "xenia/cpu/frontend/ppc/ppc_frontend.h"
|
||||
#include "xenia/cpu/runtime/raw_module.h"
|
||||
#include "xenia/cpu/raw_module.h"
|
||||
#include "poly/main.h"
|
||||
#include "poly/poly.h"
|
||||
|
||||
@@ -30,61 +30,12 @@ namespace cpu {
|
||||
namespace test {
|
||||
|
||||
using xe::cpu::frontend::ppc::PPCContext;
|
||||
using xe::cpu::runtime::Runtime;
|
||||
using xe::cpu::Runtime;
|
||||
|
||||
typedef std::vector<std::pair<std::string, std::string>> AnnotationList;
|
||||
|
||||
const uint32_t START_ADDRESS = 0x100000;
|
||||
|
||||
class ThreadState : public xe::cpu::runtime::ThreadState {
|
||||
public:
|
||||
ThreadState(Runtime* runtime, uint32_t thread_id, uint64_t stack_address,
|
||||
size_t stack_size, uint64_t thread_state_address)
|
||||
: xe::cpu::runtime::ThreadState(runtime, thread_id),
|
||||
stack_address_(stack_address),
|
||||
stack_size_(stack_size),
|
||||
thread_state_address_(thread_state_address) {
|
||||
memset(memory_->Translate(stack_address_), 0, stack_size_);
|
||||
|
||||
// Allocate with 64b alignment.
|
||||
context_ = (PPCContext*)calloc(1, sizeof(PPCContext));
|
||||
assert_true((reinterpret_cast<uint64_t>(context_) & 0xF) == 0);
|
||||
|
||||
// Stash pointers to common structures that callbacks may need.
|
||||
context_->reserve_address = memory_->reserve_address();
|
||||
context_->reserve_value = memory_->reserve_value();
|
||||
context_->membase = memory_->membase();
|
||||
context_->runtime = runtime;
|
||||
context_->thread_state = this;
|
||||
|
||||
// Set initial registers.
|
||||
context_->r[1] = stack_address_ + stack_size;
|
||||
context_->r[13] = thread_state_address_;
|
||||
|
||||
// Pad out stack a bit, as some games seem to overwrite the caller by about
|
||||
// 16 to 32b.
|
||||
context_->r[1] -= 64;
|
||||
|
||||
raw_context_ = context_;
|
||||
|
||||
runtime_->debugger()->OnThreadCreated(this);
|
||||
}
|
||||
~ThreadState() override {
|
||||
runtime_->debugger()->OnThreadDestroyed(this);
|
||||
free(context_);
|
||||
}
|
||||
|
||||
PPCContext* context() const { return context_; }
|
||||
|
||||
private:
|
||||
uint64_t stack_address_;
|
||||
size_t stack_size_;
|
||||
uint64_t thread_state_address_;
|
||||
|
||||
// NOTE: must be 64b aligned for SSE ops.
|
||||
PPCContext* context_;
|
||||
};
|
||||
|
||||
struct TestCase {
|
||||
TestCase(uint64_t address, std::string& name)
|
||||
: address(address), name(name) {}
|
||||
@@ -224,10 +175,8 @@ class TestRunner {
|
||||
memory.reset(new Memory());
|
||||
memory->Initialize();
|
||||
|
||||
runtime.reset(new Runtime(memory.get()));
|
||||
auto frontend =
|
||||
std::make_unique<xe::cpu::frontend::ppc::PPCFrontend>(runtime.get());
|
||||
runtime->Initialize(std::move(frontend), nullptr);
|
||||
runtime.reset(new Runtime(memory.get(), nullptr, 0, 0));
|
||||
runtime->Initialize(nullptr);
|
||||
}
|
||||
|
||||
~TestRunner() {
|
||||
@@ -238,7 +187,7 @@ class TestRunner {
|
||||
|
||||
bool Setup(TestSuite& suite) {
|
||||
// Load the binary module.
|
||||
auto module = std::make_unique<xe::cpu::runtime::RawModule>(runtime.get());
|
||||
auto module = std::make_unique<xe::cpu::RawModule>(runtime.get());
|
||||
if (module->LoadFile(START_ADDRESS, suite.bin_file_path)) {
|
||||
PLOGE("Unable to load test binary %ls", suite.bin_file_path.c_str());
|
||||
return false;
|
||||
@@ -263,7 +212,7 @@ class TestRunner {
|
||||
}
|
||||
|
||||
// Execute test.
|
||||
xe::cpu::runtime::Function* fn;
|
||||
xe::cpu::Function* fn;
|
||||
runtime->ResolveFunction(test_case.address, &fn);
|
||||
if (!fn) {
|
||||
PLOGE("Entry function not found");
|
||||
|
||||
Reference in New Issue
Block a user