[PATCH] [mips][microMIPS] Change register class for GP register

Zoran Jovanovic zoran.jovanovic at imgtec.com
Fri Feb 27 01:05:32 PST 2015


Hi sstankovic, dsanders,

In order to fix issues with "invalid operand" in microMIPS 16 bit instructions register class of GP register must be changed to GPRMM16RegClass.

http://reviews.llvm.org/D7934

Files:
  lib/Target/Mips/MipsMachineFunction.cpp
  test/CodeGen/Mips/micromips-gp-rc.ll

Index: lib/Target/Mips/MipsMachineFunction.cpp
===================================================================
--- lib/Target/Mips/MipsMachineFunction.cpp
+++ lib/Target/Mips/MipsMachineFunction.cpp
@@ -79,14 +79,19 @@
   if (GlobalBaseReg)
     return GlobalBaseReg;
 
+  MipsSubtarget const &STI =
+      static_cast<const MipsSubtarget &>(MF.getSubtarget());
+
   const TargetRegisterClass *RC =
-      static_cast<const MipsSubtarget &>(MF.getSubtarget()).inMips16Mode()
+      STI.inMips16Mode()
           ? &Mips::CPU16RegsRegClass
-          : static_cast<const MipsTargetMachine &>(MF.getTarget())
-                    .getABI()
-                    .IsN64()
-                ? &Mips::GPR64RegClass
-                : &Mips::GPR32RegClass;
+          : STI.inMicroMipsMode()
+                ? &Mips::GPRMM16RegClass
+                : static_cast<const MipsTargetMachine &>(MF.getTarget())
+                          .getABI()
+                          .IsN64()
+                      ? &Mips::GPR64RegClass
+                      : &Mips::GPR32RegClass;
   return GlobalBaseReg = MF.getRegInfo().createVirtualRegister(RC);
 }
 
Index: test/CodeGen/Mips/micromips-gp-rc.ll
===================================================================
--- /dev/null
+++ test/CodeGen/Mips/micromips-gp-rc.ll
@@ -0,0 +1,18 @@
+; RUN: llc -march=mipsel -mcpu=mips32r2 -mattr=+micromips \
+; RUN:   -relocation-model=pic -O3 < %s | FileCheck %s
+
+ at g = external global i32
+
+; Function Attrs: noreturn nounwind
+define void @foo() #0 {
+entry:
+  %0 = load i32* @g, align 4
+  tail call void @exit(i32 signext %0)
+  unreachable
+}
+
+; Function Attrs: noreturn
+declare void @exit(i32 signext)
+
+; CHECK: move $gp, ${{[0-9]+}}
+

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7934.20835.patch
Type: text/x-patch
Size: 1732 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150227/ecf817f9/attachment.bin>


More information about the llvm-commits mailing list