diff --git a/llvm/lib/Target/PowerPC/PPCInstrFormats.td b/llvm/lib/Target/PowerPC/PPCInstrFormats.td --- a/llvm/lib/Target/PowerPC/PPCInstrFormats.td +++ b/llvm/lib/Target/PowerPC/PPCInstrFormats.td @@ -512,6 +512,31 @@ let B = 0; } +class XForm_tlbie xo, dag OOL, dag IOL, string asmstr, + InstrItinClass itin, list pattern> + : XForm_base_r3xo<31, xo, OOL, IOL, asmstr, itin, pattern> { + let RST = 0; + let A = 0; + let B = 0; + + bits<5> RS; + bits<2> RIC; + bits<1> PRS; + bits<1> R; + bits<5> RB; + + let Pattern = pattern; + + let Inst{6-10} = RS; + let Inst{11} = 0; + let Inst{12-13} = RIC; + let Inst{14} = PRS; + let Inst{15} = R; + let Inst{16-20} = RB; + let Inst{21-30} = xo; + let Inst{31} = 0; +} + class XForm_tlbws opcode, bits<10> xo, dag OOL, dag IOL, string asmstr, InstrItinClass itin, list pattern> : I { diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.td b/llvm/lib/Target/PowerPC/PPCInstrInfo.td --- a/llvm/lib/Target/PowerPC/PPCInstrInfo.td +++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.td @@ -4623,8 +4623,9 @@ def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB), "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>; -def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RS, gprc:$RB), - "tlbie $RB,$RS", IIC_SprTLBIE, []>; +def TLBIE : XForm_tlbie<306, (outs), + (ins gprc:$RS, gprc:$RB, i32imm:$RIC, i1imm:$PRS, i1imm:$R), + "tlbie $RB, $RS, $RIC, $PRS, $R", IIC_SprTLBIE, []>; def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B", IIC_LdStLoad>, Requires<[IsBookE]>; @@ -4984,7 +4985,7 @@ } -def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>; +def : InstAlias<"tlbie $RB, $RS", (TLBIE gprc:$RS, gprc:$RB, 0, 0, 0)>; def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>, Requires<[IsPPC4xx]>; diff --git a/llvm/test/MC/PowerPC/ppc64-encoding-bookIII.s b/llvm/test/MC/PowerPC/ppc64-encoding-bookIII.s --- a/llvm/test/MC/PowerPC/ppc64-encoding-bookIII.s +++ b/llvm/test/MC/PowerPC/ppc64-encoding-bookIII.s @@ -162,13 +162,44 @@ # CHECK-LE: tlbiel 4 # encoding: [0x24,0x22,0x00,0x7c] tlbiel %r4 -# CHECK-BE: tlbie 4 # encoding: [0x7c,0x00,0x22,0x64] -# CHECK-LE: tlbie 4 # encoding: [0x64,0x22,0x00,0x7c] +# Note that the one-operand version of "tlbie" is accepted by POWER6, but seems +# to be invalid for later POWER versions. + +# CHECK-BE: tlbie 4, 0 # encoding: [0x7c,0x00,0x22,0x64] +# CHECK-LE: tlbie 4, 0 # encoding: [0x64,0x22,0x00,0x7c] + tlbie %r4, %r0, 0, 0, 0 + +# CHECK-BE: tlbie 4, 0 # encoding: [0x7c,0x00,0x22,0x64] +# CHECK-LE: tlbie 4, 0 # encoding: [0x64,0x22,0x00,0x7c] tlbie %r4, 0 -# CHECK-BE: tlbie 4 # encoding: [0x7c,0x00,0x22,0x64] -# CHECK-LE: tlbie 4 # encoding: [0x64,0x22,0x00,0x7c] - tlbie %r4 +# CHECK-BE: tlbie 10, 0 # encoding: [0x7c,0x00,0x52,0x64] +# CHECK-LE: tlbie 10, 0 # encoding: [0x64,0x52,0x00,0x7c] + tlbie %r10, 0 + +# CHECK-BE: tlbie 10, 0 # encoding: [0x7c,0x00,0x52,0x64] +# CHECK-LE: tlbie 10, 0 # encoding: [0x64,0x52,0x00,0x7c] + tlbie %r10, %r0 + +# CHECK-BE: tlbie 10, 1 # encoding: [0x7c,0x20,0x52,0x64] +# CHECK-LE: tlbie 10, 1 # encoding: [0x64,0x52,0x20,0x7c] + tlbie %r10, %r1 + +# CHECK-BE: tlbie 10, 11 # encoding: [0x7d,0x60,0x52,0x64] +# CHECK-LE: tlbie 10, 11 # encoding: [0x64,0x52,0x60,0x7d] + tlbie %r10, %r11 + +# CHECK-BE: tlbie 3, 4 # encoding: [0x7c,0x80,0x1a,0x64] +# CHECK-LE: tlbie 3, 4 # encoding: [0x64,0x1a,0x80,0x7c] + tlbie %r3, %r4 + +# CHECK-BE: tlbie 3, 4 # encoding: [0x7c,0x80,0x1a,0x64] +# CHECK-LE: tlbie 3, 4 # encoding: [0x64,0x1a,0x80,0x7c] + tlbie %r3, %r4, 0, 0, 0 + +# CHECK-BE: tlbie 3, 4, 3, 1, 1 # encoding: [0x7c,0x8f,0x1a,0x64] +# CHECK-LE: tlbie 3, 4, 3, 1, 1 # encoding: [0x64,0x1a,0x8f,0x7c] + tlbie %r3, %r4, 3, 1, 1 # CHECK-BE: rfi # encoding: [0x4c,0x00,0x00,0x64] # CHECK-LE: rfi # encoding: [0x64,0x00,0x00,0x4c]