A probably-working register allocator.

This commit is contained in:
Ben Vanik
2014-02-10 21:16:38 -08:00
parent 6bd214af0b
commit 4a584129d2
13 changed files with 613 additions and 29 deletions

View File

@@ -108,6 +108,9 @@ void HIRBuilder::DumpValue(StringBuffer* str, Value* value) {
};
str->Append("v%d.%s", value->ordinal, type_names[value->type]);
}
if (value->reg.index != -1) {
str->Append("<%s%d>", value->reg.set->name, value->reg.index);
}
}
void HIRBuilder::DumpOp(
@@ -453,6 +456,7 @@ Instr* HIRBuilder::AppendInstr(
if (!block->instr_head) {
block->instr_head = instr;
}
instr->ordinal = -1;
instr->block = block;
instr->opcode = &opcode_info;
instr->flags = flags;
@@ -477,7 +481,8 @@ Value* HIRBuilder::AllocValue(TypeName type) {
value->last_use = NULL;
value->local_slot = NULL;
value->tag = NULL;
value->reg = -1;
value->reg.set = NULL;
value->reg.index = -1;
return value;
}
@@ -492,7 +497,8 @@ Value* HIRBuilder::CloneValue(Value* source) {
value->last_use = NULL;
value->local_slot = NULL;
value->tag = NULL;
value->reg = -1;
value->reg.set = NULL;
value->reg.index = -1;
return value;
}

View File

@@ -52,7 +52,7 @@ public:
const OpcodeInfo* opcode;
uint16_t flags;
uint16_t ordinal;
uint32_t ordinal;
typedef union {
runtime::FunctionInfo* symbol_info;

View File

@@ -11,6 +11,7 @@
#define ALLOY_HIR_VALUE_H_
#include <alloy/core.h>
#include <alloy/backend/machine_info.h>
#include <alloy/hir/opcodes.h>
@@ -90,7 +91,10 @@ public:
TypeName type;
uint32_t flags;
uint32_t reg;
struct {
const backend::MachineInfo::RegisterSet* set;
int32_t index;
} reg;
ConstantValue constant;
Instr* def;