-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[AArch64][SME] Fixup ABI routine insertion points to avoid clobbering NZCV #161353
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 all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
227 changes: 227 additions & 0 deletions
227
llvm/test/CodeGen/AArch64/machine-sme-abi-find-insert-pt.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,227 @@ | ||
| # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 6 | ||
| # RUN: llc -mtriple=aarch64 -mattr=+sve -mattr=+sme -run-pass=aarch64-machine-sme-abi -verify-machineinstrs %s -o - | FileCheck %s | ||
|
|
||
| --- | | ||
| ; Test moving a state change to be before a $nzcv def | ||
| define void @move_before_nzcv_def() "aarch64_inout_za" { ret void } | ||
|
|
||
| ; Test moving a state change to a point where $x0 is live | ||
| define void @move_to_x0_live() "aarch64_inout_za" { ret void } | ||
|
|
||
| ; Test we don't move before a previous state change. | ||
| define void @do_not_move_before_prior_state_change() "aarch64_za_state_agnostic" { ret void } | ||
|
|
||
| ; Test we don't move into a call sequence. | ||
| define void @do_not_move_into_call() "aarch64_inout_za" { ret void } | ||
|
|
||
| declare void @clobber() | ||
| declare void @inout_call() "aarch64_inout_za" | ||
| ... | ||
| --- | ||
| name: move_before_nzcv_def | ||
| tracksRegLiveness: true | ||
| isSSA: true | ||
| noVRegs: false | ||
| body: | | ||
| bb.0: | ||
|
|
||
| ; CHECK-LABEL: name: move_before_nzcv_def | ||
| ; CHECK: [[RDSVLI_XI:%[0-9]+]]:gpr64 = RDSVLI_XI 1, implicit $vg | ||
| ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $sp | ||
| ; CHECK-NEXT: [[MSUBXrrr:%[0-9]+]]:gpr64 = MSUBXrrr [[RDSVLI_XI]], [[RDSVLI_XI]], [[COPY]] | ||
| ; CHECK-NEXT: $sp = COPY [[MSUBXrrr]] | ||
| ; CHECK-NEXT: STPXi [[MSUBXrrr]], [[RDSVLI_XI]], %stack.0, 0 | ||
| ; CHECK-NEXT: [[ADDXri:%[0-9]+]]:gpr64sp = ADDXri %stack.0, 0, 0 | ||
| ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY [[ADDXri]] | ||
| ; CHECK-NEXT: MSR 56965, [[COPY1]] | ||
| ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp | ||
| ; CHECK-NEXT: RequiresZASavePseudo | ||
| ; CHECK-NEXT: BL @clobber, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp | ||
| ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp | ||
| ; CHECK-NEXT: MSRpstatesvcrImm1 2, 1, implicit-def $nzcv | ||
| ; CHECK-NEXT: [[MRS:%[0-9]+]]:gpr64 = MRS 56965, implicit-def $nzcv | ||
| ; CHECK-NEXT: $x0 = ADDXri %stack.0, 0, 0 | ||
| ; CHECK-NEXT: RestoreZAPseudo [[MRS]], $x0, &__arm_tpidr2_restore, csr_aarch64_sme_abi_support_routines_preservemost_from_x0 | ||
| ; CHECK-NEXT: MSR 56965, $xzr | ||
| ; CHECK-NEXT: $nzcv = IMPLICIT_DEF | ||
| ; CHECK-NEXT: $zab0 = IMPLICIT_DEF | ||
| ; CHECK-NEXT: FAKE_USE $nzcv | ||
| ; CHECK-NEXT: RET_ReallyLR | ||
| ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp | ||
| RequiresZASavePseudo | ||
| BL @clobber, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp | ||
| ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp | ||
|
|
||
| $nzcv = IMPLICIT_DEF | ||
| $zab0 = IMPLICIT_DEF | ||
| FAKE_USE $nzcv | ||
|
|
||
| RET_ReallyLR | ||
| ... | ||
| --- | ||
| name: move_to_x0_live | ||
| tracksRegLiveness: true | ||
| isSSA: true | ||
| noVRegs: false | ||
| body: | | ||
| bb.0: | ||
|
|
||
| ; CHECK-LABEL: name: move_to_x0_live | ||
| ; CHECK: [[RDSVLI_XI:%[0-9]+]]:gpr64 = RDSVLI_XI 1, implicit $vg | ||
| ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $sp | ||
| ; CHECK-NEXT: [[MSUBXrrr:%[0-9]+]]:gpr64 = MSUBXrrr [[RDSVLI_XI]], [[RDSVLI_XI]], [[COPY]] | ||
| ; CHECK-NEXT: $sp = COPY [[MSUBXrrr]] | ||
| ; CHECK-NEXT: STPXi [[MSUBXrrr]], [[RDSVLI_XI]], %stack.0, 0 | ||
| ; CHECK-NEXT: [[ADDXri:%[0-9]+]]:gpr64sp = ADDXri %stack.0, 0, 0 | ||
| ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY [[ADDXri]] | ||
| ; CHECK-NEXT: MSR 56965, [[COPY1]] | ||
| ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp | ||
| ; CHECK-NEXT: RequiresZASavePseudo | ||
| ; CHECK-NEXT: BL @clobber, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp | ||
| ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp | ||
| ; CHECK-NEXT: $x0 = IMPLICIT_DEF | ||
| ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr64 = COPY $x0 | ||
| ; CHECK-NEXT: MSRpstatesvcrImm1 2, 1, implicit-def $nzcv | ||
| ; CHECK-NEXT: [[MRS:%[0-9]+]]:gpr64 = MRS 56965, implicit-def $nzcv | ||
| ; CHECK-NEXT: $x0 = ADDXri %stack.0, 0, 0 | ||
| ; CHECK-NEXT: RestoreZAPseudo [[MRS]], $x0, &__arm_tpidr2_restore, csr_aarch64_sme_abi_support_routines_preservemost_from_x0 | ||
| ; CHECK-NEXT: MSR 56965, $xzr | ||
| ; CHECK-NEXT: $x0 = COPY [[COPY2]] | ||
| ; CHECK-NEXT: $nzcv = IMPLICIT_DEF | ||
| ; CHECK-NEXT: FAKE_USE $x0 | ||
| ; CHECK-NEXT: $zab0 = IMPLICIT_DEF | ||
| ; CHECK-NEXT: FAKE_USE $nzcv | ||
| ; CHECK-NEXT: RET_ReallyLR | ||
| ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp | ||
| RequiresZASavePseudo | ||
| BL @clobber, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp | ||
| ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp | ||
|
|
||
| $x0 = IMPLICIT_DEF | ||
|
|
||
| $nzcv = IMPLICIT_DEF | ||
| FAKE_USE $x0 | ||
|
|
||
| $zab0 = IMPLICIT_DEF | ||
| FAKE_USE $nzcv | ||
|
|
||
| RET_ReallyLR | ||
| ... | ||
| --- | ||
| name: do_not_move_before_prior_state_change | ||
| tracksRegLiveness: true | ||
| isSSA: true | ||
| noVRegs: false | ||
| body: | | ||
| ; CHECK-LABEL: name: do_not_move_before_prior_state_change | ||
| ; CHECK: bb.0: | ||
| ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000) | ||
| ; CHECK-NEXT: {{ $}} | ||
| ; CHECK-NEXT: BL &__arm_sme_state_size, csr_aarch64_sme_abi_support_routines_preservemost_from_x1, implicit-def $lr, implicit $sp, implicit-def $x0 | ||
| ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 | ||
| ; CHECK-NEXT: $sp = SUBXrx64 $sp, [[COPY]], 24 | ||
| ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY $sp | ||
| ; CHECK-NEXT: $nzcv = IMPLICIT_DEF | ||
| ; CHECK-NEXT: $zab0 = IMPLICIT_DEF | ||
| ; CHECK-NEXT: [[MRS:%[0-9]+]]:gpr64 = MRS 55824, implicit-def $nzcv, implicit $nzcv | ||
| ; CHECK-NEXT: $x0 = COPY [[COPY1]] | ||
| ; CHECK-NEXT: BL &__arm_sme_save, csr_aarch64_sme_abi_support_routines_preservemost_from_x1, implicit-def $lr, implicit $sp, implicit $x0 | ||
| ; CHECK-NEXT: MSR 55824, [[MRS]], implicit-def $nzcv | ||
| ; CHECK-NEXT: Bcc 2, %bb.1, implicit $nzcv | ||
| ; CHECK-NEXT: B %bb.2 | ||
| ; CHECK-NEXT: {{ $}} | ||
| ; CHECK-NEXT: bb.1: | ||
| ; CHECK-NEXT: liveins: $nzcv | ||
| ; CHECK-NEXT: {{ $}} | ||
| ; CHECK-NEXT: FAKE_USE $nzcv | ||
| ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp | ||
| ; CHECK-NEXT: RequiresZASavePseudo | ||
| ; CHECK-NEXT: BL @clobber, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp | ||
| ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp | ||
| ; CHECK-NEXT: $x0 = COPY [[COPY1]] | ||
| ; CHECK-NEXT: BL &__arm_sme_restore, csr_aarch64_sme_abi_support_routines_preservemost_from_x1, implicit-def $lr, implicit $sp, implicit $x0 | ||
| ; CHECK-NEXT: RET_ReallyLR | ||
| ; CHECK-NEXT: {{ $}} | ||
| ; CHECK-NEXT: bb.2: | ||
| ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp | ||
| ; CHECK-NEXT: RequiresZASavePseudo | ||
| ; CHECK-NEXT: BL @clobber, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp | ||
| ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp | ||
| ; CHECK-NEXT: $x0 = COPY [[COPY1]] | ||
| ; CHECK-NEXT: BL &__arm_sme_restore, csr_aarch64_sme_abi_support_routines_preservemost_from_x1, implicit-def $lr, implicit $sp, implicit $x0 | ||
| ; CHECK-NEXT: RET_ReallyLR | ||
| bb.0: | ||
| successors: %bb.1, %bb.2 | ||
|
|
||
| ; The insertion point can move before the $nzcv def (as that would require | ||
| ; moving before a $zab0 def -- that requires the ACTIVE state). | ||
| $nzcv = IMPLICIT_DEF | ||
| $zab0 = IMPLICIT_DEF | ||
| Bcc 2, %bb.1, implicit $nzcv | ||
| B %bb.2 | ||
| ; bb.1 and bb.2 both require ZA saved on entry (to force bb.0's exit bundle to | ||
| ; pick the LOCAL_SAVED state). | ||
| bb.1: | ||
| liveins: $nzcv | ||
| FAKE_USE $nzcv | ||
|
|
||
| ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp | ||
| RequiresZASavePseudo | ||
| BL @clobber, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp | ||
| ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp | ||
|
|
||
| RET_ReallyLR | ||
| bb.2: | ||
| ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp | ||
| RequiresZASavePseudo | ||
| BL @clobber, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp | ||
| ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp | ||
|
|
||
| RET_ReallyLR | ||
| ... | ||
| --- | ||
| name: do_not_move_into_call | ||
| tracksRegLiveness: true | ||
| isSSA: true | ||
| noVRegs: false | ||
| body: | | ||
| bb.0: | ||
|
|
||
| ; CHECK-LABEL: name: do_not_move_into_call | ||
| ; CHECK: [[RDSVLI_XI:%[0-9]+]]:gpr64 = RDSVLI_XI 1, implicit $vg | ||
| ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $sp | ||
| ; CHECK-NEXT: [[MSUBXrrr:%[0-9]+]]:gpr64 = MSUBXrrr [[RDSVLI_XI]], [[RDSVLI_XI]], [[COPY]] | ||
| ; CHECK-NEXT: $sp = COPY [[MSUBXrrr]] | ||
| ; CHECK-NEXT: STPXi [[MSUBXrrr]], [[RDSVLI_XI]], %stack.0, 0 | ||
| ; CHECK-NEXT: [[ADDXri:%[0-9]+]]:gpr64sp = ADDXri %stack.0, 0, 0 | ||
| ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY [[ADDXri]] | ||
| ; CHECK-NEXT: MSR 56965, [[COPY1]] | ||
| ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp | ||
| ; CHECK-NEXT: RequiresZASavePseudo | ||
| ; CHECK-NEXT: BL @clobber, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp | ||
| ; CHECK-NEXT: $nzcv = IMPLICIT_DEF | ||
| ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp | ||
| ; CHECK-NEXT: [[MRS:%[0-9]+]]:gpr64 = MRS 55824, implicit-def $nzcv, implicit $nzcv | ||
| ; CHECK-NEXT: MSRpstatesvcrImm1 2, 1, implicit-def $nzcv | ||
| ; CHECK-NEXT: [[MRS1:%[0-9]+]]:gpr64 = MRS 56965, implicit-def $nzcv | ||
| ; CHECK-NEXT: $x0 = ADDXri %stack.0, 0, 0 | ||
| ; CHECK-NEXT: RestoreZAPseudo [[MRS1]], $x0, &__arm_tpidr2_restore, csr_aarch64_sme_abi_support_routines_preservemost_from_x0 | ||
| ; CHECK-NEXT: MSR 56965, $xzr | ||
| ; CHECK-NEXT: MSR 55824, [[MRS]], implicit-def $nzcv | ||
| ; CHECK-NEXT: $zab0 = IMPLICIT_DEF | ||
| ; CHECK-NEXT: FAKE_USE $nzcv | ||
| ; CHECK-NEXT: RET_ReallyLR | ||
| ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp | ||
| RequiresZASavePseudo | ||
| BL @clobber, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp | ||
|
|
||
| ; This is artificial test where NZCV is def'd inside a call, so we can't | ||
| ; move the insert point before it's definition. | ||
| $nzcv = IMPLICIT_DEF | ||
| ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp | ||
|
|
||
| $zab0 = IMPLICIT_DEF | ||
| FAKE_USE $nzcv | ||
|
|
||
| RET_ReallyLR | ||
| ... |
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
Oops, something went wrong.
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.