Skip to content

Commit f6ba7a9

Browse files
committed
[mlir][emitc] Moved some test from 'invalid' to 'invalid_ops'
1 parent 453d127 commit f6ba7a9

File tree

2 files changed

+108
-120
lines changed

2 files changed

+108
-120
lines changed

mlir/test/Dialect/EmitC/invalid_ops.mlir

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,3 +466,111 @@ func.func @member_of_ptr(%arg0: i32) {
466466
%0 = "emitc.member_of_ptr" (%arg0) {member = "a"} : (i32) -> i32
467467
return
468468
}
469+
470+
// -----
471+
472+
func.func @emitc_switch() {
473+
%0 = "emitc.variable"(){value = 1 : ui16} : () -> ui16
474+
475+
// expected-error@+1 {{'emitc.switch' op expected region to end with emitc.yield, but got emitc.call_opaque}}
476+
emitc.switch %0 : ui16
477+
case 2: {
478+
%1 = emitc.call_opaque "func_b" () : () -> i32
479+
}
480+
case 5: {
481+
%2 = emitc.call_opaque "func_a" () : () -> i32
482+
emitc.yield
483+
}
484+
default: {
485+
%3 = "emitc.variable"(){value = 42.0 : f32} : () -> f32
486+
emitc.call_opaque "func2" (%3) : (f32) -> ()
487+
emitc.yield
488+
}
489+
return
490+
}
491+
492+
// -----
493+
494+
func.func @emitc_switch() {
495+
%0 = "emitc.variable"(){value = 1 : ui16} : () -> ui16
496+
497+
// expected-error@+1 {{'emitc.switch' op expected region to end with emitc.yield, but got emitc.call_opaque}}
498+
emitc.switch %0 : ui16
499+
case 2: {
500+
%1 = emitc.call_opaque "func_b" () : () -> i32
501+
emitc.yield
502+
}
503+
case 5: {
504+
%2 = emitc.call_opaque "func_a" () : () -> i32
505+
emitc.yield
506+
}
507+
default: {
508+
%3 = "emitc.variable"(){value = 42.0 : f32} : () -> f32
509+
emitc.call_opaque "func2" (%3) : (f32) -> ()
510+
}
511+
return
512+
}
513+
514+
// -----
515+
516+
func.func @emitc_switch() {
517+
%0 = "emitc.variable"(){value = 1 : i16} : () -> i16
518+
519+
emitc.switch %0 : i16
520+
case 2: {
521+
%1 = emitc.call_opaque "func_b" () : () -> i32
522+
emitc.yield
523+
}
524+
// expected-error@+1 {{custom op 'emitc.switch' expected integer value}}
525+
case : {
526+
%2 = emitc.call_opaque "func_a" () : () -> i32
527+
emitc.yield
528+
}
529+
default: {
530+
%3 = "emitc.variable"(){value = 42.0 : f32} : () -> f32
531+
emitc.call_opaque "func2" (%3) : (f32) -> ()
532+
emitc.yield
533+
}
534+
return
535+
}
536+
537+
// -----
538+
539+
func.func @emitc_switch() {
540+
%0 = "emitc.variable"(){value = 1 : i16} : () -> i16
541+
542+
emitc.switch %0 : i16
543+
case 2: {
544+
%1 = emitc.call_opaque "func_b" () : () -> i32
545+
emitc.yield
546+
}
547+
case 3: {
548+
%2 = emitc.call_opaque "func_a" () : () -> i32
549+
emitc.yield
550+
}
551+
// expected-error@+1 {{custom op 'emitc.switch' expected 'default'}}
552+
return
553+
}
554+
555+
// -----
556+
557+
func.func @emitc_switch() {
558+
%0 = "emitc.variable"(){value = 1 : i16} : () -> i16
559+
560+
// expected-error@+1 {{'emitc.switch' op has duplicate case value: 2}}
561+
emitc.switch %0 : i16
562+
case 2: {
563+
%1 = emitc.call_opaque "func_b" () : () -> i32
564+
emitc.yield
565+
}
566+
case 2: {
567+
%2 = emitc.call_opaque "func_a" () : () -> i32
568+
emitc.yield
569+
}
570+
default: {
571+
%3 = "emitc.variable"(){value = 42.0 : f32} : () -> f32
572+
emitc.call_opaque "func2" (%3) : (f32) -> ()
573+
emitc.yield
574+
}
575+
return
576+
}

mlir/test/Target/Cpp/invalid.mlir

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -86,123 +86,3 @@ func.func @ptr_to_array() {
8686
%v = "emitc.variable"(){value = #emitc.opaque<"NULL">} : () -> !emitc.ptr<!emitc.array<9xi16>>
8787
return
8888
}
89-
90-
// -----
91-
92-
func.func @emitc_switch() {
93-
%0 = "emitc.variable"(){value = 1 : ui16} : () -> ui16
94-
95-
// expected-error@+1 {{'emitc.switch' op expected region to end with emitc.yield, but got emitc.call_opaque}}
96-
emitc.switch %0 : ui16
97-
case 2: {
98-
%1 = emitc.call_opaque "func_b" () : () -> i32
99-
}
100-
case 5: {
101-
%2 = emitc.call_opaque "func_a" () : () -> i32
102-
emitc.yield
103-
}
104-
default: {
105-
%3 = "emitc.variable"(){value = 42.0 : f32} : () -> f32
106-
%4 = "emitc.variable"(){value = 42.0 : f32} : () -> f32
107-
108-
emitc.call_opaque "func2" (%3) : (f32) -> ()
109-
emitc.call_opaque "func3" (%3, %4) { args = [1 : index, 0 : index] } : (f32, f32) -> ()
110-
emitc.yield
111-
}
112-
return
113-
}
114-
115-
// -----
116-
117-
func.func @emitc_switch() {
118-
%0 = "emitc.variable"(){value = 1 : ui16} : () -> ui16
119-
120-
// expected-error@+1 {{'emitc.switch' op expected region to end with emitc.yield, but got emitc.call_opaque}}
121-
emitc.switch %0 : ui16
122-
case 2: {
123-
%1 = emitc.call_opaque "func_b" () : () -> i32
124-
emitc.yield
125-
}
126-
case 5: {
127-
%2 = emitc.call_opaque "func_a" () : () -> i32
128-
emitc.yield
129-
}
130-
default: {
131-
%3 = "emitc.variable"(){value = 42.0 : f32} : () -> f32
132-
%4 = "emitc.variable"(){value = 42.0 : f32} : () -> f32
133-
134-
emitc.call_opaque "func2" (%3) : (f32) -> ()
135-
emitc.call_opaque "func3" (%3, %4) { args = [1 : index, 0 : index] } : (f32, f32) -> ()
136-
}
137-
return
138-
}
139-
140-
// -----
141-
142-
func.func @emitc_switch() {
143-
%0 = "emitc.variable"(){value = 1 : i16} : () -> i16
144-
145-
emitc.switch %0 : i16
146-
case 2: {
147-
%1 = emitc.call_opaque "func_b" () : () -> i32
148-
emitc.yield
149-
}
150-
// expected-error@+1 {{custom op 'emitc.switch' expected integer value}}
151-
case : {
152-
%2 = emitc.call_opaque "func_a" () : () -> i32
153-
emitc.yield
154-
}
155-
default: {
156-
%3 = "emitc.variable"(){value = 42.0 : f32} : () -> f32
157-
%4 = "emitc.variable"(){value = 42.0 : f32} : () -> f32
158-
159-
emitc.call_opaque "func2" (%3) : (f32) -> ()
160-
emitc.call_opaque "func3" (%3, %4) { args = [1 : index, 0 : index] } : (f32, f32) -> ()
161-
emitc.yield
162-
}
163-
return
164-
}
165-
166-
// -----
167-
168-
func.func @emitc_switch() {
169-
%0 = "emitc.variable"(){value = 1 : i16} : () -> i16
170-
171-
emitc.switch %0 : i16
172-
case 2: {
173-
%1 = emitc.call_opaque "func_b" () : () -> i32
174-
emitc.yield
175-
}
176-
case 3: {
177-
%2 = emitc.call_opaque "func_a" () : () -> i32
178-
emitc.yield
179-
}
180-
// expected-error@+1 {{custom op 'emitc.switch' expected 'default'}}
181-
return
182-
}
183-
184-
// -----
185-
186-
func.func @emitc_switch() {
187-
%0 = "emitc.variable"(){value = 1 : i16} : () -> i16
188-
189-
// expected-error@+1 {{'emitc.switch' op has duplicate case value: 2}}
190-
emitc.switch %0 : i16
191-
case 2: {
192-
%1 = emitc.call_opaque "func_b" () : () -> i32
193-
emitc.yield
194-
}
195-
case 2: {
196-
%2 = emitc.call_opaque "func_a" () : () -> i32
197-
emitc.yield
198-
}
199-
default: {
200-
%3 = "emitc.variable"(){value = 42.0 : f32} : () -> f32
201-
%4 = "emitc.variable"(){value = 42.0 : f32} : () -> f32
202-
203-
emitc.call_opaque "func2" (%3) : (f32) -> ()
204-
emitc.call_opaque "func3" (%3, %4) { args = [1 : index, 0 : index] } : (f32, f32) -> ()
205-
emitc.yield
206-
}
207-
return
208-
}

0 commit comments

Comments
 (0)