[PATCH] D17373: [mips][microMIPS] Prevent usage of OR16_MMR6 instruction when code for microMIPS is generated.

Daniel Sanders via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 19 03:22:51 PST 2016


dsanders added inline comments.

================
Comment at: lib/Target/Mips/MicroMips32r6InstrInfo.td:814-815
@@ -813,4 +813,4 @@
 class NOT16_MMR6_DESC : NotMM16<"not16", GPRMM16Opnd>, MMR6Arch<"not16">;
 class OR16_MMR6_DESC : LogicRMM16<"or16", GPRMM16Opnd, II_OR, or>,
-      MMR6Arch<"or16">;
+      MMR6Arch<"or16">, MicroMipsR6Inst16;
 class SLL16_MMR6_DESC : ShiftIMM16<"sll16", uimm3_shift, GPRMM16Opnd, II_SLL>,
----------------
Can you put it on POOL16C_OR16_XOR16_FM_MMR6 instead?

(The other examples of MicroMipsR6Inst16 in this file are in the wrong place too)

================
Comment at: test/CodeGen/Mips/micromips-or16.ll:3-43
@@ -2,2 +2,43 @@
 ; RUN:   -relocation-model=pic -O3 < %s | FileCheck %s
+; RUN: llc -O0 -march=mips -mcpu=mips32r2 -mattr=+micromips \
+; RUN:  -asm-show-inst < %s | FileCheck %s
+
+%class.ContextMap1 = type { i8 }
+ at pos = global i32 0, align 4
+declare i32 @_Z3minii(i32 signext %a, i32 signext %b)
+declare void @_ZN11ContextMap1C2Ev(%class.ContextMap1* %this)
+declare void @_ZN11ContextMap13setEi(%class.ContextMap1* %this, i32 signext %i)
+
+define i32 @f(i32 signext %argc, i8** %argv) {
+entry:
+  %retval = alloca i32, align 4
+  %argc.addr = alloca i32, align 4
+  %argv.addr = alloca i8**, align 4
+  %cr = alloca %class.ContextMap1, align 1
+  %bpos = alloca i32, align 4
+  %c = alloca i32, align 4
+  store i32 0, i32* %retval, align 4
+  store i32 %argc, i32* %argc.addr, align 4
+  store i8** %argv, i8*** %argv.addr, align 4
+  call void @_ZN11ContextMap1C2Ev(%class.ContextMap1* %cr)
+  %0 = load i32, i32* %bpos, align 4
+  %cmp = icmp eq i32 %0, 0
+  br i1 %cmp, label %if.then, label %if.end
+
+if.then:                                          ; preds = %entry
+; CHECK-LABEL: f
+; CHECK-NOT: OR16_MMR6
+  store i32 255, i32* %c, align 4
+  %1 = load i32, i32* @pos, align 4
+  %call = call i32 @_Z3minii(i32 signext %1, i32 signext 255)
+  %2 = load i32, i32* %c, align 4
+  %shl = shl i32 %2, 8
+  %add = add nsw i32 %shl, 234567
+  %or = or i32 %call, %add
+  call void @_ZN11ContextMap13setEi(%class.ContextMap1* %cr, i32 signext %or)
+  br label %if.end
+
+if.end:                                           ; preds = %if.then, %entry
+  ret i32 0
+}
 
----------------
This should be sufficient:
  define i32 @f(i32 signext %a, i32 signext %b) {
    %1 = or i32 %a, %b
    ret i32 %1
  }
  ; CHECK-LABEL: f:
  ; CHECK-NOT: OR16_MMR6


http://reviews.llvm.org/D17373





More information about the llvm-commits mailing list