mirror of
https://github.com/odin-lang/Odin.git
synced 2026-07-17 21:21:04 +00:00
rexcode/ir/spirv: scaffold the SPIR-V IR package (foundation + generated tables)
Start the SPIR-V intermediate representation under core/rexcode/ir/spirv,
following the ir API (docs/ir_design.md) and the ISA package conventions. SPIR-V
is table-driven on encoding and SSA on dataflow, so it re-exports the shared ir
vocabulary and is laid out like an arch package.
spirv.odin package + ir re-exports + physical format (MAGIC, version,
Header, wordCount<<16|opcode framing)
module.odin Module :: struct { using base: ir.Module, ...sections... } --
capabilities, ext-imports, entry points, exec modes, constant
pool, decorations, debug; SPIR-V's module metadata has no
ir.Module slot, so it is carried alongside the core
reloc.odin Relocation (linkage import/export)
opcodes.odin GENERATED: the Opcode enum (873 opcodes)
operand_kinds.odin GENERATED: ValueEnum/BitEnum operand kinds + Spec_Kind
tablegen/gen.odin the generator (core:encoding/json)
tablegen/spirv.core.grammar.json vendored authoritative grammar (Khronos
SPIRV-Headers unified1) -- single source of truth
Generating from the authoritative grammar avoids hand-transcription errors
(hand-authoring had Quads/Aliased/... wrong). Package compiles. Codec
(encode/decode + flat<->structured lowering), printer, and tests are next.
This commit is contained in:
127
core/rexcode/ir/spirv/module.odin
Normal file
127
core/rexcode/ir/spirv/module.odin
Normal file
@@ -0,0 +1,127 @@
|
||||
// rexcode · Brendan Punsky (dotbmp@github), original author
|
||||
|
||||
package rexcode_spirv
|
||||
|
||||
import "core:rexcode/ir"
|
||||
|
||||
// =============================================================================
|
||||
// SECTION: Module (the SPIR-V module -- ir core + SPIR-V's own sections)
|
||||
// =============================================================================
|
||||
//
|
||||
// `spirv.Module` is the `ir.Module` SSA core (types / globals / functions /
|
||||
// symbols, dataflow = .SSA) plus the SPIR-V module-level sections the shared core
|
||||
// has no slot for. A concrete IR carries those "alongside the core" per
|
||||
// docs/ir_design.md §3; here that is literal -- `using base: ir.Module` embeds
|
||||
// the core so `m.types`, `m.functions`, ... read straight through.
|
||||
//
|
||||
// SPIR-V is a *flat* stream of OpXxx, each defining an <id>. `decode` lowers it
|
||||
// into this structure -- OpTypeXxx -> base.types, OpVariable(global) ->
|
||||
// base.globals, OpFunction -> base.functions, OpConstant* -> the constant pool,
|
||||
// and the preamble / debug / annotations -> the sections below -- and `encode`
|
||||
// flattens it back in the spec's required section order.
|
||||
Module :: struct {
|
||||
using base: ir.Module, // types, globals, functions, symbols, dataflow, target
|
||||
|
||||
// --- Header ---
|
||||
version: u32, // see version(); a default is supplied on encode if 0
|
||||
generator: u32, // GENERATOR if 0
|
||||
bound: u32, // exclusive upper bound on every <id>; recomputed on encode
|
||||
|
||||
// --- Preamble (in spec section order) ---
|
||||
capabilities: []Capability,
|
||||
extensions: []string,
|
||||
ext_imports: []Ext_Import,
|
||||
addressing: Addressing_Model,
|
||||
memory: Memory_Model,
|
||||
entry_points: []Entry_Point,
|
||||
exec_modes: []Exec_Mode,
|
||||
|
||||
// --- Constant pool ---
|
||||
// SPIR-V constants are module-level value definitions, each a result <id>
|
||||
// referenced like any other value (an op_value / .CONSTANT ref).
|
||||
constants: []Constant,
|
||||
|
||||
// --- Debug + annotations ---
|
||||
debug: Debug,
|
||||
decorations: []Decoration_Inst,
|
||||
}
|
||||
|
||||
// Member index sentinel: a whole-target decoration / name (OpDecorate / OpName)
|
||||
// rather than a struct member one (OpMemberDecorate / OpMemberName).
|
||||
MEMBER_NONE :: u32(0xFFFF_FFFF)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Section element types
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// OpExtInstImport: an extended instruction set, e.g. "GLSL.std.450".
|
||||
Ext_Import :: struct {
|
||||
result: Id,
|
||||
name: string,
|
||||
}
|
||||
|
||||
// OpEntryPoint: an execution entry into the module.
|
||||
Entry_Point :: struct {
|
||||
model: Execution_Model,
|
||||
function: Id,
|
||||
name: string,
|
||||
interface: []Id, // the OpVariable <id>s forming the entry's interface
|
||||
}
|
||||
|
||||
// OpExecutionMode / OpExecutionModeId: a mode set on an entry point.
|
||||
Exec_Mode :: struct {
|
||||
entry: Id,
|
||||
mode: Execution_Mode,
|
||||
operands: []u32, // literal operands (e.g. LocalSize x, y, z)
|
||||
is_id: bool, // OpExecutionModeId: `operands` are <id>s, not literals
|
||||
}
|
||||
|
||||
// A module-level constant: OpConstant / OpConstant{True,False,Null} / OpConstantComposite.
|
||||
Constant :: struct {
|
||||
result: Result, // <id> + type
|
||||
opcode: Opcode, // which OpConstant* form produced it
|
||||
value: u64, // scalar bit pattern (OpConstant); width comes from the type
|
||||
elements: []Id, // OpConstantComposite member <id>s
|
||||
}
|
||||
|
||||
// OpDecorate / OpMemberDecorate: an annotation on an <id> (or one of its members).
|
||||
Decoration_Inst :: struct {
|
||||
target: Id,
|
||||
decoration: Decoration,
|
||||
member: u32, // OpMemberDecorate member index; MEMBER_NONE for OpDecorate
|
||||
operands: []u32, // decoration literal operands (Location = N, Binding = N, ...)
|
||||
}
|
||||
|
||||
// The debug section.
|
||||
Debug :: struct {
|
||||
source_language: u32,
|
||||
source_version: u32,
|
||||
source_file: Id, // an OpString <id>, or ID_NONE
|
||||
names: []Name, // OpName / OpMemberName
|
||||
strings: []Str, // OpString
|
||||
}
|
||||
|
||||
// OpName / OpMemberName.
|
||||
Name :: struct {
|
||||
target: Id,
|
||||
member: u32, // OpMemberName member index; MEMBER_NONE for OpName
|
||||
text: string,
|
||||
}
|
||||
|
||||
// OpString.
|
||||
Str :: struct {
|
||||
result: Id,
|
||||
text: string,
|
||||
}
|
||||
|
||||
// SPIR-V is always SSA; a freshly-made module declares it so the shared verbs
|
||||
// and printer pick the SSA path.
|
||||
@(require_results)
|
||||
make_module :: proc "contextless" () -> Module {
|
||||
m: Module
|
||||
m.base.dataflow = .SSA
|
||||
m.version = VERSION_1_5
|
||||
m.addressing = .Logical
|
||||
m.memory = .GLSL450
|
||||
return m
|
||||
}
|
||||
884
core/rexcode/ir/spirv/opcodes.odin
Normal file
884
core/rexcode/ir/spirv/opcodes.odin
Normal file
@@ -0,0 +1,884 @@
|
||||
// rexcode · Brendan Punsky (dotbmp@github), original author
|
||||
|
||||
package rexcode_spirv
|
||||
|
||||
// GENERATED from spirv.core.grammar.json (SPIRV-Headers unified1) by tablegen/gen.odin.
|
||||
// DO NOT EDIT -- regenerate with `odin run core/rexcode/ir/spirv/tablegen`.
|
||||
|
||||
// SPIR-V operation opcodes. The values ARE the wire opcodes; the codec writes
|
||||
// them directly. OpNop = 0 doubles as the zero value (a benign no-op).
|
||||
Opcode :: enum u16 {
|
||||
OpNop = 0,
|
||||
OpUndef = 1,
|
||||
OpSourceContinued = 2,
|
||||
OpSource = 3,
|
||||
OpSourceExtension = 4,
|
||||
OpName = 5,
|
||||
OpMemberName = 6,
|
||||
OpString = 7,
|
||||
OpLine = 8,
|
||||
OpExtension = 10,
|
||||
OpExtInstImport = 11,
|
||||
OpExtInst = 12,
|
||||
OpMemoryModel = 14,
|
||||
OpEntryPoint = 15,
|
||||
OpExecutionMode = 16,
|
||||
OpCapability = 17,
|
||||
OpTypeVoid = 19,
|
||||
OpTypeBool = 20,
|
||||
OpTypeInt = 21,
|
||||
OpTypeFloat = 22,
|
||||
OpTypeVector = 23,
|
||||
OpTypeMatrix = 24,
|
||||
OpTypeImage = 25,
|
||||
OpTypeSampler = 26,
|
||||
OpTypeSampledImage = 27,
|
||||
OpTypeArray = 28,
|
||||
OpTypeRuntimeArray = 29,
|
||||
OpTypeStruct = 30,
|
||||
OpTypeOpaque = 31,
|
||||
OpTypePointer = 32,
|
||||
OpTypeFunction = 33,
|
||||
OpTypeEvent = 34,
|
||||
OpTypeDeviceEvent = 35,
|
||||
OpTypeReserveId = 36,
|
||||
OpTypeQueue = 37,
|
||||
OpTypePipe = 38,
|
||||
OpTypeForwardPointer = 39,
|
||||
OpConstantTrue = 41,
|
||||
OpConstantFalse = 42,
|
||||
OpConstant = 43,
|
||||
OpConstantComposite = 44,
|
||||
OpConstantSampler = 45,
|
||||
OpConstantNull = 46,
|
||||
OpSpecConstantTrue = 48,
|
||||
OpSpecConstantFalse = 49,
|
||||
OpSpecConstant = 50,
|
||||
OpSpecConstantComposite = 51,
|
||||
OpSpecConstantOp = 52,
|
||||
OpFunction = 54,
|
||||
OpFunctionParameter = 55,
|
||||
OpFunctionEnd = 56,
|
||||
OpFunctionCall = 57,
|
||||
OpVariable = 59,
|
||||
OpImageTexelPointer = 60,
|
||||
OpLoad = 61,
|
||||
OpStore = 62,
|
||||
OpCopyMemory = 63,
|
||||
OpCopyMemorySized = 64,
|
||||
OpAccessChain = 65,
|
||||
OpInBoundsAccessChain = 66,
|
||||
OpPtrAccessChain = 67,
|
||||
OpArrayLength = 68,
|
||||
OpGenericPtrMemSemantics = 69,
|
||||
OpInBoundsPtrAccessChain = 70,
|
||||
OpDecorate = 71,
|
||||
OpMemberDecorate = 72,
|
||||
OpDecorationGroup = 73,
|
||||
OpGroupDecorate = 74,
|
||||
OpGroupMemberDecorate = 75,
|
||||
OpVectorExtractDynamic = 77,
|
||||
OpVectorInsertDynamic = 78,
|
||||
OpVectorShuffle = 79,
|
||||
OpCompositeConstruct = 80,
|
||||
OpCompositeExtract = 81,
|
||||
OpCompositeInsert = 82,
|
||||
OpCopyObject = 83,
|
||||
OpTranspose = 84,
|
||||
OpSampledImage = 86,
|
||||
OpImageSampleImplicitLod = 87,
|
||||
OpImageSampleExplicitLod = 88,
|
||||
OpImageSampleDrefImplicitLod = 89,
|
||||
OpImageSampleDrefExplicitLod = 90,
|
||||
OpImageSampleProjImplicitLod = 91,
|
||||
OpImageSampleProjExplicitLod = 92,
|
||||
OpImageSampleProjDrefImplicitLod = 93,
|
||||
OpImageSampleProjDrefExplicitLod = 94,
|
||||
OpImageFetch = 95,
|
||||
OpImageGather = 96,
|
||||
OpImageDrefGather = 97,
|
||||
OpImageRead = 98,
|
||||
OpImageWrite = 99,
|
||||
OpImage = 100,
|
||||
OpImageQueryFormat = 101,
|
||||
OpImageQueryOrder = 102,
|
||||
OpImageQuerySizeLod = 103,
|
||||
OpImageQuerySize = 104,
|
||||
OpImageQueryLod = 105,
|
||||
OpImageQueryLevels = 106,
|
||||
OpImageQuerySamples = 107,
|
||||
OpConvertFToU = 109,
|
||||
OpConvertFToS = 110,
|
||||
OpConvertSToF = 111,
|
||||
OpConvertUToF = 112,
|
||||
OpUConvert = 113,
|
||||
OpSConvert = 114,
|
||||
OpFConvert = 115,
|
||||
OpQuantizeToF16 = 116,
|
||||
OpConvertPtrToU = 117,
|
||||
OpSatConvertSToU = 118,
|
||||
OpSatConvertUToS = 119,
|
||||
OpConvertUToPtr = 120,
|
||||
OpPtrCastToGeneric = 121,
|
||||
OpGenericCastToPtr = 122,
|
||||
OpGenericCastToPtrExplicit = 123,
|
||||
OpBitcast = 124,
|
||||
OpSNegate = 126,
|
||||
OpFNegate = 127,
|
||||
OpIAdd = 128,
|
||||
OpFAdd = 129,
|
||||
OpISub = 130,
|
||||
OpFSub = 131,
|
||||
OpIMul = 132,
|
||||
OpFMul = 133,
|
||||
OpUDiv = 134,
|
||||
OpSDiv = 135,
|
||||
OpFDiv = 136,
|
||||
OpUMod = 137,
|
||||
OpSRem = 138,
|
||||
OpSMod = 139,
|
||||
OpFRem = 140,
|
||||
OpFMod = 141,
|
||||
OpVectorTimesScalar = 142,
|
||||
OpMatrixTimesScalar = 143,
|
||||
OpVectorTimesMatrix = 144,
|
||||
OpMatrixTimesVector = 145,
|
||||
OpMatrixTimesMatrix = 146,
|
||||
OpOuterProduct = 147,
|
||||
OpDot = 148,
|
||||
OpIAddCarry = 149,
|
||||
OpISubBorrow = 150,
|
||||
OpUMulExtended = 151,
|
||||
OpSMulExtended = 152,
|
||||
OpAny = 154,
|
||||
OpAll = 155,
|
||||
OpIsNan = 156,
|
||||
OpIsInf = 157,
|
||||
OpIsFinite = 158,
|
||||
OpIsNormal = 159,
|
||||
OpSignBitSet = 160,
|
||||
OpLessOrGreater = 161,
|
||||
OpOrdered = 162,
|
||||
OpUnordered = 163,
|
||||
OpLogicalEqual = 164,
|
||||
OpLogicalNotEqual = 165,
|
||||
OpLogicalOr = 166,
|
||||
OpLogicalAnd = 167,
|
||||
OpLogicalNot = 168,
|
||||
OpSelect = 169,
|
||||
OpIEqual = 170,
|
||||
OpINotEqual = 171,
|
||||
OpUGreaterThan = 172,
|
||||
OpSGreaterThan = 173,
|
||||
OpUGreaterThanEqual = 174,
|
||||
OpSGreaterThanEqual = 175,
|
||||
OpULessThan = 176,
|
||||
OpSLessThan = 177,
|
||||
OpULessThanEqual = 178,
|
||||
OpSLessThanEqual = 179,
|
||||
OpFOrdEqual = 180,
|
||||
OpFUnordEqual = 181,
|
||||
OpFOrdNotEqual = 182,
|
||||
OpFUnordNotEqual = 183,
|
||||
OpFOrdLessThan = 184,
|
||||
OpFUnordLessThan = 185,
|
||||
OpFOrdGreaterThan = 186,
|
||||
OpFUnordGreaterThan = 187,
|
||||
OpFOrdLessThanEqual = 188,
|
||||
OpFUnordLessThanEqual = 189,
|
||||
OpFOrdGreaterThanEqual = 190,
|
||||
OpFUnordGreaterThanEqual = 191,
|
||||
OpShiftRightLogical = 194,
|
||||
OpShiftRightArithmetic = 195,
|
||||
OpShiftLeftLogical = 196,
|
||||
OpBitwiseOr = 197,
|
||||
OpBitwiseXor = 198,
|
||||
OpBitwiseAnd = 199,
|
||||
OpNot = 200,
|
||||
OpBitFieldInsert = 201,
|
||||
OpBitFieldSExtract = 202,
|
||||
OpBitFieldUExtract = 203,
|
||||
OpBitReverse = 204,
|
||||
OpBitCount = 205,
|
||||
OpDPdx = 207,
|
||||
OpDPdy = 208,
|
||||
OpFwidth = 209,
|
||||
OpDPdxFine = 210,
|
||||
OpDPdyFine = 211,
|
||||
OpFwidthFine = 212,
|
||||
OpDPdxCoarse = 213,
|
||||
OpDPdyCoarse = 214,
|
||||
OpFwidthCoarse = 215,
|
||||
OpEmitVertex = 218,
|
||||
OpEndPrimitive = 219,
|
||||
OpEmitStreamVertex = 220,
|
||||
OpEndStreamPrimitive = 221,
|
||||
OpControlBarrier = 224,
|
||||
OpMemoryBarrier = 225,
|
||||
OpAtomicLoad = 227,
|
||||
OpAtomicStore = 228,
|
||||
OpAtomicExchange = 229,
|
||||
OpAtomicCompareExchange = 230,
|
||||
OpAtomicCompareExchangeWeak = 231,
|
||||
OpAtomicIIncrement = 232,
|
||||
OpAtomicIDecrement = 233,
|
||||
OpAtomicIAdd = 234,
|
||||
OpAtomicISub = 235,
|
||||
OpAtomicSMin = 236,
|
||||
OpAtomicUMin = 237,
|
||||
OpAtomicSMax = 238,
|
||||
OpAtomicUMax = 239,
|
||||
OpAtomicAnd = 240,
|
||||
OpAtomicOr = 241,
|
||||
OpAtomicXor = 242,
|
||||
OpPhi = 245,
|
||||
OpLoopMerge = 246,
|
||||
OpSelectionMerge = 247,
|
||||
OpLabel = 248,
|
||||
OpBranch = 249,
|
||||
OpBranchConditional = 250,
|
||||
OpSwitch = 251,
|
||||
OpKill = 252,
|
||||
OpReturn = 253,
|
||||
OpReturnValue = 254,
|
||||
OpUnreachable = 255,
|
||||
OpLifetimeStart = 256,
|
||||
OpLifetimeStop = 257,
|
||||
OpGroupAsyncCopy = 259,
|
||||
OpGroupWaitEvents = 260,
|
||||
OpGroupAll = 261,
|
||||
OpGroupAny = 262,
|
||||
OpGroupBroadcast = 263,
|
||||
OpGroupIAdd = 264,
|
||||
OpGroupFAdd = 265,
|
||||
OpGroupFMin = 266,
|
||||
OpGroupUMin = 267,
|
||||
OpGroupSMin = 268,
|
||||
OpGroupFMax = 269,
|
||||
OpGroupUMax = 270,
|
||||
OpGroupSMax = 271,
|
||||
OpReadPipe = 274,
|
||||
OpWritePipe = 275,
|
||||
OpReservedReadPipe = 276,
|
||||
OpReservedWritePipe = 277,
|
||||
OpReserveReadPipePackets = 278,
|
||||
OpReserveWritePipePackets = 279,
|
||||
OpCommitReadPipe = 280,
|
||||
OpCommitWritePipe = 281,
|
||||
OpIsValidReserveId = 282,
|
||||
OpGetNumPipePackets = 283,
|
||||
OpGetMaxPipePackets = 284,
|
||||
OpGroupReserveReadPipePackets = 285,
|
||||
OpGroupReserveWritePipePackets = 286,
|
||||
OpGroupCommitReadPipe = 287,
|
||||
OpGroupCommitWritePipe = 288,
|
||||
OpEnqueueMarker = 291,
|
||||
OpEnqueueKernel = 292,
|
||||
OpGetKernelNDrangeSubGroupCount = 293,
|
||||
OpGetKernelNDrangeMaxSubGroupSize = 294,
|
||||
OpGetKernelWorkGroupSize = 295,
|
||||
OpGetKernelPreferredWorkGroupSizeMultiple = 296,
|
||||
OpRetainEvent = 297,
|
||||
OpReleaseEvent = 298,
|
||||
OpCreateUserEvent = 299,
|
||||
OpIsValidEvent = 300,
|
||||
OpSetUserEventStatus = 301,
|
||||
OpCaptureEventProfilingInfo = 302,
|
||||
OpGetDefaultQueue = 303,
|
||||
OpBuildNDRange = 304,
|
||||
OpImageSparseSampleImplicitLod = 305,
|
||||
OpImageSparseSampleExplicitLod = 306,
|
||||
OpImageSparseSampleDrefImplicitLod = 307,
|
||||
OpImageSparseSampleDrefExplicitLod = 308,
|
||||
OpImageSparseSampleProjImplicitLod = 309,
|
||||
OpImageSparseSampleProjExplicitLod = 310,
|
||||
OpImageSparseSampleProjDrefImplicitLod = 311,
|
||||
OpImageSparseSampleProjDrefExplicitLod = 312,
|
||||
OpImageSparseFetch = 313,
|
||||
OpImageSparseGather = 314,
|
||||
OpImageSparseDrefGather = 315,
|
||||
OpImageSparseTexelsResident = 316,
|
||||
OpNoLine = 317,
|
||||
OpAtomicFlagTestAndSet = 318,
|
||||
OpAtomicFlagClear = 319,
|
||||
OpImageSparseRead = 320,
|
||||
OpSizeOf = 321,
|
||||
OpTypePipeStorage = 322,
|
||||
OpConstantPipeStorage = 323,
|
||||
OpCreatePipeFromPipeStorage = 324,
|
||||
OpGetKernelLocalSizeForSubgroupCount = 325,
|
||||
OpGetKernelMaxNumSubgroups = 326,
|
||||
OpTypeNamedBarrier = 327,
|
||||
OpNamedBarrierInitialize = 328,
|
||||
OpMemoryNamedBarrier = 329,
|
||||
OpModuleProcessed = 330,
|
||||
OpExecutionModeId = 331,
|
||||
OpDecorateId = 332,
|
||||
OpGroupNonUniformElect = 333,
|
||||
OpGroupNonUniformAll = 334,
|
||||
OpGroupNonUniformAny = 335,
|
||||
OpGroupNonUniformAllEqual = 336,
|
||||
OpGroupNonUniformBroadcast = 337,
|
||||
OpGroupNonUniformBroadcastFirst = 338,
|
||||
OpGroupNonUniformBallot = 339,
|
||||
OpGroupNonUniformInverseBallot = 340,
|
||||
OpGroupNonUniformBallotBitExtract = 341,
|
||||
OpGroupNonUniformBallotBitCount = 342,
|
||||
OpGroupNonUniformBallotFindLSB = 343,
|
||||
OpGroupNonUniformBallotFindMSB = 344,
|
||||
OpGroupNonUniformShuffle = 345,
|
||||
OpGroupNonUniformShuffleXor = 346,
|
||||
OpGroupNonUniformShuffleUp = 347,
|
||||
OpGroupNonUniformShuffleDown = 348,
|
||||
OpGroupNonUniformIAdd = 349,
|
||||
OpGroupNonUniformFAdd = 350,
|
||||
OpGroupNonUniformIMul = 351,
|
||||
OpGroupNonUniformFMul = 352,
|
||||
OpGroupNonUniformSMin = 353,
|
||||
OpGroupNonUniformUMin = 354,
|
||||
OpGroupNonUniformFMin = 355,
|
||||
OpGroupNonUniformSMax = 356,
|
||||
OpGroupNonUniformUMax = 357,
|
||||
OpGroupNonUniformFMax = 358,
|
||||
OpGroupNonUniformBitwiseAnd = 359,
|
||||
OpGroupNonUniformBitwiseOr = 360,
|
||||
OpGroupNonUniformBitwiseXor = 361,
|
||||
OpGroupNonUniformLogicalAnd = 362,
|
||||
OpGroupNonUniformLogicalOr = 363,
|
||||
OpGroupNonUniformLogicalXor = 364,
|
||||
OpGroupNonUniformQuadBroadcast = 365,
|
||||
OpGroupNonUniformQuadSwap = 366,
|
||||
OpCopyLogical = 400,
|
||||
OpPtrEqual = 401,
|
||||
OpPtrNotEqual = 402,
|
||||
OpPtrDiff = 403,
|
||||
OpColorAttachmentReadEXT = 4160,
|
||||
OpDepthAttachmentReadEXT = 4161,
|
||||
OpStencilAttachmentReadEXT = 4162,
|
||||
OpTypeTensorARM = 4163,
|
||||
OpTensorReadARM = 4164,
|
||||
OpTensorWriteARM = 4165,
|
||||
OpTensorQuerySizeARM = 4166,
|
||||
OpGraphConstantARM = 4181,
|
||||
OpGraphEntryPointARM = 4182,
|
||||
OpGraphARM = 4183,
|
||||
OpGraphInputARM = 4184,
|
||||
OpGraphSetOutputARM = 4185,
|
||||
OpGraphEndARM = 4186,
|
||||
OpTypeGraphARM = 4190,
|
||||
OpTerminateInvocation = 4416,
|
||||
OpTypeUntypedPointerKHR = 4417,
|
||||
OpUntypedVariableKHR = 4418,
|
||||
OpUntypedAccessChainKHR = 4419,
|
||||
OpUntypedInBoundsAccessChainKHR = 4420,
|
||||
OpSubgroupBallotKHR = 4421,
|
||||
OpSubgroupFirstInvocationKHR = 4422,
|
||||
OpUntypedPtrAccessChainKHR = 4423,
|
||||
OpUntypedInBoundsPtrAccessChainKHR = 4424,
|
||||
OpUntypedArrayLengthKHR = 4425,
|
||||
OpUntypedPrefetchKHR = 4426,
|
||||
OpFmaKHR = 4427,
|
||||
OpSubgroupAllKHR = 4428,
|
||||
OpSubgroupAnyKHR = 4429,
|
||||
OpSubgroupAllEqualKHR = 4430,
|
||||
OpGroupNonUniformRotateKHR = 4431,
|
||||
OpSubgroupReadInvocationKHR = 4432,
|
||||
OpExtInstWithForwardRefsKHR = 4433,
|
||||
OpUntypedGroupAsyncCopyKHR = 4434,
|
||||
OpTraceRayKHR = 4445,
|
||||
OpExecuteCallableKHR = 4446,
|
||||
OpConvertUToAccelerationStructureKHR = 4447,
|
||||
OpIgnoreIntersectionKHR = 4448,
|
||||
OpTerminateRayKHR = 4449,
|
||||
OpSDot = 4450,
|
||||
OpUDot = 4451,
|
||||
OpSUDot = 4452,
|
||||
OpSDotAccSat = 4453,
|
||||
OpUDotAccSat = 4454,
|
||||
OpSUDotAccSat = 4455,
|
||||
OpTypeCooperativeMatrixKHR = 4456,
|
||||
OpCooperativeMatrixLoadKHR = 4457,
|
||||
OpCooperativeMatrixStoreKHR = 4458,
|
||||
OpCooperativeMatrixMulAddKHR = 4459,
|
||||
OpCooperativeMatrixLengthKHR = 4460,
|
||||
OpConstantCompositeReplicateEXT = 4461,
|
||||
OpSpecConstantCompositeReplicateEXT = 4462,
|
||||
OpCompositeConstructReplicateEXT = 4463,
|
||||
OpTypeRayQueryKHR = 4472,
|
||||
OpRayQueryInitializeKHR = 4473,
|
||||
OpRayQueryTerminateKHR = 4474,
|
||||
OpRayQueryGenerateIntersectionKHR = 4475,
|
||||
OpRayQueryConfirmIntersectionKHR = 4476,
|
||||
OpRayQueryProceedKHR = 4477,
|
||||
OpRayQueryGetIntersectionTypeKHR = 4479,
|
||||
OpImageSampleWeightedQCOM = 4480,
|
||||
OpImageBoxFilterQCOM = 4481,
|
||||
OpImageBlockMatchSSDQCOM = 4482,
|
||||
OpImageBlockMatchSADQCOM = 4483,
|
||||
OpBitCastArrayQCOM = 4497,
|
||||
OpImageBlockMatchWindowSSDQCOM = 4500,
|
||||
OpImageBlockMatchWindowSADQCOM = 4501,
|
||||
OpImageBlockMatchGatherSSDQCOM = 4502,
|
||||
OpImageBlockMatchGatherSADQCOM = 4503,
|
||||
OpCompositeConstructCoopMatQCOM = 4540,
|
||||
OpCompositeExtractCoopMatQCOM = 4541,
|
||||
OpExtractSubArrayQCOM = 4542,
|
||||
OpGroupIAddNonUniformAMD = 5000,
|
||||
OpGroupFAddNonUniformAMD = 5001,
|
||||
OpGroupFMinNonUniformAMD = 5002,
|
||||
OpGroupUMinNonUniformAMD = 5003,
|
||||
OpGroupSMinNonUniformAMD = 5004,
|
||||
OpGroupFMaxNonUniformAMD = 5005,
|
||||
OpGroupUMaxNonUniformAMD = 5006,
|
||||
OpGroupSMaxNonUniformAMD = 5007,
|
||||
OpFragmentMaskFetchAMD = 5011,
|
||||
OpFragmentFetchAMD = 5012,
|
||||
OpReadClockKHR = 5056,
|
||||
OpAllocateNodePayloadsAMDX = 5074,
|
||||
OpEnqueueNodePayloadsAMDX = 5075,
|
||||
OpTypeNodePayloadArrayAMDX = 5076,
|
||||
OpFinishWritingNodePayloadAMDX = 5078,
|
||||
OpNodePayloadArrayLengthAMDX = 5090,
|
||||
OpIsNodePayloadValidAMDX = 5101,
|
||||
OpConstantStringAMDX = 5103,
|
||||
OpSpecConstantStringAMDX = 5104,
|
||||
OpGroupNonUniformQuadAllKHR = 5110,
|
||||
OpGroupNonUniformQuadAnyKHR = 5111,
|
||||
OpTypeBufferEXT = 5115,
|
||||
OpBufferPointerEXT = 5119,
|
||||
OpAbortKHR = 5121,
|
||||
OpUntypedImageTexelPointerEXT = 5126,
|
||||
OpMemberDecorateIdEXT = 5127,
|
||||
OpConstantSizeOfEXT = 5129,
|
||||
OpConstantDataKHR = 5147,
|
||||
OpSpecConstantDataKHR = 5148,
|
||||
OpPoisonKHR = 5158,
|
||||
OpFreezeKHR = 5159,
|
||||
OpHitObjectRecordHitMotionNV = 5249,
|
||||
OpHitObjectRecordHitWithIndexMotionNV = 5250,
|
||||
OpHitObjectRecordMissMotionNV = 5251,
|
||||
OpHitObjectGetWorldToObjectNV = 5252,
|
||||
OpHitObjectGetObjectToWorldNV = 5253,
|
||||
OpHitObjectGetObjectRayDirectionNV = 5254,
|
||||
OpHitObjectGetObjectRayOriginNV = 5255,
|
||||
OpHitObjectTraceRayMotionNV = 5256,
|
||||
OpHitObjectGetShaderRecordBufferHandleNV = 5257,
|
||||
OpHitObjectGetShaderBindingTableRecordIndexNV = 5258,
|
||||
OpHitObjectRecordEmptyNV = 5259,
|
||||
OpHitObjectTraceRayNV = 5260,
|
||||
OpHitObjectRecordHitNV = 5261,
|
||||
OpHitObjectRecordHitWithIndexNV = 5262,
|
||||
OpHitObjectRecordMissNV = 5263,
|
||||
OpHitObjectExecuteShaderNV = 5264,
|
||||
OpHitObjectGetCurrentTimeNV = 5265,
|
||||
OpHitObjectGetAttributesNV = 5266,
|
||||
OpHitObjectGetHitKindNV = 5267,
|
||||
OpHitObjectGetPrimitiveIndexNV = 5268,
|
||||
OpHitObjectGetGeometryIndexNV = 5269,
|
||||
OpHitObjectGetInstanceIdNV = 5270,
|
||||
OpHitObjectGetInstanceCustomIndexNV = 5271,
|
||||
OpHitObjectGetWorldRayDirectionNV = 5272,
|
||||
OpHitObjectGetWorldRayOriginNV = 5273,
|
||||
OpHitObjectGetRayTMaxNV = 5274,
|
||||
OpHitObjectGetRayTMinNV = 5275,
|
||||
OpHitObjectIsEmptyNV = 5276,
|
||||
OpHitObjectIsHitNV = 5277,
|
||||
OpHitObjectIsMissNV = 5278,
|
||||
OpReorderThreadWithHitObjectNV = 5279,
|
||||
OpReorderThreadWithHintNV = 5280,
|
||||
OpTypeHitObjectNV = 5281,
|
||||
OpImageSampleFootprintNV = 5283,
|
||||
OpTypeVectorIdEXT = 5288,
|
||||
OpCooperativeVectorMatrixMulNV = 5289,
|
||||
OpCooperativeVectorOuterProductAccumulateNV = 5290,
|
||||
OpCooperativeVectorReduceSumAccumulateNV = 5291,
|
||||
OpCooperativeVectorMatrixMulAddNV = 5292,
|
||||
OpCooperativeMatrixConvertNV = 5293,
|
||||
OpEmitMeshTasksEXT = 5294,
|
||||
OpSetMeshOutputsEXT = 5295,
|
||||
OpGroupNonUniformPartitionEXT = 5296,
|
||||
OpWritePackedPrimitiveIndices4x8NV = 5299,
|
||||
OpFetchMicroTriangleVertexPositionNV = 5300,
|
||||
OpFetchMicroTriangleVertexBarycentricNV = 5301,
|
||||
OpCooperativeVectorLoadNV = 5302,
|
||||
OpCooperativeVectorStoreNV = 5303,
|
||||
OpHitObjectRecordFromQueryEXT = 5304,
|
||||
OpHitObjectRecordMissEXT = 5305,
|
||||
OpHitObjectRecordMissMotionEXT = 5306,
|
||||
OpHitObjectGetIntersectionTriangleVertexPositionsEXT = 5307,
|
||||
OpHitObjectGetRayFlagsEXT = 5308,
|
||||
OpHitObjectSetShaderBindingTableRecordIndexEXT = 5309,
|
||||
OpHitObjectReorderExecuteShaderEXT = 5310,
|
||||
OpHitObjectTraceReorderExecuteEXT = 5311,
|
||||
OpHitObjectTraceMotionReorderExecuteEXT = 5312,
|
||||
OpTypeHitObjectEXT = 5313,
|
||||
OpReorderThreadWithHintEXT = 5314,
|
||||
OpReorderThreadWithHitObjectEXT = 5315,
|
||||
OpHitObjectTraceRayEXT = 5316,
|
||||
OpHitObjectTraceRayMotionEXT = 5317,
|
||||
OpHitObjectRecordEmptyEXT = 5318,
|
||||
OpHitObjectExecuteShaderEXT = 5319,
|
||||
OpHitObjectGetCurrentTimeEXT = 5320,
|
||||
OpHitObjectGetAttributesEXT = 5321,
|
||||
OpHitObjectGetHitKindEXT = 5322,
|
||||
OpHitObjectGetPrimitiveIndexEXT = 5323,
|
||||
OpHitObjectGetGeometryIndexEXT = 5324,
|
||||
OpHitObjectGetInstanceIdEXT = 5325,
|
||||
OpHitObjectGetInstanceCustomIndexEXT = 5326,
|
||||
OpHitObjectGetObjectRayOriginEXT = 5327,
|
||||
OpHitObjectGetObjectRayDirectionEXT = 5328,
|
||||
OpHitObjectGetWorldRayDirectionEXT = 5329,
|
||||
OpHitObjectGetWorldRayOriginEXT = 5330,
|
||||
OpHitObjectGetObjectToWorldEXT = 5331,
|
||||
OpHitObjectGetWorldToObjectEXT = 5332,
|
||||
OpHitObjectGetRayTMaxEXT = 5333,
|
||||
OpReportIntersectionKHR = 5334,
|
||||
OpIgnoreIntersectionNV = 5335,
|
||||
OpTerminateRayNV = 5336,
|
||||
OpTraceNV = 5337,
|
||||
OpTraceMotionNV = 5338,
|
||||
OpTraceRayMotionNV = 5339,
|
||||
OpRayQueryGetIntersectionTriangleVertexPositionsKHR = 5340,
|
||||
OpTypeAccelerationStructureKHR = 5341,
|
||||
OpExecuteCallableNV = 5344,
|
||||
OpRayQueryGetIntersectionClusterIdNV = 5345,
|
||||
OpHitObjectGetClusterIdNV = 5346,
|
||||
OpHitObjectGetRayTMinEXT = 5347,
|
||||
OpHitObjectGetShaderBindingTableRecordIndexEXT = 5348,
|
||||
OpHitObjectGetShaderRecordBufferHandleEXT = 5349,
|
||||
OpHitObjectIsEmptyEXT = 5350,
|
||||
OpHitObjectIsHitEXT = 5351,
|
||||
OpHitObjectIsMissEXT = 5352,
|
||||
OpTypeCooperativeMatrixNV = 5358,
|
||||
OpCooperativeMatrixLoadNV = 5359,
|
||||
OpCooperativeMatrixStoreNV = 5360,
|
||||
OpCooperativeMatrixMulAddNV = 5361,
|
||||
OpCooperativeMatrixLengthNV = 5362,
|
||||
OpBeginInvocationInterlockEXT = 5364,
|
||||
OpEndInvocationInterlockEXT = 5365,
|
||||
OpCooperativeMatrixReduceNV = 5366,
|
||||
OpCooperativeMatrixLoadTensorNV = 5367,
|
||||
OpCooperativeMatrixStoreTensorNV = 5368,
|
||||
OpCooperativeMatrixPerElementOpNV = 5369,
|
||||
OpTypeTensorLayoutNV = 5370,
|
||||
OpTypeTensorViewNV = 5371,
|
||||
OpCreateTensorLayoutNV = 5372,
|
||||
OpTensorLayoutSetDimensionNV = 5373,
|
||||
OpTensorLayoutSetStrideNV = 5374,
|
||||
OpTensorLayoutSliceNV = 5375,
|
||||
OpTensorLayoutSetClampValueNV = 5376,
|
||||
OpCreateTensorViewNV = 5377,
|
||||
OpTensorViewSetDimensionNV = 5378,
|
||||
OpTensorViewSetStrideNV = 5379,
|
||||
OpDemoteToHelperInvocation = 5380,
|
||||
OpIsHelperInvocationEXT = 5381,
|
||||
OpTensorViewSetClipNV = 5382,
|
||||
OpTensorLayoutSetBlockSizeNV = 5384,
|
||||
OpCooperativeMatrixTransposeNV = 5390,
|
||||
OpConvertUToImageNV = 5391,
|
||||
OpConvertUToSamplerNV = 5392,
|
||||
OpConvertImageToUNV = 5393,
|
||||
OpConvertSamplerToUNV = 5394,
|
||||
OpConvertUToSampledImageNV = 5395,
|
||||
OpConvertSampledImageToUNV = 5396,
|
||||
OpSamplerImageAddressingModeNV = 5397,
|
||||
OpRawAccessChainNV = 5398,
|
||||
OpRayQueryGetIntersectionSpherePositionNV = 5427,
|
||||
OpRayQueryGetIntersectionSphereRadiusNV = 5428,
|
||||
OpRayQueryGetIntersectionLSSPositionsNV = 5429,
|
||||
OpRayQueryGetIntersectionLSSRadiiNV = 5430,
|
||||
OpRayQueryGetIntersectionLSSHitValueNV = 5431,
|
||||
OpHitObjectGetSpherePositionNV = 5432,
|
||||
OpHitObjectGetSphereRadiusNV = 5433,
|
||||
OpHitObjectGetLSSPositionsNV = 5434,
|
||||
OpHitObjectGetLSSRadiiNV = 5435,
|
||||
OpHitObjectIsSphereHitNV = 5436,
|
||||
OpHitObjectIsLSSHitNV = 5437,
|
||||
OpRayQueryIsSphereHitNV = 5438,
|
||||
OpRayQueryIsLSSHitNV = 5439,
|
||||
OpSubgroupShuffleINTEL = 5571,
|
||||
OpSubgroupShuffleDownINTEL = 5572,
|
||||
OpSubgroupShuffleUpINTEL = 5573,
|
||||
OpSubgroupShuffleXorINTEL = 5574,
|
||||
OpSubgroupBlockReadINTEL = 5575,
|
||||
OpSubgroupBlockWriteINTEL = 5576,
|
||||
OpSubgroupImageBlockReadINTEL = 5577,
|
||||
OpSubgroupImageBlockWriteINTEL = 5578,
|
||||
OpSubgroupImageMediaBlockReadINTEL = 5580,
|
||||
OpSubgroupImageMediaBlockWriteINTEL = 5581,
|
||||
OpUCountLeadingZerosINTEL = 5585,
|
||||
OpUCountTrailingZerosINTEL = 5586,
|
||||
OpAbsISubINTEL = 5587,
|
||||
OpAbsUSubINTEL = 5588,
|
||||
OpIAddSatINTEL = 5589,
|
||||
OpUAddSatINTEL = 5590,
|
||||
OpIAverageINTEL = 5591,
|
||||
OpUAverageINTEL = 5592,
|
||||
OpIAverageRoundedINTEL = 5593,
|
||||
OpUAverageRoundedINTEL = 5594,
|
||||
OpISubSatINTEL = 5595,
|
||||
OpUSubSatINTEL = 5596,
|
||||
OpIMul32x16INTEL = 5597,
|
||||
OpUMul32x16INTEL = 5598,
|
||||
OpConstantFunctionPointerINTEL = 5600,
|
||||
OpFunctionPointerCallINTEL = 5601,
|
||||
OpAsmTargetINTEL = 5609,
|
||||
OpAsmINTEL = 5610,
|
||||
OpAsmCallINTEL = 5611,
|
||||
OpAtomicFMinEXT = 5614,
|
||||
OpAtomicFMaxEXT = 5615,
|
||||
OpAssumeTrueKHR = 5630,
|
||||
OpExpectKHR = 5631,
|
||||
OpDecorateString = 5632,
|
||||
OpMemberDecorateString = 5633,
|
||||
OpVmeImageINTEL = 5699,
|
||||
OpTypeVmeImageINTEL = 5700,
|
||||
OpTypeAvcImePayloadINTEL = 5701,
|
||||
OpTypeAvcRefPayloadINTEL = 5702,
|
||||
OpTypeAvcSicPayloadINTEL = 5703,
|
||||
OpTypeAvcMcePayloadINTEL = 5704,
|
||||
OpTypeAvcMceResultINTEL = 5705,
|
||||
OpTypeAvcImeResultINTEL = 5706,
|
||||
OpTypeAvcImeResultSingleReferenceStreamoutINTEL = 5707,
|
||||
OpTypeAvcImeResultDualReferenceStreamoutINTEL = 5708,
|
||||
OpTypeAvcImeSingleReferenceStreaminINTEL = 5709,
|
||||
OpTypeAvcImeDualReferenceStreaminINTEL = 5710,
|
||||
OpTypeAvcRefResultINTEL = 5711,
|
||||
OpTypeAvcSicResultINTEL = 5712,
|
||||
OpSubgroupAvcMceGetDefaultInterBaseMultiReferencePenaltyINTEL = 5713,
|
||||
OpSubgroupAvcMceSetInterBaseMultiReferencePenaltyINTEL = 5714,
|
||||
OpSubgroupAvcMceGetDefaultInterShapePenaltyINTEL = 5715,
|
||||
OpSubgroupAvcMceSetInterShapePenaltyINTEL = 5716,
|
||||
OpSubgroupAvcMceGetDefaultInterDirectionPenaltyINTEL = 5717,
|
||||
OpSubgroupAvcMceSetInterDirectionPenaltyINTEL = 5718,
|
||||
OpSubgroupAvcMceGetDefaultIntraLumaShapePenaltyINTEL = 5719,
|
||||
OpSubgroupAvcMceGetDefaultInterMotionVectorCostTableINTEL = 5720,
|
||||
OpSubgroupAvcMceGetDefaultHighPenaltyCostTableINTEL = 5721,
|
||||
OpSubgroupAvcMceGetDefaultMediumPenaltyCostTableINTEL = 5722,
|
||||
OpSubgroupAvcMceGetDefaultLowPenaltyCostTableINTEL = 5723,
|
||||
OpSubgroupAvcMceSetMotionVectorCostFunctionINTEL = 5724,
|
||||
OpSubgroupAvcMceGetDefaultIntraLumaModePenaltyINTEL = 5725,
|
||||
OpSubgroupAvcMceGetDefaultNonDcLumaIntraPenaltyINTEL = 5726,
|
||||
OpSubgroupAvcMceGetDefaultIntraChromaModeBasePenaltyINTEL = 5727,
|
||||
OpSubgroupAvcMceSetAcOnlyHaarINTEL = 5728,
|
||||
OpSubgroupAvcMceSetSourceInterlacedFieldPolarityINTEL = 5729,
|
||||
OpSubgroupAvcMceSetSingleReferenceInterlacedFieldPolarityINTEL = 5730,
|
||||
OpSubgroupAvcMceSetDualReferenceInterlacedFieldPolaritiesINTEL = 5731,
|
||||
OpSubgroupAvcMceConvertToImePayloadINTEL = 5732,
|
||||
OpSubgroupAvcMceConvertToImeResultINTEL = 5733,
|
||||
OpSubgroupAvcMceConvertToRefPayloadINTEL = 5734,
|
||||
OpSubgroupAvcMceConvertToRefResultINTEL = 5735,
|
||||
OpSubgroupAvcMceConvertToSicPayloadINTEL = 5736,
|
||||
OpSubgroupAvcMceConvertToSicResultINTEL = 5737,
|
||||
OpSubgroupAvcMceGetMotionVectorsINTEL = 5738,
|
||||
OpSubgroupAvcMceGetInterDistortionsINTEL = 5739,
|
||||
OpSubgroupAvcMceGetBestInterDistortionsINTEL = 5740,
|
||||
OpSubgroupAvcMceGetInterMajorShapeINTEL = 5741,
|
||||
OpSubgroupAvcMceGetInterMinorShapeINTEL = 5742,
|
||||
OpSubgroupAvcMceGetInterDirectionsINTEL = 5743,
|
||||
OpSubgroupAvcMceGetInterMotionVectorCountINTEL = 5744,
|
||||
OpSubgroupAvcMceGetInterReferenceIdsINTEL = 5745,
|
||||
OpSubgroupAvcMceGetInterReferenceInterlacedFieldPolaritiesINTEL = 5746,
|
||||
OpSubgroupAvcImeInitializeINTEL = 5747,
|
||||
OpSubgroupAvcImeSetSingleReferenceINTEL = 5748,
|
||||
OpSubgroupAvcImeSetDualReferenceINTEL = 5749,
|
||||
OpSubgroupAvcImeRefWindowSizeINTEL = 5750,
|
||||
OpSubgroupAvcImeAdjustRefOffsetINTEL = 5751,
|
||||
OpSubgroupAvcImeConvertToMcePayloadINTEL = 5752,
|
||||
OpSubgroupAvcImeSetMaxMotionVectorCountINTEL = 5753,
|
||||
OpSubgroupAvcImeSetUnidirectionalMixDisableINTEL = 5754,
|
||||
OpSubgroupAvcImeSetEarlySearchTerminationThresholdINTEL = 5755,
|
||||
OpSubgroupAvcImeSetWeightedSadINTEL = 5756,
|
||||
OpSubgroupAvcImeEvaluateWithSingleReferenceINTEL = 5757,
|
||||
OpSubgroupAvcImeEvaluateWithDualReferenceINTEL = 5758,
|
||||
OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminINTEL = 5759,
|
||||
OpSubgroupAvcImeEvaluateWithDualReferenceStreaminINTEL = 5760,
|
||||
OpSubgroupAvcImeEvaluateWithSingleReferenceStreamoutINTEL = 5761,
|
||||
OpSubgroupAvcImeEvaluateWithDualReferenceStreamoutINTEL = 5762,
|
||||
OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminoutINTEL = 5763,
|
||||
OpSubgroupAvcImeEvaluateWithDualReferenceStreaminoutINTEL = 5764,
|
||||
OpSubgroupAvcImeConvertToMceResultINTEL = 5765,
|
||||
OpSubgroupAvcImeGetSingleReferenceStreaminINTEL = 5766,
|
||||
OpSubgroupAvcImeGetDualReferenceStreaminINTEL = 5767,
|
||||
OpSubgroupAvcImeStripSingleReferenceStreamoutINTEL = 5768,
|
||||
OpSubgroupAvcImeStripDualReferenceStreamoutINTEL = 5769,
|
||||
OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeMotionVectorsINTEL = 5770,
|
||||
OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeDistortionsINTEL = 5771,
|
||||
OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeReferenceIdsINTEL = 5772,
|
||||
OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeMotionVectorsINTEL = 5773,
|
||||
OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeDistortionsINTEL = 5774,
|
||||
OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeReferenceIdsINTEL = 5775,
|
||||
OpSubgroupAvcImeGetBorderReachedINTEL = 5776,
|
||||
OpSubgroupAvcImeGetTruncatedSearchIndicationINTEL = 5777,
|
||||
OpSubgroupAvcImeGetUnidirectionalEarlySearchTerminationINTEL = 5778,
|
||||
OpSubgroupAvcImeGetWeightingPatternMinimumMotionVectorINTEL = 5779,
|
||||
OpSubgroupAvcImeGetWeightingPatternMinimumDistortionINTEL = 5780,
|
||||
OpSubgroupAvcFmeInitializeINTEL = 5781,
|
||||
OpSubgroupAvcBmeInitializeINTEL = 5782,
|
||||
OpSubgroupAvcRefConvertToMcePayloadINTEL = 5783,
|
||||
OpSubgroupAvcRefSetBidirectionalMixDisableINTEL = 5784,
|
||||
OpSubgroupAvcRefSetBilinearFilterEnableINTEL = 5785,
|
||||
OpSubgroupAvcRefEvaluateWithSingleReferenceINTEL = 5786,
|
||||
OpSubgroupAvcRefEvaluateWithDualReferenceINTEL = 5787,
|
||||
OpSubgroupAvcRefEvaluateWithMultiReferenceINTEL = 5788,
|
||||
OpSubgroupAvcRefEvaluateWithMultiReferenceInterlacedINTEL = 5789,
|
||||
OpSubgroupAvcRefConvertToMceResultINTEL = 5790,
|
||||
OpSubgroupAvcSicInitializeINTEL = 5791,
|
||||
OpSubgroupAvcSicConfigureSkcINTEL = 5792,
|
||||
OpSubgroupAvcSicConfigureIpeLumaINTEL = 5793,
|
||||
OpSubgroupAvcSicConfigureIpeLumaChromaINTEL = 5794,
|
||||
OpSubgroupAvcSicGetMotionVectorMaskINTEL = 5795,
|
||||
OpSubgroupAvcSicConvertToMcePayloadINTEL = 5796,
|
||||
OpSubgroupAvcSicSetIntraLumaShapePenaltyINTEL = 5797,
|
||||
OpSubgroupAvcSicSetIntraLumaModeCostFunctionINTEL = 5798,
|
||||
OpSubgroupAvcSicSetIntraChromaModeCostFunctionINTEL = 5799,
|
||||
OpSubgroupAvcSicSetBilinearFilterEnableINTEL = 5800,
|
||||
OpSubgroupAvcSicSetSkcForwardTransformEnableINTEL = 5801,
|
||||
OpSubgroupAvcSicSetBlockBasedRawSkipSadINTEL = 5802,
|
||||
OpSubgroupAvcSicEvaluateIpeINTEL = 5803,
|
||||
OpSubgroupAvcSicEvaluateWithSingleReferenceINTEL = 5804,
|
||||
OpSubgroupAvcSicEvaluateWithDualReferenceINTEL = 5805,
|
||||
OpSubgroupAvcSicEvaluateWithMultiReferenceINTEL = 5806,
|
||||
OpSubgroupAvcSicEvaluateWithMultiReferenceInterlacedINTEL = 5807,
|
||||
OpSubgroupAvcSicConvertToMceResultINTEL = 5808,
|
||||
OpSubgroupAvcSicGetIpeLumaShapeINTEL = 5809,
|
||||
OpSubgroupAvcSicGetBestIpeLumaDistortionINTEL = 5810,
|
||||
OpSubgroupAvcSicGetBestIpeChromaDistortionINTEL = 5811,
|
||||
OpSubgroupAvcSicGetPackedIpeLumaModesINTEL = 5812,
|
||||
OpSubgroupAvcSicGetIpeChromaModeINTEL = 5813,
|
||||
OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL = 5814,
|
||||
OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL = 5815,
|
||||
OpSubgroupAvcSicGetInterRawSadsINTEL = 5816,
|
||||
OpVariableLengthArrayINTEL = 5818,
|
||||
OpSaveMemoryINTEL = 5819,
|
||||
OpRestoreMemoryINTEL = 5820,
|
||||
OpArbitraryFloatSinCosPiALTERA = 5840,
|
||||
OpArbitraryFloatCastALTERA = 5841,
|
||||
OpArbitraryFloatCastFromIntALTERA = 5842,
|
||||
OpArbitraryFloatCastToIntALTERA = 5843,
|
||||
OpArbitraryFloatAddALTERA = 5846,
|
||||
OpArbitraryFloatSubALTERA = 5847,
|
||||
OpArbitraryFloatMulALTERA = 5848,
|
||||
OpArbitraryFloatDivALTERA = 5849,
|
||||
OpArbitraryFloatGTALTERA = 5850,
|
||||
OpArbitraryFloatGEALTERA = 5851,
|
||||
OpArbitraryFloatLTALTERA = 5852,
|
||||
OpArbitraryFloatLEALTERA = 5853,
|
||||
OpArbitraryFloatEQALTERA = 5854,
|
||||
OpArbitraryFloatRecipALTERA = 5855,
|
||||
OpArbitraryFloatRSqrtALTERA = 5856,
|
||||
OpArbitraryFloatCbrtALTERA = 5857,
|
||||
OpArbitraryFloatHypotALTERA = 5858,
|
||||
OpArbitraryFloatSqrtALTERA = 5859,
|
||||
OpArbitraryFloatLogINTEL = 5860,
|
||||
OpArbitraryFloatLog2INTEL = 5861,
|
||||
OpArbitraryFloatLog10INTEL = 5862,
|
||||
OpArbitraryFloatLog1pINTEL = 5863,
|
||||
OpArbitraryFloatExpINTEL = 5864,
|
||||
OpArbitraryFloatExp2INTEL = 5865,
|
||||
OpArbitraryFloatExp10INTEL = 5866,
|
||||
OpArbitraryFloatExpm1INTEL = 5867,
|
||||
OpArbitraryFloatSinINTEL = 5868,
|
||||
OpArbitraryFloatCosINTEL = 5869,
|
||||
OpArbitraryFloatSinCosINTEL = 5870,
|
||||
OpArbitraryFloatSinPiINTEL = 5871,
|
||||
OpArbitraryFloatCosPiINTEL = 5872,
|
||||
OpArbitraryFloatASinINTEL = 5873,
|
||||
OpArbitraryFloatASinPiINTEL = 5874,
|
||||
OpArbitraryFloatACosINTEL = 5875,
|
||||
OpArbitraryFloatACosPiINTEL = 5876,
|
||||
OpArbitraryFloatATanINTEL = 5877,
|
||||
OpArbitraryFloatATanPiINTEL = 5878,
|
||||
OpArbitraryFloatATan2INTEL = 5879,
|
||||
OpArbitraryFloatPowINTEL = 5880,
|
||||
OpArbitraryFloatPowRINTEL = 5881,
|
||||
OpArbitraryFloatPowNINTEL = 5882,
|
||||
OpLoopControlINTEL = 5887,
|
||||
OpAliasDomainDeclINTEL = 5911,
|
||||
OpAliasScopeDeclINTEL = 5912,
|
||||
OpAliasScopeListDeclINTEL = 5913,
|
||||
OpFixedSqrtALTERA = 5923,
|
||||
OpFixedRecipALTERA = 5924,
|
||||
OpFixedRsqrtALTERA = 5925,
|
||||
OpFixedSinALTERA = 5926,
|
||||
OpFixedCosALTERA = 5927,
|
||||
OpFixedSinCosALTERA = 5928,
|
||||
OpFixedSinPiALTERA = 5929,
|
||||
OpFixedCosPiALTERA = 5930,
|
||||
OpFixedSinCosPiALTERA = 5931,
|
||||
OpFixedLogALTERA = 5932,
|
||||
OpFixedExpALTERA = 5933,
|
||||
OpPtrCastToCrossWorkgroupALTERA = 5934,
|
||||
OpCrossWorkgroupCastToPtrALTERA = 5938,
|
||||
OpReadPipeBlockingALTERA = 5946,
|
||||
OpWritePipeBlockingALTERA = 5947,
|
||||
OpFPGARegALTERA = 5949,
|
||||
OpRayQueryGetRayTMinKHR = 6016,
|
||||
OpRayQueryGetRayFlagsKHR = 6017,
|
||||
OpRayQueryGetIntersectionTKHR = 6018,
|
||||
OpRayQueryGetIntersectionInstanceCustomIndexKHR = 6019,
|
||||
OpRayQueryGetIntersectionInstanceIdKHR = 6020,
|
||||
OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR = 6021,
|
||||
OpRayQueryGetIntersectionGeometryIndexKHR = 6022,
|
||||
OpRayQueryGetIntersectionPrimitiveIndexKHR = 6023,
|
||||
OpRayQueryGetIntersectionBarycentricsKHR = 6024,
|
||||
OpRayQueryGetIntersectionFrontFaceKHR = 6025,
|
||||
OpRayQueryGetIntersectionCandidateAABBOpaqueKHR = 6026,
|
||||
OpRayQueryGetIntersectionObjectRayDirectionKHR = 6027,
|
||||
OpRayQueryGetIntersectionObjectRayOriginKHR = 6028,
|
||||
OpRayQueryGetWorldRayDirectionKHR = 6029,
|
||||
OpRayQueryGetWorldRayOriginKHR = 6030,
|
||||
OpRayQueryGetIntersectionObjectToWorldKHR = 6031,
|
||||
OpRayQueryGetIntersectionWorldToObjectKHR = 6032,
|
||||
OpAtomicFAddEXT = 6035,
|
||||
OpTypeBufferSurfaceINTEL = 6086,
|
||||
OpTypeStructContinuedINTEL = 6090,
|
||||
OpConstantCompositeContinuedINTEL = 6091,
|
||||
OpSpecConstantCompositeContinuedINTEL = 6092,
|
||||
OpCompositeConstructContinuedINTEL = 6096,
|
||||
OpConvertFToBF16INTEL = 6116,
|
||||
OpConvertBF16ToFINTEL = 6117,
|
||||
OpControlBarrierArriveEXT = 6142,
|
||||
OpControlBarrierWaitEXT = 6143,
|
||||
OpArithmeticFenceEXT = 6145,
|
||||
OpTaskSequenceCreateALTERA = 6163,
|
||||
OpTaskSequenceAsyncALTERA = 6164,
|
||||
OpTaskSequenceGetALTERA = 6165,
|
||||
OpTaskSequenceReleaseALTERA = 6166,
|
||||
OpTypeTaskSequenceALTERA = 6199,
|
||||
OpSubgroupBlockPrefetchINTEL = 6221,
|
||||
OpSubgroup2DBlockLoadINTEL = 6231,
|
||||
OpSubgroup2DBlockLoadTransformINTEL = 6232,
|
||||
OpSubgroup2DBlockLoadTransposeINTEL = 6233,
|
||||
OpSubgroup2DBlockPrefetchINTEL = 6234,
|
||||
OpSubgroup2DBlockStoreINTEL = 6235,
|
||||
OpSubgroupMatrixMultiplyAccumulateINTEL = 6237,
|
||||
OpBitwiseFunctionINTEL = 6242,
|
||||
OpUntypedVariableLengthArrayINTEL = 6244,
|
||||
OpConditionalExtensionINTEL = 6248,
|
||||
OpConditionalEntryPointINTEL = 6249,
|
||||
OpConditionalCapabilityINTEL = 6250,
|
||||
OpSpecConstantTargetINTEL = 6251,
|
||||
OpSpecConstantArchitectureINTEL = 6252,
|
||||
OpSpecConstantCapabilitiesINTEL = 6253,
|
||||
OpConditionalCopyObjectINTEL = 6254,
|
||||
OpPredicatedLoadINTEL = 6258,
|
||||
OpPredicatedStoreINTEL = 6259,
|
||||
OpGroupIMulKHR = 6401,
|
||||
OpGroupFMulKHR = 6402,
|
||||
OpGroupBitwiseAndKHR = 6403,
|
||||
OpGroupBitwiseOrKHR = 6404,
|
||||
OpGroupBitwiseXorKHR = 6405,
|
||||
OpGroupLogicalAndKHR = 6406,
|
||||
OpGroupLogicalOrKHR = 6407,
|
||||
OpGroupLogicalXorKHR = 6408,
|
||||
OpRoundFToTF32INTEL = 6426,
|
||||
OpMaskedGatherINTEL = 6428,
|
||||
OpMaskedScatterINTEL = 6429,
|
||||
OpConvertHandleToImageINTEL = 6529,
|
||||
OpConvertHandleToSamplerINTEL = 6530,
|
||||
OpConvertHandleToSampledImageINTEL = 6531,
|
||||
OpFDot2MixAcc32VALVE = 6916,
|
||||
OpFDot2MixAcc16VALVE = 6917,
|
||||
OpFDot4MixAcc32VALVE = 6918,
|
||||
}
|
||||
1345
core/rexcode/ir/spirv/operand_kinds.odin
Normal file
1345
core/rexcode/ir/spirv/operand_kinds.odin
Normal file
File diff suppressed because it is too large
Load Diff
29
core/rexcode/ir/spirv/reloc.odin
Normal file
29
core/rexcode/ir/spirv/reloc.odin
Normal file
@@ -0,0 +1,29 @@
|
||||
// rexcode · Brendan Punsky (dotbmp@github), original author
|
||||
|
||||
package rexcode_spirv
|
||||
|
||||
// =============================================================================
|
||||
// SECTION: Relocation (SPIR-V linkage fixups -- the per-IR reloc.odin)
|
||||
// =============================================================================
|
||||
//
|
||||
// SPIR-V is normally self-contained: operands reference entities by <id>,
|
||||
// resolved structurally, with no cross-object fixups. The one exception is
|
||||
// *linkage*: an <id> decorated `LinkageAttributes` with `Import` is defined in
|
||||
// another module and `Export` is offered to one. A linker matching imports to
|
||||
// exports by name is the SPIR-V analog of an object-file symbol fixup, so it is
|
||||
// surfaced as a `Relocation` the way each arch surfaces its own (parallel to an
|
||||
// arch's reloc.odin), produced by `encode` for EXTERNAL references.
|
||||
//
|
||||
// Not #packed (unlike the small ISA Relocation): the linkage name is a string.
|
||||
|
||||
Relocation_Type :: enum u8 {
|
||||
NONE,
|
||||
IMPORT, // the <id> is imported (LinkageType Import) -- undefined here
|
||||
EXPORT, // the <id> is exported (LinkageType Export) -- visible to other modules
|
||||
}
|
||||
|
||||
Relocation :: struct {
|
||||
id: Id, // the <id> carrying the LinkageAttributes decoration
|
||||
name: string, // the external linkage name to match across modules
|
||||
type: Relocation_Type,
|
||||
}
|
||||
124
core/rexcode/ir/spirv/spirv.odin
Normal file
124
core/rexcode/ir/spirv/spirv.odin
Normal file
@@ -0,0 +1,124 @@
|
||||
// rexcode · Brendan Punsky (dotbmp@github), original author
|
||||
|
||||
// rexcode/ir/spirv -- the SPIR-V intermediate representation.
|
||||
//
|
||||
// SPIR-V is the Khronos binary IR for shaders and compute kernels: a stream of
|
||||
// 32-bit words, each instruction headed by a `wordCount<<16 | opcode` word, over
|
||||
// an SSA value model with a first-class type system (OpTypeInt, OpConstant,
|
||||
// OpFunction, ...). On the two axes that sort the IR family (docs/ir_design.md
|
||||
// §2) it is **table-driven** on encoding -- a static `opcode -> operand-layout`
|
||||
// grammar, exactly the ISA `ENCODING_TABLE` shape -- and **SSA** on dataflow,
|
||||
// like LLVM and unlike WASM.
|
||||
//
|
||||
// So this package is built as a sibling of the ISA arch packages: it re-exports
|
||||
// the shared `ir` vocabulary (Module / Function / Block / Operation / Operand /
|
||||
// Type / Id / ...), owns a `u16` `Opcode` (the SPIR-V opcode values), a static
|
||||
// operand-layout table that drives a word-level codec, the three Module-based
|
||||
// verbs (`encode` / `decode` / `print`), a `Relocation` for linkage fixups, and
|
||||
// the SPIR-V <-> `ir.Type` lowering. No PC-relative label pass exists; operands
|
||||
// reference entities (results, types, functions) by `Id`, resolved structurally.
|
||||
package rexcode_spirv
|
||||
|
||||
import "core:rexcode/ir"
|
||||
|
||||
// =============================================================================
|
||||
// SECTION: Re-exported shared vocabulary (the IR naming contract, ir_design §4)
|
||||
// =============================================================================
|
||||
//
|
||||
// A consumer sees one namespace -- `spirv.Operation`, `spirv.Type`, ... -- the
|
||||
// way an arch package re-exports `isa`. These are the IR's leaf model; the
|
||||
// concrete additions (Opcode, Relocation, the codec) live in the sibling files.
|
||||
|
||||
// `Module` is NOT re-exported -- SPIR-V's module carries dialect sections the
|
||||
// shared core has no slot for (capabilities, entry points, decorations, ...), so
|
||||
// it is a superset struct embedding `ir.Module`; see module.odin.
|
||||
Function :: ir.Function
|
||||
Block :: ir.Block
|
||||
Global :: ir.Global
|
||||
Operation :: ir.Operation
|
||||
Operation_Flags :: ir.Operation_Flags
|
||||
Operand :: ir.Operand
|
||||
Operand_Kind :: ir.Operand_Kind
|
||||
Result :: ir.Result
|
||||
Type :: ir.Type
|
||||
Type_Ref :: ir.Type_Ref
|
||||
Type_Kind :: ir.Type_Kind
|
||||
Id :: ir.Id
|
||||
Ref :: ir.Ref
|
||||
Ref_Space :: ir.Ref_Space
|
||||
Symbol_Table :: ir.Symbol_Table
|
||||
Dataflow :: ir.Dataflow
|
||||
Error :: ir.Error
|
||||
Error_Code :: ir.Error_Code
|
||||
Token :: ir.Token
|
||||
Token_Kind :: ir.Token_Kind
|
||||
Print_Options :: ir.Print_Options
|
||||
Print_Result :: ir.Print_Result
|
||||
|
||||
ID_NONE :: ir.ID_NONE
|
||||
TYPE_NONE :: ir.TYPE_NONE
|
||||
DEFAULT_PRINT_OPTIONS :: ir.DEFAULT_PRINT_OPTIONS
|
||||
|
||||
// Operand / type / ref constructors (shared; SSA makes them uniform).
|
||||
op_int :: ir.op_int
|
||||
op_float :: ir.op_float
|
||||
op_type :: ir.op_type
|
||||
op_ref :: ir.op_ref
|
||||
op_value :: ir.op_value
|
||||
op_block :: ir.op_block
|
||||
operand_id :: ir.operand_id
|
||||
operand_type :: ir.operand_type
|
||||
ref :: ir.ref
|
||||
|
||||
type_void :: ir.type_void
|
||||
type_int :: ir.type_int
|
||||
type_float :: ir.type_float
|
||||
type_vector :: ir.type_vector
|
||||
type_pointer :: ir.type_pointer
|
||||
|
||||
// =============================================================================
|
||||
// SECTION: Physical format (SPIR-V spec §2.3 -- the 32-bit word stream)
|
||||
// =============================================================================
|
||||
|
||||
// SPIR-V is a stream of 32-bit words in the module's declared endianness.
|
||||
Word :: u32
|
||||
|
||||
// The first word of every module.
|
||||
MAGIC :: u32(0x0723_0203)
|
||||
|
||||
// Version word layout: 0x00 <major> <minor> 0x00.
|
||||
@(require_results)
|
||||
version :: #force_inline proc "contextless" (major, minor: u8) -> u32 {
|
||||
return (u32(major) << 16) | (u32(minor) << 8)
|
||||
}
|
||||
|
||||
VERSION_1_0 :: u32(0x0001_0000)
|
||||
VERSION_1_1 :: u32(0x0001_0100)
|
||||
VERSION_1_2 :: u32(0x0001_0200)
|
||||
VERSION_1_3 :: u32(0x0001_0300)
|
||||
VERSION_1_4 :: u32(0x0001_0400)
|
||||
VERSION_1_5 :: u32(0x0001_0500)
|
||||
VERSION_1_6 :: u32(0x0001_0600)
|
||||
|
||||
// Generator's magic number, registered in the SPIR-V Registry. 0 = unregistered.
|
||||
GENERATOR :: u32(0)
|
||||
|
||||
// The 5-word module header that precedes the instruction stream.
|
||||
Header :: struct {
|
||||
magic: u32, // == MAGIC
|
||||
version: u32, // see version()
|
||||
generator: u32,
|
||||
bound: u32, // exclusive upper bound on every <id> (i.e. max id + 1)
|
||||
schema: u32, // reserved; 0
|
||||
}
|
||||
#assert(size_of(Header) == 20)
|
||||
|
||||
HEADER_WORDS :: 5
|
||||
|
||||
// An instruction's first word packs its total word count (including this word)
|
||||
// in the high 16 bits and the opcode in the low 16.
|
||||
@(require_results) inst_word_count :: #force_inline proc "contextless" (w: u32) -> u32 { return w >> 16 }
|
||||
@(require_results) inst_opcode :: #force_inline proc "contextless" (w: u32) -> u16 { return u16(w & 0xFFFF) }
|
||||
@(require_results) inst_head :: #force_inline proc "contextless" (word_count: u32, opcode: Opcode) -> u32 {
|
||||
return (word_count << 16) | u32(u16(opcode))
|
||||
}
|
||||
221
core/rexcode/ir/spirv/tablegen/gen.odin
Normal file
221
core/rexcode/ir/spirv/tablegen/gen.odin
Normal file
@@ -0,0 +1,221 @@
|
||||
// rexcode · Brendan Punsky (dotbmp@github), original author
|
||||
|
||||
// SPIR-V table generator. Reads the vendored authoritative grammar
|
||||
// (spirv.core.grammar.json, Khronos SPIRV-Headers unified1) and emits the
|
||||
// package's generated Odin tables. The SPIR-V analog of an ISA tablegen: the
|
||||
// grammar JSON is the single source of truth, as an arch's ENCODING_TABLE is.
|
||||
//
|
||||
// odin run core/rexcode/ir/spirv/tablegen # regenerate ../opcodes.odin + ../operand_kinds.odin
|
||||
package rexcode_spirv_tablegen
|
||||
|
||||
import "core:encoding/json"
|
||||
import "core:os"
|
||||
import "core:fmt"
|
||||
import "core:strings"
|
||||
import "core:strconv"
|
||||
|
||||
GRAMMAR_PATH :: #directory + "/spirv.core.grammar.json"
|
||||
OPCODES_OUT :: #directory + "/../opcodes.odin"
|
||||
KINDS_OUT :: #directory + "/../operand_kinds.odin"
|
||||
|
||||
HDR ::
|
||||
`// rexcode · Brendan Punsky (dotbmp@github), original author
|
||||
|
||||
package rexcode_spirv
|
||||
|
||||
// GENERATED from spirv.core.grammar.json (SPIRV-Headers unified1) by tablegen/gen.odin.
|
||||
// DO NOT EDIT -- regenerate with ` + "`odin run core/rexcode/ir/spirv/tablegen`" + `.
|
||||
`
|
||||
|
||||
main :: proc() {
|
||||
data, rerr := os.read_entire_file(GRAMMAR_PATH, context.allocator)
|
||||
if rerr != nil {
|
||||
fmt.eprintln("spirv tablegen: cannot read", GRAMMAR_PATH, rerr)
|
||||
os.exit(1)
|
||||
}
|
||||
defer delete(data)
|
||||
|
||||
root, err := json.parse(data, parse_integers = true)
|
||||
if err != .None {
|
||||
fmt.eprintln("spirv tablegen: json parse error:", err)
|
||||
os.exit(1)
|
||||
}
|
||||
defer json.destroy_value(root)
|
||||
|
||||
g := root.(json.Object)
|
||||
n_op := gen_opcodes(g["instructions"].(json.Array))
|
||||
n_k := gen_operand_kinds(g["operand_kinds"].(json.Array))
|
||||
fmt.printfln("spirv tablegen: %d opcodes, %d operand kinds", n_op, n_k)
|
||||
}
|
||||
|
||||
write_file :: proc(path: string, sb: ^strings.Builder) {
|
||||
if werr := os.write_entire_file(path, sb.buf[:]); werr != nil {
|
||||
fmt.eprintln("spirv tablegen: write failed:", path, werr)
|
||||
os.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// --- opcodes.odin : the Opcode enum (deduped by opcode; the grammar lists
|
||||
// aliased opnames sharing an opcode, e.g. *GOOGLE == *KHR -- first wins). ---
|
||||
gen_opcodes :: proc(insts: json.Array) -> int {
|
||||
Row :: struct { name: string, op: i64 }
|
||||
rows: [dynamic]Row; defer delete(rows)
|
||||
seen: map[i64]bool; defer delete(seen)
|
||||
w := 0
|
||||
for v in insts {
|
||||
inst := v.(json.Object)
|
||||
op := i64(inst["opcode"].(json.Integer))
|
||||
if op in seen { continue }
|
||||
seen[op] = true
|
||||
name := string(inst["opname"].(json.String))
|
||||
append(&rows, Row{name, op})
|
||||
w = max(w, len(name))
|
||||
}
|
||||
|
||||
sb := strings.builder_make(); defer strings.builder_destroy(&sb)
|
||||
strings.write_string(&sb, HDR)
|
||||
strings.write_string(&sb, "\n// SPIR-V operation opcodes. The values ARE the wire opcodes; the codec writes\n// them directly. OpNop = 0 doubles as the zero value (a benign no-op).\nOpcode :: enum u16 {\n")
|
||||
for r in rows {
|
||||
strings.write_byte(&sb, '\t')
|
||||
strings.write_string(&sb, r.name)
|
||||
for _ in 0 ..< w - len(r.name) { strings.write_byte(&sb, ' ') }
|
||||
fmt.sbprintf(&sb, " = %d,\n", r.op)
|
||||
}
|
||||
strings.write_string(&sb, "}\n")
|
||||
write_file(OPCODES_OUT, &sb)
|
||||
return len(rows)
|
||||
}
|
||||
|
||||
// --- operand_kinds.odin : the Spec_Kind dispatch enum + every ValueEnum (Odin
|
||||
// enum) and BitEnum (bit_set + _Bit enum). ---
|
||||
gen_operand_kinds :: proc(kinds: json.Array) -> int {
|
||||
sb := strings.builder_make(); defer strings.builder_destroy(&sb)
|
||||
strings.write_string(&sb, HDR)
|
||||
|
||||
strings.write_string(&sb, "\n// Every operand kind the codec dispatches on (Id / Literal / Composite / each\n// ValueEnum / each BitEnum), in grammar order. Named Spec_Kind to avoid colliding\n// with the re-exported ir.Operand_Kind; the operand-layout table tags each\n// operand with one of these.\nSpec_Kind :: enum u8 {\n\tNONE = 0,\n")
|
||||
for v in kinds {
|
||||
k := v.(json.Object)
|
||||
fmt.sbprintf(&sb, "\t%s,\n", string(k["kind"].(json.String)))
|
||||
}
|
||||
strings.write_string(&sb, "}\n")
|
||||
|
||||
for v in kinds {
|
||||
k := v.(json.Object)
|
||||
cat := string(k["category"].(json.String))
|
||||
kind := string(k["kind"].(json.String))
|
||||
switch cat {
|
||||
case "ValueEnum": gen_value_enum(&sb, snake(kind), k)
|
||||
case "BitEnum": gen_bit_enum(&sb, snake(kind), k)
|
||||
}
|
||||
}
|
||||
write_file(KINDS_OUT, &sb)
|
||||
return len(kinds)
|
||||
}
|
||||
|
||||
gen_value_enum :: proc(sb: ^strings.Builder, name: string, k: json.Object) {
|
||||
Row :: struct { nm: string, val: i64 }
|
||||
rows: [dynamic]Row; defer delete(rows)
|
||||
seen: map[i64]bool; defer delete(seen)
|
||||
w := 0
|
||||
if ens, ok := k["enumerants"]; ok {
|
||||
for ev in ens.(json.Array) {
|
||||
e := ev.(json.Object)
|
||||
val := parse_value(e["value"])
|
||||
if val in seen { continue } // dedup aliases (same value, first name)
|
||||
seen[val] = true
|
||||
nm := ident(string(e["enumerant"].(json.String)))
|
||||
append(&rows, Row{nm, val}); w = max(w, len(nm))
|
||||
}
|
||||
}
|
||||
fmt.sbprintf(sb, "\n%s :: enum u32 {{\n", name)
|
||||
for r in rows {
|
||||
strings.write_byte(sb, '\t')
|
||||
strings.write_string(sb, r.nm)
|
||||
for _ in 0 ..< w - len(r.nm) { strings.write_byte(sb, ' ') }
|
||||
fmt.sbprintf(sb, " = %d,\n", r.val)
|
||||
}
|
||||
strings.write_string(sb, "}\n")
|
||||
}
|
||||
|
||||
gen_bit_enum :: proc(sb: ^strings.Builder, name: string, k: json.Object) {
|
||||
Row :: struct { nm: string, pos: int }
|
||||
rows: [dynamic]Row; defer delete(rows)
|
||||
seen: map[int]bool; defer delete(seen)
|
||||
w, maxpos := 0, 0
|
||||
if ens, ok := k["enumerants"]; ok {
|
||||
for ev in ens.(json.Array) {
|
||||
e := ev.(json.Object)
|
||||
mask := parse_value(e["value"])
|
||||
if mask == 0 || mask & (mask - 1) != 0 { continue } // skip None / non-single-bit
|
||||
pos := bit_pos(mask)
|
||||
if pos in seen { continue }
|
||||
seen[pos] = true
|
||||
nm := ident(string(e["enumerant"].(json.String)))
|
||||
append(&rows, Row{nm, pos}); w = max(w, len(nm)); maxpos = max(maxpos, pos)
|
||||
}
|
||||
}
|
||||
backing := maxpos >= 32 ? "u64" : "u32"
|
||||
fmt.sbprintf(sb, "\n%s :: bit_set[%s_Bit; %s]\n", name, name, backing)
|
||||
fmt.sbprintf(sb, "%s_Bit :: enum %s {{\n", name, backing)
|
||||
for r in rows {
|
||||
strings.write_byte(sb, '\t')
|
||||
strings.write_string(sb, r.nm)
|
||||
for _ in 0 ..< w - len(r.nm) { strings.write_byte(sb, ' ') }
|
||||
fmt.sbprintf(sb, " = %d,\n", r.pos)
|
||||
}
|
||||
strings.write_string(sb, "}\n")
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// helpers
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
is_upper :: proc(c: u8) -> bool { return c >= 'A' && c <= 'Z' }
|
||||
is_lower :: proc(c: u8) -> bool { return c >= 'a' && c <= 'z' }
|
||||
is_digit :: proc(c: u8) -> bool { return c >= '0' && c <= '9' }
|
||||
is_alnum :: proc(c: u8) -> bool { return is_upper(c) || is_lower(c) || is_digit(c) }
|
||||
|
||||
// CamelCase grammar kind -> Snake_Case Odin type name (AddressingModel ->
|
||||
// Addressing_Model, FPRoundingMode -> FP_Rounding_Mode), preserving acronym runs.
|
||||
snake :: proc(name: string) -> string {
|
||||
sb := strings.builder_make()
|
||||
for i in 0 ..< len(name) {
|
||||
c := name[i]
|
||||
if i > 0 && is_upper(c) {
|
||||
prev := name[i - 1]
|
||||
next_lower := i + 1 < len(name) && is_lower(name[i + 1])
|
||||
if is_lower(prev) || is_digit(prev) || (is_upper(prev) && next_lower) {
|
||||
strings.write_byte(&sb, '_')
|
||||
}
|
||||
}
|
||||
strings.write_byte(&sb, c)
|
||||
}
|
||||
return strings.to_string(sb)
|
||||
}
|
||||
|
||||
// A valid Odin enumerant identifier (SPIR-V enumerants are already valid; guard
|
||||
// the rare leading digit / stray punctuation anyway).
|
||||
ident :: proc(name: string) -> string {
|
||||
sb := strings.builder_make()
|
||||
if len(name) > 0 && is_digit(name[0]) { strings.write_byte(&sb, '_') }
|
||||
for i in 0 ..< len(name) {
|
||||
c := name[i]
|
||||
strings.write_byte(&sb, (is_alnum(c) || c == '_') ? c : '_')
|
||||
}
|
||||
return strings.to_string(sb)
|
||||
}
|
||||
|
||||
bit_pos :: proc(mask: i64) -> int {
|
||||
p, m := 0, mask
|
||||
for m > 1 { m >>= 1; p += 1 }
|
||||
return p
|
||||
}
|
||||
|
||||
// An enumerant value is either a JSON integer or a hex string ("0x0001").
|
||||
parse_value :: proc(v: json.Value) -> i64 {
|
||||
#partial switch x in v {
|
||||
case json.Integer: return i64(x)
|
||||
case json.String: n, _ := strconv.parse_i64(string(x)); return n
|
||||
}
|
||||
return 0
|
||||
}
|
||||
19499
core/rexcode/ir/spirv/tablegen/spirv.core.grammar.json
Normal file
19499
core/rexcode/ir/spirv/tablegen/spirv.core.grammar.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user