Update core instruction syntax to Rev32

Many instructions added and a few changed structure.

Workarounds:
- Some operands can be enabled by either one of two
  capabilities.  The spv_operand_desc_t does not handle that
  now. For now just select the first one.

Fixes to tests:
- OpLoopMerge now takes a mandatory continue target.
- OpTypePipe drops the type argument.  Pipes are opaque.
- OpLine no longer takes a target ID argument.

The ID validator was fixed the OpLine and OpTypePipe
changes.  Those were the only ID validator tests affected.

The patch to the spec doc generator was updated so it handles
the two-capability case, even if in an hacky way.
This commit is contained in:
David Neto 2015-09-24 15:45:59 -04:00
parent 6b31ce4d50
commit e0890da603
7 changed files with 83 additions and 85 deletions

View File

@ -1,5 +1,5 @@
diff --git a/tools/spirv/CMakeLists.txt b/tools/spirv/CMakeLists.txt
index 6b47799..7b687e4 100644
index af51f86..5775510 100644
--- a/tools/spirv/CMakeLists.txt
+++ b/tools/spirv/CMakeLists.txt
@@ -12,6 +12,7 @@ include_directories(../..)
@ -12,10 +12,10 @@ index 6b47799..7b687e4 100644
doc.cpp
diff --git a/tools/spirv/assembler_table.cpp b/tools/spirv/assembler_table.cpp
new file mode 100644
index 0000000..63ea9a5
index 0000000..5a68ade
--- /dev/null
+++ b/tools/spirv/assembler_table.cpp
@@ -0,0 +1,194 @@
@@ -0,0 +1,200 @@
+// Copyright (c) 2015 The Khronos Group Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
@ -170,11 +170,16 @@ index 0000000..63ea9a5
+ out << inst.operands.getNum() << ", ";
+
+ // Emit the capability, if any.
+ // We only handle 0 or 1 capabiliites.
+ // The SPIR-V tools doesn't handle the concept of depending on more than
+ // one capability. So call it out separately. Currently the biggest case
+ // is 2. This is a big hack.
+ out << inst.capabilities.size() << ", ";
+ assert(inst.capabilities.size() < 2);
+ if (inst.capabilities.size()) {
+ assert(inst.capabilities.size() < 3);
+ if (inst.capabilities.size() == 1) {
+ out << "Capability(" << CapabilityString(inst.capabilities[0]) << "), ";
+ } else if (inst.capabilities.size() == 2) {
+ out << "Capability2(" << CapabilityString(inst.capabilities[0]) << ","
+ << CapabilityString(inst.capabilities[1]) << "), ";
+ } else {
+ out << "Capability(None), ";
+ }
@ -195,6 +200,7 @@ index 0000000..63ea9a5
+ << "// numLogicalOperands - does not include result id or type id\n"
+ << "// numCapabilities - we only handle 0 or 1 required capabilities\n"
+ << "// Capability(<capability-name>) - capability required to use this instruction. Might be None.\n"
+ << "// There can be Capability2(a,b) for dependence on two capabilities.\n"
+ << "// {0|1} - whether the instruction is variable number of words\n"
+ << "// EmptyList or List(...) - list of classes of logical operands\n"
+ << "// Example use:\n"
@ -258,7 +264,7 @@ index 0000000..03ab769
+
+#endif // ASSEMBLER_TABLE_H
diff --git a/tools/spirv/doc.h b/tools/spirv/doc.h
index 2b326e9..d16febb 100644
index 78b1031..5984835 100644
--- a/tools/spirv/doc.h
+++ b/tools/spirv/doc.h
@@ -81,6 +81,7 @@ const char* KernelEnqueueFlagsString(int);
@ -281,11 +287,11 @@ index 2b326e9..d16febb 100644
};
diff --git a/tools/spirv/main.cpp b/tools/spirv/main.cpp
index d10bd2a..b825974 100644
index d7312f9..c856271 100644
--- a/tools/spirv/main.cpp
+++ b/tools/spirv/main.cpp
@@ -46,6 +46,7 @@ namespace spv {
#include "headers/OpenCLLib.h"
#include "headers/OpenCL.std.h"
// This tool's includes
+#include "assembler_table.h"

View File

@ -47,6 +47,13 @@ spv_opcode_desc_t opcodeTableEntries[] = {
#define List(...) {__VA_ARGS__}
#define Capability(X) Capability##X
#define CapabilityNone -1
// TODO(dneto): Some things can be enabled by one of two different capabilities.
// The capabilities field in spv_operand_desc_t can't handle that yet.
// Maybe have to make it a 64-bit mask. Currently there are 54 distinct
// capabilities.
// For now, just select the first one. This must be fixed for the validator
// to work.
#define Capability2(X,Y) Capability##X
#define Instruction(Name,HasResult,HasType,NumLogicalOperands,NumCapabilities,CapabilityRequired,IsVariable,LogicalArgsList) \
{ #Name, \
Op##Name, \

View File

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

View File

@ -170,13 +170,7 @@ bool idUsage::isValid<OpMemberName>(const spv_instruction_t *inst,
template <>
bool idUsage::isValid<OpLine>(const spv_instruction_t *inst,
const spv_opcode_desc) {
auto targetIndex = 1;
auto target = find(inst->words[targetIndex]);
spvCheck(!found(target), DIAG(targetIndex) << "OpLine Target <id> '"
<< inst->words[targetIndex]
<< "' is not defined.";
return false);
auto fileIndex = 2;
auto fileIndex = 1;
auto file = find(inst->words[fileIndex]);
spvCheck(!found(file), DIAG(fileIndex) << "OpLine Target <id> '"
<< inst->words[fileIndex]
@ -525,18 +519,9 @@ bool idUsage::isValid<OpTypeFunction>(const spv_instruction_t *inst,
}
template <>
bool idUsage::isValid<OpTypePipe>(const spv_instruction_t *inst,
bool idUsage::isValid<OpTypePipe>(const spv_instruction_t *,
const spv_opcode_desc) {
auto typeIndex = 2;
auto type = find(inst->words[typeIndex]);
spvCheck(!found(type), DIAG(typeIndex) << "OpTypePipe Type <id> '"
<< inst->words[typeIndex]
<< "' is not defined.";
return false);
spvCheck(!spvOpcodeIsType(type->second.opcode),
DIAG(typeIndex) << "OpTypePipe Type <id> '" << inst->words[typeIndex]
<< "' is not a type.";
return false);
// OpTypePipe has no ID arguments.
return true;
}

View File

@ -74,10 +74,10 @@ using OpLoopMergeTest = spvtest::TextToBinaryTestBase<
::testing::TestWithParam<EnumCase<spv::LoopControlMask>>>;
TEST_P(OpLoopMergeTest, AnySingleLoopControlMask) {
std::string input = "OpLoopMerge %1 " + GetParam().name();
std::string input = "OpLoopMerge %merge %continue " + GetParam().name();
EXPECT_THAT(
CompiledInstructions(input),
Eq(MakeInstruction(spv::OpLoopMerge, {1, GetParam().value()})));
Eq(MakeInstruction(spv::OpLoopMerge, {1, 2, GetParam().value()})));
}
// clang-format off
@ -92,11 +92,11 @@ INSTANTIATE_TEST_CASE_P(TextToBinaryLoopMerge, OpLoopMergeTest,
// clang-format on
TEST_F(OpLoopMergeTest, CombinedLoopControlMask) {
const std::string input = "OpLoopMerge %1 Unroll|DontUnroll";
const std::string input = "OpLoopMerge %merge %continue Unroll|DontUnroll";
const uint32_t expected_mask =
spv::LoopControlUnrollMask | spv::LoopControlDontUnrollMask;
EXPECT_THAT(CompiledInstructions(input),
Eq(MakeInstruction(spv::OpLoopMerge, {1, expected_mask})));
Eq(MakeInstruction(spv::OpLoopMerge, {1, 2, expected_mask})));
}
// TODO(dneto): OpPhi

View File

@ -135,12 +135,9 @@ using OpTypePipeTest = spvtest::TextToBinaryTestBase<
::testing::TestWithParam<EnumCase<spv::AccessQualifier>>>;
TEST_P(OpTypePipeTest, AnyAccessQualifier) {
// TODO(dneto): In Rev31 and later, pipes are opaque, and so the %2, which
// is the type-of-element operand, should be dropped.
std::string input = "%1 = OpTypePipe %2 " + GetParam().name();
EXPECT_THAT(
CompiledInstructions(input),
Eq(MakeInstruction(spv::OpTypePipe, {1, 2, GetParam().value()})));
std::string input = "%1 = OpTypePipe " + GetParam().name();
EXPECT_THAT(CompiledInstructions(input),
Eq(MakeInstruction(spv::OpTypePipe, {1, GetParam().value()})));
}
// clang-format off

View File

@ -104,21 +104,17 @@ TEST_F(ValidateID, OpMemberNameMemberBad) {
}
TEST_F(ValidateID, OpLineGood) {
// TODO(dneto): OpLine changed after Rev31. It no longer has a first argument.
// The following is the Rev31 form.
const char *spirv = R"(
%1 = OpString "/path/to/source.file"
OpLine %4 %1 0 0
OpLine %1 0 0
%2 = OpTypeInt 32 0
%3 = OpTypePointer Generic %2
%4 = OpVariable %3 Generic)";
CHECK(spirv, SPV_SUCCESS);
}
TEST_F(ValidateID, OpLineFileBad) {
// TODO(dneto): OpLine changed after Rev31. It no longer has a first argument.
// The following is the Rev31 form.
const char *spirv = R"(
OpLine %4 %2 0 0
OpLine %2 0 0
%2 = OpTypeInt 32 0
%3 = OpTypePointer Generic %2
%4 = OpVariable %3 Generic)";
@ -386,16 +382,9 @@ TEST_F(ValidateID, OpTypePipeGood) {
const char *spirv = R"(
%1 = OpTypeFloat 32
%2 = OpTypeVector %1 16
%3 = OpTypePipe %2 ReadOnly)";
%3 = OpTypePipe ReadOnly)";
CHECK(spirv, SPV_SUCCESS);
}
TEST_F(ValidateID, OpTypePipeBad) {
const char *spirv = R"(
%1 = OpTypeFloat 32
%2 = OpConstant %1 0
%3 = OpTypePipe %2 ReadOnly)";
CHECK(spirv, SPV_ERROR_INVALID_ID);
}
TEST_F(ValidateID, OpConstantTrueGood) {
const char *spirv = R"(