Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Chibicc
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
邓家琪
Chibicc
Commits
aedbf56c
Commit
aedbf56c
authored
5 years ago
by
Rui Ueyama
Browse files
Options
Downloads
Patches
Plain Diff
Make sure that stack frames are aligned to 16 bytes boundaries
parent
5dea3682
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
codegen.c
+15
-0
15 additions, 0 deletions
codegen.c
with
15 additions
and
0 deletions
codegen.c
+
15
−
0
View file @
aedbf56c
...
...
@@ -112,7 +112,22 @@ void gen(Node *node) {
for
(
int
i
=
nargs
-
1
;
i
>=
0
;
i
--
)
printf
(
" pop %s
\n
"
,
argreg
[
i
]);
// We need to align RSP to a 16 byte boundary before
// calling a function because it is an ABI requirement.
// RAX is set to 0 for variadic function.
int
seq
=
labelseq
++
;
printf
(
" mov rax, rsp
\n
"
);
printf
(
" and rax, 15
\n
"
);
printf
(
" jnz .Lcall%d
\n
"
,
seq
);
printf
(
" mov rax, 0
\n
"
);
printf
(
" call %s
\n
"
,
node
->
funcname
);
printf
(
" jmp .Lend%d
\n
"
,
seq
);
printf
(
".Lcall%d:
\n
"
,
seq
);
printf
(
" sub rsp, 8
\n
"
);
printf
(
" mov rax, 0
\n
"
);
printf
(
" call %s
\n
"
,
node
->
funcname
);
printf
(
" add rsp, 8
\n
"
);
printf
(
".Lend%d:
\n
"
,
seq
);
printf
(
" push rax
\n
"
);
return
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment