@@ -126,21 +126,6 @@ inline match_combine_or<LTy, RTy> m_CombineOr(const LTy &L, const RTy &R) {
126
126
// / Match a VPValue, capturing it if we match.
127
127
inline bind_ty<VPValue> m_VPValue (VPValue *&V) { return V; }
128
128
129
- namespace detail {
130
-
131
- template <typename TupleTy, typename Fn, std::size_t ... Is>
132
- bool CheckTupleElements (const TupleTy &Ops, Fn P, std::index_sequence<Is...>) {
133
- return (P (std::get<Is>(Ops), Is) && ...);
134
- }
135
-
136
- // / Helper to check if predicate \p P holds on all tuple elements in \p Ops
137
- template <typename TupleTy, typename Fn>
138
- bool all_of_tuple_elements (const TupleTy &Ops, Fn P) {
139
- return CheckTupleElements (
140
- Ops, P, std::make_index_sequence<std::tuple_size<TupleTy>::value>{});
141
- }
142
- } // namespace detail
143
-
144
129
template <typename Ops_t, unsigned Opcode, bool Commutative,
145
130
typename ... RecipeTys>
146
131
struct Recipe_match {
@@ -173,13 +158,14 @@ struct Recipe_match {
173
158
assert (R->getNumOperands () == std::tuple_size<Ops_t>::value &&
174
159
" recipe with matched opcode the expected number of operands" );
175
160
176
- if (detail::all_of_tuple_elements (Ops, [R](auto Op, unsigned Idx) {
161
+ auto IdxSeq = std::make_index_sequence<std::tuple_size<Ops_t>::value>();
162
+ if (all_of_tuple_elements (IdxSeq, [R](auto Op, unsigned Idx) {
177
163
return Op.match (R->getOperand (Idx));
178
164
}))
179
165
return true ;
180
166
181
167
return Commutative &&
182
- detail:: all_of_tuple_elements (Ops , [R](auto Op, unsigned Idx) {
168
+ all_of_tuple_elements (IdxSeq , [R](auto Op, unsigned Idx) {
183
169
return Op.match (R->getOperand (R->getNumOperands () - Idx - 1 ));
184
170
});
185
171
}
@@ -198,6 +184,13 @@ struct Recipe_match {
198
184
else
199
185
return DefR && DefR->getOpcode () == Opcode;
200
186
}
187
+
188
+ // / Helper to check if predicate \p P holds on all tuple elements in Ops using
189
+ // / the provided index sequence.
190
+ template <typename Fn, std::size_t ... Is>
191
+ bool all_of_tuple_elements (std::index_sequence<Is...>, Fn P) const {
192
+ return (P (std::get<Is>(Ops), Is) && ...);
193
+ }
201
194
};
202
195
203
196
template <typename Op0_t, unsigned Opcode, typename ... RecipeTys>
0 commit comments