Deleting LIR and such, wiring up for HIR->x64.
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
#include <alloy/compiler/passes/constant_propagation_pass.h>
|
||||
#include <alloy/compiler/passes/context_promotion_pass.h>
|
||||
#include <alloy/compiler/passes/dead_code_elimination_pass.h>
|
||||
#include <alloy/compiler/passes/finalization_pass.h>
|
||||
#include <alloy/compiler/passes/register_allocation_pass.h>
|
||||
//#include <alloy/compiler/passes/dead_store_elimination_pass.h>
|
||||
#include <alloy/compiler/passes/simplification_pass.h>
|
||||
|
||||
|
||||
58
src/alloy/compiler/passes/finalization_pass.cc
Normal file
58
src/alloy/compiler/passes/finalization_pass.cc
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2014 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <alloy/compiler/passes/finalization_pass.h>
|
||||
|
||||
#include <alloy/backend/backend.h>
|
||||
#include <alloy/compiler/compiler.h>
|
||||
#include <alloy/runtime/runtime.h>
|
||||
|
||||
using namespace alloy;
|
||||
using namespace alloy::backend;
|
||||
using namespace alloy::compiler;
|
||||
using namespace alloy::compiler::passes;
|
||||
using namespace alloy::frontend;
|
||||
using namespace alloy::hir;
|
||||
using namespace alloy::runtime;
|
||||
|
||||
|
||||
FinalizationPass::FinalizationPass() :
|
||||
CompilerPass() {
|
||||
}
|
||||
|
||||
FinalizationPass::~FinalizationPass() {
|
||||
}
|
||||
|
||||
int FinalizationPass::Run(HIRBuilder* builder) {
|
||||
// Process the HIR and prepare it for lowering.
|
||||
// After this is done the HIR should be ready for emitting.
|
||||
|
||||
auto arena = builder->arena();
|
||||
|
||||
auto block = builder->first_block();
|
||||
while (block) {
|
||||
// Ensure all labels have names.
|
||||
auto label = block->label_head;
|
||||
while (label) {
|
||||
if (!label->name) {
|
||||
char* name = (char*)arena->Alloc(6 + 4 + 1);
|
||||
xestrcpya(name, 6 + 1, "_label");
|
||||
char* part = _itoa(label->id, name + 6, 10);
|
||||
label->name = name;
|
||||
}
|
||||
label = label->next;
|
||||
}
|
||||
|
||||
// ?
|
||||
|
||||
block = block->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
37
src/alloy/compiler/passes/finalization_pass.h
Normal file
37
src/alloy/compiler/passes/finalization_pass.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2014 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef ALLOY_COMPILER_PASSES_FINALIZATION_PASS_H_
|
||||
#define ALLOY_COMPILER_PASSES_FINALIZATION_PASS_H_
|
||||
|
||||
#include <alloy/compiler/compiler_pass.h>
|
||||
|
||||
|
||||
namespace alloy {
|
||||
namespace compiler {
|
||||
namespace passes {
|
||||
|
||||
|
||||
class FinalizationPass : public CompilerPass {
|
||||
public:
|
||||
FinalizationPass();
|
||||
virtual ~FinalizationPass();
|
||||
|
||||
virtual int Run(hir::HIRBuilder* builder);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
} // namespace passes
|
||||
} // namespace compiler
|
||||
} // namespace alloy
|
||||
|
||||
|
||||
#endif // ALLOY_COMPILER_PASSES_FINALIZATION_PASS_H_
|
||||
51
src/alloy/compiler/passes/register_allocation_pass.cc
Normal file
51
src/alloy/compiler/passes/register_allocation_pass.cc
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2014 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <alloy/compiler/passes/register_allocation_pass.h>
|
||||
|
||||
#include <alloy/backend/backend.h>
|
||||
#include <alloy/compiler/compiler.h>
|
||||
#include <alloy/runtime/runtime.h>
|
||||
|
||||
using namespace alloy;
|
||||
using namespace alloy::backend;
|
||||
using namespace alloy::compiler;
|
||||
using namespace alloy::compiler::passes;
|
||||
using namespace alloy::frontend;
|
||||
using namespace alloy::hir;
|
||||
using namespace alloy::runtime;
|
||||
|
||||
|
||||
RegisterAllocationPass::RegisterAllocationPass(Backend* backend) :
|
||||
CompilerPass() {
|
||||
// TODO(benvanik): query backend info (register layout, etc).
|
||||
}
|
||||
|
||||
RegisterAllocationPass::~RegisterAllocationPass() {
|
||||
}
|
||||
|
||||
int RegisterAllocationPass::Run(HIRBuilder* builder) {
|
||||
// Run through each block and give each dest value a register.
|
||||
// This pass is currently really dumb, and will over spill and other badness.
|
||||
|
||||
auto block = builder->first_block();
|
||||
while (block) {
|
||||
if (ProcessBlock(block)) {
|
||||
return 1;
|
||||
}
|
||||
block = block->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RegisterAllocationPass::ProcessBlock(Block* block) {
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
40
src/alloy/compiler/passes/register_allocation_pass.h
Normal file
40
src/alloy/compiler/passes/register_allocation_pass.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2014 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef ALLOY_COMPILER_PASSES_REGISTER_ALLOCATION_PASS_H_
|
||||
#define ALLOY_COMPILER_PASSES_REGISTER_ALLOCATION_PASS_H_
|
||||
|
||||
#include <alloy/compiler/compiler_pass.h>
|
||||
|
||||
XEDECLARECLASS2(alloy, backend, Backend);
|
||||
|
||||
|
||||
namespace alloy {
|
||||
namespace compiler {
|
||||
namespace passes {
|
||||
|
||||
|
||||
class RegisterAllocationPass : public CompilerPass {
|
||||
public:
|
||||
RegisterAllocationPass(backend::Backend* backend);
|
||||
virtual ~RegisterAllocationPass();
|
||||
|
||||
virtual int Run(hir::HIRBuilder* builder);
|
||||
|
||||
private:
|
||||
int ProcessBlock(hir::Block* block);
|
||||
};
|
||||
|
||||
|
||||
} // namespace passes
|
||||
} // namespace compiler
|
||||
} // namespace alloy
|
||||
|
||||
|
||||
#endif // ALLOY_COMPILER_PASSES_REGISTER_ALLOCATION_PASS_H_
|
||||
@@ -7,6 +7,10 @@
|
||||
'context_promotion_pass.h',
|
||||
'dead_code_elimination_pass.cc',
|
||||
'dead_code_elimination_pass.h',
|
||||
'finalization_pass.cc',
|
||||
'finalization_pass.h',
|
||||
'register_allocation_pass.cc',
|
||||
'register_allocation_pass.h',
|
||||
#'dead_store_elimination_pass.cc',
|
||||
#'dead_store_elimination_pass.h',
|
||||
'simplification_pass.cc',
|
||||
|
||||
Reference in New Issue
Block a user