Make destination be the last argument of the TAC binary instructions

This commit is contained in:
2026-04-09 22:11:15 +02:00
parent d11579d041
commit f26a8b639a

View File

@@ -974,12 +974,12 @@ var
begin
result := elna_rtl_instruction_create(operation);
elna_rtl_instruction_set_operand(result, 1, ElnaRtlKind.pseudo,
tac_instruction^.operands[1].value, tac_instruction^.operands[1].length, 0);
tac_instruction^.operands[3].value, tac_instruction^.operands[3].length, 0);
elna_rtl_operand_value(instructions, @tac_instruction^.operands[2], variable_map, @rtl_operand);
elna_rtl_operand_value(instructions, @tac_instruction^.operands[1], variable_map, @rtl_operand);
elna_rtl_instruction_set_operand(result, 2, rtl_operand.kind, rtl_operand.value, rtl_operand.length, 0);
elna_rtl_operand_value(instructions, @tac_instruction^.operands[3], variable_map, @rtl_operand);
elna_rtl_operand_value(instructions, @tac_instruction^.operands[2], variable_map, @rtl_operand);
elna_rtl_instruction_set_operand(result, 3, rtl_operand.kind, rtl_operand.value, rtl_operand.length, 0);
elna_list_append(instructions, result);
@@ -1038,12 +1038,12 @@ var
begin
slt_instruction := elna_rtl_instruction_create(ElnaRtlOperator.slt);
elna_rtl_instruction_set_operand(slt_instruction, 1, ElnaRtlKind.pseudo,
tac_instruction^.operands[1].value, tac_instruction^.operands[1].length, 0);
tac_instruction^.operands[3].value, tac_instruction^.operands[3].length, 0);
elna_rtl_operand_value(instructions, @tac_instruction^.operands[2], variable_map, @rtl_operand);
elna_rtl_operand_value(instructions, @tac_instruction^.operands[1], variable_map, @rtl_operand);
elna_rtl_instruction_set_operand(slt_instruction, lhs, rtl_operand.kind, rtl_operand.value, rtl_operand.length, 0);
elna_rtl_operand_value(instructions, @tac_instruction^.operands[3], variable_map, @rtl_operand);
elna_rtl_operand_value(instructions, @tac_instruction^.operands[2], variable_map, @rtl_operand);
elna_rtl_instruction_set_operand(slt_instruction, rhs, rtl_operand.kind, rtl_operand.value, rtl_operand.length, 0);
elna_list_append(instructions, slt_instruction);
@@ -2118,8 +2118,8 @@ begin
(* Add offset to the string block pointer. *)
instruction := elna_tac_instruction_create(ElnaTacOperator.add);
elna_tac_instruction_set_operand(instruction, 1, operand^.kind, operand^.value, operand^.length);
elna_tac_instruction_set_operand(instruction, 2, operand^.kind, operand^.value, operand^.length);
elna_tac_instruction_set_operand(instruction, 3, ElnaTacKind.constant, offset, 0);
elna_tac_instruction_set_operand(instruction, 2, ElnaTacKind.constant, offset, 0);
elna_tac_instruction_set_operand(instruction, 3, operand^.kind, operand^.value, operand^.length);
elna_list_append(instructions, instruction)
end;
@@ -2294,8 +2294,8 @@ begin
elna_list_append(instructions, instruction);
instruction := elna_tac_instruction_create(ElnaTacOperator.add);
elna_tac_instruction_set_operand(instruction, 1, to^.kind, to^.value, to^.length);
elna_tac_instruction_set_operand(instruction, 2, ElnaTacKind.constant, operand_result^.offset, 0);
elna_tac_instruction_set_operand(instruction, 1, ElnaTacKind.constant, operand_result^.offset, 0);
elna_tac_instruction_set_operand(instruction, 2, to^.kind, to^.value, to^.length);
elna_tac_instruction_set_operand(instruction, 3, to^.kind, to^.value, to^.length);
elna_list_append(instructions, instruction)
else (* ElnaTacOperandType.plain_object *)
@@ -2461,9 +2461,9 @@ begin
instruction := elna_tac_instruction_create(operator);
elna_tac_make_variable(@operand^.kind, @operand^.value, @operand^.length, symbol_table);
elna_tac_instruction_set_operand(instruction, 1, operand^.kind, operand^.value, operand^.length);
elna_tac_instruction_set_operand(instruction, 2, lhs^.kind, lhs^.value, lhs^.length);
elna_tac_instruction_set_operand(instruction, 3, rhs^.kind, rhs^.value, rhs^.length);
elna_tac_instruction_set_operand(instruction, 1, lhs^.kind, lhs^.value, lhs^.length);
elna_tac_instruction_set_operand(instruction, 2, rhs^.kind, rhs^.value, rhs^.length);
elna_tac_instruction_set_operand(instruction, 3, operand^.kind, operand^.value, operand^.length);
return instruction
end;
@@ -2817,9 +2817,9 @@ begin
elna_tac_make_variable(@operand^.kind, @operand^.value, @operand^.length, symbol_table);
instruction := elna_tac_instruction_create(ElnaTacOperator.add);
elna_tac_instruction_set_operand(instruction, 1, operand^.kind, operand^.value, operand^.length);
elna_tac_instruction_set_operand(instruction, 2, base.kind, base.value, base.length);
elna_tac_instruction_set_operand(instruction, 3, ElnaTacKind.constant, field_offset, 0);
elna_tac_instruction_set_operand(instruction, 1, base.kind, base.value, base.length);
elna_tac_instruction_set_operand(instruction, 2, ElnaTacKind.constant, field_offset, 0);
elna_tac_instruction_set_operand(instruction, 3, operand^.kind, operand^.value, operand^.length);
elna_list_append(instructions, instruction)
elsif operand_result^.kind = ElnaTacOperandType.sub_object then
memcpy(operand, @base, #size(ElnaTacOperand));
@@ -2850,9 +2850,9 @@ begin
elna_tac_make_variable(@index_operand.kind, @index_operand.value, @index_operand.length, symbol_table);
instruction := elna_tac_instruction_create(ElnaTacOperator.subtract);
elna_tac_instruction_set_operand(instruction, 1, index_operand.kind, index_operand.value, index_operand.length);
elna_tac_instruction_set_operand(instruction, 2, inter_operand.kind, inter_operand.value, inter_operand.length);
elna_tac_instruction_set_operand(instruction, 3, ElnaTacKind.constant, 1, 0);
elna_tac_instruction_set_operand(instruction, 1, inter_operand.kind, inter_operand.value, inter_operand.length);
elna_tac_instruction_set_operand(instruction, 2, ElnaTacKind.constant, 1, 0);
elna_tac_instruction_set_operand(instruction, 3, index_operand.kind, index_operand.value, index_operand.length);
elna_list_append(instructions, instruction);
elna_tac_designator(instructions, array_access_expression^.array,