Commit b40d6ac9 by John Kessenich

glslang AST -> SPIR-V: Move to new auto-generated official headers, and for the…

glslang AST -> SPIR-V: Move to new auto-generated official headers, and for the disassembler, mirror the split done between the auto-generation header database and the specification. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@30434 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent 1f77cacd
......@@ -124,7 +124,7 @@ enum Entrypoints {
inline void GetDebugNames(const char** names)
{
for (int i = 0; i < Count; ++i)
names[i] = "unknown";
names[i] = "Unknown";
names[Round] = "round";
names[RoundEven] = "roundEven";
......
......@@ -134,15 +134,15 @@ protected:
spv::ExecutionModel TranslateExecutionModel(EShLanguage stage)
{
switch (stage) {
case EShLangVertex: return spv::ModelVertex;
case EShLangTessControl: return spv::ModelTessellationControl;
case EShLangTessEvaluation: return spv::ModelTessellationEvaluation;
case EShLangGeometry: return spv::ModelGeometry;
case EShLangFragment: return spv::ModelFragment;
case EShLangCompute: return spv::ModelGLCompute;
case EShLangVertex: return spv::ExecutionModelVertex;
case EShLangTessControl: return spv::ExecutionModelTessellationControl;
case EShLangTessEvaluation: return spv::ExecutionModelTessellationEvaluation;
case EShLangGeometry: return spv::ExecutionModelGeometry;
case EShLangFragment: return spv::ExecutionModelFragment;
case EShLangCompute: return spv::ExecutionModelGLCompute;
default:
spv::MissingFunctionality("GLSL stage");
return spv::ModelFragment;
return spv::ExecutionModelFragment;
}
}
......@@ -150,30 +150,30 @@ spv::ExecutionModel TranslateExecutionModel(EShLanguage stage)
spv::StorageClass TranslateStorageClass(const glslang::TType& type)
{
if (type.getQualifier().isPipeInput())
return spv::StorageInput;
return spv::StorageClassInput;
else if (type.getQualifier().isPipeOutput())
return spv::StorageOutput;
return spv::StorageClassOutput;
else if (type.getQualifier().isUniformOrBuffer()) {
if (type.getBasicType() == glslang::EbtBlock)
return spv::StorageUniform;
return spv::StorageClassUniform;
else
return spv::StorageConstantUniform;
return spv::StorageClassUniformConstant;
// TODO: how are we distuingishing between default and non-default non-writable uniforms? Do default uniforms even exist?
} else {
switch (type.getQualifier().storage) {
case glslang::EvqShared: return spv::StorageWorkgroupLocal; break;
case glslang::EvqGlobal: return spv::StoragePrivateGlobal;
case glslang::EvqConstReadOnly: return spv::StorageFunction;
case glslang::EvqTemporary: return spv::StorageFunction;
case glslang::EvqShared: return spv::StorageClassWorkgroupLocal; break;
case glslang::EvqGlobal: return spv::StorageClassPrivateGlobal;
case glslang::EvqConstReadOnly: return spv::StorageClassFunction;
case glslang::EvqTemporary: return spv::StorageClassFunction;
default:
spv::MissingFunctionality("unknown glslang storage class");
return spv::StorageCount;
return spv::StorageClassFunction;
}
}
}
// Translate glslang sampler type to SPIR-V dimensionality.
spv::Dimensionality TranslateDimensionality(const glslang::TSampler& sampler)
spv::Dim TranslateDimensionality(const glslang::TSampler& sampler)
{
switch (sampler.dim) {
case glslang::Esd1D: return spv::Dim1D;
......@@ -192,10 +192,11 @@ spv::Dimensionality TranslateDimensionality(const glslang::TSampler& sampler)
spv::Decoration TranslatePrecisionDecoration(const glslang::TType& type)
{
switch (type.getQualifier().precision) {
case glslang::EpqLow: return spv::DecPrecisionLow;
case glslang::EpqMedium: return spv::DecPrecisionMedium;
case glslang::EpqHigh: return spv::DecPrecisionHigh;
default: return spv::DecCount;
case glslang::EpqLow: return spv::DecorationPrecisionLow;
case glslang::EpqMedium: return spv::DecorationPrecisionMedium;
case glslang::EpqHigh: return spv::DecorationPrecisionHigh;
default:
return spv::NoPrecision;
}
}
......@@ -204,17 +205,17 @@ spv::Decoration TranslateBlockDecoration(const glslang::TType& type)
{
if (type.getBasicType() == glslang::EbtBlock) {
switch (type.getQualifier().storage) {
case glslang::EvqUniform: return spv::DecBlock;
case glslang::EvqBuffer: return spv::DecBufferBlock;
case glslang::EvqVaryingIn: return spv::DecBlock;
case glslang::EvqVaryingOut: return spv::DecBlock;
case glslang::EvqUniform: return spv::DecorationBlock;
case glslang::EvqBuffer: return spv::DecorationBufferBlock;
case glslang::EvqVaryingIn: return spv::DecorationBlock;
case glslang::EvqVaryingOut: return spv::DecorationBlock;
default:
spv::MissingFunctionality("kind of block");
break;
}
}
return spv::DecCount;
return (spv::Decoration)spv::BadValue;
}
// Translate glslang type to SPIR-V layout decorations.
......@@ -223,36 +224,36 @@ spv::Decoration TranslateLayoutDecoration(const glslang::TType& type)
if (type.isMatrix()) {
switch (type.getQualifier().layoutMatrix) {
case glslang::ElmRowMajor:
return spv::DecRowMajor;
return spv::DecorationRowMajor;
default:
return spv::DecColMajor;
return spv::DecorationColMajor;
}
} else {
switch (type.getBasicType()) {
default:
return spv::DecCount;
return (spv::Decoration)spv::BadValue;
break;
case glslang::EbtBlock:
switch (type.getQualifier().storage) {
case glslang::EvqUniform:
case glslang::EvqBuffer:
switch (type.getQualifier().layoutPacking) {
case glslang::ElpShared: return spv::DecGLSLShared;
case glslang::ElpStd140: return spv::DecGLSLStd140;
case glslang::ElpStd430: return spv::DecGLSLStd430;
case glslang::ElpPacked: return spv::DecGLSLPacked;
case glslang::ElpShared: return spv::DecorationGLSLShared;
case glslang::ElpStd140: return spv::DecorationGLSLStd140;
case glslang::ElpStd430: return spv::DecorationGLSLStd430;
case glslang::ElpPacked: return spv::DecorationGLSLPacked;
default:
spv::MissingFunctionality("uniform block layout");
return spv::DecGLSLShared;
return spv::DecorationGLSLShared;
}
case glslang::EvqVaryingIn:
case glslang::EvqVaryingOut:
if (type.getQualifier().layoutPacking != glslang::ElpNone)
spv::MissingFunctionality("in/out block layout");
return spv::DecCount;
return (spv::Decoration)spv::BadValue;
default:
spv::MissingFunctionality("block storage qualification");
return spv::DecCount;
return (spv::Decoration)spv::BadValue;
}
}
}
......@@ -262,28 +263,28 @@ spv::Decoration TranslateLayoutDecoration(const glslang::TType& type)
spv::Decoration TranslateInterpolationDecoration(const glslang::TType& type)
{
if (type.getQualifier().smooth)
return spv::DecSmooth;
return spv::DecorationSmooth;
if (type.getQualifier().nopersp)
return spv::DecNoperspective;
return spv::DecorationNoperspective;
else if (type.getQualifier().patch)
return spv::DecPatch;
return spv::DecorationPatch;
else if (type.getQualifier().flat)
return spv::DecFlat;
return spv::DecorationFlat;
else if (type.getQualifier().centroid)
return spv::DecCentroid;
return spv::DecorationCentroid;
else if (type.getQualifier().sample)
return spv::DecSample;
return spv::DecorationSample;
else
return spv::DecCount;
return (spv::Decoration)spv::BadValue;
}
// If glslang type is invaraiant, return SPIR-V invariant decoration.
spv::Decoration TranslateInvariantDecoration(const glslang::TType& type)
{
if (type.getQualifier().invariant)
return spv::DecInvariant;
return spv::DecorationInvariant;
else
return spv::DecCount;
return (spv::Decoration)spv::BadValue;
}
// Identify what SPIR-V built-in variable a symbol is.
......@@ -312,7 +313,7 @@ spv::BuiltIn TranslateBuiltIn(const glslang::TIntermSymbol* node)
{
const glslang::TString& name = node->getName();
if (name.compare(0, 3, "gl_") != 0)
return spv::BuiltInCount;
return (spv::BuiltIn)spv::BadValue;
switch (node->getQualifier().storage) {
case glslang::EvqPosition: return spv::BuiltInPosition;
......@@ -325,7 +326,7 @@ spv::BuiltIn TranslateBuiltIn(const glslang::TIntermSymbol* node)
case glslang::EvqFace: return spv::BuiltInFrontFacing;
case glslang::EvqFragColor: return spv::BuiltInFragColor;
case glslang::EvqFragDepth: return spv::BuiltInFragDepth;
default: return spv::BuiltInCount;
default: return (spv::BuiltIn)spv::BadValue;
if (name == "gl_ClipDistance")
return spv::BuiltInClipDistance;
else if (name == "gl_PrimitiveID" || name == "gl_PrimitiveIDIn")
......@@ -380,9 +381,9 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
spv::ExecutionModel executionModel = TranslateExecutionModel(glslangIntermediate->getStage());
builder.clearAccessChain();
builder.setSource(spv::LangGLSL, glslangIntermediate->getVersion());
builder.setSource(spv::SourceLanguageGLSL, glslangIntermediate->getVersion());
stdBuiltins = builder.import("GLSL.std.450");
builder.setMemoryModel(spv::AddressingLogical, spv::MemoryGLSL450);
builder.setMemoryModel(spv::AddressingModelLogical, spv::MemoryModelGLSL450);
shaderEntry = builder.makeMain();
builder.addEntryPoint(executionModel, shaderEntry);
......@@ -394,7 +395,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
// Add the top-level modes for this shader.
if (glslangIntermediate->getXfbMode())
builder.addExecutionMode(shaderEntry, spv::ExecutionXfb);
builder.addExecutionMode(shaderEntry, spv::ExecutionModeXfb);
spv::ExecutionMode mode;
switch (glslangIntermediate->getStage()) {
......@@ -402,17 +403,17 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
break;
case EShLangTessControl:
builder.addExecutionMode(shaderEntry, spv::ExecutionOutputVertices, glslangIntermediate->getVertices());
builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputVertices, glslangIntermediate->getVertices());
break;
case EShLangTessEvaluation:
switch (glslangIntermediate->getInputPrimitive()) {
case glslang::ElgTriangles: mode = spv::ExecutionInputTriangles; break;
case glslang::ElgQuads: mode = spv::ExecutionInputQuads; break;
case glslang::ElgIsolines: mode = spv::ExecutionInputIsolines; break;
default: mode = spv::ExecutionModeCount; break;
case glslang::ElgTriangles: mode = spv::ExecutionModeInputTriangles; break;
case glslang::ElgQuads: mode = spv::ExecutionModeInputQuads; break;
case glslang::ElgIsolines: mode = spv::ExecutionModeInputIsolines; break;
default: mode = (spv::ExecutionMode)spv::BadValue; break;
}
if (mode != spv::ExecutionModeCount)
if (mode != spv::BadValue)
builder.addExecutionMode(shaderEntry, mode);
// TODO
......@@ -423,33 +424,33 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
case EShLangGeometry:
switch (glslangIntermediate->getInputPrimitive()) {
case glslang::ElgPoints: mode = spv::ExecutionInputPoints; break;
case glslang::ElgLines: mode = spv::ExecutionInputLines; break;
case glslang::ElgLinesAdjacency: mode = spv::ExecutionInputLinesAdjacency; break;
case glslang::ElgTriangles: mode = spv::ExecutionInputTriangles; break;
case glslang::ElgTrianglesAdjacency: mode = spv::ExecutionInputTrianglesAdjacency; break;
default: mode = spv::ExecutionModeCount; break;
case glslang::ElgPoints: mode = spv::ExecutionModeInputPoints; break;
case glslang::ElgLines: mode = spv::ExecutionModeInputLines; break;
case glslang::ElgLinesAdjacency: mode = spv::ExecutionModeInputLinesAdjacency; break;
case glslang::ElgTriangles: mode = spv::ExecutionModeInputTriangles; break;
case glslang::ElgTrianglesAdjacency: mode = spv::ExecutionModeInputTrianglesAdjacency; break;
default: mode = (spv::ExecutionMode)spv::BadValue; break;
}
if (mode != spv::ExecutionModeCount)
if (mode != spv::BadValue)
builder.addExecutionMode(shaderEntry, mode);
builder.addExecutionMode(shaderEntry, spv::ExecutionInvocations, glslangIntermediate->getInvocations());
builder.addExecutionMode(shaderEntry, spv::ExecutionModeInvocations, glslangIntermediate->getInvocations());
switch (glslangIntermediate->getOutputPrimitive()) {
case glslang::ElgPoints: mode = spv::ExecutionOutputPoints; break;
case glslang::ElgLineStrip: mode = spv::ExecutionOutputLineStrip; break;
case glslang::ElgTriangleStrip: mode = spv::ExecutionOutputTriangleStrip; break;
default: mode = spv::ExecutionModeCount; break;
case glslang::ElgPoints: mode = spv::ExecutionModeOutputPoints; break;
case glslang::ElgLineStrip: mode = spv::ExecutionModeOutputLineStrip; break;
case glslang::ElgTriangleStrip: mode = spv::ExecutionModeOutputTriangleStrip; break;
default: mode = (spv::ExecutionMode)spv::BadValue; break;
}
if (mode != spv::ExecutionModeCount)
if (mode != spv::BadValue)
builder.addExecutionMode(shaderEntry, mode);
builder.addExecutionMode(shaderEntry, spv::ExecutionOutputVertices, glslangIntermediate->getVertices());
builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputVertices, glslangIntermediate->getVertices());
break;
case EShLangFragment:
if (glslangIntermediate->getPixelCenterInteger())
builder.addExecutionMode(shaderEntry, spv::ExecutionPixelCenterInteger);
builder.addExecutionMode(shaderEntry, spv::ExecutionModePixelCenterInteger);
if (glslangIntermediate->getOriginUpperLeft())
builder.addExecutionMode(shaderEntry, spv::ExecutionOriginUpperLeft);
builder.addExecutionMode(shaderEntry, spv::ExecutionModeOriginUpperLeft);
break;
case EShLangCompute:
......@@ -1075,14 +1076,14 @@ bool TGlslangToSpvTraverser::visitSelection(glslang::TVisit /* visit */, glslang
if (node->getBasicType() != glslang::EbtVoid) {
// don't handle this as just on-the-fly temporaries, because there will be two names
// and better to leave SSA to later passes
result = builder.createVariable(spv::StorageFunction, convertGlslangToSpvType(node->getType()));
result = builder.createVariable(spv::StorageClassFunction, convertGlslangToSpvType(node->getType()));
}
// emit the condition before doing anything with selection
node->getCondition()->traverse(this);
// make an "if" based on the value created by the condition
spv::Builder::If ifBuilder(builder.accessChainLoad(spv::DecCount), builder);
spv::Builder::If ifBuilder(builder.accessChainLoad(spv::NoPrecision), builder);
if (node->getTrueBlock()) {
// emit the "then" statement
......@@ -1266,8 +1267,8 @@ spv::Id TGlslangToSpvTraverser::createSpvVariable(const glslang::TIntermSymbol*
if (glslang::IsAnonymous(name))
name = "";
if (storageClass == spv::StorageCount)
return builder.createVariable(spv::StorageFunction, spvType, name);
if (storageClass == spv::BadValue)
return builder.createVariable(spv::StorageClassFunction, spvType, name);
else
return builder.createVariable(storageClass, spvType, name);
}
......@@ -1366,11 +1367,11 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
addMemberDecoration(spvType, member, TranslateInterpolationDecoration(glslangType));
addMemberDecoration(spvType, member, TranslateInvariantDecoration(glslangType));
if (glslangType.getQualifier().hasLocation())
builder.addMemberDecoration(spvType, member, spv::DecLocation, glslangType.getQualifier().layoutLocation);
builder.addMemberDecoration(spvType, member, spv::DecorationLocation, glslangType.getQualifier().layoutLocation);
if (glslangType.getQualifier().hasComponent())
builder.addMemberDecoration(spvType, member, spv::DecComponent, glslangType.getQualifier().layoutComponent);
builder.addMemberDecoration(spvType, member, spv::DecorationComponent, glslangType.getQualifier().layoutComponent);
if (glslangType.getQualifier().hasXfbOffset())
builder.addMemberDecoration(spvType, member, spv::DecOffset, glslangType.getQualifier().layoutXfbOffset);
builder.addMemberDecoration(spvType, member, spv::DecorationOffset, glslangType.getQualifier().layoutXfbOffset);
}
}
......@@ -1378,12 +1379,12 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
addDecoration(spvType, TranslateLayoutDecoration(type));
addDecoration(spvType, TranslateBlockDecoration(type));
if (type.getQualifier().hasStream())
builder.addDecoration(spvType, spv::DecStream, type.getQualifier().layoutStream);
builder.addDecoration(spvType, spv::DecorationStream, type.getQualifier().layoutStream);
if (glslangIntermediate->getXfbMode()) {
if (type.getQualifier().hasXfbStride())
builder.addDecoration(spvType, spv::DecStride, type.getQualifier().layoutXfbStride);
builder.addDecoration(spvType, spv::DecorationStride, type.getQualifier().layoutXfbStride);
if (type.getQualifier().hasXfbBuffer())
builder.addDecoration(spvType, spv::DecXfbBuffer, type.getQualifier().layoutXfbBuffer);
builder.addDecoration(spvType, spv::DecorationXfbBuffer, type.getQualifier().layoutXfbBuffer);
}
}
break;
......@@ -1448,7 +1449,7 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
const glslang::TType& paramType = parameters[p]->getAsTyped()->getType();
spv::Id typeId = convertGlslangToSpvType(paramType);
if (paramType.getQualifier().storage != glslang::EvqConstReadOnly)
typeId = builder.makePointer(spv::StorageFunction, typeId);
typeId = builder.makePointer(spv::StorageClassFunction, typeId);
else
constReadOnlyParameters.insert(parameters[p]->getAsSymbolNode()->getId());
paramTypes.push_back(typeId);
......@@ -1674,11 +1675,11 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
if (qualifiers[a] != glslang::EvqConstReadOnly) {
// need space to hold the copy
const glslang::TType& paramType = glslangArgs[a]->getAsTyped()->getType();
arg = builder.createVariable(spv::StorageFunction, convertGlslangToSpvType(paramType), "param");
arg = builder.createVariable(spv::StorageClassFunction, convertGlslangToSpvType(paramType), "param");
if (qualifiers[a] == glslang::EvqIn || qualifiers[a] == glslang::EvqInOut) {
// need to copy the input into output space
builder.setAccessChain(lValues[lValueCount]);
spv::Id copy = builder.accessChainLoad(spv::DecCount); // TODO: get precision
spv::Id copy = builder.accessChainLoad(spv::NoPrecision); // TODO: get precision
builder.createStore(copy, arg);
}
++lValueCount;
......@@ -1715,7 +1716,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv
bool isUnsigned = typeProxy == glslang::EbtUint;
bool isFloat = typeProxy == glslang::EbtFloat || typeProxy == glslang::EbtDouble;
spv::OpCode binOp = spv::OpNop;
spv::Op binOp = spv::OpNop;
bool needsPromotion = true;
bool comparison = false;
......@@ -1943,7 +1944,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv
spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, spv::Id operand, bool isFloat)
{
spv::OpCode unaryOp = spv::OpNop;
spv::Op unaryOp = spv::OpNop;
int libCall = -1;
switch (op) {
......@@ -2158,7 +2159,7 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, spv::Decoration precision, spv::Id destType, spv::Id operand)
{
spv::OpCode convOp = spv::OpNop;
spv::Op convOp = spv::OpNop;
spv::Id zero;
spv::Id one;
......@@ -2265,7 +2266,7 @@ spv::Id TGlslangToSpvTraverser::makeSmearedConstant(spv::Id constant, int vector
spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, std::vector<spv::Id>& operands, bool isUnsigned)
{
spv::OpCode opCode = spv::OpNop;
spv::Op opCode = spv::OpNop;
int libCall = -1;
switch (op) {
......@@ -2371,19 +2372,19 @@ spv::Id TGlslangToSpvTraverser::createNoArgOperation(glslang::TOperator op)
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsAllMemory);
return 0;
case glslang::EOpMemoryBarrierAtomicCounter:
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsAtomicCounter);
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsAtomicCounterMemoryMask);
return 0;
case glslang::EOpMemoryBarrierBuffer:
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsUniform);
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsUniformMemoryMask);
return 0;
case glslang::EOpMemoryBarrierImage:
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsImage);
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsImageMemoryMask);
return 0;
case glslang::EOpMemoryBarrierShared:
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsWorkgroupLocal);
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsWorkgroupLocalMemoryMask);
return 0;
case glslang::EOpGroupMemoryBarrier:
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsWorkgroupGlobal);
builder.createMemoryBarrier(spv::ExecutionScopeDevice, spv::MemorySemanticsWorkgroupGlobalMemoryMask);
return 0;
default:
spv::MissingFunctionality("operation with no arguments");
......@@ -2409,53 +2410,53 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
addDecoration(id, TranslatePrecisionDecoration(symbol->getType()));
addDecoration(id, TranslateInterpolationDecoration(symbol->getType()));
if (symbol->getQualifier().hasLocation())
builder.addDecoration(id, spv::DecLocation, symbol->getQualifier().layoutLocation);
builder.addDecoration(id, spv::DecorationLocation, symbol->getQualifier().layoutLocation);
if (symbol->getQualifier().hasComponent())
builder.addDecoration(id, spv::DecComponent, symbol->getQualifier().layoutComponent);
builder.addDecoration(id, spv::DecorationComponent, symbol->getQualifier().layoutComponent);
if (glslangIntermediate->getXfbMode()) {
if (symbol->getQualifier().hasXfbStride())
builder.addDecoration(id, spv::DecStride, symbol->getQualifier().layoutXfbStride);
builder.addDecoration(id, spv::DecorationStride, symbol->getQualifier().layoutXfbStride);
if (symbol->getQualifier().hasXfbBuffer())
builder.addDecoration(id, spv::DecXfbBuffer, symbol->getQualifier().layoutXfbBuffer);
builder.addDecoration(id, spv::DecorationXfbBuffer, symbol->getQualifier().layoutXfbBuffer);
if (symbol->getQualifier().hasXfbOffset())
builder.addDecoration(id, spv::DecOffset, symbol->getQualifier().layoutXfbOffset);
builder.addDecoration(id, spv::DecorationOffset, symbol->getQualifier().layoutXfbOffset);
}
}
addDecoration(id, TranslateInvariantDecoration(symbol->getType()));
if (symbol->getQualifier().hasStream())
builder.addDecoration(id, spv::DecStream, symbol->getQualifier().layoutStream);
builder.addDecoration(id, spv::DecorationStream, symbol->getQualifier().layoutStream);
if (symbol->getQualifier().hasSet())
builder.addDecoration(id, spv::DecDescriptorSet, symbol->getQualifier().layoutSet);
builder.addDecoration(id, spv::DecorationDescriptorSet, symbol->getQualifier().layoutSet);
if (symbol->getQualifier().hasBinding())
builder.addDecoration(id, spv::DecBinding, symbol->getQualifier().layoutBinding);
builder.addDecoration(id, spv::DecorationBinding, symbol->getQualifier().layoutBinding);
if (glslangIntermediate->getXfbMode()) {
if (symbol->getQualifier().hasXfbStride())
builder.addDecoration(id, spv::DecStride, symbol->getQualifier().layoutXfbStride);
builder.addDecoration(id, spv::DecorationStride, symbol->getQualifier().layoutXfbStride);
if (symbol->getQualifier().hasXfbBuffer())
builder.addDecoration(id, spv::DecXfbBuffer, symbol->getQualifier().layoutXfbBuffer);
builder.addDecoration(id, spv::DecorationXfbBuffer, symbol->getQualifier().layoutXfbBuffer);
}
// built-in variable decorations
int num = TranslateBuiltInDecoration(*symbol);
if (num >= 0)
builder.addDecoration(id, spv::DecBuiltIn, num);
builder.addDecoration(id, spv::DecorationBuiltIn, num);
if (linkageOnly)
builder.addDecoration(id, spv::DecNoStaticUse);
builder.addDecoration(id, spv::DecorationNoStaticUse);
return id;
}
void TGlslangToSpvTraverser::addDecoration(spv::Id id, spv::Decoration dec)
{
if (dec != spv::DecCount)
if (dec != spv::BadValue)
builder.addDecoration(id, dec);
}
void TGlslangToSpvTraverser::addMemberDecoration(spv::Id id, int member, spv::Decoration dec)
{
if (dec != spv::DecCount)
if (dec != spv::BadValue)
builder.addMemberDecoration(id, (unsigned)member, dec);
}
......
......@@ -56,10 +56,10 @@ namespace spv {
const int SpvBuilderMagic = 0xBB;
Builder::Builder(unsigned int userNumber) :
source(LangUnknown),
source(SourceLanguageUnknown),
sourceVersion(0),
addressModel(AddressingLogical),
memoryModel(MemoryGLSL450),
addressModel(AddressingModelLogical),
memoryModel(MemoryModelGLSL450),
builderNumber(userNumber << 16 | SpvBuilderMagic),
buildPoint(0),
uniqueId(0),
......@@ -293,7 +293,7 @@ Id Builder::makeFunctionType(Id returnType, std::vector<Id>& paramTypes)
return type->getResultId();
}
Id Builder::makeSampler(Id sampledType, Dimensionality dim, samplerContent content, bool arrayed, bool shadow, bool ms)
Id Builder::makeSampler(Id sampledType, Dim dim, samplerContent content, bool arrayed, bool shadow, bool ms)
{
// try to find it
Instruction* type;
......@@ -332,11 +332,11 @@ Id Builder::getDerefTypeId(Id resultId) const
return module.getInstruction(typeId)->getImmediateOperand(1);
}
OpCode Builder::getMostBasicTypeClass(Id typeId) const
Op Builder::getMostBasicTypeClass(Id typeId) const
{
Instruction* instr = module.getInstruction(typeId);
OpCode typeClass = instr->getOpCode();
Op typeClass = instr->getOpCode();
switch (typeClass)
{
case OpTypeVoid:
......@@ -384,7 +384,7 @@ Id Builder::getScalarTypeId(Id typeId) const
{
Instruction* instr = module.getInstruction(typeId);
OpCode typeClass = instr->getOpCode();
Op typeClass = instr->getOpCode();
switch (typeClass)
{
case OpTypeVoid:
......@@ -410,7 +410,7 @@ Id Builder::getContainedTypeId(Id typeId, int member) const
{
Instruction* instr = module.getInstruction(typeId);
OpCode typeClass = instr->getOpCode();
Op typeClass = instr->getOpCode();
switch (typeClass)
{
case OpTypeVector:
......@@ -436,7 +436,7 @@ Id Builder::getContainedTypeId(Id typeId) const
// See if a scalar constant of this type has already been created, so it
// can be reused rather than duplicated. (Required by the specification).
Id Builder::findScalarConstant(OpCode typeClass, Id typeId, unsigned value) const
Id Builder::findScalarConstant(Op typeClass, Id typeId, unsigned value) const
{
Instruction* constant;
for (int i = 0; i < (int)groupedConstants[typeClass].size(); ++i) {
......@@ -515,7 +515,7 @@ Id Builder::makeDoubleConstant(double d)
return NoResult;
}
Id Builder::findCompositeConstant(OpCode typeClass, std::vector<Id>& comps) const
Id Builder::findCompositeConstant(Op typeClass, std::vector<Id>& comps) const
{
Instruction* constant;
bool found = false;
......@@ -547,7 +547,7 @@ Id Builder::findCompositeConstant(OpCode typeClass, std::vector<Id>& comps) cons
Id Builder::makeCompositeConstant(Id typeId, std::vector<Id>& members)
{
assert(typeId);
OpCode typeClass = getTypeClass(typeId);
Op typeClass = getTypeClass(typeId);
switch (typeClass) {
case OpTypeVector:
......@@ -735,7 +735,7 @@ void Builder::leaveFunction(bool main)
if (function.getReturnType() == makeVoidType())
makeReturn(true);
else {
Id retStorage = createVariable(StorageFunction, function.getReturnType(), "dummyReturn");
Id retStorage = createVariable(StorageClassFunction, function.getReturnType(), "dummyReturn");
Id retValue = createLoad(retStorage);
makeReturn(true, retValue);
}
......@@ -761,18 +761,18 @@ Id Builder::createVariable(StorageClass storageClass, Id type, const char* name)
inst->addImmediateOperand(storageClass);
switch (storageClass) {
case StorageConstantUniform:
case StorageUniform:
case StorageInput:
case StorageOutput:
case StorageWorkgroupLocal:
case StoragePrivateGlobal:
case StorageWorkgroupGlobal:
case StorageClassUniformConstant:
case StorageClassUniform:
case StorageClassInput:
case StorageClassOutput:
case StorageClassWorkgroupLocal:
case StorageClassPrivateGlobal:
case StorageClassWorkgroupGlobal:
constantsTypesGlobals.push_back(inst);
module.mapInstruction(inst);
break;
case StorageFunction:
case StorageClassFunction:
// Validation rules require the declaration in the entry block
buildPoint->getParent().addLocalVariable(inst);
break;
......@@ -878,14 +878,14 @@ Id Builder::createCompositeInsert(Id object, Id composite, Id typeId, std::vecto
}
// An opcode that has no operands, no result id, and no type
void Builder::createNoResultOp(OpCode opCode)
void Builder::createNoResultOp(Op opCode)
{
Instruction* op = new Instruction(opCode);
buildPoint->addInstruction(op);
}
// An opcode that has one operand, no result id, and no type
void Builder::createNoResultOp(OpCode opCode, Id operand)
void Builder::createNoResultOp(Op opCode, Id operand)
{
Instruction* op = new Instruction(opCode);
op->addIdOperand(operand);
......@@ -908,7 +908,7 @@ void Builder::createMemoryBarrier(unsigned executionScope, unsigned memorySemant
}
// An opcode that has one operands, a result id, and a type
Id Builder::createUnaryOp(OpCode opCode, Id typeId, Id operand)
Id Builder::createUnaryOp(Op opCode, Id typeId, Id operand)
{
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->addIdOperand(operand);
......@@ -917,7 +917,7 @@ Id Builder::createUnaryOp(OpCode opCode, Id typeId, Id operand)
return op->getResultId();
}
Id Builder::createBinOp(OpCode opCode, Id typeId, Id left, Id right)
Id Builder::createBinOp(Op opCode, Id typeId, Id left, Id right)
{
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->addIdOperand(left);
......@@ -927,7 +927,7 @@ Id Builder::createBinOp(OpCode opCode, Id typeId, Id left, Id right)
return op->getResultId();
}
Id Builder::createTriOp(OpCode opCode, Id typeId, Id op1, Id op2, Id op3)
Id Builder::createTriOp(Op opCode, Id typeId, Id op1, Id op2, Id op3)
{
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->addIdOperand(op1);
......@@ -938,7 +938,7 @@ Id Builder::createTriOp(OpCode opCode, Id typeId, Id op1, Id op2, Id op3)
return op->getResultId();
}
Id Builder::createTernaryOp(OpCode opCode, Id typeId, Id op1, Id op2, Id op3)
Id Builder::createTernaryOp(Op opCode, Id typeId, Id op1, Id op2, Id op3)
{
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->addIdOperand(op1);
......@@ -1080,7 +1080,7 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool proj, co
// Set up the instruction
//
OpCode opCode;
Op opCode;
if (proj && parameters.gradX && parameters.offset)
opCode = OpTextureSampleProjGradOffset;
else if (proj && parameters.lod && parameters.offset)
......@@ -1118,7 +1118,7 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool proj, co
}
// Comments in header
Id Builder::createTextureQueryCall(OpCode opCode, const TextureParameters& parameters)
Id Builder::createTextureQueryCall(Op opCode, const TextureParameters& parameters)
{
// Figure out the result type
Id resultType;
......@@ -1190,7 +1190,7 @@ Id Builder::createTextureQueryCall(OpCode opCode, const TextureParameters& param
// Comments in header
//Id Builder::createBitFieldExtractCall(Decoration precision, Id id, Id offset, Id bits, bool isSigned)
//{
// OpCode opCode = isSigned ? sBitFieldExtract
// Op opCode = isSigned ? sBitFieldExtract
// : uBitFieldExtract;
//
// if (isScalar(offset) == false || isScalar(bits) == false)
......@@ -1210,7 +1210,7 @@ Id Builder::createTextureQueryCall(OpCode opCode, const TextureParameters& param
// Comments in header
//Id Builder::createBitFieldInsertCall(Decoration precision, Id base, Id insert, Id offset, Id bits)
//{
// OpCode opCode = bitFieldInsert;
// Op opCode = bitFieldInsert;
//
// if (isScalar(offset) == false || isScalar(bits) == false)
// MissingFunctionality("bitFieldInsert operand types");
......@@ -1230,7 +1230,7 @@ Id Builder::createTextureQueryCall(OpCode opCode, const TextureParameters& param
Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal)
{
Instruction* compare = 0;
spv::OpCode binOp = spv::OpNop;
spv::Op binOp = spv::OpNop;
Id boolType = makeBoolType();
Id valueType = getTypeId(value1);
......@@ -1242,7 +1242,7 @@ Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal
if (isVectorType(valueType)) {
Id boolVectorType = makeVectorType(boolType, getNumTypeComponents(valueType));
Id boolVector;
OpCode op;
Op op;
if (getMostBasicTypeClass(valueType) == OpTypeFloat)
op = equal ? OpFOrdEqual : OpFOrdNotEqual;
else
......@@ -1307,9 +1307,9 @@ Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal
}
// Comments in header
//Id Builder::createOperation(Decoration precision, OpCode opCode, Id operand)
//Id Builder::createOperation(Decoration precision, Op opCode, Id operand)
//{
// OpCode* opCode = 0;
// Op* opCode = 0;
//
// // Handle special return types here. Things that don't have same result type as parameter
// switch (opCode) {
......@@ -1362,7 +1362,7 @@ Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal
//}
//
//// Comments in header
//Id Builder::createOperation(Decoration precision, OpCode opCode, Id operand0, Id operand1)
//Id Builder::createOperation(Decoration precision, Op opCode, Id operand0, Id operand1)
//{
// Function* opCode = 0;
//
......@@ -1393,7 +1393,7 @@ Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal
// return instr;
//}
//
//Id Builder::createOperation(Decoration precision, OpCode opCode, Id operand0, Id operand1, Id operand2)
//Id Builder::createOperation(Decoration precision, Op opCode, Id operand0, Id operand1, Id operand2)
//{
// Function* opCode;
//
......@@ -1608,7 +1608,7 @@ void Builder::If::makeEndIf()
// Go back to the headerBlock and make the flow control split
builder.setBuildPoint(headerBlock);
builder.createMerge(OpSelectionMerge, mergeBlock, SelectControlNone);
builder.createMerge(OpSelectionMerge, mergeBlock, SelectionControlMaskNone);
if (elseBlock)
builder.createConditionalBranch(condition, thenBlock, elseBlock);
else
......@@ -1632,7 +1632,7 @@ void Builder::makeSwitch(Id selector, int numSegments, std::vector<int>& caseVal
Block* mergeBlock = new Block(getUniqueId(), function);
// make and insert the switch's selection-merge instruction
createMerge(OpSelectionMerge, mergeBlock, SelectControlNone);
createMerge(OpSelectionMerge, mergeBlock, SelectionControlMaskNone);
// make the switch instruction
Instruction* switchInst = new Instruction(NoResult, NoType, OpSwitch);
......@@ -1706,7 +1706,7 @@ void Builder::createLoopHeaderBranch(Id condition)
Loop loop = loops.top();
Block* body = new Block(getUniqueId(), *loop.function);
createMerge(OpLoopMerge, loop.merge, LoopControlNone);
createMerge(OpLoopMerge, loop.merge, LoopControlMaskNone);
createConditionalBranch(condition, body, loop.merge);
loop.function->addBlock(body);
setBuildPoint(body);
......@@ -1831,7 +1831,7 @@ Id Builder::accessChainLoad(Decoration precision)
id = createCompositeExtract(accessChain.base, accessChain.resultType, indexes);
else {
// make a new function variable for this r-value
Id lValue = createVariable(StorageFunction, getTypeId(accessChain.base), "indexable");
Id lValue = createVariable(StorageClassUniform, getTypeId(accessChain.base), "indexable");
// store into it
createStore(accessChain.base, lValue);
......@@ -1887,7 +1887,7 @@ void Builder::dump(std::vector<unsigned int>& out) const
out.push_back(0);
// First instructions, some created on the spot here:
if (source != LangUnknown) {
if (source != SourceLanguageUnknown) {
Instruction sourceInst(0, 0, OpSource);
sourceInst.addImmediateOperand(source);
sourceInst.addImmediateOperand(sourceVersion);
......@@ -1979,7 +1979,7 @@ void Builder::createBranch(Block* block)
block->addPredecessor(buildPoint);
}
void Builder::createMerge(OpCode mergeCode, Block* mergeBlock, unsigned int control)
void Builder::createMerge(Op mergeCode, Block* mergeBlock, unsigned int control)
{
Instruction* merge = new Instruction(mergeCode);
merge->addIdOperand(mergeBlock->getId());
......
......@@ -106,14 +106,14 @@ public:
samplerContentImage,
samplerContentTextureFilter
};
Id makeSampler(Id sampledType, Dimensionality, samplerContent, bool arrayed, bool shadow, bool ms);
Id makeSampler(Id sampledType, Dim, samplerContent, bool arrayed, bool shadow, bool ms);
// For querying about types.
Id getTypeId(Id resultId) const { return module.getTypeId(resultId); }
Id getDerefTypeId(Id resultId) const;
OpCode getOpCode(Id id) const { return module.getInstruction(id)->getOpCode(); }
OpCode getTypeClass(Id typeId) const { return getOpCode(typeId); }
OpCode getMostBasicTypeClass(Id typeId) const;
Op getOpCode(Id id) const { return module.getInstruction(id)->getOpCode(); }
Op getTypeClass(Id typeId) const { return getOpCode(typeId); }
Op getMostBasicTypeClass(Id typeId) const;
int getNumComponents(Id resultId) const { return getNumTypeComponents(getTypeId(resultId)); }
int getNumTypeComponents(Id typeId) const;
Id getScalarTypeId(Id typeId) const;
......@@ -151,10 +151,10 @@ public:
}
int getNumRows(Id resultId) const { return getTypeNumRows(getTypeId(resultId)); }
Dimensionality getDimensionality(Id resultId) const
Dim getDimensionality(Id resultId) const
{
assert(isSamplerType(getTypeId(resultId)));
return (Dimensionality)module.getInstruction(getTypeId(resultId))->getImmediateOperand(1);
return (Dim)module.getInstruction(getTypeId(resultId))->getImmediateOperand(1);
}
bool isArrayedSampler(Id resultId) const
{
......@@ -228,14 +228,14 @@ public:
Id createCompositeInsert(Id object, Id composite, Id typeId, unsigned index);
Id createCompositeInsert(Id object, Id composite, Id typeId, std::vector<unsigned>& indexes);
void createNoResultOp(OpCode);
void createNoResultOp(OpCode, Id operand);
void createNoResultOp(Op);
void createNoResultOp(Op, Id operand);
void createControlBarrier(unsigned executionScope);
void createMemoryBarrier(unsigned executionScope, unsigned memorySemantics);
Id createUnaryOp(OpCode, Id typeId, Id operand);
Id createBinOp(OpCode, Id typeId, Id operand1, Id operand2);
Id createTriOp(OpCode, Id typeId, Id operand1, Id operand2, Id operand3);
Id createTernaryOp(OpCode, Id typeId, Id operand1, Id operand2, Id operand3);
Id createUnaryOp(Op, Id typeId, Id operand);
Id createBinOp(Op, Id typeId, Id operand1, Id operand2);
Id createTriOp(Op, Id typeId, Id operand1, Id operand2, Id operand3);
Id createTernaryOp(Op, Id typeId, Id operand1, Id operand2, Id operand3);
Id createFunctionCall(spv::Function*, std::vector<spv::Id>&);
// Take an rvalue (source) and a set of channels to extract from it to
......@@ -289,7 +289,7 @@ public:
// Emit the OpTextureQuery* instruction that was passed in.
// Figure out the right return value and type, and return it.
Id createTextureQueryCall(OpCode, const TextureParameters&);
Id createTextureQueryCall(Op, const TextureParameters&);
Id createSamplePositionCall(Decoration precision, Id, Id);
......@@ -461,13 +461,13 @@ public:
void dump(std::vector<unsigned int>&) const;
protected:
Id findScalarConstant(OpCode typeClass, Id typeId, unsigned value) const;
Id findCompositeConstant(OpCode typeClass, std::vector<Id>& comps) const;
Id findScalarConstant(Op typeClass, Id typeId, unsigned value) const;
Id findCompositeConstant(Op typeClass, std::vector<Id>& comps) const;
Id collapseAccessChain();
void simplifyAccessChainSwizzle();
void createAndSetNoPredecessorBlock(const char*);
void createBranch(Block* block);
void createMerge(OpCode, Block*, unsigned int control);
void createMerge(Op, Block*, unsigned int control);
void createConditionalBranch(Id condition, Block* thenBlock, Block* elseBlock);
void dumpInstructions(std::vector<unsigned int>&, const std::vector<Instruction*>&) const;
......
......@@ -40,10 +40,11 @@
// Disassembler for SPIR-V.
//
#include <stdlib.h>
#include <assert.h>
#include <iomanip>
#include <stack>
#include <sstream>
#include "stdlib.h"
#include "GLSL450Lib.h"
extern const char* GlslStd450DebugNames[GLSL_STD_450::Count];
......@@ -69,7 +70,7 @@ public:
void processInstructions();
protected:
OpCode getOpCode(int id) const { return idInstruction[id] ? (OpCode)(stream[idInstruction[id]] & OpCodeMask) : OpNop; }
Op getOpCode(int id) const { return idInstruction[id] ? (Op)(stream[idInstruction[id]] & OpCodeMask) : OpNop; }
// Output methods
void outputIndent();
......@@ -80,7 +81,7 @@ protected:
void disassembleImmediates(int numOperands);
void disassembleIds(int numOperands);
void disassembleString();
void disassembleInstruction(Id resultId, Id typeId, OpCode opCode, int numOperands);
void disassembleInstruction(Id resultId, Id typeId, Op opCode, int numOperands);
// Data
std::ostream& out; // where to write the disassembly
......@@ -144,7 +145,7 @@ void SpirvStream::processInstructions()
// Instruction wordCount and opcode
unsigned int firstWord = stream[word];
unsigned wordCount = firstWord >> WordCountShift;
OpCode opCode = (OpCode)(firstWord & OpCodeMask);
Op opCode = (Op)(firstWord & OpCodeMask);
int nextInst = word + wordCount;
++word;
......@@ -176,7 +177,7 @@ void SpirvStream::processInstructions()
outputTypeId(typeId);
outputIndent();
// Hand off the OpCode and all its operands
// Hand off the Op and all its operands
disassembleInstruction(resultId, typeId, opCode, numOperands);
if (word != nextInst) {
out << " ERROR, incorrect number of operands consumed. At " << word << " instead of " << nextInst << " instruction start was " << instructionStart;
......@@ -277,14 +278,11 @@ void SpirvStream::disassembleString()
out << "\"";
}
void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode, int numOperands)
void SpirvStream::disassembleInstruction(Id resultId, Id typeId, Op opCode, int numOperands)
{
// Process the opcode
if (opCode < 0 || opCode >= OpCount)
Kill(out, "Bad opcode");
else
out << InstructionDesc[opCode].opName + 2; // Skip the "Op"
out << (OpcodeString(opCode) + 2); // leave out the "Op"
if (opCode == OpLoopMerge || opCode == OpSelectionMerge)
nextNestedControl = stream[word];
......@@ -339,7 +337,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode,
// Handle textures specially, so can put out helpful strings.
if (opCode == OpTypeSampler) {
disassembleIds(1);
out << " " << DimensionString((Dimensionality)stream[word++]);
out << " " << DimensionString((Dim)stream[word++]);
switch (stream[word++]) {
case 0: out << " texture"; break;
case 1: out << " image"; break;
......@@ -354,7 +352,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode,
// Handle all the parameterized operands
for (int op = 0; op < InstructionDesc[opCode].operands.getNum(); ++op) {
out << " ";
switch (InstructionDesc[opCode].operands.getClass(op)) {
OperandClass operandClass = InstructionDesc[opCode].operands.getClass(op);
switch (operandClass) {
case OperandId:
disassembleIds(1);
// Get names for printing "(XXX)" for readability, *after* this id
......@@ -366,7 +365,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode,
disassembleIds(numOperands);
return;
case OperandVariableLiterals:
if (opCode == OpDecorate && stream[word - 1] == DecBuiltIn) {
if (opCode == OpDecorate && stream[word - 1] == DecorationBuiltIn) {
out << BuiltInString(stream[word++]);
--numOperands;
++op;
......@@ -376,8 +375,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode,
case OperandVariableLiteralId:
while (numOperands > 0) {
out << std::endl;
outputResultId(NoResult);
outputTypeId(NoType);
outputResultId(0);
outputTypeId(0);
outputIndent();
out << " case ";
disassembleImmediates(1);
......@@ -397,76 +396,23 @@ void SpirvStream::disassembleInstruction(Id resultId, Id typeId, OpCode opCode,
case OperandLiteralString:
disassembleString();
return;
case OperandSource:
out << SourceString((SourceLanguage)stream[word++]);
break;
case OperandExecutionModel:
out << ExecutionModelString((ExecutionModel)stream[word++]);
break;
case OperandAddressing:
out << AddressingString((AddressingModel)stream[word++]);
break;
case OperandMemory:
out << MemoryString((MemoryModel)stream[word++]);
break;
case OperandExecutionMode:
out << ExecutionModeString((ExecutionMode)stream[word++]);
break;
case OperandStorage:
out << StorageClassString((StorageClass)stream[word++]);
break;
case OperandDimensionality:
out << DimensionString((Dimensionality)stream[word++]);
break;
case OperandDecoration:
out << DecorationString((Decoration)stream[word++]);
break;
case OperandBuiltIn:
out << BuiltInString((BuiltIn)stream[word++]);
break;
case OperandSelect:
out << SelectControlString((SelectControl)stream[word++]);
break;
case OperandLoop:
out << LoopControlString((LoopControl)stream[word++]);
break;
case OperandFunction:
{
unsigned int control = stream[word++];
if (control == 0)
out << FunctionControlString(control);
else {
for (int m = 0; m < FunctionControlCount; ++m) {
if (control & (1 << m))
out << FunctionControlString(m);
}
}
break;
}
case OperandMemorySemantics:
for (int shift = 0; shift < MemorySemanticsCount; ++shift) {
unsigned lit = (stream[word] & (1 << shift));
if (lit)
out << MemorySemanticsString(lit) << " ";
}
word++;
break;
case OperandMemoryAccess:
out << MemoryAccessString(stream[word++]);
break;
case OperandExecutionScope:
out << ExecutionScopeString(stream[word++]);
break;
case OperandGroupOperation:
out << GroupOperationString(stream[word++]);
break;
case OperandKernelEnqueueFlags:
out << KernelEnqueueFlagsString(stream[word++]);
break;
case OperandKernelProfilingInfo:
out << KernelProfilingInfoString(stream[word++]);
break;
default:
assert(operandClass >= OperandSource && operandClass < OperandOpcode);
if (OperandClassParams[operandClass].bitmask) {
unsigned int mask = stream[word++];
if (mask == 0)
out << "None";
else {
for (int m = 0; m < OperandClassParams[operandClass].ceiling; ++m) {
if (mask & (1 << m))
out << OperandClassParams[operandClass].getName(m) << " ";
}
}
break;
} else
out << OperandClassParams[operandClass].getName(stream[word++]);
break;
}
--numOperands;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -37,8 +37,7 @@
//
//
// Return English versions of instruction/operand information.
// This can be used for disassembly, printing documentation, etc.
// Parameterize the SPIR-V enumerants.
//
#include "spirv.h"
......@@ -47,7 +46,7 @@
namespace spv {
// Fill in all the parameters of the instruction set
// Fill in all the parameters
void Parameterize();
// Return the English names of all the enums.
......@@ -76,6 +75,35 @@ const char* ExecutionScopeString(int);
const char* GroupOperationString(int);
const char* KernelEnqueueFlagsString(int);
const char* KernelProfilingInfoString(int);
const char* OpcodeString(int);
// For grouping opcodes into subsections
enum OpcodeClass {
OpClassMisc, // default, until opcode is classified
OpClassDebug,
OpClassAnnotate,
OpClassExtension,
OpClassMode,
OpClassType,
OpClassConstant,
OpClassMemory,
OpClassFunction,
OpClassTexture,
OpClassConvert,
OpClassComposite,
OpClassArithmetic,
OpClassRelationalLogical,
OpClassDerivative,
OpClassFlowControl,
OpClassAtomic,
OpClassPrimitive,
OpClassBarrier,
OpClassGroup,
OpClassDeviceSideEnqueue,
OpClassPipe,
OpClassCount
};
// For parameterizing operands.
enum OperandClass {
......@@ -99,35 +127,85 @@ enum OperandClass {
OperandFPFastMath,
OperandFPRoundingMode,
OperandLinkageType,
OperandAccessQualifier,
OperandFuncParamAttr,
OperandDecoration,
OperandBuiltIn,
OperandSelect,
OperandLoop,
OperandFunction,
OperandAccessQualifier,
OperandMemorySemantics,
OperandMemoryAccess,
OperandExecutionScope,
OperandGroupOperation,
OperandKernelEnqueueFlags,
OperandKernelProfilingInfo,
OperandOpcode,
OperandCount
};
// Set of capabilities. Generally, something is assumed to be in core,
// if nothing else is said. So, these are used to identify when something
// requires a specific capability to be declared.
enum Capability {
CapMatrix,
CapShader,
CapGeom,
CapTess,
CapAddr,
CapLink,
CapKernel
};
// Any specific enum can have a set of capabilities that allow it:
typedef std::vector<Capability> EnumCaps;
// Parameterize a set of operands with their OperandClass(es) and descriptions.
class OperandParameters {
public:
OperandParameters() { }
void push(OperandClass oc)
void push(OperandClass oc, const char* d)
{
opClass.push_back(oc);
desc.push_back(d);
}
OperandClass getClass(int op) const { return opClass[op]; }
const char* getDesc(int op) const { return desc[op]; }
int getNum() const { return (int)opClass.size(); }
protected:
std::vector<OperandClass> opClass;
std::vector<const char*> desc;
};
// Parameterize an enumerant
class EnumParameters {
public:
EnumParameters() : desc(0) { }
EnumCaps caps;
const char* desc;
};
// Parameterize a set of enumerants that form an enum
class EnumDefinition : public EnumParameters {
public:
EnumDefinition() :
ceiling(0), bitmask(false), getName(0), enumParams(0), operandParams(0) { }
void set(int ceil, const char* (*name)(int), EnumParameters* ep, bool mask = false)
{
ceiling = ceil;
getName = name;
bitmask = mask;
enumParams = ep;
}
void setOperands(OperandParameters* op) { operandParams = op; }
int ceiling; // ceiling of enumerants
bool bitmask; // true if these enumerants combine into a bitmask
const char* (*getName)(int); // a function that returns the name for each enumerant value (or shift)
EnumParameters* enumParams; // parameters for each individual enumerant
OperandParameters* operandParams; // sets of operands
};
// Parameterize an instruction's logical format, including its known set of operands,
......@@ -137,7 +215,8 @@ public:
InstructionParameters() :
typePresent(true), // most normal, only exceptions have to be spelled out
resultPresent(true), // most normal, only exceptions have to be spelled out
opName(0)
opDesc(0),
opClass(OpClassMisc)
{ }
void setResultAndType(bool r, bool t)
......@@ -149,7 +228,9 @@ public:
bool hasResult() const { return resultPresent != 0; }
bool hasType() const { return typePresent != 0; }
const char* opName;
const char* opDesc;
EnumCaps capabilities;
OpcodeClass opClass;
OperandParameters operands;
protected:
......@@ -157,8 +238,19 @@ protected:
int resultPresent : 1;
};
const int OpcodeCeiling = 267;
// The set of objects that hold all the instruction/operand
// parameterization information.
extern InstructionParameters InstructionDesc[spv::OpCount];
extern InstructionParameters InstructionDesc[];
// These hold definitions of the enumerants used for operands
extern EnumDefinition OperandClassParams[];
const char* GetOperandDesc(OperandClass operand);
void PrintImmediateRow(int imm, const char* name, const EnumParameters* enumParams, bool caps, bool hex = false);
const char* AccessQualifierString(int attr);
void PrintOperands(const OperandParameters& operands, int reservedOperands);
}; // end namespace spv
......@@ -21,742 +21,1281 @@
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
//
// Enumeration tokens for SPIR V.
//
/*
** This header is automatically generated by the same tool that creates
** the Binary Section of the SPIR-V specification.
*/
/*
** Specification revision 29.
** Enumeration tokens for SPIR-V, in three styles: C, C++, generic.
** - C++ will have the tokens in the "spv" name space, with no prefix.
** - C will have tokens with as "Spv" prefix.
**
** Some tokens act like mask values, which can be OR'd together,
** while others are mutually exclusive. The mask-like ones have
** "Mask" in their name, and a parallel enum that has the shift
** amount (1 << x) for each corresponding enumerant.
*/
#pragma once
#ifndef spirv_H
#define spirv_H
#ifdef __cplusplus
namespace spv{
#endif
namespace spv {
const int MagicNumber = 0x07230203;
const int Version = 99;
typedef unsigned int Id;
const Id NoResult = 0;
const Id NoType = 0;
const unsigned int OpCodeMask = 0xFFFF;
const unsigned int WordCountShift = 16;
// Set of capabilities. Generally, something is assumed to be in core,
// if nothing else is said. So, these are used to identify when something
// requires a specific capability to be declared.
enum Capability {
CapMatrix,
CapShader,
CapGeom,
CapTess,
CapAddr,
CapLink,
CapKernel
};
// What language is the source code in? Note the OpSource instruction has a separate
// operand for the version number, this is just the language name. The GLSL
// compatibility profile will be indicated by using an OpSourceExtension string.
enum SourceLanguage {
LangUnknown,
LangESSL,
LangGLSL,
LangOpenCL,
LangCount // guard for validation, "default:" statements, etc.
SourceLanguageUnknown = 0,
SourceLanguageESSL = 1,
SourceLanguageGLSL = 2,
SourceLanguageOpenCL = 3,
};
// Used per entry point to communicate the "stage" or other model of
// execution used by that entry point.
// See OpEntryPoint.
enum ExecutionModel {
ModelVertex,
ModelTessellationControl,
ModelTessellationEvaluation,
ModelGeometry,
ModelFragment,
ModelGLCompute,
ModelKernel,
ModelCount // guard for validation, "default:" statements, etc.
ExecutionModelVertex = 0,
ExecutionModelTessellationControl = 1,
ExecutionModelTessellationEvaluation = 2,
ExecutionModelGeometry = 3,
ExecutionModelFragment = 4,
ExecutionModelGLCompute = 5,
ExecutionModelKernel = 6,
};
// Used as an argument to OpMemoryModel
enum AddressingModel {
AddressingLogical,
AddressingPhysical32,
AddressingPhysical64,
AddressingCount // guard for validation, "default:" statements, etc.
AddressingModelLogical = 0,
AddressingModelPhysical32 = 1,
AddressingModelPhysical64 = 2,
};
// Used as an argment to OpMemoryModel
enum MemoryModel {
MemorySimple,
MemoryGLSL450,
MemoryOCL12,
MemoryOCL20,
MemoryOCL21,
MemoryCount // guard for validation, "default:" statements, etc.
MemoryModelSimple = 0,
MemoryModelGLSL450 = 1,
MemoryModelOpenCL12 = 2,
MemoryModelOpenCL20 = 3,
MemoryModelOpenCL21 = 4,
};
// Used per entry point to communicate modes related to input, output, and execution.
// See OpExecutionMode.
enum ExecutionMode {
ExecutionInvocations,
ExecutionSpacingEqual,
ExecutionSpacingFractionalEven,
ExecutionSpacingFractionalOdd,
ExecutionVertexOrderCw,
ExecutionVertexOrderCcw,
ExecutionPixelCenterInteger,
ExecutionOriginUpperLeft,
ExecutionEarlyFragmentTests,
ExecutionPointMode,
ExecutionXfb,
ExecutionDepthReplacing,
ExecutionDepthAny,
ExecutionDepthGreater,
ExecutionDepthLess,
ExecutionDepthUnchanged,
ExecutionLocalSize,
ExecutionLocalSizeHint,
ExecutionInputPoints,
ExecutionInputLines,
ExecutionInputLinesAdjacency,
ExecutionInputTriangles,
ExecutionInputTrianglesAdjacency,
ExecutionInputQuads,
ExecutionInputIsolines,
ExecutionOutputVertices,
ExecutionOutputPoints,
ExecutionOutputLineStrip,
ExecutionOutputTriangleStrip,
ExecutionVecTypeHint,
ExecutionContractionOff,
ExecutionModeCount // guard for validation, "default:" statements, etc.
ExecutionModeInvocations = 0,
ExecutionModeSpacingEqual = 1,
ExecutionModeSpacingFractionalEven = 2,
ExecutionModeSpacingFractionalOdd = 3,
ExecutionModeVertexOrderCw = 4,
ExecutionModeVertexOrderCcw = 5,
ExecutionModePixelCenterInteger = 6,
ExecutionModeOriginUpperLeft = 7,
ExecutionModeEarlyFragmentTests = 8,
ExecutionModePointMode = 9,
ExecutionModeXfb = 10,
ExecutionModeDepthReplacing = 11,
ExecutionModeDepthAny = 12,
ExecutionModeDepthGreater = 13,
ExecutionModeDepthLess = 14,
ExecutionModeDepthUnchanged = 15,
ExecutionModeLocalSize = 16,
ExecutionModeLocalSizeHint = 17,
ExecutionModeInputPoints = 18,
ExecutionModeInputLines = 19,
ExecutionModeInputLinesAdjacency = 20,
ExecutionModeInputTriangles = 21,
ExecutionModeInputTrianglesAdjacency = 22,
ExecutionModeInputQuads = 23,
ExecutionModeInputIsolines = 24,
ExecutionModeOutputVertices = 25,
ExecutionModeOutputPoints = 26,
ExecutionModeOutputLineStrip = 27,
ExecutionModeOutputTriangleStrip = 28,
ExecutionModeVecTypeHint = 29,
ExecutionModeContractionOff = 30,
};
enum StorageClass {
StorageConstantUniform,
StorageInput,
StorageUniform,
StorageOutput,
StorageWorkgroupLocal,
StorageWorkgroupGlobal,
StoragePrivateGlobal,
StorageFunction,
StorageGeneric,
StoragePrivate,
StorageAtomicCounter,
StorageCount // guard for validation, "default:" statements, etc.
};
// Dimensionalities currently used for sampling.
// See TypeSampler in TypeClass.
enum Dimensionality {
Dim1D,
Dim2D,
Dim3D,
DimCube,
DimRect,
DimBuffer,
DimCount // guard for validation, "default:" statements, etc.
};
// Sampler addressing mode.
StorageClassUniformConstant = 0,
StorageClassInput = 1,
StorageClassUniform = 2,
StorageClassOutput = 3,
StorageClassWorkgroupLocal = 4,
StorageClassWorkgroupGlobal = 5,
StorageClassPrivateGlobal = 6,
StorageClassFunction = 7,
StorageClassGeneric = 8,
StorageClassPrivate = 9,
StorageClassAtomicCounter = 10,
};
enum Dim {
Dim1D = 0,
Dim2D = 1,
Dim3D = 2,
DimCube = 3,
DimRect = 4,
DimBuffer = 5,
};
enum SamplerAddressingMode {
SamplerAddressingNone = 0,
SamplerAddressingClampToEdge = 2,
SamplerAddressingClamp = 4,
SamplerAddressingRepeat = 6,
SamplerAddressingRepeatMirrored = 8,
SamplerAddressingModeLast,
SamplerAddressingModeNone = 0,
SamplerAddressingModeClampToEdge = 2,
SamplerAddressingModeClamp = 4,
SamplerAddressingModeRepeat = 6,
SamplerAddressingModeRepeatMirrored = 8,
};
// Sampler filter mode.
enum SamplerFilterMode {
SamplerFilterNearest = 0x10,
SamplerFilterLinear = 0x20,
SamplerFilterModeLast,
SamplerFilterModeNearest = 16,
SamplerFilterModeLinear = 32,
};
// FP Fast Math Mode.
enum FPFastMath {
FPFastMathNNan = 0, // assume parameters and result are not NaN.
FPFastMathNInf = 0x02, // assume parameters and result are not +/- Inf.
FPFastMathNSZ = 0x04, // treat the sign of a zero parameter or result as insignificant.
FPFastMathARcp = 0x08, // allow the usage of reciprocal rather than perform a division.
FPFastMathFast = 0x10, // allow Algebraic transformations according to real number associative and distibutive algebra. This flag implies all the others.
FPFastMathLast,
enum FPFastMathModeShift {
FPFastMathModeNotNaNShift = 0,
FPFastMathModeNotInfShift = 1,
FPFastMathModeNSZShift = 2,
FPFastMathModeAllowRecipShift = 3,
FPFastMathModeFastShift = 4,
};
enum FPFastMathModeMask {
FPFastMathModeMaskNone = 0,
FPFastMathModeNotNaNMask = 0x00000001,
FPFastMathModeNotInfMask = 0x00000002,
FPFastMathModeNSZMask = 0x00000004,
FPFastMathModeAllowRecipMask = 0x00000008,
FPFastMathModeFastMask = 0x00000010,
};
// FP Fast Math Mode.
enum FPRoundingMode {
FPRoundRTE, // round to nearest even.
FPRoundRTZ, // round towards zero.
FPRoundRTP, // round towards positive infinity.
FPRoundRTN, // round towards negative infinity.
FPRoundLast,
FPRoundingModeRTE = 0,
FPRoundingModeRTZ = 1,
FPRoundingModeRTP = 2,
FPRoundingModeRTN = 3,
};
// Global identifier linkage types (by default the linkage type of global identifiers is private. This means that they are only accessible to objects inside the module.)
enum LinkageType {
LinkageExport, // accessible by objects in other modules as well.
LinkageImport, // a forward declaration to a global identifier that exists in another module.
LinkageLast,
LinkageTypeExport = 0,
LinkageTypeImport = 1,
};
// Access Qualifiers for OpenCL pipes and images
enum AccessQualifier {
AccessQualReadOnly,
AccessQualWriteOnly,
AccessQualReadWrite,
AccessQualLast,
AccessQualifierReadOnly = 0,
AccessQualifierWriteOnly = 1,
AccessQualifierReadWrite = 2,
};
// Function argument attributes
enum FunctionParameterAttribute {
FuncParamAttrZext, // value should be zero extended if needed
FuncParamAttrSext, // value should be sign extended if needed
FuncParamAttrByval, // only valid for pointer parameters (not for ret value), this indicates that the pointer parameter should really be passed by value to the function.
FuncParamAttrSret, // indicates that the pointer parameter specifies the address of a structure that is the return value of the function in the source program. only applicable to the first parameter
FuncParamAttrNoAlias,
FuncParamAttrNoCapture,
FuncParamAttrSVM,
FuncParamAttrNoWrite,
FuncParamAttrNoReadWrite,
FuncParamAttrLast, // guard for validation, "default:" statements, etc.
FunctionParameterAttributeZext = 0,
FunctionParameterAttributeSext = 1,
FunctionParameterAttributeByVal = 2,
FunctionParameterAttributeSret = 3,
FunctionParameterAttributeNoAlias = 4,
FunctionParameterAttributeNoCapture = 5,
FunctionParameterAttributeSVM = 6,
FunctionParameterAttributeNoWrite = 7,
FunctionParameterAttributeNoReadWrite = 8,
};
// Extra forms of "qualification" to add as needed. See OpDecorate.
enum Decoration {
// For legacy ES precision qualifiers; newer language
// designs can use the "num-bits" feature in TypeClass.
// The precision qualifiers may be decorated on type <id>s or instruction <id>s.
DecPrecisionLow,
DecPrecisionMedium,
DecPrecisionHigh,
DecBlock, // basic in/out/uniform block, applied only to types of TypeStruct
DecBufferBlock, // shader storage buffer block
DecRowMajor,
DecColMajor,
DecGLSLShared,
DecGLSLStd140,
DecGLSLStd430,
DecGLSLPacked,
DecSmooth,
DecNoperspective,
DecFlat,
DecPatch,
DecCentroid,
DecSample,
DecInvariant,
DecRestrict,
DecAliased,
DecVolatile,
DecConstant,
DecCoherent,
DecNonwritable,
DecNonreadable,
DecUniform,
DecNoStaticUse,
DecCPacked,
DecFPSaturatedConv,
// these all take one additional operand
DecStream,
DecLocation,
DecComponent,
DecIndex,
DecBinding,
DecDescriptorSet,
DecOffset,
DecAlignment,
DecXfbBuffer,
DecStride,
DecBuiltIn,
DecFuncParamAttr,
DecFPRoundingMode,
DecFPFastMathMode,
DecLinkageType,
DecSpecId,
DecCount // guard for validation, "default:" statements, etc.
DecorationPrecisionLow = 0,
DecorationPrecisionMedium = 1,
DecorationPrecisionHigh = 2,
DecorationBlock = 3,
DecorationBufferBlock = 4,
DecorationRowMajor = 5,
DecorationColMajor = 6,
DecorationGLSLShared = 7,
DecorationGLSLStd140 = 8,
DecorationGLSLStd430 = 9,
DecorationGLSLPacked = 10,
DecorationSmooth = 11,
DecorationNoperspective = 12,
DecorationFlat = 13,
DecorationPatch = 14,
DecorationCentroid = 15,
DecorationSample = 16,
DecorationInvariant = 17,
DecorationRestrict = 18,
DecorationAliased = 19,
DecorationVolatile = 20,
DecorationConstant = 21,
DecorationCoherent = 22,
DecorationNonwritable = 23,
DecorationNonreadable = 24,
DecorationUniform = 25,
DecorationNoStaticUse = 26,
DecorationCPacked = 27,
DecorationSaturatedConversion = 28,
DecorationStream = 29,
DecorationLocation = 30,
DecorationComponent = 31,
DecorationIndex = 32,
DecorationBinding = 33,
DecorationDescriptorSet = 34,
DecorationOffset = 35,
DecorationAlignment = 36,
DecorationXfbBuffer = 37,
DecorationStride = 38,
DecorationBuiltIn = 39,
DecorationFuncParamAttr = 40,
DecorationFPRoundingMode = 41,
DecorationFPFastMathMode = 42,
DecorationLinkageAttributes = 43,
DecorationSpecId = 44,
};
enum BuiltIn {
BuiltInPosition,
BuiltInPointSize,
BuiltInClipVertex,
BuiltInClipDistance,
BuiltInCullDistance,
BuiltInVertexId,
BuiltInInstanceId,
BuiltInPrimitiveId,
BuiltInInvocationId,
BuiltInLayer,
BuiltInViewportIndex,
BuiltInTessLevelOuter,
BuiltInTessLevelInner,
BuiltInTessCoord,
BuiltInPatchVertices,
BuiltInFragCoord,
BuiltInPointCoord,
BuiltInFrontFacing,
BuiltInSampleId,
BuiltInSamplePosition,
BuiltInSampleMask,
BuiltInFragColor,
BuiltInFragDepth,
BuiltInHelperInvocation,
// OpenGL compute stage, OpenCL work item built-ins
BuiltInNumWorkgroups, // number of work-groups that will execute a kernel
BuiltInWorkgroupSize, // OpenCL number of local work-items
BuiltInWorkgroupId, // OpenCL work group id
BuiltInLocalInvocationId, // OpenCL local work item id (decorates a vector3 i32/i64)
BuiltInGlobalInvocationId, // OpenCL global work item id (decorates a vector3 i32/i64)
BuiltInLocalInvocationIndex, // not in use in OpenCL
BuiltInWorkDim, // OpenCL number of dimensions in use (decorates a scalar i32/i64)
BuiltInGlobalSize, // OpenCL number of global work items, per dimension (decorates a vector3 i32/i64)
BuiltInEnqueuedWorkgroupSize, // OpenCL 2.0 only, get local size
BuiltInGlobalOffset, // OpenCL offset values specified global_work_offset
BuiltInGlobalLinearId, // OpenCL 2.0 only, work items 1-dimensional global ID.
BuiltInWorkgroupLinearId, // OpenCL 2.0 only work items 1-dimensional local ID.
// OpenCL 2.0 subgroups
BuiltInSubgroupSize, // Returns the number of work-items in the subgroup
BuiltInSubgroupMaxSize, // Returns the maximum size of a subgroup within the dispatch
BuiltInNumSubgroups, // Returns the maximum size of a subgroup within the dispatch
BuiltInNumEnqueuedSubgroups, // Returns the maximum size of a subgroup within the dispatch
BuiltInSubgroupId, //
BuiltInSubgroupLocalInvocationId, // Returns the unique work-item ID within the current subgroup
BuiltInCount // guard for validation, "default:" statements, etc.
};
enum SelectControl {
SelectControlNone,
SelectControlFlatten,
SelectControlDontFlatten,
SelectControlCount, // guard for validation, "default:" statements, etc.
};
enum LoopControl {
LoopControlNone,
LoopControlUnroll,
LoopControlDontUnroll,
LoopControlCount,
BuiltInPosition = 0,
BuiltInPointSize = 1,
BuiltInClipVertex = 2,
BuiltInClipDistance = 3,
BuiltInCullDistance = 4,
BuiltInVertexId = 5,
BuiltInInstanceId = 6,
BuiltInPrimitiveId = 7,
BuiltInInvocationId = 8,
BuiltInLayer = 9,
BuiltInViewportIndex = 10,
BuiltInTessLevelOuter = 11,
BuiltInTessLevelInner = 12,
BuiltInTessCoord = 13,
BuiltInPatchVertices = 14,
BuiltInFragCoord = 15,
BuiltInPointCoord = 16,
BuiltInFrontFacing = 17,
BuiltInSampleId = 18,
BuiltInSamplePosition = 19,
BuiltInSampleMask = 20,
BuiltInFragColor = 21,
BuiltInFragDepth = 22,
BuiltInHelperInvocation = 23,
BuiltInNumWorkgroups = 24,
BuiltInWorkgroupSize = 25,
BuiltInWorkgroupId = 26,
BuiltInLocalInvocationId = 27,
BuiltInGlobalInvocationId = 28,
BuiltInLocalInvocationIndex = 29,
BuiltInWorkDim = 30,
BuiltInGlobalSize = 31,
BuiltInEnqueuedWorkgroupSize = 32,
BuiltInGlobalOffset = 33,
BuiltInGlobalLinearId = 34,
BuiltInWorkgroupLinearId = 35,
BuiltInSubgroupSize = 36,
BuiltInSubgroupMaxSize = 37,
BuiltInNumSubgroups = 38,
BuiltInNumEnqueuedSubgroups = 39,
BuiltInSubgroupId = 40,
BuiltInSubgroupLocalInvocationId = 41,
};
enum SelectionControlShift {
SelectionControlFlattenShift = 0,
SelectionControlDontFlattenShift = 1,
};
enum SelectionControlMask {
SelectionControlMaskNone = 0,
SelectionControlFlattenMask = 0x00000001,
SelectionControlDontFlattenMask = 0x00000002,
};
enum LoopControlShift {
LoopControlUnrollShift = 0,
LoopControlDontUnrollShift = 1,
};
enum LoopControlMask {
LoopControlMaskNone = 0,
LoopControlUnrollMask = 0x00000001,
LoopControlDontUnrollMask = 0x00000002,
};
enum FunctionControlShift {
FunctionControlInlineShift = 0,
FunctionControlDontInlineShift = 1,
FunctionControlPureShift = 2,
FunctionControlConstShift = 3,
};
enum FunctionControlMask {
FunctionControlNone = 0x0,
FunctionControlInline = 0x1,
FunctionControlDontInline = 0x2,
FunctionControlPure = 0x4,
FunctionControlConst = 0x8,
FunctionControlMaskNone = 0,
FunctionControlInlineMask = 0x00000001,
FunctionControlDontInlineMask = 0x00000002,
FunctionControlPureMask = 0x00000004,
FunctionControlConstMask = 0x00000008,
};
FunctionControlCount = 4,
enum MemorySemanticsShift {
MemorySemanticsRelaxedShift = 0,
MemorySemanticsSequentiallyConsistentShift = 1,
MemorySemanticsAcquireShift = 2,
MemorySemanticsReleaseShift = 3,
MemorySemanticsUniformMemoryShift = 4,
MemorySemanticsSubgroupMemoryShift = 5,
MemorySemanticsWorkgroupLocalMemoryShift = 6,
MemorySemanticsWorkgroupGlobalMemoryShift = 7,
MemorySemanticsAtomicCounterMemoryShift = 8,
MemorySemanticsImageMemoryShift = 9,
};
enum MemorySemanticsMask {
MemorySemanticsRelaxed = 0x0001,
MemorySemanticsSequentiallyConsistent = 0x0002,
MemorySemanticsAcquire = 0x0004,
MemorySemanticsRelease = 0x0008,
MemorySemanticsUniform = 0x0010,
MemorySemanticsSubgroup = 0x0020,
MemorySemanticsWorkgroupLocal = 0x0040,
MemorySemanticsWorkgroupGlobal = 0x0080,
MemorySemanticsAtomicCounter = 0x0100,
MemorySemanticsImage = 0x0200,
MemorySemanticsAllMemory = 0x03FF,
MemorySemanticsMaskNone = 0,
MemorySemanticsRelaxedMask = 0x00000001,
MemorySemanticsSequentiallyConsistentMask = 0x00000002,
MemorySemanticsAcquireMask = 0x00000004,
MemorySemanticsReleaseMask = 0x00000008,
MemorySemanticsUniformMemoryMask = 0x00000010,
MemorySemanticsSubgroupMemoryMask = 0x00000020,
MemorySemanticsWorkgroupLocalMemoryMask = 0x00000040,
MemorySemanticsWorkgroupGlobalMemoryMask = 0x00000080,
MemorySemanticsAtomicCounterMemoryMask = 0x00000100,
MemorySemanticsImageMemoryMask = 0x00000200,
};
MemorySemanticsCount = 10
enum MemoryAccessShift {
MemoryAccessVolatileShift = 0,
MemoryAccessAlignedShift = 1,
};
enum MemoryAccessMask {
MemoryAccessVolatile = 0x0001,
MemoryAccessAligned = 0x0002,
MemoryAccessCount = 2
MemoryAccessMaskNone = 0,
MemoryAccessVolatileMask = 0x00000001,
MemoryAccessAlignedMask = 0x00000002,
};
enum ExecutionScope {
ExecutionScopeCrossDevice,
ExecutionScopeDevice,
ExecutionScopeWorkgroup,
ExecutionScopeSubgroup,
ExecutionScopeCount // guard for validation, "default:" statements, etc.
ExecutionScopeCrossDevice = 0,
ExecutionScopeDevice = 1,
ExecutionScopeWorkgroup = 2,
ExecutionScopeSubgroup = 3,
};
enum GroupOperation {
GroupOpReduce,
GroupOpInclusiveScan,
GroupOpExclusiveScan,
GroupOpCount
GroupOperationReduce = 0,
GroupOperationInclusiveScan = 1,
GroupOperationExclusiveScan = 2,
};
enum KernelEnqueueFlags {
EnqFlagNoWait,
EnqFlagWaitKernel,
EnqFlagWaitWaitWorgGroup,
EnqFlagCount
};
enum KernelProfilingInfo {
ProfInfoCmdExecTime = 0x01,
ProfilingInfoCount = 1
};
enum OpCode {
OpNop = 0, // Not used.
OpSource,
OpSourceExtension,
OpExtension,
OpExtInstImport,
OpMemoryModel,
OpEntryPoint,
OpExecutionMode,
OpTypeVoid,
OpTypeBool,
OpTypeInt,
OpTypeFloat,
OpTypeVector,
OpTypeMatrix,
OpTypeSampler,
OpTypeFilter,
OpTypeArray,
OpTypeRuntimeArray,
OpTypeStruct,
OpTypeOpaque,
OpTypePointer,
OpTypeFunction,
OpTypeEvent,
OpTypeDeviceEvent,
OpTypeReserveId,
OpTypeQueue,
OpTypePipe,
OpConstantTrue,
OpConstantFalse,
OpConstant,
OpConstantComposite,
OpConstantSampler,
OpConstantNullPointer,
OpConstantNullObject,
OpSpecConstantTrue,
OpSpecConstantFalse,
OpSpecConstant,
OpSpecConstantComposite,
OpVariable,
OpVariableArray,
OpFunction,
OpFunctionParameter,
OpFunctionEnd,
OpFunctionCall,
OpExtInst,
OpUndef,
OpLoad,
OpStore,
OpPhi,
OpDecorationGroup,
OpDecorate,
OpMemberDecorate,
OpGroupDecorate,
OpGroupMemberDecorate,
OpName,
OpMemberName,
OpString,
OpLine,
OpVectorExtractDynamic,
OpVectorInsertDynamic,
OpVectorShuffle,
OpCompositeConstruct,
OpCompositeExtract,
OpCompositeInsert,
OpCopyObject,
OpCopyMemory,
OpCopyMemorySized,
OpSampler,
OpTextureSample,
OpTextureSampleDref,
OpTextureSampleLod,
OpTextureSampleProj,
OpTextureSampleGrad,
OpTextureSampleOffset,
OpTextureSampleProjLod,
OpTextureSampleProjGrad,
OpTextureSampleLodOffset,
OpTextureSampleProjOffset,
OpTextureSampleGradOffset,
OpTextureSampleProjLodOffset,
OpTextureSampleProjGradOffset,
OpTextureFetchTexel,
OpTextureFetchTexelOffset,
OpTextureFetchSample,
OpTextureFetchBuffer,
OpTextureGather,
OpTextureGatherOffset,
OpTextureGatherOffsets,
OpTextureQuerySizeLod,
OpTextureQuerySize,
OpTextureQueryLod,
OpTextureQueryLevels,
OpTextureQuerySamples,
OpAccessChain,
OpInBoundsAccessChain,
OpSNegate,
OpFNegate,
OpNot,
OpAny,
OpAll,
OpConvertFToU,
OpConvertFToS,
OpConvertSToF,
OpConvertUToF,
OpUConvert,
OpSConvert,
OpFConvert,
OpConvertPtrToU,
OpConvertUToPtr,
OpPtrCastToGeneric, // cast a pointer storage class to be in storage generic
OpGenericCastToPtr, // cast a pointer in the generic storage class generic to another storage class
OpBitcast,
OpTranspose,
OpIsNan,
OpIsInf,
OpIsFinite,
OpIsNormal,
OpSignBitSet,
OpLessOrGreater,
OpOrdered,
OpUnordered,
OpArrayLength,
OpIAdd,
OpFAdd,
OpISub,
OpFSub,
OpIMul,
OpFMul,
OpUDiv,
OpSDiv,
OpFDiv,
OpUMod,
OpSRem,
OpSMod,
OpFRem,
OpFMod,
OpVectorTimesScalar,
OpMatrixTimesScalar,
OpVectorTimesMatrix,
OpMatrixTimesVector,
OpMatrixTimesMatrix,
OpOuterProduct,
OpDot,
OpShiftRightLogical,
OpShiftRightArithmetic,
OpShiftLeftLogical,
OpLogicalOr,
OpLogicalXor,
OpLogicalAnd,
OpBitwiseOr,
OpBitwiseXor,
OpBitwiseAnd,
OpSelect,
OpIEqual,
OpFOrdEqual,
OpFUnordEqual,
OpINotEqual,
OpFOrdNotEqual,
OpFUnordNotEqual,
OpULessThan,
OpSLessThan,
OpFOrdLessThan,
OpFUnordLessThan,
OpUGreaterThan,
OpSGreaterThan,
OpFOrdGreaterThan,
OpFUnordGreaterThan,
OpULessThanEqual,
OpSLessThanEqual,
OpFOrdLessThanEqual,
OpFUnordLessThanEqual,
OpUGreaterThanEqual,
OpSGreaterThanEqual,
OpFOrdGreaterThanEqual,
OpFUnordGreaterThanEqual,
OpDPdx,
OpDPdy,
OpFwidth,
OpDPdxFine,
OpDPdyFine,
OpFwidthFine,
OpDPdxCoarse,
OpDPdyCoarse,
OpFwidthCoarse,
OpEmitVertex,
OpEndPrimitive,
OpEmitStreamVertex,
OpEndStreamPrimitive,
OpControlBarrier,
OpMemoryBarrier,
OpImagePointer,
OpAtomicInit,
OpAtomicLoad,
OpAtomicStore,
OpAtomicExchange,
OpAtomicCompareExchange,
OpAtomicCompareExchangeWeak,
OpAtomicIIncrement,
OpAtomicIDecrement,
OpAtomicIAdd,
OpAtomicISub,
OpAtomicUMin,
OpAtomicUMax,
OpAtomicAnd,
OpAtomicOr,
OpAtomicXor,
OpLoopMerge,
OpSelectionMerge,
OpLabel,
OpBranch,
OpBranchConditional,
OpSwitch,
OpKill,
OpReturn,
OpReturnValue,
OpUnreachable,
OpLifetimeStart,
OpLifetimeStop,
OpCompileFlag,
OpAsyncGroupCopy,
OpWaitGroupEvents,
OpGroupAll,
OpGroupAny,
OpGroupBroadcast,
OpGroupIAdd,
OpGroupFAdd,
OpGroupFMin,
OpGroupUMin,
OpGroupSMin,
OpGroupFMax,
OpGroupUMax,
OpGroupSMax,
OpGenericCastToPtrExplicit,
OpGenericPtrMemSemantics,
OpReadPipe,
OpWritePipe,
OpReservedReadPipe,
OpReservedWritePipe,
OpReserveReadPipePackets,
OpReserveWritePipePackets,
OpCommitReadPipe,
OpCommitWritePipe,
OpIsValidReserveId,
OpGetNumPipePackets,
OpGetMaxPipePackets,
OpGroupReserveReadPipePackets,
OpGroupReserveWritePipePackets,
OpGroupCommitReadPipe,
OpGroupCommitWritePipe,
OpEnqueueMarker,
OpEnqueueKernel,
OpGetKernelNDrangeSubGroupCount,
OpGetKernelNDrangeMaxSubGroupSize,
OpGetKernelWorkGroupSize,
OpGetKernelPreferredWorkGroupSizeMultiple,
OpRetainEvent,
OpReleaseEvent,
OpCreateUserEvent,
OpIsValidEvent,
OpSetUserEventStatus,
OpCaptureEventProfilingInfo,
OpGetDefaultQueue,
OpBuildNDRange,
OpCount // guard for validation, "default:" statements, etc.
KernelEnqueueFlagsNoWait = 0,
KernelEnqueueFlagsWaitKernel = 1,
KernelEnqueueFlagsWaitWorkGroup = 2,
};
enum KernelProfilingInfoShift {
KernelProfilingInfoCmdExecTimeShift = 0,
};
enum KernelProfilingInfoMask {
KernelProfilingInfoMaskNone = 0,
KernelProfilingInfoCmdExecTimeMask = 0x00000001,
};
enum Op {
OpNop = 0,
OpSource = 1,
OpSourceExtension = 2,
OpExtension = 3,
OpExtInstImport = 4,
OpMemoryModel = 5,
OpEntryPoint = 6,
OpExecutionMode = 7,
OpTypeVoid = 8,
OpTypeBool = 9,
OpTypeInt = 10,
OpTypeFloat = 11,
OpTypeVector = 12,
OpTypeMatrix = 13,
OpTypeSampler = 14,
OpTypeFilter = 15,
OpTypeArray = 16,
OpTypeRuntimeArray = 17,
OpTypeStruct = 18,
OpTypeOpaque = 19,
OpTypePointer = 20,
OpTypeFunction = 21,
OpTypeEvent = 22,
OpTypeDeviceEvent = 23,
OpTypeReserveId = 24,
OpTypeQueue = 25,
OpTypePipe = 26,
OpConstantTrue = 27,
OpConstantFalse = 28,
OpConstant = 29,
OpConstantComposite = 30,
OpConstantSampler = 31,
OpConstantNullPointer = 32,
OpConstantNullObject = 33,
OpSpecConstantTrue = 34,
OpSpecConstantFalse = 35,
OpSpecConstant = 36,
OpSpecConstantComposite = 37,
OpVariable = 38,
OpVariableArray = 39,
OpFunction = 40,
OpFunctionParameter = 41,
OpFunctionEnd = 42,
OpFunctionCall = 43,
OpExtInst = 44,
OpUndef = 45,
OpLoad = 46,
OpStore = 47,
OpPhi = 48,
OpDecorationGroup = 49,
OpDecorate = 50,
OpMemberDecorate = 51,
OpGroupDecorate = 52,
OpGroupMemberDecorate = 53,
OpName = 54,
OpMemberName = 55,
OpString = 56,
OpLine = 57,
OpVectorExtractDynamic = 58,
OpVectorInsertDynamic = 59,
OpVectorShuffle = 60,
OpCompositeConstruct = 61,
OpCompositeExtract = 62,
OpCompositeInsert = 63,
OpCopyObject = 64,
OpCopyMemory = 65,
OpCopyMemorySized = 66,
OpSampler = 67,
OpTextureSample = 68,
OpTextureSampleDref = 69,
OpTextureSampleLod = 70,
OpTextureSampleProj = 71,
OpTextureSampleGrad = 72,
OpTextureSampleOffset = 73,
OpTextureSampleProjLod = 74,
OpTextureSampleProjGrad = 75,
OpTextureSampleLodOffset = 76,
OpTextureSampleProjOffset = 77,
OpTextureSampleGradOffset = 78,
OpTextureSampleProjLodOffset = 79,
OpTextureSampleProjGradOffset = 80,
OpTextureFetchTexelLod = 81,
OpTextureFetchTexelOffset = 82,
OpTextureFetchSample = 83,
OpTextureFetchTexel = 84,
OpTextureGather = 85,
OpTextureGatherOffset = 86,
OpTextureGatherOffsets = 87,
OpTextureQuerySizeLod = 88,
OpTextureQuerySize = 89,
OpTextureQueryLod = 90,
OpTextureQueryLevels = 91,
OpTextureQuerySamples = 92,
OpAccessChain = 93,
OpInBoundsAccessChain = 94,
OpSNegate = 95,
OpFNegate = 96,
OpNot = 97,
OpAny = 98,
OpAll = 99,
OpConvertFToU = 100,
OpConvertFToS = 101,
OpConvertSToF = 102,
OpConvertUToF = 103,
OpUConvert = 104,
OpSConvert = 105,
OpFConvert = 106,
OpConvertPtrToU = 107,
OpConvertUToPtr = 108,
OpPtrCastToGeneric = 109,
OpGenericCastToPtr = 110,
OpBitcast = 111,
OpTranspose = 112,
OpIsNan = 113,
OpIsInf = 114,
OpIsFinite = 115,
OpIsNormal = 116,
OpSignBitSet = 117,
OpLessOrGreater = 118,
OpOrdered = 119,
OpUnordered = 120,
OpArrayLength = 121,
OpIAdd = 122,
OpFAdd = 123,
OpISub = 124,
OpFSub = 125,
OpIMul = 126,
OpFMul = 127,
OpUDiv = 128,
OpSDiv = 129,
OpFDiv = 130,
OpUMod = 131,
OpSRem = 132,
OpSMod = 133,
OpFRem = 134,
OpFMod = 135,
OpVectorTimesScalar = 136,
OpMatrixTimesScalar = 137,
OpVectorTimesMatrix = 138,
OpMatrixTimesVector = 139,
OpMatrixTimesMatrix = 140,
OpOuterProduct = 141,
OpDot = 142,
OpShiftRightLogical = 143,
OpShiftRightArithmetic = 144,
OpShiftLeftLogical = 145,
OpLogicalOr = 146,
OpLogicalXor = 147,
OpLogicalAnd = 148,
OpBitwiseOr = 149,
OpBitwiseXor = 150,
OpBitwiseAnd = 151,
OpSelect = 152,
OpIEqual = 153,
OpFOrdEqual = 154,
OpFUnordEqual = 155,
OpINotEqual = 156,
OpFOrdNotEqual = 157,
OpFUnordNotEqual = 158,
OpULessThan = 159,
OpSLessThan = 160,
OpFOrdLessThan = 161,
OpFUnordLessThan = 162,
OpUGreaterThan = 163,
OpSGreaterThan = 164,
OpFOrdGreaterThan = 165,
OpFUnordGreaterThan = 166,
OpULessThanEqual = 167,
OpSLessThanEqual = 168,
OpFOrdLessThanEqual = 169,
OpFUnordLessThanEqual = 170,
OpUGreaterThanEqual = 171,
OpSGreaterThanEqual = 172,
OpFOrdGreaterThanEqual = 173,
OpFUnordGreaterThanEqual = 174,
OpDPdx = 175,
OpDPdy = 176,
OpFwidth = 177,
OpDPdxFine = 178,
OpDPdyFine = 179,
OpFwidthFine = 180,
OpDPdxCoarse = 181,
OpDPdyCoarse = 182,
OpFwidthCoarse = 183,
OpEmitVertex = 184,
OpEndPrimitive = 185,
OpEmitStreamVertex = 186,
OpEndStreamPrimitive = 187,
OpControlBarrier = 188,
OpMemoryBarrier = 189,
OpImagePointer = 190,
OpAtomicInit = 191,
OpAtomicLoad = 192,
OpAtomicStore = 193,
OpAtomicExchange = 194,
OpAtomicCompareExchange = 195,
OpAtomicCompareExchangeWeak = 196,
OpAtomicIIncrement = 197,
OpAtomicIDecrement = 198,
OpAtomicIAdd = 199,
OpAtomicISub = 200,
OpAtomicUMin = 201,
OpAtomicUMax = 202,
OpAtomicAnd = 203,
OpAtomicOr = 204,
OpAtomicXor = 205,
OpLoopMerge = 206,
OpSelectionMerge = 207,
OpLabel = 208,
OpBranch = 209,
OpBranchConditional = 210,
OpSwitch = 211,
OpKill = 212,
OpReturn = 213,
OpReturnValue = 214,
OpUnreachable = 215,
OpLifetimeStart = 216,
OpLifetimeStop = 217,
OpCompileFlag = 218,
OpAsyncGroupCopy = 219,
OpWaitGroupEvents = 220,
OpGroupAll = 221,
OpGroupAny = 222,
OpGroupBroadcast = 223,
OpGroupIAdd = 224,
OpGroupFAdd = 225,
OpGroupFMin = 226,
OpGroupUMin = 227,
OpGroupSMin = 228,
OpGroupFMax = 229,
OpGroupUMax = 230,
OpGroupSMax = 231,
OpGenericCastToPtrExplicit = 232,
OpGenericPtrMemSemantics = 233,
OpReadPipe = 234,
OpWritePipe = 235,
OpReservedReadPipe = 236,
OpReservedWritePipe = 237,
OpReserveReadPipePackets = 238,
OpReserveWritePipePackets = 239,
OpCommitReadPipe = 240,
OpCommitWritePipe = 241,
OpIsValidReserveId = 242,
OpGetNumPipePackets = 243,
OpGetMaxPipePackets = 244,
OpGroupReserveReadPipePackets = 245,
OpGroupReserveWritePipePackets = 246,
OpGroupCommitReadPipe = 247,
OpGroupCommitWritePipe = 248,
OpEnqueueMarker = 249,
OpEnqueueKernel = 250,
OpGetKernelNDrangeSubGroupCount = 251,
OpGetKernelNDrangeMaxSubGroupSize = 252,
OpGetKernelWorkGroupSize = 253,
OpGetKernelPreferredWorkGroupSizeMultiple = 254,
OpRetainEvent = 255,
OpReleaseEvent = 256,
OpCreateUserEvent = 257,
OpIsValidEvent = 258,
OpSetUserEventStatus = 259,
OpCaptureEventProfilingInfo = 260,
OpGetDefaultQueue = 261,
OpBuildNDRange = 262,
OpSatConvertSToU = 263,
OpSatConvertUToS = 264,
OpAtomicIMin = 265,
OpAtomicIMax = 266,
};
#ifdef __cplusplus
}; // end namespace spv
#endif
#endif // spirv_H
#endif // #ifdef __cplusplus
#ifndef __cplusplus
const int SpvMagicNumber = 0x07230203;
const int SpvVersion = 99;
typedef unsigned int SpvId;
const unsigned int SpvOpCodeMask = 0xFFFF;
const unsigned int SpvWordCountShift = 16;
typedef enum SpvSourceLanguage_ {
SpvSourceLanguageUnknown = 0,
SpvSourceLanguageESSL = 1,
SpvSourceLanguageGLSL = 2,
SpvSourceLanguageOpenCL = 3,
} SpvSourceLanguage;
typedef enum SpvExecutionModel_ {
SpvExecutionModelVertex = 0,
SpvExecutionModelTessellationControl = 1,
SpvExecutionModelTessellationEvaluation = 2,
SpvExecutionModelGeometry = 3,
SpvExecutionModelFragment = 4,
SpvExecutionModelGLCompute = 5,
SpvExecutionModelKernel = 6,
} SpvExecutionModel;
typedef enum SpvAddressingModel_ {
SpvAddressingModelLogical = 0,
SpvAddressingModelPhysical32 = 1,
SpvAddressingModelPhysical64 = 2,
} SpvAddressingModel;
typedef enum SpvMemoryModel_ {
SpvMemoryModelSimple = 0,
SpvMemoryModelGLSL450 = 1,
SpvMemoryModelOpenCL12 = 2,
SpvMemoryModelOpenCL20 = 3,
SpvMemoryModelOpenCL21 = 4,
} SpvMemoryModel;
typedef enum SpvExecutionMode_ {
SpvExecutionModeInvocations = 0,
SpvExecutionModeSpacingEqual = 1,
SpvExecutionModeSpacingFractionalEven = 2,
SpvExecutionModeSpacingFractionalOdd = 3,
SpvExecutionModeVertexOrderCw = 4,
SpvExecutionModeVertexOrderCcw = 5,
SpvExecutionModePixelCenterInteger = 6,
SpvExecutionModeOriginUpperLeft = 7,
SpvExecutionModeEarlyFragmentTests = 8,
SpvExecutionModePointMode = 9,
SpvExecutionModeXfb = 10,
SpvExecutionModeDepthReplacing = 11,
SpvExecutionModeDepthAny = 12,
SpvExecutionModeDepthGreater = 13,
SpvExecutionModeDepthLess = 14,
SpvExecutionModeDepthUnchanged = 15,
SpvExecutionModeLocalSize = 16,
SpvExecutionModeLocalSizeHint = 17,
SpvExecutionModeInputPoints = 18,
SpvExecutionModeInputLines = 19,
SpvExecutionModeInputLinesAdjacency = 20,
SpvExecutionModeInputTriangles = 21,
SpvExecutionModeInputTrianglesAdjacency = 22,
SpvExecutionModeInputQuads = 23,
SpvExecutionModeInputIsolines = 24,
SpvExecutionModeOutputVertices = 25,
SpvExecutionModeOutputPoints = 26,
SpvExecutionModeOutputLineStrip = 27,
SpvExecutionModeOutputTriangleStrip = 28,
SpvExecutionModeVecTypeHint = 29,
SpvExecutionModeContractionOff = 30,
} SpvExecutionMode;
typedef enum SpvStorageClass_ {
SpvStorageClassUniformConstant = 0,
SpvStorageClassInput = 1,
SpvStorageClassUniform = 2,
SpvStorageClassOutput = 3,
SpvStorageClassWorkgroupLocal = 4,
SpvStorageClassWorkgroupGlobal = 5,
SpvStorageClassPrivateGlobal = 6,
SpvStorageClassFunction = 7,
SpvStorageClassGeneric = 8,
SpvStorageClassPrivate = 9,
SpvStorageClassAtomicCounter = 10,
} SpvStorageClass;
typedef enum SpvDim_ {
SpvDim1D = 0,
SpvDim2D = 1,
SpvDim3D = 2,
SpvDimCube = 3,
SpvDimRect = 4,
SpvDimBuffer = 5,
} SpvDim;
typedef enum SpvSamplerAddressingMode_ {
SpvSamplerAddressingModeNone = 0,
SpvSamplerAddressingModeClampToEdge = 2,
SpvSamplerAddressingModeClamp = 4,
SpvSamplerAddressingModeRepeat = 6,
SpvSamplerAddressingModeRepeatMirrored = 8,
} SpvSamplerAddressingMode;
typedef enum SpvSamplerFilterMode_ {
SpvSamplerFilterModeNearest = 16,
SpvSamplerFilterModeLinear = 32,
} SpvSamplerFilterMode;
typedef enum SpvFPFastMathModeShift_ {
SpvFPFastMathModeNotNaNShift = 0,
SpvFPFastMathModeNotInfShift = 1,
SpvFPFastMathModeNSZShift = 2,
SpvFPFastMathModeAllowRecipShift = 3,
SpvFPFastMathModeFastShift = 4,
} SpvFPFastMathModeShift;
typedef enum SpvFPFastMathModeMask_ {
SpvFPFastMathModeMaskNone = 0,
SpvFPFastMathModeNotNaNMask = 0x00000001,
SpvFPFastMathModeNotInfMask = 0x00000002,
SpvFPFastMathModeNSZMask = 0x00000004,
SpvFPFastMathModeAllowRecipMask = 0x00000008,
SpvFPFastMathModeFastMask = 0x00000010,
} SpvFPFastMathModeMask;
typedef enum SpvFPRoundingMode_ {
SpvFPRoundingModeRTE = 0,
SpvFPRoundingModeRTZ = 1,
SpvFPRoundingModeRTP = 2,
SpvFPRoundingModeRTN = 3,
} SpvFPRoundingMode;
typedef enum SpvLinkageType_ {
SpvLinkageTypeExport = 0,
SpvLinkageTypeImport = 1,
} SpvLinkageType;
typedef enum SpvAccessQualifier_ {
SpvAccessQualifierReadOnly = 0,
SpvAccessQualifierWriteOnly = 1,
SpvAccessQualifierReadWrite = 2,
} SpvAccessQualifier;
typedef enum SpvFunctionParameterAttribute_ {
SpvFunctionParameterAttributeZext = 0,
SpvFunctionParameterAttributeSext = 1,
SpvFunctionParameterAttributeByVal = 2,
SpvFunctionParameterAttributeSret = 3,
SpvFunctionParameterAttributeNoAlias = 4,
SpvFunctionParameterAttributeNoCapture = 5,
SpvFunctionParameterAttributeSVM = 6,
SpvFunctionParameterAttributeNoWrite = 7,
SpvFunctionParameterAttributeNoReadWrite = 8,
} SpvFunctionParameterAttribute;
typedef enum SpvDecoration_ {
SpvDecorationPrecisionLow = 0,
SpvDecorationPrecisionMedium = 1,
SpvDecorationPrecisionHigh = 2,
SpvDecorationBlock = 3,
SpvDecorationBufferBlock = 4,
SpvDecorationRowMajor = 5,
SpvDecorationColMajor = 6,
SpvDecorationGLSLShared = 7,
SpvDecorationGLSLStd140 = 8,
SpvDecorationGLSLStd430 = 9,
SpvDecorationGLSLPacked = 10,
SpvDecorationSmooth = 11,
SpvDecorationNoperspective = 12,
SpvDecorationFlat = 13,
SpvDecorationPatch = 14,
SpvDecorationCentroid = 15,
SpvDecorationSample = 16,
SpvDecorationInvariant = 17,
SpvDecorationRestrict = 18,
SpvDecorationAliased = 19,
SpvDecorationVolatile = 20,
SpvDecorationConstant = 21,
SpvDecorationCoherent = 22,
SpvDecorationNonwritable = 23,
SpvDecorationNonreadable = 24,
SpvDecorationUniform = 25,
SpvDecorationNoStaticUse = 26,
SpvDecorationCPacked = 27,
SpvDecorationSaturatedConversion = 28,
SpvDecorationStream = 29,
SpvDecorationLocation = 30,
SpvDecorationComponent = 31,
SpvDecorationIndex = 32,
SpvDecorationBinding = 33,
SpvDecorationDescriptorSet = 34,
SpvDecorationOffset = 35,
SpvDecorationAlignment = 36,
SpvDecorationXfbBuffer = 37,
SpvDecorationStride = 38,
SpvDecorationBuiltIn = 39,
SpvDecorationFuncParamAttr = 40,
SpvDecorationFPRoundingMode = 41,
SpvDecorationFPFastMathMode = 42,
SpvDecorationLinkageAttributes = 43,
SpvDecorationSpecId = 44,
} SpvDecoration;
typedef enum SpvBuiltIn_ {
SpvBuiltInPosition = 0,
SpvBuiltInPointSize = 1,
SpvBuiltInClipVertex = 2,
SpvBuiltInClipDistance = 3,
SpvBuiltInCullDistance = 4,
SpvBuiltInVertexId = 5,
SpvBuiltInInstanceId = 6,
SpvBuiltInPrimitiveId = 7,
SpvBuiltInInvocationId = 8,
SpvBuiltInLayer = 9,
SpvBuiltInViewportIndex = 10,
SpvBuiltInTessLevelOuter = 11,
SpvBuiltInTessLevelInner = 12,
SpvBuiltInTessCoord = 13,
SpvBuiltInPatchVertices = 14,
SpvBuiltInFragCoord = 15,
SpvBuiltInPointCoord = 16,
SpvBuiltInFrontFacing = 17,
SpvBuiltInSampleId = 18,
SpvBuiltInSamplePosition = 19,
SpvBuiltInSampleMask = 20,
SpvBuiltInFragColor = 21,
SpvBuiltInFragDepth = 22,
SpvBuiltInHelperInvocation = 23,
SpvBuiltInNumWorkgroups = 24,
SpvBuiltInWorkgroupSize = 25,
SpvBuiltInWorkgroupId = 26,
SpvBuiltInLocalInvocationId = 27,
SpvBuiltInGlobalInvocationId = 28,
SpvBuiltInLocalInvocationIndex = 29,
SpvBuiltInWorkDim = 30,
SpvBuiltInGlobalSize = 31,
SpvBuiltInEnqueuedWorkgroupSize = 32,
SpvBuiltInGlobalOffset = 33,
SpvBuiltInGlobalLinearId = 34,
SpvBuiltInWorkgroupLinearId = 35,
SpvBuiltInSubgroupSize = 36,
SpvBuiltInSubgroupMaxSize = 37,
SpvBuiltInNumSubgroups = 38,
SpvBuiltInNumEnqueuedSubgroups = 39,
SpvBuiltInSubgroupId = 40,
SpvBuiltInSubgroupLocalInvocationId = 41,
} SpvBuiltIn;
typedef enum SpvSelectionControlShift_ {
SpvSelectionControlFlattenShift = 0,
SpvSelectionControlDontFlattenShift = 1,
} SpvSelectionControlShift;
typedef enum SpvSelectionControlMask_ {
SpvSelectionControlMaskNone = 0,
SpvSelectionControlFlattenMask = 0x00000001,
SpvSelectionControlDontFlattenMask = 0x00000002,
} SpvSelectionControlMask;
typedef enum SpvLoopControlShift_ {
SpvLoopControlUnrollShift = 0,
SpvLoopControlDontUnrollShift = 1,
} SpvLoopControlShift;
typedef enum SpvLoopControlMask_ {
SpvLoopControlMaskNone = 0,
SpvLoopControlUnrollMask = 0x00000001,
SpvLoopControlDontUnrollMask = 0x00000002,
} SpvLoopControlMask;
typedef enum SpvFunctionControlShift_ {
SpvFunctionControlInlineShift = 0,
SpvFunctionControlDontInlineShift = 1,
SpvFunctionControlPureShift = 2,
SpvFunctionControlConstShift = 3,
} SpvFunctionControlShift;
typedef enum SpvFunctionControlMask_ {
SpvFunctionControlMaskNone = 0,
SpvFunctionControlInlineMask = 0x00000001,
SpvFunctionControlDontInlineMask = 0x00000002,
SpvFunctionControlPureMask = 0x00000004,
SpvFunctionControlConstMask = 0x00000008,
} SpvFunctionControlMask;
typedef enum SpvMemorySemanticsShift_ {
SpvMemorySemanticsRelaxedShift = 0,
SpvMemorySemanticsSequentiallyConsistentShift = 1,
SpvMemorySemanticsAcquireShift = 2,
SpvMemorySemanticsReleaseShift = 3,
SpvMemorySemanticsUniformMemoryShift = 4,
SpvMemorySemanticsSubgroupMemoryShift = 5,
SpvMemorySemanticsWorkgroupLocalMemoryShift = 6,
SpvMemorySemanticsWorkgroupGlobalMemoryShift = 7,
SpvMemorySemanticsAtomicCounterMemoryShift = 8,
SpvMemorySemanticsImageMemoryShift = 9,
} SpvMemorySemanticsShift;
typedef enum SpvMemorySemanticsMask_ {
SpvMemorySemanticsMaskNone = 0,
SpvMemorySemanticsRelaxedMask = 0x00000001,
SpvMemorySemanticsSequentiallyConsistentMask = 0x00000002,
SpvMemorySemanticsAcquireMask = 0x00000004,
SpvMemorySemanticsReleaseMask = 0x00000008,
SpvMemorySemanticsUniformMemoryMask = 0x00000010,
SpvMemorySemanticsSubgroupMemoryMask = 0x00000020,
SpvMemorySemanticsWorkgroupLocalMemoryMask = 0x00000040,
SpvMemorySemanticsWorkgroupGlobalMemoryMask = 0x00000080,
SpvMemorySemanticsAtomicCounterMemoryMask = 0x00000100,
SpvMemorySemanticsImageMemoryMask = 0x00000200,
} SpvMemorySemanticsMask;
typedef enum SpvMemoryAccessShift_ {
SpvMemoryAccessVolatileShift = 0,
SpvMemoryAccessAlignedShift = 1,
} SpvMemoryAccessShift;
typedef enum SpvMemoryAccessMask_ {
SpvMemoryAccessMaskNone = 0,
SpvMemoryAccessVolatileMask = 0x00000001,
SpvMemoryAccessAlignedMask = 0x00000002,
} SpvMemoryAccessMask;
typedef enum SpvExecutionScope_ {
SpvExecutionScopeCrossDevice = 0,
SpvExecutionScopeDevice = 1,
SpvExecutionScopeWorkgroup = 2,
SpvExecutionScopeSubgroup = 3,
} SpvExecutionScope;
typedef enum SpvGroupOperation_ {
SpvGroupOperationReduce = 0,
SpvGroupOperationInclusiveScan = 1,
SpvGroupOperationExclusiveScan = 2,
} SpvGroupOperation;
typedef enum SpvKernelEnqueueFlags_ {
SpvKernelEnqueueFlagsNoWait = 0,
SpvKernelEnqueueFlagsWaitKernel = 1,
SpvKernelEnqueueFlagsWaitWorkGroup = 2,
} SpvKernelEnqueueFlags;
typedef enum SpvKernelProfilingInfoShift_ {
SpvKernelProfilingInfoCmdExecTimeShift = 0,
} SpvKernelProfilingInfoShift;
typedef enum SpvKernelProfilingInfoMask_ {
SpvKernelProfilingInfoMaskNone = 0,
SpvKernelProfilingInfoCmdExecTimeMask = 0x00000001,
} SpvKernelProfilingInfoMask;
typedef enum SpvOp_ {
SpvOpNop = 0,
SpvOpSource = 1,
SpvOpSourceExtension = 2,
SpvOpExtension = 3,
SpvOpExtInstImport = 4,
SpvOpMemoryModel = 5,
SpvOpEntryPoint = 6,
SpvOpExecutionMode = 7,
SpvOpTypeVoid = 8,
SpvOpTypeBool = 9,
SpvOpTypeInt = 10,
SpvOpTypeFloat = 11,
SpvOpTypeVector = 12,
SpvOpTypeMatrix = 13,
SpvOpTypeSampler = 14,
SpvOpTypeFilter = 15,
SpvOpTypeArray = 16,
SpvOpTypeRuntimeArray = 17,
SpvOpTypeStruct = 18,
SpvOpTypeOpaque = 19,
SpvOpTypePointer = 20,
SpvOpTypeFunction = 21,
SpvOpTypeEvent = 22,
SpvOpTypeDeviceEvent = 23,
SpvOpTypeReserveId = 24,
SpvOpTypeQueue = 25,
SpvOpTypePipe = 26,
SpvOpConstantTrue = 27,
SpvOpConstantFalse = 28,
SpvOpConstant = 29,
SpvOpConstantComposite = 30,
SpvOpConstantSampler = 31,
SpvOpConstantNullPointer = 32,
SpvOpConstantNullObject = 33,
SpvOpSpecConstantTrue = 34,
SpvOpSpecConstantFalse = 35,
SpvOpSpecConstant = 36,
SpvOpSpecConstantComposite = 37,
SpvOpVariable = 38,
SpvOpVariableArray = 39,
SpvOpFunction = 40,
SpvOpFunctionParameter = 41,
SpvOpFunctionEnd = 42,
SpvOpFunctionCall = 43,
SpvOpExtInst = 44,
SpvOpUndef = 45,
SpvOpLoad = 46,
SpvOpStore = 47,
SpvOpPhi = 48,
SpvOpDecorationGroup = 49,
SpvOpDecorate = 50,
SpvOpMemberDecorate = 51,
SpvOpGroupDecorate = 52,
SpvOpGroupMemberDecorate = 53,
SpvOpName = 54,
SpvOpMemberName = 55,
SpvOpString = 56,
SpvOpLine = 57,
SpvOpVectorExtractDynamic = 58,
SpvOpVectorInsertDynamic = 59,
SpvOpVectorShuffle = 60,
SpvOpCompositeConstruct = 61,
SpvOpCompositeExtract = 62,
SpvOpCompositeInsert = 63,
SpvOpCopyObject = 64,
SpvOpCopyMemory = 65,
SpvOpCopyMemorySized = 66,
SpvOpSampler = 67,
SpvOpTextureSample = 68,
SpvOpTextureSampleDref = 69,
SpvOpTextureSampleLod = 70,
SpvOpTextureSampleProj = 71,
SpvOpTextureSampleGrad = 72,
SpvOpTextureSampleOffset = 73,
SpvOpTextureSampleProjLod = 74,
SpvOpTextureSampleProjGrad = 75,
SpvOpTextureSampleLodOffset = 76,
SpvOpTextureSampleProjOffset = 77,
SpvOpTextureSampleGradOffset = 78,
SpvOpTextureSampleProjLodOffset = 79,
SpvOpTextureSampleProjGradOffset = 80,
SpvOpTextureFetchTexelLod = 81,
SpvOpTextureFetchTexelOffset = 82,
SpvOpTextureFetchSample = 83,
SpvOpTextureFetchTexel = 84,
SpvOpTextureGather = 85,
SpvOpTextureGatherOffset = 86,
SpvOpTextureGatherOffsets = 87,
SpvOpTextureQuerySizeLod = 88,
SpvOpTextureQuerySize = 89,
SpvOpTextureQueryLod = 90,
SpvOpTextureQueryLevels = 91,
SpvOpTextureQuerySamples = 92,
SpvOpAccessChain = 93,
SpvOpInBoundsAccessChain = 94,
SpvOpSNegate = 95,
SpvOpFNegate = 96,
SpvOpNot = 97,
SpvOpAny = 98,
SpvOpAll = 99,
SpvOpConvertFToU = 100,
SpvOpConvertFToS = 101,
SpvOpConvertSToF = 102,
SpvOpConvertUToF = 103,
SpvOpUConvert = 104,
SpvOpSConvert = 105,
SpvOpFConvert = 106,
SpvOpConvertPtrToU = 107,
SpvOpConvertUToPtr = 108,
SpvOpPtrCastToGeneric = 109,
SpvOpGenericCastToPtr = 110,
SpvOpBitcast = 111,
SpvOpTranspose = 112,
SpvOpIsNan = 113,
SpvOpIsInf = 114,
SpvOpIsFinite = 115,
SpvOpIsNormal = 116,
SpvOpSignBitSet = 117,
SpvOpLessOrGreater = 118,
SpvOpOrdered = 119,
SpvOpUnordered = 120,
SpvOpArrayLength = 121,
SpvOpIAdd = 122,
SpvOpFAdd = 123,
SpvOpISub = 124,
SpvOpFSub = 125,
SpvOpIMul = 126,
SpvOpFMul = 127,
SpvOpUDiv = 128,
SpvOpSDiv = 129,
SpvOpFDiv = 130,
SpvOpUMod = 131,
SpvOpSRem = 132,
SpvOpSMod = 133,
SpvOpFRem = 134,
SpvOpFMod = 135,
SpvOpVectorTimesScalar = 136,
SpvOpMatrixTimesScalar = 137,
SpvOpVectorTimesMatrix = 138,
SpvOpMatrixTimesVector = 139,
SpvOpMatrixTimesMatrix = 140,
SpvOpOuterProduct = 141,
SpvOpDot = 142,
SpvOpShiftRightLogical = 143,
SpvOpShiftRightArithmetic = 144,
SpvOpShiftLeftLogical = 145,
SpvOpLogicalOr = 146,
SpvOpLogicalXor = 147,
SpvOpLogicalAnd = 148,
SpvOpBitwiseOr = 149,
SpvOpBitwiseXor = 150,
SpvOpBitwiseAnd = 151,
SpvOpSelect = 152,
SpvOpIEqual = 153,
SpvOpFOrdEqual = 154,
SpvOpFUnordEqual = 155,
SpvOpINotEqual = 156,
SpvOpFOrdNotEqual = 157,
SpvOpFUnordNotEqual = 158,
SpvOpULessThan = 159,
SpvOpSLessThan = 160,
SpvOpFOrdLessThan = 161,
SpvOpFUnordLessThan = 162,
SpvOpUGreaterThan = 163,
SpvOpSGreaterThan = 164,
SpvOpFOrdGreaterThan = 165,
SpvOpFUnordGreaterThan = 166,
SpvOpULessThanEqual = 167,
SpvOpSLessThanEqual = 168,
SpvOpFOrdLessThanEqual = 169,
SpvOpFUnordLessThanEqual = 170,
SpvOpUGreaterThanEqual = 171,
SpvOpSGreaterThanEqual = 172,
SpvOpFOrdGreaterThanEqual = 173,
SpvOpFUnordGreaterThanEqual = 174,
SpvOpDPdx = 175,
SpvOpDPdy = 176,
SpvOpFwidth = 177,
SpvOpDPdxFine = 178,
SpvOpDPdyFine = 179,
SpvOpFwidthFine = 180,
SpvOpDPdxCoarse = 181,
SpvOpDPdyCoarse = 182,
SpvOpFwidthCoarse = 183,
SpvOpEmitVertex = 184,
SpvOpEndPrimitive = 185,
SpvOpEmitStreamVertex = 186,
SpvOpEndStreamPrimitive = 187,
SpvOpControlBarrier = 188,
SpvOpMemoryBarrier = 189,
SpvOpImagePointer = 190,
SpvOpAtomicInit = 191,
SpvOpAtomicLoad = 192,
SpvOpAtomicStore = 193,
SpvOpAtomicExchange = 194,
SpvOpAtomicCompareExchange = 195,
SpvOpAtomicCompareExchangeWeak = 196,
SpvOpAtomicIIncrement = 197,
SpvOpAtomicIDecrement = 198,
SpvOpAtomicIAdd = 199,
SpvOpAtomicISub = 200,
SpvOpAtomicUMin = 201,
SpvOpAtomicUMax = 202,
SpvOpAtomicAnd = 203,
SpvOpAtomicOr = 204,
SpvOpAtomicXor = 205,
SpvOpLoopMerge = 206,
SpvOpSelectionMerge = 207,
SpvOpLabel = 208,
SpvOpBranch = 209,
SpvOpBranchConditional = 210,
SpvOpSwitch = 211,
SpvOpKill = 212,
SpvOpReturn = 213,
SpvOpReturnValue = 214,
SpvOpUnreachable = 215,
SpvOpLifetimeStart = 216,
SpvOpLifetimeStop = 217,
SpvOpCompileFlag = 218,
SpvOpAsyncGroupCopy = 219,
SpvOpWaitGroupEvents = 220,
SpvOpGroupAll = 221,
SpvOpGroupAny = 222,
SpvOpGroupBroadcast = 223,
SpvOpGroupIAdd = 224,
SpvOpGroupFAdd = 225,
SpvOpGroupFMin = 226,
SpvOpGroupUMin = 227,
SpvOpGroupSMin = 228,
SpvOpGroupFMax = 229,
SpvOpGroupUMax = 230,
SpvOpGroupSMax = 231,
SpvOpGenericCastToPtrExplicit = 232,
SpvOpGenericPtrMemSemantics = 233,
SpvOpReadPipe = 234,
SpvOpWritePipe = 235,
SpvOpReservedReadPipe = 236,
SpvOpReservedWritePipe = 237,
SpvOpReserveReadPipePackets = 238,
SpvOpReserveWritePipePackets = 239,
SpvOpCommitReadPipe = 240,
SpvOpCommitWritePipe = 241,
SpvOpIsValidReserveId = 242,
SpvOpGetNumPipePackets = 243,
SpvOpGetMaxPipePackets = 244,
SpvOpGroupReserveReadPipePackets = 245,
SpvOpGroupReserveWritePipePackets = 246,
SpvOpGroupCommitReadPipe = 247,
SpvOpGroupCommitWritePipe = 248,
SpvOpEnqueueMarker = 249,
SpvOpEnqueueKernel = 250,
SpvOpGetKernelNDrangeSubGroupCount = 251,
SpvOpGetKernelNDrangeMaxSubGroupSize = 252,
SpvOpGetKernelWorkGroupSize = 253,
SpvOpGetKernelPreferredWorkGroupSizeMultiple = 254,
SpvOpRetainEvent = 255,
SpvOpReleaseEvent = 256,
SpvOpCreateUserEvent = 257,
SpvOpIsValidEvent = 258,
SpvOpSetUserEventStatus = 259,
SpvOpCaptureEventProfilingInfo = 260,
SpvOpGetDefaultQueue = 261,
SpvOpBuildNDRange = 262,
SpvOpSatConvertSToU = 263,
SpvOpSatConvertUToS = 264,
SpvOpAtomicIMin = 265,
SpvOpAtomicIMax = 266,
} SpvOp;
#endif // #ifndef __cplusplus
#endif // #ifndef spirv_H
......@@ -60,14 +60,21 @@ namespace spv {
class Function;
class Module;
const Id NoResult = 0;
const Id NoType = 0;
const unsigned int BadValue = 0xFFFFFFFF;
const Decoration NoPrecision = (Decoration)BadValue;
const MemorySemanticsMask MemorySemanticsAllMemory = (MemorySemanticsMask)0x3FF;
//
// SPIR-V IR instruction.
//
class Instruction {
public:
Instruction(Id resultId, Id typeId, OpCode opCode) : resultId(resultId), typeId(typeId), opCode(opCode), string(0) { }
explicit Instruction(OpCode opCode) : resultId(NoResult), typeId(NoType), opCode(opCode), string(0) { }
Instruction(Id resultId, Id typeId, Op opCode) : resultId(resultId), typeId(typeId), opCode(opCode), string(0) { }
explicit Instruction(Op opCode) : resultId(NoResult), typeId(NoType), opCode(opCode), string(0) { }
virtual ~Instruction()
{
delete string;
......@@ -103,7 +110,7 @@ public:
originalString = str;
}
OpCode getOpCode() const { return opCode; }
Op getOpCode() const { return opCode; }
int getNumOperands() const { return operands.size(); }
Id getResultId() const { return resultId; }
Id getTypeId() const { return typeId; }
......@@ -143,7 +150,7 @@ protected:
Instruction(const Instruction&);
Id resultId;
Id typeId;
OpCode opCode;
Op opCode;
std::vector<Id> operands;
std::vector<unsigned int>* string; // usually non-existent
std::string originalString; // could be optimized away; convenience for getting string operand
......@@ -310,7 +317,7 @@ __inline Function::Function(Id id, Id resultType, Id functionType, Id firstParam
: parent(parent), functionInstruction(id, resultType, OpFunction)
{
// OpFunction
functionInstruction.addImmediateOperand(FunctionControlNone);
functionInstruction.addImmediateOperand(FunctionControlMaskNone);
functionInstruction.addIdOperand(functionType);
parent.mapInstruction(&functionInstruction);
parent.addFunction(this);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment