forked from OSchip/llvm-project
228 lines
5.8 KiB
YAML
228 lines
5.8 KiB
YAML
# RUN: llc -O0 -run-pass=regbankselect -global-isel %s -o - 2>&1 | FileCheck %s
|
|
# REQUIRES: global-isel
|
|
|
|
--- |
|
|
; ModuleID = 'generic-virtual-registers-type-error.mir'
|
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
|
target triple = "aarch64-apple-ios"
|
|
define void @defaultMapping() {
|
|
entry:
|
|
ret void
|
|
}
|
|
define void @defaultMappingVector() {
|
|
entry:
|
|
ret void
|
|
}
|
|
define void @defaultMapping1Repair() {
|
|
entry:
|
|
ret void
|
|
}
|
|
define void @defaultMapping2Repairs() {
|
|
entry:
|
|
ret void
|
|
}
|
|
define void @defaultMappingDefRepair() {
|
|
entry:
|
|
ret void
|
|
}
|
|
define void @phiPropagation(i32* %src, i32* %dst, i1 %cond) {
|
|
entry:
|
|
%srcVal = load i32, i32* %src
|
|
br i1 %cond, label %end, label %then
|
|
then:
|
|
%res = add i32 %srcVal, 36
|
|
br label %end
|
|
end:
|
|
%toStore = phi i32 [ %srcVal, %entry ], [ %res, %then ]
|
|
store i32 %toStore, i32* %dst
|
|
ret void
|
|
}
|
|
define void @defaultMappingUseRepairPhysReg() {
|
|
entry:
|
|
ret void
|
|
}
|
|
define void @defaultMappingDefRepairPhysReg() {
|
|
entry:
|
|
ret void
|
|
}
|
|
...
|
|
|
|
---
|
|
# Check that we assign a relevant register bank for %0.
|
|
# Based on the type i32, this should be gpr.
|
|
name: defaultMapping
|
|
isSSA: true
|
|
# CHECK: registers:
|
|
# CHECK-NEXT: - { id: 0, class: gpr }
|
|
registers:
|
|
- { id: 0, class: _ }
|
|
body: |
|
|
bb.0.entry:
|
|
liveins: %x0
|
|
; CHECK: %0(32) = G_ADD i32 %x0
|
|
%0(32) = G_ADD i32 %x0, %x0
|
|
...
|
|
|
|
---
|
|
# Check that we assign a relevant register bank for %0.
|
|
# Based on the type <2 x i32>, this should be fpr.
|
|
# FPR is used for both floating point and vector registers.
|
|
name: defaultMappingVector
|
|
isSSA: true
|
|
# CHECK: registers:
|
|
# CHECK-NEXT: - { id: 0, class: fpr }
|
|
registers:
|
|
- { id: 0, class: _ }
|
|
body: |
|
|
bb.0.entry:
|
|
liveins: %d0
|
|
; CHECK: %0(32) = G_ADD <2 x i32> %d0
|
|
%0(32) = G_ADD <2 x i32> %d0, %d0
|
|
...
|
|
|
|
---
|
|
# Check that we repair the assignment for %0.
|
|
# Indeed based on the source of the copy it should live
|
|
# in FPR, but at the use, it should be GPR.
|
|
name: defaultMapping1Repair
|
|
isSSA: true
|
|
# CHECK: registers:
|
|
# CHECK-NEXT: - { id: 0, class: fpr }
|
|
# CHECK-NEXT: - { id: 1, class: gpr }
|
|
# CHECK-NEXT: - { id: 2, class: gpr }
|
|
registers:
|
|
- { id: 0, class: _ }
|
|
- { id: 1, class: _ }
|
|
body: |
|
|
bb.0.entry:
|
|
liveins: %s0, %x0
|
|
; CHECK: %0(32) = COPY %s0
|
|
; CHECK-NEXT: %2(32) = COPY %0
|
|
; CHECK-NEXT: %1(32) = G_ADD i32 %2, %x0
|
|
%0(32) = COPY %s0
|
|
%1(32) = G_ADD i32 %0, %x0
|
|
...
|
|
|
|
# Check that we repair the assignment for %0 differently for both uses.
|
|
name: defaultMapping2Repairs
|
|
isSSA: true
|
|
# CHECK: registers:
|
|
# CHECK-NEXT: - { id: 0, class: fpr }
|
|
# CHECK-NEXT: - { id: 1, class: gpr }
|
|
# CHECK-NEXT: - { id: 2, class: gpr }
|
|
# CHECK-NEXT: - { id: 3, class: gpr }
|
|
registers:
|
|
- { id: 0, class: _ }
|
|
- { id: 1, class: _ }
|
|
body: |
|
|
bb.0.entry:
|
|
liveins: %s0, %x0
|
|
; CHECK: %0(32) = COPY %s0
|
|
; CHECK-NEXT: %2(32) = COPY %0
|
|
; CHECK-NEXT: %3(32) = COPY %0
|
|
; CHECK-NEXT: %1(32) = G_ADD i32 %2, %3
|
|
%0(32) = COPY %s0
|
|
%1(32) = G_ADD i32 %0, %0
|
|
...
|
|
|
|
---
|
|
# Check that we repair the definition of %1.
|
|
# %1 is forced to be into FPR, but its definition actually
|
|
# requires that it lives in GPR. Make sure regbankselect
|
|
# fixes that.
|
|
name: defaultMappingDefRepair
|
|
isSSA: true
|
|
# CHECK: registers:
|
|
# CHECK-NEXT: - { id: 0, class: gpr }
|
|
# CHECK-NEXT: - { id: 1, class: fpr }
|
|
# CHECK-NEXT: - { id: 2, class: gpr }
|
|
registers:
|
|
- { id: 0, class: _ }
|
|
- { id: 1, class: fpr }
|
|
body: |
|
|
bb.0.entry:
|
|
liveins: %w0
|
|
; CHECK: %0(32) = COPY %w0
|
|
; CHECK-NEXT: %2(32) = G_ADD i32 %0, %w0
|
|
; CHECK-NEXT: %1(32) = COPY %2
|
|
%0(32) = COPY %w0
|
|
%1(32) = G_ADD i32 %0, %w0
|
|
...
|
|
|
|
---
|
|
# Check that we are able to propagate register banks from phis.
|
|
name: phiPropagation
|
|
isSSA: true
|
|
tracksRegLiveness: true
|
|
# CHECK: registers:
|
|
# CHECK-NEXT: - { id: 0, class: gpr32 }
|
|
# CHECK-NEXT: - { id: 1, class: gpr64sp }
|
|
# CHECK-NEXT: - { id: 2, class: gpr32 }
|
|
# CHECK-NEXT: - { id: 3, class: gpr }
|
|
# CHECK-NEXT: - { id: 4, class: gpr }
|
|
registers:
|
|
- { id: 0, class: gpr32 }
|
|
- { id: 1, class: gpr64sp }
|
|
- { id: 2, class: gpr32 }
|
|
- { id: 3, class: _ }
|
|
- { id: 4, class: _ }
|
|
body: |
|
|
bb.0.entry:
|
|
successors: %bb.2.end, %bb.1.then
|
|
liveins: %x0, %x1, %w2
|
|
|
|
%0 = LDRWui killed %x0, 0 :: (load 4 from %ir.src)
|
|
%1 = COPY %x1
|
|
%2 = COPY %w2
|
|
TBNZW killed %2, 0, %bb.2.end
|
|
|
|
bb.1.then:
|
|
successors: %bb.2.end
|
|
%3(32) = G_ADD i32 %0, %0
|
|
|
|
bb.2.end:
|
|
%4(32) = PHI %0, %bb.0.entry, %3, %bb.1.then
|
|
STRWui killed %4, killed %1, 0 :: (store 4 into %ir.dst)
|
|
RET_ReallyLR
|
|
...
|
|
|
|
---
|
|
# Make sure we can repair physical register uses as well.
|
|
name: defaultMappingUseRepairPhysReg
|
|
isSSA: true
|
|
# CHECK: registers:
|
|
# CHECK-NEXT: - { id: 0, class: gpr }
|
|
# CHECK-NEXT: - { id: 1, class: gpr }
|
|
# CHECK-NEXT: - { id: 2, class: gpr }
|
|
registers:
|
|
- { id: 0, class: _ }
|
|
- { id: 1, class: _ }
|
|
body: |
|
|
bb.0.entry:
|
|
liveins: %w0, %s0
|
|
; CHECK: %0(32) = COPY %w0
|
|
; CHECK-NEXT: %2(32) = COPY %s0
|
|
; CHECK-NEXT: %1(32) = G_ADD i32 %0, %2
|
|
%0(32) = COPY %w0
|
|
%1(32) = G_ADD i32 %0, %s0
|
|
...
|
|
|
|
---
|
|
# Make sure we can repair physical register defs.
|
|
name: defaultMappingDefRepairPhysReg
|
|
isSSA: true
|
|
# CHECK: registers:
|
|
# CHECK-NEXT: - { id: 0, class: gpr }
|
|
# CHECK-NEXT: - { id: 1, class: gpr }
|
|
registers:
|
|
- { id: 0, class: _ }
|
|
body: |
|
|
bb.0.entry:
|
|
liveins: %w0
|
|
; CHECK: %0(32) = COPY %w0
|
|
; CHECK-NEXT: %1(32) = G_ADD i32 %0, %0
|
|
; CHECK-NEXT: %s0 = COPY %1
|
|
%0(32) = COPY %w0
|
|
%s0 = G_ADD i32 %0, %0
|
|
...
|