File: OpSpecConstant.spvasm

package info (click to toggle)
spirv-llvm-translator 11.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,688 kB
  • sloc: cpp: 40,164; lisp: 2,185; sh: 215; python: 150; makefile: 17
file content (173 lines) | stat: -rw-r--r-- 9,604 bytes parent folder | download | duplicates (4)
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
; REQUIRES: spirv-as
; RUN: spirv-as --target-env spv1.0 -o %t.spv %s

; RUN: llvm-spirv -spec-const-info %t.spv | FileCheck %s --check-prefix=CHECK-INFO
; CHECK-INFO: Number of scalar specialization constants in the module = 11
; CHECK-INFO: Spec const id = 101, size in bytes = 1
; CHECK-INFO: Spec const id = 102, size in bytes = 2
; CHECK-INFO: Spec const id = 103, size in bytes = 4
; CHECK-INFO: Spec const id = 104, size in bytes = 8
; CHECK-INFO: Spec const id = 105, size in bytes = 1
; CHECK-INFO: Spec const id = 106, size in bytes = 1
; CHECK-INFO: Spec const id = 107, size in bytes = 1
; CHECK-INFO: Spec const id = 108, size in bytes = 2
; CHECK-INFO: Spec const id = 109, size in bytes = 4
; CHECK-INFO: Spec const id = 110, size in bytes = 8
; CHECK-INFO: Spec const id = 111, size in bytes = 8

; Negative tests for the command line option.
; RUN: not llvm-spirv -r %t.spv -spec-const "1234" 2>&1 | FileCheck %s --check-prefix=CHECK-FORMAT
; CHECK-FORMAT: Invalid format of -spec-const option: "1234". Expected format: -spec-const "<id1:type1:value1 id2:type2:value2 ...>"

; RUN: not llvm-spirv -r %t.spv -spec-const "q:i32:4" 2>&1 | FileCheck %s --check-prefix=CHECK-ID
; CHECK-ID: Invalid id for '-spec-const' option! In "q:i32:4": "q" must be a 32-bit unsigned integer

; RUN: not llvm-spirv -r %t.spv -spec-const "10:i32:1024" 2>&1 | FileCheck %s --check-prefix=CHECK-INVALID-ID
; CHECK-INVALID-ID: CL_INVALID_SPEC_ID. "10:i32:1024": There is no specialization constant with id = 10 in the SPIR-V module.

; RUN: not llvm-spirv -r %t.spv -spec-const "101:32:99" 2>&1 | FileCheck %s --check-prefix=CHECK-TYPE
; CHECK-TYPE: Invalid type for '-spec-const' option! In "101:32:99": "32" - is not allowed type. Allowed types are: i1, i8, i16, i32, i64, f16, f32, f64

; RUN: not llvm-spirv -r %t.spv -spec-const "101:i9:99" 2>&1 | FileCheck %s --check-prefix=CHECK-TYPE-INT
; CHECK-TYPE-INT: Invalid type for '-spec-const' option! In "101:i9:99": "i9" - is not allowed type. Allowed types are: i1, i8, i16, i32, i64, f16, f32, f64

; RUN: not llvm-spirv -r %t.spv -spec-const "101:f8:99" 2>&1 | FileCheck %s --check-prefix=CHECK-TYPE-FP
; CHECK-TYPE-FP: Invalid type for '-spec-const' option! In "101:f8:99": "f8" - is not allowed type. Allowed types are: i1, i8, i16, i32, i64, f16, f32, f64

; RUN: not llvm-spirv -r %t.spv -spec-const "101:i8:257" 2>&1 | FileCheck %s --check-prefix=CHECK-VALUE-INT
; CHECK-VALUE-INT: Invalid value for '-spec-const' option! In "101:i8:257": can't convert "257" to 8-bit integer number

; RUN: not llvm-spirv -r %t.spv -spec-const "101:f32:4.40282347E+38" 2>&1 | FileCheck %s --check-prefix=CHECK-VALUE-FP
; CHECK-VALUE-FP: Invalid value for '-spec-const' option! In "101:f32:4.40282347E+38": can't convert "4.40282347E+38" to 32-bit floating point number

; RUN: not llvm-spirv -r %t.spv -spec-const "101:i32:1024" 2>&1 | FileCheck %s --check-prefix=CHECK-VALUE
; CHECK-VALUE: CL_INVALID_VALUE. In "101:i32:1024": Size of type i32 (4 bytes) does not match the size of the specialization constant in the module (1 bytes)

; RUN: llvm-spirv -r -o - %t.spv | llvm-dis | FileCheck %s --check-prefix=CHECK-DEFAULT
; RUN: llvm-spirv -r -spec-const "101:i8:42 102:i16:22 103:i32:33 104:i64:44 105:i8:0 106:i1:0 107:i1:1 108:f16:5.5 109:f32:6.6 110:f64:7.7 111:f64:8.8 101:i8:11" -o - %t.spv | llvm-dis | FileCheck %s --check-prefix=CHECK-SPEC

; CHECK-DEFAULT: @bt = addrspace(2) constant i1 true, align 1
; CHECK-DEFAULT: @bf = addrspace(2) constant i1 false, align 1
; CHECK-DEFAULT: @c = addrspace(2) constant i8 97, align 1
; CHECK-DEFAULT: @s = addrspace(2) constant i16 1, align 2
; CHECK-DEFAULT: @i = addrspace(2) constant i32 2, align 4
; CHECK-DEFAULT: @l = addrspace(2) constant i64 3, align 8
; CHECK-DEFAULT: @h = addrspace(2) constant half 0xH3800, align 2
; CHECK-DEFAULT: @f = addrspace(2) constant float 0x40015C2900000000, align 4
; CHECK-DEFAULT: @d = addrspace(2) constant double 3.140000e+00, align 8
; CHECK-DEFAULT: @ss = addrspace(1) global %struct.S { i8 98, double 6.280000e+00 }, align 8

; CHECK-SPEC: @bt = addrspace(2) constant i1 false, align 1
; CHECK-SPEC: @bf = addrspace(2) constant i1 true, align 1
; CHECK-SPEC: @c = addrspace(2) constant i8 11, align 1
; CHECK-SPEC: @s = addrspace(2) constant i16 22, align 2
; CHECK-SPEC: @i = addrspace(2) constant i32 33, align 4
; CHECK-SPEC: @l = addrspace(2) constant i64 44, align 8
; CHECK-SPEC: @h = addrspace(2) constant half 0xH4580, align 2
; CHECK-SPEC: @f = addrspace(2) constant float 0x401A666660000000, align 4
; CHECK-SPEC: @d = addrspace(2) constant double 7.700000e+00, align 8
; CHECK-SPEC: @ss = addrspace(1) global %struct.S { i8 0, double 8.800000e+00 }, align 8

; SPIR-V
; Version: 1.0
; Generator: Khronos LLVM/SPIR-V Translator; 14
; Bound: 47
; Schema: 0
               OpCapability Addresses
               OpCapability Linkage
               OpCapability Kernel
               OpCapability Float16Buffer
               OpCapability Float64
               OpCapability Int64
               OpCapability Int16
               OpCapability Int8
          %1 = OpExtInstImport "OpenCL.std"
               OpMemoryModel Physical64 OpenCL
               OpSource OpenCL_C 200000
               OpName %bt "bt"
               OpName %bf "bf"
               OpName %c "c"
               OpName %s "s"
               OpName %i "i"
               OpName %l "l"
               OpName %h "h"
               OpName %f "f"
               OpName %d "d"
               OpName %struct_S "struct.S"
               OpName %ss "ss"
               OpDecorate %uchar_97 SpecId 101
               OpDecorate %ushort_1 SpecId 102
               OpDecorate %uint_2 SpecId 103
               OpDecorate %ulong_3 SpecId 104
               OpDecorate %uchar_98 SpecId 105
               OpDecorate %true SpecId 106
               OpDecorate %false SpecId 107
               OpDecorate %half_0x1pn1 SpecId 108
               OpDecorate %float_2_17000008 SpecId 109
               OpDecorate %double_3_1400000000000001 SpecId 110
               OpDecorate %double_6_2800000000000002 SpecId 111
               OpDecorate %42 Constant
         %42 = OpDecorationGroup
               OpDecorate %43 Alignment 1
         %43 = OpDecorationGroup
               OpDecorate %44 Alignment 2
         %44 = OpDecorationGroup
               OpDecorate %45 Alignment 4
         %45 = OpDecorationGroup
               OpDecorate %46 Alignment 8
         %46 = OpDecorationGroup
               OpDecorate %c LinkageAttributes "c" Export
               OpDecorate %d LinkageAttributes "d" Export
               OpDecorate %f LinkageAttributes "f" Export
               OpDecorate %h LinkageAttributes "h" Export
               OpDecorate %i LinkageAttributes "i" Export
               OpDecorate %l LinkageAttributes "l" Export
               OpDecorate %s LinkageAttributes "s" Export
               OpDecorate %bf LinkageAttributes "bf" Export
               OpDecorate %ss LinkageAttributes "ss" Export
               OpDecorate %bt LinkageAttributes "bt" Export
               OpGroupDecorate %42 %bt %bf %c %s %i %l %h %f %d
               OpGroupDecorate %43 %bt %bf %c
               OpGroupDecorate %44 %s %h
               OpGroupDecorate %45 %i %f
               OpGroupDecorate %46 %l %d %ss
      %uchar = OpTypeInt 8 0
     %ushort = OpTypeInt 16 0
       %uint = OpTypeInt 32 0
      %ulong = OpTypeInt 64 0
   %uchar_97 = OpSpecConstant %uchar 97
   %ushort_1 = OpSpecConstant %ushort 1
     %uint_2 = OpSpecConstant %uint 2
    %ulong_3 = OpSpecConstant %ulong 3
   %uchar_98 = OpSpecConstant %uchar 98
       %bool = OpTypeBool
%_ptr_UniformConstant_bool = OpTypePointer UniformConstant %bool
%_ptr_UniformConstant_uchar = OpTypePointer UniformConstant %uchar
%_ptr_UniformConstant_ushort = OpTypePointer UniformConstant %ushort
%_ptr_UniformConstant_uint = OpTypePointer UniformConstant %uint
%_ptr_UniformConstant_ulong = OpTypePointer UniformConstant %ulong
       %half = OpTypeFloat 16
%_ptr_UniformConstant_half = OpTypePointer UniformConstant %half
      %float = OpTypeFloat 32
%_ptr_UniformConstant_float = OpTypePointer UniformConstant %float
     %double = OpTypeFloat 64
%_ptr_UniformConstant_double = OpTypePointer UniformConstant %double
   %struct_S = OpTypeStruct %uchar %double
%_ptr_CrossWorkgroup_struct_S = OpTypePointer CrossWorkgroup %struct_S
       %true = OpSpecConstantTrue %bool
         %bt = OpVariable %_ptr_UniformConstant_bool UniformConstant %true
      %false = OpSpecConstantFalse %bool
         %bf = OpVariable %_ptr_UniformConstant_bool UniformConstant %false
          %c = OpVariable %_ptr_UniformConstant_uchar UniformConstant %uchar_97
          %s = OpVariable %_ptr_UniformConstant_ushort UniformConstant %ushort_1
          %i = OpVariable %_ptr_UniformConstant_uint UniformConstant %uint_2
          %l = OpVariable %_ptr_UniformConstant_ulong UniformConstant %ulong_3
%half_0x1pn1 = OpSpecConstant %half 0x1p-1
          %h = OpVariable %_ptr_UniformConstant_half UniformConstant %half_0x1pn1
%float_2_17000008 = OpSpecConstant %float 2.17000008
          %f = OpVariable %_ptr_UniformConstant_float UniformConstant %float_2_17000008
%double_3_1400000000000001 = OpSpecConstant %double 3.1400000000000001
          %d = OpVariable %_ptr_UniformConstant_double UniformConstant %double_3_1400000000000001
%double_6_2800000000000002 = OpSpecConstant %double 6.2800000000000002
         %39 = OpSpecConstantComposite %struct_S %uchar_98 %double_6_2800000000000002
         %ss = OpVariable %_ptr_CrossWorkgroup_struct_S CrossWorkgroup %39