@@ -83,6 +83,23 @@ def Polynomial_IntPolynomialAttr : Polynomial_Attr<"IntPolynomial", "int_polynom
83
83
let hasCustomAssemblyFormat = 1;
84
84
}
85
85
86
+ def Polynomial_TypedIntPolynomialAttr : Polynomial_Attr<
87
+ "TypedIntPolynomial", "typed_int_polynomial", [TypedAttrInterface]> {
88
+ let summary = "A typed variant of int_polynomial for constant folding.";
89
+ let parameters = (ins "::mlir::Type":$type, "::mlir::polynomial::IntPolynomial":$value);
90
+ let assemblyFormat = "`<` struct(params) `>`";
91
+ let builders = [
92
+ AttrBuilderWithInferredContext<(ins "Type":$type,
93
+ "const IntPolynomial &":$value), [{
94
+ return $_get(type.getContext(), type, value);
95
+ }]>
96
+ ];
97
+ let extraClassDeclaration = [{
98
+ // used for constFoldBinaryOp
99
+ using ValueType = ::mlir::polynomial::IntPolynomial;
100
+ }];
101
+ }
102
+
86
103
def Polynomial_FloatPolynomialAttr : Polynomial_Attr<"FloatPolynomial", "float_polynomial"> {
87
104
let summary = "An attribute containing a single-variable polynomial with double precision floating point coefficients.";
88
105
let description = [{
@@ -105,6 +122,23 @@ def Polynomial_FloatPolynomialAttr : Polynomial_Attr<"FloatPolynomial", "float_p
105
122
let hasCustomAssemblyFormat = 1;
106
123
}
107
124
125
+ def Polynomial_TypedFloatPolynomialAttr : Polynomial_Attr<
126
+ "TypedFloatPolynomial", "typed_float_polynomial", [TypedAttrInterface]> {
127
+ let summary = "A typed variant of float_polynomial for constant folding.";
128
+ let parameters = (ins "::mlir::Type":$type, "::mlir::polynomial::FloatPolynomial":$value);
129
+ let assemblyFormat = "`<` struct(params) `>`";
130
+ let builders = [
131
+ AttrBuilderWithInferredContext<(ins "Type":$type,
132
+ "const FloatPolynomial &":$value), [{
133
+ return $_get(type.getContext(), type, value);
134
+ }]>
135
+ ];
136
+ let extraClassDeclaration = [{
137
+ // used for constFoldBinaryOp
138
+ using ValueType = ::mlir::polynomial::FloatPolynomial;
139
+ }];
140
+ }
141
+
108
142
def Polynomial_RingAttr : Polynomial_Attr<"Ring", "ring"> {
109
143
let summary = "An attribute specifying a polynomial ring.";
110
144
let description = [{
@@ -221,6 +255,7 @@ def Polynomial_AddOp : Polynomial_BinaryOp<"add", [Commutative]> {
221
255
%2 = polynomial.add %0, %1 : !polynomial.polynomial<#ring>
222
256
```
223
257
}];
258
+ let hasFolder = 1;
224
259
}
225
260
226
261
def Polynomial_SubOp : Polynomial_BinaryOp<"sub"> {
@@ -442,7 +477,7 @@ def Polynomial_AnyPolynomialAttr : AnyAttrOf<[
442
477
]>;
443
478
444
479
// Not deriving from Polynomial_Op due to need for custom assembly format
445
- def Polynomial_ConstantOp : Op<Polynomial_Dialect, "constant", [Pure]> {
480
+ def Polynomial_ConstantOp : Op<Polynomial_Dialect, "constant", [Pure, ConstantLike ]> {
446
481
let summary = "Define a constant polynomial via an attribute.";
447
482
let description = [{
448
483
Example:
@@ -459,6 +494,7 @@ def Polynomial_ConstantOp : Op<Polynomial_Dialect, "constant", [Pure]> {
459
494
let arguments = (ins Polynomial_AnyPolynomialAttr:$value);
460
495
let results = (outs Polynomial_PolynomialType:$output);
461
496
let assemblyFormat = "attr-dict `:` type($output)";
497
+ let hasFolder = 1;
462
498
}
463
499
464
500
def Polynomial_NTTOp : Polynomial_Op<"ntt", [Pure]> {
0 commit comments