// numLogicalOperands - does not include result id or type id
// numCapabilities - we only handle 0 or 1 required capabilities
// Capability(<capability-name>) - capability required to use this instruction. Might be None.
+// There can be Capability2(a,b) for dependence on two capabilities.
// {0|1} - whether the instruction is variable number of words
// EmptyList or List(...) - list of classes of logical operands
// Example use:
// #define EmptyList {}
// #define List(...) {__VA_ARGS__}
// #define Capability(C) Capability##C
-// #define NoCapability
+// #define CapabilityNone -1
// #define Instruction(Name,HasResult,HasType,NumLogicalOperands,CapabiltyRequired,IsVariable,LogicalArgsList)
Instruction(Nop, 0, 0, 0, 0, Capability(None), 0, EmptyList)
Instruction(Undef, 1, 1, 0, 0, Capability(None), 0, EmptyList)
Instruction(Name, 0, 0, 2, 0, Capability(None), 1, List(OperandId, OperandLiteralString))
Instruction(MemberName, 0, 0, 3, 0, Capability(None), 1, List(OperandId, OperandLiteralNumber, OperandLiteralString))
Instruction(String, 1, 0, 1, 0, Capability(None), 1, List(OperandLiteralString))
-// Rev32+ has: Instruction(Line, 0, 0, 3, 0, Capability(None), 0, List(OperandId, OperandLiteralNumber, OperandLiteralNumber))
-// TODO(dneto): Remove the following hack for OpLine. It was put in to match Rev31.
-Instruction(Line, 0, 0, 3, 0, Capability(None), 0, List(OperandId, OperandId, OperandLiteralNumber, OperandLiteralNumber))
+Instruction(Line, 0, 0, 3, 0, Capability(None), 0, List(OperandId, OperandLiteralNumber, OperandLiteralNumber))
Instruction(Extension, 0, 0, 1, 0, Capability(None), 1, List(OperandLiteralString))
Instruction(ExtInstImport, 1, 0, 1, 0, Capability(None), 1, List(OperandLiteralString))
Instruction(ExtInst, 1, 1, 3, 0, Capability(None), 1, List(OperandId, OperandLiteralNumber, OperandVariableIds))
Instruction(MemoryModel, 0, 0, 2, 0, Capability(None), 0, List(OperandAddressing, OperandMemory))
-Instruction(EntryPoint, 0, 0, 3, 0, Capability(None), 1, List(OperandExecutionModel, OperandId, OperandLiteralString))
+Instruction(EntryPoint, 0, 0, 4, 0, Capability(None), 1, List(OperandExecutionModel, OperandId, OperandLiteralString, OperandVariableIds))
Instruction(ExecutionMode, 0, 0, 3, 0, Capability(None), 1, List(OperandId, OperandExecutionMode, OperandOptionalLiteral))
Instruction(Capability, 0, 0, 1, 0, Capability(None), 0, List(OperandCapability))
Instruction(TypeVoid, 1, 0, 0, 0, Capability(None), 0, EmptyList)
Instruction(TypeDeviceEvent, 1, 0, 0, 1, Capability(DeviceEnqueue), 0, EmptyList)
Instruction(TypeReserveId, 1, 0, 0, 1, Capability(Pipes), 0, EmptyList)
Instruction(TypeQueue, 1, 0, 0, 1, Capability(DeviceEnqueue), 0, EmptyList)
-Instruction(TypePipe, 1, 0, 2, 1, Capability(Pipes), 0, List(OperandId, OperandAccessQualifier))
+Instruction(TypePipe, 1, 0, 1, 1, Capability(Pipes), 0, List(OperandAccessQualifier))
Instruction(TypeForwardPointer, 0, 0, 2, 1, Capability(Addresses), 0, List(OperandId, OperandStorage))
Instruction(ConstantTrue, 1, 1, 0, 0, Capability(None), 0, EmptyList)
Instruction(ConstantFalse, 1, 1, 0, 0, Capability(None), 0, EmptyList)
Instruction(ImageWrite, 0, 0, 4, 0, Capability(None), 1, List(OperandId, OperandId, OperandId, OperandOptionalImage))
Instruction(ImageQueryFormat, 1, 1, 1, 1, Capability(Kernel), 0, List(OperandId))
Instruction(ImageQueryOrder, 1, 1, 1, 1, Capability(Kernel), 0, List(OperandId))
-Instruction(ImageQuerySizeLod, 1, 1, 2, 0, Capability(None), 0, List(OperandId, OperandId))
-Instruction(ImageQuerySize, 1, 1, 1, 0, Capability(None), 0, List(OperandId))
-Instruction(ImageQueryLod, 1, 1, 2, 1, Capability(Shader), 0, List(OperandId, OperandId))
-Instruction(ImageQueryLevels, 1, 1, 1, 0, Capability(None), 0, List(OperandId))
-Instruction(ImageQuerySamples, 1, 1, 1, 0, Capability(None), 0, List(OperandId))
+Instruction(ImageQuerySizeLod, 1, 1, 2, 2, Capability2(Kernel,ImageQuery), 0, List(OperandId, OperandId))
+Instruction(ImageQuerySize, 1, 1, 1, 2, Capability2(Kernel,ImageQuery), 0, List(OperandId))
+Instruction(ImageQueryLod, 1, 1, 2, 1, Capability(ImageQuery), 0, List(OperandId, OperandId))
+Instruction(ImageQueryLevels, 1, 1, 1, 2, Capability2(Kernel,ImageQuery), 0, List(OperandId))
+Instruction(ImageQuerySamples, 1, 1, 1, 2, Capability2(Kernel,ImageQuery), 0, List(OperandId))
Instruction(ConvertFToU, 1, 1, 1, 0, Capability(None), 0, List(OperandId))
Instruction(ConvertFToS, 1, 1, 1, 0, Capability(None), 0, List(OperandId))
Instruction(ConvertSToF, 1, 1, 1, 0, Capability(None), 0, List(OperandId))
Instruction(DPdx, 1, 1, 1, 1, Capability(Shader), 0, List(OperandId))
Instruction(DPdy, 1, 1, 1, 1, Capability(Shader), 0, List(OperandId))
Instruction(Fwidth, 1, 1, 1, 1, Capability(Shader), 0, List(OperandId))
-Instruction(DPdxFine, 1, 1, 1, 1, Capability(Shader), 0, List(OperandId))
-Instruction(DPdyFine, 1, 1, 1, 1, Capability(Shader), 0, List(OperandId))
-Instruction(FwidthFine, 1, 1, 1, 1, Capability(Shader), 0, List(OperandId))
-Instruction(DPdxCoarse, 1, 1, 1, 1, Capability(Shader), 0, List(OperandId))
-Instruction(DPdyCoarse, 1, 1, 1, 1, Capability(Shader), 0, List(OperandId))
-Instruction(FwidthCoarse, 1, 1, 1, 1, Capability(Shader), 0, List(OperandId))
+Instruction(DPdxFine, 1, 1, 1, 1, Capability(DerivativeControl), 0, List(OperandId))
+Instruction(DPdyFine, 1, 1, 1, 1, Capability(DerivativeControl), 0, List(OperandId))
+Instruction(FwidthFine, 1, 1, 1, 1, Capability(DerivativeControl), 0, List(OperandId))
+Instruction(DPdxCoarse, 1, 1, 1, 1, Capability(DerivativeControl), 0, List(OperandId))
+Instruction(DPdyCoarse, 1, 1, 1, 1, Capability(DerivativeControl), 0, List(OperandId))
+Instruction(FwidthCoarse, 1, 1, 1, 1, Capability(DerivativeControl), 0, List(OperandId))
Instruction(EmitVertex, 0, 0, 0, 1, Capability(Geometry), 0, EmptyList)
Instruction(EndPrimitive, 0, 0, 0, 1, Capability(Geometry), 0, EmptyList)
Instruction(EmitStreamVertex, 0, 0, 1, 1, Capability(Geometry), 0, List(OperandId))
Instruction(AtomicOr, 1, 1, 4, 0, Capability(None), 0, List(OperandId, OperandScope, OperandMemorySemantics, OperandId))
Instruction(AtomicXor, 1, 1, 4, 0, Capability(None), 0, List(OperandId, OperandScope, OperandMemorySemantics, OperandId))
Instruction(Phi, 1, 1, 1, 0, Capability(None), 1, List(OperandVariableIds))
-Instruction(LoopMerge, 0, 0, 2, 0, Capability(None), 0, List(OperandId, OperandLoop))
+Instruction(LoopMerge, 0, 0, 3, 0, Capability(None), 0, List(OperandId, OperandId, OperandLoop))
Instruction(SelectionMerge, 0, 0, 2, 0, Capability(None), 0, List(OperandId, OperandSelect))
Instruction(Label, 1, 0, 0, 0, Capability(None), 0, EmptyList)
Instruction(Branch, 0, 0, 1, 0, Capability(None), 0, List(OperandId))
Instruction(Return, 0, 0, 0, 0, Capability(None), 0, EmptyList)
Instruction(ReturnValue, 0, 0, 1, 0, Capability(None), 0, List(OperandId))
Instruction(Unreachable, 0, 0, 0, 0, Capability(None), 0, EmptyList)
-Instruction(LifetimeStart, 0, 0, 2, 0, Capability(None), 0, List(OperandId, OperandLiteralNumber))
-Instruction(LifetimeStop, 0, 0, 2, 0, Capability(None), 0, List(OperandId, OperandLiteralNumber))
+Instruction(LifetimeStart, 0, 0, 2, 1, Capability(Kernel), 0, List(OperandId, OperandLiteralNumber))
+Instruction(LifetimeStop, 0, 0, 2, 1, Capability(Kernel), 0, List(OperandId, OperandLiteralNumber))
Instruction(AsyncGroupCopy, 1, 1, 6, 1, Capability(Kernel), 0, List(OperandScope, OperandId, OperandId, OperandId, OperandId, OperandId))
Instruction(WaitGroupEvents, 0, 0, 3, 1, Capability(Kernel), 0, List(OperandScope, OperandId, OperandId))
Instruction(GroupAll, 1, 1, 2, 1, Capability(Groups), 0, List(OperandScope, OperandId))
Instruction(GroupFMax, 1, 1, 3, 1, Capability(Groups), 0, List(OperandScope, OperandGroupOperation, OperandId))
Instruction(GroupUMax, 1, 1, 3, 1, Capability(Groups), 0, List(OperandScope, OperandGroupOperation, OperandId))
Instruction(GroupSMax, 1, 1, 3, 1, Capability(Groups), 0, List(OperandScope, OperandGroupOperation, OperandId))
-Instruction(ReadPipe, 1, 1, 2, 1, Capability(Pipes), 0, List(OperandId, OperandId))
-Instruction(WritePipe, 1, 1, 2, 1, Capability(Pipes), 0, List(OperandId, OperandId))
-Instruction(ReservedReadPipe, 1, 1, 4, 1, Capability(Pipes), 0, List(OperandId, OperandId, OperandId, OperandId))
-Instruction(ReservedWritePipe, 1, 1, 4, 1, Capability(Pipes), 0, List(OperandId, OperandId, OperandId, OperandId))
-Instruction(ReserveReadPipePackets, 1, 1, 2, 1, Capability(Pipes), 0, List(OperandId, OperandId))
-Instruction(ReserveWritePipePackets, 1, 1, 2, 1, Capability(Pipes), 0, List(OperandId, OperandId))
-Instruction(CommitReadPipe, 0, 0, 2, 1, Capability(Pipes), 0, List(OperandId, OperandId))
-Instruction(CommitWritePipe, 0, 0, 2, 1, Capability(Pipes), 0, List(OperandId, OperandId))
+Instruction(ReadPipe, 1, 1, 4, 1, Capability(Pipes), 0, List(OperandId, OperandId, OperandId, OperandId))
+Instruction(WritePipe, 1, 1, 4, 1, Capability(Pipes), 0, List(OperandId, OperandId, OperandId, OperandId))
+Instruction(ReservedReadPipe, 1, 1, 6, 1, Capability(Pipes), 0, List(OperandId, OperandId, OperandId, OperandId, OperandId, OperandId))
+Instruction(ReservedWritePipe, 1, 1, 6, 1, Capability(Pipes), 0, List(OperandId, OperandId, OperandId, OperandId, OperandId, OperandId))
+Instruction(ReserveReadPipePackets, 1, 1, 4, 1, Capability(Pipes), 0, List(OperandId, OperandId, OperandId, OperandId))
+Instruction(ReserveWritePipePackets, 1, 1, 4, 1, Capability(Pipes), 0, List(OperandId, OperandId, OperandId, OperandId))
+Instruction(CommitReadPipe, 0, 0, 4, 1, Capability(Pipes), 0, List(OperandId, OperandId, OperandId, OperandId))
+Instruction(CommitWritePipe, 0, 0, 4, 1, Capability(Pipes), 0, List(OperandId, OperandId, OperandId, OperandId))
Instruction(IsValidReserveId, 1, 1, 1, 1, Capability(Pipes), 0, List(OperandId))
-Instruction(GetNumPipePackets, 1, 1, 1, 1, Capability(Pipes), 0, List(OperandId))
-Instruction(GetMaxPipePackets, 1, 1, 1, 1, Capability(Pipes), 0, List(OperandId))
-Instruction(GroupReserveReadPipePackets, 1, 1, 3, 1, Capability(Pipes), 0, List(OperandScope, OperandId, OperandId))
-Instruction(GroupReserveWritePipePackets, 1, 1, 3, 1, Capability(Pipes), 0, List(OperandScope, OperandId, OperandId))
-Instruction(GroupCommitReadPipe, 0, 0, 3, 1, Capability(Pipes), 0, List(OperandScope, OperandId, OperandId))
-Instruction(GroupCommitWritePipe, 0, 0, 3, 1, Capability(Pipes), 0, List(OperandScope, OperandId, OperandId))
+Instruction(GetNumPipePackets, 1, 1, 3, 1, Capability(Pipes), 0, List(OperandId, OperandId, OperandId))
+Instruction(GetMaxPipePackets, 1, 1, 3, 1, Capability(Pipes), 0, List(OperandId, OperandId, OperandId))
+Instruction(GroupReserveReadPipePackets, 1, 1, 5, 1, Capability(Pipes), 0, List(OperandScope, OperandId, OperandId, OperandId, OperandId))
+Instruction(GroupReserveWritePipePackets, 1, 1, 5, 1, Capability(Pipes), 0, List(OperandScope, OperandId, OperandId, OperandId, OperandId))
+Instruction(GroupCommitReadPipe, 0, 0, 5, 1, Capability(Pipes), 0, List(OperandScope, OperandId, OperandId, OperandId, OperandId))
+Instruction(GroupCommitWritePipe, 0, 0, 5, 1, Capability(Pipes), 0, List(OperandScope, OperandId, OperandId, OperandId, OperandId))
Instruction(EnqueueMarker, 1, 1, 4, 1, Capability(DeviceEnqueue), 0, List(OperandId, OperandId, OperandId, OperandId))
Instruction(EnqueueKernel, 1, 1, 11, 1, Capability(DeviceEnqueue), 1, List(OperandId, OperandId, OperandId, OperandId, OperandId, OperandId, OperandId, OperandId, OperandId, OperandId, OperandVariableIds))
Instruction(GetKernelNDrangeSubGroupCount, 1, 1, 5, 1, Capability(DeviceEnqueue), 0, List(OperandId, OperandId, OperandId, OperandId, OperandId))
Instruction(CaptureEventProfilingInfo, 0, 0, 3, 1, Capability(DeviceEnqueue), 0, List(OperandId, OperandId, OperandId))
Instruction(GetDefaultQueue, 1, 1, 0, 1, Capability(DeviceEnqueue), 0, EmptyList)
Instruction(BuildNDRange, 1, 1, 3, 1, Capability(DeviceEnqueue), 0, List(OperandId, OperandId, OperandId))
+Instruction(ImageSparseSampleImplicitLod, 1, 1, 3, 1, Capability(SparseResidency), 1, List(OperandId, OperandId, OperandOptionalImage))
+Instruction(ImageSparseSampleExplicitLod, 1, 1, 3, 1, Capability(SparseResidency), 1, List(OperandId, OperandId, OperandOptionalImage))
+Instruction(ImageSparseSampleDrefImplicitLod, 1, 1, 4, 1, Capability(SparseResidency), 1, List(OperandId, OperandId, OperandId, OperandOptionalImage))
+Instruction(ImageSparseSampleDrefExplicitLod, 1, 1, 4, 1, Capability(SparseResidency), 1, List(OperandId, OperandId, OperandId, OperandOptionalImage))
+Instruction(ImageSparseSampleProjImplicitLod, 1, 1, 3, 1, Capability(SparseResidency), 1, List(OperandId, OperandId, OperandOptionalImage))
+Instruction(ImageSparseSampleProjExplicitLod, 1, 1, 3, 1, Capability(SparseResidency), 1, List(OperandId, OperandId, OperandOptionalImage))
+Instruction(ImageSparseSampleProjDrefImplicitLod, 1, 1, 4, 1, Capability(SparseResidency), 1, List(OperandId, OperandId, OperandId, OperandOptionalImage))
+Instruction(ImageSparseSampleProjDrefExplicitLod, 1, 1, 4, 1, Capability(SparseResidency), 1, List(OperandId, OperandId, OperandId, OperandOptionalImage))
+Instruction(ImageSparseFetch, 1, 1, 3, 1, Capability(SparseResidency), 1, List(OperandId, OperandId, OperandOptionalImage))
+Instruction(ImageSparseGather, 1, 1, 4, 1, Capability(SparseResidency), 1, List(OperandId, OperandId, OperandId, OperandOptionalImage))
+Instruction(ImageSparseDrefGather, 1, 1, 4, 1, Capability(SparseResidency), 1, List(OperandId, OperandId, OperandId, OperandOptionalImage))
+Instruction(ImageSparseTexelsResident, 1, 1, 1, 1, Capability(SparseResidency), 0, List(OperandId))
+Instruction(NoLine, 0, 0, 0, 0, Capability(None), 0, EmptyList)
+Instruction(AtomicFlagTestAndSet, 1, 1, 3, 1, Capability(Kernel), 0, List(OperandId, OperandScope, OperandMemorySemantics))
+Instruction(AtomicFlagClear, 0, 0, 3, 1, Capability(Kernel), 0, List(OperandId, OperandScope, OperandMemorySemantics))