More X64 backend skeleton work.

This commit is contained in:
Ben Vanik
2013-12-29 19:54:17 -08:00
parent 3d01efffac
commit dec0e35957
34 changed files with 1091 additions and 29 deletions

View File

@@ -0,0 +1,46 @@
/**
******************************************************************************
* 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_LIR_LIR_BUILDER_H_
#define ALLOY_BACKEND_X64_LIR_LIR_BUILDER_H_
#include <alloy/core.h>
#include <alloy/backend/x64/lir/lir_opcodes.h>
namespace alloy {
namespace backend {
namespace x64 {
namespace lir {
class LIRBuilder {
public:
LIRBuilder();
virtual ~LIRBuilder();
virtual void Reset();
virtual int Finalize();
void Dump(StringBuffer* str);
Arena* arena() const { return arena_; }
protected:
Arena* arena_;
};
} // namespace lir
} // namespace x64
} // namespace backend
} // namespace alloy
#endif // ALLOY_BACKEND_X64_LIR_LIR_BUILDER_H_

View File

@@ -0,0 +1,34 @@
/**
******************************************************************************
* 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_LIR_LIR_INSTR_H_
#define ALLOY_BACKEND_X64_LIR_LIR_INSTR_H_
#include <alloy/core.h>
#include <alloy/backend/x64/lir/lir_opcodes.h>
namespace alloy {
namespace backend {
namespace x64 {
namespace lir {
class LIRInstr {
public:
};
} // namespace lir
} // namespace x64
} // namespace backend
} // namespace alloy
#endif // ALLOY_BACKEND_X64_LIR_LIR_INSTR_H_

View File

@@ -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/lir/lir_opcodes.h>
using namespace alloy;
using namespace alloy::backend::x64::lir;
namespace alloy {
namespace backend {
namespace x64 {
namespace lir {
#define DEFINE_OPCODE(num, name, sig, flags) \
static const LIROpcodeInfo num##_info = { flags, sig, name, num, };
#include <alloy/backend/x64/lir/lir_opcodes.inl>
#undef DEFINE_OPCODE
} // namespace lir
} // namespace x64
} // namespace backend
} // namespace alloy

View File

@@ -0,0 +1,71 @@
/**
******************************************************************************
* 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_LIR_LIR_OPCODES_H_
#define ALLOY_BACKEND_X64_LIR_LIR_OPCODES_H_
#include <alloy/core.h>
namespace alloy {
namespace backend {
namespace x64 {
namespace lir {
enum LIROpcode {
LIR_OPCODE_MOV_I32,
__LIR_OPCODE_MAX_VALUE, // Keep at end.
};
enum LIROpcodeFlags {
LIR_OPCODE_FLAG_BRANCH = (1 << 1),
LIR_OPCODE_FLAG_MEMORY = (1 << 2),
LIR_OPCODE_FLAG_COMMUNATIVE = (1 << 3),
LIR_OPCODE_FLAG_VOLATILE = (1 << 4),
LIR_OPCODE_FLAG_IGNORE = (1 << 5),
LIR_OPCODE_FLAG_HIDE = (1 << 6),
};
enum LIROpcodeSignatureType {
// 3 bits max (0-7)
LIR_OPCODE_SIG_TYPE_X = 0,
};
enum LIROpcodeSignature {
LIR_OPCODE_SIG_X = (LIR_OPCODE_SIG_TYPE_X),
};
#define GET_LIR_OPCODE_SIG_TYPE_DEST(sig) (LIROpcodeSignatureType)(sig & 0x7)
#define GET_LIR_OPCODE_SIG_TYPE_SRC1(sig) (LIROpcodeSignatureType)((sig >> 3) & 0x7)
#define GET_LIR_OPCODE_SIG_TYPE_SRC2(sig) (LIROpcodeSignatureType)((sig >> 6) & 0x7)
#define GET_LIR_OPCODE_SIG_TYPE_SRC3(sig) (LIROpcodeSignatureType)((sig >> 9) & 0x7)
typedef struct {
uint32_t flags;
uint32_t signature;
const char* name;
LIROpcode num;
} LIROpcodeInfo;
#define DEFINE_OPCODE(num, name, sig, flags) \
extern const LIROpcodeInfo num##_info;
#include <alloy/backend/x64/lir/lir_opcodes.inl>
#undef DEFINE_OPCODE
} // namespace lir
} // namespace x64
} // namespace backend
} // namespace alloy
#endif // ALLOY_BACKEND_X64_LIR_LIR_OPCODES_H_

View 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. *
******************************************************************************
*/
DEFINE_OPCODE(
LIR_OPCODE_MOV_I32,
"mov.i32",
LIR_OPCODE_SIG_X,
0);

View File

@@ -4,9 +4,9 @@
'lir_builder.cc',
'lir_builder.h',
'lir_instr.h',
'lircodes.cc',
'lircodes.h',
'lircodes.inl',
'lir_opcodes.cc',
'lir_opcodes.h',
'lir_opcodes.inl',
'tracing.h',
],
}

View File

@@ -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_BACKEND_X64_LIR_TRACING_H_
#define ALLOY_BACKEND_X64_LIR_TRACING_H_
#include <alloy/backend/x64/tracing.h>
namespace alloy {
namespace backend {
namespace x64 {
namespace lir {
const uint32_t ALLOY_BACKEND_X64_LIR =
alloy::backend::x64::EventType::ALLOY_BACKEND_X64_LIR;
class EventType {
public:
enum {
ALLOY_BACKEND_X64_LIR_FOO = ALLOY_BACKEND_X64_LIR | (1),
};
};
} // namespace lir
} // namespace x64
} // namespace backend
} // namespace alloy
#endif // ALLOY_BACKEND_X64_LIR_TRACING_H_