@@ -62,7 +62,7 @@ class Polynomial_Attr<string name, string attrMnemonic, list<Trait> traits = []>
62
62
}
63
63
64
64
def Polynomial_IntPolynomialAttr : Polynomial_Attr<"IntPolynomial", "int_polynomial"> {
65
- let summary = "An attribute containing a single-variable polynomial with integer coefficients. ";
65
+ let summary = "an attribute containing a single-variable polynomial with integer coefficients";
66
66
let description = [{
67
67
A polynomial attribute represents a single-variable polynomial with integer
68
68
coefficients, which is used to define the modulus of a `RingAttr`, as well
@@ -109,7 +109,7 @@ def Polynomial_TypedIntPolynomialAttr : Polynomial_Attr<
109
109
}
110
110
111
111
def Polynomial_FloatPolynomialAttr : Polynomial_Attr<"FloatPolynomial", "float_polynomial"> {
112
- let summary = "An attribute containing a single-variable polynomial with double precision floating point coefficients. ";
112
+ let summary = "an attribute containing a single-variable polynomial with double precision floating point coefficients";
113
113
let description = [{
114
114
A polynomial attribute represents a single-variable polynomial with double
115
115
precision floating point coefficients.
@@ -489,6 +489,25 @@ def Polynomial_AnyPolynomialAttr : AnyAttrOf<[
489
489
Polynomial_FloatPolynomialAttr,
490
490
Polynomial_IntPolynomialAttr
491
491
]>;
492
+ def Polynomial_PolynomialElementsAttr :
493
+ ElementsAttrBase<And<[//CPred<"::llvm::isa<::mlir::ElementsAttr>($_self)">,
494
+ CPred<[{
495
+ isa<::mlir::polynomial::PolynomialType>(
496
+ ::llvm::cast<::mlir::ElementsAttr>($_self)
497
+ .getShapedType()
498
+ .getElementType())
499
+ }]>]>,
500
+ "an elements attribute containing polynomial attributes"> {
501
+ let storageType = [{ ::mlir::ElementsAttr }];
502
+ let returnType = [{ ::mlir::ElementsAttr }];
503
+ let convertFromStorage = "$_self";
504
+ }
505
+
506
+ def Polynomial_PolynomialOrElementsAttr : AnyAttrOf<[
507
+ Polynomial_FloatPolynomialAttr,
508
+ Polynomial_IntPolynomialAttr,
509
+ Polynomial_PolynomialElementsAttr,
510
+ ]>;
492
511
493
512
// Not deriving from Polynomial_Op due to need for custom assembly format
494
513
def Polynomial_ConstantOp : Op<Polynomial_Dialect, "constant", [Pure, ConstantLike]> {
@@ -505,8 +524,8 @@ def Polynomial_ConstantOp : Op<Polynomial_Dialect, "constant", [Pure, ConstantLi
505
524
%0 = polynomial.constant #polynomial.float_polynomial<0.5 + 1.3e06 x**2> : !polynomial.polynomial<#float_ring>
506
525
```
507
526
}];
508
- let arguments = (ins Polynomial_AnyPolynomialAttr :$value);
509
- let results = (outs Polynomial_PolynomialType :$output);
527
+ let arguments = (ins Polynomial_PolynomialOrElementsAttr :$value);
528
+ let results = (outs PolynomialLike :$output);
510
529
let assemblyFormat = "attr-dict `:` type($output)";
511
530
let hasFolder = 1;
512
531
}
0 commit comments