[mips] Implement llvm.trap intrinsic.
authorAkira Hatanaka <ahatanaka@mips.com>
Fri, 26 Jul 2013 20:58:55 +0000 (20:58 +0000)
committerAkira Hatanaka <ahatanaka@mips.com>
Fri, 26 Jul 2013 20:58:55 +0000 (20:58 +0000)
Patch by Sasa Stankovic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187244 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/MipsISelLowering.cpp
lib/Target/Mips/MipsInstrInfo.td
test/CodeGen/Mips/trap.ll [new file with mode: 0644]

index 8bf4249af1e5d37343bae9d14f44bd3d373aab05..b6b4c2ab02d3f566f951bd95de29a4871079babc 100644 (file)
@@ -385,6 +385,8 @@ MipsTargetLowering(MipsTargetMachine &TM)
     setTruncStoreAction(MVT::i64, MVT::i32, Custom);
   }
 
+  setOperationAction(ISD::TRAP, MVT::Other, Legal);
+
   setTargetDAGCombine(ISD::SDIVREM);
   setTargetDAGCombine(ISD::UDIVREM);
   setTargetDAGCombine(ISD::SELECT);
index 5e2c68744a5e2c009d06ecb41137eb53680c5f66..83afcce98a98a64e20a1dc2d9fe7ea2a1f73f638 100644 (file)
@@ -826,6 +826,11 @@ class SCBase<string opstr, RegisterOperand RO, Operand Mem> :
 class MFC3OP<dag outs, dag ins, string asmstr> :
   InstSE<outs, ins, asmstr, [], NoItinerary, FrmFR>;
 
+let isBarrier = 1, isTerminator = 1, isCodeGenOnly = 1 in
+def TRAP : InstSE<(outs), (ins), "break", [(trap)], NoItinerary, FrmOther> {
+   let Inst = 0x0000000d;
+}
+
 //===----------------------------------------------------------------------===//
 // Pseudo instructions
 //===----------------------------------------------------------------------===//
diff --git a/test/CodeGen/Mips/trap.ll b/test/CodeGen/Mips/trap.ll
new file mode 100644 (file)
index 0000000..beb4b89
--- /dev/null
@@ -0,0 +1,11 @@
+; RUN: llc -march=mipsel -mcpu=mips32 < %s | FileCheck %s
+
+declare void @llvm.trap()
+
+define void @f1() {
+entry:
+  call void @llvm.trap()
+  unreachable
+
+; CHECK:        break
+}