-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[RISCV][GISEL] Legalize G_VAARG through expansion. #73065
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
da4cd70
[RISCV][GISEL] Legalize G_VAARG through expansion.
michaelmaitland 04f5f01
!fixup pass Ty to builder; remove Align constructor; use buildMaskLow…
michaelmaitland 4c122b9
!fixup clangformat
michaelmaitland 1544292
!fixup use Align instead of MaybeAlign
michaelmaitland 945f779
!fixup clamp scalar
michaelmaitland 0e74d27
!fixup remove observer call; remove HeadOfList
michaelmaitland d8c7063
!fixup cleanup
michaelmaitland d1f8967
!fixup rebase
michaelmaitland ac7697d
!fixup fix MMO and remove observer call
michaelmaitland 896fd70
!fixup drop ir from tests; only call getTypeForLLT once
michaelmaitland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
68 changes: 68 additions & 0 deletions
68
llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-vaarg-rv32.mir
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# RUN: llc -mtriple=riscv32 -run-pass=legalizer %s -o - | FileCheck %s | ||
|
||
# On RISC-V, the MinStackArgumentAlignment is 1 and the ABI Alignment for p0 is | ||
# greater than 1, so we will always generate code to adjust for this alignment. | ||
|
||
--- | | ||
define void @va_arg_i32() { | ||
%va = alloca ptr, align 4 | ||
%1 = va_arg ptr %va, i32 | ||
ret void | ||
} | ||
define void @va_arg_ptr() { | ||
%va = alloca ptr, align 4 | ||
%1 = va_arg ptr %va, ptr | ||
ret void | ||
} | ||
... | ||
--- | ||
name: va_arg_i32 | ||
legalized: false | ||
tracksRegLiveness: true | ||
stack: | ||
- { id: 0, name: va, type: default, offset: 0, size: 4, alignment: 4, | ||
stack-id: default, callee-saved-register: '', callee-saved-restored: true, | ||
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } | ||
body: | | ||
bb.1 (%ir-block.0): | ||
; CHECK-LABEL: name: va_arg_i32 | ||
; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0.va | ||
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(p0) = G_LOAD [[FRAME_INDEX]](p0) :: (load (p0)) | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 3 | ||
; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[LOAD]], [[C]](s32) | ||
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 -4 | ||
; CHECK-NEXT: [[PTRMASK:%[0-9]+]]:_(p0) = G_PTRMASK [[PTR_ADD]], [[C1]](s32) | ||
; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 4 | ||
; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTRMASK]], [[C2]](s32) | ||
; CHECK-NEXT: G_STORE [[PTR_ADD1]](p0), [[FRAME_INDEX]](p0) :: (store (p0)) | ||
; CHECK-NEXT: PseudoRET | ||
%0:_(p0) = G_FRAME_INDEX %stack.0.va | ||
%1:_(s32) = G_VAARG %0(p0), 4 | ||
PseudoRET | ||
... | ||
--- | ||
name: va_arg_ptr | ||
legalized: false | ||
tracksRegLiveness: true | ||
stack: | ||
- { id: 0, name: va, type: default, offset: 0, size: 4, alignment: 4, | ||
stack-id: default, callee-saved-register: '', callee-saved-restored: true, | ||
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } | ||
body: | | ||
bb.1 (%ir-block.0): | ||
; CHECK-LABEL: name: va_arg_ptr | ||
; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0.va | ||
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(p0) = G_LOAD [[FRAME_INDEX]](p0) :: (load (p0)) | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 3 | ||
; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[LOAD]], [[C]](s32) | ||
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 -4 | ||
; CHECK-NEXT: [[PTRMASK:%[0-9]+]]:_(p0) = G_PTRMASK [[PTR_ADD]], [[C1]](s32) | ||
; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 4 | ||
; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTRMASK]], [[C2]](s32) | ||
; CHECK-NEXT: G_STORE [[PTR_ADD1]](p0), [[FRAME_INDEX]](p0) :: (store (p0)) | ||
; CHECK-NEXT: PseudoRET | ||
%0:_(p0) = G_FRAME_INDEX %stack.0.va | ||
%1:_(p0) = G_VAARG %0(p0), 4 | ||
PseudoRET | ||
... |
98 changes: 98 additions & 0 deletions
98
llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-vaarg-rv64.mir
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# RUN: llc -mtriple=riscv64 -run-pass=legalizer %s -o - | FileCheck %s | ||
|
||
# On RISC-V, the MinStackArgumentAlignment is 1 and the ABI Alignment for p0 is | ||
# greater than 1, so we will always generate code to adjust for this alignment. | ||
|
||
--- | | ||
define void @va_arg_i32() { | ||
%va = alloca ptr, align 8 | ||
%1 = va_arg ptr %va, i32 | ||
ret void | ||
} | ||
define void @va_arg_i64() { | ||
%va = alloca ptr, align 8 | ||
%1 = va_arg ptr %va, i32 | ||
ret void | ||
} | ||
define void @va_arg_ptr() { | ||
%va = alloca ptr, align 8 | ||
%1 = va_arg ptr %va, ptr | ||
ret void | ||
} | ||
... | ||
--- | ||
name: va_arg_i32 | ||
legalized: false | ||
tracksRegLiveness: true | ||
stack: | ||
- { id: 0, name: va, type: default, offset: 0, size: 8, alignment: 4, | ||
stack-id: default, callee-saved-register: '', callee-saved-restored: true, | ||
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } | ||
body: | | ||
bb.1 (%ir-block.0): | ||
; CHECK-LABEL: name: va_arg_i32 | ||
; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0.va | ||
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(p0) = G_LOAD [[FRAME_INDEX]](p0) :: (load (p0)) | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 3 | ||
; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[LOAD]], [[C]](s64) | ||
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 -4 | ||
; CHECK-NEXT: [[PTRMASK:%[0-9]+]]:_(p0) = G_PTRMASK [[PTR_ADD]], [[C1]](s64) | ||
; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 4 | ||
; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTRMASK]], [[C2]](s64) | ||
; CHECK-NEXT: G_STORE [[PTR_ADD1]](p0), [[FRAME_INDEX]](p0) :: (store (p0)) | ||
; CHECK-NEXT: PseudoRET | ||
%0:_(p0) = G_FRAME_INDEX %stack.0.va | ||
%1:_(s32) = G_VAARG %0(p0), 4 | ||
PseudoRET | ||
... | ||
--- | ||
name: va_arg_i64 | ||
legalized: false | ||
tracksRegLiveness: true | ||
stack: | ||
- { id: 0, name: va, type: default, offset: 0, size: 8, alignment: 4, | ||
stack-id: default, callee-saved-register: '', callee-saved-restored: true, | ||
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } | ||
body: | | ||
bb.1 (%ir-block.0): | ||
; CHECK-LABEL: name: va_arg_i64 | ||
; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0.va | ||
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(p0) = G_LOAD [[FRAME_INDEX]](p0) :: (load (p0)) | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 3 | ||
; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[LOAD]], [[C]](s64) | ||
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 -4 | ||
; CHECK-NEXT: [[PTRMASK:%[0-9]+]]:_(p0) = G_PTRMASK [[PTR_ADD]], [[C1]](s64) | ||
; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 8 | ||
; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTRMASK]], [[C2]](s64) | ||
; CHECK-NEXT: G_STORE [[PTR_ADD1]](p0), [[FRAME_INDEX]](p0) :: (store (p0)) | ||
; CHECK-NEXT: PseudoRET | ||
%0:_(p0) = G_FRAME_INDEX %stack.0.va | ||
%1:_(s64) = G_VAARG %0(p0), 4 | ||
PseudoRET | ||
... | ||
--- | ||
name: va_arg_ptr | ||
legalized: false | ||
tracksRegLiveness: true | ||
stack: | ||
- { id: 0, name: va, type: default, offset: 0, size: 8, alignment: 4, | ||
stack-id: default, callee-saved-register: '', callee-saved-restored: true, | ||
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } | ||
body: | | ||
bb.1 (%ir-block.0): | ||
; CHECK-LABEL: name: va_arg_ptr | ||
; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0.va | ||
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(p0) = G_LOAD [[FRAME_INDEX]](p0) :: (load (p0)) | ||
; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 3 | ||
; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[LOAD]], [[C]](s64) | ||
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 -4 | ||
; CHECK-NEXT: [[PTRMASK:%[0-9]+]]:_(p0) = G_PTRMASK [[PTR_ADD]], [[C1]](s64) | ||
; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 8 | ||
; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTRMASK]], [[C2]](s64) | ||
; CHECK-NEXT: G_STORE [[PTR_ADD1]](p0), [[FRAME_INDEX]](p0) :: (store (p0)) | ||
; CHECK-NEXT: PseudoRET | ||
%0:_(p0) = G_FRAME_INDEX %stack.0.va | ||
%1:_(s64) = G_VAARG %0(p0), 4 | ||
PseudoRET | ||
... |
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.
Uh oh!
There was an error while loading. Please reload this page.