feat(codegen): x86-64 assembly backend (issue #26)#151
Merged
Conversation
4 tasks
abi::stack_arg_offset already accounted for stack-passed arguments on the callee side, but emit_call only ever wired up the 6 register arguments and panicked otherwise. Push the extra arguments onto the stack in reverse order, pad to keep the call site 16-byte aligned, and clean up rsp after the call.
Owner
|
Bug real encontrado e corrigido: emit_call em src/codegen/last/x86_64.rs suportava apenas os 6 argumentos passados por registrador (System V AMD64). Para >6 argumentos, ele dava panic!, mesmo que
Validação:
|
Owner
|
Resolvi o problema ja |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contexto
Fase final de geração de código (issue #26): traduz a IR (TAC, #24) para assembly x86-64 (sintaxe AT&T / GAS) seguindo o System V AMD64 ABI.
Depende de #23 (IR/TAC), #24 (lowering AST→TAC) e #25 (CFG), todos já em
developer.O que foi feito
src/codegen/last/abi.rs— helpers do System V AMD64 ABI (args emrdi,rsi,rdx,rcx,r8,r9, retorno emrax, offsets de stack args).src/codegen/last/frame.rs— gerenciamento de stack frame com spill universal (cada temp/var em um slot de 8 bytes, frame alinhado em 16).src/codegen/last/x86_64.rs— seleção de instruções e emissão AT&T paraBinOp,UnOp,Copy,Jump,CondJump,Call,Return,Label, com prólogo/epílogo e diretiva.note.GNU-stack.src/codegen/last/mod.rs— entrypoint do backend (emit_function,emit_program).src/main.rs— integração ao pipeline via flag-S/--emit-asm(baixa AST→TAC e emite<file>.s).Estrutura espelha exatamente o sugerido na issue.
Critérios de aceite
gcc -x assembler-with-cpptests/codegen_smoke.rsmonta, linka e executa os binários, conferindo exit codesVerificação
cargo fmt --checklimpo.cargo clippy: sem issues no código novo (6 erros pré-existentes dePIem fixtures do lexer estão emdeveloper, fora de escopo).soma(7,35)=42,abs(-15)=15,sum_to(10)=45,(20*6 - 20/6 + 20%6)=119, if/else e loops.Closes #26.