[PATCH] Allow for constant data to be referenced in Mips-fast-isel

Vasileios Kalintiris Vasileios.Kalintiris at imgtec.com
Wed Apr 29 03:52:36 PDT 2015


Added a simple test-case.


http://reviews.llvm.org/D6767

Files:
  lib/Target/Mips/MipsFastISel.cpp
  test/CodeGen/Mips/Fast-ISel/constexpr-address.ll

Index: lib/Target/Mips/MipsFastISel.cpp
===================================================================
--- lib/Target/Mips/MipsFastISel.cpp
+++ lib/Target/Mips/MipsFastISel.cpp
@@ -390,8 +390,10 @@
       Opcode = I->getOpcode();
       U = I;
     }
-  } else if (isa<ConstantExpr>(Obj))
-    return false;
+  } else if (const ConstantExpr *C = dyn_cast<ConstantExpr>(Obj)) {
+    Opcode = C->getOpcode();
+    U = C;
+  }
   switch (Opcode) {
   default:
     break;
Index: test/CodeGen/Mips/Fast-ISel/constexpr-address.ll
===================================================================
--- /dev/null
+++ test/CodeGen/Mips/Fast-ISel/constexpr-address.ll
@@ -0,0 +1,18 @@
+; RUN: llc -march=mipsel -mcpu=mips32 -relocation-model=pic \
+; RUN:     -fast-isel=true -mips-fast-isel -fast-isel-abort=1 < %s | FileCheck %s
+; RUN: llc -march=mipsel -mcpu=mips32r2 -relocation-model=pic \
+; RUN:     -fast-isel=true -mips-fast-isel -fast-isel-abort=1 < %s | FileCheck %s
+
+ at ARR = external global [10 x i32], align 4
+
+define void @foo() {
+; CHECK-LABEL: foo
+
+; CHECK-DAG:    lw      $[[ARR:[0-9]+]], %got(ARR)({{.*}})
+; CHECK-DAG:    addiu   $[[T0:[0-9]+]], $zero, 12345
+; CHECK:        sw      $[[T0]], 8($[[ARR]])
+
+entry:
+  store i32 12345, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @ARR, i32 0, i32 2), align 4
+  ret void
+}

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6767.24611.patch
Type: text/x-patch
Size: 1355 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150429/a93a6586/attachment.bin>


More information about the llvm-commits mailing list