xref: /llvm-project/mlir/test/Dialect/Polynomial/attributes.mlir (revision 4425dfba6a1f394e958e94aa471a07bcf707136a)
1// RUN: mlir-opt %s --split-input-file --verify-diagnostics
2
3#my_poly = #polynomial.int_polynomial<y + x**1024>
4// expected-error@below {{polynomials must have one indeterminate, but there were multiple: x, y}}
5#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=2837465, polynomialModulus=#my_poly>
6
7// -----
8
9// expected-error@below {{expected integer value}}
10// expected-error@below {{expected a monomial}}
11// expected-error@below {{found invalid integer exponent}}
12#my_poly = #polynomial.int_polynomial<5 + x**f>
13#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=2837465, polynomialModulus=#my_poly>
14
15// -----
16
17#my_poly = #polynomial.int_polynomial<5 + x**2 + 3x**2>
18// expected-error@below {{parsed polynomial must have unique exponents among monomials}}
19#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=2837465, polynomialModulus=#my_poly>
20
21// -----
22
23// expected-error@below {{expected + and more monomials, or > to end polynomial attribute}}
24#my_poly = #polynomial.int_polynomial<5 + x**2 7>
25#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=2837465, polynomialModulus=#my_poly>
26
27// -----
28
29// expected-error@below {{expected a monomial}}
30#my_poly = #polynomial.int_polynomial<5 + x**2 +>
31#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=2837465, polynomialModulus=#my_poly>
32
33
34// -----
35
36#my_poly = #polynomial.int_polynomial<5 + x**2>
37// expected-error@below {{failed to parse Polynomial_RingAttr parameter 'coefficientModulus' which is to be a `::mlir::IntegerAttr`}}
38// expected-error@below {{expected attribute value}}
39#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=x, polynomialModulus=#my_poly>
40
41// -----
42
43// expected-error@below {{coefficientModulus specified but coefficientType is not integral}}
44#ring1 = #polynomial.ring<coefficientType=f32, coefficientModulus=17>
45
46// -----
47
48// expected-error@below {{coefficientModulus should not be 0}}
49#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=0>
50
51// -----
52
53// expected-error@below {{coefficientModulus should be positive}}
54#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=-1>
55
56// -----
57
58// expected-error@below {{coefficientModulus needs bit width of 33 but coefficientType can only contain 32 bits}}
59#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=4294967297>
60
61// -----
62
63#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=4294967296>
64
65// -----
66
67// expected-error@below {{coefficientModulus should be positive}}
68#ring1 = #polynomial.ring<coefficientType=i64, coefficientModulus=18446744073709551615>
69
70// -----
71
72// unfortunately, coefficientModulus of 64bit should be contained in larger type
73#ring1 = #polynomial.ring<coefficientType=i64, coefficientModulus=18446744073709551615 : i128>
74