-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cranelift: add alignment parameter to stack slots. (#8635)
* Cranelift: add alignment parameter to stack slots. Fixes #6716. Currently, stack slots on the stack are aligned only to a machine-word boundary. This is insufficient for some use-cases: for example, storing SIMD data or structs that require a larger alignment. This PR adds a parameter to the `StackSlotData` to specify alignment, and the associated logic to the CLIF parser and printer. It updates the shared ABI code to compute the stackslot layout taking the alignment into account. In order to ensure the alignment is always a power of two, it is stored as a shift amount (log2 of actual alignment) in the IR. * Apply suggestions from code review Co-authored-by: Trevor Elliott <awesomelyawesome@gmail.com> * Update filetest. * Update alignment to ValRaw vector. * Fix printer test. * cargo-fmt from suggestion update. --------- Co-authored-by: Trevor Elliott <awesomelyawesome@gmail.com>
- Loading branch information
Showing
12 changed files
with
140 additions
and
47 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
test compile precise-output | ||
target x86_64 | ||
|
||
function %f0(i64 vmctx) -> i64, i64, i64, i64 { | ||
gv0 = vmctx | ||
stack_limit = gv0 | ||
ss0 = explicit_slot 8, align=16 | ||
ss1 = explicit_slot 8, align=16 | ||
ss2 = explicit_slot 4 | ||
ss3 = explicit_slot 4 | ||
|
||
block0(v0: i64): | ||
v1 = stack_addr.i64 ss0 | ||
v2 = stack_addr.i64 ss1 | ||
v3 = stack_addr.i64 ss2 | ||
v4 = stack_addr.i64 ss3 | ||
return v1, v2, v3, v4 | ||
} | ||
|
||
; VCode: | ||
; pushq %rbp | ||
; movq %rsp, %rbp | ||
; movq %rdi, %r10 | ||
; addq %r10, $48, %r10 | ||
; cmpq %rsp, %r10 | ||
; jnbe #trap=stk_ovf | ||
; subq %rsp, $48, %rsp | ||
; block0: | ||
; lea rsp(0 + virtual offset), %rax | ||
; lea rsp(16 + virtual offset), %rdx | ||
; lea rsp(32 + virtual offset), %r8 | ||
; lea rsp(40 + virtual offset), %r9 | ||
; movq %r8, 0(%rsi) | ||
; movq %r9, 8(%rsi) | ||
; addq %rsp, $48, %rsp | ||
; movq %rbp, %rsp | ||
; popq %rbp | ||
; ret | ||
; | ||
; Disassembled: | ||
; block0: ; offset 0x0 | ||
; pushq %rbp | ||
; movq %rsp, %rbp | ||
; movq %rdi, %r10 | ||
; addq $0x30, %r10 | ||
; cmpq %rsp, %r10 | ||
; ja 0x3b | ||
; subq $0x30, %rsp | ||
; block1: ; offset 0x18 | ||
; leaq (%rsp), %rax | ||
; leaq 0x10(%rsp), %rdx | ||
; leaq 0x20(%rsp), %r8 | ||
; leaq 0x28(%rsp), %r9 | ||
; movq %r8, (%rsi) | ||
; movq %r9, 8(%rsi) | ||
; addq $0x30, %rsp | ||
; movq %rbp, %rsp | ||
; popq %rbp | ||
; retq | ||
; ud2 ; trap: stk_ovf | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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