]> granicus.if.org Git - llvm/commitdiff
[ARM] GlobalISel: Support SP in regbankselect
authorDiana Picus <diana.picus@linaro.org>
Mon, 13 Mar 2017 14:28:34 +0000 (14:28 +0000)
committerDiana Picus <diana.picus@linaro.org>
Mon, 13 Mar 2017 14:28:34 +0000 (14:28 +0000)
We used to hit an unreachable in getRegBankFromRegClass when dealing with the
stack pointer. This commit adds support for the GPRsp reg class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297621 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMRegisterBankInfo.cpp
test/CodeGen/ARM/GlobalISel/arm-regbankselect.mir

index 8eb13235de1a41c98babaea9b604207ac477957f..08f3da7388684cdebe20e1d285817719d432bad7 100644 (file)
@@ -180,6 +180,7 @@ const RegisterBank &ARMRegisterBankInfo::getRegBankFromRegClass(
   switch (RC.getID()) {
   case GPRRegClassID:
   case GPRnopcRegClassID:
+  case GPRspRegClassID:
   case tGPR_and_tcGPRRegClassID:
   case tGPRRegClassID:
     return getRegBank(ARM::GPRRegBankID);
index b06a5b6fa4f3d5869a8ed87122090fcb0067d527..fbf8d81322f8f3767f4aaf98389aeb3c578a2810 100644 (file)
@@ -8,6 +8,8 @@
   define void @test_loads() #0 { ret void }
   define void @test_stores() #0 { ret void }
 
+  define void @test_stack() { ret void }
+
   define void @test_gep() { ret void }
 
   define void @test_constants() { ret void }
@@ -200,6 +202,39 @@ body:             |
     G_STORE %6(s64), %0 :: (store 8)
     BX_RET 14, _, implicit %r0
 
+...
+---
+name:            test_stack
+# CHECK-LABEL: name: test_stack
+legalized:       true
+regBankSelected: false
+selected:        false
+# CHECK: registers:
+# CHECK: - { id: 0, class: gprb }
+# CHECK: - { id: 1, class: gprb }
+# CHECK: - { id: 2, class: gprb }
+# CHECK: - { id: 3, class: gprb }
+# CHECK: - { id: 4, class: gprb }
+registers:
+  - { id: 0, class: _ }
+  - { id: 1, class: _ }
+  - { id: 2, class: _ }
+  - { id: 3, class: _ }
+  - { id: 4, class: _ }
+fixedStack:
+  - { id: 0, offset: 0, size: 4, alignment: 4, isImmutable: true, isAliased: false }
+body:             |
+  bb.0:
+    %0(p0) = G_FRAME_INDEX %fixed-stack.0
+    %1(s32) = G_LOAD %0(p0) :: (load 4 from %fixed-stack.0, align 0)
+
+    %2(p0) = COPY %sp
+    %3(s32) = G_CONSTANT i32 8
+    %4(p0) = G_GEP %2, %3(s32)
+    G_STORE %1(s32), %4(p0) :: (store 4)
+
+    BX_RET 14, _
+
 ...
 ---
 name:            test_gep