More X64 backend skeleton work.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/optimizer/optimizer.h>
|
||||
|
||||
#include <alloy/backend/x64/tracing.h>
|
||||
#include <alloy/backend/x64/optimizer/optimizer_pass.h>
|
||||
|
||||
using namespace alloy;
|
||||
using namespace alloy::backend::x64::lir;
|
||||
using namespace alloy::backend::x64::optimizer;
|
||||
using namespace alloy::runtime;
|
||||
|
||||
|
||||
Optimizer::Optimizer(Runtime* runtime) :
|
||||
runtime_(runtime) {
|
||||
alloy::tracing::WriteEvent(EventType::Init({
|
||||
}));
|
||||
}
|
||||
|
||||
Optimizer::~Optimizer() {
|
||||
Reset();
|
||||
|
||||
for (auto it = passes_.begin(); it != passes_.end(); ++it) {
|
||||
OptimizerPass* pass = *it;
|
||||
delete pass;
|
||||
}
|
||||
|
||||
alloy::tracing::WriteEvent(EventType::Deinit({
|
||||
}));
|
||||
}
|
||||
|
||||
void Optimizer::AddPass(OptimizerPass* pass) {
|
||||
pass->Initialize(this);
|
||||
passes_.push_back(pass);
|
||||
}
|
||||
|
||||
void Optimizer::Reset() {
|
||||
}
|
||||
|
||||
int Optimizer::Optimize(LIRBuilder* builder) {
|
||||
// TODO(benvanik): sophisticated stuff. Run passes in parallel, run until they
|
||||
// stop changing things, etc.
|
||||
for (auto it = passes_.begin(); it != passes_.end(); ++it) {
|
||||
OptimizerPass* pass = *it;
|
||||
if (pass->Run(builder)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef ALLOY_BACKEND_X64_OPTIMIZER_OPTIMIZER_H_
|
||||
#define ALLOY_BACKEND_X64_OPTIMIZER_OPTIMIZER_H_
|
||||
|
||||
#include <alloy/core.h>
|
||||
#include <alloy/backend/x64/lir/lir_builder.h>
|
||||
|
||||
namespace alloy { namespace runtime { class Runtime; } }
|
||||
|
||||
|
||||
namespace alloy {
|
||||
namespace backend {
|
||||
namespace x64 {
|
||||
namespace optimizer {
|
||||
|
||||
class OptimizerPass;
|
||||
|
||||
|
||||
class Optimizer {
|
||||
public:
|
||||
Optimizer(runtime::Runtime* runtime);
|
||||
~Optimizer();
|
||||
|
||||
runtime::Runtime* runtime() const { return runtime_; }
|
||||
|
||||
void AddPass(OptimizerPass* pass);
|
||||
|
||||
void Reset();
|
||||
|
||||
int Optimize(lir::LIRBuilder* builder);
|
||||
|
||||
private:
|
||||
runtime::Runtime* runtime_;
|
||||
|
||||
typedef std::vector<OptimizerPass*> PassList;
|
||||
PassList passes_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace optimizer
|
||||
} // namespace x64
|
||||
} // namespace backend
|
||||
} // namespace alloy
|
||||
|
||||
|
||||
#endif // ALLOY_BACKEND_X64_OPTIMIZER_OPTIMIZER_H_
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/optimizer/optimizer_pass.h>
|
||||
|
||||
#include <alloy/backend/x64/optimizer/optimizer.h>
|
||||
|
||||
using namespace alloy;
|
||||
using namespace alloy::backend::x64::optimizer;
|
||||
|
||||
|
||||
OptimizerPass::OptimizerPass() :
|
||||
runtime_(0), optimizer_(0) {
|
||||
}
|
||||
|
||||
OptimizerPass::~OptimizerPass() {
|
||||
}
|
||||
|
||||
int OptimizerPass::Initialize(Optimizer* optimizer) {
|
||||
runtime_ = optimizer->runtime();
|
||||
optimizer_ = optimizer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef ALLOY_BACKEND_X64_OPTIMIZER_OPTIMIZER_PASS_H_
|
||||
#define ALLOY_BACKEND_X64_OPTIMIZER_OPTIMIZER_PASS_H_
|
||||
|
||||
#include <alloy/core.h>
|
||||
|
||||
#include <alloy/backend/x64/lir/lir_builder.h>
|
||||
|
||||
namespace alloy { namespace runtime { class Runtime; } }
|
||||
|
||||
|
||||
namespace alloy {
|
||||
namespace backend {
|
||||
namespace x64 {
|
||||
namespace optimizer {
|
||||
|
||||
class Optimizer;
|
||||
|
||||
|
||||
class OptimizerPass {
|
||||
public:
|
||||
OptimizerPass();
|
||||
virtual ~OptimizerPass();
|
||||
|
||||
virtual int Initialize(Optimizer* optimizer);
|
||||
|
||||
virtual int Run(lir::LIRBuilder* builder) = 0;
|
||||
|
||||
protected:
|
||||
runtime::Runtime* runtime_;
|
||||
Optimizer* optimizer_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace optimizer
|
||||
} // namespace x64
|
||||
} // namespace backend
|
||||
} // namespace alloy
|
||||
|
||||
|
||||
#endif // ALLOY_BACKEND_X64_OPTIMIZER_OPTIMIZER_PASS_H_
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef ALLOY_BACKEND_X64_OPTIMIZER_PASSES_H_
|
||||
#define ALLOY_BACKEND_X64_OPTIMIZER_PASSES_H_
|
||||
|
||||
#include <alloy/backend/x64/optimizer/passes/redundant_mov_pass.h>
|
||||
|
||||
#endif // ALLOY_BACKEND_X64_OPTIMIZER_PASSES_H_
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef ALLOY_COMPILER_PASSES_SIMPLIFICATION_PASS_H_
|
||||
#define ALLOY_COMPILER_PASSES_SIMPLIFICATION_PASS_H_
|
||||
|
||||
#include <alloy/backend/x64/optimizer/optimizer_pass.h>
|
||||
|
||||
|
||||
namespace alloy {
|
||||
namespace backend {
|
||||
namespace x64 {
|
||||
namespace optimizer {
|
||||
namespace passes {
|
||||
|
||||
|
||||
class RedundantMovPass : public OptimizerPass {
|
||||
public:
|
||||
RedundantMovPass();
|
||||
virtual ~RedundantMovPass();
|
||||
|
||||
virtual int Run(lir::LIRBuilder* builder);
|
||||
};
|
||||
|
||||
|
||||
} // namespace passes
|
||||
} // namespace optimizer
|
||||
} // namespace x64
|
||||
} // namespace backend
|
||||
} // namespace alloy
|
||||
|
||||
|
||||
#endif // ALLOY_COMPILER_PASSES_SIMPLIFICATION_PASS_H_
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef ALLOY_BACKEND_X64_OPTIMIZER_TRACING_H_
|
||||
#define ALLOY_BACKEND_X64_OPTIMIZER_TRACING_H_
|
||||
|
||||
#include <alloy/backend/x64/tracing.h>
|
||||
|
||||
|
||||
namespace alloy {
|
||||
namespace backend {
|
||||
namespace x64 {
|
||||
namespace optimizer {
|
||||
|
||||
const uint32_t ALLOY_BACKEND_X64_OPTIMIZER =
|
||||
alloy::backend::x64::EventType::ALLOY_BACKEND_X64_OPTIMIZER;
|
||||
|
||||
|
||||
class EventType {
|
||||
public:
|
||||
enum {
|
||||
ALLOY_BACKEND_X64_OPTIMIZER_INIT = ALLOY_BACKEND_X64_OPTIMIZER | (1),
|
||||
ALLOY_BACKEND_X64_OPTIMIZER_DEINIT = ALLOY_BACKEND_X64_OPTIMIZER | (2),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
static const uint32_t event_type = ALLOY_BACKEND_X64_OPTIMIZER_INIT;
|
||||
} Init;
|
||||
typedef struct {
|
||||
static const uint32_t event_type = ALLOY_BACKEND_X64_OPTIMIZER_DEINIT;
|
||||
} Deinit;
|
||||
};
|
||||
|
||||
|
||||
} // namespace optimizer
|
||||
} // namespace x64
|
||||
} // namespace backend
|
||||
} // namespace alloy
|
||||
|
||||
|
||||
#endif // ALLOY_BACKEND_X64_OPTIMIZER_TRACING_H_
|
||||
|
||||
Reference in New Issue
Block a user