1 //===-- SPIRVBaseInfo.h - Top level definitions for SPIRV ------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains small standalone helper functions and enum definitions for
10 // the SPIRV target useful for the compiler back-end and the MC libraries.
11 // As such, it deliberately does not include references to LLVM core
12 // code gen types, passes, etc..
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_LIB_TARGET_SPIRV_MCTARGETDESC_SPIRVBASEINFO_H
17 #define LLVM_LIB_TARGET_SPIRV_MCTARGETDESC_SPIRVBASEINFO_H
18
19 #include "llvm/ADT/StringRef.h"
20 #include <string>
21
22 namespace llvm {
23 namespace SPIRV {
24 enum class Capability : uint32_t {
25 Matrix = 0,
26 Shader = 1,
27 Geometry = 2,
28 Tessellation = 3,
29 Addresses = 4,
30 Linkage = 5,
31 Kernel = 6,
32 Vector16 = 7,
33 Float16Buffer = 8,
34 Float16 = 9,
35 Float64 = 10,
36 Int64 = 11,
37 Int64Atomics = 12,
38 ImageBasic = 13,
39 ImageReadWrite = 14,
40 ImageMipmap = 15,
41 Pipes = 17,
42 Groups = 18,
43 DeviceEnqueue = 19,
44 LiteralSampler = 20,
45 AtomicStorage = 21,
46 Int16 = 22,
47 TessellationPointSize = 23,
48 GeometryPointSize = 24,
49 ImageGatherExtended = 25,
50 StorageImageMultisample = 27,
51 UniformBufferArrayDynamicIndexing = 28,
52 SampledImageArrayDymnamicIndexing = 29,
53 ClipDistance = 32,
54 CullDistance = 33,
55 ImageCubeArray = 34,
56 SampleRateShading = 35,
57 ImageRect = 36,
58 SampledRect = 37,
59 GenericPointer = 38,
60 Int8 = 39,
61 InputAttachment = 40,
62 SparseResidency = 41,
63 MinLod = 42,
64 Sampled1D = 43,
65 Image1D = 44,
66 SampledCubeArray = 45,
67 SampledBuffer = 46,
68 ImageBuffer = 47,
69 ImageMSArray = 48,
70 StorageImageExtendedFormats = 49,
71 ImageQuery = 50,
72 DerivativeControl = 51,
73 InterpolationFunction = 52,
74 TransformFeedback = 53,
75 GeometryStreams = 54,
76 StorageImageReadWithoutFormat = 55,
77 StorageImageWriteWithoutFormat = 56,
78 MultiViewport = 57,
79 SubgroupDispatch = 58,
80 NamedBarrier = 59,
81 PipeStorage = 60,
82 GroupNonUniform = 61,
83 GroupNonUniformVote = 62,
84 GroupNonUniformArithmetic = 63,
85 GroupNonUniformBallot = 64,
86 GroupNonUniformShuffle = 65,
87 GroupNonUniformShuffleRelative = 66,
88 GroupNonUniformClustered = 67,
89 GroupNonUniformQuad = 68,
90 SubgroupBallotKHR = 4423,
91 DrawParameters = 4427,
92 SubgroupVoteKHR = 4431,
93 StorageBuffer16BitAccess = 4433,
94 StorageUniform16 = 4434,
95 StoragePushConstant16 = 4435,
96 StorageInputOutput16 = 4436,
97 DeviceGroup = 4437,
98 MultiView = 4439,
99 VariablePointersStorageBuffer = 4441,
100 VariablePointers = 4442,
101 AtomicStorageOps = 4445,
102 SampleMaskPostDepthCoverage = 4447,
103 StorageBuffer8BitAccess = 4448,
104 UniformAndStorageBuffer8BitAccess = 4449,
105 StoragePushConstant8 = 4450,
106 DenormPreserve = 4464,
107 DenormFlushToZero = 4465,
108 SignedZeroInfNanPreserve = 4466,
109 RoundingModeRTE = 4467,
110 RoundingModeRTZ = 4468,
111 Float16ImageAMD = 5008,
112 ImageGatherBiasLodAMD = 5009,
113 FragmentMaskAMD = 5010,
114 StencilExportEXT = 5013,
115 ImageReadWriteLodAMD = 5015,
116 SampleMaskOverrideCoverageNV = 5249,
117 GeometryShaderPassthroughNV = 5251,
118 ShaderViewportIndexLayerEXT = 5254,
119 ShaderViewportMaskNV = 5255,
120 ShaderStereoViewNV = 5259,
121 PerViewAttributesNV = 5260,
122 FragmentFullyCoveredEXT = 5265,
123 MeshShadingNV = 5266,
124 ShaderNonUniformEXT = 5301,
125 RuntimeDescriptorArrayEXT = 5302,
126 InputAttachmentArrayDynamicIndexingEXT = 5303,
127 UniformTexelBufferArrayDynamicIndexingEXT = 5304,
128 StorageTexelBufferArrayDynamicIndexingEXT = 5305,
129 UniformBufferArrayNonUniformIndexingEXT = 5306,
130 SampledImageArrayNonUniformIndexingEXT = 5307,
131 StorageBufferArrayNonUniformIndexingEXT = 5308,
132 StorageImageArrayNonUniformIndexingEXT = 5309,
133 InputAttachmentArrayNonUniformIndexingEXT = 5310,
134 UniformTexelBufferArrayNonUniformIndexingEXT = 5311,
135 StorageTexelBufferArrayNonUniformIndexingEXT = 5312,
136 RayTracingNV = 5340,
137 SubgroupShuffleINTEL = 5568,
138 SubgroupBufferBlockIOINTEL = 5569,
139 SubgroupImageBlockIOINTEL = 5570,
140 SubgroupImageMediaBlockIOINTEL = 5579,
141 SubgroupAvcMotionEstimationINTEL = 5696,
142 SubgroupAvcMotionEstimationIntraINTEL = 5697,
143 SubgroupAvcMotionEstimationChromaINTEL = 5698,
144 GroupNonUniformPartitionedNV = 5297,
145 VulkanMemoryModelKHR = 5345,
146 VulkanMemoryModelDeviceScopeKHR = 5346,
147 ImageFootprintNV = 5282,
148 FragmentBarycentricNV = 5284,
149 ComputeDerivativeGroupQuadsNV = 5288,
150 ComputeDerivativeGroupLinearNV = 5350,
151 FragmentDensityEXT = 5291,
152 PhysicalStorageBufferAddressesEXT = 5347,
153 CooperativeMatrixNV = 5357,
154 };
155 StringRef getCapabilityName(Capability e);
156
157 enum class SourceLanguage : uint32_t {
158 Unknown = 0,
159 ESSL = 1,
160 GLSL = 2,
161 OpenCL_C = 3,
162 OpenCL_CPP = 4,
163 HLSL = 5,
164 };
165 StringRef getSourceLanguageName(SourceLanguage e);
166
167 enum class AddressingModel : uint32_t {
168 Logical = 0,
169 Physical32 = 1,
170 Physical64 = 2,
171 PhysicalStorageBuffer64EXT = 5348,
172 };
173 StringRef getAddressingModelName(AddressingModel e);
174
175 enum class ExecutionModel : uint32_t {
176 Vertex = 0,
177 TessellationControl = 1,
178 TessellationEvaluation = 2,
179 Geometry = 3,
180 Fragment = 4,
181 GLCompute = 5,
182 Kernel = 6,
183 TaskNV = 5267,
184 MeshNV = 5268,
185 RayGenerationNV = 5313,
186 IntersectionNV = 5314,
187 AnyHitNV = 5315,
188 ClosestHitNV = 5316,
189 MissNV = 5317,
190 CallableNV = 5318,
191 };
192 StringRef getExecutionModelName(ExecutionModel e);
193
194 enum class MemoryModel : uint32_t {
195 Simple = 0,
196 GLSL450 = 1,
197 OpenCL = 2,
198 VulkanKHR = 3,
199 };
200 StringRef getMemoryModelName(MemoryModel e);
201
202 enum class ExecutionMode : uint32_t {
203 Invocations = 0,
204 SpacingEqual = 1,
205 SpacingFractionalEven = 2,
206 SpacingFractionalOdd = 3,
207 VertexOrderCw = 4,
208 VertexOrderCcw = 5,
209 PixelCenterInteger = 6,
210 OriginUpperLeft = 7,
211 OriginLowerLeft = 8,
212 EarlyFragmentTests = 9,
213 PointMode = 10,
214 Xfb = 11,
215 DepthReplacing = 12,
216 DepthGreater = 14,
217 DepthLess = 15,
218 DepthUnchanged = 16,
219 LocalSize = 17,
220 LocalSizeHint = 18,
221 InputPoints = 19,
222 InputLines = 20,
223 InputLinesAdjacency = 21,
224 Triangles = 22,
225 InputTrianglesAdjacency = 23,
226 Quads = 24,
227 Isolines = 25,
228 OutputVertices = 26,
229 OutputPoints = 27,
230 OutputLineStrip = 28,
231 OutputTriangleStrip = 29,
232 VecTypeHint = 30,
233 ContractionOff = 31,
234 Initializer = 33,
235 Finalizer = 34,
236 SubgroupSize = 35,
237 SubgroupsPerWorkgroup = 36,
238 SubgroupsPerWorkgroupId = 37,
239 LocalSizeId = 38,
240 LocalSizeHintId = 39,
241 PostDepthCoverage = 4446,
242 DenormPreserve = 4459,
243 DenormFlushToZero = 4460,
244 SignedZeroInfNanPreserve = 4461,
245 RoundingModeRTE = 4462,
246 RoundingModeRTZ = 4463,
247 StencilRefReplacingEXT = 5027,
248 OutputLinesNV = 5269,
249 DerivativeGroupQuadsNV = 5289,
250 DerivativeGroupLinearNV = 5290,
251 OutputTrianglesNV = 5298,
252 };
253 StringRef getExecutionModeName(ExecutionMode e);
254
255 enum class StorageClass : uint32_t {
256 UniformConstant = 0,
257 Input = 1,
258 Uniform = 2,
259 Output = 3,
260 Workgroup = 4,
261 CrossWorkgroup = 5,
262 Private = 6,
263 Function = 7,
264 Generic = 8,
265 PushConstant = 9,
266 AtomicCounter = 10,
267 Image = 11,
268 StorageBuffer = 12,
269 CallableDataNV = 5328,
270 IncomingCallableDataNV = 5329,
271 RayPayloadNV = 5338,
272 HitAttributeNV = 5339,
273 IncomingRayPayloadNV = 5342,
274 ShaderRecordBufferNV = 5343,
275 PhysicalStorageBufferEXT = 5349,
276 };
277 StringRef getStorageClassName(StorageClass e);
278
279 enum class Dim : uint32_t {
280 DIM_1D = 0,
281 DIM_2D = 1,
282 DIM_3D = 2,
283 DIM_Cube = 3,
284 DIM_Rect = 4,
285 DIM_Buffer = 5,
286 DIM_SubpassData = 6,
287 };
288 StringRef getDimName(Dim e);
289
290 enum class SamplerAddressingMode : uint32_t {
291 None = 0,
292 ClampToEdge = 1,
293 Clamp = 2,
294 Repeat = 3,
295 RepeatMirrored = 4,
296 };
297 StringRef getSamplerAddressingModeName(SamplerAddressingMode e);
298
299 enum class SamplerFilterMode : uint32_t {
300 Nearest = 0,
301 Linear = 1,
302 };
303 StringRef getSamplerFilterModeName(SamplerFilterMode e);
304
305 enum class ImageFormat : uint32_t {
306 Unknown = 0,
307 Rgba32f = 1,
308 Rgba16f = 2,
309 R32f = 3,
310 Rgba8 = 4,
311 Rgba8Snorm = 5,
312 Rg32f = 6,
313 Rg16f = 7,
314 R11fG11fB10f = 8,
315 R16f = 9,
316 Rgba16 = 10,
317 Rgb10A2 = 11,
318 Rg16 = 12,
319 Rg8 = 13,
320 R16 = 14,
321 R8 = 15,
322 Rgba16Snorm = 16,
323 Rg16Snorm = 17,
324 Rg8Snorm = 18,
325 R16Snorm = 19,
326 R8Snorm = 20,
327 Rgba32i = 21,
328 Rgba16i = 22,
329 Rgba8i = 23,
330 R32i = 24,
331 Rg32i = 25,
332 Rg16i = 26,
333 Rg8i = 27,
334 R16i = 28,
335 R8i = 29,
336 Rgba32ui = 30,
337 Rgba16ui = 31,
338 Rgba8ui = 32,
339 R32ui = 33,
340 Rgb10a2ui = 34,
341 Rg32ui = 35,
342 Rg16ui = 36,
343 Rg8ui = 37,
344 R16ui = 38,
345 R8ui = 39,
346 };
347 StringRef getImageFormatName(ImageFormat e);
348
349 enum class ImageChannelOrder : uint32_t {
350 R = 0,
351 A = 1,
352 RG = 2,
353 RA = 3,
354 RGB = 4,
355 RGBA = 5,
356 BGRA = 6,
357 ARGB = 7,
358 Intensity = 8,
359 Luminance = 9,
360 Rx = 10,
361 RGx = 11,
362 RGBx = 12,
363 Depth = 13,
364 DepthStencil = 14,
365 sRGB = 15,
366 sRGBx = 16,
367 sRGBA = 17,
368 sBGRA = 18,
369 ABGR = 19,
370 };
371 StringRef getImageChannelOrderName(ImageChannelOrder e);
372
373 enum class ImageChannelDataType : uint32_t {
374 SnormInt8 = 0,
375 SnormInt16 = 1,
376 UnormInt8 = 2,
377 UnormInt16 = 3,
378 UnormShort565 = 4,
379 UnormShort555 = 5,
380 UnormInt101010 = 6,
381 SignedInt8 = 7,
382 SignedInt16 = 8,
383 SignedInt32 = 9,
384 UnsignedInt8 = 10,
385 UnsignedInt16 = 11,
386 UnsigendInt32 = 12,
387 HalfFloat = 13,
388 Float = 14,
389 UnormInt24 = 15,
390 UnormInt101010_2 = 16,
391 };
392 StringRef getImageChannelDataTypeName(ImageChannelDataType e);
393
394 enum class ImageOperand : uint32_t {
395 None = 0x0,
396 Bias = 0x1,
397 Lod = 0x2,
398 Grad = 0x4,
399 ConstOffset = 0x8,
400 Offset = 0x10,
401 ConstOffsets = 0x20,
402 Sample = 0x40,
403 MinLod = 0x80,
404 MakeTexelAvailableKHR = 0x100,
405 MakeTexelVisibleKHR = 0x200,
406 NonPrivateTexelKHR = 0x400,
407 VolatileTexelKHR = 0x800,
408 SignExtend = 0x1000,
409 ZeroExtend = 0x2000,
410 };
411 std::string getImageOperandName(uint32_t e);
412
413 enum class FPFastMathMode : uint32_t {
414 None = 0x0,
415 NotNaN = 0x1,
416 NotInf = 0x2,
417 NSZ = 0x4,
418 AllowRecip = 0x8,
419 Fast = 0x10,
420 };
421 std::string getFPFastMathModeName(uint32_t e);
422
423 enum class FPRoundingMode : uint32_t {
424 RTE = 0,
425 RTZ = 1,
426 RTP = 2,
427 RTN = 3,
428 };
429 StringRef getFPRoundingModeName(FPRoundingMode e);
430
431 enum class LinkageType : uint32_t {
432 Export = 0,
433 Import = 1,
434 };
435 StringRef getLinkageTypeName(LinkageType e);
436
437 enum class AccessQualifier : uint32_t {
438 ReadOnly = 0,
439 WriteOnly = 1,
440 ReadWrite = 2,
441 };
442 StringRef getAccessQualifierName(AccessQualifier e);
443
444 enum class FunctionParameterAttribute : uint32_t {
445 Zext = 0,
446 Sext = 1,
447 ByVal = 2,
448 Sret = 3,
449 NoAlias = 4,
450 NoCapture = 5,
451 NoWrite = 6,
452 NoReadWrite = 7,
453 };
454 StringRef getFunctionParameterAttributeName(FunctionParameterAttribute e);
455
456 enum class Decoration : uint32_t {
457 RelaxedPrecision = 0,
458 SpecId = 1,
459 Block = 2,
460 BufferBlock = 3,
461 RowMajor = 4,
462 ColMajor = 5,
463 ArrayStride = 6,
464 MatrixStride = 7,
465 GLSLShared = 8,
466 GLSLPacked = 9,
467 CPacked = 10,
468 BuiltIn = 11,
469 NoPerspective = 13,
470 Flat = 14,
471 Patch = 15,
472 Centroid = 16,
473 Sample = 17,
474 Invariant = 18,
475 Restrict = 19,
476 Aliased = 20,
477 Volatile = 21,
478 Constant = 22,
479 Coherent = 23,
480 NonWritable = 24,
481 NonReadable = 25,
482 Uniform = 26,
483 UniformId = 27,
484 SaturatedConversion = 28,
485 Stream = 29,
486 Location = 30,
487 Component = 31,
488 Index = 32,
489 Binding = 33,
490 DescriptorSet = 34,
491 Offset = 35,
492 XfbBuffer = 36,
493 XfbStride = 37,
494 FuncParamAttr = 38,
495 FPRoundingMode = 39,
496 FPFastMathMode = 40,
497 LinkageAttributes = 41,
498 NoContraction = 42,
499 InputAttachmentIndex = 43,
500 Alignment = 44,
501 MaxByteOffset = 45,
502 AlignmentId = 46,
503 MaxByteOffsetId = 47,
504 NoSignedWrap = 4469,
505 NoUnsignedWrap = 4470,
506 ExplicitInterpAMD = 4999,
507 OverrideCoverageNV = 5248,
508 PassthroughNV = 5250,
509 ViewportRelativeNV = 5252,
510 SecondaryViewportRelativeNV = 5256,
511 PerPrimitiveNV = 5271,
512 PerViewNV = 5272,
513 PerVertexNV = 5273,
514 NonUniformEXT = 5300,
515 CountBuffer = 5634,
516 UserSemantic = 5635,
517 RestrictPointerEXT = 5355,
518 AliasedPointerEXT = 5356,
519 };
520 StringRef getDecorationName(Decoration e);
521
522 enum class BuiltIn : uint32_t {
523 Position = 0,
524 PointSize = 1,
525 ClipDistance = 3,
526 CullDistance = 4,
527 VertexId = 5,
528 InstanceId = 6,
529 PrimitiveId = 7,
530 InvocationId = 8,
531 Layer = 9,
532 ViewportIndex = 10,
533 TessLevelOuter = 11,
534 TessLevelInner = 12,
535 TessCoord = 13,
536 PatchVertices = 14,
537 FragCoord = 15,
538 PointCoord = 16,
539 FrontFacing = 17,
540 SampleId = 18,
541 SamplePosition = 19,
542 SampleMask = 20,
543 FragDepth = 22,
544 HelperInvocation = 23,
545 NumWorkgroups = 24,
546 WorkgroupSize = 25,
547 WorkgroupId = 26,
548 LocalInvocationId = 27,
549 GlobalInvocationId = 28,
550 LocalInvocationIndex = 29,
551 WorkDim = 30,
552 GlobalSize = 31,
553 EnqueuedWorkgroupSize = 32,
554 GlobalOffset = 33,
555 GlobalLinearId = 34,
556 SubgroupSize = 36,
557 SubgroupMaxSize = 37,
558 NumSubgroups = 38,
559 NumEnqueuedSubgroups = 39,
560 SubgroupId = 40,
561 SubgroupLocalInvocationId = 41,
562 VertexIndex = 42,
563 InstanceIndex = 43,
564 SubgroupEqMask = 4416,
565 SubgroupGeMask = 4417,
566 SubgroupGtMask = 4418,
567 SubgroupLeMask = 4419,
568 SubgroupLtMask = 4420,
569 BaseVertex = 4424,
570 BaseInstance = 4425,
571 DrawIndex = 4426,
572 DeviceIndex = 4438,
573 ViewIndex = 4440,
574 BaryCoordNoPerspAMD = 4492,
575 BaryCoordNoPerspCentroidAMD = 4493,
576 BaryCoordNoPerspSampleAMD = 4494,
577 BaryCoordSmoothAMD = 4495,
578 BaryCoordSmoothCentroid = 4496,
579 BaryCoordSmoothSample = 4497,
580 BaryCoordPullModel = 4498,
581 FragStencilRefEXT = 5014,
582 ViewportMaskNV = 5253,
583 SecondaryPositionNV = 5257,
584 SecondaryViewportMaskNV = 5258,
585 PositionPerViewNV = 5261,
586 ViewportMaskPerViewNV = 5262,
587 FullyCoveredEXT = 5264,
588 TaskCountNV = 5274,
589 PrimitiveCountNV = 5275,
590 PrimitiveIndicesNV = 5276,
591 ClipDistancePerViewNV = 5277,
592 CullDistancePerViewNV = 5278,
593 LayerPerViewNV = 5279,
594 MeshViewCountNV = 5280,
595 MeshViewIndices = 5281,
596 BaryCoordNV = 5286,
597 BaryCoordNoPerspNV = 5287,
598 FragSizeEXT = 5292,
599 FragInvocationCountEXT = 5293,
600 LaunchIdNV = 5319,
601 LaunchSizeNV = 5320,
602 WorldRayOriginNV = 5321,
603 WorldRayDirectionNV = 5322,
604 ObjectRayOriginNV = 5323,
605 ObjectRayDirectionNV = 5324,
606 RayTminNV = 5325,
607 RayTmaxNV = 5326,
608 InstanceCustomIndexNV = 5327,
609 ObjectToWorldNV = 5330,
610 WorldToObjectNV = 5331,
611 HitTNV = 5332,
612 HitKindNV = 5333,
613 IncomingRayFlagsNV = 5351,
614 };
615 StringRef getBuiltInName(BuiltIn e);
616
617 enum class SelectionControl : uint32_t {
618 None = 0x0,
619 Flatten = 0x1,
620 DontFlatten = 0x2,
621 };
622 std::string getSelectionControlName(uint32_t e);
623
624 enum class LoopControl : uint32_t {
625 None = 0x0,
626 Unroll = 0x1,
627 DontUnroll = 0x2,
628 DependencyInfinite = 0x4,
629 DependencyLength = 0x8,
630 MinIterations = 0x10,
631 MaxIterations = 0x20,
632 IterationMultiple = 0x40,
633 PeelCount = 0x80,
634 PartialCount = 0x100,
635 };
636 std::string getLoopControlName(uint32_t e);
637
638 enum class FunctionControl : uint32_t {
639 None = 0x0,
640 Inline = 0x1,
641 DontInline = 0x2,
642 Pure = 0x4,
643 Const = 0x8,
644 };
645 std::string getFunctionControlName(uint32_t e);
646
647 enum class MemorySemantics : uint32_t {
648 None = 0x0,
649 Acquire = 0x2,
650 Release = 0x4,
651 AcquireRelease = 0x8,
652 SequentiallyConsistent = 0x10,
653 UniformMemory = 0x40,
654 SubgroupMemory = 0x80,
655 WorkgroupMemory = 0x100,
656 CrossWorkgroupMemory = 0x200,
657 AtomicCounterMemory = 0x400,
658 ImageMemory = 0x800,
659 OutputMemoryKHR = 0x1000,
660 MakeAvailableKHR = 0x2000,
661 MakeVisibleKHR = 0x4000,
662 };
663 std::string getMemorySemanticsName(uint32_t e);
664
665 enum class MemoryOperand : uint32_t {
666 None = 0x0,
667 Volatile = 0x1,
668 Aligned = 0x2,
669 Nontemporal = 0x4,
670 MakePointerAvailableKHR = 0x8,
671 MakePointerVisibleKHR = 0x10,
672 NonPrivatePointerKHR = 0x20,
673 };
674 std::string getMemoryOperandName(uint32_t e);
675
676 enum class Scope : uint32_t {
677 CrossDevice = 0,
678 Device = 1,
679 Workgroup = 2,
680 Subgroup = 3,
681 Invocation = 4,
682 QueueFamilyKHR = 5,
683 };
684 StringRef getScopeName(Scope e);
685
686 enum class GroupOperation : uint32_t {
687 Reduce = 0,
688 InclusiveScan = 1,
689 ExclusiveScan = 2,
690 ClusteredReduce = 3,
691 PartitionedReduceNV = 6,
692 PartitionedInclusiveScanNV = 7,
693 PartitionedExclusiveScanNV = 8,
694 };
695 StringRef getGroupOperationName(GroupOperation e);
696
697 enum class KernelEnqueueFlags : uint32_t {
698 NoWait = 0,
699 WaitKernel = 1,
700 WaitWorkGroup = 2,
701 };
702 StringRef getKernelEnqueueFlagsName(KernelEnqueueFlags e);
703
704 enum class KernelProfilingInfo : uint32_t {
705 None = 0x0,
706 CmdExecTime = 0x1,
707 };
708 StringRef getKernelProfilingInfoName(KernelProfilingInfo e);
709
710 enum class InstructionSet : uint32_t {
711 OpenCL_std = 0,
712 GLSL_std_450 = 1,
713 SPV_AMD_shader_trinary_minmax = 2,
714 };
715 std::string getExtInstSetName(InstructionSet e);
716
717 // TODO: implement other mnemonics.
718 enum class Opcode : uint32_t {
719 InBoundsPtrAccessChain = 70,
720 PtrCastToGeneric = 121,
721 };
722 } // namespace SPIRV
723 } // namespace llvm
724
725 // Return a string representation of the operands from startIndex onwards.
726 // Templated to allow both MachineInstr and MCInst to use the same logic.
727 template <class InstType>
getSPIRVStringOperand(const InstType & MI,unsigned StartIndex)728 std::string getSPIRVStringOperand(const InstType &MI, unsigned StartIndex) {
729 std::string s; // Iteratively append to this string.
730
731 const unsigned NumOps = MI.getNumOperands();
732 bool IsFinished = false;
733 for (unsigned i = StartIndex; i < NumOps && !IsFinished; ++i) {
734 const auto &Op = MI.getOperand(i);
735 if (!Op.isImm()) // Stop if we hit a register operand.
736 break;
737 assert((Op.getImm() >> 32) == 0 && "Imm operand should be i32 word");
738 const uint32_t Imm = Op.getImm(); // Each i32 word is up to 4 characters.
739 for (unsigned ShiftAmount = 0; ShiftAmount < 32; ShiftAmount += 8) {
740 char c = (Imm >> ShiftAmount) & 0xff;
741 if (c == 0) { // Stop if we hit a null-terminator character.
742 IsFinished = true;
743 break;
744 } else {
745 s += c; // Otherwise, append the character to the result string.
746 }
747 }
748 }
749 return s;
750 }
751
752 #endif // LLVM_LIB_TARGET_SPIRV_MCTARGETDESC_SPIRVBASEINFO_H
753