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 @@ -447,10 +447,29 @@ : XForm_base_r3xo, XFormMemOp; class XForm_tlb xo, dag OOL, dag IOL, string asmstr, - InstrItinClass itin> : XForm_base_r3xo<31, xo, OOL, IOL, asmstr, itin, []> { + InstrItinClass itin> + : XForm_base_r3xo<31, xo, OOL, IOL, asmstr, itin, []> { let RST = 0; } +class XForm_tlbie xo, dag OOL, dag IOL, string asmstr, + InstrItinClass itin> + : I<31, OOL, IOL, asmstr, itin> { + bits<5> RB; + bit L; + + let Pattern = []; + + bit RC = 0; // set by isRecordForm + + let Inst{6-9} = 0; + let Inst{10} = L; + let Inst{11-15} = 0; + let Inst{16-20} = RB; + let Inst{21-30} = xo; + let Inst{31} = RC; +} + class XForm_attn opcode, bits<10> xo, dag OOL, dag IOL, string asmstr, InstrItinClass itin> : 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 @@ -4383,16 +4383,15 @@ def TLBSYNC : XForm_0<31, 566, (outs), (ins), "tlbsync", IIC_SprTLBSYNC, []>; -def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB), - "tlbiel $RB", IIC_SprTLBIEL, []>; - def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB), "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>; 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:$RB, i1imm:$L), + "tlbie $RB,$L", IIC_SprTLBIE>; +def TLBIEL : XForm_tlbie<274, (outs), (ins gprc:$RB, i1imm:$L), + "tlbiel $RB,$L", IIC_SprTLBIEL>; def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B", IIC_LdStLoad>, Requires<[IsBookE]>; @@ -4738,7 +4737,8 @@ def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>; -def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>; +def : InstAlias<"tlbie $RB", (TLBIE gprc:$RB, 0)>; +def : InstAlias<"tlbiel $RB", (TLBIEL gprc:$RB, 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,14 +162,26 @@ # 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] - tlbie %r4, 0 +# CHECK-BE: tlbiel 4 # encoding: [0x7c,0x00,0x22,0x24] +# CHECK-LE: tlbiel 4 # encoding: [0x24,0x22,0x00,0x7c] + tlbiel %r4, 0 + +# CHECK-BE: tlbiel 4,1 # encoding: [0x7c,0x20,0x22,0x24] +# CHECK-LE: tlbiel 4,1 # encoding: [0x24,0x22,0x20,0x7c] + tlbiel %r4, 1 # CHECK-BE: tlbie 4 # encoding: [0x7c,0x00,0x22,0x64] # CHECK-LE: tlbie 4 # encoding: [0x64,0x22,0x00,0x7c] tlbie %r4 +# CHECK-BE: tlbie 4 # encoding: [0x7c,0x00,0x22,0x64] +# CHECK-LE: tlbie 4 # encoding: [0x64,0x22,0x00,0x7c] + tlbie %r4, 0 + +# CHECK-BE: tlbie 4,1 # encoding: [0x7c,0x20,0x22,0x64] +# CHECK-LE: tlbie 4,1 # encoding: [0x64,0x22,0x20,0x7c] + tlbie %r4, 1 + # CHECK-BE: rfi # encoding: [0x4c,0x00,0x00,0x64] # CHECK-LE: rfi # encoding: [0x64,0x00,0x00,0x4c] rfi