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

@@ -74,15 +74,19 @@ int IVMAssembler::Assemble(
builder->ResetLabelTags();
// Function prologue.
size_t stack_size = 0;
size_t stack_offset = 0;
auto locals = builder->locals();
for (auto it = locals.begin(); it != locals.end(); ++it) {
auto slot = *it;
size_t stack_offset = stack_size;
size_t type_size = GetTypeSize(slot->type);
// Align to natural size.
stack_offset = XEALIGN(stack_offset, type_size);
slot->set_constant(stack_offset);
stack_size += GetTypeSize(slot->type);
stack_offset += type_size;
}
ctx.stack_size = stack_size;
// Ensure 16b alignment.
stack_offset = XEALIGN(stack_offset, 16);
ctx.stack_size = stack_offset;
auto block = builder->first_block();
while (block) {

View File

@@ -38,14 +38,14 @@ int IVMBackend::Initialize() {
0,
"gpr",
MachineInfo::RegisterSet::INT_TYPES,
10,
6,
};
machine_info_.register_sets[1] = {
1,
"vec",
MachineInfo::RegisterSet::FLOAT_TYPES |
MachineInfo::RegisterSet::VEC_TYPES,
10,
6,
};
alloy::tracing::WriteEvent(EventType::Init({