From: Benjamin Kramer Date: Sun, 23 Feb 2014 21:43:52 +0000 (+0000) Subject: SPARC: Implement TRAP lowering. Matches what GCC emits. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=570d54479911d2c996d7bd506ac5224ef764209a;p=oota-llvm.git SPARC: Implement TRAP lowering. Matches what GCC emits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201994 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/Sparc/SparcISelLowering.cpp b/lib/Target/Sparc/SparcISelLowering.cpp index 32c278b6689..2ac5b7e8c22 100644 --- a/lib/Target/Sparc/SparcISelLowering.cpp +++ b/lib/Target/Sparc/SparcISelLowering.cpp @@ -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); diff --git a/lib/Target/Sparc/SparcInstrInfo.td b/lib/Target/Sparc/SparcInstrInfo.td index 94d2719d20e..ae10ca0bd41 100644 --- a/lib/Target/Sparc/SparcInstrInfo.td +++ b/lib/Target/Sparc/SparcInstrInfo.td @@ -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 index 00000000000..b72a63caeeb --- /dev/null +++ b/test/CodeGen/SPARC/trap.ll @@ -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()