From c594f39acb4f9f90e5e9ada6fc88a105ee652c8d Mon Sep 17 00:00:00 2001 From: Venkatraman Govindaraju Date: Sun, 2 Mar 2014 23:39:07 +0000 Subject: [PATCH] [Sparc] Add trap on integer condition codes (Ticc) instructions to Sparc backend. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202670 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Sparc/SparcInstr64Bit.td | 3 ++ lib/Target/Sparc/SparcInstrAliases.td | 56 ++++++++++++++++++++++- lib/Target/Sparc/SparcInstrFormats.td | 31 +++++++++++++ lib/Target/Sparc/SparcInstrInfo.td | 12 +++++ test/MC/Sparc/sparc64-ctrl-instructions.s | 7 +++ 5 files changed, 108 insertions(+), 1 deletion(-) diff --git a/lib/Target/Sparc/SparcInstr64Bit.td b/lib/Target/Sparc/SparcInstr64Bit.td index 9ac0e806171..a34ce262af5 100644 --- a/lib/Target/Sparc/SparcInstr64Bit.td +++ b/lib/Target/Sparc/SparcInstr64Bit.td @@ -542,6 +542,9 @@ def ATOMIC_SWAP_64 : Pseudo<(outs I64Regs:$rd), [(set i64:$rd, (atomic_swap_64 iPTR:$addr, i64:$rs2))]>; +let Predicates = [Is64Bit], hasSideEffects = 1, Uses = [ICC], cc = 0b10 in + defm TXCC : TRAP<"%xcc">; + // Global addresses, constant pool entries let Predicates = [Is64Bit] in { diff --git a/lib/Target/Sparc/SparcInstrAliases.td b/lib/Target/Sparc/SparcInstrAliases.td index 974fa849f22..33c2aa10236 100644 --- a/lib/Target/Sparc/SparcInstrAliases.td +++ b/lib/Target/Sparc/SparcInstrAliases.td @@ -136,6 +136,59 @@ multiclass int_cond_alias { (FMOVQ_XCC QFPRegs:$rd, QFPRegs:$rs2, condVal)>, Requires<[Is64Bit, HasHardQuad]>; + // t %icc, rs1 + rs2 + def : InstAlias, + Requires<[HasV9]>; + + // t %icc, rs => t %icc, G0 + rs + def : InstAlias, + Requires<[HasV9]>; + + // t %xcc, rs1 + rs2 + def : InstAlias, + Requires<[HasV9]>; + + // t %xcc, rs => t %xcc, G0 + rs + def : InstAlias, + Requires<[HasV9]>; + + // t rs1 + rs2 => t %icc, rs1 + rs2 + def : InstAlias; + + // t rs=> t %icc, G0 + rs2 + def : InstAlias; + + // t %icc, rs1 + imm + def : InstAlias, + Requires<[HasV9]>; + // t %icc, imm => t %icc, G0 + imm + def : InstAlias, + Requires<[HasV9]>; + // t %xcc, rs1 + imm + def : InstAlias, + Requires<[HasV9]>; + // t %xcc, imm => t %xcc, G0 + imm + def : InstAlias, + Requires<[HasV9]>; + + // t rs1 + imm => t %icc, rs1 + imm + def : InstAlias; + + // t imm => t %icc, G0 + imm + def : InstAlias; + } @@ -177,7 +230,8 @@ multiclass fp_cond_alias { // fb,a,pn %fcc0, $imm def : InstAlias, Requires<[HasV9]>; + (BPFCCANT brtarget:$imm, condVal, FCCRegs:$cc)>, + Requires<[HasV9]>; defm : fpcond_mov_alias op3, bits<3> rcond, dag outs, dag ins, let Inst{12-10} = rcond; let Inst{9-0} = simm10; } + + +class TRAPSP op3Val, bit isimm, dag outs, dag ins, string asmstr, + list pattern>: F3 { + + bits<4> cond; + bits<2> cc; + + let op = 0b10; + let rd{4} = 0; + let rd{3-0} = cond; + let op3 = op3Val; + let Inst{13} = isimm; + let Inst{12-11} = cc; + +} + +class TRAPSPrr op3Val, dag outs, dag ins, string asmstr, + list pattern>: TRAPSP { + bits<5> rs2; + + let Inst{10-5} = 0; + let Inst{4-0} = rs2; +} +class TRAPSPri op3Val, dag outs, dag ins, string asmstr, + list pattern>: TRAPSP { + bits<8> imm; + + let Inst{10-8} = 0; + let Inst{7-0} = imm; +} diff --git a/lib/Target/Sparc/SparcInstrInfo.td b/lib/Target/Sparc/SparcInstrInfo.td index 9de8f3790d5..fe3227e26b8 100644 --- a/lib/Target/Sparc/SparcInstrInfo.td +++ b/lib/Target/Sparc/SparcInstrInfo.td @@ -1136,6 +1136,18 @@ let hasSideEffects = 1 in { } } +multiclass TRAP { + def rr : TRAPSPrr<0b111010, (outs), (ins IntRegs:$rs1, IntRegs:$rs2, + CCOp:$cond), + !strconcat(!strconcat("t$cond ", regStr), ", $rs1 + $rs2"), []>; + def ri : TRAPSPri<0b111010, (outs), (ins IntRegs:$rs1, i32imm:$imm, + CCOp:$cond), + !strconcat(!strconcat("t$cond ", regStr), ", $rs1 + $imm"), []>; +} + +let hasSideEffects = 1, Uses = [ICC], cc = 0b00 in + defm TICC : TRAP<"%icc">; + //===----------------------------------------------------------------------===// // Non-Instruction Patterns //===----------------------------------------------------------------------===// diff --git a/test/MC/Sparc/sparc64-ctrl-instructions.s b/test/MC/Sparc/sparc64-ctrl-instructions.s index 1484e0c84c1..65bca2990f1 100644 --- a/test/MC/Sparc/sparc64-ctrl-instructions.s +++ b/test/MC/Sparc/sparc64-ctrl-instructions.s @@ -1217,3 +1217,10 @@ ! CHECK: rett %i7+8 ! encoding: [0x81,0xcf,0xe0,0x08] return %i7 + 8 + + ! CHECK: ta %icc, %g0 + 5 ! encoding: [0x91,0xd0,0x20,0x05] + ta 5 + + ! CHECK: te %xcc, %g0 + 3 ! encoding: [0x83,0xd0,0x30,0x03] + te %xcc, 3 + -- 2.34.1