structure-ops.mlir
21.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
// RUN: mlir-opt -allow-unregistered-dialect -split-input-file -verify-diagnostics %s | FileCheck %s
//===----------------------------------------------------------------------===//
// spv._address_of
//===----------------------------------------------------------------------===//
spv.module Logical GLSL450 {
spv.globalVariable @var1 : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Input>
spv.func @access_chain() -> () "None" {
%0 = spv.constant 1: i32
// CHECK: [[VAR1:%.*]] = spv._address_of @var1 : !spv.ptr<!spv.struct<f32, !spv.array<4 x f32>>, Input>
// CHECK-NEXT: spv.AccessChain [[VAR1]][{{.*}}, {{.*}}] : !spv.ptr<!spv.struct<f32, !spv.array<4 x f32>>, Input>
%1 = spv._address_of @var1 : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Input>
%2 = spv.AccessChain %1[%0, %0] : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Input>, i32, i32
spv.Return
}
}
// -----
// Allow taking address of global variables in other module-like ops
spv.globalVariable @var : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Input>
func @address_of() -> () {
// CHECK: spv._address_of @var
%1 = spv._address_of @var : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Input>
return
}
// -----
spv.module Logical GLSL450 {
spv.globalVariable @var1 : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Input>
spv.func @foo() -> () "None" {
// expected-error @+1 {{expected spv.globalVariable symbol}}
%0 = spv._address_of @var2 : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Input>
}
}
// -----
spv.module Logical GLSL450 {
spv.globalVariable @var1 : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Input>
spv.func @foo() -> () "None" {
// expected-error @+1 {{result type mismatch with the referenced global variable's type}}
%0 = spv._address_of @var1 : !spv.ptr<f32, Input>
}
}
// -----
//===----------------------------------------------------------------------===//
// spv.constant
//===----------------------------------------------------------------------===//
func @const() -> () {
// CHECK: spv.constant true
// CHECK: spv.constant 42 : i32
// CHECK: spv.constant 5.000000e-01 : f32
// CHECK: spv.constant dense<[2, 3]> : vector<2xi32>
// CHECK: spv.constant [dense<3.000000e+00> : vector<2xf32>] : !spv.array<1 x vector<2xf32>>
// CHECK: spv.constant dense<1> : tensor<2x3xi32> : !spv.array<2 x !spv.array<3 x i32>>
// CHECK: spv.constant dense<1.000000e+00> : tensor<2x3xf32> : !spv.array<2 x !spv.array<3 x f32>>
// CHECK: spv.constant dense<{{\[}}[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi32> : !spv.array<2 x !spv.array<3 x i32>>
// CHECK: spv.constant dense<{{\[}}[1.000000e+00, 2.000000e+00, 3.000000e+00], [4.000000e+00, 5.000000e+00, 6.000000e+00]]> : tensor<2x3xf32> : !spv.array<2 x !spv.array<3 x f32>>
%0 = spv.constant true
%1 = spv.constant 42 : i32
%2 = spv.constant 0.5 : f32
%3 = spv.constant dense<[2, 3]> : vector<2xi32>
%4 = spv.constant [dense<3.0> : vector<2xf32>] : !spv.array<1xvector<2xf32>>
%5 = spv.constant dense<1> : tensor<2x3xi32> : !spv.array<2 x !spv.array<3 x i32>>
%6 = spv.constant dense<1.0> : tensor<2x3xf32> : !spv.array<2 x !spv.array<3 x f32>>
%7 = spv.constant dense<[[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi32> : !spv.array<2 x !spv.array<3 x i32>>
%8 = spv.constant dense<[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]> : tensor<2x3xf32> : !spv.array<2 x !spv.array<3 x f32>>
return
}
// -----
func @unaccepted_std_attr() -> () {
// expected-error @+1 {{cannot have value of type 'none'}}
%0 = spv.constant unit : none
return
}
// -----
func @array_constant() -> () {
// expected-error @+1 {{has array element whose type ('vector<2xi32>') does not match the result element type ('vector<2xf32>')}}
%0 = spv.constant [dense<3.0> : vector<2xf32>, dense<4> : vector<2xi32>] : !spv.array<2xvector<2xf32>>
return
}
// -----
func @array_constant() -> () {
// expected-error @+1 {{must have spv.array result type for array value}}
%0 = spv.constant [dense<3.0> : vector<2xf32>] : !spv.rtarray<vector<2xf32>>
return
}
// -----
func @non_nested_array_constant() -> () {
// expected-error @+1 {{only support nested array result type}}
%0 = spv.constant dense<3.0> : tensor<2x2xf32> : !spv.array<2xvector<2xf32>>
return
}
// -----
func @value_result_type_mismatch() -> () {
// expected-error @+1 {{must have spv.array result type for array value}}
%0 = "spv.constant"() {value = dense<0> : tensor<4xi32>} : () -> (vector<4xi32>)
}
// -----
func @value_result_type_mismatch() -> () {
// expected-error @+1 {{result element type ('i32') does not match value element type ('f32')}}
%0 = spv.constant dense<1.0> : tensor<2x3xf32> : !spv.array<2 x !spv.array<3 x i32>>
}
// -----
func @value_result_num_elements_mismatch() -> () {
// expected-error @+1 {{result number of elements (6) does not match value number of elements (4)}}
%0 = spv.constant dense<1.0> : tensor<2x2xf32> : !spv.array<2 x !spv.array<3 x f32>>
return
}
// -----
//===----------------------------------------------------------------------===//
// spv.EntryPoint
//===----------------------------------------------------------------------===//
spv.module Logical GLSL450 {
spv.func @do_nothing() -> () "None" {
spv.Return
}
// CHECK: spv.EntryPoint "GLCompute" @do_nothing
spv.EntryPoint "GLCompute" @do_nothing
}
spv.module Logical GLSL450 {
spv.globalVariable @var2 : !spv.ptr<f32, Input>
spv.globalVariable @var3 : !spv.ptr<f32, Output>
spv.func @do_something(%arg0 : !spv.ptr<f32, Input>, %arg1 : !spv.ptr<f32, Output>) -> () "None" {
%1 = spv.Load "Input" %arg0 : f32
spv.Store "Output" %arg1, %1 : f32
spv.Return
}
// CHECK: spv.EntryPoint "GLCompute" @do_something, @var2, @var3
spv.EntryPoint "GLCompute" @do_something, @var2, @var3
}
// -----
spv.module Logical GLSL450 {
spv.func @do_nothing() -> () "None" {
spv.Return
}
// expected-error @+1 {{invalid kind of attribute specified}}
spv.EntryPoint "GLCompute" "do_nothing"
}
// -----
spv.module Logical GLSL450 {
spv.func @do_nothing() -> () "None" {
spv.Return
}
// expected-error @+1 {{function 'do_something' not found in 'spv.module'}}
spv.EntryPoint "GLCompute" @do_something
}
/// TODO: Add a test that verifies an error is thrown
/// when interface entries of EntryPointOp are not
/// spv.Variables. There is currently no other op that has a spv.ptr
/// return type
// -----
spv.module Logical GLSL450 {
spv.func @do_nothing() -> () "None" {
// expected-error @+1 {{op must appear in a module-like op's block}}
spv.EntryPoint "GLCompute" @do_something
}
}
// -----
spv.module Logical GLSL450 {
spv.func @do_nothing() -> () "None" {
spv.Return
}
spv.EntryPoint "GLCompute" @do_nothing
// expected-error @+1 {{duplicate of a previous EntryPointOp}}
spv.EntryPoint "GLCompute" @do_nothing
}
// -----
spv.module Logical GLSL450 {
spv.func @do_nothing() -> () "None" {
spv.Return
}
spv.EntryPoint "GLCompute" @do_nothing
// expected-error @+1 {{'spv.EntryPoint' invalid execution_model attribute specification: "ContractionOff"}}
spv.EntryPoint "ContractionOff" @do_nothing
}
// -----
//===----------------------------------------------------------------------===//
// spv.func
//===----------------------------------------------------------------------===//
// CHECK: spv.func @foo() "None"
spv.func @foo() "None"
// CHECK: spv.func @bar(%{{.+}}: i32) -> i32 "Inline|Pure" {
spv.func @bar(%arg: i32) -> (i32) "Inline|Pure" {
// CHECK-NEXT: spv.
spv.ReturnValue %arg: i32
// CHECK-NEXT: }
}
// CHECK: spv.func @baz(%{{.+}}: i32) "DontInline" attributes {additional_stuff = 64 : i64}
spv.func @baz(%arg: i32) "DontInline" attributes {
additional_stuff = 64
} { spv.Return }
// -----
// expected-error @+1 {{expected function_control attribute specified as string}}
spv.func @missing_function_control() { spv.Return }
// -----
// expected-error @+1 {{cannot have more than one result}}
spv.func @cannot_have_more_than_one_result(%arg: i32) -> (i32, i32) "None"
// -----
// expected-error @+1 {{expected SSA identifier}}
spv.func @cannot_have_variadic_arguments(%arg: i32, ...) "None"
// -----
// Nested function
spv.module Logical GLSL450 {
spv.func @outer_func() -> () "None" {
// expected-error @+1 {{must appear in a module-like op's block}}
spv.func @inner_func() -> () "None" {
spv.Return
}
spv.Return
}
}
// -----
//===----------------------------------------------------------------------===//
// spv.globalVariable
//===----------------------------------------------------------------------===//
spv.module Logical GLSL450 {
// CHECK: spv.globalVariable @var0 : !spv.ptr<f32, Input>
spv.globalVariable @var0 : !spv.ptr<f32, Input>
}
// TODO: Fix test case after initialization with normal constant is addressed
// spv.module Logical GLSL450 {
// %0 = spv.constant 4.0 : f32
// // CHECK1: spv.Variable init(%0) : !spv.ptr<f32, Private>
// spv.globalVariable @var1 init(%0) : !spv.ptr<f32, Private>
// }
// -----
spv.module Logical GLSL450 {
spv.specConstant @sc = 4.0 : f32
// CHECK: spv.globalVariable @var initializer(@sc) : !spv.ptr<f32, Private>
spv.globalVariable @var initializer(@sc) : !spv.ptr<f32, Private>
}
// -----
// Allow initializers coming from other module-like ops
spv.specConstant @sc = 4.0 : f32
// CHECK: spv.globalVariable @var initializer(@sc)
spv.globalVariable @var initializer(@sc) : !spv.ptr<f32, Private>
// -----
spv.module Logical GLSL450 {
// CHECK: spv.globalVariable @var0 bind(1, 2) : !spv.ptr<f32, Uniform>
spv.globalVariable @var0 bind(1, 2) : !spv.ptr<f32, Uniform>
}
// TODO: Fix test case after initialization with constant is addressed
// spv.module Logical GLSL450 {
// %0 = spv.constant 4.0 : f32
// // CHECK1: spv.globalVariable @var1 initializer(%0) {binding = 5 : i32} : !spv.ptr<f32, Private>
// spv.globalVariable @var1 initializer(%0) {binding = 5 : i32} : !spv.ptr<f32, Private>
// }
// -----
spv.module Logical GLSL450 {
// CHECK: spv.globalVariable @var1 built_in("GlobalInvocationID") : !spv.ptr<vector<3xi32>, Input>
spv.globalVariable @var1 built_in("GlobalInvocationID") : !spv.ptr<vector<3xi32>, Input>
// CHECK: spv.globalVariable @var2 built_in("GlobalInvocationID") : !spv.ptr<vector<3xi32>, Input>
spv.globalVariable @var2 {built_in = "GlobalInvocationID"} : !spv.ptr<vector<3xi32>, Input>
}
// -----
// Allow in other module-like ops
module {
// CHECK: spv.globalVariable
spv.globalVariable @var0 : !spv.ptr<f32, Input>
}
// -----
spv.module Logical GLSL450 {
// expected-error @+1 {{expected spv.ptr type}}
spv.globalVariable @var0 : f32
}
// -----
spv.module Logical GLSL450 {
// expected-error @+1 {{op initializer must be result of a spv.specConstant or spv.globalVariable op}}
spv.globalVariable @var0 initializer(@var1) : !spv.ptr<f32, Private>
}
// -----
spv.module Logical GLSL450 {
// expected-error @+1 {{storage class cannot be 'Generic'}}
spv.globalVariable @var0 : !spv.ptr<f32, Generic>
}
// -----
spv.module Logical GLSL450 {
// expected-error @+1 {{storage class cannot be 'Function'}}
spv.globalVariable @var0 : !spv.ptr<f32, Function>
}
// -----
spv.module Logical GLSL450 {
spv.func @foo() "None" {
// expected-error @+1 {{op must appear in a module-like op's block}}
spv.globalVariable @var0 : !spv.ptr<f32, Input>
spv.Return
}
}
// -----
//===----------------------------------------------------------------------===//
// spv.module
//===----------------------------------------------------------------------===//
// Module without capability and extension
// CHECK: spv.module Logical GLSL450
spv.module Logical GLSL450 { }
// Module with a name
// CHECK: spv.module @{{.*}} Logical GLSL450
spv.module @name Logical GLSL450 { }
// Module with (version, capabilities, extensions) triple
// CHECK: spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], [SPV_KHR_16bit_storage]>
spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], [SPV_KHR_16bit_storage]> { }
// Module with additional attributes
// CHECK: spv.module Logical GLSL450 attributes {foo = "bar"}
spv.module Logical GLSL450 attributes {foo = "bar"} { }
// Module with VCE triple and additional attributes
// CHECK: spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], [SPV_KHR_16bit_storage]> attributes {foo = "bar"}
spv.module Logical GLSL450
requires #spv.vce<v1.0, [Shader], [SPV_KHR_16bit_storage]>
attributes {foo = "bar"} { }
// Module with explicit spv._module_end
// CHECK: spv.module
spv.module Logical GLSL450 {
spv._module_end
}
// Module with function
// CHECK: spv.module
spv.module Logical GLSL450 {
spv.func @do_nothing() -> () "None" {
spv.Return
}
}
// -----
// Missing addressing model
// expected-error@+1 {{'spv.module' expected valid keyword}}
spv.module { }
// -----
// Wrong addressing model
// expected-error@+1 {{'spv.module' invalid addressing_model attribute specification: Physical}}
spv.module Physical { }
// -----
// Missing memory model
// expected-error@+1 {{'spv.module' expected valid keyword}}
spv.module Logical { }
// -----
// Wrong memory model
// expected-error@+1 {{'spv.module' invalid memory_model attribute specification: Bla}}
spv.module Logical Bla { }
// -----
// Module with multiple blocks
// expected-error @+1 {{expects region #0 to have 0 or 1 blocks}}
spv.module Logical GLSL450 {
^first:
spv.Return
^second:
spv.Return
}
// -----
// Module with wrong terminator
// expected-error@+2 {{expects regions to end with 'spv._module_end'}}
// expected-note@+1 {{in custom textual format, the absence of terminator implies 'spv._module_end'}}
"spv.module"() ({
%0 = spv.constant true
}) {addressing_model = 0 : i32, memory_model = 1 : i32} : () -> ()
// -----
// Use non SPIR-V op inside module
spv.module Logical GLSL450 {
// expected-error @+1 {{'spv.module' can only contain spv.* ops}}
"dialect.op"() : () -> ()
}
// -----
// Use non SPIR-V op inside function
spv.module Logical GLSL450 {
spv.func @do_nothing() -> () "None" {
// expected-error @+1 {{functions in 'spv.module' can only contain spv.* ops}}
"dialect.op"() : () -> ()
}
}
// -----
// Use external function
spv.module Logical GLSL450 {
// expected-error @+1 {{'spv.module' cannot contain external functions}}
spv.func @extern() -> () "None"
}
// -----
//===----------------------------------------------------------------------===//
// spv._module_end
//===----------------------------------------------------------------------===//
func @module_end_not_in_module() -> () {
// expected-error @+1 {{op must appear in a module-like op's block}}
spv._module_end
}
// -----
//===----------------------------------------------------------------------===//
// spv._reference_of
//===----------------------------------------------------------------------===//
spv.module Logical GLSL450 {
spv.specConstant @sc1 = false
spv.specConstant @sc2 = 42 : i64
spv.specConstant @sc3 = 1.5 : f32
// CHECK-LABEL: @reference
spv.func @reference() -> i1 "None" {
// CHECK: spv._reference_of @sc1 : i1
%0 = spv._reference_of @sc1 : i1
spv.ReturnValue %0 : i1
}
// CHECK-LABEL: @initialize
spv.func @initialize() -> i64 "None" {
// CHECK: spv._reference_of @sc2 : i64
%0 = spv._reference_of @sc2 : i64
%1 = spv.Variable init(%0) : !spv.ptr<i64, Function>
%2 = spv.Load "Function" %1 : i64
spv.ReturnValue %2 : i64
}
// CHECK-LABEL: @compute
spv.func @compute() -> f32 "None" {
// CHECK: spv._reference_of @sc3 : f32
%0 = spv._reference_of @sc3 : f32
%1 = spv.constant 6.0 : f32
%2 = spv.FAdd %0, %1 : f32
spv.ReturnValue %2 : f32
}
}
// -----
// Allow taking reference of spec constant in other module-like ops
spv.specConstant @sc = 5 : i32
func @reference_of() {
// CHECK: spv._reference_of @sc
%0 = spv._reference_of @sc : i32
return
}
// -----
spv.module Logical GLSL450 {
spv.func @foo() -> () "None" {
// expected-error @+1 {{expected spv.specConstant symbol}}
%0 = spv._reference_of @sc : i32
spv.Return
}
}
// -----
spv.module Logical GLSL450 {
spv.specConstant @sc = 42 : i32
spv.func @foo() -> () "None" {
// expected-error @+1 {{result type mismatch with the referenced specialization constant's type}}
%0 = spv._reference_of @sc : f32
spv.Return
}
}
// -----
//===----------------------------------------------------------------------===//
// spv.specConstant
//===----------------------------------------------------------------------===//
spv.module Logical GLSL450 {
// CHECK: spv.specConstant @sc1 = false
spv.specConstant @sc1 = false
// CHECK: spv.specConstant @sc2 spec_id(5) = 42 : i64
spv.specConstant @sc2 spec_id(5) = 42 : i64
// CHECK: spv.specConstant @sc3 = 1.500000e+00 : f32
spv.specConstant @sc3 = 1.5 : f32
}
// -----
spv.module Logical GLSL450 {
// expected-error @+1 {{SpecId cannot be negative}}
spv.specConstant @sc2 spec_id(-5) = 42 : i64
}
// -----
spv.module Logical GLSL450 {
// expected-error @+1 {{default value bitwidth disallowed}}
spv.specConstant @sc = 15 : i4
}
// -----
spv.module Logical GLSL450 {
// expected-error @+1 {{default value can only be a bool, integer, or float scalar}}
spv.specConstant @sc = dense<[2, 3]> : vector<2xi32>
}
// -----
func @use_in_function() -> () {
// expected-error @+1 {{op must appear in a module-like op's block}}
spv.specConstant @sc = false
return
}
// -----
//===----------------------------------------------------------------------===//
// spv.specConstantComposite
//===----------------------------------------------------------------------===//
spv.module Logical GLSL450 {
// expected-error @+1 {{result type must be a composite type}}
spv.specConstantComposite @scc2 (@sc1, @sc2, @sc3) : i32
}
//===----------------------------------------------------------------------===//
// spv.specConstantComposite (spv.array)
//===----------------------------------------------------------------------===//
// -----
spv.module Logical GLSL450 {
spv.specConstant @sc1 = 1.5 : f32
spv.specConstant @sc2 = 2.5 : f32
spv.specConstant @sc3 = 3.5 : f32
// CHECK: spv.specConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.array<3 x f32>
spv.specConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.array<3 x f32>
}
// -----
spv.module Logical GLSL450 {
spv.specConstant @sc1 = false
spv.specConstant @sc2 spec_id(5) = 42 : i64
spv.specConstant @sc3 = 1.5 : f32
// expected-error @+1 {{has incorrect number of operands: expected 4, but provided 3}}
spv.specConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.array<4 x f32>
}
// -----
spv.module Logical GLSL450 {
spv.specConstant @sc1 = 1 : i32
spv.specConstant @sc2 = 2.5 : f32
spv.specConstant @sc3 = 3.5 : f32
// expected-error @+1 {{has incorrect types of operands: expected 'f32', but provided 'i32'}}
spv.specConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.array<3 x f32>
}
//===----------------------------------------------------------------------===//
// spv.specConstantComposite (spv.struct)
//===----------------------------------------------------------------------===//
// -----
spv.module Logical GLSL450 {
spv.specConstant @sc1 = 1 : i32
spv.specConstant @sc2 = 2.5 : f32
spv.specConstant @sc3 = 3.5 : f32
// CHECK: spv.specConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.struct<i32, f32, f32>
spv.specConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.struct<i32, f32, f32>
}
// -----
spv.module Logical GLSL450 {
spv.specConstant @sc1 = 1 : i32
spv.specConstant @sc2 = 2.5 : f32
spv.specConstant @sc3 = 3.5 : f32
// expected-error @+1 {{has incorrect number of operands: expected 2, but provided 3}}
spv.specConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.struct<i32, f32>
}
// -----
spv.module Logical GLSL450 {
spv.specConstant @sc1 = 1.5 : f32
spv.specConstant @sc2 = 2.5 : f32
spv.specConstant @sc3 = 3.5 : f32
// expected-error @+1 {{has incorrect types of operands: expected 'i32', but provided 'f32'}}
spv.specConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.struct<i32, f32, f32>
}
//===----------------------------------------------------------------------===//
// spv.specConstantComposite (vector)
//===----------------------------------------------------------------------===//
// -----
spv.module Logical GLSL450 {
spv.specConstant @sc1 = 1.5 : f32
spv.specConstant @sc2 = 2.5 : f32
spv.specConstant @sc3 = 3.5 : f32
// CHECK: spv.specConstantComposite @scc (@sc1, @sc2, @sc3) : vector<3xf32>
spv.specConstantComposite @scc (@sc1, @sc2, @sc3) : vector<3 x f32>
}
// -----
spv.module Logical GLSL450 {
spv.specConstant @sc1 = false
spv.specConstant @sc2 spec_id(5) = 42 : i64
spv.specConstant @sc3 = 1.5 : f32
// expected-error @+1 {{has incorrect number of operands: expected 4, but provided 3}}
spv.specConstantComposite @scc (@sc1, @sc2, @sc3) : vector<4xf32>
}
// -----
spv.module Logical GLSL450 {
spv.specConstant @sc1 = 1 : i32
spv.specConstant @sc2 = 2.5 : f32
spv.specConstant @sc3 = 3.5 : f32
// expected-error @+1 {{has incorrect types of operands: expected 'f32', but provided 'i32'}}
spv.specConstantComposite @scc (@sc1, @sc2, @sc3) : vector<3xf32>
}
//===----------------------------------------------------------------------===//
// spv.specConstantComposite (spv.coopmatrix)
//===----------------------------------------------------------------------===//
// -----
spv.module Logical GLSL450 {
spv.specConstant @sc1 = 1.5 : f32
// expected-error @+1 {{unsupported composite type}}
spv.specConstantComposite @scc (@sc1) : !spv.coopmatrix<8x16xf32, Device>
}