Skip to content

Commit ea8b95d

Browse files
[PowerPC] Add a set of extended mnemonics that are missing from Power 10. (#73003)
This patch adds the majority of the missing extended mnemonics that were introduced in Power 10. The only extended mnemonics that were not added are related to the plq and pstq instructions. These will be added in a separate patch as the instructions themselves would also have to be added.
1 parent e3720bb commit ea8b95d

File tree

11 files changed

+556
-78
lines changed

11 files changed

+556
-78
lines changed

llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,26 @@ void PPCAsmParser::ProcessInstruction(MCInst &Inst,
886886
Inst = TmpInst;
887887
break;
888888
}
889+
case PPC::PLA8:
890+
case PPC::PLA: {
891+
MCInst TmpInst;
892+
TmpInst.setOpcode(Opcode == PPC::PLA ? PPC::PADDI : PPC::PADDI8);
893+
TmpInst.addOperand(Inst.getOperand(0));
894+
TmpInst.addOperand(Inst.getOperand(1));
895+
TmpInst.addOperand(Inst.getOperand(2));
896+
Inst = TmpInst;
897+
break;
898+
}
899+
case PPC::PLA8pc:
900+
case PPC::PLApc: {
901+
MCInst TmpInst;
902+
TmpInst.setOpcode(Opcode == PPC::PLApc ? PPC::PADDIpc : PPC::PADDI8pc);
903+
TmpInst.addOperand(Inst.getOperand(0));
904+
TmpInst.addOperand(MCOperand::createImm(0));
905+
TmpInst.addOperand(Inst.getOperand(1));
906+
Inst = TmpInst;
907+
break;
908+
}
889909
case PPC::SUBI: {
890910
MCInst TmpInst;
891911
TmpInst.setOpcode(PPC::ADDI);
@@ -895,6 +915,15 @@ void PPCAsmParser::ProcessInstruction(MCInst &Inst,
895915
Inst = TmpInst;
896916
break;
897917
}
918+
case PPC::PSUBI: {
919+
MCInst TmpInst;
920+
TmpInst.setOpcode(PPC::PADDI);
921+
TmpInst.addOperand(Inst.getOperand(0));
922+
TmpInst.addOperand(Inst.getOperand(1));
923+
addNegOperand(TmpInst, Inst.getOperand(2), getContext());
924+
Inst = TmpInst;
925+
break;
926+
}
898927
case PPC::SUBIS: {
899928
MCInst TmpInst;
900929
TmpInst.setOpcode(PPC::ADDIS);

llvm/lib/Target/PowerPC/P10InstrResources.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ def : InstRW<[P10W_FX_3C, P10W_DISP_ANY],
875875
MCRXRX,
876876
MFCTR, MFCTR8,
877877
MFLR, MFLR8,
878-
WAIT
878+
WAIT, WAITP10
879879
)>;
880880

881881
// 3 Cycles ALU operations, 1 input operands
@@ -1884,6 +1884,7 @@ def : InstRW<[P10W_ST_3C, P10W_DISP_EVEN, P10W_DISP_ANY, P10ST_Read, P10ST_Read,
18841884
def : InstRW<[P10W_ST_3C, P10W_DISP_EVEN, P10W_FX_3C, P10W_DISP_ANY],
18851885
(instrs
18861886
ISYNC,
1887+
SYNCP10,
18871888
SYNC
18881889
)>;
18891890

llvm/lib/Target/PowerPC/PPCBack2BackFusion.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ FUSION_FEATURE(GeneralBack2Back, hasBack2BackFusion, -1,
958958
V_SET0B,
959959
V_SET0H,
960960
WAIT,
961+
WAITP10,
961962
XOR,
962963
XOR8,
963964
XOR8_rec,

llvm/lib/Target/PowerPC/PPCInstrFormats.td

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,38 @@ class XForm_24_sync<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
725725
let Inst{31} = 0;
726726
}
727727

728+
class XForm_IMM2_IMM2<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
729+
string asmstr, InstrItinClass itin, list<dag> pattern>
730+
: I<opcode, OOL, IOL, asmstr, itin> {
731+
bits<2> L;
732+
bits<2> PL;
733+
734+
let Pattern = pattern;
735+
let Inst{6-8} = 0;
736+
let Inst{9-10} = L;
737+
let Inst{11-13} = 0;
738+
let Inst{14-15} = PL;
739+
let Inst{16-20} = 0;
740+
let Inst{21-30} = xo;
741+
let Inst{31} = 0;
742+
}
743+
744+
class XForm_IMM3_IMM2<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
745+
string asmstr, InstrItinClass itin, list<dag> pattern>
746+
: I<opcode, OOL, IOL, asmstr, itin> {
747+
bits<3> L;
748+
bits<2> SC;
749+
750+
let Pattern = pattern;
751+
let Inst{6-7} = 0;
752+
let Inst{8-10} = L;
753+
let Inst{11-13} = 0;
754+
let Inst{14-15} = SC;
755+
let Inst{16-20} = 0;
756+
let Inst{21-30} = xo;
757+
let Inst{31} = 0;
758+
}
759+
728760
class XForm_24_eieio<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
729761
string asmstr, InstrItinClass itin, list<dag> pattern>
730762
: XForm_24_sync<opcode, xo, OOL, IOL, asmstr, itin, pattern> {

llvm/lib/Target/PowerPC/PPCInstrInfo.td

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3437,6 +3437,23 @@ def crnot : OutPatFrag<(ops node:$in),
34373437
def : Pat<(not i1:$in),
34383438
(crnot $in)>;
34393439

3440+
// Pseudo-instructions for alternate assembly syntax (never used by codegen).
3441+
// These are aliases that require C++ handling to convert to the target
3442+
// instruction, while InstAliases can be handled directly by tblgen.
3443+
class PPCAsmPseudo<string asm, dag iops>
3444+
: Instruction {
3445+
let Namespace = "PPC";
3446+
bit PPC64 = 0; // Default value, override with isPPC64
3447+
3448+
let OutOperandList = (outs);
3449+
let InOperandList = iops;
3450+
let Pattern = [];
3451+
let AsmString = asm;
3452+
let isAsmParserOnly = 1;
3453+
let isPseudo = 1;
3454+
let hasNoSchedulingInfo = 1;
3455+
}
3456+
34403457
// Prefixed instructions may require access to the above defs at a later
34413458
// time so we include this after the def.
34423459
include "PPCInstrP10.td"
@@ -4458,23 +4475,6 @@ def ICBIEP : XForm_1a<31, 991, (outs), (ins (memrr $RA, $RB):$addr), "icbiep $a
44584475
// PowerPC Assembler Instruction Aliases
44594476
//
44604477

4461-
// Pseudo-instructions for alternate assembly syntax (never used by codegen).
4462-
// These are aliases that require C++ handling to convert to the target
4463-
// instruction, while InstAliases can be handled directly by tblgen.
4464-
class PPCAsmPseudo<string asm, dag iops>
4465-
: Instruction {
4466-
let Namespace = "PPC";
4467-
bit PPC64 = 0; // Default value, override with isPPC64
4468-
4469-
let OutOperandList = (outs);
4470-
let InOperandList = iops;
4471-
let Pattern = [];
4472-
let AsmString = asm;
4473-
let isAsmParserOnly = 1;
4474-
let isPseudo = 1;
4475-
let hasNoSchedulingInfo = 1;
4476-
}
4477-
44784478
def : InstAlias<"sc", (SC 0)>;
44794479

44804480
def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>;

0 commit comments

Comments
 (0)