Skip to content

Commit 31c75a1

Browse files
authored
[RISCV] Move PseudoVSET(I)VLI expansion to use PseudoInstExpansion. (#102496)
Instead of expanding in RISCVExpandPseudoInsts, expand during MachineInstr to MCInst lowering. We weren't doing anything in expansion other than copying operands.
1 parent ccc3127 commit 31c75a1

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class RISCVExpandPseudo : public MachineFunctionPass {
4646
MachineBasicBlock::iterator &NextMBBI);
4747
bool expandCCOp(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
4848
MachineBasicBlock::iterator &NextMBBI);
49-
bool expandVSetVL(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI);
5049
bool expandVMSET_VMCLR(MachineBasicBlock &MBB,
5150
MachineBasicBlock::iterator MBBI, unsigned Opcode);
5251
bool expandRV32ZdinxStore(MachineBasicBlock &MBB,
@@ -139,10 +138,6 @@ bool RISCVExpandPseudo::expandMI(MachineBasicBlock &MBB,
139138
case RISCV::PseudoCCORN:
140139
case RISCV::PseudoCCXNOR:
141140
return expandCCOp(MBB, MBBI, NextMBBI);
142-
case RISCV::PseudoVSETVLI:
143-
case RISCV::PseudoVSETVLIX0:
144-
case RISCV::PseudoVSETIVLI:
145-
return expandVSetVL(MBB, MBBI);
146141
case RISCV::PseudoVMCLR_M_B1:
147142
case RISCV::PseudoVMCLR_M_B2:
148143
case RISCV::PseudoVMCLR_M_B4:
@@ -258,36 +253,6 @@ bool RISCVExpandPseudo::expandCCOp(MachineBasicBlock &MBB,
258253
return true;
259254
}
260255

261-
bool RISCVExpandPseudo::expandVSetVL(MachineBasicBlock &MBB,
262-
MachineBasicBlock::iterator MBBI) {
263-
assert(MBBI->getNumExplicitOperands() == 3 && MBBI->getNumOperands() >= 5 &&
264-
"Unexpected instruction format");
265-
266-
DebugLoc DL = MBBI->getDebugLoc();
267-
268-
assert((MBBI->getOpcode() == RISCV::PseudoVSETVLI ||
269-
MBBI->getOpcode() == RISCV::PseudoVSETVLIX0 ||
270-
MBBI->getOpcode() == RISCV::PseudoVSETIVLI) &&
271-
"Unexpected pseudo instruction");
272-
unsigned Opcode;
273-
if (MBBI->getOpcode() == RISCV::PseudoVSETIVLI)
274-
Opcode = RISCV::VSETIVLI;
275-
else
276-
Opcode = RISCV::VSETVLI;
277-
const MCInstrDesc &Desc = TII->get(Opcode);
278-
assert(Desc.getNumOperands() == 3 && "Unexpected instruction format");
279-
280-
Register DstReg = MBBI->getOperand(0).getReg();
281-
bool DstIsDead = MBBI->getOperand(0).isDead();
282-
BuildMI(MBB, MBBI, DL, Desc)
283-
.addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead))
284-
.add(MBBI->getOperand(1)) // VL
285-
.add(MBBI->getOperand(2)); // VType
286-
287-
MBBI->eraseFromParent(); // The pseudo instruction is gone now.
288-
return true;
289-
}
290-
291256
bool RISCVExpandPseudo::expandVMSET_VMCLR(MachineBasicBlock &MBB,
292257
MachineBasicBlock::iterator MBBI,
293258
unsigned Opcode) {

llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6136,10 +6136,13 @@ let hasSideEffects = 0, mayLoad = 0, mayStore = 0, Defs = [VL, VTYPE] in {
61366136
// be accidentally be made X0 by MachineIR optimizations. To satisfy the
61376137
// verifier, we also need a GPRX0 instruction for the special encodings.
61386138
def PseudoVSETVLI : Pseudo<(outs GPR:$rd), (ins GPRNoX0:$rs1, VTypeIOp11:$vtypei), []>,
6139+
PseudoInstExpansion<(VSETVLI GPR:$rd, GPR:$rs1, VTypeIOp11:$vtypei)>,
61396140
Sched<[WriteVSETVLI, ReadVSETVLI]>;
61406141
def PseudoVSETVLIX0 : Pseudo<(outs GPR:$rd), (ins GPRX0:$rs1, VTypeIOp11:$vtypei), []>,
6142+
PseudoInstExpansion<(VSETVLI GPR:$rd, GPR:$rs1, VTypeIOp11:$vtypei)>,
61416143
Sched<[WriteVSETVLI, ReadVSETVLI]>;
61426144
def PseudoVSETIVLI : Pseudo<(outs GPR:$rd), (ins uimm5:$rs1, VTypeIOp10:$vtypei), []>,
6145+
PseudoInstExpansion<(VSETIVLI GPR:$rd, uimm5:$rs1, VTypeIOp10:$vtypei)>,
61436146
Sched<[WriteVSETIVLI]>;
61446147
}
61456148

0 commit comments

Comments
 (0)