121 lines · plain
1// RUN: mlir-opt %s -split-input-file -verify-diagnostics2 3// Check different error cases.4// -----5#hello_world = affine_map<(i, j) -> ((), j)> // expected-error {{no expression inside parentheses}}6 7// -----8#hello_world = affine_map<(i, j) -> (->, j) // expected-error {{expected affine expression}}9 10// -----11#hello_world = affine_map<(i, j) -> (:) // expected-error {{expected affine expression}}12 13// -----14#hello_world = affine_map<(i, j) -> (, j)> // expected-error {{expected affine expression}}15 16// -----17#hello_world affine_map<(i, j) [s0] -> (i, j)> // expected-error {{expected '=' in attribute alias definition}}18 19// -----20#hello_world = affine_map<(i, j) [s0] -> (2*i*, 3*j*i*2 + 5)> // expected-error {{missing right operand of binary op}}21 22// -----23#hello_world = affine_map<(i, j) [s0] -> (i+, i+j+2 + 5)> // expected-error {{missing right operand of binary op}}24 25// -----26#hello_world = affine_map<(i, j) [s0] -> ((s0 + i, j)> // expected-error {{expected ')'}}27 28// -----29#hello_world = affine_map<(i, j) [s0] -> (((s0 + (i + j) + 5), j)> // expected-error {{expected ')'}}30 31// -----32 33// expected-error @+1 {{expected '(' in affine map range}}34#hello_world = affine_map<(i, j) [s0] -> i + s0, j)>35 36// -----37#hello_world = affine_map<(i, j) [s0] -> (x)> // expected-error {{use of undeclared identifier}}38 39// -----40#hello_world = affine_map<(i, j, i) [s0] -> (i)> // expected-error {{redefinition of identifier 'i'}}41 42// -----43#hello_world = affine_map<(i, j) [s0, s1, s0] -> (i)> // expected-error {{redefinition of identifier 's0'}}44 45// -----46#hello_world = affine_map<(i, j) [i, s0] -> (j)> // expected-error {{redefinition of identifier 'i'}}47 48// -----49#hello_world = affine_map<(i, j) [s0, s1] -> (+i, j)> // expected-error {{missing left operand of binary op}}50 51// -----52 53 54#hello_world = affine_map<(i, j) [s0, s1] -> (i, *j)> // expected-error {{missing left operand of binary op}}55 56// -----57#hello_world = affine_map<(i, j) [s0, s1] -> (floordiv i 2, j)> // expected-error {{use of undeclared identifier}}58 59// -----60#hello_world = affine_map<(i, j) [s0, s1] -> (ceildiv i 2, j)> // expected-error {{use of undeclared identifier}}61 62// -----63#hello_world = affine_map<(i, j) [s0, s1] -> (mod i 2, j)> // expected-error {{use of undeclared identifier}}64 65// -----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}}69 70// -----71#hello_world = affine_map<(i, j) [s0, s1] -> (i, *j+5)> // expected-error {{missing left operand of binary op}}72 73// -----74#hello_world = affine_map<(i, j) [s0, s1] -> (i, floordiv j+5)> // expected-error {{use of undeclared identifier}}75 76// -----77#hello_world = affine_map<(i, j) [s0, s1] -> (i, ceildiv j+5)> // expected-error {{use of undeclared identifier}}78 79// -----80#hello_world = affine_map<(i, j) [s0, s1] -> (i, mod j+5)> // expected-error {{use of undeclared identifier}}81 82// -----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}}84 85// -----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}}87 88// -----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}}90 91// -----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}}93 94// -----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}}96 97// -----98// expected-error @+1 {{expected ')' in affine map range}}99#hello_world = affine_map<(i, j) [s0, s1] -> (-1*i j, j)>100 101// -----102#hello_world = affine_map<(i, j) -> (i, 3*d0 + )> // expected-error {{use of undeclared identifier}}103 104// TODO: Add more tests; coverage of error messages emitted not complete105 106// -----107#ABC = affine_map<(i,j) -> (i+j)>108#ABC = affine_map<(i,j) -> (i+j)> // expected-error {{redefinition of attribute alias id 'ABC'}}109 110// -----111 112#map = affine_map<(d0) -> (%)> // expected-error {{invalid SSA name}}113 114// -----115 116func.func @invalid_affine_structure() {117 %c0 = arith.constant 0 : index118 %idx = affine.apply affine_map<(d0, d1)> (%c0, %c0) // expected-error {{expected '->' or ':'}}119 return120}121