Skip to content

Commit 4bf34a5

Browse files
committed
[RISCV][VLOpt] Move OperandInfo into anonymous namespace. Move getEMULEqualsEEWDivSEWTimesLMUL out of RISCVVType namespace. NFC
We don't want OperandInfo to be visible outside of this object. getEMULEqualsEEWDivSEWTimesLMUL is local to this file and declared static there's no reason to put it in a namespace.
1 parent b3458fd commit 4bf34a5

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,6 @@ class RISCVVLOptimizer : public MachineFunctionPass {
6262
DenseMap<const MachineInstr *, std::optional<MachineOperand>> DemandedVLs;
6363
};
6464

65-
} // end anonymous namespace
66-
67-
char RISCVVLOptimizer::ID = 0;
68-
INITIALIZE_PASS_BEGIN(RISCVVLOptimizer, DEBUG_TYPE, PASS_NAME, false, false)
69-
INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass)
70-
INITIALIZE_PASS_END(RISCVVLOptimizer, DEBUG_TYPE, PASS_NAME, false, false)
71-
72-
FunctionPass *llvm::createRISCVVLOptimizerPass() {
73-
return new RISCVVLOptimizer();
74-
}
75-
76-
/// Return true if R is a physical or virtual vector register, false otherwise.
77-
static bool isVectorRegClass(Register R, const MachineRegisterInfo *MRI) {
78-
if (R.isPhysical())
79-
return RISCV::VRRegClass.contains(R);
80-
const TargetRegisterClass *RC = MRI->getRegClass(R);
81-
return RISCVRI::isVRegClass(RC->TSFlags);
82-
}
83-
8465
/// Represents the EMUL and EEW of a MachineOperand.
8566
struct OperandInfo {
8667
// Represent as 1,2,4,8, ... and fractional indicator. This is because
@@ -121,6 +102,25 @@ struct OperandInfo {
121102
}
122103
};
123104

105+
} // end anonymous namespace
106+
107+
char RISCVVLOptimizer::ID = 0;
108+
INITIALIZE_PASS_BEGIN(RISCVVLOptimizer, DEBUG_TYPE, PASS_NAME, false, false)
109+
INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass)
110+
INITIALIZE_PASS_END(RISCVVLOptimizer, DEBUG_TYPE, PASS_NAME, false, false)
111+
112+
FunctionPass *llvm::createRISCVVLOptimizerPass() {
113+
return new RISCVVLOptimizer();
114+
}
115+
116+
/// Return true if R is a physical or virtual vector register, false otherwise.
117+
static bool isVectorRegClass(Register R, const MachineRegisterInfo *MRI) {
118+
if (R.isPhysical())
119+
return RISCV::VRRegClass.contains(R);
120+
const TargetRegisterClass *RC = MRI->getRegClass(R);
121+
return RISCVRI::isVRegClass(RC->TSFlags);
122+
}
123+
124124
LLVM_ATTRIBUTE_UNUSED
125125
static raw_ostream &operator<<(raw_ostream &OS, const OperandInfo &OI) {
126126
OI.print(OS);
@@ -137,8 +137,6 @@ static raw_ostream &operator<<(raw_ostream &OS,
137137
return OS;
138138
}
139139

140-
namespace llvm {
141-
namespace RISCVVType {
142140
/// Return EMUL = (EEW / SEW) * LMUL where EEW comes from Log2EEW and LMUL and
143141
/// SEW are from the TSFlags of MI.
144142
static std::pair<unsigned, bool>
@@ -165,8 +163,6 @@ getEMULEqualsEEWDivSEWTimesLMUL(unsigned Log2EEW, const MachineInstr &MI) {
165163
Denom = MILMULIsFractional ? Denom * MILMUL / GCD : Denom / GCD;
166164
return std::make_pair(Num > Denom ? Num : Denom, Denom > Num);
167165
}
168-
} // end namespace RISCVVType
169-
} // end namespace llvm
170166

171167
/// Dest has EEW=SEW. Source EEW=SEW/Factor (i.e. F2 => EEW/2).
172168
/// SEW comes from TSFlags of MI.
@@ -770,7 +766,7 @@ getOperandInfo(const MachineOperand &MO, const MachineRegisterInfo *MRI) {
770766
};
771767

772768
// All others have EMUL=EEW/SEW*LMUL
773-
return OperandInfo(RISCVVType::getEMULEqualsEEWDivSEWTimesLMUL(*Log2EEW, MI),
769+
return OperandInfo(getEMULEqualsEEWDivSEWTimesLMUL(*Log2EEW, MI),
774770
*Log2EEW);
775771
}
776772

0 commit comments

Comments
 (0)