Skip to content

Commit

Permalink
[PowerPC][MC] Recognize tlbilx and its mnemonics
Browse files Browse the repository at this point in the history
This fixes issue 64080. tlbilx exists in ISA 2.07 Book III-E. Since
contents of Book III-E were eliminated after ISA 3.0, tlbilx does not
exist in ISA 3.0 and ISA 3.1.

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D156204
  • Loading branch information
ecnelises committed Aug 2, 2023
1 parent 1c10667 commit 53648ac
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
6 changes: 6 additions & 0 deletions llvm/lib/Target/PowerPC/PPCInstrFormats.td
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,12 @@ class XForm_tlb<bits<10> xo, dag OOL, dag IOL, string asmstr,
let RST = 0;
}

class XForm_tlbilx<bits<10> xo, dag OOL, dag IOL, string asmstr,
InstrItinClass itin> : XForm_base_r3xo<31, xo, OOL, IOL, asmstr, itin, []> {
bits<5> T;
let RST = T;
}

class XForm_attn<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
InstrItinClass itin>
: I<opcode, OOL, IOL, asmstr, itin> {
Expand Down
9 changes: 9 additions & 0 deletions llvm/lib/Target/PowerPC/PPCInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -4317,6 +4317,9 @@ def TLBSX : XForm_tlb<914, (outs), (ins gprc:$RA, gprc:$RB), "tlbsx $RA, $RB",
def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$RA, gprc:$RB), "tlbivax $RA, $RB",
IIC_LdStLoad>, Requires<[IsBookE]>;

def TLBILX : XForm_tlbilx<18, (outs), (ins u2imm:$T, gprc:$RA, gprc:$RB),
"tlbilx $T, $RA, $RB", IIC_LdStLoad>, Requires<[IsBookE]>;

def TLBRE : XForm_24_eieio<31, 946, (outs), (ins),
"tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>;

Expand Down Expand Up @@ -4680,6 +4683,12 @@ def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>,
def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>,
Requires<[IsPPC4xx]>;

def : InstAlias<"tlbilxlpid", (TLBILX 0, R0, R0)>, Requires<[IsBookE]>;
def : InstAlias<"tlbilxpid", (TLBILX 1, R0, R0)>, Requires<[IsBookE]>;
def : InstAlias<"tlbilxva $RA, $RB", (TLBILX 3, gprc:$RA, gprc:$RB)>,
Requires<[IsBookE]>;
def : InstAlias<"tlbilxva $RB", (TLBILX 3, R0, gprc:$RB)>, Requires<[IsBookE]>;

def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>;

def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm",
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/PowerPC/PPCScheduleP9.td
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def P9Model : SchedMachineModel {
// Power 9, or MMA, or paired vector mem ops, or PC relative mem ops, or
// instructions introduced after ISA 3.0.
let UnsupportedFeatures = [HasSPE, PrefixInstrs, MMA,
PairedVectorMemops,
PairedVectorMemops, IsBookE,
PCRelativeMemops, IsISA3_1, IsISAFuture];
}

Expand Down
20 changes: 20 additions & 0 deletions llvm/test/MC/PowerPC/ppc64-encoding-bookIII.s
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,26 @@
# CHECK-LE: tlbie 4 # encoding: [0x64,0x22,0x00,0x7c]
tlbie %r4

# CHECK-BE: tlbilx 1, 4, 5 # encoding: [0x7c,0x24,0x28,0x24]
# CHECK-LE: tlbilx 1, 4, 5 # encoding: [0x24,0x28,0x24,0x7c]
tlbilx 1, %r4, %r5

# CHECK-BE: tlbilxlpid # encoding: [0x7c,0x00,0x00,0x24]
# CHECK-LE: tlbilxlpid # encoding: [0x24,0x00,0x00,0x7c]
tlbilxlpid

# CHECK-BE: tlbilxpid # encoding: [0x7c,0x20,0x00,0x24]
# CHECK-LE: tlbilxpid # encoding: [0x24,0x00,0x20,0x7c]
tlbilxpid

# CHECK-BE: tlbilxva 4, 5 # encoding: [0x7c,0x64,0x28,0x24]
# CHECK-LE: tlbilxva 4, 5 # encoding: [0x24,0x28,0x64,0x7c]
tlbilxva %r4, %r5

# CHECK-BE: tlbilxva 0, 5 # encoding: [0x7c,0x60,0x28,0x24]
# CHECK-LE: tlbilxva 0, 5 # encoding: [0x24,0x28,0x60,0x7c]
tlbilxva %r5

# CHECK-BE: rfi # encoding: [0x4c,0x00,0x00,0x64]
# CHECK-LE: rfi # encoding: [0x64,0x00,0x00,0x4c]
rfi
Expand Down

0 comments on commit 53648ac

Please sign in to comment.