Skip to content

Commit 4f7dc99

Browse files
authored
[RISCV] Use MnemonicAlias instead of InstAlias for some vector instructions. NFC (#131732)
To make this work we have to apply mnemonic aliases before looking up custom operand parsing.
1 parent e4d910e commit 4f7dc99

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,6 +2923,13 @@ bool RISCVAsmParser::parseInstruction(ParseInstructionInfo &Info,
29232923
}
29242924
}
29252925

2926+
// Apply mnemonic aliases because the destination mnemonic may have require
2927+
// custom operand parsing. The generic tblgen'erated code does this later, at
2928+
// the start of MatchInstructionImpl(), but that's too late for custom
2929+
// operand parsing.
2930+
const FeatureBitset &AvailableFeatures = getAvailableFeatures();
2931+
applyMnemonicAliases(Name, AvailableFeatures, 0);
2932+
29262933
// First operand is token for instruction
29272934
Operands.push_back(RISCVOperand::createToken(Name, NameLoc));
29282935

llvm/lib/Target/RISCV/RISCVInstrInfoV.td

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,10 +1111,8 @@ def VLM_V : VUnitStrideLoadMask<"vlm.v">,
11111111
Sched<[WriteVLDM_WorstCase, ReadVLDX]>;
11121112
def VSM_V : VUnitStrideStoreMask<"vsm.v">,
11131113
Sched<[WriteVSTM_WorstCase, ReadVSTM_WorstCase, ReadVSTX]>;
1114-
def : InstAlias<"vle1.v $vd,$rs1",
1115-
(VLM_V VR:$vd, GPRMemZeroOffset:$rs1), 0>;
1116-
def : InstAlias<"vse1.v $vs3, $rs1",
1117-
(VSM_V VR:$vs3, GPRMemZeroOffset:$rs1), 0>;
1114+
def : MnemonicAlias<"vle1.v", "vlm.v">;
1115+
def : MnemonicAlias<"vse1.v", "vsm.v">;
11181116

11191117
def VS1R_V : VWholeStore<0, "vs1r.v", VR>,
11201118
Sched<[WriteVST1R, ReadVST1R, ReadVSTX]>;
@@ -1582,8 +1580,7 @@ defm VFREDMIN : VREDMINMAX_FV_V<"vfredmin", 0b000101>;
15821580
}
15831581
} // RVVConstraint = NoConstraint, ElementsDependOn = EltDepsVLMask
15841582

1585-
def : InstAlias<"vfredsum.vs $vd, $vs2, $vs1$vm",
1586-
(VFREDUSUM_VS VR:$vd, VR:$vs2, VR:$vs1, VMaskOp:$vm), 0>;
1583+
def : MnemonicAlias<"vfredsum.vs", "vfredusum.vs">;
15871584

15881585
// Vector Widening Floating-Point Reduction Instructions
15891586
let Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint, ElementsDependOn = EltDepsVLMask, DestEEW = EEWSEWx2 in {
@@ -1597,8 +1594,7 @@ defm VFWREDUSUM : VWRED_FV_V<"vfwredusum", 0b110001>;
15971594
}
15981595
} // Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint, ElementsDependOn = EltDepsVLMask, DestEEW = EEWSEWx2
15991596

1600-
def : InstAlias<"vfwredsum.vs $vd, $vs2, $vs1$vm",
1601-
(VFWREDUSUM_VS VR:$vd, VR:$vs2, VR:$vs1, VMaskOp:$vm), 0>;
1597+
def : MnemonicAlias<"vfwredsum.vs", "vfwredusum.vs">;
16021598
} // Predicates = [HasVInstructionsAnyF]
16031599

16041600
let Predicates = [HasVInstructions] in {
@@ -1623,10 +1619,8 @@ def : InstAlias<"vmset.m $vd",
16231619
def : InstAlias<"vmnot.m $vd, $vs",
16241620
(VMNAND_MM VR:$vd, VR:$vs, VR:$vs)>;
16251621

1626-
def : InstAlias<"vmandnot.mm $vd, $vs2, $vs1",
1627-
(VMANDN_MM VR:$vd, VR:$vs2, VR:$vs1), 0>;
1628-
def : InstAlias<"vmornot.mm $vd, $vs2, $vs1",
1629-
(VMORN_MM VR:$vd, VR:$vs2, VR:$vs1), 0>;
1622+
def : MnemonicAlias<"vmandnot.mm", "vmandn.mm">;
1623+
def : MnemonicAlias<"vmornot.mm", "vmorn.mm">;
16301624

16311625
let hasSideEffects = 0, mayLoad = 0, mayStore = 0,
16321626
RVVConstraint = NoConstraint, ElementsDependOn = EltDepsVLMask in {
@@ -1645,8 +1639,7 @@ def VFIRST_M : RVInstV<0b010000, 0b10001, OPMVV, (outs GPR:$vd),
16451639

16461640
} // hasSideEffects = 0, mayLoad = 0, mayStore = 0, RVVConstraint = NoConstraint, ElementsDependOn = EltDepsVLMask
16471641

1648-
def : InstAlias<"vpopc.m $vd, $vs2$vm",
1649-
(VCPOP_M GPR:$vd, VR:$vs2, VMaskOp:$vm), 0>;
1642+
def : MnemonicAlias<"vpopc.m", "vcpop.m">;
16501643

16511644
let Constraints = "@earlyclobber $vd", RVVConstraint = Iota, ElementsDependOn = EltDepsVLMask in {
16521645

0 commit comments

Comments
 (0)