From 18ed2ee80c540d8b9c389d3722c70f89593c2b44 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Tue, 3 May 2022 14:00:51 -0700 Subject: [PATCH] [RISCV] Add a version of insertVSETVLI which uses an iterator [NFC] This is to simplify the final version of D124869. --- llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp index f08dbee..304d1c3 100644 --- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp +++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp @@ -473,6 +473,9 @@ private: bool needVSETVLIPHI(const VSETVLIInfo &Require, const MachineBasicBlock &MBB); void insertVSETVLI(MachineBasicBlock &MBB, MachineInstr &MI, const VSETVLIInfo &Info, const VSETVLIInfo &PrevInfo); + void insertVSETVLI(MachineBasicBlock &MBB, + MachineBasicBlock::iterator InsertPt, DebugLoc DL, + const VSETVLIInfo &Info, const VSETVLIInfo &PrevInfo); bool computeVLVTYPEChanges(const MachineBasicBlock &MBB); void computeIncomingVLVTYPE(const MachineBasicBlock &MBB); @@ -627,12 +630,18 @@ void RISCVInsertVSETVLI::insertVSETVLI(MachineBasicBlock &MBB, MachineInstr &MI, const VSETVLIInfo &Info, const VSETVLIInfo &PrevInfo) { DebugLoc DL = MI.getDebugLoc(); + insertVSETVLI(MBB, MachineBasicBlock::iterator(&MI), DL, Info, PrevInfo); +} + +void RISCVInsertVSETVLI::insertVSETVLI(MachineBasicBlock &MBB, + MachineBasicBlock::iterator InsertPt, DebugLoc DL, + const VSETVLIInfo &Info, const VSETVLIInfo &PrevInfo) { // Use X0, X0 form if the AVL is the same and the SEW+LMUL gives the same // VLMAX. if (PrevInfo.isValid() && !PrevInfo.isUnknown() && Info.hasSameAVL(PrevInfo) && Info.hasSameVLMAX(PrevInfo)) { - BuildMI(MBB, MI, DL, TII->get(RISCV::PseudoVSETVLIX0)) + BuildMI(MBB, InsertPt, DL, TII->get(RISCV::PseudoVSETVLIX0)) .addReg(RISCV::X0, RegState::Define | RegState::Dead) .addReg(RISCV::X0, RegState::Kill) .addImm(Info.encodeVTYPE()) @@ -641,7 +650,7 @@ void RISCVInsertVSETVLI::insertVSETVLI(MachineBasicBlock &MBB, MachineInstr &MI, } if (Info.hasAVLImm()) { - BuildMI(MBB, MI, DL, TII->get(RISCV::PseudoVSETIVLI)) + BuildMI(MBB, InsertPt, DL, TII->get(RISCV::PseudoVSETIVLI)) .addReg(RISCV::X0, RegState::Define | RegState::Dead) .addImm(Info.getAVLImm()) .addImm(Info.encodeVTYPE()); @@ -654,7 +663,7 @@ void RISCVInsertVSETVLI::insertVSETVLI(MachineBasicBlock &MBB, MachineInstr &MI, // the previous vl to become invalid. if (PrevInfo.isValid() && !PrevInfo.isUnknown() && Info.hasSameVLMAX(PrevInfo)) { - BuildMI(MBB, MI, DL, TII->get(RISCV::PseudoVSETVLIX0)) + BuildMI(MBB, InsertPt, DL, TII->get(RISCV::PseudoVSETVLIX0)) .addReg(RISCV::X0, RegState::Define | RegState::Dead) .addReg(RISCV::X0, RegState::Kill) .addImm(Info.encodeVTYPE()) @@ -662,7 +671,7 @@ void RISCVInsertVSETVLI::insertVSETVLI(MachineBasicBlock &MBB, MachineInstr &MI, return; } // Otherwise use an AVL of 0 to avoid depending on previous vl. - BuildMI(MBB, MI, DL, TII->get(RISCV::PseudoVSETIVLI)) + BuildMI(MBB, InsertPt, DL, TII->get(RISCV::PseudoVSETIVLI)) .addReg(RISCV::X0, RegState::Define | RegState::Dead) .addImm(0) .addImm(Info.encodeVTYPE()); @@ -681,7 +690,7 @@ void RISCVInsertVSETVLI::insertVSETVLI(MachineBasicBlock &MBB, MachineInstr &MI, DestReg = MRI->createVirtualRegister(&RISCV::GPRRegClass); Opcode = RISCV::PseudoVSETVLIX0; } - BuildMI(MBB, MI, DL, TII->get(Opcode)) + BuildMI(MBB, InsertPt, DL, TII->get(Opcode)) .addReg(DestReg, RegState::Define | RegState::Dead) .addReg(AVLReg) .addImm(Info.encodeVTYPE()); -- 2.7.4