Fix pass-through configuration of register count.
This commit is contained in:
parent
46ced3980a
commit
a568144ccc
@ -35,9 +35,10 @@ mod variable_locations;
|
|||||||
|
|
||||||
pub fn compile_dvm_function(
|
pub fn compile_dvm_function(
|
||||||
ir_function: &IrFunction,
|
ir_function: &IrFunction,
|
||||||
|
register_count: usize,
|
||||||
constants_table: &mut ConstantsTable,
|
constants_table: &mut ConstantsTable,
|
||||||
) -> Function {
|
) -> Function {
|
||||||
let variable_locations = assign_registers(ir_function);
|
let variable_locations = assign_registers(ir_function, register_count);
|
||||||
let instructions = assemble_ir_function(ir_function, &variable_locations, constants_table);
|
let instructions = assemble_ir_function(ir_function, &variable_locations, constants_table);
|
||||||
Function::new(
|
Function::new(
|
||||||
ir_function.fqn().into(),
|
ir_function.fqn().into(),
|
||||||
@ -47,7 +48,7 @@ pub fn compile_dvm_function(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assign_registers(ir_function: &IrFunction) -> VariableLocations {
|
fn assign_registers(ir_function: &IrFunction, register_count: usize) -> VariableLocations {
|
||||||
if ir_function.blocks().is_empty() {
|
if ir_function.blocks().is_empty() {
|
||||||
return VariableLocations::new(HashMap::new(), HashMap::new());
|
return VariableLocations::new(HashMap::new(), HashMap::new());
|
||||||
}
|
}
|
||||||
@ -55,5 +56,5 @@ fn assign_registers(ir_function: &IrFunction) -> VariableLocations {
|
|||||||
unimplemented!("having more than one block in a function is not yet implemented.")
|
unimplemented!("having more than one block in a function is not yet implemented.")
|
||||||
}
|
}
|
||||||
let block = &ir_function.blocks()[0];
|
let block = &ir_function.blocks()[0];
|
||||||
block_assign_registers(block, 16) // TODO: make this configurable
|
block_assign_registers(block, register_count)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,7 @@ pub struct CompileCompilationUnitResult {
|
|||||||
|
|
||||||
pub fn compile_compilation_unit(
|
pub fn compile_compilation_unit(
|
||||||
input: &str,
|
input: &str,
|
||||||
|
register_count: usize,
|
||||||
constants_table: &mut ConstantsTable,
|
constants_table: &mut ConstantsTable,
|
||||||
) -> Result<CompileCompilationUnitResult, Diagnostics> {
|
) -> Result<CompileCompilationUnitResult, Diagnostics> {
|
||||||
let (compilation_unit, diagnostics) = parse_compilation_unit(input, None);
|
let (compilation_unit, diagnostics) = parse_compilation_unit(input, None);
|
||||||
@ -63,7 +64,7 @@ pub fn compile_compilation_unit(
|
|||||||
let mut dvm_functions = HashMap::new();
|
let mut dvm_functions = HashMap::new();
|
||||||
|
|
||||||
for ir_function in &lower_to_ir_result.functions {
|
for ir_function in &lower_to_ir_result.functions {
|
||||||
let dvm_function = compile_dvm_function(ir_function, constants_table);
|
let dvm_function = compile_dvm_function(ir_function, register_count, constants_table);
|
||||||
dvm_functions.insert(dvm_function.name_owned(), dvm_function);
|
dvm_functions.insert(dvm_function.name_owned(), dvm_function);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,8 @@ mod e2e_tests {
|
|||||||
fn prepare_context(input: &str) -> Result<DvmContext, Diagnostics> {
|
fn prepare_context(input: &str) -> Result<DvmContext, Diagnostics> {
|
||||||
let mut constants_table = ConstantsTable::new();
|
let mut constants_table = ConstantsTable::new();
|
||||||
|
|
||||||
let compile_compilation_unit_result = compile_compilation_unit(input, &mut constants_table);
|
let compile_compilation_unit_result =
|
||||||
|
compile_compilation_unit(input, REGISTER_COUNT, &mut constants_table);
|
||||||
|
|
||||||
let mut dvm_context = DvmContext::new();
|
let mut dvm_context = DvmContext::new();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user