Initial Alloy implementation.
This is a regression in functionality and performance, but a much better foundation for the future of the project (I think). It can run basic apps under an SSA interpreter but doesn't support some of the features required to do real 360 apps yet.
This commit is contained in:
53
src/alloy/compiler/compiler.cc
Normal file
53
src/alloy/compiler/compiler.cc
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/compiler/compiler.h>
|
||||
|
||||
#include <alloy/compiler/pass.h>
|
||||
#include <alloy/compiler/tracing.h>
|
||||
|
||||
using namespace alloy;
|
||||
using namespace alloy::compiler;
|
||||
using namespace alloy::hir;
|
||||
|
||||
|
||||
Compiler::Compiler() {
|
||||
alloy::tracing::WriteEvent(EventType::Init({
|
||||
}));
|
||||
}
|
||||
|
||||
Compiler::~Compiler() {
|
||||
Reset();
|
||||
|
||||
for (PassList::iterator it = passes_.begin(); it != passes_.end(); ++it) {
|
||||
Pass* pass = *it;
|
||||
delete pass;
|
||||
}
|
||||
|
||||
alloy::tracing::WriteEvent(EventType::Deinit({
|
||||
}));
|
||||
}
|
||||
|
||||
void Compiler::AddPass(Pass* pass) {
|
||||
passes_.push_back(pass);
|
||||
}
|
||||
|
||||
void Compiler::Reset() {
|
||||
}
|
||||
|
||||
int Compiler::Compile(FunctionBuilder* builder) {
|
||||
// TODO(benvanik): sophisticated stuff. Run passes in parallel, run until they
|
||||
// stop changing things, etc.
|
||||
for (PassList::iterator it = passes_.begin(); it != passes_.end(); ++it) {
|
||||
Pass* pass = *it;
|
||||
//
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
44
src/alloy/compiler/compiler.h
Normal file
44
src/alloy/compiler/compiler.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_COMPILER_H_
|
||||
#define ALLOY_COMPILER_COMPILER_H_
|
||||
|
||||
#include <alloy/core.h>
|
||||
#include <alloy/hir/function_builder.h>
|
||||
|
||||
|
||||
namespace alloy {
|
||||
namespace compiler {
|
||||
|
||||
class Pass;
|
||||
|
||||
|
||||
class Compiler {
|
||||
public:
|
||||
Compiler();
|
||||
~Compiler();
|
||||
|
||||
void AddPass(Pass* pass);
|
||||
|
||||
void Reset();
|
||||
|
||||
int Compile(hir::FunctionBuilder* builder);
|
||||
|
||||
private:
|
||||
typedef std::vector<Pass*> PassList;
|
||||
PassList passes_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace alloy
|
||||
|
||||
|
||||
#endif // ALLOY_COMPILER_COMPILER_H_
|
||||
20
src/alloy/compiler/pass.cc
Normal file
20
src/alloy/compiler/pass.cc
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/compiler/pass.h>
|
||||
|
||||
using namespace alloy;
|
||||
using namespace alloy::compiler;
|
||||
|
||||
|
||||
Pass::Pass() {
|
||||
}
|
||||
|
||||
Pass::~Pass() {
|
||||
}
|
||||
31
src/alloy/compiler/pass.h
Normal file
31
src/alloy/compiler/pass.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_PASS_H_
|
||||
#define ALLOY_COMPILER_PASS_H_
|
||||
|
||||
#include <alloy/core.h>
|
||||
|
||||
|
||||
namespace alloy {
|
||||
namespace compiler {
|
||||
|
||||
|
||||
class Pass {
|
||||
public:
|
||||
Pass();
|
||||
virtual ~Pass();
|
||||
};
|
||||
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace alloy
|
||||
|
||||
|
||||
#endif // ALLOY_COMPILER_PASS_H_
|
||||
15
src/alloy/compiler/passes.h
Normal file
15
src/alloy/compiler/passes.h
Normal file
@@ -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_COMPILER_PASSES_H_
|
||||
#define ALLOY_COMPILER_PASSES_H_
|
||||
|
||||
#include <alloy/compiler/passes/mem2reg_pass.h>
|
||||
|
||||
#endif // ALLOY_COMPILER_PASSES_H_
|
||||
22
src/alloy/compiler/passes/mem2reg_pass.cc
Normal file
22
src/alloy/compiler/passes/mem2reg_pass.cc
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/compiler/passes/mem2reg_pass.h>
|
||||
|
||||
using namespace alloy;
|
||||
using namespace alloy::compiler;
|
||||
using namespace alloy::compiler::passes;
|
||||
|
||||
|
||||
Mem2RegPass::Mem2RegPass() :
|
||||
Pass() {
|
||||
}
|
||||
|
||||
Mem2RegPass::~Mem2RegPass() {
|
||||
}
|
||||
33
src/alloy/compiler/passes/mem2reg_pass.h
Normal file
33
src/alloy/compiler/passes/mem2reg_pass.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_MEM2REG_PASS_H_
|
||||
#define ALLOY_COMPILER_PASSES_MEM2REG_PASS_H_
|
||||
|
||||
#include <alloy/compiler/pass.h>
|
||||
|
||||
|
||||
namespace alloy {
|
||||
namespace compiler {
|
||||
namespace passes {
|
||||
|
||||
|
||||
class Mem2RegPass : public Pass {
|
||||
public:
|
||||
Mem2RegPass();
|
||||
virtual ~Mem2RegPass();
|
||||
};
|
||||
|
||||
|
||||
} // namespace passes
|
||||
} // namespace compiler
|
||||
} // namespace alloy
|
||||
|
||||
|
||||
#endif // ALLOY_COMPILER_PASSES_MEM2REG_PASS_H_
|
||||
7
src/alloy/compiler/passes/sources.gypi
Normal file
7
src/alloy/compiler/passes/sources.gypi
Normal file
@@ -0,0 +1,7 @@
|
||||
# Copyright 2013 Ben Vanik. All Rights Reserved.
|
||||
{
|
||||
'sources': [
|
||||
'mem2reg_pass.cc',
|
||||
'mem2reg_pass.h',
|
||||
],
|
||||
}
|
||||
15
src/alloy/compiler/sources.gypi
Normal file
15
src/alloy/compiler/sources.gypi
Normal file
@@ -0,0 +1,15 @@
|
||||
# Copyright 2013 Ben Vanik. All Rights Reserved.
|
||||
{
|
||||
'sources': [
|
||||
'compiler.cc',
|
||||
'compiler.h',
|
||||
'pass.cc',
|
||||
'pass.h',
|
||||
'passes.h',
|
||||
'tracing.h',
|
||||
],
|
||||
|
||||
'includes': [
|
||||
'passes/sources.gypi',
|
||||
],
|
||||
}
|
||||
43
src/alloy/compiler/tracing.h
Normal file
43
src/alloy/compiler/tracing.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_TRACING_H_
|
||||
#define ALLOY_COMPILER_TRACING_H_
|
||||
|
||||
#include <alloy/tracing/tracing.h>
|
||||
#include <alloy/tracing/event_type.h>
|
||||
|
||||
|
||||
namespace alloy {
|
||||
namespace compiler {
|
||||
|
||||
const uint32_t ALLOY_COMPILER = alloy::tracing::EventType::ALLOY_COMPILER;
|
||||
|
||||
|
||||
class EventType {
|
||||
public:
|
||||
enum {
|
||||
ALLOY_COMPILER_INIT = ALLOY_COMPILER | (1),
|
||||
ALLOY_COMPILER_DEINIT = ALLOY_COMPILER | (2),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
static const uint32_t event_type = ALLOY_COMPILER_INIT;
|
||||
} Init;
|
||||
typedef struct {
|
||||
static const uint32_t event_type = ALLOY_COMPILER_DEINIT;
|
||||
} Deinit;
|
||||
};
|
||||
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace alloy
|
||||
|
||||
|
||||
#endif // ALLOY_COMPILER_TRACING_H_
|
||||
Reference in New Issue
Block a user