1 // RUN: mlir-opt %s -split-input-file -verify-diagnostics
3 // Check different error cases.
5 #hello_world = affine_map<(i, j) -> ((), j)> // expected-error {{no expression inside parentheses}}
8 #hello_world = affine_map<(i, j) -> (->, j) // expected-error {{expected affine expression}}
11 #hello_world = affine_map<(i, j) -> (:) // expected-error {{expected affine expression}}
14 #hello_world = affine_map<(i, j) -> (, j)> // expected-error {{expected affine expression}}
17 #hello_world affine_map<(i, j) [s0] -> (i, j)> // expected-error {{expected '=' in attribute alias definition}}
20 #hello_world = affine_map<(i, j) [s0] -> (2*i*, 3*j*i*2 + 5)> // expected-error {{missing right operand of binary op}}
23 #hello_world = affine_map<(i, j) [s0] -> (i+, i+j+2 + 5)> // expected-error {{missing right operand of binary op}}
26 #hello_world = affine_map<(i, j) [s0] -> ((s0 + i, j)> // expected-error {{expected ')'}}
29 #hello_world = affine_map<(i, j) [s0] -> (((s0 + (i + j) + 5), j)> // expected-error {{expected ')'}}
33 // expected-error @+1 {{expected '(' in affine map range}}
34 #hello_world = affine_map<(i, j) [s0] -> i + s0, j)>
37 #hello_world = affine_map<(i, j) [s0] -> (x)> // expected-error {{use of undeclared identifier}}
40 #hello_world = affine_map<(i, j, i) [s0] -> (i)> // expected-error {{redefinition of identifier 'i'}}
43 #hello_world = affine_map<(i, j) [s0, s1, s0] -> (i)> // expected-error {{redefinition of identifier 's0'}}
46 #hello_world = affine_map<(i, j) [i, s0] -> (j)> // expected-error {{redefinition of identifier 'i'}}
49 #hello_world = affine_map<(i, j) [s0, s1] -> (+i, j)> // expected-error {{missing left operand of binary op}}
54 #hello_world = affine_map<(i, j) [s0, s1] -> (i, *j)> // expected-error {{missing left operand of binary op}}
57 #hello_world = affine_map<(i, j) [s0, s1] -> (floordiv i 2, j)> // expected-error {{use of undeclared identifier}}
60 #hello_world = affine_map<(i, j) [s0, s1] -> (ceildiv i 2, j)> // expected-error {{use of undeclared identifier}}
63 #hello_world = affine_map<(i, j) [s0, s1] -> (mod i 2, j)> // expected-error {{use of undeclared identifier}}
66 #hello_world = affine_map<(i, j) [s0, s1] -> (-(), j)>
67 // expected-error@-1 {{no expression inside parentheses}}
68 // expected-error@-2 {{missing operand of negation}}
71 #hello_world = affine_map<(i, j) [s0, s1] -> (i, *j+5)> // expected-error {{missing left operand of binary op}}
74 #hello_world = affine_map<(i, j) [s0, s1] -> (i, floordiv j+5)> // expected-error {{use of undeclared identifier}}
77 #hello_world = affine_map<(i, j) [s0, s1] -> (i, ceildiv j+5)> // expected-error {{use of undeclared identifier}}
80 #hello_world = affine_map<(i, j) [s0, s1] -> (i, mod j+5)> // expected-error {{use of undeclared identifier}}
83 #hello_world = affine_map<(i, j) [s0, s1] -> (i*j, j)> // expected-error {{non-affine expression: at least one of the multiply operands has to be either a constant or symbolic}}
86 #hello_world = affine_map<(i, j) [s0, s1] -> (i, j + j ceildiv 128 mod 16 * i - 4)> // expected-error {{non-affine expression: at least one of the multiply operands has to be either a constant or symbolic}}
89 #hello_world = affine_map<(i, j) [s0, s1] -> (i, j floordiv i)> // expected-error {{non-affine expression: right operand of floordiv has to be either a constant or symbolic}}
92 #hello_world = affine_map<(i, j) [s0, s1] -> (i, i*2 ceildiv j*5)> // expected-error {{non-affine expression: right operand of ceildiv has to be either a constant or symbolic}}
95 #hello_world = affine_map<(i, j) [s0, s1] -> (i, i mod (2+i))> // expected-error {{non-affine expression: right operand of mod has to be either a constant or symbolic}}
98 // expected-error @+1 {{expected ')' in affine map range}}
99 #hello_world = affine_map<(i, j) [s0, s1] -> (-1*i j, j)>
102 #hello_world = affine_map<(i, j) -> (i, 3*d0 + )> // expected-error {{use of undeclared identifier}}
104 // TODO: Add more tests; coverage of error messages emitted not complete
107 #ABC = affine_map<(i,j) -> (i+j)>
108 #ABC = affine_map<(i,j) -> (i+j)> // expected-error {{redefinition of attribute alias id 'ABC'}}
112 #map = affine_map<(d0) -> (%)> // expected-error {{invalid SSA name}}
116 func.func @invalid_affine_structure() {
117 %c0 = arith.constant 0 : index
118 %idx = affine.apply affine_map<(d0, d1)> (%c0, %c0) // expected-error {{expected '->' or ':'}}