mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-22 03:30:06 +00:00
Update readme about the "<result-id> = <opcode> <operand>..." format.
This commit is contained in:
parent
8a37520908
commit
902e5a8a52
54
readme.md
54
readme.md
@ -95,16 +95,34 @@ text names from that specification. Here is an example.
|
|||||||
```
|
```
|
||||||
OpCapability Shader
|
OpCapability Shader
|
||||||
OpMemoryModel Logical Simple
|
OpMemoryModel Logical Simple
|
||||||
OpEntryPoint GLCompute $3 "main"
|
OpEntryPoint GLCompute %3 "main"
|
||||||
OpExecutionMode $3 LocalSize 64 64 1
|
OpExecutionMode %3 LocalSize 64 64 1
|
||||||
OpTypeVoid %1
|
OpTypeVoid %1
|
||||||
OpTypeFunction %2 $1
|
OpTypeFunction %2 %1
|
||||||
OpFunction $1 %3 None $2
|
OpFunction %1 %3 None %2
|
||||||
OpLabel %4
|
OpLabel %4
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In order to improve the text's readability, the `<result-id>` generated by an
|
||||||
|
instruction can be moved to the beginning of that instruction and followed by
|
||||||
|
an `=` sign. This allows us to distinguish between variable defs and uses and
|
||||||
|
locate variable defs more easily. So, the above example can also be written as:
|
||||||
|
|
||||||
|
```
|
||||||
|
OpCapability Shader
|
||||||
|
OpMemoryModel Logical Simple
|
||||||
|
OpEntryPoint GLCompute %3 "main"
|
||||||
|
OpExecutionMode %3 LocalSize 64 64 1
|
||||||
|
%1 = OpTypeVoid
|
||||||
|
%2 = OpTypeFunction %1
|
||||||
|
%3 = OpFunction %1 None %2
|
||||||
|
%4 = OpLabel
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
```
|
||||||
|
|
||||||
Each line encapsulates one and only one instruction, or an OpCode and all of its
|
Each line encapsulates one and only one instruction, or an OpCode and all of its
|
||||||
operands. OpCodes use the names provided in section 3.28 Instructions of the
|
operands. OpCodes use the names provided in section 3.28 Instructions of the
|
||||||
SPIR-V specification, immediate values such as Addressing Model, Memory Model,
|
SPIR-V specification, immediate values such as Addressing Model, Memory Model,
|
||||||
@ -114,11 +132,9 @@ Capability of the SPIR-V specification. Literals strings are enclosed in quotes
|
|||||||
|
|
||||||
##### ID Definitions & Usage
|
##### ID Definitions & Usage
|
||||||
|
|
||||||
An ID definition pertains to the `Result <id>` of an OpCode, and ID usage is any
|
An ID definition pertains to the `<result-id>` of an OpCode, and ID usage is any
|
||||||
input to an OpCode. To differentiate between definitions and uses, all ID
|
input to an OpCode. All IDs are prefixed with `%`. To differentiate between
|
||||||
definitions are prefixed with `%` and take the form `%<id>`, meanwhile all ID
|
defs and uses, we suggest using the second format shown in the above.
|
||||||
uses are prefixed with `$` and take the form `$<id>`. See the above example to
|
|
||||||
see this in action.
|
|
||||||
|
|
||||||
##### Named IDs
|
##### Named IDs
|
||||||
|
|
||||||
@ -128,16 +144,16 @@ apply. Names must begin with an character in the range `[a-z|A-Z]`. The
|
|||||||
following example will result in identical SPIR-V binary as the example above.
|
following example will result in identical SPIR-V binary as the example above.
|
||||||
|
|
||||||
```
|
```
|
||||||
OpCapability Shader
|
OpCapability Shader
|
||||||
OpMemoryModel Logical Simple
|
OpMemoryModel Logical Simple
|
||||||
OpEntryPoint GLCompute $main "main"
|
OpEntryPoint GLCompute %main "main"
|
||||||
OpExecutionMode $main LocalSize 64 64 1
|
OpExecutionMode %main LocalSize 64 64 1
|
||||||
OpTypeVoid %void
|
%void = OpTypeVoid
|
||||||
OpTypeFunction %fnMain $void
|
%fnMain = OpTypeFunction %void
|
||||||
OpFunction $void %main None $fnMain
|
%main = OpFunction %void None %fnMain
|
||||||
OpLabel %lbMain
|
%lbMain = OpLabel
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Arbitrary Integers
|
##### Arbitrary Integers
|
||||||
|
Loading…
Reference in New Issue
Block a user