C++11ing some things.

This commit is contained in:
Ben Vanik
2014-07-13 21:53:31 -07:00
parent 29e4c35c38
commit 0a250d5e91
28 changed files with 113 additions and 143 deletions

View File

@@ -14,10 +14,9 @@
namespace alloy {
namespace frontend {
Frontend::Frontend(runtime::Runtime* runtime)
: runtime_(runtime), context_info_(0) {}
Frontend::Frontend(runtime::Runtime* runtime) : runtime_(runtime) {}
Frontend::~Frontend() { delete context_info_; }
Frontend::~Frontend() = default;
Memory* Frontend::memory() const { return runtime_->memory(); }

View File

@@ -10,6 +10,8 @@
#ifndef ALLOY_FRONTEND_FRONTEND_H_
#define ALLOY_FRONTEND_FRONTEND_H_
#include <memory>
#include <alloy/core.h>
#include <alloy/memory.h>
#include <alloy/frontend/context_info.h>
@@ -32,7 +34,7 @@ class Frontend {
runtime::Runtime* runtime() const { return runtime_; }
Memory* memory() const;
ContextInfo* context_info() const { return context_info_; }
ContextInfo* context_info() const { return context_info_.get(); }
virtual int Initialize();
@@ -43,7 +45,7 @@ class Frontend {
protected:
runtime::Runtime* runtime_;
ContextInfo* context_info_;
std::unique_ptr<ContextInfo> context_info_;
};
} // namespace frontend

View File

@@ -46,10 +46,10 @@ void CleanupOnShutdown() {}
PPCFrontend::PPCFrontend(Runtime* runtime) : Frontend(runtime) {
InitializeIfNeeded();
ContextInfo* info =
new ContextInfo(sizeof(PPCContext), offsetof(PPCContext, thread_state));
std::unique_ptr<ContextInfo> context_info(
new ContextInfo(sizeof(PPCContext), offsetof(PPCContext, thread_state)));
// Add fields/etc.
context_info_ = info;
context_info_ = std::move(context_info);
}
PPCFrontend::~PPCFrontend() {

View File

@@ -43,23 +43,24 @@ PPCTranslator::PPCTranslator(PPCFrontend* frontend) : frontend_(frontend) {
bool validate = FLAGS_validate_hir;
// Build the CFG first.
compiler_->AddPass(new passes::ControlFlowAnalysisPass());
compiler_->AddPass(std::make_unique<passes::ControlFlowAnalysisPass>());
// Passes are executed in the order they are added. Multiple of the same
// pass type may be used.
if (validate) compiler_->AddPass(new passes::ValidationPass());
compiler_->AddPass(new passes::ContextPromotionPass());
if (validate) compiler_->AddPass(new passes::ValidationPass());
compiler_->AddPass(new passes::SimplificationPass());
if (validate) compiler_->AddPass(new passes::ValidationPass());
compiler_->AddPass(new passes::ConstantPropagationPass());
if (validate) compiler_->AddPass(new passes::ValidationPass());
compiler_->AddPass(new passes::SimplificationPass());
if (validate) compiler_->AddPass(new passes::ValidationPass());
// compiler_->AddPass(new passes::DeadStoreEliminationPass());
// if (validate) compiler_->AddPass(new passes::ValidationPass());
compiler_->AddPass(new passes::DeadCodeEliminationPass());
if (validate) compiler_->AddPass(new passes::ValidationPass());
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
compiler_->AddPass(std::make_unique<passes::ContextPromotionPass>());
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
compiler_->AddPass(std::make_unique<passes::SimplificationPass>());
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
compiler_->AddPass(std::make_unique<passes::ConstantPropagationPass>());
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
compiler_->AddPass(std::make_unique<passes::SimplificationPass>());
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
// compiler_->AddPass(std::make_unique<passes::DeadStoreEliminationPass>());
// if (validate)
// compiler_->AddPass(std::make_unique<passes::ValidationPass>());
compiler_->AddPass(std::make_unique<passes::DeadCodeEliminationPass>());
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
//// Removes all unneeded variables. Try not to add new ones after this.
// compiler_->AddPass(new passes::ValueReductionPass());
@@ -69,12 +70,12 @@ PPCTranslator::PPCTranslator(PPCFrontend* frontend) : frontend_(frontend) {
// Will modify the HIR to add loads/stores.
// This should be the last pass before finalization, as after this all
// registers are assigned and ready to be emitted.
compiler_->AddPass(
new passes::RegisterAllocationPass(backend->machine_info()));
if (validate) compiler_->AddPass(new passes::ValidationPass());
compiler_->AddPass(std::make_unique<passes::RegisterAllocationPass>(
backend->machine_info()));
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
// Must come last. The HIR is not really HIR after this.
compiler_->AddPass(new passes::FinalizationPass());
compiler_->AddPass(std::make_unique<passes::FinalizationPass>());
}
PPCTranslator::~PPCTranslator() {