MLIR

Multi-Level IR Compiler Framework

SPIR-V Dialect

This document describes the design of the SPIR-V dialect in MLIR. It lists various design choices we made for modeling different SPIR-V mechanisms, and their rationale.

This document also explains in a high-level manner how different components are organized and implemented in the code and gives steps to follow for extending them.

This document assumes familiarity with SPIR-V. SPIR-V is the Khronos Group’s binary intermediate language for representing graphics shaders and compute kernels. It is adopted by multiple Khronos Group’s APIs, including Vulkan and OpenCL. It is fully defined in a human-readable specification; the syntax of various SPIR-V instructions are encoded in a machine-readable grammar.

Design Guidelines 

SPIR-V is a binary intermediate language that serves dual purpose: on one side, it is an intermediate language to represent graphics shaders and compute kernels for high-level languages to target; on the other side, it defines a stable binary format for hardware driver consumption. As a result, SPIR-V has design principles pertain to not only intermediate language, but also binary format. For example, regularity is one of the design goals of SPIR-V. All concepts are represented as SPIR-V instructions, including declaring extensions and capabilities, defining types and constants, defining functions, attaching additional properties to computation results, etc. This way favors binary encoding and decoding for driver consumption but not necessarily compiler transformations.

Dialect design principles 

The main objective of the SPIR-V dialect is to be a proper intermediate representation (IR) to facilitate compiler transformations. While we still aim to support serializing to and deserializing from the binary format for various good reasons, the binary format and its concerns play less a role in the design of the SPIR-V dialect: when there is a trade-off to be made between favoring IR and supporting binary format, we lean towards the former.

On the IR aspect, the SPIR-V dialect aims to model SPIR-V at the same semantic level. It is not intended to be a higher level or lower level abstraction than the SPIR-V specification. Those abstractions are easily outside the domain of SPIR-V and should be modeled with other proper dialects so they can be shared among various compilation paths. Because of the dual purpose of SPIR-V, SPIR-V dialect staying at the same semantic level as the SPIR-V specification also means we can still have straightforward serialization and deserialization for the majority of functionalities.

To summarize, the SPIR-V dialect follows the following design principles:

  • Stay as the same semantic level as the SPIR-V specification by having one-to-one mapping for most concepts and entities.
  • Adopt SPIR-V specification’s syntax if possible, but deviate intentionally to utilize MLIR mechanisms if it results in better representation and benefits transformation.
  • Be straightforward to serialize into and deserialize from the SPIR-V binary format.

SPIR-V is designed to be consumed by hardware drivers, so its representation is quite clear, yet verbose for some cases. Allowing representational deviation gives us the flexibility to reduce the verbosity by using MLIR mechanisms.

Dialect scopes 

SPIR-V supports multiple execution environments, specified by client APIs. Notable adopters include Vulkan and OpenCL. It follows that the SPIR-V dialect should support multiple execution environments if to be a proper proxy of SPIR-V in MLIR systems. The SPIR-V dialect is designed with these considerations: it has proper support for versions, extensions, and capabilities and is as extensible as SPIR-V specification.

Conventions 

The SPIR-V dialect adopts the following conventions for IR:

  • The prefix for all SPIR-V types and operations are spirv..
  • All instructions in an extended instruction set are further qualified with the extended instruction set’s prefix. For example, all operations in the GLSL extended instruction set have the prefix of spirv.GL..
  • Ops that directly mirror instructions in the specification have CamelCase names that are the same as the instruction opnames (without the Op prefix). For example, spirv.FMul is a direct mirror of OpFMul in the specification. Such an op will be serialized into and deserialized from one SPIR-V instruction.
  • Ops with snake_case names are those that have different representation from corresponding instructions (or concepts) in the specification. These ops are mostly for defining the SPIR-V structure. For example, spirv.module and spirv.Constant. They may correspond to one or more instructions during (de)serialization.
  • Ops with mlir.snake_case names are those that have no corresponding instructions (or concepts) in the binary format. They are introduced to satisfy MLIR structural requirements. For example, spirv.mlir.merge. They map to no instructions during (de)serialization.

(TODO: consider merging the last two cases and adopting spirv.mlir. prefix for them.)

Module 

A SPIR-V module is defined via the spirv.module op, which has one region that contains one block. Model-level instructions, including function definitions, are all placed inside the block. Functions are defined using the builtin func op.

We choose to model a SPIR-V module with a dedicated spirv.module op based on the following considerations:

  • It maps cleanly to a SPIR-V module in the specification.
  • We can enforce SPIR-V specific verification that is suitable to be performed at the module-level.
  • We can attach additional model-level attributes.
  • We can control custom assembly form.

The spirv.module op’s region cannot capture SSA values from outside, neither implicitly nor explicitly. The spirv.module op’s region is closed as to what ops can appear inside: apart from the builtin func op, it can only contain ops from the SPIR-V dialect. The spirv.module op’s verifier enforces this rule. This meaningfully guarantees that a spirv.module can be the entry point and boundary for serialization.

Module-level operations 

SPIR-V binary format defines the following sections:

  1. Capabilities required by the module.
  2. Extensions required by the module.
  3. Extended instructions sets required by the module.
  4. Addressing and memory model specification.
  5. Entry point specifications.
  6. Execution mode declarations.
  7. Debug instructions.
  8. Annotation/decoration instructions.
  9. Type, constant, global variables.
  10. Function declarations.
  11. Function definitions.

Basically, a SPIR-V binary module contains multiple module-level instructions followed by a list of functions. Those module-level instructions are essential and they can generate result ids referenced by functions, notably, declaring resource variables to interact with the execution environment.

Compared to the binary format, we adjust how these module-level SPIR-V instructions are represented in the SPIR-V dialect:

Use MLIR attributes for metadata 

  • Requirements for capabilities, extensions, extended instruction sets, addressing model, and memory model are conveyed using spirv.module attributes. This is considered better because these information are for the execution environment. It’s easier to probe them if on the module op itself.
  • Annotations/decoration instructions are “folded” into the instructions they decorate and represented as attributes on those ops. This eliminates potential forward references of SSA values, improves IR readability, and makes querying the annotations more direct. More discussions can be found in the Decorations section.

Model types with MLIR custom types 

  • Types are represented using MLIR builtin types and SPIR-V dialect specific types. There are no type declaration ops in the SPIR-V dialect. More discussions can be found in the Types section later.

Unify and localize constants 

  • Various normal constant instructions are represented by the same spirv.Constant op. Those instructions are just for constants of different types; using one op to represent them reduces IR verbosity and makes transformations less tedious.
  • Normal constants are not placed in spirv.module’s region; they are localized into functions. This is to make functions in the SPIR-V dialect to be isolated and explicit capturing. Constants are cheap to duplicate given attributes are made unique in MLIRContext.

Adopt symbol-based global variables and specialization constant 

  • Global variables are defined with the spirv.GlobalVariable op. They do not generate SSA values. Instead they have symbols and should be referenced via symbols. To use global variables in a function block, spirv.mlir.addressof is needed to turn the symbol into an SSA value.
  • Specialization constants are defined with the spirv.SpecConstant op. Similar to global variables, they do not generate SSA values and have symbols for reference, too. spirv.mlir.referenceof is needed to turn the symbol into an SSA value for use in a function block.

The above choices enables functions in the SPIR-V dialect to be isolated and explicit capturing.

Disallow implicit capturing in functions 

  • In SPIR-V specification, functions support implicit capturing: they can reference SSA values defined in modules. In the SPIR-V dialect functions are defined with func op, which disallows implicit capturing. This is more friendly to compiler analyses and transformations. More discussions can be found in the Function section later.

Model entry points and execution models as normal ops 

  • A SPIR-V module can have multiple entry points. And these entry points refer to the function and interface variables. It’s not suitable to model them as spirv.module op attributes. We can model them as normal ops of using symbol references.
  • Similarly for execution modes, which are coupled with entry points, we can model them as normal ops in spirv.module’s region.

Decorations 

Annotations/decorations provide additional information on result ids. In SPIR-V, all instructions can generate result ids, including value-computing and type-defining ones.

For decorations on value result ids, we can just have a corresponding attribute attached to the operation generating the SSA value. For example, for the following SPIR-V:

OpDecorate %v1 RelaxedPrecision
OpDecorate %v2 NoContraction
...
%v1 = OpFMul %float %0 %0
%v2 = OpFMul %float %1 %1

We can represent them in the SPIR-V dialect as:

%v1 = "spirv.FMul"(%0, %0) {RelaxedPrecision: unit} : (f32, f32) -> (f32)
%v2 = "spirv.FMul"(%1, %1) {NoContraction: unit} : (f32, f32) -> (f32)

This approach benefits transformations. Essentially those decorations are just additional properties of the result ids (and thus their defining instructions). In SPIR-V binary format, they are just represented as instructions. Literally following SPIR-V binary format means we need to through def-use chains to find the decoration instructions and query information from them.

For decorations on type result ids, notice that practically, only result ids generated from composite types (e.g., OpTypeArray, OpTypeStruct) need to be decorated for memory layouting purpose (e.g., ArrayStride, Offset, etc.); scalar/vector types are required to be uniqued in SPIR-V. Therefore, we can just encode them directly in the dialect-specific type.

Types 

Theoretically we can define all SPIR-V types using MLIR extensible type system, but other than representational purity, it does not buy us more. Instead, we need to maintain the code and invest in pretty printing them. So we prefer to use builtin types if possible.

The SPIR-V dialect reuses builtin integer, float, and vector types:

SpecificationDialect
OpTypeBooli1
OpTypeFloat <bitwidth>f<bitwidth>
OpTypeVector <scalar-type> <count>vector<<count> x <scalar-type>>

For integer types, the SPIR-V dialect supports all signedness semantics (signless, signed, unsigned) in order to ease transformations from higher level dialects. However, SPIR-V spec only defines two signedness semantics state: 0 indicates unsigned, or no signedness semantics, 1 indicates signed semantics. So both iN and uiN are serialized into the same OpTypeInt N 0. For deserialization, we always treat OpTypeInt N 0 as iN.

mlir::NoneType is used for SPIR-V OpTypeVoid; builtin function types are used for SPIR-V OpTypeFunction types.

The SPIR-V dialect and defines the following dialect-specific types:

spirv-type ::= array-type
             | image-type
             | pointer-type
             | runtime-array-type
             | sampled-image-type
             | struct-type

Array type 

This corresponds to SPIR-V array type. Its syntax is

element-type ::= integer-type
               | floating-point-type
               | vector-type
               | spirv-type

array-type ::= `!spirv.array` `<` integer-literal `x` element-type
               (`,` `stride` `=` integer-literal)? `>`

For example,

!spirv.array<4 x i32>
!spirv.array<4 x i32, stride = 4>
!spirv.array<16 x vector<4 x f32>>

Image type 

This corresponds to SPIR-V image type. Its syntax is

dim ::= `1D` | `2D` | `3D` | `Cube` | <and other SPIR-V Dim specifiers...>

depth-info ::= `NoDepth` | `IsDepth` | `DepthUnknown`

arrayed-info ::= `NonArrayed` | `Arrayed`

sampling-info ::= `SingleSampled` | `MultiSampled`

sampler-use-info ::= `SamplerUnknown` | `NeedSampler` | `NoSampler`

format ::= `Unknown` | `Rgba32f` | <and other SPIR-V Image Formats...>

image-type ::= `!spirv.image<` element-type `,` dim `,` depth-info `,`
                           arrayed-info `,` sampling-info `,`
                           sampler-use-info `,` format `>`

For example,

!spirv.image<f32, 1D, NoDepth, NonArrayed, SingleSampled, SamplerUnknown, Unknown>
!spirv.image<f32, Cube, IsDepth, Arrayed, MultiSampled, NeedSampler, Rgba32f>

Pointer type 

This corresponds to SPIR-V pointer type. Its syntax is

storage-class ::= `UniformConstant`
                | `Uniform`
                | `Workgroup`
                | <and other storage classes...>

pointer-type ::= `!spirv.ptr<` element-type `,` storage-class `>`

For example,

!spirv.ptr<i32, Function>
!spirv.ptr<vector<4 x f32>, Uniform>

Runtime array type 

This corresponds to SPIR-V runtime array type. Its syntax is

runtime-array-type ::= `!spirv.rtarray` `<` element-type (`,` `stride` `=` integer-literal)? `>`

For example,

!spirv.rtarray<i32>
!spirv.rtarray<i32, stride=4>
!spirv.rtarray<vector<4 x f32>>

Sampled image type 

This corresponds to SPIR-V sampled image type. Its syntax is

sampled-image-type ::= `!spirv.sampled_image<!spirv.image<` element-type `,` dim `,` depth-info `,`
                                                        arrayed-info `,` sampling-info `,`
                                                        sampler-use-info `,` format `>>`

For example,

!spirv.sampled_image<!spirv.image<f32, Dim1D, NoDepth, NonArrayed, SingleSampled, NoSampler, Unknown>>
!spirv.sampled_image<!spirv.image<i32, Rect, DepthUnknown, Arrayed, MultiSampled, NeedSampler, R8ui>>

Struct type 

This corresponds to SPIR-V struct type. Its syntax is

struct-member-decoration ::= integer-literal? spirv-decoration*
struct-type ::= `!spirv.struct<` spirv-type (`[` struct-member-decoration `]`)?
                     (`, ` spirv-type (`[` struct-member-decoration `]`)? `>`

For Example,

!spirv.struct<f32>
!spirv.struct<f32 [0]>
!spirv.struct<f32, !spirv.image<f32, 1D, NoDepth, NonArrayed, SingleSampled, SamplerUnknown, Unknown>>
!spirv.struct<f32 [0], i32 [4]>

Function 

In SPIR-V, a function construct consists of multiple instructions involving OpFunction, OpFunctionParameter, OpLabel, OpFunctionEnd.

// int f(int v) { return v; }
%1 = OpTypeInt 32 0
%2 = OpTypeFunction %1 %1
%3 = OpFunction %1 %2
%4 = OpFunctionParameter %1
%5 = OpLabel
%6 = OpReturnValue %4
     OpFunctionEnd

This construct is very clear yet quite verbose. It is intended for driver consumption. There is little benefit to literally replicate this construct in the SPIR-V dialect. Instead, we reuse the builtin func op to express functions more concisely:

func.func @f(%arg: i32) -> i32 {
  "spirv.ReturnValue"(%arg) : (i32) -> (i32)
}

A SPIR-V function can have at most one result. It cannot contain nested functions or non-SPIR-V operations. spirv.module verifies these requirements.

A major difference between the SPIR-V dialect and the SPIR-V specification for functions is that the former are isolated and require explicit capturing, while the latter allows implicit capturing. In SPIR-V specification, functions can refer to SSA values (generated by constants, global variables, etc.) defined in modules. The SPIR-V dialect adjusted how constants and global variables are modeled to enable isolated functions. Isolated functions are more friendly to compiler analyses and transformations. This also enables the SPIR-V dialect to better utilize core infrastructure: many functionalities in the core infrastructure require ops to be isolated, e.g., the greedy pattern rewriter can only act on ops isolated from above.

(TODO: create a dedicated spirv.fn op for SPIR-V functions.)

Operations 

In SPIR-V, instruction is a generalized concept; a SPIR-V module is just a sequence of instructions. Declaring types, expressing computations, annotating result ids, expressing control flows and others are all in the form of instructions.

We only discuss instructions expressing computations here, which can be represented via SPIR-V dialect ops. Module-level instructions for declarations and definitions are represented differently in the SPIR-V dialect as explained earlier in the Module-level operations section.

An instruction computes zero or one result from zero or more operands. The result is a new result id. An operand can be a result id generated by a previous instruction, an immediate value, or a case of an enum type. We can model result id operands and results with MLIR SSA values; for immediate value and enum cases, we can model them with MLIR attributes.

For example,

%i32 = OpTypeInt 32 0
%c42 = OpConstant %i32 42
...
%3 = OpVariable %i32 Function 42
%4 = OpIAdd %i32 %c42 %c42

can be represented in the dialect as

%0 = "spirv.Constant"() { value = 42 : i32 } : () -> i32
%1 = "spirv.Variable"(%0) { storage_class = "Function" } : (i32) -> !spirv.ptr<i32, Function>
%2 = "spirv.IAdd"(%0, %0) : (i32, i32) -> i32

Operation documentation is written in each op’s Op Definition Spec using TableGen. A markdown version of the doc can be generated using mlir-tblgen -gen-doc and is attached in the Operation definitions section.

Ops from extended instruction sets 

Analogically extended instruction set is a mechanism to import SPIR-V instructions within another namespace. GLSL.std.450 is an extended instruction set that provides common mathematical routines that should be supported. Instead of modeling OpExtInstImport as a separate op and use a single op to model OpExtInst for all extended instructions, we model each SPIR-V instruction in an extended instruction set as a separate op with the proper name prefix. For example, for

%glsl = OpExtInstImport "GLSL.std.450"

%f32 = OpTypeFloat 32
%cst = OpConstant %f32 ...

%1 = OpExtInst %f32 %glsl 28 %cst
%2 = OpExtInst %f32 %glsl 31 %cst

we can have

%1 = "spirv.GL.Log"(%cst) : (f32) -> (f32)
%2 = "spirv.GL.Sqrt"(%cst) : (f32) -> (f32)

Control Flow 

SPIR-V binary format uses merge instructions (OpSelectionMerge and OpLoopMerge) to declare structured control flow. They explicitly declare a header block before the control flow diverges and a merge block where control flow subsequently converges. These blocks delimit constructs that must nest, and can only be entered and exited in structured ways.

In the SPIR-V dialect, we use regions to mark the boundary of a structured control flow construct. With this approach, it’s easier to discover all blocks belonging to a structured control flow construct. It is also more idiomatic to MLIR system.

We introduce a spirv.mlir.selection and spirv.mlir.loop op for structured selections and loops, respectively. The merge targets are the next ops following them. Inside their regions, a special terminator, spirv.mlir.merge is introduced for branching to the merge target.

Selection 

spirv.mlir.selection defines a selection construct. It contains one region. The region should contain at least two blocks: one selection header block and one merge block.

  • The selection header block should be the first block. It should contain the spirv.BranchConditional or spirv.Switch op.
  • The merge block should be the last block. The merge block should only contain a spirv.mlir.merge op. Any block can branch to the merge block for early exit.
               +--------------+
               | header block |                 (may have multiple outgoing branches)
               +--------------+
                    / | \
                     ...


   +---------+   +---------+   +---------+
   | case #0 |   | case #1 |   | case #2 |  ... (may have branches between each other)
   +---------+   +---------+   +---------+


                     ...
                    \ | /
                      v
               +-------------+
               | merge block |                  (may have multiple incoming branches)
               +-------------+

For example, for the given function

void loop(bool cond) {
  int x = 0;
  if (cond) {
    x = 1;
  } else {
    x = 2;
  }
  // ...
}

It will be represented as

func.func @selection(%cond: i1) -> () {
  %zero = spirv.Constant 0: i32
  %one = spirv.Constant 1: i32
  %two = spirv.Constant 2: i32
  %x = spirv.Variable init(%zero) : !spirv.ptr<i32, Function>

  spirv.mlir.selection {
    spirv.BranchConditional %cond, ^then, ^else

  ^then:
    spirv.Store "Function" %x, %one : i32
    spirv.Branch ^merge

  ^else:
    spirv.Store "Function" %x, %two : i32
    spirv.Branch ^merge

  ^merge:
    spirv.mlir.merge
  }

  // ...
}

Loop 

spirv.mlir.loop defines a loop construct. It contains one region. The region should contain at least four blocks: one entry block, one loop header block, one loop continue block, one merge block.

  • The entry block should be the first block and it should jump to the loop header block, which is the second block.
  • The merge block should be the last block. The merge block should only contain a spirv.mlir.merge op. Any block except the entry block can branch to the merge block for early exit.
  • The continue block should be the second to last block and it should have a branch to the loop header block.
  • The loop continue block should be the only block, except the entry block, branching to the loop header block.
    +-------------+
    | entry block |           (one outgoing branch)
    +-------------+
           |
           v
    +-------------+           (two incoming branches)
    | loop header | <-----+   (may have one or two outgoing branches)
    +-------------+       |
                          |
          ...             |
         \ | /            |
           v              |
   +---------------+      |   (may have multiple incoming branches)
   | loop continue | -----+   (may have one or two outgoing branches)
   +---------------+

          ...
         \ | /
           v
    +-------------+           (may have multiple incoming branches)
    | merge block |
    +-------------+

The reason to have another entry block instead of directly using the loop header block as the entry block is to satisfy region’s requirement: entry block of region may not have predecessors. We have a merge block so that branch ops can reference it as successors. The loop continue block here corresponds to “continue construct” using SPIR-V spec’s term; it does not mean the “continue block” as defined in the SPIR-V spec, which is “a block containing a branch to an OpLoopMerge instruction’s Continue Target.”

For example, for the given function

void loop(int count) {
  for (int i = 0; i < count; ++i) {
    // ...
  }
}

It will be represented as

func.func @loop(%count : i32) -> () {
  %zero = spirv.Constant 0: i32
  %one = spirv.Constant 1: i32
  %var = spirv.Variable init(%zero) : !spirv.ptr<i32, Function>

  spirv.mlir.loop {
    spirv.Branch ^header

  ^header:
    %val0 = spirv.Load "Function" %var : i32
    %cmp = spirv.SLessThan %val0, %count : i32
    spirv.BranchConditional %cmp, ^body, ^merge

  ^body:
    // ...
    spirv.Branch ^continue

  ^continue:
    %val1 = spirv.Load "Function" %var : i32
    %add = spirv.IAdd %val1, %one : i32
    spirv.Store "Function" %var, %add : i32
    spirv.Branch ^header

  ^merge:
    spirv.mlir.merge
  }
  return
}

Block argument for Phi 

There are no direct Phi operations in the SPIR-V dialect; SPIR-V OpPhi instructions are modelled as block arguments in the SPIR-V dialect. (See the Rationale doc for “Block Arguments vs Phi nodes”.) Each block argument corresponds to one OpPhi instruction in the SPIR-V binary format. For example, for the following SPIR-V function foo:

  %foo = OpFunction %void None ...
%entry = OpLabel
  %var = OpVariable %_ptr_Function_int Function
         OpSelectionMerge %merge None
         OpBranchConditional %true %true %false
 %true = OpLabel
         OpBranch %phi
%false = OpLabel
         OpBranch %phi
  %phi = OpLabel
  %val = OpPhi %int %int_1 %false %int_0 %true
         OpStore %var %val
         OpReturn
%merge = OpLabel
         OpReturn
         OpFunctionEnd

It will be represented as:

func.func @foo() -> () {
  %var = spirv.Variable : !spirv.ptr<i32, Function>

  spirv.mlir.selection {
    %true = spirv.Constant true
    spirv.BranchConditional %true, ^true, ^false

  ^true:
    %zero = spirv.Constant 0 : i32
    spirv.Branch ^phi(%zero: i32)

  ^false:
    %one = spirv.Constant 1 : i32
    spirv.Branch ^phi(%one: i32)

  ^phi(%arg: i32):
    spirv.Store "Function" %var, %arg : i32
    spirv.Return

  ^merge:
    spirv.mlir.merge
  }
  spirv.Return
}

Version, extensions, capabilities 

SPIR-V supports versions, extensions, and capabilities as ways to indicate the availability of various features (types, ops, enum cases) on target hardware. For example, non-uniform group operations were missing before v1.3, and they require special capabilities like GroupNonUniformArithmetic to be used. These availability information relates to target environment and affects the legality of patterns during dialect conversion.

SPIR-V ops’ availability requirements are modeled with op interfaces:

  • QueryMinVersionInterface and QueryMaxVersionInterface for version requirements
  • QueryExtensionInterface for extension requirements
  • QueryCapabilityInterface for capability requirements

These interface declarations are auto-generated from TableGen definitions included in SPIRVBase.td. At the moment all SPIR-V ops implement the above interfaces.

SPIR-V ops’ availability implementation methods are automatically synthesized from the availability specification on each op and enum attribute in TableGen. An op needs to look into not only the opcode but also operands to derive its availability requirements. For example, spirv.ControlBarrier requires no special capability if the execution scope is Subgroup, but it will require the VulkanMemoryModel capability if the scope is QueueFamily.

SPIR-V types’ availability implementation methods are manually written as overrides in the SPIR-V type hierarchy.

These availability requirements serve as the “ingredients” for the SPIRVConversionTarget and SPIRVTypeConverter to perform op and type conversions, by following the requirements in target environment.

Target environment 

SPIR-V aims to support multiple execution environments as specified by client APIs. These execution environments affect the availability of certain SPIR-V features. For example, a Vulkan 1.1 implementation must support the 1.0, 1.1, 1.2, and 1.3 versions of SPIR-V and the 1.0 version of the SPIR-V extended instructions for GLSL. Further Vulkan extensions may enable more SPIR-V instructions.

SPIR-V compilation should also take into consideration of the execution environment, so we generate SPIR-V modules valid for the target environment. This is conveyed by the spirv.target_env (spirv::TargetEnvAttr) attribute. It should be of #spirv.target_env attribute kind, which is defined as:

spirv-version    ::= `v1.0` | `v1.1` | ...
spirv-extension  ::= `SPV_KHR_16bit_storage` | `SPV_EXT_physical_storage_buffer` | ...
spirv-capability ::= `Shader` | `Kernel` | `GroupNonUniform` | ...

spirv-extension-list     ::= `[` (spirv-extension-elements)? `]`
spirv-extension-elements ::= spirv-extension (`,` spirv-extension)*

spirv-capability-list     ::= `[` (spirv-capability-elements)? `]`
spirv-capability-elements ::= spirv-capability (`,` spirv-capability)*

spirv-resource-limits ::= dictionary-attribute

spirv-vce-attribute ::= `#` `spirv.vce` `<`
                            spirv-version `,`
                            spirv-capability-list `,`
                            spirv-extensions-list `>`

spirv-vendor-id ::= `AMD` | `NVIDIA` | ...
spirv-device-type ::= `DiscreteGPU` | `IntegratedGPU` | `CPU` | ...
spirv-device-id ::= integer-literal
spirv-device-info ::= spirv-vendor-id (`:` spirv-device-type (`:` spirv-device-id)?)?

spirv-target-env-attribute ::= `#` `spirv.target_env` `<`
                                  spirv-vce-attribute,
                                  (spirv-device-info `,`)?
                                  spirv-resource-limits `>`

The attribute has a few fields:

  • A #spirv.vce (spirv::VerCapExtAttr) attribute:
    • The target SPIR-V version.
    • A list of SPIR-V extensions for the target.
    • A list of SPIR-V capabilities for the target.
  • A dictionary of target resource limits (see the Vulkan spec for explanation):
    • max_compute_workgroup_invocations
    • max_compute_workgroup_size

For example,

module attributes {
spirv.target_env = #spirv.target_env<
    #spirv.vce<v1.3, [Shader, GroupNonUniform], [SPV_KHR_8bit_storage]>,
    ARM:IntegratedGPU,
    {
      max_compute_workgroup_invocations = 128 : i32,
      max_compute_workgroup_size = dense<[128, 128, 64]> : vector<3xi32>
    }>
} { ... }

Dialect conversion framework will utilize the information in spirv.target_env to properly filter out patterns and ops not available in the target execution environment. When targeting SPIR-V, one needs to create a SPIRVConversionTarget by providing such an attribute.

Shader interface (ABI) 

SPIR-V itself is just expressing computation happening on GPU device. SPIR-V programs themselves are not enough for running workloads on GPU; a companion host application is needed to manage the resources referenced by SPIR-V programs and dispatch the workload. For the Vulkan execution environment, the host application will be written using Vulkan API. Unlike CUDA, the SPIR-V program and the Vulkan application are typically authored with different front-end languages, which isolates these two worlds. Yet they still need to match interfaces: the variables declared in a SPIR-V program for referencing resources need to match with the actual resources managed by the application regarding their parameters.

Still using Vulkan as an example execution environment, there are two primary resource types in Vulkan: buffers and images. They are used to back various uses that may differ regarding the classes of operations (load, store, atomic) to be performed. These uses are differentiated via descriptor types. (For example, uniform storage buffer descriptors can only support load operations while storage buffer descriptors can support load, store, and atomic operations.) Vulkan uses a binding model for resources. Resources are associated with descriptors and descriptors are further grouped into sets. Each descriptor thus has a set number and a binding number. Descriptors in the application corresponds to variables in the SPIR-V program. Their parameters must match, including but not limited to set and binding numbers.

Apart from buffers and images, there is other data that is set up by Vulkan and referenced inside the SPIR-V program, for example, push constants. They also have parameters that require matching between the two worlds.

The interface requirements are external information to the SPIR-V compilation path in MLIR. Besides, each Vulkan application may want to handle resources differently. To avoid duplication and to share common utilities, a SPIR-V shader interface specification needs to be defined to provide the external requirements to and guide the SPIR-V compilation path.

Shader interface attributes 

The SPIR-V dialect defines a few attributes for specifying these interfaces:

  • spirv.entry_point_abi is a struct attribute that should be attached to the entry function. It contains:
    • local_size for specifying the local work group size for the dispatch.
  • spirv.interface_var_abi is attribute that should be attached to each operand and result of the entry function. It should be of #spirv.interface_var_abi attribute kind, which is defined as:
spv-storage-class     ::= `StorageBuffer` | ...
spv-descriptor-set    ::= integer-literal
spv-binding           ::= integer-literal
spv-interface-var-abi ::= `#` `spirv.interface_var_abi` `<(` spv-descriptor-set
                          `,` spv-binding `)` (`,` spv-storage-class)? `>`

For example,

#spirv.interface_var_abi<(0, 0), StorageBuffer>
#spirv.interface_var_abi<(0, 1)>

The attribute has a few fields:

  • Descriptor set number for the corresponding resource variable.
  • Binding number for the corresponding resource variable.
  • Storage class for the corresponding resource variable.

The SPIR-V dialect provides a LowerABIAttributesPass that uses this information to lower the entry point function and its ABI consistent with the Vulkan validation rules. Specifically,

  • Creates spirv.GlobalVariables for the arguments, and replaces all uses of the argument with this variable. The SSA value used for replacement is obtained using the spirv.mlir.addressof operation.
  • Adds the spirv.EntryPoint and spirv.ExecutionMode operations into the spirv.module for the entry function.

Serialization and deserialization 

Although the main objective of the SPIR-V dialect is to act as a proper IR for compiler transformations, being able to serialize to and deserialize from the binary format is still very valuable for many good reasons. Serialization enables the artifacts of SPIR-V compilation to be consumed by an execution environment; deserialization allows us to import SPIR-V binary modules and run transformations on them. So serialization and deserialization are supported from the very beginning of the development of the SPIR-V dialect.

The serialization library provides two entry points, mlir::spirv::serialize() and mlir::spirv::deserialize(), for converting a MLIR SPIR-V module to binary format and back. The Code organization explains more about this.

Given that the focus is transformations, which inevitably means changes to the binary module; so serialization is not designed to be a general tool for investigating the SPIR-V binary module and does not guarantee roundtrip equivalence (at least for now). For the latter, please use the assembler/disassembler in the SPIRV-Tools project.

A few transformations are performed in the process of serialization because of the representational differences between SPIR-V dialect and binary format:

  • Attributes on spirv.module are emitted as their corresponding SPIR-V instructions.
  • Types are serialized into OpType* instructions in the SPIR-V binary module section for types, constants, and global variables.
  • spirv.Constants are unified and placed in the SPIR-V binary module section for types, constants, and global variables.
  • Attributes on ops, if not part of the op’s binary encoding, are emitted as OpDecorate* instructions in the SPIR-V binary module section for decorations.
  • spirv.mlir.selections and spirv.mlir.loops are emitted as basic blocks with Op*Merge instructions in the header block as required by the binary format.
  • Block arguments are materialized as OpPhi instructions at the beginning of the corresponding blocks.

Similarly, a few transformations are performed during deserialization:

  • Instructions for execution environment requirements (extensions, capabilities, extended instruction sets, etc.) will be placed as attributes on spirv.module.
  • OpType* instructions will be converted into proper mlir::Types.
  • OpConstant* instructions are materialized as spirv.Constant at each use site.
  • OpVariable instructions will be converted to spirv.GlobalVariable ops if in module-level; otherwise they will be converted into spirv.Variable ops.
  • Every use of a module-level OpVariable instruction will materialize a spirv.mlir.addressof op to turn the symbol of the corresponding spirv.GlobalVariable into an SSA value.
  • Every use of a OpSpecConstant instruction will materialize a spirv.mlir.referenceof op to turn the symbol of the corresponding spirv.SpecConstant into an SSA value.
  • OpPhi instructions are converted to block arguments.
  • Structured control flow are placed inside spirv.mlir.selection and spirv.mlir.loop.

Conversions 

One of the main features of MLIR is the ability to progressively lower from dialects that capture programmer abstraction into dialects that are closer to a machine representation, like SPIR-V dialect. This progressive lowering through multiple dialects is enabled through the use of the DialectConversion framework in MLIR. To simplify targeting SPIR-V dialect using the Dialect Conversion framework, two utility classes are provided.

(Note : While SPIR-V has some validation rules, additional rules are imposed by Vulkan execution environment. The lowering described below implements both these requirements.)

SPIRVConversionTarget 

The mlir::spirv::SPIRVConversionTarget class derives from the mlir::ConversionTarget class and serves as a utility to define a conversion target satisfying a given spirv.target_env. It registers proper hooks to check the dynamic legality of SPIR-V ops. Users can further register other legality constraints into the returned SPIRVConversionTarget.

spirv::lookupTargetEnvOrDefault() is a handy utility function to query an spirv.target_env attached in the input IR or use the default to construct a SPIRVConversionTarget.

SPIRVTypeConverter 

The mlir::SPIRVTypeConverter derives from mlir::TypeConverter and provides type conversion for builtin types to SPIR-V types conforming to the target environment it is constructed with. If the required extension/capability for the resultant type is not available in the given target environment, convertType() will return a null type.

Builtin scalar types are converted to their corresponding SPIR-V scalar types.

(TODO: Note that if the bitwidth is not available in the target environment, it will be unconditionally converted to 32-bit. This should be switched to properly emulating non-32-bit scalar types.)

Builtin index type need special handling since they are not directly supported in SPIR-V. Currently the index type is converted to i32.

(TODO: Allow for configuring the integer width to use for index types in the SPIR-V dialect)

SPIR-V only supports vectors of 2/3/4 elements; so builtin vector types of these lengths can be converted directly.

(TODO: Convert other vectors of lengths to scalars or arrays)

Builtin memref types with static shape and stride are converted to spirv.ptr<spirv.struct<spirv.array<...>>>s. The resultant SPIR-V array types have the same element type as the source memref and its number of elements is obtained from the layout specification of the memref. The storage class of the pointer type are derived from the memref’s memory space with SPIRVTypeConverter::getStorageClassForMemorySpace().

Utility functions for lowering 

Setting layout for shader interface variables 

SPIR-V validation rules for shaders require composite objects to be explicitly laid out. If a spirv.GlobalVariable is not explicitly laid out, the utility method mlir::spirv::decorateType implements a layout consistent with the Vulkan shader requirements.

Creating builtin variables 

In SPIR-V dialect, builtins are represented using spirv.GlobalVariables, with spirv.mlir.addressof used to get a handle to the builtin as an SSA value. The method mlir::spirv::getBuiltinVariableValue creates a spirv.GlobalVariable for the builtin in the current spirv.module if it does not exist already, and returns an SSA value generated from an spirv.mlir.addressof operation.

Current conversions to SPIR-V 

Using the above infrastructure, conversions are implemented from

  • [Arith Dialect][MlirArithDialect]
  • GPU Dialect : A gpu.module is converted to a spirv.module. A gpu.function within this module is lowered as an entry function.

Code organization 

We aim to provide multiple libraries with clear dependencies for SPIR-V related functionalities in MLIR so developers can just choose the needed components without pulling in the whole world.

The dialect 

The code for the SPIR-V dialect resides in a few places:

The whole SPIR-V dialect is exposed via multiple headers for better organization:

The dialect itself, including all types and ops, is in the MLIRSPIRV library. Serialization functionalities are in the MLIRSPIRVSerialization library.

Op definitions 

We use Op Definition Spec to define all SPIR-V ops. They are written in TableGen syntax and placed in various *Ops.td files in the header directory. Those *Ops.td files are organized according to the instruction categories used in the SPIR-V specification, for example, an op belonging to the “Atomics Instructions” section is put in the SPIRVAtomicOps.td file.

SPIRVOps.td serves as the main op definition file that includes all files for specific categories.

SPIRVBase.td defines common classes and utilities used by various op definitions. It contains the TableGen SPIR-V dialect definition, SPIR-V versions, known extensions, various SPIR-V enums, TableGen SPIR-V types, and base op classes, etc.

Many of the contents in SPIRVBase.td, e.g., the opcodes and various enums, and all *Ops.td files can be automatically updated via a Python script, which queries the SPIR-V specification and grammar. This greatly reduces the burden of supporting new ops and keeping updated with the SPIR-V spec. More details on this automated development can be found in the Automated development flow section.

Dialect conversions 

The code for conversions from other dialects to the SPIR-V dialect also resides in a few places:

These dialect to dialect conversions have their dedicated libraries, MLIRGPUToSPIRV and MLIRFuncToSPIRV, respectively.

There are also common utilities when targeting SPIR-V from any dialect:

These common utilities are implemented in the MLIRSPIRVConversion and MLIRSPIRVTransforms library, respectively.

Rationale 

Lowering memrefs to !spirv.array<..> and !spirv.rtarray<..>

The LLVM dialect lowers memref types to a MemrefDescriptor:

struct MemrefDescriptor {
  void *allocated_ptr; // Pointer to the base allocation.
  void *aligned_ptr;   // Pointer within base allocation which is aligned to
                       // the value set in the memref.
  size_t offset;       // Offset from aligned_ptr from where to get values
                       // corresponding to the memref.
  size_t shape[rank];  // Shape of the memref.
  size_t stride[rank]; // Strides used while accessing elements of the memref.
};

In SPIR-V dialect, we chose not to use a MemrefDescriptor. Instead a memref is lowered directly to a !spirv.ptr<!spirv.array<nelts x elem_type>> when the memref is statically shaped, and !spirv.ptr<!spirv.rtarray<elem_type>> when the memref is dynamically shaped. The rationale behind this choice is described below.

  1. Inputs/output buffers to a SPIR-V kernel are specified using OpVariable inside interface storage classes (e.g., Uniform, StorageBuffer, etc.), while kernel private variables reside in non-interface storage classes (e.g., Function, Workgroup, etc.). By default, Vulkan-flavored SPIR-V requires logical addressing mode: one cannot load/store pointers from/to variables and cannot perform pointer arithmetic. Expressing a struct like MemrefDescriptor in interface storage class requires special addressing mode ( PhysicalStorageBuffer) and manipulating such a struct in non-interface storage classes requires special capabilities ( VariablePointers). Requiring these two extensions together will significantly limit the Vulkan-capable device we can target; basically ruling out mobile support..

  2. An alternative to having one level of indirection (as is the case with MemrefDescriptors), is to embed the !spirv.array or !spirv.rtarray directly in the MemrefDescriptor, Having such a descriptor at the ABI boundary implies that the first few bytes of the input/output buffers would need to be reserved for shape/stride information. This adds an unnecessary burden on the host side.

  3. A more performant approach would be to have the data be an OpVariable, with the shape and strides passed using a separate OpVariable. This has further advantages:

    • All the dynamic shape/stride information of the memref can be combined into a single descriptor. Descriptors are limited resources on many Vulkan hardware. So combining them would help make the generated code more portable across devices.
    • If the shape/stride information is small enough, they could be accessed using PushConstants that are faster to access and avoid buffer allocation overheads. These would be unnecessary if all shapes are static. In the dynamic shape cases, a few parameters are typically enough to compute the shape of all memrefs used/referenced within the kernel making the use of PushConstants possible.
    • The shape/stride information (typically) needs to be update less frequently than the data stored in the buffers. They could be part of different descriptor sets.

Contribution 

All kinds of contributions are highly appreciated! :) We have GitHub issues for tracking the dialect and lowering development. You can find todo tasks there. The Code organization section gives an overview of how SPIR-V related functionalities are implemented in MLIR. This section gives more concrete steps on how to contribute.

Automated development flow 

One of the goals of SPIR-V dialect development is to leverage both the SPIR-V human-readable specification and machine-readable grammar to auto-generate as much contents as possible. Specifically, the following tasks can be automated (partially or fully):

  • Adding support for a new operation.
  • Adding support for a new SPIR-V enum.
  • Serialization and deserialization of a new operation.

We achieve this using the Python script gen_spirv_dialect.py. It fetches the human-readable specification and machine-readable grammar directly from the Internet and updates various SPIR-V *.td files in place. The script gives us an automated flow for adding support for new ops or enums.

Afterwards, we have SPIR-V specific mlir-tblgen backends for reading the Op Definition Spec and generate various components, including (de)serialization logic for ops. Together with standard mlir-tblgen backends, we auto-generate all op classes, enum classes, etc.

In the following subsections, we list the detailed steps to follow for common tasks.

Add a new op 

To add a new op, invoke the define_inst.sh script wrapper in utils/spirv. define_inst.sh requires a few parameters:

./define_inst.sh <filename> <base-class-name> <opname>

For example, to define the op for OpIAdd, invoke

./define_inst.sh SPIRVArithmeticOps.td ArithmeticBinaryOp OpIAdd

where SPIRVArithmeticOps.td is the filename for hosting the new op and ArithmeticBinaryOp is the direct base class the newly defined op will derive from.

Similarly, to define the op for OpAtomicAnd,

./define_inst.sh SPIRVAtomicOps.td AtomicUpdateWithValueOp OpAtomicAnd

Note that the generated SPIR-V op definition is just a best-effort template; it is still expected to be updated to have more accurate traits, arguments, and results.

It is also expected that a custom assembly form is defined for the new op, which will require providing the parser and printer. The EBNF form of the custom assembly should be described in the op’s description and the parser and printer should be placed in SPIRVOps.cpp with the following signatures:

static ParseResult parse<spirv-op-symbol>Op(OpAsmParser &parser,
                                            OperationState &state);
static void print(spirv::<spirv-op-symbol>Op op, OpAsmPrinter &printer);

See any existing op as an example.

Verification should be provided for the new op to cover all the rules described in the SPIR-V specification. Choosing the proper ODS types and attribute kinds, which can be found in SPIRVBase.td, can help here. Still sometimes we need to manually write additional verification logic in SPIRVOps.cpp in a function with the following signature:

LogicalResult spirv::<spirv-op-symbol>Op::verify();

See any such function in SPIRVOps.cpp as an example.

If no additional verification is needed, one needs to add the following to the op’s Op Definition Spec:

let hasVerifier = 0;

To suppress the requirement of the above C++ verification function.

Tests for the op’s custom assembly form and verification should be added to the proper file in test/Dialect/SPIRV/.

The generated op will automatically gain the logic for (de)serialization. However, tests still need to be coupled with the change to make sure no surprises. Serialization tests live in test/Dialect/SPIRV/Serialization.

Add a new enum 

To add a new enum, invoke the define_enum.sh script wrapper in utils/spirv. define_enum.sh expects the following parameters:

./define_enum.sh <enum-class-name>

For example, to add the definition for SPIR-V storage class in to SPIRVBase.td:

./define_enum.sh StorageClass

Add a new custom type 

SPIR-V specific types are defined in SPIRVTypes.h. See examples there and the tutorial for defining new custom types.

Add a new conversion 

To add conversion for a type update the mlir::spirv::SPIRVTypeConverter to return the converted type (must be a valid SPIR-V type). See Type Conversion for more details.

To lower an operation into SPIR-V dialect, implement a conversion pattern. If the conversion requires type conversion as well, the pattern must inherit from the mlir::spirv::SPIRVOpLowering class to get access to mlir::spirv::SPIRVTypeConverter. If the operation has a region, signature conversion might be needed as well.

Note: The current validation rules of spirv.module require that all operations contained within its region are valid operations in the SPIR-V dialect.

Operation definitions 

source

spirv.AccessChain (spirv::AccessChainOp) 

Create a pointer into a composite object.

Syntax:

operation ::= `spirv.AccessChain` $base_ptr `[` $indices `]` attr-dict `:` type($base_ptr) `,` type($indices) `->` type(results)

Result Type must be an OpTypePointer. Its Type operand must be the type reached by walking the Base’s type hierarchy down to the last provided index in Indexes, and its Storage Class operand must be the same as the Storage Class of Base.

Base must be a pointer, pointing to the base of a composite object.

Indexes walk the type hierarchy to the desired depth, potentially down to scalar granularity. The first index in Indexes will select the top- level member/element/component/element of the base composite. All composite constituents use zero-based numbering, as described by their OpType… instruction. The second index will apply similarly to that result, and so on. Once any non-composite type is reached, there must be no remaining (unused) indexes.

Each index in Indexes

  • must be a scalar integer type,

  • is treated as a signed count, and

  • must be an OpConstant when indexing into a structure.

Example: 

%0 = "spirv.Constant"() { value = 1: i32} : () -> i32
%1 = spirv.Variable : !spirv.ptr<!spirv.struct<f32, !spirv.array<4xf32>>, Function>
%2 = spirv.AccessChain %1[%0] : !spirv.ptr<!spirv.struct<f32, !spirv.array<4xf32>>, Function> -> !spirv.ptr<!spirv.array<4xf32>, Function>
%3 = spirv.Load "Function" %2 ["Volatile"] : !spirv.array<4xf32>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
base_ptrany SPIR-V pointer type
indicesvariadic of 8/16/32/64-bit integer

Results: 

ResultDescription
component_ptrany SPIR-V pointer type

spirv.mlir.addressof (spirv::AddressOfOp) 

Get the address of a global variable.

Syntax:

operation ::= `spirv.mlir.addressof` $variable attr-dict `:` type($pointer)

Variables in module scope are defined using symbol names. This op generates an SSA value that can be used to refer to the symbol within function scope for use in ops that expect an SSA value. This operation has no corresponding SPIR-V instruction; it’s merely used for modelling purpose in the SPIR-V dialect. Since variables in module scope in SPIR-V dialect are of pointer type, this op returns a pointer type as well, and the type is the same as the variable referenced.

Example: 

%0 = spirv.mlir.addressof @global_var : !spirv.ptr<f32, Input>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), OpAsmOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
variable::mlir::FlatSymbolRefAttrflat symbol reference attribute

Results: 

ResultDescription
pointerany SPIR-V pointer type

spirv.AtomicAnd (spirv::AtomicAndOp) 

Perform the following steps atomically with respect to any other atomic accesses within Scope to the same location:

Syntax:

operation ::= `spirv.AtomicAnd` $memory_scope $semantics operands attr-dict `:` type($pointer)
  1. load through Pointer to get an Original Value,

  2. get a New Value by the bitwise AND of Original Value and Value, and

  3. store the New Value back through Pointer.

The instruction’s result is the Original Value.

Result Type must be an integer type scalar.

The type of Value must be the same as Result Type. The type of the value pointed to by Pointer must be the same as Result Type.

Memory must be a valid memory Scope.

Example: 

%0 = spirv.AtomicAnd <Device> <None> %pointer, %value :
                   !spirv.ptr<i32, StorageBuffer>

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
value8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.AtomicCompareExchange (spirv::AtomicCompareExchangeOp) 

Perform the following steps atomically with respect to any other atomic accesses within Scope to the same location:

Syntax:

operation ::= `spirv.AtomicCompareExchange` $memory_scope $equal_semantics $unequal_semantics operands attr-dict `:`
              type($pointer)
  1. load through Pointer to get an Original Value,

  2. get a New Value from Value only if Original Value equals Comparator, and

  3. store the New Value back through Pointer’only if ‘Original Value equaled Comparator.

The instruction’s result is the Original Value.

Result Type must be an integer type scalar.

Use Equal for the memory semantics of this instruction when Value and Original Value compare equal.

Use Unequal for the memory semantics of this instruction when Value and Original Value compare unequal. Unequal must not be set to Release or Acquire and Release. In addition, Unequal cannot be set to a stronger memory-order then Equal.

The type of Value must be the same as Result Type. The type of the value pointed to by Pointer must be the same as Result Type. This type must also match the type of Comparator.

Memory is a memory Scope.

Example: 

%0 = spirv.AtomicCompareExchange <Workgroup> <Acquire> <None>
                                %pointer, %value, %comparator
                                : !spirv.ptr<i32, WorkGroup>

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
equal_semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)
unequal_semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
value8/16/32/64-bit integer
comparator8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.AtomicCompareExchangeWeak (spirv::AtomicCompareExchangeWeakOp) 

Deprecated (use OpAtomicCompareExchange).

Syntax:

operation ::= `spirv.AtomicCompareExchangeWeak` $memory_scope $equal_semantics $unequal_semantics operands attr-dict `:`
              type($pointer)

Has the same semantics as OpAtomicCompareExchange.

Memory must be a valid memory Scope.

Example: 

%0 = spirv.AtomicCompareExchangeWeak <Workgroup> <Acquire> <None>
                                   %pointer, %value, %comparator
                                   : !spirv.ptr<i32, WorkGroup>

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
equal_semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)
unequal_semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
value8/16/32/64-bit integer
comparator8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.AtomicExchange (spirv::AtomicExchangeOp) 

Perform the following steps atomically with respect to any other atomic accesses within Scope to the same location:

Syntax:

operation ::= `spirv.AtomicExchange` $memory_scope $semantics operands attr-dict `:` type($pointer)
  1. load through Pointer to get an Original Value,

  2. get a New Value from copying Value, and

  3. store the New Value back through Pointer.

The instruction’s result is the Original Value.

Result Type must be a scalar of integer type or floating-point type.

The type of Value must be the same as Result Type. The type of the value pointed to by Pointer must be the same as Result Type.

Memory is a memory Scope.

Example: 

%0 = spirv.AtomicExchange <Workgroup> <Acquire> %pointer, %value,
                        : !spirv.ptr<i32, WorkGroup>

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
value8/16/32/64-bit integer or 16/32/64-bit float

Results: 

ResultDescription
result8/16/32/64-bit integer or 16/32/64-bit float

spirv.AtomicIAdd (spirv::AtomicIAddOp) 

Perform the following steps atomically with respect to any other atomic accesses within Scope to the same location:

Syntax:

operation ::= `spirv.AtomicIAdd` $memory_scope $semantics operands attr-dict `:` type($pointer)
  1. load through Pointer to get an Original Value,

  2. get a New Value by integer addition of Original Value and Value, and

  3. store the New Value back through Pointer.

The instruction’s result is the Original Value.

Result Type must be an integer type scalar.

The type of Value must be the same as Result Type. The type of the value pointed to by Pointer must be the same as Result Type.

Memory must be a valid memory Scope.

Example: 

%0 = spirv.AtomicIAdd <Device> <None> %pointer, %value :
                    !spirv.ptr<i32, StorageBuffer>

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
value8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.AtomicIDecrement (spirv::AtomicIDecrementOp) 

Perform the following steps atomically with respect to any other atomic accesses within Scope to the same location:

Syntax:

operation ::= `spirv.AtomicIDecrement` $memory_scope $semantics operands attr-dict `:` type($pointer)
  1. load through Pointer to get an Original Value,

  2. get a New Value through integer subtraction of 1 from Original Value, and

  3. store the New Value back through Pointer.

The instruction’s result is the Original Value.

Result Type must be an integer type scalar. The type of the value pointed to by Pointer must be the same as Result Type.

Memory must be a valid memory Scope.

Example: 

%0 = spirv.AtomicIDecrement <Device> <None> %pointer :
                          !spirv.ptr<i32, StorageBuffer>

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.AtomicIIncrement (spirv::AtomicIIncrementOp) 

Perform the following steps atomically with respect to any other atomic accesses within Scope to the same location:

Syntax:

operation ::= `spirv.AtomicIIncrement` $memory_scope $semantics operands attr-dict `:` type($pointer)
  1. load through Pointer to get an Original Value,

  2. get a New Value through integer addition of 1 to Original Value, and

  3. store the New Value back through Pointer.

The instruction’s result is the Original Value.

Result Type must be an integer type scalar. The type of the value pointed to by Pointer must be the same as Result Type.

Memory must be a valid memory Scope.

Example: 

%0 = spirv.AtomicIncrement <Device> <None> %pointer :
                         !spirv.ptr<i32, StorageBuffer>

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.AtomicISub (spirv::AtomicISubOp) 

Perform the following steps atomically with respect to any other atomic accesses within Scope to the same location:

Syntax:

operation ::= `spirv.AtomicISub` $memory_scope $semantics operands attr-dict `:` type($pointer)
  1. load through Pointer to get an Original Value,

  2. get a New Value by integer subtraction of Value from Original Value, and

  3. store the New Value back through Pointer.

The instruction’s result is the Original Value.

Result Type must be an integer type scalar.

The type of Value must be the same as Result Type. The type of the value pointed to by Pointer must be the same as Result Type.

Memory must be a valid memory Scope.

Example: 

%0 = spirv.AtomicISub <Device> <None> %pointer, %value :
                    !spirv.ptr<i32, StorageBuffer>

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
value8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.AtomicOr (spirv::AtomicOrOp) 

Perform the following steps atomically with respect to any other atomic accesses within Scope to the same location:

Syntax:

operation ::= `spirv.AtomicOr` $memory_scope $semantics operands attr-dict `:` type($pointer)
  1. load through Pointer to get an Original Value,

  2. get a New Value by the bitwise OR of Original Value and Value, and

  3. store the New Value back through Pointer.

The instruction’s result is the Original Value.

Result Type must be an integer type scalar.

The type of Value must be the same as Result Type. The type of the value pointed to by Pointer must be the same as Result Type.

Memory must be a valid memory Scope.

Example: 

%0 = spirv.AtomicOr <Device> <None> %pointer, %value :
                  !spirv.ptr<i32, StorageBuffer>

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
value8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.AtomicSMax (spirv::AtomicSMaxOp) 

Perform the following steps atomically with respect to any other atomic accesses within Scope to the same location:

Syntax:

operation ::= `spirv.AtomicSMax` $memory_scope $semantics operands attr-dict `:` type($pointer)
  1. load through Pointer to get an Original Value,

  2. get a New Value by finding the largest signed integer of Original Value and Value, and

  3. store the New Value back through Pointer.

The instruction’s result is the Original Value.

Result Type must be an integer type scalar.

The type of Value must be the same as Result Type. The type of the value pointed to by Pointer must be the same as Result Type.

Memory must be a valid memory Scope.

Example: 

%0 = spirv.AtomicSMax <Device> <None> %pointer, %value :
                    !spirv.ptr<i32, StorageBuffer>

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
value8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.AtomicSMin (spirv::AtomicSMinOp) 

Perform the following steps atomically with respect to any other atomic accesses within Scope to the same location:

Syntax:

operation ::= `spirv.AtomicSMin` $memory_scope $semantics operands attr-dict `:` type($pointer)
  1. load through Pointer to get an Original Value,

  2. get a New Value by finding the smallest signed integer of Original Value and Value, and

  3. store the New Value back through Pointer.

The instruction’s result is the Original Value.

Result Type must be an integer type scalar.

The type of Value must be the same as Result Type. The type of the value pointed to by Pointer must be the same as Result Type.

Memory must be a valid memory Scope.

Example: 

%0 = spirv.AtomicSMin <Device> <None> %pointer, %value :
                    !spirv.ptr<i32, StorageBuffer>

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
value8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.AtomicUMax (spirv::AtomicUMaxOp) 

Perform the following steps atomically with respect to any other atomic accesses within Scope to the same location:

Syntax:

operation ::= `spirv.AtomicUMax` $memory_scope $semantics operands attr-dict `:` type($pointer)
  1. load through Pointer to get an Original Value,

  2. get a New Value by finding the largest unsigned integer of Original Value and Value, and

  3. store the New Value back through Pointer.

The instruction’s result is the Original Value.

Result Type must be an integer type scalar.

The type of Value must be the same as Result Type. The type of the value pointed to by Pointer must be the same as Result Type.

Memory must be a valid memory Scope.

Example: 

%0 = spirv.AtomicUMax <Device> <None> %pointer, %value :
                    !spirv.ptr<i32, StorageBuffer>

Traits: UnsignedOp

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
value8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.AtomicUMin (spirv::AtomicUMinOp) 

Perform the following steps atomically with respect to any other atomic accesses within Scope to the same location:

Syntax:

operation ::= `spirv.AtomicUMin` $memory_scope $semantics operands attr-dict `:` type($pointer)
  1. load through Pointer to get an Original Value,

  2. get a New Value by finding the smallest unsigned integer of Original Value and Value, and

  3. store the New Value back through Pointer.

The instruction’s result is the Original Value.

Result Type must be an integer type scalar.

The type of Value must be the same as Result Type. The type of the value pointed to by Pointer must be the same as Result Type.

Memory must be a valid memory Scope.

Example: 

%0 = spirv.AtomicUMin <Device> <None> %pointer, %value :
                    !spirv.ptr<i32, StorageBuffer>

Traits: UnsignedOp

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
value8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.AtomicXor (spirv::AtomicXorOp) 

Perform the following steps atomically with respect to any other atomic accesses within Scope to the same location:

Syntax:

operation ::= `spirv.AtomicXor` $memory_scope $semantics operands attr-dict `:` type($pointer)
  1. load through Pointer to get an Original Value,

  2. get a New Value by the bitwise exclusive OR of Original Value and Value, and

  3. store the New Value back through Pointer.

The instruction’s result is the Original Value.

Result Type must be an integer type scalar.

The type of Value must be the same as Result Type. The type of the value pointed to by Pointer must be the same as Result Type.

Memory must be a valid memory Scope.

Example: 

%0 = spirv.AtomicXor <Device> <None> %pointer, %value :
                   !spirv.ptr<i32, StorageBuffer>

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
value8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.BitCount (spirv::BitCountOp) 

Count the number of set bits in an object.

Syntax:

operation ::= `spirv.BitCount` $operand `:` type($operand) attr-dict

Results are computed per component.

Result Type must be a scalar or vector of integer type. The components must be wide enough to hold the unsigned Width of Base as an unsigned value. That is, no sign bit is needed or counted when checking for a wide enough result width.

Base must be a scalar or vector of integer type. It must have the same number of components as Result Type.

The result is the unsigned value that is the number of bits in Base that are 1.

Example: 

%2 = spirv.BitCount %0: i32
%3 = spirv.BitCount %1: vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.BitFieldInsert (spirv::BitFieldInsertOp) 

Make a copy of an object, with a modified bit field that comes from another object.

Syntax:

operation ::= `spirv.BitFieldInsert` operands attr-dict `:` type($base) `,` type($offset) `,` type($count)

Results are computed per component.

Result Type must be a scalar or vector of integer type.

The type of Base and Insert must be the same as Result Type.

Any result bits numbered outside [Offset, Offset + Count - 1] (inclusive) will come from the corresponding bits in Base.

Any result bits numbered in [Offset, Offset + Count - 1] come, in order, from the bits numbered [0, Count - 1] of Insert.

Count must be an integer type scalar. Count is the number of bits taken from Insert. It will be consumed as an unsigned value. Count can be 0, in which case the result will be Base.

Offset must be an integer type scalar. Offset is the lowest-order bit of the bit field. It will be consumed as an unsigned value.

The resulting value is undefined if Count or Offset or their sum is greater than the number of bits in the result.

Example: 

%0 = spirv.BitFieldInsert %base, %insert, %offset, %count : vector<3xi32>, i8, i8

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
base8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
insert8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
offset8/16/32/64-bit integer
count8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.BitFieldSExtract (spirv::BitFieldSExtractOp) 

Extract a bit field from an object, with sign extension.

Syntax:

operation ::= `spirv.BitFieldSExtract` operands attr-dict `:` type($base) `,` type($offset) `,` type($count)

Results are computed per component.

Result Type must be a scalar or vector of integer type.

The type of Base must be the same as Result Type.

If Count is greater than 0: The bits of Base numbered in [Offset, Offset

  • Count - 1] (inclusive) become the bits numbered [0, Count - 1] of the result. The remaining bits of the result will all be the same as bit Offset + Count - 1 of Base.

Count must be an integer type scalar. Count is the number of bits extracted from Base. It will be consumed as an unsigned value. Count can be 0, in which case the result will be 0.

Offset must be an integer type scalar. Offset is the lowest-order bit of the bit field to extract from Base. It will be consumed as an unsigned value.

The resulting value is undefined if Count or Offset or their sum is greater than the number of bits in the result.

Example: 

%0 = spirv.BitFieldSExtract %base, %offset, %count : vector<3xi32>, i8, i8

Traits: AlwaysSpeculatableImplTrait, SignedOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
base8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
offset8/16/32/64-bit integer
count8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.BitFieldUExtract (spirv::BitFieldUExtractOp) 

Extract a bit field from an object, without sign extension.

Syntax:

operation ::= `spirv.BitFieldUExtract` operands attr-dict `:` type($base) `,` type($offset) `,` type($count)

The semantics are the same as with OpBitFieldSExtract with the exception that there is no sign extension. The remaining bits of the result will all be 0.

Example: 

%0 = spirv.BitFieldUExtract %base, %offset, %count : vector<3xi32>, i8, i8

Traits: AlwaysSpeculatableImplTrait, UnsignedOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
base8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
offset8/16/32/64-bit integer
count8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.BitReverse (spirv::BitReverseOp) 

Reverse the bits in an object.

Syntax:

operation ::= `spirv.BitReverse` $operand `:` type($operand) attr-dict

Results are computed per component.

Result Type must be a scalar or vector of integer type.

The type of Base must be the same as Result Type.

The bit-number n of the result will be taken from bit-number Width - 1 - n of Base, where Width is the OpTypeInt operand of the Result Type.

Example: 

%2 = spirv.BitReverse %0 : i32
%3 = spirv.BitReverse %1 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.Bitcast (spirv::BitcastOp) 

Bit pattern-preserving type conversion.

Syntax:

operation ::= `spirv.Bitcast` $operand attr-dict `:` type($operand) `to` type($result)

Result Type must be an OpTypePointer, or a scalar or vector of numerical-type.

Operand must have a type of OpTypePointer, or a scalar or vector of numerical-type. It must be a different type than Result Type.

If either Result Type or Operand is a pointer, the other must be a pointer (diverges from the SPIR-V spec).

If Result Type has a different number of components than Operand, the total number of bits in Result Type must equal the total number of bits in Operand. Let L be the type, either Result Type or Operand’s type, that has the larger number of components. Let S be the other type, with the smaller number of components. The number of components in L must be an integer multiple of the number of components in S. The first component (that is, the only or lowest-numbered component) of S maps to the first components of L, and so on, up to the last component of S mapping to the last components of L. Within this mapping, any single component of S (mapping to multiple components of L) maps its lower- ordered bits to the lower-numbered components of L.

Example: 

%1 = spirv.Bitcast %0 : f32 to i32
%1 = spirv.Bitcast %0 : vector<2xf32> to i64
%1 = spirv.Bitcast %0 : !spirv.ptr<f32, Function> to !spirv.ptr<i32, Function>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand8/16/32/64-bit integer or 16/32/64-bit float or bool or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type

Results: 

ResultDescription
result8/16/32/64-bit integer or 16/32/64-bit float or bool or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type

spirv.BitwiseAnd (spirv::BitwiseAndOp) 

Result is 1 if both Operand 1 and Operand 2 are 1. Result is 0 if either Operand 1 or Operand 2 are 0.

Syntax:

operation ::= `spirv.BitwiseAnd` operands attr-dict `:` type($result)

Results are computed per component, and within each component, per bit.

Result Type must be a scalar or vector of integer type. The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same number of components as Result Type. They must have the same component width as Result Type.

Example: 

%2 = spirv.BitwiseAnd %0, %1 : i32
%2 = spirv.BitwiseAnd %0, %1 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultType, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.BitwiseOr (spirv::BitwiseOrOp) 

Result is 1 if either Operand 1 or Operand 2 is 1. Result is 0 if both Operand 1 and Operand 2 are 0.

Syntax:

operation ::= `spirv.BitwiseOr` operands attr-dict `:` type($result)

Results are computed per component, and within each component, per bit.

Result Type must be a scalar or vector of integer type. The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same number of components as Result Type. They must have the same component width as Result Type.

Example: 

%2 = spirv.BitwiseOr %0, %1 : i32
%2 = spirv.BitwiseOr %0, %1 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultType, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.BitwiseXor (spirv::BitwiseXorOp) 

Result is 1 if exactly one of Operand 1 or Operand 2 is 1. Result is 0 if Operand 1 and Operand 2 have the same value.

Syntax:

operation ::= `spirv.BitwiseXor` operands attr-dict `:` type($result)

Results are computed per component, and within each component, per bit.

Result Type must be a scalar or vector of integer type. The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same number of components as Result Type. They must have the same component width as Result Type.

Example: 

%2 = spirv.BitwiseXor %0, %1 : i32
%2 = spirv.BitwiseXor %0, %1 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultType, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.BranchConditional (spirv::BranchConditionalOp) 

If Condition is true, branch to true block, otherwise branch to false block.

Condition must be a Boolean type scalar.

Branch weights are unsigned 32-bit integer literals. There must be either no Branch Weights or exactly two branch weights. If present, the first is the weight for branching to True Label, and the second is the weight for branching to False Label. The implied probability that a branch is taken is its weight divided by the sum of the two Branch weights. At least one weight must be non-zero. A weight of zero does not imply a branch is dead or permit its removal; branch weights are only hints. The two weights must not overflow a 32-bit unsigned integer when added together.

This instruction must be the last instruction in a block.

branch-conditional-op ::= `spirv.BranchConditional` ssa-use
                          (`[` integer-literal, integer-literal `]`)?
                          `,` successor `,` successor
successor ::= bb-id branch-use-list?
branch-use-list ::= `(` ssa-use-list `:` type-list-no-parens `)`

Example: 

spirv.BranchConditional %condition, ^true_branch, ^false_branch
spirv.BranchConditional %condition, ^true_branch(%0: i32), ^false_branch(%1: i32)

Traits: AlwaysSpeculatableImplTrait, AttrSizedOperandSegments, Terminator

Interfaces: BranchOpInterface, ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
branch_weights::mlir::ArrayAttr32-bit integer array attribute

Operands: 

OperandDescription
conditionbool
trueTargetOperandsvariadic of void or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type
falseTargetOperandsvariadic of void or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

Successors: 

SuccessorDescription
trueTargetany successor
falseTargetany successor

spirv.Branch (spirv::BranchOp) 

Unconditional branch to target block.

Syntax:

operation ::= `spirv.Branch` $target (`(` $targetOperands^ `:` type($targetOperands) `)`)? attr-dict

This instruction must be the last instruction in a block.

Example: 

spirv.Branch ^target
spirv.Branch ^target(%0, %1: i32, f32)

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: BranchOpInterface, ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
targetOperandsvariadic of void or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

Successors: 

SuccessorDescription
targetany successor

spirv.CL.acos (spirv::CLAcosOp) 

Compute the arc cosine of x.

Syntax:

operation ::= `spirv.CL.acos` $operand `:` type($operand) attr-dict

Result is an angle in radians.

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.acos %0 : f32
%3 = spirv.CL.acos %1 : vector<4xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.acosh (spirv::CLAcoshOp) 

Compute the inverse hyperbolic cosine of x .

Syntax:

operation ::= `spirv.CL.acosh` $operand `:` type($operand) attr-dict

Result is an angle in radians.

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.acosh %0 : f32
%3 = spirv.CL.acosh %1 : vector<4xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.asin (spirv::CLAsinOp) 

Compute the arc sine of x.

Syntax:

operation ::= `spirv.CL.asin` $operand `:` type($operand) attr-dict

Result is an angle in radians.

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.asin %0 : f32
%3 = spirv.CL.asin %1 : vector<4xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.asinh (spirv::CLAsinhOp) 

Compute the inverse hyperbolic sine of x.

Syntax:

operation ::= `spirv.CL.asinh` $operand `:` type($operand) attr-dict

Result is an angle in radians.

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.asinh %0 : f32
%3 = spirv.CL.asinh %1 : vector<4xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.atan2 (spirv::CLAtan2Op) 

Compute the arc tangent of y / x.

Syntax:

operation ::= `spirv.CL.atan2` operands attr-dict `:` type($result)

Result is an angle in radians.

Result Type, y and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.atan2 %0, %1 : f32
%3 = spirv.CL.atan2 %0, %1 : vector<4xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
rhs16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.atan (spirv::CLAtanOp) 

Compute the arc tangent of x.

Syntax:

operation ::= `spirv.CL.atan` $operand `:` type($operand) attr-dict

Result is an angle in radians.

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.atan %0 : f32
%3 = spirv.CL.atan %1 : vector<4xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.atanh (spirv::CLAtanhOp) 

Compute the hyperbolic arc tangent of x.

Syntax:

operation ::= `spirv.CL.atanh` $operand `:` type($operand) attr-dict

Result is an angle in radians.

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.atanh %0 : f32
%3 = spirv.CL.atanh %1 : vector<4xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.ceil (spirv::CLCeilOp) 

Round x to integral value using the round to positive infinity rounding mode.

Syntax:

operation ::= `spirv.CL.ceil` $operand `:` type($operand) attr-dict

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.ceil %0 : f32
%3 = spirv.CL.ceil %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.cos (spirv::CLCosOp) 

Compute the cosine of x radians.

Syntax:

operation ::= `spirv.CL.cos` $operand `:` type($operand) attr-dict

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.cos %0 : f32
%3 = spirv.CL.cos %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.cosh (spirv::CLCoshOp) 

Compute the hyperbolic cosine of x radians.

Syntax:

operation ::= `spirv.CL.cosh` $operand `:` type($operand) attr-dict

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.cosh %0 : f32
%3 = spirv.CL.cosh %1 : vector<4xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.erf (spirv::CLErfOp) 

Error function of x encountered in integrating the normal distribution.

Syntax:

operation ::= `spirv.CL.erf` $operand `:` type($operand) attr-dict

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.erf %0 : f32
%3 = spirv.CL.erf %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.exp (spirv::CLExpOp) 

Exponentiation of Operand 1

Syntax:

operation ::= `spirv.CL.exp` $operand `:` type($operand) attr-dict

Compute the base-e exponential of x. (i.e. ex)

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.exp %0 : f32
%3 = spirv.CL.exp %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.fabs (spirv::CLFAbsOp) 

Absolute value of operand

Syntax:

operation ::= `spirv.CL.fabs` $operand `:` type($operand) attr-dict

Compute the absolute value of x.

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.fabs %0 : f32
%3 = spirv.CL.fabs %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.fmax (spirv::CLFMaxOp) 

Return maximum of two floating-point operands

Syntax:

operation ::= `spirv.CL.fmax` operands attr-dict `:` type($result)

Returns y if x < y, otherwise it returns x. If one argument is a NaN, Fmax returns the other argument. If both arguments are NaNs, Fmax returns a NaN.

Result Type, x and y must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.fmax %0, %1 : f32
%3 = spirv.CL.fmax %0, %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
rhs16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.fmin (spirv::CLFMinOp) 

Return minimum of two floating-point operands

Syntax:

operation ::= `spirv.CL.fmin` operands attr-dict `:` type($result)

Returns y if y < x, otherwise it returns x. If one argument is a NaN, Fmin returns the other argument. If both arguments are NaNs, Fmin returns a NaN.

Result Type,x and y must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.fmin %0, %1 : f32
%3 = spirv.CL.fmin %0, %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
rhs16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.floor (spirv::CLFloorOp) 

Round x to the integral value using the round to negative infinity rounding mode.

Syntax:

operation ::= `spirv.CL.floor` $operand `:` type($operand) attr-dict

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.floor %0 : f32
%3 = spirv.CL.floor %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.fma (spirv::CLFmaOp) 

Compute the correctly rounded floating-point representation of the sum of c with the infinitely precise product of a and b. Rounding of intermediate products shall not occur. Edge case results are per the IEEE 754-2008 standard.

Syntax:

operation ::= `spirv.CL.fma` operands attr-dict `:` type($result)

Result Type, a, b and c must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%0 = spirv.CL.fma %a, %b, %c : f32
%1 = spirv.CL.fma %a, %b, %c : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
x16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
y16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
z16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.log (spirv::CLLogOp) 

Compute the natural logarithm of x.

Syntax:

operation ::= `spirv.CL.log` $operand `:` type($operand) attr-dict

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.log %0 : f32
%3 = spirv.CL.log %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.mix (spirv::CLMixOp) 

Returns the linear blend of x & y implemented as: x + (y - x) * a

Syntax:

operation ::= `spirv.CL.mix` operands attr-dict `:` type($result)

Result Type, x, y and a must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Note: This instruction can be implemented using contractions such as mad or fma.

Example: 

%0 = spirv.CL.mix %a, %b, %c : f32
%1 = spirv.CL.mix %a, %b, %c : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
x16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
y16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
z16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.pow (spirv::CLPowOp) 

Compute x to the power y.

Syntax:

operation ::= `spirv.CL.pow` operands attr-dict `:` type($result)

Result Type, x and y must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.pow %0, %1 : f32
%3 = spirv.CL.pow %0, %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
rhs16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.printf (spirv::CLPrintfOp) 

The printf extended instruction writes output to an implementation- defined stream such as stdout under control of the string pointed to by format that specifies how subsequent arguments are converted for output.

Syntax:

operation ::= `spirv.CL.printf` $format ( $arguments^ )? attr-dict `:`  type($format) ( `,` type($arguments)^ )? `->` type($result)

printf returns 0 if it was executed successfully and -1 otherwise.

Result Type must be i32.

Format must be a pointer(constant) to i8. If there are insufficient arguments for the format, the behavior is undefined. If the format is exhausted while arguments remain, the excess arguments are evaluated (as always) but are otherwise ignored. The printf instruction returns when the end of the format string is encountered.

Example: 

%0 = spirv.CL.printf %fmt %1, %2  : !spirv.ptr<i8, UniformConstant>, i32, i32 -> i32

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Operands: 

OperandDescription
formatany SPIR-V pointer type
argumentsvariadic of void or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.CL.rint (spirv::CLRintOp) 

Round x to integral value (using round to nearest even rounding mode) in floating-point format.

Syntax:

operation ::= `spirv.CL.rint` $operand `:` type($operand) attr-dict

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%0 = spirv.CL.rint %0 : f32
%1 = spirv.CL.rint %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.round (spirv::CLRoundOp) 

Return the integral value nearest to x rounding halfway cases away from zero, regardless of the current rounding direction.

Syntax:

operation ::= `spirv.CL.round` $operand `:` type($operand) attr-dict

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.round %0 : f32
%3 = spirv.CL.round %0 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.rsqrt (spirv::CLRsqrtOp) 

Compute inverse square root of x.

Syntax:

operation ::= `spirv.CL.rsqrt` $operand `:` type($operand) attr-dict

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.rsqrt %0 : f32
%3 = spirv.CL.rsqrt %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.s_abs (spirv::CLSAbsOp) 

Absolute value of operand

Syntax:

operation ::= `spirv.CL.s_abs` $operand `:` type($operand) attr-dict

Returns |x|, where x is treated as signed integer.

Result Type and x must be integer or vector(2,3,4,8,16) of integer values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.s_abs %0 : i32
%3 = spirv.CL.s_abs %1 : vector<3xi16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.CL.s_max (spirv::CLSMaxOp) 

Return maximum of two signed integer operands

Syntax:

operation ::= `spirv.CL.s_max` operands attr-dict `:` type($result)

Returns y if x < y, otherwise it returns x, where x and y are treated as signed integers.

Result Type,x and y must be integer or vector(2,3,4,8,16) of integer values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.s_max %0, %1 : i32
%3 = spirv.CL.s_max %0, %1 : vector<3xi16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
rhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.CL.s_min (spirv::CLSMinOp) 

Return minimum of two signed integer operands

Syntax:

operation ::= `spirv.CL.s_min` operands attr-dict `:` type($result)

Returns y if x < y, otherwise it returns x, where x and y are treated as signed integers.

Result Type,x and y must be integer or vector(2,3,4,8,16) of integer values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.s_min %0, %1 : i32
%3 = spirv.CL.s_min %0, %1 : vector<3xi16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
rhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.CL.sin (spirv::CLSinOp) 

Compute sine of x radians.

Syntax:

operation ::= `spirv.CL.sin` $operand `:` type($operand) attr-dict

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.sin %0 : f32
%3 = spirv.CL.sin %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.sinh (spirv::CLSinhOp) 

Compute hyperbolic sine of x radians.

Syntax:

operation ::= `spirv.CL.sinh` $operand `:` type($operand) attr-dict

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.sinh %0 : f32
%3 = spirv.CL.sinh %1 : vector<4xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.sqrt (spirv::CLSqrtOp) 

Compute square root of x.

Syntax:

operation ::= `spirv.CL.sqrt` $operand `:` type($operand) attr-dict

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.sqrt %0 : f32
%3 = spirv.CL.sqrt %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.tan (spirv::CLTanOp) 

Compute tangent of x radians.

Syntax:

operation ::= `spirv.CL.tan` $operand `:` type($operand) attr-dict

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.tan %0 : f32
%3 = spirv.CL.tan %1 : vector<4xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.tanh (spirv::CLTanhOp) 

Compute hyperbolic tangent of x radians.

Syntax:

operation ::= `spirv.CL.tanh` $operand `:` type($operand) attr-dict

Result Type and x must be floating-point or vector(2,3,4,8,16) of floating-point values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.tanh %0 : f32
%3 = spirv.CL.tanh %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.CL.u_max (spirv::CLUMaxOp) 

Return maximum of two unsigned integer operands

Syntax:

operation ::= `spirv.CL.u_max` operands attr-dict `:` type($result)

Returns y if x < y, otherwise it returns x, where x and y are treated as unsigned integers.

Result Type,x and y must be integer or vector(2,3,4,8,16) of integer values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.u_max %0, %1 : i32
%3 = spirv.CL.u_max %0, %1 : vector<3xi16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
rhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.CL.u_min (spirv::CLUMinOp) 

Return minimum of two unsigned integer operands

Syntax:

operation ::= `spirv.CL.u_min` operands attr-dict `:` type($result)

Returns y if x < y, otherwise it returns x, where x and y are treated as unsigned integers.

Result Type,x and y must be integer or vector(2,3,4,8,16) of integer values.

All of the operands, including the Result Type operand, must be of the same type.

Example: 

%2 = spirv.CL.u_min %0, %1 : i32
%3 = spirv.CL.u_min %0, %1 : vector<3xi16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
rhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.CompositeConstruct (spirv::CompositeConstructOp) 

Construct a new composite object from a set of constituent objects.

Syntax:

operation ::= `spirv.CompositeConstruct` $constituents attr-dict `:` `(` type(operands) `)` `->` type($result)

Result Type must be a composite type, whose top-level members/elements/components/columns have the same type as the types of the operands, with one exception. The exception is that for constructing a vector, the operands may also be vectors with the same component type as the Result Type component type. When constructing a vector, the total number of components in all the operands must equal the number of components in Result Type.

Constituents will become members of a structure, or elements of an array, or components of a vector, or columns of a matrix. There must be exactly one Constituent for each top-level member/element/component/column of the result, with one exception. The exception is that for constructing a vector, a contiguous subset of the scalars consumed can be represented by a vector operand instead. The Constituents must appear in the order needed by the definition of the type of the result. When constructing a vector, there must be at least two Constituent operands.

Example: 

%a = spirv.CompositeConstruct %1, %2, %3 : vector<3xf32>
%b = spirv.CompositeConstruct %a, %1 : (vector<3xf32>, f32) -> vector<4xf32>

%c = spirv.CompositeConstruct %1 :
  (f32) -> !spirv.coopmatrix<4x4xf32, Subgroup, MatrixA>

%d = spirv.CompositeConstruct %a, %4, %5 :
  (vector<3xf32>, !spirv.array<4xf32>, !spirv.struct<(f32)>) ->
    !spirv.struct<(vector<3xf32>, !spirv.array<4xf32>, !spirv.struct<(f32)>)>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
constituentsvariadic of void or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

Results: 

ResultDescription
resultvector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type

spirv.CompositeExtract (spirv::CompositeExtractOp) 

Extract a part of a composite object.

Result Type must be the type of object selected by the last provided index. The instruction result is the extracted object.

Composite is the composite to extract from.

Indexes walk the type hierarchy, potentially down to component granularity, to select the part to extract. All indexes must be in bounds. All composite constituents use zero-based numbering, as described by their OpType… instruction.

composite-extract-op ::= ssa-id `=` `spirv.CompositeExtract` ssa-use
                         `[` integer-literal (',' integer-literal)* `]`
                         `:` composite-type

Example: 

%0 = spirv.Variable : !spirv.ptr<!spirv.array<4x!spirv.array<4xf32>>, Function>
%1 = spirv.Load "Function" %0 ["Volatile"] : !spirv.array<4x!spirv.array<4xf32>>
%2 = spirv.CompositeExtract %1[1 : i32] : !spirv.array<4x!spirv.array<4xf32>>

Traits: AlwaysSpeculatableImplTrait, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
indices::mlir::ArrayAttr32-bit integer array attribute

Operands: 

OperandDescription
compositevector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type

Results: 

ResultDescription
componentvoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.CompositeInsert (spirv::CompositeInsertOp) 

Make a copy of a composite object, while modifying one part of it.

Result Type must be the same type as Composite.

Object is the object to use as the modified part.

Composite is the composite to copy all but the modified part from.

Indexes walk the type hierarchy of Composite to the desired depth, potentially down to component granularity, to select the part to modify. All indexes must be in bounds. All composite constituents use zero-based numbering, as described by their OpType… instruction. The type of the part selected to modify must match the type of Object.

composite-insert-op ::= ssa-id `=` `spirv.CompositeInsert` ssa-use, ssa-use
                        `[` integer-literal (',' integer-literal)* `]`
                        `:` object-type `into` composite-type

Example: 

%0 = spirv.CompositeInsert %object, %composite[1 : i32] : f32 into !spirv.array<4xf32>

Traits: AlwaysSpeculatableImplTrait, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
indices::mlir::ArrayAttr32-bit integer array attribute

Operands: 

OperandDescription
objectvoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type
compositevector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type

Results: 

ResultDescription
resultvector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type

spirv.Constant (spirv::ConstantOp) 

Declare a new integer-type or floating-point-type scalar constant.

This op declares a SPIR-V normal constant. SPIR-V has multiple constant instructions covering different constant types:

  • OpConstantTrue and OpConstantFalse for boolean constants
  • OpConstant for scalar constants
  • OpConstantComposite for composite constants
  • OpConstantNull for null constants

Having such a plethora of constant instructions renders IR transformations more tedious. Therefore, we use a single spirv.Constant op to represent them all. Note that conversion between those SPIR-V constant instructions and this op is purely mechanical; so it can be scoped to the binary (de)serialization process.

spirv.Constant-op ::= ssa-id `=` `spirv.Constant` attribute-value
                    (`:` spirv-type)?

Example: 

%0 = spirv.Constant true
%1 = spirv.Constant dense<[2, 3]> : vector<2xf32>
%2 = spirv.Constant [dense<3.0> : vector<2xf32>] : !spirv.array<1xvector<2xf32>>

TODO: support constant structs

Traits: AlwaysSpeculatableImplTrait, ConstantLike

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), OpAsmOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
value::mlir::Attributeany attribute

Results: 

ResultDescription
constantvoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.ControlBarrier (spirv::ControlBarrierOp) 

Wait for other invocations of this module to reach the current point of execution.

Syntax:

operation ::= `spirv.ControlBarrier` $execution_scope `,` $memory_scope `,` $memory_semantics attr-dict

All invocations of this module within Execution scope must reach this point of execution before any invocation will proceed beyond it.

When Execution is Workgroup or larger, behavior is undefined if this instruction is used in control flow that is non-uniform within Execution. When Execution is Subgroup or Invocation, the behavior of this instruction in non-uniform control flow is defined by the client API.

If Semantics is not None, this instruction also serves as an OpMemoryBarrier instruction, and must also perform and adhere to the description and semantics of an OpMemoryBarrier instruction with the same Memory and Semantics operands. This allows atomically specifying both a control barrier and a memory barrier (that is, without needing two instructions). If Semantics is None, Memory is ignored.

Before version 1.3, it is only valid to use this instruction with TessellationControl, GLCompute, or Kernel execution models. There is no such restriction starting with version 1.3.

When used with the TessellationControl execution model, it also implicitly synchronizes the Output Storage Class: Writes to Output variables performed by any invocation executed prior to a OpControlBarrier will be visible to any other invocation after return from that OpControlBarrier.

Example: 

spirv.ControlBarrier <Workgroup>, <Device>, <Acquire|UniformMemory>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
memory_semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

spirv.ConvertFToS (spirv::ConvertFToSOp) 

Convert value numerically from floating point to signed integer, with round toward 0.0.

Syntax:

operation ::= `spirv.ConvertFToS` $operand attr-dict `:` type($operand) `to` type($result)

Result Type must be a scalar or vector of integer type.

Float Value must be a scalar or vector of floating-point type. It must have the same number of components as Result Type.

Results are computed per component.

Example: 

%1 = spirv.ConvertFToS %0 : f32 to i32
%3 = spirv.ConvertFToS %2 : vector<3xf32> to vector<3xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

spirv.ConvertFToU (spirv::ConvertFToUOp) 

Convert value numerically from floating point to unsigned integer, with round toward 0.0.

Syntax:

operation ::= `spirv.ConvertFToU` $operand attr-dict `:` type($operand) `to` type($result)

Result Type must be a scalar or vector of integer type, whose Signedness operand is 0.

Float Value must be a scalar or vector of floating-point type. It must have the same number of components as Result Type.

Results are computed per component.

Example: 

%1 = spirv.ConvertFToU %0 : f32 to i32
%3 = spirv.ConvertFToU %2 : vector<3xf32> to vector<3xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

spirv.ConvertPtrToU (spirv::ConvertPtrToUOp) 

Bit pattern-preserving conversion of a pointer to an unsigned scalar integer of possibly different bit width.

Syntax:

operation ::= `spirv.ConvertPtrToU` $pointer attr-dict `:` type($pointer) `to` type($result)

Result Type must be a scalar of integer type, whose Signedness operand is 0.

Pointer must be a physical pointer type. If the bit width of Pointer is smaller than that of Result Type, the conversion zero extends Pointer. If the bit width of Pointer is larger than that of Result Type, the conversion truncates Pointer.

For same bit width Pointer and Result Type, this is the same as OpBitcast.

Example: 

%1 = spirv.ConvertPtrToU %0 : !spirv.ptr<i32, Generic> to i32

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Operands: 

OperandDescription
pointerany SPIR-V pointer type

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.ConvertSToF (spirv::ConvertSToFOp) 

Convert value numerically from signed integer to floating point.

Syntax:

operation ::= `spirv.ConvertSToF` $operand attr-dict `:` type($operand) `to` type($result)

Result Type must be a scalar or vector of floating-point type.

Signed Value must be a scalar or vector of integer type. It must have the same number of components as Result Type.

Results are computed per component.

Example: 

%1 = spirv.ConvertSToF %0 : i32 to f32
%3 = spirv.ConvertSToF %2 : vector<3xi32> to vector<3xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SignedOp

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

spirv.ConvertUToF (spirv::ConvertUToFOp) 

Convert value numerically from unsigned integer to floating point.

Syntax:

operation ::= `spirv.ConvertUToF` $operand attr-dict `:` type($operand) `to` type($result)

Result Type must be a scalar or vector of floating-point type.

Unsigned Value must be a scalar or vector of integer type. It must have the same number of components as Result Type.

Results are computed per component.

Example: 

%1 = spirv.ConvertUToF %0 : i32 to f32
%3 = spirv.ConvertUToF %2 : vector<3xi32> to vector<3xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, UnsignedOp

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

spirv.ConvertUToPtr (spirv::ConvertUToPtrOp) 

Bit pattern-preserving conversion of an unsigned scalar integer to a pointer.

Syntax:

operation ::= `spirv.ConvertUToPtr` $operand attr-dict `:` type($operand) `to` type($result)

Result Type must be a physical pointer type.

Integer Value must be a scalar of integer type, whose Signedness operand is 0. If the bit width of Integer Value is smaller than that of Result Type, the conversion zero extends Integer Value. If the bit width of Integer Value is larger than that of Result Type, the conversion truncates Integer Value.

For same-width Integer Value and Result Type, this is the same as OpBitcast.

Example: 

%1 = spirv.ConvertUToPtr %0 :  i32 to !spirv.ptr<i32, Generic>

Traits: UnsignedOp

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Operands: 

OperandDescription
operand8/16/32/64-bit integer

Results: 

ResultDescription
resultany SPIR-V pointer type

spirv.CopyMemory (spirv::CopyMemoryOp) 

Copy from the memory pointed to by Source to the memory pointed to by Target. Both operands must be non-void pointers and having the same Type operand in their OpTypePointer type declaration. Matching Storage Class is not required. The amount of memory copied is the size of the type pointed to. The copied type must have a fixed size; i.e., it must not be, nor include, any OpTypeRuntimeArray types.

If present, any Memory Operands must begin with a memory operand literal. If not present, it is the same as specifying the memory operand None. Before version 1.4, at most one memory operands mask can be provided. Starting with version 1.4 two masks can be provided, as described in Memory Operands. If no masks or only one mask is present, it applies to both Source and Target. If two masks are present, the first applies to Target and cannot include MakePointerVisible, and the second applies to Source and cannot include MakePointerAvailable.

copy-memory-op ::= `spirv.CopyMemory ` storage-class ssa-use
                   storage-class ssa-use
                   (`[` memory-access `]` (`, [` memory-access `]`)?)?
                   ` : ` spirv-element-type

Example: 

%0 = spirv.Variable : !spirv.ptr<f32, Function>
%1 = spirv.Variable : !spirv.ptr<f32, Function>
spirv.CopyMemory "Function" %0, "Function" %1 : f32

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_access::mlir::spirv::MemoryAccessAttr
valid SPIR-V MemoryAccess

Enum cases:

  • None (None)
  • Volatile (Volatile)
  • Aligned (Aligned)
  • Nontemporal (Nontemporal)
  • MakePointerAvailable (MakePointerAvailable)
  • MakePointerVisible (MakePointerVisible)
  • NonPrivatePointer (NonPrivatePointer)
  • AliasScopeINTELMask (AliasScopeINTELMask)
  • NoAliasINTELMask (NoAliasINTELMask)
alignment::mlir::IntegerAttr32-bit signless integer attribute
source_memory_access::mlir::spirv::MemoryAccessAttr
valid SPIR-V MemoryAccess

Enum cases:

  • None (None)
  • Volatile (Volatile)
  • Aligned (Aligned)
  • Nontemporal (Nontemporal)
  • MakePointerAvailable (MakePointerAvailable)
  • MakePointerVisible (MakePointerVisible)
  • NonPrivatePointer (NonPrivatePointer)
  • AliasScopeINTELMask (AliasScopeINTELMask)
  • NoAliasINTELMask (NoAliasINTELMask)
source_alignment::mlir::IntegerAttr32-bit signless integer attribute

Operands: 

OperandDescription
targetany SPIR-V pointer type
sourceany SPIR-V pointer type

spirv.Dot (spirv::DotOp) 

Dot product of Vector 1 and Vector 2

Syntax:

operation ::= `spirv.Dot` operands attr-dict `:` type($vector1) `->` type($result)

Result Type must be a floating point scalar.

Vector 1 and Vector 2 must be vectors of the same type, and their component type must be Result Type.

Example: 

%0 = spirv.Dot %v1, %v2 : vector<4xf32> -> f32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
vector1vector of 16/32/64-bit float values of length 2/3/4/8/16
vector2vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float

spirv.EXT.AtomicFAdd (spirv::EXTAtomicFAddOp) 

TBD

Syntax:

operation ::= `spirv.EXT.AtomicFAdd` $memory_scope $semantics operands attr-dict `:` type($pointer)

Perform the following steps atomically with respect to any other atomic accesses within Scope to the same location:

  1. load through Pointer to get an Original Value,

  2. get a New Value by float addition of Original Value and Value, and

  3. store the New Value back through Pointer.

The instruction’s result is the Original Value.

Result Type must be a floating-point type scalar.

The type of Value must be the same as Result Type. The type of the value pointed to by Pointer must be the same as Result Type.

Memory must be a valid memory Scope.

Example: 

%0 = spirv.EXT.AtomicFAdd <Device> <None> %pointer, %value :
                       !spirv.ptr<f32, StorageBuffer>

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
value16/32/64-bit float

Results: 

ResultDescription
result16/32/64-bit float

spirv.EntryPoint (spirv::EntryPointOp) 

Declare an entry point, its execution model, and its interface.

Execution Model is the execution model for the entry point and its static call tree. See Execution Model.

Entry Point must be the Result of an OpFunction instruction.

Name is a name string for the entry point. A module cannot have two OpEntryPoint instructions with the same Execution Model and the same Name string.

Interface is a list of symbol references to spirv.GlobalVariable operations. These declare the set of global variables from a module that form the interface of this entry point. The set of Interface symbols must be equal to or a superset of the spirv.GlobalVariables referenced by the entry point’s static call tree, within the interface’s storage classes. Before version 1.4, the interface’s storage classes are limited to the Input and Output storage classes. Starting with version 1.4, the interface’s storage classes are all storage classes used in declaring all global variables referenced by the entry point’s call tree.

execution-model ::= "Vertex" | "TesellationControl" |
                    <and other SPIR-V execution models...>

entry-point-op ::= ssa-id `=` `spirv.EntryPoint` execution-model
                   symbol-reference (`, ` symbol-reference)*

Example: 

spirv.EntryPoint "GLCompute" @foo
spirv.EntryPoint "Kernel" @foo, @var1, @var2

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_model::mlir::spirv::ExecutionModelAttr
valid SPIR-V ExecutionModel

Enum cases:

  • Vertex (Vertex)
  • TessellationControl (TessellationControl)
  • TessellationEvaluation (TessellationEvaluation)
  • Geometry (Geometry)
  • Fragment (Fragment)
  • GLCompute (GLCompute)
  • Kernel (Kernel)
  • TaskNV (TaskNV)
  • MeshNV (MeshNV)
  • RayGenerationKHR (RayGenerationKHR)
  • IntersectionKHR (IntersectionKHR)
  • AnyHitKHR (AnyHitKHR)
  • ClosestHitKHR (ClosestHitKHR)
  • MissKHR (MissKHR)
  • CallableKHR (CallableKHR)
fn::mlir::FlatSymbolRefAttrflat symbol reference attribute
interface::mlir::ArrayAttrsymbol ref array attribute

spirv.ExecutionMode (spirv::ExecutionModeOp) 

Declare an execution mode for an entry point.

Entry Point must be the Entry Point operand of an OpEntryPoint instruction.

Mode is the execution mode. See Execution Mode.

This instruction is only valid when the Mode operand is an execution mode that takes no Extra Operands, or takes Extra Operands that are not operands.

execution-mode ::= "Invocations" | "SpacingEqual" |
                   <and other SPIR-V execution modes...>

execution-mode-op ::= `spirv.ExecutionMode ` ssa-use execution-mode
                      (integer-literal (`, ` integer-literal)* )?

Example: 

spirv.ExecutionMode @foo "ContractionOff"
spirv.ExecutionMode @bar "LocalSizeHint", 3, 4, 5

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
fn::mlir::FlatSymbolRefAttrflat symbol reference attribute
execution_mode::mlir::spirv::ExecutionModeAttr
valid SPIR-V ExecutionMode

Enum cases:

  • Invocations (Invocations)
  • SpacingEqual (SpacingEqual)
  • SpacingFractionalEven (SpacingFractionalEven)
  • SpacingFractionalOdd (SpacingFractionalOdd)
  • VertexOrderCw (VertexOrderCw)
  • VertexOrderCcw (VertexOrderCcw)
  • PixelCenterInteger (PixelCenterInteger)
  • OriginUpperLeft (OriginUpperLeft)
  • OriginLowerLeft (OriginLowerLeft)
  • EarlyFragmentTests (EarlyFragmentTests)
  • PointMode (PointMode)
  • Xfb (Xfb)
  • DepthReplacing (DepthReplacing)
  • DepthGreater (DepthGreater)
  • DepthLess (DepthLess)
  • DepthUnchanged (DepthUnchanged)
  • LocalSize (LocalSize)
  • LocalSizeHint (LocalSizeHint)
  • InputPoints (InputPoints)
  • InputLines (InputLines)
  • InputLinesAdjacency (InputLinesAdjacency)
  • Triangles (Triangles)
  • InputTrianglesAdjacency (InputTrianglesAdjacency)
  • Quads (Quads)
  • Isolines (Isolines)
  • OutputVertices (OutputVertices)
  • OutputPoints (OutputPoints)
  • OutputLineStrip (OutputLineStrip)
  • OutputTriangleStrip (OutputTriangleStrip)
  • VecTypeHint (VecTypeHint)
  • ContractionOff (ContractionOff)
  • Initializer (Initializer)
  • Finalizer (Finalizer)
  • SubgroupSize (SubgroupSize)
  • SubgroupsPerWorkgroup (SubgroupsPerWorkgroup)
  • SubgroupsPerWorkgroupId (SubgroupsPerWorkgroupId)
  • LocalSizeId (LocalSizeId)
  • LocalSizeHintId (LocalSizeHintId)
  • SubgroupUniformControlFlowKHR (SubgroupUniformControlFlowKHR)
  • PostDepthCoverage (PostDepthCoverage)
  • DenormPreserve (DenormPreserve)
  • DenormFlushToZero (DenormFlushToZero)
  • SignedZeroInfNanPreserve (SignedZeroInfNanPreserve)
  • RoundingModeRTE (RoundingModeRTE)
  • RoundingModeRTZ (RoundingModeRTZ)
  • EarlyAndLateFragmentTestsAMD (EarlyAndLateFragmentTestsAMD)
  • StencilRefReplacingEXT (StencilRefReplacingEXT)
  • StencilRefUnchangedFrontAMD (StencilRefUnchangedFrontAMD)
  • StencilRefGreaterFrontAMD (StencilRefGreaterFrontAMD)
  • StencilRefLessFrontAMD (StencilRefLessFrontAMD)
  • StencilRefUnchangedBackAMD (StencilRefUnchangedBackAMD)
  • StencilRefGreaterBackAMD (StencilRefGreaterBackAMD)
  • StencilRefLessBackAMD (StencilRefLessBackAMD)
  • OutputLinesNV (OutputLinesNV)
  • OutputPrimitivesNV (OutputPrimitivesNV)
  • DerivativeGroupQuadsNV (DerivativeGroupQuadsNV)
  • DerivativeGroupLinearNV (DerivativeGroupLinearNV)
  • OutputTrianglesNV (OutputTrianglesNV)
  • PixelInterlockOrderedEXT (PixelInterlockOrderedEXT)
  • PixelInterlockUnorderedEXT (PixelInterlockUnorderedEXT)
  • SampleInterlockOrderedEXT (SampleInterlockOrderedEXT)
  • SampleInterlockUnorderedEXT (SampleInterlockUnorderedEXT)
  • ShadingRateInterlockOrderedEXT (ShadingRateInterlockOrderedEXT)
  • ShadingRateInterlockUnorderedEXT (ShadingRateInterlockUnorderedEXT)
  • SharedLocalMemorySizeINTEL (SharedLocalMemorySizeINTEL)
  • RoundingModeRTPINTEL (RoundingModeRTPINTEL)
  • RoundingModeRTNINTEL (RoundingModeRTNINTEL)
  • FloatingPointModeALTINTEL (FloatingPointModeALTINTEL)
  • FloatingPointModeIEEEINTEL (FloatingPointModeIEEEINTEL)
  • MaxWorkgroupSizeINTEL (MaxWorkgroupSizeINTEL)
  • MaxWorkDimINTEL (MaxWorkDimINTEL)
  • NoGlobalOffsetINTEL (NoGlobalOffsetINTEL)
  • NumSIMDWorkitemsINTEL (NumSIMDWorkitemsINTEL)
  • SchedulerTargetFmaxMhzINTEL (SchedulerTargetFmaxMhzINTEL)
  • StreamingInterfaceINTEL (StreamingInterfaceINTEL)
  • NamedBarrierCountINTEL (NamedBarrierCountINTEL)
values::mlir::ArrayAttr32-bit integer array attribute

spirv.FAdd (spirv::FAddOp) 

Floating-point addition of Operand 1 and Operand 2.

Syntax:

operation ::= `spirv.FAdd` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of floating-point type.

The types of Operand 1 and Operand 2 both must be the same as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FAdd %0, %1 : f32
%5 = spirv.FAdd %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

spirv.FConvert (spirv::FConvertOp) 

Convert value numerically from one floating-point width to another width.

Syntax:

operation ::= `spirv.FConvert` $operand attr-dict `:` type($operand) `to` type($result)

Result Type must be a scalar or vector of floating-point type.

Float Value must be a scalar or vector of floating-point type. It must have the same number of components as Result Type. The component width cannot equal the component width in Result Type.

Results are computed per component.

Example: 

%1 = spirv.FConvertOp %0 : f32 to f64
%3 = spirv.FConvertOp %2 : vector<3xf32> to vector<3xf64>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

spirv.FDiv (spirv::FDivOp) 

Floating-point division of Operand 1 divided by Operand 2.

Syntax:

operation ::= `spirv.FDiv` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of floating-point type.

The types of Operand 1 and Operand 2 both must be the same as Result Type.

Results are computed per component. The resulting value is undefined if Operand 2 is 0.

Example: 

%4 = spirv.FDiv %0, %1 : f32
%5 = spirv.FDiv %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

spirv.FMod (spirv::FModOp) 

The floating-point remainder whose sign matches the sign of Operand 2.

Syntax:

operation ::= `spirv.FMod` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of floating-point type.

The types of Operand 1 and Operand 2 both must be the same as Result Type.

Results are computed per component. The resulting value is undefined if Operand 2 is 0. Otherwise, the result is the remainder r of Operand 1 divided by Operand 2 where if r ≠ 0, the sign of r is the same as the sign of Operand 2.

Example: 

%4 = spirv.FMod %0, %1 : f32
%5 = spirv.FMod %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

spirv.FMul (spirv::FMulOp) 

Floating-point multiplication of Operand 1 and Operand 2.

Syntax:

operation ::= `spirv.FMul` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of floating-point type.

The types of Operand 1 and Operand 2 both must be the same as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FMul %0, %1 : f32
%5 = spirv.FMul %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

spirv.FNegate (spirv::FNegateOp) 

Inverts the sign bit of Operand. (Note, however, that OpFNegate is still considered a floating-point instruction, and so is subject to the general floating-point rules regarding, for example, subnormals and NaN propagation).

Syntax:

operation ::= `spirv.FNegate` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of floating-point type.

The type of Operand must be the same as Result Type.

Results are computed per component.

Example: 

%1 = spirv.FNegate %0 : f32
%3 = spirv.FNegate %2 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

spirv.FOrdEqual (spirv::FOrdEqualOp) 

Floating-point comparison for being ordered and equal.

Syntax:

operation ::= `spirv.FOrdEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of floating-point type. They must have the same type, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FOrdEqual %0, %1 : f32
%5 = spirv.FOrdEqual %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.FOrdGreaterThanEqual (spirv::FOrdGreaterThanEqualOp) 

Floating-point comparison if operands are ordered and Operand 1 is greater than or equal to Operand 2.

Syntax:

operation ::= `spirv.FOrdGreaterThanEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of floating-point type. They must have the same type, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FOrdGreaterThanEqual %0, %1 : f32
%5 = spirv.FOrdGreaterThanEqual %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.FOrdGreaterThan (spirv::FOrdGreaterThanOp) 

Floating-point comparison if operands are ordered and Operand 1 is greater than Operand 2.

Syntax:

operation ::= `spirv.FOrdGreaterThan` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of floating-point type. They must have the same type, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FOrdGreaterThan %0, %1 : f32
%5 = spirv.FOrdGreaterThan %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.FOrdLessThanEqual (spirv::FOrdLessThanEqualOp) 

Floating-point comparison if operands are ordered and Operand 1 is less than or equal to Operand 2.

Syntax:

operation ::= `spirv.FOrdLessThanEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of floating-point type. They must have the same type, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FOrdLessThanEqual %0, %1 : f32
%5 = spirv.FOrdLessThanEqual %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.FOrdLessThan (spirv::FOrdLessThanOp) 

Floating-point comparison if operands are ordered and Operand 1 is less than Operand 2.

Syntax:

operation ::= `spirv.FOrdLessThan` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of floating-point type. They must have the same type, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FOrdLessThan %0, %1 : f32
%5 = spirv.FOrdLessThan %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.FOrdNotEqual (spirv::FOrdNotEqualOp) 

Floating-point comparison for being ordered and not equal.

Syntax:

operation ::= `spirv.FOrdNotEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of floating-point type. They must have the same type, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FOrdNotEqual %0, %1 : f32
%5 = spirv.FOrdNotEqual %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.FRem (spirv::FRemOp) 

The floating-point remainder whose sign matches the sign of Operand 1.

Syntax:

operation ::= `spirv.FRem` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of floating-point type.

The types of Operand 1 and Operand 2 both must be the same as Result Type.

Results are computed per component. The resulting value is undefined if Operand 2 is 0. Otherwise, the result is the remainder r of Operand 1 divided by Operand 2 where if r ≠ 0, the sign of r is the same as the sign of Operand 1.

Example: 

%4 = spirv.FRemOp %0, %1 : f32
%5 = spirv.FRemOp %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

spirv.FSub (spirv::FSubOp) 

Floating-point subtraction of Operand 2 from Operand 1.

Syntax:

operation ::= `spirv.FSub` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of floating-point type.

The types of Operand 1 and Operand 2 both must be the same as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FRemOp %0, %1 : f32
%5 = spirv.FRemOp %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16 or Cooperative Matrix of 16/32/64-bit float values

spirv.FUnordEqual (spirv::FUnordEqualOp) 

Floating-point comparison for being unordered or equal.

Syntax:

operation ::= `spirv.FUnordEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of floating-point type. They must have the same type, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FUnordEqual %0, %1 : f32
%5 = spirv.FUnordEqual %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.FUnordGreaterThanEqual (spirv::FUnordGreaterThanEqualOp) 

Floating-point comparison if operands are unordered or Operand 1 is greater than or equal to Operand 2.

Syntax:

operation ::= `spirv.FUnordGreaterThanEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of floating-point type. They must have the same type, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FUnordGreaterThanEqual %0, %1 : f32
%5 = spirv.FUnordGreaterThanEqual %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.FUnordGreaterThan (spirv::FUnordGreaterThanOp) 

Floating-point comparison if operands are unordered or Operand 1 is greater than Operand 2.

Syntax:

operation ::= `spirv.FUnordGreaterThan` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of floating-point type. They must have the same type, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FUnordGreaterThan %0, %1 : f32
%5 = spirv.FUnordGreaterThan %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.FUnordLessThanEqual (spirv::FUnordLessThanEqualOp) 

Floating-point comparison if operands are unordered or Operand 1 is less than or equal to Operand 2.

Syntax:

operation ::= `spirv.FUnordLessThanEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of floating-point type. They must have the same type, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FUnordLessThanEqual %0, %1 : f32
%5 = spirv.FUnordLessThanEqual %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.FUnordLessThan (spirv::FUnordLessThanOp) 

Floating-point comparison if operands are unordered or Operand 1 is less than Operand 2.

Syntax:

operation ::= `spirv.FUnordLessThan` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of floating-point type. They must have the same type, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FUnordLessThan %0, %1 : f32
%5 = spirv.FUnordLessThan %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.FUnordNotEqual (spirv::FUnordNotEqualOp) 

Floating-point comparison for being unordered or not equal.

Syntax:

operation ::= `spirv.FUnordNotEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of floating-point type. They must have the same type, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.FUnordNotEqual %0, %1 : f32
%5 = spirv.FUnordNotEqual %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.func (spirv::FuncOp) 

Declare or define a function

This op declares or defines a SPIR-V function using one region, which contains one or more blocks.

Different from the SPIR-V binary format, this op is not allowed to implicitly capture global values, and all external references must use function arguments or symbol references. This op itself defines a symbol that is unique in the enclosing module op.

This op itself takes no operands and generates no results. Its region can take zero or more arguments and return zero or one values.

From SPV_KHR_physical_storage_buffer: If a parameter of function is

  • a pointer (or contains a pointer) in the PhysicalStorageBuffer storage class, the function parameter must be decorated with exactly one of Aliased or Restrict.
  • a pointer (or contains a pointer) and the type it points to is a pointer in the PhysicalStorageBuffer storage class, the function parameter must be decorated with exactly one of AliasedPointer or RestrictPointer.
spv-function-control ::= "None" | "Inline" | "DontInline" | ...
spv-function-op ::= `spirv.func` function-signature
                     spv-function-control region

Example: 

spirv.func @foo() -> () "None" { ... }
spirv.func @bar() -> () "Inline|Pure" { ... }

spirv.func @aliased_pointer(%arg0: !spirv.ptr<i32, PhysicalStorageBuffer>,
    { spirv.decoration = #spirv.decoration<Aliased> }) -> () "None" { ... }

spirv.func @restrict_pointer(%arg0: !spirv.ptr<i32, PhysicalStorageBuffer>,
    { spirv.decoration = #spirv.decoration<Restrict> }) -> () "None" { ... }

spirv.func @aliased_pointee(%arg0: !spirv.ptr<!spirv.ptr<i32,
    PhysicalStorageBuffer>, Generic> { spirv.decoration =
    #spirv.decoration<AliasedPointer> }) -> () "None" { ... }

spirv.func @restrict_pointee(%arg0: !spirv.ptr<!spirv.ptr<i32,
    PhysicalStorageBuffer>, Generic> { spirv.decoration =
    #spirv.decoration<RestrictPointer> }) -> () "None" { ... }

Traits: AutomaticAllocationScope, IsolatedFromAbove

Interfaces: CallableOpInterface, FunctionOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface, Symbol

Attributes: 

AttributeMLIR TypeDescription
function_type::mlir::TypeAttrtype attribute of function type
arg_attrs::mlir::ArrayAttrArray of dictionary attributes
res_attrs::mlir::ArrayAttrArray of dictionary attributes
sym_name::mlir::StringAttrstring attribute
function_control::mlir::spirv::FunctionControlAttr
valid SPIR-V FunctionControl

Enum cases:

  • None (None)
  • Inline (Inline)
  • DontInline (DontInline)
  • Pure (Pure)
  • Const (Const)
  • OptNoneINTEL (OptNoneINTEL)
linkage_attributes::mlir::spirv::LinkageAttributesAttr

spirv.FunctionCall (spirv::FunctionCallOp) 

Call a function.

Syntax:

operation ::= `spirv.FunctionCall` $callee `(` $arguments `)` attr-dict `:`
              functional-type($arguments, results)

Result Type is the type of the return value of the function. It must be the same as the Return Type operand of the Function Type operand of the Function operand.

Function is an OpFunction instruction. This could be a forward reference.

Argument N is the object to copy to parameter N of Function.

Note: A forward call is possible because there is no missing type information: Result Type must match the Return Type of the function, and the calling argument types must match the formal parameter types.

Example: 

spirv.FunctionCall @f_void(%arg0) : (i32) ->  ()
%0 = spirv.FunctionCall @f_iadd(%arg0, %arg1) : (i32, i32) -> i32

Interfaces: CallOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
callee::mlir::FlatSymbolRefAttrflat symbol reference attribute

Operands: 

OperandDescription
argumentsvariadic of void or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

Results: 

ResultDescription
return_valuevoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.GL.Acos (spirv::GLAcosOp) 

Arc Cosine of operand in radians

Syntax:

operation ::= `spirv.GL.Acos` $operand `:` type($operand) attr-dict

The standard trigonometric arc cosine of x radians.

Result is an angle, in radians, whose cosine is x. The range of result values is [0, π]. Result is undefined if abs x > 1.

The operand x must be a scalar or vector whose component type is 16-bit or 32-bit floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Acos %0 : f32
%3 = spirv.GL.Acos %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

spirv.GL.Asin (spirv::GLAsinOp) 

Arc Sine of operand in radians

Syntax:

operation ::= `spirv.GL.Asin` $operand `:` type($operand) attr-dict

The standard trigonometric arc sine of x radians.

Result is an angle, in radians, whose sine is x. The range of result values is [-π / 2, π / 2]. Result is undefined if abs x > 1.

The operand x must be a scalar or vector whose component type is 16-bit or 32-bit floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Asin %0 : f32
%3 = spirv.GL.Asin %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

spirv.GL.Atan (spirv::GLAtanOp) 

Arc Tangent of operand in radians

Syntax:

operation ::= `spirv.GL.Atan` $operand `:` type($operand) attr-dict

The standard trigonometric arc tangent of x radians.

Result is an angle, in radians, whose tangent is y_over_x. The range of result values is [-π / 2, π / 2].

The operand x must be a scalar or vector whose component type is 16-bit or 32-bit floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Atan %0 : f32
%3 = spirv.GL.Atan %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

spirv.GL.Ceil (spirv::GLCeilOp) 

Rounds up to the next whole number

Syntax:

operation ::= `spirv.GL.Ceil` $operand `:` type($operand) attr-dict

Result is the value equal to the nearest whole number that is greater than or equal to x.

The operand x must be a scalar or vector whose component type is floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Ceil %0 : f32
%3 = spirv.GL.Ceil %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GL.Cos (spirv::GLCosOp) 

Cosine of operand in radians

Syntax:

operation ::= `spirv.GL.Cos` $operand `:` type($operand) attr-dict

The standard trigonometric cosine of x radians.

The operand x must be a scalar or vector whose component type is 16-bit or 32-bit floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Cos %0 : f32
%3 = spirv.GL.Cos %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

spirv.GL.Cosh (spirv::GLCoshOp) 

Hyperbolic cosine of operand in radians

Syntax:

operation ::= `spirv.GL.Cosh` $operand `:` type($operand) attr-dict

Hyperbolic cosine of x radians.

The operand x must be a scalar or vector whose component type is 16-bit or 32-bit floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Cosh %0 : f32
%3 = spirv.GL.Cosh %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

spirv.GL.Exp (spirv::GLExpOp) 

Exponentiation of Operand 1

Syntax:

operation ::= `spirv.GL.Exp` $operand `:` type($operand) attr-dict

Result is the natural exponentiation of x; e^x.

The operand x must be a scalar or vector whose component type is 16-bit or 32-bit floating-point.

Result Type and the type of x must be the same type. Results are computed per component.";

Example: 

%2 = spirv.GL.Exp %0 : f32
%3 = spirv.GL.Exp %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

spirv.GL.FAbs (spirv::GLFAbsOp) 

Absolute value of operand

Syntax:

operation ::= `spirv.GL.FAbs` $operand `:` type($operand) attr-dict

Result is x if x >= 0; otherwise result is -x.

The operand x must be a scalar or vector whose component type is floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.FAbs %0 : f32
%3 = spirv.GL.FAbs %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GL.FClamp (spirv::GLFClampOp) 

Clamp x between min and max values.

Result is min(max(x, minVal), maxVal). The resulting value is undefined if minVal > maxVal. The semantics used by min() and max() are those of FMin and FMax.

The operands must all be a scalar or vector whose component type is floating-point.

Result Type and the type of all operands must be the same type. Results are computed per component.

fclamp-op ::= ssa-id `=` `spirv.GL.FClamp` ssa-use, ssa-use, ssa-use `:`
           float-scalar-vector-type

Example: 

%2 = spirv.GL.FClamp %x, %min, %max : f32
%3 = spirv.GL.FClamp %x, %min, %max : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
x16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
y16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
z16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GL.FMax (spirv::GLFMaxOp) 

Return maximum of two floating-point operands

Syntax:

operation ::= `spirv.GL.FMax` operands attr-dict `:` type($result)

Result is y if x < y; otherwise result is x. Which operand is the result is undefined if one of the operands is a NaN.

The operands must all be a scalar or vector whose component type is floating-point.

Result Type and the type of all operands must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.FMax %0, %1 : f32
%3 = spirv.GL.FMax %0, %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
rhs16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GL.FMin (spirv::GLFMinOp) 

Return minimum of two floating-point operands

Syntax:

operation ::= `spirv.GL.FMin` operands attr-dict `:` type($result)

Result is y if y < x; otherwise result is x. Which operand is the result is undefined if one of the operands is a NaN.

The operands must all be a scalar or vector whose component type is floating-point.

Result Type and the type of all operands must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.FMin %0, %1 : f32
%3 = spirv.GL.FMin %0, %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
rhs16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GL.FMix (spirv::GLFMixOp) 

Builds the linear blend of x and y

Syntax:

operation ::= `spirv.GL.FMix` attr-dict $x `:` type($x) `,` $y `:` type($y) `,` $a `:` type($a) `->` type($result)

Result is the linear blend of x and y, i.e., x * (1 - a) + y * a.

The operands must all be a scalar or vector whose component type is floating-point.

Result Type and the type of all operands must be the same type. Results are computed per component.

Example: 

%0 = spirv.GL.FMix %x : f32, %y : f32, %a : f32 -> f32
%0 = spirv.GL.FMix %x : vector<4xf32>, %y : vector<4xf32>, %a : vector<4xf32> -> vector<4xf32>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
x16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
y16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
a16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GL.FSign (spirv::GLFSignOp) 

Returns the sign of the operand

Syntax:

operation ::= `spirv.GL.FSign` $operand `:` type($operand) attr-dict

Result is 1.0 if x > 0, 0.0 if x = 0, or -1.0 if x < 0.

The operand x must be a scalar or vector whose component type is floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.FSign %0 : f32
%3 = spirv.GL.FSign %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GL.FindUMsb (spirv::GLFindUMsbOp) 

Unsigned-integer most-significant bit

Syntax:

operation ::= `spirv.GL.FindUMsb` $operand `:` type($operand) attr-dict

Results in the bit number of the most-significant 1-bit in the binary representation of Value. If Value is 0, the result is -1.

Result Type and the type of Value must both be integer scalar or integer vector types. Result Type and operand types must have the same number of components with the same component width. Results are computed per component.

This instruction is currently limited to 32-bit width components.

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operandInt32 or vector of Int32 values of length 2/3/4/8/16

Results: 

ResultDescription
resultInt32 or vector of Int32 values of length 2/3/4/8/16

spirv.GL.Floor (spirv::GLFloorOp) 

Rounds down to the next whole number

Syntax:

operation ::= `spirv.GL.Floor` $operand `:` type($operand) attr-dict

Result is the value equal to the nearest whole number that is less than or equal to x.

The operand x must be a scalar or vector whose component type is floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Floor %0 : f32
%3 = spirv.GL.Floor %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GL.Fma (spirv::GLFmaOp) 

Computes a * b + c.

In uses where this operation is decorated with NoContraction:

  • fma is considered a single operation, whereas the expression a * b + c is considered two operations.
  • The precision of fma can differ from the precision of the expression a * b + c.
  • fma will be computed with the same precision as any other fma decorated with NoContraction, giving invariant results for the same input values of a, b, and c.

Otherwise, in the absence of a NoContraction decoration, there are no special constraints on the number of operations or difference in precision between fma and the expression a * b +c.

The operands must all be a scalar or vector whose component type is floating-point.

Result Type and the type of all operands must be the same type. Results are computed per component.

fma-op ::= ssa-id `=` `spirv.GL.Fma` ssa-use, ssa-use, ssa-use `:`
           float-scalar-vector-type

Example: 

%0 = spirv.GL.Fma %a, %b, %c : f32
%1 = spirv.GL.Fma %a, %b, %c : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
x16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
y16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
z16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GL.FrexpStruct (spirv::GLFrexpStructOp) 

Splits x into two components such that x = significand * 2^exponent

Syntax:

operation ::= `spirv.GL.FrexpStruct` attr-dict $operand `:` type($operand) `->` type($result)

Result is a structure containing x split into a floating-point significand in the range (-1.0, 0.5] or [0.5, 1.0) and an integral exponent of 2, such that:

x = significand * 2^exponent

If x is a zero, the exponent is 0.0. If x is an infinity or a NaN, the exponent is undefined. If x is 0.0, the significand is 0.0. If x is -0.0, the significand is -0.0

Result Type must be an OpTypeStruct with two members. Member 0 must have the same type as the type of x. Member 0 holds the significand. Member 1 must be a scalar or vector with integer component type, with 32-bit component width. Member 1 holds the exponent. These two members and x must have the same number of components.

The operand x must be a scalar or vector whose component type is floating-point.

Example: 

%2 = spirv.GL.FrexpStruct %0 : f32 -> !spirv.struct<f32, i32>
%3 = spirv.GL.FrexpStruct %0 : vector<3xf32> -> !spirv.struct<vector<3xf32>, vector<3xi32>>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultany SPIR-V struct type

spirv.GL.InverseSqrt (spirv::GLInverseSqrtOp) 

Reciprocal of sqrt(operand)

Syntax:

operation ::= `spirv.GL.InverseSqrt` $operand `:` type($operand) attr-dict

Result is the reciprocal of sqrt x. Result is undefined if x <= 0.

The operand x must be a scalar or vector whose component type is floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.InverseSqrt %0 : f32
%3 = spirv.GL.InverseSqrt %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GL.Ldexp (spirv::GLLdexpOp) 

Builds y such that y = significand * 2^exponent

Syntax:

operation ::= `spirv.GL.Ldexp` attr-dict $x `:` type($x) `,` $exp `:` type($exp) `->` type($y)

Builds a floating-point number from x and the corresponding integral exponent of two in exp:

significand * 2^exponent

If this product is too large to be represented in the floating-point type, the resulting value is undefined. If exp is greater than +128 (single precision) or +1024 (double precision), the resulting value is undefined. If exp is less than -126 (single precision) or -1022 (double precision), the result may be flushed to zero. Additionally, splitting the value into a significand and exponent using frexp and then reconstructing a floating-point value using ldexp should yield the original input for zero and all finite non-denormalized values.

The operand x must be a scalar or vector whose component type is floating-point.

The exp operand must be a scalar or vector with integer component type. The number of components in x and exp must be the same.

Result Type must be the same type as the type of x. Results are computed per component.

Example: 

%y = spirv.GL.Ldexp %x : f32, %exp : i32 -> f32
%y = spirv.GL.Ldexp %x : vector<3xf32>, %exp : vector<3xi32> -> vector<3xf32>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
x16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
exp8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
y16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GL.Log (spirv::GLLogOp) 

Natural logarithm of the operand

Syntax:

operation ::= `spirv.GL.Log` $operand `:` type($operand) attr-dict

Result is the natural logarithm of x, i.e., the value y which satisfies the equation x = ey. Result is undefined if x <= 0.

The operand x must be a scalar or vector whose component type is 16-bit or 32-bit floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Log %0 : f32
%3 = spirv.GL.Log %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

spirv.GL.Pow (spirv::GLPowOp) 

Return x raised to the y power of two operands

Syntax:

operation ::= `spirv.GL.Pow` operands attr-dict `:` type($result)

Result is x raised to the y power; x^y.

Result is undefined if x = 0 and y ≤ 0.

The operand x and y must be a scalar or vector whose component type is 16-bit or 32-bit floating-point.

Result Type and the type of all operands must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Pow %0, %1 : f32
%3 = spirv.GL.Pow %0, %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16
rhs16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

spirv.GL.RoundEven (spirv::GLRoundEvenOp) 

Rounds to the nearest even whole number

Syntax:

operation ::= `spirv.GL.RoundEven` $operand `:` type($operand) attr-dict

Result is the value equal to the nearest whole number to x. A fractional part of 0.5 will round toward the nearest even whole number. (Both 3.5 and 4.5 for x will be 4.0.)

The operand x must be a scalar or vector whose component type is floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.RoundEven %0 : f32
%3 = spirv.GL.RoundEven %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GL.Round (spirv::GLRoundOp) 

Rounds to the nearest whole number

Syntax:

operation ::= `spirv.GL.Round` $operand `:` type($operand) attr-dict

Result is the value equal to the nearest whole number to x. The fraction 0.5 will round in a direction chosen by the implementation, presumably the direction that is fastest. This includes the possibility that Round x is the same value as RoundEven x for all values of x.

The operand x must be a scalar or vector whose component type is floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Round %0 : f32
%3 = spirv.GL.Round %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GL.SAbs (spirv::GLSAbsOp) 

Absolute value of operand

Syntax:

operation ::= `spirv.GL.SAbs` $operand `:` type($operand) attr-dict

Result is x if x ≥ 0; otherwise result is -x, where x is interpreted as a signed integer.

Result Type and the type of x must both be integer scalar or integer vector types. Result Type and operand types must have the same number of components with the same component width. Results are computed per component.

Example: 

%2 = spirv.GL.SAbs %0 : i32
%3 = spirv.GL.SAbs %1 : vector<3xi16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GL.SClamp (spirv::GLSClampOp) 

Clamp x between min and max values.

Result is min(max(x, minVal), maxVal), where x, minVal and maxVal are interpreted as signed integers. The resulting value is undefined if minVal > maxVal.

Result Type and the type of the operands must both be integer scalar or integer vector types. Result Type and operand types must have the same number of components with the same component width. Results are computed per component.

uclamp-op ::= ssa-id `=` `spirv.GL.UClamp` ssa-use, ssa-use, ssa-use `:`
           sgined-scalar-vector-type

Example: 

%2 = spirv.GL.SClamp %x, %min, %max : si32
%3 = spirv.GL.SClamp %x, %min, %max : vector<3xsi16>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
x8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
y8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
z8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GL.SMax (spirv::GLSMaxOp) 

Return maximum of two signed integer operands

Syntax:

operation ::= `spirv.GL.SMax` operands attr-dict `:` type($result)

Result is y if x < y; otherwise result is x, where x and y are interpreted as signed integers.

Result Type and the type of x and y must both be integer scalar or integer vector types. Result Type and operand types must have the same number of components with the same component width. Results are computed per component.

Example: 

%2 = spirv.GL.SMax %0, %1 : i32
%3 = spirv.GL.SMax %0, %1 : vector<3xi16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
rhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GL.SMin (spirv::GLSMinOp) 

Return minimum of two signed integer operands

Syntax:

operation ::= `spirv.GL.SMin` operands attr-dict `:` type($result)

Result is y if y < x; otherwise result is x, where x and y are interpreted as signed integers.

Result Type and the type of x and y must both be integer scalar or integer vector types. Result Type and operand types must have the same number of components with the same component width. Results are computed per component.

Example: 

%2 = spirv.GL.SMin %0, %1 : i32
%3 = spirv.GL.SMin %0, %1 : vector<3xi16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
rhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GL.SSign (spirv::GLSSignOp) 

Returns the sign of the operand

Syntax:

operation ::= `spirv.GL.SSign` $operand `:` type($operand) attr-dict

Result is 1 if x > 0, 0 if x = 0, or -1 if x < 0, where x is interpreted as a signed integer.

Result Type and the type of x must both be integer scalar or integer vector types. Result Type and operand types must have the same number of components with the same component width. Results are computed per component.

Example: 

%2 = spirv.GL.SSign %0 : i32
%3 = spirv.GL.SSign %1 : vector<3xi16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GL.Sin (spirv::GLSinOp) 

Sine of operand in radians

Syntax:

operation ::= `spirv.GL.Sin` $operand `:` type($operand) attr-dict

The standard trigonometric sine of x radians.

The operand x must be a scalar or vector whose component type is 16-bit or 32-bit floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Sin %0 : f32
%3 = spirv.GL.Sin %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

spirv.GL.Sinh (spirv::GLSinhOp) 

Hyperbolic sine of operand in radians

Syntax:

operation ::= `spirv.GL.Sinh` $operand `:` type($operand) attr-dict

Hyperbolic sine of x radians.

The operand x must be a scalar or vector whose component type is 16-bit or 32-bit floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Sinh %0 : f32
%3 = spirv.GL.Sinh %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

spirv.GL.Sqrt (spirv::GLSqrtOp) 

Returns the square root of the operand

Syntax:

operation ::= `spirv.GL.Sqrt` $operand `:` type($operand) attr-dict

Result is the square root of x. Result is undefined if x < 0.

The operand x must be a scalar or vector whose component type is floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Sqrt %0 : f32
%3 = spirv.GL.Sqrt %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GL.Tan (spirv::GLTanOp) 

Tangent of operand in radians

Syntax:

operation ::= `spirv.GL.Tan` $operand `:` type($operand) attr-dict

The standard trigonometric tangent of x radians.

The operand x must be a scalar or vector whose component type is 16-bit or 32-bit floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Tan %0 : f32
%3 = spirv.GL.Tan %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

spirv.GL.Tanh (spirv::GLTanhOp) 

Hyperbolic tangent of operand in radians

Syntax:

operation ::= `spirv.GL.Tanh` $operand `:` type($operand) attr-dict

Hyperbolic tangent of x radians.

The operand x must be a scalar or vector whose component type is 16-bit or 32-bit floating-point.

Result Type and the type of x must be the same type. Results are computed per component.

Example: 

%2 = spirv.GL.Tanh %0 : f32
%3 = spirv.GL.Tanh %1 : vector<3xf16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32-bit float or vector of 16/32-bit float values of length 2/3/4/8/16

spirv.GL.UClamp (spirv::GLUClampOp) 

Clamp x between min and max values.

Result is min(max(x, minVal), maxVal), where x, minVal and maxVal are interpreted as unsigned integers. The resulting value is undefined if minVal > maxVal.

Result Type and the type of the operands must both be integer scalar or integer vector types. Result Type and operand types must have the same number of components with the same component width. Results are computed per component.

uclamp-op ::= ssa-id `=` `spirv.GL.UClamp` ssa-use, ssa-use, ssa-use `:`
           unsigned-signless-scalar-vector-type

Example: 

%2 = spirv.GL.UClamp %x, %min, %max : i32
%3 = spirv.GL.UClamp %x, %min, %max : vector<3xui16>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
x8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
y8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
z8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GL.UMax (spirv::GLUMaxOp) 

Return maximum of two unsigned integer operands

Syntax:

operation ::= `spirv.GL.UMax` operands attr-dict `:` type($result)

Result is y if x < y; otherwise result is x, where x and y are interpreted as unsigned integers.

Result Type and the type of x and y must both be integer scalar or integer vector types. Result Type and operand types must have the same number of components with the same component width. Results are computed per component.

Example: 

%2 = spirv.GL.UMax %0, %1 : i32
%3 = spirv.GL.UMax %0, %1 : vector<3xi16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
rhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GL.UMin (spirv::GLUMinOp) 

Return minimum of two unsigned integer operands

Syntax:

operation ::= `spirv.GL.UMin` operands attr-dict `:` type($result)

Result is y if y < x; otherwise result is x, where x and y are interpreted as unsigned integers.

Result Type and the type of x and y must both be integer scalar or integer vector types. Result Type and operand types must have the same number of components with the same component width. Results are computed per component.

Example: 

%2 = spirv.GL.UMin %0, %1 : i32
%3 = spirv.GL.UMin %0, %1 : vector<3xi16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
rhs8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GenericCastToPtrExplicit (spirv::GenericCastToPtrExplicitOp) 

Attempts to explicitly convert Pointer to Storage storage-class pointer value.

Syntax:

operation ::= `spirv.GenericCastToPtrExplicit` $pointer attr-dict `:` type($pointer) `to` type($result)

Result Type must be an OpTypePointer. Its Storage Class must be Storage.

Pointer must have a type of OpTypePointer whose Type is the same as the Type of Result Type.Pointer must point to the Generic Storage Class. If the cast fails, the instruction result is an OpConstantNull pointer in the Storage Storage Class.

Storage must be one of the following literal values from Storage Class: Workgroup, CrossWorkgroup, or Function.

Example: 

   %1 = spirv.GenericCastToPtrExplicitOp %0 : !spirv.ptr<f32, Generic> to
   !spirv.ptr<f32, CrossWorkGroup>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
pointerany SPIR-V pointer type

Results: 

ResultDescription
resultany SPIR-V pointer type

spirv.GenericCastToPtr (spirv::GenericCastToPtrOp) 

Convert a pointer’s Storage Class to a non-Generic class.

Syntax:

operation ::= `spirv.GenericCastToPtr` $pointer attr-dict `:` type($pointer) `to` type($result)

Result Type must be an OpTypePointer. Its Storage Class must be Workgroup, CrossWorkgroup, or Function.

Pointer must point to the Generic Storage Class.

Result Type and Pointer must point to the same type.

Example: 

   %1 = spirv.GenericCastToPtrOp %0 : !spirv.ptr<f32, Generic> to
   !spirv.ptr<f32, CrossWorkGroup>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
pointerany SPIR-V pointer type

Results: 

ResultDescription
resultany SPIR-V pointer type

spirv.GlobalVariable (spirv::GlobalVariableOp) 

Allocate an object in memory at module scope. The object is referenced using a symbol name.

The variable type must be an OpTypePointer. Its type operand is the type of object in memory.

Storage Class is the Storage Class of the memory holding the object. It cannot be Generic. It must be the same as the Storage Class operand of the variable types. Only those storage classes that are valid at module scope (like Input, Output, StorageBuffer, etc.) are valid.

Initializer is optional. If Initializer is present, it will be the initial value of the variable’s memory content. Initializer must be an symbol defined from a constant instruction or other spirv.GlobalVariable operation in module scope. Initializer must have the same type as the type of the defined symbol.

variable-op ::= `spirv.GlobalVariable` spirv-type symbol-ref-id
                (`initializer(` symbol-ref-id `)`)?
                (`bind(` integer-literal, integer-literal `)`)?
                (`built_in(` string-literal `)`)?
                attribute-dict?

where initializer specifies initializer and bind specifies the descriptor set and binding number. built_in specifies SPIR-V BuiltIn decoration associated with the op.

Example: 

spirv.GlobalVariable @var0 : !spirv.ptr<f32, Input> @var0
spirv.GlobalVariable @var1 initializer(@var0) : !spirv.ptr<f32, Output>
spirv.GlobalVariable @var2 bind(1, 2) : !spirv.ptr<f32, Uniform>
spirv.GlobalVariable @var3 built_in("GlobalInvocationId") : !spirv.ptr<vector<3xi32>, Input>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface, Symbol

Attributes: 

AttributeMLIR TypeDescription
type::mlir::TypeAttrany type attribute
sym_name::mlir::StringAttrstring attribute
initializer::mlir::FlatSymbolRefAttrflat symbol reference attribute
location::mlir::IntegerAttr32-bit signless integer attribute
binding::mlir::IntegerAttr32-bit signless integer attribute
descriptor_set::mlir::IntegerAttr32-bit signless integer attribute
builtin::mlir::StringAttrstring attribute
linkage_attributes::mlir::spirv::LinkageAttributesAttr

spirv.GroupBroadcast (spirv::GroupBroadcastOp) 

Broadcast the Value of the invocation identified by the local id LocalId to the result of all invocations in the group.

Syntax:

operation ::= `spirv.GroupBroadcast` $execution_scope operands attr-dict `:` type($value) `,` type($localid)

All invocations of this module within Execution must reach this point of execution.

Behavior is undefined if this instruction is used in control flow that is non-uniform within Execution.

Result Type must be a scalar or vector of floating-point type, integer type, or Boolean type.

Execution must be Workgroup or Subgroup Scope.

The type of Value must be the same as Result Type.

LocalId must be an integer datatype. It can be a scalar, or a vector with 2 components or a vector with 3 components. LocalId must be the same for all invocations in the group.

Example: 

%scalar_value = ... : f32
%vector_value = ... : vector<4xf32>
%scalar_localid = ... : i32
%vector_localid = ... : vector<3xi32>
%0 = spirv.GroupBroadcast "Subgroup" %scalar_value, %scalar_localid : f32, i32
%1 = spirv.GroupBroadcast "Workgroup" %vector_value, %vector_localid :
  vector<4xf32>, vector<3xi32>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)

Operands: 

OperandDescription
valuevoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type
localid8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultvoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.GroupFAdd (spirv::GroupFAddOp) 

A floating-point add group operation specified for all values of X specified by invocations in the group.

Syntax:

operation ::= `spirv.GroupFAdd` $execution_scope $group_operation operands attr-dict `:` type($x)

Behavior is undefined if not all invocations of this module within Execution reach this point of execution.

Behavior is undefined unless all invocations within Execution execute the same dynamic instance of this instruction.

Result Type must be a scalar or vector of floating-point type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The identity I for Operation is 0.

The type of X must be the same as Result Type.

Example: 

%0 = spirv.GroupFAdd <Workgroup> <Reduce> %value : f32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
x16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GroupFMax (spirv::GroupFMaxOp) 

A floating-point maximum group operation specified for all values of X specified by invocations in the group.

Syntax:

operation ::= `spirv.GroupFMax` $execution_scope $group_operation operands attr-dict `:` type($x)

Behavior is undefined if not all invocations of this module within Execution reach this point of execution.

Behavior is undefined unless all invocations within Execution execute the same dynamic instance of this instruction.

Result Type must be a scalar or vector of floating-point type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The identity I for Operation is -INF.

The type of X must be the same as Result Type.

Example: 

%0 = spirv.GroupFMax <Workgroup> <Reduce> %value : f32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
x16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GroupFMin (spirv::GroupFMinOp) 

A floating-point minimum group operation specified for all values of X specified by invocations in the group.

Syntax:

operation ::= `spirv.GroupFMin` $execution_scope $group_operation operands attr-dict `:` type($x)

Behavior is undefined if not all invocations of this module within Execution reach this point of execution.

Behavior is undefined unless all invocations within Execution execute the same dynamic instance of this instruction.

Result Type must be a scalar or vector of floating-point type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The identity I for Operation is +INF.

The type of X must be the same as Result Type.

Example: 

%0 = spirv.GroupFMin <Workgroup> <Reduce> %value : f32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
x16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.KHR.GroupFMul (spirv::GroupFMulKHROp) 

A floating-point multiplication group operation specified for all values of ‘X’ specified by invocations in the group.

Syntax:

operation ::= `spirv.KHR.GroupFMul` $execution_scope $group_operation operands attr-dict `:` type($x)

Behavior is undefined if not all invocations of this module within ‘Execution’ reach this point of execution.

Behavior is undefined unless all invocations within ‘Execution’ execute the same dynamic instance of this instruction.

‘Result Type’ must be a scalar or vector of floating-point type.

‘Execution’ is a Scope. It must be either Workgroup or Subgroup.

The identity I for ‘Operation’ is 1.

The type of ‘X’ must be the same as ‘Result Type’.

Example: 

%0 = spirv.KHR.GroupFMul <Workgroup> <Reduce> %value : f32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
x16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GroupIAdd (spirv::GroupIAddOp) 

An integer add group operation specified for all values of X specified by invocations in the group.

Syntax:

operation ::= `spirv.GroupIAdd` $execution_scope $group_operation operands attr-dict `:` type($x)

Behavior is undefined if not all invocations of this module within Execution reach this point of execution.

Behavior is undefined unless all invocations within Execution execute the same dynamic instance of this instruction.

Result Type must be a scalar or vector of integer type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The identity I for Operation is 0.

The type of X must be the same as Result Type.

Example: 

%0 = spirv.GroupIAdd <Workgroup> <Reduce> %value : i32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
x8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.KHR.GroupIMul (spirv::GroupIMulKHROp) 

An integer multiplication group operation specified for all values of ‘X’ specified by invocations in the group.

Syntax:

operation ::= `spirv.KHR.GroupIMul` $execution_scope $group_operation operands attr-dict `:` type($x)

Behavior is undefined if not all invocations of this module within ‘Execution’ reach this point of execution.

Behavior is undefined unless all invocations within ‘Execution’ execute the same dynamic instance of this instruction.

‘Result Type’ must be a scalar or vector of integer type.

‘Execution’ is a Scope. It must be either Workgroup or Subgroup.

The identity I for ‘Operation’ is 1.

The type of ‘X’ must be the same as ‘Result Type’.

Example: 

%0 = spirv.KHR.GroupIMul <Workgroup> <Reduce> %value : i32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
x8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GroupNonUniformBallotFindLSB (spirv::GroupNonUniformBallotFindLSBOp) 

Find the least significant bit set to 1 in Value, considering only the bits in Value required to represent all bits of the group’s invocations. If none of the considered bits is set to 1, the resulting value is undefined.

Syntax:

operation ::= `spirv.GroupNonUniformBallotFindLSB` $execution_scope $value attr-dict `:` type($value) `,` type($result)

Result Type must be a scalar of integer type, whose Signedness operand is 0.

Execution is a Scope that identifies the group of invocations affected by this command. It must be Subgroup.

Value must be a vector of four components of integer type scalar, whose Width operand is 32 and whose Signedness operand is 0.

Value is a set of bitfields where the first invocation is represented in the lowest bit of the first vector component and the last (up to the size of the group) is the higher bit number of the last bitmask needed to represent all bits of the group invocations.

Example: 

%vector = ... : vector<4xi32>
%0 = spirv.GroupNonUniformBallotFindLSB <Subgroup> %vector : vector<4xi32>, i32

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)

Operands: 

OperandDescription
valuevector of 8/16/32/64-bit signless/unsigned integer values of length 4

Results: 

ResultDescription
result8/16/32/64-bit signless/unsigned integer

spirv.GroupNonUniformBallotFindMSB (spirv::GroupNonUniformBallotFindMSBOp) 

Find the most significant bit set to 1 in Value, considering only the bits in Value required to represent all bits of the group’s invocations. If none of the considered bits is set to 1, the resulting value is undefined.

Syntax:

operation ::= `spirv.GroupNonUniformBallotFindMSB` $execution_scope $value attr-dict `:` type($value) `,` type($result)

Result Type must be a scalar of integer type, whose Signedness operand is 0.

Execution is a Scope that identifies the group of invocations affected by this command. It must be Subgroup.

Value must be a vector of four components of integer type scalar, whose Width operand is 32 and whose Signedness operand is 0.

Value is a set of bitfields where the first invocation is represented in the lowest bit of the first vector component and the last (up to the size of the group) is the higher bit number of the last bitmask needed to represent all bits of the group invocations.

Example: 

%vector = ... : vector<4xi32>
%0 = spirv.GroupNonUniformBallotFindMSB <Subgroup> %vector : vector<4xi32>, i32

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)

Operands: 

OperandDescription
valuevector of 8/16/32/64-bit signless/unsigned integer values of length 4

Results: 

ResultDescription
result8/16/32/64-bit signless/unsigned integer

spirv.GroupNonUniformBallot (spirv::GroupNonUniformBallotOp) 

Result is a bitfield value combining the Predicate value from all invocations in the group that execute the same dynamic instance of this instruction. The bit is set to one if the corresponding invocation is active and the Predicate for that invocation evaluated to true; otherwise, it is set to zero.

Syntax:

operation ::= `spirv.GroupNonUniformBallot` $execution_scope $predicate attr-dict `:` type($result)

Result Type must be a vector of four components of integer type scalar, whose Signedness operand is 0.

Result is a set of bitfields where the first invocation is represented in the lowest bit of the first vector component and the last (up to the size of the group) is the higher bit number of the last bitmask needed to represent all bits of the group invocations.

Execution must be Workgroup or Subgroup Scope.

Predicate must be a Boolean type.

Example: 

%0 = spirv.GroupNonUniformBallot <Subgroup> %predicate : vector<4xi32>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)

Operands: 

OperandDescription
predicatebool

Results: 

ResultDescription
resultvector of 8/16/32/64-bit signless/unsigned integer values of length 4

spirv.GroupNonUniformBitwiseAnd (spirv::GroupNonUniformBitwiseAndOp) 

A bitwise and group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformBitwiseAnd` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of integer type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The identity I for Operation is ~0. If Operation is ClusteredReduce, ClusterSize must be present.

The type of Value must be the same as Result Type.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : i32
%vector = ... : vector<4xi32>
%0 = spirv.GroupNonUniformBitwiseAnd <Workgroup> <Reduce> %scalar : i32 -> i32
%1 = spirv.GroupNonUniformBitwiseAnd <Subgroup> <ClusteredReduce>
       %vector cluster_size(%four) : vector<4xi32>, i32 -> vector<4xi32>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
value8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GroupNonUniformBitwiseOr (spirv::GroupNonUniformBitwiseOrOp) 

A bitwise or group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformBitwiseOr` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of integer type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The identity I for Operation is 0. If Operation is ClusteredReduce, ClusterSize must be present.

The type of Value must be the same as Result Type.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : i32
%vector = ... : vector<4xi32>
%0 = spirv.GroupNonUniformBitwiseOr <Workgroup> <Reduce> %scalar : i32 -> i32
%1 = spirv.GroupNonUniformBitwiseOr <Subgroup> <ClusteredReduce>
       %vector cluster_size(%four) : vector<4xi32>, i32 -> vector<4xi32>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
value8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GroupNonUniformBitwiseXor (spirv::GroupNonUniformBitwiseXorOp) 

A bitwise xor group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformBitwiseXor` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of integer type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The identity I for Operation is 0. If Operation is ClusteredReduce, ClusterSize must be present.

The type of Value must be the same as Result Type.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : i32
%vector = ... : vector<4xi32>
%0 = spirv.GroupNonUniformBitwiseXor <Workgroup> <Reduce> %scalar : i32 -> i32
%1 = spirv.GroupNonUniformBitwiseXor <Subgroup> <ClusteredReduce>
       %vector cluster_size(%four) : vector<4xi32>, i32 -> vector<4xi32>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
value8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GroupNonUniformBroadcast (spirv::GroupNonUniformBroadcastOp) 

Result is the Value of the invocation identified by the id Id to all active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformBroadcast` $execution_scope operands attr-dict `:` type($value) `,` type($id)

Result Type must be a scalar or vector of floating-point type, integer type, or Boolean type.

Execution must be Workgroup or Subgroup Scope.

The type of Value must be the same as Result Type.

Id must be a scalar of integer type, whose Signedness operand is 0.

Before version 1.5, Id must come from a constant instruction. Starting with version 1.5, Id must be dynamically uniform.

The resulting value is undefined if Id is an inactive invocation, or is greater than or equal to the size of the group.

Example: 

%scalar_value = ... : f32
%vector_value = ... : vector<4xf32>
%id = ... : i32
%0 = spirv.GroupNonUniformBroadcast "Subgroup" %scalar_value, %id : f32, i32
%1 = spirv.GroupNonUniformBroadcast "Workgroup" %vector_value, %id :
  vector<4xf32>, i32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)

Operands: 

OperandDescription
valuevoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type
id8/16/32/64-bit integer

Results: 

ResultDescription
resultvoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.GroupNonUniformElect (spirv::GroupNonUniformElectOp) 

Result is true only in the active invocation with the lowest id in the group, otherwise result is false.

Syntax:

operation ::= `spirv.GroupNonUniformElect` $execution_scope attr-dict `:` type($result)

Result Type must be a Boolean type.

Execution must be Workgroup or Subgroup Scope.

Example: 

%0 = spirv.GroupNonUniformElect : i1

Interfaces: InferTypeOpInterface, QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)

Results: 

ResultDescription
resultbool

spirv.GroupNonUniformFAdd (spirv::GroupNonUniformFAddOp) 

A floating point add group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformFAdd` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of floating-point type.

Execution must be Workgroup or Subgroup Scope.

The identity I for Operation is 0. If Operation is ClusteredReduce, ClusterSize must be specified.

The type of Value must be the same as Result Type. The method used to perform the group operation on the contributed Value(s) from active invocations is implementation defined.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : f32
%vector = ... : vector<4xf32>
%0 = spirv.GroupNonUniformFAdd <Workgroup> <Reduce> %scalar : f32 -> f32
%1 = spirv.GroupNonUniformFAdd <Subgroup> <ClusteredReduce> %vector cluster_size(%four) : vector<4xf32>, i32 -> vector<4xf32>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
value16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GroupNonUniformFMax (spirv::GroupNonUniformFMaxOp) 

A floating point maximum group operation of all Value operands contributed by active invocations in by group.

Syntax:

operation ::= `spirv.GroupNonUniformFMax` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of floating-point type.

Execution must be Workgroup or Subgroup Scope.

The identity I for Operation is -INF. If Operation is ClusteredReduce, ClusterSize must be specified.

The type of Value must be the same as Result Type. The method used to perform the group operation on the contributed Value(s) from active invocations is implementation defined. From the set of Value(s) provided by active invocations within a subgroup, if for any two Values one of them is a NaN, the other is chosen. If all Value(s) that are used by the current invocation are NaN, then the result is an undefined value.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : f32
%vector = ... : vector<4xf32>
%0 = spirv.GroupNonUniformFMax <Workgroup> <Reduce> %scalar : f32 -> f32
%1 = spirv.GroupNonUniformFMax <Subgroup> <ClusteredReduce> %vector cluster_size(%four) : vector<4xf32>, i32 -> vector<4xf32>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
value16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GroupNonUniformFMin (spirv::GroupNonUniformFMinOp) 

A floating point minimum group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformFMin` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of floating-point type.

Execution must be Workgroup or Subgroup Scope.

The identity I for Operation is +INF. If Operation is ClusteredReduce, ClusterSize must be specified.

The type of Value must be the same as Result Type. The method used to perform the group operation on the contributed Value(s) from active invocations is implementation defined. From the set of Value(s) provided by active invocations within a subgroup, if for any two Values one of them is a NaN, the other is chosen. If all Value(s) that are used by the current invocation are NaN, then the result is an undefined value.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : f32
%vector = ... : vector<4xf32>
%0 = spirv.GroupNonUniformFMin <Workgroup> <Reduce> %scalar : f32 -> i32
%1 = spirv.GroupNonUniformFMin <Subgroup> <ClusteredReduce> %vector cluster_size(%four) : vector<4xf32>, i32 -> vector<4xf32>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
value16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GroupNonUniformFMul (spirv::GroupNonUniformFMulOp) 

A floating point multiply group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformFMul` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of floating-point type.

Execution must be Workgroup or Subgroup Scope.

The identity I for Operation is 1. If Operation is ClusteredReduce, ClusterSize must be specified.

The type of Value must be the same as Result Type. The method used to perform the group operation on the contributed Value(s) from active invocations is implementation defined.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : f32
%vector = ... : vector<4xf32>
%0 = spirv.GroupNonUniformFMul <Workgroup> <Reduce> %scalar : f32 -> f32
%1 = spirv.GroupNonUniformFMul <Subgroup> <ClusteredReduce> %vector cluster_size(%four) : vector<4xf32>, i32 -> vector<4xf32>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
value16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
result16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

spirv.GroupNonUniformIAdd (spirv::GroupNonUniformIAddOp) 

An integer add group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformIAdd` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of integer type.

Execution must be Workgroup or Subgroup Scope.

The identity I for Operation is 0. If Operation is ClusteredReduce, ClusterSize must be specified.

The type of Value must be the same as Result Type.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : i32
%vector = ... : vector<4xi32>
%0 = spirv.GroupNonUniformIAdd <Workgroup> <Reduce> %scalar : i32 -> i32
%1 = spirv.GroupNonUniformIAdd <Subgroup> <ClusteredReduce> %vector cluster_size(%four) : vector<4xi32>, i32 -> vector<4xi32>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
value8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GroupNonUniformIMul (spirv::GroupNonUniformIMulOp) 

An integer multiply group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformIMul` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of integer type.

Execution must be Workgroup or Subgroup Scope.

The identity I for Operation is 1. If Operation is ClusteredReduce, ClusterSize must be specified.

The type of Value must be the same as Result Type.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : i32
%vector = ... : vector<4xi32>
%0 = spirv.GroupNonUniformIMul <Workgroup> <Reduce> %scalar : i32 -> i32
%1 = spirv.GroupNonUniformIMul <Subgroup> <ClusteredReduce> %vector cluster_size(%four) : vector<4xi32>, i32 -> vector<4xi32>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
value8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GroupNonUniformLogicalAnd (spirv::GroupNonUniformLogicalAndOp) 

A logical and group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformLogicalAnd` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of Boolean type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The identity I for Operation is ~0. If Operation is ClusteredReduce, ClusterSize must be present.

The type of Value must be the same as Result Type.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : i1
%vector = ... : vector<4xi1>
%0 = spirv.GroupNonUniformLogicalAnd <Workgroup> <Reduce> %scalar : i1 -> i1
%1 = spirv.GroupNonUniformLogicalAnd <Subgroup> <ClusteredReduce>
       %vector cluster_size(%four) : vector<4xi1>, i32 -> vector<4xi1>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
valuebool or vector of bool values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.GroupNonUniformLogicalOr (spirv::GroupNonUniformLogicalOrOp) 

A logical or group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformLogicalOr` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of Boolean type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The identity I for Operation is 0. If Operation is ClusteredReduce, ClusterSize must be present.

The type of Value must be the same as Result Type.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : i1
%vector = ... : vector<4xi1>
%0 = spirv.GroupNonUniformLogicalOr <Workgroup> <Reduce> %scalar : i1 -> i1
%1 = spirv.GroupNonUniformLogicalOr <Subgroup> <ClusteredReduce>
       %vector cluster_size(%four) : vector<4xi1>, i32 -> vector<4xi1>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
valuebool or vector of bool values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.GroupNonUniformLogicalXor (spirv::GroupNonUniformLogicalXorOp) 

A logical xor group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformLogicalXor` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of Boolean type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The identity I for Operation is 0. If Operation is ClusteredReduce, ClusterSize must be present.

The type of Value must be the same as Result Type.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : i1
%vector = ... : vector<4xi1>
%0 = spirv.GroupNonUniformLogicalXor <Workgroup> <Reduce> %scalar : i1 -> i1
%1 = spirv.GroupNonUniformLogicalXor <Subgroup> <ClusteredReduce>
       %vector cluster_size(%four) : vector<4xi1>, i32 -> vector<4xi1>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
valuebool or vector of bool values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.GroupNonUniformSMax (spirv::GroupNonUniformSMaxOp) 

A signed integer maximum group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformSMax` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of integer type.

Execution must be Workgroup or Subgroup Scope.

The identity I for Operation is INT_MIN. If Operation is ClusteredReduce, ClusterSize must be specified.

The type of Value must be the same as Result Type.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : i32
%vector = ... : vector<4xi32>
%0 = spirv.GroupNonUniformSMax <Workgroup> <Reduce> %scalar : i32
%1 = spirv.GroupNonUniformSMax <Subgroup> <ClusteredReduce> %vector cluster_size(%four) : vector<4xi32>, i32 -> vector<4xi32>

Traits: SignedOp

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
value8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GroupNonUniformSMin (spirv::GroupNonUniformSMinOp) 

A signed integer minimum group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformSMin` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of integer type.

Execution must be Workgroup or Subgroup Scope.

The identity I for Operation is INT_MAX. If Operation is ClusteredReduce, ClusterSize must be specified.

The type of Value must be the same as Result Type.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : i32
%vector = ... : vector<4xi32>
%0 = spirv.GroupNonUniformSMin <Workgroup> <Reduce> %scalar : i32 -> i32
%1 = spirv.GroupNonUniformSMin <Subgroup> <ClusteredReduce> %vector cluster_size(%four) : vector<4xi32>, i32 -> vector<4xi32>

Traits: SignedOp

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
value8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GroupNonUniformShuffleDown (spirv::GroupNonUniformShuffleDownOp) 

Result is the Value of the invocation identified by the current invocation’s id within the group + Delta.

Syntax:

operation ::= `spirv.GroupNonUniformShuffleDown` $execution_scope operands attr-dict `:` type($value) `,` type($delta)

Result Type must be a scalar or vector of floating-point type, integer type, or Boolean type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The type of Value must be the same as Result Type.

Delta must be a scalar of integer type, whose Signedness operand is 0.

Delta is treated as unsigned and the resulting value is undefined if Delta is greater than or equal to the size of the group, or if the current invocation’s id within the group + Delta is either an inactive invocation or greater than or equal to the size of the group.

Example: 

%0 = spirv.GroupNonUniformShuffleDown <Subgroup> %val, %delta : f32, i32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)

Operands: 

OperandDescription
value8/16/32/64-bit integer or 16/32/64-bit float or bool or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16
delta8/16/32/64-bit integer

Results: 

ResultDescription
resultvoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.GroupNonUniformShuffle (spirv::GroupNonUniformShuffleOp) 

Result is the Value of the invocation identified by the id Id.

Syntax:

operation ::= `spirv.GroupNonUniformShuffle` $execution_scope operands attr-dict `:` type($value) `,` type($id)

Result Type must be a scalar or vector of floating-point type, integer type, or Boolean type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The type of Value must be the same as Result Type.

Id must be a scalar of integer type, whose Signedness operand is 0.

The resulting value is undefined if Id is an inactive invocation, or is greater than or equal to the size of the group.

Example: 

%0 = spirv.GroupNonUniformShuffle <Subgroup> %val, %id : f32, i32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)

Operands: 

OperandDescription
value8/16/32/64-bit integer or 16/32/64-bit float or bool or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16
id8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer or 16/32/64-bit float or bool or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16

spirv.GroupNonUniformShuffleUp (spirv::GroupNonUniformShuffleUpOp) 

Result is the Value of the invocation identified by the current invocation’s id within the group - Delta.

Syntax:

operation ::= `spirv.GroupNonUniformShuffleUp` $execution_scope operands attr-dict `:` type($value) `,` type($delta)

Result Type must be a scalar or vector of floating-point type, integer type, or Boolean type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The type of Value must be the same as Result Type.

Delta must be a scalar of integer type, whose Signedness operand is 0.

Delta is treated as unsigned and the resulting value is undefined if Delta is greater than the current invocation’s id within the group or if the selected lane is inactive.

Example: 

%0 = spirv.GroupNonUniformShuffleUp <Subgroup> %val, %delta : f32, i32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)

Operands: 

OperandDescription
value8/16/32/64-bit integer or 16/32/64-bit float or bool or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16
delta8/16/32/64-bit integer

Results: 

ResultDescription
resultvoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.GroupNonUniformShuffleXor (spirv::GroupNonUniformShuffleXorOp) 

Result is the Value of the invocation identified by the current invocation’s id within the group xor’ed with Mask.

Syntax:

operation ::= `spirv.GroupNonUniformShuffleXor` $execution_scope operands attr-dict `:` type($value) `,` type($mask)

Result Type must be a scalar or vector of floating-point type, integer type, or Boolean type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The type of Value must be the same as Result Type.

Mask must be a scalar of integer type, whose Signedness operand is 0.

The resulting value is undefined if current invocation’s id within the group xor’ed with Mask is an inactive invocation, or is greater than or equal to the size of the group.

Example: 

%0 = spirv.GroupNonUniformShuffleXor <Subgroup> %val, %mask : f32, i32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)

Operands: 

OperandDescription
value8/16/32/64-bit integer or 16/32/64-bit float or bool or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16
mask8/16/32/64-bit integer

Results: 

ResultDescription
resultvoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.GroupNonUniformUMax (spirv::GroupNonUniformUMaxOp) 

An unsigned integer maximum group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformUMax` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of integer type, whose Signedness operand is 0.

Execution must be Workgroup or Subgroup Scope.

The identity I for Operation is 0. If Operation is ClusteredReduce, ClusterSize must be specified.

The type of Value must be the same as Result Type.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : i32
%vector = ... : vector<4xi32>
%0 = spirv.GroupNonUniformUMax <Workgroup> <Reduce> %scalar : i32 -> i32
%1 = spirv.GroupNonUniformUMax <Subgroup> <ClusteredReduce> %vector cluster_size(%four) : vector<4xi32>, i32 -> vector<4xi32>

Traits: UnsignedOp

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
value8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GroupNonUniformUMin (spirv::GroupNonUniformUMinOp) 

An unsigned integer minimum group operation of all Value operands contributed by active invocations in the group.

Syntax:

operation ::= `spirv.GroupNonUniformUMin` $execution_scope $group_operation $value (`cluster_size``(` $cluster_size^ `)`)? attr-dict `:` type($value) (`,` type($cluster_size)^)? `->` type(results)

Result Type must be a scalar or vector of integer type, whose Signedness operand is 0.

Execution must be Workgroup or Subgroup Scope.

The identity I for Operation is UINT_MAX. If Operation is ClusteredReduce, ClusterSize must be specified.

The type of Value must be the same as Result Type.

ClusterSize is the size of cluster to use. ClusterSize must be a scalar of integer type, whose Signedness operand is 0. ClusterSize must come from a constant instruction. ClusterSize must be at least 1, and must be a power of 2. If ClusterSize is greater than the declared SubGroupSize, executing this instruction results in undefined behavior.

Example: 

%four = spirv.Constant 4 : i32
%scalar = ... : i32
%vector = ... : vector<4xi32>
%0 = spirv.GroupNonUniformUMin <Workgroup> <Reduce> %scalar : i32 -> i32
%1 = spirv.GroupNonUniformUMin <Subgroup> <ClusteredReduce> %vector cluster_size(%four) : vector<4xi32>, i32 -> vector<4xi32>

Traits: UnsignedOp

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
value8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
cluster_size8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GroupSMax (spirv::GroupSMaxOp) 

A signed integer maximum group operation specified for all values of X specified by invocations in the group.

Syntax:

operation ::= `spirv.GroupSMax` $execution_scope $group_operation operands attr-dict `:` type($x)

Behavior is undefined if not all invocations of this module within Execution reach this point of execution.

Behavior is undefined unless all invocations within Execution execute the same dynamic instance of this instruction.

Result Type must be a scalar or vector of integer type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The identity I for Operation is INT_MIN when X is 32 bits wide and LONG_MIN when X is 64 bits wide.

The type of X must be the same as Result Type.

Example: 

%0 = spirv.GroupSMax <Workgroup> <Reduce> %value : i32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
x8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GroupSMin (spirv::GroupSMinOp) 

A signed integer minimum group operation specified for all values of X specified by invocations in the group.

Syntax:

operation ::= `spirv.GroupSMin` $execution_scope $group_operation operands attr-dict `:` type($x)

Behavior is undefined if not all invocations of this module within Execution reach this point of execution.

Behavior is undefined unless all invocations within Execution execute the same dynamic instance of this instruction.

Result Type must be a scalar or vector of integer type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The identity I for Operation is INT_MAX when X is 32 bits wide and LONG_MAX when X is 64 bits wide.

The type of X must be the same as Result Type.

Example: 

%0 = spirv.GroupSMin <Workgroup> <Reduce> %value : i32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
x8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GroupUMax (spirv::GroupUMaxOp) 

An unsigned integer maximum group operation specified for all values of X specified by invocations in the group.

Syntax:

operation ::= `spirv.GroupUMax` $execution_scope $group_operation operands attr-dict `:` type($x)

Behavior is undefined if not all invocations of this module within Execution reach this point of execution.

Behavior is undefined unless all invocations within Execution execute the same dynamic instance of this instruction.

Result Type must be a scalar or vector of integer type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The identity I for Operation is 0.

The type of X must be the same as Result Type.

Example: 

%0 = spirv.GroupUMax <Workgroup> <Reduce> %value : i32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
x8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.GroupUMin (spirv::GroupUMinOp) 

An unsigned integer minimum group operation specified for all values of X specified by invocations in the group.

Syntax:

operation ::= `spirv.GroupUMin` $execution_scope $group_operation operands attr-dict `:` type($x)

Behavior is undefined if not all invocations of this module within Execution reach this point of execution.

Behavior is undefined unless all invocations within Execution execute the same dynamic instance of this instruction.

Result Type must be a scalar or vector of integer type.

Execution is a Scope. It must be either Workgroup or Subgroup.

The identity I for Operation is UINT_MAX when X is 32 bits wide and ULONG_MAX when X is 64 bits wide.

The type of X must be the same as Result Type.

Example: 

%0 = spirv.GroupUMin <Workgroup> <Reduce> %value : i32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
group_operation::mlir::spirv::GroupOperationAttr
valid SPIR-V GroupOperation

Enum cases:

  • Reduce (Reduce)
  • InclusiveScan (InclusiveScan)
  • ExclusiveScan (ExclusiveScan)
  • ClusteredReduce (ClusteredReduce)
  • PartitionedReduceNV (PartitionedReduceNV)
  • PartitionedInclusiveScanNV (PartitionedInclusiveScanNV)
  • PartitionedExclusiveScanNV (PartitionedExclusiveScanNV)

Operands: 

OperandDescription
x8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.IAddCarry (spirv::IAddCarryOp) 

Integer addition of Operand 1 and Operand 2, including the carry.

Result Type must be from OpTypeStruct. The struct must have two members, and the two members must be the same type. The member type must be a scalar or vector of integer type, whose Signedness operand is 0.

Operand 1 and Operand 2 must have the same type as the members of Result Type. These are consumed as unsigned integers.

Results are computed per component.

Member 0 of the result gets the low-order bits (full component width) of the addition.

Member 1 of the result gets the high-order (carry) bit of the result of the addition. That is, it gets the value 1 if the addition overflowed the component width, and 0 otherwise.

Example: 

%2 = spirv.IAddCarry %0, %1 : !spirv.struct<(i32, i32)>
%2 = spirv.IAddCarry %0, %1 : !spirv.struct<(vector<2xi32>, vector<2xi32>)>

Traits: AlwaysSpeculatableImplTrait, Commutative

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultany SPIR-V struct type

spirv.IAdd (spirv::IAddOp) 

Integer addition of Operand 1 and Operand 2.

Syntax:

operation ::= `spirv.IAdd` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of integer type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same number of components as Result Type. They must have the same component width as Result Type.

The resulting value will equal the low-order N bits of the correct result R, where N is the component width and R is computed with enough precision to avoid overflow and underflow.

Results are computed per component.

Example: 

%4 = spirv.IAdd %0, %1 : i32
%5 = spirv.IAdd %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultType, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

spirv.IEqual (spirv::IEqualOp) 

Integer comparison for equality.

Syntax:

operation ::= `spirv.IEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same component width, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.IEqual %0, %1 : i32
%5 = spirv.IEqual %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultShape, SameTypeOperands, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.IMul (spirv::IMulOp) 

Integer multiplication of Operand 1 and Operand 2.

Syntax:

operation ::= `spirv.IMul` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of integer type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same number of components as Result Type. They must have the same component width as Result Type.

The resulting value will equal the low-order N bits of the correct result R, where N is the component width and R is computed with enough precision to avoid overflow and underflow.

Results are computed per component.

Example: 

%4 = spirv.IMul %0, %1 : i32
%5 = spirv.IMul %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultType, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

spirv.INTEL.ControlBarrierArrive (spirv::INTELControlBarrierArriveOp) 

See extension SPV_INTEL_split_barrier

Syntax:

operation ::= `spirv.INTEL.ControlBarrierArrive` $execution_scope $memory_scope $memory_semantics attr-dict

Indicates that an invocation has arrived at a split control barrier. This may allow other invocations waiting on the split control barrier to continue executing.

When Execution is Workgroup or larger, behavior is undefined unless all invocations within Execution execute the same dynamic instance of this instruction. When Execution is Subgroup or Invocation, the behavior of this instruction in non-uniform control flow is defined by the client API.

If Semantics is not None, this instruction also serves as the start of a memory barrier similar to an OpMemoryBarrier instruction with the same Memory and Semantics operands. This allows atomically specifying both a control barrier and a memory barrier (that is, without needing two instructions). If Semantics is None, Memory is ignored.

Example: 

spirv.ControlBarrierArrive <Workgroup> <Device> <Acquire|UniformMemory>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
memory_semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

spirv.INTEL.ControlBarrierWait (spirv::INTELControlBarrierWaitOp) 

See extension SPV_INTEL_split_barrier

Syntax:

operation ::= `spirv.INTEL.ControlBarrierWait` $execution_scope $memory_scope $memory_semantics attr-dict

Waits for other invocations of this module to arrive at a split control barrier.

When Execution is Workgroup or larger, behavior is undefined unless all invocations within Execution execute the same dynamic instance of this instruction. When Execution is Subgroup or Invocation, the behavior of this instruction in non-uniform control flow is defined by the client API.

If Semantics is not None, this instruction also serves as the end of a memory barrier similar to an OpMemoryBarrier instruction with the same Memory and Semantics operands. This ensures that memory accesses issued before arriving at the split barrier are observed before memory accesses issued after this instruction. This control is ensured only for memory accesses issued by this invocation and observed by another invocation executing within Memory scope. This allows atomically specifying both a control barrier and a memory barrier (that is, without needing two instructions). If Semantics is None, Memory is ignored.

Example: 

spirv.ControlBarrierWait <Workgroup> <Device> <Acquire|UniformMemory>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
execution_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
memory_semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

spirv.INTEL.ConvertBF16ToF (spirv::INTELConvertBF16ToFOp) 

See extension SPV_INTEL_bfloat16_conversion

Syntax:

operation ::= `spirv.INTEL.ConvertBF16ToF` $operand attr-dict `:` type($operand) `to` type($result)

Interpret a 16-bit integer as bfloat16 and convert the value numerically to 32-bit floating point type.

Result Type must be a scalar or vector of floating-point. The component width must be 32 bits.

Bfloat16 Value must be a scalar or vector of integer type, which is interpreted as a bfloat16 type. The type must have the same number of components as the Result Type. The component width must be 16 bits.

Results are computed per component.

Example: 

%1 = spirv.ConvertBF16ToF %0 : i16 to f32
%3 = spirv.ConvertBF16ToF %2 : vector<3xi16> to vector<3xf32>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Operands: 

OperandDescription
operandInt16 or vector of Int16 values of length 2/3/4/8/16

Results: 

ResultDescription
resultFloat32 or vector of Float32 values of length 2/3/4/8/16

spirv.INTEL.ConvertFToBF16 (spirv::INTELConvertFToBF16Op) 

See extension SPV_INTEL_bfloat16_conversion

Syntax:

operation ::= `spirv.INTEL.ConvertFToBF16` $operand attr-dict `:` type($operand) `to` type($result)

Convert value numerically from 32-bit floating point to bfloat16, which is represented as a 16-bit unsigned integer.

Result Type must be a scalar or vector of integer type. The component width must be 16 bits. Bit pattern in the Result represents a bfloat16 value.

Float Value must be a scalar or vector of floating-point type. It must have the same number of components as Result Type. The component width must be 32 bits.

Results are computed per component.

Example: 

%1 = spirv.ConvertFToBF16 %0 : f32 to i16
%3 = spirv.ConvertFToBF16 %2 : vector<3xf32> to vector<3xi16>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Operands: 

OperandDescription
operandFloat32 or vector of Float32 values of length 2/3/4/8/16

Results: 

ResultDescription
resultInt16 or vector of Int16 values of length 2/3/4/8/16

spirv.INTEL.SubgroupBlockRead (spirv::INTELSubgroupBlockReadOp) 

See extension SPV_INTEL_subgroups

Syntax:

operation ::= `spirv.INTEL.SubgroupBlockRead` $ptr attr-dict `:` type($ptr) `->` type($value)

Reads one or more components of Result data for each invocation in the subgroup from the specified Ptr as a block operation.

The data is read strided, so the first value read is: Ptr[ SubgroupLocalInvocationId ]

and the second value read is: Ptr[ SubgroupLocalInvocationId + SubgroupMaxSize ] etc.

Result Type may be a scalar or vector type, and its component type must be equal to the type pointed to by Ptr.

The type of Ptr must be a pointer type, and must point to a scalar type.

subgroup-block-read-INTEL-op ::= ssa-id `=` `spirv.INTEL.SubgroupBlockRead`
                            storage-class ssa_use `:` spirv-element-type

Example: 

%0 = spirv.INTEL.SubgroupBlockRead "StorageBuffer" %ptr : i32

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Operands: 

OperandDescription
ptrany SPIR-V pointer type

Results: 

ResultDescription
valuevoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.INTEL.SubgroupBlockWrite (spirv::INTELSubgroupBlockWriteOp) 

See extension SPV_INTEL_subgroups

Writes one or more components of Data for each invocation in the subgroup from the specified Ptr as a block operation.

The data is written strided, so the first value is written to: Ptr[ SubgroupLocalInvocationId ]

and the second value written is: Ptr[ SubgroupLocalInvocationId + SubgroupMaxSize ] etc.

The type of Ptr must be a pointer type, and must point to a scalar type.

The component type of Data must be equal to the type pointed to by Ptr.

subgroup-block-write-INTEL-op ::= ssa-id `=` `spirv.INTEL.SubgroupBlockWrite`
                  storage-class ssa_use `,` ssa-use `:` spirv-element-type

Example: 

spirv.INTEL.SubgroupBlockWrite "StorageBuffer" %ptr, %value : i32

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Operands: 

OperandDescription
ptrany SPIR-V pointer type
valuevoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.INotEqual (spirv::INotEqualOp) 

Integer comparison for inequality.

Syntax:

operation ::= `spirv.INotEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same component width, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.INotEqual %0, %1 : i32
%5 = spirv.INotEqual %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultShape, SameTypeOperands, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.ISubBorrow (spirv::ISubBorrowOp) 

Result is the unsigned integer subtraction of Operand 2 from Operand 1, and what it needed to borrow.

Result Type must be from OpTypeStruct. The struct must have two members, and the two members must be the same type. The member type must be a scalar or vector of integer type, whose Signedness operand is 0.

Operand 1 and Operand 2 must have the same type as the members of Result Type. These are consumed as unsigned integers.

Results are computed per component.

Member 0 of the result gets the low-order bits (full component width) of the subtraction. That is, if Operand 1 is larger than Operand 2, member 0 gets the full value of the subtraction; if Operand 2 is larger than Operand 1, member 0 gets 2w + Operand 1 - Operand 2, where w is the component width.

Member 1 of the result gets 0 if Operand 1 ≥ Operand 2, and gets 1 otherwise.

Example: 

%2 = spirv.ISubBorrow %0, %1 : !spirv.struct<(i32, i32)>
%2 = spirv.ISubBorrow %0, %1 : !spirv.struct<(vector<2xi32>, vector<2xi32>)>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultany SPIR-V struct type

spirv.ISub (spirv::ISubOp) 

Integer subtraction of Operand 2 from Operand 1.

Syntax:

operation ::= `spirv.ISub` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of integer type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same number of components as Result Type. They must have the same component width as Result Type.

The resulting value will equal the low-order N bits of the correct result R, where N is the component width and R is computed with enough precision to avoid overflow and underflow.

Results are computed per component.

Example: 

%4 = spirv.ISub %0, %1 : i32
%5 = spirv.ISub %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

spirv.ImageDrefGather (spirv::ImageDrefGatherOp) 

Gathers the requested depth-comparison from four texels.

Syntax:

operation ::= `spirv.ImageDrefGather` $sampledimage `:` type($sampledimage) `,`
              $coordinate `:` type($coordinate) `,` $dref `:` type($dref)
              custom<ImageOperands>($imageoperands)
              ( `(` $operand_arguments^ `:` type($operand_arguments) `)`)?
              attr-dict
              `->` type($result)

Result Type must be a vector of four components of floating-point type or integer type. Its components must be the same as Sampled Type of the underlying OpTypeImage (unless that underlying Sampled Type is OpTypeVoid). It has one component per gathered texel.

Sampled Image must be an object whose type is OpTypeSampledImage. Its OpTypeImage must have a Dim of 2D, Cube, or Rect. The MS operand of the underlying OpTypeImage must be 0.

Coordinate must be a scalar or vector of floating-point type. It contains (u[, v] … [, array layer]) as needed by the definition of Sampled Image.

Dref is the depth-comparison reference value. It must be a 32-bit floating-point type scalar.

Image Operands encodes what operands follow, as per Image Operands.

Example: 

%0 = spirv.ImageDrefGather %1 : !spirv.sampled_image<!spirv.image<i32, Dim2D, NoDepth, NonArrayed, SingleSampled, NoSampler, Unknown>>, %2 : vector<4xf32>, %3 : f32 -> vector<4xi32>
%0 = spirv.ImageDrefGather %1 : !spirv.sampled_image<!spirv.image<i32, Dim2D, NoDepth, NonArrayed, SingleSampled, NoSampler, Unknown>>, %2 : vector<4xf32>, %3 : f32 ["NonPrivateTexel"] : f32, f32 -> vector<4xi32>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
imageoperands::mlir::spirv::ImageOperandsAttr
valid SPIR-V ImageOperands

Enum cases:

  • None (None)
  • Bias (Bias)
  • Lod (Lod)
  • Grad (Grad)
  • ConstOffset (ConstOffset)
  • Offset (Offset)
  • ConstOffsets (ConstOffsets)
  • Sample (Sample)
  • MinLod (MinLod)
  • MakeTexelAvailable (MakeTexelAvailable)
  • MakeTexelVisible (MakeTexelVisible)
  • NonPrivateTexel (NonPrivateTexel)
  • VolatileTexel (VolatileTexel)
  • SignExtend (SignExtend)
  • Offsets (Offsets)
  • ZeroExtend (ZeroExtend)
  • Nontemporal (Nontemporal)

Operands: 

OperandDescription
sampledimageany SPIR-V sampled image type
coordinate16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
dref16/32/64-bit float
operand_argumentsvariadic of void or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

Results: 

ResultDescription
resultvector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16

spirv.Image (spirv::ImageOp) 

Extract the image from a sampled image.

Syntax:

operation ::= `spirv.Image` attr-dict $sampledimage `:` type($sampledimage)

Result Type must be OpTypeImage.

Sampled Image must have type OpTypeSampledImage whose Image Type is the same as Result Type.

Example: 

%0 = spirv.Image %1 : !spirv.sampled_image<!spirv.image<f32, Cube, NoDepth, NonArrayed, SingleSampled, NoSampler, Unknown>>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
sampledimageany SPIR-V sampled image type

Results: 

ResultDescription
resultany SPIR-V image type

spirv.ImageQuerySize (spirv::ImageQuerySizeOp) 

Query the dimensions of Image, with no level of detail.

Syntax:

operation ::= `spirv.ImageQuerySize` attr-dict $image `:` type($image) `->` type($result)

Result Type must be an integer type scalar or vector. The number of components must be:

1 for the 1D and Buffer dimensionalities,

2 for the 2D, Cube, and Rect dimensionalities,

3 for the 3D dimensionality,

plus 1 more if the image type is arrayed. This vector is filled in with (width [, height] [, elements]) where elements is the number of layers in an image array or the number of cubes in a cube-map array.

Image must be an object whose type is OpTypeImage. Its Dim operand must be one of those listed under Result Type, above. Additionally, if its Dim is 1D, 2D, 3D, or Cube, it must also have either an MS of 1 or a Sampled of 0 or 2. There is no implicit level-of-detail consumed by this instruction. See OpImageQuerySizeLod for querying images having level of detail. This operation is allowed on an image decorated as NonReadable. See the client API specification for additional image type restrictions.

Example: 

%3 = spirv.ImageQuerySize %0 : !spirv.image<i32, Dim1D, NoDepth, NonArrayed, SingleSampled, NoSampler, Unknown> -> i32
%4 = spirv.ImageQuerySize %1 : !spirv.image<i32, Dim2D, NoDepth, NonArrayed, SingleSampled, NoSampler, Unknown> -> vector<2xi32>
%5 = spirv.ImageQuerySize %2 : !spirv.image<i32, Dim2D, NoDepth, Arrayed, SingleSampled, NoSampler, Unknown> -> vector<3xi32>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
imageany SPIR-V image type

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.InBoundsPtrAccessChain (spirv::InBoundsPtrAccessChainOp) 

Has the same semantics as OpPtrAccessChain, with the addition that the resulting pointer is known to point within the base object.

Syntax:

operation ::= `spirv.InBoundsPtrAccessChain` $base_ptr `[` $element ($indices^)? `]` attr-dict `:` type($base_ptr) `,` type($element) (`,` type($indices)^)? `->` type($result)

Example: 

func @inbounds_ptr_access_chain(%arg0: !spirv.ptr<f32, CrossWorkgroup>, %arg1 : i64) -> () {
  %0 = spirv.InBoundsPtrAccessChain %arg0[%arg1] : !spirv.ptr<f32, CrossWorkgroup>, i64 -> !spirv.ptr<f32, CrossWorkgroup>
  ...
}

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
base_ptrany SPIR-V pointer type
element8/16/32/64-bit integer
indicesvariadic of 8/16/32/64-bit integer

Results: 

ResultDescription
resultany SPIR-V pointer type

spirv.IsInf (spirv::IsInfOp) 

Result is true if x is an IEEE Inf, otherwise result is false

Syntax:

operation ::= `spirv.IsInf` $operand `:` type($operand) attr-dict

Result Type must be a scalar or vector of Boolean type.

x must be a scalar or vector of floating-point type. It must have the same number of components as Result Type.

Results are computed per component.

Example: 

%2 = spirv.IsInf %0: f32
%3 = spirv.IsInf %1: vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.IsNan (spirv::IsNanOp) 

Result is true if x is an IEEE NaN, otherwise result is false.

Syntax:

operation ::= `spirv.IsNan` $operand `:` type($operand) attr-dict

Result Type must be a scalar or vector of Boolean type.

x must be a scalar or vector of floating-point type. It must have the same number of components as Result Type.

Results are computed per component.

Example: 

%2 = spirv.IsNan %0: f32
%3 = spirv.IsNan %1: vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.KHR.AssumeTrue (spirv::KHRAssumeTrueOp) 

TBD

Syntax:

operation ::= `spirv.KHR.AssumeTrue` $condition attr-dict
assumetruekhr-op ::= `spirv.KHR.AssumeTrue` ssa-use

Example: 

spirv.KHR.AssumeTrue %arg

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Operands: 

OperandDescription
conditionbool

spirv.KHR.CooperativeMatrixLength (spirv::KHRCooperativeMatrixLengthOp) 

Queries the number of cooperative matrix components

Syntax:

operation ::= `spirv.KHR.CooperativeMatrixLength` attr-dict `:` $cooperative_matrix_type

Number of components of a cooperative matrix type accessible to each invocation when treated as a composite.

The type attribute must be a cooperative matrix type.

Example: 

%0 = spirv.KHR.CooperativeMatrixLength :
       !spirv.coopmatrix<8x16xi32, Subgroup, MatrixA>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
cooperative_matrix_type::mlir::TypeAttrtype attribute of any SPIR-V cooperative matrix type

Results: 

ResultDescription
resultInt32

spirv.KHR.CooperativeMatrixLoad (spirv::KHRCooperativeMatrixLoadOp) 

Loads a cooperative matrix through a pointer

Syntax:

operation ::= `spirv.KHR.CooperativeMatrixLoad` $pointer `,` $stride `,` $matrix_layout ( `,` $memory_operand^ )? attr-dict `:`
              type(operands) `->` type($result)

Load a cooperative matrix through a pointer.

Result Type is the type of the loaded object. It must be a cooperative matrix type.

Pointer is a pointer. Its type must be an OpTypePointer whose Type operand is a scalar or vector type. If the Shader capability was declared, Pointer must point into an array and any ArrayStride decoration on Pointer is ignored.

MemoryLayout specifies how matrix elements are laid out in memory. It must come from a 32-bit integer constant instruction whose value corresponds to a Cooperative Matrix Layout. See the Cooperative Matrix Layout table for a description of the layouts and detailed layout-specific rules.

Stride further qualifies how matrix elements are laid out in memory. It must be a scalar integer type and its exact semantics depend on MemoryLayout.

Memory Operand must be a Memory Operand literal. If not present, it is the same as specifying None.

NOTE: In earlier versions of the SPIR-V spec, ‘Memory Operand’ was known as ‘Memory Access’.

For a given dynamic instance of this instruction, all operands of this instruction must be the same for all invocations in a given scope instance (where the scope is the scope the cooperative matrix type was created with). All invocations in a given scope instance must be active or all must be inactive.

TODO: In the SPIR-V spec, stride is an optional argument. We should also support this optionality in the SPIR-V dialect.

Example: 

%0 = spirv.KHR.CooperativeMatrixLoad %ptr, %stride, <RowMajor>
     : !spirv.ptr<i32, StorageBuffer>, i32
         -> !spirv.KHR.coopmatrix<16x8xi32, Workgroup, MatrixA>

%1 = spirv.KHR.CooperativeMatrixLoad %ptr, %stride, <ColumnMajor>, <Volatile>
     : !spirv.ptr<f32, StorageBuffer>, i64
         -> !spirv.KHR.coopmatrix<8x8xf32, Subgroup, MatrixAcc>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
matrix_layout::mlir::spirv::CooperativeMatrixLayoutKHRAttr
valid SPIR-V Cooperative Matrix Layout (KHR)

Enum cases:

  • RowMajor (RowMajor)
  • ColumnMajor (ColumnMajor)
memory_operand::mlir::spirv::MemoryAccessAttr
valid SPIR-V MemoryAccess

Enum cases:

  • None (None)
  • Volatile (Volatile)
  • Aligned (Aligned)
  • Nontemporal (Nontemporal)
  • MakePointerAvailable (MakePointerAvailable)
  • MakePointerVisible (MakePointerVisible)
  • NonPrivatePointer (NonPrivatePointer)
  • AliasScopeINTELMask (AliasScopeINTELMask)
  • NoAliasINTELMask (NoAliasINTELMask)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
stride8/16/32/64-bit integer

Results: 

ResultDescription
resultany SPIR-V cooperative matrix type

spirv.KHR.CooperativeMatrixMulAdd (spirv::KHRCooperativeMatrixMulAddOp) 

Returns the result of (A x B) + C of matrices A, B, and C

Syntax:

operation ::= `spirv.KHR.CooperativeMatrixMulAdd` $a `,` $b `,` $c ( `,` $matrix_operands^ )? attr-dict `:`
              type($a) `,` type($b) `->` type($c)

Linear-algebraic matrix multiply of A by B and then component-wise add C. The order of the operations is implementation-dependent. The internal precision of floating-point operations is defined by the client API. Integer operations used in the multiplication of A by B are performed at the precision of the Result Type and the resulting value will equal the low-order N bits of the correct result R, where N is the result width and R is computed with enough precision to avoid overflow and underflow if the SaturatingAccumulation Cooperative Matrix Operand is not present. If the SaturatingAccumulation Cooperative Matrix Operand is present and overflow or underflow occurs as part of calculating that intermediate result, the result of the instruction is undefined. Integer additions of the elements of that intermediate result with those of C are performed at the precision of Result Type, are exact, and are saturating if the SaturatingAccumulation Cooperative Matrix Operand is present, with the signedness of the saturation being that of the components of Result Type. If the SaturatingAccumulation Cooperative Matrix Operand is not present then the resulting value will equal the low-order N bits of the correct result R, where N is the result width and R is computed with enough precision to avoid overflow and underflow.

Result Type must be a cooperative matrix type with M rows and N columns whose Use must be MatrixAccumulatorKHR.

A is a cooperative matrix with M rows and K columns whose Use must be MatrixAKHR.

B is a cooperative matrix with K rows and N columns whose Use must be MatrixBKHR.

C is a cooperative matrix with M rows and N columns whose Use must be MatrixAccumulatorKHR.

The values of M, N, and K must be consistent across the result and operands. This is referred to as an MxNxK matrix multiply.

A, B, C, and Result Type must have the same scope, and this defines the scope of the operation. A, B, C, and Result Type need not necessarily have the same component type, this is defined by the client API.

If the Component Type of any matrix operand is an integer type, then its components are treated as signed if the Matrix{A,B,C,Result}SignedComponents Cooperative Matrix Operand is present and are treated as unsigned otherwise.

Cooperative Matrix Operands is an optional Cooperative Matrix Operand literal. If not present, it is the same as specifying the Cooperative Matrix Operand None.

For a given dynamic instance of this instruction, all invocations in a given scope instance must be active or all must be inactive (where the scope is the scope of the operation).

cooperative-matrixmuladd-op ::= ssa-id `=` `spirv.KHR.CooperativeMatrixMulAdd`
                          ssa-use `,` ssa-use `,` ssa-use
                          (`<` matrix-operands `>`)? `:`
                          a-cooperative-matrix-type `,`
                          b-cooperative-matrix-type `->`
                            result-cooperative-matrix-type

Example: 

%0 = spirv.KHR.CooperativeMatrixMulAdd %matA, %matB, %matC :
  !spirv.coopmatrix<4x4xf32, Subgroup, MatrixA>,
  !spirv.coopmatrix<4x4xf32, Subgroup, MatrixB> ->
    !spirv.coopmatrix<4x4xf32, Subgroup, MatrixAcc>

%1 = spirv.KHR.CooperativeMatrixMulAdd %matA, %matB, %matC, <ASigned | AccSat> :
  !spirv.coopmatrix<8x16xi32, Subgroup, MatrixA>,
  !spirv.coopmatrix<16x4xi32, Subgroup, MatrixB> ->
    !spirv.coopmatrix<8x4xi32, Subgroup, MatrixAcc>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
matrix_operands::mlir::spirv::CooperativeMatrixOperandsKHRAttr
valid SPIR-V Cooperative Matrix Operands (KHR)

Enum cases:

  • None (None)
  • ASigned (ASigned)
  • BSigned (BSigned)
  • CSigned (CSigned)
  • ResultSigned (ResultSigned)
  • AccSat (AccSat)

Operands: 

OperandDescription
aany SPIR-V cooperative matrix type
bany SPIR-V cooperative matrix type
cany SPIR-V cooperative matrix type

Results: 

ResultDescription
resultany SPIR-V cooperative matrix type

spirv.KHR.CooperativeMatrixStore (spirv::KHRCooperativeMatrixStoreOp) 

Stores a cooperative matrix through a pointer

Syntax:

operation ::= `spirv.KHR.CooperativeMatrixStore` $pointer `,` $object `,` $stride `,` $matrix_layout ( `,` $memory_operand^ )? attr-dict `:`
              type(operands)

Store a cooperative matrix through a pointer. Pointer is a pointer. Its type must be an OpTypePointer whose Type operand is a scalar or vector type. If the Shader capability was declared, Pointer must point into an array and any ArrayStride decoration on Pointer is ignored.

Object is the object to store. Its type must be an OpTypeCooperativeMatrixKHR.

MemoryLayout specifies how matrix elements are laid out in memory. It must come from a 32-bit integer constant instruction whose value corresponds to a Cooperative Matrix Layout. See the Cooperative Matrix Layout table for a description of the layouts and detailed layout-specific rules.

Stride further qualifies how matrix elements are laid out in memory. It must be a scalar integer type and its exact semantics depend on MemoryLayout.

Memory Operand must be a Memory Operand literal. If not present, it is the same as specifying None.

NOTE: In earlier versions of the SPIR-V spec, ‘Memory Operand’ was known as ‘Memory Access’.

For a given dynamic instance of this instruction, all operands of this instruction must be the same for all invocations in a given scope instance (where the scope is the scope the cooperative matrix type was created with). All invocations in a given scope instance must be active or all must be inactive.

TODO: In the SPIR-V spec, stride is an optional argument. We should also support this optionality in the SPIR-V dialect.

Example: 

  spirv.KHR.CooperativeMatrixStore %ptr, %obj, %stride, <RowMajor> :
    !spirv.ptr<i32, StorageBuffer>, !spirv.coopmatrix<16x8xi32, Workgroup, MatrixA>, i32

  spirv.KHR.CooperativeMatrixStore %ptr, %obj, %stride, <ColumnMajor>, <Volatile> :
    !spirv.ptr<f32, StorageBuffer>, !spirv.coopmatrix<8x8xf32, Subgroup, MatrixAcc>, i64

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
matrix_layout::mlir::spirv::CooperativeMatrixLayoutKHRAttr
valid SPIR-V Cooperative Matrix Layout (KHR)

Enum cases:

  • RowMajor (RowMajor)
  • ColumnMajor (ColumnMajor)
memory_operand::mlir::spirv::MemoryAccessAttr
valid SPIR-V MemoryAccess

Enum cases:

  • None (None)
  • Volatile (Volatile)
  • Aligned (Aligned)
  • Nontemporal (Nontemporal)
  • MakePointerAvailable (MakePointerAvailable)
  • MakePointerVisible (MakePointerVisible)
  • NonPrivatePointer (NonPrivatePointer)
  • AliasScopeINTELMask (AliasScopeINTELMask)
  • NoAliasINTELMask (NoAliasINTELMask)

Operands: 

OperandDescription
pointerany SPIR-V pointer type
objectany SPIR-V cooperative matrix type
stride8/16/32/64-bit integer

spirv.KHR.SubgroupBallot (spirv::KHRSubgroupBallotOp) 

See extension SPV_KHR_shader_ballot

Syntax:

operation ::= `spirv.KHR.SubgroupBallot` $predicate attr-dict `:` type($result)

Computes a bitfield value combining the Predicate value from all invocations in the current Subgroup that execute the same dynamic instance of this instruction. The bit is set to one if the corresponding invocation is active and the predicate is evaluated to true; otherwise, it is set to zero.

Predicate must be a Boolean type.

Result Type must be a 4 component vector of 32 bit integer types.

Result is a set of bitfields where the first invocation is represented in bit 0 of the first vector component and the last (up to SubgroupSize) is the higher bit number of the last bitmask needed to represent all bits of the subgroup invocations.

subgroup-ballot-op ::= ssa-id `=` `spirv.KHR.SubgroupBallot`
                            ssa-use `:` `vector` `<` 4 `x` `i32` `>`

Example: 

%0 = spirv.KHR.SubgroupBallot %predicate : vector<4xi32>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Operands: 

OperandDescription
predicatebool

Results: 

ResultDescription
resultvector of 32-bit integer values of length 4

spirv.Load (spirv::LoadOp) 

Load through a pointer.

Result Type is the type of the loaded object. It must be a type with fixed size; i.e., it cannot be, nor include, any OpTypeRuntimeArray types.

Pointer is the pointer to load through. Its type must be an OpTypePointer whose Type operand is the same as Result Type.

If present, any Memory Operands must begin with a memory operand literal. If not present, it is the same as specifying the memory operand None.

memory-access ::= `"None"` | `"Volatile"` | `"Aligned", ` integer-literal
                | `"NonTemporal"`

load-op ::= ssa-id ` = spirv.Load ` storage-class ssa-use
            (`[` memory-access `]`)? ` : ` spirv-element-type

Example: 

%0 = spirv.Variable : !spirv.ptr<f32, Function>
%1 = spirv.Load "Function" %0 : f32
%2 = spirv.Load "Function" %0 ["Volatile"] : f32
%3 = spirv.Load "Function" %0 ["Aligned", 4] : f32

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_access::mlir::spirv::MemoryAccessAttr
valid SPIR-V MemoryAccess

Enum cases:

  • None (None)
  • Volatile (Volatile)
  • Aligned (Aligned)
  • Nontemporal (Nontemporal)
  • MakePointerAvailable (MakePointerAvailable)
  • MakePointerVisible (MakePointerVisible)
  • NonPrivatePointer (NonPrivatePointer)
  • AliasScopeINTELMask (AliasScopeINTELMask)
  • NoAliasINTELMask (NoAliasINTELMask)
alignment::mlir::IntegerAttr32-bit signless integer attribute

Operands: 

OperandDescription
ptrany SPIR-V pointer type

Results: 

ResultDescription
valuevoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.LogicalAnd (spirv::LogicalAndOp) 

Result is true if both Operand 1 and Operand 2 are true. Result is false if either Operand 1 or Operand 2 are false.

Syntax:

operation ::= `spirv.LogicalAnd` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 must be the same as Result Type.

The type of Operand 2 must be the same as Result Type.

Results are computed per component.

Example: 

%2 = spirv.LogicalAnd %0, %1 : i1
%2 = spirv.LogicalAnd %0, %1 : vector<4xi1>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultShape, SameTypeOperands, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand1bool or vector of bool values of length 2/3/4/8/16
operand2bool or vector of bool values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.LogicalEqual (spirv::LogicalEqualOp) 

Result is true if Operand 1 and Operand 2 have the same value. Result is false if Operand 1 and Operand 2 have different values.

Syntax:

operation ::= `spirv.LogicalEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 must be the same as Result Type.

The type of Operand 2 must be the same as Result Type.

Results are computed per component.

Example: 

%2 = spirv.LogicalEqual %0, %1 : i1
%2 = spirv.LogicalEqual %0, %1 : vector<4xi1>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultShape, SameTypeOperands, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand1bool or vector of bool values of length 2/3/4/8/16
operand2bool or vector of bool values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.LogicalNotEqual (spirv::LogicalNotEqualOp) 

Result is true if Operand 1 and Operand 2 have different values. Result is false if Operand 1 and Operand 2 have the same value.

Syntax:

operation ::= `spirv.LogicalNotEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 must be the same as Result Type.

The type of Operand 2 must be the same as Result Type.

Results are computed per component.

Example: 

%2 = spirv.LogicalNotEqual %0, %1 : i1
%2 = spirv.LogicalNotEqual %0, %1 : vector<4xi1>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultShape, SameTypeOperands, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand1bool or vector of bool values of length 2/3/4/8/16
operand2bool or vector of bool values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.LogicalNot (spirv::LogicalNotOp) 

Result is true if Operand is false. Result is false if Operand is true.

Syntax:

operation ::= `spirv.LogicalNot` $operand `:` type($operand) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand must be the same as Result Type.

Results are computed per component.

Example: 

%2 = spirv.LogicalNot %0 : i1
%2 = spirv.LogicalNot %0 : vector<4xi1>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operandbool or vector of bool values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.LogicalOr (spirv::LogicalOrOp) 

Result is true if either Operand 1 or Operand 2 is true. Result is false if both Operand 1 and Operand 2 are false.

Syntax:

operation ::= `spirv.LogicalOr` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 must be the same as Result Type.

The type of Operand 2 must be the same as Result Type.

Results are computed per component.

Example: 

%2 = spirv.LogicalOr %0, %1 : i1
%2 = spirv.LogicalOr %0, %1 : vector<4xi1>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultShape, SameTypeOperands, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand1bool or vector of bool values of length 2/3/4/8/16
operand2bool or vector of bool values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.mlir.loop (spirv::LoopOp) 

Define a structured loop.

SPIR-V can explicitly declare structured control-flow constructs using merge instructions. These explicitly declare a header block before the control flow diverges and a merge block where control flow subsequently converges. These blocks delimit constructs that must nest, and can only be entered and exited in structured ways. See “2.11. Structured Control Flow” of the SPIR-V spec for more details.

Instead of having a spirv.LoopMerge op to directly model loop merge instruction for indicating the merge and continue target, we use regions to delimit the boundary of the loop: the merge target is the next op following the spirv.mlir.loop op and the continue target is the block that has a back-edge pointing to the entry block inside the spirv.mlir.loop’s region. This way it’s easier to discover all blocks belonging to a construct and it plays nicer with the MLIR system.

The spirv.mlir.loop region should contain at least four blocks: one entry block, one loop header block, one loop continue block, one loop merge block. The entry block should be the first block and it should jump to the loop header block, which is the second block. The loop merge block should be the last block. The merge block should only contain a spirv.mlir.merge op. The continue block should be the second to last block and it should have a branch to the loop header block. The loop continue block should be the only block, except the entry block, branching to the header block.

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
loop_control::mlir::spirv::LoopControlAttr
valid SPIR-V LoopControl

Enum cases:

  • None (None)
  • Unroll (Unroll)
  • DontUnroll (DontUnroll)
  • DependencyInfinite (DependencyInfinite)
  • DependencyLength (DependencyLength)
  • MinIterations (MinIterations)
  • MaxIterations (MaxIterations)
  • IterationMultiple (IterationMultiple)
  • PeelCount (PeelCount)
  • PartialCount (PartialCount)
  • InitiationIntervalINTEL (InitiationIntervalINTEL)
  • LoopCoalesceINTEL (LoopCoalesceINTEL)
  • MaxConcurrencyINTEL (MaxConcurrencyINTEL)
  • MaxInterleavingINTEL (MaxInterleavingINTEL)
  • DependencyArrayINTEL (DependencyArrayINTEL)
  • SpeculatedIterationsINTEL (SpeculatedIterationsINTEL)
  • PipelineEnableINTEL (PipelineEnableINTEL)
  • NoFusionINTEL (NoFusionINTEL)

spirv.MatrixTimesMatrix (spirv::MatrixTimesMatrixOp) 

Linear-algebraic multiply of LeftMatrix X RightMatrix.

Syntax:

operation ::= `spirv.MatrixTimesMatrix` operands attr-dict `:` type($leftmatrix) `,` type($rightmatrix) `->` type($result)

Result Type must be an OpTypeMatrix whose Column Type is a vector of floating-point type.

LeftMatrix must be a matrix whose Column Type is the same as the Column Type in Result Type.

RightMatrix must be a matrix with the same Component Type as the Component Type in Result Type. Its number of columns must equal the number of columns in Result Type. Its columns must have the same number of components as the number of columns in LeftMatrix.

Example: 

%0 = spirv.MatrixTimesMatrix %matrix_1, %matrix_2 :
    !spirv.matrix<4 x vector<3xf32>>, !spirv.matrix<3 x vector<4xf32>> ->
    !spirv.matrix<4 x vector<4xf32>>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
leftmatrixany SPIR-V matrix type
rightmatrixany SPIR-V matrix type

Results: 

ResultDescription
resultany SPIR-V matrix type

spirv.MatrixTimesScalar (spirv::MatrixTimesScalarOp) 

Scale a floating-point matrix.

Syntax:

operation ::= `spirv.MatrixTimesScalar` operands attr-dict `:` type($matrix) `,` type($scalar)

Result Type must be a matrix type with a float component type.

The type of Matrix must be the same as Result Type. Each component in each column in Matrix is multiplied by Scalar.

Scalar must have the same type as the Component Type in Result Type.

Example: 

%0 = spirv.MatrixTimesScalar %matrix, %scalar :
!spirv.matrix<3 x vector<3xf32>>, f32 -> !spirv.matrix<3 x vector<3xf32>>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
matrixany SPIR-V matrix type or Cooperative Matrix of 16/32/64-bit float values
scalar16/32/64-bit float

Results: 

ResultDescription
resultany SPIR-V matrix type or Cooperative Matrix of 16/32/64-bit float values

spirv.MemoryBarrier (spirv::MemoryBarrierOp) 

Control the order that memory accesses are observed.

Syntax:

operation ::= `spirv.MemoryBarrier` $memory_scope `,` $memory_semantics attr-dict

Ensures that memory accesses issued before this instruction will be observed before memory accesses issued after this instruction. This control is ensured only for memory accesses issued by this invocation and observed by another invocation executing within Memory scope. If the Vulkan memory model is declared, this ordering only applies to memory accesses that use the NonPrivatePointer memory operand or NonPrivateTexel image operand.

Semantics declares what kind of memory is being controlled and what kind of control to apply.

To execute both a memory barrier and a control barrier, see OpControlBarrier.

Example: 

spirv.MemoryBarrier "Device", "Acquire|UniformMemory"

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_scope::mlir::spirv::ScopeAttr
valid SPIR-V Scope

Enum cases:

  • CrossDevice (CrossDevice)
  • Device (Device)
  • Workgroup (Workgroup)
  • Subgroup (Subgroup)
  • Invocation (Invocation)
  • QueueFamily (QueueFamily)
  • ShaderCallKHR (ShaderCallKHR)
memory_semantics::mlir::spirv::MemorySemanticsAttr
valid SPIR-V MemorySemantics

Enum cases:

  • None (None)
  • Acquire (Acquire)
  • Release (Release)
  • AcquireRelease (AcquireRelease)
  • SequentiallyConsistent (SequentiallyConsistent)
  • UniformMemory (UniformMemory)
  • SubgroupMemory (SubgroupMemory)
  • WorkgroupMemory (WorkgroupMemory)
  • CrossWorkgroupMemory (CrossWorkgroupMemory)
  • AtomicCounterMemory (AtomicCounterMemory)
  • ImageMemory (ImageMemory)
  • OutputMemory (OutputMemory)
  • MakeAvailable (MakeAvailable)
  • MakeVisible (MakeVisible)
  • Volatile (Volatile)

spirv.mlir.merge (spirv::MergeOp) 

A special terminator for merging a structured selection/loop.

Syntax:

operation ::= `spirv.mlir.merge` attr-dict

We use spirv.mlir.selection/spirv.mlir.loop for modelling structured selection/loop. This op is a terminator used inside their regions to mean jumping to the merge point, which is the next op following the spirv.mlir.selection or spirv.mlir.loop op. This op does not have a corresponding instruction in the SPIR-V binary format; it’s solely for structural purpose.

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

spirv.module (spirv::ModuleOp) 

The top-level op that defines a SPIR-V module

This op defines a SPIR-V module using a MLIR region. The region contains one block. Module-level operations, including functions definitions, are all placed in this block.

Using an op with a region to define a SPIR-V module enables “embedding” SPIR-V modules in other dialects in a clean manner: this op guarantees the validity and serializability of a SPIR-V module and thus serves as a clear-cut boundary.

This op takes no operands and generates no results. This op should not implicitly capture values from the enclosing environment.

This op has only one region, which only contains one block. The block has no terminator.

addressing-model ::= `Logical` | `Physical32` | `Physical64` | ...
memory-model ::= `Simple` | `GLSL450` | `OpenCL` | `Vulkan` | ...
spv-module-op ::= `spirv.module` addressing-model memory-model
                  (requires  spirv-vce-attribute)?
                  (`attributes` attribute-dict)?
                  region

Example: 

spirv.module Logical GLSL450  {}

spirv.module Logical Vulkan
    requires #spirv.vce<v1.0, [Shader], [SPV_KHR_vulkan_memory_model]>
    attributes { some_additional_attr = ... } {
  spirv.func @do_nothing() -> () {
    spirv.Return
  }
}

Traits: IsolatedFromAbove, NoRegionArguments, NoTerminator, SingleBlock, SymbolTable

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface, Symbol

Attributes: 

AttributeMLIR TypeDescription
addressing_model::mlir::spirv::AddressingModelAttr
valid SPIR-V AddressingModel

Enum cases:

  • Logical (Logical)
  • Physical32 (Physical32)
  • Physical64 (Physical64)
  • PhysicalStorageBuffer64 (PhysicalStorageBuffer64)
memory_model::mlir::spirv::MemoryModelAttr
valid SPIR-V MemoryModel

Enum cases:

  • Simple (Simple)
  • GLSL450 (GLSL450)
  • OpenCL (OpenCL)
  • Vulkan (Vulkan)
vce_triple::mlir::spirv::VerCapExtAttrversion-capability-extension attribute
sym_name::mlir::StringAttrstring attribute

spirv.Not (spirv::NotOp) 

Complement the bits of Operand.

Syntax:

operation ::= `spirv.Not` $operand `:` type($operand) attr-dict

Results are computed per component, and within each component, per bit.

Result Type must be a scalar or vector of integer type.

Operand’s type must be a scalar or vector of integer type. It must have the same number of components as Result Type. The component width must equal the component width in Result Type.

Example: 

%2 = spirv.Not %0 : i32
%3 = spirv.Not %1 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.Ordered (spirv::OrderedOp) 

Result is true if both x == x and y == y are true, where IEEE comparison is used, otherwise result is false.

Syntax:

operation ::= `spirv.Ordered` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

x must be a scalar or vector of floating-point type. It must have the same number of components as Result Type.

y must have the same type as x.

Results are computed per component.

Example: 

%4 = spirv.Ordered %0, %1 : f32
%5 = spirv.Ordered %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.PtrAccessChain (spirv::PtrAccessChainOp) 

Has the same semantics as OpAccessChain, with the addition of the Element operand.

Syntax:

operation ::= `spirv.PtrAccessChain` $base_ptr `[` $element ($indices^)? `]` attr-dict `:` type($base_ptr) `,` type($element) (`,` type($indices)^)? `->` type($result)

Element is used to do an initial dereference of Base: Base is treated as the address of an element in an array, and a new element address is computed from Base and Element to become the OpAccessChain Base to dereference as per OpAccessChain. This computed Base has the same type as the originating Base.

To compute the new element address, Element is treated as a signed count of elements E, relative to the original Base element B, and the address of element B + E is computed using enough precision to avoid overflow and underflow. For objects in the Uniform, StorageBuffer, or PushConstant storage classes, the element’s address or location is calculated using a stride, which will be the Base-type’s Array Stride if the Base type is decorated with ArrayStride. For all other objects, the implementation calculates the element’s address or location.

With one exception, undefined behavior results when B + E is not an element in the same array (same innermost array, if array types are nested) as B. The exception being when B + E = L, where L is the length of the array: the address computation for element L is done with the same stride as any other B + E computation that stays within the array.

Note: If Base is typed to be a pointer to an array and the desired operation is to select an element of that array, OpAccessChain should be directly used, as its first Index selects the array element.

Example: 

func @ptr_access_chain(%arg0: !spirv.ptr<f32, CrossWorkgroup>, %arg1 : i64) -> () {
  %0 = spirv.PtrAccessChain %arg0[%arg1] : !spirv.ptr<f32, CrossWorkgroup>, i64 -> !spirv.ptr<f32, CrossWorkgroup>
  ...
}

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
base_ptrany SPIR-V pointer type
element8/16/32/64-bit integer
indicesvariadic of 8/16/32/64-bit integer

Results: 

ResultDescription
resultany SPIR-V pointer type

spirv.PtrCastToGeneric (spirv::PtrCastToGenericOp) 

Convert a pointer’s Storage Class to Generic.

Syntax:

operation ::= `spirv.PtrCastToGeneric` $pointer attr-dict `:` type($pointer) `to` type($result)

Result Type must be an OpTypePointer. Its Storage Class must be Generic.

Pointer must point to the Workgroup, CrossWorkgroup, or Function Storage Class.

Result Type and Pointer must point to the same type.

Example: 

%1 = spirv.PtrCastToGenericOp %0 : !spirv.ptr<f32, CrossWorkGroup> to
     !spirv.ptr<f32, Generic>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
pointerany SPIR-V pointer type

Results: 

ResultDescription
resultany SPIR-V pointer type

spirv.mlir.referenceof (spirv::ReferenceOfOp) 

Reference a specialization constant.

Syntax:

operation ::= `spirv.mlir.referenceof` $spec_const attr-dict `:` type($reference)

Specialization constants in module scope are defined using symbol names. This op generates an SSA value that can be used to refer to the symbol within function scope for use in ops that expect an SSA value. This operation has no corresponding SPIR-V instruction; it’s merely used for modelling purpose in the SPIR-V dialect. This op’s return type is the same as the specialization constant.

Example: 

%0 = spirv.mlir.referenceof @spec_const : f32

TODO Add support for composite specialization constants.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
spec_const::mlir::FlatSymbolRefAttrflat symbol reference attribute

Results: 

ResultDescription
referencevoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.Return (spirv::ReturnOp) 

Return with no value from a function with void return type.

Syntax:

operation ::= `spirv.Return` attr-dict

This instruction must be the last instruction in a block.

Example: 

spirv.Return

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

spirv.ReturnValue (spirv::ReturnValueOp) 

Return a value from a function.

Syntax:

operation ::= `spirv.ReturnValue` $value attr-dict `:` type($value)

Value is the value returned, by copy, and must match the Return Type operand of the OpTypeFunction type of the OpFunction body this return instruction is in.

This instruction must be the last instruction in a block.

Example: 

spirv.ReturnValue %0 : f32

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
valuevoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.SConvert (spirv::SConvertOp) 

Convert signed width. This is either a truncate or a sign extend.

Syntax:

operation ::= `spirv.SConvert` $operand attr-dict `:` type($operand) `to` type($result)

Result Type must be a scalar or vector of integer type.

Signed Value must be a scalar or vector of integer type. It must have the same number of components as Result Type. The component width cannot equal the component width in Result Type.

Results are computed per component.

Example: 

%1 = spirv.SConvertOp %0 : i32 to i64
%3 = spirv.SConvertOp %2 : vector<3xi32> to vector<3xi64>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SignedOp, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

spirv.SDiv (spirv::SDivOp) 

Signed-integer division of Operand 1 divided by Operand 2.

Syntax:

operation ::= `spirv.SDiv` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of integer type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same number of components as Result Type. They must have the same component width as Result Type.

Results are computed per component. The resulting value is undefined if Operand 2 is 0.

Example: 

%4 = spirv.SDiv %0, %1 : i32
%5 = spirv.SDiv %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

spirv.SDotAccSat (spirv::SDotAccSatOp) 

Signed integer dot product of Vector 1 and Vector 2 and signed saturating addition of the result with Accumulator.

Syntax:

operation ::= `spirv.SDotAccSat` $vector1 `,` $vector2 `,` $accumulator ( `,` $format^ )? attr-dict `:`
              type($vector1) `->` type($result)

Result Type must be an integer type whose Width must be greater than or equal to that of the components of Vector 1 and Vector 2.

Vector 1 and Vector 2 must have the same type.

Vector 1 and Vector 2 must be either 32-bit integers (enabled by the DotProductInput4x8BitPacked capability) or vectors of integer type (enabled by the DotProductInput4x8Bit or DotProductInputAll capability).

The type of Accumulator must be the same as Result Type.

When Vector 1 and Vector 2 are scalar integer types, Packed Vector Format must be specified to select how the integers are to be interpreted as vectors.

All components of the input vectors are sign-extended to the bit width of the result’s type. The sign-extended input vectors are then multiplied component-wise and all components of the vector resulting from the component-wise multiplication are added together. Finally, the resulting sum is added to the input accumulator. This final addition is saturating.

If any of the multiplications or additions, with the exception of the final accumulation, overflow or underflow, the result of the instruction is undefined.

Example: 

%r = spirv.SDotAccSat %a, %b, %acc, <PackedVectorFormat4x8Bit> : i32 -> i32
%r = spirv.SDotAccSat %a, %b, %acc, <PackedVectorFormat4x8Bit> : i32 -> i64
%r = spirv.SDotAccSat %a, %b, %acc : vector<4xi8> -> i32

Traits: AlwaysSpeculatableImplTrait, SignedOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
format::mlir::spirv::PackedVectorFormatAttr
valid SPIR-V PackedVectorFormat

Enum cases:

  • PackedVectorFormat4x8Bit (PackedVectorFormat4x8Bit)

Operands: 

OperandDescription
vector18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
vector28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
accumulator8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.SDot (spirv::SDotOp) 

Signed integer dot product of Vector 1 and Vector 2.

Syntax:

operation ::= `spirv.SDot` $vector1 `,` $vector2 ( `,` $format^ )? attr-dict `:`
              type($vector1) `->` type($result)

Result Type must be an integer type whose Width must be greater than or equal to that of the components of Vector 1 and Vector 2.

Vector 1 and Vector 2 must have the same type.

Vector 1 and Vector 2 must be either 32-bit integers (enabled by the DotProductInput4x8BitPacked capability) or vectors of integer type (enabled by the DotProductInput4x8Bit or DotProductInputAll capability).

When Vector 1 and Vector 2 are scalar integer types, Packed Vector Format must be specified to select how the integers are to be interpreted as vectors.

All components of the input vectors are sign-extended to the bit width of the result’s type. The sign-extended input vectors are then multiplied component-wise and all components of the vector resulting from the component-wise multiplication are added together. The resulting value will equal the low-order N bits of the correct result R, where N is the result width and R is computed with enough precision to avoid overflow and underflow.

Example: 

%r = spirv.SDot %a, %b, <PackedVectorFormat4x8Bit> : i32 -> i32
%r = spirv.SDot %a, %b, <PackedVectorFormat4x8Bit> : i32 -> i64
%r = spirv.SDot %a, %b : vector<4xi8> -> i32

Traits: AlwaysSpeculatableImplTrait, Commutative, SignedOp

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
format::mlir::spirv::PackedVectorFormatAttr
valid SPIR-V PackedVectorFormat

Enum cases:

  • PackedVectorFormat4x8Bit (PackedVectorFormat4x8Bit)

Operands: 

OperandDescription
vector18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
vector28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.SGreaterThanEqual (spirv::SGreaterThanEqualOp) 

Signed-integer comparison if Operand 1 is greater than or equal to Operand 2.

Syntax:

operation ::= `spirv.SGreaterThanEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same component width, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.SGreaterThanEqual %0, %1 : i32
%5 = spirv.SGreaterThanEqual %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands, SignedOp, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.SGreaterThan (spirv::SGreaterThanOp) 

Signed-integer comparison if Operand 1 is greater than Operand 2.

Syntax:

operation ::= `spirv.SGreaterThan` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same component width, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.SGreaterThan %0, %1 : i32
%5 = spirv.SGreaterThan %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands, SignedOp, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.SLessThanEqual (spirv::SLessThanEqualOp) 

Signed-integer comparison if Operand 1 is less than or equal to Operand 2.

Syntax:

operation ::= `spirv.SLessThanEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same component width, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.SLessThanEqual %0, %1 : i32
%5 = spirv.SLessThanEqual %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands, SignedOp, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.SLessThan (spirv::SLessThanOp) 

Signed-integer comparison if Operand 1 is less than Operand 2.

Syntax:

operation ::= `spirv.SLessThan` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same component width, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.SLessThan %0, %1 : i32
%5 = spirv.SLessThan %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands, SignedOp, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.SMod (spirv::SModOp) 

Signed remainder operation for the remainder whose sign matches the sign of Operand 2.

Syntax:

operation ::= `spirv.SMod` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of integer type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same number of components as Result Type. They must have the same component width as Result Type.

Results are computed per component. The resulting value is undefined if Operand 2 is 0. Otherwise, the result is the remainder r of Operand 1 divided by Operand 2 where if r ≠ 0, the sign of r is the same as the sign of Operand 2.

Example: 

%4 = spirv.SMod %0, %1 : i32
%5 = spirv.SMod %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

spirv.SMulExtended (spirv::SMulExtendedOp) 

Result is the full value of the signed integer multiplication of Operand 1 and Operand 2.

Result Type must be from OpTypeStruct. The struct must have two members, and the two members must be the same type. The member type must be a scalar or vector of integer type.

Operand 1 and Operand 2 must have the same type as the members of Result Type. These are consumed as signed integers.

Results are computed per component.

Member 0 of the result gets the low-order bits of the multiplication.

Member 1 of the result gets the high-order bits of the multiplication.

Example: 

%2 = spirv.SMulExtended %0, %1 : !spirv.struct<(i32, i32)>
%2 = spirv.SMulExtended %0, %1 : !spirv.struct<(vector<2xi32>, vector<2xi32>)>

Traits: AlwaysSpeculatableImplTrait, Commutative

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultany SPIR-V struct type

spirv.SNegate (spirv::SNegateOp) 

Signed-integer subtract of Operand from zero.

Syntax:

operation ::= `spirv.SNegate` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of integer type.

Operand’s type must be a scalar or vector of integer type. It must have the same number of components as Result Type. The component width must equal the component width in Result Type.

Results are computed per component.

Example: 

%1 = spirv.SNegate %0 : i32
%3 = spirv.SNegate %2 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

spirv.SRem (spirv::SRemOp) 

Signed remainder operation for the remainder whose sign matches the sign of Operand 1.

Syntax:

operation ::= `spirv.SRem` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of integer type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same number of components as Result Type. They must have the same component width as Result Type.

Results are computed per component. The resulting value is undefined if Operand 2 is 0. Otherwise, the result is the remainder r of Operand 1 divided by Operand 2 where if r ≠ 0, the sign of r is the same as the sign of Operand 1.

Example: 

%4 = spirv.SRem %0, %1 : i32
%5 = spirv.SRem %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

spirv.SUDotAccSat (spirv::SUDotAccSatOp) 

Mixed-signedness integer dot product of Vector 1 and Vector 2 and signed saturating addition of the result with Accumulator. Components of Vector 1 are treated as signed, components of Vector 2 are treated as unsigned.

Syntax:

operation ::= `spirv.SUDotAccSat` $vector1 `,` $vector2 `,` $accumulator ( `,` $format^ )? attr-dict `:`
              type($vector1) `->` type($result)

Result Type must be an integer type whose Width must be greater than or equal to that of the components of Vector 1 and Vector 2.

Vector 1 and Vector 2 must be either 32-bit integers (enabled by the DotProductInput4x8BitPacked capability) or vectors of integer type with the same number of components and same component Width (enabled by the DotProductInput4x8Bit or DotProductInputAll capability). When Vector 1 and Vector 2 are vectors, the components of Vector 2 must have a Signedness of 0.

The type of Accumulator must be the same as Result Type.

When Vector 1 and Vector 2 are scalar integer types, Packed Vector Format must be specified to select how the integers are to be interpreted as vectors.

All components of Vector 1 are sign-extended to the bit width of the result’s type. All components of Vector 2 are zero-extended to the bit width of the result’s type. The sign- or zero-extended input vectors are then multiplied component-wise and all components of the vector resulting from the component-wise multiplication are added together. Finally, the resulting sum is added to the input accumulator. This final addition is saturating.

If any of the multiplications or additions, with the exception of the final accumulation, overflow or underflow, the result of the instruction is undefined.

Example: 

%r = spirv.SUDotAccSat %a, %b, %acc, <PackedVectorFormat4x8Bit> : i32 -> i32
%r = spirv.SUDotAccSat %a, %b, %acc, <PackedVectorFormat4x8Bit> : i32 -> i64
%r = spirv.SUDotAccSat %a, %b, %acc : vector<4xi8> -> i32

Traits: AlwaysSpeculatableImplTrait, SignedOp, UnsignedOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
format::mlir::spirv::PackedVectorFormatAttr
valid SPIR-V PackedVectorFormat

Enum cases:

  • PackedVectorFormat4x8Bit (PackedVectorFormat4x8Bit)

Operands: 

OperandDescription
vector18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
vector28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
accumulator8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.SUDot (spirv::SUDotOp) 

Mixed-signedness integer dot product of Vector 1 and Vector 2. Components of Vector 1 are treated as signed, components of Vector 2 are treated as unsigned.

Syntax:

operation ::= `spirv.SUDot` $vector1 `,` $vector2 ( `,` $format^ )? attr-dict `:`
              type($vector1) `->` type($result)

Result Type must be an integer type whose Width must be greater than or equal to that of the components of Vector 1 and Vector 2.

Vector 1 and Vector 2 must be either 32-bit integers (enabled by the DotProductInput4x8BitPacked capability) or vectors of integer type with the same number of components and same component Width (enabled by the DotProductInput4x8Bit or DotProductInputAll capability). When Vector 1 and Vector 2 are vectors, the components of Vector 2 must have a Signedness of 0.

When Vector 1 and Vector 2 are scalar integer types, Packed Vector Format must be specified to select how the integers are to be interpreted as vectors.

All components of Vector 1 are sign-extended to the bit width of the result’s type. All components of Vector 2 are zero-extended to the bit width of the result’s type. The sign- or zero-extended input vectors are then multiplied component-wise and all components of the vector resulting from the component-wise multiplication are added together. The resulting value will equal the low-order N bits of the correct result R, where N is the result width and R is computed with enough precision to avoid overflow and underflow.

Example: 

%r = spirv.SUDot %a, %b, <PackedVectorFormat4x8Bit> : i32 -> i32
%r = spirv.SUDot %a, %b, <PackedVectorFormat4x8Bit> : i32 -> i64
%r = spirv.SUDot %a, %b : vector<4xi8> -> i32

Traits: AlwaysSpeculatableImplTrait, SignedOp, UnsignedOp

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
format::mlir::spirv::PackedVectorFormatAttr
valid SPIR-V PackedVectorFormat

Enum cases:

  • PackedVectorFormat4x8Bit (PackedVectorFormat4x8Bit)

Operands: 

OperandDescription
vector18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
vector28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.Select (spirv::SelectOp) 

Select between two objects. Before version 1.4, results are only computed per component.

Syntax:

operation ::= `spirv.Select` operands attr-dict `:` type($condition) `,` type($result)

Before version 1.4, Result Type must be a pointer, scalar, or vector.

The types of Object 1 and Object 2 must be the same as Result Type.

Condition must be a scalar or vector of Boolean type.

If Condition is a scalar and true, the result is Object 1. If Condition is a scalar and false, the result is Object 2.

If Condition is a vector, Result Type must be a vector with the same number of components as Condition and the result is a mix of Object 1 and Object 2: When a component of Condition is true, the corresponding component in the result is taken from Object 1, otherwise it is taken from Object 2.

Example: 

%3 = spirv.Select %0, %1, %2 : i1, f32
%3 = spirv.Select %0, %1, %2 : i1, vector<3xi32>
%3 = spirv.Select %0, %1, %2 : vector<3xi1>, vector<3xf32>

Traits: AlwaysSpeculatableImplTrait, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface, SelectLikeOpInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
conditionbool or vector of bool values of length 2/3/4/8/16
true_value8/16/32/64-bit integer or 16/32/64-bit float or bool or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type
false_value8/16/32/64-bit integer or 16/32/64-bit float or bool or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type

Results: 

ResultDescription
result8/16/32/64-bit integer or 16/32/64-bit float or bool or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type

spirv.mlir.selection (spirv::SelectionOp) 

Define a structured selection.

SPIR-V can explicitly declare structured control-flow constructs using merge instructions. These explicitly declare a header block before the control flow diverges and a merge block where control flow subsequently converges. These blocks delimit constructs that must nest, and can only be entered and exited in structured ways. See “2.11. Structured Control Flow” of the SPIR-V spec for more details.

Instead of having a spirv.SelectionMerge op to directly model selection merge instruction for indicating the merge target, we use regions to delimit the boundary of the selection: the merge target is the next op following the spirv.mlir.selection op. This way it’s easier to discover all blocks belonging to the selection and it plays nicer with the MLIR system.

The spirv.mlir.selection region should contain at least two blocks: one selection header block, and one selection merge. The selection header block should be the first block. The selection merge block should be the last block. The merge block should only contain a spirv.mlir.merge op.

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
selection_control::mlir::spirv::SelectionControlAttr
valid SPIR-V SelectionControl

Enum cases:

  • None (None)
  • Flatten (Flatten)
  • DontFlatten (DontFlatten)

spirv.ShiftLeftLogical (spirv::ShiftLeftLogicalOp) 

Shift the bits in Base left by the number of bits specified in Shift. The least-significant bits are zero filled.

Syntax:

operation ::= `spirv.ShiftLeftLogical` operands attr-dict `:` type($operand1) `,` type($operand2)

Result Type must be a scalar or vector of integer type.

The type of each Base and Shift must be a scalar or vector of integer type. Base and Shift must have the same number of components. The number of components and bit width of the type of Base must be the same as in Result Type.

Shift is treated as unsigned. The result is undefined if Shift is greater than or equal to the bit width of the components of Base.

The number of components and bit width of Result Type must match those Base type. All types must be integer types.

Results are computed per component.

Example: 

%2 = spirv.ShiftLeftLogical %0, %1 : i32, i16
%5 = spirv.ShiftLeftLogical %3, %4 : vector<3xi32>, vector<3xi16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.ShiftRightArithmetic (spirv::ShiftRightArithmeticOp) 

Shift the bits in Base right by the number of bits specified in Shift. The most-significant bits are filled with the sign bit from Base.

Syntax:

operation ::= `spirv.ShiftRightArithmetic` operands attr-dict `:` type($operand1) `,` type($operand2)

Result Type must be a scalar or vector of integer type.

The type of each Base and Shift must be a scalar or vector of integer type. Base and Shift must have the same number of components. The number of components and bit width of the type of Base must be the same as in Result Type.

Shift is treated as unsigned. The result is undefined if Shift is greater than or equal to the bit width of the components of Base.

Results are computed per component.

Example: 

%2 = spirv.ShiftRightArithmetic %0, %1 : i32, i16
%5 = spirv.ShiftRightArithmetic %3, %4 : vector<3xi32>, vector<3xi16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.ShiftRightLogical (spirv::ShiftRightLogicalOp) 

Shift the bits in Base right by the number of bits specified in Shift. The most-significant bits are zero filled.

Syntax:

operation ::= `spirv.ShiftRightLogical` operands attr-dict `:` type($operand1) `,` type($operand2)

Result Type must be a scalar or vector of integer type.

The type of each Base and Shift must be a scalar or vector of integer type. Base and Shift must have the same number of components. The number of components and bit width of the type of Base must be the same as in Result Type.

Shift is consumed as an unsigned integer. The result is undefined if Shift is greater than or equal to the bit width of the components of Base.

Results are computed per component.

Example: 

%2 = spirv.ShiftRightLogical %0, %1 : i32, i16
%5 = spirv.ShiftRightLogical %3, %4 : vector<3xi32>, vector<3xi16>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

spirv.SpecConstantComposite (spirv::SpecConstantCompositeOp) 

Declare a new composite specialization constant.

This op declares a SPIR-V composite specialization constant. This covers the OpSpecConstantComposite SPIR-V instruction. Scalar constants are covered by spirv.SpecConstant.

A constituent of a spec constant composite can be:

  • A symbol referring of another spec constant.
  • The SSA ID of a non-specialization constant (i.e. defined through spirv.SpecConstant).
  • The SSA ID of a spirv.Undef.
spv-spec-constant-composite-op ::= `spirv.SpecConstantComposite` symbol-ref-id ` (`
                                   symbol-ref-id (`, ` symbol-ref-id)*
                                   `) :` composite-type

where composite-type is some non-scalar type that can be represented in the spv dialect: spirv.struct, spirv.array, or vector.

Example: 

spirv.SpecConstant @sc1 = 1   : i32
spirv.SpecConstant @sc2 = 2.5 : f32
spirv.SpecConstant @sc3 = 3.5 : f32
spirv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spirv.struct<i32, f32, f32>

TODO Add support for constituents that are:

  • regular constants.
  • undef.
  • spec constant composite.

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface, Symbol

Attributes: 

AttributeMLIR TypeDescription
type::mlir::TypeAttrany type attribute
sym_name::mlir::StringAttrstring attribute
constituents::mlir::ArrayAttrsymbol ref array attribute

spirv.SpecConstant (spirv::SpecConstantOp) 

Declare a new integer-type or floating-point-type scalar specialization constant.

This op declares a SPIR-V scalar specialization constant. SPIR-V has multiple constant instructions covering different scalar types:

  • OpSpecConstantTrue and OpSpecConstantFalse for boolean constants
  • OpSpecConstant for scalar constants

Similar as spirv.Constant, this op represents all of the above cases. OpSpecConstantComposite and OpSpecConstantOp are modelled with separate ops.

spv-spec-constant-op ::= `spirv.SpecConstant` symbol-ref-id
                         `spec_id(` integer `)`
                         `=` attribute-value (`:` spirv-type)?

where spec_id specifies the SPIR-V SpecId decoration associated with the op.

Example: 

spirv.SpecConstant @spec_const1 = true
spirv.SpecConstant @spec_const2 spec_id(5) = 42 : i32

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface, Symbol

Attributes: 

AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute
default_value::mlir::TypedAttr
TypedAttr instance
This interface is used for attributes that have a type. The type of an
attribute is understood to represent the type of the data contained in the
attribute and is often used as the type of a value with this data.

spirv.SpecConstantOperation (spirv::SpecConstantOperationOp) 

Declare a new specialization constant that results from doing an operation.

This op declares a SPIR-V specialization constant that results from doing an operation on other constants (specialization or otherwise).

In the spv dialect, this op is modelled as follows:

spv-spec-constant-operation-op ::= `spirv.SpecConstantOperation` `wraps`
                                     generic-spirv-op `:` function-type

In particular, an spirv.SpecConstantOperation contains exactly one region. In turn, that region, contains exactly 2 instructions:

  • One of SPIR-V’s instructions that are allowed within an OpSpecConstantOp.
  • An spirv.mlir.yield instruction as the terminator.

The following SPIR-V instructions are valid:

  • OpSConvert,
  • OpUConvert,
  • OpFConvert,
  • OpSNegate,
  • OpNot,
  • OpIAdd,
  • OpISub,
  • OpIMul,
  • OpUDiv,
  • OpSDiv,
  • OpUMod,
  • OpSRem,
  • OpSMod
  • OpShiftRightLogical,
  • OpShiftRightArithmetic,
  • OpShiftLeftLogical
  • OpBitwiseOr,
  • OpBitwiseXor,
  • OpBitwiseAnd
  • OpVectorShuffle,
  • OpCompositeExtract,
  • OpCompositeInsert
  • OpLogicalOr,
  • OpLogicalAnd,
  • OpLogicalNot,
  • OpLogicalEqual,
  • OpLogicalNotEqual
  • OpSelect
  • OpIEqual,
  • OpINotEqual
  • OpULessThan,
  • OpSLessThan
  • OpUGreaterThan,
  • OpSGreaterThan
  • OpULessThanEqual,
  • OpSLessThanEqual
  • OpUGreaterThanEqual,
  • OpSGreaterThanEqual

TODO Add capability-specific ops when supported.

Example: 

%0 = spirv.Constant 1: i32
%1 = spirv.Constant 1: i32

%2 = spirv.SpecConstantOperation wraps "spirv.IAdd"(%0, %1) : (i32, i32) -> i32

Traits: AlwaysSpeculatableImplTrait, SingleBlockImplicitTerminator<YieldOp>, SingleBlock

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Results: 

ResultDescription
resultany type

spirv.Store (spirv::StoreOp) 

Store through a pointer.

Pointer is the pointer to store through. Its type must be an OpTypePointer whose Type operand is the same as the type of Object.

Object is the object to store.

If present, any Memory Operands must begin with a memory operand literal. If not present, it is the same as specifying the memory operand None.

store-op ::= `spirv.Store ` storage-class ssa-use `, ` ssa-use `, `
              (`[` memory-access `]`)? `:` spirv-element-type

Example: 

%0 = spirv.Variable : !spirv.ptr<f32, Function>
%1 = spirv.FMul ... : f32
spirv.Store "Function" %0, %1 : f32
spirv.Store "Function" %0, %1 ["Volatile"] : f32
spirv.Store "Function" %0, %1 ["Aligned", 4] : f32

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
memory_access::mlir::spirv::MemoryAccessAttr
valid SPIR-V MemoryAccess

Enum cases:

  • None (None)
  • Volatile (Volatile)
  • Aligned (Aligned)
  • Nontemporal (Nontemporal)
  • MakePointerAvailable (MakePointerAvailable)
  • MakePointerVisible (MakePointerVisible)
  • NonPrivatePointer (NonPrivatePointer)
  • AliasScopeINTELMask (AliasScopeINTELMask)
  • NoAliasINTELMask (NoAliasINTELMask)
alignment::mlir::IntegerAttr32-bit signless integer attribute

Operands: 

OperandDescription
ptrany SPIR-V pointer type
valuevoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.Transpose (spirv::TransposeOp) 

Transpose a matrix.

Syntax:

operation ::= `spirv.Transpose` operands attr-dict `:` type($matrix) `->` type($result)

Result Type must be an OpTypeMatrix.

Matrix must be an object of type OpTypeMatrix. The number of columns and the column size of Matrix must be the reverse of those in Result Type. The types of the scalar components in Matrix and Result Type must be the same.

Matrix must have of type of OpTypeMatrix.

Example: 

%0 = spirv.Transpose %matrix: !spirv.matrix<2 x vector<3xf32>> ->
!spirv.matrix<3 x vector<2xf32>>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
matrixany SPIR-V matrix type

Results: 

ResultDescription
resultany SPIR-V matrix type

spirv.UConvert (spirv::UConvertOp) 

Convert unsigned width. This is either a truncate or a zero extend.

Syntax:

operation ::= `spirv.UConvert` $operand attr-dict `:` type($operand) `to` type($result)

Result Type must be a scalar or vector of integer type, whose Signedness operand is 0.

Unsigned Value must be a scalar or vector of integer type. It must have the same number of components as Result Type. The component width cannot equal the component width in Result Type.

Results are computed per component.

Example: 

%1 = spirv.UConvertOp %0 : i32 to i64
%3 = spirv.UConvertOp %2 : vector<3xi32> to vector<3xi64>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, UnsignedOp, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

spirv.UDiv (spirv::UDivOp) 

Unsigned-integer division of Operand 1 divided by Operand 2.

Syntax:

operation ::= `spirv.UDiv` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of integer type, whose Signedness operand is 0.

The types of Operand 1 and Operand 2 both must be the same as Result Type.

Results are computed per component. The resulting value is undefined if Operand 2 is 0.

Example: 

%4 = spirv.UDiv %0, %1 : i32
%5 = spirv.UDiv %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType, UnsignedOp, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

spirv.UDotAccSat (spirv::UDotAccSatOp) 

Unsigned integer dot product of Vector 1 and Vector 2 and unsigned saturating addition of the result with Accumulator.

Syntax:

operation ::= `spirv.UDotAccSat` $vector1 `,` $vector2 `,` $accumulator ( `,` $format^ )? attr-dict `:`
              type($vector1) `->` type($result)

Result Type must be an integer type with Signedness of 0 whose Width must be greater than or equal to that of the components of Vector 1 and Vector 2.

Vector 1 and Vector 2 must have the same type.

Vector 1 and Vector 2 must be either 32-bit integers (enabled by the DotProductInput4x8BitPacked capability) or vectors of integer type with Signedness of 0 (enabled by the DotProductInput4x8Bit or DotProductInputAll capability).

The type of Accumulator must be the same as Result Type.

When Vector 1 and Vector 2 are scalar integer types, Packed Vector Format must be specified to select how the integers are to be interpreted as vectors.

All components of the input vectors are zero-extended to the bit width of the result’s type. The zero-extended input vectors are then multiplied component-wise and all components of the vector resulting from the component-wise multiplication are added together. Finally, the resulting sum is added to the input accumulator. This final addition is saturating.

If any of the multiplications or additions, with the exception of the final accumulation, overflow or underflow, the result of the instruction is undefined.

Example: 

%r = spirv.UDotAccSat %a, %b, %acc, <PackedVectorFormat4x8Bit> : i32 -> i32
%r = spirv.UDotAccSat %a, %b, %acc, <PackedVectorFormat4x8Bit> : i32 -> i64
%r = spirv.UDotAccSat %a, %b, %acc : vector<4xi8> -> i32

Traits: AlwaysSpeculatableImplTrait, UnsignedOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
format::mlir::spirv::PackedVectorFormatAttr
valid SPIR-V PackedVectorFormat

Enum cases:

  • PackedVectorFormat4x8Bit (PackedVectorFormat4x8Bit)

Operands: 

OperandDescription
vector18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
vector28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
accumulator8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.UDot (spirv::UDotOp) 

Unsigned integer dot product of Vector 1 and Vector 2.

Syntax:

operation ::= `spirv.UDot` $vector1 `,` $vector2 ( `,` $format^ )? attr-dict `:`
              type($vector1) `->` type($result)

Result Type must be an integer type with Signedness of 0 whose Width must be greater than or equal to that of the components of Vector 1 and Vector 2.

Vector 1 and Vector 2 must have the same type.

Vector 1 and Vector 2 must be either 32-bit integers (enabled by the DotProductInput4x8BitPacked capability) or vectors of integer type with Signedness of 0 (enabled by the DotProductInput4x8Bit or DotProductInputAll capability).

When Vector 1 and Vector 2 are scalar integer types, Packed Vector Format must be specified to select how the integers are to be interpreted as vectors.

All components of the input vectors are zero-extended to the bit width of the result’s type. The zero-extended input vectors are then multiplied component-wise and all components of the vector resulting from the component-wise multiplication are added together. The resulting value will equal the low-order N bits of the correct result R, where N is the result width and R is computed with enough precision to avoid overflow and underflow.

Example: 

%r = spirv.UDot %a, %b, <PackedVectorFormat4x8Bit> : i32 -> i32
%r = spirv.UDot %a, %b, <PackedVectorFormat4x8Bit> : i32 -> i64
%r = spirv.UDot %a, %b : vector<4xi8> -> i32

Traits: AlwaysSpeculatableImplTrait, Commutative, UnsignedOp

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
format::mlir::spirv::PackedVectorFormatAttr
valid SPIR-V PackedVectorFormat

Enum cases:

  • PackedVectorFormat4x8Bit (PackedVectorFormat4x8Bit)

Operands: 

OperandDescription
vector18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
vector28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
result8/16/32/64-bit integer

spirv.UGreaterThanEqual (spirv::UGreaterThanEqualOp) 

Unsigned-integer comparison if Operand 1 is greater than or equal to Operand 2.

Syntax:

operation ::= `spirv.UGreaterThanEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same component width, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.UGreaterThanEqual %0, %1 : i32
%5 = spirv.UGreaterThanEqual %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands, UnsignedOp, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.UGreaterThan (spirv::UGreaterThanOp) 

Unsigned-integer comparison if Operand 1 is greater than Operand 2.

Syntax:

operation ::= `spirv.UGreaterThan` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same component width, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.UGreaterThan %0, %1 : i32
%5 = spirv.UGreaterThan %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands, UnsignedOp, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.ULessThanEqual (spirv::ULessThanEqualOp) 

Unsigned-integer comparison if Operand 1 is less than or equal to Operand 2.

Syntax:

operation ::= `spirv.ULessThanEqual` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same component width, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.ULessThanEqual %0, %1 : i32
%5 = spirv.ULessThanEqual %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands, UnsignedOp, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.ULessThan (spirv::ULessThanOp) 

Unsigned-integer comparison if Operand 1 is less than Operand 2.

Syntax:

operation ::= `spirv.ULessThan` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. They must have the same component width, and they must have the same number of components as Result Type.

Results are computed per component.

Example: 

%4 = spirv.ULessThan %0, %1 : i32
%5 = spirv.ULessThan %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape, SameTypeOperands, UnsignedOp, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.UMod (spirv::UModOp) 

Unsigned modulo operation of Operand 1 modulo Operand 2.

Syntax:

operation ::= `spirv.UMod` operands attr-dict `:` type($result)

Result Type must be a scalar or vector of integer type, whose Signedness operand is 0.

The types of Operand 1 and Operand 2 both must be the same as Result Type.

Results are computed per component. The resulting value is undefined if Operand 2 is 0.

Example: 

%4 = spirv.UMod %0, %1 : i32
%5 = spirv.UMod %2, %3 : vector<4xi32>

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType, UnsignedOp, UsableInSpecConstantOp

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

Results: 

ResultDescription
result8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16 or Cooperative Matrix of 8/16/32/64-bit integer values

spirv.UMulExtended (spirv::UMulExtendedOp) 

Result is the full value of the unsigned integer multiplication of Operand 1 and Operand 2.

Result Type must be from OpTypeStruct. The struct must have two members, and the two members must be the same type. The member type must be a scalar or vector of integer type, whose Signedness operand is 0.

Operand 1 and Operand 2 must have the same type as the members of Result Type. These are consumed as unsigned integers.

Results are computed per component.

Member 0 of the result gets the low-order bits of the multiplication.

Member 1 of the result gets the high-order bits of the multiplication.

Example: 

%2 = spirv.UMulExtended %0, %1 : !spirv.struct<(i32, i32)>
%2 = spirv.UMulExtended %0, %1 : !spirv.struct<(vector<2xi32>, vector<2xi32>)>

Traits: AlwaysSpeculatableImplTrait, Commutative

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand18/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16
operand28/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4/8/16

Results: 

ResultDescription
resultany SPIR-V struct type

spirv.Undef (spirv::UndefOp) 

Make an intermediate object whose value is undefined.

Syntax:

operation ::= `spirv.Undef` attr-dict `:` type($result)

Result Type is the type of object to make.

Each consumption of Result yields an arbitrary, possibly different bit pattern or abstract value resulting in possibly different concrete, abstract, or opaque values.

Example: 

%0 = spirv.Undef : f32
%1 = spirv.Undef : !spirv.struct<!spirv.array<4 x vector<4xi32>>>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Results: 

ResultDescription
resultvoid or bool or 8/16/32/64-bit integer or 16/32/64-bit float or vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16 or any SPIR-V pointer type or any SPIR-V array type or any SPIR-V runtime array type or any SPIR-V struct type or any SPIR-V cooperative matrix type or any SPIR-V matrix type or any SPIR-V sampled image type

spirv.Unordered (spirv::UnorderedOp) 

Result is true if either x or y is an IEEE NaN, otherwise result is false.

Syntax:

operation ::= `spirv.Unordered` $operand1 `,` $operand2 `:` type($operand1) attr-dict

Result Type must be a scalar or vector of Boolean type.

x must be a scalar or vector of floating-point type. It must have the same number of components as Result Type.

y must have the same type as x.

Results are computed per component.

Example: 

%4 = spirv.Unordered %0, %1 : f32
%5 = spirv.Unordered %2, %3 : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultShape, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operand116/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16
operand216/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultbool or vector of bool values of length 2/3/4/8/16

spirv.Unreachable (spirv::UnreachableOp) 

Behavior is undefined if this instruction is executed.

Syntax:

operation ::= `spirv.Unreachable` attr-dict

This instruction must be the last instruction in a block.

Traits: Terminator

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

spirv.Variable (spirv::VariableOp) 

Allocate an object in memory, resulting in a pointer to it, which can be used with OpLoad and OpStore.

Result Type must be an OpTypePointer. Its Type operand is the type of object in memory.

Storage Class is the Storage Class of the memory holding the object. Since the op is used to model function-level variables, the storage class must be the Function Storage Class.

Initializer is optional. If Initializer is present, it will be the initial value of the variable’s memory content. Initializer must be an from a constant instruction or a global (module scope) OpVariable instruction. Initializer must have the same type as the type pointed to by Result Type.

From SPV_KHR_physical_storage_buffer: If an OpVariable’s pointee type is a pointer (or array of pointers) in PhysicalStorageBuffer storage class, then the variable must be decorated with exactly one of AliasedPointer or RestrictPointer.

variable-op ::= ssa-id `=` `spirv.Variable` (`init(` ssa-use `)`)?
                attribute-dict? `:` spirv-pointer-type

where init specifies initializer.

Example: 

%0 = spirv.Constant ...

%1 = spirv.Variable : !spirv.ptr<f32, Function>
%2 = spirv.Variable init(%0): !spirv.ptr<f32, Function>

%3 = spirv.Variable {aliased_pointer} :
  !spirv.ptr<!spirv.ptr<f32, PhysicalStorageBuffer>, Function>

Interfaces: QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Attributes: 

AttributeMLIR TypeDescription
storage_class::mlir::spirv::StorageClassAttr
valid SPIR-V StorageClass

Enum cases:

  • UniformConstant (UniformConstant)
  • Input (Input)
  • Uniform (Uniform)
  • Output (Output)
  • Workgroup (Workgroup)
  • CrossWorkgroup (CrossWorkgroup)
  • Private (Private)
  • Function (Function)
  • Generic (Generic)
  • PushConstant (PushConstant)
  • AtomicCounter (AtomicCounter)
  • Image (Image)
  • StorageBuffer (StorageBuffer)
  • CallableDataKHR (CallableDataKHR)
  • IncomingCallableDataKHR (IncomingCallableDataKHR)
  • RayPayloadKHR (RayPayloadKHR)
  • HitAttributeKHR (HitAttributeKHR)
  • IncomingRayPayloadKHR (IncomingRayPayloadKHR)
  • ShaderRecordBufferKHR (ShaderRecordBufferKHR)
  • PhysicalStorageBuffer (PhysicalStorageBuffer)
  • CodeSectionINTEL (CodeSectionINTEL)
  • DeviceOnlyINTEL (DeviceOnlyINTEL)
  • HostOnlyINTEL (HostOnlyINTEL)

Operands: 

OperandDescription
initializerany type

Results: 

ResultDescription
pointerany SPIR-V pointer type

spirv.VectorExtractDynamic (spirv::VectorExtractDynamicOp) 

Extract a single, dynamically selected, component of a vector.

Syntax:

operation ::= `spirv.VectorExtractDynamic` $vector `[` $index `]` attr-dict `:` type($vector) `,` type($index)

Result Type must be a scalar type.

Vector must have a type OpTypeVector whose Component Type is Result Type.

Index must be a scalar integer. It is interpreted as a 0-based index of which component of Vector to extract.

Behavior is undefined if Index’s value is less than zero or greater than or equal to the number of components in Vector.

Example: 

%2 = spirv.VectorExtractDynamic %0[%1] : vector<8xf32>, i32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
vectorvector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16
index8/16/32/64-bit integer

Results: 

ResultDescription
result8/16/32/64-bit integer or 16/32/64-bit float or bool

spirv.VectorInsertDynamic (spirv::VectorInsertDynamicOp) 

Make a copy of a vector, with a single, variably selected, component modified.

Syntax:

operation ::= `spirv.VectorInsertDynamic` $component `,` $vector `[` $index `]` attr-dict `:` type($vector) `,` type($index)

Result Type must be an OpTypeVector.

Vector must have the same type as Result Type and is the vector that the non-written components are copied from.

Component is the value supplied for the component selected by Index. It must have the same type as the type of components in Result Type.

Index must be a scalar integer. It is interpreted as a 0-based index of which component to modify.

Behavior is undefined if Index’s value is less than zero or greater than or equal to the number of components in Vector.

Example: 

%scalar = ... : f32
%2 = spirv.VectorInsertDynamic %scalar %0[%1] : f32, vector<8xf32>, i32

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
vectorvector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16
component8/16/32/64-bit integer or 16/32/64-bit float or bool
index8/16/32/64-bit integer

Results: 

ResultDescription
resultvector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16

spirv.VectorShuffle (spirv::VectorShuffleOp) 

Select arbitrary components from two vectors to make a new vector.

Syntax:

operation ::= `spirv.VectorShuffle` attr-dict $components $vector1 `,` $vector2 `:`
              type($vector1) `,` type($vector2) `->` type($result)

Result Type must be an OpTypeVector. The number of components in Result Type must be the same as the number of Component operands.

Vector 1 and Vector 2 must both have vector types, with the same Component Type as Result Type. They do not have to have the same number of components as Result Type or with each other. They are logically concatenated, forming a single vector with Vector 1’s components appearing before Vector 2’s. The components of this logical vector are logically numbered with a single consecutive set of numbers from 0 to N

  • 1, where N is the total number of components.

Components are these logical numbers (see above), selecting which of the logically numbered components form the result. Each component is an unsigned 32-bit integer. They can select the components in any order and can repeat components. The first component of the result is selected by the first Component operand, the second component of the result is selected by the second Component operand, etc. A Component literal may also be FFFFFFFF, which means the corresponding result component has no source and is undefined. All Component literals must either be FFFFFFFF or in [0, N - 1] (inclusive).

Note: A vector “swizzle” can be done by using the vector for both Vector operands, or using an OpUndef for one of the Vector operands.

Example: 

%0 = spirv.VectorShuffle [1: i32, 3: i32, 5: i32] %vector1, %vector2 :
  vector<4xf32>, vector<2xf32> -> vector<3xf32>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
components::mlir::ArrayAttr32-bit integer array attribute

Operands: 

OperandDescription
vector1vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16
vector2vector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16

Results: 

ResultDescription
resultvector of bool or 8/16/32/64-bit integer or 16/32/64-bit float values of length 2/3/4/8/16

spirv.VectorTimesScalar (spirv::VectorTimesScalarOp) 

Scale a floating-point vector.

Syntax:

operation ::= `spirv.VectorTimesScalar` operands attr-dict `:` `(` type(operands) `)` `->` type($result)

Result Type must be a vector of floating-point type.

The type of Vector must be the same as Result Type. Each component of Vector is multiplied by Scalar.

Scalar must have the same type as the Component Type in Result Type.

Example: 

%0 = spirv.VectorTimesScalar %vector, %scalar : vector<4xf32>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
vectorvector of 16/32/64-bit float values of length 2/3/4
scalar16/32/64-bit float

Results: 

ResultDescription
resultvector of 16/32/64-bit float values of length 2/3/4

spirv.mlir.yield (spirv::YieldOp) 

Yields the result computed in spirv.SpecConstantOperation’s region back to the parent op.

Syntax:

operation ::= `spirv.mlir.yield` attr-dict $operand `:` type($operand)

This op is a special terminator whose only purpose is to terminate an spirv.SpecConstantOperation’s enclosed region. It accepts a single operand produced by the preceeding (and only other) instruction in its parent block (see SPIRV_SpecConstantOperation for further details). This op has no corresponding SPIR-V instruction.

Example: 

%0 = ... (some op supported by SPIR-V OpSpecConstantOp)
spirv.mlir.yield %0

Traits: AlwaysSpeculatableImplTrait, HasParent<SpecConstantOperationOp>, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), QueryCapabilityInterface, QueryExtensionInterface, QueryMaxVersionInterface, QueryMinVersionInterface

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
operandany type