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