SPARC: Implement TRAP lowering. Matches what GCC emits.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 23 Feb 2014 21:43:52 +0000 (21:43 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 23 Feb 2014 21:43:52 +0000 (21:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201994 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Sparc/SparcISelLowering.cpp
lib/Target/Sparc/SparcInstrInfo.td
test/CodeGen/SPARC/trap.ll [new file with mode: 0644]

index 32c278b6689f4dc477feeb31eb4d5275e1a37501..2ac5b7e8c22319b9abb26b9e1722b753b19f2ac2 100644 (file)
@@ -1567,6 +1567,8 @@ SparcTargetLowering::SparcTargetLowering(TargetMachine &TM)
   // VAARG needs to be lowered to not do unaligned accesses for doubles.
   setOperationAction(ISD::VAARG             , MVT::Other, Custom);
 
+  setOperationAction(ISD::TRAP              , MVT::Other, Legal);
+
   // Use the default implementation.
   setOperationAction(ISD::VACOPY            , MVT::Other, Expand);
   setOperationAction(ISD::VAEND             , MVT::Other, Expand);
index 94d2719d20ea60d1c7127061f632d2863f0a16f9..ae10ca0bd413618f4d9ad30664669a944ab745ce 100644 (file)
@@ -312,6 +312,9 @@ let hasSideEffects = 1, mayStore = 1 in {
                    [(flushw)]>;
 }
 
+let isBarrier = 1, isTerminator = 1, rd = 0b1000, rs1 = 0, simm13 = 5 in
+  def TA5 : F3_2<0b10, 0b111010, (outs), (ins), "ta 5", [(trap)]>;
+
 let rd = 0 in
   def UNIMP : F2_1<0b000, (outs), (ins i32imm:$val),
                   "unimp $val", []>;
diff --git a/test/CodeGen/SPARC/trap.ll b/test/CodeGen/SPARC/trap.ll
new file mode 100644 (file)
index 0000000..b72a63c
--- /dev/null
@@ -0,0 +1,11 @@
+; RUN: llc -mtriple=sparc-linux-gnu < %s -show-mc-encoding | FileCheck %s
+
+define void @test1() {
+  tail call void @llvm.trap()
+  unreachable
+
+; CHECK-LABEL: test1:
+; CHECK: ta 5 ! encoding: [0x91,0xd0,0x20,0x05]
+}
+
+declare void @llvm.trap()