OSDN Git Service

[ARM] GlobalISel: Mark G_GLOBAL_VALUE as legal
authorDiana Picus <diana.picus@linaro.org>
Wed, 26 Jul 2017 09:25:15 +0000 (09:25 +0000)
committerDiana Picus <diana.picus@linaro.org>
Wed, 26 Jul 2017 09:25:15 +0000 (09:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309090 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMLegalizerInfo.cpp
test/CodeGen/ARM/GlobalISel/arm-legalizer.mir

index 1c17c07..2302e7e 100644 (file)
@@ -43,6 +43,7 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
   const LLT s32 = LLT::scalar(32);
   const LLT s64 = LLT::scalar(64);
 
+  setAction({G_GLOBAL_VALUE, p0}, Legal);
   setAction({G_FRAME_INDEX, p0}, Legal);
 
   for (unsigned Op : {G_LOAD, G_STORE}) {
index 616f29d..1fb7c79 100644 (file)
@@ -47,6 +47,9 @@
   define void @test_fadd_s32() #0 { ret void }
   define void @test_fadd_s64() #0 { ret void }
 
+  @a_global = global i32 42
+  define void @test_global_variable() { ret void }
+
   attributes #0 = { "target-features"="+vfp2" }
 ...
 ---
@@ -948,3 +951,26 @@ body:             |
     BX_RET 14, _, implicit %d0
 
 ...
+---
+name:            test_global_variable
+# CHECK-LABEL: name: test_global_variable
+legalized:       false
+# CHECK: legalized: true
+regBankSelected: false
+selected:        false
+tracksRegLiveness: true
+registers:
+  - { id: 0, class: _ }
+  - { id: 1, class: _ }
+body:             |
+  bb.0:
+    liveins: %r0
+
+    %0(s32) = COPY %r0
+    %1(p0) = G_GLOBAL_VALUE @a_global
+    ; G_GLOBAL_VALUE is legal, so we should find it unchanged in the output
+    ; CHECK: {{%[0-9]+}}(p0) = G_GLOBAL_VALUE @a_global
+    %r0 = COPY %1(p0)
+    BX_RET 14, _, implicit %r0
+
+...