[RISCV] move `isFaultFirstLoad` into `RISCVInstrInfo`
authorShao-Ce SUN <sunshaoce@iscas.ac.cn>
Fri, 10 Jun 2022 08:53:34 +0000 (16:53 +0800)
committerShao-Ce SUN <sunshaoce@iscas.ac.cn>
Fri, 10 Jun 2022 13:03:47 +0000 (21:03 +0800)
Fix build errors in D126794

```
ld.lld: error: undefined symbol: llvm::MachineInstr::getNumExplicitDefs() const
>>> referenced by RISCVBaseInfo.cpp
>>>               RISCVBaseInfo.cpp.o:(llvm::isFaultFirstLoad(llvm::MachineInstr const&)) in archive lib/libLLVMRISCVDesc.a

ld.lld: error: undefined symbol: llvm::MachineInstr::findRegisterDefOperandIdx(llvm::Register, bool, bool, llvm::TargetRegisterInfo const*) const
>>> referenced by RISCVBaseInfo.cpp
>>>               RISCVBaseInfo.cpp.o:(llvm::isFaultFirstLoad(llvm::MachineInstr const&)) in archive lib/libLLVMRISCVDesc.a
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
```

Reviewed By: fakepaper56

Differential Revision: https://reviews.llvm.org/D127477

llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
llvm/lib/Target/RISCV/RISCVMCInstLower.cpp

index b3c53c9bd526607dc5e9ee544366e06d62e79ff6..9b69170d1c4a6c180db39455bfaa3b1efab25b24 100644 (file)
@@ -182,9 +182,4 @@ void RISCVVType::printVType(unsigned VType, raw_ostream &OS) {
     OS << ", mu";
 }
 
-bool isFaultFirstLoad(const MachineInstr &MI) {
-  return MI.getNumExplicitDefs() == 2 && MI.modifiesRegister(RISCV::VL) &&
-         !MI.isInlineAsm();
-}
-
 } // namespace llvm
index 9e343a21e7bc9672c781d7ee07e2b76ca4bc1d31..c7d88d80d723093b861206a60942e819eb541633 100644 (file)
@@ -433,7 +433,13 @@ void printVType(unsigned VType, raw_ostream &OS);
 
 } // 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
index 866a6d8edb3952da76d868e5419f2ec372186da0..9db14dbcc55d66bdc9f214d2bc9cc148a4c337a5 100644 (file)
@@ -1414,7 +1414,7 @@ void RISCVInsertVSETVLI::doLocalPostpass(MachineBasicBlock &MBB) {
 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),
index e341f82db95da0d0a3841ca35fe5a8e3b3564006..530b9b03f74a2920b25c53f52740eeb4d4483c71 100644 (file)
@@ -158,7 +158,7 @@ static bool lowerRISCVVMachineInstrToMCInst(const MachineInstr *MI,
   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.