xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SPIRV/SPIRVInstrInfo.td (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1//===-- SPIRVInstrInfo.td - Target Description for SPIR-V Target ----------===//
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 describes the SPIR-V instructions in TableGen format.
10//
11//===----------------------------------------------------------------------===//
12
13include "SPIRVInstrFormats.td"
14include "SPIRVSymbolicOperands.td"
15
16// Codegen only metadata instructions
17let isCodeGenOnly=1 in {
18  def ASSIGN_TYPE: Pseudo<(outs ANYID:$dst_id), (ins ANYID:$src_id, TYPE:$src_ty)>;
19  def DECL_TYPE: Pseudo<(outs ANYID:$dst_id), (ins ANYID:$src_id, TYPE:$src_ty)>;
20  def GET_ID: Pseudo<(outs ID:$dst_id), (ins ANYID:$src)>;
21  def GET_ID64: Pseudo<(outs ID64:$dst_id), (ins ANYID:$src)>;
22  def GET_fID: Pseudo<(outs fID:$dst_id), (ins ANYID:$src)>;
23  def GET_fID64: Pseudo<(outs fID64:$dst_id), (ins ANYID:$src)>;
24  def GET_pID32: Pseudo<(outs pID32:$dst_id), (ins ANYID:$src)>;
25  def GET_pID64: Pseudo<(outs pID64:$dst_id), (ins ANYID:$src)>;
26  def GET_vID: Pseudo<(outs vID:$dst_id), (ins ANYID:$src)>;
27  def GET_vfID: Pseudo<(outs vfID:$dst_id), (ins ANYID:$src)>;
28  def GET_vpID32: Pseudo<(outs vpID32:$dst_id), (ins ANYID:$src)>;
29  def GET_vpID64: Pseudo<(outs vpID64:$dst_id), (ins ANYID:$src)>;
30}
31
32def SPVTypeBin : SDTypeProfile<1, 2, []>;
33
34def assigntype : SDNode<"SPIRVISD::AssignType", SPVTypeBin>;
35
36def : GINodeEquiv<ASSIGN_TYPE, assigntype>;
37
38class BinOp<string name, bits<16> opCode, list<dag> pattern=[]>
39                : Op<opCode, (outs ANYID:$dst), (ins TYPE:$src_ty, ANYID:$src, ANYID:$src2),
40                  "$dst = "#name#" $src_ty $src $src2", pattern>;
41
42class BinOpTyped<string name, bits<16> opCode, RegisterClass CID, SDNode node>
43                : Op<opCode, (outs ID:$dst), (ins TYPE:$src_ty, CID:$src, CID:$src2),
44                  "$dst = "#name#" $src_ty $src $src2", [(set ID:$dst, (assigntype (node CID:$src, CID:$src2), TYPE:$src_ty))]>;
45
46class TernOpTyped<string name, bits<16> opCode, RegisterClass CCond, RegisterClass CID, SDNode node>
47                : Op<opCode, (outs ID:$dst), (ins TYPE:$src_ty, CCond:$cond, CID:$src1, CID:$src2),
48                  "$dst = "#name#" $src_ty $cond $src1 $src2", [(set ID:$dst, (assigntype (node CCond:$cond, CID:$src1, CID:$src2), TYPE:$src_ty))]>;
49
50multiclass BinOpTypedGen<string name, bits<16> opCode, SDNode node, bit genF = 0, bit genV = 0> {
51  if genF then
52    def S: BinOpTyped<name, opCode, fID, node>;
53  else
54    def S: BinOpTyped<name, opCode, ID, node>;
55  if genV then {
56    if genF then
57      def V: BinOpTyped<name, opCode, vfID, node>;
58    else
59      def V: BinOpTyped<name, opCode, vID, node>;
60  }
61}
62
63multiclass TernOpTypedGen<string name, bits<16> opCode, SDNode node, bit genP = 1, bit genI = 1, bit genF = 0, bit genV = 0> {
64  if genF then {
65    def SFSCond: TernOpTyped<name, opCode, ID, fID, node>;
66    def SFVCond: TernOpTyped<name, opCode, vID, fID, node>;
67  }
68  if genI then {
69    def SISCond: TernOpTyped<name, opCode, ID, ID, node>;
70    def SIVCond: TernOpTyped<name, opCode, vID, ID, node>;
71  }
72  if genP then {
73    def SPSCond32: TernOpTyped<name, opCode, ID, pID32, node>;
74    def SPVCond32: TernOpTyped<name, opCode, vID, pID32, node>;
75    def SPSCond64: TernOpTyped<name, opCode, ID, pID64, node>;
76    def SPVCond64: TernOpTyped<name, opCode, vID, pID64, node>;
77  }
78  if genV then {
79    if genF then {
80      def VFSCond: TernOpTyped<name, opCode, ID, vfID, node>;
81      def VFVCond: TernOpTyped<name, opCode, vID, vfID, node>;
82    }
83    if genI then {
84      def VISCond: TernOpTyped<name, opCode, ID, vID, node>;
85      def VIVCond: TernOpTyped<name, opCode, vID, vID, node>;
86    }
87    if genP then {
88      def VPSCond32: TernOpTyped<name, opCode, ID, vpID32, node>;
89      def VPVCond32: TernOpTyped<name, opCode, vID, vpID32, node>;
90      def VPSCond64: TernOpTyped<name, opCode, ID, vpID64, node>;
91      def VPVCond64: TernOpTyped<name, opCode, vID, vpID64, node>;
92    }
93  }
94}
95
96class UnOp<string name, bits<16> opCode, list<dag> pattern=[]>
97                : Op<opCode, (outs ANYID:$dst), (ins TYPE:$type, ANYID:$src),
98                  "$dst = "#name#" $type $src", pattern>;
99class UnOpTyped<string name, bits<16> opCode, RegisterClass CID, SDNode node>
100                : Op<opCode, (outs ID:$dst), (ins TYPE:$src_ty, CID:$src),
101                  "$dst = "#name#" $src_ty $src", [(set ID:$dst, (assigntype (node CID:$src), TYPE:$src_ty))]>;
102
103class SimpleOp<string name, bits<16> opCode>: Op<opCode, (outs), (ins), name>;
104
105// 3.42.1 Miscellaneous Instructions
106
107def OpNop: SimpleOp<"OpNop", 0>;
108def OpUndef: Op<1, (outs ID:$res), (ins TYPE:$type), "$res = OpUndef $type">;
109def OpSizeOf: Op<321, (outs ID:$res), (ins TYPE:$ty, ID:$ptr), "$res = OpSizeOf $ty $ptr">;
110
111//  - SPV_KHR_expect_assume : Expect assume instructions
112def OpAssumeTrueKHR: Op<5630, (outs), (ins ID:$cond), "OpAssumeTrueKHR $cond">;
113def OpExpectKHR: Op<5631, (outs ID:$res), (ins TYPE:$ty, ID:$val, ID:$expected), "$res = OpExpectKHR $ty $val $expected">;
114
115// 3.42.2 Debug Instructions
116
117def OpSourceContinued: Op<2, (outs), (ins StringImm:$str, variable_ops),
118                  "OpSourceContinued $str">;
119def OpSource: Op<3, (outs), (ins SourceLanguage:$lang, i32imm:$version, variable_ops),
120                  "OpSource $lang $version">;
121def OpSourceExtension: Op<4, (outs), (ins StringImm:$extension, variable_ops),
122                  "OpSourceExtension $extension">;
123def OpName: Op<5, (outs), (ins ANY:$tar, StringImm:$name, variable_ops), "OpName $tar $name">;
124def OpMemberName: Op<6, (outs), (ins TYPE:$ty, i32imm:$mem, StringImm:$name, variable_ops),
125                  "OpMemberName $ty $mem $name">;
126def OpString: Op<7, (outs ID:$r), (ins StringImm:$s, variable_ops), "$r = OpString $s">;
127def OpLine: Op<8, (outs), (ins ID:$file, i32imm:$ln, i32imm:$col), "OpLine $file $ln $col">;
128def OpNoLine: Op<317, (outs), (ins), "OpNoLine">;
129def OpModuleProcessed: Op<330, (outs), (ins StringImm:$process, variable_ops),
130                  "OpModuleProcessed $process">;
131
132// 3.42.3 Annotation Instructions
133
134def OpDecorate: Op<71, (outs), (ins ANY:$target, Decoration:$dec, variable_ops),
135                  "OpDecorate $target $dec">;
136def OpMemberDecorate: Op<72, (outs), (ins TYPE:$t, i32imm:$m, Decoration:$d, variable_ops),
137                  "OpMemberDecorate $t $m $d">;
138
139// TODO Currently some deprecated opcodes are missing: OpDecorationGroup,
140// OpGroupDecorate and OpGroupMemberDecorate
141
142def OpDecorateId: Op<332, (outs), (ins ANY:$target, Decoration:$dec, variable_ops),
143                  "OpDecorateId $target $dec">;
144def OpDecorateString: Op<5632, (outs), (ins ANY:$t, Decoration:$d, StringImm:$s, variable_ops),
145                  "OpDecorateString $t $d $s">;
146def OpMemberDecorateString: Op<5633, (outs),
147                  (ins TYPE:$ty, i32imm:$mem, Decoration:$dec, StringImm:$str, variable_ops),
148                  "OpMemberDecorateString $ty $mem $dec $str">;
149
150// 3.42.4 Extension Instructions
151
152def OpExtension: Op<10, (outs), (ins StringImm:$name, variable_ops), "OpExtension $name">;
153def OpExtInstImport: Op<11, (outs ID:$res), (ins StringImm:$extInstsName, variable_ops),
154                  "$res = OpExtInstImport $extInstsName">;
155def OpExtInst: Op<12, (outs ID:$res), (ins TYPE:$ty, ID:$set, Extension:$inst, variable_ops),
156                  "$res = OpExtInst $ty $set $inst">;
157
158// 3.42.5 Mode-Setting Instructions
159
160def OpMemoryModel: Op<14, (outs), (ins AddressingModel:$addr, MemoryModel:$mem),
161                  "OpMemoryModel $addr $mem">;
162def OpEntryPoint: Op<15, (outs),
163                  (ins ExecutionModel:$model, ID:$entry, StringImm:$name, variable_ops),
164                  "OpEntryPoint $model $entry $name">;
165def OpExecutionMode: Op<16, (outs), (ins ID:$entry, ExecutionMode:$mode, variable_ops),
166                  "OpExecutionMode $entry $mode">;
167def OpCapability: Op<17, (outs), (ins Capability:$cap), "OpCapability $cap">;
168def OpExecutionModeId: Op<331, (outs), (ins ID:$entry, ExecutionMode:$mode, variable_ops),
169                  "OpExecutionModeId $entry $mode">;
170
171// 3.42.6 Type-Declaration Instructions
172
173def OpTypeVoid: Op<19, (outs TYPE:$type), (ins), "$type = OpTypeVoid">;
174def OpTypeBool: Op<20, (outs TYPE:$type), (ins), "$type = OpTypeBool">;
175def OpTypeInt: Op<21, (outs TYPE:$type), (ins i32imm:$width, i32imm:$signedness),
176                  "$type = OpTypeInt $width $signedness">;
177def OpTypeFloat: Op<22, (outs TYPE:$type), (ins i32imm:$width),
178                  "$type = OpTypeFloat $width">;
179def OpTypeVector: Op<23, (outs TYPE:$type), (ins TYPE:$compType, i32imm:$compCount),
180                  "$type = OpTypeVector $compType $compCount">;
181def OpTypeMatrix: Op<24, (outs TYPE:$type), (ins TYPE:$colType, i32imm:$colCount),
182                  "$type = OpTypeMatrix $colType $colCount">;
183def OpTypeImage: Op<25, (outs TYPE:$res), (ins TYPE:$sampTy, Dim:$dim, i32imm:$depth,
184      i32imm:$arrayed, i32imm:$MS, i32imm:$sampled, ImageFormat:$imFormat, variable_ops),
185                  "$res = OpTypeImage $sampTy $dim $depth $arrayed $MS $sampled $imFormat">;
186def OpTypeSampler: Op<26, (outs TYPE:$res), (ins), "$res = OpTypeSampler">;
187def OpTypeSampledImage: Op<27, (outs TYPE:$res), (ins TYPE:$imageType),
188                  "$res = OpTypeSampledImage $imageType">;
189def OpTypeArray: Op<28, (outs TYPE:$type), (ins TYPE:$elementType, ID:$length),
190                  "$type = OpTypeArray $elementType $length">;
191def OpTypeRuntimeArray: Op<29, (outs TYPE:$type), (ins TYPE:$elementType),
192                  "$type = OpTypeRuntimeArray $elementType">;
193def OpTypeStruct: Op<30, (outs TYPE:$res), (ins variable_ops), "$res = OpTypeStruct">;
194def OpTypeOpaque: Op<31, (outs TYPE:$res), (ins StringImm:$name, variable_ops),
195                  "$res = OpTypeOpaque $name">;
196def OpTypePointer: Op<32, (outs TYPE:$res), (ins StorageClass:$storage, TYPE:$type),
197                  "$res = OpTypePointer $storage $type">;
198def OpTypeFunction: Op<33, (outs TYPE:$funcType), (ins TYPE:$returnType, variable_ops),
199                  "$funcType = OpTypeFunction $returnType">;
200def OpTypeEvent: Op<34, (outs TYPE:$res), (ins), "$res = OpTypeEvent">;
201def OpTypeDeviceEvent: Op<35, (outs TYPE:$res), (ins), "$res = OpTypeDeviceEvent">;
202def OpTypeReserveId: Op<36, (outs TYPE:$res), (ins), "$res = OpTypeReserveId">;
203def OpTypeQueue: Op<37, (outs TYPE:$res), (ins), "$res = OpTypeQueue">;
204def OpTypePipe: Op<38, (outs TYPE:$res), (ins AccessQualifier:$a), "$res = OpTypePipe $a">;
205def OpTypeForwardPointer: Op<39, (outs), (ins TYPE:$ptrType, StorageClass:$storageClass),
206                  "OpTypeForwardPointer $ptrType $storageClass">;
207def OpTypePipeStorage: Op<322, (outs TYPE:$res), (ins), "$res = OpTypePipeStorage">;
208def OpTypeNamedBarrier: Op<327, (outs TYPE:$res), (ins), "$res = OpTypeNamedBarrier">;
209def OpTypeAccelerationStructureNV: Op<5341, (outs TYPE:$res), (ins),
210                  "$res = OpTypeAccelerationStructureNV">;
211def OpTypeCooperativeMatrixNV: Op<5358, (outs TYPE:$res),
212                  (ins TYPE:$compType, ID:$scope, ID:$rows, ID:$cols),
213                  "$res = OpTypeCooperativeMatrixNV $compType $scope $rows $cols">;
214def OpTypeCooperativeMatrixKHR: Op<4456, (outs TYPE:$res),
215                  (ins TYPE:$compType, ID:$scope, ID:$rows, ID:$cols, ID:$use),
216                  "$res = OpTypeCooperativeMatrixKHR $compType $scope $rows $cols $use">;
217
218// 3.42.7 Constant-Creation Instructions
219
220def imm_to_i32 : SDNodeXForm<imm, [{
221return CurDAG->getTargetConstant(
222  N->getValueAP().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i32);
223}]>;
224
225def fimm_to_i32 : SDNodeXForm<imm, [{
226return CurDAG->getTargetConstant(
227  N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i32);
228}]>;
229
230def gi_bitcast_fimm_to_i32 : GICustomOperandRenderer<"renderFImm32">,
231  GISDNodeXFormEquiv<fimm_to_i32>;
232
233def gi_bitcast_imm_to_i32 : GICustomOperandRenderer<"renderImm32">,
234  GISDNodeXFormEquiv<imm_to_i32>;
235
236def PseudoConstI: IntImmLeaf<i32, [{ return Imm.getBitWidth() <= 32; }], imm_to_i32>;
237def PseudoConstF: FPImmLeaf<f32, [{  return true; }], fimm_to_i32>;
238def ConstPseudoTrue: IntImmLeaf<i32, [{ return Imm.getBitWidth() == 1 && Imm.getZExtValue() == 1; }]>;
239def ConstPseudoFalse: IntImmLeaf<i32, [{ return Imm.getBitWidth() == 1 && Imm.getZExtValue() == 0; }]>;
240def ConstPseudoNull: IntImmLeaf<i64, [{ return Imm.isZero(); }]>;
241
242multiclass IntFPImm<bits<16> opCode, string name> {
243  def I: Op<opCode, (outs ID:$dst), (ins TYPE:$type, ID:$src, variable_ops),
244                  "$dst = "#name#" $type", [(set ID:$dst, (assigntype PseudoConstI:$src, TYPE:$type))]>;
245  def F: Op<opCode, (outs ID:$dst), (ins TYPE:$type, fID:$src, variable_ops),
246                  "$dst = "#name#" $type", [(set ID:$dst, (assigntype PseudoConstF:$src, TYPE:$type))]>;
247}
248
249def OpConstantTrue: Op<41, (outs ID:$dst), (ins TYPE:$src_ty), "$dst = OpConstantTrue $src_ty",
250                      [(set ID:$dst, (assigntype ConstPseudoTrue, TYPE:$src_ty))]>;
251def OpConstantFalse: Op<42, (outs ID:$dst), (ins TYPE:$src_ty), "$dst = OpConstantFalse $src_ty",
252                      [(set ID:$dst, (assigntype ConstPseudoFalse, TYPE:$src_ty))]>;
253
254defm OpConstant: IntFPImm<43, "OpConstant">;
255
256def OpConstantComposite: Op<44, (outs ID:$res), (ins TYPE:$type, variable_ops),
257                  "$res = OpConstantComposite $type">;
258def OpConstantSampler: Op<45, (outs ID:$res),
259                  (ins TYPE:$t, SamplerAddressingMode:$s, i32imm:$p, SamplerFilterMode:$f),
260                  "$res = OpConstantSampler $t $s $p $f">;
261def OpConstantNull: Op<46, (outs ID:$dst), (ins TYPE:$src_ty), "$dst = OpConstantNull $src_ty",
262                      [(set ID:$dst, (assigntype ConstPseudoNull, TYPE:$src_ty))]>;
263
264def OpSpecConstantTrue: Op<48, (outs ID:$r), (ins TYPE:$t), "$r = OpSpecConstantTrue $t">;
265def OpSpecConstantFalse: Op<49, (outs ID:$r), (ins TYPE:$t), "$r = OpSpecConstantFalse $t">;
266def OpSpecConstant: Op<50, (outs ID:$res), (ins TYPE:$type, i32imm:$imm, variable_ops),
267                  "$res = OpSpecConstant $type $imm">;
268def OpSpecConstantComposite: Op<51, (outs ID:$res), (ins TYPE:$type, variable_ops),
269                  "$res = OpSpecConstantComposite $type">;
270def OpSpecConstantOp: Op<52, (outs ID:$res), (ins TYPE:$t, i32imm:$c, ID:$o, variable_ops),
271                  "$res = OpSpecConstantOp $t $c $o">;
272
273// 3.42.8 Memory Instructions
274
275def OpVariable: Op<59, (outs ID:$res), (ins TYPE:$type, StorageClass:$sc, variable_ops),
276                  "$res = OpVariable $type $sc">;
277def OpImageTexelPointer: Op<60, (outs ID:$res),
278                  (ins TYPE:$resType, ID:$image, ID:$coord, ID:$sample),
279                  "$res = OpImageTexelPointer $resType $image $coord $sample">;
280def OpLoad: Op<61, (outs ID:$res), (ins TYPE:$resType, ID:$pointer, variable_ops),
281                  "$res = OpLoad $resType $pointer">;
282def OpStore: Op<62, (outs), (ins ID:$pointer, ID:$objectToStore, variable_ops),
283                  "OpStore $pointer $objectToStore">;
284def OpCopyMemory: Op<63, (outs), (ins ID:$dest, ID:$src, variable_ops),
285                  "OpCopyMemory $dest $src">;
286def OpCopyMemorySized: Op<64, (outs), (ins ID:$dest, ID:$src, ID:$size, variable_ops),
287                  "OpCopyMemorySized $dest $src $size">;
288def OpAccessChain: Op<65, (outs ID:$res), (ins TYPE:$type, ID:$base, variable_ops),
289                  "$res = OpAccessChain $type $base">;
290def OpInBoundsAccessChain: Op<66, (outs ID:$res),
291                  (ins TYPE:$type, ID:$base, variable_ops),
292                  "$res = OpInBoundsAccessChain $type $base">;
293def OpPtrAccessChain: Op<67, (outs ID:$res),
294                  (ins TYPE:$type, ID:$base, ID:$element, variable_ops),
295                  "$res = OpPtrAccessChain $type $base $element">;
296def OpArrayLength: Op<68, (outs ID:$res), (ins TYPE:$resTy, ID:$struct, i32imm:$arrayMember),
297                  "$res = OpArrayLength $resTy $struct $arrayMember">;
298def OpGenericPtrMemSemantics: Op<69, (outs ID:$res), (ins TYPE:$resType, ID:$pointer),
299                  "$res = OpGenericPtrMemSemantics $resType $pointer">;
300def OpInBoundsPtrAccessChain: Op<70, (outs ID:$res),
301                  (ins TYPE:$type, ID:$base, ID:$element, variable_ops),
302                  "$res = OpInBoundsPtrAccessChain $type $base $element">;
303def OpPtrEqual: Op<401, (outs ID:$res), (ins TYPE:$resType, ID:$a, ID:$b),
304                  "$res = OpPtrEqual $resType $a $b">;
305def OpPtrNotEqual: Op<402, (outs ID:$res), (ins TYPE:$resType, ID:$a, ID:$b),
306                  "$res = OpPtrNotEqual $resType $a $b">;
307def OpPtrDiff: Op<403, (outs ID:$res), (ins TYPE:$resType, ID:$a, ID:$b),
308                  "$res = OpPtrDiff $resType $a $b">;
309
310// - SPV_INTEL_variable_length_array
311
312def OpVariableLengthArrayINTEL: Op<5818, (outs ID:$res), (ins TYPE:$type, ID:$length),
313                  "$res = OpVariableLengthArrayINTEL $type $length">;
314def OpSaveMemoryINTEL: Op<5819, (outs ID:$res), (ins TYPE:$type),
315                  "$res = OpSaveMemoryINTEL $type">;
316def OpRestoreMemoryINTEL: Op<5820, (outs), (ins ID:$ptr),
317                  "OpRestoreMemoryINTEL $ptr">;
318
319// 3.42.9 Function Instructions
320
321def OpFunction: Op<54, (outs ID:$func),
322                  (ins TYPE:$resType, FunctionControl:$funcControl, TYPE:$funcType),
323                  "$func = OpFunction $resType $funcControl $funcType">;
324def OpFunctionParameter: Op<55, (outs ID:$arg), (ins TYPE:$type),
325                  "$arg = OpFunctionParameter $type">;
326def OpFunctionEnd: Op<56, (outs), (ins), "OpFunctionEnd"> {
327  let isTerminator=1;
328}
329def OpFunctionCall: Op<57, (outs ID:$res), (ins TYPE:$resType, ID:$function, variable_ops),
330                  "$res = OpFunctionCall $resType $function">;
331
332// 3.42.10 Image Instructions
333
334def OpSampledImage: BinOp<"OpSampledImage", 86>;
335
336def OpImageSampleImplicitLod: Op<87, (outs ID:$res),
337                  (ins TYPE:$type, ID:$sampledImage, ID:$coord, variable_ops),
338                  "$res = OpImageSampleImplicitLod $type $sampledImage $coord">;
339def OpImageSampleExplicitLod: Op<88, (outs ID:$res),
340                  (ins TYPE:$ty, ID:$sImage, ID:$uv, ImageOperand:$op, ID:$i, variable_ops),
341                  "$res = OpImageSampleExplicitLod $ty $sImage $uv $op $i">;
342
343def OpImageSampleDrefImplicitLod: Op<89, (outs ID:$res),
344                  (ins TYPE:$type, ID:$sampledImage, ID:$coord, ID:$dref, variable_ops),
345                  "$res = OpImageSampleDrefImplicitLod $type $sampledImage $dref $coord">;
346def OpImageSampleDrefExplicitLod: Op<90, (outs ID:$res),
347                  (ins TYPE:$ty, ID:$im, ID:$uv, ID:$d, ImageOperand:$op, ID:$i, variable_ops),
348                  "$res = OpImageSampleDrefExplicitLod $ty $im $uv $d $op $i">;
349
350def OpImageSampleProjImplicitLod: Op<91, (outs ID:$res),
351                  (ins TYPE:$type, ID:$sampledImage, ID:$coord, variable_ops),
352                  "$res = OpImageSampleProjImplicitLod $type $sampledImage $coord">;
353def OpImageSampleProjExplicitLod: Op<92, (outs ID:$res),
354                  (ins TYPE:$ty, ID:$im, ID:$uv, ID:$d, ImageOperand:$op, ID:$i, variable_ops),
355                  "$res = OpImageSampleProjExplicitLod $ty $im $uv $op $i">;
356
357def OpImageSampleProjDrefImplicitLod: Op<93, (outs ID:$res),
358                  (ins TYPE:$type, ID:$sampledImage, ID:$coord, ID:$dref, variable_ops),
359                  "$res = OpImageSampleProjDrefImplicitLod $type $sampledImage $dref $coord">;
360def OpImageSampleProjDrefExplicitLod: Op<94, (outs ID:$res),
361                  (ins TYPE:$ty, ID:$im, ID:$uv, ID:$d, ImageOperand:$op, ID:$i, variable_ops),
362                  "$res = OpImageSampleProjDrefExplicitLod $ty $im $uv $d $op $i">;
363
364def OpImageFetch: Op<95, (outs ID:$res),
365                  (ins TYPE:$type, ID:$image, ID:$coord, variable_ops),
366                  "$res = OpImageFetch $type $image $coord">;
367def OpImageGather: Op<96, (outs ID:$res),
368                  (ins TYPE:$type, ID:$sampledImage, ID:$coord, ID:$component, variable_ops),
369                  "$res = OpImageGather $type $sampledImage $coord $component">;
370def OpImageDrefGather: Op<97, (outs ID:$res),
371                  (ins TYPE:$type, ID:$sampledImage, ID:$coord, ID:$dref, variable_ops),
372                  "$res = OpImageDrefGather $type $sampledImage $coord $dref">;
373
374def OpImageRead: Op<98, (outs ID:$res),
375                  (ins TYPE:$type, ID:$image, ID:$coord, variable_ops),
376                  "$res = OpImageRead $type $image $coord">;
377def OpImageWrite: Op<99, (outs), (ins ID:$image, ID:$coord, ID:$texel, variable_ops),
378                  "OpImageWrite $image $coord $texel">;
379
380def OpImage: UnOp<"OpImage", 100>;
381def OpImageQueryFormat: UnOp<"OpImageQueryFormat", 101>;
382def OpImageQueryOrder: UnOp<"OpImageQueryOrder", 102>;
383def OpImageQuerySizeLod: BinOp<"OpImageQuerySizeLod", 103>;
384def OpImageQuerySize: UnOp<"OpImageQuerySize", 104>;
385def OpImageQueryLod: BinOp<"OpImageQueryLod", 105>;
386def OpImageQueryLevels: UnOp<"OpImageQueryLevels", 106>;
387def OpImageQuerySamples: UnOp<"OpImageQuerySamples", 107>;
388
389def OpImageSparseSampleImplicitLod: Op<305, (outs ID:$res),
390                  (ins TYPE:$type, ID:$sampledImage, ID:$coord, variable_ops),
391                  "$res = OpImageSparseSampleImplicitLod $type $sampledImage $coord">;
392def OpImageSparseSampleExplicitLod: Op<306, (outs ID:$res),
393                  (ins TYPE:$ty, ID:$sImage, ID:$uv, ImageOperand:$op, ID:$i, variable_ops),
394                  "$res = OpImageSparseSampleExplicitLod $ty $sImage $uv $op $i">;
395
396def OpImageSparseSampleDrefImplicitLod: Op<307, (outs ID:$res),
397                  (ins TYPE:$type, ID:$sampledImg, ID:$coord, ID:$dref, variable_ops),
398                  "$res = OpImageSparseSampleDrefImplicitLod $type $sampledImg $dref $coord">;
399def OpImageSparseSampleDrefExplicitLod: Op<308, (outs ID:$res),
400                  (ins TYPE:$ty, ID:$im, ID:$uv, ID:$d, ImageOperand:$op, ID:$i, variable_ops),
401                  "$res = OpImageSparseSampleDrefExplicitLod $ty $im $uv $d $op $i">;
402
403def OpImageSparseSampleProjImplicitLod: Op<309, (outs ID:$res),
404                  (ins TYPE:$type, ID:$sampledImage, ID:$coord, variable_ops),
405                  "$res = OpImageSparseSampleProjImplicitLod $type $sampledImage $coord">;
406def OpImageSparseSampleProjExplicitLod: Op<310, (outs ID:$res),
407                  (ins TYPE:$ty, ID:$im, ID:$uv, ID:$d, ImageOperand:$op, ID:$i, variable_ops),
408                  "$res = OpImageSparseSampleProjExplicitLod $ty $im $uv $op $i">;
409
410def OpImageSparseSampleProjDrefImplicitLod: Op<311, (outs ID:$res),
411                  (ins TYPE:$type, ID:$sImage, ID:$coord, ID:$dref, variable_ops),
412                  "$res = OpImageSparseSampleProjDrefImplicitLod $type $sImage $dref $coord">;
413def OpImageSparseSampleProjDrefExplicitLod: Op<312, (outs ID:$res),
414                  (ins TYPE:$ty, ID:$im, ID:$uv, ID:$d, ImageOperand:$op, ID:$i, variable_ops),
415                  "$res = OpImageSparseSampleProjDrefExplicitLod $ty $im $uv $d $op $i">;
416
417def OpImageSparseFetch: Op<313, (outs ID:$res),
418                  (ins TYPE:$type, ID:$image, ID:$coord, variable_ops),
419                  "$res = OpImageSparseFetch $type $image $coord">;
420def OpImageSparseGather: Op<314, (outs ID:$res),
421                  (ins TYPE:$type, ID:$sampledImage, ID:$coord, ID:$component, variable_ops),
422                  "$res = OpImageSparseGather $type $sampledImage $coord $component">;
423def OpImageSparseDrefGather: Op<315, (outs ID:$res),
424                  (ins TYPE:$type, ID:$sampledImage, ID:$coord, ID:$dref, variable_ops),
425                  "$res = OpImageSparseDrefGather $type $sampledImage $coord $dref">;
426
427def OpImageSparseTexelsResident: UnOp<"OpImageSparseTexelsResident", 316>;
428
429def OpImageSparseRead: Op<320, (outs ID:$res),
430                  (ins TYPE:$type, ID:$image, ID:$coord, variable_ops),
431                  "$res = OpImageSparseRead $type $image $coord">;
432
433def OpImageSampleFootprintNV: Op<5283, (outs ID:$res),
434                  (ins TYPE:$ty, ID:$sImg, ID:$uv, ID:$granularity, ID:$coarse, variable_ops),
435                  "$res = OpImageSampleFootprintNV $ty $sImg $uv $granularity $coarse">;
436
437// 3.42.11 Conversion instructions
438
439def OpConvertFToU : UnOp<"OpConvertFToU", 109>;
440def OpConvertFToS : UnOp<"OpConvertFToS", 110>;
441def OpConvertSToF : UnOp<"OpConvertSToF", 111>;
442def OpConvertUToF : UnOp<"OpConvertUToF", 112>;
443
444def OpUConvert : UnOp<"OpUConvert", 113>;
445def OpSConvert : UnOp<"OpSConvert", 114>;
446def OpFConvert : UnOp<"OpFConvert", 115>;
447
448def OpQuantizeToF16 : UnOp<"OpQuantizeToF16", 116>;
449
450def OpConvertPtrToU : UnOp<"OpConvertPtrToU", 117>;
451
452def OpSatConvertSToU : UnOp<"OpSatConvertSToU", 118>;
453def OpSatConvertUToS : UnOp<"OpSatConvertUToS", 119>;
454
455def OpConvertUToPtr : UnOp<"OpConvertUToPtr", 120>;
456def OpPtrCastToGeneric : UnOp<"OpPtrCastToGeneric", 121>;
457def OpGenericCastToPtr : UnOp<"OpGenericCastToPtr", 122>;
458def OpGenericCastToPtrExplicit : Op<123, (outs ID:$r), (ins TYPE:$t, ID:$p, StorageClass:$s),
459                              "$r = OpGenericCastToPtrExplicit $t $p $s">;
460def OpBitcast : UnOp<"OpBitcast", 124>;
461
462// SPV_INTEL_usm_storage_classes
463def OpPtrCastToCrossWorkgroupINTEL : UnOp<"OpPtrCastToCrossWorkgroupINTEL", 5934>;
464def OpCrossWorkgroupCastToPtrINTEL : UnOp<"OpCrossWorkgroupCastToPtrINTEL", 5938>;
465
466// SPV_INTEL_bfloat16_conversion
467def OpConvertFToBF16INTEL : UnOp<"OpConvertFToBF16INTEL", 6116>;
468def OpConvertBF16ToFINTEL : UnOp<"OpConvertBF16ToFINTEL", 6117>;
469
470// 3.42.12 Composite Instructions
471
472def OpVectorExtractDynamic: Op<77, (outs ID:$res), (ins TYPE:$type, vID:$vec, ID:$idx),
473                  "$res = OpVectorExtractDynamic $type $vec $idx", [(set ID:$res, (assigntype (extractelt vID:$vec, ID:$idx), TYPE:$type))]>;
474
475def OpVectorInsertDynamic: Op<78, (outs ID:$res), (ins TYPE:$ty, ID:$vec, ID:$comp, ID:$idx),
476                  "$res = OpVectorInsertDynamic $ty $vec $comp $idx">;
477def OpVectorShuffle: Op<79, (outs ID:$res), (ins TYPE:$ty, ID:$v1, ID:$v2, variable_ops),
478                  "$res = OpVectorShuffle $ty $v1 $v2">;
479def OpCompositeConstruct: Op<80, (outs ID:$res), (ins TYPE:$type, variable_ops),
480                  "$res = OpCompositeConstruct $type">;
481def OpCompositeExtract: Op<81, (outs ID:$res), (ins TYPE:$type, ID:$base, variable_ops),
482                  "$res = OpCompositeExtract $type $base">;
483def OpCompositeInsert: Op<82, (outs ID:$r), (ins TYPE:$ty, ID:$obj, ID:$base, variable_ops),
484                  "$r = OpCompositeInsert $ty $obj $base">;
485def OpCopyObject: UnOp<"OpCopyObject", 83>;
486def OpTranspose: UnOp<"OpTranspose", 84>;
487def OpCopyLogical: UnOp<"OpCopyLogical", 400>;
488
489// 3.42.13 Arithmetic Instructions
490
491def OpSNegate: UnOp<"OpSNegate", 126>;
492def OpFNegate: UnOpTyped<"OpFNegate", 127, fID, fneg>;
493def OpFNegateV: UnOpTyped<"OpFNegate", 127, vfID, fneg>;
494defm OpIAdd: BinOpTypedGen<"OpIAdd", 128, add, 0, 1>;
495defm OpFAdd: BinOpTypedGen<"OpFAdd", 129, fadd, 1, 1>;
496
497defm OpISub: BinOpTypedGen<"OpISub", 130, sub, 0, 1>;
498defm OpFSub: BinOpTypedGen<"OpFSub", 131, fsub, 1, 1>;
499
500defm OpIMul: BinOpTypedGen<"OpIMul", 132, mul, 0, 1>;
501defm OpFMul: BinOpTypedGen<"OpFMul", 133, fmul, 1, 1>;
502
503defm OpUDiv: BinOpTypedGen<"OpUDiv", 134, udiv, 0, 1>;
504defm OpSDiv: BinOpTypedGen<"OpSDiv", 135, sdiv, 0, 1>;
505defm OpFDiv: BinOpTypedGen<"OpFDiv", 136, fdiv, 1, 1>;
506
507defm OpUMod: BinOpTypedGen<"OpUMod", 137, urem, 0, 1>;
508defm OpSRem: BinOpTypedGen<"OpSRem", 138, srem, 0, 1>;
509
510def OpSMod: BinOp<"OpSMod", 139>;
511
512defm OpFRem: BinOpTypedGen<"OpFRem", 140, frem, 1, 1>;
513def OpFMod: BinOp<"OpFMod", 141>;
514
515def OpVectorTimesScalar: BinOp<"OpVectorTimesScalar", 142>;
516def OpMatrixTimesScalar: BinOp<"OpMatrixTimesScalar", 143>;
517def OpVectorTimesMatrix: BinOp<"OpVectorTimesMatrix", 144>;
518def OpMatrixTimesVector: BinOp<"OpMatrixTimesVector", 145>;
519def OpMatrixTimesMatrix: BinOp<"OpMatrixTimesMatrix", 146>;
520
521def OpOuterProduct: BinOp<"OpOuterProduct", 147>;
522def OpDot: BinOp<"OpDot", 148>;
523
524def OpIAddCarry: BinOpTyped<"OpIAddCarry", 149, ID, addc>;
525def OpISubBorrow: BinOpTyped<"OpISubBorrow", 150, ID, subc>;
526def OpUMulExtended: BinOp<"OpUMulExtended", 151>;
527def OpSMulExtended: BinOp<"OpSMulExtended", 152>;
528
529// 3.42.14 Bit Instructions
530
531defm OpShiftRightLogical: BinOpTypedGen<"OpShiftRightLogical", 194, srl, 0, 1>;
532defm OpShiftRightArithmetic: BinOpTypedGen<"OpShiftRightArithmetic", 195, sra, 0, 1>;
533defm OpShiftLeftLogical: BinOpTypedGen<"OpShiftLeftLogical", 196, shl, 0, 1>;
534
535defm OpBitwiseOr: BinOpTypedGen<"OpBitwiseOr", 197, or, 0, 1>;
536defm OpBitwiseXor: BinOpTypedGen<"OpBitwiseXor", 198, xor, 0, 1>;
537defm OpBitwiseAnd: BinOpTypedGen<"OpBitwiseAnd", 199, and, 0, 1>;
538def OpNot: UnOp<"OpNot", 200>;
539
540def OpBitFieldInsert: Op<201, (outs ID:$res),
541                  (ins TYPE:$ty, ID:$base, ID:$insert, ID:$offset, ID:$count),
542                  "$res = OpBitFieldInsert $ty $base $insert $offset $count">;
543def OpBitFieldSExtract: Op<202, (outs ID:$res),
544                  (ins TYPE:$ty, ID:$base, ID:$offset, ID:$count),
545                  "$res = OpBitFieldSExtract $ty $base $offset $count">;
546def OpBitFieldUExtract: Op<203, (outs ID:$res),
547                  (ins TYPE:$ty, ID:$base, ID:$offset, ID:$count),
548                  "$res = OpBitFieldUExtract $ty $base $offset $count">;
549def OpBitReverse: Op<204, (outs ID:$r), (ins TYPE:$ty, ID:$b), "$r = OpBitReverse $ty $b">;
550def OpBitCount: Op<205, (outs ID:$r), (ins TYPE:$ty, ID:$b), "$r = OpBitCount $ty $b">;
551
552// 3.42.15 Relational and Logical Instructions
553
554def OpAny: Op<154, (outs ID:$res), (ins TYPE:$ty, ID:$vec),
555                  "$res = OpAny $ty $vec">;
556def OpAll: Op<155, (outs ID:$res), (ins TYPE:$ty, ID:$vec),
557                  "$res = OpAll $ty $vec">;
558
559def OpIsNan: UnOp<"OpIsNan", 156>;
560def OpIsInf: UnOp<"OpIsInf", 157>;
561def OpIsFinite: UnOp<"OpIsFinite", 158>;
562def OpIsNormal: UnOp<"OpIsNormal", 159>;
563def OpSignBitSet: UnOp<"OpSignBitSet", 160>;
564
565def OpLessOrGreater: BinOp<"OpLessOrGreater", 161>;
566def OpOrdered: BinOp<"OpOrdered", 162>;
567def OpUnordered: BinOp<"OpUnordered", 163>;
568
569def OpLogicalEqual: BinOp<"OpLogicalEqual", 164>;
570def OpLogicalNotEqual: BinOp<"OpLogicalNotEqual", 165>;
571def OpLogicalOr: BinOp<"OpLogicalOr", 166>;
572def OpLogicalAnd: BinOp<"OpLogicalAnd", 167>;
573def OpLogicalNot: UnOp<"OpLogicalNot", 168>;
574
575defm OpSelect: TernOpTypedGen<"OpSelect", 169, select, 1, 1, 1, 1>;
576
577def OpIEqual: BinOp<"OpIEqual", 170>;
578def OpINotEqual: BinOp<"OpINotEqual", 171>;
579
580def OpUGreaterThan: BinOp<"OpUGreaterThan", 172>;
581def OpSGreaterThan: BinOp<"OpSGreaterThan", 173>;
582def OpUGreaterThanEqual: BinOp<"OpUGreaterThanEqual", 174>;
583def OpSGreaterThanEqual: BinOp<"OpSGreaterThanEqual", 175>;
584def OpULessThan: BinOp<"OpULessThan", 176>;
585def OpSLessThan: BinOp<"OpSLessThan", 177>;
586def OpULessThanEqual: BinOp<"OpULessThanEqual", 178>;
587def OpSLessThanEqual: BinOp<"OpSLessThanEqual", 179>;
588
589def OpFOrdEqual: BinOp<"OpFOrdEqual", 180>;
590def OpFUnordEqual: BinOp<"OpFUnordEqual", 181>;
591def OpFOrdNotEqual: BinOp<"OpFOrdNotEqual", 182>;
592def OpFUnordNotEqual: BinOp<"OpFUnordNotEqual", 183>;
593
594def OpFOrdLessThan: BinOp<"OpFOrdLessThan", 184>;
595def OpFUnordLessThan: BinOp<"OpFUnordLessThan", 185>;
596def OpFOrdGreaterThan: BinOp<"OpFOrdGreaterThan", 186>;
597def OpFUnordGreaterThan: BinOp<"OpFUnordGreaterThan", 187>;
598
599def OpFOrdLessThanEqual: BinOp<"OpFOrdLessThanEqual", 188>;
600def OpFUnordLessThanEqual: BinOp<"OpFUnordLessThanEqual", 189>;
601def OpFOrdGreaterThanEqual: BinOp<"OpFOrdGreaterThanEqual", 190>;
602def OpFUnordGreaterThanEqual: BinOp<"OpFUnordGreaterThanEqual", 191>;
603
604// 3.42.16 Derivative Instructions
605
606def OpDPdx: UnOp<"OpDPdx", 207>;
607def OpDPdy: UnOp<"OpDPdy", 208>;
608def OpFwidth: UnOp<"OpFwidth", 209>;
609
610def OpDPdxFine: UnOp<"OpDPdxFine", 210>;
611def OpDPdyFine: UnOp<"OpDPdyFine", 211>;
612def OpFwidthFine: UnOp<"OpFwidthFine", 212>;
613
614def OpDPdxCoarse: UnOp<"OpDPdxCoarse", 213>;
615def OpDPdyCoarse: UnOp<"OpDPdyCoarse", 214>;
616def OpFwidthCoarse: UnOp<"OpFwidthCoarse", 215>;
617
618// 3.42.17 Control-Flow Instructions
619
620def OpPhi: Op<245, (outs ID:$res), (ins TYPE:$type, ID:$var0, ID:$block0, variable_ops),
621                  "$res = OpPhi $type $var0 $block0">;
622def OpLoopMerge: Op<246, (outs), (ins ID:$merge, ID:$continue, LoopControl:$lc, variable_ops),
623                  "OpLoopMerge $merge $continue $lc">;
624def OpSelectionMerge: Op<247, (outs), (ins ID:$merge, SelectionControl:$sc),
625                  "OpSelectionMerge $merge $sc">;
626def OpLabel: Op<248, (outs ID:$label), (ins), "$label = OpLabel">;
627let isTerminator=1 in {
628  def OpBranch: Op<249, (outs), (ins ID:$label), "OpBranch $label">;
629  def OpBranchConditional: Op<250, (outs), (ins ID:$cond, ID:$true, ID:$false, variable_ops),
630                  "OpBranchConditional $cond $true $false">;
631  def OpSwitch: Op<251, (outs), (ins ID:$sel, ID:$dflt, variable_ops), "OpSwitch $sel $dflt">;
632}
633let isReturn = 1, hasDelaySlot=0, isBarrier = 0, isTerminator=1, isNotDuplicable = 1 in {
634  def OpKill: SimpleOp<"OpKill", 252>;
635  def OpReturn: SimpleOp<"OpReturn", 253>;
636  def OpReturnValue: Op<254, (outs), (ins ANYID:$ret), "OpReturnValue $ret">;
637  def OpUnreachable: SimpleOp<"OpUnreachable", 255>;
638}
639def OpLifetimeStart: Op<256, (outs), (ins ID:$ptr, i32imm:$sz), "OpLifetimeStart $ptr, $sz">;
640def OpLifetimeStop: Op<257, (outs), (ins ID:$ptr, i32imm:$sz), "OpLifetimeStop $ptr, $sz">;
641
642// 3.42.18 Atomic Instructions
643
644class AtomicOp<string name, bits<16> opCode>: Op<opCode, (outs ID:$res),
645                  (ins TYPE:$ty, ID:$ptr, ID:$sc, ID:$sem),
646                  "$res = "#name#" $ty $ptr $sc $sem">;
647
648class AtomicOpVal<string name, bits<16> opCode>: Op<opCode, (outs ID:$res),
649                  (ins TYPE:$ty, ID:$ptr, ID:$sc, ID:$sem, ID:$val),
650                  "$res = "#name#" $ty $ptr $sc $sem $val">;
651
652def OpAtomicLoad: AtomicOp<"OpAtomicLoad", 227>;
653
654def OpAtomicStore: Op<228, (outs), (ins ID:$ptr, ID:$sc, ID:$sem, ID:$val),
655                  "OpAtomicStore $ptr $sc $sem $val">;
656def OpAtomicExchange: Op<229, (outs ID:$res),
657                  (ins TYPE:$ty, ID:$ptr, ID:$sc, ID:$sem, ID:$val),
658                  "$res = OpAtomicExchange $ty $ptr $sc $sem $val">;
659def OpAtomicCompareExchange: Op<230, (outs ID:$res),
660                  (ins TYPE:$ty, ID:$ptr, ID:$sc, ID:$eq,
661                   ID:$neq, ID:$val, ID:$cmp),
662                  "$res = OpAtomicCompareExchange $ty $ptr $sc $eq $neq $val $cmp">;
663def OpAtomicCompareExchangeWeak: Op<231, (outs ID:$res),
664                   (ins TYPE:$ty, ID:$ptr, ID:$sc, ID:$eq,
665                    ID:$neq, ID:$val, ID:$cmp),
666                   "$res = OpAtomicCompareExchangeWeak $ty $ptr $sc $eq $neq $val $cmp">;
667
668def OpAtomicIIncrement: AtomicOp<"OpAtomicIIncrement", 232>;
669def OpAtomicIDecrement: AtomicOp<"OpAtomicIDecrement", 233>;
670
671def OpAtomicIAdd: AtomicOpVal<"OpAtomicIAdd", 234>;
672def OpAtomicISub: AtomicOpVal<"OpAtomicISub", 235>;
673
674def OpAtomicSMin: AtomicOpVal<"OpAtomicSMin", 236>;
675def OpAtomicUMin: AtomicOpVal<"OpAtomicUMin", 237>;
676def OpAtomicSMax: AtomicOpVal<"OpAtomicSMax", 238>;
677def OpAtomicUMax: AtomicOpVal<"OpAtomicUMax", 239>;
678
679def OpAtomicAnd: AtomicOpVal<"OpAtomicAnd", 240>;
680def OpAtomicOr: AtomicOpVal<"OpAtomicOr", 241>;
681def OpAtomicXor: AtomicOpVal<"OpAtomicXor", 242>;
682
683def OpAtomicFAddEXT: AtomicOpVal<"OpAtomicFAddEXT", 6035>;
684def OpAtomicFMinEXT: AtomicOpVal<"OpAtomicFMinEXT", 5614>;
685def OpAtomicFMaxEXT: AtomicOpVal<"OpAtomicFMaxEXT", 5615>;
686
687def OpAtomicFlagTestAndSet: AtomicOp<"OpAtomicFlagTestAndSet", 318>;
688def OpAtomicFlagClear: Op<319, (outs), (ins ID:$ptr, ID:$sc, ID:$sem),
689                  "OpAtomicFlagClear $ptr $sc $sem">;
690
691// 3.42.19 Primitive Instructions
692
693def OpEmitVertex: SimpleOp<"OpEmitVertex", 218>;
694def OpEndPrimitive: SimpleOp<"OpEndPrimitive", 219>;
695def OpEmitStreamVertex: Op<220, (outs), (ins ID:$stream), "OpEmitStreamVertex $stream">;
696def OpEndStreamPrimitive: Op<221, (outs), (ins ID:$stream), "OpEndStreamPrimitive $stream">;
697
698// 3.42.20 Barrier Instructions
699
700def OpControlBarrier: Op<224, (outs), (ins ID:$exec, ID:$mem, ID:$sem),
701                  "OpControlBarrier $exec $mem $sem">;
702def OpMemoryBarrier: Op<225, (outs), (ins ID:$mem, ID:$sem),
703                  "OpMemoryBarrier $mem $sem">;
704def OpNamedBarrierInitialize: UnOp<"OpNamedBarrierInitialize", 328>;
705def OpMemoryNamedBarrier: Op<329, (outs), (ins ID:$barr, ID:$mem, ID:$sem),
706                  "OpMemoryNamedBarrier $barr $mem $sem">;
707
708// 3.42.21. Group and Subgroup Instructions
709
710def OpGroupAsyncCopy: Op<259, (outs ID:$res), (ins TYPE:$ty, ID:$scope,
711                  ID:$dst, ID:$src, ID:$nelts, ID:$stride, ID:$event),
712                  "$res = OpGroupAsyncCopy $ty $scope $dst $src $nelts $stride $event">;
713def OpGroupWaitEvents: Op<260, (outs), (ins ID:$scope, ID:$nelts, ID:$elist),
714                  "OpGroupWaitEvents $scope $nelts $elist">;
715def OpGroupAll: Op<261, (outs ID:$res), (ins TYPE:$ty, ID:$scope, ID:$pr),
716                  "$res = OpGroupAll $ty $scope $pr">;
717def OpGroupAny: Op<262, (outs ID:$res), (ins TYPE:$ty, ID:$scope, ID:$pr),
718                  "$res = OpGroupAny $ty $scope $pr">;
719def OpGroupBroadcast: Op<263, (outs ID:$res), (ins TYPE:$ty, ID:$scope,
720                               ID:$val, ID:$id),
721                  "$res = OpGroupBroadcast $ty $scope $val $id">;
722class OpGroup<string name, bits<16> opCode>: Op<opCode, (outs ID:$res),
723                  (ins TYPE:$ty, ID:$scope, GroupOperation:$groupOp, ID:$x),
724                  "$res = OpGroup"#name#" $ty $scope $groupOp $x">;
725def OpGroupIAdd: OpGroup<"IAdd", 264>;
726def OpGroupFAdd: OpGroup<"FAdd", 265>;
727def OpGroupFMin: OpGroup<"FMin", 266>;
728def OpGroupUMin: OpGroup<"UMin", 267>;
729def OpGroupSMin: OpGroup<"SMin", 268>;
730def OpGroupFMax: OpGroup<"FMax", 269>;
731def OpGroupUMax: OpGroup<"UMax", 270>;
732def OpGroupSMax: OpGroup<"SMax", 271>;
733
734// TODO: 3.42.22. Device-Side Enqueue Instructions
735def OpEnqueueKernel: Op<292, (outs ID:$res), (ins TYPE:$type, ID:$queue, ID:$flags, ID:$NDR, ID:$nevents, ID:$wevents,
736                                              ID:$revent, ID:$invoke, ID:$param, ID:$psize, ID:$palign, variable_ops),
737                  "$res = OpEnqueueKernel $type $queue $flags $NDR $nevents $wevents $revent $invoke $param $psize $palign">;
738def OpRetainEvent: Op<297, (outs), (ins ID:$event), "OpRetainEvent $event">;
739def OpReleaseEvent: Op<298, (outs), (ins ID:$event), "OpReleaseEvent $event">;
740def OpCreateUserEvent: Op<299, (outs ID:$res), (ins TYPE:$type),
741                  "$res = OpCreateUserEvent $type">;
742def OpIsValidEvent: Op<300, (outs ID:$res), (ins TYPE:$type, ID:$event),
743                  "$res = OpIsValidEvent $type $event ">;
744def OpSetUserEventStatus: Op<301, (outs), (ins ID:$event, ID:$status),
745                  "OpSetUserEventStatus $event $status">;
746def OpCaptureEventProfilingInfo: Op<302, (outs),
747                  (ins ID:$event, ID:$info, ID:$value),
748                  "OpCaptureEventProfilingInfo $event $info $value">;
749def OpGetDefaultQueue: Op<303, (outs ID:$res), (ins TYPE:$type),
750                  "$res = OpGetDefaultQueue $type">;
751def OpBuildNDRange: Op<304, (outs ID:$res), (ins TYPE:$type, ID:$GWS, ID:$LWS, ID:$GWO),
752                  "$res = OpBuildNDRange $type $GWS $LWS $GWO">;
753
754// TODO: 3.42.23. Pipe Instructions
755
756// 3.42.24. Non-Uniform Instructions
757
758def OpGroupNonUniformElect: Op<333, (outs ID:$res), (ins TYPE:$ty, ID:$scope),
759                  "$res = OpGroupNonUniformElect $ty $scope">;
760class OpGroupNU3<string name, bits<16> opCode>: Op<opCode,
761                  (outs ID:$res), (ins TYPE:$ty, ID:$scope, ID:$pred),
762                  "$res = OpGroupNonUniform"#name#" $ty $scope $pred">;
763class OpGroupNU4<string name, bits<16> opCode>: Op<opCode,
764                  (outs ID:$res), (ins TYPE:$ty, ID:$scope, ID:$val, ID:$id),
765                  "$res = OpGroupNonUniform"#name#" $ty $scope $val $id">;
766def OpGroupNonUniformAll: OpGroupNU3<"All", 334>;
767def OpGroupNonUniformAny: OpGroupNU3<"Any", 335>;
768def OpGroupNonUniformAllEqual: OpGroupNU3<"AllEqual", 336>;
769def OpGroupNonUniformBroadcast: OpGroupNU4<"Broadcast", 337>;
770def OpGroupNonUniformBroadcastFirst: OpGroupNU3<"BroadcastFirst", 338>;
771def OpGroupNonUniformBallot: OpGroupNU3<"Ballot", 339>;
772def OpGroupNonUniformInverseBallot: OpGroupNU3<"InverseBallot", 340>;
773def OpGroupNonUniformBallotBitExtract: OpGroupNU4<"BallotBitExtract", 341>;
774def OpGroupNonUniformBallotBitCount: Op<342, (outs ID:$res),
775                  (ins TYPE:$ty, ID:$scope, GroupOperation:$groupOp, ID:$val),
776                  "$res = OpGroupNonUniformBallotBitCount "
777                          "$ty $scope $groupOp $val">;
778def OpGroupNonUniformBallotFindLSB: OpGroupNU3<"BallotFindLSB", 343>;
779def OpGroupNonUniformBallotFindMSB: OpGroupNU3<"BallotFindMSB", 344>;
780def OpGroupNonUniformShuffle: OpGroupNU4<"Shuffle", 345>;
781def OpGroupNonUniformShuffleXor: OpGroupNU4<"ShuffleXor", 346>;
782def OpGroupNonUniformShuffleUp: OpGroupNU4<"ShuffleUp", 347>;
783def OpGroupNonUniformShuffleDown: OpGroupNU4<"ShuffleDown", 348>;
784class OpGroupNUGroup<string name, bits<16> opCode>: Op<opCode, (outs ID:$res),
785                  (ins TYPE:$ty, ID:$scope, GroupOperation:$groupOp,
786                   ID:$val, variable_ops),
787                  "$res = OpGroupNonUniform"#name#" $ty $scope $groupOp $val">;
788def OpGroupNonUniformIAdd: OpGroupNUGroup<"IAdd", 349>;
789def OpGroupNonUniformFAdd: OpGroupNUGroup<"FAdd", 350>;
790def OpGroupNonUniformIMul: OpGroupNUGroup<"IMul", 351>;
791def OpGroupNonUniformFMul: OpGroupNUGroup<"FMul", 352>;
792def OpGroupNonUniformSMin: OpGroupNUGroup<"SMin", 353>;
793def OpGroupNonUniformUMin: OpGroupNUGroup<"UMin", 354>;
794def OpGroupNonUniformFMin: OpGroupNUGroup<"FMin", 355>;
795def OpGroupNonUniformSMax: OpGroupNUGroup<"SMax", 356>;
796def OpGroupNonUniformUMax: OpGroupNUGroup<"UMax", 357>;
797def OpGroupNonUniformFMax: OpGroupNUGroup<"FMax", 358>;
798def OpGroupNonUniformBitwiseAnd: OpGroupNUGroup<"BitwiseAnd", 359>;
799def OpGroupNonUniformBitwiseOr: OpGroupNUGroup<"BitwiseOr", 360>;
800def OpGroupNonUniformBitwiseXor: OpGroupNUGroup<"BitwiseXor", 361>;
801def OpGroupNonUniformLogicalAnd: OpGroupNUGroup<"LogicalAnd", 362>;
802def OpGroupNonUniformLogicalOr: OpGroupNUGroup<"LogicalOr", 363>;
803def OpGroupNonUniformLogicalXor: OpGroupNUGroup<"LogicalXor", 364>;
804
805// SPV_KHR_subgroup_rotate
806def OpGroupNonUniformRotateKHR: Op<4431, (outs ID:$res),
807                  (ins TYPE:$type, ID:$scope, ID:$value, ID:$delta, variable_ops),
808                  "$res = OpGroupNonUniformRotateKHR $type $scope $value $delta">;
809
810// SPV_KHR_shader_clock
811def OpReadClockKHR: Op<5056, (outs ID:$res),
812                  (ins TYPE:$type, ID:$scope),
813                  "$res = OpReadClockKHR $type $scope">;
814
815// 3.49.7, Constant-Creation Instructions
816
817//  - SPV_INTEL_function_pointers
818def OpConstantFunctionPointerINTEL: Op<5600, (outs ID:$res), (ins TYPE:$ty, ID:$fun), "$res = OpConstantFunctionPointerINTEL $ty $fun">;
819
820// 3.49.9. Function Instructions
821
822//  - SPV_INTEL_function_pointers
823def OpFunctionPointerCallINTEL: Op<5601, (outs ID:$res), (ins TYPE:$ty, ID:$funPtr, variable_ops), "$res = OpFunctionPointerCallINTEL $ty $funPtr">;
824
825// 3.49.21. Group and Subgroup Instructions
826
827// - SPV_INTEL_subgroups
828def OpSubgroupShuffleINTEL: Op<5571, (outs ID:$res), (ins TYPE:$type, ID:$data, ID:$invocationId),
829                  "$res = OpSubgroupShuffleINTEL $type $data $invocationId">;
830def OpSubgroupShuffleDownINTEL: Op<5572, (outs ID:$res), (ins TYPE:$type, ID:$current, ID:$next, ID:$delta),
831                  "$res = OpSubgroupShuffleDownINTEL $type $current $next $delta">;
832def OpSubgroupShuffleUpINTEL: Op<5573, (outs ID:$res), (ins TYPE:$type, ID:$previous, ID:$current, ID:$delta),
833                  "$res = OpSubgroupShuffleUpINTEL $type $previous $current $delta">;
834def OpSubgroupShuffleXorINTEL: Op<5574, (outs ID:$res), (ins TYPE:$type, ID:$data, ID:$value),
835                  "$res = OpSubgroupShuffleXorINTEL $type $data $value">;
836def OpSubgroupBlockReadINTEL: Op<5575, (outs ID:$res), (ins TYPE:$type, ID:$ptr),
837                  "$res = OpSubgroupBlockReadINTEL $type $ptr">;
838def OpSubgroupBlockWriteINTEL: Op<5576, (outs), (ins ID:$ptr, ID:$data),
839                  "OpSubgroupBlockWriteINTEL $ptr $data">;
840def OpSubgroupImageBlockReadINTEL: Op<5577, (outs ID:$res), (ins TYPE:$type, ID:$image, ID:$coordinate),
841                  "$res = OpSubgroupImageBlockReadINTEL $type $image $coordinate">;
842def OpSubgroupImageBlockWriteINTEL: Op<5578, (outs), (ins ID:$image, ID:$coordinate, ID:$data),
843                  "OpSubgroupImageBlockWriteINTEL $image $coordinate $data">;
844
845// - SPV_KHR_uniform_group_instructions
846def OpGroupIMulKHR: Op<6401, (outs ID:$res), (ins TYPE:$type, ID:$scope, i32imm:$groupOp, ID:$value),
847                  "$res = OpGroupIMulKHR $type $scope $groupOp $value">;
848def OpGroupFMulKHR: Op<6402, (outs ID:$res), (ins TYPE:$type, ID:$scope, i32imm:$groupOp, ID:$value),
849                  "$res = OpGroupFMulKHR $type $scope $groupOp $value">;
850def OpGroupBitwiseAndKHR: Op<6403, (outs ID:$res), (ins TYPE:$type, ID:$scope, i32imm:$groupOp, ID:$value),
851                  "$res = OpGroupBitwiseAndKHR $type $scope $groupOp $value">;
852def OpGroupBitwiseOrKHR: Op<6404, (outs ID:$res), (ins TYPE:$type, ID:$scope, i32imm:$groupOp, ID:$value),
853                  "$res = OpGroupBitwiseOrKHR $type $scope $groupOp $value">;
854def OpGroupBitwiseXorKHR: Op<6405, (outs ID:$res), (ins TYPE:$type, ID:$scope, i32imm:$groupOp, ID:$value),
855                  "$res = OpGroupBitwiseXorKHR $type $scope $groupOp $value">;
856def OpGroupLogicalAndKHR: Op<6406, (outs ID:$res), (ins TYPE:$type, ID:$scope, i32imm:$groupOp, ID:$value),
857                  "$res = OpGroupLogicalAndKHR $type $scope $groupOp $value">;
858def OpGroupLogicalOrKHR: Op<6407, (outs ID:$res), (ins TYPE:$type, ID:$scope, i32imm:$groupOp, ID:$value),
859                  "$res = OpGroupLogicalOrKHR $type $scope $groupOp $value">;
860def OpGroupLogicalXorKHR: Op<6408, (outs ID:$res), (ins TYPE:$type, ID:$scope, i32imm:$groupOp, ID:$value),
861                  "$res = OpGroupLogicalXorKHR $type $scope $groupOp $value">;
862
863// Inline Assembly Instructions
864def OpAsmTargetINTEL: Op<5609, (outs ID:$res), (ins StringImm:$str), "$res = OpAsmTargetINTEL $str">;
865def OpAsmINTEL: Op<5610, (outs ID:$res), (ins TYPE:$type, TYPE:$asm_type, ID:$target,
866                                          StringImm:$asm, StringImm:$constraints),
867                  "$res = OpAsmINTEL $type $asm_type $target $asm">;
868def OpAsmCallINTEL: Op<5611, (outs ID:$res), (ins TYPE:$type, ID:$asm, variable_ops),
869                  "$res = OpAsmCallINTEL $type $asm">;
870
871// SPV_KHR_cooperative_matrix
872def OpCooperativeMatrixLoadKHR: Op<4457, (outs ID:$res),
873                  (ins TYPE:$resType, ID:$pointer, ID:$memory_layout, variable_ops),
874                  "$res = OpCooperativeMatrixLoadKHR $resType $pointer $memory_layout">;
875def OpCooperativeMatrixStoreKHR: Op<4458, (outs),
876                  (ins ID:$pointer, ID:$objectToStore, ID:$memory_layout, variable_ops),
877                  "OpCooperativeMatrixStoreKHR $pointer $objectToStore $memory_layout">;
878def OpCooperativeMatrixMulAddKHR: Op<4459, (outs ID:$res),
879                  (ins TYPE:$type, ID:$A, ID:$B, ID:$C, variable_ops),
880                  "$res = OpCooperativeMatrixMulAddKHR $type $A $B $C">;
881def OpCooperativeMatrixLengthKHR: Op<4460, (outs ID:$res), (ins TYPE:$type, ID:$coop_matr_type),
882                  "$res = OpCooperativeMatrixLengthKHR $type $coop_matr_type">;
883