@@ -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.
8566struct 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+
124124LLVM_ATTRIBUTE_UNUSED
125125static 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.
144142static 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,8 +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),
774- *Log2EEW);
769+ return OperandInfo (getEMULEqualsEEWDivSEWTimesLMUL (*Log2EEW, MI), *Log2EEW);
775770}
776771
777772// / Return true if this optimization should consider MI for VL reduction. This
0 commit comments