[Sparc] Generate ta 1 for the @llvm.debugtrap intrinsic
authorDaniel Cederman <cederman@gaisler.com>
Mon, 16 Jul 2018 12:16:53 +0000 (12:16 +0000)
committerDaniel Cederman <cederman@gaisler.com>
Mon, 16 Jul 2018 12:16:53 +0000 (12:16 +0000)
Summary: Software trap number one is the trap used for breakpoints
in the Sparc ABI.

Reviewers: jyknight, venkatra

Reviewed By: jyknight

Subscribers: fedor.sergeev, jrtc27, llvm-commits

Differential Revision: https://reviews.llvm.org/D48637

llvm-svn: 337163

llvm/lib/Target/Sparc/SparcISelLowering.cpp
llvm/lib/Target/Sparc/SparcInstrInfo.td
llvm/test/CodeGen/SPARC/trap.ll

index 14a99c0..1a42b23 100644 (file)
@@ -1727,6 +1727,7 @@ SparcTargetLowering::SparcTargetLowering(const TargetMachine &TM,
   setOperationAction(ISD::VAARG             , MVT::Other, Custom);
 
   setOperationAction(ISD::TRAP              , MVT::Other, Legal);
+  setOperationAction(ISD::DEBUGTRAP         , MVT::Other, Legal);
 
   // Use the default implementation.
   setOperationAction(ISD::VACOPY            , MVT::Other, Expand);
index ad00c83..7541e3e 100644 (file)
@@ -1009,6 +1009,9 @@ let DecoderNamespace = "SparcV9", DecoderMethod = "DecodeTRAP", Predicates = [Ha
 let isBarrier = 1, isTerminator = 1, rd = 0b01000, rs1 = 0, simm13 = 5 in
   def TA5 : F3_2<0b10, 0b111010, (outs), (ins), "ta 5", [(trap)]>;
 
+def : Pat<(debugtrap),
+  (TRAPri (i32 G0), (i32 1), (i32 8))>;
+
 // Section B.28 - Read State Register Instructions
 let rs2 = 0 in
   def RDASR : F3_1<2, 0b101000,
index b72a63c..c2f66ca 100644 (file)
@@ -9,3 +9,13 @@ define void @test1() {
 }
 
 declare void @llvm.trap()
+
+; CHECK-LABEL: testdebugtrap:
+; CHECK: ta 1 ! encoding: [0x91,0xd0,0x20,0x01]
+define void @testdebugtrap() {
+entry:
+  call void @llvm.debugtrap()
+  ret void
+}
+
+declare void @llvm.debugtrap()