Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 1 | // TODO(andydavis) Resolve relative path issue w.r.t invoking mlir-opt in RUN |
| 2 | // statements (perhaps through using lit config substitutions). |
| 3 | // |
| 4 | // RUN: %S/../../mlir-opt %s -o - -check-parser-errors |
Jacques Pienaar | bae4051 | 2018-06-24 09:10:36 -0700 | [diff] [blame] | 5 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 6 | // Check different error cases. |
| 7 | // ----- |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 8 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 9 | extfunc @illegaltype(i) // expected-error {{expected type}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 10 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 11 | // ----- |
Jacques Pienaar | ca4c4a0 | 2018-06-25 08:10:46 -0700 | [diff] [blame] | 12 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 13 | extfunc @nestedtensor(tensor<tensor<i8>>) -> () // expected-error {{expected type}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 14 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 15 | // ----- |
MLIR Team | 718c82f | 2018-07-16 09:45:22 -0700 | [diff] [blame] | 16 | // Test no comma in memref type. |
| 17 | // TODO(andydavis) Fix this test if we decide to allow empty affine map to |
| 18 | // imply identity affine map. |
| 19 | extfunc @memrefs(memref<2x4xi8>) ; expected-error {{expected ',' in memref type}} |
| 20 | |
| 21 | // ----- |
| 22 | // Test no map in memref type. |
| 23 | extfunc @memrefs(memref<2x4xi8, >) ; expected-error {{expected list element}} |
| 24 | |
| 25 | // ----- |
| 26 | // Test non-existent map in memref type. |
| 27 | extfunc @memrefs(memref<2x4xi8, #map7>) ; expected-error {{undefined affine map id 'map7'}} |
| 28 | |
| 29 | // ----- |
| 30 | // Test non hash identifier in memref type. |
| 31 | extfunc @memrefs(memref<2x4xi8, %map7>) ; expected-error {{expected '(' at start of dimensional identifiers list}} |
| 32 | |
| 33 | // ----- |
| 34 | // Test non-existent map in map composition of memref type. |
| 35 | #map0 = (d0, d1) -> (d0, d1) |
| 36 | |
| 37 | extfunc @memrefs(memref<2x4xi8, #map0, #map8>) ; expected-error {{undefined affine map id 'map8'}} |
| 38 | |
| 39 | // ----- |
| 40 | // Test multiple memory space error. |
| 41 | #map0 = (d0, d1) -> (d0, d1) |
| 42 | extfunc @memrefs(memref<2x4xi8, #map0, 1, 2>) ; expected-error {{multiple memory spaces specified in memref type}} |
| 43 | |
| 44 | // ----- |
| 45 | // Test affine map after memory space. |
| 46 | #map0 = (d0, d1) -> (d0, d1) |
| 47 | #map1 = (d0, d1) -> (d0, d1) |
| 48 | |
| 49 | extfunc @memrefs(memref<2x4xi8, #map0, 1, #map1>) ; expected-error {{affine map after memory space in memref type}} |
| 50 | |
| 51 | // ----- |
| 52 | // Test no memory space error. |
| 53 | #map0 = (d0, d1) -> (d0, d1) |
| 54 | extfunc @memrefs(memref<2x4xi8, #map0>) ; expected-error {{expected memory space in memref type}} |
| 55 | |
| 56 | // ----- |
Jacques Pienaar | ca4c4a0 | 2018-06-25 08:10:46 -0700 | [diff] [blame] | 57 | |
Jacques Pienaar | bae4051 | 2018-06-24 09:10:36 -0700 | [diff] [blame] | 58 | cfgfunc @foo() |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 59 | cfgfunc @bar() // expected-error {{expected '{' in CFG function}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 60 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 61 | // ----- |
Jacques Pienaar | ca4c4a0 | 2018-06-25 08:10:46 -0700 | [diff] [blame] | 62 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 63 | extfunc missingsigil() -> (i1, affineint, f32) // expected-error {{expected a function identifier like}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 64 | |
| 65 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 66 | // ----- |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 67 | |
| 68 | cfgfunc @bad_branch() { |
| 69 | bb42: |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 70 | br missing // expected-error {{reference to an undefined basic block 'missing'}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 73 | // ----- |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 74 | |
| 75 | cfgfunc @block_redef() { |
| 76 | bb42: |
| 77 | return |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 78 | bb42: // expected-error {{redefinition of block 'bb42'}} |
Jacques Pienaar | ca4c4a0 | 2018-06-25 08:10:46 -0700 | [diff] [blame] | 79 | return |
| 80 | } |
| 81 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 82 | // ----- |
Jacques Pienaar | ca4c4a0 | 2018-06-25 08:10:46 -0700 | [diff] [blame] | 83 | |
| 84 | cfgfunc @no_terminator() { |
| 85 | bb40: |
| 86 | return |
| 87 | bb41: |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 88 | bb42: // expected-error {{expected operation name}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 89 | return |
| 90 | } |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 91 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 92 | // ----- |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 93 | |
| 94 | mlfunc @foo() |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 95 | mlfunc @bar() // expected-error {{expected '{' in ML function}} |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 96 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 97 | // ----- |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 98 | |
| 99 | mlfunc @no_return() { |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 100 | } // expected-error {{ML function must end with return statement}} |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 101 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 102 | // ----- |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 103 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 104 | " // expected-error {{expected}} |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 105 | " |
| 106 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 107 | // ----- |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 108 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 109 | " // expected-error {{expected}} |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 110 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 111 | // ----- |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 112 | |
Chris Lattner | 3b2ef76 | 2018-07-18 15:31:25 -0700 | [diff] [blame] | 113 | cfgfunc @bad_op_type() { |
| 114 | bb40: |
| 115 | "foo"() : i32 // expected-error {{expected function type}} |
| 116 | return |
| 117 | } |
| 118 | // ----- |
| 119 | |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 120 | cfgfunc @no_terminator() { |
| 121 | bb40: |
Chris Lattner | 3b2ef76 | 2018-07-18 15:31:25 -0700 | [diff] [blame] | 122 | "foo"() : ()->() |
| 123 | ""() : ()->() // expected-error {{empty operation name is invalid}} |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 124 | return |
| 125 | } |
Chris Lattner | f958bbe | 2018-06-29 22:08:05 -0700 | [diff] [blame] | 126 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 127 | // ----- |
Chris Lattner | f958bbe | 2018-06-29 22:08:05 -0700 | [diff] [blame] | 128 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 129 | extfunc @illegaltype(i0) // expected-error {{invalid integer width}} |
Chris Lattner | f958bbe | 2018-06-29 22:08:05 -0700 | [diff] [blame] | 130 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 131 | // ----- |
Chris Lattner | f958bbe | 2018-06-29 22:08:05 -0700 | [diff] [blame] | 132 | |
Tatiana Shpeisman | 1da50c4 | 2018-07-19 09:52:39 -0700 | [diff] [blame] | 133 | mlfunc @malformed_for() { |
| 134 | for %i = 1 too 10 { // expected-error {{expected 'to' between bounds}} |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | // ----- |
| 139 | |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 140 | mlfunc @incomplete_for() { |
Tatiana Shpeisman | 1da50c4 | 2018-07-19 09:52:39 -0700 | [diff] [blame] | 141 | for %i = 1 to 10 step 2 |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 142 | } // expected-error {{expected '{' before statement list}} |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 143 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 144 | // ----- |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 145 | |
Tatiana Shpeisman | 1da50c4 | 2018-07-19 09:52:39 -0700 | [diff] [blame] | 146 | mlfunc @nonconstant_step(%1 : i32) { |
| 147 | for %2 = 1 to 5 step %1 { // expected-error {{expected non-negative integer for now}} |
| 148 | |
| 149 | // ----- |
| 150 | |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 151 | mlfunc @non_statement() { |
Tatiana Shpeisman | 565b964 | 2018-07-16 11:47:09 -0700 | [diff] [blame] | 152 | asd // expected-error {{expected operation name in quotes}} |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 153 | } |
Chris Lattner | 7121b80 | 2018-07-04 20:45:39 -0700 | [diff] [blame] | 154 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 155 | // ----- |
Chris Lattner | 7121b80 | 2018-07-04 20:45:39 -0700 | [diff] [blame] | 156 | |
Chris Lattner | 21e67f6 | 2018-07-06 10:46:19 -0700 | [diff] [blame] | 157 | cfgfunc @malformed_dim() { |
| 158 | bb42: |
Chris Lattner | 3b2ef76 | 2018-07-18 15:31:25 -0700 | [diff] [blame] | 159 | "dim"(){index: "xyz"} : ()->i32 // expected-error {{'dim' op requires an integer attribute named 'index'}} |
Chris Lattner | 21e67f6 | 2018-07-06 10:46:19 -0700 | [diff] [blame] | 160 | return |
| 161 | } |
| 162 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 163 | // ----- |
Jacques Pienaar | 0bffd86 | 2018-07-11 13:26:23 -0700 | [diff] [blame] | 164 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 165 | #map = (d0) -> (% // expected-error {{invalid SSA name}} |
Jacques Pienaar | 0bffd86 | 2018-07-11 13:26:23 -0700 | [diff] [blame] | 166 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 167 | // ----- |
Chris Lattner | 7f9cc27 | 2018-07-19 08:35:28 -0700 | [diff] [blame] | 168 | |
| 169 | cfgfunc @test() { |
| 170 | bb40: |
Chris Lattner | f8cce87 | 2018-07-20 09:28:54 -0700 | [diff] [blame^] | 171 | %1 = "foo"() : (i32)->i64 // expected-error {{expected 0 operand types but had 1}} |
Chris Lattner | 7f9cc27 | 2018-07-19 08:35:28 -0700 | [diff] [blame] | 172 | return |
| 173 | } |
| 174 | |
Chris Lattner | 7f9cc27 | 2018-07-19 08:35:28 -0700 | [diff] [blame] | 175 | // ----- |
| 176 | |
| 177 | cfgfunc @redef() { |
| 178 | bb42: |
| 179 | %x = "dim"(){index: 0} : ()->i32 |
| 180 | %x = "dim"(){index: 0} : ()->i32 // expected-error {{redefinition of SSA value %x}} |
| 181 | return |
Tatiana Shpeisman | 1da50c4 | 2018-07-19 09:52:39 -0700 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | mlfunc @missing_rbrace() { |
| 185 | return %a |
| 186 | mlfunc @d {return} // expected-error {{expected ',' or '}'}} |
| 187 | |
| 188 | // ----- |
| 189 | |
| 190 | mlfunc @malformed_type(%a : intt) { // expected-error {{expected type}} |
| 191 | } |
| 192 | |
| 193 | // ----- |
| 194 | |