@@ -62,25 +62,6 @@ class RISCVVLOptimizer : public MachineFunctionPass {
62
62
DenseMap<const MachineInstr *, std::optional<MachineOperand>> DemandedVLs;
63
63
};
64
64
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
-
84
65
// / Represents the EMUL and EEW of a MachineOperand.
85
66
struct OperandInfo {
86
67
// Represent as 1,2,4,8, ... and fractional indicator. This is because
@@ -121,6 +102,25 @@ struct OperandInfo {
121
102
}
122
103
};
123
104
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
+
124
124
LLVM_ATTRIBUTE_UNUSED
125
125
static raw_ostream &operator <<(raw_ostream &OS, const OperandInfo &OI) {
126
126
OI.print (OS);
@@ -137,8 +137,6 @@ static raw_ostream &operator<<(raw_ostream &OS,
137
137
return OS;
138
138
}
139
139
140
- namespace llvm {
141
- namespace RISCVVType {
142
140
// / Return EMUL = (EEW / SEW) * LMUL where EEW comes from Log2EEW and LMUL and
143
141
// / SEW are from the TSFlags of MI.
144
142
static std::pair<unsigned , bool >
@@ -165,8 +163,6 @@ getEMULEqualsEEWDivSEWTimesLMUL(unsigned Log2EEW, const MachineInstr &MI) {
165
163
Denom = MILMULIsFractional ? Denom * MILMUL / GCD : Denom / GCD;
166
164
return std::make_pair (Num > Denom ? Num : Denom, Denom > Num);
167
165
}
168
- } // end namespace RISCVVType
169
- } // end namespace llvm
170
166
171
167
// / Dest has EEW=SEW. Source EEW=SEW/Factor (i.e. F2 => EEW/2).
172
168
// / SEW comes from TSFlags of MI.
@@ -770,8 +766,7 @@ getOperandInfo(const MachineOperand &MO, const MachineRegisterInfo *MRI) {
770
766
};
771
767
772
768
// All others have EMUL=EEW/SEW*LMUL
773
- return OperandInfo (RISCVVType::getEMULEqualsEEWDivSEWTimesLMUL (*Log2EEW, MI),
774
- *Log2EEW);
769
+ return OperandInfo (getEMULEqualsEEWDivSEWTimesLMUL (*Log2EEW, MI), *Log2EEW);
775
770
}
776
771
777
772
// / Return true if this optimization should consider MI for VL reduction. This
0 commit comments