[ARM] GlobalISel: Map G_GLOBAL_VALUE to GPR
authorDiana Picus <diana.picus@linaro.org>
Wed, 26 Jul 2017 11:01:13 +0000 (11:01 +0000)
committerDiana Picus <diana.picus@linaro.org>
Wed, 26 Jul 2017 11:01:13 +0000 (11:01 +0000)
A G_GLOBAL_VALUE is basically a pointer, so it should live in the GPR.

llvm-svn: 309101

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

index 8449302..8bb58c3 100644 (file)
@@ -254,6 +254,7 @@ ARMRegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
   }
   case G_CONSTANT:
   case G_FRAME_INDEX:
+  case G_GLOBAL_VALUE:
     OperandsMapping =
         getOperandsMapping({&ARM::ValueMappings[ARM::GPR3OpsIdx], nullptr});
     break;
index 638c6e6..eb6aabb 100644 (file)
@@ -29,6 +29,9 @@
 
   define void @test_constants() { ret void }
 
+  @a_global = global float 1.0
+  define void @test_globals() { ret void }
+
   define void @test_anyext_s8_32() { ret void }
   define void @test_anyext_s16_32() { ret void }
 
@@ -656,6 +659,22 @@ body:             |
     BX_RET 14, _, implicit %r0
 ...
 ---
+name:            test_globals
+# CHECK-LABEL: name: test_globals
+legalized:       true
+regBankSelected: false
+selected:        false
+# CHECK: registers:
+# CHECK: - { id: 0, class: gprb, preferred-register: '' }
+registers:
+  - { id: 0, class: _ }
+body:             |
+  bb.0:
+    %0(p0) = G_GLOBAL_VALUE @a_global
+    %r0 = COPY %0(p0)
+    BX_RET 14, _, implicit %r0
+...
+---
 name:            test_anyext_s8_32
 # CHECK-LABEL: name: test_anyext_s8_32
 legalized:       true