diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-05-05 01:16:48 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-05-05 01:16:48 +0900 |
| commit | ecffc7cf7aaa3fd447848568619161a95408aa0e (patch) | |
| tree | 3cd21011da3c661a28b826c436a592fc5dd8b9b8 /main.c | |
| parent | 992fc93278710bb41117d93531d9ed18db49e119 (diff) | |
| download | P4Dcc-ecffc7cf7aaa3fd447848568619161a95408aa0e.tar.gz P4Dcc-ecffc7cf7aaa3fd447848568619161a95408aa0e.tar.zst P4Dcc-ecffc7cf7aaa3fd447848568619161a95408aa0e.zip | |
align rsp
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -1632,9 +1632,28 @@ void gen_func_call(struct CodeGen* g, struct AstNode* ast) { fatal_error("gen_func_call: too many args"); } } + + int label = gen_new_label(g); + + printf(" mov rax, rsp\n"); + printf(" and rax, 15\n"); + printf(" cmp rax, 0\n"); + printf(" je .Laligned%d\n", label); + printf(" mov rax, 0\n"); + printf(" sub rsp, 8\n"); printf(" call %s\n", func_name); + printf(" add rsp, 8\n"); printf(" push rax\n"); + + printf(" jmp .Lend%d\n", label); + printf(".Laligned%d:\n", label); + + printf(" mov rax, 0\n"); + printf(" call %s\n", func_name); + printf(" push rax\n"); + + printf(".Lend%d:\n", label); } void gen_lvar(struct CodeGen* g, struct AstNode* ast, int gen_mode) { |
