Use custom 3-address code operands

This commit is contained in:
2025-11-14 22:57:00 +01:00
parent cc3acdfd12
commit ca6c306250

View File

@@ -403,7 +403,7 @@ type
start, start,
ret ret
); );
ElnaTacOperand = (register, immediate, symbol, offset, stack); ElnaTacOperand = (temporary, immediate, symbol, stack);
ElnaRtlOperand = (register, immediate, symbol, offset); ElnaRtlOperand = (register, immediate, symbol, offset);
ElnaRtlRegister = ( ElnaRtlRegister = (
zero, zero,
@@ -854,7 +854,7 @@ begin
elna_rtl_instruction_set_operand(next_instruction, 2, ElnaRtlOperand.offset, into, 0); elna_rtl_instruction_set_operand(next_instruction, 2, ElnaRtlOperand.offset, into, 0);
ElnaInstructionList_set_next(result, next_instruction) ElnaInstructionList_set_next(result, next_instruction)
elsif operand_type = ElnaTacOperand.register then elsif operand_type = ElnaTacOperand.temporary then
result := elna_rtl_instruction_create(ElnaRtlOperator.move); result := elna_rtl_instruction_create(ElnaRtlOperator.move);
elna_rtl_instruction_set_operand(result, 1, ElnaRtlOperand.register, into, 0); elna_rtl_instruction_set_operand(result, 1, ElnaRtlOperand.register, into, 0);
elna_rtl_instruction_set_operand(result, 2, ElnaRtlOperand.register, operand_value, 0) elna_rtl_instruction_set_operand(result, 2, ElnaRtlOperand.register, operand_value, 0)
@@ -993,7 +993,7 @@ begin
elna_rtl_copy_operand(tac_instruction, 1, result); elna_rtl_copy_operand(tac_instruction, 1, result);
elna_rtl_copy_operand(tac_instruction, 2, result) elna_rtl_copy_operand(tac_instruction, 2, result)
elsif operand_type = ElnaTacOperand.register then elsif operand_type = ElnaTacOperand.temporary then
result := elna_rtl_instruction_create(ElnaRtlOperator.move); result := elna_rtl_instruction_create(ElnaRtlOperator.move);
elna_rtl_copy_operand(tac_instruction, 1, result); elna_rtl_copy_operand(tac_instruction, 1, result);
@@ -1013,6 +1013,9 @@ begin
operand_value := _elna_tac_instruction_get_operand_value(tac_instruction, 2); operand_value := _elna_tac_instruction_get_operand_value(tac_instruction, 2);
elna_rtl_instruction_set_operand(result, 2, ElnaRtlOperand.offset, ElnaRtlRegister.sp, operand_value); elna_rtl_instruction_set_operand(result, 2, ElnaRtlOperand.offset, ElnaRtlRegister.sp, operand_value);
ElnaInstructionList_set_next(result, next_instruction^) ElnaInstructionList_set_next(result, next_instruction^)
elsif operand_type = ElnaTacOperand.temporary then
operand_value := _elna_tac_instruction_get_operand_value(tac_instruction, 2);
elna_rtl_instruction_set_operand(result, 2, ElnaRtlOperand.offset, operand_value, 0)
end; end;
elna_rtl_instruction_set_kind(result, ElnaRtlOperator.load_word) elna_rtl_instruction_set_kind(result, ElnaRtlOperator.load_word)
elsif instruction_kind = ElnaTacOperator.store_word then elsif instruction_kind = ElnaTacOperator.store_word then
@@ -1024,6 +1027,14 @@ begin
elna_rtl_instruction_set_kind(next_instruction^, ElnaRtlOperator.store_word); elna_rtl_instruction_set_kind(next_instruction^, ElnaRtlOperator.store_word);
elna_rtl_instruction_set_operand(next_instruction^, 1, ElnaRtlOperand.register, ElnaRtlRegister.t0, 0); elna_rtl_instruction_set_operand(next_instruction^, 1, ElnaRtlOperand.register, ElnaRtlRegister.t0, 0);
operand_type := _elna_tac_instruction_get_operand_type(tac_instruction, 2);
if operand_type = ElnaTacOperand.stack then
operand_value := _elna_tac_instruction_get_operand_value(tac_instruction, 2);
elna_rtl_instruction_set_operand(next_instruction^, 2, ElnaRtlOperand.offset, ElnaRtlRegister.sp, operand_value)
elsif operand_type = ElnaTacOperand.temporary then
operand_value := _elna_tac_instruction_get_operand_value(tac_instruction, 2);
elna_rtl_instruction_set_operand(next_instruction^, 2, ElnaRtlOperand.offset, operand_value, 0)
end;
if operands = 0 then if operands = 0 then
ElnaInstructionList_set_next(result, next_instruction^) ElnaInstructionList_set_next(result, next_instruction^)
else else
@@ -1116,7 +1127,7 @@ begin
operand_type := _elna_tac_instruction_get_operand_type(tac_instruction, 1); operand_type := _elna_tac_instruction_get_operand_type(tac_instruction, 1);
operand_value := _elna_tac_instruction_get_operand_value(tac_instruction, 1); operand_value := _elna_tac_instruction_get_operand_value(tac_instruction, 1);
if operand_type = ElnaTacOperand.register then if operand_type = ElnaTacOperand.temporary then
result := elna_rtl_load_operand_value(tac_instruction, 2, operand_value); result := elna_rtl_load_operand_value(tac_instruction, 2, operand_value);
next_instruction^ := ElnaInstructionList_get_next(result) next_instruction^ := ElnaInstructionList_get_next(result)
elsif operand_type = ElnaTacOperand.stack then elsif operand_type = ElnaTacOperand.stack then
@@ -1153,41 +1164,6 @@ begin
return result return result
end; end;
proc _elna_tac_jump(source_symbol: Word, symbol_length: Word);
var
result: Word;
begin
result := _elna_tac_instruction_create(ElnaTacOperator.jump);
_elna_tac_instruction_set_operand(result, 1, ElnaTacOperand.symbol, source_symbol, symbol_length);
return result
end;
proc _elna_tac_load_word(target: Word, register: Word, offset: Word);
var
result: Word;
begin
result := _elna_tac_instruction_create(ElnaTacOperator.load_word);
_elna_tac_instruction_set_operand(result, 1, ElnaTacOperand.register, target, 0);
_elna_tac_instruction_set_operand(result, 2, ElnaTacOperand.offset, register, offset);
return result
end;
proc _elna_tac_store_word(target: Word, register: Word, offset: Word);
var
result: Word;
begin
result := _elna_tac_instruction_create(ElnaTacOperator.store_word);
_elna_tac_instruction_set_operand(result, 1, ElnaTacOperand.register, target, 0);
_elna_tac_instruction_set_operand(result, 2, ElnaTacOperand.offset, register, offset);
return result
end;
proc _elna_tac_label(counter: Word, length: Word); proc _elna_tac_label(counter: Word, length: Word);
var var
result: Word; result: Word;
@@ -1634,17 +1610,17 @@ begin
offset := _add_string(token_start); offset := _add_string(token_start);
first_instruction := _elna_tac_instruction_create(ElnaTacOperator.get_address); first_instruction := _elna_tac_instruction_create(ElnaTacOperator.get_address);
_elna_tac_instruction_set_operand(first_instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(first_instruction, 1, ElnaTacOperand.temporary, 6, 0);
_elna_tac_instruction_set_operand(first_instruction, 2, ElnaTacOperand.symbol, "strings", 7); _elna_tac_instruction_set_operand(first_instruction, 2, ElnaTacOperand.symbol, "strings", 7);
(* Add offset to the string block pointer. *) (* Add offset to the string block pointer. *)
next_instruction := _elna_tac_instruction_create(ElnaTacOperator.add); next_instruction := _elna_tac_instruction_create(ElnaTacOperator.add);
_elna_tac_instruction_set_operand(next_instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(next_instruction, 1, ElnaTacOperand.temporary, 6, 0);
_elna_tac_instruction_set_operand(next_instruction, 2, ElnaTacOperand.register, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(next_instruction, 2, ElnaTacOperand.temporary, 6, 0);
_elna_tac_instruction_set_operand(next_instruction, 3, ElnaTacOperand.immediate, offset, 0); _elna_tac_instruction_set_operand(next_instruction, 3, ElnaTacOperand.immediate, offset, 0);
operand_type^ := ElnaTacOperand.register; operand_type^ := ElnaTacOperand.temporary;
operand_value^ := ElnaRtlRegister.t0; operand_value^ := 6;
operand_length^ := 0; operand_length^ := 0;
return elna_instruction_list_concatenate(first_instruction, next_instruction) return elna_instruction_list_concatenate(first_instruction, next_instruction)
@@ -1786,11 +1762,11 @@ begin
first_instruction := _elna_tac_designator(operand, symbol_table, @is_address, operand_type, operand_value, operand_length); first_instruction := _elna_tac_designator(operand, symbol_table, @is_address, operand_type, operand_value, operand_length);
instruction := _elna_tac_instruction_create(ElnaTacOperator.get_address); instruction := _elna_tac_instruction_create(ElnaTacOperator.get_address);
_elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.temporary, 6, 0);
_elna_tac_instruction_set_operand(instruction, 2, operand_type^, operand_value^, operand_length^); _elna_tac_instruction_set_operand(instruction, 2, operand_type^, operand_value^, operand_length^);
operand_type^ := ElnaTacOperand.register; operand_type^ := ElnaTacOperand.temporary;
operand_value^ := ElnaRtlRegister.t0; operand_value^ := 6;
operand_length^ := 0; operand_length^ := 0;
first_instruction := elna_instruction_list_concatenate(first_instruction, instruction) first_instruction := elna_instruction_list_concatenate(first_instruction, instruction)
@@ -1801,20 +1777,20 @@ begin
if first_instruction = 0 then if first_instruction = 0 then
first_instruction := _elna_tac_instruction_create(ElnaTacOperator.get_address); first_instruction := _elna_tac_instruction_create(ElnaTacOperator.get_address);
_elna_tac_instruction_set_operand(first_instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(first_instruction, 1, ElnaTacOperand.temporary, 6, 0);
_elna_tac_instruction_set_operand(first_instruction, 2, operand_type^, operand_value^, operand_length^); _elna_tac_instruction_set_operand(first_instruction, 2, operand_type^, operand_value^, operand_length^);
operand_type^ := ElnaTacOperand.register; operand_type^ := ElnaTacOperand.temporary;
operand_value^ := ElnaRtlRegister.t0; operand_value^ := 6;
operand_length^ := 0 operand_length^ := 0
end; end;
if is_address then if is_address then
instruction := _elna_tac_instruction_create(ElnaTacOperator.load_word); instruction := _elna_tac_instruction_create(ElnaTacOperator.load_word);
_elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.temporary, 6, 0);
_elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.offset, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.temporary, 6, 0);
operand_type^ := ElnaTacOperand.register; operand_type^ := ElnaTacOperand.temporary;
operand_value^ := ElnaRtlRegister.t0; operand_value^ := 6;
operand_length^ := 0; operand_length^ := 0;
elna_instruction_list_concatenate(first_instruction, instruction) elna_instruction_list_concatenate(first_instruction, instruction)
@@ -1822,13 +1798,13 @@ begin
end; end;
if operator = '-' then if operator = '-' then
instruction := _elna_tac_instruction_create(ElnaTacOperator.neg); instruction := _elna_tac_instruction_create(ElnaTacOperator.neg);
_elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.temporary, 6, 0);
_elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.register, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.temporary, 6, 0);
elna_instruction_list_concatenate(first_instruction, instruction) elna_instruction_list_concatenate(first_instruction, instruction)
elsif operator = '~' then elsif operator = '~' then
instruction := _elna_tac_instruction_create(ElnaTacOperator.not); instruction := _elna_tac_instruction_create(ElnaTacOperator.not);
_elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.temporary, 6, 0);
_elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.register, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.temporary, 6, 0);
elna_instruction_list_concatenate(first_instruction, instruction) elna_instruction_list_concatenate(first_instruction, instruction)
end; end;
return first_instruction return first_instruction
@@ -1957,7 +1933,7 @@ begin
(* Load the left expression from the stack; *) (* Load the left expression from the stack; *)
instruction := _elna_tac_instruction_create(ElnaTacOperator.assign); instruction := _elna_tac_instruction_create(ElnaTacOperator.assign);
_elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.t1, 0); _elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.temporary, 7, 0);
_elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.stack, 72, 0); _elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.stack, 72, 0);
elna_instruction_list_concatenate(current_instruction, instruction); elna_instruction_list_concatenate(current_instruction, instruction);
@@ -1992,14 +1968,14 @@ begin
elsif token_kind = ElnaLexerKind.not_equal then elsif token_kind = ElnaLexerKind.not_equal then
instruction := _elna_tac_instruction_create(ElnaTacOperator.sne) instruction := _elna_tac_instruction_create(ElnaTacOperator.sne)
end; end;
_elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.temporary, 6, 0);
_elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.stack, 72, 0); _elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.stack, 72, 0);
_elna_tac_instruction_set_operand(instruction, 3, lhs_type, lhs_value, lhs_length); _elna_tac_instruction_set_operand(instruction, 3, lhs_type, lhs_value, lhs_length);
elna_instruction_list_concatenate(current_instruction, instruction); elna_instruction_list_concatenate(current_instruction, instruction);
operand_type^ := ElnaTacOperand.register; operand_type^ := ElnaTacOperand.temporary;
operand_value^ := ElnaRtlRegister.t0; operand_value^ := 6;
operand_length^ := 0 operand_length^ := 0
end; end;
return first_instruction return first_instruction
@@ -2123,7 +2099,7 @@ begin
instruction := _elna_tac_instruction_create(ElnaTacOperator.store_word); instruction := _elna_tac_instruction_create(ElnaTacOperator.store_word);
_elna_tac_instruction_set_operand(instruction, 1, operand_type, operand_value, operand_length); _elna_tac_instruction_set_operand(instruction, 1, operand_type, operand_value, operand_length);
_elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.offset, ElnaRtlRegister.sp, 132 - stack_offset); _elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.stack, 132 - stack_offset, 0);
if first_instruction = 0 then if first_instruction = 0 then
first_instruction := instruction first_instruction := instruction
else else
@@ -2143,8 +2119,9 @@ begin
stack_offset := argument_count * 4; stack_offset := argument_count * 4;
(* Calculate the stack offset: 132 - (4 * argument_counter) *) (* Calculate the stack offset: 132 - (4 * argument_counter) *)
instruction := _elna_tac_load_word(ElnaRtlRegister.a0 + argument_count, instruction := _elna_tac_instruction_create(ElnaTacOperator.assign);
ElnaRtlRegister.sp, 132 - stack_offset); _elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.temporary, 11 + argument_count, 0);
_elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.stack, 132 - stack_offset, 0);
elna_instruction_list_concatenate(current_instruction, instruction); elna_instruction_list_concatenate(current_instruction, instruction);
current_instruction := instruction; current_instruction := instruction;
@@ -2198,7 +2175,9 @@ begin
_store_byte('.', label_with_dot); _store_byte('.', label_with_dot);
memcpy(label_with_dot + 1, label_name, label_length); memcpy(label_with_dot + 1, label_name, label_length);
return _elna_tac_jump(label_with_dot, label_length + 1) instruction := _elna_tac_instruction_create(ElnaTacOperator.jump);
_elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.symbol, label_with_dot, label_length + 1);
return instruction
end; end;
proc _elna_parser_label_declaration(); proc _elna_parser_label_declaration();
@@ -2325,11 +2304,11 @@ begin
first_instruction := _elna_tac_simple_expression(parser_node, symbol_table, is_address, operand_type, operand_value, operand_length); first_instruction := _elna_tac_simple_expression(parser_node, symbol_table, is_address, operand_type, operand_value, operand_length);
last_instruction := _elna_tac_instruction_create(ElnaTacOperator.assign); last_instruction := _elna_tac_instruction_create(ElnaTacOperator.assign);
_elna_tac_instruction_set_operand(last_instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(last_instruction, 1, ElnaTacOperand.temporary, 6, 0);
_elna_tac_instruction_set_operand(last_instruction, 2, operand_type^, operand_value^, operand_length^); _elna_tac_instruction_set_operand(last_instruction, 2, operand_type^, operand_value^, operand_length^);
operand_type^ := ElnaTacOperand.register; operand_type^ := ElnaTacOperand.temporary;
operand_value^ := ElnaRtlRegister.t0; operand_value^ := 6;
operand_length^ := 0; operand_length^ := 0;
first_instruction := elna_instruction_list_concatenate(first_instruction, last_instruction) first_instruction := elna_instruction_list_concatenate(first_instruction, last_instruction)
@@ -2340,11 +2319,11 @@ begin
first_instruction := _elna_tac_call(parser_node, symbol_table); first_instruction := _elna_tac_call(parser_node, symbol_table);
last_instruction := _elna_tac_instruction_create(ElnaTacOperator.assign); last_instruction := _elna_tac_instruction_create(ElnaTacOperator.assign);
_elna_tac_instruction_set_operand(last_instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(last_instruction, 1, ElnaTacOperand.temporary, 6, 0);
_elna_tac_instruction_set_operand(last_instruction, 2, ElnaTacOperand.register, ElnaRtlRegister.a0, 0); _elna_tac_instruction_set_operand(last_instruction, 2, ElnaTacOperand.temporary, 11, 0);
operand_type^ := ElnaTacOperand.register; operand_type^ := ElnaTacOperand.temporary;
operand_value^ := ElnaRtlRegister.t0; operand_value^ := 6;
operand_length^ := 0; operand_length^ := 0;
elna_instruction_list_concatenate(first_instruction, last_instruction); elna_instruction_list_concatenate(first_instruction, last_instruction);
@@ -2395,12 +2374,14 @@ begin
first_instruction := _elna_tac_designator(current_expression, symbol_table, @is_address, @operand_type, @operand_value, @operand_length); first_instruction := _elna_tac_designator(current_expression, symbol_table, @is_address, @operand_type, @operand_value, @operand_length);
current_instruction := _elna_tac_instruction_create(ElnaTacOperator.get_address); current_instruction := _elna_tac_instruction_create(ElnaTacOperator.get_address);
_elna_tac_instruction_set_operand(current_instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.t0, 0); _elna_tac_instruction_set_operand(current_instruction, 1, ElnaTacOperand.temporary, 6, 0);
_elna_tac_instruction_set_operand(current_instruction, 2, operand_type, operand_value, operand_length); _elna_tac_instruction_set_operand(current_instruction, 2, operand_type, operand_value, operand_length);
first_instruction := elna_instruction_list_concatenate(first_instruction, current_instruction); first_instruction := elna_instruction_list_concatenate(first_instruction, current_instruction);
(* Save the assignee address on the stack. *) (* Save the assignee address on the stack. *)
current_instruction := _elna_tac_store_word(ElnaRtlRegister.t0, ElnaRtlRegister.sp, 76); current_instruction := _elna_tac_instruction_create(ElnaTacOperator.store_word);
_elna_tac_instruction_set_operand(current_instruction, 1, ElnaTacOperand.temporary, 6, 0);
_elna_tac_instruction_set_operand(current_instruction, 2, ElnaTacOperand.stack, 76, 0);
elna_instruction_list_concatenate(first_instruction, current_instruction); elna_instruction_list_concatenate(first_instruction, current_instruction);
(* Compile the assignment. *) (* Compile the assignment. *)
@@ -2415,13 +2396,16 @@ begin
current_instruction := instruction current_instruction := instruction
end; end;
instruction := _elna_tac_load_word(ElnaRtlRegister.t1, ElnaRtlRegister.sp, 76); instruction := _elna_tac_instruction_create(ElnaTacOperator.assign);
_elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.temporary, 7, 0);
_elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.stack, 76, 0);
elna_instruction_list_concatenate(current_instruction, instruction); elna_instruction_list_concatenate(current_instruction, instruction);
current_instruction := instruction; current_instruction := instruction;
instruction := _elna_tac_instruction_create(ElnaTacOperator.store_word); instruction := _elna_tac_instruction_create(ElnaTacOperator.store_word);
_elna_tac_instruction_set_operand(instruction, 1, operand_type, operand_value, operand_length); _elna_tac_instruction_set_operand(instruction, 1, operand_type, operand_value, operand_length);
_elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.offset, ElnaRtlRegister.t1, 0); _elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.temporary, 7, 0);
elna_instruction_list_concatenate(current_instruction, instruction); elna_instruction_list_concatenate(current_instruction, instruction);
@@ -2465,7 +2449,7 @@ begin
first_instruction := _elna_tac_binary_expression(return_expression, symbol_table, @operand_type, @operand_value, @operand_length); first_instruction := _elna_tac_binary_expression(return_expression, symbol_table, @operand_type, @operand_value, @operand_length);
instruction := _elna_tac_instruction_create(ElnaTacOperator.assign); instruction := _elna_tac_instruction_create(ElnaTacOperator.assign);
_elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.a0, 0); _elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.temporary, 11, 0);
_elna_tac_instruction_set_operand(instruction, 2, operand_type, operand_value, operand_length); _elna_tac_instruction_set_operand(instruction, 2, operand_type, operand_value, operand_length);
return elna_instruction_list_concatenate(first_instruction, instruction) return elna_instruction_list_concatenate(first_instruction, instruction)
@@ -2553,7 +2537,8 @@ begin
current_instruction := instruction current_instruction := instruction
end; end;
instruction := _elna_tac_jump(after_end_label, 0); instruction := _elna_tac_instruction_create(ElnaTacOperator.jump);
_elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.symbol, after_end_label, 0);
elna_instruction_list_concatenate(current_instruction, instruction); elna_instruction_list_concatenate(current_instruction, instruction);
current_instruction := _elna_tac_label(condition_label, 0); current_instruction := _elna_tac_label(condition_label, 0);
@@ -3267,7 +3252,9 @@ begin
symbol_info := _parameter_info_get_offset(symbol_info); symbol_info := _parameter_info_get_offset(symbol_info);
instruction := _elna_tac_store_word(ElnaRtlRegister.a0 + parameter_counter, ElnaRtlRegister.sp, symbol_info); instruction := _elna_tac_instruction_create(ElnaTacOperator.store_word);
_elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.temporary, 11 + parameter_counter, 0);
_elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.stack, symbol_info, 0);
if first_instruction = 0 then if first_instruction = 0 then
first_instruction := instruction first_instruction := instruction
else else
@@ -3677,8 +3664,8 @@ begin
instruction := _elna_tac_instruction_create(ElnaTacOperator.add); instruction := _elna_tac_instruction_create(ElnaTacOperator.add);
_elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.a0, 0); _elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.temporary, 11, 0);
_elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.register, ElnaRtlRegister.a0, 0); _elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.temporary, 11, 0);
_elna_tac_instruction_set_operand(instruction, 3, ElnaTacOperand.immediate, field_offset, 0); _elna_tac_instruction_set_operand(instruction, 3, ElnaTacOperand.immediate, field_offset, 0);
return instruction return instruction
@@ -3693,15 +3680,15 @@ var
begin begin
instruction := _elna_tac_accessor(name_pointer, name_length, field_pointer, field_offset, @first_result, "_get_"); instruction := _elna_tac_accessor(name_pointer, name_length, field_pointer, field_offset, @first_result, "_get_");
next_instruction := _elna_tac_instruction_create(ElnaTacOperator.load_word); next_instruction := _elna_tac_instruction_create(ElnaTacOperator.load_word);
_elna_tac_instruction_set_operand(next_instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.a0, 0); _elna_tac_instruction_set_operand(next_instruction, 1, ElnaTacOperand.temporary, 11, 0);
_elna_tac_instruction_set_operand(next_instruction, 2, ElnaTacOperand.offset, ElnaRtlRegister.a0, 0); _elna_tac_instruction_set_operand(next_instruction, 2, ElnaTacOperand.temporary, 11, 0);
elna_instruction_list_concatenate(instruction, next_instruction); elna_instruction_list_concatenate(instruction, next_instruction);
ElnaInstructionDeclaration_set_body(first_result, instruction); ElnaInstructionDeclaration_set_body(first_result, instruction);
instruction := _elna_tac_accessor(name_pointer, name_length, field_pointer, field_offset, @second_result, "_set_"); instruction := _elna_tac_accessor(name_pointer, name_length, field_pointer, field_offset, @second_result, "_set_");
next_instruction := _elna_tac_instruction_create(ElnaTacOperator.store_word); next_instruction := _elna_tac_instruction_create(ElnaTacOperator.store_word);
_elna_tac_instruction_set_operand(next_instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.a1, 0); _elna_tac_instruction_set_operand(next_instruction, 1, ElnaTacOperand.temporary, 12, 0);
_elna_tac_instruction_set_operand(next_instruction, 2, ElnaTacOperand.offset, ElnaRtlRegister.a0, 0); _elna_tac_instruction_set_operand(next_instruction, 2, ElnaTacOperand.temporary, 11, 0);
elna_instruction_list_concatenate(instruction, next_instruction); elna_instruction_list_concatenate(instruction, next_instruction);
ElnaInstructionDeclaration_set_body(second_result, instruction); ElnaInstructionDeclaration_set_body(second_result, instruction);
@@ -3736,7 +3723,7 @@ begin
ElnaInstructionDeclaration_set_length(first_result, new_length); ElnaInstructionDeclaration_set_length(first_result, new_length);
instruction := _elna_tac_instruction_create(ElnaTacOperator.assign); instruction := _elna_tac_instruction_create(ElnaTacOperator.assign);
_elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.register, ElnaRtlRegister.a0, 0); _elna_tac_instruction_set_operand(instruction, 1, ElnaTacOperand.temporary, 11, 0);
_elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.immediate, type_size, 0); _elna_tac_instruction_set_operand(instruction, 2, ElnaTacOperand.immediate, type_size, 0);
ElnaInstructionDeclaration_set_body(first_result, instruction); ElnaInstructionDeclaration_set_body(first_result, instruction);