Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pop local variables based on their size #57

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions cc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2669,15 +2669,20 @@ void recursive_statement(void)
(((RISCV32 == Architecture) || (RISCV64 == Architecture)) && !match("ret\n", output_list->s)))
{
struct token_list* i;
int j;
for(i = function->locals; frame != i; i = i->next)
{
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("POPR R1 R15\t# _recursive_statement_locals\n");
else if(X86 == Architecture) emit_out( "pop_ebx\t# _recursive_statement_locals\n");
else if(AMD64 == Architecture) emit_out("pop_rbx\t# _recursive_statement_locals\n");
else if(ARMV7L == Architecture) emit_out("{R1} POP_ALWAYS\t# _recursive_statement_locals\n");
else if(AARCH64 == Architecture) emit_out("POP_X1\t# _recursive_statement_locals\n");
else if(RISCV32 == Architecture) emit_out("rd_a1 rs1_sp lw\t# _recursive_statement_locals\nrd_sp rs1_sp !4 addi\n");
else if(RISCV64 == Architecture) emit_out("rd_a1 rs1_sp ld\t# _recursive_statement_locals\nrd_sp rs1_sp !8 addi\n");
j = ceil_div(i->type->size, register_size);
while (j != 0) {
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("POPR R1 R15\t# _recursive_statement_locals\n");
else if(X86 == Architecture) emit_out( "pop_ebx\t# _recursive_statement_locals\n");
else if(AMD64 == Architecture) emit_out("pop_rbx\t# _recursive_statement_locals\n");
else if(ARMV7L == Architecture) emit_out("{R1} POP_ALWAYS\t# _recursive_statement_locals\n");
else if(AARCH64 == Architecture) emit_out("POP_X1\t# _recursive_statement_locals\n");
else if(RISCV32 == Architecture) emit_out("rd_a1 rs1_sp lw\t# _recursive_statement_locals\nrd_sp rs1_sp !4 addi\n");
else if(RISCV64 == Architecture) emit_out("rd_a1 rs1_sp ld\t# _recursive_statement_locals\nrd_sp rs1_sp !8 addi\n");
j = j - 1;
}
}
}
function->locals = frame;
Expand Down
Loading