Reduce the number of used temporary registers

This commit is contained in:
2026-03-20 19:00:34 +01:00
parent 5fb3c910a6
commit 5230d65efd

View File

@@ -1444,8 +1444,7 @@ begin
if instruction^.operands[2].kind = ElnaRtlKind.pseudo then
store_instruction := elna_rtl_instruction_create(ElnaRtlOperator.sw);
elna_rtl_instruction_set_operand(store_instruction, 1, instruction^.operands[1].kind,
instruction^.operands[1].value, instruction^.operands[1].length);
elna_rtl_instruction_set_operand(store_instruction, 1, ElnaRtlKind.register, ElnaRtlRegister.t0, 0);
elna_rtl_instruction_set_operand(store_instruction, 2, ElnaRtlKind.offset, ElnaRtlRegister.t1, 0);
pseudo_symbol := elna_alloc_variable(instruction^.operands[2].value, instruction^.operands[2].length,
@@ -1472,11 +1471,11 @@ begin
memcpy(new_instruction, instruction, #size(ElnaRtlInstruction));
new_instruction^.next := nil;
elna_rtl_instruction_set_operand(new_instruction, 2, ElnaRtlKind.offset, ElnaRtlRegister.t1, 0);
elna_rtl_instruction_set_operand(new_instruction, 2, ElnaRtlKind.offset, ElnaRtlRegister.t0, 0);
instruction^.operator := ElnaRtlOperator.lw;
elna_rtl_instruction_set_operand(instruction, 1, ElnaRtlKind.register, ElnaRtlRegister.t1, 0);
elna_rtl_instruction_set_operand(instruction, 1, ElnaRtlKind.register, ElnaRtlRegister.t0, 0);
elna_rtl_instruction_set_operand(instruction, 2, ElnaRtlKind.offset, ElnaRtlRegister.sp, pseudo_symbol^.counter);
elna_list_insert(instructions, instruction, new_instruction);
instruction := new_instruction
@@ -1494,12 +1493,12 @@ begin
source_pseudo := instruction^.operands[2].kind = ElnaRtlKind.pseudo;
if destination_pseudo & source_pseudo then
instruction := elna_alloc_operand(instructions, instruction, 2, ElnaRtlRegister.t4, variable_map);
instruction := elna_alloc_operand(instructions, instruction, 2, ElnaRtlRegister.t0, variable_map);
pseudo_symbol := elna_alloc_variable(instruction^.operands[1].value, instruction^.operands[1].length,
variable_map);
instruction^.operator = ElnaRtlOperator.sw;
elna_rtl_instruction_set_operand(instruction, 1, ElnaRtlKind.register, ElnaRtlRegister.t4, 0);
elna_rtl_instruction_set_operand(instruction, 1, ElnaRtlKind.register, ElnaRtlRegister.t0, 0);
elna_rtl_instruction_set_operand(instruction, 2, ElnaRtlKind.offset, ElnaRtlRegister.sp, pseudo_symbol^.counter)
elsif destination_pseudo then
pseudo_symbol := elna_alloc_variable(instruction^.operands[1].value, instruction^.operands[1].length,
@@ -1553,8 +1552,8 @@ var
new_instruction: ^ElnaRtlInstruction;
pseudo_symbol: ^ElnaRtlInfo;
begin
instruction := elna_alloc_operand(instructions, instruction, 2, ElnaRtlRegister.t2, variable_map);
instruction := elna_alloc_operand(instructions, instruction, 3, ElnaRtlRegister.t3, variable_map);
instruction := elna_alloc_operand(instructions, instruction, 2, ElnaRtlRegister.t0, variable_map);
instruction := elna_alloc_operand(instructions, instruction, 3, ElnaRtlRegister.t1, variable_map);
return elna_alloc_operation_target(instructions, instruction, variable_map)
end;
@@ -1563,7 +1562,7 @@ var
new_instruction: ^ElnaRtlInstruction;
pseudo_symbol: ^ElnaRtlInfo;
begin
instruction := elna_alloc_operand(instructions, instruction, 2, ElnaRtlRegister.t2, variable_map);
instruction := elna_alloc_operand(instructions, instruction, 2, ElnaRtlRegister.t0, variable_map);
return elna_alloc_operation_target(instructions, instruction, variable_map)
end;