diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h @@ -433,7 +433,13 @@ } // namespace RISCVVType -bool isFaultFirstLoad(const MachineInstr &MI); +namespace RISCVVInstInfo { +inline static bool isFaultFirstLoad(const MachineInstr &MI) { + return MI.getNumExplicitDefs() == 2 && MI.modifiesRegister(RISCV::VL) && + !MI.isInlineAsm(); +} +} // namespace RISCVVInstInfo + } // namespace llvm #endif diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp @@ -182,9 +182,4 @@ OS << ", mu"; } -bool isFaultFirstLoad(const MachineInstr &MI) { - return MI.getNumExplicitDefs() == 2 && MI.modifiesRegister(RISCV::VL) && - !MI.isInlineAsm(); -} - } // namespace llvm diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp --- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp +++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp @@ -1414,7 +1414,7 @@ void RISCVInsertVSETVLI::insertReadVL(MachineBasicBlock &MBB) { for (auto I = MBB.begin(), E = MBB.end(); I != E;) { MachineInstr &MI = *I++; - if (isFaultFirstLoad(MI)) { + if (RISCVVInstInfo::isFaultFirstLoad(MI)) { Register VLOutput = MI.getOperand(1).getReg(); if (!MRI->use_nodbg_empty(VLOutput)) BuildMI(MBB, I, MI.getDebugLoc(), TII->get(RISCV::PseudoReadVL), diff --git a/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp b/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp --- a/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp +++ b/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp @@ -158,7 +158,7 @@ if (RISCVII::hasSEWOp(TSFlags)) --NumOps; - bool hasVLOutput = isFaultFirstLoad(*MI); + bool hasVLOutput = RISCVVInstInfo::isFaultFirstLoad(*MI); for (unsigned OpNo = 0; OpNo != NumOps; ++OpNo) { const MachineOperand &MO = MI->getOperand(OpNo); // Skip vl ouput. It should be the second output.