@@ -52,24 +52,21 @@ class FCmpPat<string s, dag target> :
5252 Pat<(Arith_CmpFOp:$op ConstantEnumCase<Arith_CmpFPredicateAttr, s>, $lhs, $rhs, $fmf),
5353 target>;
5454
55- defvar PureCall = ConstUnitAttr;
56- defvar VectorCall = ConstUnitAttr;
57-
5855def : FCmpPat<"oeq", (Xls_CallDslxOp (FloatLib $lhs), CS<"eq_2">,
59- (variadic $lhs, $rhs), PureCall, VectorCall )>;
56+ (variadic $lhs, $rhs), ConstUnitAttr )>;
6057def : FCmpPat<"ogt", (Xls_CallDslxOp (FloatLib $lhs), CS<"gt_2">,
61- (variadic $lhs, $rhs), PureCall, VectorCall )>;
58+ (variadic $lhs, $rhs), ConstUnitAttr )>;
6259def : FCmpPat<"oge", (Xls_CallDslxOp (FloatLib $lhs), CS<"gte_2">,
63- (variadic $lhs, $rhs), PureCall, VectorCall )>;
60+ (variadic $lhs, $rhs), ConstUnitAttr )>;
6461def : FCmpPat<"olt", (Xls_CallDslxOp (FloatLib $lhs), CS<"lt_2">,
65- (variadic $lhs, $rhs), PureCall, VectorCall )>;
62+ (variadic $lhs, $rhs), ConstUnitAttr )>;
6663def : FCmpPat<"ole", (Xls_CallDslxOp (FloatLib $lhs), CS<"lte_2">,
67- (variadic $lhs, $rhs), PureCall, VectorCall )>;
64+ (variadic $lhs, $rhs), ConstUnitAttr )>;
6865
6966// Define unordered(x, y) = is_nan(x + y)
7067def : FCmpPat<"uno", (Xls_CallDslxOp (FloatLib $lhs), CS<"is_nan">,
7168 (variadic (Arith_AddFOp $lhs, $rhs, $fmf)),
72- PureCall, VectorCall )>;
69+ ConstUnitAttr )>;
7370
7471class OppositeFCmpPat<string s, string r> :
7572 Pat<(Arith_CmpFOp:$op ConstantEnumCase<Arith_CmpFPredicateAttr, s>, $lhs,
@@ -135,70 +132,69 @@ def : Pat<(Arith_ConstantOp NonIndexAttr:$val),
135132defvar ExtLib = CS<"xls/contrib/mlir/stdlib/fp_ext_trunc.x">;
136133
137134def : Pat<(Arith_NegFOp:$op $a, /*FastMathFlags=*/$_),
138- (Xls_CallDslxOp (FloatLib $a), CS<"negate">, (variadic $a), PureCall, VectorCall )>;
135+ (Xls_CallDslxOp (FloatLib $a), CS<"negate">, (variadic $a), ConstUnitAttr )>;
139136
140137// Emits a binary float library call.
141138class FloatLibcall<Op Op, string Name> :
142139 Pat<(Op:$op $a, $b, /*FastMathFlags=*/$_),
143- (Xls_CallDslxOp (FloatLib $a), CS<Name>, (variadic $a, $b),
144- PureCall, VectorCall)>;
140+ (Xls_CallDslxOp (FloatLib $a), CS<Name>, (variadic $a, $b), ConstUnitAttr)>;
145141
146142def : FloatLibcall<Arith_AddFOp, "add">;
147143def : FloatLibcall<Arith_MulFOp, "mul">;
148144def : FloatLibcall<Arith_SubFOp, "sub">;
149145
150146def : Pat<(Arith_ExtFOp:$op $a, /*FastMathFlags=*/$_),
151- (Xls_CallDslxOp ExtLib, CS<"ext">, (variadic $a), PureCall, VectorCall )>;
147+ (Xls_CallDslxOp ExtLib, CS<"ext">, (variadic $a), ConstUnitAttr )>;
152148
153149def : Pat<(Arith_TruncFOp:$op $a, /*RoundingMode=*/$_, /*FastMathFlags=*/$_),
154- (Xls_CallDslxOp ExtLib, CS<"trunc">, (variadic $a), PureCall, VectorCall ),
150+ (Xls_CallDslxOp ExtLib, CS<"trunc">, (variadic $a), ConstUnitAttr ),
155151 [(ScalarOrTensorOf<F32> $a)]>;
156152
157153multiclass FloatToIntegralPat<Op fptoi, Op itofp, Op exti, string u> {
158154 def : Pat<(itofp:$op I32:$a),
159155 (Xls_CallDslxOp (FloatLib $op), CS<"from_"#u#"int32">, (variadic $a),
160- PureCall, VectorCall ),
156+ ConstUnitAttr ),
161157 [(ScalarOrTensorOf<F32> $op)]>;
162158
163159 def : Pat<(itofp:$op I32:$a),
164160 (Xls_CallDslxOp (FloatLib $op), CS<"from_float32">,
165161 (variadic (itofp $a, (returnType "$_builder.getF32Type()"))),
166- PureCall, VectorCall ),
162+ ConstUnitAttr ),
167163 [(ScalarOrTensorOf<BF16> $op)]>;
168164
169165 def : Pat<(itofp:$op I16:$a),
170166 (Xls_CallDslxOp (FloatLib $op), CS<"from_"#u#"int32">,
171167 (variadic (exti $a, (returnType "$_builder.getI32Type()"))),
172- PureCall, VectorCall ),
168+ ConstUnitAttr ),
173169 [(ScalarOrTensorOf<F32> $op)]>;
174170
175171 def : Pat<(itofp:$op I16:$a),
176172 (Xls_CallDslxOp (FloatLib $op), CS<"from_float32">,
177173 (variadic (itofp $a, (returnType "$_builder.getF32Type()"))),
178- PureCall, VectorCall ),
174+ ConstUnitAttr ),
179175 [(ScalarOrTensorOf<BF16> $op)]>;
180176
181177 def : Pat<(itofp:$op I8:$a),
182178 (Xls_CallDslxOp (FloatLib $op), CS<"from_"#u#"int8">, (variadic $a),
183- PureCall, VectorCall ),
179+ ConstUnitAttr ),
184180 [(ScalarOrTensorOf<BF16> $op)]>;
185181
186182 def : Pat<(fptoi:$op F32:$a),
187183 (Xls_CallDslxOp (FloatLib $a), CS<"to_"#u#"int32">, (variadic $a),
188- PureCall, VectorCall ),
184+ ConstUnitAttr ),
189185 [(ScalarOrTensorOf<I32> $op)]>;
190186
191187 def : Pat<(fptoi:$op BF16:$a),
192188 (Xls_CallDslxOp (FloatLib $a), CS<"to_"#u#"int16">, (variadic $a),
193- PureCall, VectorCall ),
189+ ConstUnitAttr ),
194190 [(ScalarOrTensorOf<I16> $op)]>;
195191
196192 // TODO(jmolloy): to_int8 doesn't exist, so truncating the result of to_int16
197193 // seems like a reasonable approximation but I don't know if it's bit accurate.
198194 def : Pat<(fptoi:$op BF16:$a),
199195 (Arith_TruncIOp
200196 (Xls_CallDslxOp (FloatLib $a), CS<"to_"#u#"int16">, (variadic $a),
201- PureCall, VectorCall ,
197+ ConstUnitAttr ,
202198 (returnType "$_builder.getI16Type()"))),
203199 [(ScalarOrTensorOf<I8> $op)]>;
204200}
@@ -283,7 +279,7 @@ class MinMaxPatBase<dag Matcher, dag Predicate> : Pat<
283279
284280class FPMinMaxPat<Op Op, string Name> : MinMaxPatBase<
285281 (Op:$op $a, $b, /*FastMathFlags=*/$_),
286- (Xls_CallDslxOp (FloatLib $a), CS<Name>, (variadic $a, $b), PureCall, VectorCall ,
282+ (Xls_CallDslxOp (FloatLib $a), CS<Name>, (variadic $a, $b), ConstUnitAttr ,
287283 (returnType "boolLike(op)"))>;
288284
289285def : FPMinMaxPat<Arith_MaximumFOp, "gt_2">;
0 commit comments