diff --git a/mlir/docs/DialectConversion.md b/mlir/docs/DialectConversion.md --- a/mlir/docs/DialectConversion.md +++ b/mlir/docs/DialectConversion.md @@ -431,12 +431,12 @@ } -> FAILURE : unable to fold * Pattern : 'func.return -> ()' { - ** Insert : 'spv.Return'(0x6070000453e0) + ** Insert : 'spirv.Return'(0x6070000453e0) ** Replace : 'func.return'(0x608000002e20) //===-------------------------------------------===// - Legalizing operation : 'spv.Return'(0x6070000453e0) { - "spv.Return"() : () -> () + Legalizing operation : 'spirv.Return'(0x6070000453e0) { + "spirv.Return"() : () -> () } -> SUCCESS : operation marked legal by the target //===-------------------------------------------===// @@ -448,5 +448,5 @@ This output is describing the legalization of an `func.return` operation. We first try to legalize by folding the operation, but that is unsuccessful for `func.return`. From there, a pattern is applied that replaces the `func.return` -with a `spv.Return`. The newly generated `spv.Return` is then processed for +with a `spirv.Return`. The newly generated `spirv.Return` is then processed for legalization, but is found to already legal as per the target. diff --git a/mlir/docs/Dialects/SPIR-V.md b/mlir/docs/Dialects/SPIR-V.md --- a/mlir/docs/Dialects/SPIR-V.md +++ b/mlir/docs/Dialects/SPIR-V.md @@ -76,36 +76,36 @@ The SPIR-V dialect adopts the following conventions for IR: -* The prefix for all SPIR-V types and operations are `spv.`. +* 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 `spv.GL.`. + 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, `spv.FMul` is a direct mirror of `OpFMul` in the + 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, `spv.module` - and `spv.Constant`. They may correspond to one or more instructions during + 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, `spv.mlir.merge`. They + 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 `spv.mlir.` prefix for +(TODO: consider merging the last two cases and adopting `spirv.mlir.` prefix for them.) ## Module -A SPIR-V module is defined via the `spv.module` op, which has one region that +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 `spv.module` op based on the +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. @@ -114,11 +114,11 @@ * We can attach additional model-level attributes. * We can control custom assembly form. -The `spv.module` op's region cannot capture SSA values from outside, neither -implicitly nor explicitly. The `spv.module` op's region is closed as to what ops +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 `spv.module` op's verifier enforces this rule. This -meaningfully guarantees that a `spv.module` can be the entry point and boundary +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 @@ -148,7 +148,7 @@ #### Use MLIR attributes for metadata * Requirements for capabilities, extensions, extended instruction sets, - addressing model, and memory model are conveyed using `spv.module` + 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 @@ -166,23 +166,23 @@ #### Unify and localize constants * Various normal constant instructions are represented by the same - `spv.Constant` op. Those instructions are just for constants of different + `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 `spv.module`'s region; they are localized +* 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 `spv.GlobalVariable` op. They do not +* 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, `spv.mlir.addressof` is + 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 `spv.SpecConstant` op. Similar +* 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. `spv.mlir.referenceof` is needed to turn the symbol into an SSA + 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 @@ -200,10 +200,10 @@ * 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 - `spv.module` op attributes. We can model them as normal ops of using symbol + `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 `spv.module`'s region. + model them as normal ops in `spirv.module`'s region. ## Decorations @@ -226,8 +226,8 @@ We can represent them in the SPIR-V dialect as: ```mlir -%v1 = "spv.FMul"(%0, %0) {RelaxedPrecision: unit} : (f32, f32) -> (f32) -%v2 = "spv.FMul"(%1, %1) {NoContraction: unit} : (f32, f32) -> (f32) +%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 @@ -288,16 +288,16 @@ | vector-type | spirv-type -array-type ::= `!spv.array` `<` integer-literal `x` element-type +array-type ::= `!spirv.array` `<` integer-literal `x` element-type (`,` `stride` `=` integer-literal)? `>` ``` For example, ```mlir -!spv.array<4 x i32> -!spv.array<4 x i32, stride = 4> -!spv.array<16 x vector<4 x f32>> +!spirv.array<4 x i32> +!spirv.array<4 x i32, stride = 4> +!spirv.array<16 x vector<4 x f32>> ``` ### Image type @@ -317,7 +317,7 @@ format ::= `Unknown` | `Rgba32f` | -image-type ::= `!spv.image<` element-type `,` dim `,` depth-info `,` +image-type ::= `!spirv.image<` element-type `,` dim `,` depth-info `,` arrayed-info `,` sampling-info `,` sampler-use-info `,` format `>` ``` @@ -325,8 +325,8 @@ For example, ```mlir -!spv.image -!spv.image +!spirv.image +!spirv.image ``` ### Pointer type @@ -339,14 +339,14 @@ | `Workgroup` | -pointer-type ::= `!spv.ptr<` element-type `,` storage-class `>` +pointer-type ::= `!spirv.ptr<` element-type `,` storage-class `>` ``` For example, ```mlir -!spv.ptr -!spv.ptr, Uniform> +!spirv.ptr +!spirv.ptr, Uniform> ``` ### Runtime array type @@ -354,22 +354,22 @@ This corresponds to SPIR-V [runtime array type][RuntimeArrayType]. Its syntax is ``` -runtime-array-type ::= `!spv.rtarray` `<` element-type (`,` `stride` `=` integer-literal)? `>` +runtime-array-type ::= `!spirv.rtarray` `<` element-type (`,` `stride` `=` integer-literal)? `>` ``` For example, ```mlir -!spv.rtarray -!spv.rtarray -!spv.rtarray> +!spirv.rtarray +!spirv.rtarray +!spirv.rtarray> ``` ### Sampled image type This corresponds to SPIR-V [sampled image type][SampledImageType]. Its syntax is ``` -sampled-image-type ::= `!spv.sampled_image>` ``` @@ -377,8 +377,8 @@ For example, ```mlir -!spv.sampled_image> -!spv.sampled_image> +!spirv.sampled_image> +!spirv.sampled_image> ``` ### Struct type @@ -387,17 +387,17 @@ ``` struct-member-decoration ::= integer-literal? spirv-decoration* -struct-type ::= `!spv.struct<` spirv-type (`[` struct-member-decoration `]`)? +struct-type ::= `!spirv.struct<` spirv-type (`[` struct-member-decoration `]`)? (`, ` spirv-type (`[` struct-member-decoration `]`)? ``` For Example, ```mlir -!spv.struct -!spv.struct -!spv.struct> -!spv.struct +!spirv.struct +!spirv.struct +!spirv.struct> +!spirv.struct ``` ## Function @@ -423,12 +423,12 @@ ```mlir func.func @f(%arg: i32) -> i32 { - "spv.ReturnValue"(%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. `spv.module` verifies these requirements. +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 @@ -442,7 +442,7 @@ [greedy pattern rewriter][GreedyPatternRewriter] can only act on ops isolated from above. -(TODO: create a dedicated `spv.fn` op for SPIR-V functions.) +(TODO: create a dedicated `spirv.fn` op for SPIR-V functions.) ## Operations @@ -475,9 +475,9 @@ can be represented in the dialect as ```mlir -%0 = "spv.Constant"() { value = 42 : i32 } : () -> i32 -%1 = "spv.Variable"(%0) { storage_class = "Function" } : (i32) -> !spv.ptr -%2 = "spv.IAdd"(%0, %0) : (i32, i32) -> i32 +%0 = "spirv.Constant"() { value = 42 : i32 } : () -> i32 +%1 = "spirv.Variable"(%0) { storage_class = "Function" } : (i32) -> !spirv.ptr +%2 = "spirv.IAdd"(%0, %0) : (i32, i32) -> i32 ``` Operation documentation is written in each op's Op Definition Spec using @@ -508,8 +508,8 @@ we can have ```mlir -%1 = "spv.GL.Log"(%cst) : (f32) -> (f32) -%2 = "spv.GL.Sqrt"(%cst) : (f32) -> (f32) +%1 = "spirv.GL.Log"(%cst) : (f32) -> (f32) +%2 = "spirv.GL.Sqrt"(%cst) : (f32) -> (f32) ``` ## Control Flow @@ -525,21 +525,21 @@ belonging to a structured control flow construct. It is also more idiomatic to MLIR system. -We introduce a `spv.mlir.selection` and `spv.mlir.loop` op for structured selections and +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, `spv.mlir.merge` is introduced for branching to +their regions, a special terminator, `spirv.mlir.merge` is introduced for branching to the merge target. ### Selection -`spv.mlir.selection` defines a selection construct. It contains one region. The +`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 - `spv.BranchConditional` or `spv.Switch` op. + `spirv.BranchConditional` or `spirv.Switch` op. * The merge block should be the last block. The merge block should only - contain a `spv.mlir.merge` op. Any block can branch to the merge block for early + contain a `spirv.mlir.merge` op. Any block can branch to the merge block for early exit. ``` @@ -581,24 +581,24 @@ ```mlir func.func @selection(%cond: i1) -> () { - %zero = spv.Constant 0: i32 - %one = spv.Constant 1: i32 - %two = spv.Constant 2: i32 - %x = spv.Variable init(%zero) : !spv.ptr + %zero = spirv.Constant 0: i32 + %one = spirv.Constant 1: i32 + %two = spirv.Constant 2: i32 + %x = spirv.Variable init(%zero) : !spirv.ptr - spv.mlir.selection { - spv.BranchConditional %cond, ^then, ^else + spirv.mlir.selection { + spirv.BranchConditional %cond, ^then, ^else ^then: - spv.Store "Function" %x, %one : i32 - spv.Branch ^merge + spirv.Store "Function" %x, %one : i32 + spirv.Branch ^merge ^else: - spv.Store "Function" %x, %two : i32 - spv.Branch ^merge + spirv.Store "Function" %x, %two : i32 + spirv.Branch ^merge ^merge: - spv.mlir.merge + spirv.mlir.merge } // ... @@ -608,14 +608,14 @@ ### Loop -`spv.mlir.loop` defines a loop construct. It contains one region. The region should +`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 `spv.mlir.merge` op. Any block except the entry block can branch to + 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. @@ -669,30 +669,30 @@ ```mlir func.func @loop(%count : i32) -> () { - %zero = spv.Constant 0: i32 - %one = spv.Constant 1: i32 - %var = spv.Variable init(%zero) : !spv.ptr + %zero = spirv.Constant 0: i32 + %one = spirv.Constant 1: i32 + %var = spirv.Variable init(%zero) : !spirv.ptr - spv.mlir.loop { - spv.Branch ^header + spirv.mlir.loop { + spirv.Branch ^header ^header: - %val0 = spv.Load "Function" %var : i32 - %cmp = spv.SLessThan %val0, %count : i32 - spv.BranchConditional %cmp, ^body, ^merge + %val0 = spirv.Load "Function" %var : i32 + %cmp = spirv.SLessThan %val0, %count : i32 + spirv.BranchConditional %cmp, ^body, ^merge ^body: // ... - spv.Branch ^continue + spirv.Branch ^continue ^continue: - %val1 = spv.Load "Function" %var : i32 - %add = spv.IAdd %val1, %one : i32 - spv.Store "Function" %var, %add : i32 - spv.Branch ^header + %val1 = spirv.Load "Function" %var : i32 + %add = spirv.IAdd %val1, %one : i32 + spirv.Store "Function" %var, %add : i32 + spirv.Branch ^header ^merge: - spv.mlir.merge + spirv.mlir.merge } return } @@ -729,28 +729,28 @@ ```mlir func.func @foo() -> () { - %var = spv.Variable : !spv.ptr + %var = spirv.Variable : !spirv.ptr - spv.mlir.selection { - %true = spv.Constant true - spv.BranchConditional %true, ^true, ^false + spirv.mlir.selection { + %true = spirv.Constant true + spirv.BranchConditional %true, ^true, ^false ^true: - %zero = spv.Constant 0 : i32 - spv.Branch ^phi(%zero: i32) + %zero = spirv.Constant 0 : i32 + spirv.Branch ^phi(%zero: i32) ^false: - %one = spv.Constant 1 : i32 - spv.Branch ^phi(%one: i32) + %one = spirv.Constant 1 : i32 + spirv.Branch ^phi(%one: i32) ^phi(%arg: i32): - spv.Store "Function" %var, %arg : i32 - spv.Return + spirv.Store "Function" %var, %arg : i32 + spirv.Return ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } ``` @@ -778,7 +778,7 @@ 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, `spv.ControlBarrier` requires no +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`. @@ -801,8 +801,8 @@ 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 `spv.target_env` (`spirv::TargetEnvAttr`) attribute. It -should be of `#spv.target_env` attribute kind, which is defined as: +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` | ... @@ -817,7 +817,7 @@ spirv-resource-limits ::= dictionary-attribute -spirv-vce-attribute ::= `#` `spv.vce` `<` +spirv-vce-attribute ::= `#` `spirv.vce` `<` spirv-version `,` spirv-capability-list `,` spirv-extensions-list `>` @@ -827,7 +827,7 @@ spirv-device-id ::= integer-literal spirv-device-info ::= spirv-vendor-id (`:` spirv-device-type (`:` spirv-device-id)?)? -spirv-target-env-attribute ::= `#` `spv.target_env` `<` +spirv-target-env-attribute ::= `#` `spirv.target_env` `<` spirv-vce-attribute, (spirv-device-info `,`)? spirv-resource-limits `>` @@ -835,7 +835,7 @@ The attribute has a few fields: -* A `#spv.vce` (`spirv::VerCapExtAttr`) attribute: +* 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. @@ -848,8 +848,8 @@ ``` module attributes { -spv.target_env = #spv.target_env< - #spv.vce, +spirv.target_env = #spirv.target_env< + #spirv.vce, ARM:IntegratedGPU, { max_compute_workgroup_invocations = 128 : i32, @@ -858,7 +858,7 @@ } { ... } ``` -Dialect conversion framework will utilize the information in `spv.target_env` to +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`](#spirvconversiontarget) by providing such an @@ -904,26 +904,26 @@ The SPIR-V dialect defines [a few attributes][MlirSpirvAbi] for specifying these interfaces: -* `spv.entry_point_abi` is a struct attribute that should be attached to the +* `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. -* `spv.interface_var_abi` is attribute that should be attached to each operand - and result of the entry function. It should be of `#spv.interface_var_abi` +* `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 ::= `#` `spv.interface_var_abi` `<(` spv-descriptor-set +spv-interface-var-abi ::= `#` `spirv.interface_var_abi` `<(` spv-descriptor-set `,` spv-binding `)` (`,` spv-storage-class)? `>` ``` For example, ``` -#spv.interface_var_abi<(0, 0), StorageBuffer> -#spv.interface_var_abi<(0, 1)> +#spirv.interface_var_abi<(0, 0), StorageBuffer> +#spirv.interface_var_abi<(0, 1)> ``` The attribute has a few fields: @@ -936,11 +936,11 @@ uses this information to lower the entry point function and its ABI consistent with the Vulkan validation rules. Specifically, -* Creates `spv.GlobalVariable`s for the arguments, and replaces all uses of +* Creates `spirv.GlobalVariable`s for the arguments, and replaces all uses of the argument with this variable. The SSA value used for replacement is - obtained using the `spv.mlir.addressof` operation. -* Adds the `spv.EntryPoint` and `spv.ExecutionMode` operations into the - `spv.module` for the entry function. + 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 @@ -966,16 +966,16 @@ A few transformations are performed in the process of serialization because of the representational differences between SPIR-V dialect and binary format: -* Attributes on `spv.module` are emitted as their corresponding SPIR-V +* 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. -* `spv.Constant`s are unified and placed in the SPIR-V binary module section +* `spirv.Constant`s 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. -* `spv.mlir.selection`s and `spv.mlir.loop`s are emitted as basic blocks with `Op*Merge` +* `spirv.mlir.selection`s and `spirv.mlir.loop`s 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. @@ -984,20 +984,20 @@ * Instructions for execution environment requirements (extensions, capabilities, extended instruction sets, etc.) will be placed as attributes - on `spv.module`. + on `spirv.module`. * `OpType*` instructions will be converted into proper `mlir::Type`s. -* `OpConstant*` instructions are materialized as `spv.Constant` at each use +* `OpConstant*` instructions are materialized as `spirv.Constant` at each use site. -* `OpVariable` instructions will be converted to `spv.GlobalVariable` ops if - in module-level; otherwise they will be converted into `spv.Variable` ops. +* `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 - `spv.mlir.addressof` op to turn the symbol of the corresponding - `spv.GlobalVariable` into an SSA value. + `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 - `spv.mlir.referenceof` op to turn the symbol of the corresponding - `spv.SpecConstant` into an SSA value. + `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 `spv.mlir.selection` and `spv.mlir.loop`. +* Structured control flow are placed inside `spirv.mlir.selection` and `spirv.mlir.loop`. ## Conversions @@ -1017,12 +1017,12 @@ The `mlir::spirv::SPIRVConversionTarget` class derives from the `mlir::ConversionTarget` class and serves as a utility to define a conversion -target satisfying a given [`spv.target_env`](#target-environment). It registers +target satisfying a given [`spirv.target_env`](#target-environment). 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 -`spv.target_env` attached in the input IR or use the default to construct a +`spirv.target_env` attached in the input IR or use the default to construct a `SPIRVConversionTarget`. ### `SPIRVTypeConverter` @@ -1052,7 +1052,7 @@ (TODO: Convert other vectors of lengths to scalars or arrays) [Builtin memref types][MlirMemrefType] with static shape and stride are -converted to `spv.ptr>>`s. The resultant SPIR-V array +converted to `spirv.ptr>>`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 @@ -1063,24 +1063,24 @@ #### Setting layout for shader interface variables SPIR-V validation rules for shaders require composite objects to be explicitly -laid out. If a `spv.GlobalVariable` is not explicitly laid out, the utility +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][VulkanShaderInterface]. #### Creating builtin variables -In SPIR-V dialect, builtins are represented using `spv.GlobalVariable`s, with -`spv.mlir.addressof` used to get a handle to the builtin as an SSA value. The -method `mlir::spirv::getBuiltinVariableValue` creates a `spv.GlobalVariable` for -the builtin in the current `spv.module` if it does not exist already, and -returns an SSA value generated from an `spv.mlir.addressof` operation. +In SPIR-V dialect, builtins are represented using `spirv.GlobalVariable`s, 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 * [Arithmetic Dialect][MlirArithmeticDialect] -* [GPU Dialect][MlirGpuDialect] : A gpu.module is converted to a `spv.module`. +* [GPU Dialect][MlirGpuDialect] : A gpu.module is converted to a `spirv.module`. A gpu.function within this module is lowered as an entry function. ## Code organization @@ -1160,7 +1160,7 @@ ## Rationale -### Lowering `memref`s to `!spv.array<..>` and `!spv.rtarray<..>`. +### Lowering `memref`s to `!spirv.array<..>` and `!spirv.rtarray<..>`. The LLVM dialect lowers `memref` types to a `MemrefDescriptor`: @@ -1177,8 +1177,8 @@ ``` In SPIR-V dialect, we chose not to use a `MemrefDescriptor`. Instead a `memref` -is lowered directly to a `!spv.ptr>` when the -`memref` is statically shaped, and `!spv.ptr>` when the +is lowered directly to a `!spirv.ptr>` when the +`memref` is statically shaped, and `!spirv.ptr>` when the `memref` is dynamically shaped. The rationale behind this choice is described below. @@ -1198,7 +1198,7 @@ Vulkan-capable device we can target; basically ruling out mobile support.. 1. An alternative to having one level of indirection (as is the case with - `MemrefDescriptor`s), is to embed the `!spv.array` or `!spv.rtarray` + `MemrefDescriptor`s), 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 @@ -1364,7 +1364,7 @@ `mlir::spirv::SPIRVTypeConverter`. If the operation has a region, [signature conversion][MlirDialectConversionSignatureConversion] might be needed as well. -**Note**: The current validation rules of `spv.module` require that all +**Note**: The current validation rules of `spirv.module` require that all operations contained within its region are valid operations in the SPIR-V dialect. diff --git a/mlir/docs/PassManagement.md b/mlir/docs/PassManagement.md --- a/mlir/docs/PassManagement.md +++ b/mlir/docs/PassManagement.md @@ -379,7 +379,7 @@ ```mlir module { - spv.module "Logical" "GLSL450" { + spirv.module "Logical" "GLSL450" { func @foo() { ... } @@ -391,8 +391,8 @@ ``` `builtin.module` - `spv.module` - `spv.func` + `spirv.module` + `spirv.func` ``` Below is an example of constructing a pipeline that operates on the above @@ -419,7 +419,7 @@ nestedFunctionPM.addPass(std::make_unique()); // Nest an op-agnostic pass manager. This will operate on any viable -// operation, e.g. func.func, spv.func, spv.module, builtin.module, etc. +// operation, e.g. func.func, spirv.func, spirv.module, builtin.module, etc. OpPassManager &nestedAnyPM = nestedModulePM.nestAny(); nestedAnyPM.addPass(createCanonicalizePass()); nestedAnyPM.addPass(createCSEPass()); diff --git a/mlir/docs/SPIRVToLLVMDialectConversion.md b/mlir/docs/SPIRVToLLVMDialectConversion.md --- a/mlir/docs/SPIRVToLLVMDialectConversion.md +++ b/mlir/docs/SPIRVToLLVMDialectConversion.md @@ -45,7 +45,7 @@ SPIR-V Dialect | LLVM Dialect :-------------------------------------------: | :-------------------------: -`!spv.ptr< , >` | `!llvm.ptr<>` +`!spirv.ptr< , >` | `!llvm.ptr<>` ### Array types @@ -60,8 +60,8 @@ SPIR-V Dialect | LLVM Dialect :------------------------------------: | :-------------------------------------: -`!spv.array< x >` | `!llvm.array< x >` -`!spv.rtarray< >` | `!llvm.array<0 x >` +`!spirv.array< x >` | `!llvm.array< x >` +`!spirv.rtarray< >` | `!llvm.array<0 x >` ### Struct types @@ -86,11 +86,11 @@ a design would require index recalculation in the conversion of ops that involve memory addressing. -Examples of SPIR-V struct conversion are: ```mlir !spv.struct => -!llvm.struct !spv.struct => !llvm.struct<(i8, +Examples of SPIR-V struct conversion are: ```mlir !spirv.struct => +!llvm.struct !spirv.struct => !llvm.struct<(i8, i32)> -// error !spv.struct ``` +// error !spirv.struct ``` ### Not implemented types @@ -110,23 +110,23 @@ ### Arithmetic ops SPIR-V arithmetic ops mostly have a direct equivalent in LLVM Dialect. Such -exceptions as `spv.SMod` and `spv.FMod` are rare. +exceptions as `spirv.SMod` and `spirv.FMod` are rare. SPIR-V Dialect op | LLVM Dialect op :---------------: | :-------------: -`spv.FAdd` | `llvm.fadd` -`spv.FDiv` | `llvm.fdiv` -`spv.FNegate` | `llvm.fneg` -`spv.FMul` | `llvm.fmul` -`spv.FRem` | `llvm.frem` -`spv.FSub` | `llvm.fsub` -`spv.IAdd` | `llvm.add` -`spv.IMul` | `llvm.mul` -`spv.ISub` | `llvm.sub` -`spv.SDiv` | `llvm.sdiv` -`spv.SRem` | `llvm.srem` -`spv.UDiv` | `llvm.udiv` -`spv.UMod` | `llvm.urem` +`spirv.FAdd` | `llvm.fadd` +`spirv.FDiv` | `llvm.fdiv` +`spirv.FNegate` | `llvm.fneg` +`spirv.FMul` | `llvm.fmul` +`spirv.FRem` | `llvm.frem` +`spirv.FSub` | `llvm.fsub` +`spirv.IAdd` | `llvm.add` +`spirv.IMul` | `llvm.mul` +`spirv.ISub` | `llvm.sub` +`spirv.SDiv` | `llvm.sdiv` +`spirv.SRem` | `llvm.srem` +`spirv.UDiv` | `llvm.udiv` +`spirv.UMod` | `llvm.urem` ### Bitwise ops @@ -140,41 +140,41 @@ SPIR-V Dialect op | LLVM Dialect op :---------------: | :-------------: -`spv.BitwiseAnd` | `llvm.and` -`spv.BitwiseOr` | `llvm.or` -`spv.BitwiseXor` | `llvm.xor` +`spirv.BitwiseAnd` | `llvm.and` +`spirv.BitwiseOr` | `llvm.or` +`spirv.BitwiseXor` | `llvm.xor` Also, some of bitwise ops can be modelled with LLVM intrinsics: SPIR-V Dialect op | LLVM Dialect intrinsic :---------------: | :--------------------: -`spv.BitCount` | `llvm.intr.ctpop` -`spv.BitReverse` | `llvm.intr.bitreverse` +`spirv.BitCount` | `llvm.intr.ctpop` +`spirv.BitReverse` | `llvm.intr.bitreverse` -#### `spv.Not` +#### `spirv.Not` -`spv.Not` is modelled with a `xor` operation with a mask with all bits set. +`spirv.Not` is modelled with a `xor` operation with a mask with all bits set. ```mlir %mask = llvm.mlir.constant(-1 : i32) : i32 -%0 = spv.Not %op : i32 => %0 = llvm.xor %op, %mask : i32 +%0 = spirv.Not %op : i32 => %0 = llvm.xor %op, %mask : i32 ``` #### Bitfield ops -SPIR-V dialect has three bitfield ops: `spv.BitFieldInsert`, -`spv.BitFieldSExtract` and `spv.BitFieldUExtract`. This section will first +SPIR-V dialect has three bitfield ops: `spirv.BitFieldInsert`, +`spirv.BitFieldSExtract` and `spirv.BitFieldUExtract`. This section will first outline the general design of conversion patterns for this ops, and then describe each of them. All of these ops take `base`, `offset` and `count` (`insert` for -`spv.BitFieldInsert`) as arguments. There are two important things to note: +`spirv.BitFieldInsert`) as arguments. There are two important things to note: * `offset` and `count` are always scalar. This means that we can have the following case: ```mlir - %0 = spv.BitFieldSExtract %base, %offset, %count : vector<2xi32>, i8, i8 + %0 = spirv.BitFieldSExtract %base, %offset, %count : vector<2xi32>, i8, i8 ``` To be able to proceed with conversion algorithms described below, all @@ -213,7 +213,7 @@ Now, having these two cases in mind, we can proceed with conversion for the ops and their operands. -##### `spv.BitFieldInsert` +##### `spirv.BitFieldInsert` This operation is implemented as a series of LLVM Dialect operations. First step would be to create a mask with bits set outside [`offset`, `offset` + `count` - @@ -234,12 +234,12 @@ // Insert new bits // %sh_insert = llvm.shl %insert, %offset : i32 // %res = llvm.or %new_base, %sh_insert : i32 -%res = spv.BitFieldInsert %base, %insert, %offset, %count : i32, i32, i32 +%res = spirv.BitFieldInsert %base, %insert, %offset, %count : i32, i32, i32 ``` -##### `spv.BitFieldSExtract` +##### `spirv.BitFieldSExtract` -To implement `spv.BitFieldSExtract`, `base` is shifted left by [sizeof(`base`) - +To implement `spirv.BitFieldSExtract`, `base` is shifted left by [sizeof(`base`) - (`count` + `offset`)], so that the bit at `offset` + `count` - 1 is the most significant bit. After, the result is shifted right, filling the bits with the sign bit. @@ -254,12 +254,12 @@ // %sh_left = llvm.shl %base, %t1 : i32 // %t2 = llvm.add %offset, %t1 : i32 // %res = llvm.ashr %sh_left, %t2 : i32 -%res = spv.BitFieldSExtract %base, %offset, %count : i32, i32, i32 +%res = spirv.BitFieldSExtract %base, %offset, %count : i32, i32, i32 ``` -##### `spv.BitFieldUExtract` +##### `spirv.BitFieldUExtract` -For this op a similar pattern as for `spv.BitFieldInsert` is used. First, a mask +For this op a similar pattern as for `spirv.BitFieldInsert` is used. First, a mask with bits set at [0, `count` - 1] is created. Then `base` is shifted by `offset` and the mask is applied. @@ -272,7 +272,7 @@ // Shift Base and apply mask // %sh_base = llvm.lshr %base, %offset : i32 // %res = llvm.and %sh_base, %mask : i32 -%res = spv.BitFieldUExtract %base, %offset, %count : i32, i32, i32 +%res = spirv.BitFieldUExtract %base, %offset, %count : i32, i32, i32 ``` ### Cast ops @@ -281,12 +281,12 @@ SPIR-V Dialect op | LLVM Dialect op :---------------: | :-------------: -`spv.ConvertFToS` | `llvm.fptosi` -`spv.ConvertFToU` | `llvm.fptoui` -`spv.ConvertSToF` | `llvm.sitofp` -`spv.ConvertUToF` | `llvm.uitofp` +`spirv.ConvertFToS` | `llvm.fptosi` +`spirv.ConvertFToU` | `llvm.fptoui` +`spirv.ConvertSToF` | `llvm.sitofp` +`spirv.ConvertUToF` | `llvm.uitofp` -#### spv.Bitcast +#### spirv.Bitcast This operation has a direct counterpart in LLVM: `llvm.bitcast`. It is treated separately since it also supports pointer to pointer bit pattern-preserving type @@ -294,26 +294,26 @@ #### Special cases -Special cases include `spv.FConvert`, `spv.SConvert` and `spv.UConvert`. These +Special cases include `spirv.FConvert`, `spirv.SConvert` and `spirv.UConvert`. These operations are either a truncate or extend. Let's denote the operand component width as A, and result component width as R. Then, the following mappings are used: -##### `spv.FConvert` +##### `spirv.FConvert` Case | LLVM Dialect op :---: | :-------------: A < R | `llvm.fpext` A > R | `llvm.fptrunc` -##### `spv.SConvert` +##### `spirv.SConvert` Case | LLVM Dialect op :---: | :-------------: A < R | `llvm.sext` A > R | `llvm.trunc` -##### `spv.UConvert` +##### `spirv.UConvert` Case | LLVM Dialect op :---: | :-------------: @@ -330,55 +330,55 @@ SPIR-V Dialect op | LLVM Dialect op :--------------------------: | :---------------: -`spv.IEqual` | `llvm.icmp "eq"` -`spv.INotEqual` | `llvm.icmp "ne"` -`spv.FOrdEqual` | `llvm.fcmp "oeq"` -`spv.FOrdGreaterThan` | `llvm.fcmp "ogt"` -`spv.FOrdGreaterThanEqual` | `llvm.fcmp "oge"` -`spv.FOrdLessThan` | `llvm.fcmp "olt"` -`spv.FOrdLessThanEqual` | `llvm.fcmp "ole"` -`spv.FOrdNotEqual` | `llvm.fcmp "one"` -`spv.FUnordEqual` | `llvm.fcmp "ueq"` -`spv.FUnordGreaterThan` | `llvm.fcmp "ugt"` -`spv.FUnordGreaterThanEqual` | `llvm.fcmp "uge"` -`spv.FUnordLessThan` | `llvm.fcmp "ult"` -`spv.FUnordLessThanEqual` | `llvm.fcmp "ule"` -`spv.FUnordNotEqual` | `llvm.fcmp "une"` -`spv.SGreaterThan` | `llvm.icmp "sgt"` -`spv.SGreaterThanEqual` | `llvm.icmp "sge"` -`spv.SLessThan` | `llvm.icmp "slt"` -`spv.SLessThanEqual` | `llvm.icmp "sle"` -`spv.UGreaterThan` | `llvm.icmp "ugt"` -`spv.UGreaterThanEqual` | `llvm.icmp "uge"` -`spv.ULessThan` | `llvm.icmp "ult"` -`spv.ULessThanEqual` | `llvm.icmp "ule"` +`spirv.IEqual` | `llvm.icmp "eq"` +`spirv.INotEqual` | `llvm.icmp "ne"` +`spirv.FOrdEqual` | `llvm.fcmp "oeq"` +`spirv.FOrdGreaterThan` | `llvm.fcmp "ogt"` +`spirv.FOrdGreaterThanEqual` | `llvm.fcmp "oge"` +`spirv.FOrdLessThan` | `llvm.fcmp "olt"` +`spirv.FOrdLessThanEqual` | `llvm.fcmp "ole"` +`spirv.FOrdNotEqual` | `llvm.fcmp "one"` +`spirv.FUnordEqual` | `llvm.fcmp "ueq"` +`spirv.FUnordGreaterThan` | `llvm.fcmp "ugt"` +`spirv.FUnordGreaterThanEqual` | `llvm.fcmp "uge"` +`spirv.FUnordLessThan` | `llvm.fcmp "ult"` +`spirv.FUnordLessThanEqual` | `llvm.fcmp "ule"` +`spirv.FUnordNotEqual` | `llvm.fcmp "une"` +`spirv.SGreaterThan` | `llvm.icmp "sgt"` +`spirv.SGreaterThanEqual` | `llvm.icmp "sge"` +`spirv.SLessThan` | `llvm.icmp "slt"` +`spirv.SLessThanEqual` | `llvm.icmp "sle"` +`spirv.UGreaterThan` | `llvm.icmp "ugt"` +`spirv.UGreaterThanEqual` | `llvm.icmp "uge"` +`spirv.ULessThan` | `llvm.icmp "ult"` +`spirv.ULessThanEqual` | `llvm.icmp "ule"` ### Composite ops -Currently, conversion supports rewrite patterns for `spv.CompositeExtract` and -`spv.CompositeInsert`. We distinguish two cases for these operations: when the +Currently, conversion supports rewrite patterns for `spirv.CompositeExtract` and +`spirv.CompositeInsert`. We distinguish two cases for these operations: when the composite object is a vector, and when the composite object is of a non-vector type (*i.e.* struct, array or runtime array). Composite type | SPIR-V Dialect op | LLVM Dialect op :------------: | :--------------------: | :-------------------: -vector | `spv.CompositeExtract` | `llvm.extractelement` -vector | `spv.CompositeInsert` | `llvm.insertelement` -non-vector | `spv.CompositeExtract` | `llvm.extractvalue` -non-vector | `spv.CompositeInsert` | `llvm.insertvalue` +vector | `spirv.CompositeExtract` | `llvm.extractelement` +vector | `spirv.CompositeInsert` | `llvm.insertelement` +non-vector | `spirv.CompositeExtract` | `llvm.extractvalue` +non-vector | `spirv.CompositeInsert` | `llvm.insertvalue` -### `spv.EntryPoint` and `spv.ExecutionMode` +### `spirv.EntryPoint` and `spirv.ExecutionMode` First of all, it is important to note that there is no direct representation of entry points in LLVM. At the moment, we use the following approach: -* `spv.EntryPoint` is simply removed. +* `spirv.EntryPoint` is simply removed. -* In contrast, `spv.ExecutionMode` may contain important information about the +* In contrast, `spirv.ExecutionMode` may contain important information about the entry point. For example, `LocalSize` provides information about the work-group size that can be reused. - In order to preserve this information, `spv.ExecutionMode` is converted to a + In order to preserve this information, `spirv.ExecutionMode` is converted to a struct global variable that stores the execution mode id and any variables associated with it. In C, the struct has the structure shown below. @@ -392,7 +392,7 @@ ``` ```mlir - // spv.ExecutionMode @empty "ContractionOff" + // spirv.ExecutionMode @empty "ContractionOff" llvm.mlir.global external constant @{{.*}}() : !llvm.struct<(i32)> { %0 = llvm.mlir.undef : !llvm.struct<(i32)> %1 = llvm.mlir.constant(31 : i32) : i32 @@ -409,17 +409,17 @@ SPIR-V Dialect op | LLVM Dialect op :-------------------: | :--------------: -`spv.LogicalAnd` | `llvm.and` -`spv.LogicalOr` | `llvm.or` -`spv.LogicalEqual` | `llvm.icmp "eq"` -`spv.LogicalNotEqual` | `llvm.icmp "ne"` +`spirv.LogicalAnd` | `llvm.and` +`spirv.LogicalOr` | `llvm.or` +`spirv.LogicalEqual` | `llvm.icmp "eq"` +`spirv.LogicalNotEqual` | `llvm.icmp "ne"` -`spv.LogicalNot` has the same conversion pattern as bitwise `spv.Not`. It is +`spirv.LogicalNot` has the same conversion pattern as bitwise `spirv.Not`. It is modelled with `xor` operation with a mask with all bits set. ```mlir %mask = llvm.mlir.constant(-1 : i1) : i1 -%0 = spv.LogicalNot %op : i1 => %0 = llvm.xor %op, %mask : i1 +%0 = spirv.LogicalNot %op : i1 => %0 = llvm.xor %op, %mask : i1 ``` ### Memory ops @@ -427,17 +427,17 @@ This section describes the conversion patterns for SPIR-V dialect operations that concern memory. -#### `spv.AccessChain` +#### `spirv.AccessChain` -`spv.AccessChain` is mapped to `llvm.getelementptr` op. In order to create a -valid LLVM op, we also add a 0 index to the `spv.AccessChain`'s indices list in +`spirv.AccessChain` is mapped to `llvm.getelementptr` op. In order to create a +valid LLVM op, we also add a 0 index to the `spirv.AccessChain`'s indices list in order to go through the pointer. ```mlir // Access the 1st element of the array -%i = spv.Constant 1: i32 -%var = spv.Variable : !spv.ptr>, Function> -%el = spv.AccessChain %var[%i, %i] : !spv.ptr>, Function>, i32, i32 +%i = spirv.Constant 1: i32 +%var = spirv.Variable : !spirv.ptr>, Function> +%el = spirv.AccessChain %var[%i, %i] : !spirv.ptr>, Function>, i32, i32 // Corresponding LLVM dialect code %i = ... @@ -446,44 +446,44 @@ %el = llvm.getelementptr %var[%0, %i, %i] : (!llvm.ptr)>>, i32, i32, i32) ``` -#### `spv.Load` and `spv.Store` +#### `spirv.Load` and `spirv.Store` These ops are converted to their LLVM counterparts: `llvm.load` and `llvm.store`. If the op has a memory access attribute, then there are the following cases, based on the value of the attribute: * **Aligned**: alignment is passed on to LLVM op builder, for example: `mlir - // llvm.store %ptr, %val {alignment = 4 : i64} : !llvm.ptr spv.Store + // llvm.store %ptr, %val {alignment = 4 : i64} : !llvm.ptr spirv.Store "Function" %ptr, %val ["Aligned", 4] : f32` * **None**: same case as if there is no memory access attribute. * **Nontemporal**: set `nontemporal` flag, for example: `mlir // %res = - llvm.load %ptr {nontemporal} : !llvm.ptr %res = spv.Load "Function" + llvm.load %ptr {nontemporal} : !llvm.ptr %res = spirv.Load "Function" %ptr ["Nontemporal"] : f32` * **Volatile**: mark the op as `volatile`, for example: `mlir // %res = - llvm.load volatile %ptr : !llvm.ptr %res = spv.Load "Function" %ptr + llvm.load volatile %ptr : !llvm.ptr %res = spirv.Load "Function" %ptr ["Volatile"] : f32` Otherwise the conversion fails as other cases (`MakePointerAvailable`, `MakePointerVisible`, `NonPrivatePointer`) are not supported yet. -#### `spv.GlobalVariable` and `spv.mlir.addressof` +#### `spirv.GlobalVariable` and `spirv.mlir.addressof` -`spv.GlobalVariable` is modelled with `llvm.mlir.global` op. However, there is a +`spirv.GlobalVariable` is modelled with `llvm.mlir.global` op. However, there is a difference that has to be pointed out. In SPIR-V dialect, the global variable returns a pointer, whereas in LLVM dialect the global holds an actual value. This difference is handled by -`spv.mlir.addressof` and `llvm.mlir.addressof` ops that both return a pointer +`spirv.mlir.addressof` and `llvm.mlir.addressof` ops that both return a pointer and are used to reference the global. ```mlir // Original SPIR-V module -spv.module Logical GLSL450 { - spv.GlobalVariable @struct : !spv.ptr>, Private> - spv.func @func() -> () "None" { - %0 = spv.mlir.addressof @struct : !spv.ptr>, Private> - spv.Return +spirv.module Logical GLSL450 { + spirv.GlobalVariable @struct : !spirv.ptr>, Private> + spirv.func @func() -> () "None" { + %0 = spirv.mlir.addressof @struct : !spirv.ptr>, Private> + spirv.Return } } @@ -518,29 +518,29 @@ flag is added to LLVM op: ```mlir -spv.GlobalVariable @var : !spv.ptr => llvm.mlir.global external constant @var() : f32 +spirv.GlobalVariable @var : !spirv.ptr => llvm.mlir.global external constant @var() : f32 ``` -#### `spv.Variable` +#### `spirv.Variable` -Per SPIR-V dialect spec, `spv.Variable` allocates an object in memory, resulting -in a pointer to it, which can be used with `spv.Load` and `spv.Store`. It is +Per SPIR-V dialect spec, `spirv.Variable` allocates an object in memory, resulting +in a pointer to it, which can be used with `spirv.Load` and `spirv.Store`. It is also a function-level variable. -`spv.Variable` is modelled as `llvm.alloca` op. If initialized, an additional +`spirv.Variable` is modelled as `llvm.alloca` op. If initialized, an additional store instruction is used. Note that there is no initialization for arrays and structs since constants of these types are not supported in LLVM dialect (TODO). -Also, at the moment initialization is only possible via `spv.Constant`. +Also, at the moment initialization is only possible via `spirv.Constant`. ```mlir // Conversion of VariableOp without initialization %size = llvm.mlir.constant(1 : i32) : i32 -%res = spv.Variable : !spv.ptr, Function> => %res = llvm.alloca %size x vector<3xf32> : (i32) -> !llvm.ptr> +%res = spirv.Variable : !spirv.ptr, Function> => %res = llvm.alloca %size x vector<3xf32> : (i32) -> !llvm.ptr> // Conversion of VariableOp with initialization %c = llvm.mlir.constant(0 : i64) : i64 -%c = spv.Constant 0 : i64 %size = llvm.mlir.constant(1 : i32) : i32 -%res = spv.Variable init(%c) : !spv.ptr => %res = llvm.alloca %[[SIZE]] x i64 : (i32) -> !llvm.ptr +%c = spirv.Constant 0 : i64 %size = llvm.mlir.constant(1 : i32) : i32 +%res = spirv.Variable init(%c) : !spirv.ptr => %res = llvm.alloca %[[SIZE]] x i64 : (i32) -> !llvm.ptr llvm.store %c, %res : !llvm.ptr ``` @@ -557,8 +557,8 @@ SPIR-V Dialect op | LLVM Dialect op :---------------: | :---------------: -`spv.Select` | `llvm.select` -`spv.Undef` | `llvm.mlir.undef` +`spirv.Select` | `llvm.select` +`spirv.Undef` | `llvm.mlir.undef` ### Shift ops @@ -578,21 +578,21 @@ ```mlir // Shift without extension -%res0 = spv.ShiftRightArithmetic %0, %2 : i32, i32 => %res0 = llvm.ashr %0, %2 : i32 +%res0 = spirv.ShiftRightArithmetic %0, %2 : i32, i32 => %res0 = llvm.ashr %0, %2 : i32 // Shift with extension %ext = llvm.sext %1 : i16 to i32 -%res1 = spv.ShiftRightArithmetic %0, %1 : i32, i16 => %res1 = llvm.ashr %0, %ext: i32 +%res1 = spirv.ShiftRightArithmetic %0, %1 : i32, i16 => %res1 = llvm.ashr %0, %ext: i32 ``` -### `spv.Constant` +### `spirv.Constant` -At the moment `spv.Constant` conversion supports scalar and vector constants +At the moment `spirv.Constant` conversion supports scalar and vector constants **only**. #### Mapping -`spv.Constant` is mapped to `llvm.mlir.constant`. This is a straightforward +`spirv.Constant` is mapped to `llvm.mlir.constant`. This is a straightforward conversion pattern with a special case when the argument is signed or unsigned. #### Special case @@ -609,10 +609,10 @@ ```mlir // %0 = llvm.mlir.constant(0 : i8) : i8 -%0 = spv.Constant 0 : i8 +%0 = spirv.Constant 0 : i8 // %1 = llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi32>) : vector<3xi32> -%1 = spv.Constant dense<[2, 3, 4]> : vector<3xui32> +%1 = spirv.Constant dense<[2, 3, 4]> : vector<3xui32> ``` ### Not implemented ops @@ -626,67 +626,67 @@ As well as: -* spv.CompositeConstruct -* spv.ControlBarrier -* spv.CopyMemory -* spv.FMod -* spv.GL.Acos -* spv.GL.Asin -* spv.GL.Atan -* spv.GL.Cosh -* spv.GL.FSign -* spv.GL.SAbs -* spv.GL.Sinh -* spv.GL.SSign -* spv.MemoryBarrier -* spv.mlir.referenceof -* spv.SMod -* spv.SpecConstant -* spv.Unreachable -* spv.VectorExtractDynamic +* spirv.CompositeConstruct +* spirv.ControlBarrier +* spirv.CopyMemory +* spirv.FMod +* spirv.GL.Acos +* spirv.GL.Asin +* spirv.GL.Atan +* spirv.GL.Cosh +* spirv.GL.FSign +* spirv.GL.SAbs +* spirv.GL.Sinh +* spirv.GL.SSign +* spirv.MemoryBarrier +* spirv.mlir.referenceof +* spirv.SMod +* spirv.SpecConstant +* spirv.Unreachable +* spirv.VectorExtractDynamic ## Control flow conversion ### Branch ops -`spv.Branch` and `spv.BranchConditional` are mapped to `llvm.br` and -`llvm.cond_br`. Branch weights for `spv.BranchConditional` are mapped to +`spirv.Branch` and `spirv.BranchConditional` are mapped to `llvm.br` and +`llvm.cond_br`. Branch weights for `spirv.BranchConditional` are mapped to corresponding `branch_weights` attribute of `llvm.cond_br`. When translated to proper LLVM, `branch_weights` are converted into LLVM metadata associated with the conditional branch. -### `spv.FunctionCall` +### `spirv.FunctionCall` -`spv.FunctionCall` maps to `llvm.call`. For example: +`spirv.FunctionCall` maps to `llvm.call`. For example: ```mlir -%0 = spv.FunctionCall @foo() : () -> i32 => %0 = llvm.call @foo() : () -> f32 -spv.FunctionCall @bar(%0) : (i32) -> () => llvm.call @bar(%0) : (f32) -> () +%0 = spirv.FunctionCall @foo() : () -> i32 => %0 = llvm.call @foo() : () -> f32 +spirv.FunctionCall @bar(%0) : (i32) -> () => llvm.call @bar(%0) : (f32) -> () ``` -### `spv.mlir.selection` and `spv.mlir.loop` +### `spirv.mlir.selection` and `spirv.mlir.loop` -Control flow within `spv.mlir.selection` and `spv.mlir.loop` is lowered directly +Control flow within `spirv.mlir.selection` and `spirv.mlir.loop` is lowered directly to LLVM via branch ops. The conversion can only be applied to selection or loop with all blocks being reachable. Moreover, selection and loop control attributes (such as `Flatten` or `Unroll`) are not supported at the moment. ```mlir // Conversion of selection -%cond = spv.Constant true %cond = llvm.mlir.constant(true) : i1 -spv.mlir.selection { - spv.BranchConditional %cond, ^true, ^false llvm.cond_br %cond, ^true, ^false +%cond = spirv.Constant true %cond = llvm.mlir.constant(true) : i1 +spirv.mlir.selection { + spirv.BranchConditional %cond, ^true, ^false llvm.cond_br %cond, ^true, ^false ^true: ^true: // True block code // True block code - spv.Branch ^merge => llvm.br ^merge + spirv.Branch ^merge => llvm.br ^merge ^false: ^false: // False block code // False block code - spv.Branch ^merge llvm.br ^merge + spirv.Branch ^merge llvm.br ^merge ^merge: ^merge: - spv.mlir.merge llvm.br ^continue + spirv.mlir.merge llvm.br ^continue } // Remaining code ^continue: // Remaining code @@ -694,24 +694,24 @@ ```mlir // Conversion of loop -%cond = spv.Constant true %cond = llvm.mlir.constant(true) : i1 -spv.mlir.loop { - spv.Branch ^header llvm.br ^header +%cond = spirv.Constant true %cond = llvm.mlir.constant(true) : i1 +spirv.mlir.loop { + spirv.Branch ^header llvm.br ^header ^header: ^header: // Header code // Header code - spv.BranchConditional %cond, ^body, ^merge => llvm.cond_br %cond, ^body, ^merge + spirv.BranchConditional %cond, ^body, ^merge => llvm.cond_br %cond, ^body, ^merge ^body: ^body: // Body code // Body code - spv.Branch ^continue llvm.br ^continue + spirv.Branch ^continue llvm.br ^continue ^continue: ^continue: // Continue code // Continue code - spv.Branch ^header llvm.br ^header + spirv.Branch ^header llvm.br ^header ^merge: ^merge: - spv.mlir.merge llvm.br ^remaining + spirv.mlir.merge llvm.br ^remaining } // Remaining code ^remaining: // Remaining code @@ -730,45 +730,45 @@ SPIR-V Dialect op | LLVM Dialect op :---------------: | :----------------: -`spv.GL.Ceil` | `llvm.intr.ceil` -`spv.GL.Cos` | `llvm.intr.cos` -`spv.GL.Exp` | `llvm.intr.exp` -`spv.GL.FAbs` | `llvm.intr.fabs` -`spv.GL.Floor` | `llvm.intr.floor` -`spv.GL.FMax` | `llvm.intr.maxnum` -`spv.GL.FMin` | `llvm.intr.minnum` -`spv.GL.Log` | `llvm.intr.log` -`spv.GL.Sin` | `llvm.intr.sin` -`spv.GL.Sqrt` | `llvm.intr.sqrt` -`spv.GL.SMax` | `llvm.intr.smax` -`spv.GL.SMin` | `llvm.intr.smin` +`spirv.GL.Ceil` | `llvm.intr.ceil` +`spirv.GL.Cos` | `llvm.intr.cos` +`spirv.GL.Exp` | `llvm.intr.exp` +`spirv.GL.FAbs` | `llvm.intr.fabs` +`spirv.GL.Floor` | `llvm.intr.floor` +`spirv.GL.FMax` | `llvm.intr.maxnum` +`spirv.GL.FMin` | `llvm.intr.minnum` +`spirv.GL.Log` | `llvm.intr.log` +`spirv.GL.Sin` | `llvm.intr.sin` +`spirv.GL.Sqrt` | `llvm.intr.sqrt` +`spirv.GL.SMax` | `llvm.intr.smax` +`spirv.GL.SMin` | `llvm.intr.smin` ### Special cases -`spv.InverseSqrt` is mapped to: +`spirv.InverseSqrt` is mapped to: ```mlir %one = llvm.mlir.constant(1.0 : f32) : f32 -%res = spv.InverseSqrt %arg : f32 => %sqrt = "llvm.intr.sqrt"(%arg) : (f32) -> f32 +%res = spirv.InverseSqrt %arg : f32 => %sqrt = "llvm.intr.sqrt"(%arg) : (f32) -> f32 %res = fdiv %one, %sqrt : f32 ``` -`spv.Tan` is mapped to: +`spirv.Tan` is mapped to: ```mlir %sin = "llvm.intr.sin"(%arg) : (f32) -> f32 -%res = spv.Tan %arg : f32 => %cos = "llvm.intr.cos"(%arg) : (f32) -> f32 +%res = spirv.Tan %arg : f32 => %cos = "llvm.intr.cos"(%arg) : (f32) -> f32 %res = fdiv %sin, %cos : f32 ``` -`spv.Tanh` is modelled using the equality `tanh(x) = {exp(2x) - 1}/{exp(2x) + +`spirv.Tanh` is modelled using the equality `tanh(x) = {exp(2x) - 1}/{exp(2x) + 1}`: ```mlir %two = llvm.mlir.constant(2.0: f32) : f32 %2xArg = llvm.fmul %two, %arg : f32 %exp = "llvm.intr.exp"(%2xArg) : (f32) -> f32 -%res = spv.Tanh %arg : f32 => %one = llvm.mlir.constant(1.0 : f32) : f32 +%res = spirv.Tanh %arg : f32 => %one = llvm.mlir.constant(1.0 : f32) : f32 %num = llvm.fsub %exp, %one : f32 %den = llvm.fadd %exp, %one : f32 %res = llvm.fdiv %num, %den : f32 @@ -779,7 +779,7 @@ This section describes the conversion of function-related operations from SPIR-V to LLVM dialect. -### `spv.func` +### `spirv.func` This op declares or defines a SPIR-V function and it is converted to `llvm.func`. This conversion handles signature conversion, and function control @@ -798,7 +798,7 @@ Pure | `readonly` Const | `readnone` -### `spv.Return` and `spv.ReturnValue` +### `spirv.Return` and `spirv.ReturnValue` In LLVM IR, functions may return either 1 or 0 value. Hence, we map both ops to `llvm.return` with or without a return value. @@ -806,13 +806,13 @@ ## Module ops Module in SPIR-V has one region that contains one block. It is defined via -`spv.module` op that also takes a range of attributes: +`spirv.module` op that also takes a range of attributes: * Addressing model * Memory model * Version-Capability-Extension attribute -`spv.module` is converted into `ModuleOp`. This plays a role of enclosing scope +`spirv.module` is converted into `ModuleOp`. This plays a role of enclosing scope to LLVM ops. At the moment, SPIR-V module attributes are ignored. ## `mlir-spirv-cpu-runner` @@ -873,12 +873,12 @@ Lowering `gpu` dialect to SPIR-V dialect results in ```mlir -spv.module @__spv__foo /*VCE triple and other metadata here*/ { - spv.GlobalVariable @__spv__foo_arg bind(0,0) : ... - spv.func @bar() { +spirv.module @__spv__foo /*VCE triple and other metadata here*/ { + spirv.GlobalVariable @__spv__foo_arg bind(0,0) : ... + spirv.func @bar() { // Kernel code. } - spv.EntryPoint @bar, ... + spirv.EntryPoint @bar, ... } func.func @main() { @@ -897,12 +897,12 @@ code. ```mlir -spv.module @__spv__foo /*VCE triple and other metadata here*/ { - spv.GlobalVariable @__spv__foo_arg bind(0,0) : ... - spv.func @bar() { +spirv.module @__spv__foo /*VCE triple and other metadata here*/ { + spirv.GlobalVariable @__spv__foo_arg bind(0,0) : ... + spirv.func @bar() { // Kernel code. } - spv.EntryPoint @bar, ... + spirv.EntryPoint @bar, ... } // Kernel function declaration. diff --git a/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h b/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h --- a/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h +++ b/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h @@ -20,7 +20,7 @@ /// Appends to a pattern list additional patterns for translating GPU Ops to /// SPIR-V ops. For a gpu.func to be converted, it should have a -/// spv.entry_point_abi attribute. +/// spirv.entry_point_abi attribute. void populateGPUToSPIRVPatterns(SPIRVTypeConverter &typeConverter, RewritePatternSet &patterns); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRVPass.h b/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRVPass.h --- a/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRVPass.h +++ b/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRVPass.h @@ -25,7 +25,7 @@ #include "mlir/Conversion/Passes.h.inc" /// Creates a pass to convert GPU kernel ops to corresponding SPIR-V ops. For a -/// gpu.func to be converted, it should have a spv.entry_point_abi attribute. +/// gpu.func to be converted, it should have a spirv.entry_point_abi attribute. /// If `mapMemorySpace` is true, performs MemRef memory space to SPIR-V mapping /// according to default Vulkan rules first. std::unique_ptr> diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td --- a/mlir/include/mlir/Conversion/Passes.td +++ b/mlir/include/mlir/Conversion/Passes.td @@ -408,7 +408,7 @@ resources. By default, parameters to a `gpu.func` op will be converted to global variables. These global variables will be assigned sequential binding numbers following their order in the original `gpu.func` op, starting from - 0, in set 0. One can attach `spv.interface_var_abi` to those parameters + 0, in set 0. One can attach `spirv.interface_var_abi` to those parameters to control the set and binding if wanted. }]; let constructor = "mlir::createConvertGPUToSPIRVPass()"; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/SPIRV/IR/CMakeLists.txt --- a/mlir/include/mlir/Dialect/SPIRV/IR/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/SPIRV/IR/CMakeLists.txt @@ -1,4 +1,4 @@ -add_mlir_dialect(SPIRVOps spv) +add_mlir_dialect(SPIRVOps spirv) add_mlir_doc(SPIRVOps SPIRVOps Dialects/ -gen-op-doc) set(LLVM_TARGET_DEFINITIONS SPIRVBase.td) diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td @@ -61,14 +61,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fadd-op ::= ssa-id `=` `spv.FAdd` ssa-use, ssa-use + fadd-op ::= ssa-id `=` `spirv.FAdd` ssa-use, ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.FAdd %0, %1 : f32 - %5 = spv.FAdd %2, %3 : vector<4xf32> + %4 = spirv.FAdd %0, %1 : f32 + %5 = spirv.FAdd %2, %3 : vector<4xf32> ``` }]; } @@ -91,15 +91,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fdiv-op ::= ssa-id `=` `spv.FDiv` ssa-use, ssa-use + fdiv-op ::= ssa-id `=` `spirv.FDiv` ssa-use, ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.FDiv %0, %1 : f32 - %5 = spv.FDiv %2, %3 : vector<4xf32> + %4 = spirv.FDiv %0, %1 : f32 + %5 = spirv.FDiv %2, %3 : vector<4xf32> ``` }]; } @@ -126,14 +126,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fmod-op ::= ssa-id `=` `spv.FMod` ssa-use, ssa-use + fmod-op ::= ssa-id `=` `spirv.FMod` ssa-use, ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.FMod %0, %1 : f32 - %5 = spv.FMod %2, %3 : vector<4xf32> + %4 = spirv.FMod %0, %1 : f32 + %5 = spirv.FMod %2, %3 : vector<4xf32> ``` }]; } @@ -156,15 +156,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fmul-op ::= `spv.FMul` ssa-use, ssa-use + fmul-op ::= `spirv.FMul` ssa-use, ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.FMul %0, %1 : f32 - %5 = spv.FMul %2, %3 : vector<4xf32> + %4 = spirv.FMul %0, %1 : f32 + %5 = spirv.FMul %2, %3 : vector<4xf32> ``` }]; } @@ -191,14 +191,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fmul-op ::= `spv.FNegate` ssa-use `:` float-scalar-vector-type + fmul-op ::= `spirv.FNegate` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %1 = spv.FNegate %0 : f32 - %3 = spv.FNegate %2 : vector<4xf32> + %1 = spirv.FNegate %0 : f32 + %3 = spirv.FNegate %2 : vector<4xf32> ``` }]; } @@ -225,15 +225,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - frem-op ::= ssa-id `=` `spv.FRemOp` ssa-use, ssa-use + frem-op ::= ssa-id `=` `spirv.FRemOp` ssa-use, ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.FRemOp %0, %1 : f32 - %5 = spv.FRemOp %2, %3 : vector<4xf32> + %4 = spirv.FRemOp %0, %1 : f32 + %5 = spirv.FRemOp %2, %3 : vector<4xf32> ``` }]; } @@ -255,15 +255,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fsub-op ::= ssa-id `=` `spv.FRemOp` ssa-use, ssa-use + fsub-op ::= ssa-id `=` `spirv.FRemOp` ssa-use, ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.FRemOp %0, %1 : f32 - %5 = spv.FRemOp %2, %3 : vector<4xf32> + %4 = spirv.FRemOp %0, %1 : f32 + %5 = spirv.FRemOp %2, %3 : vector<4xf32> ``` }]; } @@ -292,15 +292,15 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - iadd-op ::= ssa-id `=` `spv.IAdd` ssa-use, ssa-use + iadd-op ::= ssa-id `=` `spirv.IAdd` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.IAdd %0, %1 : i32 - %5 = spv.IAdd %2, %3 : vector<4xi32> + %4 = spirv.IAdd %0, %1 : i32 + %5 = spirv.IAdd %2, %3 : vector<4xi32> ``` }]; @@ -340,8 +340,8 @@ #### Example: ```mlir - %2 = spv.IAddCarry %0, %1 : !spv.struct<(i32, i32)> - %2 = spv.IAddCarry %0, %1 : !spv.struct<(vector<2xi32>, vector<2xi32>)> + %2 = spirv.IAddCarry %0, %1 : !spirv.struct<(i32, i32)> + %2 = spirv.IAddCarry %0, %1 : !spirv.struct<(vector<2xi32>, vector<2xi32>)> ``` }]; @@ -389,15 +389,15 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - imul-op ::= ssa-id `=` `spv.IMul` ssa-use, ssa-use + imul-op ::= ssa-id `=` `spirv.IMul` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.IMul %0, %1 : i32 - %5 = spv.IMul %2, %3 : vector<4xi32> + %4 = spirv.IMul %0, %1 : i32 + %5 = spirv.IMul %2, %3 : vector<4xi32> ``` }]; @@ -429,15 +429,15 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - isub-op ::= `spv.ISub` ssa-use, ssa-use + isub-op ::= `spirv.ISub` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.ISub %0, %1 : i32 - %5 = spv.ISub %2, %3 : vector<4xi32> + %4 = spirv.ISub %0, %1 : i32 + %5 = spirv.ISub %2, %3 : vector<4xi32> ``` }]; @@ -479,8 +479,8 @@ #### Example: ```mlir - %2 = spv.ISubBorrow %0, %1 : !spv.struct<(i32, i32)> - %2 = spv.ISubBorrow %0, %1 : !spv.struct<(vector<2xi32>, vector<2xi32>)> + %2 = spirv.ISubBorrow %0, %1 : !spirv.struct<(i32, i32)> + %2 = spirv.ISubBorrow %0, %1 : !spirv.struct<(vector<2xi32>, vector<2xi32>)> ``` }]; @@ -525,15 +525,15 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - sdiv-op ::= ssa-id `=` `spv.SDiv` ssa-use, ssa-use + sdiv-op ::= ssa-id `=` `spirv.SDiv` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.SDiv %0, %1 : i32 - %5 = spv.SDiv %2, %3 : vector<4xi32> + %4 = spirv.SDiv %0, %1 : i32 + %5 = spirv.SDiv %2, %3 : vector<4xi32> ``` }]; @@ -565,14 +565,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - smod-op ::= ssa-id `=` `spv.SMod` ssa-use, ssa-use + smod-op ::= ssa-id `=` `spirv.SMod` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.SMod %0, %1 : i32 - %5 = spv.SMod %2, %3 : vector<4xi32> + %4 = spirv.SMod %0, %1 : i32 + %5 = spirv.SMod %2, %3 : vector<4xi32> ``` }]; @@ -599,8 +599,8 @@ #### Example: ```mlir - %1 = spv.SNegate %0 : i32 - %3 = spv.SNegate %2 : vector<4xi32> + %1 = spirv.SNegate %0 : i32 + %3 = spirv.SNegate %2 : vector<4xi32> ``` }]; } @@ -631,14 +631,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - srem-op ::= ssa-id `=` `spv.SRem` ssa-use, ssa-use + srem-op ::= ssa-id `=` `spirv.SRem` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.SRem %0, %1 : i32 - %5 = spv.SRem %2, %3 : vector<4xi32> + %4 = spirv.SRem %0, %1 : i32 + %5 = spirv.SRem %2, %3 : vector<4xi32> ``` }]; @@ -665,14 +665,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - udiv-op ::= ssa-id `=` `spv.UDiv` ssa-use, ssa-use + udiv-op ::= ssa-id `=` `spirv.UDiv` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.UDiv %0, %1 : i32 - %5 = spv.UDiv %2, %3 : vector<4xi32> + %4 = spirv.UDiv %0, %1 : i32 + %5 = spirv.UDiv %2, %3 : vector<4xi32> ``` }]; @@ -696,7 +696,7 @@ #### Example: ```mlir - %0 = spv.VectorTimesScalar %vector, %scalar : vector<4xf32> + %0 = spirv.VectorTimesScalar %vector, %scalar : vector<4xf32> ``` }]; @@ -733,14 +733,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - umod-op ::= ssa-id `=` `spv.UMod` ssa-use, ssa-use + umod-op ::= ssa-id `=` `spirv.UMod` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.UMod %0, %1 : i32 - %5 = spv.UMod %2, %3 : vector<4xi32> + %4 = spirv.UMod %0, %1 : i32 + %5 = spirv.UMod %2, %3 : vector<4xi32> ``` }]; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td @@ -79,15 +79,15 @@ memory-semantics ::= `"None"` | `"Acquire"` | "Release"` | ... atomic-and-op ::= - `spv.AtomicAnd` scope memory-semantics + `spirv.AtomicAnd` scope memory-semantics ssa-use `,` ssa-use `:` spv-pointer-type ``` #### Example: ```mlir - %0 = spv.AtomicAnd "Device" "None" %pointer, %value : - !spv.ptr + %0 = spirv.AtomicAnd "Device" "None" %pointer, %value : + !spirv.ptr ``` }]; } @@ -131,7 +131,7 @@ ``` atomic-compare-exchange-op ::= - `spv.AtomicCompareExchange` scope memory-semantics memory-semantics + `spirv.AtomicCompareExchange` scope memory-semantics memory-semantics ssa-use `,` ssa-use `,` ssa-use `:` spv-pointer-type ```mlir @@ -139,9 +139,9 @@ #### Example: ``` - %0 = spv.AtomicCompareExchange "Workgroup" "Acquire" "None" + %0 = spirv.AtomicCompareExchange "Workgroup" "Acquire" "None" %pointer, %value, %comparator - : !spv.ptr + : !spirv.ptr ``` }]; @@ -173,7 +173,7 @@ ``` atomic-compare-exchange-weak-op ::= - `spv.AtomicCompareExchangeWeak` scope memory-semantics memory-semantics + `spirv.AtomicCompareExchangeWeak` scope memory-semantics memory-semantics ssa-use `,` ssa-use `,` ssa-use `:` spv-pointer-type ``` @@ -181,9 +181,9 @@ #### Example: ```mlir - %0 = spv.AtomicCompareExchangeWeak "Workgroup" "Acquire" "None" + %0 = spirv.AtomicCompareExchangeWeak "Workgroup" "Acquire" "None" %pointer, %value, %comparator - : !spv.ptr + : !spirv.ptr ``` }]; @@ -236,15 +236,15 @@ ``` atomic-exchange-op ::= - `spv.AtomicCompareExchange` scope memory-semantics + `spirv.AtomicCompareExchange` scope memory-semantics ssa-use `,` ssa-use `:` spv-pointer-type ```mlir #### Example: ``` - %0 = spv.AtomicExchange "Workgroup" "Acquire" %pointer, %value, - : !spv.ptr + %0 = spirv.AtomicExchange "Workgroup" "Acquire" %pointer, %value, + : !spirv.ptr ``` }]; @@ -290,15 +290,15 @@ ``` atomic-fadd-op ::= - `spv.EXT.AtomicFAdd` scope memory-semantics + `spirv.EXT.AtomicFAdd` scope memory-semantics ssa-use `,` ssa-use `:` spv-pointer-type ``` #### Example: ```mlir - %0 = spv.EXT.AtomicFAdd "Device" "None" %pointer, %value : - !spv.ptr + %0 = spirv.EXT.AtomicFAdd "Device" "None" %pointer, %value : + !spirv.ptr ```mlir }]; @@ -349,15 +349,15 @@ ``` atomic-iadd-op ::= - `spv.AtomicIAdd` scope memory-semantics + `spirv.AtomicIAdd` scope memory-semantics ssa-use `,` ssa-use `:` spv-pointer-type ``` #### Example: ```mlir - %0 = spv.AtomicIAdd "Device" "None" %pointer, %value : - !spv.ptr + %0 = spirv.AtomicIAdd "Device" "None" %pointer, %value : + !spirv.ptr ``` }]; } @@ -389,15 +389,15 @@ ``` atomic-idecrement-op ::= - `spv.AtomicIDecrement` scope memory-semantics ssa-use + `spirv.AtomicIDecrement` scope memory-semantics ssa-use `:` spv-pointer-type ``` #### Example: ```mlir - %0 = spv.AtomicIDecrement "Device" "None" %pointer : - !spv.ptr + %0 = spirv.AtomicIDecrement "Device" "None" %pointer : + !spirv.ptr ``` }]; } @@ -428,15 +428,15 @@ ``` atomic-iincrement-op ::= - `spv.AtomicIIncrement` scope memory-semantics ssa-use + `spirv.AtomicIIncrement` scope memory-semantics ssa-use `:` spv-pointer-type ``` #### Example: ```mlir - %0 = spv.AtomicIncrement "Device" "None" %pointer : - !spv.ptr + %0 = spirv.AtomicIncrement "Device" "None" %pointer : + !spirv.ptr ``` }]; } @@ -470,15 +470,15 @@ ``` atomic-isub-op ::= - `spv.AtomicISub` scope memory-semantics + `spirv.AtomicISub` scope memory-semantics ssa-use `,` ssa-use `:` spv-pointer-type ``` #### Example: ```mlir - %0 = spv.AtomicISub "Device" "None" %pointer, %value : - !spv.ptr + %0 = spirv.AtomicISub "Device" "None" %pointer, %value : + !spirv.ptr ``` }]; } @@ -511,15 +511,15 @@ ``` atomic-or-op ::= - `spv.AtomicOr` scope memory-semantics + `spirv.AtomicOr` scope memory-semantics ssa-use `,` ssa-use `:` spv-pointer-type ``` #### Example: ```mlir - %0 = spv.AtomicOr "Device" "None" %pointer, %value : - !spv.ptr + %0 = spirv.AtomicOr "Device" "None" %pointer, %value : + !spirv.ptr ``` }]; } @@ -553,15 +553,15 @@ ``` atomic-smax-op ::= - `spv.AtomicSMax` scope memory-semantics + `spirv.AtomicSMax` scope memory-semantics ssa-use `,` ssa-use `:` spv-pointer-type ``` #### Example: ```mlir - %0 = spv.AtomicSMax "Device" "None" %pointer, %value : - !spv.ptr + %0 = spirv.AtomicSMax "Device" "None" %pointer, %value : + !spirv.ptr ``` }]; } @@ -595,15 +595,15 @@ ``` atomic-smin-op ::= - `spv.AtomicSMin` scope memory-semantics + `spirv.AtomicSMin` scope memory-semantics ssa-use `,` ssa-use `:` spv-pointer-type ``` #### Example: ```mlir - %0 = spv.AtomicSMin "Device" "None" %pointer, %value : - !spv.ptr + %0 = spirv.AtomicSMin "Device" "None" %pointer, %value : + !spirv.ptr ``` }]; } @@ -637,15 +637,15 @@ ``` atomic-umax-op ::= - `spv.AtomicUMax` scope memory-semantics + `spirv.AtomicUMax` scope memory-semantics ssa-use `,` ssa-use `:` spv-pointer-type ``` #### Example: ```mlir - %0 = spv.AtomicUMax "Device" "None" %pointer, %value : - !spv.ptr + %0 = spirv.AtomicUMax "Device" "None" %pointer, %value : + !spirv.ptr ``` }]; } @@ -679,15 +679,15 @@ ``` atomic-umin-op ::= - `spv.AtomicUMin` scope memory-semantics + `spirv.AtomicUMin` scope memory-semantics ssa-use `,` ssa-use `:` spv-pointer-type ``` #### Example: ```mlir - %0 = spv.AtomicUMin "Device" "None" %pointer, %value : - !spv.ptr + %0 = spirv.AtomicUMin "Device" "None" %pointer, %value : + !spirv.ptr ``` }]; } @@ -721,15 +721,15 @@ ``` atomic-xor-op ::= - `spv.AtomicXor` scope memory-semantics + `spirv.AtomicXor` scope memory-semantics ssa-use `,` ssa-use `:` spv-pointer-type ``` #### Example: ```mlir - %0 = spv.AtomicXor "Device" "None" %pointer, %value : - !spv.ptr + %0 = spirv.AtomicXor "Device" "None" %pointer, %value : + !spirv.ptr ``` }]; } diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h @@ -58,7 +58,7 @@ static InterfaceVarABIAttr get(IntegerAttr descriptorSet, IntegerAttr binding, IntegerAttr storageClass); - /// Returns the attribute kind's name (without the 'spv.' prefix). + /// Returns the attribute kind's name (without the 'spirv.' prefix). static StringRef getKindName(); /// Returns descriptor set. @@ -90,7 +90,7 @@ static VerCapExtAttr get(IntegerAttr version, ArrayAttr capabilities, ArrayAttr extensions); - /// Returns the attribute kind's name (without the 'spv.' prefix). + /// Returns the attribute kind's name (without the 'spirv.' prefix). static StringRef getKindName(); /// Returns the version. @@ -142,7 +142,7 @@ DeviceType deviceType, uint32_t deviceId, ResourceLimitsAttr limits); - /// Returns the attribute kind's name (without the 'spv.' prefix). + /// Returns the attribute kind's name (without the 'spirv.' prefix). static StringRef getKindName(); /// Returns the (version, capabilities, extensions) triple attribute. diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBarrierOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBarrierOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBarrierOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBarrierOps.td @@ -58,13 +58,13 @@ memory-semantics ::= `"None"` | `"Acquire"` | "Release"` | ... - control-barrier-op ::= `spv.ControlBarrier` scope, scope, memory-semantics + control-barrier-op ::= `spirv.ControlBarrier` scope, scope, memory-semantics ``` #### Example: ```mlir - spv.ControlBarrier "Workgroup", "Device", "Acquire|UniformMemory" + spirv.ControlBarrier "Workgroup", "Device", "Acquire|UniformMemory" ``` }]; @@ -109,13 +109,13 @@ memory-semantics ::= `"None"` | `"Acquire"` | `"Release"` | ... - memory-barrier-op ::= `spv.MemoryBarrier` scope, memory-semantics + memory-barrier-op ::= `spirv.MemoryBarrier` scope, memory-semantics ``` #### Example: ```mlir - spv.MemoryBarrier "Device", "Acquire|UniformMemory" + spirv.MemoryBarrier "Device", "Acquire|UniformMemory" ``` }]; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td @@ -24,7 +24,7 @@ //===----------------------------------------------------------------------===// def SPIRV_Dialect : Dialect { - let name = "spv"; + let name = "spirv"; let summary = "The SPIR-V dialect in MLIR."; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBitOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBitOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBitOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBitOps.td @@ -85,15 +85,15 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - bitcount-op ::= ssa-id `=` `spv.BitCount` ssa-use + bitcount-op ::= ssa-id `=` `spirv.BitCount` ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.BitCount %0: i32 - %3 = spv.BitCount %1: vector<4xi32> + %2 = spirv.BitCount %0: i32 + %3 = spirv.BitCount %1: vector<4xi32> ``` }]; } @@ -135,7 +135,7 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - bitfield-insert-op ::= ssa-id `=` `spv.BitFieldInsert` ssa-use `,` ssa-use + bitfield-insert-op ::= ssa-id `=` `spirv.BitFieldInsert` ssa-use `,` ssa-use `,` ssa-use `,` ssa-use `:` integer-scalar-vector-type `,` integer-type `,` integer-type @@ -144,7 +144,7 @@ #### Example: ```mlir - %0 = spv.BitFieldInsert %base, %insert, %offset, %count : vector<3xi32>, i8, i8 + %0 = spirv.BitFieldInsert %base, %insert, %offset, %count : vector<3xi32>, i8, i8 ``` }]; @@ -207,7 +207,7 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - bitfield-extract-s-op ::= ssa-id `=` `spv.BitFieldSExtract` ssa-use + bitfield-extract-s-op ::= ssa-id `=` `spirv.BitFieldSExtract` ssa-use `,` ssa-use `,` ssa-use `:` integer-scalar-vector-type `,` integer-type `,` integer-type @@ -216,7 +216,7 @@ #### Example: ```mlir - %0 = spv.BitFieldSExtract %base, %offset, %count : vector<3xi32>, i8, i8 + %0 = spirv.BitFieldSExtract %base, %offset, %count : vector<3xi32>, i8, i8 ``` }]; @@ -244,7 +244,7 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - bitfield-extract-u-op ::= ssa-id `=` `spv.BitFieldUExtract` ssa-use + bitfield-extract-u-op ::= ssa-id `=` `spirv.BitFieldUExtract` ssa-use `,` ssa-use `,` ssa-use `:` integer-scalar-vector-type `,` integer-type `,` integer-type @@ -253,7 +253,7 @@ #### Example: ```mlir - %0 = spv.BitFieldUExtract %base, %offset, %count : vector<3xi32>, i8, i8 + %0 = spirv.BitFieldUExtract %base, %offset, %count : vector<3xi32>, i8, i8 ``` }]; @@ -285,15 +285,15 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - bitreverse-op ::= ssa-id `=` `spv.BitReverse` ssa-use + bitreverse-op ::= ssa-id `=` `spirv.BitReverse` ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.BitReverse %0 : i32 - %3 = spv.BitReverse %1 : vector<4xi32> + %2 = spirv.BitReverse %0 : i32 + %3 = spirv.BitReverse %1 : vector<4xi32> ``` }]; @@ -327,15 +327,15 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - bitwise-and-op ::= ssa-id `=` `spv.BitwiseAnd` ssa-use, ssa-use + bitwise-and-op ::= ssa-id `=` `spirv.BitwiseAnd` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.BitwiseAnd %0, %1 : i32 - %2 = spv.BitwiseAnd %0, %1 : vector<4xi32> + %2 = spirv.BitwiseAnd %0, %1 : i32 + %2 = spirv.BitwiseAnd %0, %1 : vector<4xi32> ``` }]; } @@ -362,15 +362,15 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - bitwise-or-op ::= ssa-id `=` `spv.BitwiseOr` ssa-use, ssa-use + bitwise-or-op ::= ssa-id `=` `spirv.BitwiseOr` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.BitwiseOr %0, %1 : i32 - %2 = spv.BitwiseOr %0, %1 : vector<4xi32> + %2 = spirv.BitwiseOr %0, %1 : i32 + %2 = spirv.BitwiseOr %0, %1 : vector<4xi32> ``` }]; } @@ -397,15 +397,15 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - bitwise-xor-op ::= ssa-id `=` `spv.BitwiseXor` ssa-use, ssa-use + bitwise-xor-op ::= ssa-id `=` `spirv.BitwiseXor` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.BitwiseXor %0, %1 : i32 - %2 = spv.BitwiseXor %0, %1 : vector<4xi32> + %2 = spirv.BitwiseXor %0, %1 : i32 + %2 = spirv.BitwiseXor %0, %1 : vector<4xi32> ``` }]; } @@ -440,7 +440,7 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - shift-left-logical-op ::= ssa-id `=` `spv.ShiftLeftLogical` + shift-left-logical-op ::= ssa-id `=` `spirv.ShiftLeftLogical` ssa-use `,` ssa-use `:` integer-scalar-vector-type `,` integer-scalar-vector-type @@ -449,8 +449,8 @@ #### Example: ```mlir - %2 = spv.ShiftLeftLogical %0, %1 : i32, i16 - %5 = spv.ShiftLeftLogical %3, %4 : vector<3xi32>, vector<3xi16> + %2 = spirv.ShiftLeftLogical %0, %1 : i32, i16 + %5 = spirv.ShiftLeftLogical %3, %4 : vector<3xi32>, vector<3xi16> ``` }]; } @@ -482,7 +482,7 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - shift-right-arithmetic-op ::= ssa-id `=` `spv.ShiftRightArithmetic` + shift-right-arithmetic-op ::= ssa-id `=` `spirv.ShiftRightArithmetic` ssa-use `,` ssa-use `:` integer-scalar-vector-type `,` integer-scalar-vector-type @@ -491,8 +491,8 @@ #### Example: ```mlir - %2 = spv.ShiftRightArithmetic %0, %1 : i32, i16 - %5 = spv.ShiftRightArithmetic %3, %4 : vector<3xi32>, vector<3xi16> + %2 = spirv.ShiftRightArithmetic %0, %1 : i32, i16 + %5 = spirv.ShiftRightArithmetic %3, %4 : vector<3xi32>, vector<3xi16> ``` }]; } @@ -525,7 +525,7 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - shift-right-logical-op ::= ssa-id `=` `spv.ShiftRightLogical` + shift-right-logical-op ::= ssa-id `=` `spirv.ShiftRightLogical` ssa-use `,` ssa-use `:` integer-scalar-vector-type `,` integer-scalar-vector-type @@ -534,8 +534,8 @@ #### Example: ```mlir - %2 = spv.ShiftRightLogical %0, %1 : i32, i16 - %5 = spv.ShiftRightLogical %3, %4 : vector<3xi32>, vector<3xi16> + %2 = spirv.ShiftRightLogical %0, %1 : i32, i16 + %5 = spirv.ShiftRightLogical %3, %4 : vector<3xi32>, vector<3xi16> ``` }]; } @@ -559,14 +559,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - not-op ::= ssa-id `=` `spv.BitNot` ssa-use `:` integer-scalar-vector-type + not-op ::= ssa-id `=` `spirv.BitNot` ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.Not %0 : i32 - %3 = spv.Not %1 : vector<4xi32> + %2 = spirv.Not %0 : i32 + %3 = spirv.Not %1 : vector<4xi32> ``` }]; } diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td @@ -131,15 +131,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - ceil-op ::= ssa-id `=` `spv.CL.ceil` ssa-use `:` + ceil-op ::= ssa-id `=` `spirv.CL.ceil` ssa-use `:` float-scalar-vector-type ```mlir #### Example: ``` - %2 = spv.CL.ceil %0 : f32 - %3 = spv.CL.ceil %1 : vector<3xf16> + %2 = spirv.CL.ceil %0 : f32 + %3 = spirv.CL.ceil %1 : vector<3xf16> ``` }]; } @@ -161,15 +161,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - cos-op ::= ssa-id `=` `spv.CL.cos` ssa-use `:` + cos-op ::= ssa-id `=` `spirv.CL.cos` ssa-use `:` float-scalar-vector-type ```mlir #### Example: ``` - %2 = spv.CL.cos %0 : f32 - %3 = spv.CL.cos %1 : vector<3xf16> + %2 = spirv.CL.cos %0 : f32 + %3 = spirv.CL.cos %1 : vector<3xf16> ``` }]; } @@ -193,15 +193,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - erf-op ::= ssa-id `=` `spv.CL.erf` ssa-use `:` + erf-op ::= ssa-id `=` `spirv.CL.erf` ssa-use `:` float-scalar-vector-type ```mlir #### Example: ``` - %2 = spv.CL.erf %0 : f32 - %3 = spv.CL.erf %1 : vector<3xf16> + %2 = spirv.CL.erf %0 : f32 + %3 = spirv.CL.erf %1 : vector<3xf16> ``` }]; } @@ -224,14 +224,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - exp-op ::= ssa-id `=` `spv.CL.exp` ssa-use `:` + exp-op ::= ssa-id `=` `spirv.CL.exp` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.CL.exp %0 : f32 - %3 = spv.CL.exp %1 : vector<3xf16> + %2 = spirv.CL.exp %0 : f32 + %3 = spirv.CL.exp %1 : vector<3xf16> ``` }]; } @@ -254,14 +254,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - abs-op ::= ssa-id `=` `spv.CL.fabs` ssa-use `:` + abs-op ::= ssa-id `=` `spirv.CL.fabs` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.CL.fabs %0 : f32 - %3 = spv.CL.fabs %1 : vector<3xf16> + %2 = spirv.CL.fabs %0 : f32 + %3 = spirv.CL.fabs %1 : vector<3xf16> ``` }]; } @@ -286,15 +286,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - floor-op ::= ssa-id `=` `spv.CL.floor` ssa-use `:` + floor-op ::= ssa-id `=` `spirv.CL.floor` ssa-use `:` float-scalar-vector-type ```mlir #### Example: ``` - %2 = spv.CL.floor %0 : f32 - %3 = spv.CL.ceifloorl %1 : vector<3xf16> + %2 = spirv.CL.floor %0 : f32 + %3 = spirv.CL.ceifloorl %1 : vector<3xf16> ``` }]; } @@ -319,13 +319,13 @@ ``` - fma-op ::= ssa-id `=` `spv.CL.fma` ssa-use, ssa-use, ssa-use `:` + fma-op ::= ssa-id `=` `spirv.CL.fma` ssa-use, ssa-use, ssa-use `:` float-scalar-vector-type ```mlir ``` - %0 = spv.CL.fma %a, %b, %c : f32 - %1 = spv.CL.fma %a, %b, %c : vector<3xf16> + %0 = spirv.CL.fma %a, %b, %c : f32 + %1 = spirv.CL.fma %a, %b, %c : vector<3xf16> ``` }]; } @@ -349,14 +349,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fmax-op ::= ssa-id `=` `spv.CL.fmax` ssa-use `:` + fmax-op ::= ssa-id `=` `spirv.CL.fmax` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.CL.fmax %0, %1 : f32 - %3 = spv.CL.fmax %0, %1 : vector<3xf16> + %2 = spirv.CL.fmax %0, %1 : f32 + %3 = spirv.CL.fmax %0, %1 : vector<3xf16> ``` }]; } @@ -379,14 +379,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fmin-op ::= ssa-id `=` `spv.CL.fmin` ssa-use `:` + fmin-op ::= ssa-id `=` `spirv.CL.fmin` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.CL.fmin %0, %1 : f32 - %3 = spv.CL.fmin %0, %1 : vector<3xf16> + %2 = spirv.CL.fmin %0, %1 : f32 + %3 = spirv.CL.fmin %0, %1 : vector<3xf16> ``` }]; } @@ -408,15 +408,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - log-op ::= ssa-id `=` `spv.CL.log` ssa-use `:` + log-op ::= ssa-id `=` `spirv.CL.log` ssa-use `:` float-scalar-vector-type ```mlir #### Example: ``` - %2 = spv.CL.log %0 : f32 - %3 = spv.CL.log %1 : vector<3xf16> + %2 = spirv.CL.log %0 : f32 + %3 = spirv.CL.log %1 : vector<3xf16> ``` }]; } @@ -440,14 +440,14 @@ restricted-float-scalar-vector-type ::= restricted-float-scalar-type | `vector<` integer-literal `x` restricted-float-scalar-type `>` - pow-op ::= ssa-id `=` `spv.CL.pow` ssa-use `:` + pow-op ::= ssa-id `=` `spirv.CL.pow` ssa-use `:` restricted-float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.CL.pow %0, %1 : f32 - %3 = spv.CL.pow %0, %1 : vector<3xf16> + %2 = spirv.CL.pow %0, %1 : f32 + %3 = spirv.CL.pow %0, %1 : vector<3xf16> ``` }]; } @@ -472,14 +472,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - round-op ::= ssa-id `=` `spv.CL.round` ssa-use `:` + round-op ::= ssa-id `=` `spirv.CL.round` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.CL.round %0 : f32 - %3 = spv.CL.round %0 : vector<3xf16> + %2 = spirv.CL.round %0 : f32 + %3 = spirv.CL.round %0 : vector<3xf16> ``` }]; } @@ -501,15 +501,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - rsqrt-op ::= ssa-id `=` `spv.CL.rsqrt` ssa-use `:` + rsqrt-op ::= ssa-id `=` `spirv.CL.rsqrt` ssa-use `:` float-scalar-vector-type ```mlir #### Example: ``` - %2 = spv.CL.rsqrt %0 : f32 - %3 = spv.CL.rsqrt %1 : vector<3xf16> + %2 = spirv.CL.rsqrt %0 : f32 + %3 = spirv.CL.rsqrt %1 : vector<3xf16> ``` }]; } @@ -531,15 +531,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - sin-op ::= ssa-id `=` `spv.CL.sin` ssa-use `:` + sin-op ::= ssa-id `=` `spirv.CL.sin` ssa-use `:` float-scalar-vector-type ```mlir #### Example: ``` - %2 = spv.CL.sin %0 : f32 - %3 = spv.CL.sin %1 : vector<3xf16> + %2 = spirv.CL.sin %0 : f32 + %3 = spirv.CL.sin %1 : vector<3xf16> ``` }]; } @@ -561,15 +561,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - sqrt-op ::= ssa-id `=` `spv.CL.sqrt` ssa-use `:` + sqrt-op ::= ssa-id `=` `spirv.CL.sqrt` ssa-use `:` float-scalar-vector-type ```mlir #### Example: ``` - %2 = spv.CL.sqrt %0 : f32 - %3 = spv.CL.sqrt %1 : vector<3xf16> + %2 = spirv.CL.sqrt %0 : f32 + %3 = spirv.CL.sqrt %1 : vector<3xf16> ``` }]; } @@ -591,15 +591,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - tanh-op ::= ssa-id `=` `spv.CL.tanh` ssa-use `:` + tanh-op ::= ssa-id `=` `spirv.CL.tanh` ssa-use `:` float-scalar-vector-type ```mlir #### Example: ``` - %2 = spv.CL.tanh %0 : f32 - %3 = spv.CL.tanh %1 : vector<3xf16> + %2 = spirv.CL.tanh %0 : f32 + %3 = spirv.CL.tanh %1 : vector<3xf16> ``` }]; } @@ -622,14 +622,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - abs-op ::= ssa-id `=` `spv.CL.s_abs` ssa-use `:` + abs-op ::= ssa-id `=` `spirv.CL.s_abs` ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.CL.s_abs %0 : i32 - %3 = spv.CL.s_abs %1 : vector<3xi16> + %2 = spirv.CL.s_abs %0 : i32 + %3 = spirv.CL.s_abs %1 : vector<3xi16> ``` }]; } @@ -650,13 +650,13 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - smax-op ::= ssa-id `=` `spv.CL.s_max` ssa-use `:` + smax-op ::= ssa-id `=` `spirv.CL.s_max` ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.CL.s_max %0, %1 : i32 - %3 = spv.CL.s_max %0, %1 : vector<3xi16> + %2 = spirv.CL.s_max %0, %1 : i32 + %3 = spirv.CL.s_max %0, %1 : vector<3xi16> ``` }]; } @@ -677,13 +677,13 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - umax-op ::= ssa-id `=` `spv.CL.u_max` ssa-use `:` + umax-op ::= ssa-id `=` `spirv.CL.u_max` ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.CL.u_max %0, %1 : i32 - %3 = spv.CL.u_max %0, %1 : vector<3xi16> + %2 = spirv.CL.u_max %0, %1 : i32 + %3 = spirv.CL.u_max %0, %1 : vector<3xi16> ``` }]; } @@ -702,13 +702,13 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - smin-op ::= ssa-id `=` `spv.CL.s_min` ssa-use `:` + smin-op ::= ssa-id `=` `spirv.CL.s_min` ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.CL.s_min %0, %1 : i32 - %3 = spv.CL.s_min %0, %1 : vector<3xi16> + %2 = spirv.CL.s_min %0, %1 : i32 + %3 = spirv.CL.s_min %0, %1 : vector<3xi16> ``` }]; } @@ -729,13 +729,13 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - umin-op ::= ssa-id `=` `spv.CL.u_min` ssa-use `:` + umin-op ::= ssa-id `=` `spirv.CL.u_min` ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.CL.u_min %0, %1 : i32 - %3 = spv.CL.u_min %0, %1 : vector<3xi16> + %2 = spirv.CL.u_min %0, %1 : i32 + %3 = spirv.CL.u_min %0, %1 : vector<3xi16> ``` }]; } diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCastOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCastOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCastOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCastOps.td @@ -64,16 +64,16 @@ ``` - bitcast-op ::= ssa-id `=` `spv.Bitcast` ssa-use + bitcast-op ::= ssa-id `=` `spirv.Bitcast` ssa-use `:` operand-type `to` result-type ``` #### Example: ```mlir - %1 = spv.Bitcast %0 : f32 to i32 - %1 = spv.Bitcast %0 : vector<2xf32> to i64 - %1 = spv.Bitcast %0 : !spv.ptr to !spv.ptr + %1 = spirv.Bitcast %0 : f32 to i32 + %1 = spirv.Bitcast %0 : vector<2xf32> to i64 + %1 = spirv.Bitcast %0 : !spirv.ptr to !spirv.ptr ``` }]; @@ -110,15 +110,15 @@ ``` - convert-f-to-s-op ::= ssa-id `=` `spv.ConvertFToSOp` ssa-use + convert-f-to-s-op ::= ssa-id `=` `spirv.ConvertFToSOp` ssa-use `:` operand-type `to` result-type ``` #### Example: ```mlir - %1 = spv.ConvertFToS %0 : f32 to i32 - %3 = spv.ConvertFToS %2 : vector<3xf32> to vector<3xi32> + %1 = spirv.ConvertFToS %0 : f32 to i32 + %3 = spirv.ConvertFToS %2 : vector<3xf32> to vector<3xi32> ``` }]; } @@ -143,15 +143,15 @@ ``` - convert-f-to-u-op ::= ssa-id `=` `spv.ConvertFToUOp` ssa-use + convert-f-to-u-op ::= ssa-id `=` `spirv.ConvertFToUOp` ssa-use `:` operand-type `to` result-type ``` #### Example: ```mlir - %1 = spv.ConvertFToU %0 : f32 to i32 - %3 = spv.ConvertFToU %2 : vector<3xf32> to vector<3xi32> + %1 = spirv.ConvertFToU %0 : f32 to i32 + %3 = spirv.ConvertFToU %2 : vector<3xf32> to vector<3xi32> ``` }]; } @@ -177,15 +177,15 @@ ``` - convert-s-to-f-op ::= ssa-id `=` `spv.ConvertSToFOp` ssa-use + convert-s-to-f-op ::= ssa-id `=` `spirv.ConvertSToFOp` ssa-use `:` operand-type `to` result-type ``` #### Example: ```mlir - %1 = spv.ConvertSToF %0 : i32 to f32 - %3 = spv.ConvertSToF %2 : vector<3xi32> to vector<3xf32> + %1 = spirv.ConvertSToF %0 : i32 to f32 + %3 = spirv.ConvertSToF %2 : vector<3xi32> to vector<3xf32> ``` }]; } @@ -211,15 +211,15 @@ ``` - convert-u-to-f-op ::= ssa-id `=` `spv.ConvertUToFOp` ssa-use + convert-u-to-f-op ::= ssa-id `=` `spirv.ConvertUToFOp` ssa-use `:` operand-type `to` result-type ``` #### Example: ```mlir - %1 = spv.ConvertUToF %0 : i32 to f32 - %3 = spv.ConvertUToF %2 : vector<3xi32> to vector<3xf32> + %1 = spirv.ConvertUToF %0 : i32 to f32 + %3 = spirv.ConvertUToF %2 : vector<3xi32> to vector<3xf32> ``` }]; } @@ -247,15 +247,15 @@ ``` - f-convert-op ::= ssa-id `=` `spv.FConvertOp` ssa-use + f-convert-op ::= ssa-id `=` `spirv.FConvertOp` ssa-use `:` operand-type `to` result-type ``` #### Example: ```mlir - %1 = spv.FConvertOp %0 : f32 to f64 - %3 = spv.FConvertOp %2 : vector<3xf32> to vector<3xf64> + %1 = spirv.FConvertOp %0 : f32 to f64 + %3 = spirv.FConvertOp %2 : vector<3xf32> to vector<3xf64> ``` }]; } @@ -282,15 +282,15 @@ ``` - s-convert-op ::= ssa-id `=` `spv.SConvertOp` ssa-use + s-convert-op ::= ssa-id `=` `spirv.SConvertOp` ssa-use `:` operand-type `to` result-type ``` #### Example: ```mlir - %1 = spv.SConvertOp %0 : i32 to i64 - %3 = spv.SConvertOp %2 : vector<3xi32> to vector<3xi64> + %1 = spirv.SConvertOp %0 : i32 to i64 + %3 = spirv.SConvertOp %2 : vector<3xi32> to vector<3xi64> ``` }]; } @@ -318,15 +318,15 @@ ``` - u-convert-op ::= ssa-id `=` `spv.UConvertOp` ssa-use + u-convert-op ::= ssa-id `=` `spirv.UConvertOp` ssa-use `:` operand-type `to` result-type ``` #### Example: ```mlir - %1 = spv.UConvertOp %0 : i32 to i64 - %3 = spv.UConvertOp %2 : vector<3xi32> to vector<3xi64> + %1 = spirv.UConvertOp %0 : i32 to i64 + %3 = spirv.UConvertOp %2 : vector<3xi32> to vector<3xi64> ``` }]; } @@ -348,8 +348,8 @@ #### Example: ```mlir - %1 = spv.PtrCastToGenericOp %0 : !spv.ptr to - !spv.ptr + %1 = spirv.PtrCastToGenericOp %0 : !spirv.ptr to + !spirv.ptr ``` }]; @@ -391,8 +391,8 @@ #### Example: ```mlir - %1 = spv.GenericCastToPtrOp %0 : !spv.ptr to - !spv.ptr + %1 = spirv.GenericCastToPtrOp %0 : !spirv.ptr to + !spirv.ptr ``` }]; @@ -444,8 +444,8 @@ #### Example: ```mlir - %1 = spv.GenericCastToPtrExplicitOp %0 : !spv.ptr to - !spv.ptr + %1 = spirv.GenericCastToPtrExplicitOp %0 : !spirv.ptr to + !spirv.ptr ``` }]; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCompositeOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCompositeOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCompositeOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCompositeOps.td @@ -46,14 +46,14 @@ ``` - composite-construct-op ::= ssa-id `=` `spv.CompositeConstruct` + composite-construct-op ::= ssa-id `=` `spirv.CompositeConstruct` (ssa-use (`,` ssa-use)* )? `:` composite-type ``` #### Example: ```mlir - %0 = spv.CompositeConstruct %1, %2, %3 : vector<3xf32> + %0 = spirv.CompositeConstruct %1, %2, %3 : vector<3xf32> ``` }]; @@ -90,7 +90,7 @@ ``` - composite-extract-op ::= ssa-id `=` `spv.CompositeExtract` ssa-use + composite-extract-op ::= ssa-id `=` `spirv.CompositeExtract` ssa-use `[` integer-literal (',' integer-literal)* `]` `:` composite-type ``` @@ -98,9 +98,9 @@ #### Example: ```mlir - %0 = spv.Variable : !spv.ptr>, Function> - %1 = spv.Load "Function" %0 ["Volatile"] : !spv.array<4x!spv.array<4xf32>> - %2 = spv.CompositeExtract %1[1 : i32] : !spv.array<4x!spv.array<4xf32>> + %0 = spirv.Variable : !spirv.ptr>, 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>> ``` }]; @@ -145,7 +145,7 @@ ``` - composite-insert-op ::= ssa-id `=` `spv.CompositeInsert` ssa-use, ssa-use + composite-insert-op ::= ssa-id `=` `spirv.CompositeInsert` ssa-use, ssa-use `[` integer-literal (',' integer-literal)* `]` `:` object-type `into` composite-type ``` @@ -153,7 +153,7 @@ #### Example: ```mlir - %0 = spv.CompositeInsert %object, %composite[1 : i32] : f32 into !spv.array<4xf32> + %0 = spirv.CompositeInsert %object, %composite[1 : i32] : f32 into !spirv.array<4xf32> ``` }]; @@ -201,7 +201,7 @@ #### Example: ``` - %2 = spv.VectorExtractDynamic %0[%1] : vector<8xf32>, i32 + %2 = spirv.VectorExtractDynamic %0[%1] : vector<8xf32>, i32 ``` }]; @@ -254,7 +254,7 @@ ``` scalar-type ::= integer-type | float-type | boolean-type - vector-insert-dynamic-op ::= `spv.VectorInsertDynamic ` ssa-use `,` + vector-insert-dynamic-op ::= `spirv.VectorInsertDynamic ` ssa-use `,` ssa-use `[` ssa-use `]` `:` `vector<` integer-literal `x` scalar-type `>` `,` integer-type @@ -264,7 +264,7 @@ ``` %scalar = ... : f32 - %2 = spv.VectorInsertDynamic %scalar %0[%1] : f32, vector<8xf32>, i32 + %2 = spirv.VectorInsertDynamic %scalar %0[%1] : f32, vector<8xf32>, i32 ``` }]; @@ -323,7 +323,7 @@ #### Example: ```mlir - %0 = spv.VectorShuffle [1: i32, 3: i32, 5: i32] + %0 = spirv.VectorShuffle [1: i32, 3: i32, 5: i32] %vector1: vector<4xf32>, %vector2: vector<2xf32> -> vector<3xf32> ``` diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVControlFlowOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVControlFlowOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVControlFlowOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVControlFlowOps.td @@ -32,7 +32,7 @@ ``` - branch-op ::= `spv.Branch` successor + branch-op ::= `spirv.Branch` successor successor ::= bb-id branch-use-list? branch-use-list ::= `(` ssa-use-list `:` type-list-no-parens `)` ``` @@ -40,8 +40,8 @@ #### Example: ```mlir - spv.Branch ^target - spv.Branch ^target(%0, %1: i32, f32) + spirv.Branch ^target + spirv.Branch ^target(%0, %1: i32, f32) ``` }]; @@ -103,7 +103,7 @@ ``` - branch-conditional-op ::= `spv.BranchConditional` ssa-use + branch-conditional-op ::= `spirv.BranchConditional` ssa-use (`[` integer-literal, integer-literal `]`)? `,` successor `,` successor successor ::= bb-id branch-use-list? @@ -113,8 +113,8 @@ #### Example: ```mlir - spv.BranchConditional %condition, ^true_branch, ^false_branch - spv.BranchConditional %condition, ^true_branch(%0: i32), ^false_branch(%1: i32) + spirv.BranchConditional %condition, ^true_branch, ^false_branch + spirv.BranchConditional %condition, ^true_branch(%0: i32), ^false_branch(%1: i32) ``` }]; @@ -215,15 +215,15 @@ ``` - function-call-op ::= `spv.FunctionCall` function-id `(` ssa-use-list `)` + function-call-op ::= `spirv.FunctionCall` function-id `(` ssa-use-list `)` `:` function-type ``` #### Example: ```mlir - spv.FunctionCall @f_void(%arg0) : (i32) -> () - %0 = spv.FunctionCall @f_iadd(%arg0, %arg1) : (i32, i32) -> i32 + spirv.FunctionCall @f_void(%arg0) : (i32) -> () + %0 = spirv.FunctionCall @f_iadd(%arg0, %arg1) : (i32, i32) -> i32 ``` }]; @@ -257,19 +257,19 @@ and exited in structured ways. See "2.11. Structured Control Flow" of the SPIR-V spec for more details. - Instead of having a `spv.LoopMerge` op to directly model loop merge + 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 `spv.mlir.loop` op and the continue target is the block that - has a back-edge pointing to the entry block inside the `spv.mlir.loop`'s region. + 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 `spv.mlir.loop` region should contain at least four blocks: one entry block, + 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 `spv.mlir.merge` op. + 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. @@ -299,7 +299,7 @@ Block *getMergeBlock(); // Adds an empty entry block and loop merge block containing one - // spv.mlir.merge op. + // spirv.mlir.merge op. void addEntryAndMergeBlock(); }]; @@ -317,10 +317,10 @@ let summary = "A special terminator for merging a structured selection/loop."; let description = [{ - We use `spv.mlir.selection`/`spv.mlir.loop` for modelling structured selection/loop. + 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 `spv.mlir.selection` or - `spv.mlir.loop` op. This op does not have a corresponding instruction in 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. }]; @@ -347,7 +347,7 @@ ``` - return-op ::= `spv.Return` + return-op ::= `spirv.Return` ``` }]; @@ -369,7 +369,7 @@ ``` - unreachable-op ::= `spv.Unreachable` + unreachable-op ::= `spirv.Unreachable` ``` }]; @@ -396,13 +396,13 @@ ``` - return-value-op ::= `spv.ReturnValue` ssa-use `:` spirv-type + return-value-op ::= `spirv.ReturnValue` ssa-use `:` spirv-type ``` #### Example: ```mlir - spv.ReturnValue %0 : f32 + spirv.ReturnValue %0 : f32 ``` }]; @@ -426,16 +426,16 @@ and exited in structured ways. See "2.11. Structured Control Flow" of the SPIR-V spec for more details. - Instead of having a `spv.SelectionMerge` op to directly model selection + 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 - `spv.mlir.selection` op. This way it's easier to discover all blocks belonging to + `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 `spv.mlir.selection` region should contain at least two blocks: one selection + 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 `spv.mlir.merge` op. + The merge block should only contain a `spirv.mlir.merge` op. }]; let arguments = (ins @@ -453,12 +453,12 @@ /// Returns the selection merge block. Block *getMergeBlock(); - /// Adds a selection merge block containing one spv.mlir.merge op. + /// Adds a selection merge block containing one spirv.mlir.merge op. void addMergeBlock(); - /// Creates a spv.mlir.selection op for `if () then { }` + /// Creates a spirv.mlir.selection op for `if () then { }` /// with `builder`. `builder`'s insertion point will remain at after the - /// newly inserted spv.mlir.selection op afterwards. + /// newly inserted spirv.mlir.selection op afterwards. static SelectionOp createIfThen( Location loc, Value condition, function_ref thenBody, diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCooperativeMatrixOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCooperativeMatrixOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCooperativeMatrixOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCooperativeMatrixOps.td @@ -28,14 +28,14 @@ Type is a cooperative matrix type. ``` {.ebnf} - cooperative-matrix-length-op ::= ssa-id `=` `spv.NV.CooperativeMatrixLength + cooperative-matrix-length-op ::= ssa-id `=` `spirv.NV.CooperativeMatrixLength ` : ` cooperative-matrix-type ``` For example: ``` - %0 = spv.NV.CooperativeMatrixLength : !spv.coopmatrix + %0 = spirv.NV.CooperativeMatrixLength : !spirv.coopmatrix ``` }]; @@ -100,7 +100,7 @@ ### Custom assembly form ``` {.ebnf} - cooperative-matrixload-op ::= ssa-id `=` `spv.NV.CooperativeMatrixLoad` + cooperative-matrixload-op ::= ssa-id `=` `spirv.NV.CooperativeMatrixLoad` ssa-use `,` ssa-use `,` ssa-use (`[` memory-access `]`)? ` : ` pointer-type `as` @@ -110,8 +110,8 @@ For example: ``` - %0 = spv.NV.CooperativeMatrixLoad %ptr, %stride, %colMajor - : !spv.ptr as !spv.coopmatrix + %0 = spirv.NV.CooperativeMatrixLoad %ptr, %stride, %colMajor + : !spirv.ptr as !spirv.coopmatrix ``` }]; @@ -172,7 +172,7 @@ the scope of the operation). ``` {.ebnf} - cooperative-matrixmuladd-op ::= ssa-id `=` `spv.NV.CooperativeMatrixMulAdd` + cooperative-matrixmuladd-op ::= ssa-id `=` `spirv.NV.CooperativeMatrixMulAdd` ssa-use `,` ssa-use `,` ssa-use ` : ` a-cooperative-matrix-type, b-cooperative-matrix-type -> @@ -181,8 +181,8 @@ For example: ``` - %0 = spv.NV.CooperativeMatrixMulAdd %arg0, %arg1, %arg2, : - !spv.coopmatrix + %0 = spirv.NV.CooperativeMatrixMulAdd %arg0, %arg1, %arg2, : + !spirv.coopmatrix ``` }]; @@ -236,7 +236,7 @@ same as specifying None. ``` {.ebnf} - coop-matrix-store-op ::= `spv.NV.CooperativeMatrixStore ` + coop-matrix-store-op ::= `spirv.NV.CooperativeMatrixStore ` ssa-use `, ` ssa-use `, ` ssa-use `, ` ssa-use `, ` (`[` memory-access `]`)? `:` @@ -246,8 +246,8 @@ For example: ``` - spv.NV.CooperativeMatrixStore %arg0, %arg2, %arg1, %arg3 : - !spv.ptr, !spv.coopmatrix + spirv.NV.CooperativeMatrixStore %arg0, %arg2, %arg1, %arg3 : + !spirv.ptr, !spirv.coopmatrix ``` }]; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLOps.td @@ -120,14 +120,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - abs-op ::= ssa-id `=` `spv.GL.FAbs` ssa-use `:` + abs-op ::= ssa-id `=` `spirv.GL.FAbs` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.FAbs %0 : f32 - %3 = spv.GL.FAbs %1 : vector<3xf16> + %2 = spirv.GL.FAbs %0 : f32 + %3 = spirv.GL.FAbs %1 : vector<3xf16> ``` }]; } @@ -149,14 +149,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - abs-op ::= ssa-id `=` `spv.GL.SAbs` ssa-use `:` + abs-op ::= ssa-id `=` `spirv.GL.SAbs` ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.SAbs %0 : i32 - %3 = spv.GL.SAbs %1 : vector<3xi16> + %2 = spirv.GL.SAbs %0 : i32 + %3 = spirv.GL.SAbs %1 : vector<3xi16> ``` }]; } @@ -180,14 +180,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - ceil-op ::= ssa-id `=` `spv.GL.Ceil` ssa-use `:` + ceil-op ::= ssa-id `=` `spirv.GL.Ceil` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Ceil %0 : f32 - %3 = spv.GL.Ceil %1 : vector<3xf16> + %2 = spirv.GL.Ceil %0 : f32 + %3 = spirv.GL.Ceil %1 : vector<3xf16> ``` }]; } @@ -212,14 +212,14 @@ restricted-float-scalar-vector-type ::= restricted-float-scalar-type | `vector<` integer-literal `x` restricted-float-scalar-type `>` - cos-op ::= ssa-id `=` `spv.GL.Cos` ssa-use `:` + cos-op ::= ssa-id `=` `spirv.GL.Cos` ssa-use `:` restricted-float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Cos %0 : f32 - %3 = spv.GL.Cos %1 : vector<3xf16> + %2 = spirv.GL.Cos %0 : f32 + %3 = spirv.GL.Cos %1 : vector<3xf16> ``` }]; } @@ -244,14 +244,14 @@ restricted-float-scalar-vector-type ::= restricted-float-scalar-type | `vector<` integer-literal `x` restricted-float-scalar-type `>` - sin-op ::= ssa-id `=` `spv.GL.Sin` ssa-use `:` + sin-op ::= ssa-id `=` `spirv.GL.Sin` ssa-use `:` restricted-float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Sin %0 : f32 - %3 = spv.GL.Sin %1 : vector<3xf16> + %2 = spirv.GL.Sin %0 : f32 + %3 = spirv.GL.Sin %1 : vector<3xf16> ``` }]; } @@ -276,14 +276,14 @@ restricted-float-scalar-vector-type ::= restricted-float-scalar-type | `vector<` integer-literal `x` restricted-float-scalar-type `>` - tan-op ::= ssa-id `=` `spv.GL.Tan` ssa-use `:` + tan-op ::= ssa-id `=` `spirv.GL.Tan` ssa-use `:` restricted-float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Tan %0 : f32 - %3 = spv.GL.Tan %1 : vector<3xf16> + %2 = spirv.GL.Tan %0 : f32 + %3 = spirv.GL.Tan %1 : vector<3xf16> ``` }]; } @@ -310,14 +310,14 @@ restricted-float-scalar-vector-type ::= restricted-float-scalar-type | `vector<` integer-literal `x` restricted-float-scalar-type `>` - asin-op ::= ssa-id `=` `spv.GL.Asin` ssa-use `:` + asin-op ::= ssa-id `=` `spirv.GL.Asin` ssa-use `:` restricted-float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Asin %0 : f32 - %3 = spv.GL.Asin %1 : vector<3xf16> + %2 = spirv.GL.Asin %0 : f32 + %3 = spirv.GL.Asin %1 : vector<3xf16> ``` }]; } @@ -344,14 +344,14 @@ restricted-float-scalar-vector-type ::= restricted-float-scalar-type | `vector<` integer-literal `x` restricted-float-scalar-type `>` - acos-op ::= ssa-id `=` `spv.GL.Acos` ssa-use `:` + acos-op ::= ssa-id `=` `spirv.GL.Acos` ssa-use `:` restricted-float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Acos %0 : f32 - %3 = spv.GL.Acos %1 : vector<3xf16> + %2 = spirv.GL.Acos %0 : f32 + %3 = spirv.GL.Acos %1 : vector<3xf16> ``` }]; } @@ -378,14 +378,14 @@ restricted-float-scalar-vector-type ::= restricted-float-scalar-type | `vector<` integer-literal `x` restricted-float-scalar-type `>` - atan-op ::= ssa-id `=` `spv.GL.Atan` ssa-use `:` + atan-op ::= ssa-id `=` `spirv.GL.Atan` ssa-use `:` restricted-float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Atan %0 : f32 - %3 = spv.GL.Atan %1 : vector<3xf16> + %2 = spirv.GL.Atan %0 : f32 + %3 = spirv.GL.Atan %1 : vector<3xf16> ``` }]; } @@ -410,14 +410,14 @@ restricted-float-scalar-vector-type ::= restricted-float-scalar-type | `vector<` integer-literal `x` restricted-float-scalar-type `>` - exp-op ::= ssa-id `=` `spv.GL.Exp` ssa-use `:` + exp-op ::= ssa-id `=` `spirv.GL.Exp` ssa-use `:` restricted-float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Exp %0 : f32 - %3 = spv.GL.Exp %1 : vector<3xf16> + %2 = spirv.GL.Exp %0 : f32 + %3 = spirv.GL.Exp %1 : vector<3xf16> ``` }]; } @@ -441,14 +441,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - floor-op ::= ssa-id `=` `spv.GL.Floor` ssa-use `:` + floor-op ::= ssa-id `=` `spirv.GL.Floor` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Floor %0 : f32 - %3 = spv.GL.Floor %1 : vector<3xf16> + %2 = spirv.GL.Floor %0 : f32 + %3 = spirv.GL.Floor %1 : vector<3xf16> ``` }]; } @@ -471,14 +471,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - floor-op ::= ssa-id `=` `spv.GL.Round` ssa-use `:` + floor-op ::= ssa-id `=` `spirv.GL.Round` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Round %0 : f32 - %3 = spv.GL.Round %1 : vector<3xf16> + %2 = spirv.GL.Round %0 : f32 + %3 = spirv.GL.Round %1 : vector<3xf16> ``` }]; } @@ -501,14 +501,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - rsqrt-op ::= ssa-id `=` `spv.GL.InverseSqrt` ssa-use `:` + rsqrt-op ::= ssa-id `=` `spirv.GL.InverseSqrt` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.InverseSqrt %0 : f32 - %3 = spv.GL.InverseSqrt %1 : vector<3xf16> + %2 = spirv.GL.InverseSqrt %0 : f32 + %3 = spirv.GL.InverseSqrt %1 : vector<3xf16> ``` }]; } @@ -534,14 +534,14 @@ restricted-float-scalar-vector-type ::= restricted-float-scalar-type | `vector<` integer-literal `x` restricted-float-scalar-type `>` - log-op ::= ssa-id `=` `spv.GL.Log` ssa-use `:` + log-op ::= ssa-id `=` `spirv.GL.Log` ssa-use `:` restricted-float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Log %0 : f32 - %3 = spv.GL.Log %1 : vector<3xf16> + %2 = spirv.GL.Log %0 : f32 + %3 = spirv.GL.Log %1 : vector<3xf16> ``` }]; } @@ -565,14 +565,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fmax-op ::= ssa-id `=` `spv.GL.FMax` ssa-use `:` + fmax-op ::= ssa-id `=` `spirv.GL.FMax` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.FMax %0, %1 : f32 - %3 = spv.GL.FMax %0, %1 : vector<3xf16> + %2 = spirv.GL.FMax %0, %1 : f32 + %3 = spirv.GL.FMax %0, %1 : vector<3xf16> ``` }]; } @@ -595,14 +595,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - smax-op ::= ssa-id `=` `spv.GL.UMax` ssa-use `:` + smax-op ::= ssa-id `=` `spirv.GL.UMax` ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.UMax %0, %1 : i32 - %3 = spv.GL.UMax %0, %1 : vector<3xi16> + %2 = spirv.GL.UMax %0, %1 : i32 + %3 = spirv.GL.UMax %0, %1 : vector<3xi16> ``` }]; } @@ -625,14 +625,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - smax-op ::= ssa-id `=` `spv.GL.SMax` ssa-use `:` + smax-op ::= ssa-id `=` `spirv.GL.SMax` ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.SMax %0, %1 : i32 - %3 = spv.GL.SMax %0, %1 : vector<3xi16> + %2 = spirv.GL.SMax %0, %1 : i32 + %3 = spirv.GL.SMax %0, %1 : vector<3xi16> ``` }]; } @@ -656,14 +656,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fmin-op ::= ssa-id `=` `spv.GL.FMin` ssa-use `:` + fmin-op ::= ssa-id `=` `spirv.GL.FMin` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.FMin %0, %1 : f32 - %3 = spv.GL.FMin %0, %1 : vector<3xf16> + %2 = spirv.GL.FMin %0, %1 : f32 + %3 = spirv.GL.FMin %0, %1 : vector<3xf16> ``` }]; } @@ -686,14 +686,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - smin-op ::= ssa-id `=` `spv.GL.UMin` ssa-use `:` + smin-op ::= ssa-id `=` `spirv.GL.UMin` ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.UMin %0, %1 : i32 - %3 = spv.GL.UMin %0, %1 : vector<3xi16> + %2 = spirv.GL.UMin %0, %1 : i32 + %3 = spirv.GL.UMin %0, %1 : vector<3xi16> ``` }]; } @@ -716,14 +716,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - smin-op ::= ssa-id `=` `spv.GL.SMin` ssa-use `:` + smin-op ::= ssa-id `=` `spirv.GL.SMin` ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.SMin %0, %1 : i32 - %3 = spv.GL.SMin %0, %1 : vector<3xi16> + %2 = spirv.GL.SMin %0, %1 : i32 + %3 = spirv.GL.SMin %0, %1 : vector<3xi16> ``` }]; } @@ -750,14 +750,14 @@ restricted-float-scalar-vector-type ::= restricted-float-scalar-type | `vector<` integer-literal `x` restricted-float-scalar-type `>` - pow-op ::= ssa-id `=` `spv.GL.Pow` ssa-use `:` + pow-op ::= ssa-id `=` `spirv.GL.Pow` ssa-use `:` restricted-float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Pow %0, %1 : f32 - %3 = spv.GL.Pow %0, %1 : vector<3xf16> + %2 = spirv.GL.Pow %0, %1 : f32 + %3 = spirv.GL.Pow %0, %1 : vector<3xf16> ``` }]; } @@ -780,14 +780,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - sign-op ::= ssa-id `=` `spv.GL.FSign` ssa-use `:` + sign-op ::= ssa-id `=` `spirv.GL.FSign` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.FSign %0 : f32 - %3 = spv.GL.FSign %1 : vector<3xf16> + %2 = spirv.GL.FSign %0 : f32 + %3 = spirv.GL.FSign %1 : vector<3xf16> ``` }]; } @@ -809,14 +809,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - sign-op ::= ssa-id `=` `spv.GL.SSign` ssa-use `:` + sign-op ::= ssa-id `=` `spirv.GL.SSign` ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.SSign %0 : i32 - %3 = spv.GL.SSign %1 : vector<3xi16> + %2 = spirv.GL.SSign %0 : i32 + %3 = spirv.GL.SSign %1 : vector<3xi16> ``` }]; } @@ -839,14 +839,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - sqrt-op ::= ssa-id `=` `spv.GL.Sqrt` ssa-use `:` + sqrt-op ::= ssa-id `=` `spirv.GL.Sqrt` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Sqrt %0 : f32 - %3 = spv.GL.Sqrt %1 : vector<3xf16> + %2 = spirv.GL.Sqrt %0 : f32 + %3 = spirv.GL.Sqrt %1 : vector<3xf16> ``` }]; } @@ -871,14 +871,14 @@ restricted-float-scalar-vector-type ::= restricted-float-scalar-type | `vector<` integer-literal `x` restricted-float-scalar-type `>` - sinh-op ::= ssa-id `=` `spv.GL.Sinh` ssa-use `:` + sinh-op ::= ssa-id `=` `spirv.GL.Sinh` ssa-use `:` restricted-float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Sinh %0 : f32 - %3 = spv.GL.Sinh %1 : vector<3xf16> + %2 = spirv.GL.Sinh %0 : f32 + %3 = spirv.GL.Sinh %1 : vector<3xf16> ``` }]; } @@ -903,14 +903,14 @@ restricted-float-scalar-vector-type ::= restricted-float-scalar-type | `vector<` integer-literal `x` restricted-float-scalar-type `>` - cosh-op ::= ssa-id `=` `spv.GL.Cosh` ssa-use `:` + cosh-op ::= ssa-id `=` `spirv.GL.Cosh` ssa-use `:` restricted-float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Cosh %0 : f32 - %3 = spv.GL.Cosh %1 : vector<3xf16> + %2 = spirv.GL.Cosh %0 : f32 + %3 = spirv.GL.Cosh %1 : vector<3xf16> ``` }]; } @@ -935,14 +935,14 @@ restricted-float-scalar-vector-type ::= restricted-float-scalar-type | `vector<` integer-literal `x` restricted-float-scalar-type `>` - tanh-op ::= ssa-id `=` `spv.GL.Tanh` ssa-use `:` + tanh-op ::= ssa-id `=` `spirv.GL.Tanh` ssa-use `:` restricted-float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.Tanh %0 : f32 - %3 = spv.GL.Tanh %1 : vector<3xf16> + %2 = spirv.GL.Tanh %0 : f32 + %3 = spirv.GL.Tanh %1 : vector<3xf16> ``` }]; } @@ -965,14 +965,14 @@ ``` - fclamp-op ::= ssa-id `=` `spv.GL.FClamp` ssa-use, ssa-use, ssa-use `:` + fclamp-op ::= ssa-id `=` `spirv.GL.FClamp` ssa-use, ssa-use, ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.FClamp %x, %min, %max : f32 - %3 = spv.GL.FClamp %x, %min, %max : vector<3xf16> + %2 = spirv.GL.FClamp %x, %min, %max : f32 + %3 = spirv.GL.FClamp %x, %min, %max : vector<3xf16> ``` }]; } @@ -994,14 +994,14 @@ ``` - uclamp-op ::= ssa-id `=` `spv.GL.UClamp` ssa-use, ssa-use, ssa-use `:` + uclamp-op ::= ssa-id `=` `spirv.GL.UClamp` ssa-use, ssa-use, ssa-use `:` unsigned-signless-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.UClamp %x, %min, %max : i32 - %3 = spv.GL.UClamp %x, %min, %max : vector<3xui16> + %2 = spirv.GL.UClamp %x, %min, %max : i32 + %3 = spirv.GL.UClamp %x, %min, %max : vector<3xui16> ``` }]; } @@ -1023,14 +1023,14 @@ ``` - uclamp-op ::= ssa-id `=` `spv.GL.UClamp` ssa-use, ssa-use, ssa-use `:` + uclamp-op ::= ssa-id `=` `spirv.GL.UClamp` ssa-use, ssa-use, ssa-use `:` sgined-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.GL.SClamp %x, %min, %max : si32 - %3 = spv.GL.SClamp %x, %min, %max : vector<3xsi16> + %2 = spirv.GL.SClamp %x, %min, %max : si32 + %3 = spirv.GL.SClamp %x, %min, %max : vector<3xsi16> ``` }]; } @@ -1063,14 +1063,14 @@ ``` - fma-op ::= ssa-id `=` `spv.GL.Fma` ssa-use, ssa-use, ssa-use `:` + fma-op ::= ssa-id `=` `spirv.GL.Fma` ssa-use, ssa-use, ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %0 = spv.GL.Fma %a, %b, %c : f32 - %1 = spv.GL.Fma %a, %b, %c : vector<3xf16> + %0 = spirv.GL.Fma %a, %b, %c : f32 + %1 = spirv.GL.Fma %a, %b, %c : vector<3xf16> ``` }]; } @@ -1105,15 +1105,15 @@ `vector<` integer-literal `x` float-type `>` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - frexpstruct-op ::= ssa-id `=` `spv.GL.FrexpStruct` ssa-use `:` - `!spv.struct<` float-scalar-vector-type `,` + frexpstruct-op ::= ssa-id `=` `spirv.GL.FrexpStruct` ssa-use `:` + `!spirv.struct<` float-scalar-vector-type `,` integer-scalar-vector-type `>` ``` #### Example: ```mlir - %2 = spv.GL.FrexpStruct %0 : f32 -> !spv.struct - %3 = spv.GL.FrexpStruct %0 : vector<3xf32> -> !spv.struct, vector<3xi32>> + %2 = spirv.GL.FrexpStruct %0 : f32 -> !spirv.struct + %3 = spirv.GL.FrexpStruct %0 : vector<3xf32> -> !spirv.struct, vector<3xi32>> ``` }]; @@ -1163,8 +1163,8 @@ #### Example: ```mlir - %y = spv.GL.Ldexp %x : f32, %exp : i32 -> f32 - %y = spv.GL.Ldexp %x : vector<3xf32>, %exp : vector<3xi32> -> vector<3xf32> + %y = spirv.GL.Ldexp %x : f32, %exp : i32 -> f32 + %y = spirv.GL.Ldexp %x : vector<3xf32>, %exp : vector<3xi32> -> vector<3xf32> ``` }]; @@ -1199,8 +1199,8 @@ #### Example: ```mlir - %0 = spv.GL.FMix %x : f32, %y : f32, %a : f32 -> f32 - %0 = spv.GL.FMix %x : vector<4xf32>, %y : vector<4xf32>, %a : vector<4xf32> -> vector<4xf32> + %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> ``` }]; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGroupOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGroupOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGroupOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGroupOps.td @@ -51,7 +51,7 @@ `vector<` integer-literal `x` float-type `>` localid-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - group-broadcast-op ::= ssa-id `=` `spv.GroupBroadcast` scope ssa_use, + group-broadcast-op ::= ssa-id `=` `spirv.GroupBroadcast` scope ssa_use, ssa_use `:` integer-float-scalar-vector-type `,` localid-type ```mlir @@ -62,8 +62,8 @@ %vector_value = ... : vector<4xf32> %scalar_localid = ... : i32 %vector_localid = ... : vector<3xi32> - %0 = spv.GroupBroadcast "Subgroup" %scalar_value, %scalar_localid : f32, i32 - %1 = spv.GroupBroadcast "Workgroup" %vector_value, %vector_localid : + %0 = spirv.GroupBroadcast "Subgroup" %scalar_value, %scalar_localid : f32, i32 + %1 = spirv.GroupBroadcast "Workgroup" %vector_value, %vector_localid : vector<4xf32>, vector<3xi32> ``` }]; @@ -113,14 +113,14 @@ ``` - subgroup-ballot-op ::= ssa-id `=` `spv.KHR.SubgroupBallot` + subgroup-ballot-op ::= ssa-id `=` `spirv.KHR.SubgroupBallot` ssa-use `:` `vector` `<` 4 `x` `i32` `>` ``` #### Example: ```mlir - %0 = spv.KHR.SubgroupBallot %predicate : vector<4xi32> + %0 = spirv.KHR.SubgroupBallot %predicate : vector<4xi32> ``` }]; @@ -168,14 +168,14 @@ ``` - subgroup-block-read-INTEL-op ::= ssa-id `=` `spv.INTEL.SubgroupBlockRead` + subgroup-block-read-INTEL-op ::= ssa-id `=` `spirv.INTEL.SubgroupBlockRead` storage-class ssa_use `:` spirv-element-type ```mlir #### Example: ``` - %0 = spv.INTEL.SubgroupBlockRead "StorageBuffer" %ptr : i32 + %0 = spirv.INTEL.SubgroupBlockRead "StorageBuffer" %ptr : i32 ``` }]; @@ -218,14 +218,14 @@ ``` - subgroup-block-write-INTEL-op ::= ssa-id `=` `spv.INTEL.SubgroupBlockWrite` + subgroup-block-write-INTEL-op ::= ssa-id `=` `spirv.INTEL.SubgroupBlockWrite` storage-class ssa_use `,` ssa-use `:` spirv-element-type ```mlir #### Example: ``` - spv.INTEL.SubgroupBlockWrite "StorageBuffer" %ptr, %value : i32 + spirv.INTEL.SubgroupBlockWrite "StorageBuffer" %ptr, %value : i32 ``` }]; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVImageOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVImageOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVImageOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVImageOps.td @@ -52,8 +52,8 @@ ``` ```mlir - %0 = spv.ImageDrefGather %1 : !spv.sampled_image>, %2 : vector<4xf32>, %3 : f32 -> vector<4xi32> - %0 = spv.ImageDrefGather %1 : !spv.sampled_image>, %2 : vector<4xf32>, %3 : f32 ["NonPrivateTexel"] : f32, f32 -> vector<4xi32> + %0 = spirv.ImageDrefGather %1 : !spirv.sampled_image>, %2 : vector<4xf32>, %3 : f32 -> vector<4xi32> + %0 = spirv.ImageDrefGather %1 : !spirv.sampled_image>, %2 : vector<4xf32>, %3 : f32 ["NonPrivateTexel"] : f32, f32 -> vector<4xi32> ``` }]; @@ -116,9 +116,9 @@ #### Example: ```mlir - %3 = spv.ImageQuerySize %0 : !spv.image -> i32 - %4 = spv.ImageQuerySize %1 : !spv.image -> vector<2xi32> - %5 = spv.ImageQuerySize %2 : !spv.image -> vector<3xi32> + %3 = spirv.ImageQuerySize %0 : !spirv.image -> i32 + %4 = spirv.ImageQuerySize %1 : !spirv.image -> vector<2xi32> + %5 = spirv.ImageQuerySize %2 : !spirv.image -> vector<3xi32> ``` }]; @@ -161,7 +161,7 @@ #### Example: ```mlir - %0 = spv.Image %1 : !spv.sampled_image> + %0 = spirv.Image %1 : !spirv.sampled_image> ``` }]; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVJointMatrixOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVJointMatrixOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVJointMatrixOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVJointMatrixOps.td @@ -28,14 +28,14 @@ Type is a joint matrix type. ``` {.ebnf} - joint-matrix-length-op ::= ssa-id `=` `spv.INTEL.JointMatrixWorkItemLength + joint-matrix-length-op ::= ssa-id `=` `spirv.INTEL.JointMatrixWorkItemLength ` : ` joint-matrix-type ``` For example: ``` - %0 = spv.INTEL.JointMatrixWorkItemLength : !spv.jointmatrix + %0 = spirv.INTEL.JointMatrixWorkItemLength : !spirv.jointmatrix ``` }]; @@ -85,10 +85,10 @@ #### Example: ```mlir - %0 = spv.INTEL.JointMatrixLoad %ptr, %stride - {memory_access = #spv.memory_access} : - (!spv.ptr, i32) -> - !spv.jointmatrix<8x16xi32, ColumnMajor, Subgroup> + %0 = spirv.INTEL.JointMatrixLoad %ptr, %stride + {memory_access = #spirv.memory_access} : + (!spirv.ptr, i32) -> + !spirv.jointmatrix<8x16xi32, ColumnMajor, Subgroup> ``` }]; @@ -149,10 +149,10 @@ #### Example: ```mlir - %r = spv.INTEL.JointMatrixMad %a, %b, %c : - !spv.jointmatrix<8x32xi8, RowMajor, Subgroup>, - !spv.jointmatrix<32x8xi8, ColumnMajor, Subgroup> - -> !spv.jointmatrix<8x8xi32, RowMajor, Subgroup> + %r = spirv.INTEL.JointMatrixMad %a, %b, %c : + !spirv.jointmatrix<8x32xi8, RowMajor, Subgroup>, + !spirv.jointmatrix<32x8xi8, ColumnMajor, Subgroup> + -> !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup> ``` }]; @@ -212,9 +212,9 @@ #### Example: ```mlir - spv.INTEL.JointMatrixStore %ptr, %m, %stride - {memory_access = #spv.memory_access} : (!spv.ptr, - !spv.jointmatrix<8x16xi32, RowMajor, Subgroup>, i32) + spirv.INTEL.JointMatrixStore %ptr, %m, %stride + {memory_access = #spirv.memory_access} : (!spirv.ptr, + !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, i32) ``` }]; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td @@ -75,14 +75,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fordequal-op ::= ssa-id `=` `spv.FOrdEqual` ssa-use, ssa-use + fordequal-op ::= ssa-id `=` `spirv.FOrdEqual` ssa-use, ssa-use ``` #### Example: ```mlir - %4 = spv.FOrdEqual %0, %1 : f32 - %5 = spv.FOrdEqual %2, %3 : vector<4xf32> + %4 = spirv.FOrdEqual %0, %1 : f32 + %5 = spirv.FOrdEqual %2, %3 : vector<4xf32> ``` }]; } @@ -109,14 +109,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fordgt-op ::= ssa-id `=` `spv.FOrdGreaterThan` ssa-use, ssa-use + fordgt-op ::= ssa-id `=` `spirv.FOrdGreaterThan` ssa-use, ssa-use ``` #### Example: ```mlir - %4 = spv.FOrdGreaterThan %0, %1 : f32 - %5 = spv.FOrdGreaterThan %2, %3 : vector<4xf32> + %4 = spirv.FOrdGreaterThan %0, %1 : f32 + %5 = spirv.FOrdGreaterThan %2, %3 : vector<4xf32> ``` }]; } @@ -143,14 +143,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fordgte-op ::= ssa-id `=` `spv.FOrdGreaterThanEqual` ssa-use, ssa-use + fordgte-op ::= ssa-id `=` `spirv.FOrdGreaterThanEqual` ssa-use, ssa-use ``` #### Example: ```mlir - %4 = spv.FOrdGreaterThanEqual %0, %1 : f32 - %5 = spv.FOrdGreaterThanEqual %2, %3 : vector<4xf32> + %4 = spirv.FOrdGreaterThanEqual %0, %1 : f32 + %5 = spirv.FOrdGreaterThanEqual %2, %3 : vector<4xf32> ``` }]; } @@ -177,14 +177,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fordlt-op ::= ssa-id `=` `spv.FOrdLessThan` ssa-use, ssa-use + fordlt-op ::= ssa-id `=` `spirv.FOrdLessThan` ssa-use, ssa-use ``` #### Example: ```mlir - %4 = spv.FOrdLessThan %0, %1 : f32 - %5 = spv.FOrdLessThan %2, %3 : vector<4xf32> + %4 = spirv.FOrdLessThan %0, %1 : f32 + %5 = spirv.FOrdLessThan %2, %3 : vector<4xf32> ``` }]; } @@ -211,14 +211,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fordlte-op ::= ssa-id `=` `spv.FOrdLessThanEqual` ssa-use, ssa-use + fordlte-op ::= ssa-id `=` `spirv.FOrdLessThanEqual` ssa-use, ssa-use ``` #### Example: ```mlir - %4 = spv.FOrdLessThanEqual %0, %1 : f32 - %5 = spv.FOrdLessThanEqual %2, %3 : vector<4xf32> + %4 = spirv.FOrdLessThanEqual %0, %1 : f32 + %5 = spirv.FOrdLessThanEqual %2, %3 : vector<4xf32> ``` }]; } @@ -242,14 +242,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - fordneq-op ::= ssa-id `=` `spv.FOrdNotEqual` ssa-use, ssa-use + fordneq-op ::= ssa-id `=` `spirv.FOrdNotEqual` ssa-use, ssa-use ``` #### Example: ```mlir - %4 = spv.FOrdNotEqual %0, %1 : f32 - %5 = spv.FOrdNotEqual %2, %3 : vector<4xf32> + %4 = spirv.FOrdNotEqual %0, %1 : f32 + %5 = spirv.FOrdNotEqual %2, %3 : vector<4xf32> ``` }]; } @@ -273,14 +273,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - funordequal-op ::= ssa-id `=` `spv.FUnordEqual` ssa-use, ssa-use + funordequal-op ::= ssa-id `=` `spirv.FUnordEqual` ssa-use, ssa-use ``` #### Example: ```mlir - %4 = spv.FUnordEqual %0, %1 : f32 - %5 = spv.FUnordEqual %2, %3 : vector<4xf32> + %4 = spirv.FUnordEqual %0, %1 : f32 + %5 = spirv.FUnordEqual %2, %3 : vector<4xf32> ``` }]; } @@ -307,14 +307,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - funordgt-op ::= ssa-id `=` `spv.FUnordGreaterThan` ssa-use, ssa-use + funordgt-op ::= ssa-id `=` `spirv.FUnordGreaterThan` ssa-use, ssa-use ``` #### Example: ```mlir - %4 = spv.FUnordGreaterThan %0, %1 : f32 - %5 = spv.FUnordGreaterThan %2, %3 : vector<4xf32> + %4 = spirv.FUnordGreaterThan %0, %1 : f32 + %5 = spirv.FUnordGreaterThan %2, %3 : vector<4xf32> ``` }]; } @@ -341,14 +341,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - funordgte-op ::= ssa-id `=` `spv.FUnordGreaterThanEqual` ssa-use, ssa-use + funordgte-op ::= ssa-id `=` `spirv.FUnordGreaterThanEqual` ssa-use, ssa-use ``` #### Example: ```mlir - %4 = spv.FUnordGreaterThanEqual %0, %1 : f32 - %5 = spv.FUnordGreaterThanEqual %2, %3 : vector<4xf32> + %4 = spirv.FUnordGreaterThanEqual %0, %1 : f32 + %5 = spirv.FUnordGreaterThanEqual %2, %3 : vector<4xf32> ``` }]; } @@ -375,14 +375,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - funordlt-op ::= ssa-id `=` `spv.FUnordLessThan` ssa-use, ssa-use + funordlt-op ::= ssa-id `=` `spirv.FUnordLessThan` ssa-use, ssa-use ``` #### Example: ```mlir - %4 = spv.FUnordLessThan %0, %1 : f32 - %5 = spv.FUnordLessThan %2, %3 : vector<4xf32> + %4 = spirv.FUnordLessThan %0, %1 : f32 + %5 = spirv.FUnordLessThan %2, %3 : vector<4xf32> ``` }]; } @@ -409,14 +409,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - funordlte-op ::= ssa-id `=` `spv.FUnordLessThanEqual` ssa-use, ssa-use + funordlte-op ::= ssa-id `=` `spirv.FUnordLessThanEqual` ssa-use, ssa-use ``` #### Example: ```mlir - %4 = spv.FUnordLessThanEqual %0, %1 : f32 - %5 = spv.FUnordLessThanEqual %2, %3 : vector<4xf32> + %4 = spirv.FUnordLessThanEqual %0, %1 : f32 + %5 = spirv.FUnordLessThanEqual %2, %3 : vector<4xf32> ``` }]; } @@ -440,14 +440,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - funordneq-op ::= ssa-id `=` `spv.FUnordNotEqual` ssa-use, ssa-use + funordneq-op ::= ssa-id `=` `spirv.FUnordNotEqual` ssa-use, ssa-use ``` #### Example: ```mlir - %4 = spv.FUnordNotEqual %0, %1 : f32 - %5 = spv.FUnordNotEqual %2, %3 : vector<4xf32> + %4 = spirv.FUnordNotEqual %0, %1 : f32 + %5 = spirv.FUnordNotEqual %2, %3 : vector<4xf32> ``` }]; } @@ -472,14 +472,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - iequal-op ::= ssa-id `=` `spv.IEqual` ssa-use, ssa-use + iequal-op ::= ssa-id `=` `spirv.IEqual` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.IEqual %0, %1 : i32 - %5 = spv.IEqual %2, %3 : vector<4xi32> + %4 = spirv.IEqual %0, %1 : i32 + %5 = spirv.IEqual %2, %3 : vector<4xi32> ``` }]; @@ -505,14 +505,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - inot-equal-op ::= ssa-id `=` `spv.INotEqual` ssa-use, ssa-use + inot-equal-op ::= ssa-id `=` `spirv.INotEqual` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.INotEqual %0, %1 : i32 - %5 = spv.INotEqual %2, %3 : vector<4xi32> + %4 = spirv.INotEqual %0, %1 : i32 + %5 = spirv.INotEqual %2, %3 : vector<4xi32> ``` }]; @@ -536,15 +536,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - isinf-op ::= ssa-id `=` `spv.IsInf` ssa-use + isinf-op ::= ssa-id `=` `spirv.IsInf` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.IsInf %0: f32 - %3 = spv.IsInf %1: vector<4xi32> + %2 = spirv.IsInf %0: f32 + %3 = spirv.IsInf %1: vector<4xi32> ``` }]; } @@ -569,15 +569,15 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - isnan-op ::= ssa-id `=` `spv.IsNan` ssa-use + isnan-op ::= ssa-id `=` `spirv.IsNan` ssa-use `:` float-scalar-vector-type ``` #### Example: ```mlir - %2 = spv.IsNan %0: f32 - %3 = spv.IsNan %1: vector<4xi32> + %2 = spirv.IsNan %0: f32 + %3 = spirv.IsNan %1: vector<4xi32> ``` }]; } @@ -605,15 +605,15 @@ ``` - logical-and ::= `spv.LogicalAnd` ssa-use `,` ssa-use + logical-and ::= `spirv.LogicalAnd` ssa-use `,` ssa-use `:` operand-type ``` #### Example: ```mlir - %2 = spv.LogicalAnd %0, %1 : i1 - %2 = spv.LogicalAnd %0, %1 : vector<4xi1> + %2 = spirv.LogicalAnd %0, %1 : i1 + %2 = spirv.LogicalAnd %0, %1 : vector<4xi1> ``` }]; @@ -643,15 +643,15 @@ ``` - logical-equal ::= `spv.LogicalEqual` ssa-use `,` ssa-use + logical-equal ::= `spirv.LogicalEqual` ssa-use `,` ssa-use `:` operand-type ``` #### Example: ```mlir - %2 = spv.LogicalEqual %0, %1 : i1 - %2 = spv.LogicalEqual %0, %1 : vector<4xi1> + %2 = spirv.LogicalEqual %0, %1 : i1 + %2 = spirv.LogicalEqual %0, %1 : vector<4xi1> ``` }]; } @@ -675,14 +675,14 @@ ``` - logical-not ::= `spv.LogicalNot` ssa-use `:` operand-type + logical-not ::= `spirv.LogicalNot` ssa-use `:` operand-type ``` #### Example: ```mlir - %2 = spv.LogicalNot %0 : i1 - %2 = spv.LogicalNot %0 : vector<4xi1> + %2 = spirv.LogicalNot %0 : i1 + %2 = spirv.LogicalNot %0 : vector<4xi1> ``` }]; @@ -712,15 +712,15 @@ ``` - logical-not-equal ::= `spv.LogicalNotEqual` ssa-use `,` ssa-use + logical-not-equal ::= `spirv.LogicalNotEqual` ssa-use `,` ssa-use `:` operand-type ``` #### Example: ```mlir - %2 = spv.LogicalNotEqual %0, %1 : i1 - %2 = spv.LogicalNotEqual %0, %1 : vector<4xi1> + %2 = spirv.LogicalNotEqual %0, %1 : i1 + %2 = spirv.LogicalNotEqual %0, %1 : vector<4xi1> ``` }]; } @@ -748,15 +748,15 @@ ``` - logical-or ::= `spv.LogicalOr` ssa-use `,` ssa-use + logical-or ::= `spirv.LogicalOr` ssa-use `,` ssa-use `:` operand-type ``` #### Example: ```mlir - %2 = spv.LogicalOr %0, %1 : i1 - %2 = spv.LogicalOr %0, %1 : vector<4xi1> + %2 = spirv.LogicalOr %0, %1 : i1 + %2 = spirv.LogicalOr %0, %1 : vector<4xi1> ``` }]; @@ -786,14 +786,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - ordered-op ::= ssa-id `=` `spv.Ordered` ssa-use, ssa-use + ordered-op ::= ssa-id `=` `spirv.Ordered` ssa-use, ssa-use ```mlir #### Example: ``` - %4 = spv.Ordered %0, %1 : f32 - %5 = spv.Ordered %2, %3 : vector<4xf32> + %4 = spirv.Ordered %0, %1 : f32 + %5 = spirv.Ordered %2, %3 : vector<4xf32> ``` }]; @@ -827,14 +827,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - sgreater-than-op ::= ssa-id `=` `spv.SGreaterThan` ssa-use, ssa-use + sgreater-than-op ::= ssa-id `=` `spirv.SGreaterThan` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.SGreaterThan %0, %1 : i32 - %5 = spv.SGreaterThan %2, %3 : vector<4xi32> + %4 = spirv.SGreaterThan %0, %1 : i32 + %5 = spirv.SGreaterThan %2, %3 : vector<4xi32> ``` }]; @@ -864,14 +864,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - sgreater-than-equal-op ::= ssa-id `=` `spv.SGreaterThanEqual` ssa-use, ssa-use + sgreater-than-equal-op ::= ssa-id `=` `spirv.SGreaterThanEqual` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ``` - %4 = spv.SGreaterThanEqual %0, %1 : i32 - %5 = spv.SGreaterThanEqual %2, %3 : vector<4xi32> + %4 = spirv.SGreaterThanEqual %0, %1 : i32 + %5 = spirv.SGreaterThanEqual %2, %3 : vector<4xi32> ``` }]; @@ -899,14 +899,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - sless-than-op ::= ssa-id `=` `spv.SLessThan` ssa-use, ssa-use + sless-than-op ::= ssa-id `=` `spirv.SLessThan` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.SLessThan %0, %1 : i32 - %5 = spv.SLessThan %2, %3 : vector<4xi32> + %4 = spirv.SLessThan %0, %1 : i32 + %5 = spirv.SLessThan %2, %3 : vector<4xi32> ``` }]; @@ -936,14 +936,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - sless-than-equal-op ::= ssa-id `=` `spv.SLessThanEqual` ssa-use, ssa-use + sless-than-equal-op ::= ssa-id `=` `spirv.SLessThanEqual` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.SLessThanEqual %0, %1 : i32 - %5 = spv.SLessThanEqual %2, %3 : vector<4xi32> + %4 = spirv.SLessThanEqual %0, %1 : i32 + %5 = spirv.SLessThanEqual %2, %3 : vector<4xi32> ``` }]; @@ -985,16 +985,16 @@ | pointer-type select-condition-type ::= boolean-type | `vector<` integer-literal `x` boolean-type `>` - select-op ::= ssa-id `=` `spv.Select` ssa-use, ssa-use, ssa-use + select-op ::= ssa-id `=` `spirv.Select` ssa-use, ssa-use, ssa-use `:` select-condition-type `,` select-object-type ``` #### Example: ```mlir - %3 = spv.Select %0, %1, %2 : i1, f32 - %3 = spv.Select %0, %1, %2 : i1, vector<3xi32> - %3 = spv.Select %0, %1, %2 : vector<3xi1>, vector<3xf32> + %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> ``` }]; @@ -1036,14 +1036,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - ugreater-than-op ::= ssa-id `=` `spv.UGreaterThan` ssa-use, ssa-use + ugreater-than-op ::= ssa-id `=` `spirv.UGreaterThan` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.UGreaterThan %0, %1 : i32 - %5 = spv.UGreaterThan %2, %3 : vector<4xi32> + %4 = spirv.UGreaterThan %0, %1 : i32 + %5 = spirv.UGreaterThan %2, %3 : vector<4xi32> ``` }]; @@ -1073,14 +1073,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - ugreater-than-equal-op ::= ssa-id `=` `spv.UGreaterThanEqual` ssa-use, ssa-use + ugreater-than-equal-op ::= ssa-id `=` `spirv.UGreaterThanEqual` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.UGreaterThanEqual %0, %1 : i32 - %5 = spv.UGreaterThanEqual %2, %3 : vector<4xi32> + %4 = spirv.UGreaterThanEqual %0, %1 : i32 + %5 = spirv.UGreaterThanEqual %2, %3 : vector<4xi32> ``` }]; @@ -1108,14 +1108,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - uless-than-op ::= ssa-id `=` `spv.ULessThan` ssa-use, ssa-use + uless-than-op ::= ssa-id `=` `spirv.ULessThan` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.ULessThan %0, %1 : i32 - %5 = spv.ULessThan %2, %3 : vector<4xi32> + %4 = spirv.ULessThan %0, %1 : i32 + %5 = spirv.ULessThan %2, %3 : vector<4xi32> ``` }]; @@ -1144,14 +1144,14 @@ ``` float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - unordered-op ::= ssa-id `=` `spv.Unordered` ssa-use, ssa-use + unordered-op ::= ssa-id `=` `spirv.Unordered` ssa-use, ssa-use ```mlir #### Example: ``` - %4 = spv.Unordered %0, %1 : f32 - %5 = spv.Unordered %2, %3 : vector<4xf32> + %4 = spirv.Unordered %0, %1 : f32 + %5 = spirv.Unordered %2, %3 : vector<4xf32> ``` }]; @@ -1187,14 +1187,14 @@ ``` integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - uless-than-equal-op ::= ssa-id `=` `spv.ULessThanEqual` ssa-use, ssa-use + uless-than-equal-op ::= ssa-id `=` `spirv.ULessThanEqual` ssa-use, ssa-use `:` integer-scalar-vector-type ``` #### Example: ```mlir - %4 = spv.ULessThanEqual %0, %1 : i32 - %5 = spv.ULessThanEqual %2, %3 : vector<4xi32> + %4 = spirv.ULessThanEqual %0, %1 : i32 + %5 = spirv.ULessThanEqual %2, %3 : vector<4xi32> ``` }]; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMatrixOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMatrixOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMatrixOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMatrixOps.td @@ -34,16 +34,16 @@ ``` - matrix-times-matrix-op ::= ssa-id `=` `spv.MatrixTimesMatrix` ssa-use, + matrix-times-matrix-op ::= ssa-id `=` `spirv.MatrixTimesMatrix` ssa-use, ssa-use `:` matrix-type `,` matrix-type `->` matrix-type ```mlir #### Example: ``` - %0 = spv.MatrixTimesMatrix %matrix_1, %matrix_2 : - !spv.matrix<4 x vector<3xf32>>, !spv.matrix<3 x vector<4xf32>> -> - !spv.matrix<4 x vector<4xf32>> + %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>> ``` }]; @@ -85,7 +85,7 @@ ``` - matrix-times-scalar-op ::= ssa-id `=` `spv.MatrixTimesScalar` ssa-use, + matrix-times-scalar-op ::= ssa-id `=` `spirv.MatrixTimesScalar` ssa-use, ssa-use `:` matrix-type `,` float-type `->` matrix-type ``` @@ -94,8 +94,8 @@ ```mlir - %0 = spv.MatrixTimesScalar %matrix, %scalar : - !spv.matrix<3 x vector<3xf32>>, f32 -> !spv.matrix<3 x vector<3xf32>> + %0 = spirv.MatrixTimesScalar %matrix, %scalar : + !spirv.matrix<3 x vector<3xf32>>, f32 -> !spirv.matrix<3 x vector<3xf32>> ``` }]; @@ -148,7 +148,7 @@ ``` - transpose-op ::= ssa-id `=` `spv.Transpose` ssa-use `:` matrix-type `->` + transpose-op ::= ssa-id `=` `spirv.Transpose` ssa-use `:` matrix-type `->` matrix-type ```mlir @@ -156,8 +156,8 @@ #### Example: ``` - %0 = spv.Transpose %matrix: !spv.matrix<2 x vector<3xf32>> -> - !spv.matrix<3 x vector<2xf32>> + %0 = spirv.Transpose %matrix: !spirv.matrix<2 x vector<3xf32>> -> + !spirv.matrix<3 x vector<2xf32>> ``` }]; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMemoryOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMemoryOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMemoryOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMemoryOps.td @@ -47,7 +47,7 @@ ``` - access-chain-op ::= ssa-id `=` `spv.AccessChain` ssa-use + access-chain-op ::= ssa-id `=` `spirv.AccessChain` ssa-use `[` ssa-use (',' ssa-use)* `]` `:` pointer-type ``` @@ -55,10 +55,10 @@ #### Example: ```mlir - %0 = "spv.Constant"() { value = 1: i32} : () -> i32 - %1 = spv.Variable : !spv.ptr>, Function> - %2 = spv.AccessChain %1[%0] : !spv.ptr>, Function> - %3 = spv.Load "Function" %2 ["Volatile"] : !spv.array<4xf32> + %0 = "spirv.Constant"() { value = 1: i32} : () -> i32 + %1 = spirv.Variable : !spirv.ptr>, Function> + %2 = spirv.AccessChain %1[%0] : !spirv.ptr>, Function> + %3 = spirv.Load "Function" %2 ["Volatile"] : !spirv.array<4xf32> ``` }]; @@ -101,7 +101,7 @@ ``` - copy-memory-op ::= `spv.CopyMemory ` storage-class ssa-use + copy-memory-op ::= `spirv.CopyMemory ` storage-class ssa-use storage-class ssa-use (`[` memory-access `]` (`, [` memory-access `]`)?)? ` : ` spirv-element-type @@ -110,9 +110,9 @@ #### Example: ```mlir - %0 = spv.Variable : !spv.ptr - %1 = spv.Variable : !spv.ptr - spv.CopyMemory "Function" %0, "Function" %1 : f32 + %0 = spirv.Variable : !spirv.ptr + %1 = spirv.Variable : !spirv.ptr + spirv.CopyMemory "Function" %0, "Function" %1 : f32 ``` }]; @@ -144,7 +144,7 @@ ``` - access-chain-op ::= ssa-id `=` `spv.InBoundsPtrAccessChain` ssa-use + access-chain-op ::= ssa-id `=` `spirv.InBoundsPtrAccessChain` ssa-use `[` ssa-use (',' ssa-use)* `]` `:` pointer-type ```mlir @@ -152,8 +152,8 @@ #### Example: ``` - func @inbounds_ptr_access_chain(%arg0: !spv.ptr, %arg1 : i64) -> () { - %0 = spv.InBoundsPtrAccessChain %arg0[%arg1] : !spv.ptr, i64 + func @inbounds_ptr_access_chain(%arg0: !spirv.ptr, %arg1 : i64) -> () { + %0 = spirv.InBoundsPtrAccessChain %arg0[%arg1] : !spirv.ptr, i64 ... } ``` @@ -202,17 +202,17 @@ memory-access ::= `"None"` | `"Volatile"` | `"Aligned", ` integer-literal | `"NonTemporal"` - load-op ::= ssa-id ` = spv.Load ` storage-class ssa-use + load-op ::= ssa-id ` = spirv.Load ` storage-class ssa-use (`[` memory-access `]`)? ` : ` spirv-element-type ``` #### Example: ```mlir - %0 = spv.Variable : !spv.ptr - %1 = spv.Load "Function" %0 : f32 - %2 = spv.Load "Function" %0 ["Volatile"] : f32 - %3 = spv.Load "Function" %0 ["Aligned", 4] : f32 + %0 = spirv.Variable : !spirv.ptr + %1 = spirv.Load "Function" %0 : f32 + %2 = spirv.Load "Function" %0 ["Volatile"] : f32 + %3 = spirv.Load "Function" %0 ["Aligned", 4] : f32 ``` }]; @@ -270,7 +270,7 @@ ``` - [access-chain-op ::= ssa-id `=` `spv.PtrAccessChain` ssa-use + [access-chain-op ::= ssa-id `=` `spirv.PtrAccessChain` ssa-use `[` ssa-use (',' ssa-use)* `]` `:` pointer-type ```mlir @@ -278,8 +278,8 @@ #### Example: ``` - func @ptr_access_chain(%arg0: !spv.ptr, %arg1 : i64) -> () { - %0 = spv.PtrAccessChain %arg0[%arg1] : !spv.ptr, i64 + func @ptr_access_chain(%arg0: !spirv.ptr, %arg1 : i64) -> () { + %0 = spirv.PtrAccessChain %arg0[%arg1] : !spirv.ptr, i64 ... } ``` @@ -323,18 +323,18 @@ ``` - store-op ::= `spv.Store ` storage-class ssa-use `, ` ssa-use `, ` + store-op ::= `spirv.Store ` storage-class ssa-use `, ` ssa-use `, ` (`[` memory-access `]`)? `:` spirv-element-type ``` #### Example: ```mlir - %0 = spv.Variable : !spv.ptr - %1 = spv.FMul ... : f32 - spv.Store "Function" %0, %1 : f32 - spv.Store "Function" %0, %1 ["Volatile"] : f32 - spv.Store "Function" %0, %1 ["Aligned", 4] : f32 + %0 = spirv.Variable : !spirv.ptr + %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 ``` }]; @@ -383,7 +383,7 @@ ``` - variable-op ::= ssa-id `=` `spv.Variable` (`init(` ssa-use `)`)? + variable-op ::= ssa-id `=` `spirv.Variable` (`init(` ssa-use `)`)? attribute-dict? `:` spirv-pointer-type ``` @@ -392,10 +392,10 @@ #### Example: ```mlir - %0 = spv.Constant ... + %0 = spirv.Constant ... - %1 = spv.Variable : !spv.ptr - %2 = spv.Variable init(%0): !spv.ptr + %1 = spirv.Variable : !spirv.ptr + %2 = spirv.Variable init(%0): !spirv.ptr ``` }]; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMiscOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMiscOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMiscOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMiscOps.td @@ -27,13 +27,13 @@ ``` - assumetruekhr-op ::= `spv.KHR.AssumeTrue` ssa-use + assumetruekhr-op ::= `spirv.KHR.AssumeTrue` ssa-use ```mlir #### Example: ``` - spv.KHR.AssumeTrue %arg + spirv.KHR.AssumeTrue %arg ``` }]; @@ -69,14 +69,14 @@ ``` - undef-op ::= `spv.Undef` `:` spirv-type + undef-op ::= `spirv.Undef` `:` spirv-type ``` #### Example: ```mlir - %0 = spv.Undef : f32 - %1 = spv.Undef : !spv.struct>> + %0 = spirv.Undef : f32 + %1 = spirv.Undef : !spirv.struct>> ``` }]; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVNonUniformOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVNonUniformOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVNonUniformOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVNonUniformOps.td @@ -57,14 +57,14 @@ ``` scope ::= `"Workgroup"` | `"Subgroup"` - non-uniform-ballot-op ::= ssa-id `=` `spv.GroupNonUniformBallot` scope + non-uniform-ballot-op ::= ssa-id `=` `spirv.GroupNonUniformBallot` scope ssa-use `:` `vector` `<` 4 `x` `integer-type` `>` ``` #### Example: ```mlir - %0 = spv.GroupNonUniformBallot "SubGroup" %predicate : vector<4xi32> + %0 = spirv.GroupNonUniformBallot "SubGroup" %predicate : vector<4xi32> ``` }]; @@ -122,7 +122,7 @@ `vector<` integer-literal `x` integer-type `>` | `vector<` integer-literal `x` float-type `>` group-non-uniform-broadcast-op ::= ssa-id `=` - `spv.GroupNonUniformBroadcast` scope ssa_use, ssa_use + `spirv.GroupNonUniformBroadcast` scope ssa_use, ssa_use `:` integer-float-scalar-vector-type `,` integer-type ```mlir @@ -132,8 +132,8 @@ %scalar_value = ... : f32 %vector_value = ... : vector<4xf32> %id = ... : i32 - %0 = spv.GroupNonUniformBroadcast "Subgroup" %scalar_value, %id : f32, i32 - %1 = spv.GroupNonUniformBroadcast "Workgroup" %vector_value, %id : + %0 = spirv.GroupNonUniformBroadcast "Subgroup" %scalar_value, %id : f32, i32 + %1 = spirv.GroupNonUniformBroadcast "Workgroup" %vector_value, %id : vector<4xf32>, i32 ``` }]; @@ -177,14 +177,14 @@ ``` scope ::= `"Workgroup"` | `"Subgroup"` - non-uniform-elect-op ::= ssa-id `=` `spv.GroupNonUniformElect` scope + non-uniform-elect-op ::= ssa-id `=` `spirv.GroupNonUniformElect` scope `:` `i1` ``` #### Example: ```mlir - %0 = spv.GroupNonUniformElect : i1 + %0 = spirv.GroupNonUniformElect : i1 ``` }]; @@ -239,7 +239,7 @@ operation ::= `"Reduce"` | `"InclusiveScan"` | `"ExclusiveScan"` | ... float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - non-uniform-fadd-op ::= ssa-id `=` `spv.GroupNonUniformFAdd` scope operation + non-uniform-fadd-op ::= ssa-id `=` `spirv.GroupNonUniformFAdd` scope operation ssa-use ( `cluster_size` `(` ssa_use `)` )? `:` float-scalar-vector-type ``` @@ -247,11 +247,11 @@ #### Example: ```mlir - %four = spv.Constant 4 : i32 + %four = spirv.Constant 4 : i32 %scalar = ... : f32 %vector = ... : vector<4xf32> - %0 = spv.GroupNonUniformFAdd "Workgroup" "Reduce" %scalar : f32 - %1 = spv.GroupNonUniformFAdd "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xf32> + %0 = spirv.GroupNonUniformFAdd "Workgroup" "Reduce" %scalar : f32 + %1 = spirv.GroupNonUniformFAdd "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xf32> ``` }]; @@ -299,7 +299,7 @@ operation ::= `"Reduce"` | `"InclusiveScan"` | `"ExclusiveScan"` | ... float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - non-uniform-fmax-op ::= ssa-id `=` `spv.GroupNonUniformFMax` scope operation + non-uniform-fmax-op ::= ssa-id `=` `spirv.GroupNonUniformFMax` scope operation ssa-use ( `cluster_size` `(` ssa_use `)` )? `:` float-scalar-vector-type ``` @@ -307,11 +307,11 @@ #### Example: ```mlir - %four = spv.Constant 4 : i32 + %four = spirv.Constant 4 : i32 %scalar = ... : f32 %vector = ... : vector<4xf32> - %0 = spv.GroupNonUniformFMax "Workgroup" "Reduce" %scalar : f32 - %1 = spv.GroupNonUniformFMax "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xf32> + %0 = spirv.GroupNonUniformFMax "Workgroup" "Reduce" %scalar : f32 + %1 = spirv.GroupNonUniformFMax "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xf32> ``` }]; @@ -359,7 +359,7 @@ operation ::= `"Reduce"` | `"InclusiveScan"` | `"ExclusiveScan"` | ... float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - non-uniform-fmin-op ::= ssa-id `=` `spv.GroupNonUniformFMin` scope operation + non-uniform-fmin-op ::= ssa-id `=` `spirv.GroupNonUniformFMin` scope operation ssa-use ( `cluster_size` `(` ssa_use `)` )? `:` float-scalar-vector-type ``` @@ -367,11 +367,11 @@ #### Example: ```mlir - %four = spv.Constant 4 : i32 + %four = spirv.Constant 4 : i32 %scalar = ... : f32 %vector = ... : vector<4xf32> - %0 = spv.GroupNonUniformFMin "Workgroup" "Reduce" %scalar : f32 - %1 = spv.GroupNonUniformFMin "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xf32> + %0 = spirv.GroupNonUniformFMin "Workgroup" "Reduce" %scalar : f32 + %1 = spirv.GroupNonUniformFMin "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xf32> ``` }]; @@ -416,7 +416,7 @@ operation ::= `"Reduce"` | `"InclusiveScan"` | `"ExclusiveScan"` | ... float-scalar-vector-type ::= float-type | `vector<` integer-literal `x` float-type `>` - non-uniform-fmul-op ::= ssa-id `=` `spv.GroupNonUniformFMul` scope operation + non-uniform-fmul-op ::= ssa-id `=` `spirv.GroupNonUniformFMul` scope operation ssa-use ( `cluster_size` `(` ssa_use `)` )? `:` float-scalar-vector-type ``` @@ -424,11 +424,11 @@ #### Example: ```mlir - %four = spv.Constant 4 : i32 + %four = spirv.Constant 4 : i32 %scalar = ... : f32 %vector = ... : vector<4xf32> - %0 = spv.GroupNonUniformFMul "Workgroup" "Reduce" %scalar : f32 - %1 = spv.GroupNonUniformFMul "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xf32> + %0 = spirv.GroupNonUniformFMul "Workgroup" "Reduce" %scalar : f32 + %1 = spirv.GroupNonUniformFMul "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xf32> ``` }]; @@ -471,7 +471,7 @@ operation ::= `"Reduce"` | `"InclusiveScan"` | `"ExclusiveScan"` | ... integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - non-uniform-iadd-op ::= ssa-id `=` `spv.GroupNonUniformIAdd` scope operation + non-uniform-iadd-op ::= ssa-id `=` `spirv.GroupNonUniformIAdd` scope operation ssa-use ( `cluster_size` `(` ssa_use `)` )? `:` integer-scalar-vector-type ``` @@ -479,11 +479,11 @@ #### Example: ```mlir - %four = spv.Constant 4 : i32 + %four = spirv.Constant 4 : i32 %scalar = ... : i32 %vector = ... : vector<4xi32> - %0 = spv.GroupNonUniformIAdd "Workgroup" "Reduce" %scalar : i32 - %1 = spv.GroupNonUniformIAdd "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xi32> + %0 = spirv.GroupNonUniformIAdd "Workgroup" "Reduce" %scalar : i32 + %1 = spirv.GroupNonUniformIAdd "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xi32> ``` }]; @@ -526,7 +526,7 @@ operation ::= `"Reduce"` | `"InclusiveScan"` | `"ExclusiveScan"` | ... integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - non-uniform-imul-op ::= ssa-id `=` `spv.GroupNonUniformIMul` scope operation + non-uniform-imul-op ::= ssa-id `=` `spirv.GroupNonUniformIMul` scope operation ssa-use ( `cluster_size` `(` ssa_use `)` )? `:` integer-scalar-vector-type ``` @@ -534,11 +534,11 @@ #### Example: ```mlir - %four = spv.Constant 4 : i32 + %four = spirv.Constant 4 : i32 %scalar = ... : i32 %vector = ... : vector<4xi32> - %0 = spv.GroupNonUniformIMul "Workgroup" "Reduce" %scalar : i32 - %1 = spv.GroupNonUniformIMul "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xi32> + %0 = spirv.GroupNonUniformIMul "Workgroup" "Reduce" %scalar : i32 + %1 = spirv.GroupNonUniformIMul "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xi32> ``` }]; @@ -583,7 +583,7 @@ operation ::= `"Reduce"` | `"InclusiveScan"` | `"ExclusiveScan"` | ... integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - non-uniform-smax-op ::= ssa-id `=` `spv.GroupNonUniformSMax` scope operation + non-uniform-smax-op ::= ssa-id `=` `spirv.GroupNonUniformSMax` scope operation ssa-use ( `cluster_size` `(` ssa_use `)` )? `:` integer-scalar-vector-type ``` @@ -591,11 +591,11 @@ #### Example: ```mlir - %four = spv.Constant 4 : i32 + %four = spirv.Constant 4 : i32 %scalar = ... : i32 %vector = ... : vector<4xi32> - %0 = spv.GroupNonUniformSMax "Workgroup" "Reduce" %scalar : i32 - %1 = spv.GroupNonUniformSMax "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xi32> + %0 = spirv.GroupNonUniformSMax "Workgroup" "Reduce" %scalar : i32 + %1 = spirv.GroupNonUniformSMax "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xi32> ``` }]; @@ -640,7 +640,7 @@ operation ::= `"Reduce"` | `"InclusiveScan"` | `"ExclusiveScan"` | ... integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - non-uniform-smin-op ::= ssa-id `=` `spv.GroupNonUniformSMin` scope operation + non-uniform-smin-op ::= ssa-id `=` `spirv.GroupNonUniformSMin` scope operation ssa-use ( `cluster_size` `(` ssa_use `)` )? `:` integer-scalar-vector-type ``` @@ -648,11 +648,11 @@ #### Example: ```mlir - %four = spv.Constant 4 : i32 + %four = spirv.Constant 4 : i32 %scalar = ... : i32 %vector = ... : vector<4xi32> - %0 = spv.GroupNonUniformSMin "Workgroup" "Reduce" %scalar : i32 - %1 = spv.GroupNonUniformSMin "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xi32> + %0 = spirv.GroupNonUniformSMin "Workgroup" "Reduce" %scalar : i32 + %1 = spirv.GroupNonUniformSMin "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xi32> ``` }]; @@ -690,7 +690,7 @@ #### Example: ```mlir - %0 = spv.GroupNonUniformShuffle %val, %id : f32, i32 + %0 = spirv.GroupNonUniformShuffle %val, %id : f32, i32 ``` }]; @@ -745,7 +745,7 @@ #### Example: ```mlir - %0 = spv.GroupNonUniformShuffleDown %val, %delta : f32, i32 + %0 = spirv.GroupNonUniformShuffleDown %val, %delta : f32, i32 ``` }]; @@ -799,7 +799,7 @@ #### Example: ```mlir - %0 = spv.GroupNonUniformShuffleUp %val, %delta : f32, i32 + %0 = spirv.GroupNonUniformShuffleUp %val, %delta : f32, i32 ``` }]; @@ -853,7 +853,7 @@ #### Example: ```mlir - %0 = spv.GroupNonUniformShuffleXor %val, %mask : f32, i32 + %0 = spirv.GroupNonUniformShuffleXor %val, %mask : f32, i32 ``` }]; @@ -913,7 +913,7 @@ operation ::= `"Reduce"` | `"InclusiveScan"` | `"ExclusiveScan"` | ... integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - non-uniform-umax-op ::= ssa-id `=` `spv.GroupNonUniformUMax` scope operation + non-uniform-umax-op ::= ssa-id `=` `spirv.GroupNonUniformUMax` scope operation ssa-use ( `cluster_size` `(` ssa_use `)` )? `:` integer-scalar-vector-type ``` @@ -921,11 +921,11 @@ #### Example: ```mlir - %four = spv.Constant 4 : i32 + %four = spirv.Constant 4 : i32 %scalar = ... : i32 %vector = ... : vector<4xi32> - %0 = spv.GroupNonUniformUMax "Workgroup" "Reduce" %scalar : i32 - %1 = spv.GroupNonUniformUMax "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xi32> + %0 = spirv.GroupNonUniformUMax "Workgroup" "Reduce" %scalar : i32 + %1 = spirv.GroupNonUniformUMax "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xi32> ``` }]; @@ -971,7 +971,7 @@ operation ::= `"Reduce"` | `"InclusiveScan"` | `"ExclusiveScan"` | ... integer-scalar-vector-type ::= integer-type | `vector<` integer-literal `x` integer-type `>` - non-uniform-umin-op ::= ssa-id `=` `spv.GroupNonUniformUMin` scope operation + non-uniform-umin-op ::= ssa-id `=` `spirv.GroupNonUniformUMin` scope operation ssa-use ( `cluster_size` `(` ssa_use `)` )? `:` integer-scalar-vector-type ``` @@ -979,11 +979,11 @@ #### Example: ```mlir - %four = spv.Constant 4 : i32 + %four = spirv.Constant 4 : i32 %scalar = ... : i32 %vector = ... : vector<4xi32> - %0 = spv.GroupNonUniformUMin "Workgroup" "Reduce" %scalar : i32 - %1 = spv.GroupNonUniformUMin "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xi32> + %0 = spirv.GroupNonUniformUMin "Workgroup" "Reduce" %scalar : i32 + %1 = spirv.GroupNonUniformUMin "Subgroup" "ClusteredReduce" %vector cluster_size(%four) : vector<4xi32> ``` }]; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td @@ -42,14 +42,14 @@ ``` - spv-address-of-op ::= ssa-id `=` `spv.mlir.addressof` symbol-ref-id + spv-address-of-op ::= ssa-id `=` `spirv.mlir.addressof` symbol-ref-id `:` spirv-pointer-type ``` #### Example: ```mlir - %0 = spv.mlir.addressof @global_var : !spv.ptr + %0 = spirv.mlir.addressof @global_var : !spirv.ptr ``` }]; @@ -91,7 +91,7 @@ * ... Having such a plethora of constant instructions renders IR transformations - more tedious. Therefore, we use a single `spv.Constant` op to represent + 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. @@ -99,16 +99,16 @@ ``` - spv.Constant-op ::= ssa-id `=` `spv.Constant` attribute-value + spirv.Constant-op ::= ssa-id `=` `spirv.Constant` attribute-value (`:` spirv-type)? ``` #### Example: ```mlir - %0 = spv.Constant true - %1 = spv.Constant dense<[2, 3]> : vector<2xf32> - %2 = spv.Constant [dense<3.0> : vector<2xf32>] : !spv.array<1xvector<2xf32>> + %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 @@ -158,11 +158,11 @@ OpEntryPoint instructions with the same Execution Model and the same Name string. - Interface is a list of symbol references to `spv.GlobalVariable` + 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 - `spv.GlobalVariable`s referenced by the entry point’s static call + `spirv.GlobalVariable`s 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 @@ -175,15 +175,15 @@ execution-model ::= "Vertex" | "TesellationControl" | - entry-point-op ::= ssa-id `=` `spv.EntryPoint` execution-model + entry-point-op ::= ssa-id `=` `spirv.EntryPoint` execution-model symbol-reference (`, ` symbol-reference)* ``` #### Example: ```mlir - spv.EntryPoint "GLCompute" @foo - spv.EntryPoint "Kernel" @foo, @var1, @var2 + spirv.EntryPoint "GLCompute" @foo + spirv.EntryPoint "Kernel" @foo, @var1, @var2 ``` }]; @@ -224,15 +224,15 @@ execution-mode ::= "Invocations" | "SpacingEqual" | - execution-mode-op ::= `spv.ExecutionMode ` ssa-use execution-mode + execution-mode-op ::= `spirv.ExecutionMode ` ssa-use execution-mode (integer-literal (`, ` integer-literal)* )? ``` #### Example: ```mlir - spv.ExecutionMode @foo "ContractionOff" - spv.ExecutionMode @bar "LocalSizeHint", 3, 4, 5 + spirv.ExecutionMode @foo "ContractionOff" + spirv.ExecutionMode @bar "LocalSizeHint", 3, 4, 5 ``` }]; @@ -277,15 +277,15 @@ ``` spv-function-control ::= "None" | "Inline" | "DontInline" | ... - spv-function-op ::= `spv.func` function-signature + spv-function-op ::= `spirv.func` function-signature spv-function-control region ``` #### Example: ```mlir - spv.func @foo() -> () "None" { ... } - spv.func @bar() -> () "Inline|Pure" { ... } + spirv.func @foo() -> () "None" { ... } + spirv.func @bar() -> () "Inline|Pure" { ... } ``` }]; @@ -349,13 +349,13 @@ 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 - `spv.GlobalVariable` operation in module scope. Initializer must + `spirv.GlobalVariable` operation in module scope. Initializer must have the same type as the type of the defined symbol. ``` - variable-op ::= `spv.GlobalVariable` spirv-type symbol-ref-id + variable-op ::= `spirv.GlobalVariable` spirv-type symbol-ref-id (`initializer(` symbol-ref-id `)`)? (`bind(` integer-literal, integer-literal `)`)? (`built_in(` string-literal `)`)? @@ -369,10 +369,10 @@ #### Example: ```mlir - spv.GlobalVariable @var0 : !spv.ptr @var0 - spv.GlobalVariable @var1 initializer(@var0) : !spv.ptr - spv.GlobalVariable @var2 bind(1, 2) : !spv.ptr - spv.GlobalVariable @var3 built_in("GlobalInvocationId") : !spv.ptr, Input> + spirv.GlobalVariable @var0 : !spirv.ptr @var0 + spirv.GlobalVariable @var1 initializer(@var0) : !spirv.ptr + spirv.GlobalVariable @var2 bind(1, 2) : !spirv.ptr + spirv.GlobalVariable @var3 built_in("GlobalInvocationId") : !spirv.ptr, Input> ``` }]; @@ -457,7 +457,7 @@ ``` addressing-model ::= `Logical` | `Physical32` | `Physical64` | ... memory-model ::= `Simple` | `GLSL450` | `OpenCL` | `Vulkan` | ... - spv-module-op ::= `spv.module` addressing-model memory-model + spv-module-op ::= `spirv.module` addressing-model memory-model (requires spirv-vce-attribute)? (`attributes` attribute-dict)? region @@ -466,13 +466,13 @@ #### Example: ```mlir - spv.module Logical GLSL450 {} + spirv.module Logical GLSL450 {} - spv.module Logical Vulkan - requires #spv.vce + spirv.module Logical Vulkan + requires #spirv.vce attributes { some_additional_attr = ... } { - spv.func @do_nothing() -> () { - spv.Return + spirv.func @do_nothing() -> () { + spirv.Return } } ``` @@ -534,14 +534,14 @@ ``` - spv-reference-of-op ::= ssa-id `=` `spv.mlir.referenceof` symbol-ref-id + spv-reference-of-op ::= ssa-id `=` `spirv.mlir.referenceof` symbol-ref-id `:` spirv-scalar-type ``` #### Example: ```mlir - %0 = spv.mlir.referenceof @spec_const : f32 + %0 = spirv.mlir.referenceof @spec_const : f32 ``` TODO Add support for composite specialization constants. @@ -577,14 +577,14 @@ * `OpSpecConstantTrue` and `OpSpecConstantFalse` for boolean constants * `OpSpecConstant` for scalar constants - Similar as `spv.Constant`, this op represents all of the above cases. + Similar as `spirv.Constant`, this op represents all of the above cases. `OpSpecConstantComposite` and `OpSpecConstantOp` are modelled with separate ops. ``` - spv-spec-constant-op ::= `spv.SpecConstant` symbol-ref-id + spv-spec-constant-op ::= `spirv.SpecConstant` symbol-ref-id `spec_id(` integer `)` `=` attribute-value (`:` spirv-type)? ``` @@ -595,8 +595,8 @@ #### Example: ```mlir - spv.SpecConstant @spec_const1 = true - spv.SpecConstant @spec_const2 spec_id(5) = 42 : i32 + spirv.SpecConstant @spec_const1 = true + spirv.SpecConstant @spec_const2 spec_id(5) = 42 : i32 ``` }]; @@ -621,30 +621,30 @@ let description = [{ This op declares a SPIR-V composite specialization constant. This covers the `OpSpecConstantComposite` SPIR-V instruction. Scalar constants are - covered by `spv.SpecConstant`. + 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 - `spv.SpecConstant`). - - The SSA ID of a `spv.Undef`. + `spirv.SpecConstant`). + - The SSA ID of a `spirv.Undef`. ``` - spv-spec-constant-composite-op ::= `spv.SpecConstantComposite` symbol-ref-id ` (` + 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: `spv.struct`, `spv.array`, or `vector`. + dialect: `spirv.struct`, `spirv.array`, or `vector`. #### Example: ```mlir - spv.SpecConstant @sc1 = 1 : i32 - spv.SpecConstant @sc2 = 2.5 : f32 - spv.SpecConstant @sc3 = 3.5 : f32 - spv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.struct + 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 ``` TODO Add support for constituents that are: @@ -682,15 +682,15 @@ In the `spv` dialect, this op is modelled as follows: ``` - spv-spec-constant-operation-op ::= `spv.SpecConstantOperation` `wraps` + spv-spec-constant-operation-op ::= `spirv.SpecConstantOperation` `wraps` generic-spirv-op `:` function-type ``` - In particular, an `spv.SpecConstantOperation` contains exactly one + 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 `spv.mlir.yield` instruction as the terminator. + - An `spirv.mlir.yield` instruction as the terminator. The following SPIR-V instructions are valid: - OpSConvert, @@ -736,10 +736,10 @@ #### Example: ```mlir - %0 = spv.Constant 1: i32 - %1 = spv.Constant 1: i32 + %0 = spirv.Constant 1: i32 + %1 = spirv.Constant 1: i32 - %2 = spv.SpecConstantOperation wraps "spv.IAdd"(%0, %1) : (i32, i32) -> i32 + %2 = spirv.SpecConstantOperation wraps "spirv.IAdd"(%0, %1) : (i32, i32) -> i32 ``` }]; @@ -762,25 +762,25 @@ def SPV_YieldOp : SPV_Op<"mlir.yield", [ HasParent<"SpecConstantOperationOp">, NoSideEffect, Terminator]> { let summary = [{ - Yields the result computed in `spv.SpecConstantOperation`'s + Yields the result computed in `spirv.SpecConstantOperation`'s region back to the parent op. }]; let description = [{ This op is a special terminator whose only purpose is to terminate - an `spv.SpecConstantOperation`'s enclosed region. It accepts a + an `spirv.SpecConstantOperation`'s enclosed region. It accepts a single operand produced by the preceeding (and only other) instruction in its parent block (see SPV_SpecConstantOperation for further details). This op has no corresponding SPIR-V instruction. ``` - spv.mlir.yield ::= `spv.mlir.yield` ssa-id : spirv-type + spirv.mlir.yield ::= `spirv.mlir.yield` ssa-id : spirv-type ``` #### Example: ```mlir %0 = ... (some op supported by SPIR-V OpSpecConstantOp) - spv.mlir.yield %0 + spirv.mlir.yield %0 ``` }]; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h @@ -271,7 +271,7 @@ /// /// would be represented in MLIR as: /// -/// !spv.struct, Generic>)> +/// !spirv.struct, Generic>)> /// /// In the above, expressing recursive struct types is accomplished by giving a /// recursive struct a unique identified and using that identifier in the struct diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h b/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h --- a/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h +++ b/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h @@ -79,7 +79,7 @@ MLIRContext *context); /// Returns whether the given SPIR-V target (described by TargetEnvAttr) needs -/// ABI attributes for interface variables (spv.interface_var_abi). +/// ABI attributes for interface variables (spirv.interface_var_abi). bool needsInterfaceVarABIAttrs(TargetEnvAttr targetAttr); /// Returns the attribute name for specifying entry point information. diff --git a/mlir/include/mlir/Dialect/SPIRV/Linking/ModuleCombiner.h b/mlir/include/mlir/Dialect/SPIRV/Linking/ModuleCombiner.h --- a/mlir/include/mlir/Dialect/SPIRV/Linking/ModuleCombiner.h +++ b/mlir/include/mlir/Dialect/SPIRV/Linking/ModuleCombiner.h @@ -50,18 +50,18 @@ /// For the conflict resolution phase, the following rules are employed to /// resolve such conflicts: /// -/// - If 2 spv.func's have the same symbol name, then rename one of the +/// - If 2 spirv.func's have the same symbol name, then rename one of the /// functions. -/// - If an spv.func and another op have the same symbol name, then rename the +/// - If an spirv.func and another op have the same symbol name, then rename the /// other symbol. -/// - If none of the 2 conflicting ops are spv.func, then rename either. +/// - If none of the 2 conflicting ops are spirv.func, then rename either. /// /// For deduplication, the following 3 cases are taken into consideration: /// -/// - If 2 spv.GlobalVariable's have either the same descriptor set + binding +/// - If 2 spirv.GlobalVariable's have either the same descriptor set + binding /// or the same build_in attribute value, then replace one of them using the /// other. -/// - If 2 spv.SpecConstant's have the same spec_id attribute value, then +/// - If 2 spirv.SpecConstant's have the same spec_id attribute value, then /// replace one of them using the other. /// - Deduplicating functions are not supported right now. /// diff --git a/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h b/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h --- a/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h +++ b/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h @@ -48,27 +48,28 @@ createDecorateSPIRVCompositeTypeLayoutPass(); /// Creates an operation pass that deduces and attaches the minimal version/ -/// capabilities/extensions requirements for spv.module ops. -/// For each spv.module op, this pass requires a `spv.target_env` attribute on -/// it or an enclosing module-like op to drive the deduction. The reason is +/// capabilities/extensions requirements for spirv.module ops. +/// For each spirv.module op, this pass requires a `spirv.target_env` attribute +/// on it or an enclosing module-like op to drive the deduction. The reason is /// that an op can be enabled by multiple extensions/capabilities. So we need -/// to know which one to pick. `spv.target_env` gives the hard limit as for +/// to know which one to pick. `spirv.target_env` gives the hard limit as for /// what the target environment can support; this pass deduces what are -/// actually needed for a specific spv.module op. +/// actually needed for a specific spirv.module op. std::unique_ptr> createUpdateVersionCapabilityExtensionPass(); /// Creates an operation pass that lowers the ABI attributes specified during /// SPIR-V Lowering. Specifically, /// 1. Creates the global variables for arguments of entry point function using -/// the specification in the `spv.interface_var_abi` attribute for each +/// the specification in the `spirv.interface_var_abi` attribute for each /// argument. /// 2. Inserts the EntryPointOp and the ExecutionModeOp for entry point -/// functions using the specification in the `spv.entry_point_abi` attribute. +/// functions using the specification in the `spirv.entry_point_abi` +/// attribute. std::unique_ptr> createLowerABIAttributesPass(); /// Creates an operation pass that rewrites sequential chains of -/// spv.CompositeInsert into spv.CompositeConstruct. +/// spirv.CompositeInsert into spirv.CompositeConstruct. std::unique_ptr> createRewriteInsertsPass(); /// Creates an operation pass that unifies access of multiple aliased resources diff --git a/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td b/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td --- a/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td @@ -28,8 +28,8 @@ } def SPIRVRewriteInsertsPass : Pass<"spirv-rewrite-inserts", "spirv::ModuleOp"> { - let summary = "Rewrite sequential chains of spv.CompositeInsert operations into " - "spv.CompositeConstruct operations"; + let summary = "Rewrite sequential chains of spirv.CompositeInsert operations into " + "spirv.CompositeConstruct operations"; let constructor = "mlir::spirv::createRewriteInsertsPass()"; } @@ -42,7 +42,7 @@ def SPIRVUpdateVCE : Pass<"spirv-update-vce", "spirv::ModuleOp"> { let summary = "Deduce and attach minimal (version, capabilities, extensions) " - "requirements to spv.module ops"; + "requirements to spirv.module ops"; let constructor = "mlir::spirv::createUpdateVersionCapabilityExtensionPass()"; } diff --git a/mlir/include/mlir/IR/OpAsmInterface.td b/mlir/include/mlir/IR/OpAsmInterface.td --- a/mlir/include/mlir/IR/OpAsmInterface.td +++ b/mlir/include/mlir/IR/OpAsmInterface.td @@ -100,7 +100,7 @@ Return the default dialect used when printing/parsing operations in regions nested under this operation. This allows for eliding the dialect prefix from the operation name, for example it would be possible to omit - the `spv.` prefix from all operations within a SpirV module if this method + the `spirv.` prefix from all operations within a SpirV module if this method returned `spv`. The default implementation returns an empty string which is ignored. }], diff --git a/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp b/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp --- a/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp +++ b/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp @@ -35,7 +35,7 @@ namespace { -/// Converts composite arith.constant operation to spv.Constant. +/// Converts composite arith.constant operation to spirv.Constant. struct ConstantCompositeOpPattern final : public OpConversionPattern { using OpConversionPattern::OpConversionPattern; @@ -45,7 +45,7 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Converts scalar arith.constant operation to spv.Constant. +/// Converts scalar arith.constant operation to spirv.Constant. struct ConstantScalarOpPattern final : public OpConversionPattern { using OpConversionPattern::OpConversionPattern; @@ -58,7 +58,7 @@ /// Converts arith.remsi to GLSL SPIR-V ops. /// /// This cannot be merged into the template unary/binary pattern due to Vulkan -/// restrictions over spv.SRem and spv.SMod. +/// restrictions over spirv.SRem and spirv.SMod. struct RemSIOpGLPattern final : public OpConversionPattern { using OpConversionPattern::OpConversionPattern; @@ -108,8 +108,8 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Converts arith.uitofp to spv.Select if the type of source is i1 or vector of -/// i1. +/// Converts arith.uitofp to spirv.Select if the type of source is i1 or vector +/// of i1. struct UIToFPI1Pattern final : public OpConversionPattern { using OpConversionPattern::OpConversionPattern; @@ -118,8 +118,8 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Converts arith.extui to spv.Select if the type of source is i1 or vector of -/// i1. +/// Converts arith.extui to spirv.Select if the type of source is i1 or vector +/// of i1. struct ExtUII1Pattern final : public OpConversionPattern { using OpConversionPattern::OpConversionPattern; @@ -128,8 +128,8 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Converts arith.trunci to spv.Select if the type of result is i1 or vector of -/// i1. +/// Converts arith.trunci to spirv.Select if the type of result is i1 or vector +/// of i1. struct TruncII1Pattern final : public OpConversionPattern { using OpConversionPattern::OpConversionPattern; @@ -200,7 +200,7 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Converts arith.addui_carry to spv.IAddCarry. +/// Converts arith.addui_carry to spirv.IAddCarry. class AddICarryOpPattern final : public OpConversionPattern { public: @@ -210,7 +210,7 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Converts arith.select to spv.Select. +/// Converts arith.select to spirv.Select. class SelectOpPattern final : public OpConversionPattern { public: using OpConversionPattern::OpConversionPattern; @@ -219,7 +219,7 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Converts arith.maxf to spv.GL.FMax or spv.CL.fmax. +/// Converts arith.maxf to spirv.GL.FMax or spirv.CL.fmax. template class MinMaxFOpPattern final : public OpConversionPattern { public: @@ -478,8 +478,8 @@ /// /// Note that this is needed for Vulkan. Per the Vulkan's SPIR-V environment /// spec, "for the OpSRem and OpSMod instructions, if either operand is negative -/// the result is undefined." So we cannot directly use spv.SRem/spv.SMod -/// if either operand can be negative. Emulate it via spv.UMod. +/// the result is undefined." So we cannot directly use spirv.SRem/spirv.SMod +/// if either operand can be negative. Emulate it via spirv.UMod. template static Value emulateSignedRemainder(Location loc, Value lhs, Value rhs, Value signOperand, OpBuilder &builder) { @@ -488,7 +488,7 @@ Type type = lhs.getType(); - // Calculate the remainder with spv.UMod. + // Calculate the remainder with spirv.UMod. Value lhsAbs = builder.create(loc, type, lhs); Value rhsAbs = builder.create(loc, type, rhs); Value abs = builder.create(loc, lhsAbs, rhsAbs); @@ -926,10 +926,10 @@ // arith.maxf/minf: // "if one of the arguments is NaN, then the result is also NaN." - // spv.GL.FMax/FMin + // spirv.GL.FMax/FMin // "which operand is the result is undefined if one of the operands // is a NaN." - // spv.CL.fmax/fmin: + // spirv.CL.fmax/fmin: // "If one argument is a NaN, Fmin returns the other argument." Location loc = op.getLoc(); diff --git a/mlir/lib/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRV.cpp b/mlir/lib/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRV.cpp --- a/mlir/lib/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRV.cpp +++ b/mlir/lib/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRV.cpp @@ -31,7 +31,7 @@ namespace { -/// Converts cf.br to spv.Branch. +/// Converts cf.br to spirv.Branch. struct BranchOpPattern final : public OpConversionPattern { using OpConversionPattern::OpConversionPattern; @@ -44,7 +44,7 @@ } }; -/// Converts cf.cond_br to spv.BranchConditional. +/// Converts cf.cond_br to spirv.BranchConditional. struct CondBranchOpPattern final : public OpConversionPattern { using OpConversionPattern::OpConversionPattern; diff --git a/mlir/lib/Conversion/FuncToSPIRV/FuncToSPIRV.cpp b/mlir/lib/Conversion/FuncToSPIRV/FuncToSPIRV.cpp --- a/mlir/lib/Conversion/FuncToSPIRV/FuncToSPIRV.cpp +++ b/mlir/lib/Conversion/FuncToSPIRV/FuncToSPIRV.cpp @@ -35,7 +35,7 @@ namespace { -/// Converts func.return to spv.Return. +/// Converts func.return to spirv.Return. class ReturnOpPattern final : public OpConversionPattern { public: using OpConversionPattern::OpConversionPattern; @@ -56,7 +56,7 @@ } }; -/// Converts func.call to spv.FunctionCall. +/// Converts func.call to spirv.FunctionCall. class CallOpPattern final : public OpConversionPattern { public: using OpConversionPattern::OpConversionPattern; @@ -64,7 +64,7 @@ LogicalResult matchAndRewrite(func::CallOp callOp, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override { - // multiple results func was not converted to spv.func + // multiple results func was not converted to spirv.func if (callOp.getNumResults() > 1) return failure(); if (callOp.getNumResults() == 1) { diff --git a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp --- a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp @@ -53,7 +53,7 @@ /// This is separate because in Vulkan workgroup size is exposed to shaders via /// a constant with WorkgroupSize decoration. So here we cannot generate a -/// builtin variable; instead the information in the `spv.entry_point_abi` +/// builtin variable; instead the information in the `spirv.entry_point_abi` /// attribute on the surrounding FuncOp is used to replace the gpu::BlockDimOp. class WorkGroupSizeConversion : public OpConversionPattern { public: @@ -65,7 +65,7 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Pattern to convert a kernel function in GPU dialect within a spv.module. +/// Pattern to convert a kernel function in GPU dialect within a spirv.module. class GPUFuncOpConversion final : public OpConversionPattern { public: using OpConversionPattern::OpConversionPattern; @@ -78,7 +78,7 @@ SmallVector workGroupSizeAsInt32; }; -/// Pattern to convert a gpu.module to a spv.module. +/// Pattern to convert a gpu.module to a spirv.module. class GPUModuleConversion final : public OpConversionPattern { public: using OpConversionPattern::OpConversionPattern; @@ -112,7 +112,7 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Pattern to convert a gpu.barrier op into a spv.ControlBarrier op. +/// Pattern to convert a gpu.barrier op into a spirv.ControlBarrier op. class GPUBarrierConversion final : public OpConversionPattern { public: using OpConversionPattern::OpConversionPattern; @@ -122,7 +122,7 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Pattern to convert a gpu.shuffle op into a spv.GroupNonUniformShuffle op. +/// Pattern to convert a gpu.shuffle op into a spirv.GroupNonUniformShuffle op. class GPUShuffleConversion final : public OpConversionPattern { public: using OpConversionPattern::OpConversionPattern; @@ -249,8 +249,8 @@ return newFuncOp; } -/// Populates `argABI` with spv.interface_var_abi attributes for lowering -/// gpu.func to spv.func if no arguments have the attributes set +/// Populates `argABI` with spirv.interface_var_abi attributes for lowering +/// gpu.func to spirv.func if no arguments have the attributes set /// already. Returns failure if any argument has the ABI attribute set already. static LogicalResult getDefaultABIAttrs(MLIRContext *context, gpu::GPUFuncOp funcOp, @@ -288,7 +288,7 @@ argIndex, spirv::getInterfaceVarABIAttrName()); if (!abiAttr) { funcOp.emitRemark( - "match failure: missing 'spv.interface_var_abi' attribute at " + "match failure: missing 'spirv.interface_var_abi' attribute at " "argument ") << argIndex; return failure(); @@ -299,7 +299,8 @@ auto entryPointAttr = spirv::lookupEntryPointABI(funcOp); if (!entryPointAttr) { - funcOp.emitRemark("match failure: missing 'spv.entry_point_abi' attribute"); + funcOp.emitRemark( + "match failure: missing 'spirv.entry_point_abi' attribute"); return failure(); } spirv::FuncOp newFuncOp = lowerAsEntryFunction( @@ -323,7 +324,7 @@ FailureOr memoryModel = spirv::getMemoryModel(targetEnv); if (failed(memoryModel)) return moduleOp.emitRemark("match failure: could not selected memory model " - "based on 'spv.target_env'"); + "based on 'spirv.target_env'"); // Add a keyword to the module name to avoid symbolic conflict. std::string spvModuleName = (kSPIRVModule + moduleOp.getName()).str(); @@ -335,7 +336,7 @@ Region &spvModuleRegion = spvModule.getRegion(); rewriter.inlineRegionBefore(moduleOp.getBodyRegion(), spvModuleRegion, spvModuleRegion.begin()); - // The spv.module build method adds a block. Remove that. + // The spirv.module build method adds a block. Remove that. rewriter.eraseBlock(&spvModuleRegion.back()); rewriter.eraseOp(moduleOp); return success(); diff --git a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRVPass.cpp b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRVPass.cpp --- a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRVPass.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRVPass.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// // // This file implements a pass to convert a kernel function in the GPU Dialect -// into a spv.module operation. +// into a spirv.module operation. // //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp --- a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp +++ b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp @@ -140,7 +140,7 @@ SmallVector binary; for (auto spirvModule : module.getOps()) { if (done) - return spirvModule.emitError("should only contain one 'spv.module' op"); + return spirvModule.emitError("should only contain one 'spirv.module' op"); done = true; if (failed(spirv::serialize(spirvModule, binary))) diff --git a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp --- a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp +++ b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp @@ -172,11 +172,11 @@ zeroIndices, loc, rewriter); // Write out the final reduction result. This should be only conducted by one - // invocation. We use spv.GroupNonUniformElect to find the invocation with the - // lowest ID. + // invocation. We use spirv.GroupNonUniformElect to find the invocation with + // the lowest ID. // // ``` - // if (spv.GroupNonUniformElect) { output = ... } + // if (spirv.GroupNonUniformElect) { output = ... } // ``` Value condition = rewriter.create( diff --git a/mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp b/mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp --- a/mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp +++ b/mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp @@ -55,8 +55,8 @@ /// supported. During conversion if a memref of an unsupported type is used, /// load/stores to this memref need to be modified to use a supported higher /// bitwidth `targetBits` and extracting the required bits. For an accessing a -/// 1D array (spv.array or spv.rt_array), the last index is modified to load the -/// bits needed. The extraction of the actual bits needed are handled +/// 1D array (spirv.array or spirv.rt_array), the last index is modified to load +/// the bits needed. The extraction of the actual bits needed are handled /// separately. Note that this only works for a 1-D tensor. static Value adjustAccessChainForBitwidth(SPIRVTypeConverter &typeConverter, spirv::AccessChainOp op, @@ -170,8 +170,8 @@ /// Converts an allocation operation to SPIR-V. Currently only supports lowering /// to Workgroup memory when the size is constant. Note that this pattern needs -/// to be applied in a pass that runs at least at spv.module scope since it wil -/// ladd global variables into the spv.module. +/// to be applied in a pass that runs at least at spirv.module scope since it +/// wil ladd global variables into the spirv.module. class AllocOpPattern final : public OpConversionPattern { public: using OpConversionPattern::OpConversionPattern; @@ -192,7 +192,7 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Converts memref.load to spv.Load + spv.AccessChain on integers. +/// Converts memref.load to spirv.Load + spirv.AccessChain on integers. class IntLoadOpPattern final : public OpConversionPattern { public: using OpConversionPattern::OpConversionPattern; @@ -202,7 +202,7 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Converts memref.load to spv.Load + spv.AccessChain. +/// Converts memref.load to spirv.Load + spirv.AccessChain. class LoadOpPattern final : public OpConversionPattern { public: using OpConversionPattern::OpConversionPattern; @@ -212,7 +212,7 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Converts memref.store to spv.Store on integers. +/// Converts memref.store to spirv.Store on integers. class IntStoreOpPattern final : public OpConversionPattern { public: using OpConversionPattern::OpConversionPattern; @@ -222,7 +222,7 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Converts memref.store to spv.Store. +/// Converts memref.store to spirv.Store. class StoreOpPattern final : public OpConversionPattern { public: using OpConversionPattern::OpConversionPattern; @@ -267,7 +267,7 @@ // Get the SPIR-V type for the allocation. Type spirvType = getTypeConverter()->convertType(allocType); - // Insert spv.GlobalVariable for this allocation. + // Insert spirv.GlobalVariable for this allocation. Operation *parent = SymbolTable::getNearestSymbolTable(operation->getParentOp()); if (!parent) @@ -360,7 +360,7 @@ } // Bitcasting is currently unsupported for Kernel capability / - // spv.PtrAccessChain. + // spirv.PtrAccessChain. if (typeConverter.allows(spirv::Capability::Kernel)) return failure(); @@ -488,7 +488,7 @@ } // Bitcasting is currently unsupported for Kernel capability / - // spv.PtrAccessChain. + // spirv.PtrAccessChain. if (typeConverter.allows(spirv::Capability::Kernel)) return failure(); diff --git a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp --- a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp +++ b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp @@ -26,9 +26,9 @@ namespace mlir { struct ScfToSPIRVContextImpl { - // Map between the spirv region control flow operation (spv.mlir.loop or - // spv.mlir.selection) to the VariableOp created to store the region results. - // The order of the VariableOp matches the order of the results. + // Map between the spirv region control flow operation (spirv.mlir.loop or + // spirv.mlir.selection) to the VariableOp created to store the region + // results. The order of the VariableOp matches the order of the results. DenseMap> outputVars; }; } // namespace mlir @@ -120,9 +120,9 @@ /// Helper function to replaces SCF op outputs with SPIR-V variable loads. /// We create VariableOp to handle the results value of the control flow region. -/// spv.mlir.loop/spv.mlir.selection currently don't yield value. Right after -/// the loop we load the value from the allocation and use it as the SCF op -/// result. +/// spirv.mlir.loop/spirv.mlir.selection currently don't yield value. Right +/// after the loop we load the value from the allocation and use it as the SCF +/// op result. template static void replaceSCFOutputValue(ScfOp scfOp, OpTy newOp, ConversionPatternRewriter &rewriter, @@ -248,7 +248,7 @@ // subsequently converges. auto loc = ifOp.getLoc(); - // Create `spv.selection` operation, selection header block and merge block. + // Create `spirv.selection` operation, selection header block and merge block. auto selectionOp = rewriter.create(loc, spirv::SelectionControl::None); auto *mergeBlock = @@ -277,7 +277,7 @@ rewriter.inlineRegionBefore(elseRegion, mergeBlock); } - // Create a `spv.BranchConditional` operation for selection header block. + // Create a `spirv.BranchConditional` operation for selection header block. rewriter.setInsertionPointToEnd(selectionHeaderBlock); rewriter.create(loc, adaptor.getCondition(), thenBlock, ArrayRef(), diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp @@ -105,7 +105,7 @@ /// Fills `globalVariableMap` with SPIR-V global variables that represent kernel /// arguments from the given SPIR-V module. We assume that the module contains a -/// single entry point function. Hence, all `spv.GlobalVariable`s with a bind +/// single entry point function. Hence, all `spirv.GlobalVariable`s with a bind /// attribute are kernel arguments. static LogicalResult getKernelGlobalVariables( spirv::ModuleOp module, diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp @@ -217,7 +217,7 @@ rewriter.getIntegerAttr(rewriter.getI32Type(), value)); } -/// Utility for `spv.Load` and `spv.Store` conversion. +/// Utility for `spirv.Load` and `spirv.Store` conversion. static LogicalResult replaceWithLoadOrStore(Operation *op, ValueRange operands, ConversionPatternRewriter &rewriter, LLVMTypeConverter &typeConverter, @@ -551,8 +551,8 @@ } }; -/// Converts `spv.getCompositeExtract` to `llvm.extractvalue` if the container type -/// is an aggregate type (struct or array). Otherwise, converts to +/// Converts `spirv.getCompositeExtract` to `llvm.extractvalue` if the container +/// type is an aggregate type (struct or array). Otherwise, converts to /// `llvm.extractelement` that operates on vectors. class CompositeExtractPattern : public SPIRVToLLVMConversion { @@ -582,8 +582,8 @@ } }; -/// Converts `spv.getCompositeInsert` to `llvm.insertvalue` if the container type -/// is an aggregate type (struct or array). Otherwise, converts to +/// Converts `spirv.getCompositeInsert` to `llvm.insertvalue` if the container +/// type is an aggregate type (struct or array). Otherwise, converts to /// `llvm.insertelement` that operates on vectors. class CompositeInsertPattern : public SPIRVToLLVMConversion { @@ -633,7 +633,7 @@ } }; -/// Converts `spv.ExecutionMode` into a global struct constant that holds +/// Converts `spirv.ExecutionMode` into a global struct constant that holds /// execution mode information. class ExecutionModePattern : public SPIRVToLLVMConversion { @@ -708,9 +708,9 @@ } }; -/// Converts `spv.GlobalVariable` to `llvm.mlir.global`. Note that SPIR-V global -/// returns a pointer, whereas in LLVM dialect the global holds an actual value. -/// This difference is handled by `spv.mlir.addressof` and +/// Converts `spirv.GlobalVariable` to `llvm.mlir.global`. Note that SPIR-V +/// global returns a pointer, whereas in LLVM dialect the global holds an actual +/// value. This difference is handled by `spirv.mlir.addressof` and /// `llvm.mlir.addressof`ops that both return a pointer. class GlobalVariablePattern : public SPIRVToLLVMConversion { @@ -887,7 +887,7 @@ } }; -/// Converts `spv.Load` and `spv.Store` to LLVM dialect. +/// Converts `spirv.Load` and `spirv.Store` to LLVM dialect. template class LoadStorePattern : public SPIRVToLLVMConversion { public: @@ -923,7 +923,7 @@ } }; -/// Converts `spv.Not` and `spv.LogicalNot` into LLVM dialect. +/// Converts `spirv.Not` and `spirv.LogicalNot` into LLVM dialect. template class NotPattern : public SPIRVToLLVMConversion { public: @@ -991,12 +991,12 @@ } }; -/// Converts `spv.mlir.loop` to LLVM dialect. All blocks within selection should -/// be reachable for conversion to succeed. The structure of the loop in LLVM -/// dialect will be the following: +/// Converts `spirv.mlir.loop` to LLVM dialect. All blocks within selection +/// should be reachable for conversion to succeed. The structure of the loop in +/// LLVM dialect will be the following: /// /// +------------------------------------+ -/// | | +/// | | /// | llvm.br ^header | /// +------------------------------------+ /// | @@ -1036,7 +1036,7 @@ /// V /// +------------------------------------+ /// | ^remaining: | -/// | | +/// | | /// +------------------------------------+ /// class LoopPattern : public SPIRVToLLVMConversion { @@ -1052,8 +1052,8 @@ Location loc = loopOp.getLoc(); - // Split the current block after `spv.mlir.loop`. The remaining ops will be - // used in `endBlock`. + // Split the current block after `spirv.mlir.loop`. The remaining ops will + // be used in `endBlock`. Block *currentBlock = rewriter.getBlock(); auto position = Block::iterator(loopOp); Block *endBlock = rewriter.splitBlock(currentBlock, position); @@ -1083,7 +1083,7 @@ } }; -/// Converts `spv.mlir.selection` with `spv.BranchConditional` in its header +/// Converts `spirv.mlir.selection` with `spirv.BranchConditional` in its header /// block. All blocks within selection should be reachable for conversion to /// succeed. class SelectionPattern : public SPIRVToLLVMConversion { @@ -1099,7 +1099,7 @@ if (op.getSelectionControl() != spirv::SelectionControl::None) return failure(); - // `spv.mlir.selection` should have at least two blocks: one selection + // `spirv.mlir.selection` should have at least two blocks: one selection // header block and one merge block. If no blocks are present, or control // flow branches straight to merge block (two blocks are present), the op is // redundant and it is erased. @@ -1110,7 +1110,7 @@ Location loc = op.getLoc(); - // Split the current block after `spv.mlir.selection`. The remaining ops + // Split the current block after `spirv.mlir.selection`. The remaining ops // will be used in `continueBlock`. auto *currentBlock = rewriter.getInsertionBlock(); rewriter.setInsertionPointAfter(op); @@ -1118,9 +1118,9 @@ auto *continueBlock = rewriter.splitBlock(currentBlock, position); // Extract conditional branch information from the header block. By SPIR-V - // dialect spec, it should contain `spv.BranchConditional` or `spv.Switch` - // op. Note that `spv.Switch op` is not supported at the moment in the - // SPIR-V dialect. Remove this block when finished. + // dialect spec, it should contain `spirv.BranchConditional` or + // `spirv.Switch` op. Note that `spirv.Switch op` is not supported at the + // moment in the SPIR-V dialect. Remove this block when finished. auto *headerBlock = op.getHeaderBlock(); assert(headerBlock->getOperations().size() == 1); auto condBrOp = dyn_cast( @@ -1211,7 +1211,7 @@ } }; -/// Convert `spv.Tanh` to +/// Convert `spirv.Tanh` to /// /// exp(2x) - 1 /// ----------- diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.cpp @@ -53,7 +53,7 @@ target.addIllegalDialect(); target.addLegalDialect(); - // Set `ModuleOp` as legal for `spv.module` conversion. + // Set `ModuleOp` as legal for `spirv.module` conversion. target.addLegalOp(); if (failed(applyPartialConversion(module, target, std::move(patterns)))) signalPassFailure(); diff --git a/mlir/lib/Conversion/TensorToSPIRV/TensorToSPIRV.cpp b/mlir/lib/Conversion/TensorToSPIRV/TensorToSPIRV.cpp --- a/mlir/lib/Conversion/TensorToSPIRV/TensorToSPIRV.cpp +++ b/mlir/lib/Conversion/TensorToSPIRV/TensorToSPIRV.cpp @@ -68,7 +68,7 @@ spirv::VariableOp varOp; if (adaptor.getTensor().getDefiningOp()) { // We could use the initializer directly; but certain driver compilers - // have bugs dealing with that. So for now, use spv.Store for + // have bugs dealing with that. So for now, use spirv.Store for // initialization. varOp = rewriter.create(loc, varType, spirv::StorageClass::Function, diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp @@ -614,7 +614,7 @@ } static void print(spirv::TargetEnvAttr targetEnv, DialectAsmPrinter &printer) { - printer << spirv::TargetEnvAttr::getKindName() << "<#spv."; + printer << spirv::TargetEnvAttr::getKindName() << "<#spirv."; print(targetEnv.getTripleAttr(), printer); spirv::Vendor vendorID = targetEnv.getVendorID(); spirv::DeviceType deviceType = targetEnv.getDeviceType(); diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp @@ -74,7 +74,7 @@ } // namespace //===----------------------------------------------------------------------===// -// spv.AccessChainOp +// spirv.AccessChainOp //===----------------------------------------------------------------------===// namespace { @@ -113,7 +113,7 @@ } //===----------------------------------------------------------------------===// -// spv.BitcastOp +// spirv.BitcastOp //===----------------------------------------------------------------------===// void spirv::BitcastOp::getCanonicalizationPatterns(RewritePatternSet &results, @@ -122,7 +122,7 @@ } //===----------------------------------------------------------------------===// -// spv.CompositeExtractOp +// spirv.CompositeExtractOp //===----------------------------------------------------------------------===// OpFoldResult spirv::CompositeExtractOp::fold(ArrayRef operands) { @@ -150,20 +150,20 @@ } //===----------------------------------------------------------------------===// -// spv.Constant +// spirv.Constant //===----------------------------------------------------------------------===// OpFoldResult spirv::ConstantOp::fold(ArrayRef operands) { - assert(operands.empty() && "spv.Constant has no operands"); + assert(operands.empty() && "spirv.Constant has no operands"); return getValue(); } //===----------------------------------------------------------------------===// -// spv.IAdd +// spirv.IAdd //===----------------------------------------------------------------------===// OpFoldResult spirv::IAddOp::fold(ArrayRef operands) { - assert(operands.size() == 2 && "spv.IAdd expects two operands"); + assert(operands.size() == 2 && "spirv.IAdd expects two operands"); // x + 0 = x if (matchPattern(getOperand2(), m_Zero())) return getOperand1(); @@ -178,11 +178,11 @@ } //===----------------------------------------------------------------------===// -// spv.IMul +// spirv.IMul //===----------------------------------------------------------------------===// OpFoldResult spirv::IMulOp::fold(ArrayRef operands) { - assert(operands.size() == 2 && "spv.IMul expects two operands"); + assert(operands.size() == 2 && "spirv.IMul expects two operands"); // x * 0 == 0 if (matchPattern(getOperand2(), m_Zero())) return getOperand2(); @@ -200,7 +200,7 @@ } //===----------------------------------------------------------------------===// -// spv.ISub +// spirv.ISub //===----------------------------------------------------------------------===// OpFoldResult spirv::ISubOp::fold(ArrayRef operands) { @@ -218,11 +218,11 @@ } //===----------------------------------------------------------------------===// -// spv.LogicalAnd +// spirv.LogicalAnd //===----------------------------------------------------------------------===// OpFoldResult spirv::LogicalAndOp::fold(ArrayRef operands) { - assert(operands.size() == 2 && "spv.LogicalAnd should take two operands"); + assert(operands.size() == 2 && "spirv.LogicalAnd should take two operands"); if (Optional rhs = getScalarOrSplatBoolAttr(operands.back())) { // x && true = x @@ -238,7 +238,7 @@ } //===----------------------------------------------------------------------===// -// spv.LogicalNot +// spirv.LogicalNot //===----------------------------------------------------------------------===// void spirv::LogicalNotOp::getCanonicalizationPatterns( @@ -250,11 +250,11 @@ } //===----------------------------------------------------------------------===// -// spv.LogicalOr +// spirv.LogicalOr //===----------------------------------------------------------------------===// OpFoldResult spirv::LogicalOrOp::fold(ArrayRef operands) { - assert(operands.size() == 2 && "spv.LogicalOr should take two operands"); + assert(operands.size() == 2 && "spirv.LogicalOr should take two operands"); if (auto rhs = getScalarOrSplatBoolAttr(operands.back())) { if (rhs.value()) @@ -270,16 +270,16 @@ } //===----------------------------------------------------------------------===// -// spv.mlir.selection +// spirv.mlir.selection //===----------------------------------------------------------------------===// namespace { -// Blocks from the given `spv.mlir.selection` operation must satisfy the +// Blocks from the given `spirv.mlir.selection` operation must satisfy the // following layout: // // +-----------------------------------------------+ // | header block | -// | spv.BranchConditionalOp %cond, ^case0, ^case1 | +// | spirv.BranchConditionalOp %cond, ^case0, ^case1 | // +-----------------------------------------------+ // / \ // ... @@ -287,8 +287,8 @@ // // +------------------------+ +------------------------+ // | case #0 | | case #1 | -// | spv.Store %ptr %value0 | | spv.Store %ptr %value1 | -// | spv.Branch ^merge | | spv.Branch ^merge | +// | spirv.Store %ptr %value0 | | spirv.Store %ptr %value1 | +// | spirv.Branch ^merge | | spirv.Branch ^merge | // +------------------------+ +------------------------+ // // @@ -307,7 +307,7 @@ PatternRewriter &rewriter) const override { auto *op = selectionOp.getOperation(); auto &body = op->getRegion(0); - // Verifier allows an empty region for `spv.mlir.selection`. + // Verifier allows an empty region for `spirv.mlir.selection`. if (body.empty()) { return failure(); } @@ -345,7 +345,7 @@ rewriter.create(selectOp.getLoc(), ptrValue, selectOp.getResult(), storeOpAttributes); - // `spv.mlir.selection` is not needed anymore. + // `spirv.mlir.selection` is not needed anymore. rewriter.eraseOp(op); return success(); } @@ -353,8 +353,8 @@ private: // Checks that given blocks follow the following rules: // 1. Each conditional block consists of two operations, the first operation - // is a `spv.Store` and the last operation is a `spv.Branch`. - // 2. Each `spv.Store` uses the same pointer and the same memory attributes. + // is a `spirv.Store` and the last operation is a `spirv.Branch`. + // 2. Each `spirv.Store` uses the same pointer and the same memory attributes. // 3. A control flow goes into the given merge block from the given // conditional blocks. LogicalResult canCanonicalizeSelection(Block *trueBlock, Block *falseBlock, @@ -402,7 +402,7 @@ return failure(); } - // Checks that given type is valid for `spv.SelectOp`. + // Checks that given type is valid for `spirv.SelectOp`. // According to SPIR-V spec: // "Before version 1.4, Result Type must be a pointer, scalar, or vector. // Starting with version 1.4, Result Type can additionally be a composite type @@ -412,7 +412,7 @@ .cast() .isScalarOrVector(); - // Check that each `spv.Store` uses the same pointer, memory access + // Check that each `spirv.Store` uses the same pointer, memory access // attributes and a valid type of the value. if ((trueBrStoreOp.getPtr() != falseBrStoreOp.getPtr()) || !isSameAttrList(trueBrStoreOp, falseBrStoreOp) || !isScalarOrVector) { diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td @@ -14,14 +14,14 @@ include "mlir/Dialect/SPIRV/IR/SPIRVOps.td" //===----------------------------------------------------------------------===// -// spv.Bitcast +// spirv.Bitcast //===----------------------------------------------------------------------===// def ConvertChainedBitcast : Pat<(SPV_BitcastOp (SPV_BitcastOp $operand)), (SPV_BitcastOp $operand)>; //===----------------------------------------------------------------------===// -// spv.LogicalNot +// spirv.LogicalNot //===----------------------------------------------------------------------===// def ConvertLogicalNotOfIEqual : Pat< @@ -41,7 +41,7 @@ (SPV_LogicalEqualOp $lhs, $rhs)>; //===----------------------------------------------------------------------===// -// spv.Select -> spv.GL.*Clamp +// spirv.Select -> spirv.GL.*Clamp //===----------------------------------------------------------------------===// def ValuesAreEqual : Constraint>; diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp @@ -38,7 +38,8 @@ // InlinerInterface //===----------------------------------------------------------------------===// -/// Returns true if the given region contains spv.Return or spv.ReturnValue ops. +/// Returns true if the given region contains spirv.Return or spirv.ReturnValue +/// ops. static inline bool containsReturn(Region ®ion) { return llvm::any_of(region, [](Block &block) { Operation *terminator = block.getTerminator(); @@ -61,8 +62,8 @@ /// 'dest' that is attached to an operation registered to the current dialect. bool isLegalToInline(Region *dest, Region *src, bool wouldBeCloned, BlockAndValueMapping &) const final { - // Return true here when inlining into spv.func, spv.mlir.selection, and - // spv.mlir.loop operations. + // Return true here when inlining into spirv.func, spirv.mlir.selection, and + // spirv.mlir.loop operations. auto *op = dest->getParentOp(); return isa(op); } @@ -90,7 +91,7 @@ OpBuilder(op).create(op->getLoc(), newDest); op->erase(); } else if (auto retValOp = dyn_cast(op)) { - llvm_unreachable("unimplemented spv.ReturnValue in inliner"); + llvm_unreachable("unimplemented spirv.ReturnValue in inliner"); } } @@ -98,14 +99,14 @@ /// as necessary. void handleTerminator(Operation *op, ArrayRef valuesToRepl) const final { - // Only spv.ReturnValue needs to be handled here. + // Only spirv.ReturnValue needs to be handled here. auto retValOp = dyn_cast(op); if (!retValOp) return; // Replace the values directly with the return operands. assert(valuesToRepl.size() == 1 && - "spv.ReturnValue expected to only handle one result"); + "spirv.ReturnValue expected to only handle one result"); valuesToRepl.front().replaceAllUsesWith(retValOp.getValue()); } }; @@ -279,7 +280,7 @@ // | vector-type // | spirv-type // -// array-type ::= `!spv.array` `<` integer-literal `x` element-type +// array-type ::= `!spirv.array` `<` integer-literal `x` element-type // (`,` `stride` `=` integer-literal)? `>` static Type parseArrayType(SPIRVDialect const &dialect, DialectAsmParser &parser) { @@ -317,7 +318,8 @@ return ArrayType::get(elementType, count, stride); } -// cooperative-matrix-type ::= `!spv.coopmatrix` `<` element-type ',' scope ',' +// cooperative-matrix-type ::= `!spirv.coopmatrix` `<` element-type ',' scope +// ',' // rows ',' columns>` static Type parseCooperativeMatrixType(SPIRVDialect const &dialect, DialectAsmParser &parser) { @@ -347,7 +349,8 @@ return CooperativeMatrixNVType::get(elementTy, scope, dims[0], dims[1]); } -// joint-matrix-type ::= `!spv.jointmatrix` `<`rows `x` columns `x` element-type +// joint-matrix-type ::= `!spirv.jointmatrix` `<`rows `x` columns `x` +// element-type // `,` layout `,` scope`>` static Type parseJointMatrixType(SPIRVDialect const &dialect, DialectAsmParser &parser) { @@ -388,7 +391,7 @@ // | `Workgroup` // | // -// pointer-type ::= `!spv.ptr<` element-type `,` storage-class `>` +// pointer-type ::= `!spirv.ptr<` element-type `,` storage-class `>` static Type parsePointerType(SPIRVDialect const &dialect, DialectAsmParser &parser) { if (parser.parseLess()) @@ -414,7 +417,7 @@ return PointerType::get(pointeeType, *storageClass); } -// runtime-array-type ::= `!spv.rtarray` `<` element-type +// runtime-array-type ::= `!spirv.rtarray` `<` element-type // (`,` `stride` `=` integer-literal)? `>` static Type parseRuntimeArrayType(SPIRVDialect const &dialect, DialectAsmParser &parser) { @@ -434,7 +437,7 @@ return RuntimeArrayType::get(elementType, stride); } -// matrix-type ::= `!spv.matrix` `<` integer-literal `x` element-type `>` +// matrix-type ::= `!spirv.matrix` `<` integer-literal `x` element-type `>` static Type parseMatrixType(SPIRVDialect const &dialect, DialectAsmParser &parser) { if (parser.parseLess()) @@ -559,7 +562,7 @@ // // format ::= `Unknown` | `Rgba32f` | // -// image-type ::= `!spv.image<` element-type `,` dim `,` depth-info `,` +// image-type ::= `!spirv.image<` element-type `,` dim `,` depth-info `,` // arrayed-info `,` sampling-info `,` // sampler-use-info `,` format `>` static Type parseImageType(SPIRVDialect const &dialect, @@ -579,7 +582,7 @@ return ImageType::get(*value); } -// sampledImage-type :: = `!spv.sampledImage<` image-type `>` +// sampledImage-type :: = `!spirv.sampledImage<` image-type `>` static Type parseSampledImageType(SPIRVDialect const &dialect, DialectAsmParser &parser) { if (parser.parseLess()) @@ -658,7 +661,7 @@ // struct-member-decoration ::= integer-literal? spirv-decoration* // struct-type ::= -// `!spv.struct<` (id `,`)? +// `!spirv.struct<` (id `,`)? // `(` // (spirv-type (`[` struct-member-decoration `]`)?)* // `)>` diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp @@ -694,7 +694,7 @@ getElementType(Type type, ArrayRef indices, function_ref emitErrorFn) { if (indices.empty()) { - emitErrorFn("expected at least one index for spv.CompositeExtract"); + emitErrorFn("expected at least one index for spirv.CompositeExtract"); return nullptr; } @@ -725,7 +725,7 @@ return nullptr; } if (indicesArrayAttr.empty()) { - emitErrorFn("expected at least one index for spv.CompositeExtract"); + emitErrorFn("expected at least one index for spirv.CompositeExtract"); return nullptr; } @@ -757,7 +757,7 @@ return getElementType(type, indices, errorFn); } -/// Returns true if the given `block` only contains one `spv.mlir.merge` op. +/// Returns true if the given `block` only contains one `spirv.mlir.merge` op. static inline bool isMergeBlock(Block &block) { return !block.empty() && std::next(block.begin()) == block.end() && isa(block.front()); @@ -977,13 +977,13 @@ } //===----------------------------------------------------------------------===// -// spv.AccessChainOp +// spirv.AccessChainOp //===----------------------------------------------------------------------===// static Type getElementPtrType(Type type, ValueRange indices, Location baseLoc) { auto ptrType = type.dyn_cast(); if (!ptrType) { - emitError(baseLoc, "'spv.AccessChain' op expected a pointer " + emitError(baseLoc, "'spirv.AccessChain' op expected a pointer " "to composite type, but provided ") << type; return nullptr; @@ -996,8 +996,9 @@ for (auto indexSSA : indices) { auto cType = resultType.dyn_cast(); if (!cType) { - emitError(baseLoc, - "'spv.AccessChain' op cannot extract from non-composite type ") + emitError( + baseLoc, + "'spirv.AccessChain' op cannot extract from non-composite type ") << resultType << " with index " << index; return nullptr; } @@ -1005,23 +1006,24 @@ if (resultType.isa()) { Operation *op = indexSSA.getDefiningOp(); if (!op) { - emitError(baseLoc, "'spv.AccessChain' op index must be an " - "integer spv.Constant to access " - "element of spv.struct"); + emitError(baseLoc, "'spirv.AccessChain' op index must be an " + "integer spirv.Constant to access " + "element of spirv.struct"); return nullptr; } // TODO: this should be relaxed to allow // integer literals of other bitwidths. if (failed(extractValueFromConstOp(op, index))) { - emitError(baseLoc, - "'spv.AccessChain' index must be an integer spv.Constant to " - "access element of spv.struct, but provided ") + emitError( + baseLoc, + "'spirv.AccessChain' index must be an integer spirv.Constant to " + "access element of spirv.struct, but provided ") << op->getName(); return nullptr; } if (index < 0 || static_cast(index) >= cType.getNumElements()) { - emitError(baseLoc, "'spv.AccessChain' op index ") + emitError(baseLoc, "'spirv.AccessChain' op index ") << index << " out of bounds for " << resultType; return nullptr; } @@ -1056,8 +1058,9 @@ // Check that the provided indices list is not empty before parsing their // type list. if (indicesInfo.empty()) { - return mlir::emitError(result.location, "'spv.AccessChain' op expected at " - "least one index "); + return mlir::emitError(result.location, + "'spirv.AccessChain' op expected at " + "least one index "); } if (parser.parseComma() || parser.parseTypeList(indicesTypes)) @@ -1066,9 +1069,9 @@ // Check that the indices types list is not empty and that it has a one-to-one // mapping to the provided indices. if (indicesTypes.size() != indicesInfo.size()) { - return mlir::emitError(result.location, - "'spv.AccessChain' op indices types' count must be " - "equal to indices info count"); + return mlir::emitError( + result.location, "'spirv.AccessChain' op indices types' count must be " + "equal to indices info count"); } if (parser.resolveOperands(indicesInfo, indicesTypes, loc, result.operands)) @@ -1120,7 +1123,7 @@ } //===----------------------------------------------------------------------===// -// spv.mlir.addressof +// spirv.mlir.addressof //===----------------------------------------------------------------------===// void spirv::AddressOfOp::build(OpBuilder &builder, OperationState &state, @@ -1133,7 +1136,7 @@ SymbolTable::lookupNearestSymbolFrom((*this)->getParentOp(), getVariableAttr())); if (!varOp) { - return emitOpError("expected spv.GlobalVariable symbol"); + return emitOpError("expected spirv.GlobalVariable symbol"); } if (getPointer().getType() != varOp.getType()) { return emitOpError( @@ -1216,7 +1219,7 @@ } //===----------------------------------------------------------------------===// -// spv.AtomicAndOp +// spirv.AtomicAndOp //===----------------------------------------------------------------------===// LogicalResult spirv::AtomicAndOp::verify() { @@ -1232,7 +1235,7 @@ } //===----------------------------------------------------------------------===// -// spv.AtomicCompareExchangeOp +// spirv.AtomicCompareExchangeOp //===----------------------------------------------------------------------===// LogicalResult spirv::AtomicCompareExchangeOp::verify() { @@ -1248,7 +1251,7 @@ } //===----------------------------------------------------------------------===// -// spv.AtomicCompareExchangeWeakOp +// spirv.AtomicCompareExchangeWeakOp //===----------------------------------------------------------------------===// LogicalResult spirv::AtomicCompareExchangeWeakOp::verify() { @@ -1264,7 +1267,7 @@ } //===----------------------------------------------------------------------===// -// spv.AtomicExchange +// spirv.AtomicExchange //===----------------------------------------------------------------------===// void spirv::AtomicExchangeOp::print(OpAsmPrinter &printer) { @@ -1318,7 +1321,7 @@ } //===----------------------------------------------------------------------===// -// spv.AtomicIAddOp +// spirv.AtomicIAddOp //===----------------------------------------------------------------------===// LogicalResult spirv::AtomicIAddOp::verify() { @@ -1334,7 +1337,7 @@ } //===----------------------------------------------------------------------===// -// spv.EXT.AtomicFAddOp +// spirv.EXT.AtomicFAddOp //===----------------------------------------------------------------------===// LogicalResult spirv::EXTAtomicFAddOp::verify() { @@ -1350,7 +1353,7 @@ } //===----------------------------------------------------------------------===// -// spv.AtomicIDecrementOp +// spirv.AtomicIDecrementOp //===----------------------------------------------------------------------===// LogicalResult spirv::AtomicIDecrementOp::verify() { @@ -1366,7 +1369,7 @@ } //===----------------------------------------------------------------------===// -// spv.AtomicIIncrementOp +// spirv.AtomicIIncrementOp //===----------------------------------------------------------------------===// LogicalResult spirv::AtomicIIncrementOp::verify() { @@ -1382,7 +1385,7 @@ } //===----------------------------------------------------------------------===// -// spv.AtomicISubOp +// spirv.AtomicISubOp //===----------------------------------------------------------------------===// LogicalResult spirv::AtomicISubOp::verify() { @@ -1398,7 +1401,7 @@ } //===----------------------------------------------------------------------===// -// spv.AtomicOrOp +// spirv.AtomicOrOp //===----------------------------------------------------------------------===// LogicalResult spirv::AtomicOrOp::verify() { @@ -1414,7 +1417,7 @@ } //===----------------------------------------------------------------------===// -// spv.AtomicSMaxOp +// spirv.AtomicSMaxOp //===----------------------------------------------------------------------===// LogicalResult spirv::AtomicSMaxOp::verify() { @@ -1430,7 +1433,7 @@ } //===----------------------------------------------------------------------===// -// spv.AtomicSMinOp +// spirv.AtomicSMinOp //===----------------------------------------------------------------------===// LogicalResult spirv::AtomicSMinOp::verify() { @@ -1446,7 +1449,7 @@ } //===----------------------------------------------------------------------===// -// spv.AtomicUMaxOp +// spirv.AtomicUMaxOp //===----------------------------------------------------------------------===// LogicalResult spirv::AtomicUMaxOp::verify() { @@ -1462,7 +1465,7 @@ } //===----------------------------------------------------------------------===// -// spv.AtomicUMinOp +// spirv.AtomicUMinOp //===----------------------------------------------------------------------===// LogicalResult spirv::AtomicUMinOp::verify() { @@ -1478,7 +1481,7 @@ } //===----------------------------------------------------------------------===// -// spv.AtomicXorOp +// spirv.AtomicXorOp //===----------------------------------------------------------------------===// LogicalResult spirv::AtomicXorOp::verify() { @@ -1494,7 +1497,7 @@ } //===----------------------------------------------------------------------===// -// spv.BitcastOp +// spirv.BitcastOp //===----------------------------------------------------------------------===// LogicalResult spirv::BitcastOp::verify() { @@ -1526,7 +1529,7 @@ } //===----------------------------------------------------------------------===// -// spv.PtrCastToGenericOp +// spirv.PtrCastToGenericOp //===----------------------------------------------------------------------===// LogicalResult spirv::PtrCastToGenericOp::verify() { @@ -1554,7 +1557,7 @@ } //===----------------------------------------------------------------------===// -// spv.GenericCastToPtrOp +// spirv.GenericCastToPtrOp //===----------------------------------------------------------------------===// LogicalResult spirv::GenericCastToPtrOp::verify() { @@ -1582,7 +1585,7 @@ } //===----------------------------------------------------------------------===// -// spv.GenericCastToPtrExplicitOp +// spirv.GenericCastToPtrExplicitOp //===----------------------------------------------------------------------===// LogicalResult spirv::GenericCastToPtrExplicitOp::verify() { @@ -1610,7 +1613,7 @@ } //===----------------------------------------------------------------------===// -// spv.BranchOp +// spirv.BranchOp //===----------------------------------------------------------------------===// SuccessorOperands spirv::BranchOp::getSuccessorOperands(unsigned index) { @@ -1619,7 +1622,7 @@ } //===----------------------------------------------------------------------===// -// spv.BranchConditionalOp +// spirv.BranchConditionalOp //===----------------------------------------------------------------------===// SuccessorOperands @@ -1713,7 +1716,7 @@ } //===----------------------------------------------------------------------===// -// spv.CompositeConstruct +// spirv.CompositeConstruct //===----------------------------------------------------------------------===// LogicalResult spirv::CompositeConstructOp::verify() { @@ -1789,7 +1792,7 @@ } //===----------------------------------------------------------------------===// -// spv.CompositeExtractOp +// spirv.CompositeExtractOp //===----------------------------------------------------------------------===// void spirv::CompositeExtractOp::build(OpBuilder &builder, OperationState &state, @@ -1849,7 +1852,7 @@ } //===----------------------------------------------------------------------===// -// spv.CompositeInsert +// spirv.CompositeInsert //===----------------------------------------------------------------------===// void spirv::CompositeInsertOp::build(OpBuilder &builder, OperationState &state, @@ -1904,7 +1907,7 @@ } //===----------------------------------------------------------------------===// -// spv.Constant +// spirv.Constant //===----------------------------------------------------------------------===// ParseResult spirv::ConstantOp::parse(OpAsmParser &parser, @@ -1948,7 +1951,7 @@ if (!arrayType) return op.emitOpError("result or element type (") << opType << ") does not match value type (" << valueType - << "), must be the same or spv.array"; + << "), must be the same or spirv.array"; int numElements = arrayType.getNumElements(); auto opElemType = arrayType.getElementType(); @@ -1976,7 +1979,8 @@ if (auto arrayAttr = value.dyn_cast()) { auto arrayType = opType.dyn_cast(); if (!arrayType) - return op.emitOpError("must have spv.array result type for array value"); + return op.emitOpError( + "must have spirv.array result type for array value"); Type elemType = arrayType.getElementType(); for (Attribute element : arrayAttr.getValue()) { // Verify array elements recursively. @@ -2123,7 +2127,7 @@ } //===----------------------------------------------------------------------===// -// spv.ControlBarrierOp +// spirv.ControlBarrierOp //===----------------------------------------------------------------------===// LogicalResult spirv::ControlBarrierOp::verify() { @@ -2131,7 +2135,7 @@ } //===----------------------------------------------------------------------===// -// spv.ConvertFToSOp +// spirv.ConvertFToSOp //===----------------------------------------------------------------------===// LogicalResult spirv::ConvertFToSOp::verify() { @@ -2140,7 +2144,7 @@ } //===----------------------------------------------------------------------===// -// spv.ConvertFToUOp +// spirv.ConvertFToUOp //===----------------------------------------------------------------------===// LogicalResult spirv::ConvertFToUOp::verify() { @@ -2149,7 +2153,7 @@ } //===----------------------------------------------------------------------===// -// spv.ConvertSToFOp +// spirv.ConvertSToFOp //===----------------------------------------------------------------------===// LogicalResult spirv::ConvertSToFOp::verify() { @@ -2158,7 +2162,7 @@ } //===----------------------------------------------------------------------===// -// spv.ConvertUToFOp +// spirv.ConvertUToFOp //===----------------------------------------------------------------------===// LogicalResult spirv::ConvertUToFOp::verify() { @@ -2167,7 +2171,7 @@ } //===----------------------------------------------------------------------===// -// spv.EntryPoint +// spirv.EntryPoint //===----------------------------------------------------------------------===// void spirv::EntryPointOp::build(OpBuilder &builder, OperationState &state, @@ -2227,7 +2231,7 @@ } //===----------------------------------------------------------------------===// -// spv.ExecutionMode +// spirv.ExecutionMode //===----------------------------------------------------------------------===// void spirv::ExecutionModeOp::build(OpBuilder &builder, OperationState &state, @@ -2277,7 +2281,7 @@ } //===----------------------------------------------------------------------===// -// spv.FConvertOp +// spirv.FConvertOp //===----------------------------------------------------------------------===// LogicalResult spirv::FConvertOp::verify() { @@ -2285,7 +2289,7 @@ } //===----------------------------------------------------------------------===// -// spv.SConvertOp +// spirv.SConvertOp //===----------------------------------------------------------------------===// LogicalResult spirv::SConvertOp::verify() { @@ -2293,7 +2297,7 @@ } //===----------------------------------------------------------------------===// -// spv.UConvertOp +// spirv.UConvertOp //===----------------------------------------------------------------------===// LogicalResult spirv::UConvertOp::verify() { @@ -2301,7 +2305,7 @@ } //===----------------------------------------------------------------------===// -// spv.func +// spirv.func //===----------------------------------------------------------------------===// ParseResult spirv::FuncOp::parse(OpAsmParser &parser, OperationState &result) { @@ -2436,7 +2440,7 @@ } //===----------------------------------------------------------------------===// -// spv.FunctionCall +// spirv.FunctionCall //===----------------------------------------------------------------------===// LogicalResult spirv::FunctionCallOp::verify() { @@ -2497,7 +2501,7 @@ } //===----------------------------------------------------------------------===// -// spv.GLFClampOp +// spirv.GLFClampOp //===----------------------------------------------------------------------===// ParseResult spirv::GLFClampOp::parse(OpAsmParser &parser, @@ -2507,7 +2511,7 @@ void spirv::GLFClampOp::print(OpAsmPrinter &p) { printOneResultOp(*this, p); } //===----------------------------------------------------------------------===// -// spv.GLUClampOp +// spirv.GLUClampOp //===----------------------------------------------------------------------===// ParseResult spirv::GLUClampOp::parse(OpAsmParser &parser, @@ -2517,7 +2521,7 @@ void spirv::GLUClampOp::print(OpAsmPrinter &p) { printOneResultOp(*this, p); } //===----------------------------------------------------------------------===// -// spv.GLSClampOp +// spirv.GLSClampOp //===----------------------------------------------------------------------===// ParseResult spirv::GLSClampOp::parse(OpAsmParser &parser, @@ -2527,7 +2531,7 @@ void spirv::GLSClampOp::print(OpAsmPrinter &p) { printOneResultOp(*this, p); } //===----------------------------------------------------------------------===// -// spv.GLFmaOp +// spirv.GLFmaOp //===----------------------------------------------------------------------===// ParseResult spirv::GLFmaOp::parse(OpAsmParser &parser, OperationState &result) { @@ -2536,7 +2540,7 @@ void spirv::GLFmaOp::print(OpAsmPrinter &p) { printOneResultOp(*this, p); } //===----------------------------------------------------------------------===// -// spv.GlobalVariable +// spirv.GlobalVariable //===----------------------------------------------------------------------===// void spirv::GlobalVariableOp::build(OpBuilder &builder, OperationState &state, @@ -2589,7 +2593,7 @@ return failure(); } if (!type.isa()) { - return parser.emitError(loc, "expected spv.ptr type"); + return parser.emitError(loc, "expected spirv.ptr type"); } result.addAttribute(kTypeAttrName, TypeAttr::get(type)); @@ -2622,7 +2626,7 @@ // SPIR-V spec: "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 Result Type." - // Also, Function storage class is reserved by spv.Variable. + // Also, Function storage class is reserved by spirv.Variable. auto storageClass = this->storageClass(); if (storageClass == spirv::StorageClass::Generic || storageClass == spirv::StorageClass::Function) { @@ -2640,7 +2644,7 @@ if (!initOp || !isa(initOp)) { return emitOpError("initializer must be result of a " - "spv.SpecConstant or spv.GlobalVariable op"); + "spirv.SpecConstant or spirv.GlobalVariable op"); } } @@ -2648,7 +2652,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupBroadcast +// spirv.GroupBroadcast //===----------------------------------------------------------------------===// LogicalResult spirv::GroupBroadcastOp::verify() { @@ -2666,7 +2670,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformBallotOp +// spirv.GroupNonUniformBallotOp //===----------------------------------------------------------------------===// LogicalResult spirv::GroupNonUniformBallotOp::verify() { @@ -2678,7 +2682,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformBroadcast +// spirv.GroupNonUniformBroadcast //===----------------------------------------------------------------------===// LogicalResult spirv::GroupNonUniformBroadcastOp::verify() { @@ -2703,7 +2707,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformShuffle* +// spirv.GroupNonUniformShuffle* //===----------------------------------------------------------------------===// template @@ -2732,7 +2736,7 @@ } //===----------------------------------------------------------------------===// -// spv.INTEL.SubgroupBlockRead +// spirv.INTEL.SubgroupBlockRead //===----------------------------------------------------------------------===// ParseResult spirv::INTELSubgroupBlockReadOp::parse(OpAsmParser &parser, @@ -2770,7 +2774,7 @@ } //===----------------------------------------------------------------------===// -// spv.INTEL.SubgroupBlockWrite +// spirv.INTEL.SubgroupBlockWrite //===----------------------------------------------------------------------===// ParseResult spirv::INTELSubgroupBlockWriteOp::parse(OpAsmParser &parser, @@ -2810,7 +2814,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformElectOp +// spirv.GroupNonUniformElectOp //===----------------------------------------------------------------------===// LogicalResult spirv::GroupNonUniformElectOp::verify() { @@ -2822,7 +2826,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformFAddOp +// spirv.GroupNonUniformFAddOp //===----------------------------------------------------------------------===// LogicalResult spirv::GroupNonUniformFAddOp::verify() { @@ -2838,7 +2842,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformFMaxOp +// spirv.GroupNonUniformFMaxOp //===----------------------------------------------------------------------===// LogicalResult spirv::GroupNonUniformFMaxOp::verify() { @@ -2854,7 +2858,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformFMinOp +// spirv.GroupNonUniformFMinOp //===----------------------------------------------------------------------===// LogicalResult spirv::GroupNonUniformFMinOp::verify() { @@ -2870,7 +2874,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformFMulOp +// spirv.GroupNonUniformFMulOp //===----------------------------------------------------------------------===// LogicalResult spirv::GroupNonUniformFMulOp::verify() { @@ -2886,7 +2890,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformIAddOp +// spirv.GroupNonUniformIAddOp //===----------------------------------------------------------------------===// LogicalResult spirv::GroupNonUniformIAddOp::verify() { @@ -2902,7 +2906,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformIMulOp +// spirv.GroupNonUniformIMulOp //===----------------------------------------------------------------------===// LogicalResult spirv::GroupNonUniformIMulOp::verify() { @@ -2918,7 +2922,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformSMaxOp +// spirv.GroupNonUniformSMaxOp //===----------------------------------------------------------------------===// LogicalResult spirv::GroupNonUniformSMaxOp::verify() { @@ -2934,7 +2938,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformSMinOp +// spirv.GroupNonUniformSMinOp //===----------------------------------------------------------------------===// LogicalResult spirv::GroupNonUniformSMinOp::verify() { @@ -2950,7 +2954,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformUMaxOp +// spirv.GroupNonUniformUMaxOp //===----------------------------------------------------------------------===// LogicalResult spirv::GroupNonUniformUMaxOp::verify() { @@ -2966,7 +2970,7 @@ } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformUMinOp +// spirv.GroupNonUniformUMinOp //===----------------------------------------------------------------------===// LogicalResult spirv::GroupNonUniformUMinOp::verify() { @@ -2982,7 +2986,7 @@ } //===----------------------------------------------------------------------===// -// spv.IAddCarryOp +// spirv.IAddCarryOp //===----------------------------------------------------------------------===// LogicalResult spirv::IAddCarryOp::verify() { @@ -3013,7 +3017,7 @@ auto structType = resultType.dyn_cast(); if (!structType || structType.getNumElements() != 2) - return parser.emitError(loc, "expected spv.struct type with two members"); + return parser.emitError(loc, "expected spirv.struct type with two members"); SmallVector operandTypes(2, structType.getElementType(0)); if (parser.resolveOperands(operands, operandTypes, loc, result.operands)) @@ -3031,7 +3035,7 @@ } //===----------------------------------------------------------------------===// -// spv.ISubBorrowOp +// spirv.ISubBorrowOp //===----------------------------------------------------------------------===// LogicalResult spirv::ISubBorrowOp::verify() { @@ -3062,7 +3066,7 @@ auto structType = resultType.dyn_cast(); if (!structType || structType.getNumElements() != 2) - return parser.emitError(loc, "expected spv.struct type with two members"); + return parser.emitError(loc, "expected spirv.struct type with two members"); SmallVector operandTypes(2, structType.getElementType(0)); if (parser.resolveOperands(operands, operandTypes, loc, result.operands)) @@ -3080,7 +3084,7 @@ } //===----------------------------------------------------------------------===// -// spv.LoadOp +// spirv.LoadOp //===----------------------------------------------------------------------===// void spirv::LoadOp::build(OpBuilder &builder, OperationState &state, @@ -3135,7 +3139,7 @@ } //===----------------------------------------------------------------------===// -// spv.mlir.loop +// spirv.mlir.loop //===----------------------------------------------------------------------===// void spirv::LoopOp::build(OpBuilder &builder, OperationState &state) { @@ -3160,7 +3164,7 @@ /*printBlockTerminators=*/true); } -/// Returns true if the given `srcBlock` contains only one `spv.Branch` to the +/// Returns true if the given `srcBlock` contains only one `spirv.Branch` to the /// given `dstBlock`. static inline bool hasOneBranchOpTo(Block &srcBlock, Block &dstBlock) { // Check that there is only one op in the `srcBlock`. @@ -3208,8 +3212,8 @@ // The last block is the merge block. Block &merge = region.back(); if (!isMergeBlock(merge)) - return emitOpError( - "last block must be the merge block with only one 'spv.mlir.merge' op"); + return emitOpError("last block must be the merge block with only one " + "'spirv.mlir.merge' op"); if (std::next(region.begin()) == region.end()) return emitOpError( @@ -3225,7 +3229,7 @@ if (!hasOneBranchOpTo(entry, header)) return emitOpError( - "entry block must only have one 'spv.Branch' op to the second block"); + "entry block must only have one 'spirv.Branch' op to the second block"); if (std::next(region.begin(), 3) == region.end()) return emitOpError( @@ -3286,12 +3290,12 @@ getBody().push_back(mergeBlock); OpBuilder builder = OpBuilder::atBlockEnd(mergeBlock); - // Add a spv.mlir.merge op into the merge block. + // Add a spirv.mlir.merge op into the merge block. builder.create(getLoc()); } //===----------------------------------------------------------------------===// -// spv.MemoryBarrierOp +// spirv.MemoryBarrierOp //===----------------------------------------------------------------------===// LogicalResult spirv::MemoryBarrierOp::verify() { @@ -3299,25 +3303,25 @@ } //===----------------------------------------------------------------------===// -// spv.mlir.merge +// spirv.mlir.merge //===----------------------------------------------------------------------===// LogicalResult spirv::MergeOp::verify() { auto *parentOp = (*this)->getParentOp(); if (!parentOp || !isa(parentOp)) return emitOpError( - "expected parent op to be 'spv.mlir.selection' or 'spv.mlir.loop'"); + "expected parent op to be 'spirv.mlir.selection' or 'spirv.mlir.loop'"); // TODO: This check should be done in `verifyRegions` of parent op. Block &parentLastBlock = (*this)->getParentRegion()->back(); if (getOperation() != parentLastBlock.getTerminator()) return emitOpError("can only be used in the last block of " - "'spv.mlir.selection' or 'spv.mlir.loop'"); + "'spirv.mlir.selection' or 'spirv.mlir.loop'"); return success(); } //===----------------------------------------------------------------------===// -// spv.module +// spirv.module //===----------------------------------------------------------------------===// void spirv::ModuleOp::build(OpBuilder &builder, OperationState &state, @@ -3419,7 +3423,7 @@ for (auto &op : *getBody()) { if (op.getDialect() != dialect) - return op.emitError("'spv.module' can only contain spv.* ops"); + return op.emitError("'spirv.module' can only contain spirv.* ops"); // For EntryPoint op, check that the function and execution model is not // duplicated in EntryPointOps. Also verify that the interface specified @@ -3428,7 +3432,7 @@ auto funcOp = table.lookup(entryPointOp.getFn()); if (!funcOp) { return entryPointOp.emitError("function '") - << entryPointOp.getFn() << "' not found in 'spv.module'"; + << entryPointOp.getFn() << "' not found in 'spirv.module'"; } if (auto interface = entryPointOp.getInterface()) { for (Attribute varRef : interface) { @@ -3442,7 +3446,7 @@ auto variableOp = table.lookup(varSymRef.getValue()); if (!variableOp) { - return entryPointOp.emitError("expected spv.GlobalVariable " + return entryPointOp.emitError("expected spirv.GlobalVariable " "symbol reference instead of'") << varSymRef << "'"; } @@ -3458,14 +3462,14 @@ entryPoints[key] = entryPointOp; } else if (auto funcOp = dyn_cast(op)) { if (funcOp.isExternal()) - return op.emitError("'spv.module' cannot contain external functions"); + return op.emitError("'spirv.module' cannot contain external functions"); - // TODO: move this check to spv.func. + // TODO: move this check to spirv.func. for (auto &block : funcOp) for (auto &op : block) { if (op.getDialect() != dialect) return op.emitError( - "functions in 'spv.module' can only contain spv.* ops"); + "functions in 'spirv.module' can only contain spirv.* ops"); } } } @@ -3474,7 +3478,7 @@ } //===----------------------------------------------------------------------===// -// spv.mlir.referenceof +// spirv.mlir.referenceof //===----------------------------------------------------------------------===// LogicalResult spirv::ReferenceOfOp::verify() { @@ -3493,7 +3497,7 @@ if (!specConstOp && !specConstCompositeOp) return emitOpError( - "expected spv.SpecConstant or spv.SpecConstantComposite symbol"); + "expected spirv.SpecConstant or spirv.SpecConstantComposite symbol"); if (getReference().getType() != constType) return emitOpError("result type mismatch with the referenced " @@ -3503,25 +3507,25 @@ } //===----------------------------------------------------------------------===// -// spv.Return +// spirv.Return //===----------------------------------------------------------------------===// LogicalResult spirv::ReturnOp::verify() { - // Verification is performed in spv.func op. + // Verification is performed in spirv.func op. return success(); } //===----------------------------------------------------------------------===// -// spv.ReturnValue +// spirv.ReturnValue //===----------------------------------------------------------------------===// LogicalResult spirv::ReturnValueOp::verify() { - // Verification is performed in spv.func op. + // Verification is performed in spirv.func op. return success(); } //===----------------------------------------------------------------------===// -// spv.Select +// spirv.Select //===----------------------------------------------------------------------===// LogicalResult spirv::SelectOp::verify() { @@ -3540,7 +3544,7 @@ } //===----------------------------------------------------------------------===// -// spv.mlir.selection +// spirv.mlir.selection //===----------------------------------------------------------------------===// ParseResult spirv::SelectionOp::parse(OpAsmParser &parser, @@ -3592,8 +3596,8 @@ // The last block is the merge block. if (!isMergeBlock(region.back())) - return emitOpError( - "last block must be the merge block with only one 'spv.mlir.merge' op"); + return emitOpError("last block must be the merge block with only one " + "'spirv.mlir.merge' op"); if (std::next(region.begin()) == region.end()) return emitOpError("must have a selection header block"); @@ -3619,7 +3623,7 @@ getBody().push_back(mergeBlock); OpBuilder builder = OpBuilder::atBlockEnd(mergeBlock); - // Add a spv.mlir.merge op into the merge block. + // Add a spirv.mlir.merge op into the merge block. builder.create(getLoc()); } @@ -3655,7 +3659,7 @@ } //===----------------------------------------------------------------------===// -// spv.SpecConstant +// spirv.SpecConstant //===----------------------------------------------------------------------===// ParseResult spirv::SpecConstantOp::parse(OpAsmParser &parser, @@ -3709,7 +3713,7 @@ } //===----------------------------------------------------------------------===// -// spv.StoreOp +// spirv.StoreOp //===----------------------------------------------------------------------===// ParseResult spirv::StoreOp::parse(OpAsmParser &parser, OperationState &result) { @@ -3754,7 +3758,7 @@ } //===----------------------------------------------------------------------===// -// spv.Unreachable +// spirv.Unreachable //===----------------------------------------------------------------------===// LogicalResult spirv::UnreachableOp::verify() { @@ -3773,7 +3777,7 @@ } //===----------------------------------------------------------------------===// -// spv.Variable +// spirv.Variable //===----------------------------------------------------------------------===// ParseResult spirv::VariableOp::parse(OpAsmParser &parser, @@ -3801,7 +3805,7 @@ auto ptrType = type.dyn_cast(); if (!ptrType) - return parser.emitError(loc, "expected spv.ptr type"); + return parser.emitError(loc, "expected spirv.ptr type"); result.addTypes(ptrType); // Resolve the initializer operand @@ -3836,7 +3840,7 @@ if (getStorageClass() != spirv::StorageClass::Function) { return emitOpError( "can only be used to model function-level variables. Use " - "spv.GlobalVariable for module-level variables."); + "spirv.GlobalVariable for module-level variables."); } auto pointerType = getPointer().getType().cast(); @@ -3852,7 +3856,7 @@ spirv::ReferenceOfOp, // for spec constant spirv::AddressOfOp>(initOp)) return emitOpError("initializer must be the result of a " - "constant or spv.GlobalVariable op"); + "constant or spirv.GlobalVariable op"); } // TODO: generate these strings using ODS. @@ -3867,14 +3871,14 @@ for (const auto &attr : {descriptorSetName, bindingName, builtInName}) { if (op->getAttr(attr)) return emitOpError("cannot have '") - << attr << "' attribute (only allowed in spv.GlobalVariable)"; + << attr << "' attribute (only allowed in spirv.GlobalVariable)"; } return success(); } //===----------------------------------------------------------------------===// -// spv.VectorShuffle +// spirv.VectorShuffle //===----------------------------------------------------------------------===// LogicalResult spirv::VectorShuffleOp::verify() { @@ -3903,7 +3907,7 @@ } //===----------------------------------------------------------------------===// -// spv.NV.CooperativeMatrixLoad +// spirv.NV.CooperativeMatrixLoad //===----------------------------------------------------------------------===// ParseResult spirv::NVCooperativeMatrixLoadOp::parse(OpAsmParser &parser, @@ -3962,7 +3966,7 @@ } //===----------------------------------------------------------------------===// -// spv.NV.CooperativeMatrixStore +// spirv.NV.CooperativeMatrixStore //===----------------------------------------------------------------------===// ParseResult spirv::NVCooperativeMatrixStoreOp::parse(OpAsmParser &parser, @@ -4002,7 +4006,7 @@ } //===----------------------------------------------------------------------===// -// spv.NV.CooperativeMatrixMulAdd +// spirv.NV.CooperativeMatrixMulAdd //===----------------------------------------------------------------------===// static LogicalResult @@ -4051,7 +4055,7 @@ } //===----------------------------------------------------------------------===// -// spv.INTEL.JointMatrixLoad +// spirv.INTEL.JointMatrixLoad //===----------------------------------------------------------------------===// LogicalResult spirv::INTELJointMatrixLoadOp::verify() { @@ -4060,7 +4064,7 @@ } //===----------------------------------------------------------------------===// -// spv.INTEL.JointMatrixStore +// spirv.INTEL.JointMatrixStore //===----------------------------------------------------------------------===// LogicalResult spirv::INTELJointMatrixStoreOp::verify() { @@ -4069,7 +4073,7 @@ } //===----------------------------------------------------------------------===// -// spv.INTEL.JointMatrixMad +// spirv.INTEL.JointMatrixMad //===----------------------------------------------------------------------===// static LogicalResult verifyJointMatrixMad(spirv::INTELJointMatrixMadOp op) { @@ -4098,7 +4102,7 @@ } //===----------------------------------------------------------------------===// -// spv.MatrixTimesScalar +// spirv.MatrixTimesScalar //===----------------------------------------------------------------------===// LogicalResult spirv::MatrixTimesScalarOp::verify() { @@ -4135,7 +4139,7 @@ } //===----------------------------------------------------------------------===// -// spv.CopyMemory +// spirv.CopyMemory //===----------------------------------------------------------------------===// void spirv::CopyMemoryOp::print(OpAsmPrinter &printer) { @@ -4229,7 +4233,7 @@ } //===----------------------------------------------------------------------===// -// spv.Transpose +// spirv.Transpose //===----------------------------------------------------------------------===// LogicalResult spirv::TransposeOp::verify() { @@ -4254,7 +4258,7 @@ } //===----------------------------------------------------------------------===// -// spv.MatrixTimesMatrix +// spirv.MatrixTimesMatrix //===----------------------------------------------------------------------===// LogicalResult spirv::MatrixTimesMatrixOp::verify() { @@ -4290,7 +4294,7 @@ } //===----------------------------------------------------------------------===// -// spv.SpecConstantComposite +// spirv.SpecConstantComposite //===----------------------------------------------------------------------===// ParseResult spirv::SpecConstantCompositeOp::parse(OpAsmParser &parser, @@ -4380,7 +4384,7 @@ } //===----------------------------------------------------------------------===// -// spv.SpecConstantOperation +// spirv.SpecConstantOperation //===----------------------------------------------------------------------===// ParseResult spirv::SpecConstantOperationOp::parse(OpAsmParser &parser, @@ -4436,7 +4440,7 @@ } //===----------------------------------------------------------------------===// -// spv.GL.FrexpStruct +// spirv.GL.FrexpStruct //===----------------------------------------------------------------------===// LogicalResult spirv::GLFrexpStructOp::verify() { @@ -4483,7 +4487,7 @@ } //===----------------------------------------------------------------------===// -// spv.GL.Ldexp +// spirv.GL.Ldexp //===----------------------------------------------------------------------===// LogicalResult spirv::GLLdexpOp::verify() { @@ -4506,7 +4510,7 @@ } //===----------------------------------------------------------------------===// -// spv.ImageDrefGather +// spirv.ImageDrefGather //===----------------------------------------------------------------------===// LogicalResult spirv::ImageDrefGatherOp::verify() { @@ -4544,7 +4548,7 @@ } //===----------------------------------------------------------------------===// -// spv.ShiftLeftLogicalOp +// spirv.ShiftLeftLogicalOp //===----------------------------------------------------------------------===// LogicalResult spirv::ShiftLeftLogicalOp::verify() { @@ -4552,7 +4556,7 @@ } //===----------------------------------------------------------------------===// -// spv.ShiftRightArithmeticOp +// spirv.ShiftRightArithmeticOp //===----------------------------------------------------------------------===// LogicalResult spirv::ShiftRightArithmeticOp::verify() { @@ -4560,7 +4564,7 @@ } //===----------------------------------------------------------------------===// -// spv.ShiftRightLogicalOp +// spirv.ShiftRightLogicalOp //===----------------------------------------------------------------------===// LogicalResult spirv::ShiftRightLogicalOp::verify() { @@ -4568,7 +4572,7 @@ } //===----------------------------------------------------------------------===// -// spv.ImageQuerySize +// spirv.ImageQuerySize //===----------------------------------------------------------------------===// LogicalResult spirv::ImageQuerySizeOp::verify() { @@ -4682,7 +4686,7 @@ } //===----------------------------------------------------------------------===// -// spv.InBoundsPtrAccessChainOp +// spirv.InBoundsPtrAccessChainOp //===----------------------------------------------------------------------===// void spirv::InBoundsPtrAccessChainOp::build(OpBuilder &builder, @@ -4709,7 +4713,7 @@ } //===----------------------------------------------------------------------===// -// spv.PtrAccessChainOp +// spirv.PtrAccessChainOp //===----------------------------------------------------------------------===// void spirv::PtrAccessChainOp::build(OpBuilder &builder, OperationState &state, @@ -4735,7 +4739,7 @@ } //===----------------------------------------------------------------------===// -// spv.VectorTimesScalarOp +// spirv.VectorTimesScalarOp //===----------------------------------------------------------------------===// LogicalResult spirv::VectorTimesScalarOp::verify() { diff --git a/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp b/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp --- a/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp @@ -95,7 +95,7 @@ //===----------------------------------------------------------------------===// StringRef spirv::getInterfaceVarABIAttrName() { - return "spv.interface_var_abi"; + return "spirv.interface_var_abi"; } spirv::InterfaceVarABIAttr @@ -116,7 +116,7 @@ return false; } -StringRef spirv::getEntryPointABIAttrName() { return "spv.entry_point_abi"; } +StringRef spirv::getEntryPointABIAttrName() { return "spirv.entry_point_abi"; } spirv::EntryPointABIAttr spirv::getEntryPointABIAttr(ArrayRef localSize, MLIRContext *context) { @@ -164,7 +164,7 @@ /*cooperative_matrix_properties_nv=*/ArrayAttr()); } -StringRef spirv::getTargetEnvAttrName() { return "spv.target_env"; } +StringRef spirv::getTargetEnvAttrName() { return "spirv.target_env"; } spirv::TargetEnvAttr spirv::getDefaultTargetEnv(MLIRContext *context) { auto triple = spirv::VerCapExtAttr::get(spirv::Version::V_1_0, diff --git a/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp b/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp --- a/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp +++ b/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp @@ -130,9 +130,9 @@ // In the combined module, rename all symbols that conflict with symbols // from the current input module. This renaming applies to all ops except - // for spv.funcs. This way, if the conflicting op in the input module is - // non-spv.func, we rename that symbol instead and maintain the spv.func in - // the combined module name as it is. + // for spirv.funcs. This way, if the conflicting op in the input module is + // non-spirv.func, we rename that symbol instead and maintain the spirv.func + // in the combined module name as it is. for (auto &op : *combinedModule.getBody()) { auto symbolOp = dyn_cast(op); if (!symbolOp) @@ -169,7 +169,7 @@ } // In the current input module, rename all symbols that conflict with - // symbols from the combined module. This includes renaming spv.funcs. + // symbols from the combined module. This includes renaming spirv.funcs. for (auto &op : *moduleClone->getBody()) { auto symbolOp = dyn_cast(op); if (!symbolOp) diff --git a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp @@ -44,8 +44,8 @@ funcOp.getName().str() + "_arg_" + std::to_string(argIndex); // Get the type of variable. If this is a scalar/vector type and has an ABI - // info create a variable of type !spv.ptr>. If not - // it must already be a !spv.ptr>. + // info create a variable of type !spirv.ptr>. If + // not it must already be a !spirv.ptr>. auto varType = funcOp.getFunctionType().getInput(argIndex); if (varType.cast().isScalarOrVector()) { auto storageClass = abiInfo.getStorageClass(); @@ -73,7 +73,7 @@ } /// Gets the global variables that need to be specified as interface variable -/// with an spv.EntryPointOp. Traverses the body of a entry function to do so. +/// with an spirv.EntryPointOp. Traverses the body of a entry function to do so. static LogicalResult getInterfaceVariables(spirv::FuncOp funcOp, SmallVectorImpl &interfaceVars) { @@ -124,7 +124,7 @@ auto spirvModule = funcOp->getParentOfType(); builder.setInsertionPointToEnd(spirvModule.getBody()); - // Adds the spv.EntryPointOp after collecting all the interface variables + // Adds the spirv.EntryPointOp after collecting all the interface variables // needed. SmallVector interfaceVars; if (failed(getInterfaceVariables(funcOp, interfaceVars))) { @@ -136,12 +136,12 @@ spirv::getExecutionModel(targetEnv); if (failed(executionModel)) return funcOp.emitRemark("lower entry point failure: could not select " - "execution model based on 'spv.target_env'"); + "execution model based on 'spirv.target_env'"); builder.create(funcOp.getLoc(), executionModel.value(), funcOp, interfaceVars); - // Specifies the spv.ExecutionModeOp. + // Specifies the spirv.ExecutionModeOp. auto localSizeAttr = entryPointAttr.getLocalSize(); if (localSizeAttr) { auto values = localSizeAttr.getValues(); diff --git a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp @@ -510,7 +510,7 @@ return failure(); } - // Create the converted spv.func op. + // Create the converted spirv.func op. auto newFuncOp = rewriter.create( funcOp.getLoc(), funcOp.getName(), rewriter.getFunctionType(signatureConverter.getConvertedTypes(), @@ -545,7 +545,7 @@ static spirv::GlobalVariableOp getBuiltinVariable(Block &body, spirv::BuiltIn builtin) { // Look through all global variables in the given `body` block and check if - // there is a spv.GlobalVariable that has the same `builtin` attribute. + // there is a spirv.GlobalVariable that has the same `builtin` attribute. for (auto varOp : body.getOps()) { if (auto builtinAttr = varOp->getAttrOfType( spirv::SPIRVDialect::getAttributeName( diff --git a/mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp @@ -61,7 +61,8 @@ } /// Returns the element type if the given `type` is a runtime array resource: -/// `!spv.ptr>>`. Returns null type otherwise. +/// `!spirv.ptr>>`. Returns null type +/// otherwise. static Type getRuntimeArrayElementType(Type type) { auto ptrType = type.dyn_cast(); if (!ptrType) @@ -154,9 +155,9 @@ namespace { /// A class for analyzing aliased resources. /// -/// Resources are expected to be spv.GlobalVarible that has a descriptor set and -/// binding number. Such resources are of the type `!spv.ptr>` -/// per Vulkan requirements. +/// Resources are expected to be spirv.GlobalVarible that has a descriptor set +/// and binding number. Such resources are of the type +/// `!spirv.ptr>` per Vulkan requirements. /// /// Right now, we only support the case that there is a single runtime array /// inside the struct. @@ -410,7 +411,7 @@ } return rewriter.notifyMatchFailure( - acOp, "unsupported src/dst types for spv.AccessChain"); + acOp, "unsupported src/dst types for spirv.AccessChain"); } }; @@ -459,7 +460,7 @@ auto acOp = adaptor.getPtr().getDefiningOp(); if (!acOp) - return rewriter.notifyMatchFailure(loadOp, "ptr not spv.AccessChain"); + return rewriter.notifyMatchFailure(loadOp, "ptr not spirv.AccessChain"); auto i32Type = rewriter.getI32Type(); Value oneValue = spirv::ConstantOp::getOne(i32Type, loc, rewriter); @@ -477,7 +478,7 @@ } // Create a vector of the components and then cast back to the larger - // bitwidth element type. For spv.bitcast, the lower-numbered components + // bitwidth element type. For spirv.bitcast, the lower-numbered components // of the vector map to lower-ordered bits of the larger bitwidth element // type. Type vectorType = srcElemType; @@ -493,7 +494,7 @@ } return rewriter.notifyMatchFailure( - loadOp, "unsupported src/dst types for spv.Load"); + loadOp, "unsupported src/dst types for spirv.Load"); } }; diff --git a/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp @@ -102,7 +102,7 @@ spirv::TargetEnvAttr targetAttr = spirv::lookupTargetEnv(module); if (!targetAttr) { - module.emitError("missing 'spv.target_env' attribute"); + module.emitError("missing 'spirv.target_env' attribute"); return signalPassFailure(); } diff --git a/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp b/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp --- a/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp +++ b/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp @@ -40,7 +40,7 @@ Value spirv::Deserializer::getValue(uint32_t id) { if (auto constInfo = getConstant(id)) { - // Materialize a `spv.Constant` op at every use site. + // Materialize a `spirv.Constant` op at every use site. return opBuilder.create(unknownLoc, constInfo->second, constInfo->first); } @@ -149,7 +149,7 @@ case spirv::Opcode::OpSourceContinued: case spirv::Opcode::OpSourceExtension: // TODO: This is debug information embedded in the binary which should be - // translated into the spv.module. + // translated into the spirv.module. return success(); case spirv::Opcode::OpTypeVoid: case spirv::Opcode::OpTypeBool: diff --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h --- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h +++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h @@ -33,10 +33,10 @@ /// /// This struct is used to track original structured control flow info from /// SPIR-V blob. This info will be used to create -/// spv.mlir.selection/spv.mlir.loop later. +/// spirv.mlir.selection/spirv.mlir.loop later. struct BlockMergeInfo { Block *mergeBlock; - Block *continueBlock; // nullptr for spv.mlir.selection + Block *continueBlock; // nullptr for spirv.mlir.selection Location loc; uint32_t control; // Selection/loop control @@ -223,8 +223,8 @@ /// Processes the OpVariable instructions at current `offset` into `binary`. /// It is expected that this method is used for variables that are to be - /// defined at module scope and will be deserialized into a spv.GlobalVariable - /// instruction. + /// defined at module scope and will be deserialized into a + /// spirv.GlobalVariable instruction. LogicalResult processGlobalVariable(ArrayRef operands); /// Gets the global variable associated with a result of OpVariable. @@ -332,9 +332,9 @@ // In SPIR-V, structured control flow is explicitly declared using merge // instructions (OpSelectionMerge and OpLoopMerge). In the SPIR-V dialect, - // we use spv.mlir.selection and spv.mlir.loop to group structured control + // we use spirv.mlir.selection and spirv.mlir.loop to group structured control // flow. The deserializer need to turn structured control flow marked with - // merge instructions into using spv.mlir.selection/spv.mlir.loop ops. + // merge instructions into using spirv.mlir.selection/spirv.mlir.loop ops. // // Because structured control flow can nest and the basic block order have // flexibility, we cannot isolate a structured selection/loop without @@ -346,13 +346,14 @@ // target blocks. // 2. For each selection/loop header block, recursively get all basic blocks // reachable (except the merge block) and put them in a newly created - // spv.mlir.selection/spv.mlir.loop's region. Structured control flow + // spirv.mlir.selection/spirv.mlir.loop's region. Structured control flow // guarantees that we enter and exit in structured ways and the construct // is nestable. - // 3. Put the new spv.mlir.selection/spv.mlir.loop op at the beginning of the + // 3. Put the new spirv.mlir.selection/spirv.mlir.loop op at the beginning of + // the // old merge block and redirect all branches to the old header block to the - // old merge block (which contains the spv.mlir.selection/spv.mlir.loop op - // now). + // old merge block (which contains the spirv.mlir.selection/spirv.mlir.loop + // op now). /// For OpPhi instructions, we use block arguments to represent them. OpPhi /// encodes a list of (value, predecessor) pairs. At the time of handling the @@ -398,8 +399,8 @@ LogicalResult wireUpBlockArgument(); /// Extracts blocks belonging to a structured selection/loop into a - /// spv.mlir.selection/spv.mlir.loop op. This method iterates until all blocks - /// declared as selection/loop headers are handled. + /// spirv.mlir.selection/spirv.mlir.loop op. This method iterates until all + /// blocks declared as selection/loop headers are handled. LogicalResult structurizeControlFlow(); //===--------------------------------------------------------------------===// @@ -409,8 +410,8 @@ /// Get the Value associated with a result . /// /// This method materializes normal constants and inserts "casting" ops - /// (`spv.mlir.addressof` and `spv.mlir.referenceof`) to turn an symbol into a - /// SSA value for handling uses of module scope constants/variables in + /// (`spirv.mlir.addressof` and `spirv.mlir.referenceof`) to turn an symbol + /// into a SSA value for handling uses of module scope constants/variables in /// functions. Value getValue(uint32_t id); @@ -441,8 +442,8 @@ StringRef opName, bool hasResult, unsigned numOperands); - /// Processes a OpUndef instruction. Adds a spv.Undef operation at the current - /// insertion point. + /// Processes a OpUndef instruction. Adds a spirv.Undef operation at the + /// current insertion point. LogicalResult processUndef(ArrayRef operands); /// Method to dispatch to the specialized deserialization function for an @@ -587,8 +588,8 @@ // List of instructions that are processed in a deferred fashion (after an // initial processing of the entire binary). Some operations like // OpEntryPoint, and OpExecutionMode use forward references to function - // s. In SPIR-V dialect the corresponding operations (spv.EntryPoint and - // spv.ExecutionMode) need these references resolved. So these instructions + // s. In SPIR-V dialect the corresponding operations (spirv.EntryPoint and + // spirv.ExecutionMode) need these references resolved. So these instructions // are deserialized and stored for processing once the entire binary is // processed. SmallVector>, 4> diff --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp --- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp +++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp @@ -279,8 +279,8 @@ return emitError(unknownLoc, "OpDecoration with ") << decorationName << "needs a single target "; } - // Block decoration does not affect spv.struct type, but is still stored for - // verification. + // Block decoration does not affect spirv.struct type, but is still stored + // for verification. // TODO: Update StructType to contain this information since // it is needed for many validation rules. decorations[words[0]].set(symbol, opBuilder.getUnitAttr()); @@ -483,7 +483,8 @@ } // Wire up block arguments from OpPhi instructions. - // Put all structured control flow in spv.mlir.selection/spv.mlir.loop ops. + // Put all structured control flow in spirv.mlir.selection/spirv.mlir.loop + // ops. if (failed(wireUpBlockArgument()) || failed(structurizeControlFlow())) { return failure(); } @@ -563,7 +564,7 @@ auto ptrType = type.dyn_cast(); if (!ptrType) { return emitError(unknownLoc, - "expected a result type to be a spv.ptr, found : ") + "expected a result type to be a spirv.ptr, found : ") << type; } wordIndex++; @@ -1467,7 +1468,7 @@ } // We don't know where this block will be placed finally (in a - // spv.mlir.selection or spv.mlir.loop or function). Create it into the + // spirv.mlir.selection or spirv.mlir.loop or function). Create it into the // function for now and sort out the proper place later. auto *block = curFunction->addBlock(); LLVM_DEBUG(logger.startLine() << "[block] created block for id = " << id @@ -1639,7 +1640,7 @@ namespace { /// A class for putting all blocks in a structured selection/loop in a -/// spv.mlir.selection/spv.mlir.loop op. +/// spirv.mlir.selection/spirv.mlir.loop op. class ControlFlowStructurizer { public: #ifndef NDEBUG @@ -1660,18 +1661,19 @@ /// Structurizes the loop at the given `headerBlock`. /// - /// This method will create an spv.mlir.loop op in the `mergeBlock` and move - /// all blocks in the structured loop into the spv.mlir.loop's region. All + /// This method will create an spirv.mlir.loop op in the `mergeBlock` and move + /// all blocks in the structured loop into the spirv.mlir.loop's region. All /// branches to the `headerBlock` will be redirected to the `mergeBlock`. This /// method will also update `mergeInfo` by remapping all blocks inside to the /// newly cloned ones inside structured control flow op's regions. LogicalResult structurize(); private: - /// Creates a new spv.mlir.selection op at the beginning of the `mergeBlock`. + /// Creates a new spirv.mlir.selection op at the beginning of the + /// `mergeBlock`. spirv::SelectionOp createSelectionOp(uint32_t selectionControl); - /// Creates a new spv.mlir.loop op at the beginning of the `mergeBlock`. + /// Creates a new spirv.mlir.loop op at the beginning of the `mergeBlock`. spirv::LoopOp createLoopOp(uint32_t loopControl); /// Collects all blocks reachable from `headerBlock` except `mergeBlock`. @@ -1684,7 +1686,7 @@ Block *headerBlock; Block *mergeBlock; - Block *continueBlock; // nullptr for spv.mlir.selection + Block *continueBlock; // nullptr for spirv.mlir.selection SetVector constructBlocks; @@ -1838,8 +1840,8 @@ for (BlockArgument blockArg : headerBlock->getArguments()) mergeBlock->addArgument(blockArg.getType(), blockArg.getLoc()); - // If the loop header block has block arguments, make sure the spv.Branch op - // matches. + // If the loop header block has block arguments, make sure the spirv.Branch + // op matches. SmallVector blockArgs; if (!headerBlock->args_empty()) blockArgs = {mergeBlock->args_begin(), mergeBlock->args_end()}; @@ -1917,7 +1919,7 @@ // matching the function signature and used by the cloned blocks. if (isFnEntryBlock(block)) { LLVM_DEBUG(logger.startLine() << "[cf] changing entry block " << block - << " to only contain a spv.Branch op\n"); + << " to only contain a spirv.Branch op\n"); // Still keep the function entry block for the potential block arguments, // but replace all ops inside with a branch to the merge block. block->clear(); diff --git a/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp b/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp --- a/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp +++ b/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp @@ -407,7 +407,7 @@ return failure(); // There is nothing to do for the merge block in the selection, which just - // contains a spv.mlir.merge op, itself. But we need to have an OpLabel + // contains a spirv.mlir.merge op, itself. But we need to have an OpLabel // instruction to start a new SPIR-V block for ops following this SelectionOp. // The block should use the for the merge block. encodeInstructionInto(functionBody, spirv::Opcode::OpLabel, {mergeID}); @@ -472,8 +472,8 @@ return failure(); // There is nothing to do for the merge block in the loop, which just contains - // a spv.mlir.merge op, itself. But we need to have an OpLabel instruction to - // start a new SPIR-V block for ops following this LoopOp. The block should + // a spirv.mlir.merge op, itself. But we need to have an OpLabel instruction + // to start a new SPIR-V block for ops following this LoopOp. The block should // use the for the merge block. encodeInstructionInto(functionBody, spirv::Opcode::OpLabel, {mergeID}); LLVM_DEBUG(llvm::dbgs() << "done merge "); @@ -544,7 +544,7 @@ if (!funcID) { return op.emitError("missing for function ") << op.getFn() - << "; function needs to be defined before spv.EntryPoint is " + << "; function needs to be defined before spirv.EntryPoint is " "serialized"; } operands.push_back(funcID); @@ -556,9 +556,10 @@ for (auto var : interface.getValue()) { auto id = getVariableID(var.cast().getValue()); if (!id) { - return op.emitError("referencing undefined global variable." - "spv.EntryPoint is at the end of spv.module. All " - "referenced variables should already be defined"); + return op.emitError( + "referencing undefined global variable." + "spirv.EntryPoint is at the end of spirv.module. All " + "referenced variables should already be defined"); } operands.push_back(id); } @@ -612,7 +613,7 @@ for (auto value : op.getArguments()) { auto valueID = getValueID(value); - assert(valueID && "cannot find a value for spv.FunctionCall"); + assert(valueID && "cannot find a value for spirv.FunctionCall"); operands.push_back(valueID); } diff --git a/mlir/lib/Target/SPIRV/Serialization/Serializer.h b/mlir/lib/Target/SPIRV/Serialization/Serializer.h --- a/mlir/lib/Target/SPIRV/Serialization/Serializer.h +++ b/mlir/lib/Target/SPIRV/Serialization/Serializer.h @@ -116,7 +116,7 @@ LogicalResult processSpecConstantOperationOp(spirv::SpecConstantOperationOp op); - /// SPIR-V dialect supports OpUndef using spv.UndefOp that produces a SSA + /// SPIR-V dialect supports OpUndef using spirv.UndefOp that produces a SSA /// value to use with other operations. The SPIR-V spec recommends that /// OpUndef be generated at module level. The serialization generates an /// OpUndef for each type needed at module level. @@ -424,10 +424,10 @@ /// ... /// ^parent1: /// ... - /// spv.Branch ^phi(%val0: i32) + /// spirv.Branch ^phi(%val0: i32) /// ^parent2: /// ... - /// spv.Branch ^phi(%val1: i32) + /// spirv.Branch ^phi(%val1: i32) /// ``` /// /// When we are serializing the `^phi` block, we need to emit at the beginning diff --git a/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp --- a/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Target/SPIRV/Serialization/Serializer.cpp @@ -45,7 +45,7 @@ /// corresponding to the block arguments. static Block *getPhiIncomingBlock(Block *block) { // If the predecessor block in question is the entry block for a - // spv.mlir.loop, we jump to this spv.mlir.loop from its enclosing block. + // spirv.mlir.loop, we jump to this spirv.mlir.loop from its enclosing block. if (block->isEntryBlock()) { if (auto loopOp = dyn_cast(block->getParentOp())) { // Then the incoming parent block for OpPhi should be the merge block of @@ -1035,8 +1035,8 @@ // structure. It does not directly map to the incoming parent block for the // OpPhi instructions at SPIR-V binary level. This is because structured // control flow ops are serialized to multiple SPIR-V blocks. If there is a - // spv.mlir.selection/spv.mlir.loop op in the MLIR predecessor block, the - // branch op jumping to the OpPhi's block then resides in the previous + // spirv.mlir.selection/spirv.mlir.loop op in the MLIR predecessor block, + // the branch op jumping to the OpPhi's block then resides in the previous // structured control flow op's merge block. Block *spirvPredecessor = getPhiIncomingBlock(mlirPredecessor); LLVM_DEBUG(llvm::dbgs() << " spirv predecessor "); diff --git a/mlir/lib/Target/SPIRV/TranslateRegistration.cpp b/mlir/lib/Target/SPIRV/TranslateRegistration.cpp --- a/mlir/lib/Target/SPIRV/TranslateRegistration.cpp +++ b/mlir/lib/Target/SPIRV/TranslateRegistration.cpp @@ -90,10 +90,10 @@ module.walk([&](spirv::ModuleOp op) { spirvModules.push_back(op); }); if (spirvModules.empty()) - return module.emitError("found no 'spv.module' op"); + return module.emitError("found no 'spirv.module' op"); if (spirvModules.size() != 1) - return module.emitError("found more than one 'spv.module' op"); + return module.emitError("found more than one 'spirv.module' op"); if (failed(spirv::serialize(spirvModules[0], binary))) return failure(); @@ -128,10 +128,10 @@ auto spirvModules = srcModule.getOps(); if (spirvModules.begin() == spirvModules.end()) - return srcModule.emitError("found no 'spv.module' op"); + return srcModule.emitError("found no 'spirv.module' op"); if (std::next(spirvModules.begin()) != spirvModules.end()) - return srcModule.emitError("found more than one 'spv.module' op"); + return srcModule.emitError("found more than one 'spirv.module' op"); spirv::SerializationOptions options; options.emitDebugInfo = emitDebugInfo; diff --git a/mlir/test/Conversion/ArithmeticToSPIRV/arithmetic-to-spirv.mlir b/mlir/test/Conversion/ArithmeticToSPIRV/arithmetic-to-spirv.mlir --- a/mlir/test/Conversion/ArithmeticToSPIRV/arithmetic-to-spirv.mlir +++ b/mlir/test/Conversion/ArithmeticToSPIRV/arithmetic-to-spirv.mlir @@ -5,24 +5,24 @@ //===----------------------------------------------------------------------===// module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // Check integer operation conversions. // CHECK-LABEL: @int32_scalar func.func @int32_scalar(%lhs: i32, %rhs: i32) { - // CHECK: spv.IAdd %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.IAdd %{{.*}}, %{{.*}}: i32 %0 = arith.addi %lhs, %rhs: i32 - // CHECK: spv.ISub %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.ISub %{{.*}}, %{{.*}}: i32 %1 = arith.subi %lhs, %rhs: i32 - // CHECK: spv.IMul %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.IMul %{{.*}}, %{{.*}}: i32 %2 = arith.muli %lhs, %rhs: i32 - // CHECK: spv.SDiv %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.SDiv %{{.*}}, %{{.*}}: i32 %3 = arith.divsi %lhs, %rhs: i32 - // CHECK: spv.UDiv %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.UDiv %{{.*}}, %{{.*}}: i32 %4 = arith.divui %lhs, %rhs: i32 - // CHECK: spv.UMod %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.UMod %{{.*}}, %{{.*}}: i32 %5 = arith.remui %lhs, %rhs: i32 return } @@ -30,29 +30,29 @@ // CHECK-LABEL: @int32_scalar_srem // CHECK-SAME: (%[[LHS:.+]]: i32, %[[RHS:.+]]: i32) func.func @int32_scalar_srem(%lhs: i32, %rhs: i32) { - // CHECK: %[[LABS:.+]] = spv.GL.SAbs %[[LHS]] : i32 - // CHECK: %[[RABS:.+]] = spv.GL.SAbs %[[RHS]] : i32 - // CHECK: %[[ABS:.+]] = spv.UMod %[[LABS]], %[[RABS]] : i32 - // CHECK: %[[POS:.+]] = spv.IEqual %[[LHS]], %[[LABS]] : i32 - // CHECK: %[[NEG:.+]] = spv.SNegate %[[ABS]] : i32 - // CHECK: %{{.+}} = spv.Select %[[POS]], %[[ABS]], %[[NEG]] : i1, i32 + // CHECK: %[[LABS:.+]] = spirv.GL.SAbs %[[LHS]] : i32 + // CHECK: %[[RABS:.+]] = spirv.GL.SAbs %[[RHS]] : i32 + // CHECK: %[[ABS:.+]] = spirv.UMod %[[LABS]], %[[RABS]] : i32 + // CHECK: %[[POS:.+]] = spirv.IEqual %[[LHS]], %[[LABS]] : i32 + // CHECK: %[[NEG:.+]] = spirv.SNegate %[[ABS]] : i32 + // CHECK: %{{.+}} = spirv.Select %[[POS]], %[[ABS]], %[[NEG]] : i1, i32 %0 = arith.remsi %lhs, %rhs: i32 return } // CHECK-LABEL: @index_scalar func.func @index_scalar(%lhs: index, %rhs: index) { - // CHECK: spv.IAdd %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.IAdd %{{.*}}, %{{.*}}: i32 %0 = arith.addi %lhs, %rhs: index - // CHECK: spv.ISub %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.ISub %{{.*}}, %{{.*}}: i32 %1 = arith.subi %lhs, %rhs: index - // CHECK: spv.IMul %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.IMul %{{.*}}, %{{.*}}: i32 %2 = arith.muli %lhs, %rhs: index - // CHECK: spv.SDiv %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.SDiv %{{.*}}, %{{.*}}: i32 %3 = arith.divsi %lhs, %rhs: index - // CHECK: spv.UDiv %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.UDiv %{{.*}}, %{{.*}}: i32 %4 = arith.divui %lhs, %rhs: index - // CHECK: spv.UMod %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.UMod %{{.*}}, %{{.*}}: i32 %5 = arith.remui %lhs, %rhs: index return } @@ -62,12 +62,12 @@ func.func @index_scalar_srem(%lhs: index, %rhs: index) { // CHECK: %[[LHS:.+]] = builtin.unrealized_conversion_cast %[[A]] : index to i32 // CHECK: %[[RHS:.+]] = builtin.unrealized_conversion_cast %[[B]] : index to i32 - // CHECK: %[[LABS:.+]] = spv.GL.SAbs %[[LHS]] : i32 - // CHECK: %[[RABS:.+]] = spv.GL.SAbs %[[RHS]] : i32 - // CHECK: %[[ABS:.+]] = spv.UMod %[[LABS]], %[[RABS]] : i32 - // CHECK: %[[POS:.+]] = spv.IEqual %[[LHS]], %[[LABS]] : i32 - // CHECK: %[[NEG:.+]] = spv.SNegate %[[ABS]] : i32 - // CHECK: %{{.+}} = spv.Select %[[POS]], %[[ABS]], %[[NEG]] : i1, i32 + // CHECK: %[[LABS:.+]] = spirv.GL.SAbs %[[LHS]] : i32 + // CHECK: %[[RABS:.+]] = spirv.GL.SAbs %[[RHS]] : i32 + // CHECK: %[[ABS:.+]] = spirv.UMod %[[LABS]], %[[RABS]] : i32 + // CHECK: %[[POS:.+]] = spirv.IEqual %[[LHS]], %[[LABS]] : i32 + // CHECK: %[[NEG:.+]] = spirv.SNegate %[[ABS]] : i32 + // CHECK: %{{.+}} = spirv.Select %[[POS]], %[[ABS]], %[[NEG]] : i1, i32 %0 = arith.remsi %lhs, %rhs: index return } @@ -76,11 +76,11 @@ // CHECK-LABEL: @int32_scalar_addui_carry // CHECK-SAME: (%[[LHS:.+]]: i32, %[[RHS:.+]]: i32) func.func @int32_scalar_addui_carry(%lhs: i32, %rhs: i32) -> (i32, i1) { - // CHECK-NEXT: %[[IAC:.+]] = spv.IAddCarry %[[LHS]], %[[RHS]] : !spv.struct<(i32, i32)> - // CHECK-DAG: %[[SUM:.+]] = spv.CompositeExtract %[[IAC]][0 : i32] : !spv.struct<(i32, i32)> - // CHECK-DAG: %[[C0:.+]] = spv.CompositeExtract %[[IAC]][1 : i32] : !spv.struct<(i32, i32)> - // CHECK-DAG: %[[ONE:.+]] = spv.Constant 1 : i32 - // CHECK-NEXT: %[[C1:.+]] = spv.IEqual %[[C0]], %[[ONE]] : i32 + // CHECK-NEXT: %[[IAC:.+]] = spirv.IAddCarry %[[LHS]], %[[RHS]] : !spirv.struct<(i32, i32)> + // CHECK-DAG: %[[SUM:.+]] = spirv.CompositeExtract %[[IAC]][0 : i32] : !spirv.struct<(i32, i32)> + // CHECK-DAG: %[[C0:.+]] = spirv.CompositeExtract %[[IAC]][1 : i32] : !spirv.struct<(i32, i32)> + // CHECK-DAG: %[[ONE:.+]] = spirv.Constant 1 : i32 + // CHECK-NEXT: %[[C1:.+]] = spirv.IEqual %[[C0]], %[[ONE]] : i32 // CHECK-NEXT: return %[[SUM]], %[[C1]] : i32, i1 %sum, %carry = arith.addui_carry %lhs, %rhs: i32, i1 return %sum, %carry : i32, i1 @@ -89,11 +89,11 @@ // CHECK-LABEL: @int32_vector_addui_carry // CHECK-SAME: (%[[LHS:.+]]: vector<4xi32>, %[[RHS:.+]]: vector<4xi32>) func.func @int32_vector_addui_carry(%lhs: vector<4xi32>, %rhs: vector<4xi32>) -> (vector<4xi32>, vector<4xi1>) { - // CHECK-NEXT: %[[IAC:.+]] = spv.IAddCarry %[[LHS]], %[[RHS]] : !spv.struct<(vector<4xi32>, vector<4xi32>)> - // CHECK-DAG: %[[SUM:.+]] = spv.CompositeExtract %[[IAC]][0 : i32] : !spv.struct<(vector<4xi32>, vector<4xi32>)> - // CHECK-DAG: %[[C0:.+]] = spv.CompositeExtract %[[IAC]][1 : i32] : !spv.struct<(vector<4xi32>, vector<4xi32>)> - // CHECK-DAG: %[[ONE:.+]] = spv.Constant dense<1> : vector<4xi32> - // CHECK-NEXT: %[[C1:.+]] = spv.IEqual %[[C0]], %[[ONE]] : vector<4xi32> + // CHECK-NEXT: %[[IAC:.+]] = spirv.IAddCarry %[[LHS]], %[[RHS]] : !spirv.struct<(vector<4xi32>, vector<4xi32>)> + // CHECK-DAG: %[[SUM:.+]] = spirv.CompositeExtract %[[IAC]][0 : i32] : !spirv.struct<(vector<4xi32>, vector<4xi32>)> + // CHECK-DAG: %[[C0:.+]] = spirv.CompositeExtract %[[IAC]][1 : i32] : !spirv.struct<(vector<4xi32>, vector<4xi32>)> + // CHECK-DAG: %[[ONE:.+]] = spirv.Constant dense<1> : vector<4xi32> + // CHECK-NEXT: %[[C1:.+]] = spirv.IEqual %[[C0]], %[[ONE]] : vector<4xi32> // CHECK-NEXT: return %[[SUM]], %[[C1]] : vector<4xi32>, vector<4xi1> %sum, %carry = arith.addui_carry %lhs, %rhs: vector<4xi32>, vector<4xi1> return %sum, %carry : vector<4xi32>, vector<4xi1> @@ -102,7 +102,7 @@ // Check float unary operation conversions. // CHECK-LABEL: @float32_unary_scalar func.func @float32_unary_scalar(%arg0: f32) { - // CHECK: spv.FNegate %{{.*}}: f32 + // CHECK: spirv.FNegate %{{.*}}: f32 %0 = arith.negf %arg0 : f32 return } @@ -110,15 +110,15 @@ // Check float binary operation conversions. // CHECK-LABEL: @float32_binary_scalar func.func @float32_binary_scalar(%lhs: f32, %rhs: f32) { - // CHECK: spv.FAdd %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FAdd %{{.*}}, %{{.*}}: f32 %0 = arith.addf %lhs, %rhs: f32 - // CHECK: spv.FSub %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FSub %{{.*}}, %{{.*}}: f32 %1 = arith.subf %lhs, %rhs: f32 - // CHECK: spv.FMul %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FMul %{{.*}}, %{{.*}}: f32 %2 = arith.mulf %lhs, %rhs: f32 - // CHECK: spv.FDiv %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FDiv %{{.*}}, %{{.*}}: f32 %3 = arith.divf %lhs, %rhs: f32 - // CHECK: spv.FRem %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FRem %{{.*}}, %{{.*}}: f32 %4 = arith.remf %lhs, %rhs: f32 return } @@ -126,9 +126,9 @@ // Check int vector types. // CHECK-LABEL: @int_vector234 func.func @int_vector234(%arg0: vector<2xi8>, %arg1: vector<4xi64>) { - // CHECK: spv.SDiv %{{.*}}, %{{.*}}: vector<2xi8> + // CHECK: spirv.SDiv %{{.*}}, %{{.*}}: vector<2xi8> %0 = arith.divsi %arg0, %arg0: vector<2xi8> - // CHECK: spv.UDiv %{{.*}}, %{{.*}}: vector<4xi64> + // CHECK: spirv.UDiv %{{.*}}, %{{.*}}: vector<4xi64> %1 = arith.divui %arg1, %arg1: vector<4xi64> return } @@ -136,12 +136,12 @@ // CHECK-LABEL: @vector_srem // CHECK-SAME: (%[[LHS:.+]]: vector<3xi16>, %[[RHS:.+]]: vector<3xi16>) func.func @vector_srem(%arg0: vector<3xi16>, %arg1: vector<3xi16>) { - // CHECK: %[[LABS:.+]] = spv.GL.SAbs %[[LHS]] : vector<3xi16> - // CHECK: %[[RABS:.+]] = spv.GL.SAbs %[[RHS]] : vector<3xi16> - // CHECK: %[[ABS:.+]] = spv.UMod %[[LABS]], %[[RABS]] : vector<3xi16> - // CHECK: %[[POS:.+]] = spv.IEqual %[[LHS]], %[[LABS]] : vector<3xi16> - // CHECK: %[[NEG:.+]] = spv.SNegate %[[ABS]] : vector<3xi16> - // CHECK: %{{.+}} = spv.Select %[[POS]], %[[ABS]], %[[NEG]] : vector<3xi1>, vector<3xi16> + // CHECK: %[[LABS:.+]] = spirv.GL.SAbs %[[LHS]] : vector<3xi16> + // CHECK: %[[RABS:.+]] = spirv.GL.SAbs %[[RHS]] : vector<3xi16> + // CHECK: %[[ABS:.+]] = spirv.UMod %[[LABS]], %[[RABS]] : vector<3xi16> + // CHECK: %[[POS:.+]] = spirv.IEqual %[[LHS]], %[[LABS]] : vector<3xi16> + // CHECK: %[[NEG:.+]] = spirv.SNegate %[[ABS]] : vector<3xi16> + // CHECK: %{{.+}} = spirv.Select %[[POS]], %[[ABS]], %[[NEG]] : vector<3xi1>, vector<3xi16> %0 = arith.remsi %arg0, %arg1: vector<3xi16> return } @@ -149,16 +149,16 @@ // Check float vector types. // CHECK-LABEL: @float_vector234 func.func @float_vector234(%arg0: vector<2xf16>, %arg1: vector<3xf64>) { - // CHECK: spv.FAdd %{{.*}}, %{{.*}}: vector<2xf16> + // CHECK: spirv.FAdd %{{.*}}, %{{.*}}: vector<2xf16> %0 = arith.addf %arg0, %arg0: vector<2xf16> - // CHECK: spv.FMul %{{.*}}, %{{.*}}: vector<3xf64> + // CHECK: spirv.FMul %{{.*}}, %{{.*}}: vector<3xf64> %1 = arith.mulf %arg1, %arg1: vector<3xf64> return } // CHECK-LABEL: @one_elem_vector func.func @one_elem_vector(%arg0: vector<1xi32>) { - // CHECK: spv.IAdd %{{.+}}, %{{.+}}: i32 + // CHECK: spirv.IAdd %{{.+}}, %{{.+}}: i32 %0 = arith.addi %arg0, %arg0: vector<1xi32> return } @@ -183,23 +183,23 @@ // Check that types are converted to 32-bit when no special capabilities. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @int_vector23 func.func @int_vector23(%arg0: vector<2xi8>, %arg1: vector<3xi16>) { - // CHECK: spv.SDiv %{{.*}}, %{{.*}}: vector<2xi32> + // CHECK: spirv.SDiv %{{.*}}, %{{.*}}: vector<2xi32> %0 = arith.divsi %arg0, %arg0: vector<2xi8> - // CHECK: spv.SDiv %{{.*}}, %{{.*}}: vector<3xi32> + // CHECK: spirv.SDiv %{{.*}}, %{{.*}}: vector<3xi32> %1 = arith.divsi %arg1, %arg1: vector<3xi16> return } // CHECK-LABEL: @float_scalar func.func @float_scalar(%arg0: f16, %arg1: f64) { - // CHECK: spv.FAdd %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FAdd %{{.*}}, %{{.*}}: f32 %0 = arith.addf %arg0, %arg0: f16 - // CHECK: spv.FMul %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FMul %{{.*}}, %{{.*}}: f32 %1 = arith.mulf %arg1, %arg1: f64 return } @@ -211,7 +211,7 @@ // Check that types are converted to 32-bit when no special capabilities that // are not supported. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { func.func @int_vector4_invalid(%arg0: vector<4xi64>) { @@ -229,71 +229,71 @@ //===----------------------------------------------------------------------===// module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @bitwise_scalar func.func @bitwise_scalar(%arg0 : i32, %arg1 : i32) { - // CHECK: spv.BitwiseAnd + // CHECK: spirv.BitwiseAnd %0 = arith.andi %arg0, %arg1 : i32 - // CHECK: spv.BitwiseOr + // CHECK: spirv.BitwiseOr %1 = arith.ori %arg0, %arg1 : i32 - // CHECK: spv.BitwiseXor + // CHECK: spirv.BitwiseXor %2 = arith.xori %arg0, %arg1 : i32 return } // CHECK-LABEL: @bitwise_vector func.func @bitwise_vector(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) { - // CHECK: spv.BitwiseAnd + // CHECK: spirv.BitwiseAnd %0 = arith.andi %arg0, %arg1 : vector<4xi32> - // CHECK: spv.BitwiseOr + // CHECK: spirv.BitwiseOr %1 = arith.ori %arg0, %arg1 : vector<4xi32> - // CHECK: spv.BitwiseXor + // CHECK: spirv.BitwiseXor %2 = arith.xori %arg0, %arg1 : vector<4xi32> return } // CHECK-LABEL: @logical_scalar func.func @logical_scalar(%arg0 : i1, %arg1 : i1) { - // CHECK: spv.LogicalAnd + // CHECK: spirv.LogicalAnd %0 = arith.andi %arg0, %arg1 : i1 - // CHECK: spv.LogicalOr + // CHECK: spirv.LogicalOr %1 = arith.ori %arg0, %arg1 : i1 - // CHECK: spv.LogicalNotEqual + // CHECK: spirv.LogicalNotEqual %2 = arith.xori %arg0, %arg1 : i1 return } // CHECK-LABEL: @logical_vector func.func @logical_vector(%arg0 : vector<4xi1>, %arg1 : vector<4xi1>) { - // CHECK: spv.LogicalAnd + // CHECK: spirv.LogicalAnd %0 = arith.andi %arg0, %arg1 : vector<4xi1> - // CHECK: spv.LogicalOr + // CHECK: spirv.LogicalOr %1 = arith.ori %arg0, %arg1 : vector<4xi1> - // CHECK: spv.LogicalNotEqual + // CHECK: spirv.LogicalNotEqual %2 = arith.xori %arg0, %arg1 : vector<4xi1> return } // CHECK-LABEL: @shift_scalar func.func @shift_scalar(%arg0 : i32, %arg1 : i32) { - // CHECK: spv.ShiftLeftLogical + // CHECK: spirv.ShiftLeftLogical %0 = arith.shli %arg0, %arg1 : i32 - // CHECK: spv.ShiftRightArithmetic + // CHECK: spirv.ShiftRightArithmetic %1 = arith.shrsi %arg0, %arg1 : i32 - // CHECK: spv.ShiftRightLogical + // CHECK: spirv.ShiftRightLogical %2 = arith.shrui %arg0, %arg1 : i32 return } // CHECK-LABEL: @shift_vector func.func @shift_vector(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) { - // CHECK: spv.ShiftLeftLogical + // CHECK: spirv.ShiftLeftLogical %0 = arith.shli %arg0, %arg1 : vector<4xi32> - // CHECK: spv.ShiftRightArithmetic + // CHECK: spirv.ShiftRightArithmetic %1 = arith.shrsi %arg0, %arg1 : vector<4xi32> - // CHECK: spv.ShiftRightLogical + // CHECK: spirv.ShiftRightLogical %2 = arith.shrui %arg0, %arg1 : vector<4xi32> return } @@ -307,34 +307,34 @@ //===----------------------------------------------------------------------===// module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @cmpf func.func @cmpf(%arg0 : f32, %arg1 : f32) { - // CHECK: spv.FOrdEqual + // CHECK: spirv.FOrdEqual %1 = arith.cmpf oeq, %arg0, %arg1 : f32 - // CHECK: spv.FOrdGreaterThan + // CHECK: spirv.FOrdGreaterThan %2 = arith.cmpf ogt, %arg0, %arg1 : f32 - // CHECK: spv.FOrdGreaterThanEqual + // CHECK: spirv.FOrdGreaterThanEqual %3 = arith.cmpf oge, %arg0, %arg1 : f32 - // CHECK: spv.FOrdLessThan + // CHECK: spirv.FOrdLessThan %4 = arith.cmpf olt, %arg0, %arg1 : f32 - // CHECK: spv.FOrdLessThanEqual + // CHECK: spirv.FOrdLessThanEqual %5 = arith.cmpf ole, %arg0, %arg1 : f32 - // CHECK: spv.FOrdNotEqual + // CHECK: spirv.FOrdNotEqual %6 = arith.cmpf one, %arg0, %arg1 : f32 - // CHECK: spv.FUnordEqual + // CHECK: spirv.FUnordEqual %7 = arith.cmpf ueq, %arg0, %arg1 : f32 - // CHECK: spv.FUnordGreaterThan + // CHECK: spirv.FUnordGreaterThan %8 = arith.cmpf ugt, %arg0, %arg1 : f32 - // CHECK: spv.FUnordGreaterThanEqual + // CHECK: spirv.FUnordGreaterThanEqual %9 = arith.cmpf uge, %arg0, %arg1 : f32 - // CHECK: spv.FUnordLessThan + // CHECK: spirv.FUnordLessThan %10 = arith.cmpf ult, %arg0, %arg1 : f32 // CHECK: FUnordLessThanEqual %11 = arith.cmpf ule, %arg0, %arg1 : f32 - // CHECK: spv.FUnordNotEqual + // CHECK: spirv.FUnordNotEqual %12 = arith.cmpf une, %arg0, %arg1 : f32 return } @@ -343,16 +343,16 @@ // ----- -// With Kernel capability, we can convert NaN check to spv.Ordered/spv.Unordered. +// With Kernel capability, we can convert NaN check to spirv.Ordered/spirv.Unordered. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @cmpf func.func @cmpf(%arg0 : f32, %arg1 : f32) { - // CHECK: spv.Ordered + // CHECK: spirv.Ordered %0 = arith.cmpf ord, %arg0, %arg1 : f32 - // CHECK: spv.Unordered + // CHECK: spirv.Unordered %1 = arith.cmpf uno, %arg0, %arg1 : f32 return } @@ -361,23 +361,23 @@ // ----- -// Without Kernel capability, we need to convert NaN check to spv.IsNan. +// Without Kernel capability, we need to convert NaN check to spirv.IsNan. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @cmpf // CHECK-SAME: %[[LHS:.+]]: f32, %[[RHS:.+]]: f32 func.func @cmpf(%arg0 : f32, %arg1 : f32) { - // CHECK: %[[LHS_NAN:.+]] = spv.IsNan %[[LHS]] : f32 - // CHECK-NEXT: %[[RHS_NAN:.+]] = spv.IsNan %[[RHS]] : f32 - // CHECK-NEXT: %[[OR:.+]] = spv.LogicalOr %[[LHS_NAN]], %[[RHS_NAN]] : i1 - // CHECK-NEXT: %{{.+}} = spv.LogicalNot %[[OR]] : i1 + // CHECK: %[[LHS_NAN:.+]] = spirv.IsNan %[[LHS]] : f32 + // CHECK-NEXT: %[[RHS_NAN:.+]] = spirv.IsNan %[[RHS]] : f32 + // CHECK-NEXT: %[[OR:.+]] = spirv.LogicalOr %[[LHS_NAN]], %[[RHS_NAN]] : i1 + // CHECK-NEXT: %{{.+}} = spirv.LogicalNot %[[OR]] : i1 %0 = arith.cmpf ord, %arg0, %arg1 : f32 - // CHECK-NEXT: %[[LHS_NAN:.+]] = spv.IsNan %[[LHS]] : f32 - // CHECK-NEXT: %[[RHS_NAN:.+]] = spv.IsNan %[[RHS]] : f32 - // CHECK-NEXT: %{{.+}} = spv.LogicalOr %[[LHS_NAN]], %[[RHS_NAN]] : i1 + // CHECK-NEXT: %[[LHS_NAN:.+]] = spirv.IsNan %[[LHS]] : f32 + // CHECK-NEXT: %[[RHS_NAN:.+]] = spirv.IsNan %[[RHS]] : f32 + // CHECK-NEXT: %{{.+}} = spirv.LogicalOr %[[LHS_NAN]], %[[RHS_NAN]] : i1 %1 = arith.cmpf uno, %arg0, %arg1 : f32 return } @@ -391,99 +391,99 @@ //===----------------------------------------------------------------------===// module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @cmpi func.func @cmpi(%arg0 : i32, %arg1 : i32) { - // CHECK: spv.IEqual + // CHECK: spirv.IEqual %0 = arith.cmpi eq, %arg0, %arg1 : i32 - // CHECK: spv.INotEqual + // CHECK: spirv.INotEqual %1 = arith.cmpi ne, %arg0, %arg1 : i32 - // CHECK: spv.SLessThan + // CHECK: spirv.SLessThan %2 = arith.cmpi slt, %arg0, %arg1 : i32 - // CHECK: spv.SLessThanEqual + // CHECK: spirv.SLessThanEqual %3 = arith.cmpi sle, %arg0, %arg1 : i32 - // CHECK: spv.SGreaterThan + // CHECK: spirv.SGreaterThan %4 = arith.cmpi sgt, %arg0, %arg1 : i32 - // CHECK: spv.SGreaterThanEqual + // CHECK: spirv.SGreaterThanEqual %5 = arith.cmpi sge, %arg0, %arg1 : i32 - // CHECK: spv.ULessThan + // CHECK: spirv.ULessThan %6 = arith.cmpi ult, %arg0, %arg1 : i32 - // CHECK: spv.ULessThanEqual + // CHECK: spirv.ULessThanEqual %7 = arith.cmpi ule, %arg0, %arg1 : i32 - // CHECK: spv.UGreaterThan + // CHECK: spirv.UGreaterThan %8 = arith.cmpi ugt, %arg0, %arg1 : i32 - // CHECK: spv.UGreaterThanEqual + // CHECK: spirv.UGreaterThanEqual %9 = arith.cmpi uge, %arg0, %arg1 : i32 return } // CHECK-LABEL: @vec1cmpi func.func @vec1cmpi(%arg0 : vector<1xi32>, %arg1 : vector<1xi32>) { - // CHECK: spv.ULessThan + // CHECK: spirv.ULessThan %0 = arith.cmpi ult, %arg0, %arg1 : vector<1xi32> - // CHECK: spv.SGreaterThan + // CHECK: spirv.SGreaterThan %1 = arith.cmpi sgt, %arg0, %arg1 : vector<1xi32> return } // CHECK-LABEL: @boolcmpi_equality func.func @boolcmpi_equality(%arg0 : i1, %arg1 : i1) { - // CHECK: spv.LogicalEqual + // CHECK: spirv.LogicalEqual %0 = arith.cmpi eq, %arg0, %arg1 : i1 - // CHECK: spv.LogicalNotEqual + // CHECK: spirv.LogicalNotEqual %1 = arith.cmpi ne, %arg0, %arg1 : i1 return } // CHECK-LABEL: @boolcmpi_unsigned func.func @boolcmpi_unsigned(%arg0 : i1, %arg1 : i1) { - // CHECK-COUNT-2: spv.Select - // CHECK: spv.UGreaterThanEqual + // CHECK-COUNT-2: spirv.Select + // CHECK: spirv.UGreaterThanEqual %0 = arith.cmpi uge, %arg0, %arg1 : i1 - // CHECK-COUNT-2: spv.Select - // CHECK: spv.ULessThan + // CHECK-COUNT-2: spirv.Select + // CHECK: spirv.ULessThan %1 = arith.cmpi ult, %arg0, %arg1 : i1 return } // CHECK-LABEL: @vec1boolcmpi_equality func.func @vec1boolcmpi_equality(%arg0 : vector<1xi1>, %arg1 : vector<1xi1>) { - // CHECK: spv.LogicalEqual + // CHECK: spirv.LogicalEqual %0 = arith.cmpi eq, %arg0, %arg1 : vector<1xi1> - // CHECK: spv.LogicalNotEqual + // CHECK: spirv.LogicalNotEqual %1 = arith.cmpi ne, %arg0, %arg1 : vector<1xi1> return } // CHECK-LABEL: @vec1boolcmpi_unsigned func.func @vec1boolcmpi_unsigned(%arg0 : vector<1xi1>, %arg1 : vector<1xi1>) { - // CHECK-COUNT-2: spv.Select - // CHECK: spv.UGreaterThanEqual + // CHECK-COUNT-2: spirv.Select + // CHECK: spirv.UGreaterThanEqual %0 = arith.cmpi uge, %arg0, %arg1 : vector<1xi1> - // CHECK-COUNT-2: spv.Select - // CHECK: spv.ULessThan + // CHECK-COUNT-2: spirv.Select + // CHECK: spirv.ULessThan %1 = arith.cmpi ult, %arg0, %arg1 : vector<1xi1> return } // CHECK-LABEL: @vecboolcmpi_equality func.func @vecboolcmpi_equality(%arg0 : vector<4xi1>, %arg1 : vector<4xi1>) { - // CHECK: spv.LogicalEqual + // CHECK: spirv.LogicalEqual %0 = arith.cmpi eq, %arg0, %arg1 : vector<4xi1> - // CHECK: spv.LogicalNotEqual + // CHECK: spirv.LogicalNotEqual %1 = arith.cmpi ne, %arg0, %arg1 : vector<4xi1> return } // CHECK-LABEL: @vecboolcmpi_unsigned func.func @vecboolcmpi_unsigned(%arg0 : vector<3xi1>, %arg1 : vector<3xi1>) { - // CHECK-COUNT-2: spv.Select - // CHECK: spv.UGreaterThanEqual + // CHECK-COUNT-2: spirv.Select + // CHECK: spirv.UGreaterThanEqual %0 = arith.cmpi uge, %arg0, %arg1 : vector<3xi1> - // CHECK-COUNT-2: spv.Select - // CHECK: spv.ULessThan + // CHECK-COUNT-2: spirv.Select + // CHECK: spirv.ULessThan %1 = arith.cmpi ult, %arg0, %arg1 : vector<3xi1> return } @@ -498,70 +498,70 @@ //===----------------------------------------------------------------------===// module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @constant func.func @constant() { - // CHECK: spv.Constant true + // CHECK: spirv.Constant true %0 = arith.constant true - // CHECK: spv.Constant 42 : i32 + // CHECK: spirv.Constant 42 : i32 %1 = arith.constant 42 : i32 - // CHECK: spv.Constant 5.000000e-01 : f32 + // CHECK: spirv.Constant 5.000000e-01 : f32 %2 = arith.constant 0.5 : f32 - // CHECK: spv.Constant dense<[2, 3]> : vector<2xi32> + // CHECK: spirv.Constant dense<[2, 3]> : vector<2xi32> %3 = arith.constant dense<[2, 3]> : vector<2xi32> - // CHECK: spv.Constant 1 : i32 + // CHECK: spirv.Constant 1 : i32 %4 = arith.constant 1 : index - // CHECK: spv.Constant dense<1> : tensor<6xi32> : !spv.array<6 x i32> + // CHECK: spirv.Constant dense<1> : tensor<6xi32> : !spirv.array<6 x i32> %5 = arith.constant dense<1> : tensor<2x3xi32> - // CHECK: spv.Constant dense<1.000000e+00> : tensor<6xf32> : !spv.array<6 x f32> + // CHECK: spirv.Constant dense<1.000000e+00> : tensor<6xf32> : !spirv.array<6 x f32> %6 = arith.constant dense<1.0> : tensor<2x3xf32> - // CHECK: spv.Constant dense<{{\[}}1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00, 5.000000e+00, 6.000000e+00]> : tensor<6xf32> : !spv.array<6 x f32> + // CHECK: spirv.Constant dense<{{\[}}1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00, 5.000000e+00, 6.000000e+00]> : tensor<6xf32> : !spirv.array<6 x f32> %7 = arith.constant dense<[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]> : tensor<2x3xf32> - // CHECK: spv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spv.array<6 x i32> + // CHECK: spirv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spirv.array<6 x i32> %8 = arith.constant dense<[[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi32> - // CHECK: spv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spv.array<6 x i32> + // CHECK: spirv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spirv.array<6 x i32> %9 = arith.constant dense<[[1, 2], [3, 4], [5, 6]]> : tensor<3x2xi32> - // CHECK: spv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spv.array<6 x i32> + // CHECK: spirv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spirv.array<6 x i32> %10 = arith.constant dense<[1, 2, 3, 4, 5, 6]> : tensor<6xi32> return } // CHECK-LABEL: @constant_16bit func.func @constant_16bit() { - // CHECK: spv.Constant 4 : i16 + // CHECK: spirv.Constant 4 : i16 %0 = arith.constant 4 : i16 - // CHECK: spv.Constant 5.000000e+00 : f16 + // CHECK: spirv.Constant 5.000000e+00 : f16 %1 = arith.constant 5.0 : f16 - // CHECK: spv.Constant dense<[2, 3]> : vector<2xi16> + // CHECK: spirv.Constant dense<[2, 3]> : vector<2xi16> %2 = arith.constant dense<[2, 3]> : vector<2xi16> - // CHECK: spv.Constant dense<4.000000e+00> : tensor<5xf16> : !spv.array<5 x f16> + // CHECK: spirv.Constant dense<4.000000e+00> : tensor<5xf16> : !spirv.array<5 x f16> %3 = arith.constant dense<4.0> : tensor<5xf16> return } // CHECK-LABEL: @constant_64bit func.func @constant_64bit() { - // CHECK: spv.Constant 4 : i64 + // CHECK: spirv.Constant 4 : i64 %0 = arith.constant 4 : i64 - // CHECK: spv.Constant 5.000000e+00 : f64 + // CHECK: spirv.Constant 5.000000e+00 : f64 %1 = arith.constant 5.0 : f64 - // CHECK: spv.Constant dense<[2, 3]> : vector<2xi64> + // CHECK: spirv.Constant dense<[2, 3]> : vector<2xi64> %2 = arith.constant dense<[2, 3]> : vector<2xi64> - // CHECK: spv.Constant dense<4.000000e+00> : tensor<5xf64> : !spv.array<5 x f64> + // CHECK: spirv.Constant dense<4.000000e+00> : tensor<5xf64> : !spirv.array<5 x f64> %3 = arith.constant dense<4.0> : tensor<5xf64> return } // CHECK-LABEL: @constant_size1 func.func @constant_size1() { - // CHECK: spv.Constant true + // CHECK: spirv.Constant true %0 = arith.constant dense : tensor<1xi1> - // CHECK: spv.Constant 4 : i64 + // CHECK: spirv.Constant 4 : i64 %1 = arith.constant dense<4> : vector<1xi64> - // CHECK: spv.Constant 5.000000e+00 : f64 + // CHECK: spirv.Constant 5.000000e+00 : f64 %2 = arith.constant dense<5.0> : tensor<1xf64> return } @@ -572,72 +572,72 @@ // Check that constants are converted to 32-bit when no special capability. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @constant_16bit func.func @constant_16bit() { - // CHECK: spv.Constant 4 : i32 + // CHECK: spirv.Constant 4 : i32 %0 = arith.constant 4 : i16 - // CHECK: spv.Constant 5.000000e+00 : f32 + // CHECK: spirv.Constant 5.000000e+00 : f32 %1 = arith.constant 5.0 : f16 - // CHECK: spv.Constant dense<[2, 3]> : vector<2xi32> + // CHECK: spirv.Constant dense<[2, 3]> : vector<2xi32> %2 = arith.constant dense<[2, 3]> : vector<2xi16> - // CHECK: spv.Constant dense<4.000000e+00> : tensor<5xf32> : !spv.array<5 x f32> + // CHECK: spirv.Constant dense<4.000000e+00> : tensor<5xf32> : !spirv.array<5 x f32> %3 = arith.constant dense<4.0> : tensor<5xf16> - // CHECK: spv.Constant dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : tensor<4xf32> : !spv.array<4 x f32> + // CHECK: spirv.Constant dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : tensor<4xf32> : !spirv.array<4 x f32> %4 = arith.constant dense<[[1.0, 2.0], [3.0, 4.0]]> : tensor<2x2xf16> return } // CHECK-LABEL: @constant_64bit func.func @constant_64bit() { - // CHECK: spv.Constant 4 : i32 + // CHECK: spirv.Constant 4 : i32 %0 = arith.constant 4 : i64 - // CHECK: spv.Constant 5.000000e+00 : f32 + // CHECK: spirv.Constant 5.000000e+00 : f32 %1 = arith.constant 5.0 : f64 - // CHECK: spv.Constant dense<[2, 3]> : vector<2xi32> + // CHECK: spirv.Constant dense<[2, 3]> : vector<2xi32> %2 = arith.constant dense<[2, 3]> : vector<2xi64> - // CHECK: spv.Constant dense<4.000000e+00> : tensor<5xf32> : !spv.array<5 x f32> + // CHECK: spirv.Constant dense<4.000000e+00> : tensor<5xf32> : !spirv.array<5 x f32> %3 = arith.constant dense<4.0> : tensor<5xf64> - // CHECK: spv.Constant dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : tensor<4xf32> : !spv.array<4 x f32> + // CHECK: spirv.Constant dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : tensor<4xf32> : !spirv.array<4 x f32> %4 = arith.constant dense<[[1.0, 2.0], [3.0, 4.0]]> : tensor<2x2xf16> return } // CHECK-LABEL: @constant_size1 func.func @constant_size1() { - // CHECK: spv.Constant 4 : i32 + // CHECK: spirv.Constant 4 : i32 %0 = arith.constant dense<4> : vector<1xi64> - // CHECK: spv.Constant 5.000000e+00 : f32 + // CHECK: spirv.Constant 5.000000e+00 : f32 %1 = arith.constant dense<5.0> : tensor<1xf64> return } // CHECK-LABEL: @corner_cases func.func @corner_cases() { - // CHECK: %{{.*}} = spv.Constant -1 : i32 + // CHECK: %{{.*}} = spirv.Constant -1 : i32 %0 = arith.constant 4294967295 : i64 // 2^32 - 1 - // CHECK: %{{.*}} = spv.Constant 2147483647 : i32 + // CHECK: %{{.*}} = spirv.Constant 2147483647 : i32 %1 = arith.constant 2147483647 : i64 // 2^31 - 1 - // CHECK: %{{.*}} = spv.Constant -2147483648 : i32 + // CHECK: %{{.*}} = spirv.Constant -2147483648 : i32 %2 = arith.constant 2147483648 : i64 // 2^31 - // CHECK: %{{.*}} = spv.Constant -2147483648 : i32 + // CHECK: %{{.*}} = spirv.Constant -2147483648 : i32 %3 = arith.constant -2147483648 : i64 // -2^31 - // CHECK: %{{.*}} = spv.Constant -1 : i32 + // CHECK: %{{.*}} = spirv.Constant -1 : i32 %5 = arith.constant -1 : i64 - // CHECK: %{{.*}} = spv.Constant -2 : i32 + // CHECK: %{{.*}} = spirv.Constant -2 : i32 %6 = arith.constant -2 : i64 - // CHECK: %{{.*}} = spv.Constant -1 : i32 + // CHECK: %{{.*}} = spirv.Constant -1 : i32 %7 = arith.constant -1 : index - // CHECK: %{{.*}} = spv.Constant -2 : i32 + // CHECK: %{{.*}} = spirv.Constant -2 : i32 %8 = arith.constant -2 : index - // CHECK: spv.Constant false + // CHECK: spirv.Constant false %9 = arith.constant false - // CHECK: spv.Constant true + // CHECK: spirv.Constant true %10 = arith.constant true return @@ -663,244 +663,244 @@ //===----------------------------------------------------------------------===// module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: index_cast1 func.func @index_cast1(%arg0: i16) { - // CHECK: spv.SConvert %{{.+}} : i16 to i32 + // CHECK: spirv.SConvert %{{.+}} : i16 to i32 %0 = arith.index_cast %arg0 : i16 to index return } // CHECK-LABEL: index_cast2 func.func @index_cast2(%arg0: index) { - // CHECK: spv.SConvert %{{.+}} : i32 to i16 + // CHECK: spirv.SConvert %{{.+}} : i32 to i16 %0 = arith.index_cast %arg0 : index to i16 return } // CHECK-LABEL: index_cast3 func.func @index_cast3(%arg0: i32) { - // CHECK-NOT: spv.SConvert + // CHECK-NOT: spirv.SConvert %0 = arith.index_cast %arg0 : i32 to index return } // CHECK-LABEL: index_cast4 func.func @index_cast4(%arg0: index) { - // CHECK-NOT: spv.SConvert + // CHECK-NOT: spirv.SConvert %0 = arith.index_cast %arg0 : index to i32 return } // CHECK-LABEL: @bit_cast func.func @bit_cast(%arg0: vector<2xf32>, %arg1: i64) { - // CHECK: spv.Bitcast %{{.+}} : vector<2xf32> to vector<2xi32> + // CHECK: spirv.Bitcast %{{.+}} : vector<2xf32> to vector<2xi32> %0 = arith.bitcast %arg0 : vector<2xf32> to vector<2xi32> - // CHECK: spv.Bitcast %{{.+}} : i64 to f64 + // CHECK: spirv.Bitcast %{{.+}} : i64 to f64 %1 = arith.bitcast %arg1 : i64 to f64 return } // CHECK-LABEL: @fpext1 func.func @fpext1(%arg0: f16) -> f64 { - // CHECK: spv.FConvert %{{.*}} : f16 to f64 + // CHECK: spirv.FConvert %{{.*}} : f16 to f64 %0 = arith.extf %arg0 : f16 to f64 return %0 : f64 } // CHECK-LABEL: @fpext2 func.func @fpext2(%arg0 : f32) -> f64 { - // CHECK: spv.FConvert %{{.*}} : f32 to f64 + // CHECK: spirv.FConvert %{{.*}} : f32 to f64 %0 = arith.extf %arg0 : f32 to f64 return %0 : f64 } // CHECK-LABEL: @fptrunc1 func.func @fptrunc1(%arg0 : f64) -> f16 { - // CHECK: spv.FConvert %{{.*}} : f64 to f16 + // CHECK: spirv.FConvert %{{.*}} : f64 to f16 %0 = arith.truncf %arg0 : f64 to f16 return %0 : f16 } // CHECK-LABEL: @fptrunc2 func.func @fptrunc2(%arg0: f32) -> f16 { - // CHECK: spv.FConvert %{{.*}} : f32 to f16 + // CHECK: spirv.FConvert %{{.*}} : f32 to f16 %0 = arith.truncf %arg0 : f32 to f16 return %0 : f16 } // CHECK-LABEL: @sitofp1 func.func @sitofp1(%arg0 : i32) -> f32 { - // CHECK: spv.ConvertSToF %{{.*}} : i32 to f32 + // CHECK: spirv.ConvertSToF %{{.*}} : i32 to f32 %0 = arith.sitofp %arg0 : i32 to f32 return %0 : f32 } // CHECK-LABEL: @sitofp2 func.func @sitofp2(%arg0 : i64) -> f64 { - // CHECK: spv.ConvertSToF %{{.*}} : i64 to f64 + // CHECK: spirv.ConvertSToF %{{.*}} : i64 to f64 %0 = arith.sitofp %arg0 : i64 to f64 return %0 : f64 } // CHECK-LABEL: @uitofp_i16_f32 func.func @uitofp_i16_f32(%arg0: i16) -> f32 { - // CHECK: spv.ConvertUToF %{{.*}} : i16 to f32 + // CHECK: spirv.ConvertUToF %{{.*}} : i16 to f32 %0 = arith.uitofp %arg0 : i16 to f32 return %0 : f32 } // CHECK-LABEL: @uitofp_i32_f32 func.func @uitofp_i32_f32(%arg0 : i32) -> f32 { - // CHECK: spv.ConvertUToF %{{.*}} : i32 to f32 + // CHECK: spirv.ConvertUToF %{{.*}} : i32 to f32 %0 = arith.uitofp %arg0 : i32 to f32 return %0 : f32 } // CHECK-LABEL: @uitofp_i1_f32 func.func @uitofp_i1_f32(%arg0 : i1) -> f32 { - // CHECK: %[[ZERO:.+]] = spv.Constant 0.000000e+00 : f32 - // CHECK: %[[ONE:.+]] = spv.Constant 1.000000e+00 : f32 - // CHECK: spv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, f32 + // CHECK: %[[ZERO:.+]] = spirv.Constant 0.000000e+00 : f32 + // CHECK: %[[ONE:.+]] = spirv.Constant 1.000000e+00 : f32 + // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, f32 %0 = arith.uitofp %arg0 : i1 to f32 return %0 : f32 } // CHECK-LABEL: @uitofp_i1_f64 func.func @uitofp_i1_f64(%arg0 : i1) -> f64 { - // CHECK: %[[ZERO:.+]] = spv.Constant 0.000000e+00 : f64 - // CHECK: %[[ONE:.+]] = spv.Constant 1.000000e+00 : f64 - // CHECK: spv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, f64 + // CHECK: %[[ZERO:.+]] = spirv.Constant 0.000000e+00 : f64 + // CHECK: %[[ONE:.+]] = spirv.Constant 1.000000e+00 : f64 + // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, f64 %0 = arith.uitofp %arg0 : i1 to f64 return %0 : f64 } // CHECK-LABEL: @uitofp_vec_i1_f32 func.func @uitofp_vec_i1_f32(%arg0 : vector<4xi1>) -> vector<4xf32> { - // CHECK: %[[ZERO:.+]] = spv.Constant dense<0.000000e+00> : vector<4xf32> - // CHECK: %[[ONE:.+]] = spv.Constant dense<1.000000e+00> : vector<4xf32> - // CHECK: spv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xf32> + // CHECK: %[[ZERO:.+]] = spirv.Constant dense<0.000000e+00> : vector<4xf32> + // CHECK: %[[ONE:.+]] = spirv.Constant dense<1.000000e+00> : vector<4xf32> + // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xf32> %0 = arith.uitofp %arg0 : vector<4xi1> to vector<4xf32> return %0 : vector<4xf32> } // CHECK-LABEL: @uitofp_vec_i1_f64 -spv.func @uitofp_vec_i1_f64(%arg0: vector<4xi1>) -> vector<4xf64> "None" { - // CHECK: %[[ZERO:.+]] = spv.Constant dense<0.000000e+00> : vector<4xf64> - // CHECK: %[[ONE:.+]] = spv.Constant dense<1.000000e+00> : vector<4xf64> - // CHECK: spv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xf64> - %0 = spv.Constant dense<0.000000e+00> : vector<4xf64> - %1 = spv.Constant dense<1.000000e+00> : vector<4xf64> - %2 = spv.Select %arg0, %1, %0 : vector<4xi1>, vector<4xf64> - spv.ReturnValue %2 : vector<4xf64> +spirv.func @uitofp_vec_i1_f64(%arg0: vector<4xi1>) -> vector<4xf64> "None" { + // CHECK: %[[ZERO:.+]] = spirv.Constant dense<0.000000e+00> : vector<4xf64> + // CHECK: %[[ONE:.+]] = spirv.Constant dense<1.000000e+00> : vector<4xf64> + // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xf64> + %0 = spirv.Constant dense<0.000000e+00> : vector<4xf64> + %1 = spirv.Constant dense<1.000000e+00> : vector<4xf64> + %2 = spirv.Select %arg0, %1, %0 : vector<4xi1>, vector<4xf64> + spirv.ReturnValue %2 : vector<4xf64> } // CHECK-LABEL: @sexti1 func.func @sexti1(%arg0: i16) -> i64 { - // CHECK: spv.SConvert %{{.*}} : i16 to i64 + // CHECK: spirv.SConvert %{{.*}} : i16 to i64 %0 = arith.extsi %arg0 : i16 to i64 return %0 : i64 } // CHECK-LABEL: @sexti2 func.func @sexti2(%arg0 : i32) -> i64 { - // CHECK: spv.SConvert %{{.*}} : i32 to i64 + // CHECK: spirv.SConvert %{{.*}} : i32 to i64 %0 = arith.extsi %arg0 : i32 to i64 return %0 : i64 } // CHECK-LABEL: @zexti1 func.func @zexti1(%arg0: i16) -> i64 { - // CHECK: spv.UConvert %{{.*}} : i16 to i64 + // CHECK: spirv.UConvert %{{.*}} : i16 to i64 %0 = arith.extui %arg0 : i16 to i64 return %0 : i64 } // CHECK-LABEL: @zexti2 func.func @zexti2(%arg0 : i32) -> i64 { - // CHECK: spv.UConvert %{{.*}} : i32 to i64 + // CHECK: spirv.UConvert %{{.*}} : i32 to i64 %0 = arith.extui %arg0 : i32 to i64 return %0 : i64 } // CHECK-LABEL: @zexti3 func.func @zexti3(%arg0 : i1) -> i32 { - // CHECK: %[[ZERO:.+]] = spv.Constant 0 : i32 - // CHECK: %[[ONE:.+]] = spv.Constant 1 : i32 - // CHECK: spv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, i32 + // CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32 + // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, i32 %0 = arith.extui %arg0 : i1 to i32 return %0 : i32 } // CHECK-LABEL: @zexti4 func.func @zexti4(%arg0 : vector<4xi1>) -> vector<4xi32> { - // CHECK: %[[ZERO:.+]] = spv.Constant dense<0> : vector<4xi32> - // CHECK: %[[ONE:.+]] = spv.Constant dense<1> : vector<4xi32> - // CHECK: spv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xi32> + // CHECK: %[[ZERO:.+]] = spirv.Constant dense<0> : vector<4xi32> + // CHECK: %[[ONE:.+]] = spirv.Constant dense<1> : vector<4xi32> + // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xi32> %0 = arith.extui %arg0 : vector<4xi1> to vector<4xi32> return %0 : vector<4xi32> } // CHECK-LABEL: @zexti5 func.func @zexti5(%arg0 : vector<4xi1>) -> vector<4xi64> { - // CHECK: %[[ZERO:.+]] = spv.Constant dense<0> : vector<4xi64> - // CHECK: %[[ONE:.+]] = spv.Constant dense<1> : vector<4xi64> - // CHECK: spv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xi64> + // CHECK: %[[ZERO:.+]] = spirv.Constant dense<0> : vector<4xi64> + // CHECK: %[[ONE:.+]] = spirv.Constant dense<1> : vector<4xi64> + // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xi64> %0 = arith.extui %arg0 : vector<4xi1> to vector<4xi64> return %0 : vector<4xi64> } // CHECK-LABEL: @trunci1 func.func @trunci1(%arg0 : i64) -> i16 { - // CHECK: spv.SConvert %{{.*}} : i64 to i16 + // CHECK: spirv.SConvert %{{.*}} : i64 to i16 %0 = arith.trunci %arg0 : i64 to i16 return %0 : i16 } // CHECK-LABEL: @trunci2 func.func @trunci2(%arg0: i32) -> i16 { - // CHECK: spv.SConvert %{{.*}} : i32 to i16 + // CHECK: spirv.SConvert %{{.*}} : i32 to i16 %0 = arith.trunci %arg0 : i32 to i16 return %0 : i16 } // CHECK-LABEL: @trunc_to_i1 func.func @trunc_to_i1(%arg0: i32) -> i1 { - // CHECK: %[[MASK:.*]] = spv.Constant 1 : i32 - // CHECK: %[[MASKED_SRC:.*]] = spv.BitwiseAnd %{{.*}}, %[[MASK]] : i32 - // CHECK: %[[IS_ONE:.*]] = spv.IEqual %[[MASKED_SRC]], %[[MASK]] : i32 - // CHECK-DAG: %[[TRUE:.*]] = spv.Constant true - // CHECK-DAG: %[[FALSE:.*]] = spv.Constant false - // CHECK: spv.Select %[[IS_ONE]], %[[TRUE]], %[[FALSE]] : i1, i1 + // CHECK: %[[MASK:.*]] = spirv.Constant 1 : i32 + // CHECK: %[[MASKED_SRC:.*]] = spirv.BitwiseAnd %{{.*}}, %[[MASK]] : i32 + // CHECK: %[[IS_ONE:.*]] = spirv.IEqual %[[MASKED_SRC]], %[[MASK]] : i32 + // CHECK-DAG: %[[TRUE:.*]] = spirv.Constant true + // CHECK-DAG: %[[FALSE:.*]] = spirv.Constant false + // CHECK: spirv.Select %[[IS_ONE]], %[[TRUE]], %[[FALSE]] : i1, i1 %0 = arith.trunci %arg0 : i32 to i1 return %0 : i1 } // CHECK-LABEL: @trunc_to_veci1 func.func @trunc_to_veci1(%arg0: vector<4xi32>) -> vector<4xi1> { - // CHECK: %[[MASK:.*]] = spv.Constant dense<1> : vector<4xi32> - // CHECK: %[[MASKED_SRC:.*]] = spv.BitwiseAnd %{{.*}}, %[[MASK]] : vector<4xi32> - // CHECK: %[[IS_ONE:.*]] = spv.IEqual %[[MASKED_SRC]], %[[MASK]] : vector<4xi32> - // CHECK-DAG: %[[TRUE:.*]] = spv.Constant dense : vector<4xi1> - // CHECK-DAG: %[[FALSE:.*]] = spv.Constant dense : vector<4xi1> - // CHECK: spv.Select %[[IS_ONE]], %[[TRUE]], %[[FALSE]] : vector<4xi1>, vector<4xi1> + // CHECK: %[[MASK:.*]] = spirv.Constant dense<1> : vector<4xi32> + // CHECK: %[[MASKED_SRC:.*]] = spirv.BitwiseAnd %{{.*}}, %[[MASK]] : vector<4xi32> + // CHECK: %[[IS_ONE:.*]] = spirv.IEqual %[[MASKED_SRC]], %[[MASK]] : vector<4xi32> + // CHECK-DAG: %[[TRUE:.*]] = spirv.Constant dense : vector<4xi1> + // CHECK-DAG: %[[FALSE:.*]] = spirv.Constant dense : vector<4xi1> + // CHECK: spirv.Select %[[IS_ONE]], %[[TRUE]], %[[FALSE]] : vector<4xi1>, vector<4xi1> %0 = arith.trunci %arg0 : vector<4xi32> to vector<4xi1> return %0 : vector<4xi1> } // CHECK-LABEL: @fptosi1 func.func @fptosi1(%arg0 : f32) -> i32 { - // CHECK: spv.ConvertFToS %{{.*}} : f32 to i32 + // CHECK: spirv.ConvertFToS %{{.*}} : f32 to i32 %0 = arith.fptosi %arg0 : f32 to i32 return %0 : i32 } // CHECK-LABEL: @fptosi2 func.func @fptosi2(%arg0 : f16) -> i16 { - // CHECK: spv.ConvertFToS %{{.*}} : f16 to i16 + // CHECK: spirv.ConvertFToS %{{.*}} : f16 to i16 %0 = arith.fptosi %arg0 : f16 to i16 return %0 : i16 } @@ -912,14 +912,14 @@ // Checks that cast types will be adjusted when missing special capabilities for // certain non-32-bit scalar types. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @fpext1 // CHECK-SAME: %[[A:.*]]: f16 func.func @fpext1(%arg0: f16) -> f64 { // CHECK: %[[ARG:.+]] = builtin.unrealized_conversion_cast %[[A]] : f16 to f32 - // CHECK-NEXT: spv.FConvert %[[ARG]] : f32 to f64 + // CHECK-NEXT: spirv.FConvert %[[ARG]] : f32 to f64 %0 = arith.extf %arg0 : f16 to f64 return %0: f64 } @@ -927,7 +927,7 @@ // CHECK-LABEL: @fpext2 // CHECK-SAME: %[[ARG:.*]]: f32 func.func @fpext2(%arg0 : f32) -> f64 { - // CHECK-NEXT: spv.FConvert %[[ARG]] : f32 to f64 + // CHECK-NEXT: spirv.FConvert %[[ARG]] : f32 to f64 %0 = arith.extf %arg0 : f32 to f64 return %0: f64 } @@ -939,14 +939,14 @@ // Checks that cast types will be adjusted when missing special capabilities for // certain non-32-bit scalar types. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @fptrunc1 // CHECK-SAME: %[[A:.*]]: f64 func.func @fptrunc1(%arg0 : f64) -> f16 { // CHECK: %[[ARG:.+]] = builtin.unrealized_conversion_cast %[[A]] : f64 to f32 - // CHECK-NEXT: spv.FConvert %[[ARG]] : f32 to f16 + // CHECK-NEXT: spirv.FConvert %[[ARG]] : f32 to f16 %0 = arith.truncf %arg0 : f64 to f16 return %0: f16 } @@ -954,14 +954,14 @@ // CHECK-LABEL: @fptrunc2 // CHECK-SAME: %[[ARG:.*]]: f32 func.func @fptrunc2(%arg0: f32) -> f16 { - // CHECK-NEXT: spv.FConvert %[[ARG]] : f32 to f16 + // CHECK-NEXT: spirv.FConvert %[[ARG]] : f32 to f16 %0 = arith.truncf %arg0 : f32 to f16 return %0: f16 } // CHECK-LABEL: @sitofp func.func @sitofp(%arg0 : i64) -> f64 { - // CHECK: spv.ConvertSToF %{{.*}} : i32 to f32 + // CHECK: spirv.ConvertSToF %{{.*}} : i32 to f32 %0 = arith.sitofp %arg0 : i64 to f64 return %0: f64 } @@ -972,32 +972,32 @@ // Check various lowerings for OpenCL. module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // Check integer operation conversions. // CHECK-LABEL: @int32_scalar func.func @int32_scalar(%lhs: i32, %rhs: i32) { - // CHECK: spv.IAdd %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.IAdd %{{.*}}, %{{.*}}: i32 %0 = arith.addi %lhs, %rhs: i32 - // CHECK: spv.ISub %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.ISub %{{.*}}, %{{.*}}: i32 %1 = arith.subi %lhs, %rhs: i32 - // CHECK: spv.IMul %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.IMul %{{.*}}, %{{.*}}: i32 %2 = arith.muli %lhs, %rhs: i32 - // CHECK: spv.SDiv %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.SDiv %{{.*}}, %{{.*}}: i32 %3 = arith.divsi %lhs, %rhs: i32 - // CHECK: spv.UDiv %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.UDiv %{{.*}}, %{{.*}}: i32 %4 = arith.divui %lhs, %rhs: i32 - // CHECK: spv.UMod %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.UMod %{{.*}}, %{{.*}}: i32 %5 = arith.remui %lhs, %rhs: i32 - // CHECK: spv.CL.s_max %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.CL.s_max %{{.*}}, %{{.*}}: i32 %6 = arith.maxsi %lhs, %rhs : i32 - // CHECK: spv.CL.u_max %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.CL.u_max %{{.*}}, %{{.*}}: i32 %7 = arith.maxui %lhs, %rhs : i32 - // CHECK: spv.CL.s_min %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.CL.s_min %{{.*}}, %{{.*}}: i32 %8 = arith.minsi %lhs, %rhs : i32 - // CHECK: spv.CL.u_min %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.CL.u_min %{{.*}}, %{{.*}}: i32 %9 = arith.minui %lhs, %rhs : i32 return } @@ -1005,15 +1005,15 @@ // Check float binary operation conversions. // CHECK-LABEL: @float32_binary_scalar func.func @float32_binary_scalar(%lhs: f32, %rhs: f32) { - // CHECK: spv.FAdd %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FAdd %{{.*}}, %{{.*}}: f32 %0 = arith.addf %lhs, %rhs: f32 - // CHECK: spv.FSub %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FSub %{{.*}}, %{{.*}}: f32 %1 = arith.subf %lhs, %rhs: f32 - // CHECK: spv.FMul %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FMul %{{.*}}, %{{.*}}: f32 %2 = arith.mulf %lhs, %rhs: f32 - // CHECK: spv.FDiv %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FDiv %{{.*}}, %{{.*}}: f32 %3 = arith.divf %lhs, %rhs: f32 - // CHECK: spv.FRem %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FRem %{{.*}}, %{{.*}}: f32 %4 = arith.remf %lhs, %rhs: f32 return } @@ -1021,11 +1021,11 @@ // CHECK-LABEL: @float32_minf_scalar // CHECK-SAME: %[[LHS:.+]]: f32, %[[RHS:.+]]: f32 func.func @float32_minf_scalar(%arg0 : f32, %arg1 : f32) -> f32 { - // CHECK: %[[MIN:.+]] = spv.CL.fmin %arg0, %arg1 : f32 - // CHECK: %[[LHS_NAN:.+]] = spv.IsNan %[[LHS]] : f32 - // CHECK: %[[RHS_NAN:.+]] = spv.IsNan %[[RHS]] : f32 - // CHECK: %[[SELECT1:.+]] = spv.Select %[[LHS_NAN]], %[[LHS]], %[[MIN]] - // CHECK: %[[SELECT2:.+]] = spv.Select %[[RHS_NAN]], %[[RHS]], %[[SELECT1]] + // CHECK: %[[MIN:.+]] = spirv.CL.fmin %arg0, %arg1 : f32 + // CHECK: %[[LHS_NAN:.+]] = spirv.IsNan %[[LHS]] : f32 + // CHECK: %[[RHS_NAN:.+]] = spirv.IsNan %[[RHS]] : f32 + // CHECK: %[[SELECT1:.+]] = spirv.Select %[[LHS_NAN]], %[[LHS]], %[[MIN]] + // CHECK: %[[SELECT2:.+]] = spirv.Select %[[RHS_NAN]], %[[RHS]], %[[SELECT1]] %0 = arith.minf %arg0, %arg1 : f32 // CHECK: return %[[SELECT2]] return %0: f32 @@ -1034,11 +1034,11 @@ // CHECK-LABEL: @float32_maxf_scalar // CHECK-SAME: %[[LHS:.+]]: vector<2xf32>, %[[RHS:.+]]: vector<2xf32> func.func @float32_maxf_scalar(%arg0 : vector<2xf32>, %arg1 : vector<2xf32>) -> vector<2xf32> { - // CHECK: %[[MAX:.+]] = spv.CL.fmax %arg0, %arg1 : vector<2xf32> - // CHECK: %[[LHS_NAN:.+]] = spv.IsNan %[[LHS]] : vector<2xf32> - // CHECK: %[[RHS_NAN:.+]] = spv.IsNan %[[RHS]] : vector<2xf32> - // CHECK: %[[SELECT1:.+]] = spv.Select %[[LHS_NAN]], %[[LHS]], %[[MAX]] - // CHECK: %[[SELECT2:.+]] = spv.Select %[[RHS_NAN]], %[[RHS]], %[[SELECT1]] + // CHECK: %[[MAX:.+]] = spirv.CL.fmax %arg0, %arg1 : vector<2xf32> + // CHECK: %[[LHS_NAN:.+]] = spirv.IsNan %[[LHS]] : vector<2xf32> + // CHECK: %[[RHS_NAN:.+]] = spirv.IsNan %[[RHS]] : vector<2xf32> + // CHECK: %[[SELECT1:.+]] = spirv.Select %[[LHS_NAN]], %[[LHS]], %[[MAX]] + // CHECK: %[[SELECT2:.+]] = spirv.Select %[[RHS_NAN]], %[[RHS]], %[[SELECT1]] %0 = arith.maxf %arg0, %arg1 : vector<2xf32> // CHECK: return %[[SELECT2]] return %0: vector<2xf32> @@ -1047,12 +1047,12 @@ // CHECK-LABEL: @scalar_srem // CHECK-SAME: (%[[LHS:.+]]: i32, %[[RHS:.+]]: i32) func.func @scalar_srem(%lhs: i32, %rhs: i32) { - // CHECK: %[[LABS:.+]] = spv.CL.s_abs %[[LHS]] : i32 - // CHECK: %[[RABS:.+]] = spv.CL.s_abs %[[RHS]] : i32 - // CHECK: %[[ABS:.+]] = spv.UMod %[[LABS]], %[[RABS]] : i32 - // CHECK: %[[POS:.+]] = spv.IEqual %[[LHS]], %[[LABS]] : i32 - // CHECK: %[[NEG:.+]] = spv.SNegate %[[ABS]] : i32 - // CHECK: %{{.+}} = spv.Select %[[POS]], %[[ABS]], %[[NEG]] : i1, i32 + // CHECK: %[[LABS:.+]] = spirv.CL.s_abs %[[LHS]] : i32 + // CHECK: %[[RABS:.+]] = spirv.CL.s_abs %[[RHS]] : i32 + // CHECK: %[[ABS:.+]] = spirv.UMod %[[LABS]], %[[RABS]] : i32 + // CHECK: %[[POS:.+]] = spirv.IEqual %[[LHS]], %[[LABS]] : i32 + // CHECK: %[[NEG:.+]] = spirv.SNegate %[[ABS]] : i32 + // CHECK: %{{.+}} = spirv.Select %[[POS]], %[[ABS]], %[[NEG]] : i1, i32 %0 = arith.remsi %lhs, %rhs: i32 return } @@ -1060,12 +1060,12 @@ // CHECK-LABEL: @vector_srem // CHECK-SAME: (%[[LHS:.+]]: vector<3xi16>, %[[RHS:.+]]: vector<3xi16>) func.func @vector_srem(%arg0: vector<3xi16>, %arg1: vector<3xi16>) { - // CHECK: %[[LABS:.+]] = spv.CL.s_abs %[[LHS]] : vector<3xi16> - // CHECK: %[[RABS:.+]] = spv.CL.s_abs %[[RHS]] : vector<3xi16> - // CHECK: %[[ABS:.+]] = spv.UMod %[[LABS]], %[[RABS]] : vector<3xi16> - // CHECK: %[[POS:.+]] = spv.IEqual %[[LHS]], %[[LABS]] : vector<3xi16> - // CHECK: %[[NEG:.+]] = spv.SNegate %[[ABS]] : vector<3xi16> - // CHECK: %{{.+}} = spv.Select %[[POS]], %[[ABS]], %[[NEG]] : vector<3xi1>, vector<3xi16> + // CHECK: %[[LABS:.+]] = spirv.CL.s_abs %[[LHS]] : vector<3xi16> + // CHECK: %[[RABS:.+]] = spirv.CL.s_abs %[[RHS]] : vector<3xi16> + // CHECK: %[[ABS:.+]] = spirv.UMod %[[LABS]], %[[RABS]] : vector<3xi16> + // CHECK: %[[POS:.+]] = spirv.IEqual %[[LHS]], %[[LABS]] : vector<3xi16> + // CHECK: %[[NEG:.+]] = spirv.SNegate %[[ABS]] : vector<3xi16> + // CHECK: %{{.+}} = spirv.Select %[[POS]], %[[ABS]], %[[NEG]] : vector<3xi1>, vector<3xi16> %0 = arith.remsi %arg0, %arg1: vector<3xi16> return } @@ -1075,15 +1075,15 @@ // ----- module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @select func.func @select(%arg0 : i32, %arg1 : i32) { %0 = arith.cmpi sle, %arg0, %arg1 : i32 - // CHECK: spv.Select + // CHECK: spirv.Select %1 = arith.select %0, %arg0, %arg1 : i32 return } @@ -1097,32 +1097,32 @@ //===----------------------------------------------------------------------===// module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // Check integer operation conversions. // CHECK-LABEL: @int32_scalar func.func @int32_scalar(%lhs: i32, %rhs: i32) { - // CHECK: spv.IAdd %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.IAdd %{{.*}}, %{{.*}}: i32 %0 = arith.addi %lhs, %rhs: i32 - // CHECK: spv.ISub %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.ISub %{{.*}}, %{{.*}}: i32 %1 = arith.subi %lhs, %rhs: i32 - // CHECK: spv.IMul %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.IMul %{{.*}}, %{{.*}}: i32 %2 = arith.muli %lhs, %rhs: i32 - // CHECK: spv.SDiv %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.SDiv %{{.*}}, %{{.*}}: i32 %3 = arith.divsi %lhs, %rhs: i32 - // CHECK: spv.UDiv %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.UDiv %{{.*}}, %{{.*}}: i32 %4 = arith.divui %lhs, %rhs: i32 - // CHECK: spv.UMod %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.UMod %{{.*}}, %{{.*}}: i32 %5 = arith.remui %lhs, %rhs: i32 - // CHECK: spv.GL.SMax %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.GL.SMax %{{.*}}, %{{.*}}: i32 %6 = arith.maxsi %lhs, %rhs : i32 - // CHECK: spv.GL.UMax %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.GL.UMax %{{.*}}, %{{.*}}: i32 %7 = arith.maxui %lhs, %rhs : i32 - // CHECK: spv.GL.SMin %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.GL.SMin %{{.*}}, %{{.*}}: i32 %8 = arith.minsi %lhs, %rhs : i32 - // CHECK: spv.GL.UMin %{{.*}}, %{{.*}}: i32 + // CHECK: spirv.GL.UMin %{{.*}}, %{{.*}}: i32 %9 = arith.minui %lhs, %rhs : i32 return } @@ -1130,12 +1130,12 @@ // CHECK-LABEL: @scalar_srem // CHECK-SAME: (%[[LHS:.+]]: i32, %[[RHS:.+]]: i32) func.func @scalar_srem(%lhs: i32, %rhs: i32) { - // CHECK: %[[LABS:.+]] = spv.GL.SAbs %[[LHS]] : i32 - // CHECK: %[[RABS:.+]] = spv.GL.SAbs %[[RHS]] : i32 - // CHECK: %[[ABS:.+]] = spv.UMod %[[LABS]], %[[RABS]] : i32 - // CHECK: %[[POS:.+]] = spv.IEqual %[[LHS]], %[[LABS]] : i32 - // CHECK: %[[NEG:.+]] = spv.SNegate %[[ABS]] : i32 - // CHECK: %{{.+}} = spv.Select %[[POS]], %[[ABS]], %[[NEG]] : i1, i32 + // CHECK: %[[LABS:.+]] = spirv.GL.SAbs %[[LHS]] : i32 + // CHECK: %[[RABS:.+]] = spirv.GL.SAbs %[[RHS]] : i32 + // CHECK: %[[ABS:.+]] = spirv.UMod %[[LABS]], %[[RABS]] : i32 + // CHECK: %[[POS:.+]] = spirv.IEqual %[[LHS]], %[[LABS]] : i32 + // CHECK: %[[NEG:.+]] = spirv.SNegate %[[ABS]] : i32 + // CHECK: %{{.+}} = spirv.Select %[[POS]], %[[ABS]], %[[NEG]] : i1, i32 %0 = arith.remsi %lhs, %rhs: i32 return } @@ -1143,7 +1143,7 @@ // Check float unary operation conversions. // CHECK-LABEL: @float32_unary_scalar func.func @float32_unary_scalar(%arg0: f32) { - // CHECK: spv.FNegate %{{.*}}: f32 + // CHECK: spirv.FNegate %{{.*}}: f32 %5 = arith.negf %arg0 : f32 return } @@ -1151,15 +1151,15 @@ // Check float binary operation conversions. // CHECK-LABEL: @float32_binary_scalar func.func @float32_binary_scalar(%lhs: f32, %rhs: f32) { - // CHECK: spv.FAdd %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FAdd %{{.*}}, %{{.*}}: f32 %0 = arith.addf %lhs, %rhs: f32 - // CHECK: spv.FSub %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FSub %{{.*}}, %{{.*}}: f32 %1 = arith.subf %lhs, %rhs: f32 - // CHECK: spv.FMul %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FMul %{{.*}}, %{{.*}}: f32 %2 = arith.mulf %lhs, %rhs: f32 - // CHECK: spv.FDiv %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FDiv %{{.*}}, %{{.*}}: f32 %3 = arith.divf %lhs, %rhs: f32 - // CHECK: spv.FRem %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FRem %{{.*}}, %{{.*}}: f32 %4 = arith.remf %lhs, %rhs: f32 return } @@ -1167,11 +1167,11 @@ // CHECK-LABEL: @float32_minf_scalar // CHECK-SAME: %[[LHS:.+]]: f32, %[[RHS:.+]]: f32 func.func @float32_minf_scalar(%arg0 : f32, %arg1 : f32) -> f32 { - // CHECK: %[[MIN:.+]] = spv.GL.FMin %arg0, %arg1 : f32 - // CHECK: %[[LHS_NAN:.+]] = spv.IsNan %[[LHS]] : f32 - // CHECK: %[[RHS_NAN:.+]] = spv.IsNan %[[RHS]] : f32 - // CHECK: %[[SELECT1:.+]] = spv.Select %[[LHS_NAN]], %[[LHS]], %[[MIN]] - // CHECK: %[[SELECT2:.+]] = spv.Select %[[RHS_NAN]], %[[RHS]], %[[SELECT1]] + // CHECK: %[[MIN:.+]] = spirv.GL.FMin %arg0, %arg1 : f32 + // CHECK: %[[LHS_NAN:.+]] = spirv.IsNan %[[LHS]] : f32 + // CHECK: %[[RHS_NAN:.+]] = spirv.IsNan %[[RHS]] : f32 + // CHECK: %[[SELECT1:.+]] = spirv.Select %[[LHS_NAN]], %[[LHS]], %[[MIN]] + // CHECK: %[[SELECT2:.+]] = spirv.Select %[[RHS_NAN]], %[[RHS]], %[[SELECT1]] %0 = arith.minf %arg0, %arg1 : f32 // CHECK: return %[[SELECT2]] return %0: f32 @@ -1180,11 +1180,11 @@ // CHECK-LABEL: @float32_maxf_scalar // CHECK-SAME: %[[LHS:.+]]: vector<2xf32>, %[[RHS:.+]]: vector<2xf32> func.func @float32_maxf_scalar(%arg0 : vector<2xf32>, %arg1 : vector<2xf32>) -> vector<2xf32> { - // CHECK: %[[MAX:.+]] = spv.GL.FMax %arg0, %arg1 : vector<2xf32> - // CHECK: %[[LHS_NAN:.+]] = spv.IsNan %[[LHS]] : vector<2xf32> - // CHECK: %[[RHS_NAN:.+]] = spv.IsNan %[[RHS]] : vector<2xf32> - // CHECK: %[[SELECT1:.+]] = spv.Select %[[LHS_NAN]], %[[LHS]], %[[MAX]] - // CHECK: %[[SELECT2:.+]] = spv.Select %[[RHS_NAN]], %[[RHS]], %[[SELECT1]] + // CHECK: %[[MAX:.+]] = spirv.GL.FMax %arg0, %arg1 : vector<2xf32> + // CHECK: %[[LHS_NAN:.+]] = spirv.IsNan %[[LHS]] : vector<2xf32> + // CHECK: %[[RHS_NAN:.+]] = spirv.IsNan %[[RHS]] : vector<2xf32> + // CHECK: %[[SELECT1:.+]] = spirv.Select %[[LHS_NAN]], %[[LHS]], %[[MAX]] + // CHECK: %[[SELECT2:.+]] = spirv.Select %[[RHS_NAN]], %[[RHS]], %[[SELECT1]] %0 = arith.maxf %arg0, %arg1 : vector<2xf32> // CHECK: return %[[SELECT2]] return %0: vector<2xf32> @@ -1193,9 +1193,9 @@ // Check int vector types. // CHECK-LABEL: @int_vector234 func.func @int_vector234(%arg0: vector<2xi8>, %arg1: vector<4xi64>) { - // CHECK: spv.SDiv %{{.*}}, %{{.*}}: vector<2xi8> + // CHECK: spirv.SDiv %{{.*}}, %{{.*}}: vector<2xi8> %0 = arith.divsi %arg0, %arg0: vector<2xi8> - // CHECK: spv.UDiv %{{.*}}, %{{.*}}: vector<4xi64> + // CHECK: spirv.UDiv %{{.*}}, %{{.*}}: vector<4xi64> %1 = arith.divui %arg1, %arg1: vector<4xi64> return } @@ -1203,12 +1203,12 @@ // CHECK-LABEL: @vector_srem // CHECK-SAME: (%[[LHS:.+]]: vector<3xi16>, %[[RHS:.+]]: vector<3xi16>) func.func @vector_srem(%arg0: vector<3xi16>, %arg1: vector<3xi16>) { - // CHECK: %[[LABS:.+]] = spv.GL.SAbs %[[LHS]] : vector<3xi16> - // CHECK: %[[RABS:.+]] = spv.GL.SAbs %[[RHS]] : vector<3xi16> - // CHECK: %[[ABS:.+]] = spv.UMod %[[LABS]], %[[RABS]] : vector<3xi16> - // CHECK: %[[POS:.+]] = spv.IEqual %[[LHS]], %[[LABS]] : vector<3xi16> - // CHECK: %[[NEG:.+]] = spv.SNegate %[[ABS]] : vector<3xi16> - // CHECK: %{{.+}} = spv.Select %[[POS]], %[[ABS]], %[[NEG]] : vector<3xi1>, vector<3xi16> + // CHECK: %[[LABS:.+]] = spirv.GL.SAbs %[[LHS]] : vector<3xi16> + // CHECK: %[[RABS:.+]] = spirv.GL.SAbs %[[RHS]] : vector<3xi16> + // CHECK: %[[ABS:.+]] = spirv.UMod %[[LABS]], %[[RABS]] : vector<3xi16> + // CHECK: %[[POS:.+]] = spirv.IEqual %[[LHS]], %[[LABS]] : vector<3xi16> + // CHECK: %[[NEG:.+]] = spirv.SNegate %[[ABS]] : vector<3xi16> + // CHECK: %{{.+}} = spirv.Select %[[POS]], %[[ABS]], %[[NEG]] : vector<3xi1>, vector<3xi16> %0 = arith.remsi %arg0, %arg1: vector<3xi16> return } @@ -1216,16 +1216,16 @@ // Check float vector types. // CHECK-LABEL: @float_vector234 func.func @float_vector234(%arg0: vector<2xf16>, %arg1: vector<3xf64>) { - // CHECK: spv.FAdd %{{.*}}, %{{.*}}: vector<2xf16> + // CHECK: spirv.FAdd %{{.*}}, %{{.*}}: vector<2xf16> %0 = arith.addf %arg0, %arg0: vector<2xf16> - // CHECK: spv.FMul %{{.*}}, %{{.*}}: vector<3xf64> + // CHECK: spirv.FMul %{{.*}}, %{{.*}}: vector<3xf64> %1 = arith.mulf %arg1, %arg1: vector<3xf64> return } // CHECK-LABEL: @one_elem_vector func.func @one_elem_vector(%arg0: vector<1xi32>) { - // CHECK: spv.IAdd %{{.+}}, %{{.+}}: i32 + // CHECK: spirv.IAdd %{{.+}}, %{{.+}}: i32 %0 = arith.addi %arg0, %arg0: vector<1xi32> return } @@ -1250,23 +1250,23 @@ // Check that types are converted to 32-bit when no special capabilities. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @int_vector23 func.func @int_vector23(%arg0: vector<2xi8>, %arg1: vector<3xi16>) { - // CHECK: spv.SDiv %{{.*}}, %{{.*}}: vector<2xi32> + // CHECK: spirv.SDiv %{{.*}}, %{{.*}}: vector<2xi32> %0 = arith.divsi %arg0, %arg0: vector<2xi8> - // CHECK: spv.SDiv %{{.*}}, %{{.*}}: vector<3xi32> + // CHECK: spirv.SDiv %{{.*}}, %{{.*}}: vector<3xi32> %1 = arith.divsi %arg1, %arg1: vector<3xi16> return } // CHECK-LABEL: @float_scalar func.func @float_scalar(%arg0: f16, %arg1: f64) { - // CHECK: spv.FAdd %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FAdd %{{.*}}, %{{.*}}: f32 %0 = arith.addf %arg0, %arg0: f16 - // CHECK: spv.FMul %{{.*}}, %{{.*}}: f32 + // CHECK: spirv.FMul %{{.*}}, %{{.*}}: f32 %1 = arith.mulf %arg1, %arg1: f64 return } @@ -1278,7 +1278,7 @@ // Check that types are converted to 32-bit when no special capabilities that // are not supported. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { func.func @int_vector4_invalid(%arg0: vector<4xi64>) { @@ -1296,71 +1296,71 @@ //===----------------------------------------------------------------------===// module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @bitwise_scalar func.func @bitwise_scalar(%arg0 : i32, %arg1 : i32) { - // CHECK: spv.BitwiseAnd + // CHECK: spirv.BitwiseAnd %0 = arith.andi %arg0, %arg1 : i32 - // CHECK: spv.BitwiseOr + // CHECK: spirv.BitwiseOr %1 = arith.ori %arg0, %arg1 : i32 - // CHECK: spv.BitwiseXor + // CHECK: spirv.BitwiseXor %2 = arith.xori %arg0, %arg1 : i32 return } // CHECK-LABEL: @bitwise_vector func.func @bitwise_vector(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) { - // CHECK: spv.BitwiseAnd + // CHECK: spirv.BitwiseAnd %0 = arith.andi %arg0, %arg1 : vector<4xi32> - // CHECK: spv.BitwiseOr + // CHECK: spirv.BitwiseOr %1 = arith.ori %arg0, %arg1 : vector<4xi32> - // CHECK: spv.BitwiseXor + // CHECK: spirv.BitwiseXor %2 = arith.xori %arg0, %arg1 : vector<4xi32> return } // CHECK-LABEL: @logical_scalar func.func @logical_scalar(%arg0 : i1, %arg1 : i1) { - // CHECK: spv.LogicalAnd + // CHECK: spirv.LogicalAnd %0 = arith.andi %arg0, %arg1 : i1 - // CHECK: spv.LogicalOr + // CHECK: spirv.LogicalOr %1 = arith.ori %arg0, %arg1 : i1 - // CHECK: spv.LogicalNotEqual + // CHECK: spirv.LogicalNotEqual %2 = arith.xori %arg0, %arg1 : i1 return } // CHECK-LABEL: @logical_vector func.func @logical_vector(%arg0 : vector<4xi1>, %arg1 : vector<4xi1>) { - // CHECK: spv.LogicalAnd + // CHECK: spirv.LogicalAnd %0 = arith.andi %arg0, %arg1 : vector<4xi1> - // CHECK: spv.LogicalOr + // CHECK: spirv.LogicalOr %1 = arith.ori %arg0, %arg1 : vector<4xi1> - // CHECK: spv.LogicalNotEqual + // CHECK: spirv.LogicalNotEqual %2 = arith.xori %arg0, %arg1 : vector<4xi1> return } // CHECK-LABEL: @shift_scalar func.func @shift_scalar(%arg0 : i32, %arg1 : i32) { - // CHECK: spv.ShiftLeftLogical + // CHECK: spirv.ShiftLeftLogical %0 = arith.shli %arg0, %arg1 : i32 - // CHECK: spv.ShiftRightArithmetic + // CHECK: spirv.ShiftRightArithmetic %1 = arith.shrsi %arg0, %arg1 : i32 - // CHECK: spv.ShiftRightLogical + // CHECK: spirv.ShiftRightLogical %2 = arith.shrui %arg0, %arg1 : i32 return } // CHECK-LABEL: @shift_vector func.func @shift_vector(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) { - // CHECK: spv.ShiftLeftLogical + // CHECK: spirv.ShiftLeftLogical %0 = arith.shli %arg0, %arg1 : vector<4xi32> - // CHECK: spv.ShiftRightArithmetic + // CHECK: spirv.ShiftRightArithmetic %1 = arith.shrsi %arg0, %arg1 : vector<4xi32> - // CHECK: spv.ShiftRightLogical + // CHECK: spirv.ShiftRightLogical %2 = arith.shrui %arg0, %arg1 : vector<4xi32> return } @@ -1374,43 +1374,43 @@ //===----------------------------------------------------------------------===// module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @cmpf func.func @cmpf(%arg0 : f32, %arg1 : f32) { - // CHECK: spv.FOrdEqual + // CHECK: spirv.FOrdEqual %1 = arith.cmpf oeq, %arg0, %arg1 : f32 - // CHECK: spv.FOrdGreaterThan + // CHECK: spirv.FOrdGreaterThan %2 = arith.cmpf ogt, %arg0, %arg1 : f32 - // CHECK: spv.FOrdGreaterThanEqual + // CHECK: spirv.FOrdGreaterThanEqual %3 = arith.cmpf oge, %arg0, %arg1 : f32 - // CHECK: spv.FOrdLessThan + // CHECK: spirv.FOrdLessThan %4 = arith.cmpf olt, %arg0, %arg1 : f32 - // CHECK: spv.FOrdLessThanEqual + // CHECK: spirv.FOrdLessThanEqual %5 = arith.cmpf ole, %arg0, %arg1 : f32 - // CHECK: spv.FOrdNotEqual + // CHECK: spirv.FOrdNotEqual %6 = arith.cmpf one, %arg0, %arg1 : f32 - // CHECK: spv.FUnordEqual + // CHECK: spirv.FUnordEqual %7 = arith.cmpf ueq, %arg0, %arg1 : f32 - // CHECK: spv.FUnordGreaterThan + // CHECK: spirv.FUnordGreaterThan %8 = arith.cmpf ugt, %arg0, %arg1 : f32 - // CHECK: spv.FUnordGreaterThanEqual + // CHECK: spirv.FUnordGreaterThanEqual %9 = arith.cmpf uge, %arg0, %arg1 : f32 - // CHECK: spv.FUnordLessThan + // CHECK: spirv.FUnordLessThan %10 = arith.cmpf ult, %arg0, %arg1 : f32 // CHECK: FUnordLessThanEqual %11 = arith.cmpf ule, %arg0, %arg1 : f32 - // CHECK: spv.FUnordNotEqual + // CHECK: spirv.FUnordNotEqual %12 = arith.cmpf une, %arg0, %arg1 : f32 return } // CHECK-LABEL: @vec1cmpf func.func @vec1cmpf(%arg0 : vector<1xf32>, %arg1 : vector<1xf32>) { - // CHECK: spv.FOrdGreaterThan + // CHECK: spirv.FOrdGreaterThan %0 = arith.cmpf ogt, %arg0, %arg1 : vector<1xf32> - // CHECK: spv.FUnordLessThan + // CHECK: spirv.FUnordLessThan %1 = arith.cmpf ult, %arg0, %arg1 : vector<1xf32> return } @@ -1419,16 +1419,16 @@ // ----- -// With Kernel capability, we can convert NaN check to spv.Ordered/spv.Unordered. +// With Kernel capability, we can convert NaN check to spirv.Ordered/spirv.Unordered. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @cmpf func.func @cmpf(%arg0 : f32, %arg1 : f32) { - // CHECK: spv.Ordered + // CHECK: spirv.Ordered %0 = arith.cmpf ord, %arg0, %arg1 : f32 - // CHECK: spv.Unordered + // CHECK: spirv.Unordered %1 = arith.cmpf uno, %arg0, %arg1 : f32 return } @@ -1437,23 +1437,23 @@ // ----- -// Without Kernel capability, we need to convert NaN check to spv.IsNan. +// Without Kernel capability, we need to convert NaN check to spirv.IsNan. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @cmpf // CHECK-SAME: %[[LHS:.+]]: f32, %[[RHS:.+]]: f32 func.func @cmpf(%arg0 : f32, %arg1 : f32) { - // CHECK: %[[LHS_NAN:.+]] = spv.IsNan %[[LHS]] : f32 - // CHECK-NEXT: %[[RHS_NAN:.+]] = spv.IsNan %[[RHS]] : f32 - // CHECK-NEXT: %[[OR:.+]] = spv.LogicalOr %[[LHS_NAN]], %[[RHS_NAN]] : i1 - // CHECK-NEXT: %{{.+}} = spv.LogicalNot %[[OR]] : i1 + // CHECK: %[[LHS_NAN:.+]] = spirv.IsNan %[[LHS]] : f32 + // CHECK-NEXT: %[[RHS_NAN:.+]] = spirv.IsNan %[[RHS]] : f32 + // CHECK-NEXT: %[[OR:.+]] = spirv.LogicalOr %[[LHS_NAN]], %[[RHS_NAN]] : i1 + // CHECK-NEXT: %{{.+}} = spirv.LogicalNot %[[OR]] : i1 %0 = arith.cmpf ord, %arg0, %arg1 : f32 - // CHECK-NEXT: %[[LHS_NAN:.+]] = spv.IsNan %[[LHS]] : f32 - // CHECK-NEXT: %[[RHS_NAN:.+]] = spv.IsNan %[[RHS]] : f32 - // CHECK-NEXT: %{{.+}} = spv.LogicalOr %[[LHS_NAN]], %[[RHS_NAN]] : i1 + // CHECK-NEXT: %[[LHS_NAN:.+]] = spirv.IsNan %[[LHS]] : f32 + // CHECK-NEXT: %[[RHS_NAN:.+]] = spirv.IsNan %[[RHS]] : f32 + // CHECK-NEXT: %{{.+}} = spirv.LogicalOr %[[LHS_NAN]], %[[RHS_NAN]] : i1 %1 = arith.cmpf uno, %arg0, %arg1 : f32 return } @@ -1467,48 +1467,48 @@ //===----------------------------------------------------------------------===// module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @cmpi func.func @cmpi(%arg0 : i32, %arg1 : i32) { - // CHECK: spv.IEqual + // CHECK: spirv.IEqual %0 = arith.cmpi eq, %arg0, %arg1 : i32 - // CHECK: spv.INotEqual + // CHECK: spirv.INotEqual %1 = arith.cmpi ne, %arg0, %arg1 : i32 - // CHECK: spv.SLessThan + // CHECK: spirv.SLessThan %2 = arith.cmpi slt, %arg0, %arg1 : i32 - // CHECK: spv.SLessThanEqual + // CHECK: spirv.SLessThanEqual %3 = arith.cmpi sle, %arg0, %arg1 : i32 - // CHECK: spv.SGreaterThan + // CHECK: spirv.SGreaterThan %4 = arith.cmpi sgt, %arg0, %arg1 : i32 - // CHECK: spv.SGreaterThanEqual + // CHECK: spirv.SGreaterThanEqual %5 = arith.cmpi sge, %arg0, %arg1 : i32 - // CHECK: spv.ULessThan + // CHECK: spirv.ULessThan %6 = arith.cmpi ult, %arg0, %arg1 : i32 - // CHECK: spv.ULessThanEqual + // CHECK: spirv.ULessThanEqual %7 = arith.cmpi ule, %arg0, %arg1 : i32 - // CHECK: spv.UGreaterThan + // CHECK: spirv.UGreaterThan %8 = arith.cmpi ugt, %arg0, %arg1 : i32 - // CHECK: spv.UGreaterThanEqual + // CHECK: spirv.UGreaterThanEqual %9 = arith.cmpi uge, %arg0, %arg1 : i32 return } // CHECK-LABEL: @boolcmpi func.func @boolcmpi(%arg0 : i1, %arg1 : i1) { - // CHECK: spv.LogicalEqual + // CHECK: spirv.LogicalEqual %0 = arith.cmpi eq, %arg0, %arg1 : i1 - // CHECK: spv.LogicalNotEqual + // CHECK: spirv.LogicalNotEqual %1 = arith.cmpi ne, %arg0, %arg1 : i1 return } // CHECK-LABEL: @vecboolcmpi func.func @vecboolcmpi(%arg0 : vector<4xi1>, %arg1 : vector<4xi1>) { - // CHECK: spv.LogicalEqual + // CHECK: spirv.LogicalEqual %0 = arith.cmpi eq, %arg0, %arg1 : vector<4xi1> - // CHECK: spv.LogicalNotEqual + // CHECK: spirv.LogicalNotEqual %1 = arith.cmpi ne, %arg0, %arg1 : vector<4xi1> return } @@ -1522,59 +1522,59 @@ //===----------------------------------------------------------------------===// module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @constant func.func @constant() { - // CHECK: spv.Constant true + // CHECK: spirv.Constant true %0 = arith.constant true - // CHECK: spv.Constant 42 : i32 + // CHECK: spirv.Constant 42 : i32 %1 = arith.constant 42 : i32 - // CHECK: spv.Constant 5.000000e-01 : f32 + // CHECK: spirv.Constant 5.000000e-01 : f32 %2 = arith.constant 0.5 : f32 - // CHECK: spv.Constant dense<[2, 3]> : vector<2xi32> + // CHECK: spirv.Constant dense<[2, 3]> : vector<2xi32> %3 = arith.constant dense<[2, 3]> : vector<2xi32> - // CHECK: spv.Constant 1 : i32 + // CHECK: spirv.Constant 1 : i32 %4 = arith.constant 1 : index - // CHECK: spv.Constant dense<1> : tensor<6xi32> : !spv.array<6 x i32> + // CHECK: spirv.Constant dense<1> : tensor<6xi32> : !spirv.array<6 x i32> %5 = arith.constant dense<1> : tensor<2x3xi32> - // CHECK: spv.Constant dense<1.000000e+00> : tensor<6xf32> : !spv.array<6 x f32> + // CHECK: spirv.Constant dense<1.000000e+00> : tensor<6xf32> : !spirv.array<6 x f32> %6 = arith.constant dense<1.0> : tensor<2x3xf32> - // CHECK: spv.Constant dense<{{\[}}1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00, 5.000000e+00, 6.000000e+00]> : tensor<6xf32> : !spv.array<6 x f32> + // CHECK: spirv.Constant dense<{{\[}}1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00, 5.000000e+00, 6.000000e+00]> : tensor<6xf32> : !spirv.array<6 x f32> %7 = arith.constant dense<[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]> : tensor<2x3xf32> - // CHECK: spv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spv.array<6 x i32> + // CHECK: spirv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spirv.array<6 x i32> %8 = arith.constant dense<[[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi32> - // CHECK: spv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spv.array<6 x i32> + // CHECK: spirv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spirv.array<6 x i32> %9 = arith.constant dense<[[1, 2], [3, 4], [5, 6]]> : tensor<3x2xi32> - // CHECK: spv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spv.array<6 x i32> + // CHECK: spirv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spirv.array<6 x i32> %10 = arith.constant dense<[1, 2, 3, 4, 5, 6]> : tensor<6xi32> return } // CHECK-LABEL: @constant_16bit func.func @constant_16bit() { - // CHECK: spv.Constant 4 : i16 + // CHECK: spirv.Constant 4 : i16 %0 = arith.constant 4 : i16 - // CHECK: spv.Constant 5.000000e+00 : f16 + // CHECK: spirv.Constant 5.000000e+00 : f16 %1 = arith.constant 5.0 : f16 - // CHECK: spv.Constant dense<[2, 3]> : vector<2xi16> + // CHECK: spirv.Constant dense<[2, 3]> : vector<2xi16> %2 = arith.constant dense<[2, 3]> : vector<2xi16> - // CHECK: spv.Constant dense<4.000000e+00> : tensor<5xf16> : !spv.array<5 x f16> + // CHECK: spirv.Constant dense<4.000000e+00> : tensor<5xf16> : !spirv.array<5 x f16> %3 = arith.constant dense<4.0> : tensor<5xf16> return } // CHECK-LABEL: @constant_64bit func.func @constant_64bit() { - // CHECK: spv.Constant 4 : i64 + // CHECK: spirv.Constant 4 : i64 %0 = arith.constant 4 : i64 - // CHECK: spv.Constant 5.000000e+00 : f64 + // CHECK: spirv.Constant 5.000000e+00 : f64 %1 = arith.constant 5.0 : f64 - // CHECK: spv.Constant dense<[2, 3]> : vector<2xi64> + // CHECK: spirv.Constant dense<[2, 3]> : vector<2xi64> %2 = arith.constant dense<[2, 3]> : vector<2xi64> - // CHECK: spv.Constant dense<4.000000e+00> : tensor<5xf64> : !spv.array<5 x f64> + // CHECK: spirv.Constant dense<4.000000e+00> : tensor<5xf64> : !spirv.array<5 x f64> %3 = arith.constant dense<4.0> : tensor<5xf64> return } @@ -1585,63 +1585,63 @@ // Check that constants are converted to 32-bit when no special capability. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @constant_16bit func.func @constant_16bit() { - // CHECK: spv.Constant 4 : i32 + // CHECK: spirv.Constant 4 : i32 %0 = arith.constant 4 : i16 - // CHECK: spv.Constant 5.000000e+00 : f32 + // CHECK: spirv.Constant 5.000000e+00 : f32 %1 = arith.constant 5.0 : f16 - // CHECK: spv.Constant dense<[2, 3]> : vector<2xi32> + // CHECK: spirv.Constant dense<[2, 3]> : vector<2xi32> %2 = arith.constant dense<[2, 3]> : vector<2xi16> - // CHECK: spv.Constant dense<4.000000e+00> : tensor<5xf32> : !spv.array<5 x f32> + // CHECK: spirv.Constant dense<4.000000e+00> : tensor<5xf32> : !spirv.array<5 x f32> %3 = arith.constant dense<4.0> : tensor<5xf16> - // CHECK: spv.Constant dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : tensor<4xf32> : !spv.array<4 x f32> + // CHECK: spirv.Constant dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : tensor<4xf32> : !spirv.array<4 x f32> %4 = arith.constant dense<[[1.0, 2.0], [3.0, 4.0]]> : tensor<2x2xf16> return } // CHECK-LABEL: @constant_64bit func.func @constant_64bit() { - // CHECK: spv.Constant 4 : i32 + // CHECK: spirv.Constant 4 : i32 %0 = arith.constant 4 : i64 - // CHECK: spv.Constant 5.000000e+00 : f32 + // CHECK: spirv.Constant 5.000000e+00 : f32 %1 = arith.constant 5.0 : f64 - // CHECK: spv.Constant dense<[2, 3]> : vector<2xi32> + // CHECK: spirv.Constant dense<[2, 3]> : vector<2xi32> %2 = arith.constant dense<[2, 3]> : vector<2xi64> - // CHECK: spv.Constant dense<4.000000e+00> : tensor<5xf32> : !spv.array<5 x f32> + // CHECK: spirv.Constant dense<4.000000e+00> : tensor<5xf32> : !spirv.array<5 x f32> %3 = arith.constant dense<4.0> : tensor<5xf64> - // CHECK: spv.Constant dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : tensor<4xf32> : !spv.array<4 x f32> + // CHECK: spirv.Constant dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : tensor<4xf32> : !spirv.array<4 x f32> %4 = arith.constant dense<[[1.0, 2.0], [3.0, 4.0]]> : tensor<2x2xf16> return } // CHECK-LABEL: @corner_cases func.func @corner_cases() { - // CHECK: %{{.*}} = spv.Constant -1 : i32 + // CHECK: %{{.*}} = spirv.Constant -1 : i32 %0 = arith.constant 4294967295 : i64 // 2^32 - 1 - // CHECK: %{{.*}} = spv.Constant 2147483647 : i32 + // CHECK: %{{.*}} = spirv.Constant 2147483647 : i32 %1 = arith.constant 2147483647 : i64 // 2^31 - 1 - // CHECK: %{{.*}} = spv.Constant -2147483648 : i32 + // CHECK: %{{.*}} = spirv.Constant -2147483648 : i32 %2 = arith.constant 2147483648 : i64 // 2^31 - // CHECK: %{{.*}} = spv.Constant -2147483648 : i32 + // CHECK: %{{.*}} = spirv.Constant -2147483648 : i32 %3 = arith.constant -2147483648 : i64 // -2^31 - // CHECK: %{{.*}} = spv.Constant -1 : i32 + // CHECK: %{{.*}} = spirv.Constant -1 : i32 %5 = arith.constant -1 : i64 - // CHECK: %{{.*}} = spv.Constant -2 : i32 + // CHECK: %{{.*}} = spirv.Constant -2 : i32 %6 = arith.constant -2 : i64 - // CHECK: %{{.*}} = spv.Constant -1 : i32 + // CHECK: %{{.*}} = spirv.Constant -1 : i32 %7 = arith.constant -1 : index - // CHECK: %{{.*}} = spv.Constant -2 : i32 + // CHECK: %{{.*}} = spirv.Constant -2 : i32 %8 = arith.constant -2 : index - // CHECK: spv.Constant false + // CHECK: spirv.Constant false %9 = arith.constant false - // CHECK: spv.Constant true + // CHECK: spirv.Constant true %10 = arith.constant true return @@ -1667,235 +1667,235 @@ //===----------------------------------------------------------------------===// module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: index_cast1 func.func @index_cast1(%arg0: i16) { - // CHECK: spv.SConvert %{{.+}} : i16 to i32 + // CHECK: spirv.SConvert %{{.+}} : i16 to i32 %0 = arith.index_cast %arg0 : i16 to index return } // CHECK-LABEL: index_cast2 func.func @index_cast2(%arg0: index) { - // CHECK: spv.SConvert %{{.+}} : i32 to i16 + // CHECK: spirv.SConvert %{{.+}} : i32 to i16 %0 = arith.index_cast %arg0 : index to i16 return } // CHECK-LABEL: index_cast3 func.func @index_cast3(%arg0: i32) { - // CHECK-NOT: spv.SConvert + // CHECK-NOT: spirv.SConvert %0 = arith.index_cast %arg0 : i32 to index return } // CHECK-LABEL: index_cast4 func.func @index_cast4(%arg0: index) { - // CHECK-NOT: spv.SConvert + // CHECK-NOT: spirv.SConvert %0 = arith.index_cast %arg0 : index to i32 return } // CHECK-LABEL: @fpext1 func.func @fpext1(%arg0: f16) -> f64 { - // CHECK: spv.FConvert %{{.*}} : f16 to f64 + // CHECK: spirv.FConvert %{{.*}} : f16 to f64 %0 = arith.extf %arg0 : f16 to f64 return %0 : f64 } // CHECK-LABEL: @fpext2 func.func @fpext2(%arg0 : f32) -> f64 { - // CHECK: spv.FConvert %{{.*}} : f32 to f64 + // CHECK: spirv.FConvert %{{.*}} : f32 to f64 %0 = arith.extf %arg0 : f32 to f64 return %0 : f64 } // CHECK-LABEL: @fptrunc1 func.func @fptrunc1(%arg0 : f64) -> f16 { - // CHECK: spv.FConvert %{{.*}} : f64 to f16 + // CHECK: spirv.FConvert %{{.*}} : f64 to f16 %0 = arith.truncf %arg0 : f64 to f16 return %0 : f16 } // CHECK-LABEL: @fptrunc2 func.func @fptrunc2(%arg0: f32) -> f16 { - // CHECK: spv.FConvert %{{.*}} : f32 to f16 + // CHECK: spirv.FConvert %{{.*}} : f32 to f16 %0 = arith.truncf %arg0 : f32 to f16 return %0 : f16 } // CHECK-LABEL: @sitofp1 func.func @sitofp1(%arg0 : i32) -> f32 { - // CHECK: spv.ConvertSToF %{{.*}} : i32 to f32 + // CHECK: spirv.ConvertSToF %{{.*}} : i32 to f32 %0 = arith.sitofp %arg0 : i32 to f32 return %0 : f32 } // CHECK-LABEL: @sitofp2 func.func @sitofp2(%arg0 : i64) -> f64 { - // CHECK: spv.ConvertSToF %{{.*}} : i64 to f64 + // CHECK: spirv.ConvertSToF %{{.*}} : i64 to f64 %0 = arith.sitofp %arg0 : i64 to f64 return %0 : f64 } // CHECK-LABEL: @uitofp_i16_f32 func.func @uitofp_i16_f32(%arg0: i16) -> f32 { - // CHECK: spv.ConvertUToF %{{.*}} : i16 to f32 + // CHECK: spirv.ConvertUToF %{{.*}} : i16 to f32 %0 = arith.uitofp %arg0 : i16 to f32 return %0 : f32 } // CHECK-LABEL: @uitofp_i32_f32 func.func @uitofp_i32_f32(%arg0 : i32) -> f32 { - // CHECK: spv.ConvertUToF %{{.*}} : i32 to f32 + // CHECK: spirv.ConvertUToF %{{.*}} : i32 to f32 %0 = arith.uitofp %arg0 : i32 to f32 return %0 : f32 } // CHECK-LABEL: @uitofp_i1_f32 func.func @uitofp_i1_f32(%arg0 : i1) -> f32 { - // CHECK: %[[ZERO:.+]] = spv.Constant 0.000000e+00 : f32 - // CHECK: %[[ONE:.+]] = spv.Constant 1.000000e+00 : f32 - // CHECK: spv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, f32 + // CHECK: %[[ZERO:.+]] = spirv.Constant 0.000000e+00 : f32 + // CHECK: %[[ONE:.+]] = spirv.Constant 1.000000e+00 : f32 + // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, f32 %0 = arith.uitofp %arg0 : i1 to f32 return %0 : f32 } // CHECK-LABEL: @uitofp_i1_f64 func.func @uitofp_i1_f64(%arg0 : i1) -> f64 { - // CHECK: %[[ZERO:.+]] = spv.Constant 0.000000e+00 : f64 - // CHECK: %[[ONE:.+]] = spv.Constant 1.000000e+00 : f64 - // CHECK: spv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, f64 + // CHECK: %[[ZERO:.+]] = spirv.Constant 0.000000e+00 : f64 + // CHECK: %[[ONE:.+]] = spirv.Constant 1.000000e+00 : f64 + // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, f64 %0 = arith.uitofp %arg0 : i1 to f64 return %0 : f64 } // CHECK-LABEL: @uitofp_vec_i1_f32 func.func @uitofp_vec_i1_f32(%arg0 : vector<4xi1>) -> vector<4xf32> { - // CHECK: %[[ZERO:.+]] = spv.Constant dense<0.000000e+00> : vector<4xf32> - // CHECK: %[[ONE:.+]] = spv.Constant dense<1.000000e+00> : vector<4xf32> - // CHECK: spv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xf32> + // CHECK: %[[ZERO:.+]] = spirv.Constant dense<0.000000e+00> : vector<4xf32> + // CHECK: %[[ONE:.+]] = spirv.Constant dense<1.000000e+00> : vector<4xf32> + // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xf32> %0 = arith.uitofp %arg0 : vector<4xi1> to vector<4xf32> return %0 : vector<4xf32> } // CHECK-LABEL: @uitofp_vec_i1_f64 -spv.func @uitofp_vec_i1_f64(%arg0: vector<4xi1>) -> vector<4xf64> "None" { - // CHECK: %[[ZERO:.+]] = spv.Constant dense<0.000000e+00> : vector<4xf64> - // CHECK: %[[ONE:.+]] = spv.Constant dense<1.000000e+00> : vector<4xf64> - // CHECK: spv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xf64> - %0 = spv.Constant dense<0.000000e+00> : vector<4xf64> - %1 = spv.Constant dense<1.000000e+00> : vector<4xf64> - %2 = spv.Select %arg0, %1, %0 : vector<4xi1>, vector<4xf64> - spv.ReturnValue %2 : vector<4xf64> +spirv.func @uitofp_vec_i1_f64(%arg0: vector<4xi1>) -> vector<4xf64> "None" { + // CHECK: %[[ZERO:.+]] = spirv.Constant dense<0.000000e+00> : vector<4xf64> + // CHECK: %[[ONE:.+]] = spirv.Constant dense<1.000000e+00> : vector<4xf64> + // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xf64> + %0 = spirv.Constant dense<0.000000e+00> : vector<4xf64> + %1 = spirv.Constant dense<1.000000e+00> : vector<4xf64> + %2 = spirv.Select %arg0, %1, %0 : vector<4xi1>, vector<4xf64> + spirv.ReturnValue %2 : vector<4xf64> } // CHECK-LABEL: @sexti1 func.func @sexti1(%arg0: i16) -> i64 { - // CHECK: spv.SConvert %{{.*}} : i16 to i64 + // CHECK: spirv.SConvert %{{.*}} : i16 to i64 %0 = arith.extsi %arg0 : i16 to i64 return %0 : i64 } // CHECK-LABEL: @sexti2 func.func @sexti2(%arg0 : i32) -> i64 { - // CHECK: spv.SConvert %{{.*}} : i32 to i64 + // CHECK: spirv.SConvert %{{.*}} : i32 to i64 %0 = arith.extsi %arg0 : i32 to i64 return %0 : i64 } // CHECK-LABEL: @zexti1 func.func @zexti1(%arg0: i16) -> i64 { - // CHECK: spv.UConvert %{{.*}} : i16 to i64 + // CHECK: spirv.UConvert %{{.*}} : i16 to i64 %0 = arith.extui %arg0 : i16 to i64 return %0 : i64 } // CHECK-LABEL: @zexti2 func.func @zexti2(%arg0 : i32) -> i64 { - // CHECK: spv.UConvert %{{.*}} : i32 to i64 + // CHECK: spirv.UConvert %{{.*}} : i32 to i64 %0 = arith.extui %arg0 : i32 to i64 return %0 : i64 } // CHECK-LABEL: @zexti3 func.func @zexti3(%arg0 : i1) -> i32 { - // CHECK: %[[ZERO:.+]] = spv.Constant 0 : i32 - // CHECK: %[[ONE:.+]] = spv.Constant 1 : i32 - // CHECK: spv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, i32 + // CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32 + // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, i32 %0 = arith.extui %arg0 : i1 to i32 return %0 : i32 } // CHECK-LABEL: @zexti4 func.func @zexti4(%arg0 : vector<4xi1>) -> vector<4xi32> { - // CHECK: %[[ZERO:.+]] = spv.Constant dense<0> : vector<4xi32> - // CHECK: %[[ONE:.+]] = spv.Constant dense<1> : vector<4xi32> - // CHECK: spv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xi32> + // CHECK: %[[ZERO:.+]] = spirv.Constant dense<0> : vector<4xi32> + // CHECK: %[[ONE:.+]] = spirv.Constant dense<1> : vector<4xi32> + // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xi32> %0 = arith.extui %arg0 : vector<4xi1> to vector<4xi32> return %0 : vector<4xi32> } // CHECK-LABEL: @zexti5 func.func @zexti5(%arg0 : vector<4xi1>) -> vector<4xi64> { - // CHECK: %[[ZERO:.+]] = spv.Constant dense<0> : vector<4xi64> - // CHECK: %[[ONE:.+]] = spv.Constant dense<1> : vector<4xi64> - // CHECK: spv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xi64> + // CHECK: %[[ZERO:.+]] = spirv.Constant dense<0> : vector<4xi64> + // CHECK: %[[ONE:.+]] = spirv.Constant dense<1> : vector<4xi64> + // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xi64> %0 = arith.extui %arg0 : vector<4xi1> to vector<4xi64> return %0 : vector<4xi64> } // CHECK-LABEL: @trunci1 func.func @trunci1(%arg0 : i64) -> i16 { - // CHECK: spv.SConvert %{{.*}} : i64 to i16 + // CHECK: spirv.SConvert %{{.*}} : i64 to i16 %0 = arith.trunci %arg0 : i64 to i16 return %0 : i16 } // CHECK-LABEL: @trunci2 func.func @trunci2(%arg0: i32) -> i16 { - // CHECK: spv.SConvert %{{.*}} : i32 to i16 + // CHECK: spirv.SConvert %{{.*}} : i32 to i16 %0 = arith.trunci %arg0 : i32 to i16 return %0 : i16 } // CHECK-LABEL: @trunc_to_i1 func.func @trunc_to_i1(%arg0: i32) -> i1 { - // CHECK: %[[MASK:.*]] = spv.Constant 1 : i32 - // CHECK: %[[MASKED_SRC:.*]] = spv.BitwiseAnd %{{.*}}, %[[MASK]] : i32 - // CHECK: %[[IS_ONE:.*]] = spv.IEqual %[[MASKED_SRC]], %[[MASK]] : i32 - // CHECK-DAG: %[[TRUE:.*]] = spv.Constant true - // CHECK-DAG: %[[FALSE:.*]] = spv.Constant false - // CHECK: spv.Select %[[IS_ONE]], %[[TRUE]], %[[FALSE]] : i1, i1 + // CHECK: %[[MASK:.*]] = spirv.Constant 1 : i32 + // CHECK: %[[MASKED_SRC:.*]] = spirv.BitwiseAnd %{{.*}}, %[[MASK]] : i32 + // CHECK: %[[IS_ONE:.*]] = spirv.IEqual %[[MASKED_SRC]], %[[MASK]] : i32 + // CHECK-DAG: %[[TRUE:.*]] = spirv.Constant true + // CHECK-DAG: %[[FALSE:.*]] = spirv.Constant false + // CHECK: spirv.Select %[[IS_ONE]], %[[TRUE]], %[[FALSE]] : i1, i1 %0 = arith.trunci %arg0 : i32 to i1 return %0 : i1 } // CHECK-LABEL: @trunc_to_veci1 func.func @trunc_to_veci1(%arg0: vector<4xi32>) -> vector<4xi1> { - // CHECK: %[[MASK:.*]] = spv.Constant dense<1> : vector<4xi32> - // CHECK: %[[MASKED_SRC:.*]] = spv.BitwiseAnd %{{.*}}, %[[MASK]] : vector<4xi32> - // CHECK: %[[IS_ONE:.*]] = spv.IEqual %[[MASKED_SRC]], %[[MASK]] : vector<4xi32> - // CHECK-DAG: %[[TRUE:.*]] = spv.Constant dense : vector<4xi1> - // CHECK-DAG: %[[FALSE:.*]] = spv.Constant dense : vector<4xi1> - // CHECK: spv.Select %[[IS_ONE]], %[[TRUE]], %[[FALSE]] : vector<4xi1>, vector<4xi1> + // CHECK: %[[MASK:.*]] = spirv.Constant dense<1> : vector<4xi32> + // CHECK: %[[MASKED_SRC:.*]] = spirv.BitwiseAnd %{{.*}}, %[[MASK]] : vector<4xi32> + // CHECK: %[[IS_ONE:.*]] = spirv.IEqual %[[MASKED_SRC]], %[[MASK]] : vector<4xi32> + // CHECK-DAG: %[[TRUE:.*]] = spirv.Constant dense : vector<4xi1> + // CHECK-DAG: %[[FALSE:.*]] = spirv.Constant dense : vector<4xi1> + // CHECK: spirv.Select %[[IS_ONE]], %[[TRUE]], %[[FALSE]] : vector<4xi1>, vector<4xi1> %0 = arith.trunci %arg0 : vector<4xi32> to vector<4xi1> return %0 : vector<4xi1> } // CHECK-LABEL: @fptosi1 func.func @fptosi1(%arg0 : f32) -> i32 { - // CHECK: spv.ConvertFToS %{{.*}} : f32 to i32 + // CHECK: spirv.ConvertFToS %{{.*}} : f32 to i32 %0 = arith.fptosi %arg0 : f32 to i32 return %0 : i32 } // CHECK-LABEL: @fptosi2 func.func @fptosi2(%arg0 : f16) -> i16 { - // CHECK: spv.ConvertFToS %{{.*}} : f16 to i16 + // CHECK: spirv.ConvertFToS %{{.*}} : f16 to i16 %0 = arith.fptosi %arg0 : f16 to i16 return %0 : i16 } @@ -1907,14 +1907,14 @@ // Checks that cast types will be adjusted when missing special capabilities for // certain non-32-bit scalar types. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @fpext1 // CHECK-SAME: %[[A:.*]]: f16 func.func @fpext1(%arg0: f16) -> f64 { // CHECK: %[[ARG:.+]] = builtin.unrealized_conversion_cast %[[A]] : f16 to f32 - // CHECK-NEXT: spv.FConvert %[[ARG]] : f32 to f64 + // CHECK-NEXT: spirv.FConvert %[[ARG]] : f32 to f64 %0 = arith.extf %arg0 : f16 to f64 return %0: f64 } @@ -1922,7 +1922,7 @@ // CHECK-LABEL: @fpext2 // CHECK-SAME: %[[ARG:.*]]: f32 func.func @fpext2(%arg0 : f32) -> f64 { - // CHECK-NEXT: spv.FConvert %[[ARG]] : f32 to f64 + // CHECK-NEXT: spirv.FConvert %[[ARG]] : f32 to f64 %0 = arith.extf %arg0 : f32 to f64 return %0: f64 } @@ -1934,14 +1934,14 @@ // Checks that cast types will be adjusted when missing special capabilities for // certain non-32-bit scalar types. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @fptrunc1 // CHECK-SAME: %[[A:.*]]: f64 func.func @fptrunc1(%arg0 : f64) -> f16 { // CHECK: %[[ARG:.+]] = builtin.unrealized_conversion_cast %[[A]] : f64 to f32 - // CHECK-NEXT: spv.FConvert %[[ARG]] : f32 to f16 + // CHECK-NEXT: spirv.FConvert %[[ARG]] : f32 to f16 %0 = arith.truncf %arg0 : f64 to f16 return %0: f16 } @@ -1949,14 +1949,14 @@ // CHECK-LABEL: @fptrunc2 // CHECK-SAME: %[[ARG:.*]]: f32 func.func @fptrunc2(%arg0: f32) -> f16 { - // CHECK-NEXT: spv.FConvert %[[ARG]] : f32 to f16 + // CHECK-NEXT: spirv.FConvert %[[ARG]] : f32 to f16 %0 = arith.truncf %arg0 : f32 to f16 return %0: f16 } // CHECK-LABEL: @sitofp func.func @sitofp(%arg0 : i64) -> f64 { - // CHECK: spv.ConvertSToF %{{.*}} : i32 to f32 + // CHECK: spirv.ConvertSToF %{{.*}} : i32 to f32 %0 = arith.sitofp %arg0 : i64 to f64 return %0: f64 } diff --git a/mlir/test/Conversion/ArithmeticToSPIRV/fast-math.mlir b/mlir/test/Conversion/ArithmeticToSPIRV/fast-math.mlir --- a/mlir/test/Conversion/ArithmeticToSPIRV/fast-math.mlir +++ b/mlir/test/Conversion/ArithmeticToSPIRV/fast-math.mlir @@ -1,13 +1,13 @@ // RUN: mlir-opt -split-input-file -convert-arith-to-spirv=enable-fast-math -verify-diagnostics %s | FileCheck %s module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @cmpf_ordered // CHECK-SAME: %[[LHS:.+]]: f32, %[[RHS:.+]]: f32 func.func @cmpf_ordered(%arg0 : f32, %arg1 : f32) -> i1 { - // CHECK: %[[T:.+]] = spv.Constant true + // CHECK: %[[T:.+]] = spirv.Constant true %0 = arith.cmpf ord, %arg0, %arg1 : f32 // CHECK: return %[[T]] return %0: i1 @@ -16,7 +16,7 @@ // CHECK-LABEL: @cmpf_unordered // CHECK-SAME: %[[LHS:.+]]: vector<4xf32>, %[[RHS:.+]]: vector<4xf32> func.func @cmpf_unordered(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) -> vector<4xi1> { - // CHECK: %[[F:.+]] = spv.Constant dense + // CHECK: %[[F:.+]] = spirv.Constant dense %0 = arith.cmpf uno, %arg0, %arg1 : vector<4xf32> // CHECK: return %[[F]] return %0: vector<4xi1> @@ -27,13 +27,13 @@ // ----- module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @minf // CHECK-SAME: %[[LHS:.+]]: f32, %[[RHS:.+]]: f32 func.func @minf(%arg0 : f32, %arg1 : f32) -> f32 { - // CHECK: %[[F:.+]] = spv.GL.FMin %[[LHS]], %[[RHS]] + // CHECK: %[[F:.+]] = spirv.GL.FMin %[[LHS]], %[[RHS]] %0 = arith.minf %arg0, %arg1 : f32 // CHECK: return %[[F]] return %0: f32 @@ -42,7 +42,7 @@ // CHECK-LABEL: @maxf // CHECK-SAME: %[[LHS:.+]]: vector<4xf32>, %[[RHS:.+]]: vector<4xf32> func.func @maxf(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) -> vector<4xf32> { - // CHECK: %[[F:.+]] = spv.GL.FMax %[[LHS]], %[[RHS]] + // CHECK: %[[F:.+]] = spirv.GL.FMax %[[LHS]], %[[RHS]] %0 = arith.maxf %arg0, %arg1 : vector<4xf32> // CHECK: return %[[F]] return %0: vector<4xf32> diff --git a/mlir/test/Conversion/ControlFlowToSPIRV/cf-ops-to-spirv.mlir b/mlir/test/Conversion/ControlFlowToSPIRV/cf-ops-to-spirv.mlir --- a/mlir/test/Conversion/ControlFlowToSPIRV/cf-ops-to-spirv.mlir +++ b/mlir/test/Conversion/ControlFlowToSPIRV/cf-ops-to-spirv.mlir @@ -5,27 +5,27 @@ //===----------------------------------------------------------------------===// module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: func @simple_loop func.func @simple_loop(%begin: i32, %end: i32, %step: i32) { -// CHECK-NEXT: spv.Branch ^bb1 +// CHECK-NEXT: spirv.Branch ^bb1 cf.br ^bb1 // CHECK-NEXT: ^bb1: // pred: ^bb0 -// CHECK-NEXT: spv.Branch ^bb2({{.*}} : i32) +// CHECK-NEXT: spirv.Branch ^bb2({{.*}} : i32) ^bb1: // pred: ^bb0 cf.br ^bb2(%begin : i32) // CHECK: ^bb2({{.*}}: i32): // 2 preds: ^bb1, ^bb3 -// CHECK: spv.BranchConditional {{.*}}, ^bb3, ^bb4 +// CHECK: spirv.BranchConditional {{.*}}, ^bb3, ^bb4 ^bb2(%0: i32): // 2 preds: ^bb1, ^bb3 %1 = arith.cmpi slt, %0, %end : i32 cf.cond_br %1, ^bb3, ^bb4 // CHECK: ^bb3: // pred: ^bb2 -// CHECK: spv.Branch ^bb2({{.*}} : i32) +// CHECK: spirv.Branch ^bb2({{.*}} : i32) ^bb3: // pred: ^bb2 %2 = arith.addi %0, %step : i32 cf.br ^bb2(%2 : i32) diff --git a/mlir/test/Conversion/FuncToSPIRV/func-ops-to-spirv.mlir b/mlir/test/Conversion/FuncToSPIRV/func-ops-to-spirv.mlir --- a/mlir/test/Conversion/FuncToSPIRV/func-ops-to-spirv.mlir +++ b/mlir/test/Conversion/FuncToSPIRV/func-ops-to-spirv.mlir @@ -5,19 +5,19 @@ //===----------------------------------------------------------------------===// module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @return_none_val +// CHECK-LABEL: spirv.func @return_none_val func.func @return_none_val() { - // CHECK: spv.Return + // CHECK: spirv.Return return } -// CHECK-LABEL: spv.func @return_one_val +// CHECK-LABEL: spirv.func @return_one_val // CHECK-SAME: (%[[ARG:.+]]: f32) func.func @return_one_val(%arg0: f32) -> f32 { - // CHECK: spv.ReturnValue %[[ARG]] : f32 + // CHECK: spirv.ReturnValue %[[ARG]] : f32 return %arg0: f32 } @@ -28,21 +28,21 @@ return %arg0, %arg0: f32, f32 } -// CHECK-LABEL: spv.func @return_one_index +// CHECK-LABEL: spirv.func @return_one_index // CHECK-SAME: (%[[ARG:.+]]: i32) func.func @return_one_index(%arg0: index) -> index { - // CHECK: spv.ReturnValue %[[ARG]] : i32 + // CHECK: spirv.ReturnValue %[[ARG]] : i32 return %arg0: index } -// CHECK-LABEL: spv.func @call_functions +// CHECK-LABEL: spirv.func @call_functions // CHECK-SAME: (%[[ARG:.+]]: i32) func.func @call_functions(%arg0: index) -> index { - // CHECK: spv.FunctionCall @return_none_val() : () -> () + // CHECK: spirv.FunctionCall @return_none_val() : () -> () call @return_none_val(): () -> () - // CHECK: {{%.*}} = spv.FunctionCall @return_one_index(%[[ARG]]) : (i32) -> i32 + // CHECK: {{%.*}} = spirv.FunctionCall @return_one_index(%[[ARG]]) : (i32) -> i32 %0 = call @return_one_index(%arg0): (index) -> index - // CHECK: spv.ReturnValue {{%.*}} : i32 + // CHECK: spirv.ReturnValue {{%.*}} : i32 return %0: index } diff --git a/mlir/test/Conversion/FuncToSPIRV/types-to-spirv.mlir b/mlir/test/Conversion/FuncToSPIRV/types-to-spirv.mlir --- a/mlir/test/Conversion/FuncToSPIRV/types-to-spirv.mlir +++ b/mlir/test/Conversion/FuncToSPIRV/types-to-spirv.mlir @@ -8,10 +8,10 @@ // Check that non-32-bit integer types are converted to 32-bit types if the // corresponding capabilities are not available. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @integer8 +// CHECK-LABEL: spirv.func @integer8 // CHECK-SAME: i32 // CHECK-SAME: si32 // CHECK-SAME: ui32 @@ -21,7 +21,7 @@ // NOEMU-SAME: ui8 func.func @integer8(%arg0: i8, %arg1: si8, %arg2: ui8) { return } -// CHECK-LABEL: spv.func @integer16 +// CHECK-LABEL: spirv.func @integer16 // CHECK-SAME: i32 // CHECK-SAME: si32 // CHECK-SAME: ui32 @@ -31,7 +31,7 @@ // NOEMU-SAME: ui16 func.func @integer16(%arg0: i16, %arg1: si16, %arg2: ui16) { return } -// CHECK-LABEL: spv.func @integer64 +// CHECK-LABEL: spirv.func @integer64 // CHECK-SAME: i32 // CHECK-SAME: si32 // CHECK-SAME: ui32 @@ -48,34 +48,34 @@ // Check that non-32-bit integer types are kept untouched if the corresponding // capabilities are available. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @integer8 +// CHECK-LABEL: spirv.func @integer8 // CHECK-SAME: i8 // CHECK-SAME: si8 // CHECK-SAME: ui8 -// NOEMU-LABEL: spv.func @integer8 +// NOEMU-LABEL: spirv.func @integer8 // NOEMU-SAME: i8 // NOEMU-SAME: si8 // NOEMU-SAME: ui8 func.func @integer8(%arg0: i8, %arg1: si8, %arg2: ui8) { return } -// CHECK-LABEL: spv.func @integer16 +// CHECK-LABEL: spirv.func @integer16 // CHECK-SAME: i16 // CHECK-SAME: si16 // CHECK-SAME: ui16 -// NOEMU-LABEL: spv.func @integer16 +// NOEMU-LABEL: spirv.func @integer16 // NOEMU-SAME: i16 // NOEMU-SAME: si16 // NOEMU-SAME: ui16 func.func @integer16(%arg0: i16, %arg1: si16, %arg2: ui16) { return } -// CHECK-LABEL: spv.func @integer64 +// CHECK-LABEL: spirv.func @integer64 // CHECK-SAME: i64 // CHECK-SAME: si64 // CHECK-SAME: ui64 -// NOEMU-LABEL: spv.func @integer64 +// NOEMU-LABEL: spirv.func @integer64 // NOEMU-SAME: i64 // NOEMU-SAME: si64 // NOEMU-SAME: ui64 @@ -87,16 +87,16 @@ // Check that weird bitwidths are not supported. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { -// CHECK-NOT: spv.func @integer4 +// CHECK-NOT: spirv.func @integer4 func.func @integer4(%arg0: i4) { return } -// CHECK-NOT: spv.func @integer128 +// CHECK-NOT: spirv.func @integer128 func.func @integer128(%arg0: i128) { return } -// CHECK-NOT: spv.func @integer42 +// CHECK-NOT: spirv.func @integer42 func.func @integer42(%arg0: i42) { return } } // end module @@ -108,10 +108,10 @@ // The index type is always converted into i32. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @index_type +// CHECK-LABEL: spirv.func @index_type // CHECK-SAME: %{{.*}}: i32 func.func @index_type(%arg0: index) { return } @@ -126,16 +126,16 @@ // Check that non-32-bit float types are converted to 32-bit types if the // corresponding capabilities are not available. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @float16 +// CHECK-LABEL: spirv.func @float16 // CHECK-SAME: f32 // NOEMU-LABEL: func @float16 // NOEMU-SAME: f16 func.func @float16(%arg0: f16) { return } -// CHECK-LABEL: spv.func @float64 +// CHECK-LABEL: spirv.func @float64 // CHECK-SAME: f32 // NOEMU-LABEL: func @float64 // NOEMU-SAME: f64 @@ -148,18 +148,18 @@ // Check that non-32-bit float types are kept untouched if the corresponding // capabilities are available. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @float16 +// CHECK-LABEL: spirv.func @float16 // CHECK-SAME: f16 -// NOEMU-LABEL: spv.func @float16 +// NOEMU-LABEL: spirv.func @float16 // NOEMU-SAME: f16 func.func @float16(%arg0: f16) { return } -// CHECK-LABEL: spv.func @float64 +// CHECK-LABEL: spirv.func @float64 // CHECK-SAME: f64 -// NOEMU-LABEL: spv.func @float64 +// NOEMU-LABEL: spirv.func @float64 // NOEMU-SAME: f64 func.func @float64(%arg0: f64) { return } @@ -169,10 +169,10 @@ // Check that bf16 is not supported. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { -// CHECK-NOT: spv.func @bf16_type +// CHECK-NOT: spirv.func @bf16_type func.func @bf16_type(%arg0: bf16) { return } } // end module @@ -186,10 +186,10 @@ // Check that capabilities for scalar types affects vector types too: no special // capabilities available means using turning element types to 32-bit. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @int_vector +// CHECK-LABEL: spirv.func @int_vector // CHECK-SAME: vector<2xi32> // CHECK-SAME: vector<3xsi32> // CHECK-SAME: vector<4xui32> @@ -199,7 +199,7 @@ %arg2: vector<4xui64> ) { return } -// CHECK-LABEL: spv.func @float_vector +// CHECK-LABEL: spirv.func @float_vector // CHECK-SAME: vector<2xf32> // CHECK-SAME: vector<3xf32> func.func @float_vector( @@ -214,11 +214,11 @@ // Check that capabilities for scalar types affects vector types too: having // special capabilities means keep vector types untouched. module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @int_vector +// CHECK-LABEL: spirv.func @int_vector // CHECK-SAME: vector<2xi8> // CHECK-SAME: vector<3xsi16> // CHECK-SAME: vector<4xui64> @@ -228,7 +228,7 @@ %arg2: vector<4xui64> ) { return } -// CHECK-LABEL: spv.func @float_vector +// CHECK-LABEL: spirv.func @float_vector // CHECK-SAME: vector<2xf16> // CHECK-SAME: vector<3xf64> func.func @float_vector( @@ -236,11 +236,11 @@ %arg1: vector<3xf64> ) { return } -// CHECK-LABEL: spv.func @one_element_vector +// CHECK-LABEL: spirv.func @one_element_vector // CHECK-SAME: %{{.+}}: i32 func.func @one_element_vector(%arg0: vector<1xi32>) { return } -// CHECK-LABEL: spv.func @zerod_vector +// CHECK-LABEL: spirv.func @zerod_vector // CHECK-SAME: %{{.+}}: f32 func.func @zerod_vector(%arg0: vector) { return } @@ -250,10 +250,10 @@ // Check that > 4-element vectors are not supported. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { -// CHECK-NOT: spv.func @large_vector +// CHECK-NOT: spirv.func @large_vector func.func @large_vector(%arg0: vector<1024xi32>) { return } } // end module @@ -266,8 +266,8 @@ // Check memory spaces. module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: func @memref_mem_space @@ -278,23 +278,23 @@ // CHECK-SAME: Private // CHECK-SAME: Function func.func @memref_mem_space( - %arg0: memref<4xf32, #spv.storage_class>, - %arg1: memref<4xf32, #spv.storage_class>, - %arg2: memref<4xf32, #spv.storage_class>, - %arg3: memref<4xf32, #spv.storage_class>, - %arg4: memref<4xf32, #spv.storage_class>, - %arg5: memref<4xf32, #spv.storage_class> + %arg0: memref<4xf32, #spirv.storage_class>, + %arg1: memref<4xf32, #spirv.storage_class>, + %arg2: memref<4xf32, #spirv.storage_class>, + %arg3: memref<4xf32, #spirv.storage_class>, + %arg4: memref<4xf32, #spirv.storage_class>, + %arg5: memref<4xf32, #spirv.storage_class> ) { return } // CHECK-LABEL: func @memref_1bit_type -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> -// CHECK-SAME: !spv.ptr)>, Function> +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> +// CHECK-SAME: !spirv.ptr)>, Function> // NOEMU-LABEL: func @memref_1bit_type -// NOEMU-SAME: memref<4x8xi1, #spv.storage_class> -// NOEMU-SAME: memref<4x8xi1, #spv.storage_class> +// NOEMU-SAME: memref<4x8xi1, #spirv.storage_class> +// NOEMU-SAME: memref<4x8xi1, #spirv.storage_class> func.func @memref_1bit_type( - %arg0: memref<4x8xi1, #spv.storage_class>, - %arg1: memref<4x8xi1, #spv.storage_class> + %arg0: memref<4x8xi1, #spirv.storage_class>, + %arg1: memref<4x8xi1, #spirv.storage_class> ) { return } } // end module @@ -303,8 +303,8 @@ // Reject memory spaces. module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: func @numeric_memref_mem_space1 @@ -327,93 +327,93 @@ // requires special capability and extension: convert them to 32-bit if not // satisfied. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // An i1 is store in 8-bit, so 5xi1 has 40 bits, which is stored in 2xi32. -// CHECK-LABEL: spv.func @memref_1bit_type -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> +// CHECK-LABEL: spirv.func @memref_1bit_type +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> // NOEMU-LABEL: func @memref_1bit_type -// NOEMU-SAME: memref<5xi1, #spv.storage_class> -func.func @memref_1bit_type(%arg0: memref<5xi1, #spv.storage_class>) { return } +// NOEMU-SAME: memref<5xi1, #spirv.storage_class> +func.func @memref_1bit_type(%arg0: memref<5xi1, #spirv.storage_class>) { return } -// CHECK-LABEL: spv.func @memref_8bit_StorageBuffer -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> +// CHECK-LABEL: spirv.func @memref_8bit_StorageBuffer +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> // NOEMU-LABEL: func @memref_8bit_StorageBuffer -// NOEMU-SAME: memref<16xi8, #spv.storage_class> -func.func @memref_8bit_StorageBuffer(%arg0: memref<16xi8, #spv.storage_class>) { return } +// NOEMU-SAME: memref<16xi8, #spirv.storage_class> +func.func @memref_8bit_StorageBuffer(%arg0: memref<16xi8, #spirv.storage_class>) { return } -// CHECK-LABEL: spv.func @memref_8bit_Uniform -// CHECK-SAME: !spv.ptr [0])>, Uniform> +// CHECK-LABEL: spirv.func @memref_8bit_Uniform +// CHECK-SAME: !spirv.ptr [0])>, Uniform> // NOEMU-LABEL: func @memref_8bit_Uniform -// NOEMU-SAME: memref<16xsi8, #spv.storage_class> -func.func @memref_8bit_Uniform(%arg0: memref<16xsi8, #spv.storage_class>) { return } +// NOEMU-SAME: memref<16xsi8, #spirv.storage_class> +func.func @memref_8bit_Uniform(%arg0: memref<16xsi8, #spirv.storage_class>) { return } -// CHECK-LABEL: spv.func @memref_8bit_PushConstant -// CHECK-SAME: !spv.ptr [0])>, PushConstant> +// CHECK-LABEL: spirv.func @memref_8bit_PushConstant +// CHECK-SAME: !spirv.ptr [0])>, PushConstant> // NOEMU-LABEL: func @memref_8bit_PushConstant -// NOEMU-SAME: memref<16xui8, #spv.storage_class> -func.func @memref_8bit_PushConstant(%arg0: memref<16xui8, #spv.storage_class>) { return } +// NOEMU-SAME: memref<16xui8, #spirv.storage_class> +func.func @memref_8bit_PushConstant(%arg0: memref<16xui8, #spirv.storage_class>) { return } -// CHECK-LABEL: spv.func @memref_16bit_StorageBuffer -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> +// CHECK-LABEL: spirv.func @memref_16bit_StorageBuffer +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> // NOEMU-LABEL: func @memref_16bit_StorageBuffer -// NOEMU-SAME: memref<16xi16, #spv.storage_class> -func.func @memref_16bit_StorageBuffer(%arg0: memref<16xi16, #spv.storage_class>) { return } +// NOEMU-SAME: memref<16xi16, #spirv.storage_class> +func.func @memref_16bit_StorageBuffer(%arg0: memref<16xi16, #spirv.storage_class>) { return } -// CHECK-LABEL: spv.func @memref_16bit_Uniform -// CHECK-SAME: !spv.ptr [0])>, Uniform> +// CHECK-LABEL: spirv.func @memref_16bit_Uniform +// CHECK-SAME: !spirv.ptr [0])>, Uniform> // NOEMU-LABEL: func @memref_16bit_Uniform -// NOEMU-SAME: memref<16xsi16, #spv.storage_class> -func.func @memref_16bit_Uniform(%arg0: memref<16xsi16, #spv.storage_class>) { return } +// NOEMU-SAME: memref<16xsi16, #spirv.storage_class> +func.func @memref_16bit_Uniform(%arg0: memref<16xsi16, #spirv.storage_class>) { return } -// CHECK-LABEL: spv.func @memref_16bit_PushConstant -// CHECK-SAME: !spv.ptr [0])>, PushConstant> +// CHECK-LABEL: spirv.func @memref_16bit_PushConstant +// CHECK-SAME: !spirv.ptr [0])>, PushConstant> // NOEMU-LABEL: func @memref_16bit_PushConstant -// NOEMU-SAME: memref<16xui16, #spv.storage_class> -func.func @memref_16bit_PushConstant(%arg0: memref<16xui16, #spv.storage_class>) { return } +// NOEMU-SAME: memref<16xui16, #spirv.storage_class> +func.func @memref_16bit_PushConstant(%arg0: memref<16xui16, #spirv.storage_class>) { return } -// CHECK-LABEL: spv.func @memref_16bit_Input -// CHECK-SAME: !spv.ptr)>, Input> +// CHECK-LABEL: spirv.func @memref_16bit_Input +// CHECK-SAME: !spirv.ptr)>, Input> // NOEMU-LABEL: func @memref_16bit_Input -// NOEMU-SAME: memref<16xf16, #spv.storage_class> -func.func @memref_16bit_Input(%arg3: memref<16xf16, #spv.storage_class>) { return } +// NOEMU-SAME: memref<16xf16, #spirv.storage_class> +func.func @memref_16bit_Input(%arg3: memref<16xf16, #spirv.storage_class>) { return } -// CHECK-LABEL: spv.func @memref_16bit_Output -// CHECK-SAME: !spv.ptr)>, Output> +// CHECK-LABEL: spirv.func @memref_16bit_Output +// CHECK-SAME: !spirv.ptr)>, Output> // NOEMU-LABEL: func @memref_16bit_Output -// NOEMU-SAME: memref<16xf16, #spv.storage_class> -func.func @memref_16bit_Output(%arg4: memref<16xf16, #spv.storage_class>) { return } +// NOEMU-SAME: memref<16xf16, #spirv.storage_class> +func.func @memref_16bit_Output(%arg4: memref<16xf16, #spirv.storage_class>) { return } -// CHECK-LABEL: spv.func @memref_64bit_StorageBuffer -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> +// CHECK-LABEL: spirv.func @memref_64bit_StorageBuffer +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> // NOEMU-LABEL: func @memref_64bit_StorageBuffer -// NOEMU-SAME: memref<16xi64, #spv.storage_class> -func.func @memref_64bit_StorageBuffer(%arg0: memref<16xi64, #spv.storage_class>) { return } +// NOEMU-SAME: memref<16xi64, #spirv.storage_class> +func.func @memref_64bit_StorageBuffer(%arg0: memref<16xi64, #spirv.storage_class>) { return } -// CHECK-LABEL: spv.func @memref_64bit_Uniform -// CHECK-SAME: !spv.ptr [0])>, Uniform> +// CHECK-LABEL: spirv.func @memref_64bit_Uniform +// CHECK-SAME: !spirv.ptr [0])>, Uniform> // NOEMU-LABEL: func @memref_64bit_Uniform -// NOEMU-SAME: memref<16xsi64, #spv.storage_class> -func.func @memref_64bit_Uniform(%arg0: memref<16xsi64, #spv.storage_class>) { return } +// NOEMU-SAME: memref<16xsi64, #spirv.storage_class> +func.func @memref_64bit_Uniform(%arg0: memref<16xsi64, #spirv.storage_class>) { return } -// CHECK-LABEL: spv.func @memref_64bit_PushConstant -// CHECK-SAME: !spv.ptr [0])>, PushConstant> +// CHECK-LABEL: spirv.func @memref_64bit_PushConstant +// CHECK-SAME: !spirv.ptr [0])>, PushConstant> // NOEMU-LABEL: func @memref_64bit_PushConstant -// NOEMU-SAME: memref<16xui64, #spv.storage_class> -func.func @memref_64bit_PushConstant(%arg0: memref<16xui64, #spv.storage_class>) { return } +// NOEMU-SAME: memref<16xui64, #spirv.storage_class> +func.func @memref_64bit_PushConstant(%arg0: memref<16xui64, #spirv.storage_class>) { return } -// CHECK-LABEL: spv.func @memref_64bit_Input -// CHECK-SAME: !spv.ptr)>, Input> +// CHECK-LABEL: spirv.func @memref_64bit_Input +// CHECK-SAME: !spirv.ptr)>, Input> // NOEMU-LABEL: func @memref_64bit_Input -// NOEMU-SAME: memref<16xf64, #spv.storage_class> -func.func @memref_64bit_Input(%arg3: memref<16xf64, #spv.storage_class>) { return } +// NOEMU-SAME: memref<16xf64, #spirv.storage_class> +func.func @memref_64bit_Input(%arg3: memref<16xf64, #spirv.storage_class>) { return } -// CHECK-LABEL: spv.func @memref_64bit_Output -// CHECK-SAME: !spv.ptr)>, Output> +// CHECK-LABEL: spirv.func @memref_64bit_Output +// CHECK-SAME: !spirv.ptr)>, Output> // NOEMU-LABEL: func @memref_64bit_Output -// NOEMU-SAME: memref<16xf64, #spv.storage_class> -func.func @memref_64bit_Output(%arg4: memref<16xf64, #spv.storage_class>) { return } +// NOEMU-SAME: memref<16xf64, #spirv.storage_class> +func.func @memref_64bit_Output(%arg4: memref<16xf64, #spirv.storage_class>) { return } } // end module @@ -423,37 +423,37 @@ // requires special capability and extension: keep as-is when the capability // and extension is available. module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @memref_8bit_PushConstant -// CHECK-SAME: !spv.ptr [0])>, PushConstant> -// NOEMU-LABEL: spv.func @memref_8bit_PushConstant -// NOEMU-SAME: !spv.ptr [0])>, PushConstant> -func.func @memref_8bit_PushConstant(%arg0: memref<16xi8, #spv.storage_class>) { return } - -// CHECK-LABEL: spv.func @memref_16bit_PushConstant -// CHECK-SAME: !spv.ptr [0])>, PushConstant> -// CHECK-SAME: !spv.ptr [0])>, PushConstant> -// NOEMU-LABEL: spv.func @memref_16bit_PushConstant -// NOEMU-SAME: !spv.ptr [0])>, PushConstant> -// NOEMU-SAME: !spv.ptr [0])>, PushConstant> +// CHECK-LABEL: spirv.func @memref_8bit_PushConstant +// CHECK-SAME: !spirv.ptr [0])>, PushConstant> +// NOEMU-LABEL: spirv.func @memref_8bit_PushConstant +// NOEMU-SAME: !spirv.ptr [0])>, PushConstant> +func.func @memref_8bit_PushConstant(%arg0: memref<16xi8, #spirv.storage_class>) { return } + +// CHECK-LABEL: spirv.func @memref_16bit_PushConstant +// CHECK-SAME: !spirv.ptr [0])>, PushConstant> +// CHECK-SAME: !spirv.ptr [0])>, PushConstant> +// NOEMU-LABEL: spirv.func @memref_16bit_PushConstant +// NOEMU-SAME: !spirv.ptr [0])>, PushConstant> +// NOEMU-SAME: !spirv.ptr [0])>, PushConstant> func.func @memref_16bit_PushConstant( - %arg0: memref<16xi16, #spv.storage_class>, - %arg1: memref<16xf16, #spv.storage_class> + %arg0: memref<16xi16, #spirv.storage_class>, + %arg1: memref<16xf16, #spirv.storage_class> ) { return } -// CHECK-LABEL: spv.func @memref_64bit_PushConstant -// CHECK-SAME: !spv.ptr [0])>, PushConstant> -// CHECK-SAME: !spv.ptr [0])>, PushConstant> -// NOEMU-LABEL: spv.func @memref_64bit_PushConstant -// NOEMU-SAME: !spv.ptr [0])>, PushConstant> -// NOEMU-SAME: !spv.ptr [0])>, PushConstant> +// CHECK-LABEL: spirv.func @memref_64bit_PushConstant +// CHECK-SAME: !spirv.ptr [0])>, PushConstant> +// CHECK-SAME: !spirv.ptr [0])>, PushConstant> +// NOEMU-LABEL: spirv.func @memref_64bit_PushConstant +// NOEMU-SAME: !spirv.ptr [0])>, PushConstant> +// NOEMU-SAME: !spirv.ptr [0])>, PushConstant> func.func @memref_64bit_PushConstant( - %arg0: memref<16xi64, #spv.storage_class>, - %arg1: memref<16xf64, #spv.storage_class> + %arg0: memref<16xi64, #spirv.storage_class>, + %arg1: memref<16xf64, #spirv.storage_class> ) { return } } // end module @@ -464,37 +464,37 @@ // requires special capability and extension: keep as-is when the capability // and extension is available. module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @memref_8bit_StorageBuffer -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> -// NOEMU-LABEL: spv.func @memref_8bit_StorageBuffer -// NOEMU-SAME: !spv.ptr [0])>, StorageBuffer> -func.func @memref_8bit_StorageBuffer(%arg0: memref<16xi8, #spv.storage_class>) { return } - -// CHECK-LABEL: spv.func @memref_16bit_StorageBuffer -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> -// NOEMU-LABEL: spv.func @memref_16bit_StorageBuffer -// NOEMU-SAME: !spv.ptr [0])>, StorageBuffer> -// NOEMU-SAME: !spv.ptr [0])>, StorageBuffer> +// CHECK-LABEL: spirv.func @memref_8bit_StorageBuffer +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> +// NOEMU-LABEL: spirv.func @memref_8bit_StorageBuffer +// NOEMU-SAME: !spirv.ptr [0])>, StorageBuffer> +func.func @memref_8bit_StorageBuffer(%arg0: memref<16xi8, #spirv.storage_class>) { return } + +// CHECK-LABEL: spirv.func @memref_16bit_StorageBuffer +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> +// NOEMU-LABEL: spirv.func @memref_16bit_StorageBuffer +// NOEMU-SAME: !spirv.ptr [0])>, StorageBuffer> +// NOEMU-SAME: !spirv.ptr [0])>, StorageBuffer> func.func @memref_16bit_StorageBuffer( - %arg0: memref<16xi16, #spv.storage_class>, - %arg1: memref<16xf16, #spv.storage_class> + %arg0: memref<16xi16, #spirv.storage_class>, + %arg1: memref<16xf16, #spirv.storage_class> ) { return } -// CHECK-LABEL: spv.func @memref_64bit_StorageBuffer -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> -// NOEMU-LABEL: spv.func @memref_64bit_StorageBuffer -// NOEMU-SAME: !spv.ptr [0])>, StorageBuffer> -// NOEMU-SAME: !spv.ptr [0])>, StorageBuffer> +// CHECK-LABEL: spirv.func @memref_64bit_StorageBuffer +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> +// NOEMU-LABEL: spirv.func @memref_64bit_StorageBuffer +// NOEMU-SAME: !spirv.ptr [0])>, StorageBuffer> +// NOEMU-SAME: !spirv.ptr [0])>, StorageBuffer> func.func @memref_64bit_StorageBuffer( - %arg0: memref<16xi64, #spv.storage_class>, - %arg1: memref<16xf64, #spv.storage_class> + %arg0: memref<16xi64, #spirv.storage_class>, + %arg1: memref<16xf64, #spirv.storage_class> ) { return } } // end module @@ -505,37 +505,37 @@ // requires special capability and extension: keep as-is when the capability // and extension is available. module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @memref_8bit_Uniform -// CHECK-SAME: !spv.ptr [0])>, Uniform> -// NOEMU-LABEL: spv.func @memref_8bit_Uniform -// NOEMU-SAME: !spv.ptr [0])>, Uniform> -func.func @memref_8bit_Uniform(%arg0: memref<16xi8, #spv.storage_class>) { return } - -// CHECK-LABEL: spv.func @memref_16bit_Uniform -// CHECK-SAME: !spv.ptr [0])>, Uniform> -// CHECK-SAME: !spv.ptr [0])>, Uniform> -// NOEMU-LABEL: spv.func @memref_16bit_Uniform -// NOEMU-SAME: !spv.ptr [0])>, Uniform> -// NOEMU-SAME: !spv.ptr [0])>, Uniform> +// CHECK-LABEL: spirv.func @memref_8bit_Uniform +// CHECK-SAME: !spirv.ptr [0])>, Uniform> +// NOEMU-LABEL: spirv.func @memref_8bit_Uniform +// NOEMU-SAME: !spirv.ptr [0])>, Uniform> +func.func @memref_8bit_Uniform(%arg0: memref<16xi8, #spirv.storage_class>) { return } + +// CHECK-LABEL: spirv.func @memref_16bit_Uniform +// CHECK-SAME: !spirv.ptr [0])>, Uniform> +// CHECK-SAME: !spirv.ptr [0])>, Uniform> +// NOEMU-LABEL: spirv.func @memref_16bit_Uniform +// NOEMU-SAME: !spirv.ptr [0])>, Uniform> +// NOEMU-SAME: !spirv.ptr [0])>, Uniform> func.func @memref_16bit_Uniform( - %arg0: memref<16xi16, #spv.storage_class>, - %arg1: memref<16xf16, #spv.storage_class> + %arg0: memref<16xi16, #spirv.storage_class>, + %arg1: memref<16xf16, #spirv.storage_class> ) { return } -// CHECK-LABEL: spv.func @memref_64bit_Uniform -// CHECK-SAME: !spv.ptr [0])>, Uniform> -// CHECK-SAME: !spv.ptr [0])>, Uniform> -// NOEMU-LABEL: spv.func @memref_64bit_Uniform -// NOEMU-SAME: !spv.ptr [0])>, Uniform> -// NOEMU-SAME: !spv.ptr [0])>, Uniform> +// CHECK-LABEL: spirv.func @memref_64bit_Uniform +// CHECK-SAME: !spirv.ptr [0])>, Uniform> +// CHECK-SAME: !spirv.ptr [0])>, Uniform> +// NOEMU-LABEL: spirv.func @memref_64bit_Uniform +// NOEMU-SAME: !spirv.ptr [0])>, Uniform> +// NOEMU-SAME: !spirv.ptr [0])>, Uniform> func.func @memref_64bit_Uniform( - %arg0: memref<16xi64, #spv.storage_class>, - %arg1: memref<16xf64, #spv.storage_class> + %arg0: memref<16xi64, #spirv.storage_class>, + %arg1: memref<16xf64, #spirv.storage_class> ) { return } } // end module @@ -546,42 +546,42 @@ // requires special capability and extension: keep as-is when the capability // and extension is available. module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @memref_16bit_Input -// CHECK-SAME: !spv.ptr)>, Input> -// NOEMU-LABEL: spv.func @memref_16bit_Input -// NOEMU-SAME: !spv.ptr)>, Input> -func.func @memref_16bit_Input(%arg3: memref<16xf16, #spv.storage_class>) { return } - -// CHECK-LABEL: spv.func @memref_16bit_Output -// CHECK-SAME: !spv.ptr)>, Output> -// NOEMU-LABEL: spv.func @memref_16bit_Output -// NOEMU-SAME: !spv.ptr)>, Output> -func.func @memref_16bit_Output(%arg4: memref<16xi16, #spv.storage_class>) { return } - -// CHECK-LABEL: spv.func @memref_64bit_Input -// CHECK-SAME: !spv.ptr)>, Input> -// CHECK-SAME: !spv.ptr)>, Input> -// NOEMU-LABEL: spv.func @memref_64bit_Input -// NOEMU-SAME: !spv.ptr)>, Input> -// NOEMU-SAME: !spv.ptr)>, Input> +// CHECK-LABEL: spirv.func @memref_16bit_Input +// CHECK-SAME: !spirv.ptr)>, Input> +// NOEMU-LABEL: spirv.func @memref_16bit_Input +// NOEMU-SAME: !spirv.ptr)>, Input> +func.func @memref_16bit_Input(%arg3: memref<16xf16, #spirv.storage_class>) { return } + +// CHECK-LABEL: spirv.func @memref_16bit_Output +// CHECK-SAME: !spirv.ptr)>, Output> +// NOEMU-LABEL: spirv.func @memref_16bit_Output +// NOEMU-SAME: !spirv.ptr)>, Output> +func.func @memref_16bit_Output(%arg4: memref<16xi16, #spirv.storage_class>) { return } + +// CHECK-LABEL: spirv.func @memref_64bit_Input +// CHECK-SAME: !spirv.ptr)>, Input> +// CHECK-SAME: !spirv.ptr)>, Input> +// NOEMU-LABEL: spirv.func @memref_64bit_Input +// NOEMU-SAME: !spirv.ptr)>, Input> +// NOEMU-SAME: !spirv.ptr)>, Input> func.func @memref_64bit_Input( - %arg0: memref<16xi64, #spv.storage_class>, - %arg1: memref<16xf64, #spv.storage_class> + %arg0: memref<16xi64, #spirv.storage_class>, + %arg1: memref<16xf64, #spirv.storage_class> ) { return } -// CHECK-LABEL: spv.func @memref_64bit_Output -// CHECK-SAME: !spv.ptr)>, Output> -// CHECK-SAME: !spv.ptr)>, Output> -// NOEMU-LABEL: spv.func @memref_64bit_Output -// NOEMU-SAME: !spv.ptr)>, Output> -// NOEMU-SAME: !spv.ptr)>, Output> +// CHECK-LABEL: spirv.func @memref_64bit_Output +// CHECK-SAME: !spirv.ptr)>, Output> +// CHECK-SAME: !spirv.ptr)>, Output> +// NOEMU-LABEL: spirv.func @memref_64bit_Output +// NOEMU-SAME: !spirv.ptr)>, Output> +// NOEMU-SAME: !spirv.ptr)>, Output> func.func @memref_64bit_Output( - %arg0: memref<16xi64, #spv.storage_class>, - %arg1: memref<16xf64, #spv.storage_class> + %arg0: memref<16xi64, #spirv.storage_class>, + %arg1: memref<16xf64, #spirv.storage_class> ) { return } } // end module @@ -590,33 +590,33 @@ // Check that memref offset and strides affect the array size. module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @memref_offset_strides +// CHECK-LABEL: spirv.func @memref_offset_strides func.func @memref_offset_strides( -// CHECK-SAME: !spv.array<64 x f32, stride=4> [0])>, StorageBuffer> -// CHECK-SAME: !spv.array<72 x f32, stride=4> [0])>, StorageBuffer> -// CHECK-SAME: !spv.array<256 x f32, stride=4> [0])>, StorageBuffer> -// CHECK-SAME: !spv.array<64 x f32, stride=4> [0])>, StorageBuffer> -// CHECK-SAME: !spv.array<88 x f32, stride=4> [0])>, StorageBuffer> - %arg0: memref<16x4xf32, strided<[4, 1], offset: 0>, #spv.storage_class>, // tightly packed; row major - %arg1: memref<16x4xf32, strided<[4, 1], offset: 8>, #spv.storage_class>, // offset 8 - %arg2: memref<16x4xf32, strided<[16, 1], offset: 0>, #spv.storage_class>, // pad 12 after each row - %arg3: memref<16x4xf32, strided<[1, 16], offset: 0>, #spv.storage_class>, // tightly packed; col major - %arg4: memref<16x4xf32, strided<[1, 22], offset: 0>, #spv.storage_class>, // pad 4 after each col - -// CHECK-SAME: !spv.array<64 x f16, stride=2> [0])>, StorageBuffer> -// CHECK-SAME: !spv.array<72 x f16, stride=2> [0])>, StorageBuffer> -// CHECK-SAME: !spv.array<256 x f16, stride=2> [0])>, StorageBuffer> -// CHECK-SAME: !spv.array<64 x f16, stride=2> [0])>, StorageBuffer> -// CHECK-SAME: !spv.array<88 x f16, stride=2> [0])>, StorageBuffer> - %arg5: memref<16x4xf16, strided<[4, 1], offset: 0>, #spv.storage_class>, - %arg6: memref<16x4xf16, strided<[4, 1], offset: 8>, #spv.storage_class>, - %arg7: memref<16x4xf16, strided<[16, 1], offset: 0>, #spv.storage_class>, - %arg8: memref<16x4xf16, strided<[1, 16], offset: 0>, #spv.storage_class>, - %arg9: memref<16x4xf16, strided<[1, 22], offset: 0>, #spv.storage_class> +// CHECK-SAME: !spirv.array<64 x f32, stride=4> [0])>, StorageBuffer> +// CHECK-SAME: !spirv.array<72 x f32, stride=4> [0])>, StorageBuffer> +// CHECK-SAME: !spirv.array<256 x f32, stride=4> [0])>, StorageBuffer> +// CHECK-SAME: !spirv.array<64 x f32, stride=4> [0])>, StorageBuffer> +// CHECK-SAME: !spirv.array<88 x f32, stride=4> [0])>, StorageBuffer> + %arg0: memref<16x4xf32, strided<[4, 1], offset: 0>, #spirv.storage_class>, // tightly packed; row major + %arg1: memref<16x4xf32, strided<[4, 1], offset: 8>, #spirv.storage_class>, // offset 8 + %arg2: memref<16x4xf32, strided<[16, 1], offset: 0>, #spirv.storage_class>, // pad 12 after each row + %arg3: memref<16x4xf32, strided<[1, 16], offset: 0>, #spirv.storage_class>, // tightly packed; col major + %arg4: memref<16x4xf32, strided<[1, 22], offset: 0>, #spirv.storage_class>, // pad 4 after each col + +// CHECK-SAME: !spirv.array<64 x f16, stride=2> [0])>, StorageBuffer> +// CHECK-SAME: !spirv.array<72 x f16, stride=2> [0])>, StorageBuffer> +// CHECK-SAME: !spirv.array<256 x f16, stride=2> [0])>, StorageBuffer> +// CHECK-SAME: !spirv.array<64 x f16, stride=2> [0])>, StorageBuffer> +// CHECK-SAME: !spirv.array<88 x f16, stride=2> [0])>, StorageBuffer> + %arg5: memref<16x4xf16, strided<[4, 1], offset: 0>, #spirv.storage_class>, + %arg6: memref<16x4xf16, strided<[4, 1], offset: 8>, #spirv.storage_class>, + %arg7: memref<16x4xf16, strided<[16, 1], offset: 0>, #spirv.storage_class>, + %arg8: memref<16x4xf16, strided<[1, 16], offset: 0>, #spirv.storage_class>, + %arg9: memref<16x4xf16, strided<[1, 22], offset: 0>, #spirv.storage_class> ) { return } } // end module @@ -625,7 +625,7 @@ // Dynamic shapes module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // Check that unranked shapes are not supported. @@ -634,69 +634,69 @@ func.func @unranked_memref(%arg0: memref<*xi32>) { return } // CHECK-LABEL: func @memref_1bit_type -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> // NOEMU-LABEL: func @memref_1bit_type -// NOEMU-SAME: memref> -func.func @memref_1bit_type(%arg0: memref>) { return } +// NOEMU-SAME: memref> +func.func @memref_1bit_type(%arg0: memref>) { return } // CHECK-LABEL: func @dynamic_dim_memref -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> func.func @dynamic_dim_memref( - %arg0: memref<8x?xi32, #spv.storage_class>, - %arg1: memref>) { return } + %arg0: memref<8x?xi32, #spirv.storage_class>, + %arg1: memref>) { return } // Check that using non-32-bit scalar types in interface storage classes // requires special capability and extension: convert them to 32-bit if not // satisfied. -// CHECK-LABEL: spv.func @memref_8bit_StorageBuffer -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> +// CHECK-LABEL: spirv.func @memref_8bit_StorageBuffer +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> // NOEMU-LABEL: func @memref_8bit_StorageBuffer -// NOEMU-SAME: memref> -func.func @memref_8bit_StorageBuffer(%arg0: memref>) { return } +// NOEMU-SAME: memref> +func.func @memref_8bit_StorageBuffer(%arg0: memref>) { return } -// CHECK-LABEL: spv.func @memref_8bit_Uniform -// CHECK-SAME: !spv.ptr [0])>, Uniform> +// CHECK-LABEL: spirv.func @memref_8bit_Uniform +// CHECK-SAME: !spirv.ptr [0])>, Uniform> // NOEMU-LABEL: func @memref_8bit_Uniform -// NOEMU-SAME: memref> -func.func @memref_8bit_Uniform(%arg0: memref>) { return } +// NOEMU-SAME: memref> +func.func @memref_8bit_Uniform(%arg0: memref>) { return } -// CHECK-LABEL: spv.func @memref_8bit_PushConstant -// CHECK-SAME: !spv.ptr [0])>, PushConstant> +// CHECK-LABEL: spirv.func @memref_8bit_PushConstant +// CHECK-SAME: !spirv.ptr [0])>, PushConstant> // NOEMU-LABEL: func @memref_8bit_PushConstant -// NOEMU-SAME: memref> -func.func @memref_8bit_PushConstant(%arg0: memref>) { return } +// NOEMU-SAME: memref> +func.func @memref_8bit_PushConstant(%arg0: memref>) { return } -// CHECK-LABEL: spv.func @memref_16bit_StorageBuffer -// CHECK-SAME: !spv.ptr [0])>, StorageBuffer> +// CHECK-LABEL: spirv.func @memref_16bit_StorageBuffer +// CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> // NOEMU-LABEL: func @memref_16bit_StorageBuffer -// NOEMU-SAME: memref> -func.func @memref_16bit_StorageBuffer(%arg0: memref>) { return } +// NOEMU-SAME: memref> +func.func @memref_16bit_StorageBuffer(%arg0: memref>) { return } -// CHECK-LABEL: spv.func @memref_16bit_Uniform -// CHECK-SAME: !spv.ptr [0])>, Uniform> +// CHECK-LABEL: spirv.func @memref_16bit_Uniform +// CHECK-SAME: !spirv.ptr [0])>, Uniform> // NOEMU-LABEL: func @memref_16bit_Uniform -// NOEMU-SAME: memref> -func.func @memref_16bit_Uniform(%arg0: memref>) { return } +// NOEMU-SAME: memref> +func.func @memref_16bit_Uniform(%arg0: memref>) { return } -// CHECK-LABEL: spv.func @memref_16bit_PushConstant -// CHECK-SAME: !spv.ptr [0])>, PushConstant> +// CHECK-LABEL: spirv.func @memref_16bit_PushConstant +// CHECK-SAME: !spirv.ptr [0])>, PushConstant> // NOEMU-LABEL: func @memref_16bit_PushConstant -// NOEMU-SAME: memref> -func.func @memref_16bit_PushConstant(%arg0: memref>) { return } +// NOEMU-SAME: memref> +func.func @memref_16bit_PushConstant(%arg0: memref>) { return } -// CHECK-LABEL: spv.func @memref_16bit_Input -// CHECK-SAME: !spv.ptr)>, Input> +// CHECK-LABEL: spirv.func @memref_16bit_Input +// CHECK-SAME: !spirv.ptr)>, Input> // NOEMU-LABEL: func @memref_16bit_Input -// NOEMU-SAME: memref> -func.func @memref_16bit_Input(%arg3: memref>) { return } +// NOEMU-SAME: memref> +func.func @memref_16bit_Input(%arg3: memref>) { return } -// CHECK-LABEL: spv.func @memref_16bit_Output -// CHECK-SAME: !spv.ptr)>, Output> +// CHECK-LABEL: spirv.func @memref_16bit_Output +// CHECK-SAME: !spirv.ptr)>, Output> // NOEMU-LABEL: func @memref_16bit_Output -// NOEMU-SAME: memref> -func.func @memref_16bit_Output(%arg4: memref>) { return } +// NOEMU-SAME: memref> +func.func @memref_16bit_Output(%arg4: memref>) { return } } // end module @@ -704,23 +704,23 @@ // Vector types module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: func @memref_vector -// CHECK-SAME: !spv.ptr, stride=8> [0])>, StorageBuffer> -// CHECK-SAME: !spv.ptr, stride=16> [0])>, Uniform> +// CHECK-SAME: !spirv.ptr, stride=8> [0])>, StorageBuffer> +// CHECK-SAME: !spirv.ptr, stride=16> [0])>, Uniform> func.func @memref_vector( - %arg0: memref<4xvector<2xf32>, #spv.storage_class>, - %arg1: memref<4xvector<4xf32>, #spv.storage_class>) + %arg0: memref<4xvector<2xf32>, #spirv.storage_class>, + %arg1: memref<4xvector<4xf32>, #spirv.storage_class>) { return } // CHECK-LABEL: func @dynamic_dim_memref_vector -// CHECK-SAME: !spv.ptr, stride=16> [0])>, StorageBuffer> -// CHECK-SAME: !spv.ptr, stride=8> [0])>, StorageBuffer> +// CHECK-SAME: !spirv.ptr, stride=16> [0])>, StorageBuffer> +// CHECK-SAME: !spirv.ptr, stride=8> [0])>, StorageBuffer> func.func @dynamic_dim_memref_vector( - %arg0: memref<8x?xvector<4xi32>, #spv.storage_class>, - %arg1: memref, #spv.storage_class>) + %arg0: memref<8x?xvector<4xi32>, #spirv.storage_class>, + %arg1: memref, #spirv.storage_class>) { return } } // end module @@ -729,13 +729,13 @@ // Vector types, check that sizes not available in SPIR-V are not transformed. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: func @memref_vector_wrong_size -// CHECK-SAME: memref<4xvector<5xf32>, #spv.storage_class> +// CHECK-SAME: memref<4xvector<5xf32>, #spirv.storage_class> func.func @memref_vector_wrong_size( - %arg0: memref<4xvector<5xf32>, #spv.storage_class>) + %arg0: memref<4xvector<5xf32>, #spirv.storage_class>) { return } } // end module @@ -748,15 +748,15 @@ // Check that tensor element types are kept untouched with proper capabilities. module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @int_tensor_types -// CHECK-SAME: !spv.array<32 x i64> -// CHECK-SAME: !spv.array<32 x i32> -// CHECK-SAME: !spv.array<32 x i16> -// CHECK-SAME: !spv.array<32 x i8> +// CHECK-LABEL: spirv.func @int_tensor_types +// CHECK-SAME: !spirv.array<32 x i64> +// CHECK-SAME: !spirv.array<32 x i32> +// CHECK-SAME: !spirv.array<32 x i16> +// CHECK-SAME: !spirv.array<32 x i8> func.func @int_tensor_types( %arg0: tensor<8x4xi64>, %arg1: tensor<8x4xi32>, @@ -764,10 +764,10 @@ %arg3: tensor<8x4xi8> ) { return } -// CHECK-LABEL: spv.func @float_tensor_types -// CHECK-SAME: !spv.array<32 x f64> -// CHECK-SAME: !spv.array<32 x f32> -// CHECK-SAME: !spv.array<32 x f16> +// CHECK-LABEL: spirv.func @float_tensor_types +// CHECK-SAME: !spirv.array<32 x f64> +// CHECK-SAME: !spirv.array<32 x f32> +// CHECK-SAME: !spirv.array<32 x f16> func.func @float_tensor_types( %arg0: tensor<8x4xf64>, %arg1: tensor<8x4xf32>, @@ -780,14 +780,14 @@ // Check that tensor element types are changed to 32-bit without capabilities. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.func @int_tensor_types -// CHECK-SAME: !spv.array<32 x i32> -// CHECK-SAME: !spv.array<32 x i32> -// CHECK-SAME: !spv.array<32 x i32> -// CHECK-SAME: !spv.array<32 x i32> +// CHECK-LABEL: spirv.func @int_tensor_types +// CHECK-SAME: !spirv.array<32 x i32> +// CHECK-SAME: !spirv.array<32 x i32> +// CHECK-SAME: !spirv.array<32 x i32> +// CHECK-SAME: !spirv.array<32 x i32> func.func @int_tensor_types( %arg0: tensor<8x4xi64>, %arg1: tensor<8x4xi32>, @@ -795,10 +795,10 @@ %arg3: tensor<8x4xi8> ) { return } -// CHECK-LABEL: spv.func @float_tensor_types -// CHECK-SAME: !spv.array<32 x f32> -// CHECK-SAME: !spv.array<32 x f32> -// CHECK-SAME: !spv.array<32 x f32> +// CHECK-LABEL: spirv.func @float_tensor_types +// CHECK-SAME: !spirv.array<32 x f32> +// CHECK-SAME: !spirv.array<32 x f32> +// CHECK-SAME: !spirv.array<32 x f32> func.func @float_tensor_types( %arg0: tensor<8x4xf64>, %arg1: tensor<8x4xf32>, @@ -811,7 +811,7 @@ // Check that dynamic shapes are not supported. module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: func @unranked_tensor diff --git a/mlir/test/Conversion/GPUToSPIRV/builtins.mlir b/mlir/test/Conversion/GPUToSPIRV/builtins.mlir --- a/mlir/test/Conversion/GPUToSPIRV/builtins.mlir +++ b/mlir/test/Conversion/GPUToSPIRV/builtins.mlir @@ -8,14 +8,14 @@ return } - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 - // CHECK: spv.GlobalVariable [[WORKGROUPID:@.*]] built_in("WorkgroupId") + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 + // CHECK: spirv.GlobalVariable [[WORKGROUPID:@.*]] built_in("WorkgroupId") gpu.module @kernels { gpu.func @builtin_workgroup_id_x() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: [[ADDRESS:%.*]] = spv.mlir.addressof [[WORKGROUPID]] - // CHECK-NEXT: [[VEC:%.*]] = spv.Load "Input" [[ADDRESS]] - // CHECK-NEXT: {{%.*}} = spv.CompositeExtract [[VEC]]{{\[}}0 : i32{{\]}} + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: [[ADDRESS:%.*]] = spirv.mlir.addressof [[WORKGROUPID]] + // CHECK-NEXT: [[VEC:%.*]] = spirv.Load "Input" [[ADDRESS]] + // CHECK-NEXT: {{%.*}} = spirv.CompositeExtract [[VEC]]{{\[}}0 : i32{{\]}} %0 = gpu.block_id x gpu.return } @@ -34,14 +34,14 @@ return } - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 - // CHECK: spv.GlobalVariable [[WORKGROUPID:@.*]] built_in("WorkgroupId") + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 + // CHECK: spirv.GlobalVariable [[WORKGROUPID:@.*]] built_in("WorkgroupId") gpu.module @kernels { gpu.func @builtin_workgroup_id_y() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: [[ADDRESS:%.*]] = spv.mlir.addressof [[WORKGROUPID]] - // CHECK-NEXT: [[VEC:%.*]] = spv.Load "Input" [[ADDRESS]] - // CHECK-NEXT: {{%.*}} = spv.CompositeExtract [[VEC]]{{\[}}1 : i32{{\]}} + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: [[ADDRESS:%.*]] = spirv.mlir.addressof [[WORKGROUPID]] + // CHECK-NEXT: [[VEC:%.*]] = spirv.Load "Input" [[ADDRESS]] + // CHECK-NEXT: {{%.*}} = spirv.CompositeExtract [[VEC]]{{\[}}1 : i32{{\]}} %0 = gpu.block_id y gpu.return } @@ -58,14 +58,14 @@ return } - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 - // CHECK: spv.GlobalVariable [[WORKGROUPID:@.*]] built_in("WorkgroupId") + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 + // CHECK: spirv.GlobalVariable [[WORKGROUPID:@.*]] built_in("WorkgroupId") gpu.module @kernels { gpu.func @builtin_workgroup_id_z() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: [[ADDRESS:%.*]] = spv.mlir.addressof [[WORKGROUPID]] - // CHECK-NEXT: [[VEC:%.*]] = spv.Load "Input" [[ADDRESS]] - // CHECK-NEXT: {{%.*}} = spv.CompositeExtract [[VEC]]{{\[}}2 : i32{{\]}} + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: [[ADDRESS:%.*]] = spirv.mlir.addressof [[WORKGROUPID]] + // CHECK-NEXT: [[VEC:%.*]] = spirv.Load "Input" [[ADDRESS]] + // CHECK-NEXT: {{%.*}} = spirv.CompositeExtract [[VEC]]{{\[}}2 : i32{{\]}} %0 = gpu.block_id z gpu.return } @@ -82,15 +82,15 @@ return } - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 gpu.module @kernels { gpu.func @builtin_workgroup_size_x() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // The constant value is obtained from the spv.entry_point_abi. + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // The constant value is obtained from the spirv.entry_point_abi. // Note that this ignores the workgroup size specification in gpu.launch. // We may want to define gpu.workgroup_size and convert it to the entry // point ABI we want here. - // CHECK: spv.Constant 32 : i32 + // CHECK: spirv.Constant 32 : i32 %0 = gpu.block_dim x gpu.return } @@ -107,12 +107,12 @@ return } - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 gpu.module @kernels { gpu.func @builtin_workgroup_size_y() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // The constant value is obtained from the spv.entry_point_abi. - // CHECK: spv.Constant 4 : i32 + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // The constant value is obtained from the spirv.entry_point_abi. + // CHECK: spirv.Constant 4 : i32 %0 = gpu.block_dim y gpu.return } @@ -129,12 +129,12 @@ return } - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 gpu.module @kernels { gpu.func @builtin_workgroup_size_z() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // The constant value is obtained from the spv.entry_point_abi. - // CHECK: spv.Constant 1 : i32 + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // The constant value is obtained from the spirv.entry_point_abi. + // CHECK: spirv.Constant 1 : i32 %0 = gpu.block_dim z gpu.return } @@ -151,14 +151,14 @@ return } - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 - // CHECK: spv.GlobalVariable [[LOCALINVOCATIONID:@.*]] built_in("LocalInvocationId") + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 + // CHECK: spirv.GlobalVariable [[LOCALINVOCATIONID:@.*]] built_in("LocalInvocationId") gpu.module @kernels { gpu.func @builtin_local_id_x() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: [[ADDRESS:%.*]] = spv.mlir.addressof [[LOCALINVOCATIONID]] - // CHECK-NEXT: [[VEC:%.*]] = spv.Load "Input" [[ADDRESS]] - // CHECK-NEXT: {{%.*}} = spv.CompositeExtract [[VEC]]{{\[}}0 : i32{{\]}} + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: [[ADDRESS:%.*]] = spirv.mlir.addressof [[LOCALINVOCATIONID]] + // CHECK-NEXT: [[VEC:%.*]] = spirv.Load "Input" [[ADDRESS]] + // CHECK-NEXT: {{%.*}} = spirv.CompositeExtract [[VEC]]{{\[}}0 : i32{{\]}} %0 = gpu.thread_id x gpu.return } @@ -175,14 +175,14 @@ return } - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 - // CHECK: spv.GlobalVariable [[NUMWORKGROUPS:@.*]] built_in("NumWorkgroups") + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 + // CHECK: spirv.GlobalVariable [[NUMWORKGROUPS:@.*]] built_in("NumWorkgroups") gpu.module @kernels { gpu.func @builtin_num_workgroups_x() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: [[ADDRESS:%.*]] = spv.mlir.addressof [[NUMWORKGROUPS]] - // CHECK-NEXT: [[VEC:%.*]] = spv.Load "Input" [[ADDRESS]] - // CHECK-NEXT: {{%.*}} = spv.CompositeExtract [[VEC]]{{\[}}0 : i32{{\]}} + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: [[ADDRESS:%.*]] = spirv.mlir.addressof [[NUMWORKGROUPS]] + // CHECK-NEXT: [[VEC:%.*]] = spirv.Load "Input" [[ADDRESS]] + // CHECK-NEXT: {{%.*}} = spirv.CompositeExtract [[VEC]]{{\[}}0 : i32{{\]}} %0 = gpu.grid_dim x gpu.return } @@ -192,13 +192,13 @@ // ----- module attributes {gpu.container_module} { - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 - // CHECK: spv.GlobalVariable [[SUBGROUPID:@.*]] built_in("SubgroupId") + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 + // CHECK: spirv.GlobalVariable [[SUBGROUPID:@.*]] built_in("SubgroupId") gpu.module @kernels { gpu.func @builtin_subgroup_id() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: [[ADDRESS:%.*]] = spv.mlir.addressof [[SUBGROUPID]] - // CHECK-NEXT: {{%.*}} = spv.Load "Input" [[ADDRESS]] + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: [[ADDRESS:%.*]] = spirv.mlir.addressof [[SUBGROUPID]] + // CHECK-NEXT: {{%.*}} = spirv.Load "Input" [[ADDRESS]] %0 = gpu.subgroup_id : index gpu.return } @@ -208,13 +208,13 @@ // ----- module attributes {gpu.container_module} { - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 - // CHECK: spv.GlobalVariable [[NUMSUBGROUPS:@.*]] built_in("NumSubgroups") + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 + // CHECK: spirv.GlobalVariable [[NUMSUBGROUPS:@.*]] built_in("NumSubgroups") gpu.module @kernels { gpu.func @builtin_num_subgroups() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: [[ADDRESS:%.*]] = spv.mlir.addressof [[NUMSUBGROUPS]] - // CHECK-NEXT: {{%.*}} = spv.Load "Input" [[ADDRESS]] + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: [[ADDRESS:%.*]] = spirv.mlir.addressof [[NUMSUBGROUPS]] + // CHECK-NEXT: {{%.*}} = spirv.Load "Input" [[ADDRESS]] %0 = gpu.num_subgroups : index gpu.return } @@ -231,14 +231,14 @@ return } - // CHECK-LABEL: spv.module @{{.*}} - // CHECK: spv.GlobalVariable [[WORKGROUPSIZE:@.*]] built_in("WorkgroupSize") + // CHECK-LABEL: spirv.module @{{.*}} + // CHECK: spirv.GlobalVariable [[WORKGROUPSIZE:@.*]] built_in("WorkgroupSize") gpu.module @kernels { gpu.func @builtin_workgroup_size_x() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi<>} { - // CHECK: [[ADDRESS:%.*]] = spv.mlir.addressof [[WORKGROUPSIZE]] - // CHECK-NEXT: [[VEC:%.*]] = spv.Load "Input" [[ADDRESS]] - // CHECK-NEXT: {{%.*}} = spv.CompositeExtract [[VEC]]{{\[}}0 : i32{{\]}} + attributes {spirv.entry_point_abi = #spirv.entry_point_abi<>} { + // CHECK: [[ADDRESS:%.*]] = spirv.mlir.addressof [[WORKGROUPSIZE]] + // CHECK-NEXT: [[VEC:%.*]] = spirv.Load "Input" [[ADDRESS]] + // CHECK-NEXT: {{%.*}} = spirv.CompositeExtract [[VEC]]{{\[}}0 : i32{{\]}} %0 = gpu.block_dim x gpu.return } @@ -255,14 +255,14 @@ return } - // CHECK-LABEL: spv.module @{{.*}} - // CHECK: spv.GlobalVariable [[WORKGROUPSIZE:@.*]] built_in("WorkgroupSize") + // CHECK-LABEL: spirv.module @{{.*}} + // CHECK: spirv.GlobalVariable [[WORKGROUPSIZE:@.*]] built_in("WorkgroupSize") gpu.module @kernels { gpu.func @builtin_workgroup_size_y() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi<>} { - // CHECK: [[ADDRESS:%.*]] = spv.mlir.addressof [[WORKGROUPSIZE]] - // CHECK-NEXT: [[VEC:%.*]] = spv.Load "Input" [[ADDRESS]] - // CHECK-NEXT: {{%.*}} = spv.CompositeExtract [[VEC]]{{\[}}1 : i32{{\]}} + attributes {spirv.entry_point_abi = #spirv.entry_point_abi<>} { + // CHECK: [[ADDRESS:%.*]] = spirv.mlir.addressof [[WORKGROUPSIZE]] + // CHECK-NEXT: [[VEC:%.*]] = spirv.Load "Input" [[ADDRESS]] + // CHECK-NEXT: {{%.*}} = spirv.CompositeExtract [[VEC]]{{\[}}1 : i32{{\]}} %0 = gpu.block_dim y gpu.return } @@ -279,14 +279,14 @@ return } - // CHECK-LABEL: spv.module @{{.*}} - // CHECK: spv.GlobalVariable [[WORKGROUPSIZE:@.*]] built_in("WorkgroupSize") + // CHECK-LABEL: spirv.module @{{.*}} + // CHECK: spirv.GlobalVariable [[WORKGROUPSIZE:@.*]] built_in("WorkgroupSize") gpu.module @kernels { gpu.func @builtin_workgroup_size_z() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi<>} { - // CHECK: [[ADDRESS:%.*]] = spv.mlir.addressof [[WORKGROUPSIZE]] - // CHECK-NEXT: [[VEC:%.*]] = spv.Load "Input" [[ADDRESS]] - // CHECK-NEXT: {{%.*}} = spv.CompositeExtract [[VEC]]{{\[}}2 : i32{{\]}} + attributes {spirv.entry_point_abi = #spirv.entry_point_abi<>} { + // CHECK: [[ADDRESS:%.*]] = spirv.mlir.addressof [[WORKGROUPSIZE]] + // CHECK-NEXT: [[VEC:%.*]] = spirv.Load "Input" [[ADDRESS]] + // CHECK-NEXT: {{%.*}} = spirv.CompositeExtract [[VEC]]{{\[}}2 : i32{{\]}} %0 = gpu.block_dim z gpu.return } @@ -303,14 +303,14 @@ return } - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 - // CHECK: spv.GlobalVariable [[GLOBALINVOCATIONID:@.*]] built_in("GlobalInvocationId") + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 + // CHECK: spirv.GlobalVariable [[GLOBALINVOCATIONID:@.*]] built_in("GlobalInvocationId") gpu.module @kernels { gpu.func @builtin_global_id_x() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: [[ADDRESS:%.*]] = spv.mlir.addressof [[GLOBALINVOCATIONID]] - // CHECK-NEXT: [[VEC:%.*]] = spv.Load "Input" [[ADDRESS]] - // CHECK-NEXT: {{%.*}} = spv.CompositeExtract [[VEC]]{{\[}}0 : i32{{\]}} + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: [[ADDRESS:%.*]] = spirv.mlir.addressof [[GLOBALINVOCATIONID]] + // CHECK-NEXT: [[VEC:%.*]] = spirv.Load "Input" [[ADDRESS]] + // CHECK-NEXT: {{%.*}} = spirv.CompositeExtract [[VEC]]{{\[}}0 : i32{{\]}} %0 = gpu.global_id x gpu.return } @@ -327,14 +327,14 @@ return } - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 - // CHECK: spv.GlobalVariable [[GLOBALINVOCATIONID:@.*]] built_in("GlobalInvocationId") + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 + // CHECK: spirv.GlobalVariable [[GLOBALINVOCATIONID:@.*]] built_in("GlobalInvocationId") gpu.module @kernels { gpu.func @builtin_global_id_y() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: [[ADDRESS:%.*]] = spv.mlir.addressof [[GLOBALINVOCATIONID]] - // CHECK-NEXT: [[VEC:%.*]] = spv.Load "Input" [[ADDRESS]] - // CHECK-NEXT: {{%.*}} = spv.CompositeExtract [[VEC]]{{\[}}1 : i32{{\]}} + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: [[ADDRESS:%.*]] = spirv.mlir.addressof [[GLOBALINVOCATIONID]] + // CHECK-NEXT: [[VEC:%.*]] = spirv.Load "Input" [[ADDRESS]] + // CHECK-NEXT: {{%.*}} = spirv.CompositeExtract [[VEC]]{{\[}}1 : i32{{\]}} %0 = gpu.global_id y gpu.return } @@ -351,14 +351,14 @@ return } - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 - // CHECK: spv.GlobalVariable [[GLOBALINVOCATIONID:@.*]] built_in("GlobalInvocationId") + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 + // CHECK: spirv.GlobalVariable [[GLOBALINVOCATIONID:@.*]] built_in("GlobalInvocationId") gpu.module @kernels { gpu.func @builtin_global_id_z() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: [[ADDRESS:%.*]] = spv.mlir.addressof [[GLOBALINVOCATIONID]] - // CHECK-NEXT: [[VEC:%.*]] = spv.Load "Input" [[ADDRESS]] - // CHECK-NEXT: {{%.*}} = spv.CompositeExtract [[VEC]]{{\[}}2 : i32{{\]}} + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: [[ADDRESS:%.*]] = spirv.mlir.addressof [[GLOBALINVOCATIONID]] + // CHECK-NEXT: [[VEC:%.*]] = spirv.Load "Input" [[ADDRESS]] + // CHECK-NEXT: {{%.*}} = spirv.CompositeExtract [[VEC]]{{\[}}2 : i32{{\]}} %0 = gpu.global_id z gpu.return } @@ -369,13 +369,13 @@ // ----- module attributes {gpu.container_module} { - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 - // CHECK: spv.GlobalVariable [[SUBGROUPSIZE:@.*]] built_in("SubgroupSize") + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 + // CHECK: spirv.GlobalVariable [[SUBGROUPSIZE:@.*]] built_in("SubgroupSize") gpu.module @kernels { gpu.func @builtin_subgroup_size() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: [[ADDRESS:%.*]] = spv.mlir.addressof [[SUBGROUPSIZE]] - // CHECK-NEXT: {{%.*}} = spv.Load "Input" [[ADDRESS]] + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: [[ADDRESS:%.*]] = spirv.mlir.addressof [[SUBGROUPSIZE]] + // CHECK-NEXT: {{%.*}} = spirv.Load "Input" [[ADDRESS]] %0 = gpu.subgroup_size : index gpu.return } diff --git a/mlir/test/Conversion/GPUToSPIRV/entry-point.mlir b/mlir/test/Conversion/GPUToSPIRV/entry-point.mlir --- a/mlir/test/Conversion/GPUToSPIRV/entry-point.mlir +++ b/mlir/test/Conversion/GPUToSPIRV/entry-point.mlir @@ -2,10 +2,10 @@ // RUN: mlir-opt -test-spirv-entry-point-abi="workgroup-size=32" %s | FileCheck %s -check-prefix=WG32 // DEFAULT: gpu.func @foo() -// DEFAULT-SAME: spv.entry_point_abi = #spv.entry_point_abi : vector<3xi32>> +// DEFAULT-SAME: spirv.entry_point_abi = #spirv.entry_point_abi : vector<3xi32>> // WG32: gpu.func @foo() -// WG32-SAME: spv.entry_point_abi = #spv.entry_point_abi : vector<3xi32>> +// WG32-SAME: spirv.entry_point_abi = #spirv.entry_point_abi : vector<3xi32>> gpu.module @kernels { gpu.func @foo() kernel { diff --git a/mlir/test/Conversion/GPUToSPIRV/gpu-to-spirv.mlir b/mlir/test/Conversion/GPUToSPIRV/gpu-to-spirv.mlir --- a/mlir/test/Conversion/GPUToSPIRV/gpu-to-spirv.mlir +++ b/mlir/test/Conversion/GPUToSPIRV/gpu-to-spirv.mlir @@ -2,25 +2,25 @@ module attributes {gpu.container_module} { gpu.module @kernels { - // CHECK: spv.module @{{.*}} Logical GLSL450 { - // CHECK-LABEL: spv.func @basic_module_structure - // CHECK-SAME: {{%.*}}: f32 {spv.interface_var_abi = #spv.interface_var_abi<(0, 0), StorageBuffer>} - // CHECK-SAME: {{%.*}}: !spv.ptr [0])>, StorageBuffer> {spv.interface_var_abi = #spv.interface_var_abi<(0, 1)>} - // CHECK-SAME: spv.entry_point_abi = #spv.entry_point_abi : vector<3xi32>> - gpu.func @basic_module_structure(%arg0 : f32, %arg1 : memref<12xf32, #spv.storage_class>) kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: spv.Return + // CHECK: spirv.module @{{.*}} Logical GLSL450 { + // CHECK-LABEL: spirv.func @basic_module_structure + // CHECK-SAME: {{%.*}}: f32 {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 0), StorageBuffer>} + // CHECK-SAME: {{%.*}}: !spirv.ptr [0])>, StorageBuffer> {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1)>} + // CHECK-SAME: spirv.entry_point_abi = #spirv.entry_point_abi : vector<3xi32>> + gpu.func @basic_module_structure(%arg0 : f32, %arg1 : memref<12xf32, #spirv.storage_class>) kernel + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: spirv.Return gpu.return } } func.func @main() { %0 = "op"() : () -> (f32) - %1 = "op"() : () -> (memref<12xf32, #spv.storage_class>) + %1 = "op"() : () -> (memref<12xf32, #spirv.storage_class>) %cst = arith.constant 1 : index gpu.launch_func @kernels::@basic_module_structure blocks in (%cst, %cst, %cst) threads in (%cst, %cst, %cst) - args(%0 : f32, %1 : memref<12xf32, #spv.storage_class>) + args(%0 : f32, %1 : memref<12xf32, #spirv.storage_class>) return } } @@ -29,21 +29,21 @@ module attributes {gpu.container_module} { gpu.module @kernels { - // CHECK: spv.module @{{.*}} Logical GLSL450 { - // CHECK-LABEL: spv.func @basic_module_structure_preset_ABI + // CHECK: spirv.module @{{.*}} Logical GLSL450 { + // CHECK-LABEL: spirv.func @basic_module_structure_preset_ABI // CHECK-SAME: {{%[a-zA-Z0-9_]*}}: f32 - // CHECK-SAME: spv.interface_var_abi = #spv.interface_var_abi<(1, 2), StorageBuffer> - // CHECK-SAME: !spv.ptr [0])>, StorageBuffer> - // CHECK-SAME: spv.interface_var_abi = #spv.interface_var_abi<(3, 0)> - // CHECK-SAME: spv.entry_point_abi = #spv.entry_point_abi : vector<3xi32>> + // CHECK-SAME: spirv.interface_var_abi = #spirv.interface_var_abi<(1, 2), StorageBuffer> + // CHECK-SAME: !spirv.ptr [0])>, StorageBuffer> + // CHECK-SAME: spirv.interface_var_abi = #spirv.interface_var_abi<(3, 0)> + // CHECK-SAME: spirv.entry_point_abi = #spirv.entry_point_abi : vector<3xi32>> gpu.func @basic_module_structure_preset_ABI( %arg0 : f32 - {spv.interface_var_abi = #spv.interface_var_abi<(1, 2), StorageBuffer>}, - %arg1 : memref<12xf32, #spv.storage_class> - {spv.interface_var_abi = #spv.interface_var_abi<(3, 0)>}) kernel + {spirv.interface_var_abi = #spirv.interface_var_abi<(1, 2), StorageBuffer>}, + %arg1 : memref<12xf32, #spirv.storage_class> + {spirv.interface_var_abi = #spirv.interface_var_abi<(3, 0)>}) kernel attributes - {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: spv.Return + {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: spirv.Return gpu.return } } @@ -54,19 +54,19 @@ module attributes {gpu.container_module} { gpu.module @kernels { // expected-error @below {{failed to legalize operation 'gpu.func'}} - // expected-remark @below {{match failure: missing 'spv.entry_point_abi' attribute}} - gpu.func @missing_entry_point_abi(%arg0 : f32, %arg1 : memref<12xf32, #spv.storage_class>) kernel { + // expected-remark @below {{match failure: missing 'spirv.entry_point_abi' attribute}} + gpu.func @missing_entry_point_abi(%arg0 : f32, %arg1 : memref<12xf32, #spirv.storage_class>) kernel { gpu.return } } func.func @main() { %0 = "op"() : () -> (f32) - %1 = "op"() : () -> (memref<12xf32, #spv.storage_class>) + %1 = "op"() : () -> (memref<12xf32, #spirv.storage_class>) %cst = arith.constant 1 : index gpu.launch_func @kernels::@missing_entry_point_abi blocks in (%cst, %cst, %cst) threads in (%cst, %cst, %cst) - args(%0 : f32, %1 : memref<12xf32, #spv.storage_class>) + args(%0 : f32, %1 : memref<12xf32, #spirv.storage_class>) return } } @@ -76,13 +76,13 @@ module attributes {gpu.container_module} { gpu.module @kernels { // expected-error @below {{failed to legalize operation 'gpu.func'}} - // expected-remark @below {{match failure: missing 'spv.interface_var_abi' attribute at argument 1}} + // expected-remark @below {{match failure: missing 'spirv.interface_var_abi' attribute at argument 1}} gpu.func @missing_entry_point_abi( %arg0 : f32 - {spv.interface_var_abi = #spv.interface_var_abi<(1, 2), StorageBuffer>}, - %arg1 : memref<12xf32, #spv.storage_class>) kernel + {spirv.interface_var_abi = #spirv.interface_var_abi<(1, 2), StorageBuffer>}, + %arg1 : memref<12xf32, #spirv.storage_class>) kernel attributes - {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { + {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { gpu.return } } @@ -93,13 +93,13 @@ module attributes {gpu.container_module} { gpu.module @kernels { // expected-error @below {{failed to legalize operation 'gpu.func'}} - // expected-remark @below {{match failure: missing 'spv.interface_var_abi' attribute at argument 0}} + // expected-remark @below {{match failure: missing 'spirv.interface_var_abi' attribute at argument 0}} gpu.func @missing_entry_point_abi( %arg0 : f32, - %arg1 : memref<12xf32, #spv.storage_class> - {spv.interface_var_abi = #spv.interface_var_abi<(3, 0)>}) kernel + %arg1 : memref<12xf32, #spirv.storage_class> + {spirv.interface_var_abi = #spirv.interface_var_abi<(3, 0)>}) kernel attributes - {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { + {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { gpu.return } } @@ -109,10 +109,10 @@ module attributes {gpu.container_module} { gpu.module @kernels { - // CHECK-LABEL: spv.func @barrier - gpu.func @barrier(%arg0 : f32, %arg1 : memref<12xf32, #spv.storage_class>) kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: spv.ControlBarrier , , + // CHECK-LABEL: spirv.func @barrier + gpu.func @barrier(%arg0 : f32, %arg1 : memref<12xf32, #spirv.storage_class>) kernel + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: spirv.ControlBarrier , , gpu.barrier gpu.return } @@ -120,11 +120,11 @@ func.func @main() { %0 = "op"() : () -> (f32) - %1 = "op"() : () -> (memref<12xf32, #spv.storage_class>) + %1 = "op"() : () -> (memref<12xf32, #spirv.storage_class>) %cst = arith.constant 1 : index gpu.launch_func @kernels::@barrier blocks in (%cst, %cst, %cst) threads in (%cst, %cst, %cst) - args(%0 : f32, %1 : memref<12xf32, #spv.storage_class>) + args(%0 : f32, %1 : memref<12xf32, #spirv.storage_class>) return } } diff --git a/mlir/test/Conversion/GPUToSPIRV/load-store.mlir b/mlir/test/Conversion/GPUToSPIRV/load-store.mlir --- a/mlir/test/Conversion/GPUToSPIRV/load-store.mlir +++ b/mlir/test/Conversion/GPUToSPIRV/load-store.mlir @@ -2,10 +2,10 @@ module attributes { gpu.container_module, - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { - func.func @load_store(%arg0: memref<12x4xf32, #spv.storage_class>, %arg1: memref<12x4xf32, #spv.storage_class>, %arg2: memref<12x4xf32, #spv.storage_class>) { + func.func @load_store(%arg0: memref<12x4xf32, #spirv.storage_class>, %arg1: memref<12x4xf32, #spirv.storage_class>, %arg2: memref<12x4xf32, #spirv.storage_class>) { %c0 = arith.constant 0 : index %c12 = arith.constant 12 : index %0 = arith.subi %c12, %c0 : index @@ -17,32 +17,32 @@ %c1_2 = arith.constant 1 : index gpu.launch_func @kernels::@load_store_kernel blocks in (%0, %c1_2, %c1_2) threads in (%1, %c1_2, %c1_2) - args(%arg0 : memref<12x4xf32, #spv.storage_class>, %arg1 : memref<12x4xf32, #spv.storage_class>, %arg2 : memref<12x4xf32, #spv.storage_class>, + args(%arg0 : memref<12x4xf32, #spirv.storage_class>, %arg1 : memref<12x4xf32, #spirv.storage_class>, %arg2 : memref<12x4xf32, #spirv.storage_class>, %c0 : index, %c0_0 : index, %c1 : index, %c1_1 : index) return } - // CHECK-LABEL: spv.module @{{.*}} Logical GLSL450 + // CHECK-LABEL: spirv.module @{{.*}} Logical GLSL450 gpu.module @kernels { - // CHECK-DAG: spv.GlobalVariable @[[NUMWORKGROUPSVAR:.*]] built_in("NumWorkgroups") : !spv.ptr, Input> - // CHECK-DAG: spv.GlobalVariable @[[$LOCALINVOCATIONIDVAR:.*]] built_in("LocalInvocationId") : !spv.ptr, Input> - // CHECK-DAG: spv.GlobalVariable @[[$WORKGROUPIDVAR:.*]] built_in("WorkgroupId") : !spv.ptr, Input> - // CHECK-LABEL: spv.func @load_store_kernel - // CHECK-SAME: %[[ARG0:.*]]: !spv.ptr [0])>, StorageBuffer> {spv.interface_var_abi = #spv.interface_var_abi<(0, 0)>} - // CHECK-SAME: %[[ARG1:.*]]: !spv.ptr [0])>, StorageBuffer> {spv.interface_var_abi = #spv.interface_var_abi<(0, 1)>} - // CHECK-SAME: %[[ARG2:.*]]: !spv.ptr [0])>, StorageBuffer> {spv.interface_var_abi = #spv.interface_var_abi<(0, 2)>} - // CHECK-SAME: %[[ARG3:.*]]: i32 {spv.interface_var_abi = #spv.interface_var_abi<(0, 3), StorageBuffer>} - // CHECK-SAME: %[[ARG4:.*]]: i32 {spv.interface_var_abi = #spv.interface_var_abi<(0, 4), StorageBuffer>} - // CHECK-SAME: %[[ARG5:.*]]: i32 {spv.interface_var_abi = #spv.interface_var_abi<(0, 5), StorageBuffer>} - // CHECK-SAME: %[[ARG6:.*]]: i32 {spv.interface_var_abi = #spv.interface_var_abi<(0, 6), StorageBuffer>} - gpu.func @load_store_kernel(%arg0: memref<12x4xf32, #spv.storage_class>, %arg1: memref<12x4xf32, #spv.storage_class>, %arg2: memref<12x4xf32, #spv.storage_class>, %arg3: index, %arg4: index, %arg5: index, %arg6: index) kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { - // CHECK: %[[ADDRESSWORKGROUPID:.*]] = spv.mlir.addressof @[[$WORKGROUPIDVAR]] - // CHECK: %[[WORKGROUPID:.*]] = spv.Load "Input" %[[ADDRESSWORKGROUPID]] - // CHECK: %[[WORKGROUPIDX:.*]] = spv.CompositeExtract %[[WORKGROUPID]]{{\[}}0 : i32{{\]}} - // CHECK: %[[ADDRESSLOCALINVOCATIONID:.*]] = spv.mlir.addressof @[[$LOCALINVOCATIONIDVAR]] - // CHECK: %[[LOCALINVOCATIONID:.*]] = spv.Load "Input" %[[ADDRESSLOCALINVOCATIONID]] - // CHECK: %[[LOCALINVOCATIONIDX:.*]] = spv.CompositeExtract %[[LOCALINVOCATIONID]]{{\[}}0 : i32{{\]}} + // CHECK-DAG: spirv.GlobalVariable @[[NUMWORKGROUPSVAR:.*]] built_in("NumWorkgroups") : !spirv.ptr, Input> + // CHECK-DAG: spirv.GlobalVariable @[[$LOCALINVOCATIONIDVAR:.*]] built_in("LocalInvocationId") : !spirv.ptr, Input> + // CHECK-DAG: spirv.GlobalVariable @[[$WORKGROUPIDVAR:.*]] built_in("WorkgroupId") : !spirv.ptr, Input> + // CHECK-LABEL: spirv.func @load_store_kernel + // CHECK-SAME: %[[ARG0:.*]]: !spirv.ptr [0])>, StorageBuffer> {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 0)>} + // CHECK-SAME: %[[ARG1:.*]]: !spirv.ptr [0])>, StorageBuffer> {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1)>} + // CHECK-SAME: %[[ARG2:.*]]: !spirv.ptr [0])>, StorageBuffer> {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 2)>} + // CHECK-SAME: %[[ARG3:.*]]: i32 {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 3), StorageBuffer>} + // CHECK-SAME: %[[ARG4:.*]]: i32 {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 4), StorageBuffer>} + // CHECK-SAME: %[[ARG5:.*]]: i32 {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 5), StorageBuffer>} + // CHECK-SAME: %[[ARG6:.*]]: i32 {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 6), StorageBuffer>} + gpu.func @load_store_kernel(%arg0: memref<12x4xf32, #spirv.storage_class>, %arg1: memref<12x4xf32, #spirv.storage_class>, %arg2: memref<12x4xf32, #spirv.storage_class>, %arg3: index, %arg4: index, %arg5: index, %arg6: index) kernel + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { + // CHECK: %[[ADDRESSWORKGROUPID:.*]] = spirv.mlir.addressof @[[$WORKGROUPIDVAR]] + // CHECK: %[[WORKGROUPID:.*]] = spirv.Load "Input" %[[ADDRESSWORKGROUPID]] + // CHECK: %[[WORKGROUPIDX:.*]] = spirv.CompositeExtract %[[WORKGROUPID]]{{\[}}0 : i32{{\]}} + // CHECK: %[[ADDRESSLOCALINVOCATIONID:.*]] = spirv.mlir.addressof @[[$LOCALINVOCATIONIDVAR]] + // CHECK: %[[LOCALINVOCATIONID:.*]] = spirv.Load "Input" %[[ADDRESSLOCALINVOCATIONID]] + // CHECK: %[[LOCALINVOCATIONIDX:.*]] = spirv.CompositeExtract %[[LOCALINVOCATIONID]]{{\[}}0 : i32{{\]}} %0 = gpu.block_id x %1 = gpu.block_id y %2 = gpu.block_id z @@ -55,29 +55,29 @@ %9 = gpu.block_dim x %10 = gpu.block_dim y %11 = gpu.block_dim z - // CHECK: %[[INDEX1:.*]] = spv.IAdd %[[ARG3]], %[[WORKGROUPIDX]] + // CHECK: %[[INDEX1:.*]] = spirv.IAdd %[[ARG3]], %[[WORKGROUPIDX]] %12 = arith.addi %arg3, %0 : index - // CHECK: %[[INDEX2:.*]] = spv.IAdd %[[ARG4]], %[[LOCALINVOCATIONIDX]] + // CHECK: %[[INDEX2:.*]] = spirv.IAdd %[[ARG4]], %[[LOCALINVOCATIONIDX]] %13 = arith.addi %arg4, %3 : index - // CHECK: %[[ZERO:.*]] = spv.Constant 0 : i32 - // CHECK: %[[OFFSET1_0:.*]] = spv.Constant 0 : i32 - // CHECK: %[[STRIDE1_1:.*]] = spv.Constant 4 : i32 - // CHECK: %[[UPDATE1_1:.*]] = spv.IMul %[[STRIDE1_1]], %[[INDEX1]] : i32 - // CHECK: %[[OFFSET1_1:.*]] = spv.IAdd %[[OFFSET1_0]], %[[UPDATE1_1]] : i32 - // CHECK: %[[STRIDE1_2:.*]] = spv.Constant 1 : i32 - // CHECK: %[[UPDATE1_2:.*]] = spv.IMul %[[STRIDE1_2]], %[[INDEX2]] : i32 - // CHECK: %[[OFFSET1_2:.*]] = spv.IAdd %[[OFFSET1_1]], %[[UPDATE1_2]] : i32 - // CHECK: %[[PTR1:.*]] = spv.AccessChain %[[ARG0]]{{\[}}%[[ZERO]], %[[OFFSET1_2]]{{\]}} - // CHECK-NEXT: %[[VAL1:.*]] = spv.Load "StorageBuffer" %[[PTR1]] - %14 = memref.load %arg0[%12, %13] : memref<12x4xf32, #spv.storage_class> - // CHECK: %[[PTR2:.*]] = spv.AccessChain %[[ARG1]]{{\[}}{{%.*}}, {{%.*}}{{\]}} - // CHECK-NEXT: %[[VAL2:.*]] = spv.Load "StorageBuffer" %[[PTR2]] - %15 = memref.load %arg1[%12, %13] : memref<12x4xf32, #spv.storage_class> - // CHECK: %[[VAL3:.*]] = spv.FAdd %[[VAL1]], %[[VAL2]] + // CHECK: %[[ZERO:.*]] = spirv.Constant 0 : i32 + // CHECK: %[[OFFSET1_0:.*]] = spirv.Constant 0 : i32 + // CHECK: %[[STRIDE1_1:.*]] = spirv.Constant 4 : i32 + // CHECK: %[[UPDATE1_1:.*]] = spirv.IMul %[[STRIDE1_1]], %[[INDEX1]] : i32 + // CHECK: %[[OFFSET1_1:.*]] = spirv.IAdd %[[OFFSET1_0]], %[[UPDATE1_1]] : i32 + // CHECK: %[[STRIDE1_2:.*]] = spirv.Constant 1 : i32 + // CHECK: %[[UPDATE1_2:.*]] = spirv.IMul %[[STRIDE1_2]], %[[INDEX2]] : i32 + // CHECK: %[[OFFSET1_2:.*]] = spirv.IAdd %[[OFFSET1_1]], %[[UPDATE1_2]] : i32 + // CHECK: %[[PTR1:.*]] = spirv.AccessChain %[[ARG0]]{{\[}}%[[ZERO]], %[[OFFSET1_2]]{{\]}} + // CHECK-NEXT: %[[VAL1:.*]] = spirv.Load "StorageBuffer" %[[PTR1]] + %14 = memref.load %arg0[%12, %13] : memref<12x4xf32, #spirv.storage_class> + // CHECK: %[[PTR2:.*]] = spirv.AccessChain %[[ARG1]]{{\[}}{{%.*}}, {{%.*}}{{\]}} + // CHECK-NEXT: %[[VAL2:.*]] = spirv.Load "StorageBuffer" %[[PTR2]] + %15 = memref.load %arg1[%12, %13] : memref<12x4xf32, #spirv.storage_class> + // CHECK: %[[VAL3:.*]] = spirv.FAdd %[[VAL1]], %[[VAL2]] %16 = arith.addf %14, %15 : f32 - // CHECK: %[[PTR3:.*]] = spv.AccessChain %[[ARG2]]{{\[}}{{%.*}}, {{%.*}}{{\]}} - // CHECK-NEXT: spv.Store "StorageBuffer" %[[PTR3]], %[[VAL3]] - memref.store %16, %arg2[%12, %13] : memref<12x4xf32, #spv.storage_class> + // CHECK: %[[PTR3:.*]] = spirv.AccessChain %[[ARG2]]{{\[}}{{%.*}}, {{%.*}}{{\]}} + // CHECK-NEXT: spirv.Store "StorageBuffer" %[[PTR3]], %[[VAL3]] + memref.store %16, %arg2[%12, %13] : memref<12x4xf32, #spirv.storage_class> gpu.return } } diff --git a/mlir/test/Conversion/GPUToSPIRV/module-opencl.mlir b/mlir/test/Conversion/GPUToSPIRV/module-opencl.mlir --- a/mlir/test/Conversion/GPUToSPIRV/module-opencl.mlir +++ b/mlir/test/Conversion/GPUToSPIRV/module-opencl.mlir @@ -2,29 +2,29 @@ module attributes { gpu.container_module, - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { gpu.module @kernels { - // CHECK-LABEL: spv.module @{{.*}} Physical64 OpenCL - // CHECK: spv.func + // CHECK-LABEL: spirv.module @{{.*}} Physical64 OpenCL + // CHECK: spirv.func // CHECK-SAME: {{%.*}}: f32 - // CHECK-NOT: spv.interface_var_abi - // CHECK-SAME: {{%.*}}: !spv.ptr - // CHECK-NOT: spv.interface_var_abi - // CHECK-SAME: spv.entry_point_abi = #spv.entry_point_abi : vector<3xi32>> - gpu.func @basic_module_structure(%arg0 : f32, %arg1 : memref<12xf32, #spv.storage_class>) kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { + // CHECK-NOT: spirv.interface_var_abi + // CHECK-SAME: {{%.*}}: !spirv.ptr + // CHECK-NOT: spirv.interface_var_abi + // CHECK-SAME: spirv.entry_point_abi = #spirv.entry_point_abi : vector<3xi32>> + gpu.func @basic_module_structure(%arg0 : f32, %arg1 : memref<12xf32, #spirv.storage_class>) kernel + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { gpu.return } } func.func @main() { %0 = "op"() : () -> (f32) - %1 = "op"() : () -> (memref<12xf32, #spv.storage_class>) + %1 = "op"() : () -> (memref<12xf32, #spirv.storage_class>) %cst = arith.constant 1 : index gpu.launch_func @kernels::@basic_module_structure blocks in (%cst, %cst, %cst) threads in (%cst, %cst, %cst) - args(%0 : f32, %1 : memref<12xf32, #spv.storage_class>) + args(%0 : f32, %1 : memref<12xf32, #spirv.storage_class>) return } } diff --git a/mlir/test/Conversion/GPUToSPIRV/shuffle.mlir b/mlir/test/Conversion/GPUToSPIRV/shuffle.mlir --- a/mlir/test/Conversion/GPUToSPIRV/shuffle.mlir +++ b/mlir/test/Conversion/GPUToSPIRV/shuffle.mlir @@ -2,21 +2,21 @@ module attributes { gpu.container_module, - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits> } { gpu.module @kernels { - // CHECK-LABEL: spv.func @shuffle_xor() + // CHECK-LABEL: spirv.func @shuffle_xor() gpu.func @shuffle_xor() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { %mask = arith.constant 8 : i32 %width = arith.constant 16 : i32 %val = arith.constant 42.0 : f32 - // CHECK: %[[MASK:.+]] = spv.Constant 8 : i32 - // CHECK: %[[VAL:.+]] = spv.Constant 4.200000e+01 : f32 - // CHECK: %{{.+}} = spv.Constant true - // CHECK: %{{.+}} = spv.GroupNonUniformShuffleXor %[[VAL]], %[[MASK]] : f32, i32 + // CHECK: %[[MASK:.+]] = spirv.Constant 8 : i32 + // CHECK: %[[VAL:.+]] = spirv.Constant 4.200000e+01 : f32 + // CHECK: %{{.+}} = spirv.Constant true + // CHECK: %{{.+}} = spirv.GroupNonUniformShuffleXor %[[VAL]], %[[MASK]] : f32, i32 %result, %valid = gpu.shuffle xor %val, %mask, %width : f32 gpu.return } @@ -28,12 +28,12 @@ module attributes { gpu.container_module, - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits> } { gpu.module @kernels { gpu.func @shuffle_xor() kernel - attributes {spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { + attributes {spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { %mask = arith.constant 8 : i32 %width = arith.constant 16 : i32 %val = arith.constant 42.0 : f32 diff --git a/mlir/test/Conversion/GPUToVulkan/lower-gpu-launch-vulkan-launch.mlir b/mlir/test/Conversion/GPUToVulkan/lower-gpu-launch-vulkan-launch.mlir --- a/mlir/test/Conversion/GPUToVulkan/lower-gpu-launch-vulkan-launch.mlir +++ b/mlir/test/Conversion/GPUToVulkan/lower-gpu-launch-vulkan-launch.mlir @@ -5,18 +5,18 @@ // CHECK: call @vulkanLaunch(%[[index]], %[[index]], %[[index]], %[[resource]]) {spirv_blob = "{{.*}}", spirv_entry_point = "kernel"} module attributes {gpu.container_module} { - spv.module Logical GLSL450 requires #spv.vce { - spv.GlobalVariable @kernel_arg_0 bind(0, 0) : !spv.ptr [0])>, StorageBuffer> - spv.func @kernel() "None" attributes {workgroup_attributions = 0 : i64} { - %0 = spv.mlir.addressof @kernel_arg_0 : !spv.ptr [0])>, StorageBuffer> - %2 = spv.Constant 0 : i32 - %3 = spv.mlir.addressof @kernel_arg_0 : !spv.ptr [0])>, StorageBuffer> - %4 = spv.AccessChain %0[%2, %2] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %5 = spv.Load "StorageBuffer" %4 : f32 - spv.Return + spirv.module Logical GLSL450 requires #spirv.vce { + spirv.GlobalVariable @kernel_arg_0 bind(0, 0) : !spirv.ptr [0])>, StorageBuffer> + spirv.func @kernel() "None" attributes {workgroup_attributions = 0 : i64} { + %0 = spirv.mlir.addressof @kernel_arg_0 : !spirv.ptr [0])>, StorageBuffer> + %2 = spirv.Constant 0 : i32 + %3 = spirv.mlir.addressof @kernel_arg_0 : !spirv.ptr [0])>, StorageBuffer> + %4 = spirv.AccessChain %0[%2, %2] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %5 = spirv.Load "StorageBuffer" %4 : f32 + spirv.Return } - spv.EntryPoint "GLCompute" @kernel - spv.ExecutionMode @kernel "LocalSize", 1, 1, 1 + spirv.EntryPoint "GLCompute" @kernel + spirv.ExecutionMode @kernel "LocalSize", 1, 1, 1 } gpu.module @kernels { gpu.func @kernel(%arg0: memref<12xf32>) kernel { diff --git a/mlir/test/Conversion/LinalgToSPIRV/linalg-to-spirv.mlir b/mlir/test/Conversion/LinalgToSPIRV/linalg-to-spirv.mlir --- a/mlir/test/Conversion/LinalgToSPIRV/linalg-to-spirv.mlir +++ b/mlir/test/Conversion/LinalgToSPIRV/linalg-to-spirv.mlir @@ -13,48 +13,48 @@ } module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { -// CHECK: spv.GlobalVariable +// CHECK: spirv.GlobalVariable // CHECK-SAME: built_in("LocalInvocationId") // CHECK: @single_workgroup_reduction -// CHECK-SAME: (%[[INPUT:.+]]: !spv.ptr{{.+}}, %[[OUTPUT:.+]]: !spv.ptr{{.+}}) +// CHECK-SAME: (%[[INPUT:.+]]: !spirv.ptr{{.+}}, %[[OUTPUT:.+]]: !spirv.ptr{{.+}}) -// CHECK: %[[ZERO:.+]] = spv.Constant 0 : i32 -// CHECK: %[[ID:.+]] = spv.Load "Input" %{{.+}} : vector<3xi32> -// CHECK: %[[X:.+]] = spv.CompositeExtract %[[ID]][0 : i32] +// CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32 +// CHECK: %[[ID:.+]] = spirv.Load "Input" %{{.+}} : vector<3xi32> +// CHECK: %[[X:.+]] = spirv.CompositeExtract %[[ID]][0 : i32] -// CHECK: %[[INPTR:.+]] = spv.AccessChain %[[INPUT]][%[[ZERO]], %[[X]]] -// CHECK: %[[VAL:.+]] = spv.Load "StorageBuffer" %[[INPTR]] : i32 -// CHECK: %[[ADD:.+]] = spv.GroupNonUniformIAdd "Subgroup" "Reduce" %[[VAL]] : i32 +// CHECK: %[[INPTR:.+]] = spirv.AccessChain %[[INPUT]][%[[ZERO]], %[[X]]] +// CHECK: %[[VAL:.+]] = spirv.Load "StorageBuffer" %[[INPTR]] : i32 +// CHECK: %[[ADD:.+]] = spirv.GroupNonUniformIAdd "Subgroup" "Reduce" %[[VAL]] : i32 -// CHECK: %[[OUTPTR:.+]] = spv.AccessChain %[[OUTPUT]][%[[ZERO]], %[[ZERO]]] -// CHECK: %[[ELECT:.+]] = spv.GroupNonUniformElect : i1 +// CHECK: %[[OUTPTR:.+]] = spirv.AccessChain %[[OUTPUT]][%[[ZERO]], %[[ZERO]]] +// CHECK: %[[ELECT:.+]] = spirv.GroupNonUniformElect : i1 -// CHECK: spv.mlir.selection { -// CHECK: spv.BranchConditional %[[ELECT]], ^bb1, ^bb2 +// CHECK: spirv.mlir.selection { +// CHECK: spirv.BranchConditional %[[ELECT]], ^bb1, ^bb2 // CHECK: ^bb1: -// CHECK: spv.AtomicIAdd "Device" "AcquireRelease" %[[OUTPTR]], %[[ADD]] -// CHECK: spv.Branch ^bb2 +// CHECK: spirv.AtomicIAdd "Device" "AcquireRelease" %[[OUTPTR]], %[[ADD]] +// CHECK: spirv.Branch ^bb2 // CHECK: ^bb2: -// CHECK: spv.mlir.merge +// CHECK: spirv.mlir.merge // CHECK: } -// CHECK: spv.Return +// CHECK: spirv.Return -func.func @single_workgroup_reduction(%input: memref<16xi32, #spv.storage_class>, %output: memref<1xi32, #spv.storage_class>) attributes { - spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>> +func.func @single_workgroup_reduction(%input: memref<16xi32, #spirv.storage_class>, %output: memref<1xi32, #spirv.storage_class>) attributes { + spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>> } { linalg.generic #single_workgroup_reduction_trait - ins(%input : memref<16xi32, #spv.storage_class>) - outs(%output : memref<1xi32, #spv.storage_class>) { + ins(%input : memref<16xi32, #spirv.storage_class>) + outs(%output : memref<1xi32, #spirv.storage_class>) { ^bb(%in: i32, %out: i32): %sum = arith.addi %in, %out : i32 linalg.yield %sum : i32 } - spv.Return + spirv.Return } } @@ -71,14 +71,14 @@ } module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { -func.func @single_workgroup_reduction(%input: memref<16xi32, #spv.storage_class>, %output: memref<1xi32, #spv.storage_class>) { +func.func @single_workgroup_reduction(%input: memref<16xi32, #spirv.storage_class>, %output: memref<1xi32, #spirv.storage_class>) { // expected-error @+1 {{failed to legalize operation 'linalg.generic'}} linalg.generic #single_workgroup_reduction_trait - ins(%input : memref<16xi32, #spv.storage_class>) - outs(%output : memref<1xi32, #spv.storage_class>) { + ins(%input : memref<16xi32, #spirv.storage_class>) + outs(%output : memref<1xi32, #spirv.storage_class>) { ^bb(%in: i32, %out: i32): %sum = arith.addi %in, %out : i32 linalg.yield %sum : i32 @@ -100,21 +100,21 @@ } module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { -func.func @single_workgroup_reduction(%input: memref<16xi32, #spv.storage_class>, %output: memref<1xi32, #spv.storage_class>) attributes { - spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>> +func.func @single_workgroup_reduction(%input: memref<16xi32, #spirv.storage_class>, %output: memref<1xi32, #spirv.storage_class>) attributes { + spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>> } { // expected-error @+1 {{failed to legalize operation 'linalg.generic'}} linalg.generic #single_workgroup_reduction_trait - ins(%input : memref<16xi32, #spv.storage_class>) - outs(%output : memref<1xi32, #spv.storage_class>) { + ins(%input : memref<16xi32, #spirv.storage_class>) + outs(%output : memref<1xi32, #spirv.storage_class>) { ^bb(%in: i32, %out: i32): %sum = arith.addi %in, %out : i32 linalg.yield %sum : i32 } - spv.Return + spirv.Return } } @@ -131,20 +131,20 @@ } module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { -func.func @single_workgroup_reduction(%input: memref<16x8xi32, #spv.storage_class>, %output: memref<16xi32, #spv.storage_class>) attributes { - spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>> +func.func @single_workgroup_reduction(%input: memref<16x8xi32, #spirv.storage_class>, %output: memref<16xi32, #spirv.storage_class>) attributes { + spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>> } { // expected-error @+1 {{failed to legalize operation 'linalg.generic'}} linalg.generic #single_workgroup_reduction_trait - ins(%input : memref<16x8xi32, #spv.storage_class>) - outs(%output : memref<16xi32, #spv.storage_class>) { + ins(%input : memref<16x8xi32, #spirv.storage_class>) + outs(%output : memref<16xi32, #spirv.storage_class>) { ^bb(%in: i32, %out: i32): %sum = arith.addi %in, %out : i32 linalg.yield %sum : i32 } - spv.Return + spirv.Return } } diff --git a/mlir/test/Conversion/MathToSPIRV/math-to-core-spirv.mlir b/mlir/test/Conversion/MathToSPIRV/math-to-core-spirv.mlir --- a/mlir/test/Conversion/MathToSPIRV/math-to-core-spirv.mlir +++ b/mlir/test/Conversion/MathToSPIRV/math-to-core-spirv.mlir @@ -7,19 +7,19 @@ // CHECK-LABEL: func @copy_sign_scalar // CHECK-SAME: (%[[VALUE:.+]]: f32, %[[SIGN:.+]]: f32) -// CHECK: %[[SMASK:.+]] = spv.Constant -2147483648 : i32 -// CHECK: %[[VMASK:.+]] = spv.Constant 2147483647 : i32 -// CHECK: %[[VCAST:.+]] = spv.Bitcast %[[VALUE]] : f32 to i32 -// CHECK: %[[SCAST:.+]] = spv.Bitcast %[[SIGN]] : f32 to i32 -// CHECK: %[[VAND:.+]] = spv.BitwiseAnd %[[VCAST]], %[[VMASK]] : i32 -// CHECK: %[[SAND:.+]] = spv.BitwiseAnd %[[SCAST]], %[[SMASK]] : i32 -// CHECK: %[[OR:.+]] = spv.BitwiseOr %[[VAND]], %[[SAND]] : i32 -// CHECK: %[[RESULT:.+]] = spv.Bitcast %[[OR]] : i32 to f32 +// CHECK: %[[SMASK:.+]] = spirv.Constant -2147483648 : i32 +// CHECK: %[[VMASK:.+]] = spirv.Constant 2147483647 : i32 +// CHECK: %[[VCAST:.+]] = spirv.Bitcast %[[VALUE]] : f32 to i32 +// CHECK: %[[SCAST:.+]] = spirv.Bitcast %[[SIGN]] : f32 to i32 +// CHECK: %[[VAND:.+]] = spirv.BitwiseAnd %[[VCAST]], %[[VMASK]] : i32 +// CHECK: %[[SAND:.+]] = spirv.BitwiseAnd %[[SCAST]], %[[SMASK]] : i32 +// CHECK: %[[OR:.+]] = spirv.BitwiseOr %[[VAND]], %[[SAND]] : i32 +// CHECK: %[[RESULT:.+]] = spirv.Bitcast %[[OR]] : i32 to f32 // CHECK: return %[[RESULT]] // ----- -module attributes { spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> } { +module attributes { spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { func.func @copy_sign_vector(%value: vector<3xf16>, %sign: vector<3xf16>) -> vector<3xf16> { %0 = math.copysign %value, %sign : vector<3xf16> @@ -30,14 +30,14 @@ // CHECK-LABEL: func @copy_sign_vector // CHECK-SAME: (%[[VALUE:.+]]: vector<3xf16>, %[[SIGN:.+]]: vector<3xf16>) -// CHECK: %[[SMASK:.+]] = spv.Constant -32768 : i16 -// CHECK: %[[VMASK:.+]] = spv.Constant 32767 : i16 -// CHECK: %[[SVMASK:.+]] = spv.CompositeConstruct %[[SMASK]], %[[SMASK]], %[[SMASK]] -// CHECK: %[[VVMASK:.+]] = spv.CompositeConstruct %[[VMASK]], %[[VMASK]], %[[VMASK]] -// CHECK: %[[VCAST:.+]] = spv.Bitcast %[[VALUE]] : vector<3xf16> to vector<3xi16> -// CHECK: %[[SCAST:.+]] = spv.Bitcast %[[SIGN]] : vector<3xf16> to vector<3xi16> -// CHECK: %[[VAND:.+]] = spv.BitwiseAnd %[[VCAST]], %[[VVMASK]] : vector<3xi16> -// CHECK: %[[SAND:.+]] = spv.BitwiseAnd %[[SCAST]], %[[SVMASK]] : vector<3xi16> -// CHECK: %[[OR:.+]] = spv.BitwiseOr %[[VAND]], %[[SAND]] : vector<3xi16> -// CHECK: %[[RESULT:.+]] = spv.Bitcast %[[OR]] : vector<3xi16> to vector<3xf16> +// CHECK: %[[SMASK:.+]] = spirv.Constant -32768 : i16 +// CHECK: %[[VMASK:.+]] = spirv.Constant 32767 : i16 +// CHECK: %[[SVMASK:.+]] = spirv.CompositeConstruct %[[SMASK]], %[[SMASK]], %[[SMASK]] +// CHECK: %[[VVMASK:.+]] = spirv.CompositeConstruct %[[VMASK]], %[[VMASK]], %[[VMASK]] +// CHECK: %[[VCAST:.+]] = spirv.Bitcast %[[VALUE]] : vector<3xf16> to vector<3xi16> +// CHECK: %[[SCAST:.+]] = spirv.Bitcast %[[SIGN]] : vector<3xf16> to vector<3xi16> +// CHECK: %[[VAND:.+]] = spirv.BitwiseAnd %[[VCAST]], %[[VVMASK]] : vector<3xi16> +// CHECK: %[[SAND:.+]] = spirv.BitwiseAnd %[[SCAST]], %[[SVMASK]] : vector<3xi16> +// CHECK: %[[OR:.+]] = spirv.BitwiseOr %[[VAND]], %[[SAND]] : vector<3xi16> +// CHECK: %[[RESULT:.+]] = spirv.Bitcast %[[OR]] : vector<3xi16> to vector<3xf16> // CHECK: return %[[RESULT]] diff --git a/mlir/test/Conversion/MathToSPIRV/math-to-gl-spirv.mlir b/mlir/test/Conversion/MathToSPIRV/math-to-gl-spirv.mlir --- a/mlir/test/Conversion/MathToSPIRV/math-to-gl-spirv.mlir +++ b/mlir/test/Conversion/MathToSPIRV/math-to-gl-spirv.mlir @@ -1,72 +1,72 @@ // RUN: mlir-opt -split-input-file -convert-math-to-spirv -verify-diagnostics %s -o - | FileCheck %s module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @float32_unary_scalar func.func @float32_unary_scalar(%arg0: f32) { - // CHECK: spv.GL.Cos %{{.*}}: f32 + // CHECK: spirv.GL.Cos %{{.*}}: f32 %0 = math.cos %arg0 : f32 - // CHECK: spv.GL.Exp %{{.*}}: f32 + // CHECK: spirv.GL.Exp %{{.*}}: f32 %1 = math.exp %arg0 : f32 - // CHECK: %[[EXP:.+]] = spv.GL.Exp %arg0 - // CHECK: %[[ONE:.+]] = spv.Constant 1.000000e+00 : f32 - // CHECK: spv.FSub %[[EXP]], %[[ONE]] + // CHECK: %[[EXP:.+]] = spirv.GL.Exp %arg0 + // CHECK: %[[ONE:.+]] = spirv.Constant 1.000000e+00 : f32 + // CHECK: spirv.FSub %[[EXP]], %[[ONE]] %2 = math.expm1 %arg0 : f32 - // CHECK: spv.GL.Log %{{.*}}: f32 + // CHECK: spirv.GL.Log %{{.*}}: f32 %3 = math.log %arg0 : f32 - // CHECK: %[[ONE:.+]] = spv.Constant 1.000000e+00 : f32 - // CHECK: %[[ADDONE:.+]] = spv.FAdd %[[ONE]], %{{.+}} - // CHECK: spv.GL.Log %[[ADDONE]] + // CHECK: %[[ONE:.+]] = spirv.Constant 1.000000e+00 : f32 + // CHECK: %[[ADDONE:.+]] = spirv.FAdd %[[ONE]], %{{.+}} + // CHECK: spirv.GL.Log %[[ADDONE]] %4 = math.log1p %arg0 : f32 - // CHECK: spv.GL.InverseSqrt %{{.*}}: f32 + // CHECK: spirv.GL.InverseSqrt %{{.*}}: f32 %5 = math.rsqrt %arg0 : f32 - // CHECK: spv.GL.Sqrt %{{.*}}: f32 + // CHECK: spirv.GL.Sqrt %{{.*}}: f32 %6 = math.sqrt %arg0 : f32 - // CHECK: spv.GL.Tanh %{{.*}}: f32 + // CHECK: spirv.GL.Tanh %{{.*}}: f32 %7 = math.tanh %arg0 : f32 - // CHECK: spv.GL.Sin %{{.*}}: f32 + // CHECK: spirv.GL.Sin %{{.*}}: f32 %8 = math.sin %arg0 : f32 - // CHECK: spv.GL.FAbs %{{.*}}: f32 + // CHECK: spirv.GL.FAbs %{{.*}}: f32 %9 = math.absf %arg0 : f32 - // CHECK: spv.GL.Ceil %{{.*}}: f32 + // CHECK: spirv.GL.Ceil %{{.*}}: f32 %10 = math.ceil %arg0 : f32 - // CHECK: spv.GL.Floor %{{.*}}: f32 + // CHECK: spirv.GL.Floor %{{.*}}: f32 %11 = math.floor %arg0 : f32 return } // CHECK-LABEL: @float32_unary_vector func.func @float32_unary_vector(%arg0: vector<3xf32>) { - // CHECK: spv.GL.Cos %{{.*}}: vector<3xf32> + // CHECK: spirv.GL.Cos %{{.*}}: vector<3xf32> %0 = math.cos %arg0 : vector<3xf32> - // CHECK: spv.GL.Exp %{{.*}}: vector<3xf32> + // CHECK: spirv.GL.Exp %{{.*}}: vector<3xf32> %1 = math.exp %arg0 : vector<3xf32> - // CHECK: %[[EXP:.+]] = spv.GL.Exp %arg0 - // CHECK: %[[ONE:.+]] = spv.Constant dense<1.000000e+00> : vector<3xf32> - // CHECK: spv.FSub %[[EXP]], %[[ONE]] + // CHECK: %[[EXP:.+]] = spirv.GL.Exp %arg0 + // CHECK: %[[ONE:.+]] = spirv.Constant dense<1.000000e+00> : vector<3xf32> + // CHECK: spirv.FSub %[[EXP]], %[[ONE]] %2 = math.expm1 %arg0 : vector<3xf32> - // CHECK: spv.GL.Log %{{.*}}: vector<3xf32> + // CHECK: spirv.GL.Log %{{.*}}: vector<3xf32> %3 = math.log %arg0 : vector<3xf32> - // CHECK: %[[ONE:.+]] = spv.Constant dense<1.000000e+00> : vector<3xf32> - // CHECK: %[[ADDONE:.+]] = spv.FAdd %[[ONE]], %{{.+}} - // CHECK: spv.GL.Log %[[ADDONE]] + // CHECK: %[[ONE:.+]] = spirv.Constant dense<1.000000e+00> : vector<3xf32> + // CHECK: %[[ADDONE:.+]] = spirv.FAdd %[[ONE]], %{{.+}} + // CHECK: spirv.GL.Log %[[ADDONE]] %4 = math.log1p %arg0 : vector<3xf32> - // CHECK: spv.GL.InverseSqrt %{{.*}}: vector<3xf32> + // CHECK: spirv.GL.InverseSqrt %{{.*}}: vector<3xf32> %5 = math.rsqrt %arg0 : vector<3xf32> - // CHECK: spv.GL.Sqrt %{{.*}}: vector<3xf32> + // CHECK: spirv.GL.Sqrt %{{.*}}: vector<3xf32> %6 = math.sqrt %arg0 : vector<3xf32> - // CHECK: spv.GL.Tanh %{{.*}}: vector<3xf32> + // CHECK: spirv.GL.Tanh %{{.*}}: vector<3xf32> %7 = math.tanh %arg0 : vector<3xf32> - // CHECK: spv.GL.Sin %{{.*}}: vector<3xf32> + // CHECK: spirv.GL.Sin %{{.*}}: vector<3xf32> %8 = math.sin %arg0 : vector<3xf32> return } // CHECK-LABEL: @float32_ternary_scalar func.func @float32_ternary_scalar(%a: f32, %b: f32, %c: f32) { - // CHECK: spv.GL.Fma %{{.*}}: f32 + // CHECK: spirv.GL.Fma %{{.*}}: f32 %0 = math.fma %a, %b, %c : f32 return } @@ -74,14 +74,14 @@ // CHECK-LABEL: @float32_ternary_vector func.func @float32_ternary_vector(%a: vector<4xf32>, %b: vector<4xf32>, %c: vector<4xf32>) { - // CHECK: spv.GL.Fma %{{.*}}: vector<4xf32> + // CHECK: spirv.GL.Fma %{{.*}}: vector<4xf32> %0 = math.fma %a, %b, %c : vector<4xf32> return } // CHECK-LABEL: @int_unary func.func @int_unary(%arg0: i32) { - // CHECK: spv.GL.SAbs %{{.*}} + // CHECK: spirv.GL.SAbs %{{.*}} %0 = math.absi %arg0 : i32 return } @@ -89,14 +89,14 @@ // CHECK-LABEL: @ctlz_scalar // CHECK-SAME: (%[[VAL:.+]]: i32) func.func @ctlz_scalar(%val: i32) -> i32 { - // CHECK-DAG: %[[V1:.+]] = spv.Constant 1 : i32 - // CHECK-DAG: %[[V31:.+]] = spv.Constant 31 : i32 - // CHECK-DAG: %[[V32:.+]] = spv.Constant 32 : i32 - // CHECK: %[[MSB:.+]] = spv.GL.FindUMsb %[[VAL]] : i32 - // CHECK: %[[SUB1:.+]] = spv.ISub %[[V31]], %[[MSB]] : i32 - // CHECK: %[[SUB2:.+]] = spv.ISub %[[V32]], %[[VAL]] : i32 - // CHECK: %[[CMP:.+]] = spv.ULessThanEqual %[[VAL]], %[[V1]] : i32 - // CHECK: %[[R:.+]] = spv.Select %[[CMP]], %[[SUB2]], %[[SUB1]] : i1, i32 + // CHECK-DAG: %[[V1:.+]] = spirv.Constant 1 : i32 + // CHECK-DAG: %[[V31:.+]] = spirv.Constant 31 : i32 + // CHECK-DAG: %[[V32:.+]] = spirv.Constant 32 : i32 + // CHECK: %[[MSB:.+]] = spirv.GL.FindUMsb %[[VAL]] : i32 + // CHECK: %[[SUB1:.+]] = spirv.ISub %[[V31]], %[[MSB]] : i32 + // CHECK: %[[SUB2:.+]] = spirv.ISub %[[V32]], %[[VAL]] : i32 + // CHECK: %[[CMP:.+]] = spirv.ULessThanEqual %[[VAL]], %[[V1]] : i32 + // CHECK: %[[R:.+]] = spirv.Select %[[CMP]], %[[SUB2]], %[[SUB1]] : i1, i32 // CHECK: return %[[R]] %0 = math.ctlz %val : i32 return %0 : i32 @@ -104,10 +104,10 @@ // CHECK-LABEL: @ctlz_vector1 func.func @ctlz_vector1(%val: vector<1xi32>) -> vector<1xi32> { - // CHECK: spv.GL.FindUMsb - // CHECK: spv.ISub - // CHECK: spv.ULessThanEqual - // CHECK: spv.Select + // CHECK: spirv.GL.FindUMsb + // CHECK: spirv.ISub + // CHECK: spirv.ULessThanEqual + // CHECK: spirv.Select %0 = math.ctlz %val : vector<1xi32> return %0 : vector<1xi32> } @@ -115,14 +115,14 @@ // CHECK-LABEL: @ctlz_vector2 // CHECK-SAME: (%[[VAL:.+]]: vector<2xi32>) func.func @ctlz_vector2(%val: vector<2xi32>) -> vector<2xi32> { - // CHECK-DAG: %[[V1:.+]] = spv.Constant dense<1> : vector<2xi32> - // CHECK-DAG: %[[V31:.+]] = spv.Constant dense<31> : vector<2xi32> - // CHECK-DAG: %[[V32:.+]] = spv.Constant dense<32> : vector<2xi32> - // CHECK: %[[MSB:.+]] = spv.GL.FindUMsb %[[VAL]] : vector<2xi32> - // CHECK: %[[SUB1:.+]] = spv.ISub %[[V31]], %[[MSB]] : vector<2xi32> - // CHECK: %[[SUB2:.+]] = spv.ISub %[[V32]], %[[VAL]] : vector<2xi32> - // CHECK: %[[CMP:.+]] = spv.ULessThanEqual %[[VAL]], %[[V1]] : vector<2xi32> - // CHECK: %[[R:.+]] = spv.Select %[[CMP]], %[[SUB2]], %[[SUB1]] : vector<2xi1>, vector<2xi32> + // CHECK-DAG: %[[V1:.+]] = spirv.Constant dense<1> : vector<2xi32> + // CHECK-DAG: %[[V31:.+]] = spirv.Constant dense<31> : vector<2xi32> + // CHECK-DAG: %[[V32:.+]] = spirv.Constant dense<32> : vector<2xi32> + // CHECK: %[[MSB:.+]] = spirv.GL.FindUMsb %[[VAL]] : vector<2xi32> + // CHECK: %[[SUB1:.+]] = spirv.ISub %[[V31]], %[[MSB]] : vector<2xi32> + // CHECK: %[[SUB2:.+]] = spirv.ISub %[[V32]], %[[VAL]] : vector<2xi32> + // CHECK: %[[CMP:.+]] = spirv.ULessThanEqual %[[VAL]], %[[V1]] : vector<2xi32> + // CHECK: %[[R:.+]] = spirv.Select %[[CMP]], %[[SUB2]], %[[SUB1]] : vector<2xi1>, vector<2xi32> %0 = math.ctlz %val : vector<2xi32> return %0 : vector<2xi32> } @@ -130,12 +130,12 @@ // CHECK-LABEL: @powf_scalar // CHECK-SAME: (%[[LHS:.+]]: f32, %[[RHS:.+]]: f32) func.func @powf_scalar(%lhs: f32, %rhs: f32) -> f32 { - // CHECK: %[[F0:.+]] = spv.Constant 0.000000e+00 : f32 - // CHECK: %[[LT:.+]] = spv.FOrdLessThan %[[LHS]], %[[F0]] : f32 - // CHECK: %[[ABS:.+]] = spv.GL.FAbs %[[LHS]] : f32 - // CHECK: %[[POW:.+]] = spv.GL.Pow %[[ABS]], %[[RHS]] : f32 - // CHECK: %[[NEG:.+]] = spv.FNegate %[[POW]] : f32 - // CHECK: %[[SEL:.+]] = spv.Select %[[LT]], %[[NEG]], %[[POW]] : i1, f32 + // CHECK: %[[F0:.+]] = spirv.Constant 0.000000e+00 : f32 + // CHECK: %[[LT:.+]] = spirv.FOrdLessThan %[[LHS]], %[[F0]] : f32 + // CHECK: %[[ABS:.+]] = spirv.GL.FAbs %[[LHS]] : f32 + // CHECK: %[[POW:.+]] = spirv.GL.Pow %[[ABS]], %[[RHS]] : f32 + // CHECK: %[[NEG:.+]] = spirv.FNegate %[[POW]] : f32 + // CHECK: %[[SEL:.+]] = spirv.Select %[[LT]], %[[NEG]], %[[POW]] : i1, f32 %0 = math.powf %lhs, %rhs : f32 // CHECK: return %[[SEL]] return %0: f32 @@ -143,43 +143,43 @@ // CHECK-LABEL: @powf_vector func.func @powf_vector(%lhs: vector<4xf32>, %rhs: vector<4xf32>) -> vector<4xf32> { - // CHECK: spv.FOrdLessThan - // CHEKC: spv.GL.FAbs - // CHECK: spv.GL.Pow %{{.*}}: vector<4xf32> - // CHECK: spv.FNegate - // CHECK: spv.Select + // CHECK: spirv.FOrdLessThan + // CHEKC: spirv.GL.FAbs + // CHECK: spirv.GL.Pow %{{.*}}: vector<4xf32> + // CHECK: spirv.FNegate + // CHECK: spirv.Select %0 = math.powf %lhs, %rhs : vector<4xf32> return %0: vector<4xf32> } // CHECK-LABEL: @round_scalar func.func @round_scalar(%x: f32) -> f32 { - // CHECK: %[[ZERO:.+]] = spv.Constant 0.000000e+00 - // CHECK: %[[ONE:.+]] = spv.Constant 1.000000e+00 - // CHECK: %[[HALF:.+]] = spv.Constant 5.000000e-01 - // CHECK: %[[ABS:.+]] = spv.GL.FAbs %arg0 - // CHECK: %[[FLOOR:.+]] = spv.GL.Floor %[[ABS]] - // CHECK: %[[SUB:.+]] = spv.FSub %[[ABS]], %[[FLOOR]] - // CHECK: %[[GE:.+]] = spv.FOrdGreaterThanEqual %[[SUB]], %[[HALF]] - // CHECK: %[[SEL:.+]] = spv.Select %[[GE]], %[[ONE]], %[[ZERO]] - // CHECK: %[[ADD:.+]] = spv.FAdd %[[FLOOR]], %[[SEL]] - // CHECK: %[[BITCAST:.+]] = spv.Bitcast %[[ADD]] + // CHECK: %[[ZERO:.+]] = spirv.Constant 0.000000e+00 + // CHECK: %[[ONE:.+]] = spirv.Constant 1.000000e+00 + // CHECK: %[[HALF:.+]] = spirv.Constant 5.000000e-01 + // CHECK: %[[ABS:.+]] = spirv.GL.FAbs %arg0 + // CHECK: %[[FLOOR:.+]] = spirv.GL.Floor %[[ABS]] + // CHECK: %[[SUB:.+]] = spirv.FSub %[[ABS]], %[[FLOOR]] + // CHECK: %[[GE:.+]] = spirv.FOrdGreaterThanEqual %[[SUB]], %[[HALF]] + // CHECK: %[[SEL:.+]] = spirv.Select %[[GE]], %[[ONE]], %[[ZERO]] + // CHECK: %[[ADD:.+]] = spirv.FAdd %[[FLOOR]], %[[SEL]] + // CHECK: %[[BITCAST:.+]] = spirv.Bitcast %[[ADD]] %0 = math.round %x : f32 return %0: f32 } // CHECK-LABEL: @round_vector func.func @round_vector(%x: vector<4xf32>) -> vector<4xf32> { - // CHECK: %[[ZERO:.+]] = spv.Constant dense<0.000000e+00> - // CHECK: %[[ONE:.+]] = spv.Constant dense<1.000000e+00> - // CHECK: %[[HALF:.+]] = spv.Constant dense<5.000000e-01> - // CHECK: %[[ABS:.+]] = spv.GL.FAbs %arg0 - // CHECK: %[[FLOOR:.+]] = spv.GL.Floor %[[ABS]] - // CHECK: %[[SUB:.+]] = spv.FSub %[[ABS]], %[[FLOOR]] - // CHECK: %[[GE:.+]] = spv.FOrdGreaterThanEqual %[[SUB]], %[[HALF]] - // CHECK: %[[SEL:.+]] = spv.Select %[[GE]], %[[ONE]], %[[ZERO]] - // CHECK: %[[ADD:.+]] = spv.FAdd %[[FLOOR]], %[[SEL]] - // CHECK: %[[BITCAST:.+]] = spv.Bitcast %[[ADD]] + // CHECK: %[[ZERO:.+]] = spirv.Constant dense<0.000000e+00> + // CHECK: %[[ONE:.+]] = spirv.Constant dense<1.000000e+00> + // CHECK: %[[HALF:.+]] = spirv.Constant dense<5.000000e-01> + // CHECK: %[[ABS:.+]] = spirv.GL.FAbs %arg0 + // CHECK: %[[FLOOR:.+]] = spirv.GL.Floor %[[ABS]] + // CHECK: %[[SUB:.+]] = spirv.FSub %[[ABS]], %[[FLOOR]] + // CHECK: %[[GE:.+]] = spirv.FOrdGreaterThanEqual %[[SUB]], %[[HALF]] + // CHECK: %[[SEL:.+]] = spirv.Select %[[GE]], %[[ONE]], %[[ZERO]] + // CHECK: %[[ADD:.+]] = spirv.FAdd %[[FLOOR]], %[[SEL]] + // CHECK: %[[BITCAST:.+]] = spirv.Bitcast %[[ADD]] %0 = math.round %x : vector<4xf32> return %0: vector<4xf32> } @@ -189,7 +189,7 @@ // ----- module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @ctlz_scalar diff --git a/mlir/test/Conversion/MathToSPIRV/math-to-opencl-spirv.mlir b/mlir/test/Conversion/MathToSPIRV/math-to-opencl-spirv.mlir --- a/mlir/test/Conversion/MathToSPIRV/math-to-opencl-spirv.mlir +++ b/mlir/test/Conversion/MathToSPIRV/math-to-opencl-spirv.mlir @@ -1,88 +1,88 @@ // RUN: mlir-opt -split-input-file -convert-math-to-spirv -verify-diagnostics %s -o - | FileCheck %s -module attributes { spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> } { +module attributes { spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @float32_unary_scalar func.func @float32_unary_scalar(%arg0: f32) { - // CHECK: spv.CL.cos %{{.*}}: f32 + // CHECK: spirv.CL.cos %{{.*}}: f32 %0 = math.cos %arg0 : f32 - // CHECK: spv.CL.exp %{{.*}}: f32 + // CHECK: spirv.CL.exp %{{.*}}: f32 %1 = math.exp %arg0 : f32 - // CHECK: %[[EXP:.+]] = spv.CL.exp %arg0 - // CHECK: %[[ONE:.+]] = spv.Constant 1.000000e+00 : f32 - // CHECK: spv.FSub %[[EXP]], %[[ONE]] + // CHECK: %[[EXP:.+]] = spirv.CL.exp %arg0 + // CHECK: %[[ONE:.+]] = spirv.Constant 1.000000e+00 : f32 + // CHECK: spirv.FSub %[[EXP]], %[[ONE]] %2 = math.expm1 %arg0 : f32 - // CHECK: spv.CL.log %{{.*}}: f32 + // CHECK: spirv.CL.log %{{.*}}: f32 %3 = math.log %arg0 : f32 - // CHECK: %[[ONE:.+]] = spv.Constant 1.000000e+00 : f32 - // CHECK: %[[ADDONE:.+]] = spv.FAdd %[[ONE]], %{{.+}} - // CHECK: spv.CL.log %[[ADDONE]] + // CHECK: %[[ONE:.+]] = spirv.Constant 1.000000e+00 : f32 + // CHECK: %[[ADDONE:.+]] = spirv.FAdd %[[ONE]], %{{.+}} + // CHECK: spirv.CL.log %[[ADDONE]] %4 = math.log1p %arg0 : f32 - // CHECK: spv.CL.rsqrt %{{.*}}: f32 + // CHECK: spirv.CL.rsqrt %{{.*}}: f32 %5 = math.rsqrt %arg0 : f32 - // CHECK: spv.CL.sqrt %{{.*}}: f32 + // CHECK: spirv.CL.sqrt %{{.*}}: f32 %6 = math.sqrt %arg0 : f32 - // CHECK: spv.CL.tanh %{{.*}}: f32 + // CHECK: spirv.CL.tanh %{{.*}}: f32 %7 = math.tanh %arg0 : f32 - // CHECK: spv.CL.sin %{{.*}}: f32 + // CHECK: spirv.CL.sin %{{.*}}: f32 %8 = math.sin %arg0 : f32 - // CHECK: spv.CL.fabs %{{.*}}: f32 + // CHECK: spirv.CL.fabs %{{.*}}: f32 %9 = math.absf %arg0 : f32 - // CHECK: spv.CL.ceil %{{.*}}: f32 + // CHECK: spirv.CL.ceil %{{.*}}: f32 %10 = math.ceil %arg0 : f32 - // CHECK: spv.CL.floor %{{.*}}: f32 + // CHECK: spirv.CL.floor %{{.*}}: f32 %11 = math.floor %arg0 : f32 - // CHECK: spv.CL.erf %{{.*}}: f32 + // CHECK: spirv.CL.erf %{{.*}}: f32 %12 = math.erf %arg0 : f32 - // CHECK: spv.CL.round %{{.*}}: f32 + // CHECK: spirv.CL.round %{{.*}}: f32 %13 = math.round %arg0 : f32 return } // CHECK-LABEL: @float32_unary_vector func.func @float32_unary_vector(%arg0: vector<3xf32>) { - // CHECK: spv.CL.cos %{{.*}}: vector<3xf32> + // CHECK: spirv.CL.cos %{{.*}}: vector<3xf32> %0 = math.cos %arg0 : vector<3xf32> - // CHECK: spv.CL.exp %{{.*}}: vector<3xf32> + // CHECK: spirv.CL.exp %{{.*}}: vector<3xf32> %1 = math.exp %arg0 : vector<3xf32> - // CHECK: %[[EXP:.+]] = spv.CL.exp %arg0 - // CHECK: %[[ONE:.+]] = spv.Constant dense<1.000000e+00> : vector<3xf32> - // CHECK: spv.FSub %[[EXP]], %[[ONE]] + // CHECK: %[[EXP:.+]] = spirv.CL.exp %arg0 + // CHECK: %[[ONE:.+]] = spirv.Constant dense<1.000000e+00> : vector<3xf32> + // CHECK: spirv.FSub %[[EXP]], %[[ONE]] %2 = math.expm1 %arg0 : vector<3xf32> - // CHECK: spv.CL.log %{{.*}}: vector<3xf32> + // CHECK: spirv.CL.log %{{.*}}: vector<3xf32> %3 = math.log %arg0 : vector<3xf32> - // CHECK: %[[ONE:.+]] = spv.Constant dense<1.000000e+00> : vector<3xf32> - // CHECK: %[[ADDONE:.+]] = spv.FAdd %[[ONE]], %{{.+}} - // CHECK: spv.CL.log %[[ADDONE]] + // CHECK: %[[ONE:.+]] = spirv.Constant dense<1.000000e+00> : vector<3xf32> + // CHECK: %[[ADDONE:.+]] = spirv.FAdd %[[ONE]], %{{.+}} + // CHECK: spirv.CL.log %[[ADDONE]] %4 = math.log1p %arg0 : vector<3xf32> - // CHECK: spv.CL.rsqrt %{{.*}}: vector<3xf32> + // CHECK: spirv.CL.rsqrt %{{.*}}: vector<3xf32> %5 = math.rsqrt %arg0 : vector<3xf32> - // CHECK: spv.CL.sqrt %{{.*}}: vector<3xf32> + // CHECK: spirv.CL.sqrt %{{.*}}: vector<3xf32> %6 = math.sqrt %arg0 : vector<3xf32> - // CHECK: spv.CL.tanh %{{.*}}: vector<3xf32> + // CHECK: spirv.CL.tanh %{{.*}}: vector<3xf32> %7 = math.tanh %arg0 : vector<3xf32> - // CHECK: spv.CL.sin %{{.*}}: vector<3xf32> + // CHECK: spirv.CL.sin %{{.*}}: vector<3xf32> %8 = math.sin %arg0 : vector<3xf32> return } // CHECK-LABEL: @float32_binary_scalar func.func @float32_binary_scalar(%lhs: f32, %rhs: f32) { - // CHECK: spv.CL.pow %{{.*}}: f32 + // CHECK: spirv.CL.pow %{{.*}}: f32 %0 = math.powf %lhs, %rhs : f32 return } // CHECK-LABEL: @float32_binary_vector func.func @float32_binary_vector(%lhs: vector<4xf32>, %rhs: vector<4xf32>) { - // CHECK: spv.CL.pow %{{.*}}: vector<4xf32> + // CHECK: spirv.CL.pow %{{.*}}: vector<4xf32> %0 = math.powf %lhs, %rhs : vector<4xf32> return } // CHECK-LABEL: @float32_ternary_scalar func.func @float32_ternary_scalar(%a: f32, %b: f32, %c: f32) { - // CHECK: spv.CL.fma %{{.*}}: f32 + // CHECK: spirv.CL.fma %{{.*}}: f32 %0 = math.fma %a, %b, %c : f32 return } @@ -90,7 +90,7 @@ // CHECK-LABEL: @float32_ternary_vector func.func @float32_ternary_vector(%a: vector<4xf32>, %b: vector<4xf32>, %c: vector<4xf32>) { - // CHECK: spv.CL.fma %{{.*}}: vector<4xf32> + // CHECK: spirv.CL.fma %{{.*}}: vector<4xf32> %0 = math.fma %a, %b, %c : vector<4xf32> return } diff --git a/mlir/test/Conversion/MemRefToSPIRV/alloc.mlir b/mlir/test/Conversion/MemRefToSPIRV/alloc.mlir --- a/mlir/test/Conversion/MemRefToSPIRV/alloc.mlir +++ b/mlir/test/Conversion/MemRefToSPIRV/alloc.mlir @@ -1,110 +1,110 @@ // RUN: mlir-opt -split-input-file -convert-memref-to-spirv -canonicalize -verify-diagnostics %s -o - | FileCheck %s module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { func.func @alloc_dealloc_workgroup_mem(%arg0 : index, %arg1 : index) { - %0 = memref.alloc() : memref<4x5xf32, #spv.storage_class> - %1 = memref.load %0[%arg0, %arg1] : memref<4x5xf32, #spv.storage_class> - memref.store %1, %0[%arg0, %arg1] : memref<4x5xf32, #spv.storage_class> - memref.dealloc %0 : memref<4x5xf32, #spv.storage_class> + %0 = memref.alloc() : memref<4x5xf32, #spirv.storage_class> + %1 = memref.load %0[%arg0, %arg1] : memref<4x5xf32, #spirv.storage_class> + memref.store %1, %0[%arg0, %arg1] : memref<4x5xf32, #spirv.storage_class> + memref.dealloc %0 : memref<4x5xf32, #spirv.storage_class> return } } -// CHECK: spv.GlobalVariable @[[VAR:.+]] : !spv.ptr)>, Workgroup> +// CHECK: spirv.GlobalVariable @[[VAR:.+]] : !spirv.ptr)>, Workgroup> // CHECK: func @alloc_dealloc_workgroup_mem // CHECK-NOT: memref.alloc -// CHECK: %[[PTR:.+]] = spv.mlir.addressof @[[VAR]] -// CHECK: %[[LOADPTR:.+]] = spv.AccessChain %[[PTR]] -// CHECK: %[[VAL:.+]] = spv.Load "Workgroup" %[[LOADPTR]] : f32 -// CHECK: %[[STOREPTR:.+]] = spv.AccessChain %[[PTR]] -// CHECK: spv.Store "Workgroup" %[[STOREPTR]], %[[VAL]] : f32 +// CHECK: %[[PTR:.+]] = spirv.mlir.addressof @[[VAR]] +// CHECK: %[[LOADPTR:.+]] = spirv.AccessChain %[[PTR]] +// CHECK: %[[VAL:.+]] = spirv.Load "Workgroup" %[[LOADPTR]] : f32 +// CHECK: %[[STOREPTR:.+]] = spirv.AccessChain %[[PTR]] +// CHECK: spirv.Store "Workgroup" %[[STOREPTR]], %[[VAL]] : f32 // CHECK-NOT: memref.dealloc // ----- module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { func.func @alloc_dealloc_workgroup_mem(%arg0 : index, %arg1 : index) { - %0 = memref.alloc() : memref<4x5xi16, #spv.storage_class> - %1 = memref.load %0[%arg0, %arg1] : memref<4x5xi16, #spv.storage_class> - memref.store %1, %0[%arg0, %arg1] : memref<4x5xi16, #spv.storage_class> - memref.dealloc %0 : memref<4x5xi16, #spv.storage_class> + %0 = memref.alloc() : memref<4x5xi16, #spirv.storage_class> + %1 = memref.load %0[%arg0, %arg1] : memref<4x5xi16, #spirv.storage_class> + memref.store %1, %0[%arg0, %arg1] : memref<4x5xi16, #spirv.storage_class> + memref.dealloc %0 : memref<4x5xi16, #spirv.storage_class> return } } -// CHECK: spv.GlobalVariable @__workgroup_mem__{{[0-9]+}} -// CHECK-SAME: !spv.ptr)>, Workgroup> +// CHECK: spirv.GlobalVariable @__workgroup_mem__{{[0-9]+}} +// CHECK-SAME: !spirv.ptr)>, Workgroup> // CHECK: func @alloc_dealloc_workgroup_mem -// CHECK: %[[VAR:.+]] = spv.mlir.addressof @__workgroup_mem__0 -// CHECK: %[[LOC:.+]] = spv.SDiv -// CHECK: %[[PTR:.+]] = spv.AccessChain %[[VAR]][%{{.+}}, %[[LOC]]] -// CHECK: %{{.+}} = spv.Load "Workgroup" %[[PTR]] : i32 -// CHECK: %[[LOC:.+]] = spv.SDiv -// CHECK: %[[PTR:.+]] = spv.AccessChain %[[VAR]][%{{.+}}, %[[LOC]]] -// CHECK: %{{.+}} = spv.AtomicAnd "Workgroup" "AcquireRelease" %[[PTR]], %{{.+}} : !spv.ptr -// CHECK: %{{.+}} = spv.AtomicOr "Workgroup" "AcquireRelease" %[[PTR]], %{{.+}} : !spv.ptr +// CHECK: %[[VAR:.+]] = spirv.mlir.addressof @__workgroup_mem__0 +// CHECK: %[[LOC:.+]] = spirv.SDiv +// CHECK: %[[PTR:.+]] = spirv.AccessChain %[[VAR]][%{{.+}}, %[[LOC]]] +// CHECK: %{{.+}} = spirv.Load "Workgroup" %[[PTR]] : i32 +// CHECK: %[[LOC:.+]] = spirv.SDiv +// CHECK: %[[PTR:.+]] = spirv.AccessChain %[[VAR]][%{{.+}}, %[[LOC]]] +// CHECK: %{{.+}} = spirv.AtomicAnd "Workgroup" "AcquireRelease" %[[PTR]], %{{.+}} : !spirv.ptr +// CHECK: %{{.+}} = spirv.AtomicOr "Workgroup" "AcquireRelease" %[[PTR]], %{{.+}} : !spirv.ptr // ----- module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { func.func @two_allocs() { - %0 = memref.alloc() : memref<4x5xf32, #spv.storage_class> - %1 = memref.alloc() : memref<2x3xi32, #spv.storage_class> + %0 = memref.alloc() : memref<4x5xf32, #spirv.storage_class> + %1 = memref.alloc() : memref<2x3xi32, #spirv.storage_class> return } } -// CHECK-DAG: spv.GlobalVariable @__workgroup_mem__{{[0-9]+}} -// CHECK-SAME: !spv.ptr)>, Workgroup> -// CHECK-DAG: spv.GlobalVariable @__workgroup_mem__{{[0-9]+}} -// CHECK-SAME: !spv.ptr)>, Workgroup> +// CHECK-DAG: spirv.GlobalVariable @__workgroup_mem__{{[0-9]+}} +// CHECK-SAME: !spirv.ptr)>, Workgroup> +// CHECK-DAG: spirv.GlobalVariable @__workgroup_mem__{{[0-9]+}} +// CHECK-SAME: !spirv.ptr)>, Workgroup> // CHECK: func @two_allocs() // ----- module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { func.func @two_allocs_vector() { - %0 = memref.alloc() : memref<4xvector<4xf32>, #spv.storage_class> - %1 = memref.alloc() : memref<2xvector<2xi32>, #spv.storage_class> + %0 = memref.alloc() : memref<4xvector<4xf32>, #spirv.storage_class> + %1 = memref.alloc() : memref<2xvector<2xi32>, #spirv.storage_class> return } } -// CHECK-DAG: spv.GlobalVariable @__workgroup_mem__{{[0-9]+}} -// CHECK-SAME: !spv.ptr>)>, Workgroup> -// CHECK-DAG: spv.GlobalVariable @__workgroup_mem__{{[0-9]+}} -// CHECK-SAME: !spv.ptr>)>, Workgroup> +// CHECK-DAG: spirv.GlobalVariable @__workgroup_mem__{{[0-9]+}} +// CHECK-SAME: !spirv.ptr>)>, Workgroup> +// CHECK-DAG: spirv.GlobalVariable @__workgroup_mem__{{[0-9]+}} +// CHECK-SAME: !spirv.ptr>)>, Workgroup> // CHECK: func @two_allocs_vector() // ----- module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: func @alloc_dynamic_size func.func @alloc_dynamic_size(%arg0 : index) -> f32 { // CHECK: memref.alloc - %0 = memref.alloc(%arg0) : memref<4x?xf32, #spv.storage_class> - %1 = memref.load %0[%arg0, %arg0] : memref<4x?xf32, #spv.storage_class> + %0 = memref.alloc(%arg0) : memref<4x?xf32, #spirv.storage_class> + %1 = memref.load %0[%arg0, %arg0] : memref<4x?xf32, #spirv.storage_class> return %1: f32 } } @@ -112,15 +112,15 @@ // ----- module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: func @alloc_unsupported_memory_space func.func @alloc_unsupported_memory_space(%arg0: index) -> f32 { // CHECK: memref.alloc - %0 = memref.alloc() : memref<4x5xf32, #spv.storage_class> - %1 = memref.load %0[%arg0, %arg0] : memref<4x5xf32, #spv.storage_class> + %0 = memref.alloc() : memref<4x5xf32, #spirv.storage_class> + %1 = memref.load %0[%arg0, %arg0] : memref<4x5xf32, #spirv.storage_class> return %1: f32 } } @@ -129,14 +129,14 @@ // ----- module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: func @dealloc_dynamic_size - func.func @dealloc_dynamic_size(%arg0 : memref<4x?xf32, #spv.storage_class>) { + func.func @dealloc_dynamic_size(%arg0 : memref<4x?xf32, #spirv.storage_class>) { // CHECK: memref.dealloc - memref.dealloc %arg0 : memref<4x?xf32, #spv.storage_class> + memref.dealloc %arg0 : memref<4x?xf32, #spirv.storage_class> return } } @@ -144,14 +144,14 @@ // ----- module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: func @dealloc_unsupported_memory_space - func.func @dealloc_unsupported_memory_space(%arg0 : memref<4x5xf32, #spv.storage_class>) { + func.func @dealloc_unsupported_memory_space(%arg0 : memref<4x5xf32, #spirv.storage_class>) { // CHECK: memref.dealloc - memref.dealloc %arg0 : memref<4x5xf32, #spv.storage_class> + memref.dealloc %arg0 : memref<4x5xf32, #spirv.storage_class> return } } diff --git a/mlir/test/Conversion/MemRefToSPIRV/alloca.mlir b/mlir/test/Conversion/MemRefToSPIRV/alloca.mlir --- a/mlir/test/Conversion/MemRefToSPIRV/alloca.mlir +++ b/mlir/test/Conversion/MemRefToSPIRV/alloca.mlir @@ -1,66 +1,66 @@ // RUN: mlir-opt -split-input-file -convert-memref-to-spirv -canonicalize -verify-diagnostics %s -o - | FileCheck %s -module attributes {spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>>} { +module attributes {spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>>} { func.func @alloc_function_variable(%arg0 : index, %arg1 : index) { - %0 = memref.alloca() : memref<4x5xf32, #spv.storage_class> - %1 = memref.load %0[%arg0, %arg1] : memref<4x5xf32, #spv.storage_class> - memref.store %1, %0[%arg0, %arg1] : memref<4x5xf32, #spv.storage_class> + %0 = memref.alloca() : memref<4x5xf32, #spirv.storage_class> + %1 = memref.load %0[%arg0, %arg1] : memref<4x5xf32, #spirv.storage_class> + memref.store %1, %0[%arg0, %arg1] : memref<4x5xf32, #spirv.storage_class> return } } // CHECK-LABEL: func @alloc_function_variable -// CHECK: %[[VAR:.+]] = spv.Variable : !spv.ptr)>, Function> -// CHECK: %[[LOADPTR:.+]] = spv.AccessChain %[[VAR]] -// CHECK: %[[VAL:.+]] = spv.Load "Function" %[[LOADPTR]] : f32 -// CHECK: %[[STOREPTR:.+]] = spv.AccessChain %[[VAR]] -// CHECK: spv.Store "Function" %[[STOREPTR]], %[[VAL]] : f32 +// CHECK: %[[VAR:.+]] = spirv.Variable : !spirv.ptr)>, Function> +// CHECK: %[[LOADPTR:.+]] = spirv.AccessChain %[[VAR]] +// CHECK: %[[VAL:.+]] = spirv.Load "Function" %[[LOADPTR]] : f32 +// CHECK: %[[STOREPTR:.+]] = spirv.AccessChain %[[VAR]] +// CHECK: spirv.Store "Function" %[[STOREPTR]], %[[VAL]] : f32 // ----- -module attributes {spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>>} { +module attributes {spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>>} { func.func @two_allocs() { - %0 = memref.alloca() : memref<4x5xf32, #spv.storage_class> - %1 = memref.alloca() : memref<2x3xi32, #spv.storage_class> + %0 = memref.alloca() : memref<4x5xf32, #spirv.storage_class> + %1 = memref.alloca() : memref<2x3xi32, #spirv.storage_class> return } } // CHECK-LABEL: func @two_allocs -// CHECK-DAG: spv.Variable : !spv.ptr)>, Function> -// CHECK-DAG: spv.Variable : !spv.ptr)>, Function> +// CHECK-DAG: spirv.Variable : !spirv.ptr)>, Function> +// CHECK-DAG: spirv.Variable : !spirv.ptr)>, Function> // ----- -module attributes {spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>>} { +module attributes {spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>>} { func.func @two_allocs_vector() { - %0 = memref.alloca() : memref<4xvector<4xf32>, #spv.storage_class> - %1 = memref.alloca() : memref<2xvector<2xi32>, #spv.storage_class> + %0 = memref.alloca() : memref<4xvector<4xf32>, #spirv.storage_class> + %1 = memref.alloca() : memref<2xvector<2xi32>, #spirv.storage_class> return } } // CHECK-LABEL: func @two_allocs_vector -// CHECK-DAG: spv.Variable : !spv.ptr>)>, Function> -// CHECK-DAG: spv.Variable : !spv.ptr>)>, Function> +// CHECK-DAG: spirv.Variable : !spirv.ptr>)>, Function> +// CHECK-DAG: spirv.Variable : !spirv.ptr>)>, Function> // ----- -module attributes {spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>>} { +module attributes {spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>>} { // CHECK-LABEL: func @alloc_dynamic_size func.func @alloc_dynamic_size(%arg0 : index) -> f32 { // CHECK: memref.alloca - %0 = memref.alloca(%arg0) : memref<4x?xf32, #spv.storage_class> - %1 = memref.load %0[%arg0, %arg0] : memref<4x?xf32, #spv.storage_class> + %0 = memref.alloca(%arg0) : memref<4x?xf32, #spirv.storage_class> + %1 = memref.load %0[%arg0, %arg0] : memref<4x?xf32, #spirv.storage_class> return %1: f32 } } // ----- -module attributes {spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>>} { +module attributes {spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>>} { // CHECK-LABEL: func @alloc_unsupported_memory_space func.func @alloc_unsupported_memory_space(%arg0: index) -> f32 { // CHECK: memref.alloca diff --git a/mlir/test/Conversion/MemRefToSPIRV/map-storage-class.mlir b/mlir/test/Conversion/MemRefToSPIRV/map-storage-class.mlir --- a/mlir/test/Conversion/MemRefToSPIRV/map-storage-class.mlir +++ b/mlir/test/Conversion/MemRefToSPIRV/map-storage-class.mlir @@ -18,29 +18,29 @@ // VULKAN-LABEL: func @operand_result // OPENCL-LABEL: func @operand_result func.func @operand_result() { - // VULKAN: memref> - // OPENCL: memref> + // VULKAN: memref> + // OPENCL: memref> %0 = "dialect.memref_producer"() : () -> (memref) - // VULKAN: memref<4xi32, #spv.storage_class> - // OPENCL: memref<4xi32, #spv.storage_class> + // VULKAN: memref<4xi32, #spirv.storage_class> + // OPENCL: memref<4xi32, #spirv.storage_class> %1 = "dialect.memref_producer"() : () -> (memref<4xi32, 1>) - // VULKAN: memref> - // OPENCL: memref> + // VULKAN: memref> + // OPENCL: memref> %2 = "dialect.memref_producer"() : () -> (memref) - // VULKAN: memref<*xf16, #spv.storage_class> - // OPENCL: memref<*xf16, #spv.storage_class> + // VULKAN: memref<*xf16, #spirv.storage_class> + // OPENCL: memref<*xf16, #spirv.storage_class> %3 = "dialect.memref_producer"() : () -> (memref<*xf16, 4>) "dialect.memref_consumer"(%0) : (memref) -> () - // VULKAN: memref<4xi32, #spv.storage_class> - // OPENCL: memref<4xi32, #spv.storage_class> + // VULKAN: memref<4xi32, #spirv.storage_class> + // OPENCL: memref<4xi32, #spirv.storage_class> "dialect.memref_consumer"(%1) : (memref<4xi32, 1>) -> () - // VULKAN: memref> - // OPENCL: memref> + // VULKAN: memref> + // OPENCL: memref> "dialect.memref_consumer"(%2) : (memref) -> () - // VULKAN: memref<*xf16, #spv.storage_class> - // OPENCL: memref<*xf16, #spv.storage_class> + // VULKAN: memref<*xf16, #spirv.storage_class> + // OPENCL: memref<*xf16, #spirv.storage_class> "dialect.memref_consumer"(%3) : (memref<*xf16, 4>) -> () return @@ -51,8 +51,8 @@ // VULKAN-LABEL: func @type_attribute // OPENCL-LABEL: func @type_attribute func.func @type_attribute() { - // VULKAN: attr = memref> - // OPENCL: attr = memref> + // VULKAN: attr = memref> + // OPENCL: attr = memref> "dialect.memref_producer"() { attr = memref } : () -> () return } @@ -62,11 +62,11 @@ // VULKAN-LABEL: func.func @function_io // OPENCL-LABEL: func.func @function_io func.func @function_io - // VULKAN-SAME: (%{{.+}}: memref>, %{{.+}}: memref<4xi32, #spv.storage_class>) - // OPENCL-SAME: (%{{.+}}: memref>, %{{.+}}: memref<4xi32, #spv.storage_class>) + // VULKAN-SAME: (%{{.+}}: memref>, %{{.+}}: memref<4xi32, #spirv.storage_class>) + // OPENCL-SAME: (%{{.+}}: memref>, %{{.+}}: memref<4xi32, #spirv.storage_class>) (%arg0: memref, %arg1: memref<4xi32, 3>) - // VULKAN-SAME: -> (memref>, memref<4xi32, #spv.storage_class>) - // OPENCL-SAME: -> (memref>, memref<4xi32, #spv.storage_class>) + // VULKAN-SAME: -> (memref>, memref<4xi32, #spirv.storage_class>) + // OPENCL-SAME: -> (memref>, memref<4xi32, #spirv.storage_class>) -> (memref, memref<4xi32, 3>) { return %arg0, %arg1: memref, memref<4xi32, 3> } @@ -76,8 +76,8 @@ gpu.module @kernel { // VULKAN-LABEL: gpu.func @function_io // OPENCL-LABEL: gpu.func @function_io -// VULKAN-SAME: memref<8xi32, #spv.storage_class> -// OPENCL-SAME: memref<8xi32, #spv.storage_class> +// VULKAN-SAME: memref<8xi32, #spirv.storage_class> +// OPENCL-SAME: memref<8xi32, #spirv.storage_class> gpu.func @function_io(%arg0 : memref<8xi32>) kernel { gpu.return } } @@ -87,10 +87,10 @@ // OPENCL-LABEL: func.func @region func.func @region(%cond: i1, %arg0: memref) { scf.if %cond { - // VULKAN: "dialect.memref_consumer"(%{{.+}}) {attr = memref>} - // OPENCL: "dialect.memref_consumer"(%{{.+}}) {attr = memref>} - // VULKAN-SAME: (memref>) -> memref> - // OPENCL-SAME: (memref>) -> memref> + // VULKAN: "dialect.memref_consumer"(%{{.+}}) {attr = memref>} + // OPENCL: "dialect.memref_consumer"(%{{.+}}) {attr = memref>} + // VULKAN-SAME: (memref>) -> memref> + // OPENCL-SAME: (memref>) -> memref> %0 = "dialect.memref_consumer"(%arg0) { attr = memref } : (memref) -> (memref) } return @@ -118,24 +118,24 @@ // ----- /// Checks memory maps to OpenCL mapping if Kernel capability is enabled. -module attributes { spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> } { +module attributes { spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { func.func @operand_result() { - // CHECK: memref> + // CHECK: memref> %0 = "dialect.memref_producer"() : () -> (memref) - // CHECK: memref<4xi32, #spv.storage_class> + // CHECK: memref<4xi32, #spirv.storage_class> %1 = "dialect.memref_producer"() : () -> (memref<4xi32, 1>) - // CHECK: memref> + // CHECK: memref> %2 = "dialect.memref_producer"() : () -> (memref) - // CHECK: memref<*xf16, #spv.storage_class> + // CHECK: memref<*xf16, #spirv.storage_class> %3 = "dialect.memref_producer"() : () -> (memref<*xf16, 4>) "dialect.memref_consumer"(%0) : (memref) -> () - // CHECK: memref<4xi32, #spv.storage_class> + // CHECK: memref<4xi32, #spirv.storage_class> "dialect.memref_consumer"(%1) : (memref<4xi32, 1>) -> () - // CHECK: memref> + // CHECK: memref> "dialect.memref_consumer"(%2) : (memref) -> () - // CHECK: memref<*xf16, #spv.storage_class> + // CHECK: memref<*xf16, #spirv.storage_class> "dialect.memref_consumer"(%3) : (memref<*xf16, 4>) -> () return @@ -145,25 +145,25 @@ // ----- /// Checks memory maps to Vulkan mapping if Shader capability is enabled. -module attributes { spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> } { +module attributes { spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { func.func @operand_result() { - // CHECK: memref> + // CHECK: memref> %0 = "dialect.memref_producer"() : () -> (memref) - // CHECK: memref<4xi32, #spv.storage_class> + // CHECK: memref<4xi32, #spirv.storage_class> %1 = "dialect.memref_producer"() : () -> (memref<4xi32, 1>) - // CHECK: memref> + // CHECK: memref> %2 = "dialect.memref_producer"() : () -> (memref) - // CHECK: memref<*xf16, #spv.storage_class> + // CHECK: memref<*xf16, #spirv.storage_class> %3 = "dialect.memref_producer"() : () -> (memref<*xf16, 4>) "dialect.memref_consumer"(%0) : (memref) -> () - // CHECK: memref<4xi32, #spv.storage_class> + // CHECK: memref<4xi32, #spirv.storage_class> "dialect.memref_consumer"(%1) : (memref<4xi32, 1>) -> () - // CHECK: memref> + // CHECK: memref> "dialect.memref_consumer"(%2) : (memref) -> () - // CHECK: memref<*xf16, #spv.storage_class> + // CHECK: memref<*xf16, #spirv.storage_class> "dialect.memref_consumer"(%3) : (memref<*xf16, 4>) -> () return } } \ No newline at end of file diff --git a/mlir/test/Conversion/MemRefToSPIRV/memref-to-spirv.mlir b/mlir/test/Conversion/MemRefToSPIRV/memref-to-spirv.mlir --- a/mlir/test/Conversion/MemRefToSPIRV/memref-to-spirv.mlir +++ b/mlir/test/Conversion/MemRefToSPIRV/memref-to-spirv.mlir @@ -4,104 +4,104 @@ // perform special tricks. module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + [SPV_KHR_16bit_storage, SPV_KHR_8bit_storage, SPV_KHR_storage_buffer_storage_class]>, #spirv.resource_limits<>> } { // CHECK-LABEL: @load_store_zero_rank_float -func.func @load_store_zero_rank_float(%arg0: memref>, %arg1: memref>) { - // CHECK: [[ARG0:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spv.ptr [0])>, StorageBuffer> - // CHECK: [[ARG1:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spv.ptr [0])>, StorageBuffer> - // CHECK: [[ZERO1:%.*]] = spv.Constant 0 : i32 - // CHECK: spv.AccessChain [[ARG0]][ +func.func @load_store_zero_rank_float(%arg0: memref>, %arg1: memref>) { + // CHECK: [[ARG0:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spirv.ptr [0])>, StorageBuffer> + // CHECK: [[ARG1:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spirv.ptr [0])>, StorageBuffer> + // CHECK: [[ZERO1:%.*]] = spirv.Constant 0 : i32 + // CHECK: spirv.AccessChain [[ARG0]][ // CHECK-SAME: [[ZERO1]], [[ZERO1]] // CHECK-SAME: ] : - // CHECK: spv.Load "StorageBuffer" %{{.*}} : f32 - %0 = memref.load %arg0[] : memref> - // CHECK: [[ZERO2:%.*]] = spv.Constant 0 : i32 - // CHECK: spv.AccessChain [[ARG1]][ + // CHECK: spirv.Load "StorageBuffer" %{{.*}} : f32 + %0 = memref.load %arg0[] : memref> + // CHECK: [[ZERO2:%.*]] = spirv.Constant 0 : i32 + // CHECK: spirv.AccessChain [[ARG1]][ // CHECK-SAME: [[ZERO2]], [[ZERO2]] // CHECK-SAME: ] : - // CHECK: spv.Store "StorageBuffer" %{{.*}} : f32 - memref.store %0, %arg1[] : memref> + // CHECK: spirv.Store "StorageBuffer" %{{.*}} : f32 + memref.store %0, %arg1[] : memref> return } // CHECK-LABEL: @load_store_zero_rank_int -func.func @load_store_zero_rank_int(%arg0: memref>, %arg1: memref>) { - // CHECK: [[ARG0:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spv.ptr [0])>, StorageBuffer> - // CHECK: [[ARG1:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spv.ptr [0])>, StorageBuffer> - // CHECK: [[ZERO1:%.*]] = spv.Constant 0 : i32 - // CHECK: spv.AccessChain [[ARG0]][ +func.func @load_store_zero_rank_int(%arg0: memref>, %arg1: memref>) { + // CHECK: [[ARG0:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spirv.ptr [0])>, StorageBuffer> + // CHECK: [[ARG1:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spirv.ptr [0])>, StorageBuffer> + // CHECK: [[ZERO1:%.*]] = spirv.Constant 0 : i32 + // CHECK: spirv.AccessChain [[ARG0]][ // CHECK-SAME: [[ZERO1]], [[ZERO1]] // CHECK-SAME: ] : - // CHECK: spv.Load "StorageBuffer" %{{.*}} : i32 - %0 = memref.load %arg0[] : memref> - // CHECK: [[ZERO2:%.*]] = spv.Constant 0 : i32 - // CHECK: spv.AccessChain [[ARG1]][ + // CHECK: spirv.Load "StorageBuffer" %{{.*}} : i32 + %0 = memref.load %arg0[] : memref> + // CHECK: [[ZERO2:%.*]] = spirv.Constant 0 : i32 + // CHECK: spirv.AccessChain [[ARG1]][ // CHECK-SAME: [[ZERO2]], [[ZERO2]] // CHECK-SAME: ] : - // CHECK: spv.Store "StorageBuffer" %{{.*}} : i32 - memref.store %0, %arg1[] : memref> + // CHECK: spirv.Store "StorageBuffer" %{{.*}} : i32 + memref.store %0, %arg1[] : memref> return } // CHECK-LABEL: func @load_store_unknown_dim -func.func @load_store_unknown_dim(%i: index, %source: memref>, %dest: memref>) { - // CHECK: %[[SRC:.+]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spv.ptr [0])>, StorageBuffer> - // CHECK: %[[DST:.+]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spv.ptr [0])>, StorageBuffer> - // CHECK: %[[AC0:.+]] = spv.AccessChain %[[SRC]] - // CHECK: spv.Load "StorageBuffer" %[[AC0]] - %0 = memref.load %source[%i] : memref> - // CHECK: %[[AC1:.+]] = spv.AccessChain %[[DST]] - // CHECK: spv.Store "StorageBuffer" %[[AC1]] - memref.store %0, %dest[%i]: memref> +func.func @load_store_unknown_dim(%i: index, %source: memref>, %dest: memref>) { + // CHECK: %[[SRC:.+]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spirv.ptr [0])>, StorageBuffer> + // CHECK: %[[DST:.+]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spirv.ptr [0])>, StorageBuffer> + // CHECK: %[[AC0:.+]] = spirv.AccessChain %[[SRC]] + // CHECK: spirv.Load "StorageBuffer" %[[AC0]] + %0 = memref.load %source[%i] : memref> + // CHECK: %[[AC1:.+]] = spirv.AccessChain %[[DST]] + // CHECK: spirv.Store "StorageBuffer" %[[AC1]] + memref.store %0, %dest[%i]: memref> return } // CHECK-LABEL: func @load_i1 -// CHECK-SAME: (%[[SRC:.+]]: memref<4xi1, #spv.storage_class>, %[[IDX:.+]]: index) -func.func @load_i1(%src: memref<4xi1, #spv.storage_class>, %i : index) -> i1 { - // CHECK-DAG: %[[SRC_CAST:.+]] = builtin.unrealized_conversion_cast %[[SRC]] : memref<4xi1, #spv.storage_class> to !spv.ptr [0])>, StorageBuffer> +// CHECK-SAME: (%[[SRC:.+]]: memref<4xi1, #spirv.storage_class>, %[[IDX:.+]]: index) +func.func @load_i1(%src: memref<4xi1, #spirv.storage_class>, %i : index) -> i1 { + // CHECK-DAG: %[[SRC_CAST:.+]] = builtin.unrealized_conversion_cast %[[SRC]] : memref<4xi1, #spirv.storage_class> to !spirv.ptr [0])>, StorageBuffer> // CHECK-DAG: %[[IDX_CAST:.+]] = builtin.unrealized_conversion_cast %[[IDX]] - // CHECK: %[[ZERO_0:.+]] = spv.Constant 0 : i32 - // CHECK: %[[ZERO_1:.+]] = spv.Constant 0 : i32 - // CHECK: %[[ONE:.+]] = spv.Constant 1 : i32 - // CHECK: %[[MUL:.+]] = spv.IMul %[[ONE]], %[[IDX_CAST]] : i32 - // CHECK: %[[ADD:.+]] = spv.IAdd %[[ZERO_1]], %[[MUL]] : i32 - // CHECK: %[[ADDR:.+]] = spv.AccessChain %[[SRC_CAST]][%[[ZERO_0]], %[[ADD]]] - // CHECK: %[[VAL:.+]] = spv.Load "StorageBuffer" %[[ADDR]] : i8 - // CHECK: %[[ONE_I8:.+]] = spv.Constant 1 : i8 - // CHECK: %[[BOOL:.+]] = spv.IEqual %[[VAL]], %[[ONE_I8]] : i8 - %0 = memref.load %src[%i] : memref<4xi1, #spv.storage_class> + // CHECK: %[[ZERO_0:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[ZERO_1:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32 + // CHECK: %[[MUL:.+]] = spirv.IMul %[[ONE]], %[[IDX_CAST]] : i32 + // CHECK: %[[ADD:.+]] = spirv.IAdd %[[ZERO_1]], %[[MUL]] : i32 + // CHECK: %[[ADDR:.+]] = spirv.AccessChain %[[SRC_CAST]][%[[ZERO_0]], %[[ADD]]] + // CHECK: %[[VAL:.+]] = spirv.Load "StorageBuffer" %[[ADDR]] : i8 + // CHECK: %[[ONE_I8:.+]] = spirv.Constant 1 : i8 + // CHECK: %[[BOOL:.+]] = spirv.IEqual %[[VAL]], %[[ONE_I8]] : i8 + %0 = memref.load %src[%i] : memref<4xi1, #spirv.storage_class> // CHECK: return %[[BOOL]] return %0: i1 } // CHECK-LABEL: func @store_i1 -// CHECK-SAME: %[[DST:.+]]: memref<4xi1, #spv.storage_class>, +// CHECK-SAME: %[[DST:.+]]: memref<4xi1, #spirv.storage_class>, // CHECK-SAME: %[[IDX:.+]]: index -func.func @store_i1(%dst: memref<4xi1, #spv.storage_class>, %i: index) { +func.func @store_i1(%dst: memref<4xi1, #spirv.storage_class>, %i: index) { %true = arith.constant true - // CHECK-DAG: %[[DST_CAST:.+]] = builtin.unrealized_conversion_cast %[[DST]] : memref<4xi1, #spv.storage_class> to !spv.ptr [0])>, StorageBuffer> + // CHECK-DAG: %[[DST_CAST:.+]] = builtin.unrealized_conversion_cast %[[DST]] : memref<4xi1, #spirv.storage_class> to !spirv.ptr [0])>, StorageBuffer> // CHECK-DAG: %[[IDX_CAST:.+]] = builtin.unrealized_conversion_cast %[[IDX]] - // CHECK: %[[ZERO_0:.+]] = spv.Constant 0 : i32 - // CHECK: %[[ZERO_1:.+]] = spv.Constant 0 : i32 - // CHECK: %[[ONE:.+]] = spv.Constant 1 : i32 - // CHECK: %[[MUL:.+]] = spv.IMul %[[ONE]], %[[IDX_CAST]] : i32 - // CHECK: %[[ADD:.+]] = spv.IAdd %[[ZERO_1]], %[[MUL]] : i32 - // CHECK: %[[ADDR:.+]] = spv.AccessChain %[[DST_CAST]][%[[ZERO_0]], %[[ADD]]] - // CHECK: %[[ZERO_I8:.+]] = spv.Constant 0 : i8 - // CHECK: %[[ONE_I8:.+]] = spv.Constant 1 : i8 - // CHECK: %[[RES:.+]] = spv.Select %{{.+}}, %[[ONE_I8]], %[[ZERO_I8]] : i1, i8 - // CHECK: spv.Store "StorageBuffer" %[[ADDR]], %[[RES]] : i8 - memref.store %true, %dst[%i]: memref<4xi1, #spv.storage_class> + // CHECK: %[[ZERO_0:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[ZERO_1:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32 + // CHECK: %[[MUL:.+]] = spirv.IMul %[[ONE]], %[[IDX_CAST]] : i32 + // CHECK: %[[ADD:.+]] = spirv.IAdd %[[ZERO_1]], %[[MUL]] : i32 + // CHECK: %[[ADDR:.+]] = spirv.AccessChain %[[DST_CAST]][%[[ZERO_0]], %[[ADD]]] + // CHECK: %[[ZERO_I8:.+]] = spirv.Constant 0 : i8 + // CHECK: %[[ONE_I8:.+]] = spirv.Constant 1 : i8 + // CHECK: %[[RES:.+]] = spirv.Select %{{.+}}, %[[ONE_I8]], %[[ZERO_I8]] : i1, i8 + // CHECK: spirv.Store "StorageBuffer" %[[ADDR]], %[[RES]] : i8 + memref.store %true, %dst[%i]: memref<4xi1, #spirv.storage_class> return } @@ -113,100 +113,100 @@ // perform special tricks. module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + Kernel, Addresses, Int8, Int16, Int64, Float16, Float64], []>, #spirv.resource_limits<>> } { // CHECK-LABEL: @load_store_zero_rank_float -func.func @load_store_zero_rank_float(%arg0: memref>, %arg1: memref>) { - // CHECK: [[ARG0:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spv.ptr - // CHECK: [[ARG1:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spv.ptr - // CHECK: [[ZERO1:%.*]] = spv.Constant 0 : i32 - // CHECK: spv.PtrAccessChain [[ARG0]][ +func.func @load_store_zero_rank_float(%arg0: memref>, %arg1: memref>) { + // CHECK: [[ARG0:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spirv.ptr + // CHECK: [[ARG1:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spirv.ptr + // CHECK: [[ZERO1:%.*]] = spirv.Constant 0 : i32 + // CHECK: spirv.PtrAccessChain [[ARG0]][ // CHECK-SAME: [[ZERO1]] // CHECK-SAME: ] : - // CHECK: spv.Load "CrossWorkgroup" %{{.*}} : f32 - %0 = memref.load %arg0[] : memref> - // CHECK: [[ZERO2:%.*]] = spv.Constant 0 : i32 - // CHECK: spv.PtrAccessChain [[ARG1]][ + // CHECK: spirv.Load "CrossWorkgroup" %{{.*}} : f32 + %0 = memref.load %arg0[] : memref> + // CHECK: [[ZERO2:%.*]] = spirv.Constant 0 : i32 + // CHECK: spirv.PtrAccessChain [[ARG1]][ // CHECK-SAME: [[ZERO2]] // CHECK-SAME: ] : - // CHECK: spv.Store "CrossWorkgroup" %{{.*}} : f32 - memref.store %0, %arg1[] : memref> + // CHECK: spirv.Store "CrossWorkgroup" %{{.*}} : f32 + memref.store %0, %arg1[] : memref> return } // CHECK-LABEL: @load_store_zero_rank_int -func.func @load_store_zero_rank_int(%arg0: memref>, %arg1: memref>) { - // CHECK: [[ARG0:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spv.ptr - // CHECK: [[ARG1:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spv.ptr - // CHECK: [[ZERO1:%.*]] = spv.Constant 0 : i32 - // CHECK: spv.PtrAccessChain [[ARG0]][ +func.func @load_store_zero_rank_int(%arg0: memref>, %arg1: memref>) { + // CHECK: [[ARG0:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spirv.ptr + // CHECK: [[ARG1:%.*]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spirv.ptr + // CHECK: [[ZERO1:%.*]] = spirv.Constant 0 : i32 + // CHECK: spirv.PtrAccessChain [[ARG0]][ // CHECK-SAME: [[ZERO1]] // CHECK-SAME: ] : - // CHECK: spv.Load "CrossWorkgroup" %{{.*}} : i32 - %0 = memref.load %arg0[] : memref> - // CHECK: [[ZERO2:%.*]] = spv.Constant 0 : i32 - // CHECK: spv.PtrAccessChain [[ARG1]][ + // CHECK: spirv.Load "CrossWorkgroup" %{{.*}} : i32 + %0 = memref.load %arg0[] : memref> + // CHECK: [[ZERO2:%.*]] = spirv.Constant 0 : i32 + // CHECK: spirv.PtrAccessChain [[ARG1]][ // CHECK-SAME: [[ZERO2]] // CHECK-SAME: ] : - // CHECK: spv.Store "CrossWorkgroup" %{{.*}} : i32 - memref.store %0, %arg1[] : memref> + // CHECK: spirv.Store "CrossWorkgroup" %{{.*}} : i32 + memref.store %0, %arg1[] : memref> return } // CHECK-LABEL: func @load_store_unknown_dim -func.func @load_store_unknown_dim(%i: index, %source: memref>, %dest: memref>) { - // CHECK: %[[SRC:.+]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spv.ptr - // CHECK: %[[DST:.+]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spv.ptr - // CHECK: %[[AC0:.+]] = spv.PtrAccessChain %[[SRC]] - // CHECK: spv.Load "CrossWorkgroup" %[[AC0]] - %0 = memref.load %source[%i] : memref> - // CHECK: %[[AC1:.+]] = spv.PtrAccessChain %[[DST]] - // CHECK: spv.Store "CrossWorkgroup" %[[AC1]] - memref.store %0, %dest[%i]: memref> +func.func @load_store_unknown_dim(%i: index, %source: memref>, %dest: memref>) { + // CHECK: %[[SRC:.+]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spirv.ptr + // CHECK: %[[DST:.+]] = builtin.unrealized_conversion_cast {{.+}} : memref> to !spirv.ptr + // CHECK: %[[AC0:.+]] = spirv.PtrAccessChain %[[SRC]] + // CHECK: spirv.Load "CrossWorkgroup" %[[AC0]] + %0 = memref.load %source[%i] : memref> + // CHECK: %[[AC1:.+]] = spirv.PtrAccessChain %[[DST]] + // CHECK: spirv.Store "CrossWorkgroup" %[[AC1]] + memref.store %0, %dest[%i]: memref> return } // CHECK-LABEL: func @load_i1 -// CHECK-SAME: (%[[SRC:.+]]: memref<4xi1, #spv.storage_class>, %[[IDX:.+]]: index) -func.func @load_i1(%src: memref<4xi1, #spv.storage_class>, %i : index) -> i1 { - // CHECK-DAG: %[[SRC_CAST:.+]] = builtin.unrealized_conversion_cast %[[SRC]] : memref<4xi1, #spv.storage_class> to !spv.ptr +// CHECK-SAME: (%[[SRC:.+]]: memref<4xi1, #spirv.storage_class>, %[[IDX:.+]]: index) +func.func @load_i1(%src: memref<4xi1, #spirv.storage_class>, %i : index) -> i1 { + // CHECK-DAG: %[[SRC_CAST:.+]] = builtin.unrealized_conversion_cast %[[SRC]] : memref<4xi1, #spirv.storage_class> to !spirv.ptr // CHECK-DAG: %[[IDX_CAST:.+]] = builtin.unrealized_conversion_cast %[[IDX]] - // CHECK: %[[ZERO_0:.+]] = spv.Constant 0 : i32 - // CHECK: %[[ZERO_1:.+]] = spv.Constant 0 : i32 - // CHECK: %[[ONE:.+]] = spv.Constant 1 : i32 - // CHECK: %[[MUL:.+]] = spv.IMul %[[ONE]], %[[IDX_CAST]] : i32 - // CHECK: %[[ADD:.+]] = spv.IAdd %[[ZERO_1]], %[[MUL]] : i32 - // CHECK: %[[ADDR:.+]] = spv.PtrAccessChain %[[SRC_CAST]][%[[ADD]]] - // CHECK: %[[VAL:.+]] = spv.Load "CrossWorkgroup" %[[ADDR]] : i8 - // CHECK: %[[ONE_I8:.+]] = spv.Constant 1 : i8 - // CHECK: %[[BOOL:.+]] = spv.IEqual %[[VAL]], %[[ONE_I8]] : i8 - %0 = memref.load %src[%i] : memref<4xi1, #spv.storage_class> + // CHECK: %[[ZERO_0:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[ZERO_1:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32 + // CHECK: %[[MUL:.+]] = spirv.IMul %[[ONE]], %[[IDX_CAST]] : i32 + // CHECK: %[[ADD:.+]] = spirv.IAdd %[[ZERO_1]], %[[MUL]] : i32 + // CHECK: %[[ADDR:.+]] = spirv.PtrAccessChain %[[SRC_CAST]][%[[ADD]]] + // CHECK: %[[VAL:.+]] = spirv.Load "CrossWorkgroup" %[[ADDR]] : i8 + // CHECK: %[[ONE_I8:.+]] = spirv.Constant 1 : i8 + // CHECK: %[[BOOL:.+]] = spirv.IEqual %[[VAL]], %[[ONE_I8]] : i8 + %0 = memref.load %src[%i] : memref<4xi1, #spirv.storage_class> // CHECK: return %[[BOOL]] return %0: i1 } // CHECK-LABEL: func @store_i1 -// CHECK-SAME: %[[DST:.+]]: memref<4xi1, #spv.storage_class>, +// CHECK-SAME: %[[DST:.+]]: memref<4xi1, #spirv.storage_class>, // CHECK-SAME: %[[IDX:.+]]: index -func.func @store_i1(%dst: memref<4xi1, #spv.storage_class>, %i: index) { +func.func @store_i1(%dst: memref<4xi1, #spirv.storage_class>, %i: index) { %true = arith.constant true - // CHECK-DAG: %[[DST_CAST:.+]] = builtin.unrealized_conversion_cast %[[DST]] : memref<4xi1, #spv.storage_class> to !spv.ptr + // CHECK-DAG: %[[DST_CAST:.+]] = builtin.unrealized_conversion_cast %[[DST]] : memref<4xi1, #spirv.storage_class> to !spirv.ptr // CHECK-DAG: %[[IDX_CAST:.+]] = builtin.unrealized_conversion_cast %[[IDX]] - // CHECK: %[[ZERO_0:.+]] = spv.Constant 0 : i32 - // CHECK: %[[ZERO_1:.+]] = spv.Constant 0 : i32 - // CHECK: %[[ONE:.+]] = spv.Constant 1 : i32 - // CHECK: %[[MUL:.+]] = spv.IMul %[[ONE]], %[[IDX_CAST]] : i32 - // CHECK: %[[ADD:.+]] = spv.IAdd %[[ZERO_1]], %[[MUL]] : i32 - // CHECK: %[[ADDR:.+]] = spv.PtrAccessChain %[[DST_CAST]][%[[ADD]]] - // CHECK: %[[ZERO_I8:.+]] = spv.Constant 0 : i8 - // CHECK: %[[ONE_I8:.+]] = spv.Constant 1 : i8 - // CHECK: %[[RES:.+]] = spv.Select %{{.+}}, %[[ONE_I8]], %[[ZERO_I8]] : i1, i8 - // CHECK: spv.Store "CrossWorkgroup" %[[ADDR]], %[[RES]] : i8 - memref.store %true, %dst[%i]: memref<4xi1, #spv.storage_class> + // CHECK: %[[ZERO_0:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[ZERO_1:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32 + // CHECK: %[[MUL:.+]] = spirv.IMul %[[ONE]], %[[IDX_CAST]] : i32 + // CHECK: %[[ADD:.+]] = spirv.IAdd %[[ZERO_1]], %[[MUL]] : i32 + // CHECK: %[[ADDR:.+]] = spirv.PtrAccessChain %[[DST_CAST]][%[[ADD]]] + // CHECK: %[[ZERO_I8:.+]] = spirv.Constant 0 : i8 + // CHECK: %[[ONE_I8:.+]] = spirv.Constant 1 : i8 + // CHECK: %[[RES:.+]] = spirv.Select %{{.+}}, %[[ONE_I8]], %[[ZERO_I8]] : i1, i8 + // CHECK: spirv.Store "CrossWorkgroup" %[[ADDR]], %[[RES]] : i8 + memref.store %true, %dst[%i]: memref<4xi1, #spirv.storage_class> return } @@ -218,195 +218,195 @@ // emulated via 32-bit types. // TODO: Test i64 types. module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @load_i1 -func.func @load_i1(%arg0: memref>) -> i1 { - // CHECK: %[[ZERO:.+]] = spv.Constant 0 : i32 - // CHECK: %[[FOUR1:.+]] = spv.Constant 4 : i32 - // CHECK: %[[QUOTIENT:.+]] = spv.SDiv %[[ZERO]], %[[FOUR1]] : i32 - // CHECK: %[[PTR:.+]] = spv.AccessChain %{{.+}}[%[[ZERO]], %[[QUOTIENT]]] - // CHECK: %[[LOAD:.+]] = spv.Load "StorageBuffer" %[[PTR]] - // CHECK: %[[FOUR2:.+]] = spv.Constant 4 : i32 - // CHECK: %[[EIGHT:.+]] = spv.Constant 8 : i32 - // CHECK: %[[IDX:.+]] = spv.UMod %[[ZERO]], %[[FOUR2]] : i32 - // CHECK: %[[BITS:.+]] = spv.IMul %[[IDX]], %[[EIGHT]] : i32 - // CHECK: %[[VALUE:.+]] = spv.ShiftRightArithmetic %[[LOAD]], %[[BITS]] : i32, i32 - // CHECK: %[[MASK:.+]] = spv.Constant 255 : i32 - // CHECK: %[[T1:.+]] = spv.BitwiseAnd %[[VALUE]], %[[MASK]] : i32 - // CHECK: %[[T2:.+]] = spv.Constant 24 : i32 - // CHECK: %[[T3:.+]] = spv.ShiftLeftLogical %[[T1]], %[[T2]] : i32, i32 - // CHECK: %[[T4:.+]] = spv.ShiftRightArithmetic %[[T3]], %[[T2]] : i32, i32 +func.func @load_i1(%arg0: memref>) -> i1 { + // CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[FOUR1:.+]] = spirv.Constant 4 : i32 + // CHECK: %[[QUOTIENT:.+]] = spirv.SDiv %[[ZERO]], %[[FOUR1]] : i32 + // CHECK: %[[PTR:.+]] = spirv.AccessChain %{{.+}}[%[[ZERO]], %[[QUOTIENT]]] + // CHECK: %[[LOAD:.+]] = spirv.Load "StorageBuffer" %[[PTR]] + // CHECK: %[[FOUR2:.+]] = spirv.Constant 4 : i32 + // CHECK: %[[EIGHT:.+]] = spirv.Constant 8 : i32 + // CHECK: %[[IDX:.+]] = spirv.UMod %[[ZERO]], %[[FOUR2]] : i32 + // CHECK: %[[BITS:.+]] = spirv.IMul %[[IDX]], %[[EIGHT]] : i32 + // CHECK: %[[VALUE:.+]] = spirv.ShiftRightArithmetic %[[LOAD]], %[[BITS]] : i32, i32 + // CHECK: %[[MASK:.+]] = spirv.Constant 255 : i32 + // CHECK: %[[T1:.+]] = spirv.BitwiseAnd %[[VALUE]], %[[MASK]] : i32 + // CHECK: %[[T2:.+]] = spirv.Constant 24 : i32 + // CHECK: %[[T3:.+]] = spirv.ShiftLeftLogical %[[T1]], %[[T2]] : i32, i32 + // CHECK: %[[T4:.+]] = spirv.ShiftRightArithmetic %[[T3]], %[[T2]] : i32, i32 // Convert to i1 type. - // CHECK: %[[ONE:.+]] = spv.Constant 1 : i32 - // CHECK: %[[RES:.+]] = spv.IEqual %[[T4]], %[[ONE]] : i32 + // CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32 + // CHECK: %[[RES:.+]] = spirv.IEqual %[[T4]], %[[ONE]] : i32 // CHECK: return %[[RES]] - %0 = memref.load %arg0[] : memref> + %0 = memref.load %arg0[] : memref> return %0 : i1 } // CHECK-LABEL: @load_i8 -func.func @load_i8(%arg0: memref>) { - // CHECK: %[[ZERO:.+]] = spv.Constant 0 : i32 - // CHECK: %[[FOUR1:.+]] = spv.Constant 4 : i32 - // CHECK: %[[QUOTIENT:.+]] = spv.SDiv %[[ZERO]], %[[FOUR1]] : i32 - // CHECK: %[[PTR:.+]] = spv.AccessChain %{{.+}}[%[[ZERO]], %[[QUOTIENT]]] - // CHECK: %[[LOAD:.+]] = spv.Load "StorageBuffer" %[[PTR]] - // CHECK: %[[FOUR2:.+]] = spv.Constant 4 : i32 - // CHECK: %[[EIGHT:.+]] = spv.Constant 8 : i32 - // CHECK: %[[IDX:.+]] = spv.UMod %[[ZERO]], %[[FOUR2]] : i32 - // CHECK: %[[BITS:.+]] = spv.IMul %[[IDX]], %[[EIGHT]] : i32 - // CHECK: %[[VALUE:.+]] = spv.ShiftRightArithmetic %[[LOAD]], %[[BITS]] : i32, i32 - // CHECK: %[[MASK:.+]] = spv.Constant 255 : i32 - // CHECK: %[[T1:.+]] = spv.BitwiseAnd %[[VALUE]], %[[MASK]] : i32 - // CHECK: %[[T2:.+]] = spv.Constant 24 : i32 - // CHECK: %[[T3:.+]] = spv.ShiftLeftLogical %[[T1]], %[[T2]] : i32, i32 - // CHECK: spv.ShiftRightArithmetic %[[T3]], %[[T2]] : i32, i32 - %0 = memref.load %arg0[] : memref> +func.func @load_i8(%arg0: memref>) { + // CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[FOUR1:.+]] = spirv.Constant 4 : i32 + // CHECK: %[[QUOTIENT:.+]] = spirv.SDiv %[[ZERO]], %[[FOUR1]] : i32 + // CHECK: %[[PTR:.+]] = spirv.AccessChain %{{.+}}[%[[ZERO]], %[[QUOTIENT]]] + // CHECK: %[[LOAD:.+]] = spirv.Load "StorageBuffer" %[[PTR]] + // CHECK: %[[FOUR2:.+]] = spirv.Constant 4 : i32 + // CHECK: %[[EIGHT:.+]] = spirv.Constant 8 : i32 + // CHECK: %[[IDX:.+]] = spirv.UMod %[[ZERO]], %[[FOUR2]] : i32 + // CHECK: %[[BITS:.+]] = spirv.IMul %[[IDX]], %[[EIGHT]] : i32 + // CHECK: %[[VALUE:.+]] = spirv.ShiftRightArithmetic %[[LOAD]], %[[BITS]] : i32, i32 + // CHECK: %[[MASK:.+]] = spirv.Constant 255 : i32 + // CHECK: %[[T1:.+]] = spirv.BitwiseAnd %[[VALUE]], %[[MASK]] : i32 + // CHECK: %[[T2:.+]] = spirv.Constant 24 : i32 + // CHECK: %[[T3:.+]] = spirv.ShiftLeftLogical %[[T1]], %[[T2]] : i32, i32 + // CHECK: spirv.ShiftRightArithmetic %[[T3]], %[[T2]] : i32, i32 + %0 = memref.load %arg0[] : memref> return } // CHECK-LABEL: @load_i16 // CHECK: (%[[ARG0:.+]]: {{.*}}, %[[ARG1:.+]]: index) -func.func @load_i16(%arg0: memref<10xi16, #spv.storage_class>, %index : index) { +func.func @load_i16(%arg0: memref<10xi16, #spirv.storage_class>, %index : index) { // CHECK: %[[ARG1_CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG1]] : index to i32 - // CHECK: %[[ZERO:.+]] = spv.Constant 0 : i32 - // CHECK: %[[OFFSET:.+]] = spv.Constant 0 : i32 - // CHECK: %[[ONE:.+]] = spv.Constant 1 : i32 - // CHECK: %[[UPDATE:.+]] = spv.IMul %[[ONE]], %[[ARG1_CAST]] : i32 - // CHECK: %[[FLAT_IDX:.+]] = spv.IAdd %[[OFFSET]], %[[UPDATE]] : i32 - // CHECK: %[[TWO1:.+]] = spv.Constant 2 : i32 - // CHECK: %[[QUOTIENT:.+]] = spv.SDiv %[[FLAT_IDX]], %[[TWO1]] : i32 - // CHECK: %[[PTR:.+]] = spv.AccessChain %{{.+}}[%[[ZERO]], %[[QUOTIENT]]] - // CHECK: %[[LOAD:.+]] = spv.Load "StorageBuffer" %[[PTR]] - // CHECK: %[[TWO2:.+]] = spv.Constant 2 : i32 - // CHECK: %[[SIXTEEN:.+]] = spv.Constant 16 : i32 - // CHECK: %[[IDX:.+]] = spv.UMod %[[FLAT_IDX]], %[[TWO2]] : i32 - // CHECK: %[[BITS:.+]] = spv.IMul %[[IDX]], %[[SIXTEEN]] : i32 - // CHECK: %[[VALUE:.+]] = spv.ShiftRightArithmetic %[[LOAD]], %[[BITS]] : i32, i32 - // CHECK: %[[MASK:.+]] = spv.Constant 65535 : i32 - // CHECK: %[[T1:.+]] = spv.BitwiseAnd %[[VALUE]], %[[MASK]] : i32 - // CHECK: %[[T2:.+]] = spv.Constant 16 : i32 - // CHECK: %[[T3:.+]] = spv.ShiftLeftLogical %[[T1]], %[[T2]] : i32, i32 - // CHECK: spv.ShiftRightArithmetic %[[T3]], %[[T2]] : i32, i32 - %0 = memref.load %arg0[%index] : memref<10xi16, #spv.storage_class> + // CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[OFFSET:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32 + // CHECK: %[[UPDATE:.+]] = spirv.IMul %[[ONE]], %[[ARG1_CAST]] : i32 + // CHECK: %[[FLAT_IDX:.+]] = spirv.IAdd %[[OFFSET]], %[[UPDATE]] : i32 + // CHECK: %[[TWO1:.+]] = spirv.Constant 2 : i32 + // CHECK: %[[QUOTIENT:.+]] = spirv.SDiv %[[FLAT_IDX]], %[[TWO1]] : i32 + // CHECK: %[[PTR:.+]] = spirv.AccessChain %{{.+}}[%[[ZERO]], %[[QUOTIENT]]] + // CHECK: %[[LOAD:.+]] = spirv.Load "StorageBuffer" %[[PTR]] + // CHECK: %[[TWO2:.+]] = spirv.Constant 2 : i32 + // CHECK: %[[SIXTEEN:.+]] = spirv.Constant 16 : i32 + // CHECK: %[[IDX:.+]] = spirv.UMod %[[FLAT_IDX]], %[[TWO2]] : i32 + // CHECK: %[[BITS:.+]] = spirv.IMul %[[IDX]], %[[SIXTEEN]] : i32 + // CHECK: %[[VALUE:.+]] = spirv.ShiftRightArithmetic %[[LOAD]], %[[BITS]] : i32, i32 + // CHECK: %[[MASK:.+]] = spirv.Constant 65535 : i32 + // CHECK: %[[T1:.+]] = spirv.BitwiseAnd %[[VALUE]], %[[MASK]] : i32 + // CHECK: %[[T2:.+]] = spirv.Constant 16 : i32 + // CHECK: %[[T3:.+]] = spirv.ShiftLeftLogical %[[T1]], %[[T2]] : i32, i32 + // CHECK: spirv.ShiftRightArithmetic %[[T3]], %[[T2]] : i32, i32 + %0 = memref.load %arg0[%index] : memref<10xi16, #spirv.storage_class> return } // CHECK-LABEL: @load_i32 -func.func @load_i32(%arg0: memref>) { - // CHECK-NOT: spv.SDiv - // CHECK: spv.Load - // CHECK-NOT: spv.ShiftRightArithmetic - %0 = memref.load %arg0[] : memref> +func.func @load_i32(%arg0: memref>) { + // CHECK-NOT: spirv.SDiv + // CHECK: spirv.Load + // CHECK-NOT: spirv.ShiftRightArithmetic + %0 = memref.load %arg0[] : memref> return } // CHECK-LABEL: @load_f32 -func.func @load_f32(%arg0: memref>) { - // CHECK-NOT: spv.SDiv - // CHECK: spv.Load - // CHECK-NOT: spv.ShiftRightArithmetic - %0 = memref.load %arg0[] : memref> +func.func @load_f32(%arg0: memref>) { + // CHECK-NOT: spirv.SDiv + // CHECK: spirv.Load + // CHECK-NOT: spirv.ShiftRightArithmetic + %0 = memref.load %arg0[] : memref> return } // CHECK-LABEL: @store_i1 // CHECK: (%[[ARG0:.+]]: {{.*}}, %[[ARG1:.+]]: i1) -func.func @store_i1(%arg0: memref>, %value: i1) { +func.func @store_i1(%arg0: memref>, %value: i1) { // CHECK: %[[ARG0_CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG0]] - // CHECK: %[[ZERO:.+]] = spv.Constant 0 : i32 - // CHECK: %[[FOUR:.+]] = spv.Constant 4 : i32 - // CHECK: %[[EIGHT:.+]] = spv.Constant 8 : i32 - // CHECK: %[[IDX:.+]] = spv.UMod %[[ZERO]], %[[FOUR]] : i32 - // CHECK: %[[OFFSET:.+]] = spv.IMul %[[IDX]], %[[EIGHT]] : i32 - // CHECK: %[[MASK1:.+]] = spv.Constant 255 : i32 - // CHECK: %[[TMP1:.+]] = spv.ShiftLeftLogical %[[MASK1]], %[[OFFSET]] : i32, i32 - // CHECK: %[[MASK:.+]] = spv.Not %[[TMP1]] : i32 - // CHECK: %[[ZERO1:.+]] = spv.Constant 0 : i32 - // CHECK: %[[ONE1:.+]] = spv.Constant 1 : i32 - // CHECK: %[[CASTED_ARG1:.+]] = spv.Select %[[ARG1]], %[[ONE1]], %[[ZERO1]] : i1, i32 - // CHECK: %[[CLAMPED_VAL:.+]] = spv.BitwiseAnd %[[CASTED_ARG1]], %[[MASK1]] : i32 - // CHECK: %[[STORE_VAL:.+]] = spv.ShiftLeftLogical %[[CLAMPED_VAL]], %[[OFFSET]] : i32, i32 - // CHECK: %[[FOUR2:.+]] = spv.Constant 4 : i32 - // CHECK: %[[ACCESS_IDX:.+]] = spv.SDiv %[[ZERO]], %[[FOUR2]] : i32 - // CHECK: %[[PTR:.+]] = spv.AccessChain %[[ARG0_CAST]][%[[ZERO]], %[[ACCESS_IDX]]] - // CHECK: spv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]] - // CHECK: spv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]] - memref.store %value, %arg0[] : memref> + // CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[FOUR:.+]] = spirv.Constant 4 : i32 + // CHECK: %[[EIGHT:.+]] = spirv.Constant 8 : i32 + // CHECK: %[[IDX:.+]] = spirv.UMod %[[ZERO]], %[[FOUR]] : i32 + // CHECK: %[[OFFSET:.+]] = spirv.IMul %[[IDX]], %[[EIGHT]] : i32 + // CHECK: %[[MASK1:.+]] = spirv.Constant 255 : i32 + // CHECK: %[[TMP1:.+]] = spirv.ShiftLeftLogical %[[MASK1]], %[[OFFSET]] : i32, i32 + // CHECK: %[[MASK:.+]] = spirv.Not %[[TMP1]] : i32 + // CHECK: %[[ZERO1:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[ONE1:.+]] = spirv.Constant 1 : i32 + // CHECK: %[[CASTED_ARG1:.+]] = spirv.Select %[[ARG1]], %[[ONE1]], %[[ZERO1]] : i1, i32 + // CHECK: %[[CLAMPED_VAL:.+]] = spirv.BitwiseAnd %[[CASTED_ARG1]], %[[MASK1]] : i32 + // CHECK: %[[STORE_VAL:.+]] = spirv.ShiftLeftLogical %[[CLAMPED_VAL]], %[[OFFSET]] : i32, i32 + // CHECK: %[[FOUR2:.+]] = spirv.Constant 4 : i32 + // CHECK: %[[ACCESS_IDX:.+]] = spirv.SDiv %[[ZERO]], %[[FOUR2]] : i32 + // CHECK: %[[PTR:.+]] = spirv.AccessChain %[[ARG0_CAST]][%[[ZERO]], %[[ACCESS_IDX]]] + // CHECK: spirv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]] + // CHECK: spirv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]] + memref.store %value, %arg0[] : memref> return } // CHECK-LABEL: @store_i8 // CHECK: (%[[ARG0:.+]]: {{.*}}, %[[ARG1:.+]]: i8) -func.func @store_i8(%arg0: memref>, %value: i8) { +func.func @store_i8(%arg0: memref>, %value: i8) { // CHECK-DAG: %[[ARG1_CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG1]] : i8 to i32 // CHECK-DAG: %[[ARG0_CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG0]] - // CHECK: %[[ZERO:.+]] = spv.Constant 0 : i32 - // CHECK: %[[FOUR:.+]] = spv.Constant 4 : i32 - // CHECK: %[[EIGHT:.+]] = spv.Constant 8 : i32 - // CHECK: %[[IDX:.+]] = spv.UMod %[[ZERO]], %[[FOUR]] : i32 - // CHECK: %[[OFFSET:.+]] = spv.IMul %[[IDX]], %[[EIGHT]] : i32 - // CHECK: %[[MASK1:.+]] = spv.Constant 255 : i32 - // CHECK: %[[TMP1:.+]] = spv.ShiftLeftLogical %[[MASK1]], %[[OFFSET]] : i32, i32 - // CHECK: %[[MASK:.+]] = spv.Not %[[TMP1]] : i32 - // CHECK: %[[CLAMPED_VAL:.+]] = spv.BitwiseAnd %[[ARG1_CAST]], %[[MASK1]] : i32 - // CHECK: %[[STORE_VAL:.+]] = spv.ShiftLeftLogical %[[CLAMPED_VAL]], %[[OFFSET]] : i32, i32 - // CHECK: %[[FOUR2:.+]] = spv.Constant 4 : i32 - // CHECK: %[[ACCESS_IDX:.+]] = spv.SDiv %[[ZERO]], %[[FOUR2]] : i32 - // CHECK: %[[PTR:.+]] = spv.AccessChain %[[ARG0_CAST]][%[[ZERO]], %[[ACCESS_IDX]]] - // CHECK: spv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]] - // CHECK: spv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]] - memref.store %value, %arg0[] : memref> + // CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[FOUR:.+]] = spirv.Constant 4 : i32 + // CHECK: %[[EIGHT:.+]] = spirv.Constant 8 : i32 + // CHECK: %[[IDX:.+]] = spirv.UMod %[[ZERO]], %[[FOUR]] : i32 + // CHECK: %[[OFFSET:.+]] = spirv.IMul %[[IDX]], %[[EIGHT]] : i32 + // CHECK: %[[MASK1:.+]] = spirv.Constant 255 : i32 + // CHECK: %[[TMP1:.+]] = spirv.ShiftLeftLogical %[[MASK1]], %[[OFFSET]] : i32, i32 + // CHECK: %[[MASK:.+]] = spirv.Not %[[TMP1]] : i32 + // CHECK: %[[CLAMPED_VAL:.+]] = spirv.BitwiseAnd %[[ARG1_CAST]], %[[MASK1]] : i32 + // CHECK: %[[STORE_VAL:.+]] = spirv.ShiftLeftLogical %[[CLAMPED_VAL]], %[[OFFSET]] : i32, i32 + // CHECK: %[[FOUR2:.+]] = spirv.Constant 4 : i32 + // CHECK: %[[ACCESS_IDX:.+]] = spirv.SDiv %[[ZERO]], %[[FOUR2]] : i32 + // CHECK: %[[PTR:.+]] = spirv.AccessChain %[[ARG0_CAST]][%[[ZERO]], %[[ACCESS_IDX]]] + // CHECK: spirv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]] + // CHECK: spirv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]] + memref.store %value, %arg0[] : memref> return } // CHECK-LABEL: @store_i16 -// CHECK: (%[[ARG0:.+]]: memref<10xi16, #spv.storage_class>, %[[ARG1:.+]]: index, %[[ARG2:.+]]: i16) -func.func @store_i16(%arg0: memref<10xi16, #spv.storage_class>, %index: index, %value: i16) { +// CHECK: (%[[ARG0:.+]]: memref<10xi16, #spirv.storage_class>, %[[ARG1:.+]]: index, %[[ARG2:.+]]: i16) +func.func @store_i16(%arg0: memref<10xi16, #spirv.storage_class>, %index: index, %value: i16) { // CHECK-DAG: %[[ARG2_CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG2]] : i16 to i32 // CHECK-DAG: %[[ARG0_CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG0]] // CHECK-DAG: %[[ARG1_CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG1]] : index to i32 - // CHECK: %[[ZERO:.+]] = spv.Constant 0 : i32 - // CHECK: %[[OFFSET:.+]] = spv.Constant 0 : i32 - // CHECK: %[[ONE:.+]] = spv.Constant 1 : i32 - // CHECK: %[[UPDATE:.+]] = spv.IMul %[[ONE]], %[[ARG1_CAST]] : i32 - // CHECK: %[[FLAT_IDX:.+]] = spv.IAdd %[[OFFSET]], %[[UPDATE]] : i32 - // CHECK: %[[TWO:.+]] = spv.Constant 2 : i32 - // CHECK: %[[SIXTEEN:.+]] = spv.Constant 16 : i32 - // CHECK: %[[IDX:.+]] = spv.UMod %[[FLAT_IDX]], %[[TWO]] : i32 - // CHECK: %[[OFFSET:.+]] = spv.IMul %[[IDX]], %[[SIXTEEN]] : i32 - // CHECK: %[[MASK1:.+]] = spv.Constant 65535 : i32 - // CHECK: %[[TMP1:.+]] = spv.ShiftLeftLogical %[[MASK1]], %[[OFFSET]] : i32, i32 - // CHECK: %[[MASK:.+]] = spv.Not %[[TMP1]] : i32 - // CHECK: %[[CLAMPED_VAL:.+]] = spv.BitwiseAnd %[[ARG2_CAST]], %[[MASK1]] : i32 - // CHECK: %[[STORE_VAL:.+]] = spv.ShiftLeftLogical %[[CLAMPED_VAL]], %[[OFFSET]] : i32, i32 - // CHECK: %[[TWO2:.+]] = spv.Constant 2 : i32 - // CHECK: %[[ACCESS_IDX:.+]] = spv.SDiv %[[FLAT_IDX]], %[[TWO2]] : i32 - // CHECK: %[[PTR:.+]] = spv.AccessChain %[[ARG0_CAST]][%[[ZERO]], %[[ACCESS_IDX]]] - // CHECK: spv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]] - // CHECK: spv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]] - memref.store %value, %arg0[%index] : memref<10xi16, #spv.storage_class> + // CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[OFFSET:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32 + // CHECK: %[[UPDATE:.+]] = spirv.IMul %[[ONE]], %[[ARG1_CAST]] : i32 + // CHECK: %[[FLAT_IDX:.+]] = spirv.IAdd %[[OFFSET]], %[[UPDATE]] : i32 + // CHECK: %[[TWO:.+]] = spirv.Constant 2 : i32 + // CHECK: %[[SIXTEEN:.+]] = spirv.Constant 16 : i32 + // CHECK: %[[IDX:.+]] = spirv.UMod %[[FLAT_IDX]], %[[TWO]] : i32 + // CHECK: %[[OFFSET:.+]] = spirv.IMul %[[IDX]], %[[SIXTEEN]] : i32 + // CHECK: %[[MASK1:.+]] = spirv.Constant 65535 : i32 + // CHECK: %[[TMP1:.+]] = spirv.ShiftLeftLogical %[[MASK1]], %[[OFFSET]] : i32, i32 + // CHECK: %[[MASK:.+]] = spirv.Not %[[TMP1]] : i32 + // CHECK: %[[CLAMPED_VAL:.+]] = spirv.BitwiseAnd %[[ARG2_CAST]], %[[MASK1]] : i32 + // CHECK: %[[STORE_VAL:.+]] = spirv.ShiftLeftLogical %[[CLAMPED_VAL]], %[[OFFSET]] : i32, i32 + // CHECK: %[[TWO2:.+]] = spirv.Constant 2 : i32 + // CHECK: %[[ACCESS_IDX:.+]] = spirv.SDiv %[[FLAT_IDX]], %[[TWO2]] : i32 + // CHECK: %[[PTR:.+]] = spirv.AccessChain %[[ARG0_CAST]][%[[ZERO]], %[[ACCESS_IDX]]] + // CHECK: spirv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]] + // CHECK: spirv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]] + memref.store %value, %arg0[%index] : memref<10xi16, #spirv.storage_class> return } // CHECK-LABEL: @store_i32 -func.func @store_i32(%arg0: memref>, %value: i32) { - // CHECK: spv.Store - // CHECK-NOT: spv.AtomicAnd - // CHECK-NOT: spv.AtomicOr - memref.store %value, %arg0[] : memref> +func.func @store_i32(%arg0: memref>, %value: i32) { + // CHECK: spirv.Store + // CHECK-NOT: spirv.AtomicAnd + // CHECK-NOT: spirv.AtomicOr + memref.store %value, %arg0[] : memref> return } // CHECK-LABEL: @store_f32 -func.func @store_f32(%arg0: memref>, %value: f32) { - // CHECK: spv.Store - // CHECK-NOT: spv.AtomicAnd - // CHECK-NOT: spv.AtomicOr - memref.store %value, %arg0[] : memref> +func.func @store_f32(%arg0: memref>, %value: f32) { + // CHECK: spirv.Store + // CHECK-NOT: spirv.AtomicAnd + // CHECK-NOT: spirv.AtomicOr + memref.store %value, %arg0[] : memref> return } @@ -417,71 +417,71 @@ // Check that access chain indices are properly adjusted if non-16/32-bit types // are emulated via 32-bit types. module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @load_i8 -func.func @load_i8(%arg0: memref>) { - // CHECK: %[[ZERO:.+]] = spv.Constant 0 : i32 - // CHECK: %[[FOUR1:.+]] = spv.Constant 4 : i32 - // CHECK: %[[QUOTIENT:.+]] = spv.SDiv %[[ZERO]], %[[FOUR1]] : i32 - // CHECK: %[[PTR:.+]] = spv.AccessChain %{{.+}}[%[[ZERO]], %[[QUOTIENT]]] - // CHECK: %[[LOAD:.+]] = spv.Load "StorageBuffer" %[[PTR]] - // CHECK: %[[FOUR2:.+]] = spv.Constant 4 : i32 - // CHECK: %[[EIGHT:.+]] = spv.Constant 8 : i32 - // CHECK: %[[IDX:.+]] = spv.UMod %[[ZERO]], %[[FOUR2]] : i32 - // CHECK: %[[BITS:.+]] = spv.IMul %[[IDX]], %[[EIGHT]] : i32 - // CHECK: %[[VALUE:.+]] = spv.ShiftRightArithmetic %[[LOAD]], %[[BITS]] : i32, i32 - // CHECK: %[[MASK:.+]] = spv.Constant 255 : i32 - // CHECK: %[[T1:.+]] = spv.BitwiseAnd %[[VALUE]], %[[MASK]] : i32 - // CHECK: %[[T2:.+]] = spv.Constant 24 : i32 - // CHECK: %[[T3:.+]] = spv.ShiftLeftLogical %[[T1]], %[[T2]] : i32, i32 - // CHECK: spv.ShiftRightArithmetic %[[T3]], %[[T2]] : i32, i32 - %0 = memref.load %arg0[] : memref> +func.func @load_i8(%arg0: memref>) { + // CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[FOUR1:.+]] = spirv.Constant 4 : i32 + // CHECK: %[[QUOTIENT:.+]] = spirv.SDiv %[[ZERO]], %[[FOUR1]] : i32 + // CHECK: %[[PTR:.+]] = spirv.AccessChain %{{.+}}[%[[ZERO]], %[[QUOTIENT]]] + // CHECK: %[[LOAD:.+]] = spirv.Load "StorageBuffer" %[[PTR]] + // CHECK: %[[FOUR2:.+]] = spirv.Constant 4 : i32 + // CHECK: %[[EIGHT:.+]] = spirv.Constant 8 : i32 + // CHECK: %[[IDX:.+]] = spirv.UMod %[[ZERO]], %[[FOUR2]] : i32 + // CHECK: %[[BITS:.+]] = spirv.IMul %[[IDX]], %[[EIGHT]] : i32 + // CHECK: %[[VALUE:.+]] = spirv.ShiftRightArithmetic %[[LOAD]], %[[BITS]] : i32, i32 + // CHECK: %[[MASK:.+]] = spirv.Constant 255 : i32 + // CHECK: %[[T1:.+]] = spirv.BitwiseAnd %[[VALUE]], %[[MASK]] : i32 + // CHECK: %[[T2:.+]] = spirv.Constant 24 : i32 + // CHECK: %[[T3:.+]] = spirv.ShiftLeftLogical %[[T1]], %[[T2]] : i32, i32 + // CHECK: spirv.ShiftRightArithmetic %[[T3]], %[[T2]] : i32, i32 + %0 = memref.load %arg0[] : memref> return } // CHECK-LABEL: @load_i16 -func.func @load_i16(%arg0: memref>) { - // CHECK-NOT: spv.SDiv - // CHECK: spv.Load - // CHECK-NOT: spv.ShiftRightArithmetic - %0 = memref.load %arg0[] : memref> +func.func @load_i16(%arg0: memref>) { + // CHECK-NOT: spirv.SDiv + // CHECK: spirv.Load + // CHECK-NOT: spirv.ShiftRightArithmetic + %0 = memref.load %arg0[] : memref> return } // CHECK-LABEL: @store_i8 // CHECK: (%[[ARG0:.+]]: {{.*}}, %[[ARG1:.+]]: i8) -func.func @store_i8(%arg0: memref>, %value: i8) { +func.func @store_i8(%arg0: memref>, %value: i8) { // CHECK-DAG: %[[ARG1_CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG1]] : i8 to i32 // CHECK-DAG: %[[ARG0_CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG0]] - // CHECK: %[[ZERO:.+]] = spv.Constant 0 : i32 - // CHECK: %[[FOUR:.+]] = spv.Constant 4 : i32 - // CHECK: %[[EIGHT:.+]] = spv.Constant 8 : i32 - // CHECK: %[[IDX:.+]] = spv.UMod %[[ZERO]], %[[FOUR]] : i32 - // CHECK: %[[OFFSET:.+]] = spv.IMul %[[IDX]], %[[EIGHT]] : i32 - // CHECK: %[[MASK1:.+]] = spv.Constant 255 : i32 - // CHECK: %[[TMP1:.+]] = spv.ShiftLeftLogical %[[MASK1]], %[[OFFSET]] : i32, i32 - // CHECK: %[[MASK:.+]] = spv.Not %[[TMP1]] : i32 - // CHECK: %[[CLAMPED_VAL:.+]] = spv.BitwiseAnd %[[ARG1_CAST]], %[[MASK1]] : i32 - // CHECK: %[[STORE_VAL:.+]] = spv.ShiftLeftLogical %[[CLAMPED_VAL]], %[[OFFSET]] : i32, i32 - // CHECK: %[[FOUR2:.+]] = spv.Constant 4 : i32 - // CHECK: %[[ACCESS_IDX:.+]] = spv.SDiv %[[ZERO]], %[[FOUR2]] : i32 - // CHECK: %[[PTR:.+]] = spv.AccessChain %[[ARG0_CAST]][%[[ZERO]], %[[ACCESS_IDX]]] - // CHECK: spv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]] - // CHECK: spv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]] - memref.store %value, %arg0[] : memref> + // CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[FOUR:.+]] = spirv.Constant 4 : i32 + // CHECK: %[[EIGHT:.+]] = spirv.Constant 8 : i32 + // CHECK: %[[IDX:.+]] = spirv.UMod %[[ZERO]], %[[FOUR]] : i32 + // CHECK: %[[OFFSET:.+]] = spirv.IMul %[[IDX]], %[[EIGHT]] : i32 + // CHECK: %[[MASK1:.+]] = spirv.Constant 255 : i32 + // CHECK: %[[TMP1:.+]] = spirv.ShiftLeftLogical %[[MASK1]], %[[OFFSET]] : i32, i32 + // CHECK: %[[MASK:.+]] = spirv.Not %[[TMP1]] : i32 + // CHECK: %[[CLAMPED_VAL:.+]] = spirv.BitwiseAnd %[[ARG1_CAST]], %[[MASK1]] : i32 + // CHECK: %[[STORE_VAL:.+]] = spirv.ShiftLeftLogical %[[CLAMPED_VAL]], %[[OFFSET]] : i32, i32 + // CHECK: %[[FOUR2:.+]] = spirv.Constant 4 : i32 + // CHECK: %[[ACCESS_IDX:.+]] = spirv.SDiv %[[ZERO]], %[[FOUR2]] : i32 + // CHECK: %[[PTR:.+]] = spirv.AccessChain %[[ARG0_CAST]][%[[ZERO]], %[[ACCESS_IDX]]] + // CHECK: spirv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]] + // CHECK: spirv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]] + memref.store %value, %arg0[] : memref> return } // CHECK-LABEL: @store_i16 -func.func @store_i16(%arg0: memref<10xi16, #spv.storage_class>, %index: index, %value: i16) { - // CHECK: spv.Store - // CHECK-NOT: spv.AtomicAnd - // CHECK-NOT: spv.AtomicOr - memref.store %value, %arg0[%index] : memref<10xi16, #spv.storage_class> +func.func @store_i16(%arg0: memref<10xi16, #spirv.storage_class>, %index: index, %value: i16) { + // CHECK: spirv.Store + // CHECK-NOT: spirv.AtomicAnd + // CHECK-NOT: spirv.AtomicOr + memref.store %value, %arg0[%index] : memref<10xi16, #spirv.storage_class> return } diff --git a/mlir/test/Conversion/SCFToSPIRV/for.mlir b/mlir/test/Conversion/SCFToSPIRV/for.mlir --- a/mlir/test/Conversion/SCFToSPIRV/for.mlir +++ b/mlir/test/Conversion/SCFToSPIRV/for.mlir @@ -1,85 +1,85 @@ // RUN: mlir-opt -convert-scf-to-spirv %s -o - | FileCheck %s module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { -func.func @loop_kernel(%arg2 : memref<10xf32, #spv.storage_class>, %arg3 : memref<10xf32, #spv.storage_class>) { - // CHECK: %[[LB:.*]] = spv.Constant 4 : i32 +func.func @loop_kernel(%arg2 : memref<10xf32, #spirv.storage_class>, %arg3 : memref<10xf32, #spirv.storage_class>) { + // CHECK: %[[LB:.*]] = spirv.Constant 4 : i32 %lb = arith.constant 4 : index - // CHECK: %[[UB:.*]] = spv.Constant 42 : i32 + // CHECK: %[[UB:.*]] = spirv.Constant 42 : i32 %ub = arith.constant 42 : index - // CHECK: %[[STEP:.*]] = spv.Constant 2 : i32 + // CHECK: %[[STEP:.*]] = spirv.Constant 2 : i32 %step = arith.constant 2 : index - // CHECK: spv.mlir.loop { - // CHECK-NEXT: spv.Branch ^[[HEADER:.*]](%[[LB]] : i32) + // CHECK: spirv.mlir.loop { + // CHECK-NEXT: spirv.Branch ^[[HEADER:.*]](%[[LB]] : i32) // CHECK: ^[[HEADER]](%[[INDVAR:.*]]: i32): - // CHECK: %[[CMP:.*]] = spv.SLessThan %[[INDVAR]], %[[UB]] : i32 - // CHECK: spv.BranchConditional %[[CMP]], ^[[BODY:.*]], ^[[MERGE:.*]] + // CHECK: %[[CMP:.*]] = spirv.SLessThan %[[INDVAR]], %[[UB]] : i32 + // CHECK: spirv.BranchConditional %[[CMP]], ^[[BODY:.*]], ^[[MERGE:.*]] // CHECK: ^[[BODY]]: - // CHECK: %[[ZERO1:.*]] = spv.Constant 0 : i32 - // CHECK: %[[OFFSET1:.*]] = spv.Constant 0 : i32 - // CHECK: %[[STRIDE1:.*]] = spv.Constant 1 : i32 - // CHECK: %[[UPDATE1:.*]] = spv.IMul %[[STRIDE1]], %[[INDVAR]] : i32 - // CHECK: %[[INDEX1:.*]] = spv.IAdd %[[OFFSET1]], %[[UPDATE1]] : i32 - // CHECK: spv.AccessChain {{%.*}}{{\[}}%[[ZERO1]], %[[INDEX1]]{{\]}} - // CHECK: %[[ZERO2:.*]] = spv.Constant 0 : i32 - // CHECK: %[[OFFSET2:.*]] = spv.Constant 0 : i32 - // CHECK: %[[STRIDE2:.*]] = spv.Constant 1 : i32 - // CHECK: %[[UPDATE2:.*]] = spv.IMul %[[STRIDE2]], %[[INDVAR]] : i32 - // CHECK: %[[INDEX2:.*]] = spv.IAdd %[[OFFSET2]], %[[UPDATE2]] : i32 - // CHECK: spv.AccessChain {{%.*}}[%[[ZERO2]], %[[INDEX2]]] - // CHECK: %[[INCREMENT:.*]] = spv.IAdd %[[INDVAR]], %[[STEP]] : i32 - // CHECK: spv.Branch ^[[HEADER]](%[[INCREMENT]] : i32) + // CHECK: %[[ZERO1:.*]] = spirv.Constant 0 : i32 + // CHECK: %[[OFFSET1:.*]] = spirv.Constant 0 : i32 + // CHECK: %[[STRIDE1:.*]] = spirv.Constant 1 : i32 + // CHECK: %[[UPDATE1:.*]] = spirv.IMul %[[STRIDE1]], %[[INDVAR]] : i32 + // CHECK: %[[INDEX1:.*]] = spirv.IAdd %[[OFFSET1]], %[[UPDATE1]] : i32 + // CHECK: spirv.AccessChain {{%.*}}{{\[}}%[[ZERO1]], %[[INDEX1]]{{\]}} + // CHECK: %[[ZERO2:.*]] = spirv.Constant 0 : i32 + // CHECK: %[[OFFSET2:.*]] = spirv.Constant 0 : i32 + // CHECK: %[[STRIDE2:.*]] = spirv.Constant 1 : i32 + // CHECK: %[[UPDATE2:.*]] = spirv.IMul %[[STRIDE2]], %[[INDVAR]] : i32 + // CHECK: %[[INDEX2:.*]] = spirv.IAdd %[[OFFSET2]], %[[UPDATE2]] : i32 + // CHECK: spirv.AccessChain {{%.*}}[%[[ZERO2]], %[[INDEX2]]] + // CHECK: %[[INCREMENT:.*]] = spirv.IAdd %[[INDVAR]], %[[STEP]] : i32 + // CHECK: spirv.Branch ^[[HEADER]](%[[INCREMENT]] : i32) // CHECK: ^[[MERGE]] - // CHECK: spv.mlir.merge + // CHECK: spirv.mlir.merge // CHECK: } scf.for %arg4 = %lb to %ub step %step { - %1 = memref.load %arg2[%arg4] : memref<10xf32, #spv.storage_class> - memref.store %1, %arg3[%arg4] : memref<10xf32, #spv.storage_class> + %1 = memref.load %arg2[%arg4] : memref<10xf32, #spirv.storage_class> + memref.store %1, %arg3[%arg4] : memref<10xf32, #spirv.storage_class> } return } // CHECK-LABEL: @loop_yield -func.func @loop_yield(%arg2 : memref<10xf32, #spv.storage_class>, %arg3 : memref<10xf32, #spv.storage_class>) { - // CHECK: %[[LB:.*]] = spv.Constant 4 : i32 +func.func @loop_yield(%arg2 : memref<10xf32, #spirv.storage_class>, %arg3 : memref<10xf32, #spirv.storage_class>) { + // CHECK: %[[LB:.*]] = spirv.Constant 4 : i32 %lb = arith.constant 4 : index - // CHECK: %[[UB:.*]] = spv.Constant 42 : i32 + // CHECK: %[[UB:.*]] = spirv.Constant 42 : i32 %ub = arith.constant 42 : index - // CHECK: %[[STEP:.*]] = spv.Constant 2 : i32 + // CHECK: %[[STEP:.*]] = spirv.Constant 2 : i32 %step = arith.constant 2 : index - // CHECK: %[[INITVAR1:.*]] = spv.Constant 0.000000e+00 : f32 + // CHECK: %[[INITVAR1:.*]] = spirv.Constant 0.000000e+00 : f32 %s0 = arith.constant 0.0 : f32 - // CHECK: %[[INITVAR2:.*]] = spv.Constant 1.000000e+00 : f32 + // CHECK: %[[INITVAR2:.*]] = spirv.Constant 1.000000e+00 : f32 %s1 = arith.constant 1.0 : f32 - // CHECK: %[[VAR1:.*]] = spv.Variable : !spv.ptr - // CHECK: %[[VAR2:.*]] = spv.Variable : !spv.ptr - // CHECK: spv.mlir.loop { - // CHECK: spv.Branch ^[[HEADER:.*]](%[[LB]], %[[INITVAR1]], %[[INITVAR2]] : i32, f32, f32) + // CHECK: %[[VAR1:.*]] = spirv.Variable : !spirv.ptr + // CHECK: %[[VAR2:.*]] = spirv.Variable : !spirv.ptr + // CHECK: spirv.mlir.loop { + // CHECK: spirv.Branch ^[[HEADER:.*]](%[[LB]], %[[INITVAR1]], %[[INITVAR2]] : i32, f32, f32) // CHECK: ^[[HEADER]](%[[INDVAR:.*]]: i32, %[[CARRIED1:.*]]: f32, %[[CARRIED2:.*]]: f32): - // CHECK: %[[CMP:.*]] = spv.SLessThan %[[INDVAR]], %[[UB]] : i32 - // CHECK: spv.BranchConditional %[[CMP]], ^[[BODY:.*]], ^[[MERGE:.*]] + // CHECK: %[[CMP:.*]] = spirv.SLessThan %[[INDVAR]], %[[UB]] : i32 + // CHECK: spirv.BranchConditional %[[CMP]], ^[[BODY:.*]], ^[[MERGE:.*]] // CHECK: ^[[BODY]]: - // CHECK: %[[UPDATED:.*]] = spv.FAdd %[[CARRIED1]], %[[CARRIED1]] : f32 - // CHECK-DAG: %[[INCREMENT:.*]] = spv.IAdd %[[INDVAR]], %[[STEP]] : i32 - // CHECK-DAG: spv.Store "Function" %[[VAR1]], %[[UPDATED]] : f32 - // CHECK-DAG: spv.Store "Function" %[[VAR2]], %[[UPDATED]] : f32 - // CHECK: spv.Branch ^[[HEADER]](%[[INCREMENT]], %[[UPDATED]], %[[UPDATED]] : i32, f32, f32) + // CHECK: %[[UPDATED:.*]] = spirv.FAdd %[[CARRIED1]], %[[CARRIED1]] : f32 + // CHECK-DAG: %[[INCREMENT:.*]] = spirv.IAdd %[[INDVAR]], %[[STEP]] : i32 + // CHECK-DAG: spirv.Store "Function" %[[VAR1]], %[[UPDATED]] : f32 + // CHECK-DAG: spirv.Store "Function" %[[VAR2]], %[[UPDATED]] : f32 + // CHECK: spirv.Branch ^[[HEADER]](%[[INCREMENT]], %[[UPDATED]], %[[UPDATED]] : i32, f32, f32) // CHECK: ^[[MERGE]]: - // CHECK: spv.mlir.merge + // CHECK: spirv.mlir.merge // CHECK: } %result:2 = scf.for %i0 = %lb to %ub step %step iter_args(%si = %s0, %sj = %s1) -> (f32, f32) { %sn = arith.addf %si, %si : f32 scf.yield %sn, %sn : f32, f32 } - // CHECK-DAG: %[[OUT1:.*]] = spv.Load "Function" %[[VAR1]] : f32 - // CHECK-DAG: %[[OUT2:.*]] = spv.Load "Function" %[[VAR2]] : f32 - // CHECK: spv.Store "StorageBuffer" {{%.*}}, %[[OUT1]] : f32 - // CHECK: spv.Store "StorageBuffer" {{%.*}}, %[[OUT2]] : f32 - memref.store %result#0, %arg3[%lb] : memref<10xf32, #spv.storage_class> - memref.store %result#1, %arg3[%ub] : memref<10xf32, #spv.storage_class> + // CHECK-DAG: %[[OUT1:.*]] = spirv.Load "Function" %[[VAR1]] : f32 + // CHECK-DAG: %[[OUT2:.*]] = spirv.Load "Function" %[[VAR2]] : f32 + // CHECK: spirv.Store "StorageBuffer" {{%.*}}, %[[OUT1]] : f32 + // CHECK: spirv.Store "StorageBuffer" {{%.*}}, %[[OUT2]] : f32 + memref.store %result#0, %arg3[%lb] : memref<10xf32, #spirv.storage_class> + memref.store %result#1, %arg3[%ub] : memref<10xf32, #spirv.storage_class> return } diff --git a/mlir/test/Conversion/SCFToSPIRV/if.mlir b/mlir/test/Conversion/SCFToSPIRV/if.mlir --- a/mlir/test/Conversion/SCFToSPIRV/if.mlir +++ b/mlir/test/Conversion/SCFToSPIRV/if.mlir @@ -1,110 +1,110 @@ // RUN: mlir-opt -convert-scf-to-spirv %s -o - | FileCheck %s module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @kernel_simple_selection -func.func @kernel_simple_selection(%arg2 : memref<10xf32, #spv.storage_class>, %arg3 : i1) { +func.func @kernel_simple_selection(%arg2 : memref<10xf32, #spirv.storage_class>, %arg3 : i1) { %value = arith.constant 0.0 : f32 %i = arith.constant 0 : index - // CHECK: spv.mlir.selection { - // CHECK-NEXT: spv.BranchConditional {{%.*}}, [[TRUE:\^.*]], [[MERGE:\^.*]] + // CHECK: spirv.mlir.selection { + // CHECK-NEXT: spirv.BranchConditional {{%.*}}, [[TRUE:\^.*]], [[MERGE:\^.*]] // CHECK-NEXT: [[TRUE]]: - // CHECK: spv.Branch [[MERGE]] + // CHECK: spirv.Branch [[MERGE]] // CHECK-NEXT: [[MERGE]]: - // CHECK-NEXT: spv.mlir.merge + // CHECK-NEXT: spirv.mlir.merge // CHECK-NEXT: } - // CHECK-NEXT: spv.Return + // CHECK-NEXT: spirv.Return scf.if %arg3 { - memref.store %value, %arg2[%i] : memref<10xf32, #spv.storage_class> + memref.store %value, %arg2[%i] : memref<10xf32, #spirv.storage_class> } return } // CHECK-LABEL: @kernel_nested_selection -func.func @kernel_nested_selection(%arg3 : memref<10xf32, #spv.storage_class>, %arg4 : memref<10xf32, #spv.storage_class>, %arg5 : i1, %arg6 : i1) { +func.func @kernel_nested_selection(%arg3 : memref<10xf32, #spirv.storage_class>, %arg4 : memref<10xf32, #spirv.storage_class>, %arg5 : i1, %arg6 : i1) { %i = arith.constant 0 : index %j = arith.constant 9 : index - // CHECK: spv.mlir.selection { - // CHECK-NEXT: spv.BranchConditional {{%.*}}, [[TRUE_TOP:\^.*]], [[FALSE_TOP:\^.*]] + // CHECK: spirv.mlir.selection { + // CHECK-NEXT: spirv.BranchConditional {{%.*}}, [[TRUE_TOP:\^.*]], [[FALSE_TOP:\^.*]] // CHECK-NEXT: [[TRUE_TOP]]: - // CHECK-NEXT: spv.mlir.selection { - // CHECK-NEXT: spv.BranchConditional {{%.*}}, [[TRUE_NESTED_TRUE_PATH:\^.*]], [[FALSE_NESTED_TRUE_PATH:\^.*]] + // CHECK-NEXT: spirv.mlir.selection { + // CHECK-NEXT: spirv.BranchConditional {{%.*}}, [[TRUE_NESTED_TRUE_PATH:\^.*]], [[FALSE_NESTED_TRUE_PATH:\^.*]] // CHECK-NEXT: [[TRUE_NESTED_TRUE_PATH]]: - // CHECK: spv.Branch [[MERGE_NESTED_TRUE_PATH:\^.*]] + // CHECK: spirv.Branch [[MERGE_NESTED_TRUE_PATH:\^.*]] // CHECK-NEXT: [[FALSE_NESTED_TRUE_PATH]]: - // CHECK: spv.Branch [[MERGE_NESTED_TRUE_PATH]] + // CHECK: spirv.Branch [[MERGE_NESTED_TRUE_PATH]] // CHECK-NEXT: [[MERGE_NESTED_TRUE_PATH]]: - // CHECK-NEXT: spv.mlir.merge + // CHECK-NEXT: spirv.mlir.merge // CHECK-NEXT: } - // CHECK-NEXT: spv.Branch [[MERGE_TOP:\^.*]] + // CHECK-NEXT: spirv.Branch [[MERGE_TOP:\^.*]] // CHECK-NEXT: [[FALSE_TOP]]: - // CHECK-NEXT: spv.mlir.selection { - // CHECK-NEXT: spv.BranchConditional {{%.*}}, [[TRUE_NESTED_FALSE_PATH:\^.*]], [[FALSE_NESTED_FALSE_PATH:\^.*]] + // CHECK-NEXT: spirv.mlir.selection { + // CHECK-NEXT: spirv.BranchConditional {{%.*}}, [[TRUE_NESTED_FALSE_PATH:\^.*]], [[FALSE_NESTED_FALSE_PATH:\^.*]] // CHECK-NEXT: [[TRUE_NESTED_FALSE_PATH]]: - // CHECK: spv.Branch [[MERGE_NESTED_FALSE_PATH:\^.*]] + // CHECK: spirv.Branch [[MERGE_NESTED_FALSE_PATH:\^.*]] // CHECK-NEXT: [[FALSE_NESTED_FALSE_PATH]]: - // CHECK: spv.Branch [[MERGE_NESTED_FALSE_PATH]] + // CHECK: spirv.Branch [[MERGE_NESTED_FALSE_PATH]] // CHECK: [[MERGE_NESTED_FALSE_PATH]]: - // CHECK-NEXT: spv.mlir.merge + // CHECK-NEXT: spirv.mlir.merge // CHECK-NEXT: } - // CHECK-NEXT: spv.Branch [[MERGE_TOP]] + // CHECK-NEXT: spirv.Branch [[MERGE_TOP]] // CHECK-NEXT: [[MERGE_TOP]]: - // CHECK-NEXT: spv.mlir.merge + // CHECK-NEXT: spirv.mlir.merge // CHECK-NEXT: } - // CHECK-NEXT: spv.Return + // CHECK-NEXT: spirv.Return scf.if %arg5 { scf.if %arg6 { - %value = memref.load %arg3[%i] : memref<10xf32, #spv.storage_class> - memref.store %value, %arg4[%i] : memref<10xf32, #spv.storage_class> + %value = memref.load %arg3[%i] : memref<10xf32, #spirv.storage_class> + memref.store %value, %arg4[%i] : memref<10xf32, #spirv.storage_class> } else { - %value = memref.load %arg4[%i] : memref<10xf32, #spv.storage_class> - memref.store %value, %arg3[%i] : memref<10xf32, #spv.storage_class> + %value = memref.load %arg4[%i] : memref<10xf32, #spirv.storage_class> + memref.store %value, %arg3[%i] : memref<10xf32, #spirv.storage_class> } } else { scf.if %arg6 { - %value = memref.load %arg3[%j] : memref<10xf32, #spv.storage_class> - memref.store %value, %arg4[%j] : memref<10xf32, #spv.storage_class> + %value = memref.load %arg3[%j] : memref<10xf32, #spirv.storage_class> + memref.store %value, %arg4[%j] : memref<10xf32, #spirv.storage_class> } else { - %value = memref.load %arg4[%j] : memref<10xf32, #spv.storage_class> - memref.store %value, %arg3[%j] : memref<10xf32, #spv.storage_class> + %value = memref.load %arg4[%j] : memref<10xf32, #spirv.storage_class> + memref.store %value, %arg3[%j] : memref<10xf32, #spirv.storage_class> } } return } // CHECK-LABEL: @simple_if_yield -func.func @simple_if_yield(%arg2 : memref<10xf32, #spv.storage_class>, %arg3 : i1) { - // CHECK: %[[VAR1:.*]] = spv.Variable : !spv.ptr - // CHECK: %[[VAR2:.*]] = spv.Variable : !spv.ptr - // CHECK: spv.mlir.selection { - // CHECK-NEXT: spv.BranchConditional {{%.*}}, [[TRUE:\^.*]], [[FALSE:\^.*]] +func.func @simple_if_yield(%arg2 : memref<10xf32, #spirv.storage_class>, %arg3 : i1) { + // CHECK: %[[VAR1:.*]] = spirv.Variable : !spirv.ptr + // CHECK: %[[VAR2:.*]] = spirv.Variable : !spirv.ptr + // CHECK: spirv.mlir.selection { + // CHECK-NEXT: spirv.BranchConditional {{%.*}}, [[TRUE:\^.*]], [[FALSE:\^.*]] // CHECK-NEXT: [[TRUE]]: - // CHECK: %[[RET1TRUE:.*]] = spv.Constant 0.000000e+00 : f32 - // CHECK: %[[RET2TRUE:.*]] = spv.Constant 1.000000e+00 : f32 - // CHECK-DAG: spv.Store "Function" %[[VAR1]], %[[RET1TRUE]] : f32 - // CHECK-DAG: spv.Store "Function" %[[VAR2]], %[[RET2TRUE]] : f32 - // CHECK: spv.Branch ^[[MERGE:.*]] + // CHECK: %[[RET1TRUE:.*]] = spirv.Constant 0.000000e+00 : f32 + // CHECK: %[[RET2TRUE:.*]] = spirv.Constant 1.000000e+00 : f32 + // CHECK-DAG: spirv.Store "Function" %[[VAR1]], %[[RET1TRUE]] : f32 + // CHECK-DAG: spirv.Store "Function" %[[VAR2]], %[[RET2TRUE]] : f32 + // CHECK: spirv.Branch ^[[MERGE:.*]] // CHECK-NEXT: [[FALSE]]: - // CHECK: %[[RET2FALSE:.*]] = spv.Constant 2.000000e+00 : f32 - // CHECK: %[[RET1FALSE:.*]] = spv.Constant 3.000000e+00 : f32 - // CHECK-DAG: spv.Store "Function" %[[VAR1]], %[[RET1FALSE]] : f32 - // CHECK-DAG: spv.Store "Function" %[[VAR2]], %[[RET2FALSE]] : f32 - // CHECK: spv.Branch ^[[MERGE]] + // CHECK: %[[RET2FALSE:.*]] = spirv.Constant 2.000000e+00 : f32 + // CHECK: %[[RET1FALSE:.*]] = spirv.Constant 3.000000e+00 : f32 + // CHECK-DAG: spirv.Store "Function" %[[VAR1]], %[[RET1FALSE]] : f32 + // CHECK-DAG: spirv.Store "Function" %[[VAR2]], %[[RET2FALSE]] : f32 + // CHECK: spirv.Branch ^[[MERGE]] // CHECK-NEXT: ^[[MERGE]]: - // CHECK: spv.mlir.merge + // CHECK: spirv.mlir.merge // CHECK-NEXT: } - // CHECK-DAG: %[[OUT1:.*]] = spv.Load "Function" %[[VAR1]] : f32 - // CHECK-DAG: %[[OUT2:.*]] = spv.Load "Function" %[[VAR2]] : f32 - // CHECK: spv.Store "StorageBuffer" {{%.*}}, %[[OUT1]] : f32 - // CHECK: spv.Store "StorageBuffer" {{%.*}}, %[[OUT2]] : f32 - // CHECK: spv.Return + // CHECK-DAG: %[[OUT1:.*]] = spirv.Load "Function" %[[VAR1]] : f32 + // CHECK-DAG: %[[OUT2:.*]] = spirv.Load "Function" %[[VAR2]] : f32 + // CHECK: spirv.Store "StorageBuffer" {{%.*}}, %[[OUT1]] : f32 + // CHECK: spirv.Store "StorageBuffer" {{%.*}}, %[[OUT2]] : f32 + // CHECK: spirv.Return %0:2 = scf.if %arg3 -> (f32, f32) { %c0 = arith.constant 0.0 : f32 %c1 = arith.constant 1.0 : f32 @@ -116,40 +116,40 @@ } %i = arith.constant 0 : index %j = arith.constant 1 : index - memref.store %0#0, %arg2[%i] : memref<10xf32, #spv.storage_class> - memref.store %0#1, %arg2[%j] : memref<10xf32, #spv.storage_class> + memref.store %0#0, %arg2[%i] : memref<10xf32, #spirv.storage_class> + memref.store %0#1, %arg2[%j] : memref<10xf32, #spirv.storage_class> return } // TODO: The transformation should only be legal if VariablePointer capability // is supported. This test is still useful to make sure we can handle scf op // result with type change. -func.func @simple_if_yield_type_change(%arg2 : memref<10xf32, #spv.storage_class>, %arg3 : memref<10xf32, #spv.storage_class>, %arg4 : i1) { +func.func @simple_if_yield_type_change(%arg2 : memref<10xf32, #spirv.storage_class>, %arg3 : memref<10xf32, #spirv.storage_class>, %arg4 : i1) { // CHECK-LABEL: @simple_if_yield_type_change - // CHECK: %[[VAR:.*]] = spv.Variable : !spv.ptr [0])>, StorageBuffer>, Function> - // CHECK: spv.mlir.selection { - // CHECK-NEXT: spv.BranchConditional {{%.*}}, [[TRUE:\^.*]], [[FALSE:\^.*]] + // CHECK: %[[VAR:.*]] = spirv.Variable : !spirv.ptr [0])>, StorageBuffer>, Function> + // CHECK: spirv.mlir.selection { + // CHECK-NEXT: spirv.BranchConditional {{%.*}}, [[TRUE:\^.*]], [[FALSE:\^.*]] // CHECK-NEXT: [[TRUE]]: - // CHECK: spv.Store "Function" %[[VAR]], {{%.*}} : !spv.ptr [0])>, StorageBuffer> - // CHECK: spv.Branch ^[[MERGE:.*]] + // CHECK: spirv.Store "Function" %[[VAR]], {{%.*}} : !spirv.ptr [0])>, StorageBuffer> + // CHECK: spirv.Branch ^[[MERGE:.*]] // CHECK-NEXT: [[FALSE]]: - // CHECK: spv.Store "Function" %[[VAR]], {{%.*}} : !spv.ptr [0])>, StorageBuffer> - // CHECK: spv.Branch ^[[MERGE]] + // CHECK: spirv.Store "Function" %[[VAR]], {{%.*}} : !spirv.ptr [0])>, StorageBuffer> + // CHECK: spirv.Branch ^[[MERGE]] // CHECK-NEXT: ^[[MERGE]]: - // CHECK: spv.mlir.merge + // CHECK: spirv.mlir.merge // CHECK-NEXT: } - // CHECK: %[[OUT:.*]] = spv.Load "Function" %[[VAR]] : !spv.ptr [0])>, StorageBuffer> - // CHECK: %[[ADD:.*]] = spv.AccessChain %[[OUT]][{{%.*}}, {{%.*}}] : !spv.ptr [0])>, StorageBuffer> - // CHECK: spv.Store "StorageBuffer" %[[ADD]], {{%.*}} : f32 - // CHECK: spv.Return + // CHECK: %[[OUT:.*]] = spirv.Load "Function" %[[VAR]] : !spirv.ptr [0])>, StorageBuffer> + // CHECK: %[[ADD:.*]] = spirv.AccessChain %[[OUT]][{{%.*}}, {{%.*}}] : !spirv.ptr [0])>, StorageBuffer> + // CHECK: spirv.Store "StorageBuffer" %[[ADD]], {{%.*}} : f32 + // CHECK: spirv.Return %i = arith.constant 0 : index %value = arith.constant 0.0 : f32 - %0 = scf.if %arg4 -> (memref<10xf32, #spv.storage_class>) { - scf.yield %arg2 : memref<10xf32, #spv.storage_class> + %0 = scf.if %arg4 -> (memref<10xf32, #spirv.storage_class>) { + scf.yield %arg2 : memref<10xf32, #spirv.storage_class> } else { - scf.yield %arg3 : memref<10xf32, #spv.storage_class> + scf.yield %arg3 : memref<10xf32, #spirv.storage_class> } - memref.store %value, %0[%i] : memref<10xf32, #spv.storage_class> + memref.store %value, %0[%i] : memref<10xf32, #spirv.storage_class> return } diff --git a/mlir/test/Conversion/SCFToSPIRV/while.mlir b/mlir/test/Conversion/SCFToSPIRV/while.mlir --- a/mlir/test/Conversion/SCFToSPIRV/while.mlir +++ b/mlir/test/Conversion/SCFToSPIRV/while.mlir @@ -1,26 +1,26 @@ // RUN: mlir-opt -allow-unregistered-dialect -convert-scf-to-spirv %s -o - | FileCheck %s module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @while_loop1 func.func @while_loop1(%arg0: i32, %arg1: i32) -> i32 { // CHECK-SAME: (%[[ARG1:.*]]: i32, %[[ARG2:.*]]: i32) - // CHECK: %[[INITVAR:.*]] = spv.Constant 2 : i32 - // CHECK: %[[VAR1:.*]] = spv.Variable : !spv.ptr - // CHECK: spv.mlir.loop { - // CHECK: spv.Branch ^[[HEADER:.*]](%[[ARG1]] : i32) + // CHECK: %[[INITVAR:.*]] = spirv.Constant 2 : i32 + // CHECK: %[[VAR1:.*]] = spirv.Variable : !spirv.ptr + // CHECK: spirv.mlir.loop { + // CHECK: spirv.Branch ^[[HEADER:.*]](%[[ARG1]] : i32) // CHECK: ^[[HEADER]](%[[INDVAR1:.*]]: i32): - // CHECK: %[[CMP:.*]] = spv.SLessThan %[[INDVAR1]], %[[ARG2]] : i32 - // CHECK: spv.Store "Function" %[[VAR1]], %[[INDVAR1]] : i32 - // CHECK: spv.BranchConditional %[[CMP]], ^[[BODY:.*]](%[[INDVAR1]] : i32), ^[[MERGE:.*]] + // CHECK: %[[CMP:.*]] = spirv.SLessThan %[[INDVAR1]], %[[ARG2]] : i32 + // CHECK: spirv.Store "Function" %[[VAR1]], %[[INDVAR1]] : i32 + // CHECK: spirv.BranchConditional %[[CMP]], ^[[BODY:.*]](%[[INDVAR1]] : i32), ^[[MERGE:.*]] // CHECK: ^[[BODY]](%[[INDVAR2:.*]]: i32): - // CHECK: %[[UPDATED:.*]] = spv.IMul %[[INDVAR2]], %[[INITVAR]] : i32 - // CHECK: spv.Branch ^[[HEADER]](%[[UPDATED]] : i32) + // CHECK: %[[UPDATED:.*]] = spirv.IMul %[[INDVAR2]], %[[INITVAR]] : i32 + // CHECK: spirv.Branch ^[[HEADER]](%[[UPDATED]] : i32) // CHECK: ^[[MERGE]]: - // CHECK: spv.mlir.merge + // CHECK: spirv.mlir.merge // CHECK: } %c2_i32 = arith.constant 2 : i32 %0 = scf.while (%arg3 = %arg0) : (i32) -> (i32) { @@ -31,8 +31,8 @@ %1 = arith.muli %arg5, %c2_i32 : i32 scf.yield %1 : i32 } - // CHECK: %[[OUT:.*]] = spv.Load "Function" %[[VAR1]] : i32 - // CHECK: spv.ReturnValue %[[OUT]] : i32 + // CHECK: %[[OUT:.*]] = spirv.Load "Function" %[[VAR1]] : i32 + // CHECK: spirv.ReturnValue %[[OUT]] : i32 return %0 : i32 } @@ -41,19 +41,19 @@ // CHECK-LABEL: @while_loop2 func.func @while_loop2(%arg0: f32) -> i64 { // CHECK-SAME: (%[[ARG:.*]]: f32) - // CHECK: %[[VAR:.*]] = spv.Variable : !spv.ptr - // CHECK: spv.mlir.loop { - // CHECK: spv.Branch ^[[HEADER:.*]](%[[ARG]] : f32) + // CHECK: %[[VAR:.*]] = spirv.Variable : !spirv.ptr + // CHECK: spirv.mlir.loop { + // CHECK: spirv.Branch ^[[HEADER:.*]](%[[ARG]] : f32) // CHECK: ^[[HEADER]](%[[INDVAR1:.*]]: f32): // CHECK: %[[SHARED:.*]] = "foo.shared_compute"(%[[INDVAR1]]) : (f32) -> i64 // CHECK: %[[CMP:.*]] = "foo.evaluate_condition"(%[[INDVAR1]], %[[SHARED]]) : (f32, i64) -> i1 - // CHECK: spv.Store "Function" %[[VAR]], %[[SHARED]] : i64 - // CHECK: spv.BranchConditional %[[CMP]], ^[[BODY:.*]](%[[SHARED]] : i64), ^[[MERGE:.*]] + // CHECK: spirv.Store "Function" %[[VAR]], %[[SHARED]] : i64 + // CHECK: spirv.BranchConditional %[[CMP]], ^[[BODY:.*]](%[[SHARED]] : i64), ^[[MERGE:.*]] // CHECK: ^[[BODY]](%[[INDVAR2:.*]]: i64): // CHECK: %[[UPDATED:.*]] = "foo.payload"(%[[INDVAR2]]) : (i64) -> f32 - // CHECK: spv.Branch ^[[HEADER]](%[[UPDATED]] : f32) + // CHECK: spirv.Branch ^[[HEADER]](%[[UPDATED]] : f32) // CHECK: ^[[MERGE]]: - // CHECK: spv.mlir.merge + // CHECK: spirv.mlir.merge // CHECK: } %res = scf.while (%arg1 = %arg0) : (f32) -> i64 { %shared = "foo.shared_compute"(%arg1) : (f32) -> i64 @@ -64,8 +64,8 @@ %res = "foo.payload"(%arg2) : (i64) -> f32 scf.yield %res : f32 } - // CHECK: %[[OUT:.*]] = spv.Load "Function" %[[VAR]] : i64 - // CHECK: spv.ReturnValue %[[OUT]] : i64 + // CHECK: %[[OUT:.*]] = spirv.Load "Function" %[[VAR]] : i64 + // CHECK: spirv.ReturnValue %[[OUT]] : i64 return %res : i64 } diff --git a/mlir/test/Conversion/SPIRVToLLVM/arithmetic-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/arithmetic-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/arithmetic-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/arithmetic-ops-to-llvm.mlir @@ -1,235 +1,235 @@ // RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.IAdd +// spirv.IAdd //===----------------------------------------------------------------------===// // CHECK-LABEL: @iadd_scalar -spv.func @iadd_scalar(%arg0: i32, %arg1: i32) "None" { +spirv.func @iadd_scalar(%arg0: i32, %arg1: i32) "None" { // CHECK: llvm.add %{{.*}}, %{{.*}} : i32 - %0 = spv.IAdd %arg0, %arg1 : i32 - spv.Return + %0 = spirv.IAdd %arg0, %arg1 : i32 + spirv.Return } // CHECK-LABEL: @iadd_vector -spv.func @iadd_vector(%arg0: vector<4xi64>, %arg1: vector<4xi64>) "None" { +spirv.func @iadd_vector(%arg0: vector<4xi64>, %arg1: vector<4xi64>) "None" { // CHECK: llvm.add %{{.*}}, %{{.*}} : vector<4xi64> - %0 = spv.IAdd %arg0, %arg1 : vector<4xi64> - spv.Return + %0 = spirv.IAdd %arg0, %arg1 : vector<4xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.ISub +// spirv.ISub //===----------------------------------------------------------------------===// // CHECK-LABEL: @isub_scalar -spv.func @isub_scalar(%arg0: i8, %arg1: i8) "None" { +spirv.func @isub_scalar(%arg0: i8, %arg1: i8) "None" { // CHECK: llvm.sub %{{.*}}, %{{.*}} : i8 - %0 = spv.ISub %arg0, %arg1 : i8 - spv.Return + %0 = spirv.ISub %arg0, %arg1 : i8 + spirv.Return } // CHECK-LABEL: @isub_vector -spv.func @isub_vector(%arg0: vector<2xi16>, %arg1: vector<2xi16>) "None" { +spirv.func @isub_vector(%arg0: vector<2xi16>, %arg1: vector<2xi16>) "None" { // CHECK: llvm.sub %{{.*}}, %{{.*}} : vector<2xi16> - %0 = spv.ISub %arg0, %arg1 : vector<2xi16> - spv.Return + %0 = spirv.ISub %arg0, %arg1 : vector<2xi16> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.IMul +// spirv.IMul //===----------------------------------------------------------------------===// // CHECK-LABEL: @imul_scalar -spv.func @imul_scalar(%arg0: i32, %arg1: i32) "None" { +spirv.func @imul_scalar(%arg0: i32, %arg1: i32) "None" { // CHECK: llvm.mul %{{.*}}, %{{.*}} : i32 - %0 = spv.IMul %arg0, %arg1 : i32 - spv.Return + %0 = spirv.IMul %arg0, %arg1 : i32 + spirv.Return } // CHECK-LABEL: @imul_vector -spv.func @imul_vector(%arg0: vector<3xi32>, %arg1: vector<3xi32>) "None" { +spirv.func @imul_vector(%arg0: vector<3xi32>, %arg1: vector<3xi32>) "None" { // CHECK: llvm.mul %{{.*}}, %{{.*}} : vector<3xi32> - %0 = spv.IMul %arg0, %arg1 : vector<3xi32> - spv.Return + %0 = spirv.IMul %arg0, %arg1 : vector<3xi32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FAdd +// spirv.FAdd //===----------------------------------------------------------------------===// // CHECK-LABEL: @fadd_scalar -spv.func @fadd_scalar(%arg0: f16, %arg1: f16) "None" { +spirv.func @fadd_scalar(%arg0: f16, %arg1: f16) "None" { // CHECK: llvm.fadd %{{.*}}, %{{.*}} : f16 - %0 = spv.FAdd %arg0, %arg1 : f16 - spv.Return + %0 = spirv.FAdd %arg0, %arg1 : f16 + spirv.Return } // CHECK-LABEL: @fadd_vector -spv.func @fadd_vector(%arg0: vector<4xf32>, %arg1: vector<4xf32>) "None" { +spirv.func @fadd_vector(%arg0: vector<4xf32>, %arg1: vector<4xf32>) "None" { // CHECK: llvm.fadd %{{.*}}, %{{.*}} : vector<4xf32> - %0 = spv.FAdd %arg0, %arg1 : vector<4xf32> - spv.Return + %0 = spirv.FAdd %arg0, %arg1 : vector<4xf32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FSub +// spirv.FSub //===----------------------------------------------------------------------===// // CHECK-LABEL: @fsub_scalar -spv.func @fsub_scalar(%arg0: f32, %arg1: f32) "None" { +spirv.func @fsub_scalar(%arg0: f32, %arg1: f32) "None" { // CHECK: llvm.fsub %{{.*}}, %{{.*}} : f32 - %0 = spv.FSub %arg0, %arg1 : f32 - spv.Return + %0 = spirv.FSub %arg0, %arg1 : f32 + spirv.Return } // CHECK-LABEL: @fsub_vector -spv.func @fsub_vector(%arg0: vector<2xf32>, %arg1: vector<2xf32>) "None" { +spirv.func @fsub_vector(%arg0: vector<2xf32>, %arg1: vector<2xf32>) "None" { // CHECK: llvm.fsub %{{.*}}, %{{.*}} : vector<2xf32> - %0 = spv.FSub %arg0, %arg1 : vector<2xf32> - spv.Return + %0 = spirv.FSub %arg0, %arg1 : vector<2xf32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FDiv +// spirv.FDiv //===----------------------------------------------------------------------===// // CHECK-LABEL: @fdiv_scalar -spv.func @fdiv_scalar(%arg0: f32, %arg1: f32) "None" { +spirv.func @fdiv_scalar(%arg0: f32, %arg1: f32) "None" { // CHECK: llvm.fdiv %{{.*}}, %{{.*}} : f32 - %0 = spv.FDiv %arg0, %arg1 : f32 - spv.Return + %0 = spirv.FDiv %arg0, %arg1 : f32 + spirv.Return } // CHECK-LABEL: @fdiv_vector -spv.func @fdiv_vector(%arg0: vector<3xf64>, %arg1: vector<3xf64>) "None" { +spirv.func @fdiv_vector(%arg0: vector<3xf64>, %arg1: vector<3xf64>) "None" { // CHECK: llvm.fdiv %{{.*}}, %{{.*}} : vector<3xf64> - %0 = spv.FDiv %arg0, %arg1 : vector<3xf64> - spv.Return + %0 = spirv.FDiv %arg0, %arg1 : vector<3xf64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FMul +// spirv.FMul //===----------------------------------------------------------------------===// // CHECK-LABEL: @fmul_scalar -spv.func @fmul_scalar(%arg0: f32, %arg1: f32) "None" { +spirv.func @fmul_scalar(%arg0: f32, %arg1: f32) "None" { // CHECK: llvm.fmul %{{.*}}, %{{.*}} : f32 - %0 = spv.FMul %arg0, %arg1 : f32 - spv.Return + %0 = spirv.FMul %arg0, %arg1 : f32 + spirv.Return } // CHECK-LABEL: @fmul_vector -spv.func @fmul_vector(%arg0: vector<2xf32>, %arg1: vector<2xf32>) "None" { +spirv.func @fmul_vector(%arg0: vector<2xf32>, %arg1: vector<2xf32>) "None" { // CHECK: llvm.fmul %{{.*}}, %{{.*}} : vector<2xf32> - %0 = spv.FMul %arg0, %arg1 : vector<2xf32> - spv.Return + %0 = spirv.FMul %arg0, %arg1 : vector<2xf32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FRem +// spirv.FRem //===----------------------------------------------------------------------===// // CHECK-LABEL: @frem_scalar -spv.func @frem_scalar(%arg0: f32, %arg1: f32) "None" { +spirv.func @frem_scalar(%arg0: f32, %arg1: f32) "None" { // CHECK: llvm.frem %{{.*}}, %{{.*}} : f32 - %0 = spv.FRem %arg0, %arg1 : f32 - spv.Return + %0 = spirv.FRem %arg0, %arg1 : f32 + spirv.Return } // CHECK-LABEL: @frem_vector -spv.func @frem_vector(%arg0: vector<3xf64>, %arg1: vector<3xf64>) "None" { +spirv.func @frem_vector(%arg0: vector<3xf64>, %arg1: vector<3xf64>) "None" { // CHECK: llvm.frem %{{.*}}, %{{.*}} : vector<3xf64> - %0 = spv.FRem %arg0, %arg1 : vector<3xf64> - spv.Return + %0 = spirv.FRem %arg0, %arg1 : vector<3xf64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FNegate +// spirv.FNegate //===----------------------------------------------------------------------===// // CHECK-LABEL: @fneg_scalar -spv.func @fneg_scalar(%arg: f64) "None" { +spirv.func @fneg_scalar(%arg: f64) "None" { // CHECK: llvm.fneg %{{.*}} : f64 - %0 = spv.FNegate %arg : f64 - spv.Return + %0 = spirv.FNegate %arg : f64 + spirv.Return } // CHECK-LABEL: @fneg_vector -spv.func @fneg_vector(%arg: vector<2xf32>) "None" { +spirv.func @fneg_vector(%arg: vector<2xf32>) "None" { // CHECK: llvm.fneg %{{.*}} : vector<2xf32> - %0 = spv.FNegate %arg : vector<2xf32> - spv.Return + %0 = spirv.FNegate %arg : vector<2xf32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.UDiv +// spirv.UDiv //===----------------------------------------------------------------------===// // CHECK-LABEL: @udiv_scalar -spv.func @udiv_scalar(%arg0: i32, %arg1: i32) "None" { +spirv.func @udiv_scalar(%arg0: i32, %arg1: i32) "None" { // CHECK: llvm.udiv %{{.*}}, %{{.*}} : i32 - %0 = spv.UDiv %arg0, %arg1 : i32 - spv.Return + %0 = spirv.UDiv %arg0, %arg1 : i32 + spirv.Return } // CHECK-LABEL: @udiv_vector -spv.func @udiv_vector(%arg0: vector<3xi64>, %arg1: vector<3xi64>) "None" { +spirv.func @udiv_vector(%arg0: vector<3xi64>, %arg1: vector<3xi64>) "None" { // CHECK: llvm.udiv %{{.*}}, %{{.*}} : vector<3xi64> - %0 = spv.UDiv %arg0, %arg1 : vector<3xi64> - spv.Return + %0 = spirv.UDiv %arg0, %arg1 : vector<3xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.UMod +// spirv.UMod //===----------------------------------------------------------------------===// // CHECK-LABEL: @umod_scalar -spv.func @umod_scalar(%arg0: i32, %arg1: i32) "None" { +spirv.func @umod_scalar(%arg0: i32, %arg1: i32) "None" { // CHECK: llvm.urem %{{.*}}, %{{.*}} : i32 - %0 = spv.UMod %arg0, %arg1 : i32 - spv.Return + %0 = spirv.UMod %arg0, %arg1 : i32 + spirv.Return } // CHECK-LABEL: @umod_vector -spv.func @umod_vector(%arg0: vector<3xi64>, %arg1: vector<3xi64>) "None" { +spirv.func @umod_vector(%arg0: vector<3xi64>, %arg1: vector<3xi64>) "None" { // CHECK: llvm.urem %{{.*}}, %{{.*}} : vector<3xi64> - %0 = spv.UMod %arg0, %arg1 : vector<3xi64> - spv.Return + %0 = spirv.UMod %arg0, %arg1 : vector<3xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.SDiv +// spirv.SDiv //===----------------------------------------------------------------------===// // CHECK-LABEL: @sdiv_scalar -spv.func @sdiv_scalar(%arg0: i16, %arg1: i16) "None" { +spirv.func @sdiv_scalar(%arg0: i16, %arg1: i16) "None" { // CHECK: llvm.sdiv %{{.*}}, %{{.*}} : i16 - %0 = spv.SDiv %arg0, %arg1 : i16 - spv.Return + %0 = spirv.SDiv %arg0, %arg1 : i16 + spirv.Return } // CHECK-LABEL: @sdiv_vector -spv.func @sdiv_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { +spirv.func @sdiv_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { // CHECK: llvm.sdiv %{{.*}}, %{{.*}} : vector<2xi64> - %0 = spv.SDiv %arg0, %arg1 : vector<2xi64> - spv.Return + %0 = spirv.SDiv %arg0, %arg1 : vector<2xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.SRem +// spirv.SRem //===----------------------------------------------------------------------===// // CHECK-LABEL: @srem_scalar -spv.func @srem_scalar(%arg0: i32, %arg1: i32) "None" { +spirv.func @srem_scalar(%arg0: i32, %arg1: i32) "None" { // CHECK: llvm.srem %{{.*}}, %{{.*}} : i32 - %0 = spv.SRem %arg0, %arg1 : i32 - spv.Return + %0 = spirv.SRem %arg0, %arg1 : i32 + spirv.Return } // CHECK-LABEL: @srem_vector -spv.func @srem_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { +spirv.func @srem_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { // CHECK: llvm.srem %{{.*}}, %{{.*}} : vector<4xi32> - %0 = spv.SRem %arg0, %arg1 : vector<4xi32> - spv.Return + %0 = spirv.SRem %arg0, %arg1 : vector<4xi32> + spirv.Return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/bitwise-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/bitwise-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/bitwise-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/bitwise-ops-to-llvm.mlir @@ -1,48 +1,48 @@ // RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.BitCount +// spirv.BitCount //===----------------------------------------------------------------------===// // CHECK-LABEL: @bitcount_scalar -spv.func @bitcount_scalar(%arg0: i16) "None" { +spirv.func @bitcount_scalar(%arg0: i16) "None" { // CHECK: "llvm.intr.ctpop"(%{{.*}}) : (i16) -> i16 - %0 = spv.BitCount %arg0: i16 - spv.Return + %0 = spirv.BitCount %arg0: i16 + spirv.Return } // CHECK-LABEL: @bitcount_vector -spv.func @bitcount_vector(%arg0: vector<3xi32>) "None" { +spirv.func @bitcount_vector(%arg0: vector<3xi32>) "None" { // CHECK: "llvm.intr.ctpop"(%{{.*}}) : (vector<3xi32>) -> vector<3xi32> - %0 = spv.BitCount %arg0: vector<3xi32> - spv.Return + %0 = spirv.BitCount %arg0: vector<3xi32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.BitReverse +// spirv.BitReverse //===----------------------------------------------------------------------===// // CHECK-LABEL: @bitreverse_scalar -spv.func @bitreverse_scalar(%arg0: i64) "None" { +spirv.func @bitreverse_scalar(%arg0: i64) "None" { // CHECK: "llvm.intr.bitreverse"(%{{.*}}) : (i64) -> i64 - %0 = spv.BitReverse %arg0: i64 - spv.Return + %0 = spirv.BitReverse %arg0: i64 + spirv.Return } // CHECK-LABEL: @bitreverse_vector -spv.func @bitreverse_vector(%arg0: vector<4xi32>) "None" { +spirv.func @bitreverse_vector(%arg0: vector<4xi32>) "None" { // CHECK: "llvm.intr.bitreverse"(%{{.*}}) : (vector<4xi32>) -> vector<4xi32> - %0 = spv.BitReverse %arg0: vector<4xi32> - spv.Return + %0 = spirv.BitReverse %arg0: vector<4xi32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.BitFieldInsert +// spirv.BitFieldInsert //===----------------------------------------------------------------------===// // CHECK-LABEL: @bitfield_insert_scalar_same_bit_width // CHECK-SAME: %[[BASE:.*]]: i32, %[[INSERT:.*]]: i32, %[[OFFSET:.*]]: i32, %[[COUNT:.*]]: i32 -spv.func @bitfield_insert_scalar_same_bit_width(%base: i32, %insert: i32, %offset: i32, %count: i32) "None" { +spirv.func @bitfield_insert_scalar_same_bit_width(%base: i32, %insert: i32, %offset: i32, %count: i32) "None" { // CHECK: %[[MINUS_ONE:.*]] = llvm.mlir.constant(-1 : i32) : i32 // CHECK: %[[T0:.*]] = llvm.shl %[[MINUS_ONE]], %[[COUNT]] : i32 // CHECK: %[[T1:.*]] = llvm.xor %[[T0]], %[[MINUS_ONE]] : i32 @@ -51,13 +51,13 @@ // CHECK: %[[NEW_BASE:.*]] = llvm.and %[[BASE]], %[[MASK]] : i32 // CHECK: %[[SHIFTED_INSERT:.*]] = llvm.shl %[[INSERT]], %[[OFFSET]] : i32 // CHECK: llvm.or %[[NEW_BASE]], %[[SHIFTED_INSERT]] : i32 - %0 = spv.BitFieldInsert %base, %insert, %offset, %count : i32, i32, i32 - spv.Return + %0 = spirv.BitFieldInsert %base, %insert, %offset, %count : i32, i32, i32 + spirv.Return } // CHECK-LABEL: @bitfield_insert_scalar_smaller_bit_width // CHECK-SAME: %[[BASE:.*]]: i64, %[[INSERT:.*]]: i64, %[[OFFSET:.*]]: i8, %[[COUNT:.*]]: i8 -spv.func @bitfield_insert_scalar_smaller_bit_width(%base: i64, %insert: i64, %offset: i8, %count: i8) "None" { +spirv.func @bitfield_insert_scalar_smaller_bit_width(%base: i64, %insert: i64, %offset: i8, %count: i8) "None" { // CHECK: %[[EXT_OFFSET:.*]] = llvm.zext %[[OFFSET]] : i8 to i64 // CHECK: %[[EXT_COUNT:.*]] = llvm.zext %[[COUNT]] : i8 to i64 // CHECK: %[[MINUS_ONE:.*]] = llvm.mlir.constant(-1 : i64) : i64 @@ -68,13 +68,13 @@ // CHECK: %[[NEW_BASE:.*]] = llvm.and %[[BASE]], %[[MASK]] : i64 // CHECK: %[[SHIFTED_INSERT:.*]] = llvm.shl %[[INSERT]], %[[EXT_OFFSET]] : i64 // CHECK: llvm.or %[[NEW_BASE]], %[[SHIFTED_INSERT]] : i64 - %0 = spv.BitFieldInsert %base, %insert, %offset, %count : i64, i8, i8 - spv.Return + %0 = spirv.BitFieldInsert %base, %insert, %offset, %count : i64, i8, i8 + spirv.Return } // CHECK-LABEL: @bitfield_insert_scalar_greater_bit_width // CHECK-SAME: %[[BASE:.*]]: i16, %[[INSERT:.*]]: i16, %[[OFFSET:.*]]: i32, %[[COUNT:.*]]: i64 -spv.func @bitfield_insert_scalar_greater_bit_width(%base: i16, %insert: i16, %offset: i32, %count: i64) "None" { +spirv.func @bitfield_insert_scalar_greater_bit_width(%base: i16, %insert: i16, %offset: i32, %count: i64) "None" { // CHECK: %[[TRUNC_OFFSET:.*]] = llvm.trunc %[[OFFSET]] : i32 to i16 // CHECK: %[[TRUNC_COUNT:.*]] = llvm.trunc %[[COUNT]] : i64 to i16 // CHECK: %[[MINUS_ONE:.*]] = llvm.mlir.constant(-1 : i16) : i16 @@ -85,13 +85,13 @@ // CHECK: %[[NEW_BASE:.*]] = llvm.and %[[BASE]], %[[MASK]] : i16 // CHECK: %[[SHIFTED_INSERT:.*]] = llvm.shl %[[INSERT]], %[[TRUNC_OFFSET]] : i16 // CHECK: llvm.or %[[NEW_BASE]], %[[SHIFTED_INSERT]] : i16 - %0 = spv.BitFieldInsert %base, %insert, %offset, %count : i16, i32, i64 - spv.Return + %0 = spirv.BitFieldInsert %base, %insert, %offset, %count : i16, i32, i64 + spirv.Return } // CHECK-LABEL: @bitfield_insert_vector // CHECK-SAME: %[[BASE:.*]]: vector<2xi32>, %[[INSERT:.*]]: vector<2xi32>, %[[OFFSET:.*]]: i32, %[[COUNT:.*]]: i32 -spv.func @bitfield_insert_vector(%base: vector<2xi32>, %insert: vector<2xi32>, %offset: i32, %count: i32) "None" { +spirv.func @bitfield_insert_vector(%base: vector<2xi32>, %insert: vector<2xi32>, %offset: i32, %count: i32) "None" { // CHECK: %[[OFFSET_V0:.*]] = llvm.mlir.undef : vector<2xi32> // CHECK: %[[ZERO:.*]] = llvm.mlir.constant(0 : i32) : i32 // CHECK: %[[OFFSET_V1:.*]] = llvm.insertelement %[[OFFSET]], %[[OFFSET_V0]][%[[ZERO]] : i32] : vector<2xi32> @@ -110,30 +110,30 @@ // CHECK: %[[NEW_BASE:.*]] = llvm.and %[[BASE]], %[[MASK]] : vector<2xi32> // CHECK: %[[SHIFTED_INSERT:.*]] = llvm.shl %[[INSERT]], %[[OFFSET_V2]] : vector<2xi32> // CHECK: llvm.or %[[NEW_BASE]], %[[SHIFTED_INSERT]] : vector<2xi32> - %0 = spv.BitFieldInsert %base, %insert, %offset, %count : vector<2xi32>, i32, i32 - spv.Return + %0 = spirv.BitFieldInsert %base, %insert, %offset, %count : vector<2xi32>, i32, i32 + spirv.Return } //===----------------------------------------------------------------------===// -// spv.BitFieldSExtract +// spirv.BitFieldSExtract //===----------------------------------------------------------------------===// // CHECK-LABEL: @bitfield_sextract_scalar_same_bit_width // CHECK-SAME: %[[BASE:.*]]: i64, %[[OFFSET:.*]]: i64, %[[COUNT:.*]]: i64 -spv.func @bitfield_sextract_scalar_same_bit_width(%base: i64, %offset: i64, %count: i64) "None" { +spirv.func @bitfield_sextract_scalar_same_bit_width(%base: i64, %offset: i64, %count: i64) "None" { // CHECK: %[[SIZE:.]] = llvm.mlir.constant(64 : i64) : i64 // CHECK: %[[T0:.*]] = llvm.add %[[COUNT]], %[[OFFSET]] : i64 // CHECK: %[[T1:.*]] = llvm.sub %[[SIZE]], %[[T0]] : i64 // CHECK: %[[SHIFTED_LEFT:.*]] = llvm.shl %[[BASE]], %[[T1]] : i64 // CHECK: %[[T2:.*]] = llvm.add %[[OFFSET]], %[[T1]] : i64 // CHECK: llvm.ashr %[[SHIFTED_LEFT]], %[[T2]] : i64 - %0 = spv.BitFieldSExtract %base, %offset, %count : i64, i64, i64 - spv.Return + %0 = spirv.BitFieldSExtract %base, %offset, %count : i64, i64, i64 + spirv.Return } // CHECK-LABEL: @bitfield_sextract_scalar_smaller_bit_width // CHECK-SAME: %[[BASE:.*]]: i32, %[[OFFSET:.*]]: i8, %[[COUNT:.*]]: i8 -spv.func @bitfield_sextract_scalar_smaller_bit_width(%base: i32, %offset: i8, %count: i8) "None" { +spirv.func @bitfield_sextract_scalar_smaller_bit_width(%base: i32, %offset: i8, %count: i8) "None" { // CHECK: %[[EXT_OFFSET:.*]] = llvm.zext %[[OFFSET]] : i8 to i32 // CHECK: %[[EXT_COUNT:.*]] = llvm.zext %[[COUNT]] : i8 to i32 // CHECK: %[[SIZE:.]] = llvm.mlir.constant(32 : i32) : i32 @@ -142,13 +142,13 @@ // CHECK: %[[SHIFTED_LEFT:.*]] = llvm.shl %[[BASE]], %[[T1]] : i32 // CHECK: %[[T2:.*]] = llvm.add %[[EXT_OFFSET]], %[[T1]] : i32 // CHECK: llvm.ashr %[[SHIFTED_LEFT]], %[[T2]] : i32 - %0 = spv.BitFieldSExtract %base, %offset, %count : i32, i8, i8 - spv.Return + %0 = spirv.BitFieldSExtract %base, %offset, %count : i32, i8, i8 + spirv.Return } // CHECK-LABEL: @bitfield_sextract_scalar_greater_bit_width // CHECK-SAME: %[[BASE:.*]]: i32, %[[OFFSET:.*]]: i64, %[[COUNT:.*]]: i64 -spv.func @bitfield_sextract_scalar_greater_bit_width(%base: i32, %offset: i64, %count: i64) "None" { +spirv.func @bitfield_sextract_scalar_greater_bit_width(%base: i32, %offset: i64, %count: i64) "None" { // CHECK: %[[TRUNC_OFFSET:.*]] = llvm.trunc %[[OFFSET]] : i64 to i32 // CHECK: %[[TRUNC_COUNT:.*]] = llvm.trunc %[[COUNT]] : i64 to i32 // CHECK: %[[SIZE:.]] = llvm.mlir.constant(32 : i32) : i32 @@ -157,13 +157,13 @@ // CHECK: %[[SHIFTED_LEFT:.*]] = llvm.shl %[[BASE]], %[[T1]] : i32 // CHECK: %[[T2:.*]] = llvm.add %[[TRUNC_OFFSET]], %[[T1]] : i32 // CHECK: llvm.ashr %[[SHIFTED_LEFT]], %[[T2]] : i32 - %0 = spv.BitFieldSExtract %base, %offset, %count : i32, i64, i64 - spv.Return + %0 = spirv.BitFieldSExtract %base, %offset, %count : i32, i64, i64 + spirv.Return } // CHECK-LABEL: @bitfield_sextract_vector // CHECK-SAME: %[[BASE:.*]]: vector<2xi32>, %[[OFFSET:.*]]: i32, %[[COUNT:.*]]: i32 -spv.func @bitfield_sextract_vector(%base: vector<2xi32>, %offset: i32, %count: i32) "None" { +spirv.func @bitfield_sextract_vector(%base: vector<2xi32>, %offset: i32, %count: i32) "None" { // CHECK: %[[OFFSET_V0:.*]] = llvm.mlir.undef : vector<2xi32> // CHECK: %[[ZERO:.*]] = llvm.mlir.constant(0 : i32) : i32 // CHECK: %[[OFFSET_V1:.*]] = llvm.insertelement %[[OFFSET]], %[[OFFSET_V0]][%[[ZERO]] : i32] : vector<2xi32> @@ -180,29 +180,29 @@ // CHECK: %[[SHIFTED_LEFT:.*]] = llvm.shl %[[BASE]], %[[T1]] : vector<2xi32> // CHECK: %[[T2:.*]] = llvm.add %[[OFFSET_V2]], %[[T1]] : vector<2xi32> // CHECK: llvm.ashr %[[SHIFTED_LEFT]], %[[T2]] : vector<2xi32> - %0 = spv.BitFieldSExtract %base, %offset, %count : vector<2xi32>, i32, i32 - spv.Return + %0 = spirv.BitFieldSExtract %base, %offset, %count : vector<2xi32>, i32, i32 + spirv.Return } //===----------------------------------------------------------------------===// -// spv.BitFieldUExtract +// spirv.BitFieldUExtract //===----------------------------------------------------------------------===// // CHECK-LABEL: @bitfield_uextract_scalar_same_bit_width // CHECK-SAME: %[[BASE:.*]]: i32, %[[OFFSET:.*]]: i32, %[[COUNT:.*]]: i32 -spv.func @bitfield_uextract_scalar_same_bit_width(%base: i32, %offset: i32, %count: i32) "None" { +spirv.func @bitfield_uextract_scalar_same_bit_width(%base: i32, %offset: i32, %count: i32) "None" { // CHECK: %[[MINUS_ONE:.*]] = llvm.mlir.constant(-1 : i32) : i32 // CHECK: %[[T0:.*]] = llvm.shl %[[MINUS_ONE]], %[[COUNT]] : i32 // CHECK: %[[MASK:.*]] = llvm.xor %[[T0]], %[[MINUS_ONE]] : i32 // CHECK: %[[SHIFTED_BASE:.*]] = llvm.lshr %[[BASE]], %[[OFFSET]] : i32 // CHECK: llvm.and %[[SHIFTED_BASE]], %[[MASK]] : i32 - %0 = spv.BitFieldUExtract %base, %offset, %count : i32, i32, i32 - spv.Return + %0 = spirv.BitFieldUExtract %base, %offset, %count : i32, i32, i32 + spirv.Return } // CHECK-LABEL: @bitfield_uextract_scalar_smaller_bit_width // CHECK-SAME: %[[BASE:.*]]: i32, %[[OFFSET:.*]]: i16, %[[COUNT:.*]]: i8 -spv.func @bitfield_uextract_scalar_smaller_bit_width(%base: i32, %offset: i16, %count: i8) "None" { +spirv.func @bitfield_uextract_scalar_smaller_bit_width(%base: i32, %offset: i16, %count: i8) "None" { // CHECK: %[[EXT_OFFSET:.*]] = llvm.zext %[[OFFSET]] : i16 to i32 // CHECK: %[[EXT_COUNT:.*]] = llvm.zext %[[COUNT]] : i8 to i32 // CHECK: %[[MINUS_ONE:.*]] = llvm.mlir.constant(-1 : i32) : i32 @@ -210,26 +210,26 @@ // CHECK: %[[MASK:.*]] = llvm.xor %[[T0]], %[[MINUS_ONE]] : i32 // CHECK: %[[SHIFTED_BASE:.*]] = llvm.lshr %[[BASE]], %[[EXT_OFFSET]] : i32 // CHECK: llvm.and %[[SHIFTED_BASE]], %[[MASK]] : i32 - %0 = spv.BitFieldUExtract %base, %offset, %count : i32, i16, i8 - spv.Return + %0 = spirv.BitFieldUExtract %base, %offset, %count : i32, i16, i8 + spirv.Return } // CHECK-LABEL: @bitfield_uextract_scalar_greater_bit_width // CHECK-SAME: %[[BASE:.*]]: i8, %[[OFFSET:.*]]: i16, %[[COUNT:.*]]: i8 -spv.func @bitfield_uextract_scalar_greater_bit_width(%base: i8, %offset: i16, %count: i8) "None" { +spirv.func @bitfield_uextract_scalar_greater_bit_width(%base: i8, %offset: i16, %count: i8) "None" { // CHECK: %[[TRUNC_OFFSET:.*]] = llvm.trunc %[[OFFSET]] : i16 to i8 // CHECK: %[[MINUS_ONE:.*]] = llvm.mlir.constant(-1 : i8) : i8 // CHECK: %[[T0:.*]] = llvm.shl %[[MINUS_ONE]], %[[COUNT]] : i8 // CHECK: %[[MASK:.*]] = llvm.xor %[[T0]], %[[MINUS_ONE]] : i8 // CHECK: %[[SHIFTED_BASE:.*]] = llvm.lshr %[[BASE]], %[[TRUNC_OFFSET]] : i8 // CHECK: llvm.and %[[SHIFTED_BASE]], %[[MASK]] : i8 - %0 = spv.BitFieldUExtract %base, %offset, %count : i8, i16, i8 - spv.Return + %0 = spirv.BitFieldUExtract %base, %offset, %count : i8, i16, i8 + spirv.Return } // CHECK-LABEL: @bitfield_uextract_vector // CHECK-SAME: %[[BASE:.*]]: vector<2xi32>, %[[OFFSET:.*]]: i32, %[[COUNT:.*]]: i32 -spv.func @bitfield_uextract_vector(%base: vector<2xi32>, %offset: i32, %count: i32) "None" { +spirv.func @bitfield_uextract_vector(%base: vector<2xi32>, %offset: i32, %count: i32) "None" { // CHECK: %[[OFFSET_V0:.*]] = llvm.mlir.undef : vector<2xi32> // CHECK: %[[ZERO:.*]] = llvm.mlir.constant(0 : i32) : i32 // CHECK: %[[OFFSET_V1:.*]] = llvm.insertelement %[[OFFSET]], %[[OFFSET_V0]][%[[ZERO]] : i32] : vector<2xi32> @@ -245,80 +245,80 @@ // CHECK: %[[MASK:.*]] = llvm.xor %[[T0]], %[[MINUS_ONE]] : vector<2xi32> // CHECK: %[[SHIFTED_BASE:.*]] = llvm.lshr %[[BASE]], %[[OFFSET_V2]] : vector<2xi32> // CHECK: llvm.and %[[SHIFTED_BASE]], %[[MASK]] : vector<2xi32> - %0 = spv.BitFieldUExtract %base, %offset, %count : vector<2xi32>, i32, i32 - spv.Return + %0 = spirv.BitFieldUExtract %base, %offset, %count : vector<2xi32>, i32, i32 + spirv.Return } //===----------------------------------------------------------------------===// -// spv.BitwiseAnd +// spirv.BitwiseAnd //===----------------------------------------------------------------------===// // CHECK-LABEL: @bitwise_and_scalar -spv.func @bitwise_and_scalar(%arg0: i32, %arg1: i32) "None" { +spirv.func @bitwise_and_scalar(%arg0: i32, %arg1: i32) "None" { // CHECK: llvm.and %{{.*}}, %{{.*}} : i32 - %0 = spv.BitwiseAnd %arg0, %arg1 : i32 - spv.Return + %0 = spirv.BitwiseAnd %arg0, %arg1 : i32 + spirv.Return } // CHECK-LABEL: @bitwise_and_vector -spv.func @bitwise_and_vector(%arg0: vector<4xi64>, %arg1: vector<4xi64>) "None" { +spirv.func @bitwise_and_vector(%arg0: vector<4xi64>, %arg1: vector<4xi64>) "None" { // CHECK: llvm.and %{{.*}}, %{{.*}} : vector<4xi64> - %0 = spv.BitwiseAnd %arg0, %arg1 : vector<4xi64> - spv.Return + %0 = spirv.BitwiseAnd %arg0, %arg1 : vector<4xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.BitwiseOr +// spirv.BitwiseOr //===----------------------------------------------------------------------===// // CHECK-LABEL: @bitwise_or_scalar -spv.func @bitwise_or_scalar(%arg0: i64, %arg1: i64) "None" { +spirv.func @bitwise_or_scalar(%arg0: i64, %arg1: i64) "None" { // CHECK: llvm.or %{{.*}}, %{{.*}} : i64 - %0 = spv.BitwiseOr %arg0, %arg1 : i64 - spv.Return + %0 = spirv.BitwiseOr %arg0, %arg1 : i64 + spirv.Return } // CHECK-LABEL: @bitwise_or_vector -spv.func @bitwise_or_vector(%arg0: vector<3xi8>, %arg1: vector<3xi8>) "None" { +spirv.func @bitwise_or_vector(%arg0: vector<3xi8>, %arg1: vector<3xi8>) "None" { // CHECK: llvm.or %{{.*}}, %{{.*}} : vector<3xi8> - %0 = spv.BitwiseOr %arg0, %arg1 : vector<3xi8> - spv.Return + %0 = spirv.BitwiseOr %arg0, %arg1 : vector<3xi8> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.BitwiseXor +// spirv.BitwiseXor //===----------------------------------------------------------------------===// // CHECK-LABEL: @bitwise_xor_scalar -spv.func @bitwise_xor_scalar(%arg0: i32, %arg1: i32) "None" { +spirv.func @bitwise_xor_scalar(%arg0: i32, %arg1: i32) "None" { // CHECK: llvm.xor %{{.*}}, %{{.*}} : i32 - %0 = spv.BitwiseXor %arg0, %arg1 : i32 - spv.Return + %0 = spirv.BitwiseXor %arg0, %arg1 : i32 + spirv.Return } // CHECK-LABEL: @bitwise_xor_vector -spv.func @bitwise_xor_vector(%arg0: vector<2xi16>, %arg1: vector<2xi16>) "None" { +spirv.func @bitwise_xor_vector(%arg0: vector<2xi16>, %arg1: vector<2xi16>) "None" { // CHECK: llvm.xor %{{.*}}, %{{.*}} : vector<2xi16> - %0 = spv.BitwiseXor %arg0, %arg1 : vector<2xi16> - spv.Return + %0 = spirv.BitwiseXor %arg0, %arg1 : vector<2xi16> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.Not +// spirv.Not //===----------------------------------------------------------------------===// // CHECK-LABEL: @not_scalar -spv.func @not_scalar(%arg0: i32) "None" { +spirv.func @not_scalar(%arg0: i32) "None" { // CHECK: %[[CONST:.*]] = llvm.mlir.constant(-1 : i32) : i32 // CHECK: llvm.xor %{{.*}}, %[[CONST]] : i32 - %0 = spv.Not %arg0 : i32 - spv.Return + %0 = spirv.Not %arg0 : i32 + spirv.Return } // CHECK-LABEL: @not_vector -spv.func @not_vector(%arg0: vector<2xi16>) "None" { +spirv.func @not_vector(%arg0: vector<2xi16>) "None" { // CHECK: %[[CONST:.*]] = llvm.mlir.constant(dense<-1> : vector<2xi16>) : vector<2xi16> // CHECK: llvm.xor %{{.*}}, %[[CONST]] : vector<2xi16> - %0 = spv.Not %arg0 : vector<2xi16> - spv.Return + %0 = spirv.Not %arg0 : vector<2xi16> + spirv.Return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/cast-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/cast-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/cast-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/cast-ops-to-llvm.mlir @@ -1,191 +1,191 @@ // RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.Bitcast +// spirv.Bitcast //===----------------------------------------------------------------------===// // CHECK-LABEL: @bitcast_float_to_integer_scalar -spv.func @bitcast_float_to_integer_scalar(%arg0 : f32) "None" { +spirv.func @bitcast_float_to_integer_scalar(%arg0 : f32) "None" { // CHECK: llvm.bitcast {{.*}} : f32 to i32 - %0 = spv.Bitcast %arg0: f32 to i32 - spv.Return + %0 = spirv.Bitcast %arg0: f32 to i32 + spirv.Return } // CHECK-LABEL: @bitcast_float_to_integer_vector -spv.func @bitcast_float_to_integer_vector(%arg0 : vector<3xf32>) "None" { +spirv.func @bitcast_float_to_integer_vector(%arg0 : vector<3xf32>) "None" { // CHECK: {{.*}} = llvm.bitcast {{.*}} : vector<3xf32> to vector<3xi32> - %0 = spv.Bitcast %arg0: vector<3xf32> to vector<3xi32> - spv.Return + %0 = spirv.Bitcast %arg0: vector<3xf32> to vector<3xi32> + spirv.Return } // CHECK-LABEL: @bitcast_vector_to_scalar -spv.func @bitcast_vector_to_scalar(%arg0 : vector<2xf32>) "None" { +spirv.func @bitcast_vector_to_scalar(%arg0 : vector<2xf32>) "None" { // CHECK: {{.*}} = llvm.bitcast {{.*}} : vector<2xf32> to i64 - %0 = spv.Bitcast %arg0: vector<2xf32> to i64 - spv.Return + %0 = spirv.Bitcast %arg0: vector<2xf32> to i64 + spirv.Return } // CHECK-LABEL: @bitcast_scalar_to_vector -spv.func @bitcast_scalar_to_vector(%arg0 : f64) "None" { +spirv.func @bitcast_scalar_to_vector(%arg0 : f64) "None" { // CHECK: {{.*}} = llvm.bitcast {{.*}} : f64 to vector<2xi32> - %0 = spv.Bitcast %arg0: f64 to vector<2xi32> - spv.Return + %0 = spirv.Bitcast %arg0: f64 to vector<2xi32> + spirv.Return } // CHECK-LABEL: @bitcast_vector_to_vector -spv.func @bitcast_vector_to_vector(%arg0 : vector<4xf32>) "None" { +spirv.func @bitcast_vector_to_vector(%arg0 : vector<4xf32>) "None" { // CHECK: {{.*}} = llvm.bitcast {{.*}} : vector<4xf32> to vector<2xi64> - %0 = spv.Bitcast %arg0: vector<4xf32> to vector<2xi64> - spv.Return + %0 = spirv.Bitcast %arg0: vector<4xf32> to vector<2xi64> + spirv.Return } // CHECK-LABEL: @bitcast_pointer -spv.func @bitcast_pointer(%arg0: !spv.ptr) "None" { +spirv.func @bitcast_pointer(%arg0: !spirv.ptr) "None" { // CHECK: llvm.bitcast %{{.*}} : !llvm.ptr to !llvm.ptr - %0 = spv.Bitcast %arg0 : !spv.ptr to !spv.ptr - spv.Return + %0 = spirv.Bitcast %arg0 : !spirv.ptr to !spirv.ptr + spirv.Return } //===----------------------------------------------------------------------===// -// spv.ConvertFToS +// spirv.ConvertFToS //===----------------------------------------------------------------------===// // CHECK-LABEL: @convert_float_to_signed_scalar -spv.func @convert_float_to_signed_scalar(%arg0: f32) "None" { +spirv.func @convert_float_to_signed_scalar(%arg0: f32) "None" { // CHECK: llvm.fptosi %{{.*}} : f32 to i32 - %0 = spv.ConvertFToS %arg0: f32 to i32 - spv.Return + %0 = spirv.ConvertFToS %arg0: f32 to i32 + spirv.Return } // CHECK-LABEL: @convert_float_to_signed_vector -spv.func @convert_float_to_signed_vector(%arg0: vector<2xf32>) "None" { +spirv.func @convert_float_to_signed_vector(%arg0: vector<2xf32>) "None" { // CHECK: llvm.fptosi %{{.*}} : vector<2xf32> to vector<2xi32> - %0 = spv.ConvertFToS %arg0: vector<2xf32> to vector<2xi32> - spv.Return + %0 = spirv.ConvertFToS %arg0: vector<2xf32> to vector<2xi32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.ConvertFToU +// spirv.ConvertFToU //===----------------------------------------------------------------------===// // CHECK-LABEL: @convert_float_to_unsigned_scalar -spv.func @convert_float_to_unsigned_scalar(%arg0: f32) "None" { +spirv.func @convert_float_to_unsigned_scalar(%arg0: f32) "None" { // CHECK: llvm.fptoui %{{.*}} : f32 to i32 - %0 = spv.ConvertFToU %arg0: f32 to i32 - spv.Return + %0 = spirv.ConvertFToU %arg0: f32 to i32 + spirv.Return } // CHECK-LABEL: @convert_float_to_unsigned_vector -spv.func @convert_float_to_unsigned_vector(%arg0: vector<2xf32>) "None" { +spirv.func @convert_float_to_unsigned_vector(%arg0: vector<2xf32>) "None" { // CHECK: llvm.fptoui %{{.*}} : vector<2xf32> to vector<2xi32> - %0 = spv.ConvertFToU %arg0: vector<2xf32> to vector<2xi32> - spv.Return + %0 = spirv.ConvertFToU %arg0: vector<2xf32> to vector<2xi32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.ConvertSToF +// spirv.ConvertSToF //===----------------------------------------------------------------------===// // CHECK-LABEL: @convert_signed_to_float_scalar -spv.func @convert_signed_to_float_scalar(%arg0: i32) "None" { +spirv.func @convert_signed_to_float_scalar(%arg0: i32) "None" { // CHECK: llvm.sitofp %{{.*}} : i32 to f32 - %0 = spv.ConvertSToF %arg0: i32 to f32 - spv.Return + %0 = spirv.ConvertSToF %arg0: i32 to f32 + spirv.Return } // CHECK-LABEL: @convert_signed_to_float_vector -spv.func @convert_signed_to_float_vector(%arg0: vector<3xi32>) "None" { +spirv.func @convert_signed_to_float_vector(%arg0: vector<3xi32>) "None" { // CHECK: llvm.sitofp %{{.*}} : vector<3xi32> to vector<3xf32> - %0 = spv.ConvertSToF %arg0: vector<3xi32> to vector<3xf32> - spv.Return + %0 = spirv.ConvertSToF %arg0: vector<3xi32> to vector<3xf32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.ConvertUToF +// spirv.ConvertUToF //===----------------------------------------------------------------------===// // CHECK-LABEL: @convert_unsigned_to_float_scalar -spv.func @convert_unsigned_to_float_scalar(%arg0: i32) "None" { +spirv.func @convert_unsigned_to_float_scalar(%arg0: i32) "None" { // CHECK: llvm.uitofp %{{.*}} : i32 to f32 - %0 = spv.ConvertUToF %arg0: i32 to f32 - spv.Return + %0 = spirv.ConvertUToF %arg0: i32 to f32 + spirv.Return } // CHECK-LABEL: @convert_unsigned_to_float_vector -spv.func @convert_unsigned_to_float_vector(%arg0: vector<3xi32>) "None" { +spirv.func @convert_unsigned_to_float_vector(%arg0: vector<3xi32>) "None" { // CHECK: llvm.uitofp %{{.*}} : vector<3xi32> to vector<3xf32> - %0 = spv.ConvertUToF %arg0: vector<3xi32> to vector<3xf32> - spv.Return + %0 = spirv.ConvertUToF %arg0: vector<3xi32> to vector<3xf32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FConvert +// spirv.FConvert //===----------------------------------------------------------------------===// // CHECK-LABEL: @fconvert_scalar -spv.func @fconvert_scalar(%arg0: f32, %arg1: f64) "None" { +spirv.func @fconvert_scalar(%arg0: f32, %arg1: f64) "None" { // CHECK: llvm.fpext %{{.*}} : f32 to f64 - %0 = spv.FConvert %arg0: f32 to f64 + %0 = spirv.FConvert %arg0: f32 to f64 // CHECK: llvm.fptrunc %{{.*}} : f64 to f32 - %1 = spv.FConvert %arg1: f64 to f32 - spv.Return + %1 = spirv.FConvert %arg1: f64 to f32 + spirv.Return } // CHECK-LABEL: @fconvert_vector -spv.func @fconvert_vector(%arg0: vector<2xf32>, %arg1: vector<2xf64>) "None" { +spirv.func @fconvert_vector(%arg0: vector<2xf32>, %arg1: vector<2xf64>) "None" { // CHECK: llvm.fpext %{{.*}} : vector<2xf32> to vector<2xf64> - %0 = spv.FConvert %arg0: vector<2xf32> to vector<2xf64> + %0 = spirv.FConvert %arg0: vector<2xf32> to vector<2xf64> // CHECK: llvm.fptrunc %{{.*}} : vector<2xf64> to vector<2xf32> - %1 = spv.FConvert %arg1: vector<2xf64> to vector<2xf32> - spv.Return + %1 = spirv.FConvert %arg1: vector<2xf64> to vector<2xf32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.SConvert +// spirv.SConvert //===----------------------------------------------------------------------===// // CHECK-LABEL: @sconvert_scalar -spv.func @sconvert_scalar(%arg0: i32, %arg1: i64) "None" { +spirv.func @sconvert_scalar(%arg0: i32, %arg1: i64) "None" { // CHECK: llvm.sext %{{.*}} : i32 to i64 - %0 = spv.SConvert %arg0: i32 to i64 + %0 = spirv.SConvert %arg0: i32 to i64 // CHECK: llvm.trunc %{{.*}} : i64 to i32 - %1 = spv.SConvert %arg1: i64 to i32 - spv.Return + %1 = spirv.SConvert %arg1: i64 to i32 + spirv.Return } // CHECK-LABEL: @sconvert_vector -spv.func @sconvert_vector(%arg0: vector<3xi32>, %arg1: vector<3xi64>) "None" { +spirv.func @sconvert_vector(%arg0: vector<3xi32>, %arg1: vector<3xi64>) "None" { // CHECK: llvm.sext %{{.*}} : vector<3xi32> to vector<3xi64> - %0 = spv.SConvert %arg0: vector<3xi32> to vector<3xi64> + %0 = spirv.SConvert %arg0: vector<3xi32> to vector<3xi64> // CHECK: llvm.trunc %{{.*}} : vector<3xi64> to vector<3xi32> - %1 = spv.SConvert %arg1: vector<3xi64> to vector<3xi32> - spv.Return + %1 = spirv.SConvert %arg1: vector<3xi64> to vector<3xi32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.UConvert +// spirv.UConvert //===----------------------------------------------------------------------===// // CHECK-LABEL: @uconvert_scalar -spv.func @uconvert_scalar(%arg0: i32, %arg1: i64) "None" { +spirv.func @uconvert_scalar(%arg0: i32, %arg1: i64) "None" { // CHECK: llvm.zext %{{.*}} : i32 to i64 - %0 = spv.UConvert %arg0: i32 to i64 + %0 = spirv.UConvert %arg0: i32 to i64 // CHECK: llvm.trunc %{{.*}} : i64 to i32 - %1 = spv.UConvert %arg1: i64 to i32 - spv.Return + %1 = spirv.UConvert %arg1: i64 to i32 + spirv.Return } // CHECK-LABEL: @uconvert_vector -spv.func @uconvert_vector(%arg0: vector<3xi32>, %arg1: vector<3xi64>) "None" { +spirv.func @uconvert_vector(%arg0: vector<3xi32>, %arg1: vector<3xi64>) "None" { // CHECK: llvm.zext %{{.*}} : vector<3xi32> to vector<3xi64> - %0 = spv.UConvert %arg0: vector<3xi32> to vector<3xi64> + %0 = spirv.UConvert %arg0: vector<3xi32> to vector<3xi64> // CHECK: llvm.trunc %{{.*}} : vector<3xi64> to vector<3xi32> - %1 = spv.UConvert %arg1: vector<3xi64> to vector<3xi32> - spv.Return + %1 = spirv.UConvert %arg1: vector<3xi64> to vector<3xi32> + spirv.Return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/comparison-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/comparison-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/comparison-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/comparison-ops-to-llvm.mlir @@ -1,397 +1,397 @@ // RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.IEqual +// spirv.IEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @i_equal_scalar -spv.func @i_equal_scalar(%arg0: i32, %arg1: i32) "None" { +spirv.func @i_equal_scalar(%arg0: i32, %arg1: i32) "None" { // CHECK: llvm.icmp "eq" %{{.*}}, %{{.*}} : i32 - %0 = spv.IEqual %arg0, %arg1 : i32 - spv.Return + %0 = spirv.IEqual %arg0, %arg1 : i32 + spirv.Return } // CHECK-LABEL: @i_equal_vector -spv.func @i_equal_vector(%arg0: vector<4xi64>, %arg1: vector<4xi64>) "None" { +spirv.func @i_equal_vector(%arg0: vector<4xi64>, %arg1: vector<4xi64>) "None" { // CHECK: llvm.icmp "eq" %{{.*}}, %{{.*}} : vector<4xi64> - %0 = spv.IEqual %arg0, %arg1 : vector<4xi64> - spv.Return + %0 = spirv.IEqual %arg0, %arg1 : vector<4xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.INotEqual +// spirv.INotEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @i_not_equal_scalar -spv.func @i_not_equal_scalar(%arg0: i64, %arg1: i64) "None" { +spirv.func @i_not_equal_scalar(%arg0: i64, %arg1: i64) "None" { // CHECK: llvm.icmp "ne" %{{.*}}, %{{.*}} : i64 - %0 = spv.INotEqual %arg0, %arg1 : i64 - spv.Return + %0 = spirv.INotEqual %arg0, %arg1 : i64 + spirv.Return } // CHECK-LABEL: @i_not_equal_vector -spv.func @i_not_equal_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { +spirv.func @i_not_equal_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { // CHECK: llvm.icmp "ne" %{{.*}}, %{{.*}} : vector<2xi64> - %0 = spv.INotEqual %arg0, %arg1 : vector<2xi64> - spv.Return + %0 = spirv.INotEqual %arg0, %arg1 : vector<2xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.SGreaterThanEqual +// spirv.SGreaterThanEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @s_greater_than_equal_scalar -spv.func @s_greater_than_equal_scalar(%arg0: i64, %arg1: i64) "None" { +spirv.func @s_greater_than_equal_scalar(%arg0: i64, %arg1: i64) "None" { // CHECK: llvm.icmp "sge" %{{.*}}, %{{.*}} : i64 - %0 = spv.SGreaterThanEqual %arg0, %arg1 : i64 - spv.Return + %0 = spirv.SGreaterThanEqual %arg0, %arg1 : i64 + spirv.Return } // CHECK-LABEL: @s_greater_than_equal_vector -spv.func @s_greater_than_equal_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { +spirv.func @s_greater_than_equal_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { // CHECK: llvm.icmp "sge" %{{.*}}, %{{.*}} : vector<2xi64> - %0 = spv.SGreaterThanEqual %arg0, %arg1 : vector<2xi64> - spv.Return + %0 = spirv.SGreaterThanEqual %arg0, %arg1 : vector<2xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.SGreaterThan +// spirv.SGreaterThan //===----------------------------------------------------------------------===// // CHECK-LABEL: @s_greater_than_scalar -spv.func @s_greater_than_scalar(%arg0: i64, %arg1: i64) "None" { +spirv.func @s_greater_than_scalar(%arg0: i64, %arg1: i64) "None" { // CHECK: llvm.icmp "sgt" %{{.*}}, %{{.*}} : i64 - %0 = spv.SGreaterThan %arg0, %arg1 : i64 - spv.Return + %0 = spirv.SGreaterThan %arg0, %arg1 : i64 + spirv.Return } // CHECK-LABEL: @s_greater_than_vector -spv.func @s_greater_than_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { +spirv.func @s_greater_than_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { // CHECK: llvm.icmp "sgt" %{{.*}}, %{{.*}} : vector<2xi64> - %0 = spv.SGreaterThan %arg0, %arg1 : vector<2xi64> - spv.Return + %0 = spirv.SGreaterThan %arg0, %arg1 : vector<2xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.SLessThanEqual +// spirv.SLessThanEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @s_less_than_equal_scalar -spv.func @s_less_than_equal_scalar(%arg0: i64, %arg1: i64) "None" { +spirv.func @s_less_than_equal_scalar(%arg0: i64, %arg1: i64) "None" { // CHECK: llvm.icmp "sle" %{{.*}}, %{{.*}} : i64 - %0 = spv.SLessThanEqual %arg0, %arg1 : i64 - spv.Return + %0 = spirv.SLessThanEqual %arg0, %arg1 : i64 + spirv.Return } // CHECK-LABEL: @s_less_than_equal_vector -spv.func @s_less_than_equal_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { +spirv.func @s_less_than_equal_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { // CHECK: llvm.icmp "sle" %{{.*}}, %{{.*}} : vector<2xi64> - %0 = spv.SLessThanEqual %arg0, %arg1 : vector<2xi64> - spv.Return + %0 = spirv.SLessThanEqual %arg0, %arg1 : vector<2xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.SLessThan +// spirv.SLessThan //===----------------------------------------------------------------------===// // CHECK-LABEL: @s_less_than_scalar -spv.func @s_less_than_scalar(%arg0: i64, %arg1: i64) "None" { +spirv.func @s_less_than_scalar(%arg0: i64, %arg1: i64) "None" { // CHECK: llvm.icmp "slt" %{{.*}}, %{{.*}} : i64 - %0 = spv.SLessThan %arg0, %arg1 : i64 - spv.Return + %0 = spirv.SLessThan %arg0, %arg1 : i64 + spirv.Return } // CHECK-LABEL: @s_less_than_vector -spv.func @s_less_than_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { +spirv.func @s_less_than_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { // CHECK: llvm.icmp "slt" %{{.*}}, %{{.*}} : vector<2xi64> - %0 = spv.SLessThan %arg0, %arg1 : vector<2xi64> - spv.Return + %0 = spirv.SLessThan %arg0, %arg1 : vector<2xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.UGreaterThanEqual +// spirv.UGreaterThanEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @u_greater_than_equal_scalar -spv.func @u_greater_than_equal_scalar(%arg0: i64, %arg1: i64) "None" { +spirv.func @u_greater_than_equal_scalar(%arg0: i64, %arg1: i64) "None" { // CHECK: llvm.icmp "uge" %{{.*}}, %{{.*}} : i64 - %0 = spv.UGreaterThanEqual %arg0, %arg1 : i64 - spv.Return + %0 = spirv.UGreaterThanEqual %arg0, %arg1 : i64 + spirv.Return } // CHECK-LABEL: @u_greater_than_equal_vector -spv.func @u_greater_than_equal_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { +spirv.func @u_greater_than_equal_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { // CHECK: llvm.icmp "uge" %{{.*}}, %{{.*}} : vector<2xi64> - %0 = spv.UGreaterThanEqual %arg0, %arg1 : vector<2xi64> - spv.Return + %0 = spirv.UGreaterThanEqual %arg0, %arg1 : vector<2xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.UGreaterThan +// spirv.UGreaterThan //===----------------------------------------------------------------------===// // CHECK-LABEL: @u_greater_than_scalar -spv.func @u_greater_than_scalar(%arg0: i64, %arg1: i64) "None" { +spirv.func @u_greater_than_scalar(%arg0: i64, %arg1: i64) "None" { // CHECK: llvm.icmp "ugt" %{{.*}}, %{{.*}} : i64 - %0 = spv.UGreaterThan %arg0, %arg1 : i64 - spv.Return + %0 = spirv.UGreaterThan %arg0, %arg1 : i64 + spirv.Return } // CHECK-LABEL: @u_greater_than_vector -spv.func @u_greater_than_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { +spirv.func @u_greater_than_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { // CHECK: llvm.icmp "ugt" %{{.*}}, %{{.*}} : vector<2xi64> - %0 = spv.UGreaterThan %arg0, %arg1 : vector<2xi64> - spv.Return + %0 = spirv.UGreaterThan %arg0, %arg1 : vector<2xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.ULessThanEqual +// spirv.ULessThanEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @u_less_than_equal_scalar -spv.func @u_less_than_equal_scalar(%arg0: i64, %arg1: i64) "None" { +spirv.func @u_less_than_equal_scalar(%arg0: i64, %arg1: i64) "None" { // CHECK: llvm.icmp "ule" %{{.*}}, %{{.*}} : i64 - %0 = spv.ULessThanEqual %arg0, %arg1 : i64 - spv.Return + %0 = spirv.ULessThanEqual %arg0, %arg1 : i64 + spirv.Return } // CHECK-LABEL: @u_less_than_equal_vector -spv.func @u_less_than_equal_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { +spirv.func @u_less_than_equal_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { // CHECK: llvm.icmp "ule" %{{.*}}, %{{.*}} : vector<2xi64> - %0 = spv.ULessThanEqual %arg0, %arg1 : vector<2xi64> - spv.Return + %0 = spirv.ULessThanEqual %arg0, %arg1 : vector<2xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.ULessThan +// spirv.ULessThan //===----------------------------------------------------------------------===// // CHECK-LABEL: @u_less_than_scalar -spv.func @u_less_than_scalar(%arg0: i64, %arg1: i64) "None" { +spirv.func @u_less_than_scalar(%arg0: i64, %arg1: i64) "None" { // CHECK: llvm.icmp "ult" %{{.*}}, %{{.*}} : i64 - %0 = spv.ULessThan %arg0, %arg1 : i64 - spv.Return + %0 = spirv.ULessThan %arg0, %arg1 : i64 + spirv.Return } // CHECK-LABEL: @u_less_than_vector -spv.func @u_less_than_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { +spirv.func @u_less_than_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { // CHECK: llvm.icmp "ult" %{{.*}}, %{{.*}} : vector<2xi64> - %0 = spv.ULessThan %arg0, %arg1 : vector<2xi64> - spv.Return + %0 = spirv.ULessThan %arg0, %arg1 : vector<2xi64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FOrdEqual +// spirv.FOrdEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @f_ord_equal_scalar -spv.func @f_ord_equal_scalar(%arg0: f32, %arg1: f32) "None" { +spirv.func @f_ord_equal_scalar(%arg0: f32, %arg1: f32) "None" { // CHECK: llvm.fcmp "oeq" %{{.*}}, %{{.*}} : f32 - %0 = spv.FOrdEqual %arg0, %arg1 : f32 - spv.Return + %0 = spirv.FOrdEqual %arg0, %arg1 : f32 + spirv.Return } // CHECK-LABEL: @f_ord_equal_vector -spv.func @f_ord_equal_vector(%arg0: vector<4xf64>, %arg1: vector<4xf64>) "None" { +spirv.func @f_ord_equal_vector(%arg0: vector<4xf64>, %arg1: vector<4xf64>) "None" { // CHECK: llvm.fcmp "oeq" %{{.*}}, %{{.*}} : vector<4xf64> - %0 = spv.FOrdEqual %arg0, %arg1 : vector<4xf64> - spv.Return + %0 = spirv.FOrdEqual %arg0, %arg1 : vector<4xf64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FOrdGreaterThanEqual +// spirv.FOrdGreaterThanEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @f_ord_greater_than_equal_scalar -spv.func @f_ord_greater_than_equal_scalar(%arg0: f64, %arg1: f64) "None" { +spirv.func @f_ord_greater_than_equal_scalar(%arg0: f64, %arg1: f64) "None" { // CHECK: llvm.fcmp "oge" %{{.*}}, %{{.*}} : f64 - %0 = spv.FOrdGreaterThanEqual %arg0, %arg1 : f64 - spv.Return + %0 = spirv.FOrdGreaterThanEqual %arg0, %arg1 : f64 + spirv.Return } // CHECK-LABEL: @f_ord_greater_than_equal_vector -spv.func @f_ord_greater_than_equal_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { +spirv.func @f_ord_greater_than_equal_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { // CHECK: llvm.fcmp "oge" %{{.*}}, %{{.*}} : vector<2xf64> - %0 = spv.FOrdGreaterThanEqual %arg0, %arg1 : vector<2xf64> - spv.Return + %0 = spirv.FOrdGreaterThanEqual %arg0, %arg1 : vector<2xf64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FOrdGreaterThan +// spirv.FOrdGreaterThan //===----------------------------------------------------------------------===// // CHECK-LABEL: @f_ord_greater_than_scalar -spv.func @f_ord_greater_than_scalar(%arg0: f64, %arg1: f64) "None" { +spirv.func @f_ord_greater_than_scalar(%arg0: f64, %arg1: f64) "None" { // CHECK: llvm.fcmp "ogt" %{{.*}}, %{{.*}} : f64 - %0 = spv.FOrdGreaterThan %arg0, %arg1 : f64 - spv.Return + %0 = spirv.FOrdGreaterThan %arg0, %arg1 : f64 + spirv.Return } // CHECK-LABEL: @f_ord_greater_than_vector -spv.func @f_ord_greater_than_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { +spirv.func @f_ord_greater_than_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { // CHECK: llvm.fcmp "ogt" %{{.*}}, %{{.*}} : vector<2xf64> - %0 = spv.FOrdGreaterThan %arg0, %arg1 : vector<2xf64> - spv.Return + %0 = spirv.FOrdGreaterThan %arg0, %arg1 : vector<2xf64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FOrdLessThan +// spirv.FOrdLessThan //===----------------------------------------------------------------------===// // CHECK-LABEL: @f_ord_less_than_scalar -spv.func @f_ord_less_than_scalar(%arg0: f64, %arg1: f64) "None" { +spirv.func @f_ord_less_than_scalar(%arg0: f64, %arg1: f64) "None" { // CHECK: llvm.fcmp "olt" %{{.*}}, %{{.*}} : f64 - %0 = spv.FOrdLessThan %arg0, %arg1 : f64 - spv.Return + %0 = spirv.FOrdLessThan %arg0, %arg1 : f64 + spirv.Return } // CHECK-LABEL: @f_ord_less_than_vector -spv.func @f_ord_less_than_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { +spirv.func @f_ord_less_than_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { // CHECK: llvm.fcmp "olt" %{{.*}}, %{{.*}} : vector<2xf64> - %0 = spv.FOrdLessThan %arg0, %arg1 : vector<2xf64> - spv.Return + %0 = spirv.FOrdLessThan %arg0, %arg1 : vector<2xf64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FOrdLessThanEqual +// spirv.FOrdLessThanEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @f_ord_less_than_equal_scalar -spv.func @f_ord_less_than_equal_scalar(%arg0: f64, %arg1: f64) "None" { +spirv.func @f_ord_less_than_equal_scalar(%arg0: f64, %arg1: f64) "None" { // CHECK: llvm.fcmp "ole" %{{.*}}, %{{.*}} : f64 - %0 = spv.FOrdLessThanEqual %arg0, %arg1 : f64 - spv.Return + %0 = spirv.FOrdLessThanEqual %arg0, %arg1 : f64 + spirv.Return } // CHECK-LABEL: @f_ord_less_than_equal_vector -spv.func @f_ord_less_than_equal_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { +spirv.func @f_ord_less_than_equal_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { // CHECK: llvm.fcmp "ole" %{{.*}}, %{{.*}} : vector<2xf64> - %0 = spv.FOrdLessThanEqual %arg0, %arg1 : vector<2xf64> - spv.Return + %0 = spirv.FOrdLessThanEqual %arg0, %arg1 : vector<2xf64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FOrdNotEqual +// spirv.FOrdNotEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @f_ord_not_equal_scalar -spv.func @f_ord_not_equal_scalar(%arg0: f32, %arg1: f32) "None" { +spirv.func @f_ord_not_equal_scalar(%arg0: f32, %arg1: f32) "None" { // CHECK: llvm.fcmp "one" %{{.*}}, %{{.*}} : f32 - %0 = spv.FOrdNotEqual %arg0, %arg1 : f32 - spv.Return + %0 = spirv.FOrdNotEqual %arg0, %arg1 : f32 + spirv.Return } // CHECK-LABEL: @f_ord_not_equal_vector -spv.func @f_ord_not_equal_vector(%arg0: vector<4xf64>, %arg1: vector<4xf64>) "None" { +spirv.func @f_ord_not_equal_vector(%arg0: vector<4xf64>, %arg1: vector<4xf64>) "None" { // CHECK: llvm.fcmp "one" %{{.*}}, %{{.*}} : vector<4xf64> - %0 = spv.FOrdNotEqual %arg0, %arg1 : vector<4xf64> - spv.Return + %0 = spirv.FOrdNotEqual %arg0, %arg1 : vector<4xf64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FUnordEqual +// spirv.FUnordEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @f_unord_equal_scalar -spv.func @f_unord_equal_scalar(%arg0: f32, %arg1: f32) "None" { +spirv.func @f_unord_equal_scalar(%arg0: f32, %arg1: f32) "None" { // CHECK: llvm.fcmp "ueq" %{{.*}}, %{{.*}} : f32 - %0 = spv.FUnordEqual %arg0, %arg1 : f32 - spv.Return + %0 = spirv.FUnordEqual %arg0, %arg1 : f32 + spirv.Return } // CHECK-LABEL: @f_unord_equal_vector -spv.func @f_unord_equal_vector(%arg0: vector<4xf64>, %arg1: vector<4xf64>) "None" { +spirv.func @f_unord_equal_vector(%arg0: vector<4xf64>, %arg1: vector<4xf64>) "None" { // CHECK: llvm.fcmp "ueq" %{{.*}}, %{{.*}} : vector<4xf64> - %0 = spv.FUnordEqual %arg0, %arg1 : vector<4xf64> - spv.Return + %0 = spirv.FUnordEqual %arg0, %arg1 : vector<4xf64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FUnordGreaterThanEqual +// spirv.FUnordGreaterThanEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @f_unord_greater_than_equal_scalar -spv.func @f_unord_greater_than_equal_scalar(%arg0: f64, %arg1: f64) "None" { +spirv.func @f_unord_greater_than_equal_scalar(%arg0: f64, %arg1: f64) "None" { // CHECK: llvm.fcmp "uge" %{{.*}}, %{{.*}} : f64 - %0 = spv.FUnordGreaterThanEqual %arg0, %arg1 : f64 - spv.Return + %0 = spirv.FUnordGreaterThanEqual %arg0, %arg1 : f64 + spirv.Return } // CHECK-LABEL: @f_unord_greater_than_equal_vector -spv.func @f_unord_greater_than_equal_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { +spirv.func @f_unord_greater_than_equal_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { // CHECK: llvm.fcmp "uge" %{{.*}}, %{{.*}} : vector<2xf64> - %0 = spv.FUnordGreaterThanEqual %arg0, %arg1 : vector<2xf64> - spv.Return + %0 = spirv.FUnordGreaterThanEqual %arg0, %arg1 : vector<2xf64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FUnordGreaterThan +// spirv.FUnordGreaterThan //===----------------------------------------------------------------------===// // CHECK-LABEL: @f_unord_greater_than_scalar -spv.func @f_unord_greater_than_scalar(%arg0: f64, %arg1: f64) "None" { +spirv.func @f_unord_greater_than_scalar(%arg0: f64, %arg1: f64) "None" { // CHECK: llvm.fcmp "ugt" %{{.*}}, %{{.*}} : f64 - %0 = spv.FUnordGreaterThan %arg0, %arg1 : f64 - spv.Return + %0 = spirv.FUnordGreaterThan %arg0, %arg1 : f64 + spirv.Return } // CHECK-LABEL: @f_unord_greater_than_vector -spv.func @f_unord_greater_than_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { +spirv.func @f_unord_greater_than_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { // CHECK: llvm.fcmp "ugt" %{{.*}}, %{{.*}} : vector<2xf64> - %0 = spv.FUnordGreaterThan %arg0, %arg1 : vector<2xf64> - spv.Return + %0 = spirv.FUnordGreaterThan %arg0, %arg1 : vector<2xf64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FUnordLessThan +// spirv.FUnordLessThan //===----------------------------------------------------------------------===// // CHECK-LABEL: @f_unord_less_than_scalar -spv.func @f_unord_less_than_scalar(%arg0: f64, %arg1: f64) "None" { +spirv.func @f_unord_less_than_scalar(%arg0: f64, %arg1: f64) "None" { // CHECK: llvm.fcmp "ult" %{{.*}}, %{{.*}} : f64 - %0 = spv.FUnordLessThan %arg0, %arg1 : f64 - spv.Return + %0 = spirv.FUnordLessThan %arg0, %arg1 : f64 + spirv.Return } // CHECK-LABEL: @f_unord_less_than_vector -spv.func @f_unord_less_than_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { +spirv.func @f_unord_less_than_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { // CHECK: llvm.fcmp "ult" %{{.*}}, %{{.*}} : vector<2xf64> - %0 = spv.FUnordLessThan %arg0, %arg1 : vector<2xf64> - spv.Return + %0 = spirv.FUnordLessThan %arg0, %arg1 : vector<2xf64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FUnordLessThanEqual +// spirv.FUnordLessThanEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @f_unord_less_than_equal_scalar -spv.func @f_unord_less_than_equal_scalar(%arg0: f64, %arg1: f64) "None" { +spirv.func @f_unord_less_than_equal_scalar(%arg0: f64, %arg1: f64) "None" { // CHECK: llvm.fcmp "ule" %{{.*}}, %{{.*}} : f64 - %0 = spv.FUnordLessThanEqual %arg0, %arg1 : f64 - spv.Return + %0 = spirv.FUnordLessThanEqual %arg0, %arg1 : f64 + spirv.Return } // CHECK-LABEL: @f_unord_less_than_equal_vector -spv.func @f_unord_less_than_equal_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { +spirv.func @f_unord_less_than_equal_vector(%arg0: vector<2xf64>, %arg1: vector<2xf64>) "None" { // CHECK: llvm.fcmp "ule" %{{.*}}, %{{.*}} : vector<2xf64> - %0 = spv.FUnordLessThanEqual %arg0, %arg1 : vector<2xf64> - spv.Return + %0 = spirv.FUnordLessThanEqual %arg0, %arg1 : vector<2xf64> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.FUnordNotEqual +// spirv.FUnordNotEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @f_unord_not_equal_scalar -spv.func @f_unord_not_equal_scalar(%arg0: f32, %arg1: f32) "None" { +spirv.func @f_unord_not_equal_scalar(%arg0: f32, %arg1: f32) "None" { // CHECK: llvm.fcmp "une" %{{.*}}, %{{.*}} : f32 - %0 = spv.FUnordNotEqual %arg0, %arg1 : f32 - spv.Return + %0 = spirv.FUnordNotEqual %arg0, %arg1 : f32 + spirv.Return } // CHECK-LABEL: @f_unord_not_equal_vector -spv.func @f_unord_not_equal_vector(%arg0: vector<4xf64>, %arg1: vector<4xf64>) "None" { +spirv.func @f_unord_not_equal_vector(%arg0: vector<4xf64>, %arg1: vector<4xf64>) "None" { // CHECK: llvm.fcmp "une" %{{.*}}, %{{.*}} : vector<4xf64> - %0 = spv.FUnordNotEqual %arg0, %arg1 : vector<4xf64> - spv.Return + %0 = spirv.FUnordNotEqual %arg0, %arg1 : vector<4xf64> + spirv.Return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/constant-op-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/constant-op-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/constant-op-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/constant-op-to-llvm.mlir @@ -1,61 +1,61 @@ // RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.Constant +// spirv.Constant //===----------------------------------------------------------------------===// // CHECK-LABEL: @bool_constant_scalar -spv.func @bool_constant_scalar() "None" { +spirv.func @bool_constant_scalar() "None" { // CHECK: llvm.mlir.constant(true) : i1 - %0 = spv.Constant true + %0 = spirv.Constant true // CHECK: llvm.mlir.constant(false) : i1 - %1 = spv.Constant false - spv.Return + %1 = spirv.Constant false + spirv.Return } // CHECK-LABEL: @bool_constant_vector -spv.func @bool_constant_vector() "None" { +spirv.func @bool_constant_vector() "None" { // CHECK: llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : vector<2xi1> - %0 = spv.Constant dense<[true, false]> : vector<2xi1> + %0 = spirv.Constant dense<[true, false]> : vector<2xi1> // CHECK: llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> - %1 = spv.Constant dense : vector<3xi1> - spv.Return + %1 = spirv.Constant dense : vector<3xi1> + spirv.Return } // CHECK-LABEL: @integer_constant_scalar -spv.func @integer_constant_scalar() "None" { +spirv.func @integer_constant_scalar() "None" { // CHECK: llvm.mlir.constant(0 : i8) : i8 - %0 = spv.Constant 0 : i8 + %0 = spirv.Constant 0 : i8 // CHECK: llvm.mlir.constant(-5 : i64) : i64 - %1 = spv.Constant -5 : si64 + %1 = spirv.Constant -5 : si64 // CHECK: llvm.mlir.constant(10 : i16) : i16 - %2 = spv.Constant 10 : ui16 - spv.Return + %2 = spirv.Constant 10 : ui16 + spirv.Return } // CHECK-LABEL: @integer_constant_vector -spv.func @integer_constant_vector() "None" { +spirv.func @integer_constant_vector() "None" { // CHECK: llvm.mlir.constant(dense<[2, 3]> : vector<2xi32>) : vector<2xi32> - %0 = spv.Constant dense<[2, 3]> : vector<2xi32> + %0 = spirv.Constant dense<[2, 3]> : vector<2xi32> // CHECK: llvm.mlir.constant(dense<-4> : vector<2xi32>) : vector<2xi32> - %1 = spv.Constant dense<-4> : vector<2xsi32> + %1 = spirv.Constant dense<-4> : vector<2xsi32> // CHECK: llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi32>) : vector<3xi32> - %2 = spv.Constant dense<[2, 3, 4]> : vector<3xui32> - spv.Return + %2 = spirv.Constant dense<[2, 3, 4]> : vector<3xui32> + spirv.Return } // CHECK-LABEL: @float_constant_scalar -spv.func @float_constant_scalar() "None" { +spirv.func @float_constant_scalar() "None" { // CHECK: llvm.mlir.constant(5.000000e+00 : f16) : f16 - %0 = spv.Constant 5.000000e+00 : f16 + %0 = spirv.Constant 5.000000e+00 : f16 // CHECK: llvm.mlir.constant(5.000000e+00 : f64) : f64 - %1 = spv.Constant 5.000000e+00 : f64 - spv.Return + %1 = spirv.Constant 5.000000e+00 : f64 + spirv.Return } // CHECK-LABEL: @float_constant_vector -spv.func @float_constant_vector() "None" { +spirv.func @float_constant_vector() "None" { // CHECK: llvm.mlir.constant(dense<[2.000000e+00, 3.000000e+00]> : vector<2xf32>) : vector<2xf32> - %0 = spv.Constant dense<[2.000000e+00, 3.000000e+00]> : vector<2xf32> - spv.Return + %0 = spirv.Constant dense<[2.000000e+00, 3.000000e+00]> : vector<2xf32> + spirv.Return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/control-flow-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/control-flow-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/control-flow-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/control-flow-ops-to-llvm.mlir @@ -1,93 +1,93 @@ // RUN: mlir-opt -convert-spirv-to-llvm -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.Branch +// spirv.Branch //===----------------------------------------------------------------------===// -spv.module Logical GLSL450 { - spv.func @branch_without_arguments() -> () "None" { +spirv.module Logical GLSL450 { + spirv.func @branch_without_arguments() -> () "None" { // CHECK: llvm.br ^bb1 - spv.Branch ^label + spirv.Branch ^label // CHECK: ^bb1 ^label: - spv.Return + spirv.Return } - spv.func @branch_with_arguments() -> () "None" { - %0 = spv.Constant 0 : i32 - %1 = spv.Constant true + spirv.func @branch_with_arguments() -> () "None" { + %0 = spirv.Constant 0 : i32 + %1 = spirv.Constant true // CHECK: llvm.br ^bb1(%{{.*}}, %{{.*}} : i32, i1) - spv.Branch ^label(%0, %1: i32, i1) + spirv.Branch ^label(%0, %1: i32, i1) // CHECK: ^bb1(%{{.*}}: i32, %{{.*}}: i1) ^label(%arg0: i32, %arg1: i1): - spv.Return + spirv.Return } } // ----- //===----------------------------------------------------------------------===// -// spv.BranchConditional +// spirv.BranchConditional //===----------------------------------------------------------------------===// -spv.module Logical GLSL450 { - spv.func @cond_branch_without_arguments() -> () "None" { +spirv.module Logical GLSL450 { + spirv.func @cond_branch_without_arguments() -> () "None" { // CHECK: %[[COND:.*]] = llvm.mlir.constant(true) : i1 - %cond = spv.Constant true + %cond = spirv.Constant true // CHECK: lvm.cond_br %[[COND]], ^bb1, ^bb2 - spv.BranchConditional %cond, ^true, ^false + spirv.BranchConditional %cond, ^true, ^false // CHECK: ^bb1: ^true: - spv.Return + spirv.Return // CHECK: ^bb2: ^false: - spv.Return + spirv.Return } - spv.func @cond_branch_with_arguments_nested() -> () "None" { + spirv.func @cond_branch_with_arguments_nested() -> () "None" { // CHECK: %[[COND1:.*]] = llvm.mlir.constant(true) : i1 - %cond = spv.Constant true - %0 = spv.Constant 0 : i32 + %cond = spirv.Constant true + %0 = spirv.Constant 0 : i32 // CHECK: %[[COND2:.*]] = llvm.mlir.constant(false) : i1 - %false = spv.Constant false + %false = spirv.Constant false // CHECK: llvm.cond_br %[[COND1]], ^bb1(%{{.*}}, %[[COND2]] : i32, i1), ^bb2 - spv.BranchConditional %cond, ^outer_true(%0, %false: i32, i1), ^outer_false + spirv.BranchConditional %cond, ^outer_true(%0, %false: i32, i1), ^outer_false // CHECK: ^bb1(%{{.*}}: i32, %[[COND:.*]]: i1): ^outer_true(%arg0: i32, %arg1: i1): // CHECK: llvm.cond_br %[[COND]], ^bb3, ^bb4(%{{.*}}, %{{.*}} : i32, i32) - spv.BranchConditional %arg1, ^inner_true, ^inner_false(%arg0, %arg0: i32, i32) + spirv.BranchConditional %arg1, ^inner_true, ^inner_false(%arg0, %arg0: i32, i32) // CHECK: ^bb2: ^outer_false: - spv.Return + spirv.Return // CHECK: ^bb3: ^inner_true: - spv.Return + spirv.Return // CHECK: ^bb4(%{{.*}}: i32, %{{.*}}: i32): ^inner_false(%arg3: i32, %arg4: i32): - spv.Return + spirv.Return } - spv.func @cond_branch_with_weights(%cond: i1) -> () "None" { + spirv.func @cond_branch_with_weights(%cond: i1) -> () "None" { // CHECK: llvm.cond_br %{{.*}} weights(dense<[1, 2]> : vector<2xi32>), ^bb1, ^bb2 - spv.BranchConditional %cond [1, 2], ^true, ^false + spirv.BranchConditional %cond [1, 2], ^true, ^false // CHECK: ^bb1: ^true: - spv.Return + spirv.Return // CHECK: ^bb2: ^false: - spv.Return + spirv.Return } } // ----- //===----------------------------------------------------------------------===// -// spv.mlir.loop +// spirv.mlir.loop //===----------------------------------------------------------------------===// -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { // CHECK-LABEL: @infinite_loop - spv.func @infinite_loop(%count : i32) -> () "None" { + spirv.func @infinite_loop(%count : i32) -> () "None" { // CHECK: llvm.br ^[[BB1:.*]] // CHECK: ^[[BB1]]: // CHECK: %[[COND:.*]] = llvm.mlir.constant(true) : i1 @@ -100,110 +100,110 @@ // CHECK: llvm.br ^[[BB5:.*]] // CHECK: ^[[BB5]]: // CHECK: llvm.return - spv.mlir.loop { - spv.Branch ^header + spirv.mlir.loop { + spirv.Branch ^header ^header: - %cond = spv.Constant true - spv.BranchConditional %cond, ^body, ^merge + %cond = spirv.Constant true + spirv.BranchConditional %cond, ^body, ^merge ^body: // Do nothing - spv.Branch ^continue + spirv.Branch ^continue ^continue: // Do nothing - spv.Branch ^header + spirv.Branch ^header ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } } // ----- //===----------------------------------------------------------------------===// -// spv.mlir.selection +// spirv.mlir.selection //===----------------------------------------------------------------------===// -spv.module Logical GLSL450 { - spv.func @selection_empty() -> () "None" { +spirv.module Logical GLSL450 { + spirv.func @selection_empty() -> () "None" { // CHECK: llvm.return - spv.mlir.selection { + spirv.mlir.selection { } - spv.Return + spirv.Return } - spv.func @selection_with_merge_block_only() -> () "None" { - %cond = spv.Constant true + spirv.func @selection_with_merge_block_only() -> () "None" { + %cond = spirv.Constant true // CHECK: llvm.return - spv.mlir.selection { - spv.BranchConditional %cond, ^merge, ^merge + spirv.mlir.selection { + spirv.BranchConditional %cond, ^merge, ^merge ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } - spv.func @selection_with_true_block_only() -> () "None" { + spirv.func @selection_with_true_block_only() -> () "None" { // CHECK: %[[COND:.*]] = llvm.mlir.constant(true) : i1 - %cond = spv.Constant true + %cond = spirv.Constant true // CHECK: llvm.cond_br %[[COND]], ^bb1, ^bb2 - spv.mlir.selection { - spv.BranchConditional %cond, ^true, ^merge + spirv.mlir.selection { + spirv.BranchConditional %cond, ^true, ^merge // CHECK: ^bb1: ^true: // CHECK: llvm.br ^bb2 - spv.Branch ^merge + spirv.Branch ^merge // CHECK: ^bb2: ^merge: // CHECK: llvm.br ^bb3 - spv.mlir.merge + spirv.mlir.merge } // CHECK: ^bb3: // CHECK-NEXT: llvm.return - spv.Return + spirv.Return } - spv.func @selection_with_both_true_and_false_block() -> () "None" { + spirv.func @selection_with_both_true_and_false_block() -> () "None" { // CHECK: %[[COND:.*]] = llvm.mlir.constant(true) : i1 - %cond = spv.Constant true + %cond = spirv.Constant true // CHECK: llvm.cond_br %[[COND]], ^bb1, ^bb2 - spv.mlir.selection { - spv.BranchConditional %cond, ^true, ^false + spirv.mlir.selection { + spirv.BranchConditional %cond, ^true, ^false // CHECK: ^bb1: ^true: // CHECK: llvm.br ^bb3 - spv.Branch ^merge + spirv.Branch ^merge // CHECK: ^bb2: ^false: // CHECK: llvm.br ^bb3 - spv.Branch ^merge + spirv.Branch ^merge // CHECK: ^bb3: ^merge: // CHECK: llvm.br ^bb4 - spv.mlir.merge + spirv.mlir.merge } // CHECK: ^bb4: // CHECK-NEXT: llvm.return - spv.Return + spirv.Return } - spv.func @selection_with_early_return(%arg0: i1) -> i32 "None" { + spirv.func @selection_with_early_return(%arg0: i1) -> i32 "None" { // CHECK: %[[ZERO:.*]] = llvm.mlir.constant(0 : i32) : i32 - %0 = spv.Constant 0 : i32 + %0 = spirv.Constant 0 : i32 // CHECK: llvm.cond_br %{{.*}}, ^bb1(%[[ZERO]] : i32), ^bb2 - spv.mlir.selection { - spv.BranchConditional %arg0, ^true(%0 : i32), ^merge + spirv.mlir.selection { + spirv.BranchConditional %arg0, ^true(%0 : i32), ^merge // CHECK: ^bb1(%[[ARG:.*]]: i32): ^true(%arg1: i32): // CHECK: llvm.return %[[ARG]] : i32 - spv.ReturnValue %arg1 : i32 + spirv.ReturnValue %arg1 : i32 // CHECK: ^bb2: ^merge: // CHECK: llvm.br ^bb3 - spv.mlir.merge + spirv.mlir.merge } // CHECK: ^bb3: - %one = spv.Constant 1 : i32 - spv.ReturnValue %one : i32 + %one = spirv.Constant 1 : i32 + spirv.ReturnValue %one : i32 } } diff --git a/mlir/test/Conversion/SPIRVToLLVM/func-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/func-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/func-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/func-ops-to-llvm.mlir @@ -1,95 +1,95 @@ // RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.Return +// spirv.Return //===----------------------------------------------------------------------===// // CHECK-LABEL: @return -spv.func @return() "None" { +spirv.func @return() "None" { // CHECK: llvm.return - spv.Return + spirv.Return } //===----------------------------------------------------------------------===// -// spv.ReturnValue +// spirv.ReturnValue //===----------------------------------------------------------------------===// // CHECK-LABEL: @return_value -spv.func @return_value(%arg: i32) -> i32 "None" { +spirv.func @return_value(%arg: i32) -> i32 "None" { // CHECK: llvm.return %{{.*}} : i32 - spv.ReturnValue %arg : i32 + spirv.ReturnValue %arg : i32 } //===----------------------------------------------------------------------===// -// spv.func +// spirv.func //===----------------------------------------------------------------------===// // CHECK-LABEL: llvm.func @none() -spv.func @none() "None" { - spv.Return +spirv.func @none() "None" { + spirv.Return } // CHECK-LABEL: llvm.func @inline() attributes {passthrough = ["alwaysinline"]} -spv.func @inline() "Inline" { - spv.Return +spirv.func @inline() "Inline" { + spirv.Return } // CHECK-LABEL: llvm.func @dont_inline() attributes {passthrough = ["noinline"]} -spv.func @dont_inline() "DontInline" { - spv.Return +spirv.func @dont_inline() "DontInline" { + spirv.Return } // CHECK-LABEL: llvm.func @pure() attributes {passthrough = ["readonly"]} -spv.func @pure() "Pure" { - spv.Return +spirv.func @pure() "Pure" { + spirv.Return } // CHECK-LABEL: llvm.func @const() attributes {passthrough = ["readnone"]} -spv.func @const() "Const" { - spv.Return +spirv.func @const() "Const" { + spirv.Return } // CHECK-LABEL: llvm.func @scalar_types(%arg0: i32, %arg1: i1, %arg2: f64, %arg3: f32) -spv.func @scalar_types(%arg0: i32, %arg1: i1, %arg2: f64, %arg3: f32) "None" { - spv.Return +spirv.func @scalar_types(%arg0: i32, %arg1: i1, %arg2: f64, %arg3: f32) "None" { + spirv.Return } // CHECK-LABEL: llvm.func @vector_types(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> -spv.func @vector_types(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> "None" { - %0 = spv.IAdd %arg0, %arg1 : vector<2xi64> - spv.ReturnValue %0 : vector<2xi64> +spirv.func @vector_types(%arg0: vector<2xi64>, %arg1: vector<2xi64>) -> vector<2xi64> "None" { + %0 = spirv.IAdd %arg0, %arg1 : vector<2xi64> + spirv.ReturnValue %0 : vector<2xi64> } //===----------------------------------------------------------------------===// -// spv.FunctionCall +// spirv.FunctionCall //===----------------------------------------------------------------------===// // CHECK-LABEL: llvm.func @function_calls // CHECK-SAME: %[[ARG0:.*]]: i32, %[[ARG1:.*]]: i1, %[[ARG2:.*]]: f64, %[[ARG3:.*]]: vector<2xi64>, %[[ARG4:.*]]: vector<2xf32> -spv.func @function_calls(%arg0: i32, %arg1: i1, %arg2: f64, %arg3: vector<2xi64>, %arg4: vector<2xf32>) "None" { +spirv.func @function_calls(%arg0: i32, %arg1: i1, %arg2: f64, %arg3: vector<2xi64>, %arg4: vector<2xf32>) "None" { // CHECK: llvm.call @void_1() : () -> () // CHECK: llvm.call @void_2(%[[ARG3]]) : (vector<2xi64>) -> () // CHECK: llvm.call @value_scalar(%[[ARG0]], %[[ARG1]], %[[ARG2]]) : (i32, i1, f64) -> i32 // CHECK: llvm.call @value_vector(%[[ARG3]], %[[ARG4]]) : (vector<2xi64>, vector<2xf32>) -> vector<2xf32> - spv.FunctionCall @void_1() : () -> () - spv.FunctionCall @void_2(%arg3) : (vector<2xi64>) -> () - %0 = spv.FunctionCall @value_scalar(%arg0, %arg1, %arg2) : (i32, i1, f64) -> i32 - %1 = spv.FunctionCall @value_vector(%arg3, %arg4) : (vector<2xi64>, vector<2xf32>) -> vector<2xf32> - spv.Return + spirv.FunctionCall @void_1() : () -> () + spirv.FunctionCall @void_2(%arg3) : (vector<2xi64>) -> () + %0 = spirv.FunctionCall @value_scalar(%arg0, %arg1, %arg2) : (i32, i1, f64) -> i32 + %1 = spirv.FunctionCall @value_vector(%arg3, %arg4) : (vector<2xi64>, vector<2xf32>) -> vector<2xf32> + spirv.Return } -spv.func @void_1() "None" { - spv.Return +spirv.func @void_1() "None" { + spirv.Return } -spv.func @void_2(%arg0: vector<2xi64>) "None" { - spv.Return +spirv.func @void_2(%arg0: vector<2xi64>) "None" { + spirv.Return } -spv.func @value_scalar(%arg0: i32, %arg1: i1, %arg2: f64) -> i32 "None" { - spv.ReturnValue %arg0: i32 +spirv.func @value_scalar(%arg0: i32, %arg1: i1, %arg2: f64) -> i32 "None" { + spirv.ReturnValue %arg0: i32 } -spv.func @value_vector(%arg0: vector<2xi64>, %arg1: vector<2xf32>) -> vector<2xf32> "None" { - spv.ReturnValue %arg1: vector<2xf32> +spirv.func @value_vector(%arg0: vector<2xi64>, %arg1: vector<2xf32>) -> vector<2xf32> "None" { + spirv.ReturnValue %arg1: vector<2xf32> } diff --git a/mlir/test/Conversion/SPIRVToLLVM/gl-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/gl-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/gl-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/gl-ops-to-llvm.mlir @@ -1,180 +1,180 @@ // RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.GL.Ceil +// spirv.GL.Ceil //===----------------------------------------------------------------------===// // CHECK-LABEL: @ceil -spv.func @ceil(%arg0: f32, %arg1: vector<3xf16>) "None" { +spirv.func @ceil(%arg0: f32, %arg1: vector<3xf16>) "None" { // CHECK: "llvm.intr.ceil"(%{{.*}}) : (f32) -> f32 - %0 = spv.GL.Ceil %arg0 : f32 + %0 = spirv.GL.Ceil %arg0 : f32 // CHECK: "llvm.intr.ceil"(%{{.*}}) : (vector<3xf16>) -> vector<3xf16> - %1 = spv.GL.Ceil %arg1 : vector<3xf16> - spv.Return + %1 = spirv.GL.Ceil %arg1 : vector<3xf16> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GL.Cos +// spirv.GL.Cos //===----------------------------------------------------------------------===// // CHECK-LABEL: @cos -spv.func @cos(%arg0: f32, %arg1: vector<3xf16>) "None" { +spirv.func @cos(%arg0: f32, %arg1: vector<3xf16>) "None" { // CHECK: "llvm.intr.cos"(%{{.*}}) : (f32) -> f32 - %0 = spv.GL.Cos %arg0 : f32 + %0 = spirv.GL.Cos %arg0 : f32 // CHECK: "llvm.intr.cos"(%{{.*}}) : (vector<3xf16>) -> vector<3xf16> - %1 = spv.GL.Cos %arg1 : vector<3xf16> - spv.Return + %1 = spirv.GL.Cos %arg1 : vector<3xf16> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GL.Exp +// spirv.GL.Exp //===----------------------------------------------------------------------===// // CHECK-LABEL: @exp -spv.func @exp(%arg0: f32, %arg1: vector<3xf16>) "None" { +spirv.func @exp(%arg0: f32, %arg1: vector<3xf16>) "None" { // CHECK: "llvm.intr.exp"(%{{.*}}) : (f32) -> f32 - %0 = spv.GL.Exp %arg0 : f32 + %0 = spirv.GL.Exp %arg0 : f32 // CHECK: "llvm.intr.exp"(%{{.*}}) : (vector<3xf16>) -> vector<3xf16> - %1 = spv.GL.Exp %arg1 : vector<3xf16> - spv.Return + %1 = spirv.GL.Exp %arg1 : vector<3xf16> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GL.FAbs +// spirv.GL.FAbs //===----------------------------------------------------------------------===// // CHECK-LABEL: @fabs -spv.func @fabs(%arg0: f32, %arg1: vector<3xf16>) "None" { +spirv.func @fabs(%arg0: f32, %arg1: vector<3xf16>) "None" { // CHECK: "llvm.intr.fabs"(%{{.*}}) : (f32) -> f32 - %0 = spv.GL.FAbs %arg0 : f32 + %0 = spirv.GL.FAbs %arg0 : f32 // CHECK: "llvm.intr.fabs"(%{{.*}}) : (vector<3xf16>) -> vector<3xf16> - %1 = spv.GL.FAbs %arg1 : vector<3xf16> - spv.Return + %1 = spirv.GL.FAbs %arg1 : vector<3xf16> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GL.Floor +// spirv.GL.Floor //===----------------------------------------------------------------------===// // CHECK-LABEL: @floor -spv.func @floor(%arg0: f32, %arg1: vector<3xf16>) "None" { +spirv.func @floor(%arg0: f32, %arg1: vector<3xf16>) "None" { // CHECK: "llvm.intr.floor"(%{{.*}}) : (f32) -> f32 - %0 = spv.GL.Floor %arg0 : f32 + %0 = spirv.GL.Floor %arg0 : f32 // CHECK: "llvm.intr.floor"(%{{.*}}) : (vector<3xf16>) -> vector<3xf16> - %1 = spv.GL.Floor %arg1 : vector<3xf16> - spv.Return + %1 = spirv.GL.Floor %arg1 : vector<3xf16> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GL.FMax +// spirv.GL.FMax //===----------------------------------------------------------------------===// // CHECK-LABEL: @fmax -spv.func @fmax(%arg0: f32, %arg1: vector<3xf16>) "None" { +spirv.func @fmax(%arg0: f32, %arg1: vector<3xf16>) "None" { // CHECK: "llvm.intr.maxnum"(%{{.*}}, %{{.*}}) : (f32, f32) -> f32 - %0 = spv.GL.FMax %arg0, %arg0 : f32 + %0 = spirv.GL.FMax %arg0, %arg0 : f32 // CHECK: "llvm.intr.maxnum"(%{{.*}}, %{{.*}}) : (vector<3xf16>, vector<3xf16>) -> vector<3xf16> - %1 = spv.GL.FMax %arg1, %arg1 : vector<3xf16> - spv.Return + %1 = spirv.GL.FMax %arg1, %arg1 : vector<3xf16> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GL.FMin +// spirv.GL.FMin //===----------------------------------------------------------------------===// // CHECK-LABEL: @fmin -spv.func @fmin(%arg0: f32, %arg1: vector<3xf16>) "None" { +spirv.func @fmin(%arg0: f32, %arg1: vector<3xf16>) "None" { // CHECK: "llvm.intr.minnum"(%{{.*}}, %{{.*}}) : (f32, f32) -> f32 - %0 = spv.GL.FMin %arg0, %arg0 : f32 + %0 = spirv.GL.FMin %arg0, %arg0 : f32 // CHECK: "llvm.intr.minnum"(%{{.*}}, %{{.*}}) : (vector<3xf16>, vector<3xf16>) -> vector<3xf16> - %1 = spv.GL.FMin %arg1, %arg1 : vector<3xf16> - spv.Return + %1 = spirv.GL.FMin %arg1, %arg1 : vector<3xf16> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GL.Log +// spirv.GL.Log //===----------------------------------------------------------------------===// // CHECK-LABEL: @log -spv.func @log(%arg0: f32, %arg1: vector<3xf16>) "None" { +spirv.func @log(%arg0: f32, %arg1: vector<3xf16>) "None" { // CHECK: "llvm.intr.log"(%{{.*}}) : (f32) -> f32 - %0 = spv.GL.Log %arg0 : f32 + %0 = spirv.GL.Log %arg0 : f32 // CHECK: "llvm.intr.log"(%{{.*}}) : (vector<3xf16>) -> vector<3xf16> - %1 = spv.GL.Log %arg1 : vector<3xf16> - spv.Return + %1 = spirv.GL.Log %arg1 : vector<3xf16> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GL.Sin +// spirv.GL.Sin //===----------------------------------------------------------------------===// // CHECK-LABEL: @sin -spv.func @sin(%arg0: f32, %arg1: vector<3xf16>) "None" { +spirv.func @sin(%arg0: f32, %arg1: vector<3xf16>) "None" { // CHECK: "llvm.intr.sin"(%{{.*}}) : (f32) -> f32 - %0 = spv.GL.Sin %arg0 : f32 + %0 = spirv.GL.Sin %arg0 : f32 // CHECK: "llvm.intr.sin"(%{{.*}}) : (vector<3xf16>) -> vector<3xf16> - %1 = spv.GL.Sin %arg1 : vector<3xf16> - spv.Return + %1 = spirv.GL.Sin %arg1 : vector<3xf16> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GL.SMax +// spirv.GL.SMax //===----------------------------------------------------------------------===// // CHECK-LABEL: @smax -spv.func @smax(%arg0: i16, %arg1: vector<3xi32>) "None" { +spirv.func @smax(%arg0: i16, %arg1: vector<3xi32>) "None" { // CHECK: "llvm.intr.smax"(%{{.*}}, %{{.*}}) : (i16, i16) -> i16 - %0 = spv.GL.SMax %arg0, %arg0 : i16 + %0 = spirv.GL.SMax %arg0, %arg0 : i16 // CHECK: "llvm.intr.smax"(%{{.*}}, %{{.*}}) : (vector<3xi32>, vector<3xi32>) -> vector<3xi32> - %1 = spv.GL.SMax %arg1, %arg1 : vector<3xi32> - spv.Return + %1 = spirv.GL.SMax %arg1, %arg1 : vector<3xi32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GL.SMin +// spirv.GL.SMin //===----------------------------------------------------------------------===// // CHECK-LABEL: @smin -spv.func @smin(%arg0: i16, %arg1: vector<3xi32>) "None" { +spirv.func @smin(%arg0: i16, %arg1: vector<3xi32>) "None" { // CHECK: "llvm.intr.smin"(%{{.*}}, %{{.*}}) : (i16, i16) -> i16 - %0 = spv.GL.SMin %arg0, %arg0 : i16 + %0 = spirv.GL.SMin %arg0, %arg0 : i16 // CHECK: "llvm.intr.smin"(%{{.*}}, %{{.*}}) : (vector<3xi32>, vector<3xi32>) -> vector<3xi32> - %1 = spv.GL.SMin %arg1, %arg1 : vector<3xi32> - spv.Return + %1 = spirv.GL.SMin %arg1, %arg1 : vector<3xi32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GL.Sqrt +// spirv.GL.Sqrt //===----------------------------------------------------------------------===// // CHECK-LABEL: @sqrt -spv.func @sqrt(%arg0: f32, %arg1: vector<3xf16>) "None" { +spirv.func @sqrt(%arg0: f32, %arg1: vector<3xf16>) "None" { // CHECK: "llvm.intr.sqrt"(%{{.*}}) : (f32) -> f32 - %0 = spv.GL.Sqrt %arg0 : f32 + %0 = spirv.GL.Sqrt %arg0 : f32 // CHECK: "llvm.intr.sqrt"(%{{.*}}) : (vector<3xf16>) -> vector<3xf16> - %1 = spv.GL.Sqrt %arg1 : vector<3xf16> - spv.Return + %1 = spirv.GL.Sqrt %arg1 : vector<3xf16> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GL.Tan +// spirv.GL.Tan //===----------------------------------------------------------------------===// // CHECK-LABEL: @tan -spv.func @tan(%arg0: f32) "None" { +spirv.func @tan(%arg0: f32) "None" { // CHECK: %[[SIN:.*]] = "llvm.intr.sin"(%{{.*}}) : (f32) -> f32 // CHECK: %[[COS:.*]] = "llvm.intr.cos"(%{{.*}}) : (f32) -> f32 // CHECK: llvm.fdiv %[[SIN]], %[[COS]] : f32 - %0 = spv.GL.Tan %arg0 : f32 - spv.Return + %0 = spirv.GL.Tan %arg0 : f32 + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GL.Tanh +// spirv.GL.Tanh //===----------------------------------------------------------------------===// // CHECK-LABEL: @tanh -spv.func @tanh(%arg0: f32) "None" { +spirv.func @tanh(%arg0: f32) "None" { // CHECK: %[[TWO:.*]] = llvm.mlir.constant(2.000000e+00 : f32) : f32 // CHECK: %[[X2:.*]] = llvm.fmul %[[TWO]], %{{.*}} : f32 // CHECK: %[[EXP:.*]] = "llvm.intr.exp"(%[[X2]]) : (f32) -> f32 @@ -182,19 +182,19 @@ // CHECK: %[[T0:.*]] = llvm.fsub %[[EXP]], %[[ONE]] : f32 // CHECK: %[[T1:.*]] = llvm.fadd %[[EXP]], %[[ONE]] : f32 // CHECK: llvm.fdiv %[[T0]], %[[T1]] : f32 - %0 = spv.GL.Tanh %arg0 : f32 - spv.Return + %0 = spirv.GL.Tanh %arg0 : f32 + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GL.InverseSqrt +// spirv.GL.InverseSqrt //===----------------------------------------------------------------------===// // CHECK-LABEL: @inverse_sqrt -spv.func @inverse_sqrt(%arg0: f32) "None" { +spirv.func @inverse_sqrt(%arg0: f32) "None" { // CHECK: %[[ONE:.*]] = llvm.mlir.constant(1.000000e+00 : f32) : f32 // CHECK: %[[SQRT:.*]] = "llvm.intr.sqrt"(%{{.*}}) : (f32) -> f32 // CHECK: llvm.fdiv %[[ONE]], %[[SQRT]] : f32 - %0 = spv.GL.InverseSqrt %arg0 : f32 - spv.Return + %0 = spirv.GL.InverseSqrt %arg0 : f32 + spirv.Return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/logical-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/logical-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/logical-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/logical-ops-to-llvm.mlir @@ -1,93 +1,93 @@ // RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.LogicalEqual +// spirv.LogicalEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @logical_equal_scalar -spv.func @logical_equal_scalar(%arg0: i1, %arg1: i1) "None" { +spirv.func @logical_equal_scalar(%arg0: i1, %arg1: i1) "None" { // CHECK: llvm.icmp "eq" %{{.*}}, %{{.*}} : i1 - %0 = spv.LogicalEqual %arg0, %arg0 : i1 - spv.Return + %0 = spirv.LogicalEqual %arg0, %arg0 : i1 + spirv.Return } // CHECK-LABEL: @logical_equal_vector -spv.func @logical_equal_vector(%arg0: vector<4xi1>, %arg1: vector<4xi1>) "None" { +spirv.func @logical_equal_vector(%arg0: vector<4xi1>, %arg1: vector<4xi1>) "None" { // CHECK: llvm.icmp "eq" %{{.*}}, %{{.*}} : vector<4xi1> - %0 = spv.LogicalEqual %arg0, %arg0 : vector<4xi1> - spv.Return + %0 = spirv.LogicalEqual %arg0, %arg0 : vector<4xi1> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.LogicalNotEqual +// spirv.LogicalNotEqual //===----------------------------------------------------------------------===// // CHECK-LABEL: @logical_not_equal_scalar -spv.func @logical_not_equal_scalar(%arg0: i1, %arg1: i1) "None" { +spirv.func @logical_not_equal_scalar(%arg0: i1, %arg1: i1) "None" { // CHECK: llvm.icmp "ne" %{{.*}}, %{{.*}} : i1 - %0 = spv.LogicalNotEqual %arg0, %arg0 : i1 - spv.Return + %0 = spirv.LogicalNotEqual %arg0, %arg0 : i1 + spirv.Return } // CHECK-LABEL: @logical_not_equal_vector -spv.func @logical_not_equal_vector(%arg0: vector<4xi1>, %arg1: vector<4xi1>) "None" { +spirv.func @logical_not_equal_vector(%arg0: vector<4xi1>, %arg1: vector<4xi1>) "None" { // CHECK: llvm.icmp "ne" %{{.*}}, %{{.*}} : vector<4xi1> - %0 = spv.LogicalNotEqual %arg0, %arg0 : vector<4xi1> - spv.Return + %0 = spirv.LogicalNotEqual %arg0, %arg0 : vector<4xi1> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.LogicalNot +// spirv.LogicalNot //===----------------------------------------------------------------------===// // CHECK-LABEL: @logical_not_scalar -spv.func @logical_not_scalar(%arg0: i1) "None" { +spirv.func @logical_not_scalar(%arg0: i1) "None" { // CHECK: %[[CONST:.*]] = llvm.mlir.constant(true) : i1 // CHECK: llvm.xor %{{.*}}, %[[CONST]] : i1 - %0 = spv.LogicalNot %arg0 : i1 - spv.Return + %0 = spirv.LogicalNot %arg0 : i1 + spirv.Return } // CHECK-LABEL: @logical_not_vector -spv.func @logical_not_vector(%arg0: vector<4xi1>) "None" { +spirv.func @logical_not_vector(%arg0: vector<4xi1>) "None" { // CHECK: %[[CONST:.*]] = llvm.mlir.constant(dense : vector<4xi1>) : vector<4xi1> // CHECK: llvm.xor %{{.*}}, %[[CONST]] : vector<4xi1> - %0 = spv.LogicalNot %arg0 : vector<4xi1> - spv.Return + %0 = spirv.LogicalNot %arg0 : vector<4xi1> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.LogicalAnd +// spirv.LogicalAnd //===----------------------------------------------------------------------===// // CHECK-LABEL: @logical_and_scalar -spv.func @logical_and_scalar(%arg0: i1, %arg1: i1) "None" { +spirv.func @logical_and_scalar(%arg0: i1, %arg1: i1) "None" { // CHECK: llvm.and %{{.*}}, %{{.*}} : i1 - %0 = spv.LogicalAnd %arg0, %arg0 : i1 - spv.Return + %0 = spirv.LogicalAnd %arg0, %arg0 : i1 + spirv.Return } // CHECK-LABEL: @logical_and_vector -spv.func @logical_and_vector(%arg0: vector<4xi1>, %arg1: vector<4xi1>) "None" { +spirv.func @logical_and_vector(%arg0: vector<4xi1>, %arg1: vector<4xi1>) "None" { // CHECK: llvm.and %{{.*}}, %{{.*}} : vector<4xi1> - %0 = spv.LogicalAnd %arg0, %arg0 : vector<4xi1> - spv.Return + %0 = spirv.LogicalAnd %arg0, %arg0 : vector<4xi1> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.LogicalOr +// spirv.LogicalOr //===----------------------------------------------------------------------===// // CHECK-LABEL: @logical_or_scalar -spv.func @logical_or_scalar(%arg0: i1, %arg1: i1) "None" { +spirv.func @logical_or_scalar(%arg0: i1, %arg1: i1) "None" { // CHECK: llvm.or %{{.*}}, %{{.*}} : i1 - %0 = spv.LogicalOr %arg0, %arg0 : i1 - spv.Return + %0 = spirv.LogicalOr %arg0, %arg0 : i1 + spirv.Return } // CHECK-LABEL: @logical_or_vector -spv.func @logical_or_vector(%arg0: vector<4xi1>, %arg1: vector<4xi1>) "None" { +spirv.func @logical_or_vector(%arg0: vector<4xi1>, %arg1: vector<4xi1>) "None" { // CHECK: llvm.or %{{.*}}, %{{.*}} : vector<4xi1> - %0 = spv.LogicalOr %arg0, %arg0 : vector<4xi1> - spv.Return + %0 = spirv.LogicalOr %arg0, %arg0 : vector<4xi1> + spirv.Return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/lower-host-to-llvm-calls.mlir b/mlir/test/Conversion/SPIRVToLLVM/lower-host-to-llvm-calls.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/lower-host-to-llvm-calls.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/lower-host-to-llvm-calls.mlir @@ -1,16 +1,16 @@ // RUN: mlir-opt --lower-host-to-llvm %s | FileCheck %s -module attributes {gpu.container_module, spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits>} { +module attributes {gpu.container_module, spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits>} { // CHECK: llvm.mlir.global linkonce @__spv__foo_bar_arg_0_descriptor_set0_binding0() {addr_space = 0 : i32} : !llvm.struct<(array<6 x i32>)> // CHECK: llvm.func @__spv__foo_bar() - // CHECK: spv.module @__spv__foo - // CHECK: spv.GlobalVariable @bar_arg_0 bind(0, 0) : !spv.ptr [0])>, StorageBuffer> - // CHECK: spv.func @__spv__foo_bar + // CHECK: spirv.module @__spv__foo + // CHECK: spirv.GlobalVariable @bar_arg_0 bind(0, 0) : !spirv.ptr [0])>, StorageBuffer> + // CHECK: spirv.func @__spv__foo_bar - // CHECK: spv.EntryPoint "GLCompute" @__spv__foo_bar - // CHECK: spv.ExecutionMode @__spv__foo_bar "LocalSize", 1, 1, 1 + // CHECK: spirv.EntryPoint "GLCompute" @__spv__foo_bar + // CHECK: spirv.ExecutionMode @__spv__foo_bar "LocalSize", 1, 1, 1 // CHECK-LABEL: @main // CHECK: %[[SRC:.*]] = llvm.extractvalue %{{.*}}[0] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)> @@ -21,18 +21,18 @@ // CHECK-NEXT: llvm.mlir.constant(false) : i1 // CHECK-NEXT: "llvm.intr.memcpy"(%[[SRC]], %[[DEST]], %[[SIZE]], %{{.*}}) : (!llvm.ptr, !llvm.ptr)>>, i64, i1) -> () - spv.module @__spv__foo Logical GLSL450 requires #spv.vce { - spv.GlobalVariable @bar_arg_0 bind(0, 0) : !spv.ptr [0])>, StorageBuffer> - spv.func @bar() "None" attributes {workgroup_attributions = 0 : i64} { - %0 = spv.mlir.addressof @bar_arg_0 : !spv.ptr [0])>, StorageBuffer> - spv.Return + spirv.module @__spv__foo Logical GLSL450 requires #spirv.vce { + spirv.GlobalVariable @bar_arg_0 bind(0, 0) : !spirv.ptr [0])>, StorageBuffer> + spirv.func @bar() "None" attributes {workgroup_attributions = 0 : i64} { + %0 = spirv.mlir.addressof @bar_arg_0 : !spirv.ptr [0])>, StorageBuffer> + spirv.Return } - spv.EntryPoint "GLCompute" @bar - spv.ExecutionMode @bar "LocalSize", 1, 1, 1 + spirv.EntryPoint "GLCompute" @bar + spirv.ExecutionMode @bar "LocalSize", 1, 1, 1 } gpu.module @foo { - gpu.func @bar(%arg0: memref<6xi32>) kernel attributes {spv.entry_point_abi = #spv.entry_point_abi : vector<3xi32>>} { + gpu.func @bar(%arg0: memref<6xi32>) kernel attributes {spirv.entry_point_abi = #spirv.entry_point_abi : vector<3xi32>>} { gpu.return } } diff --git a/mlir/test/Conversion/SPIRVToLLVM/memory-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/memory-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/memory-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/memory-ops-to-llvm.mlir @@ -1,229 +1,229 @@ // RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.AccessChain +// spirv.AccessChain //===----------------------------------------------------------------------===// // CHECK-LABEL: @access_chain -spv.func @access_chain() "None" { +spirv.func @access_chain() "None" { // CHECK: %[[ONE:.*]] = llvm.mlir.constant(1 : i32) : i32 - %0 = spv.Constant 1: i32 - %1 = spv.Variable : !spv.ptr)>, Function> + %0 = spirv.Constant 1: i32 + %1 = spirv.Variable : !spirv.ptr)>, Function> // CHECK: %[[ZERO:.*]] = llvm.mlir.constant(0 : i32) : i32 // CHECK: llvm.getelementptr %{{.*}}[%[[ZERO]], 1, %[[ONE]]] : (!llvm.ptr)>>, i32, i32) -> !llvm.ptr - %2 = spv.AccessChain %1[%0, %0] : !spv.ptr)>, Function>, i32, i32 - spv.Return + %2 = spirv.AccessChain %1[%0, %0] : !spirv.ptr)>, Function>, i32, i32 + spirv.Return } // CHECK-LABEL: @access_chain_array -spv.func @access_chain_array(%arg0 : i32) "None" { - %0 = spv.Variable : !spv.ptr>, Function> +spirv.func @access_chain_array(%arg0 : i32) "None" { + %0 = spirv.Variable : !spirv.ptr>, Function> // CHECK: %[[ZERO:.*]] = llvm.mlir.constant(0 : i32) : i32 // CHECK: llvm.getelementptr %{{.*}}[%[[ZERO]], %{{.*}}] : (!llvm.ptr>>, i32, i32) -> !llvm.ptr> - %1 = spv.AccessChain %0[%arg0] : !spv.ptr>, Function>, i32 - %2 = spv.Load "Function" %1 ["Volatile"] : !spv.array<4xf32> - spv.Return + %1 = spirv.AccessChain %0[%arg0] : !spirv.ptr>, Function>, i32 + %2 = spirv.Load "Function" %1 ["Volatile"] : !spirv.array<4xf32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.GlobalVariable and spv.mlir.addressof +// spirv.GlobalVariable and spirv.mlir.addressof //===----------------------------------------------------------------------===// -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { // CHECK: llvm.mlir.global external constant @var() {addr_space = 0 : i32} : f32 - spv.GlobalVariable @var : !spv.ptr + spirv.GlobalVariable @var : !spirv.ptr } -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { // CHECK: llvm.mlir.global private @struct() {addr_space = 0 : i32} : !llvm.struct)> // CHECK-LABEL: @func // CHECK: llvm.mlir.addressof @struct : !llvm.ptr)>> - spv.GlobalVariable @struct : !spv.ptr)>, Private> - spv.func @func() "None" { - %0 = spv.mlir.addressof @struct : !spv.ptr)>, Private> - spv.Return + spirv.GlobalVariable @struct : !spirv.ptr)>, Private> + spirv.func @func() "None" { + %0 = spirv.mlir.addressof @struct : !spirv.ptr)>, Private> + spirv.Return } } -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { // CHECK: llvm.mlir.global external @bar_descriptor_set0_binding0() {addr_space = 0 : i32} : i32 // CHECK-LABEL: @foo // CHECK: llvm.mlir.addressof @bar_descriptor_set0_binding0 : !llvm.ptr - spv.GlobalVariable @bar bind(0, 0) : !spv.ptr - spv.func @foo() "None" { - %0 = spv.mlir.addressof @bar : !spv.ptr - spv.Return + spirv.GlobalVariable @bar bind(0, 0) : !spirv.ptr + spirv.func @foo() "None" { + %0 = spirv.mlir.addressof @bar : !spirv.ptr + spirv.Return } } -spv.module @name Logical GLSL450 { +spirv.module @name Logical GLSL450 { // CHECK: llvm.mlir.global external @name_bar_descriptor_set0_binding0() {addr_space = 0 : i32} : i32 // CHECK-LABEL: @foo // CHECK: llvm.mlir.addressof @name_bar_descriptor_set0_binding0 : !llvm.ptr - spv.GlobalVariable @bar bind(0, 0) : !spv.ptr - spv.func @foo() "None" { - %0 = spv.mlir.addressof @bar : !spv.ptr - spv.Return + spirv.GlobalVariable @bar bind(0, 0) : !spirv.ptr + spirv.func @foo() "None" { + %0 = spirv.mlir.addressof @bar : !spirv.ptr + spirv.Return } } -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { // CHECK: llvm.mlir.global external @bar() {addr_space = 0 : i32, location = 1 : i32} : i32 // CHECK-LABEL: @foo - spv.GlobalVariable @bar {location = 1 : i32} : !spv.ptr - spv.func @foo() "None" { - %0 = spv.mlir.addressof @bar : !spv.ptr - spv.Return + spirv.GlobalVariable @bar {location = 1 : i32} : !spirv.ptr + spirv.func @foo() "None" { + %0 = spirv.mlir.addressof @bar : !spirv.ptr + spirv.Return } } -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { // CHECK: llvm.mlir.global external constant @bar() {addr_space = 0 : i32, location = 3 : i32} : f32 // CHECK-LABEL: @foo - spv.GlobalVariable @bar {descriptor_set = 0 : i32, location = 3 : i32} : !spv.ptr - spv.func @foo() "None" { - %0 = spv.mlir.addressof @bar : !spv.ptr - spv.Return + spirv.GlobalVariable @bar {descriptor_set = 0 : i32, location = 3 : i32} : !spirv.ptr + spirv.func @foo() "None" { + %0 = spirv.mlir.addressof @bar : !spirv.ptr + spirv.Return } } //===----------------------------------------------------------------------===// -// spv.Load +// spirv.Load //===----------------------------------------------------------------------===// // CHECK-LABEL: @load -spv.func @load() "None" { - %0 = spv.Variable : !spv.ptr +spirv.func @load() "None" { + %0 = spirv.Variable : !spirv.ptr // CHECK: llvm.load %{{.*}} : !llvm.ptr - %1 = spv.Load "Function" %0 : f32 - spv.Return + %1 = spirv.Load "Function" %0 : f32 + spirv.Return } // CHECK-LABEL: @load_none -spv.func @load_none() "None" { - %0 = spv.Variable : !spv.ptr +spirv.func @load_none() "None" { + %0 = spirv.Variable : !spirv.ptr // CHECK: llvm.load %{{.*}} : !llvm.ptr - %1 = spv.Load "Function" %0 ["None"] : f32 - spv.Return + %1 = spirv.Load "Function" %0 ["None"] : f32 + spirv.Return } // CHECK-LABEL: @load_with_alignment -spv.func @load_with_alignment() "None" { - %0 = spv.Variable : !spv.ptr +spirv.func @load_with_alignment() "None" { + %0 = spirv.Variable : !spirv.ptr // CHECK: llvm.load %{{.*}} {alignment = 4 : i64} : !llvm.ptr - %1 = spv.Load "Function" %0 ["Aligned", 4] : f32 - spv.Return + %1 = spirv.Load "Function" %0 ["Aligned", 4] : f32 + spirv.Return } // CHECK-LABEL: @load_volatile -spv.func @load_volatile() "None" { - %0 = spv.Variable : !spv.ptr +spirv.func @load_volatile() "None" { + %0 = spirv.Variable : !spirv.ptr // CHECK: llvm.load volatile %{{.*}} : !llvm.ptr - %1 = spv.Load "Function" %0 ["Volatile"] : f32 - spv.Return + %1 = spirv.Load "Function" %0 ["Volatile"] : f32 + spirv.Return } // CHECK-LABEL: @load_nontemporal -spv.func @load_nontemporal() "None" { - %0 = spv.Variable : !spv.ptr +spirv.func @load_nontemporal() "None" { + %0 = spirv.Variable : !spirv.ptr // CHECK: llvm.load %{{.*}} {nontemporal} : !llvm.ptr - %1 = spv.Load "Function" %0 ["Nontemporal"] : f32 - spv.Return + %1 = spirv.Load "Function" %0 ["Nontemporal"] : f32 + spirv.Return } //===----------------------------------------------------------------------===// -// spv.Store +// spirv.Store //===----------------------------------------------------------------------===// // CHECK-LABEL: @store -spv.func @store(%arg0 : f32) "None" { - %0 = spv.Variable : !spv.ptr +spirv.func @store(%arg0 : f32) "None" { + %0 = spirv.Variable : !spirv.ptr // CHECK: llvm.store %{{.*}}, %{{.*}} : !llvm.ptr - spv.Store "Function" %0, %arg0 : f32 - spv.Return + spirv.Store "Function" %0, %arg0 : f32 + spirv.Return } // CHECK-LABEL: @store_composite -spv.func @store_composite(%arg0 : !spv.struct<(f64)>) "None" { - %0 = spv.Variable : !spv.ptr, Function> +spirv.func @store_composite(%arg0 : !spirv.struct<(f64)>) "None" { + %0 = spirv.Variable : !spirv.ptr, Function> // CHECK: llvm.store %{{.*}}, %{{.*}} : !llvm.ptr> - spv.Store "Function" %0, %arg0 : !spv.struct<(f64)> - spv.Return + spirv.Store "Function" %0, %arg0 : !spirv.struct<(f64)> + spirv.Return } // CHECK-LABEL: @store_with_alignment -spv.func @store_with_alignment(%arg0 : f32) "None" { - %0 = spv.Variable : !spv.ptr +spirv.func @store_with_alignment(%arg0 : f32) "None" { + %0 = spirv.Variable : !spirv.ptr // CHECK: llvm.store %{{.*}}, %{{.*}} {alignment = 4 : i64} : !llvm.ptr - spv.Store "Function" %0, %arg0 ["Aligned", 4] : f32 - spv.Return + spirv.Store "Function" %0, %arg0 ["Aligned", 4] : f32 + spirv.Return } // CHECK-LABEL: @store_volatile -spv.func @store_volatile(%arg0 : f32) "None" { - %0 = spv.Variable : !spv.ptr +spirv.func @store_volatile(%arg0 : f32) "None" { + %0 = spirv.Variable : !spirv.ptr // CHECK: llvm.store volatile %{{.*}}, %{{.*}} : !llvm.ptr - spv.Store "Function" %0, %arg0 ["Volatile"] : f32 - spv.Return + spirv.Store "Function" %0, %arg0 ["Volatile"] : f32 + spirv.Return } // CHECK-LABEL: @store_nontemporal -spv.func @store_nontemporal(%arg0 : f32) "None" { - %0 = spv.Variable : !spv.ptr +spirv.func @store_nontemporal(%arg0 : f32) "None" { + %0 = spirv.Variable : !spirv.ptr // CHECK: llvm.store %{{.*}}, %{{.*}} {nontemporal} : !llvm.ptr - spv.Store "Function" %0, %arg0 ["Nontemporal"] : f32 - spv.Return + spirv.Store "Function" %0, %arg0 ["Nontemporal"] : f32 + spirv.Return } //===----------------------------------------------------------------------===// -// spv.Variable +// spirv.Variable //===----------------------------------------------------------------------===// // CHECK-LABEL: @variable_scalar -spv.func @variable_scalar() "None" { +spirv.func @variable_scalar() "None" { // CHECK: %[[SIZE1:.*]] = llvm.mlir.constant(1 : i32) : i32 // CHECK: llvm.alloca %[[SIZE1]] x f32 : (i32) -> !llvm.ptr - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // CHECK: %[[SIZE2:.*]] = llvm.mlir.constant(1 : i32) : i32 // CHECK: llvm.alloca %[[SIZE2]] x i8 : (i32) -> !llvm.ptr - %1 = spv.Variable : !spv.ptr - spv.Return + %1 = spirv.Variable : !spirv.ptr + spirv.Return } // CHECK-LABEL: @variable_scalar_with_initialization -spv.func @variable_scalar_with_initialization() "None" { +spirv.func @variable_scalar_with_initialization() "None" { // CHECK: %[[VALUE:.*]] = llvm.mlir.constant(0 : i64) : i64 // CHECK: %[[SIZE:.*]] = llvm.mlir.constant(1 : i32) : i32 // CHECK: %[[ALLOCATED:.*]] = llvm.alloca %[[SIZE]] x i64 : (i32) -> !llvm.ptr // CHECK: llvm.store %[[VALUE]], %[[ALLOCATED]] : !llvm.ptr - %c = spv.Constant 0 : i64 - %0 = spv.Variable init(%c) : !spv.ptr - spv.Return + %c = spirv.Constant 0 : i64 + %0 = spirv.Variable init(%c) : !spirv.ptr + spirv.Return } // CHECK-LABEL: @variable_vector -spv.func @variable_vector() "None" { +spirv.func @variable_vector() "None" { // CHECK: %[[SIZE:.*]] = llvm.mlir.constant(1 : i32) : i32 // CHECK: llvm.alloca %[[SIZE]] x vector<3xf32> : (i32) -> !llvm.ptr> - %0 = spv.Variable : !spv.ptr, Function> - spv.Return + %0 = spirv.Variable : !spirv.ptr, Function> + spirv.Return } // CHECK-LABEL: @variable_vector_with_initialization -spv.func @variable_vector_with_initialization() "None" { +spirv.func @variable_vector_with_initialization() "None" { // CHECK: %[[VALUE:.*]] = llvm.mlir.constant(dense : vector<3xi1>) : vector<3xi1> // CHECK: %[[SIZE:.*]] = llvm.mlir.constant(1 : i32) : i32 // CHECK: %[[ALLOCATED:.*]] = llvm.alloca %[[SIZE]] x vector<3xi1> : (i32) -> !llvm.ptr> // CHECK: llvm.store %[[VALUE]], %[[ALLOCATED]] : !llvm.ptr> - %c = spv.Constant dense : vector<3xi1> - %0 = spv.Variable init(%c) : !spv.ptr, Function> - spv.Return + %c = spirv.Constant dense : vector<3xi1> + %0 = spirv.Variable init(%c) : !spirv.ptr, Function> + spirv.Return } // CHECK-LABEL: @variable_array -spv.func @variable_array() "None" { +spirv.func @variable_array() "None" { // CHECK: %[[SIZE:.*]] = llvm.mlir.constant(1 : i32) : i32 // CHECK: llvm.alloca %[[SIZE]] x !llvm.array<10 x i32> : (i32) -> !llvm.ptr> - %0 = spv.Variable : !spv.ptr, Function> - spv.Return + %0 = spirv.Variable : !spirv.ptr, Function> + spirv.Return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/misc-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/misc-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/misc-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/misc-ops-to-llvm.mlir @@ -1,75 +1,75 @@ // RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.CompositeExtract +// spirv.CompositeExtract //===----------------------------------------------------------------------===// // CHECK-LABEL: @composite_extract_array -spv.func @composite_extract_array(%arg: !spv.array<4x!spv.array<4xf32>>) "None" { +spirv.func @composite_extract_array(%arg: !spirv.array<4x!spirv.array<4xf32>>) "None" { // CHECK: llvm.extractvalue %{{.*}}[1, 3] : !llvm.array<4 x array<4 x f32>> - %0 = spv.CompositeExtract %arg[1 : i32, 3 : i32] : !spv.array<4x!spv.array<4xf32>> - spv.Return + %0 = spirv.CompositeExtract %arg[1 : i32, 3 : i32] : !spirv.array<4x!spirv.array<4xf32>> + spirv.Return } // CHECK-LABEL: @composite_extract_vector -spv.func @composite_extract_vector(%arg: vector<3xf32>) "None" { +spirv.func @composite_extract_vector(%arg: vector<3xf32>) "None" { // CHECK: %[[ZERO:.*]] = llvm.mlir.constant(0 : i32) : i32 // CHECK: llvm.extractelement %{{.*}}[%[[ZERO]] : i32] : vector<3xf32> - %0 = spv.CompositeExtract %arg[0 : i32] : vector<3xf32> - spv.Return + %0 = spirv.CompositeExtract %arg[0 : i32] : vector<3xf32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.CompositeInsert +// spirv.CompositeInsert //===----------------------------------------------------------------------===// // CHECK-LABEL: @composite_insert_struct -spv.func @composite_insert_struct(%arg0: i32, %arg1: !spv.struct<(f32, !spv.array<4xi32>)>) "None" { +spirv.func @composite_insert_struct(%arg0: i32, %arg1: !spirv.struct<(f32, !spirv.array<4xi32>)>) "None" { // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[1, 3] : !llvm.struct)> - %0 = spv.CompositeInsert %arg0, %arg1[1 : i32, 3 : i32] : i32 into !spv.struct<(f32, !spv.array<4xi32>)> - spv.Return + %0 = spirv.CompositeInsert %arg0, %arg1[1 : i32, 3 : i32] : i32 into !spirv.struct<(f32, !spirv.array<4xi32>)> + spirv.Return } // CHECK-LABEL: @composite_insert_vector -spv.func @composite_insert_vector(%arg0: vector<3xf32>, %arg1: f32) "None" { +spirv.func @composite_insert_vector(%arg0: vector<3xf32>, %arg1: f32) "None" { // CHECK: %[[ONE:.*]] = llvm.mlir.constant(1 : i32) : i32 // CHECK: llvm.insertelement %{{.*}}, %{{.*}}[%[[ONE]] : i32] : vector<3xf32> - %0 = spv.CompositeInsert %arg1, %arg0[1 : i32] : f32 into vector<3xf32> - spv.Return + %0 = spirv.CompositeInsert %arg1, %arg0[1 : i32] : f32 into vector<3xf32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.Select +// spirv.Select //===----------------------------------------------------------------------===// // CHECK-LABEL: @select_scalar -spv.func @select_scalar(%arg0: i1, %arg1: vector<3xi32>, %arg2: f32) "None" { +spirv.func @select_scalar(%arg0: i1, %arg1: vector<3xi32>, %arg2: f32) "None" { // CHECK: llvm.select %{{.*}}, %{{.*}}, %{{.*}} : i1, vector<3xi32> - %0 = spv.Select %arg0, %arg1, %arg1 : i1, vector<3xi32> + %0 = spirv.Select %arg0, %arg1, %arg1 : i1, vector<3xi32> // CHECK: llvm.select %{{.*}}, %{{.*}}, %{{.*}} : i1, f32 - %1 = spv.Select %arg0, %arg2, %arg2 : i1, f32 - spv.Return + %1 = spirv.Select %arg0, %arg2, %arg2 : i1, f32 + spirv.Return } // CHECK-LABEL: @select_vector -spv.func @select_vector(%arg0: vector<2xi1>, %arg1: vector<2xi32>) "None" { +spirv.func @select_vector(%arg0: vector<2xi1>, %arg1: vector<2xi32>) "None" { // CHECK: llvm.select %{{.*}}, %{{.*}}, %{{.*}} : vector<2xi1>, vector<2xi32> - %0 = spv.Select %arg0, %arg1, %arg1 : vector<2xi1>, vector<2xi32> - spv.Return + %0 = spirv.Select %arg0, %arg1, %arg1 : vector<2xi1>, vector<2xi32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.VectorShuffle +// spirv.VectorShuffle //===----------------------------------------------------------------------===// -spv.func @vector_shuffle_same_size(%vector1: vector<2xf32>, %vector2: vector<2xf32>) -> vector<3xf32> "None" { +spirv.func @vector_shuffle_same_size(%vector1: vector<2xf32>, %vector2: vector<2xf32>) -> vector<3xf32> "None" { // CHECK: %[[res:.*]] = llvm.shufflevector {{.*}} [0, 2, -1] : vector<2xf32> // CHECK-NEXT: return %[[res]] : vector<3xf32> - %0 = spv.VectorShuffle [0: i32, 2: i32, 0xffffffff: i32] %vector1: vector<2xf32>, %vector2: vector<2xf32> -> vector<3xf32> - spv.ReturnValue %0: vector<3xf32> + %0 = spirv.VectorShuffle [0: i32, 2: i32, 0xffffffff: i32] %vector1: vector<2xf32>, %vector2: vector<2xf32> -> vector<3xf32> + spirv.ReturnValue %0: vector<3xf32> } -spv.func @vector_shuffle_different_size(%vector1: vector<3xf32>, %vector2: vector<2xf32>) -> vector<3xf32> "None" { +spirv.func @vector_shuffle_different_size(%vector1: vector<3xf32>, %vector2: vector<2xf32>) -> vector<3xf32> "None" { // CHECK: %[[UNDEF:.*]] = llvm.mlir.undef : vector<3xf32> // CHECK-NEXT: %[[C0_0:.*]] = llvm.mlir.constant(0 : i32) : i32 // CHECK-NEXT: %[[C0_1:.*]] = llvm.mlir.constant(0 : i32) : i32 @@ -80,12 +80,12 @@ // CHECK-NEXT: %[[EXT1:.*]] = llvm.extractelement {{.*}}[%[[C1_1]] : i32] : vector<2xf32> // CHECK-NEXT: %[[RES:.*]] = llvm.insertelement %[[EXT1]], %[[INSERT0]][%[[C1_0]] : i32] : vector<3xf32> // CHECK-NEXT: llvm.return %[[RES]] : vector<3xf32> - %0 = spv.VectorShuffle [0: i32, 4: i32, 0xffffffff: i32] %vector1: vector<3xf32>, %vector2: vector<2xf32> -> vector<3xf32> - spv.ReturnValue %0: vector<3xf32> + %0 = spirv.VectorShuffle [0: i32, 4: i32, 0xffffffff: i32] %vector1: vector<3xf32>, %vector2: vector<2xf32> -> vector<3xf32> + spirv.ReturnValue %0: vector<3xf32> } //===----------------------------------------------------------------------===// -// spv.EntryPoint and spv.ExecutionMode +// spirv.EntryPoint and spirv.ExecutionMode //===----------------------------------------------------------------------===// // CHECK: module { @@ -99,12 +99,12 @@ // CHECK-NEXT: llvm.return // CHECK-NEXT: } // CHECK-NEXT: } -spv.module Logical OpenCL { - spv.func @empty() "None" { - spv.Return +spirv.module Logical OpenCL { + spirv.func @empty() "None" { + spirv.Return } - spv.EntryPoint "Kernel" @empty - spv.ExecutionMode @empty "ContractionOff" + spirv.EntryPoint "Kernel" @empty + spirv.ExecutionMode @empty "ContractionOff" } // CHECK: module { @@ -125,29 +125,29 @@ // CHECK-NEXT: llvm.return // CHECK-NEXT: } // CHECK-NEXT: } -spv.module Logical OpenCL { - spv.func @bar() "None" { - spv.Return +spirv.module Logical OpenCL { + spirv.func @bar() "None" { + spirv.Return } - spv.EntryPoint "Kernel" @bar - spv.ExecutionMode @bar "ContractionOff" - spv.ExecutionMode @bar "LocalSizeHint", 32, 1, 1 + spirv.EntryPoint "Kernel" @bar + spirv.ExecutionMode @bar "ContractionOff" + spirv.ExecutionMode @bar "LocalSizeHint", 32, 1, 1 } //===----------------------------------------------------------------------===// -// spv.Undef +// spirv.Undef //===----------------------------------------------------------------------===// // CHECK-LABEL: @undef_scalar -spv.func @undef_scalar() "None" { +spirv.func @undef_scalar() "None" { // CHECK: llvm.mlir.undef : f32 - %0 = spv.Undef : f32 - spv.Return + %0 = spirv.Undef : f32 + spirv.Return } // CHECK-LABEL: @undef_vector -spv.func @undef_vector() "None" { +spirv.func @undef_vector() "None" { // CHECK: llvm.mlir.undef : vector<2xi32> - %0 = spv.Undef : vector<2xi32> - spv.Return + %0 = spirv.Undef : vector<2xi32> + spirv.Return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/module-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/module-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/module-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/module-ops-to-llvm.mlir @@ -1,23 +1,23 @@ // RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.module +// spirv.module //===----------------------------------------------------------------------===// // CHECK: module -spv.module Logical GLSL450 {} +spirv.module Logical GLSL450 {} // CHECK: module @foo -spv.module @foo Logical GLSL450 {} +spirv.module @foo Logical GLSL450 {} // CHECK: module -spv.module Logical GLSL450 requires #spv.vce {} +spirv.module Logical GLSL450 requires #spirv.vce {} // CHECK: module -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { // CHECK-LABEL: llvm.func @empty() - spv.func @empty() -> () "None" { + spirv.func @empty() -> () "None" { // CHECK: llvm.return - spv.Return + spirv.Return } } diff --git a/mlir/test/Conversion/SPIRVToLLVM/shift-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/shift-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/shift-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/shift-ops-to-llvm.mlir @@ -1,121 +1,121 @@ // RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.ShiftRightArithmetic +// spirv.ShiftRightArithmetic //===----------------------------------------------------------------------===// // CHECK-LABEL: @shift_right_arithmetic_scalar -spv.func @shift_right_arithmetic_scalar(%arg0: i32, %arg1: si32, %arg2 : i16, %arg3 : ui16) "None" { +spirv.func @shift_right_arithmetic_scalar(%arg0: i32, %arg1: si32, %arg2 : i16, %arg3 : ui16) "None" { // CHECK: llvm.ashr %{{.*}}, %{{.*}} : i32 - %0 = spv.ShiftRightArithmetic %arg0, %arg0 : i32, i32 + %0 = spirv.ShiftRightArithmetic %arg0, %arg0 : i32, i32 // CHECK: llvm.ashr %{{.*}}, %{{.*}} : i32 - %1 = spv.ShiftRightArithmetic %arg0, %arg1 : i32, si32 + %1 = spirv.ShiftRightArithmetic %arg0, %arg1 : i32, si32 // CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : i16 to i32 // CHECK: llvm.ashr %{{.*}}, %[[SEXT]] : i32 - %2 = spv.ShiftRightArithmetic %arg0, %arg2 : i32, i16 + %2 = spirv.ShiftRightArithmetic %arg0, %arg2 : i32, i16 // CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : i16 to i32 // CHECK: llvm.ashr %{{.*}}, %[[ZEXT]] : i32 - %3 = spv.ShiftRightArithmetic %arg0, %arg3 : i32, ui16 - spv.Return + %3 = spirv.ShiftRightArithmetic %arg0, %arg3 : i32, ui16 + spirv.Return } // CHECK-LABEL: @shift_right_arithmetic_vector -spv.func @shift_right_arithmetic_vector(%arg0: vector<4xi64>, %arg1: vector<4xui64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) "None" { +spirv.func @shift_right_arithmetic_vector(%arg0: vector<4xi64>, %arg1: vector<4xui64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) "None" { // CHECK: llvm.ashr %{{.*}}, %{{.*}} : vector<4xi64> - %0 = spv.ShiftRightArithmetic %arg0, %arg0 : vector<4xi64>, vector<4xi64> + %0 = spirv.ShiftRightArithmetic %arg0, %arg0 : vector<4xi64>, vector<4xi64> // CHECK: llvm.ashr %{{.*}}, %{{.*}} : vector<4xi64> - %1 = spv.ShiftRightArithmetic %arg0, %arg1 : vector<4xi64>, vector<4xui64> + %1 = spirv.ShiftRightArithmetic %arg0, %arg1 : vector<4xi64>, vector<4xui64> // CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : vector<4xi32> to vector<4xi64> // CHECK: llvm.ashr %{{.*}}, %[[SEXT]] : vector<4xi64> - %2 = spv.ShiftRightArithmetic %arg0, %arg2 : vector<4xi64>, vector<4xi32> + %2 = spirv.ShiftRightArithmetic %arg0, %arg2 : vector<4xi64>, vector<4xi32> // CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : vector<4xi32> to vector<4xi64> // CHECK: llvm.ashr %{{.*}}, %[[ZEXT]] : vector<4xi64> - %3 = spv.ShiftRightArithmetic %arg0, %arg3 : vector<4xi64>, vector<4xui32> - spv.Return + %3 = spirv.ShiftRightArithmetic %arg0, %arg3 : vector<4xi64>, vector<4xui32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.ShiftRightLogical +// spirv.ShiftRightLogical //===----------------------------------------------------------------------===// // CHECK-LABEL: @shift_right_logical_scalar -spv.func @shift_right_logical_scalar(%arg0: i32, %arg1: si32, %arg2 : si16, %arg3 : ui16) "None" { +spirv.func @shift_right_logical_scalar(%arg0: i32, %arg1: si32, %arg2 : si16, %arg3 : ui16) "None" { // CHECK: llvm.lshr %{{.*}}, %{{.*}} : i32 - %0 = spv.ShiftRightLogical %arg0, %arg0 : i32, i32 + %0 = spirv.ShiftRightLogical %arg0, %arg0 : i32, i32 // CHECK: llvm.lshr %{{.*}}, %{{.*}} : i32 - %1 = spv.ShiftRightLogical %arg0, %arg1 : i32, si32 + %1 = spirv.ShiftRightLogical %arg0, %arg1 : i32, si32 // CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : i16 to i32 // CHECK: llvm.lshr %{{.*}}, %[[SEXT]] : i32 - %2 = spv.ShiftRightLogical %arg0, %arg2 : i32, si16 + %2 = spirv.ShiftRightLogical %arg0, %arg2 : i32, si16 // CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : i16 to i32 // CHECK: llvm.lshr %{{.*}}, %[[ZEXT]] : i32 - %3 = spv.ShiftRightLogical %arg0, %arg3 : i32, ui16 - spv.Return + %3 = spirv.ShiftRightLogical %arg0, %arg3 : i32, ui16 + spirv.Return } // CHECK-LABEL: @shift_right_logical_vector -spv.func @shift_right_logical_vector(%arg0: vector<4xi64>, %arg1: vector<4xsi64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) "None" { +spirv.func @shift_right_logical_vector(%arg0: vector<4xi64>, %arg1: vector<4xsi64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) "None" { // CHECK: llvm.lshr %{{.*}}, %{{.*}} : vector<4xi64> - %0 = spv.ShiftRightLogical %arg0, %arg0 : vector<4xi64>, vector<4xi64> + %0 = spirv.ShiftRightLogical %arg0, %arg0 : vector<4xi64>, vector<4xi64> // CHECK: llvm.lshr %{{.*}}, %{{.*}} : vector<4xi64> - %1 = spv.ShiftRightLogical %arg0, %arg1 : vector<4xi64>, vector<4xsi64> + %1 = spirv.ShiftRightLogical %arg0, %arg1 : vector<4xi64>, vector<4xsi64> // CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : vector<4xi32> to vector<4xi64> // CHECK: llvm.lshr %{{.*}}, %[[SEXT]] : vector<4xi64> - %2 = spv.ShiftRightLogical %arg0, %arg2 : vector<4xi64>, vector<4xi32> + %2 = spirv.ShiftRightLogical %arg0, %arg2 : vector<4xi64>, vector<4xi32> // CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : vector<4xi32> to vector<4xi64> // CHECK: llvm.lshr %{{.*}}, %[[ZEXT]] : vector<4xi64> - %3 = spv.ShiftRightLogical %arg0, %arg3 : vector<4xi64>, vector<4xui32> - spv.Return + %3 = spirv.ShiftRightLogical %arg0, %arg3 : vector<4xi64>, vector<4xui32> + spirv.Return } //===----------------------------------------------------------------------===// -// spv.ShiftLeftLogical +// spirv.ShiftLeftLogical //===----------------------------------------------------------------------===// // CHECK-LABEL: @shift_left_logical_scalar -spv.func @shift_left_logical_scalar(%arg0: i32, %arg1: si32, %arg2 : i16, %arg3 : ui16) "None" { +spirv.func @shift_left_logical_scalar(%arg0: i32, %arg1: si32, %arg2 : i16, %arg3 : ui16) "None" { // CHECK: llvm.shl %{{.*}}, %{{.*}} : i32 - %0 = spv.ShiftLeftLogical %arg0, %arg0 : i32, i32 + %0 = spirv.ShiftLeftLogical %arg0, %arg0 : i32, i32 // CHECK: llvm.shl %{{.*}}, %{{.*}} : i32 - %1 = spv.ShiftLeftLogical %arg0, %arg1 : i32, si32 + %1 = spirv.ShiftLeftLogical %arg0, %arg1 : i32, si32 // CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : i16 to i32 // CHECK: llvm.shl %{{.*}}, %[[SEXT]] : i32 - %2 = spv.ShiftLeftLogical %arg0, %arg2 : i32, i16 + %2 = spirv.ShiftLeftLogical %arg0, %arg2 : i32, i16 // CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : i16 to i32 // CHECK: llvm.shl %{{.*}}, %[[ZEXT]] : i32 - %3 = spv.ShiftLeftLogical %arg0, %arg3 : i32, ui16 - spv.Return + %3 = spirv.ShiftLeftLogical %arg0, %arg3 : i32, ui16 + spirv.Return } // CHECK-LABEL: @shift_left_logical_vector -spv.func @shift_left_logical_vector(%arg0: vector<4xi64>, %arg1: vector<4xsi64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) "None" { +spirv.func @shift_left_logical_vector(%arg0: vector<4xi64>, %arg1: vector<4xsi64>, %arg2: vector<4xi32>, %arg3: vector<4xui32>) "None" { // CHECK: llvm.shl %{{.*}}, %{{.*}} : vector<4xi64> - %0 = spv.ShiftLeftLogical %arg0, %arg0 : vector<4xi64>, vector<4xi64> + %0 = spirv.ShiftLeftLogical %arg0, %arg0 : vector<4xi64>, vector<4xi64> // CHECK: llvm.shl %{{.*}}, %{{.*}} : vector<4xi64> - %1 = spv.ShiftLeftLogical %arg0, %arg1 : vector<4xi64>, vector<4xsi64> + %1 = spirv.ShiftLeftLogical %arg0, %arg1 : vector<4xi64>, vector<4xsi64> // CHECK: %[[SEXT:.*]] = llvm.sext %{{.*}} : vector<4xi32> to vector<4xi64> // CHECK: llvm.shl %{{.*}}, %[[SEXT]] : vector<4xi64> - %2 = spv.ShiftLeftLogical %arg0, %arg2 : vector<4xi64>, vector<4xi32> + %2 = spirv.ShiftLeftLogical %arg0, %arg2 : vector<4xi64>, vector<4xi32> // CHECK: %[[ZEXT:.*]] = llvm.zext %{{.*}} : vector<4xi32> to vector<4xi64> // CHECK: llvm.shl %{{.*}}, %[[ZEXT]] : vector<4xi64> - %3 = spv.ShiftLeftLogical %arg0, %arg3 : vector<4xi64>, vector<4xui32> - spv.Return + %3 = spirv.ShiftLeftLogical %arg0, %arg3 : vector<4xi64>, vector<4xui32> + spirv.Return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/spirv-types-to-llvm-invalid.mlir b/mlir/test/Conversion/SPIRVToLLVM/spirv-types-to-llvm-invalid.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/spirv-types-to-llvm-invalid.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/spirv-types-to-llvm-invalid.mlir @@ -1,20 +1,20 @@ // RUN: mlir-opt %s -convert-spirv-to-llvm -verify-diagnostics -split-input-file -// expected-error@+1 {{failed to legalize operation 'spv.func' that was explicitly marked illegal}} -spv.func @array_with_unnatural_stride(%arg: !spv.array<4 x f32, stride=8>) -> () "None" { - spv.Return +// expected-error@+1 {{failed to legalize operation 'spirv.func' that was explicitly marked illegal}} +spirv.func @array_with_unnatural_stride(%arg: !spirv.array<4 x f32, stride=8>) -> () "None" { + spirv.Return } // ----- -// expected-error@+1 {{failed to legalize operation 'spv.func' that was explicitly marked illegal}} -spv.func @struct_with_unnatural_offset(%arg: !spv.struct<(i32[0], i32[8])>) -> () "None" { - spv.Return +// expected-error@+1 {{failed to legalize operation 'spirv.func' that was explicitly marked illegal}} +spirv.func @struct_with_unnatural_offset(%arg: !spirv.struct<(i32[0], i32[8])>) -> () "None" { + spirv.Return } // ----- -// expected-error@+1 {{failed to legalize operation 'spv.func' that was explicitly marked illegal}} -spv.func @struct_with_decorations(%arg: !spv.struct<(f32 [RelaxedPrecision])>) -> () "None" { - spv.Return +// expected-error@+1 {{failed to legalize operation 'spirv.func' that was explicitly marked illegal}} +spirv.func @struct_with_decorations(%arg: !spirv.struct<(f32 [RelaxedPrecision])>) -> () "None" { + spirv.Return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/spirv-types-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/spirv-types-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/spirv-types-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/spirv-types-to-llvm.mlir @@ -5,40 +5,40 @@ //===----------------------------------------------------------------------===// // CHECK-LABEL: @array(!llvm.array<16 x f32>, !llvm.array<32 x vector<4xf32>>) -spv.func @array(!spv.array<16 x f32>, !spv.array< 32 x vector<4xf32> >) "None" +spirv.func @array(!spirv.array<16 x f32>, !spirv.array< 32 x vector<4xf32> >) "None" // CHECK-LABEL: @array_with_natural_stride(!llvm.array<16 x f32>) -spv.func @array_with_natural_stride(!spv.array<16 x f32, stride=4>) "None" +spirv.func @array_with_natural_stride(!spirv.array<16 x f32, stride=4>) "None" //===----------------------------------------------------------------------===// // Pointer type //===----------------------------------------------------------------------===// // CHECK-LABEL: @pointer_scalar(!llvm.ptr, !llvm.ptr) -spv.func @pointer_scalar(!spv.ptr, !spv.ptr) "None" +spirv.func @pointer_scalar(!spirv.ptr, !spirv.ptr) "None" // CHECK-LABEL: @pointer_vector(!llvm.ptr>) -spv.func @pointer_vector(!spv.ptr, Function>) "None" +spirv.func @pointer_vector(!spirv.ptr, Function>) "None" //===----------------------------------------------------------------------===// // Runtime array type //===----------------------------------------------------------------------===// // CHECK-LABEL: @runtime_array_vector(!llvm.array<0 x vector<4xf32>>) -spv.func @runtime_array_vector(!spv.rtarray< vector<4xf32> >) "None" +spirv.func @runtime_array_vector(!spirv.rtarray< vector<4xf32> >) "None" // CHECK-LABEL: @runtime_array_scalar(!llvm.array<0 x f32>) -spv.func @runtime_array_scalar(!spv.rtarray) "None" +spirv.func @runtime_array_scalar(!spirv.rtarray) "None" //===----------------------------------------------------------------------===// // Struct type //===----------------------------------------------------------------------===// // CHECK-LABEL: @struct(!llvm.struct) -spv.func @struct(!spv.struct<(f64)>) "None" +spirv.func @struct(!spirv.struct<(f64)>) "None" // CHECK-LABEL: @struct_nested(!llvm.struct)>) -spv.func @struct_nested(!spv.struct<(i32, !spv.struct<(i64, i32)>)>) "None" +spirv.func @struct_nested(!spirv.struct<(i32, !spirv.struct<(i64, i32)>)>) "None" // CHECK-LABEL: @struct_with_natural_offset(!llvm.struct<(i8, i32)>) -spv.func @struct_with_natural_offset(!spv.struct<(i8[0], i32[4])>) "None" +spirv.func @struct_with_natural_offset(!spirv.struct<(i8[0], i32[4])>) "None" diff --git a/mlir/test/Conversion/TensorToSPIRV/tensor-ops-to-spirv.mlir b/mlir/test/Conversion/TensorToSPIRV/tensor-ops-to-spirv.mlir --- a/mlir/test/Conversion/TensorToSPIRV/tensor-ops-to-spirv.mlir +++ b/mlir/test/Conversion/TensorToSPIRV/tensor-ops-to-spirv.mlir @@ -7,23 +7,23 @@ // CHECK-LABEL: func @tensor_extract_constant // CHECK-SAME: (%[[A:.+]]: i32, %[[B:.+]]: i32, %[[C:.+]]: i32) func.func @tensor_extract_constant(%a : index, %b: index, %c: index) -> i32 { - // CHECK: %[[CST:.+]] = spv.Constant dense<[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]> + // CHECK: %[[CST:.+]] = spirv.Constant dense<[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]> %cst = arith.constant dense<[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]> : tensor<2x2x3xi32> - // CHECK: %[[VAR:.+]] = spv.Variable : !spv.ptr, Function> - // CHECK: spv.Store "Function" %[[VAR]], %[[CST]] : !spv.array<12 x i32> - // CHECK: %[[C0:.+]] = spv.Constant 0 : i32 - // CHECK: %[[C6:.+]] = spv.Constant 6 : i32 - // CHECK: %[[MUL0:.+]] = spv.IMul %[[C6]], %[[A]] : i32 - // CHECK: %[[ADD0:.+]] = spv.IAdd %[[C0]], %[[MUL0]] : i32 - // CHECK: %[[C3:.+]] = spv.Constant 3 : i32 - // CHECK: %[[MUL1:.+]] = spv.IMul %[[C3]], %[[B]] : i32 - // CHECK: %[[ADD1:.+]] = spv.IAdd %[[ADD0]], %[[MUL1]] : i32 - // CHECK: %[[C1:.+]] = spv.Constant 1 : i32 - // CHECK: %[[MUL2:.+]] = spv.IMul %[[C1]], %[[C]] : i32 - // CHECK: %[[ADD2:.+]] = spv.IAdd %[[ADD1]], %[[MUL2]] : i32 - // CHECK: %[[AC:.+]] = spv.AccessChain %[[VAR]][%[[ADD2]]] - // CHECK: %[[VAL:.+]] = spv.Load "Function" %[[AC]] : i32 + // CHECK: %[[VAR:.+]] = spirv.Variable : !spirv.ptr, Function> + // CHECK: spirv.Store "Function" %[[VAR]], %[[CST]] : !spirv.array<12 x i32> + // CHECK: %[[C0:.+]] = spirv.Constant 0 : i32 + // CHECK: %[[C6:.+]] = spirv.Constant 6 : i32 + // CHECK: %[[MUL0:.+]] = spirv.IMul %[[C6]], %[[A]] : i32 + // CHECK: %[[ADD0:.+]] = spirv.IAdd %[[C0]], %[[MUL0]] : i32 + // CHECK: %[[C3:.+]] = spirv.Constant 3 : i32 + // CHECK: %[[MUL1:.+]] = spirv.IMul %[[C3]], %[[B]] : i32 + // CHECK: %[[ADD1:.+]] = spirv.IAdd %[[ADD0]], %[[MUL1]] : i32 + // CHECK: %[[C1:.+]] = spirv.Constant 1 : i32 + // CHECK: %[[MUL2:.+]] = spirv.IMul %[[C1]], %[[C]] : i32 + // CHECK: %[[ADD2:.+]] = spirv.IAdd %[[ADD1]], %[[MUL2]] : i32 + // CHECK: %[[AC:.+]] = spirv.AccessChain %[[VAR]][%[[ADD2]]] + // CHECK: %[[VAL:.+]] = spirv.Load "Function" %[[AC]] : i32 %extract = tensor.extract %cst[%a, %b, %c] : tensor<2x2x3xi32> - // CHECK: spv.ReturnValue %[[VAL]] + // CHECK: spirv.ReturnValue %[[VAL]] return %extract : i32 } diff --git a/mlir/test/Conversion/VectorToSPIRV/vector-to-spirv.mlir b/mlir/test/Conversion/VectorToSPIRV/vector-to-spirv.mlir --- a/mlir/test/Conversion/VectorToSPIRV/vector-to-spirv.mlir +++ b/mlir/test/Conversion/VectorToSPIRV/vector-to-spirv.mlir @@ -1,11 +1,11 @@ // RUN: mlir-opt -split-input-file -convert-vector-to-spirv -verify-diagnostics %s -o - | FileCheck %s -module attributes { spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> } { +module attributes { spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @bitcast // CHECK-SAME: %[[ARG0:.+]]: vector<2xf32>, %[[ARG1:.+]]: vector<2xf16> -// CHECK: spv.Bitcast %[[ARG0]] : vector<2xf32> to vector<4xf16> -// CHECK: spv.Bitcast %[[ARG1]] : vector<2xf16> to f32 +// CHECK: spirv.Bitcast %[[ARG0]] : vector<2xf32> to vector<4xf16> +// CHECK: spirv.Bitcast %[[ARG1]] : vector<2xf16> to f32 func.func @bitcast(%arg0 : vector<2xf32>, %arg1: vector<2xf16>) -> (vector<4xf16>, vector<1xf32>) { %0 = vector.bitcast %arg0 : vector<2xf32> to vector<4xf16> %1 = vector.bitcast %arg1 : vector<2xf16> to vector<1xf32> @@ -16,18 +16,18 @@ // ----- -module attributes { spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> } { +module attributes { spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK-LABEL: @cl_fma // CHECK-SAME: %[[A:.*]]: vector<4xf32>, %[[B:.*]]: vector<4xf32>, %[[C:.*]]: vector<4xf32> -// CHECK: spv.CL.fma %[[A]], %[[B]], %[[C]] : vector<4xf32> +// CHECK: spirv.CL.fma %[[A]], %[[B]], %[[C]] : vector<4xf32> func.func @cl_fma(%a: vector<4xf32>, %b: vector<4xf32>, %c: vector<4xf32>) -> vector<4xf32> { %0 = vector.fma %a, %b, %c: vector<4xf32> return %0 : vector<4xf32> } // CHECK-LABEL: @cl_fma_size1_vector -// CHECK: spv.CL.fma %{{.+}} : f32 +// CHECK: spirv.CL.fma %{{.+}} : f32 func.func @cl_fma_size1_vector(%a: vector<1xf32>, %b: vector<1xf32>, %c: vector<1xf32>) -> vector<1xf32> { %0 = vector.fma %a, %b, %c: vector<1xf32> return %0 : vector<1xf32> @@ -35,12 +35,12 @@ // CHECK-LABEL: func @cl_reduction_maxf // CHECK-SAME: (%[[V:.+]]: vector<3xf32>, %[[S:.+]]: f32) -// CHECK: %[[S0:.+]] = spv.CompositeExtract %[[V]][0 : i32] : vector<3xf32> -// CHECK: %[[S1:.+]] = spv.CompositeExtract %[[V]][1 : i32] : vector<3xf32> -// CHECK: %[[S2:.+]] = spv.CompositeExtract %[[V]][2 : i32] : vector<3xf32> -// CHECK: %[[MAX0:.+]] = spv.CL.fmax %[[S0]], %[[S1]] -// CHECK: %[[MAX1:.+]] = spv.CL.fmax %[[MAX0]], %[[S2]] -// CHECK: %[[MAX2:.+]] = spv.CL.fmax %[[MAX1]], %[[S]] +// CHECK: %[[S0:.+]] = spirv.CompositeExtract %[[V]][0 : i32] : vector<3xf32> +// CHECK: %[[S1:.+]] = spirv.CompositeExtract %[[V]][1 : i32] : vector<3xf32> +// CHECK: %[[S2:.+]] = spirv.CompositeExtract %[[V]][2 : i32] : vector<3xf32> +// CHECK: %[[MAX0:.+]] = spirv.CL.fmax %[[S0]], %[[S1]] +// CHECK: %[[MAX1:.+]] = spirv.CL.fmax %[[MAX0]], %[[S2]] +// CHECK: %[[MAX2:.+]] = spirv.CL.fmax %[[MAX1]], %[[S]] // CHECK: return %[[MAX2]] func.func @cl_reduction_maxf(%v : vector<3xf32>, %s: f32) -> f32 { %reduce = vector.reduction , %v, %s : vector<3xf32> into f32 @@ -49,12 +49,12 @@ // CHECK-LABEL: func @cl_reduction_minf // CHECK-SAME: (%[[V:.+]]: vector<3xf32>, %[[S:.+]]: f32) -// CHECK: %[[S0:.+]] = spv.CompositeExtract %[[V]][0 : i32] : vector<3xf32> -// CHECK: %[[S1:.+]] = spv.CompositeExtract %[[V]][1 : i32] : vector<3xf32> -// CHECK: %[[S2:.+]] = spv.CompositeExtract %[[V]][2 : i32] : vector<3xf32> -// CHECK: %[[MIN0:.+]] = spv.CL.fmin %[[S0]], %[[S1]] -// CHECK: %[[MIN1:.+]] = spv.CL.fmin %[[MIN0]], %[[S2]] -// CHECK: %[[MIN2:.+]] = spv.CL.fmin %[[MIN1]], %[[S]] +// CHECK: %[[S0:.+]] = spirv.CompositeExtract %[[V]][0 : i32] : vector<3xf32> +// CHECK: %[[S1:.+]] = spirv.CompositeExtract %[[V]][1 : i32] : vector<3xf32> +// CHECK: %[[S2:.+]] = spirv.CompositeExtract %[[V]][2 : i32] : vector<3xf32> +// CHECK: %[[MIN0:.+]] = spirv.CL.fmin %[[S0]], %[[S1]] +// CHECK: %[[MIN1:.+]] = spirv.CL.fmin %[[MIN0]], %[[S2]] +// CHECK: %[[MIN2:.+]] = spirv.CL.fmin %[[MIN1]], %[[S]] // CHECK: return %[[MIN2]] func.func @cl_reduction_minf(%v : vector<3xf32>, %s: f32) -> f32 { %reduce = vector.reduction , %v, %s : vector<3xf32> into f32 @@ -63,12 +63,12 @@ // CHECK-LABEL: func @cl_reduction_maxsi // CHECK-SAME: (%[[V:.+]]: vector<3xi32>, %[[S:.+]]: i32) -// CHECK: %[[S0:.+]] = spv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> -// CHECK: %[[S1:.+]] = spv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> -// CHECK: %[[S2:.+]] = spv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> -// CHECK: %[[MAX0:.+]] = spv.CL.s_max %[[S0]], %[[S1]] -// CHECK: %[[MAX1:.+]] = spv.CL.s_max %[[MAX0]], %[[S2]] -// CHECK: %[[MAX2:.+]] = spv.CL.s_max %[[MAX1]], %[[S]] +// CHECK: %[[S0:.+]] = spirv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> +// CHECK: %[[S1:.+]] = spirv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> +// CHECK: %[[S2:.+]] = spirv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> +// CHECK: %[[MAX0:.+]] = spirv.CL.s_max %[[S0]], %[[S1]] +// CHECK: %[[MAX1:.+]] = spirv.CL.s_max %[[MAX0]], %[[S2]] +// CHECK: %[[MAX2:.+]] = spirv.CL.s_max %[[MAX1]], %[[S]] // CHECK: return %[[MAX2]] func.func @cl_reduction_maxsi(%v : vector<3xi32>, %s: i32) -> i32 { %reduce = vector.reduction , %v, %s : vector<3xi32> into i32 @@ -77,12 +77,12 @@ // CHECK-LABEL: func @cl_reduction_minsi // CHECK-SAME: (%[[V:.+]]: vector<3xi32>, %[[S:.+]]: i32) -// CHECK: %[[S0:.+]] = spv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> -// CHECK: %[[S1:.+]] = spv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> -// CHECK: %[[S2:.+]] = spv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> -// CHECK: %[[MIN0:.+]] = spv.CL.s_min %[[S0]], %[[S1]] -// CHECK: %[[MIN1:.+]] = spv.CL.s_min %[[MIN0]], %[[S2]] -// CHECK: %[[MIN2:.+]] = spv.CL.s_min %[[MIN1]], %[[S]] +// CHECK: %[[S0:.+]] = spirv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> +// CHECK: %[[S1:.+]] = spirv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> +// CHECK: %[[S2:.+]] = spirv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> +// CHECK: %[[MIN0:.+]] = spirv.CL.s_min %[[S0]], %[[S1]] +// CHECK: %[[MIN1:.+]] = spirv.CL.s_min %[[MIN0]], %[[S2]] +// CHECK: %[[MIN2:.+]] = spirv.CL.s_min %[[MIN1]], %[[S]] // CHECK: return %[[MIN2]] func.func @cl_reduction_minsi(%v : vector<3xi32>, %s: i32) -> i32 { %reduce = vector.reduction , %v, %s : vector<3xi32> into i32 @@ -91,12 +91,12 @@ // CHECK-LABEL: func @cl_reduction_maxui // CHECK-SAME: (%[[V:.+]]: vector<3xi32>, %[[S:.+]]: i32) -// CHECK: %[[S0:.+]] = spv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> -// CHECK: %[[S1:.+]] = spv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> -// CHECK: %[[S2:.+]] = spv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> -// CHECK: %[[MAX0:.+]] = spv.CL.u_max %[[S0]], %[[S1]] -// CHECK: %[[MAX1:.+]] = spv.CL.u_max %[[MAX0]], %[[S2]] -// CHECK: %[[MAX2:.+]] = spv.CL.u_max %[[MAX1]], %[[S]] +// CHECK: %[[S0:.+]] = spirv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> +// CHECK: %[[S1:.+]] = spirv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> +// CHECK: %[[S2:.+]] = spirv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> +// CHECK: %[[MAX0:.+]] = spirv.CL.u_max %[[S0]], %[[S1]] +// CHECK: %[[MAX1:.+]] = spirv.CL.u_max %[[MAX0]], %[[S2]] +// CHECK: %[[MAX2:.+]] = spirv.CL.u_max %[[MAX1]], %[[S]] // CHECK: return %[[MAX2]] func.func @cl_reduction_maxui(%v : vector<3xi32>, %s: i32) -> i32 { %reduce = vector.reduction , %v, %s : vector<3xi32> into i32 @@ -105,12 +105,12 @@ // CHECK-LABEL: func @cl_reduction_minui // CHECK-SAME: (%[[V:.+]]: vector<3xi32>, %[[S:.+]]: i32) -// CHECK: %[[S0:.+]] = spv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> -// CHECK: %[[S1:.+]] = spv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> -// CHECK: %[[S2:.+]] = spv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> -// CHECK: %[[MIN0:.+]] = spv.CL.u_min %[[S0]], %[[S1]] -// CHECK: %[[MIN1:.+]] = spv.CL.u_min %[[MIN0]], %[[S2]] -// CHECK: %[[MIN2:.+]] = spv.CL.u_min %[[MIN1]], %[[S]] +// CHECK: %[[S0:.+]] = spirv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> +// CHECK: %[[S1:.+]] = spirv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> +// CHECK: %[[S2:.+]] = spirv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> +// CHECK: %[[MIN0:.+]] = spirv.CL.u_min %[[S0]], %[[S1]] +// CHECK: %[[MIN1:.+]] = spirv.CL.u_min %[[MIN0]], %[[S2]] +// CHECK: %[[MIN2:.+]] = spirv.CL.u_min %[[MIN1]], %[[S]] // CHECK: return %[[MIN2]] func.func @cl_reduction_minui(%v : vector<3xi32>, %s: i32) -> i32 { %reduce = vector.reduction , %v, %s : vector<3xi32> into i32 @@ -123,8 +123,8 @@ // CHECK-LABEL: @broadcast // CHECK-SAME: %[[A:.*]]: f32 -// CHECK: spv.CompositeConstruct %[[A]], %[[A]], %[[A]], %[[A]] -// CHECK: spv.CompositeConstruct %[[A]], %[[A]] +// CHECK: spirv.CompositeConstruct %[[A]], %[[A]], %[[A]], %[[A]] +// CHECK: spirv.CompositeConstruct %[[A]], %[[A]] func.func @broadcast(%arg0 : f32) -> (vector<4xf32>, vector<2xf32>) { %0 = vector.broadcast %arg0 : f32 to vector<4xf32> %1 = vector.broadcast %arg0 : f32 to vector<2xf32> @@ -135,8 +135,8 @@ // CHECK-LABEL: @extract // CHECK-SAME: %[[ARG:.+]]: vector<2xf32> -// CHECK: spv.CompositeExtract %[[ARG]][0 : i32] : vector<2xf32> -// CHECK: spv.CompositeExtract %[[ARG]][1 : i32] : vector<2xf32> +// CHECK: spirv.CompositeExtract %[[ARG]][0 : i32] : vector<2xf32> +// CHECK: spirv.CompositeExtract %[[ARG]][1 : i32] : vector<2xf32> func.func @extract(%arg0 : vector<2xf32>) -> (vector<1xf32>, f32) { %0 = "vector.extract"(%arg0) {position = [0]} : (vector<2xf32>) -> vector<1xf32> %1 = "vector.extract"(%arg0) {position = [1]} : (vector<2xf32>) -> f32 @@ -158,7 +158,7 @@ // CHECK-LABEL: @insert // CHECK-SAME: %[[V:.*]]: vector<4xf32>, %[[S:.*]]: f32 -// CHECK: spv.CompositeInsert %[[S]], %[[V]][2 : i32] : f32 into vector<4xf32> +// CHECK: spirv.CompositeInsert %[[S]], %[[V]][2 : i32] : f32 into vector<4xf32> func.func @insert(%arg0 : vector<4xf32>, %arg1: f32) -> vector<4xf32> { %1 = vector.insert %arg1, %arg0[2] : f32 into vector<4xf32> return %1: vector<4xf32> @@ -179,7 +179,7 @@ // CHECK-LABEL: @extract_element // CHECK-SAME: %[[V:.*]]: vector<4xf32>, %[[ID:.*]]: i32 -// CHECK: spv.VectorExtractDynamic %[[V]][%[[ID]]] : vector<4xf32>, i32 +// CHECK: spirv.VectorExtractDynamic %[[V]][%[[ID]]] : vector<4xf32>, i32 func.func @extract_element(%arg0 : vector<4xf32>, %id : i32) -> f32 { %0 = vector.extractelement %arg0[%id : i32] : vector<4xf32> return %0: f32 @@ -229,8 +229,8 @@ // CHECK-LABEL: @extract_strided_slice // CHECK-SAME: %[[ARG:.+]]: vector<4xf32> -// CHECK: spv.VectorShuffle [1 : i32, 2 : i32] %[[ARG]] : vector<4xf32>, %[[ARG]] : vector<4xf32> -> vector<2xf32> -// CHECK: spv.CompositeExtract %[[ARG]][1 : i32] : vector<4xf32> +// CHECK: spirv.VectorShuffle [1 : i32, 2 : i32] %[[ARG]] : vector<4xf32>, %[[ARG]] : vector<4xf32> -> vector<2xf32> +// CHECK: spirv.CompositeExtract %[[ARG]][1 : i32] : vector<4xf32> func.func @extract_strided_slice(%arg0: vector<4xf32>) -> (vector<2xf32>, vector<1xf32>) { %0 = vector.extract_strided_slice %arg0 {offsets = [1], sizes = [2], strides = [1]} : vector<4xf32> to vector<2xf32> %1 = vector.extract_strided_slice %arg0 {offsets = [1], sizes = [1], strides = [1]} : vector<4xf32> to vector<1xf32> @@ -241,7 +241,7 @@ // CHECK-LABEL: @insert_element // CHECK-SAME: %[[VAL:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[ID:.*]]: i32 -// CHECK: spv.VectorInsertDynamic %[[VAL]], %[[V]][%[[ID]]] : vector<4xf32>, i32 +// CHECK: spirv.VectorInsertDynamic %[[VAL]], %[[V]][%[[ID]]] : vector<4xf32>, i32 func.func @insert_element(%val: f32, %arg0 : vector<4xf32>, %id : i32) -> vector<4xf32> { %0 = vector.insertelement %val, %arg0[%id : i32] : vector<4xf32> return %0: vector<4xf32> @@ -291,7 +291,7 @@ // CHECK-LABEL: @insert_strided_slice // CHECK-SAME: %[[PART:.+]]: vector<2xf32>, %[[ALL:.+]]: vector<4xf32> -// CHECK: spv.VectorShuffle [0 : i32, 4 : i32, 5 : i32, 3 : i32] %[[ALL]] : vector<4xf32>, %[[PART]] : vector<2xf32> -> vector<4xf32> +// CHECK: spirv.VectorShuffle [0 : i32, 4 : i32, 5 : i32, 3 : i32] %[[ALL]] : vector<4xf32>, %[[PART]] : vector<2xf32> -> vector<4xf32> func.func @insert_strided_slice(%arg0: vector<2xf32>, %arg1: vector<4xf32>) -> vector<4xf32> { %0 = vector.insert_strided_slice %arg0, %arg1 {offsets = [1], strides = [1]} : vector<2xf32> into vector<4xf32> return %0 : vector<4xf32> @@ -302,7 +302,7 @@ // CHECK-LABEL: @insert_size1_vector // CHECK-SAME: %[[SUB:.*]]: vector<1xf32>, %[[FULL:.*]]: vector<3xf32> // CHECK: %[[S:.+]] = builtin.unrealized_conversion_cast %[[SUB]] -// CHECK: spv.CompositeInsert %[[S]], %[[FULL]][2 : i32] : f32 into vector<3xf32> +// CHECK: spirv.CompositeInsert %[[S]], %[[FULL]][2 : i32] : f32 into vector<3xf32> func.func @insert_size1_vector(%arg0 : vector<1xf32>, %arg1: vector<3xf32>) -> vector<3xf32> { %1 = vector.insert_strided_slice %arg0, %arg1 {offsets = [2], strides = [1]} : vector<1xf32> into vector<3xf32> return %1 : vector<3xf32> @@ -312,7 +312,7 @@ // CHECK-LABEL: @fma // CHECK-SAME: %[[A:.*]]: vector<4xf32>, %[[B:.*]]: vector<4xf32>, %[[C:.*]]: vector<4xf32> -// CHECK: spv.GL.Fma %[[A]], %[[B]], %[[C]] : vector<4xf32> +// CHECK: spirv.GL.Fma %[[A]], %[[B]], %[[C]] : vector<4xf32> func.func @fma(%a: vector<4xf32>, %b: vector<4xf32>, %c: vector<4xf32>) -> vector<4xf32> { %0 = vector.fma %a, %b, %c: vector<4xf32> return %0 : vector<4xf32> @@ -321,7 +321,7 @@ // ----- // CHECK-LABEL: @fma_size1_vector -// CHECK: spv.GL.Fma %{{.+}} : f32 +// CHECK: spirv.GL.Fma %{{.+}} : f32 func.func @fma_size1_vector(%a: vector<1xf32>, %b: vector<1xf32>, %c: vector<1xf32>) -> vector<1xf32> { %0 = vector.fma %a, %b, %c: vector<1xf32> return %0 : vector<1xf32> @@ -331,7 +331,7 @@ // CHECK-LABEL: func @splat // CHECK-SAME: (%[[A:.+]]: f32) -// CHECK: %[[VAL:.+]] = spv.CompositeConstruct %[[A]], %[[A]], %[[A]], %[[A]] +// CHECK: %[[VAL:.+]] = spirv.CompositeConstruct %[[A]], %[[A]], %[[A]], %[[A]] // CHECK: return %[[VAL]] func.func @splat(%f : f32) -> vector<4xf32> { %splat = vector.splat %f : vector<4xf32> @@ -355,7 +355,7 @@ // CHECK-SAME: %[[ARG0:.+]]: vector<1xf32>, %[[ARG1:.+]]: vector<1xf32> // CHECK: %[[V0:.+]] = builtin.unrealized_conversion_cast %[[ARG0]] // CHECK: %[[V1:.+]] = builtin.unrealized_conversion_cast %[[ARG1]] -// CHECK: spv.CompositeConstruct %[[V0]], %[[V1]], %[[V1]], %[[V0]] : (f32, f32, f32, f32) -> vector<4xf32> +// CHECK: spirv.CompositeConstruct %[[V0]], %[[V1]], %[[V1]], %[[V0]] : (f32, f32, f32, f32) -> vector<4xf32> func.func @shuffle(%v0 : vector<1xf32>, %v1: vector<1xf32>) -> vector<4xf32> { %shuffle = vector.shuffle %v0, %v1 [0, 1, 1, 0] : vector<1xf32>, vector<1xf32> return %shuffle : vector<4xf32> @@ -365,7 +365,7 @@ // CHECK-LABEL: func @shuffle // CHECK-SAME: %[[V0:.+]]: vector<3xf32>, %[[V1:.+]]: vector<3xf32> -// CHECK: spv.VectorShuffle [3 : i32, 2 : i32, 5 : i32, 1 : i32] %[[V0]] : vector<3xf32>, %[[V1]] : vector<3xf32> -> vector<4xf32> +// CHECK: spirv.VectorShuffle [3 : i32, 2 : i32, 5 : i32, 1 : i32] %[[V0]] : vector<3xf32>, %[[V1]] : vector<3xf32> -> vector<4xf32> func.func @shuffle(%v0 : vector<3xf32>, %v1: vector<3xf32>) -> vector<4xf32> { %shuffle = vector.shuffle %v0, %v1 [3, 2, 5, 1] : vector<3xf32>, vector<3xf32> return %shuffle : vector<4xf32> @@ -384,13 +384,13 @@ // CHECK-LABEL: func @reduction_add // CHECK-SAME: (%[[V:.+]]: vector<4xi32>) -// CHECK: %[[S0:.+]] = spv.CompositeExtract %[[V]][0 : i32] : vector<4xi32> -// CHECK: %[[S1:.+]] = spv.CompositeExtract %[[V]][1 : i32] : vector<4xi32> -// CHECK: %[[S2:.+]] = spv.CompositeExtract %[[V]][2 : i32] : vector<4xi32> -// CHECK: %[[S3:.+]] = spv.CompositeExtract %[[V]][3 : i32] : vector<4xi32> -// CHECK: %[[ADD0:.+]] = spv.IAdd %[[S0]], %[[S1]] -// CHECK: %[[ADD1:.+]] = spv.IAdd %[[ADD0]], %[[S2]] -// CHECK: %[[ADD2:.+]] = spv.IAdd %[[ADD1]], %[[S3]] +// CHECK: %[[S0:.+]] = spirv.CompositeExtract %[[V]][0 : i32] : vector<4xi32> +// CHECK: %[[S1:.+]] = spirv.CompositeExtract %[[V]][1 : i32] : vector<4xi32> +// CHECK: %[[S2:.+]] = spirv.CompositeExtract %[[V]][2 : i32] : vector<4xi32> +// CHECK: %[[S3:.+]] = spirv.CompositeExtract %[[V]][3 : i32] : vector<4xi32> +// CHECK: %[[ADD0:.+]] = spirv.IAdd %[[S0]], %[[S1]] +// CHECK: %[[ADD1:.+]] = spirv.IAdd %[[ADD0]], %[[S2]] +// CHECK: %[[ADD2:.+]] = spirv.IAdd %[[ADD1]], %[[S3]] // CHECK: return %[[ADD2]] func.func @reduction_add(%v : vector<4xi32>) -> i32 { %reduce = vector.reduction , %v : vector<4xi32> into i32 @@ -401,12 +401,12 @@ // CHECK-LABEL: func @reduction_mul // CHECK-SAME: (%[[V:.+]]: vector<3xf32>, %[[S:.+]]: f32) -// CHECK: %[[S0:.+]] = spv.CompositeExtract %[[V]][0 : i32] : vector<3xf32> -// CHECK: %[[S1:.+]] = spv.CompositeExtract %[[V]][1 : i32] : vector<3xf32> -// CHECK: %[[S2:.+]] = spv.CompositeExtract %[[V]][2 : i32] : vector<3xf32> -// CHECK: %[[MUL0:.+]] = spv.FMul %[[S0]], %[[S1]] -// CHECK: %[[MUL1:.+]] = spv.FMul %[[MUL0]], %[[S2]] -// CHECK: %[[MUL2:.+]] = spv.FMul %[[MUL1]], %[[S]] +// CHECK: %[[S0:.+]] = spirv.CompositeExtract %[[V]][0 : i32] : vector<3xf32> +// CHECK: %[[S1:.+]] = spirv.CompositeExtract %[[V]][1 : i32] : vector<3xf32> +// CHECK: %[[S2:.+]] = spirv.CompositeExtract %[[V]][2 : i32] : vector<3xf32> +// CHECK: %[[MUL0:.+]] = spirv.FMul %[[S0]], %[[S1]] +// CHECK: %[[MUL1:.+]] = spirv.FMul %[[MUL0]], %[[S2]] +// CHECK: %[[MUL2:.+]] = spirv.FMul %[[MUL1]], %[[S]] // CHECK: return %[[MUL2]] func.func @reduction_mul(%v : vector<3xf32>, %s: f32) -> f32 { %reduce = vector.reduction , %v, %s : vector<3xf32> into f32 @@ -417,12 +417,12 @@ // CHECK-LABEL: func @reduction_maxf // CHECK-SAME: (%[[V:.+]]: vector<3xf32>, %[[S:.+]]: f32) -// CHECK: %[[S0:.+]] = spv.CompositeExtract %[[V]][0 : i32] : vector<3xf32> -// CHECK: %[[S1:.+]] = spv.CompositeExtract %[[V]][1 : i32] : vector<3xf32> -// CHECK: %[[S2:.+]] = spv.CompositeExtract %[[V]][2 : i32] : vector<3xf32> -// CHECK: %[[MAX0:.+]] = spv.GL.FMax %[[S0]], %[[S1]] -// CHECK: %[[MAX1:.+]] = spv.GL.FMax %[[MAX0]], %[[S2]] -// CHECK: %[[MAX2:.+]] = spv.GL.FMax %[[MAX1]], %[[S]] +// CHECK: %[[S0:.+]] = spirv.CompositeExtract %[[V]][0 : i32] : vector<3xf32> +// CHECK: %[[S1:.+]] = spirv.CompositeExtract %[[V]][1 : i32] : vector<3xf32> +// CHECK: %[[S2:.+]] = spirv.CompositeExtract %[[V]][2 : i32] : vector<3xf32> +// CHECK: %[[MAX0:.+]] = spirv.GL.FMax %[[S0]], %[[S1]] +// CHECK: %[[MAX1:.+]] = spirv.GL.FMax %[[MAX0]], %[[S2]] +// CHECK: %[[MAX2:.+]] = spirv.GL.FMax %[[MAX1]], %[[S]] // CHECK: return %[[MAX2]] func.func @reduction_maxf(%v : vector<3xf32>, %s: f32) -> f32 { %reduce = vector.reduction , %v, %s : vector<3xf32> into f32 @@ -433,12 +433,12 @@ // CHECK-LABEL: func @reduction_minf // CHECK-SAME: (%[[V:.+]]: vector<3xf32>, %[[S:.+]]: f32) -// CHECK: %[[S0:.+]] = spv.CompositeExtract %[[V]][0 : i32] : vector<3xf32> -// CHECK: %[[S1:.+]] = spv.CompositeExtract %[[V]][1 : i32] : vector<3xf32> -// CHECK: %[[S2:.+]] = spv.CompositeExtract %[[V]][2 : i32] : vector<3xf32> -// CHECK: %[[MIN0:.+]] = spv.GL.FMin %[[S0]], %[[S1]] -// CHECK: %[[MIN1:.+]] = spv.GL.FMin %[[MIN0]], %[[S2]] -// CHECK: %[[MIN2:.+]] = spv.GL.FMin %[[MIN1]], %[[S]] +// CHECK: %[[S0:.+]] = spirv.CompositeExtract %[[V]][0 : i32] : vector<3xf32> +// CHECK: %[[S1:.+]] = spirv.CompositeExtract %[[V]][1 : i32] : vector<3xf32> +// CHECK: %[[S2:.+]] = spirv.CompositeExtract %[[V]][2 : i32] : vector<3xf32> +// CHECK: %[[MIN0:.+]] = spirv.GL.FMin %[[S0]], %[[S1]] +// CHECK: %[[MIN1:.+]] = spirv.GL.FMin %[[MIN0]], %[[S2]] +// CHECK: %[[MIN2:.+]] = spirv.GL.FMin %[[MIN1]], %[[S]] // CHECK: return %[[MIN2]] func.func @reduction_minf(%v : vector<3xf32>, %s: f32) -> f32 { %reduce = vector.reduction , %v, %s : vector<3xf32> into f32 @@ -449,12 +449,12 @@ // CHECK-LABEL: func @reduction_maxsi // CHECK-SAME: (%[[V:.+]]: vector<3xi32>, %[[S:.+]]: i32) -// CHECK: %[[S0:.+]] = spv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> -// CHECK: %[[S1:.+]] = spv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> -// CHECK: %[[S2:.+]] = spv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> -// CHECK: %[[MAX0:.+]] = spv.GL.SMax %[[S0]], %[[S1]] -// CHECK: %[[MAX1:.+]] = spv.GL.SMax %[[MAX0]], %[[S2]] -// CHECK: %[[MAX2:.+]] = spv.GL.SMax %[[MAX1]], %[[S]] +// CHECK: %[[S0:.+]] = spirv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> +// CHECK: %[[S1:.+]] = spirv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> +// CHECK: %[[S2:.+]] = spirv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> +// CHECK: %[[MAX0:.+]] = spirv.GL.SMax %[[S0]], %[[S1]] +// CHECK: %[[MAX1:.+]] = spirv.GL.SMax %[[MAX0]], %[[S2]] +// CHECK: %[[MAX2:.+]] = spirv.GL.SMax %[[MAX1]], %[[S]] // CHECK: return %[[MAX2]] func.func @reduction_maxsi(%v : vector<3xi32>, %s: i32) -> i32 { %reduce = vector.reduction , %v, %s : vector<3xi32> into i32 @@ -465,12 +465,12 @@ // CHECK-LABEL: func @reduction_minsi // CHECK-SAME: (%[[V:.+]]: vector<3xi32>, %[[S:.+]]: i32) -// CHECK: %[[S0:.+]] = spv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> -// CHECK: %[[S1:.+]] = spv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> -// CHECK: %[[S2:.+]] = spv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> -// CHECK: %[[MIN0:.+]] = spv.GL.SMin %[[S0]], %[[S1]] -// CHECK: %[[MIN1:.+]] = spv.GL.SMin %[[MIN0]], %[[S2]] -// CHECK: %[[MIN2:.+]] = spv.GL.SMin %[[MIN1]], %[[S]] +// CHECK: %[[S0:.+]] = spirv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> +// CHECK: %[[S1:.+]] = spirv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> +// CHECK: %[[S2:.+]] = spirv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> +// CHECK: %[[MIN0:.+]] = spirv.GL.SMin %[[S0]], %[[S1]] +// CHECK: %[[MIN1:.+]] = spirv.GL.SMin %[[MIN0]], %[[S2]] +// CHECK: %[[MIN2:.+]] = spirv.GL.SMin %[[MIN1]], %[[S]] // CHECK: return %[[MIN2]] func.func @reduction_minsi(%v : vector<3xi32>, %s: i32) -> i32 { %reduce = vector.reduction , %v, %s : vector<3xi32> into i32 @@ -481,12 +481,12 @@ // CHECK-LABEL: func @reduction_maxui // CHECK-SAME: (%[[V:.+]]: vector<3xi32>, %[[S:.+]]: i32) -// CHECK: %[[S0:.+]] = spv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> -// CHECK: %[[S1:.+]] = spv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> -// CHECK: %[[S2:.+]] = spv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> -// CHECK: %[[MAX0:.+]] = spv.GL.UMax %[[S0]], %[[S1]] -// CHECK: %[[MAX1:.+]] = spv.GL.UMax %[[MAX0]], %[[S2]] -// CHECK: %[[MAX2:.+]] = spv.GL.UMax %[[MAX1]], %[[S]] +// CHECK: %[[S0:.+]] = spirv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> +// CHECK: %[[S1:.+]] = spirv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> +// CHECK: %[[S2:.+]] = spirv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> +// CHECK: %[[MAX0:.+]] = spirv.GL.UMax %[[S0]], %[[S1]] +// CHECK: %[[MAX1:.+]] = spirv.GL.UMax %[[MAX0]], %[[S2]] +// CHECK: %[[MAX2:.+]] = spirv.GL.UMax %[[MAX1]], %[[S]] // CHECK: return %[[MAX2]] func.func @reduction_maxui(%v : vector<3xi32>, %s: i32) -> i32 { %reduce = vector.reduction , %v, %s : vector<3xi32> into i32 @@ -497,12 +497,12 @@ // CHECK-LABEL: func @reduction_minui // CHECK-SAME: (%[[V:.+]]: vector<3xi32>, %[[S:.+]]: i32) -// CHECK: %[[S0:.+]] = spv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> -// CHECK: %[[S1:.+]] = spv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> -// CHECK: %[[S2:.+]] = spv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> -// CHECK: %[[MIN0:.+]] = spv.GL.UMin %[[S0]], %[[S1]] -// CHECK: %[[MIN1:.+]] = spv.GL.UMin %[[MIN0]], %[[S2]] -// CHECK: %[[MIN2:.+]] = spv.GL.UMin %[[MIN1]], %[[S]] +// CHECK: %[[S0:.+]] = spirv.CompositeExtract %[[V]][0 : i32] : vector<3xi32> +// CHECK: %[[S1:.+]] = spirv.CompositeExtract %[[V]][1 : i32] : vector<3xi32> +// CHECK: %[[S2:.+]] = spirv.CompositeExtract %[[V]][2 : i32] : vector<3xi32> +// CHECK: %[[MIN0:.+]] = spirv.GL.UMin %[[S0]], %[[S1]] +// CHECK: %[[MIN1:.+]] = spirv.GL.UMin %[[MIN0]], %[[S2]] +// CHECK: %[[MIN2:.+]] = spirv.GL.UMin %[[MIN1]], %[[S]] // CHECK: return %[[MIN2]] func.func @reduction_minui(%v : vector<3xi32>, %s: i32) -> i32 { %reduce = vector.reduction , %v, %s : vector<3xi32> into i32 diff --git a/mlir/test/Dialect/SPIRV/IR/arithmetic-ops.mlir b/mlir/test/Dialect/SPIRV/IR/arithmetic-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/arithmetic-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/arithmetic-ops.mlir @@ -1,54 +1,54 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.FAdd +// spirv.FAdd //===----------------------------------------------------------------------===// func.func @fadd_scalar(%arg: f32) -> f32 { - // CHECK: spv.FAdd - %0 = spv.FAdd %arg, %arg : f32 + // CHECK: spirv.FAdd + %0 = spirv.FAdd %arg, %arg : f32 return %0 : f32 } // ----- //===----------------------------------------------------------------------===// -// spv.FDiv +// spirv.FDiv //===----------------------------------------------------------------------===// func.func @fdiv_scalar(%arg: f32) -> f32 { - // CHECK: spv.FDiv - %0 = spv.FDiv %arg, %arg : f32 + // CHECK: spirv.FDiv + %0 = spirv.FDiv %arg, %arg : f32 return %0 : f32 } // ----- //===----------------------------------------------------------------------===// -// spv.FMod +// spirv.FMod //===----------------------------------------------------------------------===// func.func @fmod_scalar(%arg: f32) -> f32 { - // CHECK: spv.FMod - %0 = spv.FMod %arg, %arg : f32 + // CHECK: spirv.FMod + %0 = spirv.FMod %arg, %arg : f32 return %0 : f32 } // ----- //===----------------------------------------------------------------------===// -// spv.FMul +// spirv.FMul //===----------------------------------------------------------------------===// func.func @fmul_scalar(%arg: f32) -> f32 { - // CHECK: spv.FMul - %0 = spv.FMul %arg, %arg : f32 + // CHECK: spirv.FMul + %0 = spirv.FMul %arg, %arg : f32 return %0 : f32 } func.func @fmul_vector(%arg: vector<4xf32>) -> vector<4xf32> { - // CHECK: spv.FMul - %0 = spv.FMul %arg, %arg : vector<4xf32> + // CHECK: spirv.FMul + %0 = spirv.FMul %arg, %arg : vector<4xf32> return %0 : vector<4xf32> } @@ -56,7 +56,7 @@ func.func @fmul_i32(%arg: i32) -> i32 { // expected-error @+1 {{operand #0 must be 16/32/64-bit float or vector of 16/32/64-bit float values}} - %0 = spv.FMul %arg, %arg : i32 + %0 = spirv.FMul %arg, %arg : i32 return %0 : i32 } @@ -64,7 +64,7 @@ func.func @fmul_bf16(%arg: bf16) -> bf16 { // expected-error @+1 {{operand #0 must be 16/32/64-bit float or vector of 16/32/64-bit float values}} - %0 = spv.FMul %arg, %arg : bf16 + %0 = spirv.FMul %arg, %arg : bf16 return %0 : bf16 } @@ -72,265 +72,265 @@ func.func @fmul_tensor(%arg: tensor<4xf32>) -> tensor<4xf32> { // expected-error @+1 {{operand #0 must be 16/32/64-bit float or vector of 16/32/64-bit float values}} - %0 = spv.FMul %arg, %arg : tensor<4xf32> + %0 = spirv.FMul %arg, %arg : tensor<4xf32> return %0 : tensor<4xf32> } // ----- //===----------------------------------------------------------------------===// -// spv.FNegate +// spirv.FNegate //===----------------------------------------------------------------------===// func.func @fnegate_scalar(%arg: f32) -> f32 { - // CHECK: spv.FNegate - %0 = spv.FNegate %arg : f32 + // CHECK: spirv.FNegate + %0 = spirv.FNegate %arg : f32 return %0 : f32 } // ----- //===----------------------------------------------------------------------===// -// spv.FRem +// spirv.FRem //===----------------------------------------------------------------------===// func.func @frem_scalar(%arg: f32) -> f32 { - // CHECK: spv.FRem - %0 = spv.FRem %arg, %arg : f32 + // CHECK: spirv.FRem + %0 = spirv.FRem %arg, %arg : f32 return %0 : f32 } // ----- //===----------------------------------------------------------------------===// -// spv.FSub +// spirv.FSub //===----------------------------------------------------------------------===// func.func @fsub_scalar(%arg: f32) -> f32 { - // CHECK: spv.FSub - %0 = spv.FSub %arg, %arg : f32 + // CHECK: spirv.FSub + %0 = spirv.FSub %arg, %arg : f32 return %0 : f32 } // ----- //===----------------------------------------------------------------------===// -// spv.IAdd +// spirv.IAdd //===----------------------------------------------------------------------===// func.func @iadd_scalar(%arg: i32) -> i32 { - // CHECK: spv.IAdd - %0 = spv.IAdd %arg, %arg : i32 + // CHECK: spirv.IAdd + %0 = spirv.IAdd %arg, %arg : i32 return %0 : i32 } // ----- //===----------------------------------------------------------------------===// -// spv.IMul +// spirv.IMul //===----------------------------------------------------------------------===// func.func @imul_scalar(%arg: i32) -> i32 { - // CHECK: spv.IMul - %0 = spv.IMul %arg, %arg : i32 + // CHECK: spirv.IMul + %0 = spirv.IMul %arg, %arg : i32 return %0 : i32 } // ----- //===----------------------------------------------------------------------===// -// spv.ISub +// spirv.ISub //===----------------------------------------------------------------------===// func.func @isub_scalar(%arg: i32) -> i32 { - // CHECK: spv.ISub - %0 = spv.ISub %arg, %arg : i32 + // CHECK: spirv.ISub + %0 = spirv.ISub %arg, %arg : i32 return %0 : i32 } // ----- //===----------------------------------------------------------------------===// -// spv.IAddCarry +// spirv.IAddCarry //===----------------------------------------------------------------------===// // CHECK-LABEL: @iadd_carry_scalar -func.func @iadd_carry_scalar(%arg: i32) -> !spv.struct<(i32, i32)> { - // CHECK: spv.IAddCarry %{{.+}}, %{{.+}} : !spv.struct<(i32, i32)> - %0 = spv.IAddCarry %arg, %arg : !spv.struct<(i32, i32)> - return %0 : !spv.struct<(i32, i32)> +func.func @iadd_carry_scalar(%arg: i32) -> !spirv.struct<(i32, i32)> { + // CHECK: spirv.IAddCarry %{{.+}}, %{{.+}} : !spirv.struct<(i32, i32)> + %0 = spirv.IAddCarry %arg, %arg : !spirv.struct<(i32, i32)> + return %0 : !spirv.struct<(i32, i32)> } // CHECK-LABEL: @iadd_carry_vector -func.func @iadd_carry_vector(%arg: vector<3xi32>) -> !spv.struct<(vector<3xi32>, vector<3xi32>)> { - // CHECK: spv.IAddCarry %{{.+}}, %{{.+}} : !spv.struct<(vector<3xi32>, vector<3xi32>)> - %0 = spv.IAddCarry %arg, %arg : !spv.struct<(vector<3xi32>, vector<3xi32>)> - return %0 : !spv.struct<(vector<3xi32>, vector<3xi32>)> +func.func @iadd_carry_vector(%arg: vector<3xi32>) -> !spirv.struct<(vector<3xi32>, vector<3xi32>)> { + // CHECK: spirv.IAddCarry %{{.+}}, %{{.+}} : !spirv.struct<(vector<3xi32>, vector<3xi32>)> + %0 = spirv.IAddCarry %arg, %arg : !spirv.struct<(vector<3xi32>, vector<3xi32>)> + return %0 : !spirv.struct<(vector<3xi32>, vector<3xi32>)> } // ----- -func.func @iadd_carry(%arg: i32) -> !spv.struct<(i32, i32, i32)> { - // expected-error @+1 {{expected spv.struct type with two members}} - %0 = spv.IAddCarry %arg, %arg : !spv.struct<(i32, i32, i32)> - return %0 : !spv.struct<(i32, i32, i32)> +func.func @iadd_carry(%arg: i32) -> !spirv.struct<(i32, i32, i32)> { + // expected-error @+1 {{expected spirv.struct type with two members}} + %0 = spirv.IAddCarry %arg, %arg : !spirv.struct<(i32, i32, i32)> + return %0 : !spirv.struct<(i32, i32, i32)> } // ----- -func.func @iadd_carry(%arg: i32) -> !spv.struct<(i32)> { +func.func @iadd_carry(%arg: i32) -> !spirv.struct<(i32)> { // expected-error @+1 {{expected result struct type containing two members}} - %0 = "spv.IAddCarry"(%arg, %arg): (i32, i32) -> !spv.struct<(i32)> - return %0 : !spv.struct<(i32)> + %0 = "spirv.IAddCarry"(%arg, %arg): (i32, i32) -> !spirv.struct<(i32)> + return %0 : !spirv.struct<(i32)> } // ----- -func.func @iadd_carry(%arg: i32) -> !spv.struct<(i32, i64)> { +func.func @iadd_carry(%arg: i32) -> !spirv.struct<(i32, i64)> { // expected-error @+1 {{expected all operand types and struct member types are the same}} - %0 = "spv.IAddCarry"(%arg, %arg): (i32, i32) -> !spv.struct<(i32, i64)> - return %0 : !spv.struct<(i32, i64)> + %0 = "spirv.IAddCarry"(%arg, %arg): (i32, i32) -> !spirv.struct<(i32, i64)> + return %0 : !spirv.struct<(i32, i64)> } // ----- -func.func @iadd_carry(%arg: i64) -> !spv.struct<(i32, i32)> { +func.func @iadd_carry(%arg: i64) -> !spirv.struct<(i32, i32)> { // expected-error @+1 {{expected all operand types and struct member types are the same}} - %0 = "spv.IAddCarry"(%arg, %arg): (i64, i64) -> !spv.struct<(i32, i32)> - return %0 : !spv.struct<(i32, i32)> + %0 = "spirv.IAddCarry"(%arg, %arg): (i64, i64) -> !spirv.struct<(i32, i32)> + return %0 : !spirv.struct<(i32, i32)> } // ----- //===----------------------------------------------------------------------===// -// spv.ISubBorrow +// spirv.ISubBorrow //===----------------------------------------------------------------------===// // CHECK-LABEL: @isub_borrow_scalar -func.func @isub_borrow_scalar(%arg: i32) -> !spv.struct<(i32, i32)> { - // CHECK: spv.ISubBorrow %{{.+}}, %{{.+}} : !spv.struct<(i32, i32)> - %0 = spv.ISubBorrow %arg, %arg : !spv.struct<(i32, i32)> - return %0 : !spv.struct<(i32, i32)> +func.func @isub_borrow_scalar(%arg: i32) -> !spirv.struct<(i32, i32)> { + // CHECK: spirv.ISubBorrow %{{.+}}, %{{.+}} : !spirv.struct<(i32, i32)> + %0 = spirv.ISubBorrow %arg, %arg : !spirv.struct<(i32, i32)> + return %0 : !spirv.struct<(i32, i32)> } // CHECK-LABEL: @isub_borrow_vector -func.func @isub_borrow_vector(%arg: vector<3xi32>) -> !spv.struct<(vector<3xi32>, vector<3xi32>)> { - // CHECK: spv.ISubBorrow %{{.+}}, %{{.+}} : !spv.struct<(vector<3xi32>, vector<3xi32>)> - %0 = spv.ISubBorrow %arg, %arg : !spv.struct<(vector<3xi32>, vector<3xi32>)> - return %0 : !spv.struct<(vector<3xi32>, vector<3xi32>)> +func.func @isub_borrow_vector(%arg: vector<3xi32>) -> !spirv.struct<(vector<3xi32>, vector<3xi32>)> { + // CHECK: spirv.ISubBorrow %{{.+}}, %{{.+}} : !spirv.struct<(vector<3xi32>, vector<3xi32>)> + %0 = spirv.ISubBorrow %arg, %arg : !spirv.struct<(vector<3xi32>, vector<3xi32>)> + return %0 : !spirv.struct<(vector<3xi32>, vector<3xi32>)> } // ----- -func.func @isub_borrow(%arg: i32) -> !spv.struct<(i32, i32, i32)> { - // expected-error @+1 {{expected spv.struct type with two members}} - %0 = spv.ISubBorrow %arg, %arg : !spv.struct<(i32, i32, i32)> - return %0 : !spv.struct<(i32, i32, i32)> +func.func @isub_borrow(%arg: i32) -> !spirv.struct<(i32, i32, i32)> { + // expected-error @+1 {{expected spirv.struct type with two members}} + %0 = spirv.ISubBorrow %arg, %arg : !spirv.struct<(i32, i32, i32)> + return %0 : !spirv.struct<(i32, i32, i32)> } // ----- -func.func @isub_borrow(%arg: i32) -> !spv.struct<(i32)> { +func.func @isub_borrow(%arg: i32) -> !spirv.struct<(i32)> { // expected-error @+1 {{expected result struct type containing two members}} - %0 = "spv.ISubBorrow"(%arg, %arg): (i32, i32) -> !spv.struct<(i32)> - return %0 : !spv.struct<(i32)> + %0 = "spirv.ISubBorrow"(%arg, %arg): (i32, i32) -> !spirv.struct<(i32)> + return %0 : !spirv.struct<(i32)> } // ----- -func.func @isub_borrow(%arg: i32) -> !spv.struct<(i32, i64)> { +func.func @isub_borrow(%arg: i32) -> !spirv.struct<(i32, i64)> { // expected-error @+1 {{expected all operand types and struct member types are the same}} - %0 = "spv.ISubBorrow"(%arg, %arg): (i32, i32) -> !spv.struct<(i32, i64)> - return %0 : !spv.struct<(i32, i64)> + %0 = "spirv.ISubBorrow"(%arg, %arg): (i32, i32) -> !spirv.struct<(i32, i64)> + return %0 : !spirv.struct<(i32, i64)> } // ----- -func.func @isub_borrow(%arg: i64) -> !spv.struct<(i32, i32)> { +func.func @isub_borrow(%arg: i64) -> !spirv.struct<(i32, i32)> { // expected-error @+1 {{expected all operand types and struct member types are the same}} - %0 = "spv.ISubBorrow"(%arg, %arg): (i64, i64) -> !spv.struct<(i32, i32)> - return %0 : !spv.struct<(i32, i32)> + %0 = "spirv.ISubBorrow"(%arg, %arg): (i64, i64) -> !spirv.struct<(i32, i32)> + return %0 : !spirv.struct<(i32, i32)> } // ----- //===----------------------------------------------------------------------===// -// spv.SDiv +// spirv.SDiv //===----------------------------------------------------------------------===// func.func @sdiv_scalar(%arg: i32) -> i32 { - // CHECK: spv.SDiv - %0 = spv.SDiv %arg, %arg : i32 + // CHECK: spirv.SDiv + %0 = spirv.SDiv %arg, %arg : i32 return %0 : i32 } // ----- //===----------------------------------------------------------------------===// -// spv.SMod +// spirv.SMod //===----------------------------------------------------------------------===// func.func @smod_scalar(%arg: i32) -> i32 { - // CHECK: spv.SMod - %0 = spv.SMod %arg, %arg : i32 + // CHECK: spirv.SMod + %0 = spirv.SMod %arg, %arg : i32 return %0 : i32 } // ----- //===----------------------------------------------------------------------===// -// spv.SNegate +// spirv.SNegate //===----------------------------------------------------------------------===// func.func @snegate_scalar(%arg: i32) -> i32 { - // CHECK: spv.SNegate - %0 = spv.SNegate %arg : i32 + // CHECK: spirv.SNegate + %0 = spirv.SNegate %arg : i32 return %0 : i32 } // ----- //===----------------------------------------------------------------------===// -// spv.SRem +// spirv.SRem //===----------------------------------------------------------------------===// func.func @srem_scalar(%arg: i32) -> i32 { - // CHECK: spv.SRem - %0 = spv.SRem %arg, %arg : i32 + // CHECK: spirv.SRem + %0 = spirv.SRem %arg, %arg : i32 return %0 : i32 } // ----- //===----------------------------------------------------------------------===// -// spv.UDiv +// spirv.UDiv //===----------------------------------------------------------------------===// func.func @udiv_scalar(%arg: i32) -> i32 { - // CHECK: spv.UDiv - %0 = spv.UDiv %arg, %arg : i32 + // CHECK: spirv.UDiv + %0 = spirv.UDiv %arg, %arg : i32 return %0 : i32 } // ----- //===----------------------------------------------------------------------===// -// spv.UMod +// spirv.UMod //===----------------------------------------------------------------------===// func.func @umod_scalar(%arg: i32) -> i32 { - // CHECK: spv.UMod - %0 = spv.UMod %arg, %arg : i32 + // CHECK: spirv.UMod + %0 = spirv.UMod %arg, %arg : i32 return %0 : i32 } // ----- //===----------------------------------------------------------------------===// -// spv.VectorTimesScalar +// spirv.VectorTimesScalar //===----------------------------------------------------------------------===// func.func @vector_times_scalar(%vector: vector<4xf32>, %scalar: f32) -> vector<4xf32> { - // CHECK: spv.VectorTimesScalar %{{.+}}, %{{.+}} : (vector<4xf32>, f32) -> vector<4xf32> - %0 = spv.VectorTimesScalar %vector, %scalar : (vector<4xf32>, f32) -> vector<4xf32> + // CHECK: spirv.VectorTimesScalar %{{.+}}, %{{.+}} : (vector<4xf32>, f32) -> vector<4xf32> + %0 = spirv.VectorTimesScalar %vector, %scalar : (vector<4xf32>, f32) -> vector<4xf32> return %0 : vector<4xf32> } @@ -338,7 +338,7 @@ func.func @vector_times_scalar(%vector: vector<4xf32>, %scalar: f16) -> vector<4xf32> { // expected-error @+1 {{scalar operand and result element type match}} - %0 = spv.VectorTimesScalar %vector, %scalar : (vector<4xf32>, f16) -> vector<4xf32> + %0 = spirv.VectorTimesScalar %vector, %scalar : (vector<4xf32>, f16) -> vector<4xf32> return %0 : vector<4xf32> } @@ -346,6 +346,6 @@ func.func @vector_times_scalar(%vector: vector<4xf32>, %scalar: f32) -> vector<3xf32> { // expected-error @+1 {{vector operand and result type mismatch}} - %0 = spv.VectorTimesScalar %vector, %scalar : (vector<4xf32>, f32) -> vector<3xf32> + %0 = spirv.VectorTimesScalar %vector, %scalar : (vector<4xf32>, f32) -> vector<3xf32> return %0 : vector<3xf32> } diff --git a/mlir/test/Dialect/SPIRV/IR/asm-op-interface.mlir b/mlir/test/Dialect/SPIRV/IR/asm-op-interface.mlir --- a/mlir/test/Dialect/SPIRV/IR/asm-op-interface.mlir +++ b/mlir/test/Dialect/SPIRV/IR/asm-op-interface.mlir @@ -2,40 +2,40 @@ func.func @const() -> () { // CHECK: %true - %0 = spv.Constant true + %0 = spirv.Constant true // CHECK: %false - %1 = spv.Constant false + %1 = spirv.Constant false // CHECK: %cst42_i32 - %2 = spv.Constant 42 : i32 + %2 = spirv.Constant 42 : i32 // CHECK: %cst-42_i32 - %-2 = spv.Constant -42 : i32 + %-2 = spirv.Constant -42 : i32 // CHECK: %cst43_i64 - %3 = spv.Constant 43 : i64 + %3 = spirv.Constant 43 : i64 // CHECK: %cst_f32 - %4 = spv.Constant 0.5 : f32 + %4 = spirv.Constant 0.5 : f32 // CHECK: %cst_f64 - %5 = spv.Constant 0.5 : f64 + %5 = spirv.Constant 0.5 : f64 // CHECK: %cst_vec_3xi32 - %6 = spv.Constant dense<[1, 2, 3]> : vector<3xi32> + %6 = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> // CHECK: %cst - %8 = spv.Constant [dense<3.0> : vector<2xf32>] : !spv.array<1xvector<2xf32>> + %8 = spirv.Constant [dense<3.0> : vector<2xf32>] : !spirv.array<1xvector<2xf32>> return } // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @global_var : !spv.ptr +spirv.module Logical GLSL450 { + spirv.GlobalVariable @global_var : !spirv.ptr - spv.func @addressof() -> () "None" { - // CHECK: %global_var_addr = spv.mlir.addressof - %0 = spv.mlir.addressof @global_var : !spv.ptr - spv.Return + spirv.func @addressof() -> () "None" { + // CHECK: %global_var_addr = spirv.mlir.addressof + %0 = spirv.mlir.addressof @global_var : !spirv.ptr + spirv.Return } } diff --git a/mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir b/mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir @@ -1,274 +1,274 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.AtomicAnd +// spirv.AtomicAnd //===----------------------------------------------------------------------===// -func.func @atomic_and(%ptr : !spv.ptr, %value : i32) -> i32 { - // CHECK: spv.AtomicAnd "Device" "None" %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.AtomicAnd "Device" "None" %ptr, %value : !spv.ptr +func.func @atomic_and(%ptr : !spirv.ptr, %value : i32) -> i32 { + // CHECK: spirv.AtomicAnd "Device" "None" %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.AtomicAnd "Device" "None" %ptr, %value : !spirv.ptr return %0 : i32 } // ----- -func.func @atomic_and(%ptr : !spv.ptr, %value : i32) -> i32 { +func.func @atomic_and(%ptr : !spirv.ptr, %value : i32) -> i32 { // expected-error @+1 {{pointer operand must point to an integer value, found 'f32'}} - %0 = "spv.AtomicAnd"(%ptr, %value) {memory_scope = #spv.scope, semantics = #spv.memory_semantics} : (!spv.ptr, i32) -> (i32) + %0 = "spirv.AtomicAnd"(%ptr, %value) {memory_scope = #spirv.scope, semantics = #spirv.memory_semantics} : (!spirv.ptr, i32) -> (i32) return %0 : i32 } // ----- -func.func @atomic_and(%ptr : !spv.ptr, %value : i64) -> i64 { +func.func @atomic_and(%ptr : !spirv.ptr, %value : i64) -> i64 { // expected-error @+1 {{expected value to have the same type as the pointer operand's pointee type 'i32', but found 'i64'}} - %0 = "spv.AtomicAnd"(%ptr, %value) {memory_scope = #spv.scope, semantics = #spv.memory_semantics} : (!spv.ptr, i64) -> (i64) + %0 = "spirv.AtomicAnd"(%ptr, %value) {memory_scope = #spirv.scope, semantics = #spirv.memory_semantics} : (!spirv.ptr, i64) -> (i64) return %0 : i64 } // ----- -func.func @atomic_and(%ptr : !spv.ptr, %value : i32) -> i32 { +func.func @atomic_and(%ptr : !spirv.ptr, %value : i32) -> i32 { // expected-error @+1 {{expected at most one of these four memory constraints to be set: `Acquire`, `Release`,`AcquireRelease` or `SequentiallyConsistent`}} - %0 = spv.AtomicAnd "Device" "Acquire|Release" %ptr, %value : !spv.ptr + %0 = spirv.AtomicAnd "Device" "Acquire|Release" %ptr, %value : !spirv.ptr return %0 : i32 } // ----- //===----------------------------------------------------------------------===// -// spv.AtomicCompareExchange +// spirv.AtomicCompareExchange //===----------------------------------------------------------------------===// -func.func @atomic_compare_exchange(%ptr: !spv.ptr, %value: i32, %comparator: i32) -> i32 { - // CHECK: spv.AtomicCompareExchange "Workgroup" "Release" "Acquire" %{{.*}}, %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.AtomicCompareExchange "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spv.ptr +func.func @atomic_compare_exchange(%ptr: !spirv.ptr, %value: i32, %comparator: i32) -> i32 { + // CHECK: spirv.AtomicCompareExchange "Workgroup" "Release" "Acquire" %{{.*}}, %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.AtomicCompareExchange "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spirv.ptr return %0: i32 } // ----- -func.func @atomic_compare_exchange(%ptr: !spv.ptr, %value: i64, %comparator: i32) -> i32 { +func.func @atomic_compare_exchange(%ptr: !spirv.ptr, %value: i64, %comparator: i32) -> i32 { // expected-error @+1 {{value operand must have the same type as the op result, but found 'i64' vs 'i32'}} - %0 = "spv.AtomicCompareExchange"(%ptr, %value, %comparator) {memory_scope = #spv.scope, equal_semantics = #spv.memory_semantics, unequal_semantics = #spv.memory_semantics} : (!spv.ptr, i64, i32) -> (i32) + %0 = "spirv.AtomicCompareExchange"(%ptr, %value, %comparator) {memory_scope = #spirv.scope, equal_semantics = #spirv.memory_semantics, unequal_semantics = #spirv.memory_semantics} : (!spirv.ptr, i64, i32) -> (i32) return %0: i32 } // ----- -func.func @atomic_compare_exchange(%ptr: !spv.ptr, %value: i32, %comparator: i16) -> i32 { +func.func @atomic_compare_exchange(%ptr: !spirv.ptr, %value: i32, %comparator: i16) -> i32 { // expected-error @+1 {{comparator operand must have the same type as the op result, but found 'i16' vs 'i32'}} - %0 = "spv.AtomicCompareExchange"(%ptr, %value, %comparator) {memory_scope = #spv.scope, equal_semantics = #spv.memory_semantics, unequal_semantics = #spv.memory_semantics} : (!spv.ptr, i32, i16) -> (i32) + %0 = "spirv.AtomicCompareExchange"(%ptr, %value, %comparator) {memory_scope = #spirv.scope, equal_semantics = #spirv.memory_semantics, unequal_semantics = #spirv.memory_semantics} : (!spirv.ptr, i32, i16) -> (i32) return %0: i32 } // ----- -func.func @atomic_compare_exchange(%ptr: !spv.ptr, %value: i32, %comparator: i32) -> i32 { +func.func @atomic_compare_exchange(%ptr: !spirv.ptr, %value: i32, %comparator: i32) -> i32 { // expected-error @+1 {{pointer operand's pointee type must have the same as the op result type, but found 'i64' vs 'i32'}} - %0 = "spv.AtomicCompareExchange"(%ptr, %value, %comparator) {memory_scope = #spv.scope, equal_semantics = #spv.memory_semantics, unequal_semantics = #spv.memory_semantics} : (!spv.ptr, i32, i32) -> (i32) + %0 = "spirv.AtomicCompareExchange"(%ptr, %value, %comparator) {memory_scope = #spirv.scope, equal_semantics = #spirv.memory_semantics, unequal_semantics = #spirv.memory_semantics} : (!spirv.ptr, i32, i32) -> (i32) return %0: i32 } // ----- //===----------------------------------------------------------------------===// -// spv.AtomicCompareExchangeWeak +// spirv.AtomicCompareExchangeWeak //===----------------------------------------------------------------------===// -func.func @atomic_compare_exchange_weak(%ptr: !spv.ptr, %value: i32, %comparator: i32) -> i32 { - // CHECK: spv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %{{.*}}, %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spv.ptr +func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr, %value: i32, %comparator: i32) -> i32 { + // CHECK: spirv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %{{.*}}, %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spirv.ptr return %0: i32 } // ----- -func.func @atomic_compare_exchange_weak(%ptr: !spv.ptr, %value: i64, %comparator: i32) -> i32 { +func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr, %value: i64, %comparator: i32) -> i32 { // expected-error @+1 {{value operand must have the same type as the op result, but found 'i64' vs 'i32'}} - %0 = "spv.AtomicCompareExchangeWeak"(%ptr, %value, %comparator) {memory_scope = #spv.scope, equal_semantics = #spv.memory_semantics, unequal_semantics = #spv.memory_semantics} : (!spv.ptr, i64, i32) -> (i32) + %0 = "spirv.AtomicCompareExchangeWeak"(%ptr, %value, %comparator) {memory_scope = #spirv.scope, equal_semantics = #spirv.memory_semantics, unequal_semantics = #spirv.memory_semantics} : (!spirv.ptr, i64, i32) -> (i32) return %0: i32 } // ----- -func.func @atomic_compare_exchange_weak(%ptr: !spv.ptr, %value: i32, %comparator: i16) -> i32 { +func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr, %value: i32, %comparator: i16) -> i32 { // expected-error @+1 {{comparator operand must have the same type as the op result, but found 'i16' vs 'i32'}} - %0 = "spv.AtomicCompareExchangeWeak"(%ptr, %value, %comparator) {memory_scope = #spv.scope, equal_semantics = #spv.memory_semantics, unequal_semantics = #spv.memory_semantics} : (!spv.ptr, i32, i16) -> (i32) + %0 = "spirv.AtomicCompareExchangeWeak"(%ptr, %value, %comparator) {memory_scope = #spirv.scope, equal_semantics = #spirv.memory_semantics, unequal_semantics = #spirv.memory_semantics} : (!spirv.ptr, i32, i16) -> (i32) return %0: i32 } // ----- -func.func @atomic_compare_exchange_weak(%ptr: !spv.ptr, %value: i32, %comparator: i32) -> i32 { +func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr, %value: i32, %comparator: i32) -> i32 { // expected-error @+1 {{pointer operand's pointee type must have the same as the op result type, but found 'i64' vs 'i32'}} - %0 = "spv.AtomicCompareExchangeWeak"(%ptr, %value, %comparator) {memory_scope = #spv.scope, equal_semantics = #spv.memory_semantics, unequal_semantics = #spv.memory_semantics} : (!spv.ptr, i32, i32) -> (i32) + %0 = "spirv.AtomicCompareExchangeWeak"(%ptr, %value, %comparator) {memory_scope = #spirv.scope, equal_semantics = #spirv.memory_semantics, unequal_semantics = #spirv.memory_semantics} : (!spirv.ptr, i32, i32) -> (i32) return %0: i32 } // ----- //===----------------------------------------------------------------------===// -// spv.AtomicExchange +// spirv.AtomicExchange //===----------------------------------------------------------------------===// -func.func @atomic_exchange(%ptr: !spv.ptr, %value: i32) -> i32 { - // CHECK: spv.AtomicExchange "Workgroup" "Release" %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.AtomicExchange "Workgroup" "Release" %ptr, %value: !spv.ptr +func.func @atomic_exchange(%ptr: !spirv.ptr, %value: i32) -> i32 { + // CHECK: spirv.AtomicExchange "Workgroup" "Release" %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.AtomicExchange "Workgroup" "Release" %ptr, %value: !spirv.ptr return %0: i32 } // ----- -func.func @atomic_exchange(%ptr: !spv.ptr, %value: i64) -> i32 { +func.func @atomic_exchange(%ptr: !spirv.ptr, %value: i64) -> i32 { // expected-error @+1 {{value operand must have the same type as the op result, but found 'i64' vs 'i32'}} - %0 = "spv.AtomicExchange"(%ptr, %value) {memory_scope = #spv.scope, semantics = #spv.memory_semantics} : (!spv.ptr, i64) -> (i32) + %0 = "spirv.AtomicExchange"(%ptr, %value) {memory_scope = #spirv.scope, semantics = #spirv.memory_semantics} : (!spirv.ptr, i64) -> (i32) return %0: i32 } // ----- -func.func @atomic_exchange(%ptr: !spv.ptr, %value: i32) -> i32 { +func.func @atomic_exchange(%ptr: !spirv.ptr, %value: i32) -> i32 { // expected-error @+1 {{pointer operand's pointee type must have the same as the op result type, but found 'i64' vs 'i32'}} - %0 = "spv.AtomicExchange"(%ptr, %value) {memory_scope = #spv.scope, semantics = #spv.memory_semantics} : (!spv.ptr, i32) -> (i32) + %0 = "spirv.AtomicExchange"(%ptr, %value) {memory_scope = #spirv.scope, semantics = #spirv.memory_semantics} : (!spirv.ptr, i32) -> (i32) return %0: i32 } // ----- //===----------------------------------------------------------------------===// -// spv.AtomicIAdd +// spirv.AtomicIAdd //===----------------------------------------------------------------------===// -func.func @atomic_iadd(%ptr : !spv.ptr, %value : i32) -> i32 { - // CHECK: spv.AtomicIAdd "Workgroup" "None" %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.AtomicIAdd "Workgroup" "None" %ptr, %value : !spv.ptr +func.func @atomic_iadd(%ptr : !spirv.ptr, %value : i32) -> i32 { + // CHECK: spirv.AtomicIAdd "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.AtomicIAdd "Workgroup" "None" %ptr, %value : !spirv.ptr return %0 : i32 } //===----------------------------------------------------------------------===// -// spv.AtomicIDecrement +// spirv.AtomicIDecrement //===----------------------------------------------------------------------===// -func.func @atomic_idecrement(%ptr : !spv.ptr) -> i32 { - // CHECK: spv.AtomicIDecrement "Workgroup" "None" %{{.*}} : !spv.ptr - %0 = spv.AtomicIDecrement "Workgroup" "None" %ptr : !spv.ptr +func.func @atomic_idecrement(%ptr : !spirv.ptr) -> i32 { + // CHECK: spirv.AtomicIDecrement "Workgroup" "None" %{{.*}} : !spirv.ptr + %0 = spirv.AtomicIDecrement "Workgroup" "None" %ptr : !spirv.ptr return %0 : i32 } //===----------------------------------------------------------------------===// -// spv.AtomicIIncrement +// spirv.AtomicIIncrement //===----------------------------------------------------------------------===// -func.func @atomic_iincrement(%ptr : !spv.ptr) -> i32 { - // CHECK: spv.AtomicIIncrement "Workgroup" "None" %{{.*}} : !spv.ptr - %0 = spv.AtomicIIncrement "Workgroup" "None" %ptr : !spv.ptr +func.func @atomic_iincrement(%ptr : !spirv.ptr) -> i32 { + // CHECK: spirv.AtomicIIncrement "Workgroup" "None" %{{.*}} : !spirv.ptr + %0 = spirv.AtomicIIncrement "Workgroup" "None" %ptr : !spirv.ptr return %0 : i32 } //===----------------------------------------------------------------------===// -// spv.AtomicISub +// spirv.AtomicISub //===----------------------------------------------------------------------===// -func.func @atomic_isub(%ptr : !spv.ptr, %value : i32) -> i32 { - // CHECK: spv.AtomicISub "Workgroup" "None" %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.AtomicISub "Workgroup" "None" %ptr, %value : !spv.ptr +func.func @atomic_isub(%ptr : !spirv.ptr, %value : i32) -> i32 { + // CHECK: spirv.AtomicISub "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.AtomicISub "Workgroup" "None" %ptr, %value : !spirv.ptr return %0 : i32 } //===----------------------------------------------------------------------===// -// spv.AtomicOr +// spirv.AtomicOr //===----------------------------------------------------------------------===// -func.func @atomic_or(%ptr : !spv.ptr, %value : i32) -> i32 { - // CHECK: spv.AtomicOr "Workgroup" "None" %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.AtomicOr "Workgroup" "None" %ptr, %value : !spv.ptr +func.func @atomic_or(%ptr : !spirv.ptr, %value : i32) -> i32 { + // CHECK: spirv.AtomicOr "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.AtomicOr "Workgroup" "None" %ptr, %value : !spirv.ptr return %0 : i32 } //===----------------------------------------------------------------------===// -// spv.AtomicSMax +// spirv.AtomicSMax //===----------------------------------------------------------------------===// -func.func @atomic_smax(%ptr : !spv.ptr, %value : i32) -> i32 { - // CHECK: spv.AtomicSMax "Workgroup" "None" %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.AtomicSMax "Workgroup" "None" %ptr, %value : !spv.ptr +func.func @atomic_smax(%ptr : !spirv.ptr, %value : i32) -> i32 { + // CHECK: spirv.AtomicSMax "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.AtomicSMax "Workgroup" "None" %ptr, %value : !spirv.ptr return %0 : i32 } //===----------------------------------------------------------------------===// -// spv.AtomicSMin +// spirv.AtomicSMin //===----------------------------------------------------------------------===// -func.func @atomic_smin(%ptr : !spv.ptr, %value : i32) -> i32 { - // CHECK: spv.AtomicSMin "Workgroup" "None" %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.AtomicSMin "Workgroup" "None" %ptr, %value : !spv.ptr +func.func @atomic_smin(%ptr : !spirv.ptr, %value : i32) -> i32 { + // CHECK: spirv.AtomicSMin "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.AtomicSMin "Workgroup" "None" %ptr, %value : !spirv.ptr return %0 : i32 } //===----------------------------------------------------------------------===// -// spv.AtomicUMax +// spirv.AtomicUMax //===----------------------------------------------------------------------===// -func.func @atomic_umax(%ptr : !spv.ptr, %value : i32) -> i32 { - // CHECK: spv.AtomicUMax "Workgroup" "None" %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.AtomicUMax "Workgroup" "None" %ptr, %value : !spv.ptr +func.func @atomic_umax(%ptr : !spirv.ptr, %value : i32) -> i32 { + // CHECK: spirv.AtomicUMax "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.AtomicUMax "Workgroup" "None" %ptr, %value : !spirv.ptr return %0 : i32 } //===----------------------------------------------------------------------===// -// spv.AtomicUMin +// spirv.AtomicUMin //===----------------------------------------------------------------------===// -func.func @atomic_umin(%ptr : !spv.ptr, %value : i32) -> i32 { - // CHECK: spv.AtomicUMin "Workgroup" "None" %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.AtomicUMin "Workgroup" "None" %ptr, %value : !spv.ptr +func.func @atomic_umin(%ptr : !spirv.ptr, %value : i32) -> i32 { + // CHECK: spirv.AtomicUMin "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.AtomicUMin "Workgroup" "None" %ptr, %value : !spirv.ptr return %0 : i32 } //===----------------------------------------------------------------------===// -// spv.AtomicXor +// spirv.AtomicXor //===----------------------------------------------------------------------===// -func.func @atomic_xor(%ptr : !spv.ptr, %value : i32) -> i32 { - // CHECK: spv.AtomicXor "Workgroup" "None" %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.AtomicXor "Workgroup" "None" %ptr, %value : !spv.ptr +func.func @atomic_xor(%ptr : !spirv.ptr, %value : i32) -> i32 { + // CHECK: spirv.AtomicXor "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.AtomicXor "Workgroup" "None" %ptr, %value : !spirv.ptr return %0 : i32 } // ----- //===----------------------------------------------------------------------===// -// spv.EXT.AtomicFAdd +// spirv.EXT.AtomicFAdd //===----------------------------------------------------------------------===// -func.func @atomic_fadd(%ptr : !spv.ptr, %value : f32) -> f32 { - // CHECK: spv.EXT.AtomicFAdd "Device" "None" %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.EXT.AtomicFAdd "Device" "None" %ptr, %value : !spv.ptr +func.func @atomic_fadd(%ptr : !spirv.ptr, %value : f32) -> f32 { + // CHECK: spirv.EXT.AtomicFAdd "Device" "None" %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.EXT.AtomicFAdd "Device" "None" %ptr, %value : !spirv.ptr return %0 : f32 } // ----- -func.func @atomic_fadd(%ptr : !spv.ptr, %value : f32) -> f32 { +func.func @atomic_fadd(%ptr : !spirv.ptr, %value : f32) -> f32 { // expected-error @+1 {{pointer operand must point to an float value, found 'i32'}} - %0 = "spv.EXT.AtomicFAdd"(%ptr, %value) {memory_scope = #spv.scope, semantics = #spv.memory_semantics} : (!spv.ptr, f32) -> (f32) + %0 = "spirv.EXT.AtomicFAdd"(%ptr, %value) {memory_scope = #spirv.scope, semantics = #spirv.memory_semantics} : (!spirv.ptr, f32) -> (f32) return %0 : f32 } // ----- -func.func @atomic_fadd(%ptr : !spv.ptr, %value : f64) -> f64 { +func.func @atomic_fadd(%ptr : !spirv.ptr, %value : f64) -> f64 { // expected-error @+1 {{expected value to have the same type as the pointer operand's pointee type 'f32', but found 'f64'}} - %0 = "spv.EXT.AtomicFAdd"(%ptr, %value) {memory_scope = #spv.scope, semantics = #spv.memory_semantics} : (!spv.ptr, f64) -> (f64) + %0 = "spirv.EXT.AtomicFAdd"(%ptr, %value) {memory_scope = #spirv.scope, semantics = #spirv.memory_semantics} : (!spirv.ptr, f64) -> (f64) return %0 : f64 } // ----- -func.func @atomic_fadd(%ptr : !spv.ptr, %value : f32) -> f32 { +func.func @atomic_fadd(%ptr : !spirv.ptr, %value : f32) -> f32 { // expected-error @+1 {{expected at most one of these four memory constraints to be set: `Acquire`, `Release`,`AcquireRelease` or `SequentiallyConsistent`}} - %0 = spv.EXT.AtomicFAdd "Device" "Acquire|Release" %ptr, %value : !spv.ptr + %0 = spirv.EXT.AtomicFAdd "Device" "Acquire|Release" %ptr, %value : !spirv.ptr return %0 : f32 } diff --git a/mlir/test/Dialect/SPIRV/IR/availability.mlir b/mlir/test/Dialect/SPIRV/IR/availability.mlir --- a/mlir/test/Dialect/SPIRV/IR/availability.mlir +++ b/mlir/test/Dialect/SPIRV/IR/availability.mlir @@ -6,17 +6,17 @@ // CHECK: max version: v1.6 // CHECK: extensions: [ ] // CHECK: capabilities: [ ] - %0 = spv.IAdd %arg, %arg: i32 + %0 = spirv.IAdd %arg, %arg: i32 return %0: i32 } // CHECK: atomic_compare_exchange_weak -func.func @atomic_compare_exchange_weak(%ptr: !spv.ptr, %value: i32, %comparator: i32) -> i32 { +func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr, %value: i32, %comparator: i32) -> i32 { // CHECK: min version: v1.0 // CHECK: max version: v1.3 // CHECK: extensions: [ ] // CHECK: capabilities: [ [Kernel] ] - %0 = spv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spv.ptr + %0 = spirv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spirv.ptr return %0: i32 } @@ -26,26 +26,26 @@ // CHECK: max version: v1.6 // CHECK: extensions: [ ] // CHECK: capabilities: [ [GroupNonUniformBallot] ] - %0 = spv.GroupNonUniformBallot %predicate : vector<4xi32> + %0 = spirv.GroupNonUniformBallot %predicate : vector<4xi32> return %0: vector<4xi32> } // CHECK-LABEL: module_logical_glsl450 func.func @module_logical_glsl450() { - // CHECK: spv.module min version: v1.0 - // CHECK: spv.module max version: v1.6 - // CHECK: spv.module extensions: [ ] - // CHECK: spv.module capabilities: [ [Shader] ] - spv.module Logical GLSL450 { } + // CHECK: spirv.module min version: v1.0 + // CHECK: spirv.module max version: v1.6 + // CHECK: spirv.module extensions: [ ] + // CHECK: spirv.module capabilities: [ [Shader] ] + spirv.module Logical GLSL450 { } return } // CHECK-LABEL: module_physical_storage_buffer64_vulkan func.func @module_physical_storage_buffer64_vulkan() { - // CHECK: spv.module min version: v1.0 - // CHECK: spv.module max version: v1.6 - // CHECK: spv.module extensions: [ [SPV_EXT_physical_storage_buffer, SPV_KHR_physical_storage_buffer] [SPV_KHR_vulkan_memory_model] ] - // CHECK: spv.module capabilities: [ [PhysicalStorageBufferAddresses] [VulkanMemoryModel] ] - spv.module PhysicalStorageBuffer64 Vulkan { } + // CHECK: spirv.module min version: v1.0 + // CHECK: spirv.module max version: v1.6 + // CHECK: spirv.module extensions: [ [SPV_EXT_physical_storage_buffer, SPV_KHR_physical_storage_buffer] [SPV_KHR_vulkan_memory_model] ] + // CHECK: spirv.module capabilities: [ [PhysicalStorageBufferAddresses] [VulkanMemoryModel] ] + spirv.module PhysicalStorageBuffer64 Vulkan { } return } diff --git a/mlir/test/Dialect/SPIRV/IR/barrier-ops.mlir b/mlir/test/Dialect/SPIRV/IR/barrier-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/barrier-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/barrier-ops.mlir @@ -1,12 +1,12 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.ControlBarrier +// spirv.ControlBarrier //===----------------------------------------------------------------------===// func.func @control_barrier_0() -> () { - // CHECK: spv.ControlBarrier , , - spv.ControlBarrier , , + // CHECK: spirv.ControlBarrier , , + spirv.ControlBarrier , , return } @@ -15,7 +15,7 @@ func.func @control_barrier_1() -> () { // expected-error @+2 {{to be one of}} // expected-error @+1 {{failed to parse SPV_ScopeAttr}} - spv.ControlBarrier , , + spirv.ControlBarrier , , return } @@ -23,20 +23,20 @@ // ----- //===----------------------------------------------------------------------===// -// spv.MemoryBarrier +// spirv.MemoryBarrier //===----------------------------------------------------------------------===// func.func @memory_barrier_0() -> () { - // CHECK: spv.MemoryBarrier , - spv.MemoryBarrier , + // CHECK: spirv.MemoryBarrier , + spirv.MemoryBarrier , return } // ----- func.func @memory_barrier_1() -> () { - // CHECK: spv.MemoryBarrier , - spv.MemoryBarrier , + // CHECK: spirv.MemoryBarrier , + spirv.MemoryBarrier , return } @@ -44,7 +44,7 @@ func.func @memory_barrier_2() -> () { // expected-error @+1 {{expected at most one of these four memory constraints to be set: `Acquire`, `Release`,`AcquireRelease` or `SequentiallyConsistent`}} - spv.MemoryBarrier , + spirv.MemoryBarrier , return } diff --git a/mlir/test/Dialect/SPIRV/IR/bit-ops.mlir b/mlir/test/Dialect/SPIRV/IR/bit-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/bit-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/bit-ops.mlir @@ -1,25 +1,25 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.BitCount +// spirv.BitCount //===----------------------------------------------------------------------===// func.func @bitcount(%arg: i32) -> i32 { - // CHECK: spv.BitCount {{%.*}} : i32 - %0 = spv.BitCount %arg : i32 - spv.ReturnValue %0 : i32 + // CHECK: spirv.BitCount {{%.*}} : i32 + %0 = spirv.BitCount %arg : i32 + spirv.ReturnValue %0 : i32 } // ----- //===----------------------------------------------------------------------===// -// spv.BitFieldInsert +// spirv.BitFieldInsert //===----------------------------------------------------------------------===// func.func @bit_field_insert_vec(%base: vector<3xi32>, %insert: vector<3xi32>, %offset: i32, %count: i16) -> vector<3xi32> { - // CHECK: {{%.*}} = spv.BitFieldInsert {{%.*}}, {{%.*}}, {{%.*}}, {{%.*}} : vector<3xi32>, i32, i16 - %0 = spv.BitFieldInsert %base, %insert, %offset, %count : vector<3xi32>, i32, i16 - spv.ReturnValue %0 : vector<3xi32> + // CHECK: {{%.*}} = spirv.BitFieldInsert {{%.*}}, {{%.*}}, {{%.*}}, {{%.*}} : vector<3xi32>, i32, i16 + %0 = spirv.BitFieldInsert %base, %insert, %offset, %count : vector<3xi32>, i32, i16 + spirv.ReturnValue %0 : vector<3xi32> } // ----- @@ -30,67 +30,67 @@ // message. In final state the error should refer to mismatch in base and // insert. // expected-error @+1 {{type}} - %0 = "spv.BitFieldInsert" (%base, %insert, %offset, %count) : (vector<3xi32>, vector<2xi32>, i32, i16) -> vector<3xi32> - spv.ReturnValue %0 : vector<3xi32> + %0 = "spirv.BitFieldInsert" (%base, %insert, %offset, %count) : (vector<3xi32>, vector<2xi32>, i32, i16) -> vector<3xi32> + spirv.ReturnValue %0 : vector<3xi32> } // ----- //===----------------------------------------------------------------------===// -// spv.BitFieldSExtract +// spirv.BitFieldSExtract //===----------------------------------------------------------------------===// func.func @bit_field_s_extract_vec(%base: vector<3xi32>, %offset: i8, %count: i8) -> vector<3xi32> { - // CHECK: {{%.*}} = spv.BitFieldSExtract {{%.*}}, {{%.*}}, {{%.*}} : vector<3xi32>, i8, i8 - %0 = spv.BitFieldSExtract %base, %offset, %count : vector<3xi32>, i8, i8 - spv.ReturnValue %0 : vector<3xi32> + // CHECK: {{%.*}} = spirv.BitFieldSExtract {{%.*}}, {{%.*}}, {{%.*}} : vector<3xi32>, i8, i8 + %0 = spirv.BitFieldSExtract %base, %offset, %count : vector<3xi32>, i8, i8 + spirv.ReturnValue %0 : vector<3xi32> } //===----------------------------------------------------------------------===// -// spv.BitFieldUExtract +// spirv.BitFieldUExtract //===----------------------------------------------------------------------===// func.func @bit_field_u_extract_vec(%base: vector<3xi32>, %offset: i8, %count: i8) -> vector<3xi32> { - // CHECK: {{%.*}} = spv.BitFieldUExtract {{%.*}}, {{%.*}}, {{%.*}} : vector<3xi32>, i8, i8 - %0 = spv.BitFieldUExtract %base, %offset, %count : vector<3xi32>, i8, i8 - spv.ReturnValue %0 : vector<3xi32> + // CHECK: {{%.*}} = spirv.BitFieldUExtract {{%.*}}, {{%.*}}, {{%.*}} : vector<3xi32>, i8, i8 + %0 = spirv.BitFieldUExtract %base, %offset, %count : vector<3xi32>, i8, i8 + spirv.ReturnValue %0 : vector<3xi32> } // ----- func.func @bit_field_u_extract_invalid_result_type(%base: vector<3xi32>, %offset: i32, %count: i16) -> vector<4xi32> { // expected-error @+1 {{failed to verify that all of {base, result} have same type}} - %0 = "spv.BitFieldUExtract" (%base, %offset, %count) : (vector<3xi32>, i32, i16) -> vector<4xi32> - spv.ReturnValue %0 : vector<4xi32> + %0 = "spirv.BitFieldUExtract" (%base, %offset, %count) : (vector<3xi32>, i32, i16) -> vector<4xi32> + spirv.ReturnValue %0 : vector<4xi32> } // ----- //===----------------------------------------------------------------------===// -// spv.BitReverse +// spirv.BitReverse //===----------------------------------------------------------------------===// func.func @bitreverse(%arg: i32) -> i32 { - // CHECK: spv.BitReverse {{%.*}} : i32 - %0 = spv.BitReverse %arg : i32 - spv.ReturnValue %0 : i32 + // CHECK: spirv.BitReverse {{%.*}} : i32 + %0 = spirv.BitReverse %arg : i32 + spirv.ReturnValue %0 : i32 } // ----- //===----------------------------------------------------------------------===// -// spv.BitwiseOr +// spirv.BitwiseOr //===----------------------------------------------------------------------===// func.func @bitwise_or_scalar(%arg: i32) -> i32 { - // CHECK: spv.BitwiseOr - %0 = spv.BitwiseOr %arg, %arg : i32 + // CHECK: spirv.BitwiseOr + %0 = spirv.BitwiseOr %arg, %arg : i32 return %0 : i32 } func.func @bitwise_or_vector(%arg: vector<4xi32>) -> vector<4xi32> { - // CHECK: spv.BitwiseOr - %0 = spv.BitwiseOr %arg, %arg : vector<4xi32> + // CHECK: spirv.BitwiseOr + %0 = spirv.BitwiseOr %arg, %arg : vector<4xi32> return %0 : vector<4xi32> } @@ -98,25 +98,25 @@ func.func @bitwise_or_float(%arg0: f16, %arg1: f16) -> f16 { // expected-error @+1 {{operand #0 must be 8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4}} - %0 = spv.BitwiseOr %arg0, %arg1 : f16 + %0 = spirv.BitwiseOr %arg0, %arg1 : f16 return %0 : f16 } // ----- //===----------------------------------------------------------------------===// -// spv.BitwiseXor +// spirv.BitwiseXor //===----------------------------------------------------------------------===// func.func @bitwise_xor_scalar(%arg: i32) -> i32 { - // CHECK: spv.BitwiseXor - %0 = spv.BitwiseXor %arg, %arg : i32 + // CHECK: spirv.BitwiseXor + %0 = spirv.BitwiseXor %arg, %arg : i32 return %0 : i32 } func.func @bitwise_xor_vector(%arg: vector<4xi32>) -> vector<4xi32> { - // CHECK: spv.BitwiseXor - %0 = spv.BitwiseXor %arg, %arg : vector<4xi32> + // CHECK: spirv.BitwiseXor + %0 = spirv.BitwiseXor %arg, %arg : vector<4xi32> return %0 : vector<4xi32> } @@ -124,25 +124,25 @@ func.func @bitwise_xor_float(%arg0: f16, %arg1: f16) -> f16 { // expected-error @+1 {{operand #0 must be 8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4}} - %0 = spv.BitwiseXor %arg0, %arg1 : f16 + %0 = spirv.BitwiseXor %arg0, %arg1 : f16 return %0 : f16 } // ----- //===----------------------------------------------------------------------===// -// spv.BitwiseAnd +// spirv.BitwiseAnd //===----------------------------------------------------------------------===// func.func @bitwise_and_scalar(%arg: i32) -> i32 { - // CHECK: spv.BitwiseAnd - %0 = spv.BitwiseAnd %arg, %arg : i32 + // CHECK: spirv.BitwiseAnd + %0 = spirv.BitwiseAnd %arg, %arg : i32 return %0 : i32 } func.func @bitwise_and_vector(%arg: vector<4xi32>) -> vector<4xi32> { - // CHECK: spv.BitwiseAnd - %0 = spv.BitwiseAnd %arg, %arg : vector<4xi32> + // CHECK: spirv.BitwiseAnd + %0 = spirv.BitwiseAnd %arg, %arg : vector<4xi32> return %0 : vector<4xi32> } @@ -150,62 +150,62 @@ func.func @bitwise_and_float(%arg0: f16, %arg1: f16) -> f16 { // expected-error @+1 {{operand #0 must be 8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4}} - %0 = spv.BitwiseAnd %arg0, %arg1 : f16 + %0 = spirv.BitwiseAnd %arg0, %arg1 : f16 return %0 : f16 } // ----- //===----------------------------------------------------------------------===// -// spv.Not +// spirv.Not //===----------------------------------------------------------------------===// func.func @not(%arg: i32) -> i32 { - // CHECK: spv.Not {{%.*}} : i32 - %0 = spv.Not %arg : i32 - spv.ReturnValue %0 : i32 + // CHECK: spirv.Not {{%.*}} : i32 + %0 = spirv.Not %arg : i32 + spirv.ReturnValue %0 : i32 } // ----- //===----------------------------------------------------------------------===// -// spv.ShiftLeftLogical +// spirv.ShiftLeftLogical //===----------------------------------------------------------------------===// func.func @shift_left_logical(%arg0: i32, %arg1 : i16) -> i32 { - // CHECK: {{%.*}} = spv.ShiftLeftLogical {{%.*}}, {{%.*}} : i32, i16 - %0 = spv.ShiftLeftLogical %arg0, %arg1: i32, i16 - spv.ReturnValue %0 : i32 + // CHECK: {{%.*}} = spirv.ShiftLeftLogical {{%.*}}, {{%.*}} : i32, i16 + %0 = spirv.ShiftLeftLogical %arg0, %arg1: i32, i16 + spirv.ReturnValue %0 : i32 } // ----- func.func @shift_left_logical_invalid_result_type(%arg0: i32, %arg1 : i16) -> i16 { // expected-error @+1 {{op failed to verify that all of {operand1, result} have same type}} - %0 = "spv.ShiftLeftLogical" (%arg0, %arg1) : (i32, i16) -> (i16) - spv.ReturnValue %0 : i16 + %0 = "spirv.ShiftLeftLogical" (%arg0, %arg1) : (i32, i16) -> (i16) + spirv.ReturnValue %0 : i16 } // ----- //===----------------------------------------------------------------------===// -// spv.ShiftRightArithmetic +// spirv.ShiftRightArithmetic //===----------------------------------------------------------------------===// func.func @shift_right_arithmetic(%arg0: vector<4xi32>, %arg1 : vector<4xi8>) -> vector<4xi32> { - // CHECK: {{%.*}} = spv.ShiftRightArithmetic {{%.*}}, {{%.*}} : vector<4xi32>, vector<4xi8> - %0 = spv.ShiftRightArithmetic %arg0, %arg1: vector<4xi32>, vector<4xi8> - spv.ReturnValue %0 : vector<4xi32> + // CHECK: {{%.*}} = spirv.ShiftRightArithmetic {{%.*}}, {{%.*}} : vector<4xi32>, vector<4xi8> + %0 = spirv.ShiftRightArithmetic %arg0, %arg1: vector<4xi32>, vector<4xi8> + spirv.ReturnValue %0 : vector<4xi32> } // ----- //===----------------------------------------------------------------------===// -// spv.ShiftRightLogical +// spirv.ShiftRightLogical //===----------------------------------------------------------------------===// func.func @shift_right_logical(%arg0: vector<2xi32>, %arg1 : vector<2xi8>) -> vector<2xi32> { - // CHECK: {{%.*}} = spv.ShiftRightLogical {{%.*}}, {{%.*}} : vector<2xi32>, vector<2xi8> - %0 = spv.ShiftRightLogical %arg0, %arg1: vector<2xi32>, vector<2xi8> - spv.ReturnValue %0 : vector<2xi32> + // CHECK: {{%.*}} = spirv.ShiftRightLogical {{%.*}}, {{%.*}} : vector<2xi32>, vector<2xi8> + %0 = spirv.ShiftRightLogical %arg0, %arg1: vector<2xi32>, vector<2xi8> + spirv.ReturnValue %0 : vector<2xi32> } diff --git a/mlir/test/Dialect/SPIRV/IR/cast-ops.mlir b/mlir/test/Dialect/SPIRV/IR/cast-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/cast-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/cast-ops.mlir @@ -1,42 +1,42 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.Bitcast +// spirv.Bitcast //===----------------------------------------------------------------------===// func.func @cast1(%arg0 : f32) { - // CHECK: {{%.*}} = spv.Bitcast {{%.*}} : f32 to i32 - %0 = spv.Bitcast %arg0 : f32 to i32 + // CHECK: {{%.*}} = spirv.Bitcast {{%.*}} : f32 to i32 + %0 = spirv.Bitcast %arg0 : f32 to i32 return } func.func @cast2(%arg0 : vector<2xf32>) { - // CHECK: {{%.*}} = spv.Bitcast {{%.*}} : vector<2xf32> to vector<2xi32> - %0 = spv.Bitcast %arg0 : vector<2xf32> to vector<2xi32> + // CHECK: {{%.*}} = spirv.Bitcast {{%.*}} : vector<2xf32> to vector<2xi32> + %0 = spirv.Bitcast %arg0 : vector<2xf32> to vector<2xi32> return } func.func @cast3(%arg0 : vector<2xf32>) { - // CHECK: {{%.*}} = spv.Bitcast {{%.*}} : vector<2xf32> to i64 - %0 = spv.Bitcast %arg0 : vector<2xf32> to i64 + // CHECK: {{%.*}} = spirv.Bitcast {{%.*}} : vector<2xf32> to i64 + %0 = spirv.Bitcast %arg0 : vector<2xf32> to i64 return } -func.func @cast4(%arg0 : !spv.ptr) { - // CHECK: {{%.*}} = spv.Bitcast {{%.*}} : !spv.ptr to !spv.ptr - %0 = spv.Bitcast %arg0 : !spv.ptr to !spv.ptr +func.func @cast4(%arg0 : !spirv.ptr) { + // CHECK: {{%.*}} = spirv.Bitcast {{%.*}} : !spirv.ptr to !spirv.ptr + %0 = spirv.Bitcast %arg0 : !spirv.ptr to !spirv.ptr return } -func.func @cast5(%arg0 : !spv.ptr) { - // CHECK: {{%.*}} = spv.Bitcast {{%.*}} : !spv.ptr to !spv.ptr, Function> - %0 = spv.Bitcast %arg0 : !spv.ptr to !spv.ptr, Function> +func.func @cast5(%arg0 : !spirv.ptr) { + // CHECK: {{%.*}} = spirv.Bitcast {{%.*}} : !spirv.ptr to !spirv.ptr, Function> + %0 = spirv.Bitcast %arg0 : !spirv.ptr to !spirv.ptr, Function> return } func.func @cast6(%arg0 : vector<4xf32>) { - // CHECK: {{%.*}} = spv.Bitcast {{%.*}} : vector<4xf32> to vector<2xi64> - %0 = spv.Bitcast %arg0 : vector<4xf32> to vector<2xi64> + // CHECK: {{%.*}} = spirv.Bitcast {{%.*}} : vector<4xf32> to vector<2xi64> + %0 = spirv.Bitcast %arg0 : vector<4xf32> to vector<2xi64> return } @@ -44,7 +44,7 @@ func.func @cast1(%arg0 : f32) { // expected-error @+1 {{result type must be different from operand type}} - %0 = spv.Bitcast %arg0 : f32 to f32 + %0 = spirv.Bitcast %arg0 : f32 to f32 return } @@ -52,7 +52,7 @@ func.func @cast1(%arg0 : f32) { // expected-error @+1 {{mismatch in result type bitwidth 64 and operand type bitwidth 32}} - %0 = spv.Bitcast %arg0 : f32 to i64 + %0 = spirv.Bitcast %arg0 : f32 to i64 return } @@ -60,15 +60,15 @@ func.func @cast1(%arg0 : vector<2xf32>) { // expected-error @+1 {{mismatch in result type bitwidth 96 and operand type bitwidth 64}} - %0 = spv.Bitcast %arg0 : vector<2xf32> to vector<3xf32> + %0 = spirv.Bitcast %arg0 : vector<2xf32> to vector<3xf32> return } // ----- -func.func @cast3(%arg0 : !spv.ptr) { +func.func @cast3(%arg0 : !spirv.ptr) { // expected-error @+1 {{unhandled bit cast conversion from pointer type to non-pointer type}} - %0 = spv.Bitcast %arg0 : !spv.ptr to i64 + %0 = spirv.Bitcast %arg0 : !spirv.ptr to i64 return } @@ -76,290 +76,290 @@ func.func @cast3(%arg0 : i64) { // expected-error @+1 {{unhandled bit cast conversion from non-pointer type to pointer type}} - %0 = spv.Bitcast %arg0 : i64 to !spv.ptr + %0 = spirv.Bitcast %arg0 : i64 to !spirv.ptr return } // ----- //===----------------------------------------------------------------------===// -// spv.ConvertFToS +// spirv.ConvertFToS //===----------------------------------------------------------------------===// func.func @convert_f_to_s_scalar(%arg0 : f32) -> i32 { - // CHECK: {{%.*}} = spv.ConvertFToS {{%.*}} : f32 to i32 - %0 = spv.ConvertFToS %arg0 : f32 to i32 - spv.ReturnValue %0 : i32 + // CHECK: {{%.*}} = spirv.ConvertFToS {{%.*}} : f32 to i32 + %0 = spirv.ConvertFToS %arg0 : f32 to i32 + spirv.ReturnValue %0 : i32 } // ----- func.func @convert_f64_to_s32_scalar(%arg0 : f64) -> i32 { - // CHECK: {{%.*}} = spv.ConvertFToS {{%.*}} : f64 to i32 - %0 = spv.ConvertFToS %arg0 : f64 to i32 - spv.ReturnValue %0 : i32 + // CHECK: {{%.*}} = spirv.ConvertFToS {{%.*}} : f64 to i32 + %0 = spirv.ConvertFToS %arg0 : f64 to i32 + spirv.ReturnValue %0 : i32 } // ----- func.func @convert_f_to_s_vector(%arg0 : vector<3xf32>) -> vector<3xi32> { - // CHECK: {{%.*}} = spv.ConvertFToS {{%.*}} : vector<3xf32> to vector<3xi32> - %0 = spv.ConvertFToS %arg0 : vector<3xf32> to vector<3xi32> - spv.ReturnValue %0 : vector<3xi32> + // CHECK: {{%.*}} = spirv.ConvertFToS {{%.*}} : vector<3xf32> to vector<3xi32> + %0 = spirv.ConvertFToS %arg0 : vector<3xf32> to vector<3xi32> + spirv.ReturnValue %0 : vector<3xi32> } // ----- //===----------------------------------------------------------------------===// -// spv.ConvertFToU +// spirv.ConvertFToU //===----------------------------------------------------------------------===// func.func @convert_f_to_u_scalar(%arg0 : f32) -> i32 { - // CHECK: {{%.*}} = spv.ConvertFToU {{%.*}} : f32 to i32 - %0 = spv.ConvertFToU %arg0 : f32 to i32 - spv.ReturnValue %0 : i32 + // CHECK: {{%.*}} = spirv.ConvertFToU {{%.*}} : f32 to i32 + %0 = spirv.ConvertFToU %arg0 : f32 to i32 + spirv.ReturnValue %0 : i32 } // ----- func.func @convert_f64_to_u32_scalar(%arg0 : f64) -> i32 { - // CHECK: {{%.*}} = spv.ConvertFToU {{%.*}} : f64 to i32 - %0 = spv.ConvertFToU %arg0 : f64 to i32 - spv.ReturnValue %0 : i32 + // CHECK: {{%.*}} = spirv.ConvertFToU {{%.*}} : f64 to i32 + %0 = spirv.ConvertFToU %arg0 : f64 to i32 + spirv.ReturnValue %0 : i32 } // ----- func.func @convert_f_to_u_vector(%arg0 : vector<3xf32>) -> vector<3xi32> { - // CHECK: {{%.*}} = spv.ConvertFToU {{%.*}} : vector<3xf32> to vector<3xi32> - %0 = spv.ConvertFToU %arg0 : vector<3xf32> to vector<3xi32> - spv.ReturnValue %0 : vector<3xi32> + // CHECK: {{%.*}} = spirv.ConvertFToU {{%.*}} : vector<3xf32> to vector<3xi32> + %0 = spirv.ConvertFToU %arg0 : vector<3xf32> to vector<3xi32> + spirv.ReturnValue %0 : vector<3xi32> } // ----- -func.func @convert_f_to_u_coopmatrix(%arg0 : !spv.coopmatrix<8x16xf32, Subgroup>) { - // CHECK: {{%.*}} = spv.ConvertFToU {{%.*}} : !spv.coopmatrix<8x16xf32, Subgroup> to !spv.coopmatrix<8x16xi32, Subgroup> - %0 = spv.ConvertFToU %arg0 : !spv.coopmatrix<8x16xf32, Subgroup> to !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return +func.func @convert_f_to_u_coopmatrix(%arg0 : !spirv.coopmatrix<8x16xf32, Subgroup>) { + // CHECK: {{%.*}} = spirv.ConvertFToU {{%.*}} : !spirv.coopmatrix<8x16xf32, Subgroup> to !spirv.coopmatrix<8x16xi32, Subgroup> + %0 = spirv.ConvertFToU %arg0 : !spirv.coopmatrix<8x16xf32, Subgroup> to !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // ----- //===----------------------------------------------------------------------===// -// spv.ConvertSToF +// spirv.ConvertSToF //===----------------------------------------------------------------------===// func.func @convert_s_to_f_scalar(%arg0 : i32) -> f32 { - // CHECK: {{%.*}} = spv.ConvertSToF {{%.*}} : i32 to f32 - %0 = spv.ConvertSToF %arg0 : i32 to f32 - spv.ReturnValue %0 : f32 + // CHECK: {{%.*}} = spirv.ConvertSToF {{%.*}} : i32 to f32 + %0 = spirv.ConvertSToF %arg0 : i32 to f32 + spirv.ReturnValue %0 : f32 } // ----- func.func @convert_s64_to_f32_scalar(%arg0 : i64) -> f32 { - // CHECK: {{%.*}} = spv.ConvertSToF {{%.*}} : i64 to f32 - %0 = spv.ConvertSToF %arg0 : i64 to f32 - spv.ReturnValue %0 : f32 + // CHECK: {{%.*}} = spirv.ConvertSToF {{%.*}} : i64 to f32 + %0 = spirv.ConvertSToF %arg0 : i64 to f32 + spirv.ReturnValue %0 : f32 } // ----- func.func @convert_s_to_f_vector(%arg0 : vector<3xi32>) -> vector<3xf32> { - // CHECK: {{%.*}} = spv.ConvertSToF {{%.*}} : vector<3xi32> to vector<3xf32> - %0 = spv.ConvertSToF %arg0 : vector<3xi32> to vector<3xf32> - spv.ReturnValue %0 : vector<3xf32> + // CHECK: {{%.*}} = spirv.ConvertSToF {{%.*}} : vector<3xi32> to vector<3xf32> + %0 = spirv.ConvertSToF %arg0 : vector<3xi32> to vector<3xf32> + spirv.ReturnValue %0 : vector<3xf32> } // ----- //===----------------------------------------------------------------------===// -// spv.ConvertUToF +// spirv.ConvertUToF //===----------------------------------------------------------------------===// func.func @convert_u_to_f_scalar(%arg0 : i32) -> f32 { - // CHECK: {{%.*}} = spv.ConvertUToF {{%.*}} : i32 to f32 - %0 = spv.ConvertUToF %arg0 : i32 to f32 - spv.ReturnValue %0 : f32 + // CHECK: {{%.*}} = spirv.ConvertUToF {{%.*}} : i32 to f32 + %0 = spirv.ConvertUToF %arg0 : i32 to f32 + spirv.ReturnValue %0 : f32 } // ----- func.func @convert_u64_to_f32_scalar(%arg0 : i64) -> f32 { - // CHECK: {{%.*}} = spv.ConvertUToF {{%.*}} : i64 to f32 - %0 = spv.ConvertUToF %arg0 : i64 to f32 - spv.ReturnValue %0 : f32 + // CHECK: {{%.*}} = spirv.ConvertUToF {{%.*}} : i64 to f32 + %0 = spirv.ConvertUToF %arg0 : i64 to f32 + spirv.ReturnValue %0 : f32 } // ----- func.func @convert_u_to_f_vector(%arg0 : vector<3xi32>) -> vector<3xf32> { - // CHECK: {{%.*}} = spv.ConvertUToF {{%.*}} : vector<3xi32> to vector<3xf32> - %0 = spv.ConvertUToF %arg0 : vector<3xi32> to vector<3xf32> - spv.ReturnValue %0 : vector<3xf32> + // CHECK: {{%.*}} = spirv.ConvertUToF {{%.*}} : vector<3xi32> to vector<3xf32> + %0 = spirv.ConvertUToF %arg0 : vector<3xi32> to vector<3xf32> + spirv.ReturnValue %0 : vector<3xf32> } // ----- //===----------------------------------------------------------------------===// -// spv.FConvert +// spirv.FConvert //===----------------------------------------------------------------------===// func.func @f_convert_scalar(%arg0 : f32) -> f64 { - // CHECK: {{%.*}} = spv.FConvert {{%.*}} : f32 to f64 - %0 = spv.FConvert %arg0 : f32 to f64 - spv.ReturnValue %0 : f64 + // CHECK: {{%.*}} = spirv.FConvert {{%.*}} : f32 to f64 + %0 = spirv.FConvert %arg0 : f32 to f64 + spirv.ReturnValue %0 : f64 } // ----- func.func @f_convert_vector(%arg0 : vector<3xf32>) -> vector<3xf64> { - // CHECK: {{%.*}} = spv.FConvert {{%.*}} : vector<3xf32> to vector<3xf64> - %0 = spv.FConvert %arg0 : vector<3xf32> to vector<3xf64> - spv.ReturnValue %0 : vector<3xf64> + // CHECK: {{%.*}} = spirv.FConvert {{%.*}} : vector<3xf32> to vector<3xf64> + %0 = spirv.FConvert %arg0 : vector<3xf32> to vector<3xf64> + spirv.ReturnValue %0 : vector<3xf64> } // ----- -func.func @f_convert_coop_matrix(%arg0 : !spv.coopmatrix<8x16xf32, Subgroup>) { - // CHECK: {{%.*}} = spv.FConvert {{%.*}} : !spv.coopmatrix<8x16xf32, Subgroup> to !spv.coopmatrix<8x16xf64, Subgroup> - %0 = spv.FConvert %arg0 : !spv.coopmatrix<8x16xf32, Subgroup> to !spv.coopmatrix<8x16xf64, Subgroup> - spv.Return +func.func @f_convert_coop_matrix(%arg0 : !spirv.coopmatrix<8x16xf32, Subgroup>) { + // CHECK: {{%.*}} = spirv.FConvert {{%.*}} : !spirv.coopmatrix<8x16xf32, Subgroup> to !spirv.coopmatrix<8x16xf64, Subgroup> + %0 = spirv.FConvert %arg0 : !spirv.coopmatrix<8x16xf32, Subgroup> to !spirv.coopmatrix<8x16xf64, Subgroup> + spirv.Return } // ----- func.func @f_convert_vector(%arg0 : f32) -> f32 { // expected-error @+1 {{expected the different bit widths for operand type and result type, but provided 'f32' and 'f32'}} - %0 = spv.FConvert %arg0 : f32 to f32 - spv.ReturnValue %0 : f32 + %0 = spirv.FConvert %arg0 : f32 to f32 + spirv.ReturnValue %0 : f32 } // ----- //===----------------------------------------------------------------------===// -// spv.SConvert +// spirv.SConvert //===----------------------------------------------------------------------===// func.func @s_convert_scalar(%arg0 : i32) -> i64 { - // CHECK: {{%.*}} = spv.SConvert {{%.*}} : i32 to i64 - %0 = spv.SConvert %arg0 : i32 to i64 - spv.ReturnValue %0 : i64 + // CHECK: {{%.*}} = spirv.SConvert {{%.*}} : i32 to i64 + %0 = spirv.SConvert %arg0 : i32 to i64 + spirv.ReturnValue %0 : i64 } // ----- //===----------------------------------------------------------------------===// -// spv.UConvert +// spirv.UConvert //===----------------------------------------------------------------------===// func.func @u_convert_scalar(%arg0 : i32) -> i64 { - // CHECK: {{%.*}} = spv.UConvert {{%.*}} : i32 to i64 - %0 = spv.UConvert %arg0 : i32 to i64 - spv.ReturnValue %0 : i64 + // CHECK: {{%.*}} = spirv.UConvert {{%.*}} : i32 to i64 + %0 = spirv.UConvert %arg0 : i32 to i64 + spirv.ReturnValue %0 : i64 } // ----- //===----------------------------------------------------------------------===// -// spv.PtrCastToGeneric +// spirv.PtrCastToGeneric //===----------------------------------------------------------------------===// -func.func @ptrcasttogeneric1(%arg0 : !spv.ptr) { - // CHECK: {{%.*}} = spv.PtrCastToGeneric {{%.*}} : !spv.ptr to !spv.ptr - %0 = spv.PtrCastToGeneric %arg0 : !spv.ptr to !spv.ptr +func.func @ptrcasttogeneric1(%arg0 : !spirv.ptr) { + // CHECK: {{%.*}} = spirv.PtrCastToGeneric {{%.*}} : !spirv.ptr to !spirv.ptr + %0 = spirv.PtrCastToGeneric %arg0 : !spirv.ptr to !spirv.ptr return } // ----- -func.func @ptrcasttogeneric2(%arg0 : !spv.ptr) { +func.func @ptrcasttogeneric2(%arg0 : !spirv.ptr) { // expected-error @+1 {{pointer must point to the Workgroup, CrossWorkgroup, or Function Storage Class}} - %0 = spv.PtrCastToGeneric %arg0 : !spv.ptr to !spv.ptr + %0 = spirv.PtrCastToGeneric %arg0 : !spirv.ptr to !spirv.ptr return } // ----- -func.func @ptrcasttogeneric3(%arg0 : !spv.ptr) { +func.func @ptrcasttogeneric3(%arg0 : !spirv.ptr) { // expected-error @+1 {{result type must be of storage class Generic}} - %0 = spv.PtrCastToGeneric %arg0 : !spv.ptr to !spv.ptr + %0 = spirv.PtrCastToGeneric %arg0 : !spirv.ptr to !spirv.ptr return } // ----- -func.func @ptrcasttogeneric4(%arg0 : !spv.ptr) { +func.func @ptrcasttogeneric4(%arg0 : !spirv.ptr) { // expected-error @+1 {{pointee type must have the same as the op result type}} - %0 = spv.PtrCastToGeneric %arg0 : !spv.ptr to !spv.ptr, Generic> + %0 = spirv.PtrCastToGeneric %arg0 : !spirv.ptr to !spirv.ptr, Generic> return } // ----- //===----------------------------------------------------------------------===// -// spv.GenericCastToPtr +// spirv.GenericCastToPtr //===----------------------------------------------------------------------===// -func.func @genericcasttoptr1(%arg0 : !spv.ptr, Generic>) { - // CHECK: {{%.*}} = spv.GenericCastToPtr {{%.*}} : !spv.ptr, Generic> to !spv.ptr, CrossWorkgroup> - %0 = spv.GenericCastToPtr %arg0 : !spv.ptr, Generic> to !spv.ptr, CrossWorkgroup> +func.func @genericcasttoptr1(%arg0 : !spirv.ptr, Generic>) { + // CHECK: {{%.*}} = spirv.GenericCastToPtr {{%.*}} : !spirv.ptr, Generic> to !spirv.ptr, CrossWorkgroup> + %0 = spirv.GenericCastToPtr %arg0 : !spirv.ptr, Generic> to !spirv.ptr, CrossWorkgroup> return } // ----- -func.func @genericcasttoptr2(%arg0 : !spv.ptr) { +func.func @genericcasttoptr2(%arg0 : !spirv.ptr) { // expected-error @+1 {{pointer type must be of storage class Generic}} - %0 = spv.GenericCastToPtr %arg0 : !spv.ptr to !spv.ptr + %0 = spirv.GenericCastToPtr %arg0 : !spirv.ptr to !spirv.ptr return } // ----- -func.func @genericcasttoptr3(%arg0 : !spv.ptr) { +func.func @genericcasttoptr3(%arg0 : !spirv.ptr) { // expected-error @+1 {{result must point to the Workgroup, CrossWorkgroup, or Function Storage Class}} - %0 = spv.GenericCastToPtr %arg0 : !spv.ptr to !spv.ptr + %0 = spirv.GenericCastToPtr %arg0 : !spirv.ptr to !spirv.ptr return } // ----- -func.func @genericcasttoptr4(%arg0 : !spv.ptr) { +func.func @genericcasttoptr4(%arg0 : !spirv.ptr) { // expected-error @+1 {{pointee type must have the same as the op result type}} - %0 = spv.GenericCastToPtr %arg0 : !spv.ptr to !spv.ptr, Workgroup> + %0 = spirv.GenericCastToPtr %arg0 : !spirv.ptr to !spirv.ptr, Workgroup> return } // ----- //===----------------------------------------------------------------------===// -// spv.GenericCastToPtrExplicit +// spirv.GenericCastToPtrExplicit //===----------------------------------------------------------------------===// -func.func @genericcasttoptrexplicit1(%arg0 : !spv.ptr, Generic>) { - // CHECK: {{%.*}} = spv.GenericCastToPtrExplicit {{%.*}} : !spv.ptr, Generic> to !spv.ptr, CrossWorkgroup> - %0 = spv.GenericCastToPtrExplicit %arg0 : !spv.ptr, Generic> to !spv.ptr, CrossWorkgroup> +func.func @genericcasttoptrexplicit1(%arg0 : !spirv.ptr, Generic>) { + // CHECK: {{%.*}} = spirv.GenericCastToPtrExplicit {{%.*}} : !spirv.ptr, Generic> to !spirv.ptr, CrossWorkgroup> + %0 = spirv.GenericCastToPtrExplicit %arg0 : !spirv.ptr, Generic> to !spirv.ptr, CrossWorkgroup> return } // ----- -func.func @genericcasttoptrexplicit2(%arg0 : !spv.ptr) { +func.func @genericcasttoptrexplicit2(%arg0 : !spirv.ptr) { // expected-error @+1 {{pointer type must be of storage class Generic}} - %0 = spv.GenericCastToPtrExplicit %arg0 : !spv.ptr to !spv.ptr + %0 = spirv.GenericCastToPtrExplicit %arg0 : !spirv.ptr to !spirv.ptr return } // ----- -func.func @genericcasttoptrexplicit3(%arg0 : !spv.ptr) { +func.func @genericcasttoptrexplicit3(%arg0 : !spirv.ptr) { // expected-error @+1 {{result must point to the Workgroup, CrossWorkgroup, or Function Storage Class}} - %0 = spv.GenericCastToPtrExplicit %arg0 : !spv.ptr to !spv.ptr + %0 = spirv.GenericCastToPtrExplicit %arg0 : !spirv.ptr to !spirv.ptr return } // ----- -func.func @genericcasttoptrexplicit4(%arg0 : !spv.ptr) { +func.func @genericcasttoptrexplicit4(%arg0 : !spirv.ptr) { // expected-error @+1 {{pointee type must have the same as the op result type}} - %0 = spv.GenericCastToPtrExplicit %arg0 : !spv.ptr to !spv.ptr, Workgroup> + %0 = spirv.GenericCastToPtrExplicit %arg0 : !spirv.ptr to !spirv.ptr, Workgroup> return } diff --git a/mlir/test/Dialect/SPIRV/IR/composite-ops.mlir b/mlir/test/Dialect/SPIRV/IR/composite-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/composite-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/composite-ops.mlir @@ -1,45 +1,45 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.CompositeConstruct +// spirv.CompositeConstruct //===----------------------------------------------------------------------===// func.func @composite_construct_vector(%arg0: f32, %arg1: f32, %arg2 : f32) -> vector<3xf32> { - // CHECK: spv.CompositeConstruct {{%.*}}, {{%.*}}, {{%.*}} : (f32, f32, f32) -> vector<3xf32> - %0 = spv.CompositeConstruct %arg0, %arg1, %arg2 : (f32, f32, f32) -> vector<3xf32> + // CHECK: spirv.CompositeConstruct {{%.*}}, {{%.*}}, {{%.*}} : (f32, f32, f32) -> vector<3xf32> + %0 = spirv.CompositeConstruct %arg0, %arg1, %arg2 : (f32, f32, f32) -> vector<3xf32> return %0: vector<3xf32> } // ----- -func.func @composite_construct_struct(%arg0: vector<3xf32>, %arg1: !spv.array<4xf32>, %arg2 : !spv.struct<(f32)>) -> !spv.struct<(vector<3xf32>, !spv.array<4xf32>, !spv.struct<(f32)>)> { - // CHECK: spv.CompositeConstruct - %0 = spv.CompositeConstruct %arg0, %arg1, %arg2 : (vector<3xf32>, !spv.array<4xf32>, !spv.struct<(f32)>) -> !spv.struct<(vector<3xf32>, !spv.array<4xf32>, !spv.struct<(f32)>)> - return %0: !spv.struct<(vector<3xf32>, !spv.array<4xf32>, !spv.struct<(f32)>)> +func.func @composite_construct_struct(%arg0: vector<3xf32>, %arg1: !spirv.array<4xf32>, %arg2 : !spirv.struct<(f32)>) -> !spirv.struct<(vector<3xf32>, !spirv.array<4xf32>, !spirv.struct<(f32)>)> { + // CHECK: spirv.CompositeConstruct + %0 = spirv.CompositeConstruct %arg0, %arg1, %arg2 : (vector<3xf32>, !spirv.array<4xf32>, !spirv.struct<(f32)>) -> !spirv.struct<(vector<3xf32>, !spirv.array<4xf32>, !spirv.struct<(f32)>)> + return %0: !spirv.struct<(vector<3xf32>, !spirv.array<4xf32>, !spirv.struct<(f32)>)> } // ----- // CHECK-LABEL: func @composite_construct_mixed_scalar_vector func.func @composite_construct_mixed_scalar_vector(%arg0: f32, %arg1: f32, %arg2 : vector<2xf32>) -> vector<4xf32> { - // CHECK: spv.CompositeConstruct %{{.+}}, %{{.+}}, %{{.+}} : (f32, vector<2xf32>, f32) -> vector<4xf32> - %0 = spv.CompositeConstruct %arg0, %arg2, %arg1 : (f32, vector<2xf32>, f32) -> vector<4xf32> + // CHECK: spirv.CompositeConstruct %{{.+}}, %{{.+}}, %{{.+}} : (f32, vector<2xf32>, f32) -> vector<4xf32> + %0 = spirv.CompositeConstruct %arg0, %arg2, %arg1 : (f32, vector<2xf32>, f32) -> vector<4xf32> return %0: vector<4xf32> } // ----- -func.func @composite_construct_coopmatrix(%arg0 : f32) -> !spv.coopmatrix<8x16xf32, Subgroup> { - // CHECK: spv.CompositeConstruct {{%.*}} : (f32) -> !spv.coopmatrix<8x16xf32, Subgroup> - %0 = spv.CompositeConstruct %arg0 : (f32) -> !spv.coopmatrix<8x16xf32, Subgroup> - return %0: !spv.coopmatrix<8x16xf32, Subgroup> +func.func @composite_construct_coopmatrix(%arg0 : f32) -> !spirv.coopmatrix<8x16xf32, Subgroup> { + // CHECK: spirv.CompositeConstruct {{%.*}} : (f32) -> !spirv.coopmatrix<8x16xf32, Subgroup> + %0 = spirv.CompositeConstruct %arg0 : (f32) -> !spirv.coopmatrix<8x16xf32, Subgroup> + return %0: !spirv.coopmatrix<8x16xf32, Subgroup> } // ----- func.func @composite_construct_invalid_result_type(%arg0: f32, %arg1: f32, %arg2 : f32) -> vector<3xf32> { // expected-error @+1 {{has incorrect number of operands: expected 3, but provided 2}} - %0 = spv.CompositeConstruct %arg0, %arg2 : (f32, f32) -> vector<3xf32> + %0 = spirv.CompositeConstruct %arg0, %arg2 : (f32, f32) -> vector<3xf32> return %0: vector<3xf32> } @@ -47,39 +47,39 @@ func.func @composite_construct_invalid_operand_type(%arg0: f32, %arg1: f32, %arg2 : f32) -> vector<3xi32> { // expected-error @+1 {{operand type mismatch: expected operand type 'i32', but provided 'f32'}} - %0 = spv.CompositeConstruct %arg0, %arg1, %arg2 : (f32, f32, f32) -> vector<3xi32> + %0 = spirv.CompositeConstruct %arg0, %arg1, %arg2 : (f32, f32, f32) -> vector<3xi32> return %0: vector<3xi32> } // ----- -func.func @composite_construct_coopmatrix_incorrect_operand_count(%arg0 : f32, %arg1 : f32) -> !spv.coopmatrix<8x16xf32, Subgroup> { +func.func @composite_construct_coopmatrix_incorrect_operand_count(%arg0 : f32, %arg1 : f32) -> !spirv.coopmatrix<8x16xf32, Subgroup> { // expected-error @+1 {{has incorrect number of operands: expected 1, but provided 2}} - %0 = spv.CompositeConstruct %arg0, %arg1 : (f32, f32) -> !spv.coopmatrix<8x16xf32, Subgroup> - return %0: !spv.coopmatrix<8x16xf32, Subgroup> + %0 = spirv.CompositeConstruct %arg0, %arg1 : (f32, f32) -> !spirv.coopmatrix<8x16xf32, Subgroup> + return %0: !spirv.coopmatrix<8x16xf32, Subgroup> } // ----- -func.func @composite_construct_coopmatrix_incorrect_element_type(%arg0 : i32) -> !spv.coopmatrix<8x16xf32, Subgroup> { +func.func @composite_construct_coopmatrix_incorrect_element_type(%arg0 : i32) -> !spirv.coopmatrix<8x16xf32, Subgroup> { // expected-error @+1 {{operand type mismatch: expected operand type 'f32', but provided 'i32'}} - %0 = spv.CompositeConstruct %arg0 : (i32) -> !spv.coopmatrix<8x16xf32, Subgroup> - return %0: !spv.coopmatrix<8x16xf32, Subgroup> + %0 = spirv.CompositeConstruct %arg0 : (i32) -> !spirv.coopmatrix<8x16xf32, Subgroup> + return %0: !spirv.coopmatrix<8x16xf32, Subgroup> } // ----- -func.func @composite_construct_array(%arg0: f32) -> !spv.array<4xf32> { +func.func @composite_construct_array(%arg0: f32) -> !spirv.array<4xf32> { // expected-error @+1 {{expected to return a vector or cooperative matrix when the number of constituents is less than what the result needs}} - %0 = spv.CompositeConstruct %arg0 : (f32) -> !spv.array<4xf32> - return %0: !spv.array<4xf32> + %0 = spirv.CompositeConstruct %arg0 : (f32) -> !spirv.array<4xf32> + return %0: !spirv.array<4xf32> } // ----- func.func @composite_construct_vector_wrong_element_type(%arg0: f32, %arg1: f32, %arg2 : vector<2xi32>) -> vector<4xf32> { // expected-error @+1 {{operand element type mismatch: expected to be 'f32', but provided 'i32'}} - %0 = spv.CompositeConstruct %arg0, %arg2, %arg1 : (f32, vector<2xi32>, f32) -> vector<4xf32> + %0 = spirv.CompositeConstruct %arg0, %arg2, %arg1 : (f32, vector<2xi32>, f32) -> vector<4xf32> return %0: vector<4xf32> } @@ -87,43 +87,43 @@ func.func @composite_construct_vector_wrong_count(%arg0: f32, %arg1: f32, %arg2 : vector<2xf32>) -> vector<4xf32> { // expected-error @+1 {{op has incorrect number of operands: expected 4, but provided 3}} - %0 = spv.CompositeConstruct %arg0, %arg2 : (f32, vector<2xf32>) -> vector<4xf32> + %0 = spirv.CompositeConstruct %arg0, %arg2 : (f32, vector<2xf32>) -> vector<4xf32> return %0: vector<4xf32> } // ----- //===----------------------------------------------------------------------===// -// spv.CompositeExtractOp +// spirv.CompositeExtractOp //===----------------------------------------------------------------------===// -func.func @composite_extract_array(%arg0: !spv.array<4xf32>) -> f32 { - // CHECK: {{%.*}} = spv.CompositeExtract {{%.*}}[1 : i32] : !spv.array<4 x f32> - %0 = spv.CompositeExtract %arg0[1 : i32] : !spv.array<4xf32> +func.func @composite_extract_array(%arg0: !spirv.array<4xf32>) -> f32 { + // CHECK: {{%.*}} = spirv.CompositeExtract {{%.*}}[1 : i32] : !spirv.array<4 x f32> + %0 = spirv.CompositeExtract %arg0[1 : i32] : !spirv.array<4xf32> return %0: f32 } // ----- -func.func @composite_extract_struct(%arg0 : !spv.struct<(f32, !spv.array<4xf32>)>) -> f32 { - // CHECK: {{%.*}} = spv.CompositeExtract {{%.*}}[1 : i32, 2 : i32] : !spv.struct<(f32, !spv.array<4 x f32>)> - %0 = spv.CompositeExtract %arg0[1 : i32, 2 : i32] : !spv.struct<(f32, !spv.array<4xf32>)> +func.func @composite_extract_struct(%arg0 : !spirv.struct<(f32, !spirv.array<4xf32>)>) -> f32 { + // CHECK: {{%.*}} = spirv.CompositeExtract {{%.*}}[1 : i32, 2 : i32] : !spirv.struct<(f32, !spirv.array<4 x f32>)> + %0 = spirv.CompositeExtract %arg0[1 : i32, 2 : i32] : !spirv.struct<(f32, !spirv.array<4xf32>)> return %0 : f32 } // ----- func.func @composite_extract_vector(%arg0 : vector<4xf32>) -> f32 { - // CHECK: {{%.*}} = spv.CompositeExtract {{%.*}}[1 : i32] : vector<4xf32> - %0 = spv.CompositeExtract %arg0[1 : i32] : vector<4xf32> + // CHECK: {{%.*}} = spirv.CompositeExtract {{%.*}}[1 : i32] : vector<4xf32> + %0 = spirv.CompositeExtract %arg0[1 : i32] : vector<4xf32> return %0 : f32 } // ----- -func.func @composite_extract_coopmatrix(%arg0 : !spv.coopmatrix<8x16xf32, Subgroup>) -> f32 { - // CHECK: {{%.*}} = spv.CompositeExtract {{%.*}}[2 : i32] : !spv.coopmatrix<8x16xf32, Subgroup> - %0 = spv.CompositeExtract %arg0[2 : i32] : !spv.coopmatrix<8x16xf32, Subgroup> +func.func @composite_extract_coopmatrix(%arg0 : !spirv.coopmatrix<8x16xf32, Subgroup>) -> f32 { + // CHECK: {{%.*}} = spirv.CompositeExtract {{%.*}}[2 : i32] : !spirv.coopmatrix<8x16xf32, Subgroup> + %0 = spirv.CompositeExtract %arg0[2 : i32] : !spirv.coopmatrix<8x16xf32, Subgroup> return %0 : f32 } @@ -131,59 +131,59 @@ func.func @composite_extract_no_ssa_operand() -> () { // expected-error @+1 {{expected SSA operand}} - %0 = spv.CompositeExtract [4 : i32, 1 : i32] : !spv.array<4x!spv.array<4xf32>> + %0 = spirv.CompositeExtract [4 : i32, 1 : i32] : !spirv.array<4x!spirv.array<4xf32>> return } // ----- func.func @composite_extract_invalid_index_type_1() -> () { - %0 = spv.Constant 10 : i32 - %1 = spv.Variable : !spv.ptr>, Function> - %2 = spv.Load "Function" %1 ["Volatile"] : !spv.array<4x!spv.array<4xf32>> + %0 = spirv.Constant 10 : i32 + %1 = spirv.Variable : !spirv.ptr>, Function> + %2 = spirv.Load "Function" %1 ["Volatile"] : !spirv.array<4x!spirv.array<4xf32>> // expected-error @+1 {{expected attribute value}} - %3 = spv.CompositeExtract %2[%0] : !spv.array<4x!spv.array<4xf32>> + %3 = spirv.CompositeExtract %2[%0] : !spirv.array<4x!spirv.array<4xf32>> return } // ----- -func.func @composite_extract_invalid_index_type_2(%arg0 : !spv.array<4x!spv.array<4xf32>>) -> () { +func.func @composite_extract_invalid_index_type_2(%arg0 : !spirv.array<4x!spirv.array<4xf32>>) -> () { // expected-error @+1 {{attribute 'indices' failed to satisfy constraint: 32-bit integer array attribute}} - %0 = spv.CompositeExtract %arg0[1] : !spv.array<4x!spv.array<4xf32>> + %0 = spirv.CompositeExtract %arg0[1] : !spirv.array<4x!spirv.array<4xf32>> return } // ----- -func.func @composite_extract_invalid_index_identifier(%arg0 : !spv.array<4x!spv.array<4xf32>>) -> () { +func.func @composite_extract_invalid_index_identifier(%arg0 : !spirv.array<4x!spirv.array<4xf32>>) -> () { // expected-error @+1 {{expected attribute value}} - %0 = spv.CompositeExtract %arg0 ]1 : i32) : !spv.array<4x!spv.array<4xf32>> + %0 = spirv.CompositeExtract %arg0 ]1 : i32) : !spirv.array<4x!spirv.array<4xf32>> return } // ----- -func.func @composite_extract_2D_array_out_of_bounds_access_1(%arg0: !spv.array<4x!spv.array<4xf32>>) -> () { - // expected-error @+1 {{index 4 out of bounds for '!spv.array<4 x !spv.array<4 x f32>>'}} - %0 = spv.CompositeExtract %arg0[4 : i32, 1 : i32] : !spv.array<4x!spv.array<4xf32>> +func.func @composite_extract_2D_array_out_of_bounds_access_1(%arg0: !spirv.array<4x!spirv.array<4xf32>>) -> () { + // expected-error @+1 {{index 4 out of bounds for '!spirv.array<4 x !spirv.array<4 x f32>>'}} + %0 = spirv.CompositeExtract %arg0[4 : i32, 1 : i32] : !spirv.array<4x!spirv.array<4xf32>> return } // ----- -func.func @composite_extract_2D_array_out_of_bounds_access_2(%arg0: !spv.array<4x!spv.array<4xf32>> +func.func @composite_extract_2D_array_out_of_bounds_access_2(%arg0: !spirv.array<4x!spirv.array<4xf32>> ) -> () { - // expected-error @+1 {{index 4 out of bounds for '!spv.array<4 x f32>'}} - %0 = spv.CompositeExtract %arg0[1 : i32, 4 : i32] : !spv.array<4x!spv.array<4xf32>> + // expected-error @+1 {{index 4 out of bounds for '!spirv.array<4 x f32>'}} + %0 = spirv.CompositeExtract %arg0[1 : i32, 4 : i32] : !spirv.array<4x!spirv.array<4xf32>> return } // ----- -func.func @composite_extract_struct_element_out_of_bounds_access(%arg0 : !spv.struct<(f32, !spv.array<4xf32>)>) -> () { - // expected-error @+1 {{index 2 out of bounds for '!spv.struct<(f32, !spv.array<4 x f32>)>'}} - %0 = spv.CompositeExtract %arg0[2 : i32, 0 : i32] : !spv.struct<(f32, !spv.array<4xf32>)> +func.func @composite_extract_struct_element_out_of_bounds_access(%arg0 : !spirv.struct<(f32, !spirv.array<4xf32>)>) -> () { + // expected-error @+1 {{index 2 out of bounds for '!spirv.struct<(f32, !spirv.array<4 x f32>)>'}} + %0 = spirv.CompositeExtract %arg0[2 : i32, 0 : i32] : !spirv.struct<(f32, !spirv.array<4xf32>)> return } @@ -191,15 +191,15 @@ func.func @composite_extract_vector_out_of_bounds_access(%arg0: vector<4xf32>) -> () { // expected-error @+1 {{index 4 out of bounds for 'vector<4xf32>'}} - %0 = spv.CompositeExtract %arg0[4 : i32] : vector<4xf32> + %0 = spirv.CompositeExtract %arg0[4 : i32] : vector<4xf32> return } // ----- -func.func @composite_extract_invalid_types_1(%arg0: !spv.array<4x!spv.array<4xf32>>) -> () { +func.func @composite_extract_invalid_types_1(%arg0: !spirv.array<4x!spirv.array<4xf32>>) -> () { // expected-error @+1 {{cannot extract from non-composite type 'f32' with index 3}} - %0 = spv.CompositeExtract %arg0[1 : i32, 2 : i32, 3 : i32] : !spv.array<4x!spv.array<4xf32>> + %0 = spirv.CompositeExtract %arg0[1 : i32, 2 : i32, 3 : i32] : !spirv.array<4x!spirv.array<4xf32>> return } @@ -207,117 +207,117 @@ func.func @composite_extract_invalid_types_2(%arg0: f32) -> () { // expected-error @+1 {{cannot extract from non-composite type 'f32' with index 1}} - %0 = spv.CompositeExtract %arg0[1 : i32] : f32 + %0 = spirv.CompositeExtract %arg0[1 : i32] : f32 return } // ----- -func.func @composite_extract_invalid_extracted_type(%arg0: !spv.array<4x!spv.array<4xf32>>) -> () { - // expected-error @+1 {{expected at least one index for spv.CompositeExtract}} - %0 = spv.CompositeExtract %arg0[] : !spv.array<4x!spv.array<4xf32>> +func.func @composite_extract_invalid_extracted_type(%arg0: !spirv.array<4x!spirv.array<4xf32>>) -> () { + // expected-error @+1 {{expected at least one index for spirv.CompositeExtract}} + %0 = spirv.CompositeExtract %arg0[] : !spirv.array<4x!spirv.array<4xf32>> return } // ----- -func.func @composite_extract_result_type_mismatch(%arg0: !spv.array<4xf32>) -> i32 { +func.func @composite_extract_result_type_mismatch(%arg0: !spirv.array<4xf32>) -> i32 { // expected-error @+1 {{invalid result type: expected 'f32' but provided 'i32'}} - %0 = "spv.CompositeExtract"(%arg0) {indices = [2: i32]} : (!spv.array<4xf32>) -> (i32) + %0 = "spirv.CompositeExtract"(%arg0) {indices = [2: i32]} : (!spirv.array<4xf32>) -> (i32) return %0: i32 } // ----- //===----------------------------------------------------------------------===// -// spv.CompositeInsert +// spirv.CompositeInsert //===----------------------------------------------------------------------===// -func.func @composite_insert_array(%arg0: !spv.array<4xf32>, %arg1: f32) -> !spv.array<4xf32> { - // CHECK: {{%.*}} = spv.CompositeInsert {{%.*}}, {{%.*}}[1 : i32] : f32 into !spv.array<4 x f32> - %0 = spv.CompositeInsert %arg1, %arg0[1 : i32] : f32 into !spv.array<4xf32> - return %0: !spv.array<4xf32> +func.func @composite_insert_array(%arg0: !spirv.array<4xf32>, %arg1: f32) -> !spirv.array<4xf32> { + // CHECK: {{%.*}} = spirv.CompositeInsert {{%.*}}, {{%.*}}[1 : i32] : f32 into !spirv.array<4 x f32> + %0 = spirv.CompositeInsert %arg1, %arg0[1 : i32] : f32 into !spirv.array<4xf32> + return %0: !spirv.array<4xf32> } // ----- -func.func @composite_insert_struct(%arg0: !spv.struct<(!spv.array<4xf32>, f32)>, %arg1: !spv.array<4xf32>) -> !spv.struct<(!spv.array<4xf32>, f32)> { - // CHECK: {{%.*}} = spv.CompositeInsert {{%.*}}, {{%.*}}[0 : i32] : !spv.array<4 x f32> into !spv.struct<(!spv.array<4 x f32>, f32)> - %0 = spv.CompositeInsert %arg1, %arg0[0 : i32] : !spv.array<4xf32> into !spv.struct<(!spv.array<4xf32>, f32)> - return %0: !spv.struct<(!spv.array<4xf32>, f32)> +func.func @composite_insert_struct(%arg0: !spirv.struct<(!spirv.array<4xf32>, f32)>, %arg1: !spirv.array<4xf32>) -> !spirv.struct<(!spirv.array<4xf32>, f32)> { + // CHECK: {{%.*}} = spirv.CompositeInsert {{%.*}}, {{%.*}}[0 : i32] : !spirv.array<4 x f32> into !spirv.struct<(!spirv.array<4 x f32>, f32)> + %0 = spirv.CompositeInsert %arg1, %arg0[0 : i32] : !spirv.array<4xf32> into !spirv.struct<(!spirv.array<4xf32>, f32)> + return %0: !spirv.struct<(!spirv.array<4xf32>, f32)> } // ----- -func.func @composite_insert_coopmatrix(%arg0: !spv.coopmatrix<8x16xi32, Subgroup>, %arg1: i32) -> !spv.coopmatrix<8x16xi32, Subgroup> { - // CHECK: {{%.*}} = spv.CompositeInsert {{%.*}}, {{%.*}}[5 : i32] : i32 into !spv.coopmatrix<8x16xi32, Subgroup> - %0 = spv.CompositeInsert %arg1, %arg0[5 : i32] : i32 into !spv.coopmatrix<8x16xi32, Subgroup> - return %0: !spv.coopmatrix<8x16xi32, Subgroup> +func.func @composite_insert_coopmatrix(%arg0: !spirv.coopmatrix<8x16xi32, Subgroup>, %arg1: i32) -> !spirv.coopmatrix<8x16xi32, Subgroup> { + // CHECK: {{%.*}} = spirv.CompositeInsert {{%.*}}, {{%.*}}[5 : i32] : i32 into !spirv.coopmatrix<8x16xi32, Subgroup> + %0 = spirv.CompositeInsert %arg1, %arg0[5 : i32] : i32 into !spirv.coopmatrix<8x16xi32, Subgroup> + return %0: !spirv.coopmatrix<8x16xi32, Subgroup> } // ----- -func.func @composite_insert_no_indices(%arg0: !spv.array<4xf32>, %arg1: f32) -> !spv.array<4xf32> { +func.func @composite_insert_no_indices(%arg0: !spirv.array<4xf32>, %arg1: f32) -> !spirv.array<4xf32> { // expected-error @+1 {{expected at least one index}} - %0 = spv.CompositeInsert %arg1, %arg0[] : f32 into !spv.array<4xf32> - return %0: !spv.array<4xf32> + %0 = spirv.CompositeInsert %arg1, %arg0[] : f32 into !spirv.array<4xf32> + return %0: !spirv.array<4xf32> } // ----- -func.func @composite_insert_out_of_bounds(%arg0: !spv.array<4xf32>, %arg1: f32) -> !spv.array<4xf32> { +func.func @composite_insert_out_of_bounds(%arg0: !spirv.array<4xf32>, %arg1: f32) -> !spirv.array<4xf32> { // expected-error @+1 {{index 4 out of bounds}} - %0 = spv.CompositeInsert %arg1, %arg0[4 : i32] : f32 into !spv.array<4xf32> - return %0: !spv.array<4xf32> + %0 = spirv.CompositeInsert %arg1, %arg0[4 : i32] : f32 into !spirv.array<4xf32> + return %0: !spirv.array<4xf32> } // ----- -func.func @composite_insert_invalid_object_type(%arg0: !spv.array<4xf32>, %arg1: f64) -> !spv.array<4xf32> { +func.func @composite_insert_invalid_object_type(%arg0: !spirv.array<4xf32>, %arg1: f64) -> !spirv.array<4xf32> { // expected-error @+1 {{object operand type should be 'f32', but found 'f64'}} - %0 = spv.CompositeInsert %arg1, %arg0[3 : i32] : f64 into !spv.array<4xf32> - return %0: !spv.array<4xf32> + %0 = spirv.CompositeInsert %arg1, %arg0[3 : i32] : f64 into !spirv.array<4xf32> + return %0: !spirv.array<4xf32> } // ----- -func.func @composite_insert_invalid_result_type(%arg0: !spv.array<4xf32>, %arg1 : f32) -> !spv.array<4xf64> { - // expected-error @+1 {{result type should be the same as the composite type, but found '!spv.array<4 x f32>' vs '!spv.array<4 x f64>'}} - %0 = "spv.CompositeInsert"(%arg1, %arg0) {indices = [0: i32]} : (f32, !spv.array<4xf32>) -> !spv.array<4xf64> - return %0: !spv.array<4xf64> +func.func @composite_insert_invalid_result_type(%arg0: !spirv.array<4xf32>, %arg1 : f32) -> !spirv.array<4xf64> { + // expected-error @+1 {{result type should be the same as the composite type, but found '!spirv.array<4 x f32>' vs '!spirv.array<4 x f64>'}} + %0 = "spirv.CompositeInsert"(%arg1, %arg0) {indices = [0: i32]} : (f32, !spirv.array<4xf32>) -> !spirv.array<4xf64> + return %0: !spirv.array<4xf64> } // ----- //===----------------------------------------------------------------------===// -// spv.VectorExtractDynamic +// spirv.VectorExtractDynamic //===----------------------------------------------------------------------===// func.func @vector_dynamic_extract(%vec: vector<4xf32>, %id : i32) -> f32 { - // CHECK: spv.VectorExtractDynamic %{{.*}}[%{{.*}}] : vector<4xf32>, i32 - %0 = spv.VectorExtractDynamic %vec[%id] : vector<4xf32>, i32 + // CHECK: spirv.VectorExtractDynamic %{{.*}}[%{{.*}}] : vector<4xf32>, i32 + %0 = spirv.VectorExtractDynamic %vec[%id] : vector<4xf32>, i32 return %0 : f32 } //===----------------------------------------------------------------------===// -// spv.VectorInsertDynamic +// spirv.VectorInsertDynamic //===----------------------------------------------------------------------===// func.func @vector_dynamic_insert(%val: f32, %vec: vector<4xf32>, %id : i32) -> vector<4xf32> { - // CHECK: spv.VectorInsertDynamic %{{.*}}, %{{.*}}[%{{.*}}] : vector<4xf32>, i32 - %0 = spv.VectorInsertDynamic %val, %vec[%id] : vector<4xf32>, i32 + // CHECK: spirv.VectorInsertDynamic %{{.*}}, %{{.*}}[%{{.*}}] : vector<4xf32>, i32 + %0 = spirv.VectorInsertDynamic %val, %vec[%id] : vector<4xf32>, i32 return %0 : vector<4xf32> } // ----- //===----------------------------------------------------------------------===// -// spv.VectorShuffle +// spirv.VectorShuffle //===----------------------------------------------------------------------===// func.func @vector_shuffle(%vector1: vector<4xf32>, %vector2: vector<2xf32>) -> vector<3xf32> { - // CHECK: %{{.+}} = spv.VectorShuffle [1 : i32, 3 : i32, -1 : i32] %{{.+}} : vector<4xf32>, %arg1 : vector<2xf32> -> vector<3xf32> - %0 = spv.VectorShuffle [1: i32, 3: i32, 0xffffffff: i32] %vector1: vector<4xf32>, %vector2: vector<2xf32> -> vector<3xf32> + // CHECK: %{{.+}} = spirv.VectorShuffle [1 : i32, 3 : i32, -1 : i32] %{{.+}} : vector<4xf32>, %arg1 : vector<2xf32> -> vector<3xf32> + %0 = spirv.VectorShuffle [1: i32, 3: i32, 0xffffffff: i32] %vector1: vector<4xf32>, %vector2: vector<2xf32> -> vector<3xf32> return %0: vector<3xf32> } @@ -325,7 +325,7 @@ func.func @vector_shuffle_extra_selector(%vector1: vector<4xf32>, %vector2: vector<2xf32>) -> vector<3xf32> { // expected-error @+1 {{result type element count (3) mismatch with the number of component selectors (4)}} - %0 = spv.VectorShuffle [1: i32, 3: i32, 5: i32, 2: i32] %vector1: vector<4xf32>, %vector2: vector<2xf32> -> vector<3xf32> + %0 = spirv.VectorShuffle [1: i32, 3: i32, 5: i32, 2: i32] %vector1: vector<4xf32>, %vector2: vector<2xf32> -> vector<3xf32> return %0: vector<3xf32> } @@ -333,6 +333,6 @@ func.func @vector_shuffle_extra_selector(%vector1: vector<4xf32>, %vector2: vector<2xf32>) -> vector<3xf32> { // expected-error @+1 {{component selector 7 out of range: expected to be in [0, 6) or 0xffffffff}} - %0 = spv.VectorShuffle [1: i32, 7: i32, 5: i32] %vector1: vector<4xf32>, %vector2: vector<2xf32> -> vector<3xf32> + %0 = spirv.VectorShuffle [1: i32, 7: i32, 5: i32] %vector1: vector<4xf32>, %vector2: vector<2xf32> -> vector<3xf32> return %0: vector<3xf32> } diff --git a/mlir/test/Dialect/SPIRV/IR/control-flow-ops.mlir b/mlir/test/Dialect/SPIRV/IR/control-flow-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/control-flow-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/control-flow-ops.mlir @@ -1,306 +1,306 @@ // RUN: mlir-opt -allow-unregistered-dialect -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.Branch +// spirv.Branch //===----------------------------------------------------------------------===// func.func @branch() -> () { - // CHECK: spv.Branch ^bb1 - spv.Branch ^next + // CHECK: spirv.Branch ^bb1 + spirv.Branch ^next ^next: - spv.Return + spirv.Return } // ----- func.func @branch_argument() -> () { - %zero = spv.Constant 0 : i32 - // CHECK: spv.Branch ^bb1(%{{.*}}, %{{.*}} : i32, i32) - spv.Branch ^next(%zero, %zero: i32, i32) + %zero = spirv.Constant 0 : i32 + // CHECK: spirv.Branch ^bb1(%{{.*}}, %{{.*}} : i32, i32) + spirv.Branch ^next(%zero, %zero: i32, i32) ^next(%arg0: i32, %arg1: i32): - spv.Return + spirv.Return } // ----- func.func @missing_accessor() -> () { // expected-error @+1 {{expected block name}} - spv.Branch + spirv.Branch } // ----- func.func @wrong_accessor_count() -> () { - %true = spv.Constant true + %true = spirv.Constant true // expected-error @+1 {{requires 1 successor but found 2}} - "spv.Branch"()[^one, ^two] : () -> () + "spirv.Branch"()[^one, ^two] : () -> () ^one: - spv.Return + spirv.Return ^two: - spv.Return + spirv.Return } // ----- //===----------------------------------------------------------------------===// -// spv.BranchConditional +// spirv.BranchConditional //===----------------------------------------------------------------------===// func.func @cond_branch() -> () { - %true = spv.Constant true - // CHECK: spv.BranchConditional %{{.*}}, ^bb1, ^bb2 - spv.BranchConditional %true, ^one, ^two + %true = spirv.Constant true + // CHECK: spirv.BranchConditional %{{.*}}, ^bb1, ^bb2 + spirv.BranchConditional %true, ^one, ^two // CHECK: ^bb1 ^one: - spv.Return + spirv.Return // CHECK: ^bb2 ^two: - spv.Return + spirv.Return } // ----- func.func @cond_branch_argument() -> () { - %true = spv.Constant true - %zero = spv.Constant 0 : i32 - // CHECK: spv.BranchConditional %{{.*}}, ^bb1(%{{.*}}, %{{.*}} : i32, i32), ^bb2 - spv.BranchConditional %true, ^true1(%zero, %zero: i32, i32), ^false1 + %true = spirv.Constant true + %zero = spirv.Constant 0 : i32 + // CHECK: spirv.BranchConditional %{{.*}}, ^bb1(%{{.*}}, %{{.*}} : i32, i32), ^bb2 + spirv.BranchConditional %true, ^true1(%zero, %zero: i32, i32), ^false1 ^true1(%arg0: i32, %arg1: i32): - // CHECK: spv.BranchConditional %{{.*}}, ^bb3, ^bb4(%{{.*}}, %{{.*}} : i32, i32) - spv.BranchConditional %true, ^true2, ^false2(%zero, %zero: i32, i32) + // CHECK: spirv.BranchConditional %{{.*}}, ^bb3, ^bb4(%{{.*}}, %{{.*}} : i32, i32) + spirv.BranchConditional %true, ^true2, ^false2(%zero, %zero: i32, i32) ^false1: - spv.Return + spirv.Return ^true2: - spv.Return + spirv.Return ^false2(%arg3: i32, %arg4: i32): - spv.Return + spirv.Return } // ----- func.func @cond_branch_with_weights() -> () { - %true = spv.Constant true - // CHECK: spv.BranchConditional %{{.*}} [5, 10] - spv.BranchConditional %true [5, 10], ^one, ^two + %true = spirv.Constant true + // CHECK: spirv.BranchConditional %{{.*}} [5, 10] + spirv.BranchConditional %true [5, 10], ^one, ^two ^one: - spv.Return + spirv.Return ^two: - spv.Return + spirv.Return } // ----- func.func @missing_condition() -> () { // expected-error @+1 {{expected SSA operand}} - spv.BranchConditional ^one, ^two + spirv.BranchConditional ^one, ^two ^one: - spv.Return + spirv.Return ^two: - spv.Return + spirv.Return } // ----- func.func @wrong_condition_type() -> () { // expected-note @+1 {{prior use here}} - %zero = spv.Constant 0 : i32 + %zero = spirv.Constant 0 : i32 // expected-error @+1 {{use of value '%zero' expects different type than prior uses: 'i1' vs 'i32'}} - spv.BranchConditional %zero, ^one, ^two + spirv.BranchConditional %zero, ^one, ^two ^one: - spv.Return + spirv.Return ^two: - spv.Return + spirv.Return } // ----- func.func @wrong_accessor_count() -> () { - %true = spv.Constant true + %true = spirv.Constant true // expected-error @+1 {{requires 2 successors but found 1}} - "spv.BranchConditional"(%true)[^one] {operand_segment_sizes = array} : (i1) -> () + "spirv.BranchConditional"(%true)[^one] {operand_segment_sizes = array} : (i1) -> () ^one: - spv.Return + spirv.Return ^two: - spv.Return + spirv.Return } // ----- func.func @wrong_number_of_weights() -> () { - %true = spv.Constant true + %true = spirv.Constant true // expected-error @+1 {{must have exactly two branch weights}} - "spv.BranchConditional"(%true)[^one, ^two] {branch_weights = [1 : i32, 2 : i32, 3 : i32], + "spirv.BranchConditional"(%true)[^one, ^two] {branch_weights = [1 : i32, 2 : i32, 3 : i32], operand_segment_sizes = array} : (i1) -> () ^one: - spv.Return + spirv.Return ^two: - spv.Return + spirv.Return } // ----- func.func @weights_cannot_both_be_zero() -> () { - %true = spv.Constant true + %true = spirv.Constant true // expected-error @+1 {{branch weights cannot both be zero}} - spv.BranchConditional %true [0, 0], ^one, ^two + spirv.BranchConditional %true [0, 0], ^one, ^two ^one: - spv.Return + spirv.Return ^two: - spv.Return + spirv.Return } // ----- //===----------------------------------------------------------------------===// -// spv.FunctionCall +// spirv.FunctionCall //===----------------------------------------------------------------------===// -spv.module Logical GLSL450 { - spv.func @fmain(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>, %arg2 : i32) -> i32 "None" { - // CHECK: {{%.*}} = spv.FunctionCall @f_0({{%.*}}, {{%.*}}) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - %0 = spv.FunctionCall @f_0(%arg0, %arg1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> - // CHECK: spv.FunctionCall @f_1({{%.*}}, {{%.*}}) : (vector<4xf32>, vector<4xf32>) -> () - spv.FunctionCall @f_1(%0, %arg1) : (vector<4xf32>, vector<4xf32>) -> () - // CHECK: spv.FunctionCall @f_2() : () -> () - spv.FunctionCall @f_2() : () -> () - // CHECK: {{%.*}} = spv.FunctionCall @f_3({{%.*}}) : (i32) -> i32 - %1 = spv.FunctionCall @f_3(%arg2) : (i32) -> i32 - spv.ReturnValue %1 : i32 +spirv.module Logical GLSL450 { + spirv.func @fmain(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>, %arg2 : i32) -> i32 "None" { + // CHECK: {{%.*}} = spirv.FunctionCall @f_0({{%.*}}, {{%.*}}) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> + %0 = spirv.FunctionCall @f_0(%arg0, %arg1) : (vector<4xf32>, vector<4xf32>) -> vector<4xf32> + // CHECK: spirv.FunctionCall @f_1({{%.*}}, {{%.*}}) : (vector<4xf32>, vector<4xf32>) -> () + spirv.FunctionCall @f_1(%0, %arg1) : (vector<4xf32>, vector<4xf32>) -> () + // CHECK: spirv.FunctionCall @f_2() : () -> () + spirv.FunctionCall @f_2() : () -> () + // CHECK: {{%.*}} = spirv.FunctionCall @f_3({{%.*}}) : (i32) -> i32 + %1 = spirv.FunctionCall @f_3(%arg2) : (i32) -> i32 + spirv.ReturnValue %1 : i32 } - spv.func @f_0(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) -> (vector<4xf32>) "None" { - spv.ReturnValue %arg0 : vector<4xf32> + spirv.func @f_0(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) -> (vector<4xf32>) "None" { + spirv.ReturnValue %arg0 : vector<4xf32> } - spv.func @f_1(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) -> () "None" { - spv.Return + spirv.func @f_1(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) -> () "None" { + spirv.Return } - spv.func @f_2() -> () "None" { - spv.Return + spirv.func @f_2() -> () "None" { + spirv.Return } - spv.func @f_3(%arg0 : i32) -> (i32) "None" { - spv.ReturnValue %arg0 : i32 + spirv.func @f_3(%arg0 : i32) -> (i32) "None" { + spirv.ReturnValue %arg0 : i32 } } // ----- // Allow calling functions in other module-like ops -spv.func @callee() "None" { - spv.Return +spirv.func @callee() "None" { + spirv.Return } func.func @caller() { - // CHECK: spv.FunctionCall - spv.FunctionCall @callee() : () -> () - spv.Return + // CHECK: spirv.FunctionCall + spirv.FunctionCall @callee() : () -> () + spirv.Return } // ----- -spv.module Logical GLSL450 { - spv.func @f_invalid_result_type(%arg0 : i32, %arg1 : i32) -> () "None" { +spirv.module Logical GLSL450 { + spirv.func @f_invalid_result_type(%arg0 : i32, %arg1 : i32) -> () "None" { // expected-error @+1 {{result group starting at #0 requires 0 or 1 element, but found 2}} - %0:2 = spv.FunctionCall @f_invalid_result_type(%arg0, %arg1) : (i32, i32) -> (i32, i32) - spv.Return + %0:2 = spirv.FunctionCall @f_invalid_result_type(%arg0, %arg1) : (i32, i32) -> (i32, i32) + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.func @f_result_type_mismatch(%arg0 : i32, %arg1 : i32) -> () "None" { +spirv.module Logical GLSL450 { + spirv.func @f_result_type_mismatch(%arg0 : i32, %arg1 : i32) -> () "None" { // expected-error @+1 {{has incorrect number of results has for callee: expected 0, but provided 1}} - %1 = spv.FunctionCall @f_result_type_mismatch(%arg0, %arg0) : (i32, i32) -> (i32) - spv.Return + %1 = spirv.FunctionCall @f_result_type_mismatch(%arg0, %arg0) : (i32, i32) -> (i32) + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.func @f_type_mismatch(%arg0 : i32, %arg1 : i32) -> () "None" { +spirv.module Logical GLSL450 { + spirv.func @f_type_mismatch(%arg0 : i32, %arg1 : i32) -> () "None" { // expected-error @+1 {{has incorrect number of operands for callee: expected 2, but provided 1}} - spv.FunctionCall @f_type_mismatch(%arg0) : (i32) -> () - spv.Return + spirv.FunctionCall @f_type_mismatch(%arg0) : (i32) -> () + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.func @f_type_mismatch(%arg0 : i32, %arg1 : i32) -> () "None" { - %0 = spv.Constant 2.0 : f32 +spirv.module Logical GLSL450 { + spirv.func @f_type_mismatch(%arg0 : i32, %arg1 : i32) -> () "None" { + %0 = spirv.Constant 2.0 : f32 // expected-error @+1 {{operand type mismatch: expected operand type 'i32', but provided 'f32' for operand number 1}} - spv.FunctionCall @f_type_mismatch(%arg0, %0) : (i32, f32) -> () - spv.Return + spirv.FunctionCall @f_type_mismatch(%arg0, %0) : (i32, f32) -> () + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.func @f_type_mismatch(%arg0 : i32, %arg1 : i32) -> i32 "None" { - %cst = spv.Constant 0: i32 +spirv.module Logical GLSL450 { + spirv.func @f_type_mismatch(%arg0 : i32, %arg1 : i32) -> i32 "None" { + %cst = spirv.Constant 0: i32 // expected-error @+1 {{result type mismatch: expected 'i32', but provided 'f32'}} - %0 = spv.FunctionCall @f_type_mismatch(%arg0, %arg0) : (i32, i32) -> f32 - spv.ReturnValue %cst: i32 + %0 = spirv.FunctionCall @f_type_mismatch(%arg0, %arg0) : (i32, i32) -> f32 + spirv.ReturnValue %cst: i32 } } // ----- -spv.module Logical GLSL450 { - spv.func @f_foo(%arg0 : i32, %arg1 : i32) -> i32 "None" { +spirv.module Logical GLSL450 { + spirv.func @f_foo(%arg0 : i32, %arg1 : i32) -> i32 "None" { // expected-error @+1 {{op callee function 'f_undefined' not found in nearest symbol table}} - %0 = spv.FunctionCall @f_undefined(%arg0, %arg0) : (i32, i32) -> i32 - spv.ReturnValue %0: i32 + %0 = spirv.FunctionCall @f_undefined(%arg0, %arg0) : (i32, i32) -> i32 + spirv.ReturnValue %0: i32 } } // ----- //===----------------------------------------------------------------------===// -// spv.mlir.loop +// spirv.mlir.loop //===----------------------------------------------------------------------===// // for (int i = 0; i < count; ++i) {} func.func @loop(%count : i32) -> () { - %zero = spv.Constant 0: i32 - %one = spv.Constant 1: i32 - %var = spv.Variable init(%zero) : !spv.ptr + %zero = spirv.Constant 0: i32 + %one = spirv.Constant 1: i32 + %var = spirv.Variable init(%zero) : !spirv.ptr - // CHECK: spv.mlir.loop { - spv.mlir.loop { - // CHECK-NEXT: spv.Branch ^bb1 - spv.Branch ^header + // CHECK: spirv.mlir.loop { + spirv.mlir.loop { + // CHECK-NEXT: spirv.Branch ^bb1 + spirv.Branch ^header // CHECK-NEXT: ^bb1: ^header: - %val0 = spv.Load "Function" %var : i32 - %cmp = spv.SLessThan %val0, %count : i32 - // CHECK: spv.BranchConditional %{{.*}}, ^bb2, ^bb4 - spv.BranchConditional %cmp, ^body, ^merge + %val0 = spirv.Load "Function" %var : i32 + %cmp = spirv.SLessThan %val0, %count : i32 + // CHECK: spirv.BranchConditional %{{.*}}, ^bb2, ^bb4 + spirv.BranchConditional %cmp, ^body, ^merge // CHECK-NEXT: ^bb2: ^body: // Do nothing - // CHECK-NEXT: spv.Branch ^bb3 - spv.Branch ^continue + // CHECK-NEXT: spirv.Branch ^bb3 + spirv.Branch ^continue // CHECK-NEXT: ^bb3: ^continue: - %val1 = spv.Load "Function" %var : i32 - %add = spv.IAdd %val1, %one : i32 - spv.Store "Function" %var, %add : i32 - // CHECK: spv.Branch ^bb1 - spv.Branch ^header + %val1 = spirv.Load "Function" %var : i32 + %add = spirv.IAdd %val1, %one : i32 + spirv.Store "Function" %var, %add : i32 + // CHECK: spirv.Branch ^bb1 + spirv.Branch ^header // CHECK-NEXT: ^bb4: ^merge: - spv.mlir.merge + spirv.mlir.merge } return } @@ -309,8 +309,8 @@ // CHECK-LABEL: @empty_region func.func @empty_region() -> () { - // CHECK: spv.mlir.loop - spv.mlir.loop { + // CHECK: spirv.mlir.loop + spirv.mlir.loop { } return } @@ -319,8 +319,8 @@ // CHECK-LABEL: @loop_with_control func.func @loop_with_control() -> () { - // CHECK: spv.mlir.loop control(Unroll) - spv.mlir.loop control(Unroll) { + // CHECK: spirv.mlir.loop control(Unroll) + spirv.mlir.loop control(Unroll) { } return } @@ -328,9 +328,9 @@ // ----- func.func @wrong_merge_block() -> () { - // expected-error @+1 {{last block must be the merge block with only one 'spv.mlir.merge' op}} - spv.mlir.loop { - spv.Return + // expected-error @+1 {{last block must be the merge block with only one 'spirv.mlir.merge' op}} + spirv.mlir.loop { + spirv.Return } return } @@ -339,8 +339,8 @@ func.func @missing_entry_block() -> () { // expected-error @+1 {{must have an entry block branching to the loop header block}} - spv.mlir.loop { - spv.mlir.merge + spirv.mlir.loop { + spirv.mlir.merge } return } @@ -349,11 +349,11 @@ func.func @missing_header_block() -> () { // expected-error @+1 {{must have a loop header block branched from the entry block}} - spv.mlir.loop { + spirv.mlir.loop { ^entry: - spv.Branch ^merge + spirv.Branch ^merge ^merge: - spv.mlir.merge + spirv.mlir.merge } return } @@ -361,14 +361,14 @@ // ----- func.func @entry_should_branch_to_header() -> () { - // expected-error @+1 {{entry block must only have one 'spv.Branch' op to the second block}} - spv.mlir.loop { + // expected-error @+1 {{entry block must only have one 'spirv.Branch' op to the second block}} + spirv.mlir.loop { ^entry: - spv.Branch ^merge + spirv.Branch ^merge ^header: - spv.Branch ^merge + spirv.Branch ^merge ^merge: - spv.mlir.merge + spirv.mlir.merge } return } @@ -377,13 +377,13 @@ func.func @missing_continue_block() -> () { // expected-error @+1 {{requires a loop continue block branching to the loop header block}} - spv.mlir.loop { + spirv.mlir.loop { ^entry: - spv.Branch ^header + spirv.Branch ^header ^header: - spv.Branch ^merge + spirv.Branch ^merge ^merge: - spv.mlir.merge + spirv.mlir.merge } return } @@ -392,15 +392,15 @@ func.func @continue_should_branch_to_header() -> () { // expected-error @+1 {{second to last block must be the loop continue block that branches to the loop header block}} - spv.mlir.loop { + spirv.mlir.loop { ^entry: - spv.Branch ^header + spirv.Branch ^header ^header: - spv.Branch ^continue + spirv.Branch ^continue ^continue: - spv.Branch ^merge + spirv.Branch ^merge ^merge: - spv.mlir.merge + spirv.mlir.merge } return } @@ -409,17 +409,17 @@ func.func @only_entry_and_continue_branch_to_header() -> () { // expected-error @+1 {{can only have the entry and loop continue block branching to the loop header block}} - spv.mlir.loop { + spirv.mlir.loop { ^entry: - spv.Branch ^header + spirv.Branch ^header ^header: - spv.Branch ^cont1 + spirv.Branch ^cont1 ^cont1: - spv.Branch ^header + spirv.Branch ^header ^cont2: - spv.Branch ^header + spirv.Branch ^header ^merge: - spv.mlir.merge + spirv.mlir.merge } return } @@ -427,51 +427,51 @@ // ----- //===----------------------------------------------------------------------===// -// spv.mlir.merge +// spirv.mlir.merge //===----------------------------------------------------------------------===// func.func @merge() -> () { - // expected-error @+1 {{expected parent op to be 'spv.mlir.selection' or 'spv.mlir.loop'}} - spv.mlir.merge + // expected-error @+1 {{expected parent op to be 'spirv.mlir.selection' or 'spirv.mlir.loop'}} + spirv.mlir.merge } // ----- func.func @only_allowed_in_last_block(%cond : i1) -> () { - %zero = spv.Constant 0: i32 - %one = spv.Constant 1: i32 - %var = spv.Variable init(%zero) : !spv.ptr + %zero = spirv.Constant 0: i32 + %one = spirv.Constant 1: i32 + %var = spirv.Variable init(%zero) : !spirv.ptr - spv.mlir.selection { - spv.BranchConditional %cond, ^then, ^merge + spirv.mlir.selection { + spirv.BranchConditional %cond, ^then, ^merge ^then: - spv.Store "Function" %var, %one : i32 - // expected-error @+1 {{can only be used in the last block of 'spv.mlir.selection' or 'spv.mlir.loop'}} - spv.mlir.merge + spirv.Store "Function" %var, %one : i32 + // expected-error @+1 {{can only be used in the last block of 'spirv.mlir.selection' or 'spirv.mlir.loop'}} + spirv.mlir.merge ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // ----- func.func @only_allowed_in_last_block() -> () { - %true = spv.Constant true - spv.mlir.loop { - spv.Branch ^header + %true = spirv.Constant true + spirv.mlir.loop { + spirv.Branch ^header ^header: - spv.BranchConditional %true, ^body, ^merge + spirv.BranchConditional %true, ^body, ^merge ^body: - // expected-error @+1 {{can only be used in the last block of 'spv.mlir.selection' or 'spv.mlir.loop'}} - spv.mlir.merge + // expected-error @+1 {{can only be used in the last block of 'spirv.mlir.selection' or 'spirv.mlir.loop'}} + spirv.mlir.merge ^continue: - spv.Branch ^header + spirv.Branch ^header ^merge: - spv.mlir.merge + spirv.mlir.merge } return } @@ -479,249 +479,249 @@ // ----- //===----------------------------------------------------------------------===// -// spv.Return +// spirv.Return //===----------------------------------------------------------------------===// // CHECK-LABEL: func @in_selection func.func @in_selection(%cond : i1) -> () { - spv.mlir.selection { - spv.BranchConditional %cond, ^then, ^merge + spirv.mlir.selection { + spirv.BranchConditional %cond, ^then, ^merge ^then: - // CHECK: spv.Return - spv.Return + // CHECK: spirv.Return + spirv.Return ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // CHECK-LABEL: func @in_loop func.func @in_loop(%cond : i1) -> () { - spv.mlir.loop { - spv.Branch ^header + spirv.mlir.loop { + spirv.Branch ^header ^header: - spv.BranchConditional %cond, ^body, ^merge + spirv.BranchConditional %cond, ^body, ^merge ^body: - // CHECK: spv.Return - spv.Return + // CHECK: spirv.Return + spirv.Return ^continue: - spv.Branch ^header + spirv.Branch ^header ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // CHECK-LABEL: in_other_func_like_op func.func @in_other_func_like_op() { - // CHECK: spv.Return - spv.Return + // CHECK: spirv.Return + spirv.Return } // ----- "foo.function"() ({ // expected-error @+1 {{op must appear in a function-like op's block}} - spv.Return + spirv.Return }) : () -> () // ----- // Return mismatches function signature -spv.module Logical GLSL450 { - spv.func @work() -> (i32) "None" { +spirv.module Logical GLSL450 { + spirv.func @work() -> (i32) "None" { // expected-error @+1 {{cannot be used in functions returning value}} - spv.Return + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.func @in_nested_region(%cond: i1) -> (i32) "None" { - spv.mlir.selection { - spv.BranchConditional %cond, ^then, ^merge +spirv.module Logical GLSL450 { + spirv.func @in_nested_region(%cond: i1) -> (i32) "None" { + spirv.mlir.selection { + spirv.BranchConditional %cond, ^then, ^merge ^then: // expected-error @+1 {{cannot be used in functions returning value}} - spv.Return + spirv.Return ^merge: - spv.mlir.merge + spirv.mlir.merge } - %zero = spv.Constant 0: i32 - spv.ReturnValue %zero: i32 + %zero = spirv.Constant 0: i32 + spirv.ReturnValue %zero: i32 } } // ----- //===----------------------------------------------------------------------===// -// spv.ReturnValue +// spirv.ReturnValue //===----------------------------------------------------------------------===// func.func @ret_val() -> (i32) { - %0 = spv.Constant 42 : i32 - // CHECK: spv.ReturnValue %{{.*}} : i32 - spv.ReturnValue %0 : i32 + %0 = spirv.Constant 42 : i32 + // CHECK: spirv.ReturnValue %{{.*}} : i32 + spirv.ReturnValue %0 : i32 } // CHECK-LABEL: func @in_selection func.func @in_selection(%cond : i1) -> (i32) { - spv.mlir.selection { - spv.BranchConditional %cond, ^then, ^merge + spirv.mlir.selection { + spirv.BranchConditional %cond, ^then, ^merge ^then: - %zero = spv.Constant 0 : i32 - // CHECK: spv.ReturnValue - spv.ReturnValue %zero : i32 + %zero = spirv.Constant 0 : i32 + // CHECK: spirv.ReturnValue + spirv.ReturnValue %zero : i32 ^merge: - spv.mlir.merge + spirv.mlir.merge } - %one = spv.Constant 1 : i32 - spv.ReturnValue %one : i32 + %one = spirv.Constant 1 : i32 + spirv.ReturnValue %one : i32 } // CHECK-LABEL: func @in_loop func.func @in_loop(%cond : i1) -> (i32) { - spv.mlir.loop { - spv.Branch ^header + spirv.mlir.loop { + spirv.Branch ^header ^header: - spv.BranchConditional %cond, ^body, ^merge + spirv.BranchConditional %cond, ^body, ^merge ^body: - %zero = spv.Constant 0 : i32 - // CHECK: spv.ReturnValue - spv.ReturnValue %zero : i32 + %zero = spirv.Constant 0 : i32 + // CHECK: spirv.ReturnValue + spirv.ReturnValue %zero : i32 ^continue: - spv.Branch ^header + spirv.Branch ^header ^merge: - spv.mlir.merge + spirv.mlir.merge } - %one = spv.Constant 1 : i32 - spv.ReturnValue %one : i32 + %one = spirv.Constant 1 : i32 + spirv.ReturnValue %one : i32 } // CHECK-LABEL: in_other_func_like_op func.func @in_other_func_like_op(%arg: i32) -> i32 { - // CHECK: spv.ReturnValue - spv.ReturnValue %arg: i32 + // CHECK: spirv.ReturnValue + spirv.ReturnValue %arg: i32 } // ----- "foo.function"() ({ - %0 = spv.Constant true + %0 = spirv.Constant true // expected-error @+1 {{op must appear in a function-like op's block}} - spv.ReturnValue %0 : i1 + spirv.ReturnValue %0 : i1 }) : () -> () // ----- -spv.module Logical GLSL450 { - spv.func @value_count_mismatch() -> () "None" { - %0 = spv.Constant 42 : i32 +spirv.module Logical GLSL450 { + spirv.func @value_count_mismatch() -> () "None" { + %0 = spirv.Constant 42 : i32 // expected-error @+1 {{op returns 1 value but enclosing function requires 0 results}} - spv.ReturnValue %0 : i32 + spirv.ReturnValue %0 : i32 } } // ----- -spv.module Logical GLSL450 { - spv.func @value_type_mismatch() -> (f32) "None" { - %0 = spv.Constant 42 : i32 +spirv.module Logical GLSL450 { + spirv.func @value_type_mismatch() -> (f32) "None" { + %0 = spirv.Constant 42 : i32 // expected-error @+1 {{return value's type ('i32') mismatch with function's result type ('f32')}} - spv.ReturnValue %0 : i32 + spirv.ReturnValue %0 : i32 } } // ----- -spv.module Logical GLSL450 { - spv.func @in_nested_region(%cond: i1) -> () "None" { - spv.mlir.selection { - spv.BranchConditional %cond, ^then, ^merge +spirv.module Logical GLSL450 { + spirv.func @in_nested_region(%cond: i1) -> () "None" { + spirv.mlir.selection { + spirv.BranchConditional %cond, ^then, ^merge ^then: - %cst = spv.Constant 0: i32 + %cst = spirv.Constant 0: i32 // expected-error @+1 {{op returns 1 value but enclosing function requires 0 results}} - spv.ReturnValue %cst: i32 + spirv.ReturnValue %cst: i32 ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } } // ----- //===----------------------------------------------------------------------===// -// spv.mlir.selection +// spirv.mlir.selection //===----------------------------------------------------------------------===// func.func @selection(%cond: i1) -> () { - %zero = spv.Constant 0: i32 - %one = spv.Constant 1: i32 - %var = spv.Variable init(%zero) : !spv.ptr + %zero = spirv.Constant 0: i32 + %one = spirv.Constant 1: i32 + %var = spirv.Variable init(%zero) : !spirv.ptr - // CHECK: spv.mlir.selection { - spv.mlir.selection { - // CHECK-NEXT: spv.BranchConditional %{{.*}}, ^bb1, ^bb2 - spv.BranchConditional %cond, ^then, ^merge + // CHECK: spirv.mlir.selection { + spirv.mlir.selection { + // CHECK-NEXT: spirv.BranchConditional %{{.*}}, ^bb1, ^bb2 + spirv.BranchConditional %cond, ^then, ^merge // CHECK: ^bb1 ^then: - spv.Store "Function" %var, %one : i32 - // CHECK: spv.Branch ^bb2 - spv.Branch ^merge + spirv.Store "Function" %var, %one : i32 + // CHECK: spirv.Branch ^bb2 + spirv.Branch ^merge // CHECK: ^bb2 ^merge: - // CHECK-NEXT: spv.mlir.merge - spv.mlir.merge + // CHECK-NEXT: spirv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // ----- func.func @selection(%cond: i1) -> () { - %zero = spv.Constant 0: i32 - %one = spv.Constant 1: i32 - %two = spv.Constant 2: i32 - %var = spv.Variable init(%zero) : !spv.ptr + %zero = spirv.Constant 0: i32 + %one = spirv.Constant 1: i32 + %two = spirv.Constant 2: i32 + %var = spirv.Variable init(%zero) : !spirv.ptr - // CHECK: spv.mlir.selection { - spv.mlir.selection { - // CHECK-NEXT: spv.BranchConditional %{{.*}}, ^bb1, ^bb2 - spv.BranchConditional %cond, ^then, ^else + // CHECK: spirv.mlir.selection { + spirv.mlir.selection { + // CHECK-NEXT: spirv.BranchConditional %{{.*}}, ^bb1, ^bb2 + spirv.BranchConditional %cond, ^then, ^else // CHECK: ^bb1 ^then: - spv.Store "Function" %var, %one : i32 - // CHECK: spv.Branch ^bb3 - spv.Branch ^merge + spirv.Store "Function" %var, %one : i32 + // CHECK: spirv.Branch ^bb3 + spirv.Branch ^merge // CHECK: ^bb2 ^else: - spv.Store "Function" %var, %two : i32 - // CHECK: spv.Branch ^bb3 - spv.Branch ^merge + spirv.Store "Function" %var, %two : i32 + // CHECK: spirv.Branch ^bb3 + spirv.Branch ^merge // CHECK: ^bb3 ^merge: - // CHECK-NEXT: spv.mlir.merge - spv.mlir.merge + // CHECK-NEXT: spirv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // ----- // CHECK-LABEL: @empty_region func.func @empty_region() -> () { - // CHECK: spv.mlir.selection - spv.mlir.selection { + // CHECK: spirv.mlir.selection + spirv.mlir.selection { } return } @@ -730,8 +730,8 @@ // CHECK-LABEL: @selection_with_control func.func @selection_with_control() -> () { - // CHECK: spv.mlir.selection control(Flatten) - spv.mlir.selection control(Flatten) { + // CHECK: spirv.mlir.selection control(Flatten) + spirv.mlir.selection control(Flatten) { } return } @@ -739,9 +739,9 @@ // ----- func.func @wrong_merge_block() -> () { - // expected-error @+1 {{last block must be the merge block with only one 'spv.mlir.merge' op}} - spv.mlir.selection { - spv.Return + // expected-error @+1 {{last block must be the merge block with only one 'spirv.mlir.merge' op}} + spirv.mlir.selection { + spirv.Return } return } @@ -750,8 +750,8 @@ func.func @missing_entry_block() -> () { // expected-error @+1 {{must have a selection header block}} - spv.mlir.selection { - spv.mlir.merge + spirv.mlir.selection { + spirv.mlir.merge } return } @@ -759,33 +759,33 @@ // ----- //===----------------------------------------------------------------------===// -// spv.Unreachable +// spirv.Unreachable //===----------------------------------------------------------------------===// // CHECK-LABEL: func @unreachable_no_pred func.func @unreachable_no_pred() { - spv.Return + spirv.Return ^next: - // CHECK: spv.Unreachable - spv.Unreachable + // CHECK: spirv.Unreachable + spirv.Unreachable } // CHECK-LABEL: func @unreachable_with_pred func.func @unreachable_with_pred() { - spv.Return + spirv.Return ^parent: - spv.Branch ^unreachable + spirv.Branch ^unreachable ^unreachable: - // CHECK: spv.Unreachable - spv.Unreachable + // CHECK: spirv.Unreachable + spirv.Unreachable } // ----- func.func @unreachable() { // expected-error @+1 {{cannot be used in reachable block}} - spv.Unreachable + spirv.Unreachable } diff --git a/mlir/test/Dialect/SPIRV/IR/cooperative-matrix-ops.mlir b/mlir/test/Dialect/SPIRV/IR/cooperative-matrix-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/cooperative-matrix-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/cooperative-matrix-ops.mlir @@ -1,158 +1,158 @@ // RUN: mlir-opt -allow-unregistered-dialect -split-input-file -verify-diagnostics %s | FileCheck %s // CHECK-LABEL: @cooperative_matrix_load -spv.func @cooperative_matrix_load(%ptr : !spv.ptr, %stride : i32, %b : i1) "None" { - // CHECK: {{%.*}} = spv.NV.CooperativeMatrixLoad {{%.*}}, {{%.*}}, {{%.*}} : !spv.ptr as !spv.coopmatrix<16x8xi32, Workgroup> - %0 = spv.NV.CooperativeMatrixLoad %ptr, %stride, %b : !spv.ptr as !spv.coopmatrix<16x8xi32, Workgroup> - spv.Return +spirv.func @cooperative_matrix_load(%ptr : !spirv.ptr, %stride : i32, %b : i1) "None" { + // CHECK: {{%.*}} = spirv.NV.CooperativeMatrixLoad {{%.*}}, {{%.*}}, {{%.*}} : !spirv.ptr as !spirv.coopmatrix<16x8xi32, Workgroup> + %0 = spirv.NV.CooperativeMatrixLoad %ptr, %stride, %b : !spirv.ptr as !spirv.coopmatrix<16x8xi32, Workgroup> + spirv.Return } // ----- // CHECK-LABEL: @cooperative_matrix_load_memaccess -spv.func @cooperative_matrix_load_memaccess(%ptr : !spv.ptr, %stride : i32, %b : i1) "None" { - // CHECK: {{%.*}} = spv.NV.CooperativeMatrixLoad {{%.*}}, {{%.*}}, {{%.*}} ["Volatile"] : !spv.ptr as !spv.coopmatrix<8x16xi32, Subgroup> - %0 = spv.NV.CooperativeMatrixLoad %ptr, %stride, %b ["Volatile"] : !spv.ptr as !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return +spirv.func @cooperative_matrix_load_memaccess(%ptr : !spirv.ptr, %stride : i32, %b : i1) "None" { + // CHECK: {{%.*}} = spirv.NV.CooperativeMatrixLoad {{%.*}}, {{%.*}}, {{%.*}} ["Volatile"] : !spirv.ptr as !spirv.coopmatrix<8x16xi32, Subgroup> + %0 = spirv.NV.CooperativeMatrixLoad %ptr, %stride, %b ["Volatile"] : !spirv.ptr as !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_load_diff_ptr_type -spv.func @cooperative_matrix_load_diff_ptr_type(%ptr : !spv.ptr, StorageBuffer>, %stride : i32, %b : i1) "None" { - // CHECK: {{%.*}} = spv.NV.CooperativeMatrixLoad {{%.*}}, {{%.*}}, {{%.*}} ["Volatile"] : !spv.ptr, StorageBuffer> as !spv.coopmatrix<8x16xi32, Subgroup> - %0 = spv.NV.CooperativeMatrixLoad %ptr, %stride, %b ["Volatile"] : !spv.ptr, StorageBuffer> as !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return +spirv.func @cooperative_matrix_load_diff_ptr_type(%ptr : !spirv.ptr, StorageBuffer>, %stride : i32, %b : i1) "None" { + // CHECK: {{%.*}} = spirv.NV.CooperativeMatrixLoad {{%.*}}, {{%.*}}, {{%.*}} ["Volatile"] : !spirv.ptr, StorageBuffer> as !spirv.coopmatrix<8x16xi32, Subgroup> + %0 = spirv.NV.CooperativeMatrixLoad %ptr, %stride, %b ["Volatile"] : !spirv.ptr, StorageBuffer> as !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_store -spv.func @cooperative_matrix_store(%ptr : !spv.ptr, %stride : i32, %m : !spv.coopmatrix<8x16xi32, Workgroup>, %b : i1) "None" { - // CHECK: spv.NV.CooperativeMatrixStore {{%.*}}, {{%.*}}, {{%.*}} : !spv.ptr, !spv.coopmatrix<8x16xi32, Workgroup> - spv.NV.CooperativeMatrixStore %ptr, %m, %stride, %b : !spv.ptr, !spv.coopmatrix<8x16xi32, Workgroup> - spv.Return +spirv.func @cooperative_matrix_store(%ptr : !spirv.ptr, %stride : i32, %m : !spirv.coopmatrix<8x16xi32, Workgroup>, %b : i1) "None" { + // CHECK: spirv.NV.CooperativeMatrixStore {{%.*}}, {{%.*}}, {{%.*}} : !spirv.ptr, !spirv.coopmatrix<8x16xi32, Workgroup> + spirv.NV.CooperativeMatrixStore %ptr, %m, %stride, %b : !spirv.ptr, !spirv.coopmatrix<8x16xi32, Workgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_store_memaccess -spv.func @cooperative_matrix_store_memaccess(%ptr : !spv.ptr, %m : !spv.coopmatrix<8x16xi32, Subgroup>, %stride : i32, %b : i1) "None" { - // CHECK: spv.NV.CooperativeMatrixStore {{%.*}}, {{%.*}}, {{%.*}} ["Volatile"] : !spv.ptr, !spv.coopmatrix<8x16xi32, Subgroup> - spv.NV.CooperativeMatrixStore %ptr, %m, %stride, %b ["Volatile"] : !spv.ptr, !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return +spirv.func @cooperative_matrix_store_memaccess(%ptr : !spirv.ptr, %m : !spirv.coopmatrix<8x16xi32, Subgroup>, %stride : i32, %b : i1) "None" { + // CHECK: spirv.NV.CooperativeMatrixStore {{%.*}}, {{%.*}}, {{%.*}} ["Volatile"] : !spirv.ptr, !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.NV.CooperativeMatrixStore %ptr, %m, %stride, %b ["Volatile"] : !spirv.ptr, !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_length -spv.func @cooperative_matrix_length() -> i32 "None" { - // CHECK: {{%.*}} = spv.NV.CooperativeMatrixLength : !spv.coopmatrix<8x16xi32, Subgroup> - %0 = spv.NV.CooperativeMatrixLength : !spv.coopmatrix<8x16xi32, Subgroup> - spv.ReturnValue %0 : i32 +spirv.func @cooperative_matrix_length() -> i32 "None" { + // CHECK: {{%.*}} = spirv.NV.CooperativeMatrixLength : !spirv.coopmatrix<8x16xi32, Subgroup> + %0 = spirv.NV.CooperativeMatrixLength : !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.ReturnValue %0 : i32 } // CHECK-LABEL: @cooperative_matrix_muladd -spv.func @cooperative_matrix_muladd(%a : !spv.coopmatrix<8x32xi8, Subgroup>, %b : !spv.coopmatrix<32x8xi8, Subgroup>, %c : !spv.coopmatrix<8x8xi32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.NV.CooperativeMatrixMulAdd {{%.*}}, {{%.*}}, {{%.*}} : !spv.coopmatrix<8x32xi8, Subgroup>, !spv.coopmatrix<32x8xi8, Subgroup> -> !spv.coopmatrix<8x8xi32, Subgroup> - %r = spv.NV.CooperativeMatrixMulAdd %a, %b, %c : !spv.coopmatrix<8x32xi8, Subgroup>, !spv.coopmatrix<32x8xi8, Subgroup> -> !spv.coopmatrix<8x8xi32, Subgroup> - spv.Return +spirv.func @cooperative_matrix_muladd(%a : !spirv.coopmatrix<8x32xi8, Subgroup>, %b : !spirv.coopmatrix<32x8xi8, Subgroup>, %c : !spirv.coopmatrix<8x8xi32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.NV.CooperativeMatrixMulAdd {{%.*}}, {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x32xi8, Subgroup>, !spirv.coopmatrix<32x8xi8, Subgroup> -> !spirv.coopmatrix<8x8xi32, Subgroup> + %r = spirv.NV.CooperativeMatrixMulAdd %a, %b, %c : !spirv.coopmatrix<8x32xi8, Subgroup>, !spirv.coopmatrix<32x8xi8, Subgroup> -> !spirv.coopmatrix<8x8xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_add -spv.func @cooperative_matrix_add(%a : !spv.coopmatrix<8x16xi32, Subgroup>, %b : !spv.coopmatrix<8x16xi32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.IAdd {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xi32, Subgroup> - %r = spv.IAdd %a, %b : !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return +spirv.func @cooperative_matrix_add(%a : !spirv.coopmatrix<8x16xi32, Subgroup>, %b : !spirv.coopmatrix<8x16xi32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.IAdd {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xi32, Subgroup> + %r = spirv.IAdd %a, %b : !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_sub -spv.func @cooperative_matrix_sub(%a : !spv.coopmatrix<8x16xi32, Subgroup>, %b : !spv.coopmatrix<8x16xi32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.ISub {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xi32, Subgroup> - %r = spv.ISub %a, %b : !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return +spirv.func @cooperative_matrix_sub(%a : !spirv.coopmatrix<8x16xi32, Subgroup>, %b : !spirv.coopmatrix<8x16xi32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.ISub {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xi32, Subgroup> + %r = spirv.ISub %a, %b : !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_sdiv -spv.func @cooperative_matrix_sdiv(%a : !spv.coopmatrix<8x16xi32, Subgroup>, %b : !spv.coopmatrix<8x16xi32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.SDiv {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xi32, Subgroup> - %r = spv.SDiv %a, %b : !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return +spirv.func @cooperative_matrix_sdiv(%a : !spirv.coopmatrix<8x16xi32, Subgroup>, %b : !spirv.coopmatrix<8x16xi32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.SDiv {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xi32, Subgroup> + %r = spirv.SDiv %a, %b : !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_udiv -spv.func @cooperative_matrix_udiv(%a : !spv.coopmatrix<8x16xi32, Subgroup>, %b : !spv.coopmatrix<8x16xi32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.UDiv {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xi32, Subgroup> - %r = spv.UDiv %a, %b : !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return +spirv.func @cooperative_matrix_udiv(%a : !spirv.coopmatrix<8x16xi32, Subgroup>, %b : !spirv.coopmatrix<8x16xi32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.UDiv {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xi32, Subgroup> + %r = spirv.UDiv %a, %b : !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_fadd -spv.func @cooperative_matrix_fadd(%a : !spv.coopmatrix<8x16xf32, Subgroup>, %b : !spv.coopmatrix<8x16xf32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.FAdd {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xf32, Subgroup> - %r = spv.FAdd %a, %b : !spv.coopmatrix<8x16xf32, Subgroup> - spv.Return +spirv.func @cooperative_matrix_fadd(%a : !spirv.coopmatrix<8x16xf32, Subgroup>, %b : !spirv.coopmatrix<8x16xf32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.FAdd {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xf32, Subgroup> + %r = spirv.FAdd %a, %b : !spirv.coopmatrix<8x16xf32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_fsub -spv.func @cooperative_matrix_fsub(%a : !spv.coopmatrix<8x16xf32, Subgroup>, %b : !spv.coopmatrix<8x16xf32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.FSub {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xf32, Subgroup> - %r = spv.FSub %a, %b : !spv.coopmatrix<8x16xf32, Subgroup> - spv.Return +spirv.func @cooperative_matrix_fsub(%a : !spirv.coopmatrix<8x16xf32, Subgroup>, %b : !spirv.coopmatrix<8x16xf32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.FSub {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xf32, Subgroup> + %r = spirv.FSub %a, %b : !spirv.coopmatrix<8x16xf32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_fdiv -spv.func @cooperative_matrix_fdiv(%a : !spv.coopmatrix<8x16xf32, Subgroup>, %b : !spv.coopmatrix<8x16xf32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.FDiv {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xf32, Subgroup> - %r = spv.FDiv %a, %b : !spv.coopmatrix<8x16xf32, Subgroup> - spv.Return +spirv.func @cooperative_matrix_fdiv(%a : !spirv.coopmatrix<8x16xf32, Subgroup>, %b : !spirv.coopmatrix<8x16xf32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.FDiv {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xf32, Subgroup> + %r = spirv.FDiv %a, %b : !spirv.coopmatrix<8x16xf32, Subgroup> + spirv.Return } // ----- // CHECK-LABEL: @cooperative_matrix_access_chain -spv.func @cooperative_matrix_access_chain(%a : !spv.ptr, Function>) -> !spv.ptr "None" { - %0 = spv.Constant 0: i32 - // CHECK: {{%.*}} = spv.AccessChain {{%.*}}[{{%.*}}] : !spv.ptr, Function>, i32 - %1 = spv.AccessChain %a[%0] : !spv.ptr, Function>, i32 - spv.ReturnValue %1 : !spv.ptr +spirv.func @cooperative_matrix_access_chain(%a : !spirv.ptr, Function>) -> !spirv.ptr "None" { + %0 = spirv.Constant 0: i32 + // CHECK: {{%.*}} = spirv.AccessChain {{%.*}}[{{%.*}}] : !spirv.ptr, Function>, i32 + %1 = spirv.AccessChain %a[%0] : !spirv.ptr, Function>, i32 + spirv.ReturnValue %1 : !spirv.ptr } // ----- -spv.func @cooperative_matrix_muladd(%a : !spv.coopmatrix<16x16xi32, Subgroup>, %b : !spv.coopmatrix<16x8xi32, Subgroup>, %c : !spv.coopmatrix<8x8xi32, Subgroup>) "None" { - // expected-error @+1 {{'spv.NV.CooperativeMatrixMulAdd' op matrix size must match}} - %r = spv.NV.CooperativeMatrixMulAdd %a, %b, %c : !spv.coopmatrix<16x16xi32, Subgroup>, !spv.coopmatrix<16x8xi32, Subgroup> -> !spv.coopmatrix<8x8xi32, Subgroup> - spv.Return +spirv.func @cooperative_matrix_muladd(%a : !spirv.coopmatrix<16x16xi32, Subgroup>, %b : !spirv.coopmatrix<16x8xi32, Subgroup>, %c : !spirv.coopmatrix<8x8xi32, Subgroup>) "None" { + // expected-error @+1 {{'spirv.NV.CooperativeMatrixMulAdd' op matrix size must match}} + %r = spirv.NV.CooperativeMatrixMulAdd %a, %b, %c : !spirv.coopmatrix<16x16xi32, Subgroup>, !spirv.coopmatrix<16x8xi32, Subgroup> -> !spirv.coopmatrix<8x8xi32, Subgroup> + spirv.Return } // ----- -spv.func @cooperative_matrix_muladd(%a : !spv.coopmatrix<8x16xi32, Subgroup>, %b : !spv.coopmatrix<8x8xi32, Subgroup>, %c : !spv.coopmatrix<8x8xi32, Subgroup>) "None" { - // expected-error @+1 {{'spv.NV.CooperativeMatrixMulAdd' op matrix size must match}} - %r = spv.NV.CooperativeMatrixMulAdd %a, %b, %c : !spv.coopmatrix<8x16xi32, Subgroup>, !spv.coopmatrix<8x8xi32, Subgroup> -> !spv.coopmatrix<8x8xi32, Subgroup> - spv.Return +spirv.func @cooperative_matrix_muladd(%a : !spirv.coopmatrix<8x16xi32, Subgroup>, %b : !spirv.coopmatrix<8x8xi32, Subgroup>, %c : !spirv.coopmatrix<8x8xi32, Subgroup>) "None" { + // expected-error @+1 {{'spirv.NV.CooperativeMatrixMulAdd' op matrix size must match}} + %r = spirv.NV.CooperativeMatrixMulAdd %a, %b, %c : !spirv.coopmatrix<8x16xi32, Subgroup>, !spirv.coopmatrix<8x8xi32, Subgroup> -> !spirv.coopmatrix<8x8xi32, Subgroup> + spirv.Return } // ----- -spv.func @cooperative_matrix_muladd(%a : !spv.coopmatrix<8x16xi32, Subgroup>, %b : !spv.coopmatrix<16x8xi32, Workgroup>, %c : !spv.coopmatrix<8x8xi32, Subgroup>) "None" { - // expected-error @+1 {{'spv.NV.CooperativeMatrixMulAdd' op matrix scope must match}} - %r = spv.NV.CooperativeMatrixMulAdd %a, %b, %c : !spv.coopmatrix<8x16xi32, Subgroup>, !spv.coopmatrix<16x8xi32, Workgroup> -> !spv.coopmatrix<8x8xi32, Subgroup> - spv.Return +spirv.func @cooperative_matrix_muladd(%a : !spirv.coopmatrix<8x16xi32, Subgroup>, %b : !spirv.coopmatrix<16x8xi32, Workgroup>, %c : !spirv.coopmatrix<8x8xi32, Subgroup>) "None" { + // expected-error @+1 {{'spirv.NV.CooperativeMatrixMulAdd' op matrix scope must match}} + %r = spirv.NV.CooperativeMatrixMulAdd %a, %b, %c : !spirv.coopmatrix<8x16xi32, Subgroup>, !spirv.coopmatrix<16x8xi32, Workgroup> -> !spirv.coopmatrix<8x8xi32, Subgroup> + spirv.Return } // ----- -spv.func @cooperative_matrix_muladd(%a : !spv.coopmatrix<8x16xf32, Subgroup>, %b : !spv.coopmatrix<16x8xi32, Subgroup>, %c : !spv.coopmatrix<8x8xi32, Subgroup>) "None" { +spirv.func @cooperative_matrix_muladd(%a : !spirv.coopmatrix<8x16xf32, Subgroup>, %b : !spirv.coopmatrix<16x8xi32, Subgroup>, %c : !spirv.coopmatrix<8x8xi32, Subgroup>) "None" { // expected-error @+1 {{matrix element type must match}} - %r = spv.NV.CooperativeMatrixMulAdd %a, %b, %c : !spv.coopmatrix<8x16xf32, Subgroup>, !spv.coopmatrix<16x8xi32, Subgroup> -> !spv.coopmatrix<8x8xi32, Subgroup> - spv.Return + %r = spirv.NV.CooperativeMatrixMulAdd %a, %b, %c : !spirv.coopmatrix<8x16xf32, Subgroup>, !spirv.coopmatrix<16x8xi32, Subgroup> -> !spirv.coopmatrix<8x8xi32, Subgroup> + spirv.Return } // ----- -spv.func @cooperative_matrix_load_memaccess(%ptr : !spv.ptr, StorageBuffer>, %stride : i32, %b : i1) "None" { +spirv.func @cooperative_matrix_load_memaccess(%ptr : !spirv.ptr, StorageBuffer>, %stride : i32, %b : i1) "None" { // expected-error @+1 {{Pointer must point to a scalar or vector type}} - %0 = spv.NV.CooperativeMatrixLoad %ptr, %stride, %b : !spv.ptr, StorageBuffer> as !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return + %0 = spirv.NV.CooperativeMatrixLoad %ptr, %stride, %b : !spirv.ptr, StorageBuffer> as !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // ----- -spv.func @cooperative_matrix_load_memaccess(%ptr : !spv.ptr, %stride : i32, %b : i1) "None" { +spirv.func @cooperative_matrix_load_memaccess(%ptr : !spirv.ptr, %stride : i32, %b : i1) "None" { // expected-error @+1 {{Pointer storage class must be Workgroup, StorageBuffer or PhysicalStorageBufferEXT}} - %0 = spv.NV.CooperativeMatrixLoad %ptr, %stride, %b : !spv.ptr as !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return + %0 = spirv.NV.CooperativeMatrixLoad %ptr, %stride, %b : !spirv.ptr as !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } diff --git a/mlir/test/Dialect/SPIRV/IR/gl-ops.mlir b/mlir/test/Dialect/SPIRV/IR/gl-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/gl-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/gl-ops.mlir @@ -1,18 +1,18 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.GL.Exp +// spirv.GL.Exp //===----------------------------------------------------------------------===// func.func @exp(%arg0 : f32) -> () { - // CHECK: spv.GL.Exp {{%.*}} : f32 - %2 = spv.GL.Exp %arg0 : f32 + // CHECK: spirv.GL.Exp {{%.*}} : f32 + %2 = spirv.GL.Exp %arg0 : f32 return } func.func @expvec(%arg0 : vector<3xf16>) -> () { - // CHECK: spv.GL.Exp {{%.*}} : vector<3xf16> - %2 = spv.GL.Exp %arg0 : vector<3xf16> + // CHECK: spirv.GL.Exp {{%.*}} : vector<3xf16> + %2 = spirv.GL.Exp %arg0 : vector<3xf16> return } @@ -20,7 +20,7 @@ func.func @exp(%arg0 : i32) -> () { // expected-error @+1 {{op operand #0 must be 16/32-bit float or vector of 16/32-bit float values}} - %2 = spv.GL.Exp %arg0 : i32 + %2 = spirv.GL.Exp %arg0 : i32 return } @@ -28,7 +28,7 @@ func.func @exp(%arg0 : vector<5xf32>) -> () { // expected-error @+1 {{op operand #0 must be 16/32-bit float or vector of 16/32-bit float values of length 2/3/4}} - %2 = spv.GL.Exp %arg0 : vector<5xf32> + %2 = spirv.GL.Exp %arg0 : vector<5xf32> return } @@ -36,7 +36,7 @@ func.func @exp(%arg0 : f32, %arg1 : f32) -> () { // expected-error @+1 {{expected ':'}} - %2 = spv.GL.Exp %arg0, %arg1 : i32 + %2 = spirv.GL.Exp %arg0, %arg1 : i32 return } @@ -44,366 +44,366 @@ func.func @exp(%arg0 : i32) -> () { // expected-error @+1 {{expected non-function type}} - %2 = spv.GL.Exp %arg0 : + %2 = spirv.GL.Exp %arg0 : return } // ----- //===----------------------------------------------------------------------===// -// spv.GL.{F|S|U}{Max|Min} +// spirv.GL.{F|S|U}{Max|Min} //===----------------------------------------------------------------------===// func.func @fmaxmin(%arg0 : f32, %arg1 : f32) { - // CHECK: spv.GL.FMax {{%.*}}, {{%.*}} : f32 - %1 = spv.GL.FMax %arg0, %arg1 : f32 - // CHECK: spv.GL.FMin {{%.*}}, {{%.*}} : f32 - %2 = spv.GL.FMin %arg0, %arg1 : f32 + // CHECK: spirv.GL.FMax {{%.*}}, {{%.*}} : f32 + %1 = spirv.GL.FMax %arg0, %arg1 : f32 + // CHECK: spirv.GL.FMin {{%.*}}, {{%.*}} : f32 + %2 = spirv.GL.FMin %arg0, %arg1 : f32 return } func.func @fmaxminvec(%arg0 : vector<3xf16>, %arg1 : vector<3xf16>) { - // CHECK: spv.GL.FMax {{%.*}}, {{%.*}} : vector<3xf16> - %1 = spv.GL.FMax %arg0, %arg1 : vector<3xf16> - // CHECK: spv.GL.FMin {{%.*}}, {{%.*}} : vector<3xf16> - %2 = spv.GL.FMin %arg0, %arg1 : vector<3xf16> + // CHECK: spirv.GL.FMax {{%.*}}, {{%.*}} : vector<3xf16> + %1 = spirv.GL.FMax %arg0, %arg1 : vector<3xf16> + // CHECK: spirv.GL.FMin {{%.*}}, {{%.*}} : vector<3xf16> + %2 = spirv.GL.FMin %arg0, %arg1 : vector<3xf16> return } func.func @fmaxminf64(%arg0 : f64, %arg1 : f64) { - // CHECK: spv.GL.FMax {{%.*}}, {{%.*}} : f64 - %1 = spv.GL.FMax %arg0, %arg1 : f64 - // CHECK: spv.GL.FMin {{%.*}}, {{%.*}} : f64 - %2 = spv.GL.FMin %arg0, %arg1 : f64 + // CHECK: spirv.GL.FMax {{%.*}}, {{%.*}} : f64 + %1 = spirv.GL.FMax %arg0, %arg1 : f64 + // CHECK: spirv.GL.FMin {{%.*}}, {{%.*}} : f64 + %2 = spirv.GL.FMin %arg0, %arg1 : f64 return } func.func @iminmax(%arg0: i32, %arg1: i32) { - // CHECK: spv.GL.SMax {{%.*}}, {{%.*}} : i32 - %1 = spv.GL.SMax %arg0, %arg1 : i32 - // CHECK: spv.GL.UMax {{%.*}}, {{%.*}} : i32 - %2 = spv.GL.UMax %arg0, %arg1 : i32 - // CHECK: spv.GL.SMin {{%.*}}, {{%.*}} : i32 - %3 = spv.GL.SMin %arg0, %arg1 : i32 - // CHECK: spv.GL.UMin {{%.*}}, {{%.*}} : i32 - %4 = spv.GL.UMin %arg0, %arg1 : i32 + // CHECK: spirv.GL.SMax {{%.*}}, {{%.*}} : i32 + %1 = spirv.GL.SMax %arg0, %arg1 : i32 + // CHECK: spirv.GL.UMax {{%.*}}, {{%.*}} : i32 + %2 = spirv.GL.UMax %arg0, %arg1 : i32 + // CHECK: spirv.GL.SMin {{%.*}}, {{%.*}} : i32 + %3 = spirv.GL.SMin %arg0, %arg1 : i32 + // CHECK: spirv.GL.UMin {{%.*}}, {{%.*}} : i32 + %4 = spirv.GL.UMin %arg0, %arg1 : i32 return } // ----- //===----------------------------------------------------------------------===// -// spv.GL.InverseSqrt +// spirv.GL.InverseSqrt //===----------------------------------------------------------------------===// func.func @inversesqrt(%arg0 : f32) -> () { - // CHECK: spv.GL.InverseSqrt {{%.*}} : f32 - %2 = spv.GL.InverseSqrt %arg0 : f32 + // CHECK: spirv.GL.InverseSqrt {{%.*}} : f32 + %2 = spirv.GL.InverseSqrt %arg0 : f32 return } func.func @inversesqrtvec(%arg0 : vector<3xf16>) -> () { - // CHECK: spv.GL.InverseSqrt {{%.*}} : vector<3xf16> - %2 = spv.GL.InverseSqrt %arg0 : vector<3xf16> + // CHECK: spirv.GL.InverseSqrt {{%.*}} : vector<3xf16> + %2 = spirv.GL.InverseSqrt %arg0 : vector<3xf16> return } // ----- //===----------------------------------------------------------------------===// -// spv.GL.Sqrt +// spirv.GL.Sqrt //===----------------------------------------------------------------------===// func.func @sqrt(%arg0 : f32) -> () { - // CHECK: spv.GL.Sqrt {{%.*}} : f32 - %2 = spv.GL.Sqrt %arg0 : f32 + // CHECK: spirv.GL.Sqrt {{%.*}} : f32 + %2 = spirv.GL.Sqrt %arg0 : f32 return } func.func @sqrtvec(%arg0 : vector<3xf16>) -> () { - // CHECK: spv.GL.Sqrt {{%.*}} : vector<3xf16> - %2 = spv.GL.Sqrt %arg0 : vector<3xf16> + // CHECK: spirv.GL.Sqrt {{%.*}} : vector<3xf16> + %2 = spirv.GL.Sqrt %arg0 : vector<3xf16> return } //===----------------------------------------------------------------------===// -// spv.GL.Cos +// spirv.GL.Cos //===----------------------------------------------------------------------===// func.func @cos(%arg0 : f32) -> () { - // CHECK: spv.GL.Cos {{%.*}} : f32 - %2 = spv.GL.Cos %arg0 : f32 + // CHECK: spirv.GL.Cos {{%.*}} : f32 + %2 = spirv.GL.Cos %arg0 : f32 return } func.func @cosvec(%arg0 : vector<3xf16>) -> () { - // CHECK: spv.GL.Cos {{%.*}} : vector<3xf16> - %2 = spv.GL.Cos %arg0 : vector<3xf16> + // CHECK: spirv.GL.Cos {{%.*}} : vector<3xf16> + %2 = spirv.GL.Cos %arg0 : vector<3xf16> return } //===----------------------------------------------------------------------===// -// spv.GL.Sin +// spirv.GL.Sin //===----------------------------------------------------------------------===// func.func @sin(%arg0 : f32) -> () { - // CHECK: spv.GL.Sin {{%.*}} : f32 - %2 = spv.GL.Sin %arg0 : f32 + // CHECK: spirv.GL.Sin {{%.*}} : f32 + %2 = spirv.GL.Sin %arg0 : f32 return } func.func @sinvec(%arg0 : vector<3xf16>) -> () { - // CHECK: spv.GL.Sin {{%.*}} : vector<3xf16> - %2 = spv.GL.Sin %arg0 : vector<3xf16> + // CHECK: spirv.GL.Sin {{%.*}} : vector<3xf16> + %2 = spirv.GL.Sin %arg0 : vector<3xf16> return } //===----------------------------------------------------------------------===// -// spv.GL.Tan +// spirv.GL.Tan //===----------------------------------------------------------------------===// func.func @tan(%arg0 : f32) -> () { - // CHECK: spv.GL.Tan {{%.*}} : f32 - %2 = spv.GL.Tan %arg0 : f32 + // CHECK: spirv.GL.Tan {{%.*}} : f32 + %2 = spirv.GL.Tan %arg0 : f32 return } func.func @tanvec(%arg0 : vector<3xf16>) -> () { - // CHECK: spv.GL.Tan {{%.*}} : vector<3xf16> - %2 = spv.GL.Tan %arg0 : vector<3xf16> + // CHECK: spirv.GL.Tan {{%.*}} : vector<3xf16> + %2 = spirv.GL.Tan %arg0 : vector<3xf16> return } //===----------------------------------------------------------------------===// -// spv.GL.Acos +// spirv.GL.Acos //===----------------------------------------------------------------------===// func.func @acos(%arg0 : f32) -> () { - // CHECK: spv.GL.Acos {{%.*}} : f32 - %2 = spv.GL.Acos %arg0 : f32 + // CHECK: spirv.GL.Acos {{%.*}} : f32 + %2 = spirv.GL.Acos %arg0 : f32 return } func.func @acosvec(%arg0 : vector<3xf16>) -> () { - // CHECK: spv.GL.Acos {{%.*}} : vector<3xf16> - %2 = spv.GL.Acos %arg0 : vector<3xf16> + // CHECK: spirv.GL.Acos {{%.*}} : vector<3xf16> + %2 = spirv.GL.Acos %arg0 : vector<3xf16> return } //===----------------------------------------------------------------------===// -// spv.GL.Asin +// spirv.GL.Asin //===----------------------------------------------------------------------===// func.func @asin(%arg0 : f32) -> () { - // CHECK: spv.GL.Asin {{%.*}} : f32 - %2 = spv.GL.Asin %arg0 : f32 + // CHECK: spirv.GL.Asin {{%.*}} : f32 + %2 = spirv.GL.Asin %arg0 : f32 return } func.func @asinvec(%arg0 : vector<3xf16>) -> () { - // CHECK: spv.GL.Asin {{%.*}} : vector<3xf16> - %2 = spv.GL.Asin %arg0 : vector<3xf16> + // CHECK: spirv.GL.Asin {{%.*}} : vector<3xf16> + %2 = spirv.GL.Asin %arg0 : vector<3xf16> return } //===----------------------------------------------------------------------===// -// spv.GL.Atan +// spirv.GL.Atan //===----------------------------------------------------------------------===// func.func @atan(%arg0 : f32) -> () { - // CHECK: spv.GL.Atan {{%.*}} : f32 - %2 = spv.GL.Atan %arg0 : f32 + // CHECK: spirv.GL.Atan {{%.*}} : f32 + %2 = spirv.GL.Atan %arg0 : f32 return } func.func @atanvec(%arg0 : vector<3xf16>) -> () { - // CHECK: spv.GL.Atan {{%.*}} : vector<3xf16> - %2 = spv.GL.Atan %arg0 : vector<3xf16> + // CHECK: spirv.GL.Atan {{%.*}} : vector<3xf16> + %2 = spirv.GL.Atan %arg0 : vector<3xf16> return } //===----------------------------------------------------------------------===// -// spv.GL.Sinh +// spirv.GL.Sinh //===----------------------------------------------------------------------===// func.func @sinh(%arg0 : f32) -> () { - // CHECK: spv.GL.Sinh {{%.*}} : f32 - %2 = spv.GL.Sinh %arg0 : f32 + // CHECK: spirv.GL.Sinh {{%.*}} : f32 + %2 = spirv.GL.Sinh %arg0 : f32 return } func.func @sinhvec(%arg0 : vector<3xf16>) -> () { - // CHECK: spv.GL.Sinh {{%.*}} : vector<3xf16> - %2 = spv.GL.Sinh %arg0 : vector<3xf16> + // CHECK: spirv.GL.Sinh {{%.*}} : vector<3xf16> + %2 = spirv.GL.Sinh %arg0 : vector<3xf16> return } //===----------------------------------------------------------------------===// -// spv.GL.Cosh +// spirv.GL.Cosh //===----------------------------------------------------------------------===// func.func @cosh(%arg0 : f32) -> () { - // CHECK: spv.GL.Cosh {{%.*}} : f32 - %2 = spv.GL.Cosh %arg0 : f32 + // CHECK: spirv.GL.Cosh {{%.*}} : f32 + %2 = spirv.GL.Cosh %arg0 : f32 return } func.func @coshvec(%arg0 : vector<3xf16>) -> () { - // CHECK: spv.GL.Cosh {{%.*}} : vector<3xf16> - %2 = spv.GL.Cosh %arg0 : vector<3xf16> + // CHECK: spirv.GL.Cosh {{%.*}} : vector<3xf16> + %2 = spirv.GL.Cosh %arg0 : vector<3xf16> return } //===----------------------------------------------------------------------===// -// spv.GL.Pow +// spirv.GL.Pow //===----------------------------------------------------------------------===// func.func @pow(%arg0 : f32, %arg1 : f32) -> () { - // CHECK: spv.GL.Pow {{%.*}}, {{%.*}} : f32 - %2 = spv.GL.Pow %arg0, %arg1 : f32 + // CHECK: spirv.GL.Pow {{%.*}}, {{%.*}} : f32 + %2 = spirv.GL.Pow %arg0, %arg1 : f32 return } func.func @powvec(%arg0 : vector<3xf16>, %arg1 : vector<3xf16>) -> () { - // CHECK: spv.GL.Pow {{%.*}}, {{%.*}} : vector<3xf16> - %2 = spv.GL.Pow %arg0, %arg1 : vector<3xf16> + // CHECK: spirv.GL.Pow {{%.*}}, {{%.*}} : vector<3xf16> + %2 = spirv.GL.Pow %arg0, %arg1 : vector<3xf16> return } // ----- //===----------------------------------------------------------------------===// -// spv.GL.Round +// spirv.GL.Round //===----------------------------------------------------------------------===// func.func @round(%arg0 : f32) -> () { - // CHECK: spv.GL.Round {{%.*}} : f32 - %2 = spv.GL.Round %arg0 : f32 + // CHECK: spirv.GL.Round {{%.*}} : f32 + %2 = spirv.GL.Round %arg0 : f32 return } func.func @roundvec(%arg0 : vector<3xf16>) -> () { - // CHECK: spv.GL.Round {{%.*}} : vector<3xf16> - %2 = spv.GL.Round %arg0 : vector<3xf16> + // CHECK: spirv.GL.Round {{%.*}} : vector<3xf16> + %2 = spirv.GL.Round %arg0 : vector<3xf16> return } // ----- //===----------------------------------------------------------------------===// -// spv.GL.FClamp +// spirv.GL.FClamp //===----------------------------------------------------------------------===// func.func @fclamp(%arg0 : f32, %min : f32, %max : f32) -> () { - // CHECK: spv.GL.FClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32 - %2 = spv.GL.FClamp %arg0, %min, %max : f32 + // CHECK: spirv.GL.FClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32 + %2 = spirv.GL.FClamp %arg0, %min, %max : f32 return } // ----- func.func @fclamp(%arg0 : vector<3xf32>, %min : vector<3xf32>, %max : vector<3xf32>) -> () { - // CHECK: spv.GL.FClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<3xf32> - %2 = spv.GL.FClamp %arg0, %min, %max : vector<3xf32> + // CHECK: spirv.GL.FClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<3xf32> + %2 = spirv.GL.FClamp %arg0, %min, %max : vector<3xf32> return } // ----- //===----------------------------------------------------------------------===// -// spv.GL.UClamp +// spirv.GL.UClamp //===----------------------------------------------------------------------===// func.func @uclamp(%arg0 : ui32, %min : ui32, %max : ui32) -> () { - // CHECK: spv.GL.UClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : ui32 - %2 = spv.GL.UClamp %arg0, %min, %max : ui32 + // CHECK: spirv.GL.UClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : ui32 + %2 = spirv.GL.UClamp %arg0, %min, %max : ui32 return } // ----- func.func @uclamp(%arg0 : vector<4xi32>, %min : vector<4xi32>, %max : vector<4xi32>) -> () { - // CHECK: spv.GL.UClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<4xi32> - %2 = spv.GL.UClamp %arg0, %min, %max : vector<4xi32> + // CHECK: spirv.GL.UClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<4xi32> + %2 = spirv.GL.UClamp %arg0, %min, %max : vector<4xi32> return } // ----- func.func @uclamp(%arg0 : si32, %min : si32, %max : si32) -> () { - // CHECK: spv.GL.UClamp - %2 = spv.GL.UClamp %arg0, %min, %max : si32 + // CHECK: spirv.GL.UClamp + %2 = spirv.GL.UClamp %arg0, %min, %max : si32 return } // ----- //===----------------------------------------------------------------------===// -// spv.GL.SClamp +// spirv.GL.SClamp //===----------------------------------------------------------------------===// func.func @sclamp(%arg0 : si32, %min : si32, %max : si32) -> () { - // CHECK: spv.GL.SClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : si32 - %2 = spv.GL.SClamp %arg0, %min, %max : si32 + // CHECK: spirv.GL.SClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : si32 + %2 = spirv.GL.SClamp %arg0, %min, %max : si32 return } // ----- func.func @sclamp(%arg0 : vector<4xsi32>, %min : vector<4xsi32>, %max : vector<4xsi32>) -> () { - // CHECK: spv.GL.SClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<4xsi32> - %2 = spv.GL.SClamp %arg0, %min, %max : vector<4xsi32> + // CHECK: spirv.GL.SClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<4xsi32> + %2 = spirv.GL.SClamp %arg0, %min, %max : vector<4xsi32> return } // ----- func.func @sclamp(%arg0 : i32, %min : i32, %max : i32) -> () { - // CHECK: spv.GL.SClamp - %2 = spv.GL.SClamp %arg0, %min, %max : i32 + // CHECK: spirv.GL.SClamp + %2 = spirv.GL.SClamp %arg0, %min, %max : i32 return } // ----- //===----------------------------------------------------------------------===// -// spv.GL.Fma +// spirv.GL.Fma //===----------------------------------------------------------------------===// func.func @fma(%a : f32, %b : f32, %c : f32) -> () { - // CHECK: spv.GL.Fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32 - %2 = spv.GL.Fma %a, %b, %c : f32 + // CHECK: spirv.GL.Fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32 + %2 = spirv.GL.Fma %a, %b, %c : f32 return } // ----- func.func @fma(%a : vector<3xf32>, %b : vector<3xf32>, %c : vector<3xf32>) -> () { - // CHECK: spv.GL.Fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<3xf32> - %2 = spv.GL.Fma %a, %b, %c : vector<3xf32> + // CHECK: spirv.GL.Fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<3xf32> + %2 = spirv.GL.Fma %a, %b, %c : vector<3xf32> return } // ----- //===----------------------------------------------------------------------===// -// spv.GL.FrexpStruct +// spirv.GL.FrexpStruct //===----------------------------------------------------------------------===// func.func @frexp_struct(%arg0 : f32) -> () { - // CHECK: spv.GL.FrexpStruct {{%.*}} : f32 -> !spv.struct<(f32, i32)> - %2 = spv.GL.FrexpStruct %arg0 : f32 -> !spv.struct<(f32, i32)> + // CHECK: spirv.GL.FrexpStruct {{%.*}} : f32 -> !spirv.struct<(f32, i32)> + %2 = spirv.GL.FrexpStruct %arg0 : f32 -> !spirv.struct<(f32, i32)> return } func.func @frexp_struct_64(%arg0 : f64) -> () { - // CHECK: spv.GL.FrexpStruct {{%.*}} : f64 -> !spv.struct<(f64, i32)> - %2 = spv.GL.FrexpStruct %arg0 : f64 -> !spv.struct<(f64, i32)> + // CHECK: spirv.GL.FrexpStruct {{%.*}} : f64 -> !spirv.struct<(f64, i32)> + %2 = spirv.GL.FrexpStruct %arg0 : f64 -> !spirv.struct<(f64, i32)> return } func.func @frexp_struct_vec(%arg0 : vector<3xf32>) -> () { - // CHECK: spv.GL.FrexpStruct {{%.*}} : vector<3xf32> -> !spv.struct<(vector<3xf32>, vector<3xi32>)> - %2 = spv.GL.FrexpStruct %arg0 : vector<3xf32> -> !spv.struct<(vector<3xf32>, vector<3xi32>)> + // CHECK: spirv.GL.FrexpStruct {{%.*}} : vector<3xf32> -> !spirv.struct<(vector<3xf32>, vector<3xi32>)> + %2 = spirv.GL.FrexpStruct %arg0 : vector<3xf32> -> !spirv.struct<(vector<3xf32>, vector<3xi32>)> return } @@ -411,7 +411,7 @@ func.func @frexp_struct_mismatch_type(%arg0 : f32) -> () { // expected-error @+1 {{member zero of the resulting struct type must be the same type as the operand}} - %2 = spv.GL.FrexpStruct %arg0 : f32 -> !spv.struct<(vector<3xf32>, i32)> + %2 = spirv.GL.FrexpStruct %arg0 : f32 -> !spirv.struct<(vector<3xf32>, i32)> return } @@ -419,7 +419,7 @@ func.func @frexp_struct_wrong_type(%arg0 : i32) -> () { // expected-error @+1 {{op operand #0 must be 16/32/64-bit float or vector of 16/32/64-bit float values}} - %2 = spv.GL.FrexpStruct %arg0 : i32 -> !spv.struct<(i32, i32)> + %2 = spirv.GL.FrexpStruct %arg0 : i32 -> !spirv.struct<(i32, i32)> return } @@ -427,7 +427,7 @@ func.func @frexp_struct_mismatch_num_components(%arg0 : vector<3xf32>) -> () { // expected-error @+1 {{member one of the resulting struct type must have the same number of components as the operand type}} - %2 = spv.GL.FrexpStruct %arg0 : vector<3xf32> -> !spv.struct<(vector<3xf32>, vector<2xi32>)> + %2 = spirv.GL.FrexpStruct %arg0 : vector<3xf32> -> !spirv.struct<(vector<3xf32>, vector<2xi32>)> return } @@ -435,26 +435,26 @@ func.func @frexp_struct_not_i32(%arg0 : f32) -> () { // expected-error @+1 {{member one of the resulting struct type must be a scalar or vector of 32 bit integer type}} - %2 = spv.GL.FrexpStruct %arg0 : f32 -> !spv.struct<(f32, i64)> + %2 = spirv.GL.FrexpStruct %arg0 : f32 -> !spirv.struct<(f32, i64)> return } // ----- //===----------------------------------------------------------------------===// -// spv.GL.Ldexp +// spirv.GL.Ldexp //===----------------------------------------------------------------------===// func.func @ldexp(%arg0 : f32, %arg1 : i32) -> () { - // CHECK: {{%.*}} = spv.GL.Ldexp {{%.*}} : f32, {{%.*}} : i32 -> f32 - %0 = spv.GL.Ldexp %arg0 : f32, %arg1 : i32 -> f32 + // CHECK: {{%.*}} = spirv.GL.Ldexp {{%.*}} : f32, {{%.*}} : i32 -> f32 + %0 = spirv.GL.Ldexp %arg0 : f32, %arg1 : i32 -> f32 return } // ----- func.func @ldexp_vec(%arg0 : vector<3xf32>, %arg1 : vector<3xi32>) -> () { - // CHECK: {{%.*}} = spv.GL.Ldexp {{%.*}} : vector<3xf32>, {{%.*}} : vector<3xi32> -> vector<3xf32> - %0 = spv.GL.Ldexp %arg0 : vector<3xf32>, %arg1 : vector<3xi32> -> vector<3xf32> + // CHECK: {{%.*}} = spirv.GL.Ldexp {{%.*}} : vector<3xf32>, {{%.*}} : vector<3xi32> -> vector<3xf32> + %0 = spirv.GL.Ldexp %arg0 : vector<3xf32>, %arg1 : vector<3xi32> -> vector<3xf32> return } @@ -462,7 +462,7 @@ func.func @ldexp_wrong_type_scalar(%arg0 : f32, %arg1 : vector<2xi32>) -> () { // expected-error @+1 {{operands must both be scalars or vectors}} - %0 = spv.GL.Ldexp %arg0 : f32, %arg1 : vector<2xi32> -> f32 + %0 = spirv.GL.Ldexp %arg0 : f32, %arg1 : vector<2xi32> -> f32 return } @@ -470,7 +470,7 @@ func.func @ldexp_wrong_type_vec_1(%arg0 : vector<3xf32>, %arg1 : i32) -> () { // expected-error @+1 {{operands must both be scalars or vectors}} - %0 = spv.GL.Ldexp %arg0 : vector<3xf32>, %arg1 : i32 -> vector<3xf32> + %0 = spirv.GL.Ldexp %arg0 : vector<3xf32>, %arg1 : i32 -> vector<3xf32> return } @@ -478,43 +478,43 @@ func.func @ldexp_wrong_type_vec_2(%arg0 : vector<3xf32>, %arg1 : vector<2xi32>) -> () { // expected-error @+1 {{operands must have the same number of elements}} - %0 = spv.GL.Ldexp %arg0 : vector<3xf32>, %arg1 : vector<2xi32> -> vector<3xf32> + %0 = spirv.GL.Ldexp %arg0 : vector<3xf32>, %arg1 : vector<2xi32> -> vector<3xf32> return } // ----- //===----------------------------------------------------------------------===// -// spv.GL.FMix +// spirv.GL.FMix //===----------------------------------------------------------------------===// func.func @fmix(%arg0 : f32, %arg1 : f32, %arg2 : f32) -> () { - // CHECK: {{%.*}} = spv.GL.FMix {{%.*}} : f32, {{%.*}} : f32, {{%.*}} : f32 -> f32 - %0 = spv.GL.FMix %arg0 : f32, %arg1 : f32, %arg2 : f32 -> f32 + // CHECK: {{%.*}} = spirv.GL.FMix {{%.*}} : f32, {{%.*}} : f32, {{%.*}} : f32 -> f32 + %0 = spirv.GL.FMix %arg0 : f32, %arg1 : f32, %arg2 : f32 -> f32 return } func.func @fmix_vector(%arg0 : vector<3xf32>, %arg1 : vector<3xf32>, %arg2 : vector<3xf32>) -> () { - // CHECK: {{%.*}} = spv.GL.FMix {{%.*}} : vector<3xf32>, {{%.*}} : vector<3xf32>, {{%.*}} : vector<3xf32> -> vector<3xf32> - %0 = spv.GL.FMix %arg0 : vector<3xf32>, %arg1 : vector<3xf32>, %arg2 : vector<3xf32> -> vector<3xf32> + // CHECK: {{%.*}} = spirv.GL.FMix {{%.*}} : vector<3xf32>, {{%.*}} : vector<3xf32>, {{%.*}} : vector<3xf32> -> vector<3xf32> + %0 = spirv.GL.FMix %arg0 : vector<3xf32>, %arg1 : vector<3xf32>, %arg2 : vector<3xf32> -> vector<3xf32> return } // ----- //===----------------------------------------------------------------------===// -// spv.GL.Exp +// spirv.GL.Exp //===----------------------------------------------------------------------===// func.func @findumsb(%arg0 : i32) -> () { - // CHECK: spv.GL.FindUMsb {{%.*}} : i32 - %2 = spv.GL.FindUMsb %arg0 : i32 + // CHECK: spirv.GL.FindUMsb {{%.*}} : i32 + %2 = spirv.GL.FindUMsb %arg0 : i32 return } func.func @findumsb_vector(%arg0 : vector<3xi32>) -> () { - // CHECK: spv.GL.FindUMsb {{%.*}} : vector<3xi32> - %2 = spv.GL.FindUMsb %arg0 : vector<3xi32> + // CHECK: spirv.GL.FindUMsb {{%.*}} : vector<3xi32> + %2 = spirv.GL.FindUMsb %arg0 : vector<3xi32> return } @@ -522,6 +522,6 @@ func.func @findumsb(%arg0 : i64) -> () { // expected-error @+1 {{operand #0 must be Int32 or vector of Int32}} - %2 = spv.GL.FindUMsb %arg0 : i64 + %2 = spirv.GL.FindUMsb %arg0 : i64 return } diff --git a/mlir/test/Dialect/SPIRV/IR/group-ops.mlir b/mlir/test/Dialect/SPIRV/IR/group-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/group-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/group-ops.mlir @@ -1,40 +1,40 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.KHR.SubgroupBallot +// spirv.KHR.SubgroupBallot //===----------------------------------------------------------------------===// func.func @subgroup_ballot(%predicate: i1) -> vector<4xi32> { - // CHECK: %{{.*}} = spv.KHR.SubgroupBallot %{{.*}} : vector<4xi32> - %0 = spv.KHR.SubgroupBallot %predicate: vector<4xi32> + // CHECK: %{{.*}} = spirv.KHR.SubgroupBallot %{{.*}} : vector<4xi32> + %0 = spirv.KHR.SubgroupBallot %predicate: vector<4xi32> return %0: vector<4xi32> } // ----- //===----------------------------------------------------------------------===// -// spv.GroupBroadcast +// spirv.GroupBroadcast //===----------------------------------------------------------------------===// func.func @group_broadcast_scalar(%value: f32, %localid: i32 ) -> f32 { - // CHECK: spv.GroupBroadcast %{{.*}}, %{{.*}} : f32, i32 - %0 = spv.GroupBroadcast %value, %localid : f32, i32 + // CHECK: spirv.GroupBroadcast %{{.*}}, %{{.*}} : f32, i32 + %0 = spirv.GroupBroadcast %value, %localid : f32, i32 return %0: f32 } // ----- func.func @group_broadcast_scalar_vector(%value: f32, %localid: vector<3xi32> ) -> f32 { - // CHECK: spv.GroupBroadcast %{{.*}}, %{{.*}} : f32, vector<3xi32> - %0 = spv.GroupBroadcast %value, %localid : f32, vector<3xi32> + // CHECK: spirv.GroupBroadcast %{{.*}}, %{{.*}} : f32, vector<3xi32> + %0 = spirv.GroupBroadcast %value, %localid : f32, vector<3xi32> return %0: f32 } // ----- func.func @group_broadcast_vector(%value: vector<4xf32>, %localid: vector<3xi32> ) -> vector<4xf32> { - // CHECK: spv.GroupBroadcast %{{.*}}, %{{.*}} : vector<4xf32>, vector<3xi32> - %0 = spv.GroupBroadcast %value, %localid : vector<4xf32>, vector<3xi32> + // CHECK: spirv.GroupBroadcast %{{.*}}, %{{.*}} : vector<4xf32>, vector<3xi32> + %0 = spirv.GroupBroadcast %value, %localid : vector<4xf32>, vector<3xi32> return %0: vector<4xf32> } @@ -42,7 +42,7 @@ func.func @group_broadcast_negative_scope(%value: f32, %localid: vector<3xi32> ) -> f32 { // expected-error @+1 {{execution scope must be 'Workgroup' or 'Subgroup'}} - %0 = spv.GroupBroadcast %value, %localid : f32, vector<3xi32> + %0 = spirv.GroupBroadcast %value, %localid : f32, vector<3xi32> return %0: f32 } @@ -50,7 +50,7 @@ func.func @group_broadcast_negative_locid_dtype(%value: f32, %localid: vector<3xf32> ) -> f32 { // expected-error @+1 {{operand #1 must be 8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values}} - %0 = spv.GroupBroadcast %value, %localid : f32, vector<3xf32> + %0 = spirv.GroupBroadcast %value, %localid : f32, vector<3xf32> return %0: f32 } @@ -58,57 +58,57 @@ func.func @group_broadcast_negative_locid_vec4(%value: f32, %localid: vector<4xi32> ) -> f32 { // expected-error @+1 {{localid is a vector and can be with only 2 or 3 components, actual number is 4}} - %0 = spv.GroupBroadcast %value, %localid : f32, vector<4xi32> + %0 = spirv.GroupBroadcast %value, %localid : f32, vector<4xi32> return %0: f32 } // ----- //===----------------------------------------------------------------------===// -// spv.KHR.SubgroupBallot +// spirv.KHR.SubgroupBallot //===----------------------------------------------------------------------===// func.func @subgroup_ballot(%predicate: i1) -> vector<4xi32> { - %0 = spv.KHR.SubgroupBallot %predicate: vector<4xi32> + %0 = spirv.KHR.SubgroupBallot %predicate: vector<4xi32> return %0: vector<4xi32> } // ----- //===----------------------------------------------------------------------===// -// spv.INTEL.SubgroupBlockRead +// spirv.INTEL.SubgroupBlockRead //===----------------------------------------------------------------------===// -func.func @subgroup_block_read_intel(%ptr : !spv.ptr) -> i32 { - // CHECK: spv.INTEL.SubgroupBlockRead %{{.*}} : i32 - %0 = spv.INTEL.SubgroupBlockRead "StorageBuffer" %ptr : i32 +func.func @subgroup_block_read_intel(%ptr : !spirv.ptr) -> i32 { + // CHECK: spirv.INTEL.SubgroupBlockRead %{{.*}} : i32 + %0 = spirv.INTEL.SubgroupBlockRead "StorageBuffer" %ptr : i32 return %0: i32 } // ----- -func.func @subgroup_block_read_intel_vector(%ptr : !spv.ptr) -> vector<3xi32> { - // CHECK: spv.INTEL.SubgroupBlockRead %{{.*}} : vector<3xi32> - %0 = spv.INTEL.SubgroupBlockRead "StorageBuffer" %ptr : vector<3xi32> +func.func @subgroup_block_read_intel_vector(%ptr : !spirv.ptr) -> vector<3xi32> { + // CHECK: spirv.INTEL.SubgroupBlockRead %{{.*}} : vector<3xi32> + %0 = spirv.INTEL.SubgroupBlockRead "StorageBuffer" %ptr : vector<3xi32> return %0: vector<3xi32> } // ----- //===----------------------------------------------------------------------===// -// spv.INTEL.SubgroupBlockWrite +// spirv.INTEL.SubgroupBlockWrite //===----------------------------------------------------------------------===// -func.func @subgroup_block_write_intel(%ptr : !spv.ptr, %value: i32) -> () { - // CHECK: spv.INTEL.SubgroupBlockWrite %{{.*}}, %{{.*}} : i32 - spv.INTEL.SubgroupBlockWrite "StorageBuffer" %ptr, %value : i32 +func.func @subgroup_block_write_intel(%ptr : !spirv.ptr, %value: i32) -> () { + // CHECK: spirv.INTEL.SubgroupBlockWrite %{{.*}}, %{{.*}} : i32 + spirv.INTEL.SubgroupBlockWrite "StorageBuffer" %ptr, %value : i32 return } // ----- -func.func @subgroup_block_write_intel_vector(%ptr : !spv.ptr, %value: vector<3xi32>) -> () { - // CHECK: spv.INTEL.SubgroupBlockWrite %{{.*}}, %{{.*}} : vector<3xi32> - spv.INTEL.SubgroupBlockWrite "StorageBuffer" %ptr, %value : vector<3xi32> +func.func @subgroup_block_write_intel_vector(%ptr : !spirv.ptr, %value: vector<3xi32>) -> () { + // CHECK: spirv.INTEL.SubgroupBlockWrite %{{.*}}, %{{.*}} : vector<3xi32> + spirv.INTEL.SubgroupBlockWrite "StorageBuffer" %ptr, %value : vector<3xi32> return } diff --git a/mlir/test/Dialect/SPIRV/IR/image-ops.mlir b/mlir/test/Dialect/SPIRV/IR/image-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/image-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/image-ops.mlir @@ -1,117 +1,117 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.ImageDrefGather +// spirv.ImageDrefGather //===----------------------------------------------------------------------===// -func.func @image_dref_gather(%arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) -> () { - // CHECK: spv.ImageDrefGather {{.*}} : !spv.sampled_image>, {{.*}} : vector<4xf32>, {{.*}} : f32 -> vector<4xi32> - %0 = spv.ImageDrefGather %arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 -> vector<4xi32> - spv.Return +func.func @image_dref_gather(%arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) -> () { + // CHECK: spirv.ImageDrefGather {{.*}} : !spirv.sampled_image>, {{.*}} : vector<4xf32>, {{.*}} : f32 -> vector<4xi32> + %0 = spirv.ImageDrefGather %arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 -> vector<4xi32> + spirv.Return } // ----- -func.func @image_dref_gather_with_single_imageoperands(%arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) -> () { - // CHECK: spv.ImageDrefGather {{.*}} ["NonPrivateTexel"] -> vector<4xi32> - %0 = spv.ImageDrefGather %arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 ["NonPrivateTexel"] -> vector<4xi32> - spv.Return +func.func @image_dref_gather_with_single_imageoperands(%arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) -> () { + // CHECK: spirv.ImageDrefGather {{.*}} ["NonPrivateTexel"] -> vector<4xi32> + %0 = spirv.ImageDrefGather %arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 ["NonPrivateTexel"] -> vector<4xi32> + spirv.Return } // ----- -func.func @image_dref_gather_with_mismatch_imageoperands(%arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) -> () { +func.func @image_dref_gather_with_mismatch_imageoperands(%arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) -> () { // expected-error @+1 {{the Image Operands should encode what operands follow, as per Image Operands}} - %0 = spv.ImageDrefGather %arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 (%arg2, %arg2 : f32, f32) -> vector<4xi32> - spv.Return + %0 = spirv.ImageDrefGather %arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 (%arg2, %arg2 : f32, f32) -> vector<4xi32> + spirv.Return } // ----- -func.func @image_dref_gather_error_result_type(%arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) -> () { +func.func @image_dref_gather_error_result_type(%arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) -> () { // expected-error @+1 {{result type must be a vector of four components}} - %0 = spv.ImageDrefGather %arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 -> vector<3xi32> - spv.Return + %0 = spirv.ImageDrefGather %arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 -> vector<3xi32> + spirv.Return } // ----- -func.func @image_dref_gather_error_same_type(%arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) -> () { +func.func @image_dref_gather_error_same_type(%arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) -> () { // expected-error @+1 {{the component type of result must be the same as sampled type of the underlying image type}} - %0 = spv.ImageDrefGather %arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 -> vector<4xf32> - spv.Return + %0 = spirv.ImageDrefGather %arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 -> vector<4xf32> + spirv.Return } // ----- -func.func @image_dref_gather_error_dim(%arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) -> () { +func.func @image_dref_gather_error_dim(%arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) -> () { // expected-error @+1 {{the Dim operand of the underlying image type must be 2D, Cube, or Rect}} - %0 = spv.ImageDrefGather %arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 -> vector<4xi32> - spv.Return + %0 = spirv.ImageDrefGather %arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 -> vector<4xi32> + spirv.Return } // ----- -func.func @image_dref_gather_error_ms(%arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) -> () { +func.func @image_dref_gather_error_ms(%arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) -> () { // expected-error @+1 {{the MS operand of the underlying image type must be 0}} - %0 = spv.ImageDrefGather %arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 -> vector<4xi32> - spv.Return + %0 = spirv.ImageDrefGather %arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 -> vector<4xi32> + spirv.Return } // ----- //===----------------------------------------------------------------------===// -// spv.Image +// spirv.Image //===----------------------------------------------------------------------===// -func.func @image(%arg0 : !spv.sampled_image>) -> () { - // CHECK: spv.Image {{.*}} : !spv.sampled_image> - %0 = spv.Image %arg0 : !spv.sampled_image> +func.func @image(%arg0 : !spirv.sampled_image>) -> () { + // CHECK: spirv.Image {{.*}} : !spirv.sampled_image> + %0 = spirv.Image %arg0 : !spirv.sampled_image> return } // ----- //===----------------------------------------------------------------------===// -// spv.ImageQuerySize +// spirv.ImageQuerySize //===----------------------------------------------------------------------===// -func.func @image_query_size(%arg0 : !spv.image) -> () { - // CHECK: {{%.*}} = spv.ImageQuerySize %arg0 : !spv.image -> i32 - %0 = spv.ImageQuerySize %arg0 : !spv.image -> i32 - spv.Return +func.func @image_query_size(%arg0 : !spirv.image) -> () { + // CHECK: {{%.*}} = spirv.ImageQuerySize %arg0 : !spirv.image -> i32 + %0 = spirv.ImageQuerySize %arg0 : !spirv.image -> i32 + spirv.Return } // ----- -func.func @image_query_size_error_dim(%arg0 : !spv.image) -> () { +func.func @image_query_size_error_dim(%arg0 : !spirv.image) -> () { // expected-error @+1 {{the Dim operand of the image type must be 1D, 2D, 3D, Buffer, Cube, or Rect}} - %0 = spv.ImageQuerySize %arg0 : !spv.image -> i32 - spv.Return + %0 = spirv.ImageQuerySize %arg0 : !spirv.image -> i32 + spirv.Return } // ----- -func.func @image_query_size_error_dim_sample(%arg0 : !spv.image) -> () { +func.func @image_query_size_error_dim_sample(%arg0 : !spirv.image) -> () { // expected-error @+1 {{if Dim is 1D, 2D, 3D, or Cube, it must also have either an MS of 1 or a Sampled of 0 or 2}} - %0 = spv.ImageQuerySize %arg0 : !spv.image -> i32 - spv.Return + %0 = spirv.ImageQuerySize %arg0 : !spirv.image -> i32 + spirv.Return } // ----- -func.func @image_query_size_error_result1(%arg0 : !spv.image) -> () { +func.func @image_query_size_error_result1(%arg0 : !spirv.image) -> () { // expected-error @+1 {{expected the result to have 4 component(s), but found 3 component(s)}} - %0 = spv.ImageQuerySize %arg0 : !spv.image -> vector<3xi32> - spv.Return + %0 = spirv.ImageQuerySize %arg0 : !spirv.image -> vector<3xi32> + spirv.Return } // ----- -func.func @image_query_size_error_result2(%arg0 : !spv.image) -> () { +func.func @image_query_size_error_result2(%arg0 : !spirv.image) -> () { // expected-error @+1 {{expected the result to have 1 component(s), but found 2 component(s)}} - %0 = spv.ImageQuerySize %arg0 : !spv.image -> vector<2xi32> - spv.Return + %0 = spirv.ImageQuerySize %arg0 : !spirv.image -> vector<2xi32> + spirv.Return } // ----- diff --git a/mlir/test/Dialect/SPIRV/IR/joint-matrix-ops.mlir b/mlir/test/Dialect/SPIRV/IR/joint-matrix-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/joint-matrix-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/joint-matrix-ops.mlir @@ -1,99 +1,99 @@ // RUN: mlir-opt -allow-unregistered-dialect -split-input-file -verify-diagnostics %s | FileCheck %s // CHECK-LABEL: @joint_matrix_load -spv.func @joint_matrix_load(%ptr : !spv.ptr, %stride : i32) "None" { - // CHECK: {{%.*}} = spv.INTEL.JointMatrixLoad {{%.*}}, {{%.*}} : (!spv.ptr, i32) -> !spv.jointmatrix<16x8xi32, RowMajor, Workgroup> - %0 = spv.INTEL.JointMatrixLoad %ptr, %stride : (!spv.ptr, i32) -> !spv.jointmatrix<16x8xi32, RowMajor, Workgroup> - spv.Return +spirv.func @joint_matrix_load(%ptr : !spirv.ptr, %stride : i32) "None" { + // CHECK: {{%.*}} = spirv.INTEL.JointMatrixLoad {{%.*}}, {{%.*}} : (!spirv.ptr, i32) -> !spirv.jointmatrix<16x8xi32, RowMajor, Workgroup> + %0 = spirv.INTEL.JointMatrixLoad %ptr, %stride : (!spirv.ptr, i32) -> !spirv.jointmatrix<16x8xi32, RowMajor, Workgroup> + spirv.Return } // ----- // CHECK-LABEL: @joint_matrix_load_memaccess -spv.func @joint_matrix_load_memaccess(%ptr : !spv.ptr, %stride : i32) "None" { - // CHECK: {{%.*}} = spv.INTEL.JointMatrixLoad {{%.*}}, {{%.*}} {memory_access = #spv.memory_access} : (!spv.ptr, i32) -> !spv.jointmatrix<8x16xi32, ColumnMajor, Subgroup> - %0 = spv.INTEL.JointMatrixLoad %ptr, %stride {memory_access = #spv.memory_access} : (!spv.ptr, i32) -> !spv.jointmatrix<8x16xi32, ColumnMajor, Subgroup> - spv.Return +spirv.func @joint_matrix_load_memaccess(%ptr : !spirv.ptr, %stride : i32) "None" { + // CHECK: {{%.*}} = spirv.INTEL.JointMatrixLoad {{%.*}}, {{%.*}} {memory_access = #spirv.memory_access} : (!spirv.ptr, i32) -> !spirv.jointmatrix<8x16xi32, ColumnMajor, Subgroup> + %0 = spirv.INTEL.JointMatrixLoad %ptr, %stride {memory_access = #spirv.memory_access} : (!spirv.ptr, i32) -> !spirv.jointmatrix<8x16xi32, ColumnMajor, Subgroup> + spirv.Return } // CHECK-LABEL: @joint_matrix_load_diff_ptr_type -spv.func @joint_matrix_load_diff_ptr_type(%ptr : !spv.ptr, Workgroup>, %stride : i32) "None" { - // CHECK: {{%.*}} = spv.INTEL.JointMatrixLoad {{%.*}}, {{%.*}} {memory_access = #spv.memory_access} : (!spv.ptr, Workgroup>, i32) -> !spv.jointmatrix<8x16xi32, RowMajor, Workgroup> - %0 = spv.INTEL.JointMatrixLoad %ptr, %stride {memory_access = #spv.memory_access} : (!spv.ptr, Workgroup>, i32) -> !spv.jointmatrix<8x16xi32, RowMajor, Workgroup> - spv.Return +spirv.func @joint_matrix_load_diff_ptr_type(%ptr : !spirv.ptr, Workgroup>, %stride : i32) "None" { + // CHECK: {{%.*}} = spirv.INTEL.JointMatrixLoad {{%.*}}, {{%.*}} {memory_access = #spirv.memory_access} : (!spirv.ptr, Workgroup>, i32) -> !spirv.jointmatrix<8x16xi32, RowMajor, Workgroup> + %0 = spirv.INTEL.JointMatrixLoad %ptr, %stride {memory_access = #spirv.memory_access} : (!spirv.ptr, Workgroup>, i32) -> !spirv.jointmatrix<8x16xi32, RowMajor, Workgroup> + spirv.Return } // CHECK-LABEL: @joint_matrix_store -spv.func @joint_matrix_store(%ptr : !spv.ptr, %stride : i32, %m : !spv.jointmatrix<8x16xi32, RowMajor, Workgroup>) "None" { - // CHECK: spv.INTEL.JointMatrixStore {{%.*}}, {{%.*}}, {{%.*}} : (!spv.ptr, !spv.jointmatrix<8x16xi32, RowMajor, Workgroup>, i32) - spv.INTEL.JointMatrixStore %ptr, %m, %stride : (!spv.ptr, !spv.jointmatrix<8x16xi32, RowMajor, Workgroup>, i32) - spv.Return +spirv.func @joint_matrix_store(%ptr : !spirv.ptr, %stride : i32, %m : !spirv.jointmatrix<8x16xi32, RowMajor, Workgroup>) "None" { + // CHECK: spirv.INTEL.JointMatrixStore {{%.*}}, {{%.*}}, {{%.*}} : (!spirv.ptr, !spirv.jointmatrix<8x16xi32, RowMajor, Workgroup>, i32) + spirv.INTEL.JointMatrixStore %ptr, %m, %stride : (!spirv.ptr, !spirv.jointmatrix<8x16xi32, RowMajor, Workgroup>, i32) + spirv.Return } // CHECK-LABEL: @joint_matrix_store_memaccess -spv.func @joint_matrix_store_memaccess(%ptr : !spv.ptr, %m : !spv.jointmatrix<8x16xi32, RowMajor, Subgroup>, %stride : i32) "None" { - // CHECK: spv.INTEL.JointMatrixStore {{%.*}}, {{%.*}}, {{%.*}} {Volatile} : (!spv.ptr, !spv.jointmatrix<8x16xi32, RowMajor, Subgroup>, i32) - spv.INTEL.JointMatrixStore %ptr, %m, %stride {Volatile} : (!spv.ptr, !spv.jointmatrix<8x16xi32, RowMajor, Subgroup>, i32) - spv.Return +spirv.func @joint_matrix_store_memaccess(%ptr : !spirv.ptr, %m : !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, %stride : i32) "None" { + // CHECK: spirv.INTEL.JointMatrixStore {{%.*}}, {{%.*}}, {{%.*}} {Volatile} : (!spirv.ptr, !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, i32) + spirv.INTEL.JointMatrixStore %ptr, %m, %stride {Volatile} : (!spirv.ptr, !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, i32) + spirv.Return } // CHECK-LABEL: @joint_matrix_length -spv.func @joint_matrix_length() -> i32 "None" { - // CHECK: {{%.*}} = spv.INTEL.JointMatrixWorkItemLength : !spv.jointmatrix<8x16xi32, PackedB, Subgroup> - %0 = spv.INTEL.JointMatrixWorkItemLength : !spv.jointmatrix<8x16xi32, PackedB, Subgroup> - spv.ReturnValue %0 : i32 +spirv.func @joint_matrix_length() -> i32 "None" { + // CHECK: {{%.*}} = spirv.INTEL.JointMatrixWorkItemLength : !spirv.jointmatrix<8x16xi32, PackedB, Subgroup> + %0 = spirv.INTEL.JointMatrixWorkItemLength : !spirv.jointmatrix<8x16xi32, PackedB, Subgroup> + spirv.ReturnValue %0 : i32 } // CHECK-LABEL: @joint_matrix_muladd -spv.func @joint_matrix_muladd(%a : !spv.jointmatrix<8x32xi8, RowMajor, Subgroup>, %b : !spv.jointmatrix<32x8xi8, ColumnMajor, Subgroup>, %c : !spv.jointmatrix<8x8xi32, RowMajor, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.INTEL.JointMatrixMad {{%.*}}, {{%.*}}, {{%.*}} : !spv.jointmatrix<8x32xi8, RowMajor, Subgroup>, !spv.jointmatrix<32x8xi8, ColumnMajor, Subgroup> -> !spv.jointmatrix<8x8xi32, RowMajor, Subgroup> - %r = spv.INTEL.JointMatrixMad %a, %b, %c : !spv.jointmatrix<8x32xi8, RowMajor, Subgroup>, !spv.jointmatrix<32x8xi8, ColumnMajor, Subgroup> -> !spv.jointmatrix<8x8xi32, RowMajor, Subgroup> - spv.Return +spirv.func @joint_matrix_muladd(%a : !spirv.jointmatrix<8x32xi8, RowMajor, Subgroup>, %b : !spirv.jointmatrix<32x8xi8, ColumnMajor, Subgroup>, %c : !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.INTEL.JointMatrixMad {{%.*}}, {{%.*}}, {{%.*}} : !spirv.jointmatrix<8x32xi8, RowMajor, Subgroup>, !spirv.jointmatrix<32x8xi8, ColumnMajor, Subgroup> -> !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup> + %r = spirv.INTEL.JointMatrixMad %a, %b, %c : !spirv.jointmatrix<8x32xi8, RowMajor, Subgroup>, !spirv.jointmatrix<32x8xi8, ColumnMajor, Subgroup> -> !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup> + spirv.Return } // ----- -spv.func @joint_matrix_muladd(%a : !spv.jointmatrix<16x16xi32, RowMajor, Subgroup>, %b : !spv.jointmatrix<16x8xi32, RowMajor, Subgroup>, %c : !spv.jointmatrix<8x8xi32, RowMajor, Subgroup>) "None" { - // expected-error @+1 {{'spv.INTEL.JointMatrixMad' op matrix size must match}} - %r = spv.INTEL.JointMatrixMad %a, %b, %c : !spv.jointmatrix<16x16xi32, RowMajor, Subgroup>, !spv.jointmatrix<16x8xi32, RowMajor, Subgroup> -> !spv.jointmatrix<8x8xi32, RowMajor, Subgroup> - spv.Return +spirv.func @joint_matrix_muladd(%a : !spirv.jointmatrix<16x16xi32, RowMajor, Subgroup>, %b : !spirv.jointmatrix<16x8xi32, RowMajor, Subgroup>, %c : !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup>) "None" { + // expected-error @+1 {{'spirv.INTEL.JointMatrixMad' op matrix size must match}} + %r = spirv.INTEL.JointMatrixMad %a, %b, %c : !spirv.jointmatrix<16x16xi32, RowMajor, Subgroup>, !spirv.jointmatrix<16x8xi32, RowMajor, Subgroup> -> !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup> + spirv.Return } // ----- -spv.func @joint_matrix_muladd(%a : !spv.jointmatrix<8x16xi32, RowMajor, Subgroup>, %b : !spv.jointmatrix<8x8xi32, RowMajor, Subgroup>, %c : !spv.jointmatrix<8x8xi32, RowMajor, Subgroup>) "None" { - // expected-error @+1 {{'spv.INTEL.JointMatrixMad' op matrix size must match}} - %r = spv.INTEL.JointMatrixMad %a, %b, %c : !spv.jointmatrix<8x16xi32, RowMajor, Subgroup>, !spv.jointmatrix<8x8xi32, RowMajor, Subgroup> -> !spv.jointmatrix<8x8xi32, RowMajor, Subgroup> - spv.Return +spirv.func @joint_matrix_muladd(%a : !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, %b : !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup>, %c : !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup>) "None" { + // expected-error @+1 {{'spirv.INTEL.JointMatrixMad' op matrix size must match}} + %r = spirv.INTEL.JointMatrixMad %a, %b, %c : !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup> -> !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup> + spirv.Return } // ----- -spv.func @joint_matrix_muladd(%a : !spv.jointmatrix<8x16xi32, RowMajor, Subgroup>, %b : !spv.jointmatrix<16x8xi32, RowMajor, Workgroup>, %c : !spv.jointmatrix<8x8xi32, RowMajor, Subgroup>) "None" { - // expected-error @+1 {{'spv.INTEL.JointMatrixMad' op matrix scope must match}} - %r = spv.INTEL.JointMatrixMad %a, %b, %c : !spv.jointmatrix<8x16xi32, RowMajor, Subgroup>, !spv.jointmatrix<16x8xi32, RowMajor, Workgroup> -> !spv.jointmatrix<8x8xi32, RowMajor, Subgroup> - spv.Return +spirv.func @joint_matrix_muladd(%a : !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, %b : !spirv.jointmatrix<16x8xi32, RowMajor, Workgroup>, %c : !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup>) "None" { + // expected-error @+1 {{'spirv.INTEL.JointMatrixMad' op matrix scope must match}} + %r = spirv.INTEL.JointMatrixMad %a, %b, %c : !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, !spirv.jointmatrix<16x8xi32, RowMajor, Workgroup> -> !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup> + spirv.Return } // ----- -spv.func @joint_matrix_muladd(%a : !spv.jointmatrix<8x16xf32, RowMajor, Subgroup>, %b : !spv.jointmatrix<16x8xi32, RowMajor, Subgroup>, %c : !spv.jointmatrix<8x8xi32, RowMajor, Subgroup>) "None" { +spirv.func @joint_matrix_muladd(%a : !spirv.jointmatrix<8x16xf32, RowMajor, Subgroup>, %b : !spirv.jointmatrix<16x8xi32, RowMajor, Subgroup>, %c : !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup>) "None" { // expected-error @+1 {{matrix element type must match}} - %r = spv.INTEL.JointMatrixMad %a, %b, %c : !spv.jointmatrix<8x16xf32, RowMajor, Subgroup>, !spv.jointmatrix<16x8xi32, RowMajor, Subgroup> -> !spv.jointmatrix<8x8xi32, RowMajor, Subgroup> - spv.Return + %r = spirv.INTEL.JointMatrixMad %a, %b, %c : !spirv.jointmatrix<8x16xf32, RowMajor, Subgroup>, !spirv.jointmatrix<16x8xi32, RowMajor, Subgroup> -> !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup> + spirv.Return } // ----- -spv.func @joint_matrix_load_memaccess(%ptr : !spv.ptr, Workgroup>, %stride : i32) "None" { +spirv.func @joint_matrix_load_memaccess(%ptr : !spirv.ptr, Workgroup>, %stride : i32) "None" { // expected-error @+1 {{Pointer must point to a scalar or vector type}} - %0 = spv.INTEL.JointMatrixLoad %ptr, %stride : (!spv.ptr, Workgroup>, i32)-> !spv.jointmatrix<8x16xi32, RowMajor, Subgroup> - spv.Return + %0 = spirv.INTEL.JointMatrixLoad %ptr, %stride : (!spirv.ptr, Workgroup>, i32)-> !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup> + spirv.Return } // ----- -spv.func @joint_matrix_load_memaccess(%ptr : !spv.ptr, %stride : i32) "None" { +spirv.func @joint_matrix_load_memaccess(%ptr : !spirv.ptr, %stride : i32) "None" { // expected-error @+1 {{Pointer storage class must be Workgroup or CrossWorkgroup}} - %0 = spv.INTEL.JointMatrixLoad %ptr, %stride : (!spv.ptr, i32) -> !spv.jointmatrix<8x16xi32, RowMajor, Subgroup> - spv.Return + %0 = spirv.INTEL.JointMatrixLoad %ptr, %stride : (!spirv.ptr, i32) -> !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup> + spirv.Return } diff --git a/mlir/test/Dialect/SPIRV/IR/logical-ops.mlir b/mlir/test/Dialect/SPIRV/IR/logical-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/logical-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/logical-ops.mlir @@ -1,88 +1,88 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.IEqual +// spirv.IEqual //===----------------------------------------------------------------------===// func.func @iequal_scalar(%arg0: i32, %arg1: i32) -> i1 { - // CHECK: spv.IEqual {{.*}}, {{.*}} : i32 - %0 = spv.IEqual %arg0, %arg1 : i32 + // CHECK: spirv.IEqual {{.*}}, {{.*}} : i32 + %0 = spirv.IEqual %arg0, %arg1 : i32 return %0 : i1 } // ----- func.func @iequal_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { - // CHECK: spv.IEqual {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.IEqual %arg0, %arg1 : vector<4xi32> + // CHECK: spirv.IEqual {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.IEqual %arg0, %arg1 : vector<4xi32> return %0 : vector<4xi1> } // ----- //===----------------------------------------------------------------------===// -// spv.INotEqual +// spirv.INotEqual //===----------------------------------------------------------------------===// func.func @inotequal_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { - // CHECK: spv.INotEqual {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.INotEqual %arg0, %arg1 : vector<4xi32> + // CHECK: spirv.INotEqual {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.INotEqual %arg0, %arg1 : vector<4xi32> return %0 : vector<4xi1> } // ----- //===----------------------------------------------------------------------===// -// spv.IsInf +// spirv.IsInf //===----------------------------------------------------------------------===// func.func @isinf_scalar(%arg0: f32) -> i1 { - // CHECK: spv.IsInf {{.*}} : f32 - %0 = spv.IsInf %arg0 : f32 + // CHECK: spirv.IsInf {{.*}} : f32 + %0 = spirv.IsInf %arg0 : f32 return %0 : i1 } func.func @isinf_vector(%arg0: vector<2xf32>) -> vector<2xi1> { - // CHECK: spv.IsInf {{.*}} : vector<2xf32> - %0 = spv.IsInf %arg0 : vector<2xf32> + // CHECK: spirv.IsInf {{.*}} : vector<2xf32> + %0 = spirv.IsInf %arg0 : vector<2xf32> return %0 : vector<2xi1> } // ----- //===----------------------------------------------------------------------===// -// spv.IsNan +// spirv.IsNan //===----------------------------------------------------------------------===// func.func @isnan_scalar(%arg0: f32) -> i1 { - // CHECK: spv.IsNan {{.*}} : f32 - %0 = spv.IsNan %arg0 : f32 + // CHECK: spirv.IsNan {{.*}} : f32 + %0 = spirv.IsNan %arg0 : f32 return %0 : i1 } func.func @isnan_vector(%arg0: vector<2xf32>) -> vector<2xi1> { - // CHECK: spv.IsNan {{.*}} : vector<2xf32> - %0 = spv.IsNan %arg0 : vector<2xf32> + // CHECK: spirv.IsNan {{.*}} : vector<2xf32> + %0 = spirv.IsNan %arg0 : vector<2xf32> return %0 : vector<2xi1> } //===----------------------------------------------------------------------===// -// spv.LogicalAnd +// spirv.LogicalAnd //===----------------------------------------------------------------------===// func.func @logicalBinary(%arg0 : i1, %arg1 : i1, %arg2 : i1) { - // CHECK: [[TMP:%.*]] = spv.LogicalAnd {{%.*}}, {{%.*}} : i1 - %0 = spv.LogicalAnd %arg0, %arg1 : i1 - // CHECK: {{%.*}} = spv.LogicalAnd [[TMP]], {{%.*}} : i1 - %1 = spv.LogicalAnd %0, %arg2 : i1 + // CHECK: [[TMP:%.*]] = spirv.LogicalAnd {{%.*}}, {{%.*}} : i1 + %0 = spirv.LogicalAnd %arg0, %arg1 : i1 + // CHECK: {{%.*}} = spirv.LogicalAnd [[TMP]], {{%.*}} : i1 + %1 = spirv.LogicalAnd %0, %arg2 : i1 return } func.func @logicalBinary2(%arg0 : vector<4xi1>, %arg1 : vector<4xi1>) { - // CHECK: {{%.*}} = spv.LogicalAnd {{%.*}}, {{%.*}} : vector<4xi1> - %0 = spv.LogicalAnd %arg0, %arg1 : vector<4xi1> + // CHECK: {{%.*}} = spirv.LogicalAnd {{%.*}}, {{%.*}} : vector<4xi1> + %0 = spirv.LogicalAnd %arg0, %arg1 : vector<4xi1> return } @@ -91,7 +91,7 @@ func.func @logicalBinary(%arg0 : i1, %arg1 : i1) { // expected-error @+1 {{expected ':'}} - %0 = spv.LogicalAnd %arg0, %arg1 + %0 = spirv.LogicalAnd %arg0, %arg1 return } @@ -100,7 +100,7 @@ func.func @logicalBinary(%arg0 : i1, %arg1 : i1) { // expected-error @+1 {{expected non-function type}} - %0 = spv.LogicalAnd %arg0, %arg1 : + %0 = spirv.LogicalAnd %arg0, %arg1 : return } @@ -109,29 +109,29 @@ func.func @logicalBinary(%arg0 : i1, %arg1 : i1) { // expected-error @+1 {{expected ','}} - %0 = spv.LogicalAnd %arg0 : i1 + %0 = spirv.LogicalAnd %arg0 : i1 return } // ----- //===----------------------------------------------------------------------===// -// spv.LogicalNot +// spirv.LogicalNot //===----------------------------------------------------------------------===// func.func @logicalUnary(%arg0 : i1, %arg1 : i1) { - // CHECK: [[TMP:%.*]] = spv.LogicalNot {{%.*}} : i1 - %0 = spv.LogicalNot %arg0 : i1 - // CHECK: {{%.*}} = spv.LogicalNot [[TMP]] : i1 - %1 = spv.LogicalNot %0 : i1 + // CHECK: [[TMP:%.*]] = spirv.LogicalNot {{%.*}} : i1 + %0 = spirv.LogicalNot %arg0 : i1 + // CHECK: {{%.*}} = spirv.LogicalNot [[TMP]] : i1 + %1 = spirv.LogicalNot %0 : i1 return } func.func @logicalUnary2(%arg0 : vector<4xi1>) { - // CHECK: {{%.*}} = spv.LogicalNot {{%.*}} : vector<4xi1> - %0 = spv.LogicalNot %arg0 : vector<4xi1> + // CHECK: {{%.*}} = spirv.LogicalNot {{%.*}} : vector<4xi1> + %0 = spirv.LogicalNot %arg0 : vector<4xi1> return } @@ -140,7 +140,7 @@ func.func @logicalUnary(%arg0 : i1) { // expected-error @+1 {{expected ':'}} - %0 = spv.LogicalNot %arg0 + %0 = spirv.LogicalNot %arg0 return } @@ -149,7 +149,7 @@ func.func @logicalUnary(%arg0 : i1) { // expected-error @+1 {{expected non-function type}} - %0 = spv.LogicalNot %arg0 : + %0 = spirv.LogicalNot %arg0 : return } @@ -158,7 +158,7 @@ func.func @logicalUnary(%arg0 : i1) { // expected-error @+1 {{expected SSA operand}} - %0 = spv.LogicalNot : i1 + %0 = spirv.LogicalNot : i1 return } @@ -167,210 +167,210 @@ func.func @logicalUnary(%arg0 : i32) { // expected-error @+1 {{'operand' must be bool or vector of bool values of length 2/3/4/8/16, but got 'i32'}} - %0 = spv.LogicalNot %arg0 : i32 + %0 = spirv.LogicalNot %arg0 : i32 return } // ----- //===----------------------------------------------------------------------===// -// spv.SelectOp +// spirv.SelectOp //===----------------------------------------------------------------------===// func.func @select_op_bool(%arg0: i1) -> () { - %0 = spv.Constant true - %1 = spv.Constant false - // CHECK : spv.Select {{%.*}}, {{%.*}}, {{%.*}} : i1, i1 - %2 = spv.Select %arg0, %0, %1 : i1, i1 + %0 = spirv.Constant true + %1 = spirv.Constant false + // CHECK : spirv.Select {{%.*}}, {{%.*}}, {{%.*}} : i1, i1 + %2 = spirv.Select %arg0, %0, %1 : i1, i1 return } func.func @select_op_int(%arg0: i1) -> () { - %0 = spv.Constant 2 : i32 - %1 = spv.Constant 3 : i32 - // CHECK : spv.Select {{%.*}}, {{%.*}}, {{%.*}} : i1, i32 - %2 = spv.Select %arg0, %0, %1 : i1, i32 + %0 = spirv.Constant 2 : i32 + %1 = spirv.Constant 3 : i32 + // CHECK : spirv.Select {{%.*}}, {{%.*}}, {{%.*}} : i1, i32 + %2 = spirv.Select %arg0, %0, %1 : i1, i32 return } func.func @select_op_float(%arg0: i1) -> () { - %0 = spv.Constant 2.0 : f32 - %1 = spv.Constant 3.0 : f32 - // CHECK : spv.Select {{%.*}}, {{%.*}}, {{%.*}} : i1, f32 - %2 = spv.Select %arg0, %0, %1 : i1, f32 + %0 = spirv.Constant 2.0 : f32 + %1 = spirv.Constant 3.0 : f32 + // CHECK : spirv.Select {{%.*}}, {{%.*}}, {{%.*}} : i1, f32 + %2 = spirv.Select %arg0, %0, %1 : i1, f32 return } func.func @select_op_ptr(%arg0: i1) -> () { - %0 = spv.Variable : !spv.ptr - %1 = spv.Variable : !spv.ptr - // CHECK : spv.Select {{%.*}}, {{%.*}}, {{%.*}} : i1, !spv.ptr - %2 = spv.Select %arg0, %0, %1 : i1, !spv.ptr + %0 = spirv.Variable : !spirv.ptr + %1 = spirv.Variable : !spirv.ptr + // CHECK : spirv.Select {{%.*}}, {{%.*}}, {{%.*}} : i1, !spirv.ptr + %2 = spirv.Select %arg0, %0, %1 : i1, !spirv.ptr return } func.func @select_op_vec(%arg0: i1) -> () { - %0 = spv.Constant dense<[2.0, 3.0, 4.0]> : vector<3xf32> - %1 = spv.Constant dense<[5.0, 6.0, 7.0]> : vector<3xf32> - // CHECK : spv.Select {{%.*}}, {{%.*}}, {{%.*}} : i1, vector<3xf32> - %2 = spv.Select %arg0, %0, %1 : i1, vector<3xf32> + %0 = spirv.Constant dense<[2.0, 3.0, 4.0]> : vector<3xf32> + %1 = spirv.Constant dense<[5.0, 6.0, 7.0]> : vector<3xf32> + // CHECK : spirv.Select {{%.*}}, {{%.*}}, {{%.*}} : i1, vector<3xf32> + %2 = spirv.Select %arg0, %0, %1 : i1, vector<3xf32> return } func.func @select_op_vec_condn_vec(%arg0: vector<3xi1>) -> () { - %0 = spv.Constant dense<[2.0, 3.0, 4.0]> : vector<3xf32> - %1 = spv.Constant dense<[5.0, 6.0, 7.0]> : vector<3xf32> - // CHECK : spv.Select {{%.*}}, {{%.*}}, {{%.*}} : vector<3xi1>, vector<3xf32> - %2 = spv.Select %arg0, %0, %1 : vector<3xi1>, vector<3xf32> + %0 = spirv.Constant dense<[2.0, 3.0, 4.0]> : vector<3xf32> + %1 = spirv.Constant dense<[5.0, 6.0, 7.0]> : vector<3xf32> + // CHECK : spirv.Select {{%.*}}, {{%.*}}, {{%.*}} : vector<3xi1>, vector<3xf32> + %2 = spirv.Select %arg0, %0, %1 : vector<3xi1>, vector<3xf32> return } // ----- func.func @select_op(%arg0: i1) -> () { - %0 = spv.Constant 2 : i32 - %1 = spv.Constant 3 : i32 + %0 = spirv.Constant 2 : i32 + %1 = spirv.Constant 3 : i32 // expected-error @+1 {{expected ','}} - %2 = spv.Select %arg0, %0, %1 : i1 + %2 = spirv.Select %arg0, %0, %1 : i1 return } // ----- func.func @select_op(%arg1: vector<3xi1>) -> () { - %0 = spv.Constant 2 : i32 - %1 = spv.Constant 3 : i32 + %0 = spirv.Constant 2 : i32 + %1 = spirv.Constant 3 : i32 // expected-error @+1 {{result expected to be of vector type when condition is of vector type}} - %2 = spv.Select %arg1, %0, %1 : vector<3xi1>, i32 + %2 = spirv.Select %arg1, %0, %1 : vector<3xi1>, i32 return } // ----- func.func @select_op(%arg1: vector<4xi1>) -> () { - %0 = spv.Constant dense<[2, 3, 4]> : vector<3xi32> - %1 = spv.Constant dense<[5, 6, 7]> : vector<3xi32> + %0 = spirv.Constant dense<[2, 3, 4]> : vector<3xi32> + %1 = spirv.Constant dense<[5, 6, 7]> : vector<3xi32> // expected-error @+1 {{result should have the same number of elements as the condition when condition is of vector type}} - %2 = spv.Select %arg1, %0, %1 : vector<4xi1>, vector<3xi32> + %2 = spirv.Select %arg1, %0, %1 : vector<4xi1>, vector<3xi32> return } // ----- func.func @select_op(%arg1: vector<4xi1>) -> () { - %0 = spv.Constant dense<[2.0, 3.0, 4.0]> : vector<3xf32> - %1 = spv.Constant dense<[5, 6, 7]> : vector<3xi32> + %0 = spirv.Constant dense<[2.0, 3.0, 4.0]> : vector<3xf32> + %1 = spirv.Constant dense<[5, 6, 7]> : vector<3xi32> // expected-error @+1 {{all of {true_value, false_value, result} have same type}} - %2 = "spv.Select"(%arg1, %0, %1) : (vector<4xi1>, vector<3xf32>, vector<3xi32>) -> vector<3xi32> + %2 = "spirv.Select"(%arg1, %0, %1) : (vector<4xi1>, vector<3xf32>, vector<3xi32>) -> vector<3xi32> return } // ----- func.func @select_op(%arg1: vector<4xi1>) -> () { - %0 = spv.Constant dense<[2.0, 3.0, 4.0]> : vector<3xf32> - %1 = spv.Constant dense<[5, 6, 7]> : vector<3xi32> + %0 = spirv.Constant dense<[2.0, 3.0, 4.0]> : vector<3xf32> + %1 = spirv.Constant dense<[5, 6, 7]> : vector<3xi32> // TODO: expand post change in verification order. This is currently only // verifying that the type verification is failing but not the specific error // message. In final state the error should refer to mismatch in true_value and // false_value. // expected-error @+1 {{type}} - %2 = "spv.Select"(%arg1, %1, %0) : (vector<4xi1>, vector<3xi32>, vector<3xf32>) -> vector<3xi32> + %2 = "spirv.Select"(%arg1, %1, %0) : (vector<4xi1>, vector<3xi32>, vector<3xf32>) -> vector<3xi32> return } // ----- //===----------------------------------------------------------------------===// -// spv.SGreaterThan +// spirv.SGreaterThan //===----------------------------------------------------------------------===// func.func @sgt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { - // CHECK: spv.SGreaterThan {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.SGreaterThan %arg0, %arg1 : vector<4xi32> + // CHECK: spirv.SGreaterThan {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.SGreaterThan %arg0, %arg1 : vector<4xi32> return %0 : vector<4xi1> } // ----- //===----------------------------------------------------------------------===// -// spv.SGreaterThanEqual +// spirv.SGreaterThanEqual //===----------------------------------------------------------------------===// func.func @sge_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { - // CHECK: spv.SGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.SGreaterThanEqual %arg0, %arg1 : vector<4xi32> + // CHECK: spirv.SGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.SGreaterThanEqual %arg0, %arg1 : vector<4xi32> return %0 : vector<4xi1> } // ----- //===----------------------------------------------------------------------===// -// spv.SLessThan +// spirv.SLessThan //===----------------------------------------------------------------------===// func.func @slt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { - // CHECK: spv.SLessThan {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.SLessThan %arg0, %arg1 : vector<4xi32> + // CHECK: spirv.SLessThan {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.SLessThan %arg0, %arg1 : vector<4xi32> return %0 : vector<4xi1> } // ----- //===----------------------------------------------------------------------===// -// spv.SLessThanEqual +// spirv.SLessThanEqual //===----------------------------------------------------------------------===// func.func @slte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { - // CHECK: spv.SLessThanEqual {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.SLessThanEqual %arg0, %arg1 : vector<4xi32> + // CHECK: spirv.SLessThanEqual {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.SLessThanEqual %arg0, %arg1 : vector<4xi32> return %0 : vector<4xi1> } // ----- //===----------------------------------------------------------------------===// -// spv.UGreaterThan +// spirv.UGreaterThan //===----------------------------------------------------------------------===// func.func @ugt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { - // CHECK: spv.UGreaterThan {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.UGreaterThan %arg0, %arg1 : vector<4xi32> + // CHECK: spirv.UGreaterThan {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.UGreaterThan %arg0, %arg1 : vector<4xi32> return %0 : vector<4xi1> } // ----- //===----------------------------------------------------------------------===// -// spv.UGreaterThanEqual +// spirv.UGreaterThanEqual //===----------------------------------------------------------------------===// func.func @ugte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { - // CHECK: spv.UGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.UGreaterThanEqual %arg0, %arg1 : vector<4xi32> + // CHECK: spirv.UGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.UGreaterThanEqual %arg0, %arg1 : vector<4xi32> return %0 : vector<4xi1> } // ----- //===----------------------------------------------------------------------===// -// spv.ULessThan +// spirv.ULessThan //===----------------------------------------------------------------------===// func.func @ult_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { - // CHECK: spv.ULessThan {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.ULessThan %arg0, %arg1 : vector<4xi32> + // CHECK: spirv.ULessThan {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.ULessThan %arg0, %arg1 : vector<4xi32> return %0 : vector<4xi1> } // ----- //===----------------------------------------------------------------------===// -// spv.ULessThanEqual +// spirv.ULessThanEqual //===----------------------------------------------------------------------===// func.func @ulte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) -> vector<4xi1> { - // CHECK: spv.ULessThanEqual {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.ULessThanEqual %arg0, %arg1 : vector<4xi32> + // CHECK: spirv.ULessThanEqual {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.ULessThanEqual %arg0, %arg1 : vector<4xi32> return %0 : vector<4xi1> } diff --git a/mlir/test/Dialect/SPIRV/IR/matrix-ops.mlir b/mlir/test/Dialect/SPIRV/IR/matrix-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/matrix-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/matrix-ops.mlir @@ -1,126 +1,126 @@ // RUN: mlir-opt -allow-unregistered-dialect -split-input-file -verify-diagnostics %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK-LABEL: @matrix_times_scalar - spv.func @matrix_times_scalar(%arg0 : !spv.matrix<3 x vector<3xf32>>, %arg1 : f32) -> !spv.matrix<3 x vector<3xf32>> "None" { - // CHECK: {{%.*}} = spv.MatrixTimesScalar {{%.*}}, {{%.*}} : !spv.matrix<3 x vector<3xf32>>, f32 -> !spv.matrix<3 x vector<3xf32>> - %result = spv.MatrixTimesScalar %arg0, %arg1 : !spv.matrix<3 x vector<3xf32>>, f32 -> !spv.matrix<3 x vector<3xf32>> - spv.ReturnValue %result : !spv.matrix<3 x vector<3xf32>> + spirv.func @matrix_times_scalar(%arg0 : !spirv.matrix<3 x vector<3xf32>>, %arg1 : f32) -> !spirv.matrix<3 x vector<3xf32>> "None" { + // CHECK: {{%.*}} = spirv.MatrixTimesScalar {{%.*}}, {{%.*}} : !spirv.matrix<3 x vector<3xf32>>, f32 -> !spirv.matrix<3 x vector<3xf32>> + %result = spirv.MatrixTimesScalar %arg0, %arg1 : !spirv.matrix<3 x vector<3xf32>>, f32 -> !spirv.matrix<3 x vector<3xf32>> + spirv.ReturnValue %result : !spirv.matrix<3 x vector<3xf32>> } // CHECK-LABEL: @matrix_transpose_1 - spv.func @matrix_transpose_1(%arg0 : !spv.matrix<3 x vector<2xf32>>) -> !spv.matrix<2 x vector<3xf32>> "None" { - // CHECK: {{%.*}} = spv.Transpose {{%.*}} : !spv.matrix<3 x vector<2xf32>> -> !spv.matrix<2 x vector<3xf32>> - %result = spv.Transpose %arg0 : !spv.matrix<3 x vector<2xf32>> -> !spv.matrix<2 x vector<3xf32>> - spv.ReturnValue %result : !spv.matrix<2 x vector<3xf32>> + spirv.func @matrix_transpose_1(%arg0 : !spirv.matrix<3 x vector<2xf32>>) -> !spirv.matrix<2 x vector<3xf32>> "None" { + // CHECK: {{%.*}} = spirv.Transpose {{%.*}} : !spirv.matrix<3 x vector<2xf32>> -> !spirv.matrix<2 x vector<3xf32>> + %result = spirv.Transpose %arg0 : !spirv.matrix<3 x vector<2xf32>> -> !spirv.matrix<2 x vector<3xf32>> + spirv.ReturnValue %result : !spirv.matrix<2 x vector<3xf32>> } // CHECK-LABEL: @matrix_transpose_2 - spv.func @matrix_transpose_2(%arg0 : !spv.matrix<3 x vector<3xf32>>) -> !spv.matrix<3 x vector<3xf32>> "None" { - // CHECK: {{%.*}} = spv.Transpose {{%.*}} : !spv.matrix<3 x vector<3xf32>> -> !spv.matrix<3 x vector<3xf32>> - %result = spv.Transpose %arg0 : !spv.matrix<3 x vector<3xf32>> -> !spv.matrix<3 x vector<3xf32>> - spv.ReturnValue %result : !spv.matrix<3 x vector<3xf32>> + spirv.func @matrix_transpose_2(%arg0 : !spirv.matrix<3 x vector<3xf32>>) -> !spirv.matrix<3 x vector<3xf32>> "None" { + // CHECK: {{%.*}} = spirv.Transpose {{%.*}} : !spirv.matrix<3 x vector<3xf32>> -> !spirv.matrix<3 x vector<3xf32>> + %result = spirv.Transpose %arg0 : !spirv.matrix<3 x vector<3xf32>> -> !spirv.matrix<3 x vector<3xf32>> + spirv.ReturnValue %result : !spirv.matrix<3 x vector<3xf32>> } // CHECK-LABEL: @matrix_times_matrix_1 - spv.func @matrix_times_matrix_1(%arg0: !spv.matrix<3 x vector<3xf32>>, %arg1: !spv.matrix<3 x vector<3xf32>>) -> !spv.matrix<3 x vector<3xf32>> "None"{ - // CHECK: {{%.*}} = spv.MatrixTimesMatrix {{%.*}}, {{%.*}} : !spv.matrix<3 x vector<3xf32>>, !spv.matrix<3 x vector<3xf32>> -> !spv.matrix<3 x vector<3xf32>> - %result = spv.MatrixTimesMatrix %arg0, %arg1 : !spv.matrix<3 x vector<3xf32>>, !spv.matrix<3 x vector<3xf32>> -> !spv.matrix<3 x vector<3xf32>> - spv.ReturnValue %result : !spv.matrix<3 x vector<3xf32>> + spirv.func @matrix_times_matrix_1(%arg0: !spirv.matrix<3 x vector<3xf32>>, %arg1: !spirv.matrix<3 x vector<3xf32>>) -> !spirv.matrix<3 x vector<3xf32>> "None"{ + // CHECK: {{%.*}} = spirv.MatrixTimesMatrix {{%.*}}, {{%.*}} : !spirv.matrix<3 x vector<3xf32>>, !spirv.matrix<3 x vector<3xf32>> -> !spirv.matrix<3 x vector<3xf32>> + %result = spirv.MatrixTimesMatrix %arg0, %arg1 : !spirv.matrix<3 x vector<3xf32>>, !spirv.matrix<3 x vector<3xf32>> -> !spirv.matrix<3 x vector<3xf32>> + spirv.ReturnValue %result : !spirv.matrix<3 x vector<3xf32>> } // CHECK-LABEL: @matrix_times_matrix_2 - spv.func @matrix_times_matrix_2(%arg0: !spv.matrix<3 x vector<2xf32>>, %arg1: !spv.matrix<2 x vector<3xf32>>) -> !spv.matrix<2 x vector<2xf32>> "None"{ - // CHECK: {{%.*}} = spv.MatrixTimesMatrix {{%.*}}, {{%.*}} : !spv.matrix<3 x vector<2xf32>>, !spv.matrix<2 x vector<3xf32>> -> !spv.matrix<2 x vector<2xf32>> - %result = spv.MatrixTimesMatrix %arg0, %arg1 : !spv.matrix<3 x vector<2xf32>>, !spv.matrix<2 x vector<3xf32>> -> !spv.matrix<2 x vector<2xf32>> - spv.ReturnValue %result : !spv.matrix<2 x vector<2xf32>> + spirv.func @matrix_times_matrix_2(%arg0: !spirv.matrix<3 x vector<2xf32>>, %arg1: !spirv.matrix<2 x vector<3xf32>>) -> !spirv.matrix<2 x vector<2xf32>> "None"{ + // CHECK: {{%.*}} = spirv.MatrixTimesMatrix {{%.*}}, {{%.*}} : !spirv.matrix<3 x vector<2xf32>>, !spirv.matrix<2 x vector<3xf32>> -> !spirv.matrix<2 x vector<2xf32>> + %result = spirv.MatrixTimesMatrix %arg0, %arg1 : !spirv.matrix<3 x vector<2xf32>>, !spirv.matrix<2 x vector<3xf32>> -> !spirv.matrix<2 x vector<2xf32>> + spirv.ReturnValue %result : !spirv.matrix<2 x vector<2xf32>> } } // ----- -func.func @input_type_mismatch(%arg0 : !spv.matrix<3 x vector<3xf32>>, %arg1 : f16) -> () { +func.func @input_type_mismatch(%arg0 : !spirv.matrix<3 x vector<3xf32>>, %arg1 : f16) -> () { // expected-error @+1 {{input matrix components' type and scaling value must have the same type}} - %result = spv.MatrixTimesScalar %arg0, %arg1 : !spv.matrix<3 x vector<3xf32>>, f16 -> !spv.matrix<3 x vector<3xf32>> + %result = spirv.MatrixTimesScalar %arg0, %arg1 : !spirv.matrix<3 x vector<3xf32>>, f16 -> !spirv.matrix<3 x vector<3xf32>> } // ----- -func.func @input_type_mismatch(%arg0 : !spv.matrix<3 x vector<3xf32>>, %arg1 : f64) -> () { +func.func @input_type_mismatch(%arg0 : !spirv.matrix<3 x vector<3xf32>>, %arg1 : f64) -> () { // expected-error @+1 {{input matrix components' type and scaling value must have the same type}} - %result = spv.MatrixTimesScalar %arg0, %arg1 : !spv.matrix<3 x vector<3xf32>>, f64 -> !spv.matrix<3 x vector<3xf32>> + %result = spirv.MatrixTimesScalar %arg0, %arg1 : !spirv.matrix<3 x vector<3xf32>>, f64 -> !spirv.matrix<3 x vector<3xf32>> } // ----- -func.func @input_output_component_type_mismatch(%arg0 : !spv.matrix<3 x vector<3xf32>>, %arg1 : f32) -> () { +func.func @input_output_component_type_mismatch(%arg0 : !spirv.matrix<3 x vector<3xf32>>, %arg1 : f32) -> () { // expected-error @+1 {{input and result matrices' columns must have the same component type}} - %result = spv.MatrixTimesScalar %arg0, %arg1 : !spv.matrix<3 x vector<3xf32>>, f32 -> !spv.matrix<3 x vector<3xf64>> + %result = spirv.MatrixTimesScalar %arg0, %arg1 : !spirv.matrix<3 x vector<3xf32>>, f32 -> !spirv.matrix<3 x vector<3xf64>> } // ----- -func.func @input_output_size_mismatch(%arg0 : !spv.matrix<3 x vector<3xf32>>, %arg1 : f32) -> () { +func.func @input_output_size_mismatch(%arg0 : !spirv.matrix<3 x vector<3xf32>>, %arg1 : f32) -> () { // expected-error @+1 {{input and result matrices must have the same number of columns}} - %result = spv.MatrixTimesScalar %arg0, %arg1 : !spv.matrix<3 x vector<3xf32>>, f32 -> !spv.matrix<4 x vector<3xf32>> + %result = spirv.MatrixTimesScalar %arg0, %arg1 : !spirv.matrix<3 x vector<3xf32>>, f32 -> !spirv.matrix<4 x vector<3xf32>> } // ----- -func.func @transpose_op_shape_mismatch_1(%arg0 : !spv.matrix<3 x vector<4xf32>>) -> () { +func.func @transpose_op_shape_mismatch_1(%arg0 : !spirv.matrix<3 x vector<4xf32>>) -> () { // expected-error @+1 {{input matrix rows count must be equal to output matrix columns count}} - %result = spv.Transpose %arg0 : !spv.matrix<3 x vector<4xf32>> -> !spv.matrix<3 x vector<3xf32>> - spv.Return + %result = spirv.Transpose %arg0 : !spirv.matrix<3 x vector<4xf32>> -> !spirv.matrix<3 x vector<3xf32>> + spirv.Return } // ----- -func.func @transpose_op_shape_mismatch_2(%arg0 : !spv.matrix<3 x vector<4xf32>>) -> () { +func.func @transpose_op_shape_mismatch_2(%arg0 : !spirv.matrix<3 x vector<4xf32>>) -> () { // expected-error @+1 {{input matrix rows count must be equal to output matrix columns count}} - %result = spv.Transpose %arg0 : !spv.matrix<3 x vector<4xf32>> -> !spv.matrix<2 x vector<4xf32>> - spv.Return + %result = spirv.Transpose %arg0 : !spirv.matrix<3 x vector<4xf32>> -> !spirv.matrix<2 x vector<4xf32>> + spirv.Return } // ----- -func.func @transpose_op_type_mismatch(%arg0 : !spv.matrix<3 x vector<4xf32>>) -> () { +func.func @transpose_op_type_mismatch(%arg0 : !spirv.matrix<3 x vector<4xf32>>) -> () { // expected-error @+1 {{input and output matrices must have the same component type}} - %result = spv.Transpose %arg0 : !spv.matrix<3 x vector<4xf32>> -> !spv.matrix<4 x vector<3xf16>> - spv.Return + %result = spirv.Transpose %arg0 : !spirv.matrix<3 x vector<4xf32>> -> !spirv.matrix<4 x vector<3xf16>> + spirv.Return } // ----- -func.func @matrix_times_matrix_invalid_input_shape_1(%arg0 : !spv.matrix<3 x vector<2xf32>>, %arg1 : !spv.matrix<2 x vector<3xf32>>){ +func.func @matrix_times_matrix_invalid_input_shape_1(%arg0 : !spirv.matrix<3 x vector<2xf32>>, %arg1 : !spirv.matrix<2 x vector<3xf32>>){ // expected-error @+1 {{right and result matrices must have equal columns' count}} - %result = spv.MatrixTimesMatrix %arg0, %arg1 : !spv.matrix<3 x vector<2xf32>>, !spv.matrix<2 x vector<3xf32>> -> !spv.matrix<3 x vector<2xf32>> + %result = spirv.MatrixTimesMatrix %arg0, %arg1 : !spirv.matrix<3 x vector<2xf32>>, !spirv.matrix<2 x vector<3xf32>> -> !spirv.matrix<3 x vector<2xf32>> } // ----- -func.func @matrix_times_matrix_invalid_input_shape_2(%arg0 : !spv.matrix<3 x vector<2xf32>>, %arg1 : !spv.matrix<2 x vector<3xf32>>){ +func.func @matrix_times_matrix_invalid_input_shape_2(%arg0 : !spirv.matrix<3 x vector<2xf32>>, %arg1 : !spirv.matrix<2 x vector<3xf32>>){ // expected-error @+1 {{left and result matrices must have equal rows' count}} - %result = spv.MatrixTimesMatrix %arg0, %arg1 : !spv.matrix<3 x vector<2xf32>>, !spv.matrix<2 x vector<3xf32>> -> !spv.matrix<2 x vector<3xf32>> + %result = spirv.MatrixTimesMatrix %arg0, %arg1 : !spirv.matrix<3 x vector<2xf32>>, !spirv.matrix<2 x vector<3xf32>> -> !spirv.matrix<2 x vector<3xf32>> } // ----- -func.func @matrix_times_matrix_inputs_shape_mismatch(%arg0 : !spv.matrix<3 x vector<2xf32>>, %arg1 : !spv.matrix<2 x vector<2xf32>>){ +func.func @matrix_times_matrix_inputs_shape_mismatch(%arg0 : !spirv.matrix<3 x vector<2xf32>>, %arg1 : !spirv.matrix<2 x vector<2xf32>>){ // expected-error @+1 {{left matrix columns' count must be equal to the right matrix rows' count}} - %result = spv.MatrixTimesMatrix %arg0, %arg1 : !spv.matrix<3 x vector<2xf32>>, !spv.matrix<2 x vector<2xf32>> -> !spv.matrix<2 x vector<2xf32>> + %result = spirv.MatrixTimesMatrix %arg0, %arg1 : !spirv.matrix<3 x vector<2xf32>>, !spirv.matrix<2 x vector<2xf32>> -> !spirv.matrix<2 x vector<2xf32>> } // ----- -func.func @matrix_times_matrix_component_type_mismatch_1(%arg0 : !spv.matrix<3 x vector<3xf32>>, %arg1 : !spv.matrix<3x vector<3xf32>>){ +func.func @matrix_times_matrix_component_type_mismatch_1(%arg0 : !spirv.matrix<3 x vector<3xf32>>, %arg1 : !spirv.matrix<3x vector<3xf32>>){ // expected-error @+1 {{right and result matrices' component type must be the same}} - %result = spv.MatrixTimesMatrix %arg0, %arg1 : !spv.matrix<3 x vector<3xf32>>, !spv.matrix<3 x vector<3xf32>> -> !spv.matrix<3 x vector<3xf64>> + %result = spirv.MatrixTimesMatrix %arg0, %arg1 : !spirv.matrix<3 x vector<3xf32>>, !spirv.matrix<3 x vector<3xf32>> -> !spirv.matrix<3 x vector<3xf64>> } // ----- -func.func @matrix_times_matrix_component_type_mismatch_2(%arg0 : !spv.matrix<3 x vector<3xf64>>, %arg1 : !spv.matrix<3x vector<3xf32>>){ +func.func @matrix_times_matrix_component_type_mismatch_2(%arg0 : !spirv.matrix<3 x vector<3xf64>>, %arg1 : !spirv.matrix<3x vector<3xf32>>){ // expected-error @+1 {{left and result matrices' component type must be the same}} - %result = spv.MatrixTimesMatrix %arg0, %arg1 : !spv.matrix<3 x vector<3xf64>>, !spv.matrix<3 x vector<3xf32>> -> !spv.matrix<3 x vector<3xf32>> + %result = spirv.MatrixTimesMatrix %arg0, %arg1 : !spirv.matrix<3 x vector<3xf64>>, !spirv.matrix<3 x vector<3xf32>> -> !spirv.matrix<3 x vector<3xf32>> } diff --git a/mlir/test/Dialect/SPIRV/IR/memory-ops.mlir b/mlir/test/Dialect/SPIRV/IR/memory-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/memory-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/memory-ops.mlir @@ -1,119 +1,119 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.AccessChain +// spirv.AccessChain //===----------------------------------------------------------------------===// func.func @access_chain_struct() -> () { - %0 = spv.Constant 1: i32 - %1 = spv.Variable : !spv.ptr)>, Function> - // CHECK: spv.AccessChain {{.*}}[{{.*}}, {{.*}}] : !spv.ptr)>, Function> - %2 = spv.AccessChain %1[%0, %0] : !spv.ptr)>, Function>, i32, i32 + %0 = spirv.Constant 1: i32 + %1 = spirv.Variable : !spirv.ptr)>, Function> + // CHECK: spirv.AccessChain {{.*}}[{{.*}}, {{.*}}] : !spirv.ptr)>, Function> + %2 = spirv.AccessChain %1[%0, %0] : !spirv.ptr)>, Function>, i32, i32 return } func.func @access_chain_1D_array(%arg0 : i32) -> () { - %0 = spv.Variable : !spv.ptr, Function> - // CHECK: spv.AccessChain {{.*}}[{{.*}}] : !spv.ptr, Function> - %1 = spv.AccessChain %0[%arg0] : !spv.ptr, Function>, i32 + %0 = spirv.Variable : !spirv.ptr, Function> + // CHECK: spirv.AccessChain {{.*}}[{{.*}}] : !spirv.ptr, Function> + %1 = spirv.AccessChain %0[%arg0] : !spirv.ptr, Function>, i32 return } func.func @access_chain_2D_array_1(%arg0 : i32) -> () { - %0 = spv.Variable : !spv.ptr>, Function> - // CHECK: spv.AccessChain {{.*}}[{{.*}}, {{.*}}] : !spv.ptr>, Function> - %1 = spv.AccessChain %0[%arg0, %arg0] : !spv.ptr>, Function>, i32, i32 - %2 = spv.Load "Function" %1 ["Volatile"] : f32 + %0 = spirv.Variable : !spirv.ptr>, Function> + // CHECK: spirv.AccessChain {{.*}}[{{.*}}, {{.*}}] : !spirv.ptr>, Function> + %1 = spirv.AccessChain %0[%arg0, %arg0] : !spirv.ptr>, Function>, i32, i32 + %2 = spirv.Load "Function" %1 ["Volatile"] : f32 return } func.func @access_chain_2D_array_2(%arg0 : i32) -> () { - %0 = spv.Variable : !spv.ptr>, Function> - // CHECK: spv.AccessChain {{.*}}[{{.*}}] : !spv.ptr>, Function> - %1 = spv.AccessChain %0[%arg0] : !spv.ptr>, Function>, i32 - %2 = spv.Load "Function" %1 ["Volatile"] : !spv.array<4xf32> + %0 = spirv.Variable : !spirv.ptr>, Function> + // CHECK: spirv.AccessChain {{.*}}[{{.*}}] : !spirv.ptr>, Function> + %1 = spirv.AccessChain %0[%arg0] : !spirv.ptr>, Function>, i32 + %2 = spirv.Load "Function" %1 ["Volatile"] : !spirv.array<4xf32> return } func.func @access_chain_rtarray(%arg0 : i32) -> () { - %0 = spv.Variable : !spv.ptr, Function> - // CHECK: spv.AccessChain {{.*}}[{{.*}}] : !spv.ptr, Function> - %1 = spv.AccessChain %0[%arg0] : !spv.ptr, Function>, i32 - %2 = spv.Load "Function" %1 ["Volatile"] : f32 + %0 = spirv.Variable : !spirv.ptr, Function> + // CHECK: spirv.AccessChain {{.*}}[{{.*}}] : !spirv.ptr, Function> + %1 = spirv.AccessChain %0[%arg0] : !spirv.ptr, Function>, i32 + %2 = spirv.Load "Function" %1 ["Volatile"] : f32 return } // ----- func.func @access_chain_non_composite() -> () { - %0 = spv.Constant 1: i32 - %1 = spv.Variable : !spv.ptr + %0 = spirv.Constant 1: i32 + %1 = spirv.Variable : !spirv.ptr // expected-error @+1 {{cannot extract from non-composite type 'f32' with index 0}} - %2 = spv.AccessChain %1[%0] : !spv.ptr, i32 + %2 = spirv.AccessChain %1[%0] : !spirv.ptr, i32 return } // ----- func.func @access_chain_no_indices(%index0 : i32) -> () { - %0 = spv.Variable : !spv.ptr>, Function> + %0 = spirv.Variable : !spirv.ptr>, Function> // expected-error @+1 {{expected at least one index}} - %1 = spv.AccessChain %0[] : !spv.ptr>, Function>, i32 + %1 = spirv.AccessChain %0[] : !spirv.ptr>, Function>, i32 return } // ----- func.func @access_chain_missing_comma(%index0 : i32) -> () { - %0 = spv.Variable : !spv.ptr>, Function> + %0 = spirv.Variable : !spirv.ptr>, Function> // expected-error @+1 {{expected ','}} - %1 = spv.AccessChain %0[%index0] : !spv.ptr>, Function> i32 + %1 = spirv.AccessChain %0[%index0] : !spirv.ptr>, Function> i32 return } // ----- func.func @access_chain_invalid_indices_types_count(%index0 : i32) -> () { - %0 = spv.Variable : !spv.ptr>, Function> - // expected-error @+1 {{'spv.AccessChain' op indices types' count must be equal to indices info count}} - %1 = spv.AccessChain %0[%index0] : !spv.ptr>, Function>, i32, i32 + %0 = spirv.Variable : !spirv.ptr>, Function> + // expected-error @+1 {{'spirv.AccessChain' op indices types' count must be equal to indices info count}} + %1 = spirv.AccessChain %0[%index0] : !spirv.ptr>, Function>, i32, i32 return } // ----- func.func @access_chain_missing_indices_type(%index0 : i32) -> () { - %0 = spv.Variable : !spv.ptr>, Function> - // expected-error @+1 {{'spv.AccessChain' op indices types' count must be equal to indices info count}} - %1 = spv.AccessChain %0[%index0, %index0] : !spv.ptr>, Function>, i32 + %0 = spirv.Variable : !spirv.ptr>, Function> + // expected-error @+1 {{'spirv.AccessChain' op indices types' count must be equal to indices info count}} + %1 = spirv.AccessChain %0[%index0, %index0] : !spirv.ptr>, Function>, i32 return } // ----- func.func @access_chain_invalid_type(%index0 : i32) -> () { - %0 = spv.Variable : !spv.ptr>, Function> - %1 = spv.Load "Function" %0 ["Volatile"] : !spv.array<4x!spv.array<4xf32>> - // expected-error @+1 {{expected a pointer to composite type, but provided '!spv.array<4 x !spv.array<4 x f32>>'}} - %2 = spv.AccessChain %1[%index0] : !spv.array<4x!spv.array<4xf32>>, i32 + %0 = spirv.Variable : !spirv.ptr>, Function> + %1 = spirv.Load "Function" %0 ["Volatile"] : !spirv.array<4x!spirv.array<4xf32>> + // expected-error @+1 {{expected a pointer to composite type, but provided '!spirv.array<4 x !spirv.array<4 x f32>>'}} + %2 = spirv.AccessChain %1[%index0] : !spirv.array<4x!spirv.array<4xf32>>, i32 return } // ----- func.func @access_chain_invalid_index_1(%index0 : i32) -> () { - %0 = spv.Variable : !spv.ptr>, Function> + %0 = spirv.Variable : !spirv.ptr>, Function> // expected-error @+1 {{expected SSA operand}} - %1 = spv.AccessChain %0[%index, 4] : !spv.ptr>, Function>, i32, i32 + %1 = spirv.AccessChain %0[%index, 4] : !spirv.ptr>, Function>, i32, i32 return } // ----- func.func @access_chain_invalid_index_2(%index0 : i32) -> () { - %0 = spv.Variable : !spv.ptr)>, Function> - // expected-error @+1 {{index must be an integer spv.Constant to access element of spv.struct}} - %1 = spv.AccessChain %0[%index0, %index0] : !spv.ptr)>, Function>, i32, i32 + %0 = spirv.Variable : !spirv.ptr)>, Function> + // expected-error @+1 {{index must be an integer spirv.Constant to access element of spirv.struct}} + %1 = spirv.AccessChain %0[%index0, %index0] : !spirv.ptr)>, Function>, i32, i32 return } @@ -121,73 +121,73 @@ func.func @access_chain_invalid_constant_type_1() -> () { %0 = arith.constant 1: i32 - %1 = spv.Variable : !spv.ptr)>, Function> - // expected-error @+1 {{index must be an integer spv.Constant to access element of spv.struct, but provided arith.constant}} - %2 = spv.AccessChain %1[%0, %0] : !spv.ptr)>, Function>, i32, i32 + %1 = spirv.Variable : !spirv.ptr)>, Function> + // expected-error @+1 {{index must be an integer spirv.Constant to access element of spirv.struct, but provided arith.constant}} + %2 = spirv.AccessChain %1[%0, %0] : !spirv.ptr)>, Function>, i32, i32 return } // ----- func.func @access_chain_out_of_bounds() -> () { - %index0 = "spv.Constant"() { value = 12: i32} : () -> i32 - %0 = spv.Variable : !spv.ptr)>, Function> - // expected-error @+1 {{'spv.AccessChain' op index 12 out of bounds for '!spv.struct<(f32, !spv.array<4 x f32>)>'}} - %1 = spv.AccessChain %0[%index0, %index0] : !spv.ptr)>, Function>, i32, i32 + %index0 = "spirv.Constant"() { value = 12: i32} : () -> i32 + %0 = spirv.Variable : !spirv.ptr)>, Function> + // expected-error @+1 {{'spirv.AccessChain' op index 12 out of bounds for '!spirv.struct<(f32, !spirv.array<4 x f32>)>'}} + %1 = spirv.AccessChain %0[%index0, %index0] : !spirv.ptr)>, Function>, i32, i32 return } // ----- func.func @access_chain_invalid_accessing_type(%index0 : i32) -> () { - %0 = spv.Variable : !spv.ptr>, Function> + %0 = spirv.Variable : !spirv.ptr>, Function> // expected-error @+1 {{cannot extract from non-composite type 'f32' with index 0}} - %1 = spv.AccessChain %0[%index, %index0, %index0] : !spv.ptr>, Function>, i32, i32, i32 + %1 = spirv.AccessChain %0[%index, %index0, %index0] : !spirv.ptr>, Function>, i32, i32, i32 return // ----- //===----------------------------------------------------------------------===// -// spv.LoadOp +// spirv.LoadOp //===----------------------------------------------------------------------===// // CHECK-LABEL: @simple_load func.func @simple_load() -> () { - %0 = spv.Variable : !spv.ptr - // CHECK: spv.Load "Function" %{{.*}} : f32 - %1 = spv.Load "Function" %0 : f32 + %0 = spirv.Variable : !spirv.ptr + // CHECK: spirv.Load "Function" %{{.*}} : f32 + %1 = spirv.Load "Function" %0 : f32 return } // CHECK-LABEL: @load_none_access func.func @load_none_access() -> () { - %0 = spv.Variable : !spv.ptr - // CHECK: spv.Load "Function" %{{.*}} ["None"] : f32 - %1 = spv.Load "Function" %0 ["None"] : f32 + %0 = spirv.Variable : !spirv.ptr + // CHECK: spirv.Load "Function" %{{.*}} ["None"] : f32 + %1 = spirv.Load "Function" %0 ["None"] : f32 return } // CHECK-LABEL: @volatile_load func.func @volatile_load() -> () { - %0 = spv.Variable : !spv.ptr - // CHECK: spv.Load "Function" %{{.*}} ["Volatile"] : f32 - %1 = spv.Load "Function" %0 ["Volatile"] : f32 + %0 = spirv.Variable : !spirv.ptr + // CHECK: spirv.Load "Function" %{{.*}} ["Volatile"] : f32 + %1 = spirv.Load "Function" %0 ["Volatile"] : f32 return } // CHECK-LABEL: @aligned_load func.func @aligned_load() -> () { - %0 = spv.Variable : !spv.ptr - // CHECK: spv.Load "Function" %{{.*}} ["Aligned", 4] : f32 - %1 = spv.Load "Function" %0 ["Aligned", 4] : f32 + %0 = spirv.Variable : !spirv.ptr + // CHECK: spirv.Load "Function" %{{.*}} ["Aligned", 4] : f32 + %1 = spirv.Load "Function" %0 ["Aligned", 4] : f32 return } // CHECK-LABEL: @volatile_aligned_load func.func @volatile_aligned_load() -> () { - %0 = spv.Variable : !spv.ptr - // CHECK: spv.Load "Function" %{{.*}} ["Volatile|Aligned", 4] : f32 - %1 = spv.Load "Function" %0 ["Volatile|Aligned", 4] : f32 + %0 = spirv.Variable : !spirv.ptr + // CHECK: spirv.Load "Function" %{{.*}} ["Volatile|Aligned", 4] : f32 + %1 = spirv.Load "Function" %0 ["Volatile|Aligned", 4] : f32 return } @@ -195,470 +195,470 @@ // CHECK-LABEL: load_none_access func.func @load_none_access() -> () { - %0 = spv.Variable : !spv.ptr - // CHECK: spv.Load + %0 = spirv.Variable : !spirv.ptr + // CHECK: spirv.Load // CHECK-SAME: ["None"] - %1 = "spv.Load"(%0) {memory_access = #spv.memory_access} : (!spv.ptr) -> (f32) + %1 = "spirv.Load"(%0) {memory_access = #spirv.memory_access} : (!spirv.ptr) -> (f32) return } // CHECK-LABEL: volatile_load func.func @volatile_load() -> () { - %0 = spv.Variable : !spv.ptr - // CHECK: spv.Load + %0 = spirv.Variable : !spirv.ptr + // CHECK: spirv.Load // CHECK-SAME: ["Volatile"] - %1 = "spv.Load"(%0) {memory_access = #spv.memory_access} : (!spv.ptr) -> (f32) + %1 = "spirv.Load"(%0) {memory_access = #spirv.memory_access} : (!spirv.ptr) -> (f32) return } // CHECK-LABEL: aligned_load func.func @aligned_load() -> () { - %0 = spv.Variable : !spv.ptr - // CHECK: spv.Load + %0 = spirv.Variable : !spirv.ptr + // CHECK: spirv.Load // CHECK-SAME: ["Aligned", 4] - %1 = "spv.Load"(%0) {memory_access = #spv.memory_access, alignment = 4 : i32} : (!spv.ptr) -> (f32) + %1 = "spirv.Load"(%0) {memory_access = #spirv.memory_access, alignment = 4 : i32} : (!spirv.ptr) -> (f32) return } // CHECK-LABEL: volatile_aligned_load func.func @volatile_aligned_load() -> () { - %0 = spv.Variable : !spv.ptr - // CHECK: spv.Load + %0 = spirv.Variable : !spirv.ptr + // CHECK: spirv.Load // CHECK-SAME: ["Volatile|Aligned", 4] - %1 = "spv.Load"(%0) {memory_access = #spv.memory_access, alignment = 4 : i32} : (!spv.ptr) -> (f32) + %1 = "spirv.Load"(%0) {memory_access = #spirv.memory_access, alignment = 4 : i32} : (!spirv.ptr) -> (f32) return } // ----- func.func @simple_load_missing_storageclass() -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected attribute value}} - %1 = spv.Load %0 : f32 + %1 = spirv.Load %0 : f32 return } // ----- func.func @simple_load_missing_operand() -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected SSA operand}} - %1 = spv.Load "Function" : f32 + %1 = spirv.Load "Function" : f32 return } // ----- func.func @simple_load_missing_rettype() -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected ':'}} - %1 = spv.Load "Function" %0 + %1 = spirv.Load "Function" %0 return } // ----- func.func @volatile_load_missing_lbrace() -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected ':'}} - %1 = spv.Load "Function" %0 "Volatile"] : f32 + %1 = spirv.Load "Function" %0 "Volatile"] : f32 return } // ----- func.func @volatile_load_missing_rbrace() -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected ']'}} - %1 = spv.Load "Function" %0 ["Volatile"} : f32 + %1 = spirv.Load "Function" %0 ["Volatile"} : f32 return } // ----- func.func @aligned_load_missing_alignment() -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected ','}} - %1 = spv.Load "Function" %0 ["Aligned"] : f32 + %1 = spirv.Load "Function" %0 ["Aligned"] : f32 return } // ----- func.func @aligned_load_missing_comma() -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected ','}} - %1 = spv.Load "Function" %0 ["Aligned" 4] : f32 + %1 = spirv.Load "Function" %0 ["Aligned" 4] : f32 return } // ----- func.func @load_incorrect_attributes() -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected ']'}} - %1 = spv.Load "Function" %0 ["Volatile", 4] : f32 + %1 = spirv.Load "Function" %0 ["Volatile", 4] : f32 return } // ----- func.func @load_unknown_memory_access() -> () { - %0 = spv.Variable : !spv.ptr - // expected-error @+1 {{custom op 'spv.Load' invalid memory_access attribute specification: "Something"}} - %1 = spv.Load "Function" %0 ["Something"] : f32 + %0 = spirv.Variable : !spirv.ptr + // expected-error @+1 {{custom op 'spirv.Load' invalid memory_access attribute specification: "Something"}} + %1 = spirv.Load "Function" %0 ["Something"] : f32 return } // ----- func.func @load_unknown_memory_access() -> () { - %0 = spv.Variable : !spv.ptr - // expected-error @+1 {{custom op 'spv.Load' invalid memory_access attribute specification: "Volatile|Something"}} - %1 = spv.Load "Function" %0 ["Volatile|Something"] : f32 + %0 = spirv.Variable : !spirv.ptr + // expected-error @+1 {{custom op 'spirv.Load' invalid memory_access attribute specification: "Volatile|Something"}} + %1 = spirv.Load "Function" %0 ["Volatile|Something"] : f32 return } // ----- func.func @load_unknown_memory_access() -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{failed to satisfy constraint: valid SPIR-V MemoryAccess}} - %1 = "spv.Load"(%0) {memory_access = 0x80000000 : i32} : (!spv.ptr) -> (f32) + %1 = "spirv.Load"(%0) {memory_access = 0x80000000 : i32} : (!spirv.ptr) -> (f32) return } // ----- func.func @aligned_load_incorrect_attributes() -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected ']'}} - %1 = spv.Load "Function" %0 ["Aligned", 4, 23] : f32 + %1 = spirv.Load "Function" %0 ["Aligned", 4, 23] : f32 return } // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var0 : !spv.ptr - spv.GlobalVariable @var1 : !spv.ptr>, UniformConstant> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var0 : !spirv.ptr + spirv.GlobalVariable @var1 : !spirv.ptr>, UniformConstant> // CHECK-LABEL: @simple_load - spv.func @simple_load() -> () "None" { - // CHECK: spv.Load "Input" {{%.*}} : f32 - %0 = spv.mlir.addressof @var0 : !spv.ptr - %1 = spv.Load "Input" %0 : f32 - %2 = spv.mlir.addressof @var1 : !spv.ptr>, UniformConstant> - // CHECK: spv.Load "UniformConstant" {{%.*}} : !spv.sampled_image - %3 = spv.Load "UniformConstant" %2 : !spv.sampled_image> - spv.Return + spirv.func @simple_load() -> () "None" { + // CHECK: spirv.Load "Input" {{%.*}} : f32 + %0 = spirv.mlir.addressof @var0 : !spirv.ptr + %1 = spirv.Load "Input" %0 : f32 + %2 = spirv.mlir.addressof @var1 : !spirv.ptr>, UniformConstant> + // CHECK: spirv.Load "UniformConstant" {{%.*}} : !spirv.sampled_image + %3 = spirv.Load "UniformConstant" %2 : !spirv.sampled_image> + spirv.Return } } // ----- //===----------------------------------------------------------------------===// -// spv.StoreOp +// spirv.StoreOp //===----------------------------------------------------------------------===// func.func @simple_store(%arg0 : f32) -> () { - %0 = spv.Variable : !spv.ptr - // CHECK: spv.Store "Function" %0, %arg0 : f32 - spv.Store "Function" %0, %arg0 : f32 + %0 = spirv.Variable : !spirv.ptr + // CHECK: spirv.Store "Function" %0, %arg0 : f32 + spirv.Store "Function" %0, %arg0 : f32 return } // CHECK-LABEL: @volatile_store func.func @volatile_store(%arg0 : f32) -> () { - %0 = spv.Variable : !spv.ptr - // CHECK: spv.Store "Function" %0, %arg0 ["Volatile"] : f32 - spv.Store "Function" %0, %arg0 ["Volatile"] : f32 + %0 = spirv.Variable : !spirv.ptr + // CHECK: spirv.Store "Function" %0, %arg0 ["Volatile"] : f32 + spirv.Store "Function" %0, %arg0 ["Volatile"] : f32 return } // CHECK-LABEL: @aligned_store func.func @aligned_store(%arg0 : f32) -> () { - %0 = spv.Variable : !spv.ptr - // CHECK: spv.Store "Function" %0, %arg0 ["Aligned", 4] : f32 - spv.Store "Function" %0, %arg0 ["Aligned", 4] : f32 + %0 = spirv.Variable : !spirv.ptr + // CHECK: spirv.Store "Function" %0, %arg0 ["Aligned", 4] : f32 + spirv.Store "Function" %0, %arg0 ["Aligned", 4] : f32 return } // ----- func.func @simple_store_missing_ptr_type(%arg0 : f32) -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected attribute value}} - spv.Store %0, %arg0 : f32 + spirv.Store %0, %arg0 : f32 return } // ----- func.func @simple_store_missing_operand(%arg0 : f32) -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected operand}} - spv.Store "Function" , %arg0 : f32 + spirv.Store "Function" , %arg0 : f32 return } // ----- func.func @simple_store_missing_operand(%arg0 : f32) -> () { - %0 = spv.Variable : !spv.ptr - // expected-error @+1 {{custom op 'spv.Store' expected 2 operands}} - spv.Store "Function" %0 : f32 + %0 = spirv.Variable : !spirv.ptr + // expected-error @+1 {{custom op 'spirv.Store' expected 2 operands}} + spirv.Store "Function" %0 : f32 return } // ----- func.func @volatile_store_missing_lbrace(%arg0 : f32) -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected ':'}} - spv.Store "Function" %0, %arg0 "Volatile"] : f32 + spirv.Store "Function" %0, %arg0 "Volatile"] : f32 return } // ----- func.func @volatile_store_missing_rbrace(%arg0 : f32) -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected ']'}} - spv.Store "Function" %0, %arg0 ["Volatile"} : f32 + spirv.Store "Function" %0, %arg0 ["Volatile"} : f32 return } // ----- func.func @aligned_store_missing_alignment(%arg0 : f32) -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected ','}} - spv.Store "Function" %0, %arg0 ["Aligned"] : f32 + spirv.Store "Function" %0, %arg0 ["Aligned"] : f32 return } // ----- func.func @aligned_store_missing_comma(%arg0 : f32) -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected ','}} - spv.Store "Function" %0, %arg0 ["Aligned" 4] : f32 + spirv.Store "Function" %0, %arg0 ["Aligned" 4] : f32 return } // ----- func.func @load_incorrect_attributes(%arg0 : f32) -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected ']'}} - spv.Store "Function" %0, %arg0 ["Volatile", 4] : f32 + spirv.Store "Function" %0, %arg0 ["Volatile", 4] : f32 return } // ----- func.func @aligned_store_incorrect_attributes(%arg0 : f32) -> () { - %0 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{expected ']'}} - spv.Store "Function" %0, %arg0 ["Aligned", 4, 23] : f32 + spirv.Store "Function" %0, %arg0 ["Aligned", 4, 23] : f32 return } // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var0 : !spv.ptr - spv.func @simple_store(%arg0 : f32) -> () "None" { - %0 = spv.mlir.addressof @var0 : !spv.ptr - // CHECK: spv.Store "Input" {{%.*}}, {{%.*}} : f32 - spv.Store "Input" %0, %arg0 : f32 - spv.Return +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var0 : !spirv.ptr + spirv.func @simple_store(%arg0 : f32) -> () "None" { + %0 = spirv.mlir.addressof @var0 : !spirv.ptr + // CHECK: spirv.Store "Input" {{%.*}}, {{%.*}} : f32 + spirv.Store "Input" %0, %arg0 : f32 + spirv.Return } } // ----- //===----------------------------------------------------------------------===// -// spv.Variable +// spirv.Variable //===----------------------------------------------------------------------===// func.func @variable(%arg0: f32) -> () { - // CHECK: spv.Variable : !spv.ptr - %0 = spv.Variable : !spv.ptr + // CHECK: spirv.Variable : !spirv.ptr + %0 = spirv.Variable : !spirv.ptr return } // ----- func.func @variable_init_normal_constant() -> () { - // CHECK: %[[cst:.*]] = spv.Constant - %0 = spv.Constant 4.0 : f32 - // CHECK: spv.Variable init(%[[cst]]) : !spv.ptr - %1 = spv.Variable init(%0) : !spv.ptr + // CHECK: %[[cst:.*]] = spirv.Constant + %0 = spirv.Constant 4.0 : f32 + // CHECK: spirv.Variable init(%[[cst]]) : !spirv.ptr + %1 = spirv.Variable init(%0) : !spirv.ptr return } // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @global : !spv.ptr - spv.func @variable_init_global_variable() -> () "None" { - %0 = spv.mlir.addressof @global : !spv.ptr - // CHECK: spv.Variable init({{.*}}) : !spv.ptr, Function> - %1 = spv.Variable init(%0) : !spv.ptr, Function> - spv.Return +spirv.module Logical GLSL450 { + spirv.GlobalVariable @global : !spirv.ptr + spirv.func @variable_init_global_variable() -> () "None" { + %0 = spirv.mlir.addressof @global : !spirv.ptr + // CHECK: spirv.Variable init({{.*}}) : !spirv.ptr, Function> + %1 = spirv.Variable init(%0) : !spirv.ptr, Function> + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc = 42 : i32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc = 42 : i32 // CHECK-LABEL: @variable_init_spec_constant - spv.func @variable_init_spec_constant() -> () "None" { - %0 = spv.mlir.referenceof @sc : i32 - // CHECK: spv.Variable init(%0) : !spv.ptr - %1 = spv.Variable init(%0) : !spv.ptr - spv.Return + spirv.func @variable_init_spec_constant() -> () "None" { + %0 = spirv.mlir.referenceof @sc : i32 + // CHECK: spirv.Variable init(%0) : !spirv.ptr + %1 = spirv.Variable init(%0) : !spirv.ptr + spirv.Return } } // ----- func.func @variable_bind() -> () { - // expected-error @+1 {{cannot have 'descriptor_set' attribute (only allowed in spv.GlobalVariable)}} - %0 = spv.Variable bind(1, 2) : !spv.ptr + // expected-error @+1 {{cannot have 'descriptor_set' attribute (only allowed in spirv.GlobalVariable)}} + %0 = spirv.Variable bind(1, 2) : !spirv.ptr return } // ----- func.func @variable_init_bind() -> () { - %0 = spv.Constant 4.0 : f32 - // expected-error @+1 {{cannot have 'binding' attribute (only allowed in spv.GlobalVariable)}} - %1 = spv.Variable init(%0) {binding = 5 : i32} : !spv.ptr + %0 = spirv.Constant 4.0 : f32 + // expected-error @+1 {{cannot have 'binding' attribute (only allowed in spirv.GlobalVariable)}} + %1 = spirv.Variable init(%0) {binding = 5 : i32} : !spirv.ptr return } // ----- func.func @variable_builtin() -> () { - // expected-error @+1 {{cannot have 'built_in' attribute (only allowed in spv.GlobalVariable)}} - %1 = spv.Variable built_in("GlobalInvocationID") : !spv.ptr, Function> + // expected-error @+1 {{cannot have 'built_in' attribute (only allowed in spirv.GlobalVariable)}} + %1 = spirv.Variable built_in("GlobalInvocationID") : !spirv.ptr, Function> return } // ----- func.func @expect_ptr_result_type(%arg0: f32) -> () { - // expected-error @+1 {{expected spv.ptr type}} - %0 = spv.Variable : f32 + // expected-error @+1 {{expected spirv.ptr type}} + %0 = spirv.Variable : f32 return } // ----- func.func @variable_init(%arg0: f32) -> () { - // expected-error @+1 {{op initializer must be the result of a constant or spv.GlobalVariable op}} - %0 = spv.Variable init(%arg0) : !spv.ptr + // expected-error @+1 {{op initializer must be the result of a constant or spirv.GlobalVariable op}} + %0 = spirv.Variable init(%arg0) : !spirv.ptr return } // ----- func.func @cannot_be_generic_storage_class(%arg0: f32) -> () { - // expected-error @+1 {{op can only be used to model function-level variables. Use spv.GlobalVariable for module-level variables}} - %0 = spv.Variable : !spv.ptr + // expected-error @+1 {{op can only be used to model function-level variables. Use spirv.GlobalVariable for module-level variables}} + %0 = spirv.Variable : !spirv.ptr return } // ----- func.func @copy_memory_incompatible_ptrs() { - %0 = spv.Variable : !spv.ptr - %1 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr + %1 = spirv.Variable : !spirv.ptr // expected-error @+1 {{both operands must be pointers to the same type}} - "spv.CopyMemory"(%0, %1) {} : (!spv.ptr, !spv.ptr) -> () - spv.Return + "spirv.CopyMemory"(%0, %1) {} : (!spirv.ptr, !spirv.ptr) -> () + spirv.Return } // ----- func.func @copy_memory_invalid_maa() { - %0 = spv.Variable : !spv.ptr - %1 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr + %1 = spirv.Variable : !spirv.ptr // expected-error @+1 {{missing alignment value}} - "spv.CopyMemory"(%0, %1) {memory_access=#spv.memory_access} : (!spv.ptr, !spv.ptr) -> () - spv.Return + "spirv.CopyMemory"(%0, %1) {memory_access=#spirv.memory_access} : (!spirv.ptr, !spirv.ptr) -> () + spirv.Return } // ----- func.func @copy_memory_invalid_source_maa() { - %0 = spv.Variable : !spv.ptr - %1 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr + %1 = spirv.Variable : !spirv.ptr // expected-error @+1 {{invalid alignment specification with non-aligned memory access specification}} - "spv.CopyMemory"(%0, %1) {source_memory_access=#spv.memory_access, memory_access=#spv.memory_access, source_alignment=8 : i32, alignment=4 : i32} : (!spv.ptr, !spv.ptr) -> () - spv.Return + "spirv.CopyMemory"(%0, %1) {source_memory_access=#spirv.memory_access, memory_access=#spirv.memory_access, source_alignment=8 : i32, alignment=4 : i32} : (!spirv.ptr, !spirv.ptr) -> () + spirv.Return } // ----- func.func @copy_memory_invalid_source_maa2() { - %0 = spv.Variable : !spv.ptr - %1 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr + %1 = spirv.Variable : !spirv.ptr // expected-error @+1 {{missing alignment value}} - "spv.CopyMemory"(%0, %1) {source_memory_access=#spv.memory_access, memory_access=#spv.memory_access, alignment=4 : i32} : (!spv.ptr, !spv.ptr) -> () - spv.Return + "spirv.CopyMemory"(%0, %1) {source_memory_access=#spirv.memory_access, memory_access=#spirv.memory_access, alignment=4 : i32} : (!spirv.ptr, !spirv.ptr) -> () + spirv.Return } // ----- func.func @copy_memory_print_maa() { - %0 = spv.Variable : !spv.ptr - %1 = spv.Variable : !spv.ptr + %0 = spirv.Variable : !spirv.ptr + %1 = spirv.Variable : !spirv.ptr - // CHECK: spv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Volatile"] : f32 - "spv.CopyMemory"(%0, %1) {memory_access=#spv.memory_access} : (!spv.ptr, !spv.ptr) -> () + // CHECK: spirv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Volatile"] : f32 + "spirv.CopyMemory"(%0, %1) {memory_access=#spirv.memory_access} : (!spirv.ptr, !spirv.ptr) -> () - // CHECK: spv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Aligned", 4] : f32 - "spv.CopyMemory"(%0, %1) {memory_access=#spv.memory_access, alignment=4 : i32} : (!spv.ptr, !spv.ptr) -> () + // CHECK: spirv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Aligned", 4] : f32 + "spirv.CopyMemory"(%0, %1) {memory_access=#spirv.memory_access, alignment=4 : i32} : (!spirv.ptr, !spirv.ptr) -> () - // CHECK: spv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Aligned", 4], ["Volatile"] : f32 - "spv.CopyMemory"(%0, %1) {source_memory_access=#spv.memory_access, memory_access=#spv.memory_access, alignment=4 : i32} : (!spv.ptr, !spv.ptr) -> () + // CHECK: spirv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Aligned", 4], ["Volatile"] : f32 + "spirv.CopyMemory"(%0, %1) {source_memory_access=#spirv.memory_access, memory_access=#spirv.memory_access, alignment=4 : i32} : (!spirv.ptr, !spirv.ptr) -> () - // CHECK: spv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Aligned", 4], ["Aligned", 8] : f32 - "spv.CopyMemory"(%0, %1) {source_memory_access=#spv.memory_access, memory_access=#spv.memory_access, source_alignment=8 : i32, alignment=4 : i32} : (!spv.ptr, !spv.ptr) -> () + // CHECK: spirv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Aligned", 4], ["Aligned", 8] : f32 + "spirv.CopyMemory"(%0, %1) {source_memory_access=#spirv.memory_access, memory_access=#spirv.memory_access, source_alignment=8 : i32, alignment=4 : i32} : (!spirv.ptr, !spirv.ptr) -> () - spv.Return + spirv.Return } // ----- //===----------------------------------------------------------------------===// -// spv.PtrAccessChain +// spirv.PtrAccessChain //===----------------------------------------------------------------------===// // CHECK-LABEL: func @ptr_access_chain1( -// CHECK-SAME: %[[ARG0:.*]]: !spv.ptr, +// CHECK-SAME: %[[ARG0:.*]]: !spirv.ptr, // CHECK-SAME: %[[ARG1:.*]]: i64) -// CHECK: spv.PtrAccessChain %[[ARG0]][%[[ARG1]]] : !spv.ptr, i64 -func.func @ptr_access_chain1(%arg0: !spv.ptr, %arg1 : i64) -> () { - %0 = spv.PtrAccessChain %arg0[%arg1] : !spv.ptr, i64 +// CHECK: spirv.PtrAccessChain %[[ARG0]][%[[ARG1]]] : !spirv.ptr, i64 +func.func @ptr_access_chain1(%arg0: !spirv.ptr, %arg1 : i64) -> () { + %0 = spirv.PtrAccessChain %arg0[%arg1] : !spirv.ptr, i64 return } // ----- //===----------------------------------------------------------------------===// -// spv.InBoundsPtrAccessChain +// spirv.InBoundsPtrAccessChain //===----------------------------------------------------------------------===// // CHECK-LABEL: func @inbounds_ptr_access_chain1( -// CHECK-SAME: %[[ARG0:.*]]: !spv.ptr, +// CHECK-SAME: %[[ARG0:.*]]: !spirv.ptr, // CHECK-SAME: %[[ARG1:.*]]: i64) -// CHECK: spv.InBoundsPtrAccessChain %[[ARG0]][%[[ARG1]]] : !spv.ptr, i64 -func.func @inbounds_ptr_access_chain1(%arg0: !spv.ptr, %arg1 : i64) -> () { - %0 = spv.InBoundsPtrAccessChain %arg0[%arg1] : !spv.ptr, i64 +// CHECK: spirv.InBoundsPtrAccessChain %[[ARG0]][%[[ARG1]]] : !spirv.ptr, i64 +func.func @inbounds_ptr_access_chain1(%arg0: !spirv.ptr, %arg1 : i64) -> () { + %0 = spirv.InBoundsPtrAccessChain %arg0[%arg1] : !spirv.ptr, i64 return } diff --git a/mlir/test/Dialect/SPIRV/IR/misc-ops.mlir b/mlir/test/Dialect/SPIRV/IR/misc-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/misc-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/misc-ops.mlir @@ -1,39 +1,39 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.Undef +// spirv.Undef //===----------------------------------------------------------------------===// func.func @undef() -> () { - // CHECK: %{{.*}} = spv.Undef : f32 - %0 = spv.Undef : f32 - // CHECK: %{{.*}} = spv.Undef : vector<4xf32> - %1 = spv.Undef : vector<4xf32> - spv.Return + // CHECK: %{{.*}} = spirv.Undef : f32 + %0 = spirv.Undef : f32 + // CHECK: %{{.*}} = spirv.Undef : vector<4xf32> + %1 = spirv.Undef : vector<4xf32> + spirv.Return } // ----- func.func @undef() -> () { // expected-error @+1{{expected non-function type}} - %0 = spv.Undef : - spv.Return + %0 = spirv.Undef : + spirv.Return } // ----- func.func @undef() -> () { // expected-error @+1{{expected ':'}} - %0 = spv.Undef - spv.Return + %0 = spirv.Undef + spirv.Return } // ----- func.func @assume_true(%arg : i1) -> () { - // CHECK: spv.KHR.AssumeTrue %{{.*}} - spv.KHR.AssumeTrue %arg - spv.Return + // CHECK: spirv.KHR.AssumeTrue %{{.*}} + spirv.KHR.AssumeTrue %arg + spirv.Return } // ----- @@ -41,6 +41,6 @@ func.func @assume_true(%arg : f32) -> () { // expected-error @+2{{use of value '%arg' expects different type than prior uses: 'i1' vs 'f32'}} // expected-note @-2 {{prior use here}} - spv.KHR.AssumeTrue %arg - spv.Return + spirv.KHR.AssumeTrue %arg + spirv.Return } diff --git a/mlir/test/Dialect/SPIRV/IR/non-uniform-ops.mlir b/mlir/test/Dialect/SPIRV/IR/non-uniform-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/non-uniform-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/non-uniform-ops.mlir @@ -1,12 +1,12 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.GroupNonUniformBallot +// spirv.GroupNonUniformBallot //===----------------------------------------------------------------------===// func.func @group_non_uniform_ballot(%predicate: i1) -> vector<4xi32> { - // CHECK: %{{.*}} = spv.GroupNonUniformBallot %{{.*}}: vector<4xi32> - %0 = spv.GroupNonUniformBallot %predicate : vector<4xi32> + // CHECK: %{{.*}} = spirv.GroupNonUniformBallot %{{.*}}: vector<4xi32> + %0 = spirv.GroupNonUniformBallot %predicate : vector<4xi32> return %0: vector<4xi32> } @@ -14,7 +14,7 @@ func.func @group_non_uniform_ballot(%predicate: i1) -> vector<4xi32> { // expected-error @+1 {{execution scope must be 'Workgroup' or 'Subgroup'}} - %0 = spv.GroupNonUniformBallot %predicate : vector<4xi32> + %0 = spirv.GroupNonUniformBallot %predicate : vector<4xi32> return %0: vector<4xi32> } @@ -22,38 +22,38 @@ func.func @group_non_uniform_ballot(%predicate: i1) -> vector<4xsi32> { // expected-error @+1 {{op result #0 must be vector of 8/16/32/64-bit signless/unsigned integer values of length 4, but got 'vector<4xsi32>'}} - %0 = spv.GroupNonUniformBallot %predicate : vector<4xsi32> + %0 = spirv.GroupNonUniformBallot %predicate : vector<4xsi32> return %0: vector<4xsi32> } // ----- //===----------------------------------------------------------------------===// -// spv.NonUniformGroupBroadcast +// spirv.NonUniformGroupBroadcast //===----------------------------------------------------------------------===// func.func @group_non_uniform_broadcast_scalar(%value: f32) -> f32 { - %one = spv.Constant 1 : i32 - // CHECK: spv.GroupNonUniformBroadcast %{{.*}}, %{{.*}} : f32, i32 - %0 = spv.GroupNonUniformBroadcast %value, %one : f32, i32 + %one = spirv.Constant 1 : i32 + // CHECK: spirv.GroupNonUniformBroadcast %{{.*}}, %{{.*}} : f32, i32 + %0 = spirv.GroupNonUniformBroadcast %value, %one : f32, i32 return %0: f32 } // ----- func.func @group_non_uniform_broadcast_vector(%value: vector<4xf32>) -> vector<4xf32> { - %one = spv.Constant 1 : i32 - // CHECK: spv.GroupNonUniformBroadcast %{{.*}}, %{{.*}} : vector<4xf32>, i32 - %0 = spv.GroupNonUniformBroadcast %value, %one : vector<4xf32>, i32 + %one = spirv.Constant 1 : i32 + // CHECK: spirv.GroupNonUniformBroadcast %{{.*}}, %{{.*}} : vector<4xf32>, i32 + %0 = spirv.GroupNonUniformBroadcast %value, %one : vector<4xf32>, i32 return %0: vector<4xf32> } // ----- func.func @group_non_uniform_broadcast_negative_scope(%value: f32, %localid: i32 ) -> f32 { - %one = spv.Constant 1 : i32 + %one = spirv.Constant 1 : i32 // expected-error @+1 {{execution scope must be 'Workgroup' or 'Subgroup'}} - %0 = spv.GroupNonUniformBroadcast %value, %one : f32, i32 + %0 = spirv.GroupNonUniformBroadcast %value, %one : f32, i32 return %0: f32 } @@ -61,20 +61,20 @@ func.func @group_non_uniform_broadcast_negative_non_const(%value: f32, %localid: i32) -> f32 { // expected-error @+1 {{id must be the result of a constant op}} - %0 = spv.GroupNonUniformBroadcast %value, %localid : f32, i32 + %0 = spirv.GroupNonUniformBroadcast %value, %localid : f32, i32 return %0: f32 } // ----- //===----------------------------------------------------------------------===// -// spv.GroupNonUniformElect +// spirv.GroupNonUniformElect //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_elect func.func @group_non_uniform_elect() -> i1 { - // CHECK: %{{.+}} = spv.GroupNonUniformElect : i1 - %0 = spv.GroupNonUniformElect : i1 + // CHECK: %{{.+}} = spirv.GroupNonUniformElect : i1 + %0 = spirv.GroupNonUniformElect : i1 return %0: i1 } @@ -82,94 +82,94 @@ func.func @group_non_uniform_elect() -> i1 { // expected-error @+1 {{execution scope must be 'Workgroup' or 'Subgroup'}} - %0 = spv.GroupNonUniformElect : i1 + %0 = spirv.GroupNonUniformElect : i1 return %0: i1 } // ----- //===----------------------------------------------------------------------===// -// spv.GroupNonUniformFAdd +// spirv.GroupNonUniformFAdd //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_fadd_reduce func.func @group_non_uniform_fadd_reduce(%val: f32) -> f32 { - // CHECK: %{{.+}} = spv.GroupNonUniformFAdd "Workgroup" "Reduce" %{{.+}} : f32 - %0 = spv.GroupNonUniformFAdd "Workgroup" "Reduce" %val : f32 + // CHECK: %{{.+}} = spirv.GroupNonUniformFAdd "Workgroup" "Reduce" %{{.+}} : f32 + %0 = spirv.GroupNonUniformFAdd "Workgroup" "Reduce" %val : f32 return %0: f32 } // CHECK-LABEL: @group_non_uniform_fadd_clustered_reduce func.func @group_non_uniform_fadd_clustered_reduce(%val: vector<2xf32>) -> vector<2xf32> { - %four = spv.Constant 4 : i32 - // CHECK: %{{.+}} = spv.GroupNonUniformFAdd "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xf32> - %0 = spv.GroupNonUniformFAdd "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xf32> + %four = spirv.Constant 4 : i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformFAdd "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xf32> + %0 = spirv.GroupNonUniformFAdd "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xf32> return %0: vector<2xf32> } //===----------------------------------------------------------------------===// -// spv.GroupNonUniformFMul +// spirv.GroupNonUniformFMul //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_fmul_reduce func.func @group_non_uniform_fmul_reduce(%val: f32) -> f32 { - // CHECK: %{{.+}} = spv.GroupNonUniformFMul "Workgroup" "Reduce" %{{.+}} : f32 - %0 = spv.GroupNonUniformFMul "Workgroup" "Reduce" %val : f32 + // CHECK: %{{.+}} = spirv.GroupNonUniformFMul "Workgroup" "Reduce" %{{.+}} : f32 + %0 = spirv.GroupNonUniformFMul "Workgroup" "Reduce" %val : f32 return %0: f32 } // CHECK-LABEL: @group_non_uniform_fmul_clustered_reduce func.func @group_non_uniform_fmul_clustered_reduce(%val: vector<2xf32>) -> vector<2xf32> { - %four = spv.Constant 4 : i32 - // CHECK: %{{.+}} = spv.GroupNonUniformFMul "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xf32> - %0 = spv.GroupNonUniformFMul "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xf32> + %four = spirv.Constant 4 : i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformFMul "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xf32> + %0 = spirv.GroupNonUniformFMul "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xf32> return %0: vector<2xf32> } // ----- //===----------------------------------------------------------------------===// -// spv.GroupNonUniformFMax +// spirv.GroupNonUniformFMax //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_fmax_reduce func.func @group_non_uniform_fmax_reduce(%val: f32) -> f32 { - // CHECK: %{{.+}} = spv.GroupNonUniformFMax "Workgroup" "Reduce" %{{.+}} : f32 - %0 = spv.GroupNonUniformFMax "Workgroup" "Reduce" %val : f32 + // CHECK: %{{.+}} = spirv.GroupNonUniformFMax "Workgroup" "Reduce" %{{.+}} : f32 + %0 = spirv.GroupNonUniformFMax "Workgroup" "Reduce" %val : f32 return %0: f32 } // ----- //===----------------------------------------------------------------------===// -// spv.GroupNonUniformFMin +// spirv.GroupNonUniformFMin //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_fmin_reduce func.func @group_non_uniform_fmin_reduce(%val: f32) -> f32 { - // CHECK: %{{.+}} = spv.GroupNonUniformFMin "Workgroup" "Reduce" %{{.+}} : f32 - %0 = spv.GroupNonUniformFMin "Workgroup" "Reduce" %val : f32 + // CHECK: %{{.+}} = spirv.GroupNonUniformFMin "Workgroup" "Reduce" %{{.+}} : f32 + %0 = spirv.GroupNonUniformFMin "Workgroup" "Reduce" %val : f32 return %0: f32 } // ----- //===----------------------------------------------------------------------===// -// spv.GroupNonUniformIAdd +// spirv.GroupNonUniformIAdd //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_iadd_reduce func.func @group_non_uniform_iadd_reduce(%val: i32) -> i32 { - // CHECK: %{{.+}} = spv.GroupNonUniformIAdd "Workgroup" "Reduce" %{{.+}} : i32 - %0 = spv.GroupNonUniformIAdd "Workgroup" "Reduce" %val : i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformIAdd "Workgroup" "Reduce" %{{.+}} : i32 + %0 = spirv.GroupNonUniformIAdd "Workgroup" "Reduce" %val : i32 return %0: i32 } // CHECK-LABEL: @group_non_uniform_iadd_clustered_reduce func.func @group_non_uniform_iadd_clustered_reduce(%val: vector<2xi32>) -> vector<2xi32> { - %four = spv.Constant 4 : i32 - // CHECK: %{{.+}} = spv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xi32> - %0 = spv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xi32> + %four = spirv.Constant 4 : i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xi32> + %0 = spirv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xi32> return %0: vector<2xi32> } @@ -177,7 +177,7 @@ func.func @group_non_uniform_iadd_reduce(%val: i32) -> i32 { // expected-error @+1 {{execution scope must be 'Workgroup' or 'Subgroup'}} - %0 = spv.GroupNonUniformIAdd "Device" "Reduce" %val : i32 + %0 = spirv.GroupNonUniformIAdd "Device" "Reduce" %val : i32 return %0: i32 } @@ -185,7 +185,7 @@ func.func @group_non_uniform_iadd_clustered_reduce(%val: vector<2xi32>) -> vector<2xi32> { // expected-error @+1 {{cluster size operand must be provided for 'ClusteredReduce' group operation}} - %0 = spv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val : vector<2xi32> + %0 = spirv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val : vector<2xi32> return %0: vector<2xi32> } @@ -193,83 +193,83 @@ func.func @group_non_uniform_iadd_clustered_reduce(%val: vector<2xi32>, %size: i32) -> vector<2xi32> { // expected-error @+1 {{cluster size operand must come from a constant op}} - %0 = spv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val cluster_size(%size) : vector<2xi32> + %0 = spirv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val cluster_size(%size) : vector<2xi32> return %0: vector<2xi32> } // ----- func.func @group_non_uniform_iadd_clustered_reduce(%val: vector<2xi32>) -> vector<2xi32> { - %five = spv.Constant 5 : i32 + %five = spirv.Constant 5 : i32 // expected-error @+1 {{cluster size operand must be a power of two}} - %0 = spv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val cluster_size(%five) : vector<2xi32> + %0 = spirv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val cluster_size(%five) : vector<2xi32> return %0: vector<2xi32> } // ----- //===----------------------------------------------------------------------===// -// spv.GroupNonUniformIMul +// spirv.GroupNonUniformIMul //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_imul_reduce func.func @group_non_uniform_imul_reduce(%val: i32) -> i32 { - // CHECK: %{{.+}} = spv.GroupNonUniformIMul "Workgroup" "Reduce" %{{.+}} : i32 - %0 = spv.GroupNonUniformIMul "Workgroup" "Reduce" %val : i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformIMul "Workgroup" "Reduce" %{{.+}} : i32 + %0 = spirv.GroupNonUniformIMul "Workgroup" "Reduce" %val : i32 return %0: i32 } // CHECK-LABEL: @group_non_uniform_imul_clustered_reduce func.func @group_non_uniform_imul_clustered_reduce(%val: vector<2xi32>) -> vector<2xi32> { - %four = spv.Constant 4 : i32 - // CHECK: %{{.+}} = spv.GroupNonUniformIMul "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xi32> - %0 = spv.GroupNonUniformIMul "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xi32> + %four = spirv.Constant 4 : i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformIMul "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xi32> + %0 = spirv.GroupNonUniformIMul "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xi32> return %0: vector<2xi32> } // ----- //===----------------------------------------------------------------------===// -// spv.GroupNonUniformSMax +// spirv.GroupNonUniformSMax //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_smax_reduce func.func @group_non_uniform_smax_reduce(%val: i32) -> i32 { - // CHECK: %{{.+}} = spv.GroupNonUniformSMax "Workgroup" "Reduce" %{{.+}} : i32 - %0 = spv.GroupNonUniformSMax "Workgroup" "Reduce" %val : i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformSMax "Workgroup" "Reduce" %{{.+}} : i32 + %0 = spirv.GroupNonUniformSMax "Workgroup" "Reduce" %val : i32 return %0: i32 } // ----- //===----------------------------------------------------------------------===// -// spv.GroupNonUniformSMin +// spirv.GroupNonUniformSMin //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_smin_reduce func.func @group_non_uniform_smin_reduce(%val: i32) -> i32 { - // CHECK: %{{.+}} = spv.GroupNonUniformSMin "Workgroup" "Reduce" %{{.+}} : i32 - %0 = spv.GroupNonUniformSMin "Workgroup" "Reduce" %val : i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformSMin "Workgroup" "Reduce" %{{.+}} : i32 + %0 = spirv.GroupNonUniformSMin "Workgroup" "Reduce" %val : i32 return %0: i32 } // ----- //===----------------------------------------------------------------------===// -// spv.GroupNonUniformShuffle +// spirv.GroupNonUniformShuffle //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_shuffle1 func.func @group_non_uniform_shuffle1(%val: f32, %id: i32) -> f32 { - // CHECK: %{{.+}} = spv.GroupNonUniformShuffle %{{.+}}, %{{.+}} : f32, i32 - %0 = spv.GroupNonUniformShuffle %val, %id : f32, i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformShuffle %{{.+}}, %{{.+}} : f32, i32 + %0 = spirv.GroupNonUniformShuffle %val, %id : f32, i32 return %0: f32 } // CHECK-LABEL: @group_non_uniform_shuffle2 func.func @group_non_uniform_shuffle2(%val: vector<2xf32>, %id: i32) -> vector<2xf32> { - // CHECK: %{{.+}} = spv.GroupNonUniformShuffle %{{.+}}, %{{.+}} : vector<2xf32>, i32 - %0 = spv.GroupNonUniformShuffle %val, %id : vector<2xf32>, i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformShuffle %{{.+}}, %{{.+}} : vector<2xf32>, i32 + %0 = spirv.GroupNonUniformShuffle %val, %id : vector<2xf32>, i32 return %0: vector<2xf32> } @@ -277,7 +277,7 @@ func.func @group_non_uniform_shuffle(%val: vector<2xf32>, %id: i32) -> vector<2xf32> { // expected-error @+1 {{execution scope must be 'Workgroup' or 'Subgroup'}} - %0 = spv.GroupNonUniformShuffle %val, %id : vector<2xf32>, i32 + %0 = spirv.GroupNonUniformShuffle %val, %id : vector<2xf32>, i32 return %0: vector<2xf32> } @@ -285,27 +285,27 @@ func.func @group_non_uniform_shuffle(%val: vector<2xf32>, %id: si32) -> vector<2xf32> { // expected-error @+1 {{second operand must be a singless/unsigned integer}} - %0 = spv.GroupNonUniformShuffle %val, %id : vector<2xf32>, si32 + %0 = spirv.GroupNonUniformShuffle %val, %id : vector<2xf32>, si32 return %0: vector<2xf32> } // ----- //===----------------------------------------------------------------------===// -// spv.GroupNonUniformShuffleXor +// spirv.GroupNonUniformShuffleXor //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_shuffle1 func.func @group_non_uniform_shuffle1(%val: f32, %id: i32) -> f32 { - // CHECK: %{{.+}} = spv.GroupNonUniformShuffleXor %{{.+}}, %{{.+}} : f32, i32 - %0 = spv.GroupNonUniformShuffleXor %val, %id : f32, i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformShuffleXor %{{.+}}, %{{.+}} : f32, i32 + %0 = spirv.GroupNonUniformShuffleXor %val, %id : f32, i32 return %0: f32 } // CHECK-LABEL: @group_non_uniform_shuffle2 func.func @group_non_uniform_shuffle2(%val: vector<2xf32>, %id: i32) -> vector<2xf32> { - // CHECK: %{{.+}} = spv.GroupNonUniformShuffleXor %{{.+}}, %{{.+}} : vector<2xf32>, i32 - %0 = spv.GroupNonUniformShuffleXor %val, %id : vector<2xf32>, i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformShuffleXor %{{.+}}, %{{.+}} : vector<2xf32>, i32 + %0 = spirv.GroupNonUniformShuffleXor %val, %id : vector<2xf32>, i32 return %0: vector<2xf32> } @@ -313,7 +313,7 @@ func.func @group_non_uniform_shuffle(%val: vector<2xf32>, %id: i32) -> vector<2xf32> { // expected-error @+1 {{execution scope must be 'Workgroup' or 'Subgroup'}} - %0 = spv.GroupNonUniformShuffleXor %val, %id : vector<2xf32>, i32 + %0 = spirv.GroupNonUniformShuffleXor %val, %id : vector<2xf32>, i32 return %0: vector<2xf32> } @@ -321,27 +321,27 @@ func.func @group_non_uniform_shuffle(%val: vector<2xf32>, %id: si32) -> vector<2xf32> { // expected-error @+1 {{second operand must be a singless/unsigned integer}} - %0 = spv.GroupNonUniformShuffleXor %val, %id : vector<2xf32>, si32 + %0 = spirv.GroupNonUniformShuffleXor %val, %id : vector<2xf32>, si32 return %0: vector<2xf32> } // ----- //===----------------------------------------------------------------------===// -// spv.GroupNonUniformShuffleUp +// spirv.GroupNonUniformShuffleUp //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_shuffle1 func.func @group_non_uniform_shuffle1(%val: f32, %id: i32) -> f32 { - // CHECK: %{{.+}} = spv.GroupNonUniformShuffleUp %{{.+}}, %{{.+}} : f32, i32 - %0 = spv.GroupNonUniformShuffleUp %val, %id : f32, i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformShuffleUp %{{.+}}, %{{.+}} : f32, i32 + %0 = spirv.GroupNonUniformShuffleUp %val, %id : f32, i32 return %0: f32 } // CHECK-LABEL: @group_non_uniform_shuffle2 func.func @group_non_uniform_shuffle2(%val: vector<2xf32>, %id: i32) -> vector<2xf32> { - // CHECK: %{{.+}} = spv.GroupNonUniformShuffleUp %{{.+}}, %{{.+}} : vector<2xf32>, i32 - %0 = spv.GroupNonUniformShuffleUp %val, %id : vector<2xf32>, i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformShuffleUp %{{.+}}, %{{.+}} : vector<2xf32>, i32 + %0 = spirv.GroupNonUniformShuffleUp %val, %id : vector<2xf32>, i32 return %0: vector<2xf32> } @@ -349,7 +349,7 @@ func.func @group_non_uniform_shuffle(%val: vector<2xf32>, %id: i32) -> vector<2xf32> { // expected-error @+1 {{execution scope must be 'Workgroup' or 'Subgroup'}} - %0 = spv.GroupNonUniformShuffleUp %val, %id : vector<2xf32>, i32 + %0 = spirv.GroupNonUniformShuffleUp %val, %id : vector<2xf32>, i32 return %0: vector<2xf32> } @@ -357,27 +357,27 @@ func.func @group_non_uniform_shuffle(%val: vector<2xf32>, %id: si32) -> vector<2xf32> { // expected-error @+1 {{second operand must be a singless/unsigned integer}} - %0 = spv.GroupNonUniformShuffleUp %val, %id : vector<2xf32>, si32 + %0 = spirv.GroupNonUniformShuffleUp %val, %id : vector<2xf32>, si32 return %0: vector<2xf32> } // ----- //===----------------------------------------------------------------------===// -// spv.GroupNonUniformShuffleDown +// spirv.GroupNonUniformShuffleDown //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_shuffle1 func.func @group_non_uniform_shuffle1(%val: f32, %id: i32) -> f32 { - // CHECK: %{{.+}} = spv.GroupNonUniformShuffleDown %{{.+}}, %{{.+}} : f32, i32 - %0 = spv.GroupNonUniformShuffleDown %val, %id : f32, i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformShuffleDown %{{.+}}, %{{.+}} : f32, i32 + %0 = spirv.GroupNonUniformShuffleDown %val, %id : f32, i32 return %0: f32 } // CHECK-LABEL: @group_non_uniform_shuffle2 func.func @group_non_uniform_shuffle2(%val: vector<2xf32>, %id: i32) -> vector<2xf32> { - // CHECK: %{{.+}} = spv.GroupNonUniformShuffleDown %{{.+}}, %{{.+}} : vector<2xf32>, i32 - %0 = spv.GroupNonUniformShuffleDown %val, %id : vector<2xf32>, i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformShuffleDown %{{.+}}, %{{.+}} : vector<2xf32>, i32 + %0 = spirv.GroupNonUniformShuffleDown %val, %id : vector<2xf32>, i32 return %0: vector<2xf32> } @@ -385,7 +385,7 @@ func.func @group_non_uniform_shuffle(%val: vector<2xf32>, %id: i32) -> vector<2xf32> { // expected-error @+1 {{execution scope must be 'Workgroup' or 'Subgroup'}} - %0 = spv.GroupNonUniformShuffleDown %val, %id : vector<2xf32>, i32 + %0 = spirv.GroupNonUniformShuffleDown %val, %id : vector<2xf32>, i32 return %0: vector<2xf32> } @@ -393,32 +393,32 @@ func.func @group_non_uniform_shuffle(%val: vector<2xf32>, %id: si32) -> vector<2xf32> { // expected-error @+1 {{second operand must be a singless/unsigned integer}} - %0 = spv.GroupNonUniformShuffleDown %val, %id : vector<2xf32>, si32 + %0 = spirv.GroupNonUniformShuffleDown %val, %id : vector<2xf32>, si32 return %0: vector<2xf32> } // ----- //===----------------------------------------------------------------------===// -// spv.GroupNonUniformUMax +// spirv.GroupNonUniformUMax //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_umax_reduce func.func @group_non_uniform_umax_reduce(%val: i32) -> i32 { - // CHECK: %{{.+}} = spv.GroupNonUniformUMax "Workgroup" "Reduce" %{{.+}} : i32 - %0 = spv.GroupNonUniformUMax "Workgroup" "Reduce" %val : i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformUMax "Workgroup" "Reduce" %{{.+}} : i32 + %0 = spirv.GroupNonUniformUMax "Workgroup" "Reduce" %val : i32 return %0: i32 } // ----- //===----------------------------------------------------------------------===// -// spv.GroupNonUniformUMin +// spirv.GroupNonUniformUMin //===----------------------------------------------------------------------===// // CHECK-LABEL: @group_non_uniform_umin_reduce func.func @group_non_uniform_umin_reduce(%val: i32) -> i32 { - // CHECK: %{{.+}} = spv.GroupNonUniformUMin "Workgroup" "Reduce" %{{.+}} : i32 - %0 = spv.GroupNonUniformUMin "Workgroup" "Reduce" %val : i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformUMin "Workgroup" "Reduce" %{{.+}} : i32 + %0 = spirv.GroupNonUniformUMin "Workgroup" "Reduce" %val : i32 return %0: i32 } diff --git a/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir b/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir @@ -1,18 +1,18 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.CL.exp +// spirv.CL.exp //===----------------------------------------------------------------------===// func.func @exp(%arg0 : f32) -> () { - // CHECK: spv.CL.exp {{%.*}} : f32 - %2 = spv.CL.exp %arg0 : f32 + // CHECK: spirv.CL.exp {{%.*}} : f32 + %2 = spirv.CL.exp %arg0 : f32 return } func.func @expvec(%arg0 : vector<3xf16>) -> () { - // CHECK: spv.CL.exp {{%.*}} : vector<3xf16> - %2 = spv.CL.exp %arg0 : vector<3xf16> + // CHECK: spirv.CL.exp {{%.*}} : vector<3xf16> + %2 = spirv.CL.exp %arg0 : vector<3xf16> return } @@ -20,7 +20,7 @@ func.func @exp(%arg0 : i32) -> () { // expected-error @+1 {{op operand #0 must be 16/32/64-bit float or vector of 16/32/64-bit float values}} - %2 = spv.CL.exp %arg0 : i32 + %2 = spirv.CL.exp %arg0 : i32 return } @@ -28,7 +28,7 @@ func.func @exp(%arg0 : vector<5xf32>) -> () { // expected-error @+1 {{op operand #0 must be 16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4}} - %2 = spv.CL.exp %arg0 : vector<5xf32> + %2 = spirv.CL.exp %arg0 : vector<5xf32> return } @@ -36,7 +36,7 @@ func.func @exp(%arg0 : f32, %arg1 : f32) -> () { // expected-error @+1 {{expected ':'}} - %2 = spv.CL.exp %arg0, %arg1 : i32 + %2 = spirv.CL.exp %arg0, %arg1 : i32 return } @@ -44,31 +44,31 @@ func.func @exp(%arg0 : i32) -> () { // expected-error @+1 {{expected non-function type}} - %2 = spv.CL.exp %arg0 : + %2 = spirv.CL.exp %arg0 : return } // ----- //===----------------------------------------------------------------------===// -// spv.CL.fabs +// spirv.CL.fabs //===----------------------------------------------------------------------===// func.func @fabs(%arg0 : f32) -> () { - // CHECK: spv.CL.fabs {{%.*}} : f32 - %2 = spv.CL.fabs %arg0 : f32 + // CHECK: spirv.CL.fabs {{%.*}} : f32 + %2 = spirv.CL.fabs %arg0 : f32 return } func.func @fabsvec(%arg0 : vector<3xf16>) -> () { - // CHECK: spv.CL.fabs {{%.*}} : vector<3xf16> - %2 = spv.CL.fabs %arg0 : vector<3xf16> + // CHECK: spirv.CL.fabs {{%.*}} : vector<3xf16> + %2 = spirv.CL.fabs %arg0 : vector<3xf16> return } func.func @fabsf64(%arg0 : f64) -> () { - // CHECK: spv.CL.fabs {{%.*}} : f64 - %2 = spv.CL.fabs %arg0 : f64 + // CHECK: spirv.CL.fabs {{%.*}} : f64 + %2 = spirv.CL.fabs %arg0 : f64 return } @@ -76,7 +76,7 @@ func.func @fabs(%arg0 : i32) -> () { // expected-error @+1 {{op operand #0 must be 16/32/64-bit float or vector of 16/32/64-bit float values}} - %2 = spv.CL.fabs %arg0 : i32 + %2 = spirv.CL.fabs %arg0 : i32 return } @@ -84,7 +84,7 @@ func.func @fabs(%arg0 : vector<5xf32>) -> () { // expected-error @+1 {{op operand #0 must be 16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4}} - %2 = spv.CL.fabs %arg0 : vector<5xf32> + %2 = spirv.CL.fabs %arg0 : vector<5xf32> return } @@ -92,7 +92,7 @@ func.func @fabs(%arg0 : f32, %arg1 : f32) -> () { // expected-error @+1 {{expected ':'}} - %2 = spv.CL.fabs %arg0, %arg1 : i32 + %2 = spirv.CL.fabs %arg0, %arg1 : i32 return } @@ -100,37 +100,37 @@ func.func @fabs(%arg0 : i32) -> () { // expected-error @+1 {{expected non-function type}} - %2 = spv.CL.fabs %arg0 : + %2 = spirv.CL.fabs %arg0 : return } // ----- //===----------------------------------------------------------------------===// -// spv.CL.s_abs +// spirv.CL.s_abs //===----------------------------------------------------------------------===// func.func @sabs(%arg0 : i32) -> () { - // CHECK: spv.CL.s_abs {{%.*}} : i32 - %2 = spv.CL.s_abs %arg0 : i32 + // CHECK: spirv.CL.s_abs {{%.*}} : i32 + %2 = spirv.CL.s_abs %arg0 : i32 return } func.func @sabsvec(%arg0 : vector<3xi16>) -> () { - // CHECK: spv.CL.s_abs {{%.*}} : vector<3xi16> - %2 = spv.CL.s_abs %arg0 : vector<3xi16> + // CHECK: spirv.CL.s_abs {{%.*}} : vector<3xi16> + %2 = spirv.CL.s_abs %arg0 : vector<3xi16> return } func.func @sabsi64(%arg0 : i64) -> () { - // CHECK: spv.CL.s_abs {{%.*}} : i64 - %2 = spv.CL.s_abs %arg0 : i64 + // CHECK: spirv.CL.s_abs {{%.*}} : i64 + %2 = spirv.CL.s_abs %arg0 : i64 return } func.func @sabsi8(%arg0 : i8) -> () { - // CHECK: spv.CL.s_abs {{%.*}} : i8 - %2 = spv.CL.s_abs %arg0 : i8 + // CHECK: spirv.CL.s_abs {{%.*}} : i8 + %2 = spirv.CL.s_abs %arg0 : i8 return } @@ -138,7 +138,7 @@ func.func @sabs(%arg0 : f32) -> () { // expected-error @+1 {{op operand #0 must be 8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values}} - %2 = spv.CL.s_abs %arg0 : f32 + %2 = spirv.CL.s_abs %arg0 : f32 return } @@ -146,7 +146,7 @@ func.func @sabs(%arg0 : vector<5xi32>) -> () { // expected-error @+1 {{op operand #0 must be 8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4}} - %2 = spv.CL.s_abs %arg0 : vector<5xi32> + %2 = spirv.CL.s_abs %arg0 : vector<5xi32> return } @@ -154,7 +154,7 @@ func.func @sabs(%arg0 : i32, %arg1 : i32) -> () { // expected-error @+1 {{expected ':'}} - %2 = spv.CL.s_abs %arg0, %arg1 : i32 + %2 = spirv.CL.s_abs %arg0, %arg1 : i32 return } @@ -162,68 +162,68 @@ func.func @sabs(%arg0 : i32) -> () { // expected-error @+1 {{expected non-function type}} - %2 = spv.CL.s_abs %arg0 : + %2 = spirv.CL.s_abs %arg0 : return } // ----- //===----------------------------------------------------------------------===// -// spv.CL.fma +// spirv.CL.fma //===----------------------------------------------------------------------===// func.func @fma(%a : f32, %b : f32, %c : f32) -> () { - // CHECK: spv.CL.fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32 - %2 = spv.CL.fma %a, %b, %c : f32 + // CHECK: spirv.CL.fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32 + %2 = spirv.CL.fma %a, %b, %c : f32 return } // ----- func.func @fma(%a : vector<3xf32>, %b : vector<3xf32>, %c : vector<3xf32>) -> () { - // CHECK: spv.CL.fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<3xf32> - %2 = spv.CL.fma %a, %b, %c : vector<3xf32> + // CHECK: spirv.CL.fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<3xf32> + %2 = spirv.CL.fma %a, %b, %c : vector<3xf32> return } // ----- //===----------------------------------------------------------------------===// -// spv.CL.{F|S|U}{Max|Min} +// spirv.CL.{F|S|U}{Max|Min} //===----------------------------------------------------------------------===// func.func @fmaxmin(%arg0 : f32, %arg1 : f32) { - // CHECK: spv.CL.fmax {{%.*}}, {{%.*}} : f32 - %1 = spv.CL.fmax %arg0, %arg1 : f32 - // CHECK: spv.CL.fmin {{%.*}}, {{%.*}} : f32 - %2 = spv.CL.fmin %arg0, %arg1 : f32 + // CHECK: spirv.CL.fmax {{%.*}}, {{%.*}} : f32 + %1 = spirv.CL.fmax %arg0, %arg1 : f32 + // CHECK: spirv.CL.fmin {{%.*}}, {{%.*}} : f32 + %2 = spirv.CL.fmin %arg0, %arg1 : f32 return } func.func @fmaxminvec(%arg0 : vector<3xf16>, %arg1 : vector<3xf16>) { - // CHECK: spv.CL.fmax {{%.*}}, {{%.*}} : vector<3xf16> - %1 = spv.CL.fmax %arg0, %arg1 : vector<3xf16> - // CHECK: spv.CL.fmin {{%.*}}, {{%.*}} : vector<3xf16> - %2 = spv.CL.fmin %arg0, %arg1 : vector<3xf16> + // CHECK: spirv.CL.fmax {{%.*}}, {{%.*}} : vector<3xf16> + %1 = spirv.CL.fmax %arg0, %arg1 : vector<3xf16> + // CHECK: spirv.CL.fmin {{%.*}}, {{%.*}} : vector<3xf16> + %2 = spirv.CL.fmin %arg0, %arg1 : vector<3xf16> return } func.func @fmaxminf64(%arg0 : f64, %arg1 : f64) { - // CHECK: spv.CL.fmax {{%.*}}, {{%.*}} : f64 - %1 = spv.CL.fmax %arg0, %arg1 : f64 - // CHECK: spv.CL.fmin {{%.*}}, {{%.*}} : f64 - %2 = spv.CL.fmin %arg0, %arg1 : f64 + // CHECK: spirv.CL.fmax {{%.*}}, {{%.*}} : f64 + %1 = spirv.CL.fmax %arg0, %arg1 : f64 + // CHECK: spirv.CL.fmin {{%.*}}, {{%.*}} : f64 + %2 = spirv.CL.fmin %arg0, %arg1 : f64 return } func.func @iminmax(%arg0: i32, %arg1: i32) { - // CHECK: spv.CL.s_max {{%.*}}, {{%.*}} : i32 - %1 = spv.CL.s_max %arg0, %arg1 : i32 - // CHECK: spv.CL.u_max {{%.*}}, {{%.*}} : i32 - %2 = spv.CL.u_max %arg0, %arg1 : i32 - // CHECK: spv.CL.s_min {{%.*}}, {{%.*}} : i32 - %3 = spv.CL.s_min %arg0, %arg1 : i32 - // CHECK: spv.CL.u_min {{%.*}}, {{%.*}} : i32 - %4 = spv.CL.u_min %arg0, %arg1 : i32 + // CHECK: spirv.CL.s_max {{%.*}}, {{%.*}} : i32 + %1 = spirv.CL.s_max %arg0, %arg1 : i32 + // CHECK: spirv.CL.u_max {{%.*}}, {{%.*}} : i32 + %2 = spirv.CL.u_max %arg0, %arg1 : i32 + // CHECK: spirv.CL.s_min {{%.*}}, {{%.*}} : i32 + %3 = spirv.CL.s_min %arg0, %arg1 : i32 + // CHECK: spirv.CL.u_min {{%.*}}, {{%.*}} : i32 + %4 = spirv.CL.u_min %arg0, %arg1 : i32 return } diff --git a/mlir/test/Dialect/SPIRV/IR/structure-ops.mlir b/mlir/test/Dialect/SPIRV/IR/structure-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/structure-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/structure-ops.mlir @@ -1,78 +1,78 @@ // RUN: mlir-opt -allow-unregistered-dialect -split-input-file -verify-diagnostics %s | FileCheck %s //===----------------------------------------------------------------------===// -// spv.mlir.addressof +// spirv.mlir.addressof //===----------------------------------------------------------------------===// -spv.module Logical GLSL450 { - spv.GlobalVariable @var1 : !spv.ptr)>, Input> - spv.func @access_chain() -> () "None" { - %0 = spv.Constant 1: i32 - // CHECK: [[VAR1:%.*]] = spv.mlir.addressof @var1 : !spv.ptr)>, Input> - // CHECK-NEXT: spv.AccessChain [[VAR1]][{{.*}}, {{.*}}] : !spv.ptr)>, Input> - %1 = spv.mlir.addressof @var1 : !spv.ptr)>, Input> - %2 = spv.AccessChain %1[%0, %0] : !spv.ptr)>, Input>, i32, i32 - spv.Return +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var1 : !spirv.ptr)>, Input> + spirv.func @access_chain() -> () "None" { + %0 = spirv.Constant 1: i32 + // CHECK: [[VAR1:%.*]] = spirv.mlir.addressof @var1 : !spirv.ptr)>, Input> + // CHECK-NEXT: spirv.AccessChain [[VAR1]][{{.*}}, {{.*}}] : !spirv.ptr)>, Input> + %1 = spirv.mlir.addressof @var1 : !spirv.ptr)>, Input> + %2 = spirv.AccessChain %1[%0, %0] : !spirv.ptr)>, Input>, i32, i32 + spirv.Return } } // ----- // Allow taking address of global variables in other module-like ops -spv.GlobalVariable @var : !spv.ptr)>, Input> +spirv.GlobalVariable @var : !spirv.ptr)>, Input> func.func @addressof() -> () { - // CHECK: spv.mlir.addressof @var - %1 = spv.mlir.addressof @var : !spv.ptr)>, Input> + // CHECK: spirv.mlir.addressof @var + %1 = spirv.mlir.addressof @var : !spirv.ptr)>, Input> return } // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var1 : !spv.ptr)>, Input> - spv.func @foo() -> () "None" { - // expected-error @+1 {{expected spv.GlobalVariable symbol}} - %0 = spv.mlir.addressof @var2 : !spv.ptr)>, Input> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var1 : !spirv.ptr)>, Input> + spirv.func @foo() -> () "None" { + // expected-error @+1 {{expected spirv.GlobalVariable symbol}} + %0 = spirv.mlir.addressof @var2 : !spirv.ptr)>, Input> } } // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var1 : !spv.ptr)>, Input> - spv.func @foo() -> () "None" { +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var1 : !spirv.ptr)>, Input> + spirv.func @foo() -> () "None" { // expected-error @+1 {{result type mismatch with the referenced global variable's type}} - %0 = spv.mlir.addressof @var1 : !spv.ptr + %0 = spirv.mlir.addressof @var1 : !spirv.ptr } } // ----- //===----------------------------------------------------------------------===// -// spv.Constant +// spirv.Constant //===----------------------------------------------------------------------===// func.func @const() -> () { - // CHECK: spv.Constant true - // CHECK: spv.Constant 42 : i32 - // CHECK: spv.Constant 5.000000e-01 : f32 - // CHECK: spv.Constant dense<[2, 3]> : vector<2xi32> - // CHECK: spv.Constant [dense<3.000000e+00> : vector<2xf32>] : !spv.array<1 x vector<2xf32>> - // CHECK: spv.Constant dense<1> : tensor<2x3xi32> : !spv.array<2 x !spv.array<3 x i32>> - // CHECK: spv.Constant dense<1.000000e+00> : tensor<2x3xf32> : !spv.array<2 x !spv.array<3 x f32>> - // CHECK: spv.Constant dense<{{\[}}[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi32> : !spv.array<2 x !spv.array<3 x i32>> - // CHECK: spv.Constant dense<{{\[}}[1.000000e+00, 2.000000e+00, 3.000000e+00], [4.000000e+00, 5.000000e+00, 6.000000e+00]]> : tensor<2x3xf32> : !spv.array<2 x !spv.array<3 x f32>> - - %0 = spv.Constant true - %1 = spv.Constant 42 : i32 - %2 = spv.Constant 0.5 : f32 - %3 = spv.Constant dense<[2, 3]> : vector<2xi32> - %4 = spv.Constant [dense<3.0> : vector<2xf32>] : !spv.array<1xvector<2xf32>> - %5 = spv.Constant dense<1> : tensor<2x3xi32> : !spv.array<2 x !spv.array<3 x i32>> - %6 = spv.Constant dense<1.0> : tensor<2x3xf32> : !spv.array<2 x !spv.array<3 x f32>> - %7 = spv.Constant dense<[[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi32> : !spv.array<2 x !spv.array<3 x i32>> - %8 = spv.Constant dense<[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]> : tensor<2x3xf32> : !spv.array<2 x !spv.array<3 x f32>> - %9 = spv.Constant [[dense<3.0> : vector<2xf32>]] : !spv.array<1 x !spv.array<1xvector<2xf32>>> + // CHECK: spirv.Constant true + // CHECK: spirv.Constant 42 : i32 + // CHECK: spirv.Constant 5.000000e-01 : f32 + // CHECK: spirv.Constant dense<[2, 3]> : vector<2xi32> + // CHECK: spirv.Constant [dense<3.000000e+00> : vector<2xf32>] : !spirv.array<1 x vector<2xf32>> + // CHECK: spirv.Constant dense<1> : tensor<2x3xi32> : !spirv.array<2 x !spirv.array<3 x i32>> + // CHECK: spirv.Constant dense<1.000000e+00> : tensor<2x3xf32> : !spirv.array<2 x !spirv.array<3 x f32>> + // CHECK: spirv.Constant dense<{{\[}}[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi32> : !spirv.array<2 x !spirv.array<3 x i32>> + // CHECK: spirv.Constant dense<{{\[}}[1.000000e+00, 2.000000e+00, 3.000000e+00], [4.000000e+00, 5.000000e+00, 6.000000e+00]]> : tensor<2x3xf32> : !spirv.array<2 x !spirv.array<3 x f32>> + + %0 = spirv.Constant true + %1 = spirv.Constant 42 : i32 + %2 = spirv.Constant 0.5 : f32 + %3 = spirv.Constant dense<[2, 3]> : vector<2xi32> + %4 = spirv.Constant [dense<3.0> : vector<2xf32>] : !spirv.array<1xvector<2xf32>> + %5 = spirv.Constant dense<1> : tensor<2x3xi32> : !spirv.array<2 x !spirv.array<3 x i32>> + %6 = spirv.Constant dense<1.0> : tensor<2x3xf32> : !spirv.array<2 x !spirv.array<3 x f32>> + %7 = spirv.Constant dense<[[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi32> : !spirv.array<2 x !spirv.array<3 x i32>> + %8 = spirv.Constant dense<[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]> : tensor<2x3xf32> : !spirv.array<2 x !spirv.array<3 x f32>> + %9 = spirv.Constant [[dense<3.0> : vector<2xf32>]] : !spirv.array<1 x !spirv.array<1xvector<2xf32>>> return } @@ -80,7 +80,7 @@ func.func @unaccepted_std_attr() -> () { // expected-error @+1 {{cannot have attribute: unit}} - %0 = spv.Constant unit : none + %0 = spirv.Constant unit : none return } @@ -88,15 +88,15 @@ func.func @array_constant() -> () { // expected-error @+1 {{result or element type ('vector<2xf32>') does not match value type ('vector<2xi32>')}} - %0 = spv.Constant [dense<3.0> : vector<2xf32>, dense<4> : vector<2xi32>] : !spv.array<2xvector<2xf32>> + %0 = spirv.Constant [dense<3.0> : vector<2xf32>, dense<4> : vector<2xi32>] : !spirv.array<2xvector<2xf32>> return } // ----- func.func @array_constant() -> () { - // expected-error @+1 {{must have spv.array result type for array value}} - %0 = spv.Constant [dense<3.0> : vector<2xf32>] : !spv.rtarray> + // expected-error @+1 {{must have spirv.array result type for array value}} + %0 = spirv.Constant [dense<3.0> : vector<2xf32>] : !spirv.rtarray> return } @@ -104,7 +104,7 @@ func.func @non_nested_array_constant() -> () { // expected-error @+1 {{only support nested array result type}} - %0 = spv.Constant dense<3.0> : tensor<2x2xf32> : !spv.array<2xvector<2xf32>> + %0 = spirv.Constant dense<3.0> : tensor<2x2xf32> : !spirv.array<2xvector<2xf32>> return } @@ -112,377 +112,377 @@ func.func @value_result_type_mismatch() -> () { // expected-error @+1 {{result or element type ('vector<4xi32>') does not match value type ('tensor<4xi32>')}} - %0 = "spv.Constant"() {value = dense<0> : tensor<4xi32>} : () -> (vector<4xi32>) + %0 = "spirv.Constant"() {value = dense<0> : tensor<4xi32>} : () -> (vector<4xi32>) } // ----- func.func @value_result_type_mismatch() -> () { // expected-error @+1 {{result element type ('i32') does not match value element type ('f32')}} - %0 = spv.Constant dense<1.0> : tensor<2x3xf32> : !spv.array<2 x !spv.array<3 x i32>> + %0 = spirv.Constant dense<1.0> : tensor<2x3xf32> : !spirv.array<2 x !spirv.array<3 x i32>> } // ----- func.func @value_result_num_elements_mismatch() -> () { // expected-error @+1 {{result number of elements (6) does not match value number of elements (4)}} - %0 = spv.Constant dense<1.0> : tensor<2x2xf32> : !spv.array<2 x !spv.array<3 x f32>> + %0 = spirv.Constant dense<1.0> : tensor<2x2xf32> : !spirv.array<2 x !spirv.array<3 x f32>> return } // ----- //===----------------------------------------------------------------------===// -// spv.EntryPoint +// spirv.EntryPoint //===----------------------------------------------------------------------===// -spv.module Logical GLSL450 { - spv.func @do_nothing() -> () "None" { - spv.Return +spirv.module Logical GLSL450 { + spirv.func @do_nothing() -> () "None" { + spirv.Return } - // CHECK: spv.EntryPoint "GLCompute" @do_nothing - spv.EntryPoint "GLCompute" @do_nothing + // CHECK: spirv.EntryPoint "GLCompute" @do_nothing + spirv.EntryPoint "GLCompute" @do_nothing } -spv.module Logical GLSL450 { - spv.GlobalVariable @var2 : !spv.ptr - spv.GlobalVariable @var3 : !spv.ptr - spv.func @do_something(%arg0 : !spv.ptr, %arg1 : !spv.ptr) -> () "None" { - %1 = spv.Load "Input" %arg0 : f32 - spv.Store "Output" %arg1, %1 : f32 - spv.Return +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var2 : !spirv.ptr + spirv.GlobalVariable @var3 : !spirv.ptr + spirv.func @do_something(%arg0 : !spirv.ptr, %arg1 : !spirv.ptr) -> () "None" { + %1 = spirv.Load "Input" %arg0 : f32 + spirv.Store "Output" %arg1, %1 : f32 + spirv.Return } - // CHECK: spv.EntryPoint "GLCompute" @do_something, @var2, @var3 - spv.EntryPoint "GLCompute" @do_something, @var2, @var3 + // CHECK: spirv.EntryPoint "GLCompute" @do_something, @var2, @var3 + spirv.EntryPoint "GLCompute" @do_something, @var2, @var3 } // ----- -spv.module Logical GLSL450 { - spv.func @do_nothing() -> () "None" { - spv.Return +spirv.module Logical GLSL450 { + spirv.func @do_nothing() -> () "None" { + spirv.Return } // expected-error @+1 {{invalid kind of attribute specified}} - spv.EntryPoint "GLCompute" "do_nothing" + spirv.EntryPoint "GLCompute" "do_nothing" } // ----- -spv.module Logical GLSL450 { - spv.func @do_nothing() -> () "None" { - spv.Return +spirv.module Logical GLSL450 { + spirv.func @do_nothing() -> () "None" { + spirv.Return } - // expected-error @+1 {{function 'do_something' not found in 'spv.module'}} - spv.EntryPoint "GLCompute" @do_something + // expected-error @+1 {{function 'do_something' not found in 'spirv.module'}} + spirv.EntryPoint "GLCompute" @do_something } /// TODO: Add a test that verifies an error is thrown /// when interface entries of EntryPointOp are not -/// spv.Variables. There is currently no other op that has a spv.ptr +/// spirv.Variables. There is currently no other op that has a spirv.ptr /// return type // ----- -spv.module Logical GLSL450 { - spv.func @do_nothing() -> () "None" { +spirv.module Logical GLSL450 { + spirv.func @do_nothing() -> () "None" { // expected-error @+1 {{op must appear in a module-like op's block}} - spv.EntryPoint "GLCompute" @do_something + spirv.EntryPoint "GLCompute" @do_something } } // ----- -spv.module Logical GLSL450 { - spv.func @do_nothing() -> () "None" { - spv.Return +spirv.module Logical GLSL450 { + spirv.func @do_nothing() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @do_nothing + spirv.EntryPoint "GLCompute" @do_nothing // expected-error @+1 {{duplicate of a previous EntryPointOp}} - spv.EntryPoint "GLCompute" @do_nothing + spirv.EntryPoint "GLCompute" @do_nothing } // ----- -spv.module Logical GLSL450 { - spv.func @do_nothing() -> () "None" { - spv.Return +spirv.module Logical GLSL450 { + spirv.func @do_nothing() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @do_nothing - // expected-error @+1 {{'spv.EntryPoint' invalid execution_model attribute specification: "ContractionOff"}} - spv.EntryPoint "ContractionOff" @do_nothing + spirv.EntryPoint "GLCompute" @do_nothing + // expected-error @+1 {{'spirv.EntryPoint' invalid execution_model attribute specification: "ContractionOff"}} + spirv.EntryPoint "ContractionOff" @do_nothing } // ----- //===----------------------------------------------------------------------===// -// spv.ExecutionMode +// spirv.ExecutionMode //===----------------------------------------------------------------------===// -spv.module Logical GLSL450 { - spv.func @do_nothing() -> () "None" { - spv.Return +spirv.module Logical GLSL450 { + spirv.func @do_nothing() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @do_nothing - // CHECK: spv.ExecutionMode {{@.*}} "ContractionOff" - spv.ExecutionMode @do_nothing "ContractionOff" + spirv.EntryPoint "GLCompute" @do_nothing + // CHECK: spirv.ExecutionMode {{@.*}} "ContractionOff" + spirv.ExecutionMode @do_nothing "ContractionOff" } -spv.module Logical GLSL450 { - spv.func @do_nothing() -> () "None" { - spv.Return +spirv.module Logical GLSL450 { + spirv.func @do_nothing() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @do_nothing - // CHECK: spv.ExecutionMode {{@.*}} "LocalSizeHint", 3, 4, 5 - spv.ExecutionMode @do_nothing "LocalSizeHint", 3, 4, 5 + spirv.EntryPoint "GLCompute" @do_nothing + // CHECK: spirv.ExecutionMode {{@.*}} "LocalSizeHint", 3, 4, 5 + spirv.ExecutionMode @do_nothing "LocalSizeHint", 3, 4, 5 } // ----- -spv.module Logical GLSL450 { - spv.func @do_nothing() -> () "None" { - spv.Return +spirv.module Logical GLSL450 { + spirv.func @do_nothing() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @do_nothing - // expected-error @+1 {{custom op 'spv.ExecutionMode' invalid execution_mode attribute specification: "GLCompute"}} - spv.ExecutionMode @do_nothing "GLCompute", 3, 4, 5 + spirv.EntryPoint "GLCompute" @do_nothing + // expected-error @+1 {{custom op 'spirv.ExecutionMode' invalid execution_mode attribute specification: "GLCompute"}} + spirv.ExecutionMode @do_nothing "GLCompute", 3, 4, 5 } // ----- //===----------------------------------------------------------------------===// -// spv.func +// spirv.func //===----------------------------------------------------------------------===// -// CHECK: spv.func @foo() "None" -spv.func @foo() "None" +// CHECK: spirv.func @foo() "None" +spirv.func @foo() "None" -// CHECK: spv.func @bar(%{{.+}}: i32) -> i32 "Inline|Pure" { -spv.func @bar(%arg: i32) -> (i32) "Inline|Pure" { - // CHECK-NEXT: spv. - spv.ReturnValue %arg: i32 +// CHECK: spirv.func @bar(%{{.+}}: i32) -> i32 "Inline|Pure" { +spirv.func @bar(%arg: i32) -> (i32) "Inline|Pure" { + // CHECK-NEXT: spirv. + spirv.ReturnValue %arg: i32 // CHECK-NEXT: } } -// CHECK: spv.func @baz(%{{.+}}: i32) "DontInline" attributes {additional_stuff = 64 : i64} -spv.func @baz(%arg: i32) "DontInline" attributes { +// CHECK: spirv.func @baz(%{{.+}}: i32) "DontInline" attributes {additional_stuff = 64 : i64} +spirv.func @baz(%arg: i32) "DontInline" attributes { additional_stuff = 64 -} { spv.Return } +} { spirv.Return } // ----- // expected-error @+1 {{expected function_control attribute specified as string}} -spv.func @missing_function_control() { spv.Return } +spirv.func @missing_function_control() { spirv.Return } // ----- // expected-error @+1 {{cannot have more than one result}} -spv.func @cannot_have_more_than_one_result(%arg: i32) -> (i32, i32) "None" +spirv.func @cannot_have_more_than_one_result(%arg: i32) -> (i32, i32) "None" // ----- // expected-error @+1 {{expected SSA identifier}} -spv.func @cannot_have_variadic_arguments(%arg: i32, ...) "None" +spirv.func @cannot_have_variadic_arguments(%arg: i32, ...) "None" // ----- // Nested function -spv.module Logical GLSL450 { - spv.func @outer_func() -> () "None" { +spirv.module Logical GLSL450 { + spirv.func @outer_func() -> () "None" { // expected-error @+1 {{must appear in a module-like op's block}} - spv.func @inner_func() -> () "None" { - spv.Return + spirv.func @inner_func() -> () "None" { + spirv.Return } - spv.Return + spirv.Return } } // ----- //===----------------------------------------------------------------------===// -// spv.GlobalVariable +// spirv.GlobalVariable //===----------------------------------------------------------------------===// -spv.module Logical GLSL450 { - // CHECK: spv.GlobalVariable @var0 : !spv.ptr - spv.GlobalVariable @var0 : !spv.ptr +spirv.module Logical GLSL450 { + // CHECK: spirv.GlobalVariable @var0 : !spirv.ptr + spirv.GlobalVariable @var0 : !spirv.ptr } // TODO: Fix test case after initialization with normal constant is addressed -// spv.module Logical GLSL450 { -// %0 = spv.Constant 4.0 : f32 -// // CHECK1: spv.Variable init(%0) : !spv.ptr -// spv.GlobalVariable @var1 init(%0) : !spv.ptr +// spirv.module Logical GLSL450 { +// %0 = spirv.Constant 4.0 : f32 +// // CHECK1: spirv.Variable init(%0) : !spirv.ptr +// spirv.GlobalVariable @var1 init(%0) : !spirv.ptr // } // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc = 4.0 : f32 - // CHECK: spv.GlobalVariable @var initializer(@sc) : !spv.ptr - spv.GlobalVariable @var initializer(@sc) : !spv.ptr +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc = 4.0 : f32 + // CHECK: spirv.GlobalVariable @var initializer(@sc) : !spirv.ptr + spirv.GlobalVariable @var initializer(@sc) : !spirv.ptr } // ----- // Allow initializers coming from other module-like ops -spv.SpecConstant @sc = 4.0 : f32 -// CHECK: spv.GlobalVariable @var initializer(@sc) -spv.GlobalVariable @var initializer(@sc) : !spv.ptr +spirv.SpecConstant @sc = 4.0 : f32 +// CHECK: spirv.GlobalVariable @var initializer(@sc) +spirv.GlobalVariable @var initializer(@sc) : !spirv.ptr // ----- -spv.module Logical GLSL450 { - // CHECK: spv.GlobalVariable @var0 bind(1, 2) : !spv.ptr - spv.GlobalVariable @var0 bind(1, 2) : !spv.ptr +spirv.module Logical GLSL450 { + // CHECK: spirv.GlobalVariable @var0 bind(1, 2) : !spirv.ptr + spirv.GlobalVariable @var0 bind(1, 2) : !spirv.ptr } // TODO: Fix test case after initialization with constant is addressed -// spv.module Logical GLSL450 { -// %0 = spv.Constant 4.0 : f32 -// // CHECK1: spv.GlobalVariable @var1 initializer(%0) {binding = 5 : i32} : !spv.ptr -// spv.GlobalVariable @var1 initializer(%0) {binding = 5 : i32} : !spv.ptr +// spirv.module Logical GLSL450 { +// %0 = spirv.Constant 4.0 : f32 +// // CHECK1: spirv.GlobalVariable @var1 initializer(%0) {binding = 5 : i32} : !spirv.ptr +// spirv.GlobalVariable @var1 initializer(%0) {binding = 5 : i32} : !spirv.ptr // } // ----- -spv.module Logical GLSL450 { - // CHECK: spv.GlobalVariable @var1 built_in("GlobalInvocationID") : !spv.ptr, Input> - spv.GlobalVariable @var1 built_in("GlobalInvocationID") : !spv.ptr, Input> - // CHECK: spv.GlobalVariable @var2 built_in("GlobalInvocationID") : !spv.ptr, Input> - spv.GlobalVariable @var2 {built_in = "GlobalInvocationID"} : !spv.ptr, Input> +spirv.module Logical GLSL450 { + // CHECK: spirv.GlobalVariable @var1 built_in("GlobalInvocationID") : !spirv.ptr, Input> + spirv.GlobalVariable @var1 built_in("GlobalInvocationID") : !spirv.ptr, Input> + // CHECK: spirv.GlobalVariable @var2 built_in("GlobalInvocationID") : !spirv.ptr, Input> + spirv.GlobalVariable @var2 {built_in = "GlobalInvocationID"} : !spirv.ptr, Input> } // ----- // Allow in other module-like ops module { - // CHECK: spv.GlobalVariable - spv.GlobalVariable @var0 : !spv.ptr + // CHECK: spirv.GlobalVariable + spirv.GlobalVariable @var0 : !spirv.ptr } // ----- -spv.module Logical GLSL450 { - // expected-error @+1 {{expected spv.ptr type}} - spv.GlobalVariable @var0 : f32 +spirv.module Logical GLSL450 { + // expected-error @+1 {{expected spirv.ptr type}} + spirv.GlobalVariable @var0 : f32 } // ----- -spv.module Logical GLSL450 { - // expected-error @+1 {{op initializer must be result of a spv.SpecConstant or spv.GlobalVariable op}} - spv.GlobalVariable @var0 initializer(@var1) : !spv.ptr +spirv.module Logical GLSL450 { + // expected-error @+1 {{op initializer must be result of a spirv.SpecConstant or spirv.GlobalVariable op}} + spirv.GlobalVariable @var0 initializer(@var1) : !spirv.ptr } // ----- -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { // expected-error @+1 {{storage class cannot be 'Generic'}} - spv.GlobalVariable @var0 : !spv.ptr + spirv.GlobalVariable @var0 : !spirv.ptr } // ----- -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { // expected-error @+1 {{storage class cannot be 'Function'}} - spv.GlobalVariable @var0 : !spv.ptr + spirv.GlobalVariable @var0 : !spirv.ptr } // ----- -spv.module Logical GLSL450 { - spv.func @foo() "None" { +spirv.module Logical GLSL450 { + spirv.func @foo() "None" { // expected-error @+1 {{op must appear in a module-like op's block}} - spv.GlobalVariable @var0 : !spv.ptr - spv.Return + spirv.GlobalVariable @var0 : !spirv.ptr + spirv.Return } } // ----- //===----------------------------------------------------------------------===// -// spv.module +// spirv.module //===----------------------------------------------------------------------===// // Module without capability and extension -// CHECK: spv.module Logical GLSL450 -spv.module Logical GLSL450 { } +// CHECK: spirv.module Logical GLSL450 +spirv.module Logical GLSL450 { } // Module with a name -// CHECK: spv.module @{{.*}} Logical GLSL450 -spv.module @name Logical GLSL450 { } +// CHECK: spirv.module @{{.*}} Logical GLSL450 +spirv.module @name Logical GLSL450 { } // Module with (version, capabilities, extensions) triple -// CHECK: spv.module Logical GLSL450 requires #spv.vce -spv.module Logical GLSL450 requires #spv.vce { } +// CHECK: spirv.module Logical GLSL450 requires #spirv.vce +spirv.module Logical GLSL450 requires #spirv.vce { } // Module with additional attributes -// CHECK: spv.module Logical GLSL450 attributes {foo = "bar"} -spv.module Logical GLSL450 attributes {foo = "bar"} { } +// CHECK: spirv.module Logical GLSL450 attributes {foo = "bar"} +spirv.module Logical GLSL450 attributes {foo = "bar"} { } // Module with VCE triple and additional attributes -// CHECK: spv.module Logical GLSL450 requires #spv.vce attributes {foo = "bar"} -spv.module Logical GLSL450 - requires #spv.vce +// CHECK: spirv.module Logical GLSL450 requires #spirv.vce attributes {foo = "bar"} +spirv.module Logical GLSL450 + requires #spirv.vce attributes {foo = "bar"} { } // Module with function -// CHECK: spv.module -spv.module Logical GLSL450 { - spv.func @do_nothing() -> () "None" { - spv.Return +// CHECK: spirv.module +spirv.module Logical GLSL450 { + spirv.func @do_nothing() -> () "None" { + spirv.Return } } // ----- // Missing addressing model -// expected-error@+1 {{'spv.module' expected valid keyword}} -spv.module { } +// expected-error@+1 {{'spirv.module' expected valid keyword}} +spirv.module { } // ----- // Wrong addressing model -// expected-error@+1 {{'spv.module' invalid addressing_model attribute specification: Physical}} -spv.module Physical { } +// expected-error@+1 {{'spirv.module' invalid addressing_model attribute specification: Physical}} +spirv.module Physical { } // ----- // Missing memory model -// expected-error@+1 {{'spv.module' expected valid keyword}} -spv.module Logical { } +// expected-error@+1 {{'spirv.module' expected valid keyword}} +spirv.module Logical { } // ----- // Wrong memory model -// expected-error@+1 {{'spv.module' invalid memory_model attribute specification: Bla}} -spv.module Logical Bla { } +// expected-error@+1 {{'spirv.module' invalid memory_model attribute specification: Bla}} +spirv.module Logical Bla { } // ----- // Module with multiple blocks // expected-error @+1 {{expects region #0 to have 0 or 1 blocks}} -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { ^first: - spv.Return + spirv.Return ^second: - spv.Return + spirv.Return } // ----- // Use non SPIR-V op inside module -spv.module Logical GLSL450 { - // expected-error @+1 {{'spv.module' can only contain spv.* ops}} +spirv.module Logical GLSL450 { + // expected-error @+1 {{'spirv.module' can only contain spirv.* ops}} "dialect.op"() : () -> () } // ----- // Use non SPIR-V op inside function -spv.module Logical GLSL450 { - spv.func @do_nothing() -> () "None" { - // expected-error @+1 {{functions in 'spv.module' can only contain spv.* ops}} +spirv.module Logical GLSL450 { + spirv.func @do_nothing() -> () "None" { + // expected-error @+1 {{functions in 'spirv.module' can only contain spirv.* ops}} "dialect.op"() : () -> () } } @@ -490,350 +490,350 @@ // ----- // Use external function -spv.module Logical GLSL450 { - // expected-error @+1 {{'spv.module' cannot contain external functions}} - spv.func @extern() -> () "None" +spirv.module Logical GLSL450 { + // expected-error @+1 {{'spirv.module' cannot contain external functions}} + spirv.func @extern() -> () "None" } // ----- //===----------------------------------------------------------------------===// -// spv.mlir.referenceof +// spirv.mlir.referenceof //===----------------------------------------------------------------------===// -spv.module Logical GLSL450 { - spv.SpecConstant @sc1 = false - spv.SpecConstant @sc2 = 42 : i64 - spv.SpecConstant @sc3 = 1.5 : f32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc1 = false + spirv.SpecConstant @sc2 = 42 : i64 + spirv.SpecConstant @sc3 = 1.5 : f32 - spv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.struct<(i1, i64, f32)> + spirv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spirv.struct<(i1, i64, f32)> // CHECK-LABEL: @reference - spv.func @reference() -> i1 "None" { - // CHECK: spv.mlir.referenceof @sc1 : i1 - %0 = spv.mlir.referenceof @sc1 : i1 - spv.ReturnValue %0 : i1 + spirv.func @reference() -> i1 "None" { + // CHECK: spirv.mlir.referenceof @sc1 : i1 + %0 = spirv.mlir.referenceof @sc1 : i1 + spirv.ReturnValue %0 : i1 } // CHECK-LABEL: @reference_composite - spv.func @reference_composite() -> i1 "None" { - // CHECK: spv.mlir.referenceof @scc : !spv.struct<(i1, i64, f32)> - %0 = spv.mlir.referenceof @scc : !spv.struct<(i1, i64, f32)> - %1 = spv.CompositeExtract %0[0 : i32] : !spv.struct<(i1, i64, f32)> - spv.ReturnValue %1 : i1 + spirv.func @reference_composite() -> i1 "None" { + // CHECK: spirv.mlir.referenceof @scc : !spirv.struct<(i1, i64, f32)> + %0 = spirv.mlir.referenceof @scc : !spirv.struct<(i1, i64, f32)> + %1 = spirv.CompositeExtract %0[0 : i32] : !spirv.struct<(i1, i64, f32)> + spirv.ReturnValue %1 : i1 } // CHECK-LABEL: @initialize - spv.func @initialize() -> i64 "None" { - // CHECK: spv.mlir.referenceof @sc2 : i64 - %0 = spv.mlir.referenceof @sc2 : i64 - %1 = spv.Variable init(%0) : !spv.ptr - %2 = spv.Load "Function" %1 : i64 - spv.ReturnValue %2 : i64 + spirv.func @initialize() -> i64 "None" { + // CHECK: spirv.mlir.referenceof @sc2 : i64 + %0 = spirv.mlir.referenceof @sc2 : i64 + %1 = spirv.Variable init(%0) : !spirv.ptr + %2 = spirv.Load "Function" %1 : i64 + spirv.ReturnValue %2 : i64 } // CHECK-LABEL: @compute - spv.func @compute() -> f32 "None" { - // CHECK: spv.mlir.referenceof @sc3 : f32 - %0 = spv.mlir.referenceof @sc3 : f32 - %1 = spv.Constant 6.0 : f32 - %2 = spv.FAdd %0, %1 : f32 - spv.ReturnValue %2 : f32 + spirv.func @compute() -> f32 "None" { + // CHECK: spirv.mlir.referenceof @sc3 : f32 + %0 = spirv.mlir.referenceof @sc3 : f32 + %1 = spirv.Constant 6.0 : f32 + %2 = spirv.FAdd %0, %1 : f32 + spirv.ReturnValue %2 : f32 } } // ----- // Allow taking reference of spec constant in other module-like ops -spv.SpecConstant @sc = 5 : i32 +spirv.SpecConstant @sc = 5 : i32 func.func @reference_of() { - // CHECK: spv.mlir.referenceof @sc - %0 = spv.mlir.referenceof @sc : i32 + // CHECK: spirv.mlir.referenceof @sc + %0 = spirv.mlir.referenceof @sc : i32 return } // ----- -spv.SpecConstant @sc = 5 : i32 -spv.SpecConstantComposite @scc (@sc) : !spv.array<1 x i32> +spirv.SpecConstant @sc = 5 : i32 +spirv.SpecConstantComposite @scc (@sc) : !spirv.array<1 x i32> func.func @reference_of_composite() { - // CHECK: spv.mlir.referenceof @scc : !spv.array<1 x i32> - %0 = spv.mlir.referenceof @scc : !spv.array<1 x i32> - %1 = spv.CompositeExtract %0[0 : i32] : !spv.array<1 x i32> + // CHECK: spirv.mlir.referenceof @scc : !spirv.array<1 x i32> + %0 = spirv.mlir.referenceof @scc : !spirv.array<1 x i32> + %1 = spirv.CompositeExtract %0[0 : i32] : !spirv.array<1 x i32> return } // ----- -spv.module Logical GLSL450 { - spv.func @foo() -> () "None" { - // expected-error @+1 {{expected spv.SpecConstant or spv.SpecConstantComposite symbol}} - %0 = spv.mlir.referenceof @sc : i32 - spv.Return +spirv.module Logical GLSL450 { + spirv.func @foo() -> () "None" { + // expected-error @+1 {{expected spirv.SpecConstant or spirv.SpecConstantComposite symbol}} + %0 = spirv.mlir.referenceof @sc : i32 + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc = 42 : i32 - spv.func @foo() -> () "None" { +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc = 42 : i32 + spirv.func @foo() -> () "None" { // expected-error @+1 {{result type mismatch with the referenced specialization constant's type}} - %0 = spv.mlir.referenceof @sc : f32 - spv.Return + %0 = spirv.mlir.referenceof @sc : f32 + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc = 42 : i32 - spv.SpecConstantComposite @scc (@sc) : !spv.array<1 x i32> - spv.func @foo() -> () "None" { +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc = 42 : i32 + spirv.SpecConstantComposite @scc (@sc) : !spirv.array<1 x i32> + spirv.func @foo() -> () "None" { // expected-error @+1 {{result type mismatch with the referenced specialization constant's type}} - %0 = spv.mlir.referenceof @scc : f32 - spv.Return + %0 = spirv.mlir.referenceof @scc : f32 + spirv.Return } } // ----- //===----------------------------------------------------------------------===// -// spv.SpecConstant +// spirv.SpecConstant //===----------------------------------------------------------------------===// -spv.module Logical GLSL450 { - // CHECK: spv.SpecConstant @sc1 = false - spv.SpecConstant @sc1 = false - // CHECK: spv.SpecConstant @sc2 spec_id(5) = 42 : i64 - spv.SpecConstant @sc2 spec_id(5) = 42 : i64 - // CHECK: spv.SpecConstant @sc3 = 1.500000e+00 : f32 - spv.SpecConstant @sc3 = 1.5 : f32 +spirv.module Logical GLSL450 { + // CHECK: spirv.SpecConstant @sc1 = false + spirv.SpecConstant @sc1 = false + // CHECK: spirv.SpecConstant @sc2 spec_id(5) = 42 : i64 + spirv.SpecConstant @sc2 spec_id(5) = 42 : i64 + // CHECK: spirv.SpecConstant @sc3 = 1.500000e+00 : f32 + spirv.SpecConstant @sc3 = 1.5 : f32 } // ----- -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { // expected-error @+1 {{SpecId cannot be negative}} - spv.SpecConstant @sc2 spec_id(-5) = 42 : i64 + spirv.SpecConstant @sc2 spec_id(-5) = 42 : i64 } // ----- -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { // expected-error @+1 {{default value bitwidth disallowed}} - spv.SpecConstant @sc = 15 : i4 + spirv.SpecConstant @sc = 15 : i4 } // ----- -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { // expected-error @+1 {{default value can only be a bool, integer, or float scalar}} - spv.SpecConstant @sc = dense<[2, 3]> : vector<2xi32> + spirv.SpecConstant @sc = dense<[2, 3]> : vector<2xi32> } // ----- func.func @use_in_function() -> () { // expected-error @+1 {{op must appear in a module-like op's block}} - spv.SpecConstant @sc = false + spirv.SpecConstant @sc = false return } // ----- //===----------------------------------------------------------------------===// -// spv.SpecConstantComposite +// spirv.SpecConstantComposite //===----------------------------------------------------------------------===// -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { // expected-error @+1 {{result type must be a composite type}} - spv.SpecConstantComposite @scc2 (@sc1, @sc2, @sc3) : i32 + spirv.SpecConstantComposite @scc2 (@sc1, @sc2, @sc3) : i32 } //===----------------------------------------------------------------------===// -// spv.SpecConstantComposite (spv.array) +// spirv.SpecConstantComposite (spirv.array) //===----------------------------------------------------------------------===// // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc1 = 1.5 : f32 - spv.SpecConstant @sc2 = 2.5 : f32 - spv.SpecConstant @sc3 = 3.5 : f32 - // CHECK: spv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.array<3 x f32> - spv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.array<3 x f32> +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc1 = 1.5 : f32 + spirv.SpecConstant @sc2 = 2.5 : f32 + spirv.SpecConstant @sc3 = 3.5 : f32 + // CHECK: spirv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spirv.array<3 x f32> + spirv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spirv.array<3 x f32> } // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc1 = false - spv.SpecConstant @sc2 spec_id(5) = 42 : i64 - spv.SpecConstant @sc3 = 1.5 : f32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc1 = false + spirv.SpecConstant @sc2 spec_id(5) = 42 : i64 + spirv.SpecConstant @sc3 = 1.5 : f32 // expected-error @+1 {{has incorrect number of operands: expected 4, but provided 3}} - spv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.array<4 x f32> + spirv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spirv.array<4 x f32> } // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc1 = 1 : i32 - spv.SpecConstant @sc2 = 2.5 : f32 - spv.SpecConstant @sc3 = 3.5 : f32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc1 = 1 : i32 + spirv.SpecConstant @sc2 = 2.5 : f32 + spirv.SpecConstant @sc3 = 3.5 : f32 // expected-error @+1 {{has incorrect types of operands: expected 'f32', but provided 'i32'}} - spv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.array<3 x f32> + spirv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spirv.array<3 x f32> } //===----------------------------------------------------------------------===// -// spv.SpecConstantComposite (spv.struct) +// spirv.SpecConstantComposite (spirv.struct) //===----------------------------------------------------------------------===// // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc1 = 1 : i32 - spv.SpecConstant @sc2 = 2.5 : f32 - spv.SpecConstant @sc3 = 3.5 : f32 - // CHECK: spv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.struct<(i32, f32, f32)> - spv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.struct<(i32, f32, f32)> +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc1 = 1 : i32 + spirv.SpecConstant @sc2 = 2.5 : f32 + spirv.SpecConstant @sc3 = 3.5 : f32 + // CHECK: spirv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spirv.struct<(i32, f32, f32)> + spirv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spirv.struct<(i32, f32, f32)> } // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc1 = 1 : i32 - spv.SpecConstant @sc2 = 2.5 : f32 - spv.SpecConstant @sc3 = 3.5 : f32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc1 = 1 : i32 + spirv.SpecConstant @sc2 = 2.5 : f32 + spirv.SpecConstant @sc3 = 3.5 : f32 // expected-error @+1 {{has incorrect number of operands: expected 2, but provided 3}} - spv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.struct<(i32, f32)> + spirv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spirv.struct<(i32, f32)> } // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc1 = 1.5 : f32 - spv.SpecConstant @sc2 = 2.5 : f32 - spv.SpecConstant @sc3 = 3.5 : f32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc1 = 1.5 : f32 + spirv.SpecConstant @sc2 = 2.5 : f32 + spirv.SpecConstant @sc3 = 3.5 : f32 // expected-error @+1 {{has incorrect types of operands: expected 'i32', but provided 'f32'}} - spv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spv.struct<(i32, f32, f32)> + spirv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : !spirv.struct<(i32, f32, f32)> } //===----------------------------------------------------------------------===// -// spv.SpecConstantComposite (vector) +// spirv.SpecConstantComposite (vector) //===----------------------------------------------------------------------===// // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc1 = 1.5 : f32 - spv.SpecConstant @sc2 = 2.5 : f32 - spv.SpecConstant @sc3 = 3.5 : f32 - // CHECK: spv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : vector<3xf32> - spv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : vector<3 x f32> +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc1 = 1.5 : f32 + spirv.SpecConstant @sc2 = 2.5 : f32 + spirv.SpecConstant @sc3 = 3.5 : f32 + // CHECK: spirv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : vector<3xf32> + spirv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : vector<3 x f32> } // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc1 = false - spv.SpecConstant @sc2 spec_id(5) = 42 : i64 - spv.SpecConstant @sc3 = 1.5 : f32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc1 = false + spirv.SpecConstant @sc2 spec_id(5) = 42 : i64 + spirv.SpecConstant @sc3 = 1.5 : f32 // expected-error @+1 {{has incorrect number of operands: expected 4, but provided 3}} - spv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : vector<4xf32> + spirv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : vector<4xf32> } // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc1 = 1 : i32 - spv.SpecConstant @sc2 = 2.5 : f32 - spv.SpecConstant @sc3 = 3.5 : f32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc1 = 1 : i32 + spirv.SpecConstant @sc2 = 2.5 : f32 + spirv.SpecConstant @sc3 = 3.5 : f32 // expected-error @+1 {{has incorrect types of operands: expected 'f32', but provided 'i32'}} - spv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : vector<3xf32> + spirv.SpecConstantComposite @scc (@sc1, @sc2, @sc3) : vector<3xf32> } //===----------------------------------------------------------------------===// -// spv.SpecConstantComposite (spv.coopmatrix) +// spirv.SpecConstantComposite (spirv.coopmatrix) //===----------------------------------------------------------------------===// // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc1 = 1.5 : f32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc1 = 1.5 : f32 // expected-error @+1 {{unsupported composite type}} - spv.SpecConstantComposite @scc (@sc1) : !spv.coopmatrix<8x16xf32, Device> + spirv.SpecConstantComposite @scc (@sc1) : !spirv.coopmatrix<8x16xf32, Device> } //===----------------------------------------------------------------------===// -// spv.SpecConstantOperation +// spirv.SpecConstantOperation //===----------------------------------------------------------------------===// // ----- -spv.module Logical GLSL450 { - spv.func @foo() -> i32 "None" { - // CHECK: [[LHS:%.*]] = spv.Constant - %0 = spv.Constant 1: i32 - // CHECK: [[RHS:%.*]] = spv.Constant - %1 = spv.Constant 1: i32 +spirv.module Logical GLSL450 { + spirv.func @foo() -> i32 "None" { + // CHECK: [[LHS:%.*]] = spirv.Constant + %0 = spirv.Constant 1: i32 + // CHECK: [[RHS:%.*]] = spirv.Constant + %1 = spirv.Constant 1: i32 - // CHECK: spv.SpecConstantOperation wraps "spv.IAdd"([[LHS]], [[RHS]]) : (i32, i32) -> i32 - %2 = spv.SpecConstantOperation wraps "spv.IAdd"(%0, %1) : (i32, i32) -> i32 + // CHECK: spirv.SpecConstantOperation wraps "spirv.IAdd"([[LHS]], [[RHS]]) : (i32, i32) -> i32 + %2 = spirv.SpecConstantOperation wraps "spirv.IAdd"(%0, %1) : (i32, i32) -> i32 - spv.ReturnValue %2 : i32 + spirv.ReturnValue %2 : i32 } } // ----- -spv.module Logical GLSL450 { - spv.SpecConstant @sc = 42 : i32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @sc = 42 : i32 - spv.func @foo() -> i32 "None" { - // CHECK: [[SC:%.*]] = spv.mlir.referenceof @sc - %0 = spv.mlir.referenceof @sc : i32 - // CHECK: spv.SpecConstantOperation wraps "spv.ISub"([[SC]], [[SC]]) : (i32, i32) -> i32 - %1 = spv.SpecConstantOperation wraps "spv.ISub"(%0, %0) : (i32, i32) -> i32 - spv.ReturnValue %1 : i32 + spirv.func @foo() -> i32 "None" { + // CHECK: [[SC:%.*]] = spirv.mlir.referenceof @sc + %0 = spirv.mlir.referenceof @sc : i32 + // CHECK: spirv.SpecConstantOperation wraps "spirv.ISub"([[SC]], [[SC]]) : (i32, i32) -> i32 + %1 = spirv.SpecConstantOperation wraps "spirv.ISub"(%0, %0) : (i32, i32) -> i32 + spirv.ReturnValue %1 : i32 } } // ----- -spv.module Logical GLSL450 { - spv.func @foo() -> i32 "None" { - %0 = spv.Constant 1: i32 - // expected-error @+1 {{op expects parent op 'spv.SpecConstantOperation'}} - spv.mlir.yield %0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo() -> i32 "None" { + %0 = spirv.Constant 1: i32 + // expected-error @+1 {{op expects parent op 'spirv.SpecConstantOperation'}} + spirv.mlir.yield %0 : i32 } } // ----- -spv.module Logical GLSL450 { - spv.func @foo() -> () "None" { - %0 = spv.Variable : !spv.ptr +spirv.module Logical GLSL450 { + spirv.func @foo() -> () "None" { + %0 = spirv.Variable : !spirv.ptr // expected-error @+1 {{invalid enclosed op}} - %1 = spv.SpecConstantOperation wraps "spv.Load"(%0) {memory_access = #spv.memory_access} : (!spv.ptr) -> i32 - spv.Return + %1 = spirv.SpecConstantOperation wraps "spirv.Load"(%0) {memory_access = #spirv.memory_access} : (!spirv.ptr) -> i32 + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.func @foo() -> () "None" { - %0 = spv.Variable : !spv.ptr - %1 = spv.Load "Function" %0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo() -> () "None" { + %0 = spirv.Variable : !spirv.ptr + %1 = spirv.Load "Function" %0 : i32 // expected-error @+1 {{invalid operand, must be defined by a constant operation}} - %2 = spv.SpecConstantOperation wraps "spv.IAdd"(%1, %1) : (i32, i32) -> i32 + %2 = spirv.SpecConstantOperation wraps "spirv.IAdd"(%1, %1) : (i32, i32) -> i32 - spv.Return + spirv.Return } } diff --git a/mlir/test/Dialect/SPIRV/IR/target-and-abi.mlir b/mlir/test/Dialect/SPIRV/IR/target-and-abi.mlir --- a/mlir/test/Dialect/SPIRV/IR/target-and-abi.mlir +++ b/mlir/test/Dialect/SPIRV/IR/target-and-abi.mlir @@ -1,21 +1,21 @@ // RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s -// expected-error @+1 {{found unsupported 'spv.something' attribute on operation}} +// expected-error @+1 {{found unsupported 'spirv.something' attribute on operation}} func.func @unknown_attr_on_op() attributes { - spv.something = 64 + spirv.something = 64 } { return } // ----- -// expected-error @+1 {{found unsupported 'spv.something' attribute on region argument}} -func.func @unknown_attr_on_region(%arg: i32 {spv.something}) { +// expected-error @+1 {{found unsupported 'spirv.something' attribute on region argument}} +func.func @unknown_attr_on_region(%arg: i32 {spirv.something}) { return } // ----- // expected-error @+1 {{cannot attach SPIR-V attributes to region result}} -func.func @unknown_attr_on_region() -> (i32 {spv.something}) { +func.func @unknown_attr_on_region() -> (i32 {spirv.something}) { %0 = arith.constant 10.0 : f32 return %0: f32 } @@ -23,12 +23,12 @@ // ----- //===----------------------------------------------------------------------===// -// spv.entry_point_abi +// spirv.entry_point_abi //===----------------------------------------------------------------------===// -// expected-error @+1 {{'spv.entry_point_abi' attribute must be an entry point ABI attribute}} +// expected-error @+1 {{'spirv.entry_point_abi' attribute must be an entry point ABI attribute}} func.func @spv_entry_point() attributes { - spv.entry_point_abi = 64 + spirv.entry_point_abi = 64 } { return } // ----- @@ -36,82 +36,82 @@ func.func @spv_entry_point() attributes { // expected-error @+2 {{failed to parse SPV_EntryPointABIAttr parameter 'local_size' which is to be a `DenseIntElementsAttr`}} // expected-error @+1 {{invalid kind of attribute specified}} - spv.entry_point_abi = #spv.entry_point_abi + spirv.entry_point_abi = #spirv.entry_point_abi } { return } // ----- func.func @spv_entry_point() attributes { - // CHECK: {spv.entry_point_abi = #spv.entry_point_abi : vector<3xi32>>} - spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>> + // CHECK: {spirv.entry_point_abi = #spirv.entry_point_abi : vector<3xi32>>} + spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>> } { return } // ----- //===----------------------------------------------------------------------===// -// spv.interface_var_abi +// spirv.interface_var_abi //===----------------------------------------------------------------------===// -// expected-error @+1 {{'spv.interface_var_abi' must be a spirv::InterfaceVarABIAttr}} +// expected-error @+1 {{'spirv.interface_var_abi' must be a spirv::InterfaceVarABIAttr}} func.func @interface_var( - %arg0 : f32 {spv.interface_var_abi = 64} + %arg0 : f32 {spirv.interface_var_abi = 64} ) { return } // ----- func.func @interface_var( // expected-error @+1 {{missing descriptor set}} - %arg0 : f32 {spv.interface_var_abi = #spv.interface_var_abi<()>} + %arg0 : f32 {spirv.interface_var_abi = #spirv.interface_var_abi<()>} ) { return } // ----- func.func @interface_var( // expected-error @+1 {{missing binding}} - %arg0 : f32 {spv.interface_var_abi = #spv.interface_var_abi<(1,)>} + %arg0 : f32 {spirv.interface_var_abi = #spirv.interface_var_abi<(1,)>} ) { return } // ----- func.func @interface_var( // expected-error @+1 {{unknown storage class: }} - %arg0 : f32 {spv.interface_var_abi = #spv.interface_var_abi<(1,2), Foo>} + %arg0 : f32 {spirv.interface_var_abi = #spirv.interface_var_abi<(1,2), Foo>} ) { return } // ----- -// CHECK: {spv.interface_var_abi = #spv.interface_var_abi<(0, 1), Uniform>} +// CHECK: {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1), Uniform>} func.func @interface_var( - %arg0 : f32 {spv.interface_var_abi = #spv.interface_var_abi<(0, 1), Uniform>} + %arg0 : f32 {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1), Uniform>} ) { return } // ----- -// CHECK: {spv.interface_var_abi = #spv.interface_var_abi<(0, 1)>} +// CHECK: {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1)>} func.func @interface_var( - %arg0 : f32 {spv.interface_var_abi = #spv.interface_var_abi<(0, 1)>} + %arg0 : f32 {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1)>} ) { return } // ----- -// expected-error @+1 {{'spv.interface_var_abi' attribute cannot specify storage class when attaching to a non-scalar value}} +// expected-error @+1 {{'spirv.interface_var_abi' attribute cannot specify storage class when attaching to a non-scalar value}} func.func @interface_var( - %arg0 : memref<4xf32> {spv.interface_var_abi = #spv.interface_var_abi<(0, 1), Uniform>} + %arg0 : memref<4xf32> {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1), Uniform>} ) { return } // ----- //===----------------------------------------------------------------------===// -// spv.target_env +// spirv.target_env //===----------------------------------------------------------------------===// func.func @target_env() attributes { - // CHECK: spv.target_env = #spv.target_env< - // CHECK-SAME: #spv.vce, - // CHECK-SAME: #spv.resource_limits> - spv.target_env = #spv.target_env< - #spv.vce, - #spv.resource_limits< + // CHECK: spirv.target_env = #spirv.target_env< + // CHECK-SAME: #spirv.vce, + // CHECK-SAME: #spirv.resource_limits> + spirv.target_env = #spirv.target_env< + #spirv.vce, + #spirv.resource_limits< max_compute_workgroup_size = [128, 64, 64] >> } { return } @@ -119,40 +119,40 @@ // ----- func.func @target_env_vendor_id() attributes { - // CHECK: spv.target_env = #spv.target_env< - // CHECK-SAME: #spv.vce, + // CHECK: spirv.target_env = #spirv.target_env< + // CHECK-SAME: #spirv.vce, // CHECK-SAME: NVIDIA, - // CHECK-SAME: #spv.resource_limits<>> - spv.target_env = #spv.target_env<#spv.vce, NVIDIA, #spv.resource_limits<>> + // CHECK-SAME: #spirv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, NVIDIA, #spirv.resource_limits<>> } { return } // ----- func.func @target_env_vendor_id_device_type() attributes { - // CHECK: spv.target_env = #spv.target_env< - // CHECK-SAME: #spv.vce, + // CHECK: spirv.target_env = #spirv.target_env< + // CHECK-SAME: #spirv.vce, // CHECK-SAME: AMD:DiscreteGPU, - // CHECK-SAME: #spv.resource_limits<>> - spv.target_env = #spv.target_env<#spv.vce, AMD:DiscreteGPU, #spv.resource_limits<>> + // CHECK-SAME: #spirv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, AMD:DiscreteGPU, #spirv.resource_limits<>> } { return } // ----- func.func @target_env_vendor_id_device_type_device_id() attributes { - // CHECK: spv.target_env = #spv.target_env< - // CHECK-SAME: #spv.vce, + // CHECK: spirv.target_env = #spirv.target_env< + // CHECK-SAME: #spirv.vce, // CHECK-SAME: Qualcomm:IntegratedGPU:100925441, - // CHECK-SAME: #spv.resource_limits<>> - spv.target_env = #spv.target_env<#spv.vce, Qualcomm:IntegratedGPU:0x6040001, #spv.resource_limits<>> + // CHECK-SAME: #spirv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, Qualcomm:IntegratedGPU:0x6040001, #spirv.resource_limits<>> } { return } // ----- func.func @target_env_extra_fields() attributes { // expected-error @+3 {{expected '>'}} - spv.target_env = #spv.target_env< - #spv.vce, - #spv.resource_limits<>, + spirv.target_env = #spirv.target_env< + #spirv.vce, + #spirv.resource_limits<>, more_stuff > } { return } @@ -160,21 +160,21 @@ // ----- func.func @target_env_cooperative_matrix() attributes{ - // CHECK: spv.target_env = #spv.target_env< + // CHECK: spirv.target_env = #spirv.target_env< // CHECK-SAME: SPV_NV_cooperative_matrix - // CHECK-SAME: #spv.coop_matrix_props< + // CHECK-SAME: #spirv.coop_matrix_props< // CHECK-SAME: m_size = 8, n_size = 8, k_size = 32, // CHECK-SAME: a_type = i8, b_type = i8, c_type = i32, // CHECK-SAME: result_type = i32, scope = > - // CHECK-SAME: #spv.coop_matrix_props< + // CHECK-SAME: #spirv.coop_matrix_props< // CHECK-SAME: m_size = 8, n_size = 8, k_size = 16, // CHECK-SAME: a_type = f16, b_type = f16, c_type = f16, // CHECK-SAME: result_type = f16, scope = > - spv.target_env = #spv.target_env< - #spv.vce, - #spv.resource_limits< - cooperative_matrix_properties_nv = [#spv.coop_matrix_props< + #spirv.resource_limits< + cooperative_matrix_properties_nv = [#spirv.coop_matrix_props< m_size = 8, n_size = 8, k_size = 32, @@ -182,8 +182,8 @@ b_type = i8, c_type = i32, result_type = i32, - scope = #spv.scope - >, #spv.coop_matrix_props< + scope = #spirv.scope + >, #spirv.coop_matrix_props< m_size = 8, n_size = 8, k_size = 16, @@ -191,7 +191,7 @@ b_type = f16, c_type = f16, result_type = f16, - scope = #spv.scope + scope = #spirv.scope >] >> } { return } @@ -199,52 +199,52 @@ // ----- //===----------------------------------------------------------------------===// -// spv.vce +// spirv.vce //===----------------------------------------------------------------------===// func.func @vce_wrong_type() attributes { // expected-error @+1 {{expected valid keyword}} - vce = #spv.vce<64> + vce = #spirv.vce<64> } { return } // ----- func.func @vce_missing_fields() attributes { // expected-error @+1 {{expected ','}} - vce = #spv.vce + vce = #spirv.vce } { return } // ----- func.func @vce_wrong_version() attributes { // expected-error @+1 {{unknown version: V_x_y}} - vce = #spv.vce + vce = #spirv.vce } { return } // ----- func.func @vce_wrong_extension_type() attributes { // expected-error @+1 {{expected valid keyword}} - vce = #spv.vce + vce = #spirv.vce } { return } // ----- func.func @vce_wrong_extension() attributes { // expected-error @+1 {{unknown extension: SPV_Something}} - vce = #spv.vce + vce = #spirv.vce } { return } // ----- func.func @vce_wrong_capability() attributes { // expected-error @+1 {{unknown capability: Something}} - vce = #spv.vce + vce = #spirv.vce } { return } // ----- func.func @vce() attributes { - // CHECK: #spv.vce - vce = #spv.vce + // CHECK: #spirv.vce + vce = #spirv.vce } { return } diff --git a/mlir/test/Dialect/SPIRV/IR/target-env.mlir b/mlir/test/Dialect/SPIRV/IR/target-env.mlir --- a/mlir/test/Dialect/SPIRV/IR/target-env.mlir +++ b/mlir/test/Dialect/SPIRV/IR/target-env.mlir @@ -1,22 +1,22 @@ // RUN: mlir-opt -mlir-disable-threading -test-spirv-target-env %s | FileCheck %s -// Note: The following tests check that a spv.target_env can properly control +// Note: The following tests check that a spirv.target_env can properly control // the conversion target and filter unavailable ops during the conversion. // We don't care about the op argument consistency too much; so certain enum // values for enum attributes may not make much sense for the test op. -// spv.AtomicCompareExchangeWeak is available from SPIR-V 1.0 to 1.3 under +// spirv.AtomicCompareExchangeWeak is available from SPIR-V 1.0 to 1.3 under // Kernel capability. -// spv.AtomicCompareExchangeWeak has two memory semantics enum attribute, +// spirv.AtomicCompareExchangeWeak has two memory semantics enum attribute, // whose value, if containing AtomicCounterMemory bit, additionally requires // AtomicStorage capability. -// spv.BitReverse is available in all SPIR-V versions under Shader capability. +// spirv.BitReverse is available in all SPIR-V versions under Shader capability. -// spv.GroupNonUniformBallot is available starting from SPIR-V 1.3 under +// spirv.GroupNonUniformBallot is available starting from SPIR-V 1.3 under // GroupNonUniform capability. -// spv.KHR.SubgroupBallot is available under in all SPIR-V versions under +// spirv.KHR.SubgroupBallot is available under in all SPIR-V versions under // SubgroupBallotKHR capability and SPV_KHR_shader_ballot extension. // The GeometryPointSize capability implies the Geometry capability, which @@ -34,20 +34,20 @@ //===----------------------------------------------------------------------===// // CHECK-LABEL: @cmp_exchange_weak_suitable_version_capabilities -func.func @cmp_exchange_weak_suitable_version_capabilities(%ptr: !spv.ptr, %value: i32, %comparator: i32) -> i32 attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> +func.func @cmp_exchange_weak_suitable_version_capabilities(%ptr: !spirv.ptr, %value: i32, %comparator: i32) -> i32 attributes { + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { - // CHECK: spv.AtomicCompareExchangeWeak "Workgroup" "AcquireRelease|AtomicCounterMemory" "Acquire" - %0 = "test.convert_to_atomic_compare_exchange_weak_op"(%ptr, %value, %comparator): (!spv.ptr, i32, i32) -> (i32) + // CHECK: spirv.AtomicCompareExchangeWeak "Workgroup" "AcquireRelease|AtomicCounterMemory" "Acquire" + %0 = "test.convert_to_atomic_compare_exchange_weak_op"(%ptr, %value, %comparator): (!spirv.ptr, i32, i32) -> (i32) return %0: i32 } // CHECK-LABEL: @cmp_exchange_weak_unsupported_version -func.func @cmp_exchange_weak_unsupported_version(%ptr: !spv.ptr, %value: i32, %comparator: i32) -> i32 attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> +func.func @cmp_exchange_weak_unsupported_version(%ptr: !spirv.ptr, %value: i32, %comparator: i32) -> i32 attributes { + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK: test.convert_to_atomic_compare_exchange_weak_op - %0 = "test.convert_to_atomic_compare_exchange_weak_op"(%ptr, %value, %comparator): (!spv.ptr, i32, i32) -> (i32) + %0 = "test.convert_to_atomic_compare_exchange_weak_op"(%ptr, %value, %comparator): (!spirv.ptr, i32, i32) -> (i32) return %0: i32 } @@ -57,16 +57,16 @@ // CHECK-LABEL: @group_non_uniform_ballot_suitable_version func.func @group_non_uniform_ballot_suitable_version(%predicate: i1) -> vector<4xi32> attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { - // CHECK: spv.GroupNonUniformBallot + // CHECK: spirv.GroupNonUniformBallot %0 = "test.convert_to_group_non_uniform_ballot_op"(%predicate): (i1) -> (vector<4xi32>) return %0: vector<4xi32> } // CHECK-LABEL: @group_non_uniform_ballot_unsupported_version func.func @group_non_uniform_ballot_unsupported_version(%predicate: i1) -> vector<4xi32> attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK: test.convert_to_group_non_uniform_ballot_op %0 = "test.convert_to_group_non_uniform_ballot_op"(%predicate): (i1) -> (vector<4xi32>) @@ -78,26 +78,26 @@ //===----------------------------------------------------------------------===// // CHECK-LABEL: @cmp_exchange_weak_missing_capability_kernel -func.func @cmp_exchange_weak_missing_capability_kernel(%ptr: !spv.ptr, %value: i32, %comparator: i32) -> i32 attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> +func.func @cmp_exchange_weak_missing_capability_kernel(%ptr: !spirv.ptr, %value: i32, %comparator: i32) -> i32 attributes { + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK: test.convert_to_atomic_compare_exchange_weak_op - %0 = "test.convert_to_atomic_compare_exchange_weak_op"(%ptr, %value, %comparator): (!spv.ptr, i32, i32) -> (i32) + %0 = "test.convert_to_atomic_compare_exchange_weak_op"(%ptr, %value, %comparator): (!spirv.ptr, i32, i32) -> (i32) return %0: i32 } // CHECK-LABEL: @cmp_exchange_weak_missing_capability_atomic_storage -func.func @cmp_exchange_weak_missing_capability_atomic_storage(%ptr: !spv.ptr, %value: i32, %comparator: i32) -> i32 attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> +func.func @cmp_exchange_weak_missing_capability_atomic_storage(%ptr: !spirv.ptr, %value: i32, %comparator: i32) -> i32 attributes { + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK: test.convert_to_atomic_compare_exchange_weak_op - %0 = "test.convert_to_atomic_compare_exchange_weak_op"(%ptr, %value, %comparator): (!spv.ptr, i32, i32) -> (i32) + %0 = "test.convert_to_atomic_compare_exchange_weak_op"(%ptr, %value, %comparator): (!spirv.ptr, i32, i32) -> (i32) return %0: i32 } // CHECK-LABEL: @subgroup_ballot_missing_capability func.func @subgroup_ballot_missing_capability(%predicate: i1) -> vector<4xi32> attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK: test.convert_to_subgroup_ballot_op %0 = "test.convert_to_subgroup_ballot_op"(%predicate): (i1) -> (vector<4xi32>) @@ -106,18 +106,18 @@ // CHECK-LABEL: @bit_reverse_directly_implied_capability func.func @bit_reverse_directly_implied_capability(%operand: i32) -> i32 attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { - // CHECK: spv.BitReverse + // CHECK: spirv.BitReverse %0 = "test.convert_to_bit_reverse_op"(%operand): (i32) -> (i32) return %0: i32 } // CHECK-LABEL: @bit_reverse_recursively_implied_capability func.func @bit_reverse_recursively_implied_capability(%operand: i32) -> i32 attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { - // CHECK: spv.BitReverse + // CHECK: spirv.BitReverse %0 = "test.convert_to_bit_reverse_op"(%operand): (i32) -> (i32) return %0: i32 } @@ -128,16 +128,16 @@ // CHECK-LABEL: @subgroup_ballot_suitable_extension func.func @subgroup_ballot_suitable_extension(%predicate: i1) -> vector<4xi32> attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { - // CHECK: spv.KHR.SubgroupBallot + // CHECK: spirv.KHR.SubgroupBallot %0 = "test.convert_to_subgroup_ballot_op"(%predicate): (i1) -> (vector<4xi32>) return %0: vector<4xi32> } // CHECK-LABEL: @subgroup_ballot_missing_extension func.func @subgroup_ballot_missing_extension(%predicate: i1) -> vector<4xi32> attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK: test.convert_to_subgroup_ballot_op %0 = "test.convert_to_subgroup_ballot_op"(%predicate): (i1) -> (vector<4xi32>) @@ -146,25 +146,25 @@ // CHECK-LABEL: @module_suitable_extension1 func.func @module_suitable_extension1() attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { - // CHECK: spv.module PhysicalStorageBuffer64 Vulkan + // CHECK: spirv.module PhysicalStorageBuffer64 Vulkan "test.convert_to_module_op"() : () ->() return } // CHECK-LABEL: @module_suitable_extension2 func.func @module_suitable_extension2() attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { - // CHECK: spv.module PhysicalStorageBuffer64 Vulkan + // CHECK: spirv.module PhysicalStorageBuffer64 Vulkan "test.convert_to_module_op"() : () -> () return } // CHECK-LABEL: @module_missing_extension_mm func.func @module_missing_extension_mm() attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK: test.convert_to_module_op "test.convert_to_module_op"() : () -> () @@ -173,7 +173,7 @@ // CHECK-LABEL: @module_missing_extension_am func.func @module_missing_extension_am() attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { // CHECK: test.convert_to_module_op "test.convert_to_module_op"() : () -> () @@ -183,9 +183,9 @@ // CHECK-LABEL: @module_implied_extension func.func @module_implied_extension() attributes { // Version 1.5 implies SPV_KHR_vulkan_memory_model and SPV_KHR_physical_storage_buffer. - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { - // CHECK: spv.module PhysicalStorageBuffer64 Vulkan + // CHECK: spirv.module PhysicalStorageBuffer64 Vulkan "test.convert_to_module_op"() : () -> () return } diff --git a/mlir/test/Dialect/SPIRV/IR/types.mlir b/mlir/test/Dialect/SPIRV/IR/types.mlir --- a/mlir/test/Dialect/SPIRV/IR/types.mlir +++ b/mlir/test/Dialect/SPIRV/IR/types.mlir @@ -6,84 +6,84 @@ // ArrayType //===----------------------------------------------------------------------===// -// CHECK: func private @scalar_array_type(!spv.array<16 x f32>, !spv.array<8 x i32>) -func.func private @scalar_array_type(!spv.array<16xf32>, !spv.array<8 x i32>) -> () +// CHECK: func private @scalar_array_type(!spirv.array<16 x f32>, !spirv.array<8 x i32>) +func.func private @scalar_array_type(!spirv.array<16xf32>, !spirv.array<8 x i32>) -> () -// CHECK: func private @vector_array_type(!spv.array<32 x vector<4xf32>>) -func.func private @vector_array_type(!spv.array< 32 x vector<4xf32> >) -> () +// CHECK: func private @vector_array_type(!spirv.array<32 x vector<4xf32>>) +func.func private @vector_array_type(!spirv.array< 32 x vector<4xf32> >) -> () -// CHECK: func private @array_type_stride(!spv.array<4 x !spv.array<4 x f32, stride=4>, stride=128>) -func.func private @array_type_stride(!spv.array< 4 x !spv.array<4 x f32, stride=4>, stride = 128>) -> () +// CHECK: func private @array_type_stride(!spirv.array<4 x !spirv.array<4 x f32, stride=4>, stride=128>) +func.func private @array_type_stride(!spirv.array< 4 x !spirv.array<4 x f32, stride=4>, stride = 128>) -> () // ----- // expected-error @+1 {{expected '<'}} -func.func private @missing_left_angle_bracket(!spv.array 4xf32>) -> () +func.func private @missing_left_angle_bracket(!spirv.array 4xf32>) -> () // ----- // expected-error @+1 {{expected single integer for array element count}} -func.func private @missing_count(!spv.array) -> () +func.func private @missing_count(!spirv.array) -> () // ----- // expected-error @+1 {{expected 'x' in dimension list}} -func.func private @missing_x(!spv.array<4 f32>) -> () +func.func private @missing_x(!spirv.array<4 f32>) -> () // ----- // expected-error @+1 {{expected non-function type}} -func.func private @missing_element_type(!spv.array<4x>) -> () +func.func private @missing_element_type(!spirv.array<4x>) -> () // ----- // expected-error @+1 {{expected non-function type}} -func.func private @cannot_parse_type(!spv.array<4xblabla>) -> () +func.func private @cannot_parse_type(!spirv.array<4xblabla>) -> () // ----- // expected-error @+1 {{expected single integer for array element count}} -func.func private @more_than_one_dim(!spv.array<4x3xf32>) -> () +func.func private @more_than_one_dim(!spirv.array<4x3xf32>) -> () // ----- // expected-error @+1 {{only 1-D vector allowed but found 'vector<4x3xf32>'}} -func.func private @non_1D_vector(!spv.array<4xvector<4x3xf32>>) -> () +func.func private @non_1D_vector(!spirv.array<4xvector<4x3xf32>>) -> () // ----- // expected-error @+1 {{cannot use 'tensor<4xf32>' to compose SPIR-V types}} -func.func private @tensor_type(!spv.array<4xtensor<4xf32>>) -> () +func.func private @tensor_type(!spirv.array<4xtensor<4xf32>>) -> () // ----- // expected-error @+1 {{cannot use 'bf16' to compose SPIR-V types}} -func.func private @bf16_type(!spv.array<4xbf16>) -> () +func.func private @bf16_type(!spirv.array<4xbf16>) -> () // ----- // expected-error @+1 {{only 1/8/16/32/64-bit integer type allowed but found 'i256'}} -func.func private @i256_type(!spv.array<4xi256>) -> () +func.func private @i256_type(!spirv.array<4xi256>) -> () // ----- // expected-error @+1 {{cannot use 'index' to compose SPIR-V types}} -func.func private @index_type(!spv.array<4xindex>) -> () +func.func private @index_type(!spirv.array<4xindex>) -> () // ----- // expected-error @+1 {{cannot use '!llvm.struct<()>' to compose SPIR-V types}} -func.func private @llvm_type(!spv.array<4x!llvm.struct<()>>) -> () +func.func private @llvm_type(!spirv.array<4x!llvm.struct<()>>) -> () // ----- // expected-error @+1 {{ArrayStride must be greater than zero}} -func.func private @array_type_zero_stride(!spv.array<4xi32, stride=0>) -> () +func.func private @array_type_zero_stride(!spirv.array<4xi32, stride=0>) -> () // ----- // expected-error @+1 {{expected array length greater than 0}} -func.func private @array_type_zero_length(!spv.array<0xf32>) -> () +func.func private @array_type_zero_length(!spirv.array<0xf32>) -> () // ----- @@ -91,34 +91,34 @@ // PointerType //===----------------------------------------------------------------------===// -// CHECK: @bool_ptr_type(!spv.ptr) -func.func private @bool_ptr_type(!spv.ptr) -> () +// CHECK: @bool_ptr_type(!spirv.ptr) +func.func private @bool_ptr_type(!spirv.ptr) -> () -// CHECK: @scalar_ptr_type(!spv.ptr) -func.func private @scalar_ptr_type(!spv.ptr) -> () +// CHECK: @scalar_ptr_type(!spirv.ptr) +func.func private @scalar_ptr_type(!spirv.ptr) -> () -// CHECK: @vector_ptr_type(!spv.ptr, PushConstant>) -func.func private @vector_ptr_type(!spv.ptr,PushConstant>) -> () +// CHECK: @vector_ptr_type(!spirv.ptr, PushConstant>) +func.func private @vector_ptr_type(!spirv.ptr,PushConstant>) -> () // ----- // expected-error @+1 {{expected '<'}} -func.func private @missing_left_angle_bracket(!spv.ptr f32, Uniform>) -> () +func.func private @missing_left_angle_bracket(!spirv.ptr f32, Uniform>) -> () // ----- // expected-error @+1 {{expected ','}} -func.func private @missing_comma(!spv.ptr) -> () +func.func private @missing_comma(!spirv.ptr) -> () // ----- // expected-error @+1 {{expected non-function type}} -func.func private @missing_pointee_type(!spv.ptr<, Uniform>) -> () +func.func private @missing_pointee_type(!spirv.ptr<, Uniform>) -> () // ----- // expected-error @+1 {{unknown storage class: SomeStorageClass}} -func.func private @unknown_storage_class(!spv.ptr) -> () +func.func private @unknown_storage_class(!spirv.ptr) -> () // ----- @@ -126,34 +126,34 @@ // RuntimeArrayType //===----------------------------------------------------------------------===// -// CHECK: func private @scalar_runtime_array_type(!spv.rtarray, !spv.rtarray) -func.func private @scalar_runtime_array_type(!spv.rtarray, !spv.rtarray) -> () +// CHECK: func private @scalar_runtime_array_type(!spirv.rtarray, !spirv.rtarray) +func.func private @scalar_runtime_array_type(!spirv.rtarray, !spirv.rtarray) -> () -// CHECK: func private @vector_runtime_array_type(!spv.rtarray>) -func.func private @vector_runtime_array_type(!spv.rtarray< vector<4xf32> >) -> () +// CHECK: func private @vector_runtime_array_type(!spirv.rtarray>) +func.func private @vector_runtime_array_type(!spirv.rtarray< vector<4xf32> >) -> () -// CHECK: func private @runtime_array_type_stride(!spv.rtarray) -func.func private @runtime_array_type_stride(!spv.rtarray) -> () +// CHECK: func private @runtime_array_type_stride(!spirv.rtarray) +func.func private @runtime_array_type_stride(!spirv.rtarray) -> () // ----- // expected-error @+1 {{expected '<'}} -func.func private @missing_left_angle_bracket(!spv.rtarray f32>) -> () +func.func private @missing_left_angle_bracket(!spirv.rtarray f32>) -> () // ----- // expected-error @+1 {{expected non-function type}} -func.func private @missing_element_type(!spv.rtarray<>) -> () +func.func private @missing_element_type(!spirv.rtarray<>) -> () // ----- // expected-error @+1 {{expected non-function type}} -func.func private @redundant_count(!spv.rtarray<4xf32>) -> () +func.func private @redundant_count(!spirv.rtarray<4xf32>) -> () // ----- // expected-error @+1 {{ArrayStride must be greater than zero}} -func.func private @runtime_array_type_zero_stride(!spv.rtarray) -> () +func.func private @runtime_array_type_zero_stride(!spirv.rtarray) -> () // ----- @@ -161,68 +161,68 @@ // ImageType //===----------------------------------------------------------------------===// -// CHECK: func private @image_parameters_1D(!spv.image) -func.func private @image_parameters_1D(!spv.image) -> () +// CHECK: func private @image_parameters_1D(!spirv.image) +func.func private @image_parameters_1D(!spirv.image) -> () // ----- // expected-error @+1 {{expected ','}} -func.func private @image_parameters_one_element(!spv.image) -> () +func.func private @image_parameters_one_element(!spirv.image) -> () // ----- // expected-error @+1 {{expected ','}} -func.func private @image_parameters_two_elements(!spv.image) -> () +func.func private @image_parameters_two_elements(!spirv.image) -> () // ----- // expected-error @+1 {{expected ','}} -func.func private @image_parameters_three_elements(!spv.image) -> () +func.func private @image_parameters_three_elements(!spirv.image) -> () // ----- // expected-error @+1 {{expected ','}} -func.func private @image_parameters_four_elements(!spv.image) -> () +func.func private @image_parameters_four_elements(!spirv.image) -> () // ----- // expected-error @+1 {{expected ','}} -func.func private @image_parameters_five_elements(!spv.image) -> () +func.func private @image_parameters_five_elements(!spirv.image) -> () // ----- // expected-error @+1 {{expected ','}} -func.func private @image_parameters_six_elements(!spv.image) -> () +func.func private @image_parameters_six_elements(!spirv.image) -> () // ----- // expected-error @+1 {{expected '<'}} -func.func private @image_parameters_delimiter(!spv.image f32, Dim1D, NoDepth, NonArrayed, SingleSampled, SamplerUnknown, Unknown>) -> () +func.func private @image_parameters_delimiter(!spirv.image f32, Dim1D, NoDepth, NonArrayed, SingleSampled, SamplerUnknown, Unknown>) -> () // ----- // expected-error @+1 {{expected ','}} -func.func private @image_parameters_nocomma_1(!spv.image) -> () +func.func private @image_parameters_nocomma_1(!spirv.image) -> () // ----- // expected-error @+1 {{expected ','}} -func.func private @image_parameters_nocomma_2(!spv.image) -> () +func.func private @image_parameters_nocomma_2(!spirv.image) -> () // ----- // expected-error @+1 {{expected ','}} -func.func private @image_parameters_nocomma_3(!spv.image) -> () +func.func private @image_parameters_nocomma_3(!spirv.image) -> () // ----- // expected-error @+1 {{expected ','}} -func.func private @image_parameters_nocomma_4(!spv.image) -> () +func.func private @image_parameters_nocomma_4(!spirv.image) -> () // ----- // expected-error @+1 {{expected ','}} -func.func private @image_parameters_nocomma_5(!spv.image) -> () +func.func private @image_parameters_nocomma_5(!spirv.image) -> () // ----- @@ -230,13 +230,13 @@ // SampledImageType //===----------------------------------------------------------------------===// -// CHECK: func private @sampled_image_type(!spv.sampled_image>) -func.func private @sampled_image_type(!spv.sampled_image>) -> () +// CHECK: func private @sampled_image_type(!spirv.sampled_image>) +func.func private @sampled_image_type(!spirv.sampled_image>) -> () // ----- // expected-error @+1 {{sampled image must be composed using image type, got 'f32'}} -func.func private @samped_image_type_invaid_type(!spv.sampled_image) -> () +func.func private @samped_image_type_invaid_type(!spirv.sampled_image) -> () // ----- @@ -244,119 +244,119 @@ // StructType //===----------------------------------------------------------------------===// -// CHECK: func private @struct_type(!spv.struct<(f32)>) -func.func private @struct_type(!spv.struct<(f32)>) -> () +// CHECK: func private @struct_type(!spirv.struct<(f32)>) +func.func private @struct_type(!spirv.struct<(f32)>) -> () -// CHECK: func private @struct_type2(!spv.struct<(f32 [0])>) -func.func private @struct_type2(!spv.struct<(f32 [0])>) -> () +// CHECK: func private @struct_type2(!spirv.struct<(f32 [0])>) +func.func private @struct_type2(!spirv.struct<(f32 [0])>) -> () -// CHECK: func private @struct_type_simple(!spv.struct<(f32, !spv.image)>) -func.func private @struct_type_simple(!spv.struct<(f32, !spv.image)>) -> () +// CHECK: func private @struct_type_simple(!spirv.struct<(f32, !spirv.image)>) +func.func private @struct_type_simple(!spirv.struct<(f32, !spirv.image)>) -> () -// CHECK: func private @struct_type_with_offset(!spv.struct<(f32 [0], i32 [4])>) -func.func private @struct_type_with_offset(!spv.struct<(f32 [0], i32 [4])>) -> () +// CHECK: func private @struct_type_with_offset(!spirv.struct<(f32 [0], i32 [4])>) +func.func private @struct_type_with_offset(!spirv.struct<(f32 [0], i32 [4])>) -> () -// CHECK: func private @nested_struct(!spv.struct<(f32, !spv.struct<(f32, i32)>)>) -func.func private @nested_struct(!spv.struct<(f32, !spv.struct<(f32, i32)>)>) +// CHECK: func private @nested_struct(!spirv.struct<(f32, !spirv.struct<(f32, i32)>)>) +func.func private @nested_struct(!spirv.struct<(f32, !spirv.struct<(f32, i32)>)>) -// CHECK: func private @nested_struct_with_offset(!spv.struct<(f32 [0], !spv.struct<(f32 [0], i32 [4])> [4])>) -func.func private @nested_struct_with_offset(!spv.struct<(f32 [0], !spv.struct<(f32 [0], i32 [4])> [4])>) +// CHECK: func private @nested_struct_with_offset(!spirv.struct<(f32 [0], !spirv.struct<(f32 [0], i32 [4])> [4])>) +func.func private @nested_struct_with_offset(!spirv.struct<(f32 [0], !spirv.struct<(f32 [0], i32 [4])> [4])>) -// CHECK: func private @struct_type_with_decoration(!spv.struct<(f32 [NonWritable])>) -func.func private @struct_type_with_decoration(!spv.struct<(f32 [NonWritable])>) +// CHECK: func private @struct_type_with_decoration(!spirv.struct<(f32 [NonWritable])>) +func.func private @struct_type_with_decoration(!spirv.struct<(f32 [NonWritable])>) -// CHECK: func private @struct_type_with_decoration_and_offset(!spv.struct<(f32 [0, NonWritable])>) -func.func private @struct_type_with_decoration_and_offset(!spv.struct<(f32 [0, NonWritable])>) +// CHECK: func private @struct_type_with_decoration_and_offset(!spirv.struct<(f32 [0, NonWritable])>) +func.func private @struct_type_with_decoration_and_offset(!spirv.struct<(f32 [0, NonWritable])>) -// CHECK: func private @struct_type_with_decoration2(!spv.struct<(f32 [NonWritable], i32 [NonReadable])>) -func.func private @struct_type_with_decoration2(!spv.struct<(f32 [NonWritable], i32 [NonReadable])>) +// CHECK: func private @struct_type_with_decoration2(!spirv.struct<(f32 [NonWritable], i32 [NonReadable])>) +func.func private @struct_type_with_decoration2(!spirv.struct<(f32 [NonWritable], i32 [NonReadable])>) -// CHECK: func private @struct_type_with_decoration3(!spv.struct<(f32, i32 [NonReadable])>) -func.func private @struct_type_with_decoration3(!spv.struct<(f32, i32 [NonReadable])>) +// CHECK: func private @struct_type_with_decoration3(!spirv.struct<(f32, i32 [NonReadable])>) +func.func private @struct_type_with_decoration3(!spirv.struct<(f32, i32 [NonReadable])>) -// CHECK: func private @struct_type_with_decoration4(!spv.struct<(f32 [0], i32 [4, NonReadable])>) -func.func private @struct_type_with_decoration4(!spv.struct<(f32 [0], i32 [4, NonReadable])>) +// CHECK: func private @struct_type_with_decoration4(!spirv.struct<(f32 [0], i32 [4, NonReadable])>) +func.func private @struct_type_with_decoration4(!spirv.struct<(f32 [0], i32 [4, NonReadable])>) -// CHECK: func private @struct_type_with_decoration5(!spv.struct<(f32 [NonWritable, NonReadable])>) -func.func private @struct_type_with_decoration5(!spv.struct<(f32 [NonWritable, NonReadable])>) +// CHECK: func private @struct_type_with_decoration5(!spirv.struct<(f32 [NonWritable, NonReadable])>) +func.func private @struct_type_with_decoration5(!spirv.struct<(f32 [NonWritable, NonReadable])>) -// CHECK: func private @struct_type_with_decoration6(!spv.struct<(f32, !spv.struct<(i32 [NonWritable, NonReadable])>)>) -func.func private @struct_type_with_decoration6(!spv.struct<(f32, !spv.struct<(i32 [NonWritable, NonReadable])>)>) +// CHECK: func private @struct_type_with_decoration6(!spirv.struct<(f32, !spirv.struct<(i32 [NonWritable, NonReadable])>)>) +func.func private @struct_type_with_decoration6(!spirv.struct<(f32, !spirv.struct<(i32 [NonWritable, NonReadable])>)>) -// CHECK: func private @struct_type_with_decoration7(!spv.struct<(f32 [0], !spv.struct<(i32, f32 [NonReadable])> [4])>) -func.func private @struct_type_with_decoration7(!spv.struct<(f32 [0], !spv.struct<(i32, f32 [NonReadable])> [4])>) +// CHECK: func private @struct_type_with_decoration7(!spirv.struct<(f32 [0], !spirv.struct<(i32, f32 [NonReadable])> [4])>) +func.func private @struct_type_with_decoration7(!spirv.struct<(f32 [0], !spirv.struct<(i32, f32 [NonReadable])> [4])>) -// CHECK: func private @struct_type_with_decoration8(!spv.struct<(f32, !spv.struct<(i32 [0], f32 [4, NonReadable])>)>) -func.func private @struct_type_with_decoration8(!spv.struct<(f32, !spv.struct<(i32 [0], f32 [4, NonReadable])>)>) +// CHECK: func private @struct_type_with_decoration8(!spirv.struct<(f32, !spirv.struct<(i32 [0], f32 [4, NonReadable])>)>) +func.func private @struct_type_with_decoration8(!spirv.struct<(f32, !spirv.struct<(i32 [0], f32 [4, NonReadable])>)>) -// CHECK: func private @struct_type_with_matrix_1(!spv.struct<(!spv.matrix<3 x vector<3xf32>> [0, ColMajor, MatrixStride=16])>) -func.func private @struct_type_with_matrix_1(!spv.struct<(!spv.matrix<3 x vector<3xf32>> [0, ColMajor, MatrixStride=16])>) +// CHECK: func private @struct_type_with_matrix_1(!spirv.struct<(!spirv.matrix<3 x vector<3xf32>> [0, ColMajor, MatrixStride=16])>) +func.func private @struct_type_with_matrix_1(!spirv.struct<(!spirv.matrix<3 x vector<3xf32>> [0, ColMajor, MatrixStride=16])>) -// CHECK: func private @struct_type_with_matrix_2(!spv.struct<(!spv.matrix<3 x vector<3xf32>> [0, RowMajor, MatrixStride=16])>) -func.func private @struct_type_with_matrix_2(!spv.struct<(!spv.matrix<3 x vector<3xf32>> [0, RowMajor, MatrixStride=16])>) +// CHECK: func private @struct_type_with_matrix_2(!spirv.struct<(!spirv.matrix<3 x vector<3xf32>> [0, RowMajor, MatrixStride=16])>) +func.func private @struct_type_with_matrix_2(!spirv.struct<(!spirv.matrix<3 x vector<3xf32>> [0, RowMajor, MatrixStride=16])>) -// CHECK: func private @struct_empty(!spv.struct<()>) -func.func private @struct_empty(!spv.struct<()>) +// CHECK: func private @struct_empty(!spirv.struct<()>) +func.func private @struct_empty(!spirv.struct<()>) // ----- // expected-error @+1 {{offset specification must be given for all members}} -func.func private @struct_type_missing_offset1((!spv.struct<(f32, i32 [4])>) -> () +func.func private @struct_type_missing_offset1((!spirv.struct<(f32, i32 [4])>) -> () // ----- // expected-error @+1 {{offset specification must be given for all members}} -func.func private @struct_type_missing_offset2(!spv.struct<(f32 [3], i32)>) -> () +func.func private @struct_type_missing_offset2(!spirv.struct<(f32 [3], i32)>) -> () // ----- // expected-error @+1 {{expected ')'}} -func.func private @struct_type_missing_comma1(!spv.struct<(f32 i32)>) -> () +func.func private @struct_type_missing_comma1(!spirv.struct<(f32 i32)>) -> () // ----- // expected-error @+1 {{expected ')'}} -func.func private @struct_type_missing_comma2(!spv.struct<(f32 [0] i32)>) -> () +func.func private @struct_type_missing_comma2(!spirv.struct<(f32 [0] i32)>) -> () // ----- // expected-error @+1 {{unbalanced ')' character in pretty dialect name}} -func.func private @struct_type_neg_offset(!spv.struct<(f32 [0)>) -> () +func.func private @struct_type_neg_offset(!spirv.struct<(f32 [0)>) -> () // ----- // expected-error @+1 {{unbalanced ']' character in pretty dialect name}} -func.func private @struct_type_neg_offset(!spv.struct<(f32 0])>) -> () +func.func private @struct_type_neg_offset(!spirv.struct<(f32 0])>) -> () // ----- // expected-error @+1 {{expected ']'}} -func.func private @struct_type_neg_offset(!spv.struct<(f32 [NonWritable 0])>) -> () +func.func private @struct_type_neg_offset(!spirv.struct<(f32 [NonWritable 0])>) -> () // ----- // expected-error @+1 {{expected valid keyword}} -func.func private @struct_type_neg_offset(!spv.struct<(f32 [NonWritable, 0])>) -> () +func.func private @struct_type_neg_offset(!spirv.struct<(f32 [NonWritable, 0])>) -> () // ----- // expected-error @+1 {{expected ','}} -func.func private @struct_type_missing_comma(!spv.struct<(f32 [0 NonWritable], i32 [4])>) +func.func private @struct_type_missing_comma(!spirv.struct<(f32 [0 NonWritable], i32 [4])>) // ----- // expected-error @+1 {{expected ']'}} -func.func private @struct_type_missing_comma(!spv.struct<(f32 [0, NonWritable NonReadable], i32 [4])>) +func.func private @struct_type_missing_comma(!spirv.struct<(f32 [0, NonWritable NonReadable], i32 [4])>) // ----- // expected-error @+1 {{expected ']'}} -func.func private @struct_type_missing_comma(!spv.struct<(!spv.matrix<3 x vector<3xf32>> [0, RowMajor MatrixStride=16])>) +func.func private @struct_type_missing_comma(!spirv.struct<(!spirv.matrix<3 x vector<3xf32>> [0, RowMajor MatrixStride=16])>) // ----- // expected-error @+1 {{expected integer value}} -func.func private @struct_missing_member_decorator_value(!spv.struct<(!spv.matrix<3 x vector<3xf32>> [0, RowMajor, MatrixStride=])>) +func.func private @struct_missing_member_decorator_value(!spirv.struct<(!spirv.matrix<3 x vector<3xf32>> [0, RowMajor, MatrixStride=])>) // ----- @@ -364,74 +364,74 @@ // StructType (identified) //===----------------------------------------------------------------------===// -// CHECK: func private @id_struct_empty(!spv.struct) -func.func private @id_struct_empty(!spv.struct) -> () +// CHECK: func private @id_struct_empty(!spirv.struct) +func.func private @id_struct_empty(!spirv.struct) -> () // ----- -// CHECK: func private @id_struct_simple(!spv.struct) -func.func private @id_struct_simple(!spv.struct) -> () +// CHECK: func private @id_struct_simple(!spirv.struct) +func.func private @id_struct_simple(!spirv.struct) -> () // ----- -// CHECK: func private @id_struct_multiple_elements(!spv.struct) -func.func private @id_struct_multiple_elements(!spv.struct) -> () +// CHECK: func private @id_struct_multiple_elements(!spirv.struct) +func.func private @id_struct_multiple_elements(!spirv.struct) -> () // ----- -// CHECK: func private @id_struct_nested_literal(!spv.struct)>) -func.func private @id_struct_nested_literal(!spv.struct)>) -> () +// CHECK: func private @id_struct_nested_literal(!spirv.struct)>) +func.func private @id_struct_nested_literal(!spirv.struct)>) -> () // ----- -// CHECK: func private @id_struct_nested_id(!spv.struct)>) -func.func private @id_struct_nested_id(!spv.struct)>) -> () +// CHECK: func private @id_struct_nested_id(!spirv.struct)>) +func.func private @id_struct_nested_id(!spirv.struct)>) -> () // ----- -// CHECK: func private @literal_struct_nested_id(!spv.struct<(!spv.struct)>) -func.func private @literal_struct_nested_id(!spv.struct<(!spv.struct)>) -> () +// CHECK: func private @literal_struct_nested_id(!spirv.struct<(!spirv.struct)>) +func.func private @literal_struct_nested_id(!spirv.struct<(!spirv.struct)>) -> () // ----- -// CHECK: func private @id_struct_self_recursive(!spv.struct, Uniform>)>) -func.func private @id_struct_self_recursive(!spv.struct, Uniform>)>) -> () +// CHECK: func private @id_struct_self_recursive(!spirv.struct, Uniform>)>) +func.func private @id_struct_self_recursive(!spirv.struct, Uniform>)>) -> () // ----- -// CHECK: func private @id_struct_self_recursive2(!spv.struct, Uniform>)>) -func.func private @id_struct_self_recursive2(!spv.struct, Uniform>)>) -> () +// CHECK: func private @id_struct_self_recursive2(!spirv.struct, Uniform>)>) +func.func private @id_struct_self_recursive2(!spirv.struct, Uniform>)>) -> () // ----- // expected-error @+1 {{recursive struct reference not nested in struct definition}} -func.func private @id_wrong_recursive_reference(!spv.struct) -> () +func.func private @id_wrong_recursive_reference(!spirv.struct) -> () // ----- // expected-error @+1 {{recursive struct reference not nested in struct definition}} -func.func private @id_struct_recursive_invalid(!spv.struct, Uniform>)>) -> () +func.func private @id_struct_recursive_invalid(!spirv.struct, Uniform>)>) -> () // ----- // expected-error @+1 {{identifier already used for an enclosing struct}} -func.func private @id_struct_redefinition(!spv.struct, Uniform>)>, Uniform>)>) -> () +func.func private @id_struct_redefinition(!spirv.struct, Uniform>)>, Uniform>)>) -> () // ----- // Equivalent to: // struct a { struct b *bPtr; }; // struct b { struct a *aPtr; }; -// CHECK: func private @id_struct_recursive(!spv.struct, Uniform>)>, Uniform>)>) -func.func private @id_struct_recursive(!spv.struct, Uniform>)>, Uniform>)>) -> () +// CHECK: func private @id_struct_recursive(!spirv.struct, Uniform>)>, Uniform>)>) +func.func private @id_struct_recursive(!spirv.struct, Uniform>)>, Uniform>)>) -> () // ----- // Equivalent to: // struct a { struct b *bPtr; }; // struct b { struct a *aPtr, struct b *bPtr; }; -// CHECK: func private @id_struct_recursive(!spv.struct, Uniform>, !spv.ptr, Uniform>)>, Uniform>)>) -func.func private @id_struct_recursive(!spv.struct, Uniform>, !spv.ptr, Uniform>)>, Uniform>)>) -> () +// CHECK: func private @id_struct_recursive(!spirv.struct, Uniform>, !spirv.ptr, Uniform>)>, Uniform>)>) +func.func private @id_struct_recursive(!spirv.struct, Uniform>, !spirv.ptr, Uniform>)>, Uniform>)>) -> () // ----- @@ -439,100 +439,100 @@ // CooperativeMatrix //===----------------------------------------------------------------------===// -// CHECK: func private @coop_matrix_type(!spv.coopmatrix<8x16xi32, Subgroup>, !spv.coopmatrix<8x8xf32, Workgroup>) -func.func private @coop_matrix_type(!spv.coopmatrix<8x16xi32, Subgroup>, !spv.coopmatrix<8x8xf32, Workgroup>) -> () +// CHECK: func private @coop_matrix_type(!spirv.coopmatrix<8x16xi32, Subgroup>, !spirv.coopmatrix<8x8xf32, Workgroup>) +func.func private @coop_matrix_type(!spirv.coopmatrix<8x16xi32, Subgroup>, !spirv.coopmatrix<8x8xf32, Workgroup>) -> () // ----- // expected-error @+1 {{expected ','}} -func.func private @missing_scope(!spv.coopmatrix<8x16xi32>) -> () +func.func private @missing_scope(!spirv.coopmatrix<8x16xi32>) -> () // ----- // expected-error @+1 {{expected rows and columns size}} -func.func private @missing_count(!spv.coopmatrix<8xi32, Subgroup>) -> () +func.func private @missing_count(!spirv.coopmatrix<8xi32, Subgroup>) -> () // ----- //===----------------------------------------------------------------------===// // Matrix //===----------------------------------------------------------------------===// -// CHECK: func private @matrix_type(!spv.matrix<2 x vector<2xf16>>) -func.func private @matrix_type(!spv.matrix<2 x vector<2xf16>>) -> () +// CHECK: func private @matrix_type(!spirv.matrix<2 x vector<2xf16>>) +func.func private @matrix_type(!spirv.matrix<2 x vector<2xf16>>) -> () // ----- -// CHECK: func private @matrix_type(!spv.matrix<3 x vector<3xf32>>) -func.func private @matrix_type(!spv.matrix<3 x vector<3xf32>>) -> () +// CHECK: func private @matrix_type(!spirv.matrix<3 x vector<3xf32>>) +func.func private @matrix_type(!spirv.matrix<3 x vector<3xf32>>) -> () // ----- -// CHECK: func private @matrix_type(!spv.matrix<4 x vector<4xf16>>) -func.func private @matrix_type(!spv.matrix<4 x vector<4xf16>>) -> () +// CHECK: func private @matrix_type(!spirv.matrix<4 x vector<4xf16>>) +func.func private @matrix_type(!spirv.matrix<4 x vector<4xf16>>) -> () // ----- // expected-error @+1 {{matrix is expected to have 2, 3, or 4 columns}} -func.func private @matrix_invalid_size(!spv.matrix<5 x vector<3xf32>>) -> () +func.func private @matrix_invalid_size(!spirv.matrix<5 x vector<3xf32>>) -> () // ----- // expected-error @+1 {{matrix is expected to have 2, 3, or 4 columns}} -func.func private @matrix_invalid_size(!spv.matrix<1 x vector<3xf32>>) -> () +func.func private @matrix_invalid_size(!spirv.matrix<1 x vector<3xf32>>) -> () // ----- // expected-error @+1 {{matrix columns size has to be less than or equal to 4 and greater than or equal 2, but found 5}} -func.func private @matrix_invalid_columns_size(!spv.matrix<3 x vector<5xf32>>) -> () +func.func private @matrix_invalid_columns_size(!spirv.matrix<3 x vector<5xf32>>) -> () // ----- // expected-error @+1 {{matrix columns size has to be less than or equal to 4 and greater than or equal 2, but found 1}} -func.func private @matrix_invalid_columns_size(!spv.matrix<3 x vector<1xf32>>) -> () +func.func private @matrix_invalid_columns_size(!spirv.matrix<3 x vector<1xf32>>) -> () // ----- // expected-error @+1 {{expected '<'}} -func.func private @matrix_invalid_format(!spv.matrix 3 x vector<3xf32>>) -> () +func.func private @matrix_invalid_format(!spirv.matrix 3 x vector<3xf32>>) -> () // ----- // expected-error @+1 {{unbalanced ')' character in pretty dialect name}} -func.func private @matrix_invalid_format(!spv.matrix< 3 x vector<3xf32>) -> () +func.func private @matrix_invalid_format(!spirv.matrix< 3 x vector<3xf32>) -> () // ----- // expected-error @+1 {{expected 'x' in dimension list}} -func.func private @matrix_invalid_format(!spv.matrix<2 vector<3xi32>>) -> () +func.func private @matrix_invalid_format(!spirv.matrix<2 vector<3xi32>>) -> () // ----- // expected-error @+1 {{matrix must be composed using vector type, got 'i32'}} -func.func private @matrix_invalid_type(!spv.matrix< 3 x i32>) -> () +func.func private @matrix_invalid_type(!spirv.matrix< 3 x i32>) -> () // ----- -// expected-error @+1 {{matrix must be composed using vector type, got '!spv.array<16 x f32>'}} -func.func private @matrix_invalid_type(!spv.matrix< 3 x !spv.array<16 x f32>>) -> () +// expected-error @+1 {{matrix must be composed using vector type, got '!spirv.array<16 x f32>'}} +func.func private @matrix_invalid_type(!spirv.matrix< 3 x !spirv.array<16 x f32>>) -> () // ----- -// expected-error @+1 {{matrix must be composed using vector type, got '!spv.rtarray'}} -func.func private @matrix_invalid_type(!spv.matrix< 3 x !spv.rtarray>) -> () +// expected-error @+1 {{matrix must be composed using vector type, got '!spirv.rtarray'}} +func.func private @matrix_invalid_type(!spirv.matrix< 3 x !spirv.rtarray>) -> () // ----- // expected-error @+1 {{matrix columns' elements must be of Float type, got 'i32'}} -func.func private @matrix_invalid_type(!spv.matrix<2 x vector<3xi32>>) -> () +func.func private @matrix_invalid_type(!spirv.matrix<2 x vector<3xi32>>) -> () // ----- // expected-error @+1 {{expected single unsigned integer for number of columns}} -func.func private @matrix_size_type(!spv.matrix< x vector<3xi32>>) -> () +func.func private @matrix_size_type(!spirv.matrix< x vector<3xi32>>) -> () // ----- // expected-error @+1 {{expected single unsigned integer for number of columns}} -func.func private @matrix_size_type(!spv.matrix<2.0 x vector<3xi32>>) -> () +func.func private @matrix_size_type(!spirv.matrix<2.0 x vector<3xi32>>) -> () // ----- diff --git a/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/basic.mlir b/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/basic.mlir --- a/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/basic.mlir +++ b/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/basic.mlir @@ -3,43 +3,43 @@ // Combine modules without the same symbols // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.SpecConstant @m1_sc -// CHECK-NEXT: spv.GlobalVariable @m1_gv bind(1, 0) -// CHECK-NEXT: spv.func @no_op -// CHECK-NEXT: spv.Return +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.SpecConstant @m1_sc +// CHECK-NEXT: spirv.GlobalVariable @m1_gv bind(1, 0) +// CHECK-NEXT: spirv.func @no_op +// CHECK-NEXT: spirv.Return // CHECK-NEXT: } -// CHECK-NEXT: spv.EntryPoint "GLCompute" @no_op -// CHECK-NEXT: spv.ExecutionMode @no_op "LocalSize", 32, 1, 1 +// CHECK-NEXT: spirv.EntryPoint "GLCompute" @no_op +// CHECK-NEXT: spirv.ExecutionMode @no_op "LocalSize", 32, 1, 1 -// CHECK-NEXT: spv.SpecConstant @m2_sc -// CHECK-NEXT: spv.GlobalVariable @m2_gv bind(0, 1) -// CHECK-NEXT: spv.func @variable_init_spec_constant -// CHECK-NEXT: spv.mlir.referenceof @m2_sc -// CHECK-NEXT: spv.Variable init -// CHECK-NEXT: spv.Return +// CHECK-NEXT: spirv.SpecConstant @m2_sc +// CHECK-NEXT: spirv.GlobalVariable @m2_gv bind(0, 1) +// CHECK-NEXT: spirv.func @variable_init_spec_constant +// CHECK-NEXT: spirv.mlir.referenceof @m2_sc +// CHECK-NEXT: spirv.Variable init +// CHECK-NEXT: spirv.Return // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.SpecConstant @m1_sc = 42.42 : f32 - spv.GlobalVariable @m1_gv bind(1, 0): !spv.ptr - spv.func @no_op() -> () "None" { - spv.Return +spirv.module Logical GLSL450 { + spirv.SpecConstant @m1_sc = 42.42 : f32 + spirv.GlobalVariable @m1_gv bind(1, 0): !spirv.ptr + spirv.func @no_op() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @no_op - spv.ExecutionMode @no_op "LocalSize", 32, 1, 1 + spirv.EntryPoint "GLCompute" @no_op + spirv.ExecutionMode @no_op "LocalSize", 32, 1, 1 } -spv.module Logical GLSL450 { - spv.SpecConstant @m2_sc = 42 : i32 - spv.GlobalVariable @m2_gv bind(0, 1): !spv.ptr - spv.func @variable_init_spec_constant() -> () "None" { - %0 = spv.mlir.referenceof @m2_sc : i32 - %1 = spv.Variable init(%0) : !spv.ptr - spv.Return +spirv.module Logical GLSL450 { + spirv.SpecConstant @m2_sc = 42 : i32 + spirv.GlobalVariable @m2_gv bind(0, 1): !spirv.ptr + spirv.func @variable_init_spec_constant() -> () "None" { + %0 = spirv.mlir.referenceof @m2_sc : i32 + %1 = spirv.Variable init(%0) : !spirv.ptr + spirv.Return } } } @@ -47,33 +47,33 @@ // ----- module { -spv.module Physical64 GLSL450 { +spirv.module Physical64 GLSL450 { } // expected-error @+1 {{input modules differ in addressing model, memory model, and/or VCE triple}} -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { } } // ----- module { -spv.module Logical Simple { +spirv.module Logical Simple { } // expected-error @+1 {{input modules differ in addressing model, memory model, and/or VCE triple}} -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { } } // ----- module { -spv.module Logical GLSL450 { +spirv.module Logical GLSL450 { } // expected-error @+1 {{input modules differ in addressing model, memory model, and/or VCE triple}} -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { } } diff --git a/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/conflict-resolution.mlir b/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/conflict-resolution.mlir --- a/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/conflict-resolution.mlir +++ b/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/conflict-resolution.mlir @@ -3,27 +3,27 @@ // Test basic renaming of conflicting funcOps. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @foo_1 -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @foo_1 +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } } -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : f32) -> f32 "None" { - spv.ReturnValue %arg0 : f32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : f32) -> f32 "None" { + spirv.ReturnValue %arg0 : f32 } } } @@ -33,41 +33,41 @@ // Test basic renaming of conflicting funcOps across 3 modules. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @foo_1 -// CHECK-NEXT: spv.FAdd -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @foo_1 +// CHECK-NEXT: spirv.FAdd +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @foo_2 -// CHECK-NEXT: spv.ISub -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @foo_2 +// CHECK-NEXT: spirv.ISub +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } } -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : f32) -> f32 "None" { - %0 = spv.FAdd %arg0, %arg0 : f32 - spv.ReturnValue %0 : f32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : f32) -> f32 "None" { + %0 = spirv.FAdd %arg0, %arg0 : f32 + spirv.ReturnValue %0 : f32 } } -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - %0 = spv.ISub %arg0, %arg0 : i32 - spv.ReturnValue %0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + %0 = spirv.ISub %arg0, %arg0 : i32 + spirv.ReturnValue %0 : i32 } } } @@ -77,37 +77,37 @@ // Test properly updating references to a renamed funcOp. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @foo_1 -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @foo_1 +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @bar -// CHECK-NEXT: spv.FunctionCall @foo_1 -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @bar +// CHECK-NEXT: spirv.FunctionCall @foo_1 +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } } -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : f32) -> f32 "None" { - spv.ReturnValue %arg0 : f32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : f32) -> f32 "None" { + spirv.ReturnValue %arg0 : f32 } - spv.func @bar(%arg0 : f32) -> f32 "None" { - %0 = spv.FunctionCall @foo(%arg0) : (f32) -> (f32) - spv.ReturnValue %0 : f32 + spirv.func @bar(%arg0 : f32) -> f32 "None" { + %0 = spirv.FunctionCall @foo(%arg0) : (f32) -> (f32) + spirv.ReturnValue %0 : f32 } } } @@ -118,37 +118,37 @@ // preceeds the callee funcOp definition. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @bar -// CHECK-NEXT: spv.FunctionCall @foo_1 -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @bar +// CHECK-NEXT: spirv.FunctionCall @foo_1 +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @foo_1 -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @foo_1 +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } } -spv.module Logical GLSL450 { - spv.func @bar(%arg0 : f32) -> f32 "None" { - %0 = spv.FunctionCall @foo(%arg0) : (f32) -> (f32) - spv.ReturnValue %0 : f32 +spirv.module Logical GLSL450 { + spirv.func @bar(%arg0 : f32) -> f32 "None" { + %0 = spirv.FunctionCall @foo(%arg0) : (f32) -> (f32) + spirv.ReturnValue %0 : f32 } - spv.func @foo(%arg0 : f32) -> f32 "None" { - spv.ReturnValue %arg0 : f32 + spirv.func @foo(%arg0 : f32) -> f32 "None" { + spirv.ReturnValue %arg0 : f32 } } } @@ -159,74 +159,74 @@ // funcOp. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @foo_1 -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @foo_1 +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.EntryPoint "GLCompute" @foo_1 -// CHECK-NEXT: spv.ExecutionMode @foo_1 "ContractionOff" +// CHECK-NEXT: spirv.EntryPoint "GLCompute" @foo_1 +// CHECK-NEXT: spirv.ExecutionMode @foo_1 "ContractionOff" // CHECK-NEXT: } // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } } -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : f32) -> f32 "None" { - spv.ReturnValue %arg0 : f32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : f32) -> f32 "None" { + spirv.ReturnValue %arg0 : f32 } - spv.EntryPoint "GLCompute" @foo - spv.ExecutionMode @foo "ContractionOff" + spirv.EntryPoint "GLCompute" @foo + spirv.ExecutionMode @foo "ContractionOff" } } // ----- // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.EntryPoint "GLCompute" @fo -// CHECK-NEXT: spv.ExecutionMode @foo "ContractionOff" +// CHECK-NEXT: spirv.EntryPoint "GLCompute" @fo +// CHECK-NEXT: spirv.ExecutionMode @foo "ContractionOff" -// CHECK-NEXT: spv.func @foo_1 -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @foo_1 +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.EntryPoint "GLCompute" @foo_1 -// CHECK-NEXT: spv.ExecutionMode @foo_1 "ContractionOff" +// CHECK-NEXT: spirv.EntryPoint "GLCompute" @foo_1 +// CHECK-NEXT: spirv.ExecutionMode @foo_1 "ContractionOff" // CHECK-NEXT: } // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } - spv.EntryPoint "GLCompute" @foo - spv.ExecutionMode @foo "ContractionOff" + spirv.EntryPoint "GLCompute" @foo + spirv.ExecutionMode @foo "ContractionOff" } -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : f32) -> f32 "None" { - spv.ReturnValue %arg0 : f32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : f32) -> f32 "None" { + spirv.ReturnValue %arg0 : f32 } - spv.EntryPoint "GLCompute" @foo - spv.ExecutionMode @foo "ContractionOff" + spirv.EntryPoint "GLCompute" @foo + spirv.ExecutionMode @foo "ContractionOff" } } @@ -235,23 +235,23 @@ // Resolve conflicting funcOp and globalVariableOp. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.GlobalVariable @foo_1 +// CHECK-NEXT: spirv.GlobalVariable @foo_1 // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } } -spv.module Logical GLSL450 { - spv.GlobalVariable @foo bind(1, 0) : !spv.ptr +spirv.module Logical GLSL450 { + spirv.GlobalVariable @foo bind(1, 0) : !spirv.ptr } } @@ -261,33 +261,33 @@ // references. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.GlobalVariable @foo_1 -// CHECK-NEXT: spv.func @bar -// CHECK-NEXT: spv.mlir.addressof @foo_1 -// CHECK-NEXT: spv.Load -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.GlobalVariable @foo_1 +// CHECK-NEXT: spirv.func @bar +// CHECK-NEXT: spirv.mlir.addressof @foo_1 +// CHECK-NEXT: spirv.Load +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } } -spv.module Logical GLSL450 { - spv.GlobalVariable @foo bind(1, 0) : !spv.ptr +spirv.module Logical GLSL450 { + spirv.GlobalVariable @foo bind(1, 0) : !spirv.ptr - spv.func @bar() -> f32 "None" { - %0 = spv.mlir.addressof @foo : !spv.ptr - %1 = spv.Load "Input" %0 : f32 - spv.ReturnValue %1 : f32 + spirv.func @bar() -> f32 "None" { + %0 = spirv.mlir.addressof @foo : !spirv.ptr + %1 = spirv.Load "Input" %0 : f32 + spirv.ReturnValue %1 : f32 } } } @@ -298,33 +298,33 @@ // references. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.GlobalVariable @foo_1 -// CHECK-NEXT: spv.func @bar -// CHECK-NEXT: spv.mlir.addressof @foo_1 -// CHECK-NEXT: spv.Load -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.GlobalVariable @foo_1 +// CHECK-NEXT: spirv.func @bar +// CHECK-NEXT: spirv.mlir.addressof @foo_1 +// CHECK-NEXT: spirv.Load +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.GlobalVariable @foo bind(1, 0) : !spv.ptr +spirv.module Logical GLSL450 { + spirv.GlobalVariable @foo bind(1, 0) : !spirv.ptr - spv.func @bar() -> f32 "None" { - %0 = spv.mlir.addressof @foo : !spv.ptr - %1 = spv.Load "Input" %0 : f32 - spv.ReturnValue %1 : f32 + spirv.func @bar() -> f32 "None" { + %0 = spirv.mlir.addressof @foo : !spirv.ptr + %1 = spirv.Load "Input" %0 : f32 + spirv.ReturnValue %1 : f32 } } -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } } } @@ -334,23 +334,23 @@ // Resolve conflicting funcOp and specConstantOp. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.SpecConstant @foo_1 +// CHECK-NEXT: spirv.SpecConstant @foo_1 // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } } -spv.module Logical GLSL450 { - spv.SpecConstant @foo = -5 : i32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @foo = -5 : i32 } } @@ -360,31 +360,31 @@ // references. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.SpecConstant @foo_1 -// CHECK-NEXT: spv.func @bar -// CHECK-NEXT: spv.mlir.referenceof @foo_1 -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.SpecConstant @foo_1 +// CHECK-NEXT: spirv.func @bar +// CHECK-NEXT: spirv.mlir.referenceof @foo_1 +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } } -spv.module Logical GLSL450 { - spv.SpecConstant @foo = -5 : i32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @foo = -5 : i32 - spv.func @bar() -> i32 "None" { - %0 = spv.mlir.referenceof @foo : i32 - spv.ReturnValue %0 : i32 + spirv.func @bar() -> i32 "None" { + %0 = spirv.mlir.referenceof @foo : i32 + spirv.ReturnValue %0 : i32 } } } @@ -395,31 +395,31 @@ // references. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.SpecConstant @foo_1 -// CHECK-NEXT: spv.func @bar -// CHECK-NEXT: spv.mlir.referenceof @foo_1 -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.SpecConstant @foo_1 +// CHECK-NEXT: spirv.func @bar +// CHECK-NEXT: spirv.mlir.referenceof @foo_1 +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.SpecConstant @foo = -5 : i32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @foo = -5 : i32 - spv.func @bar() -> i32 "None" { - %0 = spv.mlir.referenceof @foo : i32 - spv.ReturnValue %0 : i32 + spirv.func @bar() -> i32 "None" { + %0 = spirv.mlir.referenceof @foo : i32 + spirv.ReturnValue %0 : i32 } } -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } } } @@ -429,25 +429,25 @@ // Resolve conflicting funcOp and specConstantCompositeOp. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.SpecConstant @bar -// CHECK-NEXT: spv.SpecConstantComposite @foo_1 (@bar, @bar) +// CHECK-NEXT: spirv.SpecConstant @bar +// CHECK-NEXT: spirv.SpecConstantComposite @foo_1 (@bar, @bar) // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } } -spv.module Logical GLSL450 { - spv.SpecConstant @bar = -5 : i32 - spv.SpecConstantComposite @foo (@bar, @bar) : !spv.array<2 x i32> +spirv.module Logical GLSL450 { + spirv.SpecConstant @bar = -5 : i32 + spirv.SpecConstantComposite @foo (@bar, @bar) : !spirv.array<2 x i32> } } @@ -457,35 +457,35 @@ // constant's references. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.SpecConstant @bar -// CHECK-NEXT: spv.SpecConstantComposite @foo_1 (@bar, @bar) -// CHECK-NEXT: spv.func @baz -// CHECK-NEXT: spv.mlir.referenceof @foo_1 -// CHECK-NEXT: spv.CompositeExtract -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.SpecConstant @bar +// CHECK-NEXT: spirv.SpecConstantComposite @foo_1 (@bar, @bar) +// CHECK-NEXT: spirv.func @baz +// CHECK-NEXT: spirv.mlir.referenceof @foo_1 +// CHECK-NEXT: spirv.CompositeExtract +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } } -spv.module Logical GLSL450 { - spv.SpecConstant @bar = -5 : i32 - spv.SpecConstantComposite @foo (@bar, @bar) : !spv.array<2 x i32> +spirv.module Logical GLSL450 { + spirv.SpecConstant @bar = -5 : i32 + spirv.SpecConstantComposite @foo (@bar, @bar) : !spirv.array<2 x i32> - spv.func @baz() -> i32 "None" { - %0 = spv.mlir.referenceof @foo : !spv.array<2 x i32> - %1 = spv.CompositeExtract %0[0 : i32] : !spv.array<2 x i32> - spv.ReturnValue %1 : i32 + spirv.func @baz() -> i32 "None" { + %0 = spirv.mlir.referenceof @foo : !spirv.array<2 x i32> + %1 = spirv.CompositeExtract %0[0 : i32] : !spirv.array<2 x i32> + spirv.ReturnValue %1 : i32 } } } @@ -496,35 +496,35 @@ // constant's references. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.SpecConstant @bar -// CHECK-NEXT: spv.SpecConstantComposite @foo_1 (@bar, @bar) -// CHECK-NEXT: spv.func @baz -// CHECK-NEXT: spv.mlir.referenceof @foo_1 -// CHECK-NEXT: spv.CompositeExtract -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.SpecConstant @bar +// CHECK-NEXT: spirv.SpecConstantComposite @foo_1 (@bar, @bar) +// CHECK-NEXT: spirv.func @baz +// CHECK-NEXT: spirv.mlir.referenceof @foo_1 +// CHECK-NEXT: spirv.CompositeExtract +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.SpecConstant @bar = -5 : i32 - spv.SpecConstantComposite @foo (@bar, @bar) : !spv.array<2 x i32> +spirv.module Logical GLSL450 { + spirv.SpecConstant @bar = -5 : i32 + spirv.SpecConstantComposite @foo (@bar, @bar) : !spirv.array<2 x i32> - spv.func @baz() -> i32 "None" { - %0 = spv.mlir.referenceof @foo : !spv.array<2 x i32> - %1 = spv.CompositeExtract %0[0 : i32] : !spv.array<2 x i32> - spv.ReturnValue %1 : i32 + spirv.func @baz() -> i32 "None" { + %0 = spirv.mlir.referenceof @foo : !spirv.array<2 x i32> + %1 = spirv.CompositeExtract %0[0 : i32] : !spirv.array<2 x i32> + spirv.ReturnValue %1 : i32 } } -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } } } @@ -535,43 +535,43 @@ // references. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.SpecConstant @bar_1 -// CHECK-NEXT: spv.SpecConstantComposite @foo_2 (@bar_1, @bar_1) -// CHECK-NEXT: spv.func @baz -// CHECK-NEXT: spv.mlir.referenceof @foo_2 -// CHECK-NEXT: spv.CompositeExtract -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.SpecConstant @bar_1 +// CHECK-NEXT: spirv.SpecConstantComposite @foo_2 (@bar_1, @bar_1) +// CHECK-NEXT: spirv.func @baz +// CHECK-NEXT: spirv.mlir.referenceof @foo_2 +// CHECK-NEXT: spirv.CompositeExtract +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @bar -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @bar +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.SpecConstant @bar = -5 : i32 - spv.SpecConstantComposite @foo (@bar, @bar) : !spv.array<2 x i32> +spirv.module Logical GLSL450 { + spirv.SpecConstant @bar = -5 : i32 + spirv.SpecConstantComposite @foo (@bar, @bar) : !spirv.array<2 x i32> - spv.func @baz() -> i32 "None" { - %0 = spv.mlir.referenceof @foo : !spv.array<2 x i32> - %1 = spv.CompositeExtract %0[0 : i32] : !spv.array<2 x i32> - spv.ReturnValue %1 : i32 + spirv.func @baz() -> i32 "None" { + %0 = spirv.mlir.referenceof @foo : !spirv.array<2 x i32> + %1 = spirv.CompositeExtract %0[0 : i32] : !spirv.array<2 x i32> + spirv.ReturnValue %1 : i32 } } -spv.module Logical GLSL450 { - spv.func @foo(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 +spirv.module Logical GLSL450 { + spirv.func @foo(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } - spv.func @bar(%arg0 : f32) -> f32 "None" { - spv.ReturnValue %arg0 : f32 + spirv.func @bar(%arg0 : f32) -> f32 "None" { + spirv.ReturnValue %arg0 : f32 } } } @@ -581,38 +581,38 @@ // Resolve conflicting globalVariableOps. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.GlobalVariable @foo_1 bind(1, 0) +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.GlobalVariable @foo_1 bind(1, 0) -// CHECK-NEXT: spv.GlobalVariable @foo bind(2, 0) +// CHECK-NEXT: spirv.GlobalVariable @foo bind(2, 0) // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.GlobalVariable @foo bind(1, 0) : !spv.ptr +spirv.module Logical GLSL450 { + spirv.GlobalVariable @foo bind(1, 0) : !spirv.ptr } -spv.module Logical GLSL450 { - spv.GlobalVariable @foo bind(2, 0) : !spv.ptr +spirv.module Logical GLSL450 { + spirv.GlobalVariable @foo bind(2, 0) : !spirv.ptr } } // ----- // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.GlobalVariable @foo_1 built_in("GlobalInvocationId") +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.GlobalVariable @foo_1 built_in("GlobalInvocationId") -// CHECK-NEXT: spv.GlobalVariable @foo built_in("LocalInvocationId") +// CHECK-NEXT: spirv.GlobalVariable @foo built_in("LocalInvocationId") // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.GlobalVariable @foo built_in("GlobalInvocationId") : !spv.ptr, Input> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @foo built_in("GlobalInvocationId") : !spirv.ptr, Input> } -spv.module Logical GLSL450 { - spv.GlobalVariable @foo built_in("LocalInvocationId") : !spv.ptr, Input> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @foo built_in("LocalInvocationId") : !spirv.ptr, Input> } } @@ -621,19 +621,19 @@ // Resolve conflicting globalVariableOp and specConstantOp. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.GlobalVariable @foo_1 +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.GlobalVariable @foo_1 -// CHECK-NEXT: spv.SpecConstant @foo +// CHECK-NEXT: spirv.SpecConstant @foo // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.GlobalVariable @foo bind(1, 0) : !spv.ptr +spirv.module Logical GLSL450 { + spirv.GlobalVariable @foo bind(1, 0) : !spirv.ptr } -spv.module Logical GLSL450 { - spv.SpecConstant @foo = -5 : i32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @foo = -5 : i32 } } @@ -642,19 +642,19 @@ // Resolve conflicting specConstantOp and globalVariableOp. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.SpecConstant @foo_1 +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.SpecConstant @foo_1 -// CHECK-NEXT: spv.GlobalVariable @foo +// CHECK-NEXT: spirv.GlobalVariable @foo // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.SpecConstant @foo = -5 : i32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @foo = -5 : i32 } -spv.module Logical GLSL450 { - spv.GlobalVariable @foo bind(1, 0) : !spv.ptr +spirv.module Logical GLSL450 { + spirv.GlobalVariable @foo bind(1, 0) : !spirv.ptr } } @@ -663,21 +663,21 @@ // Resolve conflicting globalVariableOp and specConstantCompositeOp. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.GlobalVariable @foo_1 +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.GlobalVariable @foo_1 -// CHECK-NEXT: spv.SpecConstant @bar -// CHECK-NEXT: spv.SpecConstantComposite @foo (@bar, @bar) +// CHECK-NEXT: spirv.SpecConstant @bar +// CHECK-NEXT: spirv.SpecConstantComposite @foo (@bar, @bar) // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.GlobalVariable @foo bind(1, 0) : !spv.ptr +spirv.module Logical GLSL450 { + spirv.GlobalVariable @foo bind(1, 0) : !spirv.ptr } -spv.module Logical GLSL450 { - spv.SpecConstant @bar = -5 : i32 - spv.SpecConstantComposite @foo (@bar, @bar) : !spv.array<2 x i32> +spirv.module Logical GLSL450 { + spirv.SpecConstant @bar = -5 : i32 + spirv.SpecConstantComposite @foo (@bar, @bar) : !spirv.array<2 x i32> } } @@ -686,20 +686,20 @@ // Resolve conflicting globalVariableOp and specConstantComposite. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.SpecConstant @bar -// CHECK-NEXT: spv.SpecConstantComposite @foo_1 (@bar, @bar) +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.SpecConstant @bar +// CHECK-NEXT: spirv.SpecConstantComposite @foo_1 (@bar, @bar) -// CHECK-NEXT: spv.GlobalVariable @foo +// CHECK-NEXT: spirv.GlobalVariable @foo // CHECK-NEXT: } module { -spv.module Logical GLSL450 { - spv.SpecConstant @bar = -5 : i32 - spv.SpecConstantComposite @foo (@bar, @bar) : !spv.array<2 x i32> +spirv.module Logical GLSL450 { + spirv.SpecConstant @bar = -5 : i32 + spirv.SpecConstantComposite @foo (@bar, @bar) : !spirv.array<2 x i32> } -spv.module Logical GLSL450 { - spv.GlobalVariable @foo bind(1, 0) : !spv.ptr +spirv.module Logical GLSL450 { + spirv.GlobalVariable @foo bind(1, 0) : !spirv.ptr } } diff --git a/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/deduplication.mlir b/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/deduplication.mlir --- a/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/deduplication.mlir +++ b/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/deduplication.mlir @@ -3,42 +3,42 @@ // Deduplicate 2 global variables with the same descriptor set and binding. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.GlobalVariable @foo +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.GlobalVariable @foo -// CHECK-NEXT: spv.func @use_foo -// CHECK-NEXT: spv.mlir.addressof @foo -// CHECK-NEXT: spv.Load -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @use_foo +// CHECK-NEXT: spirv.mlir.addressof @foo +// CHECK-NEXT: spirv.Load +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @use_bar -// CHECK-NEXT: spv.mlir.addressof @foo -// CHECK-NEXT: spv.Load -// CHECK-NEXT: spv.FAdd -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @use_bar +// CHECK-NEXT: spirv.mlir.addressof @foo +// CHECK-NEXT: spirv.Load +// CHECK-NEXT: spirv.FAdd +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } -spv.module Logical GLSL450 { - spv.GlobalVariable @foo bind(1, 0) : !spv.ptr +spirv.module Logical GLSL450 { + spirv.GlobalVariable @foo bind(1, 0) : !spirv.ptr - spv.func @use_foo() -> f32 "None" { - %0 = spv.mlir.addressof @foo : !spv.ptr - %1 = spv.Load "Input" %0 : f32 - spv.ReturnValue %1 : f32 + spirv.func @use_foo() -> f32 "None" { + %0 = spirv.mlir.addressof @foo : !spirv.ptr + %1 = spirv.Load "Input" %0 : f32 + spirv.ReturnValue %1 : f32 } } -spv.module Logical GLSL450 { - spv.GlobalVariable @bar bind(1, 0) : !spv.ptr +spirv.module Logical GLSL450 { + spirv.GlobalVariable @bar bind(1, 0) : !spirv.ptr - spv.func @use_bar() -> f32 "None" { - %0 = spv.mlir.addressof @bar : !spv.ptr - %1 = spv.Load "Input" %0 : f32 - %2 = spv.FAdd %1, %1 : f32 - spv.ReturnValue %2 : f32 + spirv.func @use_bar() -> f32 "None" { + %0 = spirv.mlir.addressof @bar : !spirv.ptr + %1 = spirv.Load "Input" %0 : f32 + %2 = spirv.FAdd %1, %1 : f32 + spirv.ReturnValue %2 : f32 } } @@ -47,30 +47,30 @@ // Deduplicate 2 global variables with the same descriptor set and binding but different types. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.GlobalVariable @foo bind(1, 0) +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.GlobalVariable @foo bind(1, 0) -// CHECK-NEXT: spv.GlobalVariable @bar bind(1, 0) +// CHECK-NEXT: spirv.GlobalVariable @bar bind(1, 0) -// CHECK-NEXT: spv.func @use_bar -// CHECK-NEXT: spv.mlir.addressof @bar -// CHECK-NEXT: spv.Load -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @use_bar +// CHECK-NEXT: spirv.mlir.addressof @bar +// CHECK-NEXT: spirv.Load +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } -spv.module Logical GLSL450 { - spv.GlobalVariable @foo bind(1, 0) : !spv.ptr +spirv.module Logical GLSL450 { + spirv.GlobalVariable @foo bind(1, 0) : !spirv.ptr } -spv.module Logical GLSL450 { - spv.GlobalVariable @bar bind(1, 0) : !spv.ptr +spirv.module Logical GLSL450 { + spirv.GlobalVariable @bar bind(1, 0) : !spirv.ptr - spv.func @use_bar() -> f32 "None" { - %0 = spv.mlir.addressof @bar : !spv.ptr - %1 = spv.Load "Input" %0 : f32 - spv.ReturnValue %1 : f32 + spirv.func @use_bar() -> f32 "None" { + %0 = spirv.mlir.addressof @bar : !spirv.ptr + %1 = spirv.Load "Input" %0 : f32 + spirv.ReturnValue %1 : f32 } } @@ -79,27 +79,27 @@ // Deduplicate 2 global variables with the same built-in attribute. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.GlobalVariable @foo built_in("GlobalInvocationId") -// CHECK-NEXT: spv.func @use_bar -// CHECK-NEXT: spv.mlir.addressof @foo -// CHECK-NEXT: spv.Load -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.GlobalVariable @foo built_in("GlobalInvocationId") +// CHECK-NEXT: spirv.func @use_bar +// CHECK-NEXT: spirv.mlir.addressof @foo +// CHECK-NEXT: spirv.Load +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } -spv.module Logical GLSL450 { - spv.GlobalVariable @foo built_in("GlobalInvocationId") : !spv.ptr, Input> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @foo built_in("GlobalInvocationId") : !spirv.ptr, Input> } -spv.module Logical GLSL450 { - spv.GlobalVariable @bar built_in("GlobalInvocationId") : !spv.ptr, Input> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @bar built_in("GlobalInvocationId") : !spirv.ptr, Input> - spv.func @use_bar() -> vector<3xi32> "None" { - %0 = spv.mlir.addressof @bar : !spv.ptr, Input> - %1 = spv.Load "Input" %0 : vector<3xi32> - spv.ReturnValue %1 : vector<3xi32> + spirv.func @use_bar() -> vector<3xi32> "None" { + %0 = spirv.mlir.addressof @bar : !spirv.ptr, Input> + %1 = spirv.Load "Input" %0 : vector<3xi32> + spirv.ReturnValue %1 : vector<3xi32> } } @@ -108,38 +108,38 @@ // Deduplicate 2 spec constants with the same spec ID. // CHECK: module { -// CHECK-NEXT: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.SpecConstant @foo spec_id(5) +// CHECK-NEXT: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.SpecConstant @foo spec_id(5) -// CHECK-NEXT: spv.func @use_foo() -// CHECK-NEXT: %0 = spv.mlir.referenceof @foo -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @use_foo() +// CHECK-NEXT: %0 = spirv.mlir.referenceof @foo +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } -// CHECK-NEXT: spv.func @use_bar() -// CHECK-NEXT: %0 = spv.mlir.referenceof @foo -// CHECK-NEXT: spv.FAdd -// CHECK-NEXT: spv.ReturnValue +// CHECK-NEXT: spirv.func @use_bar() +// CHECK-NEXT: %0 = spirv.mlir.referenceof @foo +// CHECK-NEXT: spirv.FAdd +// CHECK-NEXT: spirv.ReturnValue // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } -spv.module Logical GLSL450 { - spv.SpecConstant @foo spec_id(5) = 1. : f32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @foo spec_id(5) = 1. : f32 - spv.func @use_foo() -> (f32) "None" { - %0 = spv.mlir.referenceof @foo : f32 - spv.ReturnValue %0 : f32 + spirv.func @use_foo() -> (f32) "None" { + %0 = spirv.mlir.referenceof @foo : f32 + spirv.ReturnValue %0 : f32 } } -spv.module Logical GLSL450 { - spv.SpecConstant @bar spec_id(5) = 1. : f32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @bar spec_id(5) = 1. : f32 - spv.func @use_bar() -> (f32) "None" { - %0 = spv.mlir.referenceof @bar : f32 - %1 = spv.FAdd %0, %0 : f32 - spv.ReturnValue %1 : f32 + spirv.func @use_bar() -> (f32) "None" { + %0 = spirv.mlir.referenceof @bar : f32 + %1 = spirv.FAdd %0, %0 : f32 + spirv.ReturnValue %1 : f32 } } @@ -147,32 +147,32 @@ // Don't deduplicate functions with similar ops but different operands. -// CHECK: spv.module Logical GLSL450 { -// CHECK-NEXT: spv.func @foo(%[[ARG0:.+]]: f32, %[[ARG1:.+]]: f32, %[[ARG2:.+]]: f32) -// CHECK-NEXT: %[[ADD:.+]] = spv.FAdd %[[ARG0]], %[[ARG1]] : f32 -// CHECK-NEXT: %[[MUL:.+]] = spv.FMul %[[ADD]], %[[ARG2]] : f32 -// CHECK-NEXT: spv.ReturnValue %[[MUL]] : f32 +// CHECK: spirv.module Logical GLSL450 { +// CHECK-NEXT: spirv.func @foo(%[[ARG0:.+]]: f32, %[[ARG1:.+]]: f32, %[[ARG2:.+]]: f32) +// CHECK-NEXT: %[[ADD:.+]] = spirv.FAdd %[[ARG0]], %[[ARG1]] : f32 +// CHECK-NEXT: %[[MUL:.+]] = spirv.FMul %[[ADD]], %[[ARG2]] : f32 +// CHECK-NEXT: spirv.ReturnValue %[[MUL]] : f32 // CHECK-NEXT: } -// CHECK-NEXT: spv.func @foo_1(%[[ARG0:.+]]: f32, %[[ARG1:.+]]: f32, %[[ARG2:.+]]: f32) -// CHECK-NEXT: %[[ADD:.+]] = spv.FAdd %[[ARG0]], %[[ARG2]] : f32 -// CHECK-NEXT: %[[MUL:.+]] = spv.FMul %[[ADD]], %[[ARG1]] : f32 -// CHECK-NEXT: spv.ReturnValue %[[MUL]] : f32 +// CHECK-NEXT: spirv.func @foo_1(%[[ARG0:.+]]: f32, %[[ARG1:.+]]: f32, %[[ARG2:.+]]: f32) +// CHECK-NEXT: %[[ADD:.+]] = spirv.FAdd %[[ARG0]], %[[ARG2]] : f32 +// CHECK-NEXT: %[[MUL:.+]] = spirv.FMul %[[ADD]], %[[ARG1]] : f32 +// CHECK-NEXT: spirv.ReturnValue %[[MUL]] : f32 // CHECK-NEXT: } // CHECK-NEXT: } -spv.module Logical GLSL450 { - spv.func @foo(%a: f32, %b: f32, %c: f32) -> f32 "None" { - %add = spv.FAdd %a, %b: f32 - %mul = spv.FMul %add, %c: f32 - spv.ReturnValue %mul: f32 +spirv.module Logical GLSL450 { + spirv.func @foo(%a: f32, %b: f32, %c: f32) -> f32 "None" { + %add = spirv.FAdd %a, %b: f32 + %mul = spirv.FMul %add, %c: f32 + spirv.ReturnValue %mul: f32 } } -spv.module Logical GLSL450 { - spv.func @foo(%a: f32, %b: f32, %c: f32) -> f32 "None" { - %add = spv.FAdd %a, %c: f32 - %mul = spv.FMul %add, %b: f32 - spv.ReturnValue %mul: f32 +spirv.module Logical GLSL450 { + spirv.func @foo(%a: f32, %b: f32, %c: f32) -> f32 "None" { + %add = spirv.FAdd %a, %c: f32 + %mul = spirv.FMul %add, %b: f32 + spirv.ReturnValue %mul: f32 } } @@ -181,93 +181,93 @@ // TODO: re-enable this test once we have better function deduplication. // XXXXX: module { -// XXXXX-NEXT: spv.module Logical GLSL450 { -// XXXXX-NEXT: spv.SpecConstant @bar spec_id(5) +// XXXXX-NEXT: spirv.module Logical GLSL450 { +// XXXXX-NEXT: spirv.SpecConstant @bar spec_id(5) -// XXXXX-NEXT: spv.func @foo(%arg0: f32) -// XXXXX-NEXT: spv.ReturnValue +// XXXXX-NEXT: spirv.func @foo(%arg0: f32) +// XXXXX-NEXT: spirv.ReturnValue // XXXXX-NEXT: } -// XXXXX-NEXT: spv.func @foo_different_body(%arg0: f32) -// XXXXX-NEXT: spv.mlir.referenceof -// XXXXX-NEXT: spv.ReturnValue +// XXXXX-NEXT: spirv.func @foo_different_body(%arg0: f32) +// XXXXX-NEXT: spirv.mlir.referenceof +// XXXXX-NEXT: spirv.ReturnValue // XXXXX-NEXT: } -// XXXXX-NEXT: spv.func @baz(%arg0: i32) -// XXXXX-NEXT: spv.ReturnValue +// XXXXX-NEXT: spirv.func @baz(%arg0: i32) +// XXXXX-NEXT: spirv.ReturnValue // XXXXX-NEXT: } -// XXXXX-NEXT: spv.func @baz_no_return(%arg0: i32) -// XXXXX-NEXT: spv.Return +// XXXXX-NEXT: spirv.func @baz_no_return(%arg0: i32) +// XXXXX-NEXT: spirv.Return // XXXXX-NEXT: } -// XXXXX-NEXT: spv.func @baz_no_return_different_control -// XXXXX-NEXT: spv.Return +// XXXXX-NEXT: spirv.func @baz_no_return_different_control +// XXXXX-NEXT: spirv.Return // XXXXX-NEXT: } -// XXXXX-NEXT: spv.func @baz_no_return_another_control -// XXXXX-NEXT: spv.Return +// XXXXX-NEXT: spirv.func @baz_no_return_another_control +// XXXXX-NEXT: spirv.Return // XXXXX-NEXT: } -// XXXXX-NEXT: spv.func @kernel -// XXXXX-NEXT: spv.Return +// XXXXX-NEXT: spirv.func @kernel +// XXXXX-NEXT: spirv.Return // XXXXX-NEXT: } -// XXXXX-NEXT: spv.func @kernel_different_attr -// XXXXX-NEXT: spv.Return +// XXXXX-NEXT: spirv.func @kernel_different_attr +// XXXXX-NEXT: spirv.Return // XXXXX-NEXT: } // XXXXX-NEXT: } // XXXXX-NEXT: } module { -spv.module Logical GLSL450 { - spv.SpecConstant @bar spec_id(5) = 1. : f32 +spirv.module Logical GLSL450 { + spirv.SpecConstant @bar spec_id(5) = 1. : f32 - spv.func @foo(%arg0: f32) -> (f32) "None" { - spv.ReturnValue %arg0 : f32 + spirv.func @foo(%arg0: f32) -> (f32) "None" { + spirv.ReturnValue %arg0 : f32 } - spv.func @foo_duplicate(%arg0: f32) -> (f32) "None" { - spv.ReturnValue %arg0 : f32 + spirv.func @foo_duplicate(%arg0: f32) -> (f32) "None" { + spirv.ReturnValue %arg0 : f32 } - spv.func @foo_different_body(%arg0: f32) -> (f32) "None" { - %0 = spv.mlir.referenceof @bar : f32 - spv.ReturnValue %arg0 : f32 + spirv.func @foo_different_body(%arg0: f32) -> (f32) "None" { + %0 = spirv.mlir.referenceof @bar : f32 + spirv.ReturnValue %arg0 : f32 } - spv.func @baz(%arg0: i32) -> (i32) "None" { - spv.ReturnValue %arg0 : i32 + spirv.func @baz(%arg0: i32) -> (i32) "None" { + spirv.ReturnValue %arg0 : i32 } - spv.func @baz_no_return(%arg0: i32) "None" { - spv.Return + spirv.func @baz_no_return(%arg0: i32) "None" { + spirv.Return } - spv.func @baz_no_return_duplicate(%arg0: i32) -> () "None" { - spv.Return + spirv.func @baz_no_return_duplicate(%arg0: i32) -> () "None" { + spirv.Return } - spv.func @baz_no_return_different_control(%arg0: i32) -> () "Inline" { - spv.Return + spirv.func @baz_no_return_different_control(%arg0: i32) -> () "Inline" { + spirv.Return } - spv.func @baz_no_return_another_control(%arg0: i32) -> () "Inline|Pure" { - spv.Return + spirv.func @baz_no_return_another_control(%arg0: i32) -> () "Inline|Pure" { + spirv.Return } - spv.func @kernel( + spirv.func @kernel( %arg0: f32, - %arg1: !spv.ptr)>, CrossWorkgroup>) "None" - attributes {spv.entry_point_abi = #spv.entry_point_abi : vector<3xi32>>} { - spv.Return + %arg1: !spirv.ptr)>, CrossWorkgroup>) "None" + attributes {spirv.entry_point_abi = #spirv.entry_point_abi : vector<3xi32>>} { + spirv.Return } - spv.func @kernel_different_attr( + spirv.func @kernel_different_attr( %arg0: f32, - %arg1: !spv.ptr)>, CrossWorkgroup>) "None" - attributes {spv.entry_point_abi = #spv.entry_point_abi : vector<3xi32>>} { - spv.Return + %arg1: !spirv.ptr)>, CrossWorkgroup>) "None" + attributes {spirv.entry_point_abi = #spirv.entry_point_abi : vector<3xi32>>} { + spirv.Return } } } diff --git a/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/symbol-rename-listener.mlir b/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/symbol-rename-listener.mlir --- a/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/symbol-rename-listener.mlir +++ b/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/symbol-rename-listener.mlir @@ -1,44 +1,44 @@ // RUN: mlir-opt -test-spirv-module-combiner -split-input-file -verify-diagnostics %s | FileCheck %s module { -spv.module @Module1 Logical GLSL450 { - spv.GlobalVariable @foo bind(1, 0) : !spv.ptr - spv.func @bar() -> () "None" { - spv.Return +spirv.module @Module1 Logical GLSL450 { + spirv.GlobalVariable @foo bind(1, 0) : !spirv.ptr + spirv.func @bar() -> () "None" { + spirv.Return } - spv.func @baz() -> () "None" { - spv.Return + spirv.func @baz() -> () "None" { + spirv.Return } - spv.SpecConstant @sc = -5 : i32 + spirv.SpecConstant @sc = -5 : i32 } -spv.module @Module2 Logical GLSL450 { - spv.func @foo() -> () "None" { - spv.Return +spirv.module @Module2 Logical GLSL450 { + spirv.func @foo() -> () "None" { + spirv.Return } - spv.GlobalVariable @bar bind(1, 0) : !spv.ptr + spirv.GlobalVariable @bar bind(1, 0) : !spirv.ptr - spv.func @baz() -> () "None" { - spv.Return + spirv.func @baz() -> () "None" { + spirv.Return } - spv.SpecConstant @sc = -5 : i32 + spirv.SpecConstant @sc = -5 : i32 } -spv.module @Module3 Logical GLSL450 { - spv.func @foo() -> () "None" { - spv.Return +spirv.module @Module3 Logical GLSL450 { + spirv.func @foo() -> () "None" { + spirv.Return } - spv.GlobalVariable @bar bind(1, 0) : !spv.ptr + spirv.GlobalVariable @bar bind(1, 0) : !spirv.ptr - spv.func @baz() -> () "None" { - spv.Return + spirv.func @baz() -> () "None" { + spirv.Return } - spv.SpecConstant @sc = -5 : i32 + spirv.SpecConstant @sc = -5 : i32 } } diff --git a/mlir/test/Dialect/SPIRV/Transforms/abi-interface-opencl.mlir b/mlir/test/Dialect/SPIRV/Transforms/abi-interface-opencl.mlir --- a/mlir/test/Dialect/SPIRV/Transforms/abi-interface-opencl.mlir +++ b/mlir/test/Dialect/SPIRV/Transforms/abi-interface-opencl.mlir @@ -1,18 +1,18 @@ // RUN: mlir-opt -spirv-lower-abi-attrs -verify-diagnostics %s -o - | FileCheck %s module attributes { - spv.target_env = #spv.target_env<#spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env<#spirv.vce, #spirv.resource_limits<>> } { - spv.module Physical64 OpenCL { - // CHECK-LABEL: spv.module - // CHECK: spv.func [[FN:@.*]]({{%.*}}: f32, {{%.*}}: !spv.ptr)>, CrossWorkgroup> - // CHECK: spv.EntryPoint "Kernel" [[FN]] - // CHECK: spv.ExecutionMode [[FN]] "LocalSize", 32, 1, 1 - spv.func @kernel( + spirv.module Physical64 OpenCL { + // CHECK-LABEL: spirv.module + // CHECK: spirv.func [[FN:@.*]]({{%.*}}: f32, {{%.*}}: !spirv.ptr)>, CrossWorkgroup> + // CHECK: spirv.EntryPoint "Kernel" [[FN]] + // CHECK: spirv.ExecutionMode [[FN]] "LocalSize", 32, 1, 1 + spirv.func @kernel( %arg0: f32, - %arg1: !spv.ptr)>, CrossWorkgroup>) "None" - attributes {spv.entry_point_abi = #spv.entry_point_abi : vector<3xi32>>} { - spv.Return + %arg1: !spirv.ptr)>, CrossWorkgroup>) "None" + attributes {spirv.entry_point_abi = #spirv.entry_point_abi : vector<3xi32>>} { + spirv.Return } } } diff --git a/mlir/test/Dialect/SPIRV/Transforms/abi-interface.mlir b/mlir/test/Dialect/SPIRV/Transforms/abi-interface.mlir --- a/mlir/test/Dialect/SPIRV/Transforms/abi-interface.mlir +++ b/mlir/test/Dialect/SPIRV/Transforms/abi-interface.mlir @@ -1,31 +1,31 @@ // RUN: mlir-opt -spirv-lower-abi-attrs -verify-diagnostics %s -o - | FileCheck %s module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.module -spv.module Logical GLSL450 { - // CHECK-DAG: spv.GlobalVariable [[VAR0:@.*]] bind(0, 0) : !spv.ptr, StorageBuffer> - // CHECK-DAG: spv.GlobalVariable [[VAR1:@.*]] bind(0, 1) : !spv.ptr [0])>, StorageBuffer> - // CHECK: spv.func [[FN:@.*]]() - spv.func @kernel( +// CHECK-LABEL: spirv.module +spirv.module Logical GLSL450 { + // CHECK-DAG: spirv.GlobalVariable [[VAR0:@.*]] bind(0, 0) : !spirv.ptr, StorageBuffer> + // CHECK-DAG: spirv.GlobalVariable [[VAR1:@.*]] bind(0, 1) : !spirv.ptr [0])>, StorageBuffer> + // CHECK: spirv.func [[FN:@.*]]() + spirv.func @kernel( %arg0: f32 - {spv.interface_var_abi = #spv.interface_var_abi<(0, 0), StorageBuffer>}, - %arg1: !spv.ptr)>, StorageBuffer> - {spv.interface_var_abi = #spv.interface_var_abi<(0, 1)>}) "None" - attributes {spv.entry_point_abi = #spv.entry_point_abi : vector<3xi32>>} { - // CHECK: [[ARG1:%.*]] = spv.mlir.addressof [[VAR1]] - // CHECK: [[ADDRESSARG0:%.*]] = spv.mlir.addressof [[VAR0]] - // CHECK: [[CONST0:%.*]] = spv.Constant 0 : i32 - // CHECK: [[ARG0PTR:%.*]] = spv.AccessChain [[ADDRESSARG0]]{{\[}}[[CONST0]] - // CHECK: [[ARG0:%.*]] = spv.Load "StorageBuffer" [[ARG0PTR]] - // CHECK: spv.Return - spv.Return + {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 0), StorageBuffer>}, + %arg1: !spirv.ptr)>, StorageBuffer> + {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1)>}) "None" + attributes {spirv.entry_point_abi = #spirv.entry_point_abi : vector<3xi32>>} { + // CHECK: [[ARG1:%.*]] = spirv.mlir.addressof [[VAR1]] + // CHECK: [[ADDRESSARG0:%.*]] = spirv.mlir.addressof [[VAR0]] + // CHECK: [[CONST0:%.*]] = spirv.Constant 0 : i32 + // CHECK: [[ARG0PTR:%.*]] = spirv.AccessChain [[ADDRESSARG0]]{{\[}}[[CONST0]] + // CHECK: [[ARG0:%.*]] = spirv.Load "StorageBuffer" [[ARG0PTR]] + // CHECK: spirv.Return + spirv.Return } - // CHECK: spv.EntryPoint "GLCompute" [[FN]] - // CHECK: spv.ExecutionMode [[FN]] "LocalSize", 32, 1, 1 -} // end spv.module + // CHECK: spirv.EntryPoint "GLCompute" [[FN]] + // CHECK: spirv.ExecutionMode [[FN]] "LocalSize", 32, 1, 1 +} // end spirv.module } // end module diff --git a/mlir/test/Dialect/SPIRV/Transforms/abi-load-store.mlir b/mlir/test/Dialect/SPIRV/Transforms/abi-load-store.mlir --- a/mlir/test/Dialect/SPIRV/Transforms/abi-load-store.mlir +++ b/mlir/test/Dialect/SPIRV/Transforms/abi-load-store.mlir @@ -1,121 +1,121 @@ // RUN: mlir-opt -spirv-lower-abi-attrs -verify-diagnostics %s -o - | FileCheck %s module attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { -// CHECK-LABEL: spv.module -spv.module Logical GLSL450 { - // CHECK-DAG: spv.GlobalVariable [[WORKGROUPSIZE:@.*]] built_in("WorkgroupSize") - spv.GlobalVariable @__builtin_var_WorkgroupSize__ built_in("WorkgroupSize") : !spv.ptr, Input> - // CHECK-DAG: spv.GlobalVariable [[NUMWORKGROUPS:@.*]] built_in("NumWorkgroups") - spv.GlobalVariable @__builtin_var_NumWorkgroups__ built_in("NumWorkgroups") : !spv.ptr, Input> - // CHECK-DAG: spv.GlobalVariable [[LOCALINVOCATIONID:@.*]] built_in("LocalInvocationId") - spv.GlobalVariable @__builtin_var_LocalInvocationId__ built_in("LocalInvocationId") : !spv.ptr, Input> - // CHECK-DAG: spv.GlobalVariable [[WORKGROUPID:@.*]] built_in("WorkgroupId") - spv.GlobalVariable @__builtin_var_WorkgroupId__ built_in("WorkgroupId") : !spv.ptr, Input> - // CHECK-DAG: spv.GlobalVariable [[VAR0:@.*]] bind(0, 0) : !spv.ptr, stride=16> [0])>, StorageBuffer> - // CHECK-DAG: spv.GlobalVariable [[VAR1:@.*]] bind(0, 1) : !spv.ptr, stride=16> [0])>, StorageBuffer> - // CHECK-DAG: spv.GlobalVariable [[VAR2:@.*]] bind(0, 2) : !spv.ptr, stride=16> [0])>, StorageBuffer> - // CHECK-DAG: spv.GlobalVariable [[VAR3:@.*]] bind(0, 3) : !spv.ptr, StorageBuffer> - // CHECK-DAG: spv.GlobalVariable [[VAR4:@.*]] bind(0, 4) : !spv.ptr, StorageBuffer> - // CHECK-DAG: spv.GlobalVariable [[VAR5:@.*]] bind(0, 5) : !spv.ptr, StorageBuffer> - // CHECK-DAG: spv.GlobalVariable [[VAR6:@.*]] bind(0, 6) : !spv.ptr, StorageBuffer> - // CHECK: spv.func [[FN:@.*]]() - spv.func @load_store_kernel( - %arg0: !spv.ptr>)>, StorageBuffer> - {spv.interface_var_abi = #spv.interface_var_abi<(0, 0)>}, - %arg1: !spv.ptr>)>, StorageBuffer> - {spv.interface_var_abi = #spv.interface_var_abi<(0, 1)>}, - %arg2: !spv.ptr>)>, StorageBuffer> - {spv.interface_var_abi = #spv.interface_var_abi<(0, 2)>}, +// CHECK-LABEL: spirv.module +spirv.module Logical GLSL450 { + // CHECK-DAG: spirv.GlobalVariable [[WORKGROUPSIZE:@.*]] built_in("WorkgroupSize") + spirv.GlobalVariable @__builtin_var_WorkgroupSize__ built_in("WorkgroupSize") : !spirv.ptr, Input> + // CHECK-DAG: spirv.GlobalVariable [[NUMWORKGROUPS:@.*]] built_in("NumWorkgroups") + spirv.GlobalVariable @__builtin_var_NumWorkgroups__ built_in("NumWorkgroups") : !spirv.ptr, Input> + // CHECK-DAG: spirv.GlobalVariable [[LOCALINVOCATIONID:@.*]] built_in("LocalInvocationId") + spirv.GlobalVariable @__builtin_var_LocalInvocationId__ built_in("LocalInvocationId") : !spirv.ptr, Input> + // CHECK-DAG: spirv.GlobalVariable [[WORKGROUPID:@.*]] built_in("WorkgroupId") + spirv.GlobalVariable @__builtin_var_WorkgroupId__ built_in("WorkgroupId") : !spirv.ptr, Input> + // CHECK-DAG: spirv.GlobalVariable [[VAR0:@.*]] bind(0, 0) : !spirv.ptr, stride=16> [0])>, StorageBuffer> + // CHECK-DAG: spirv.GlobalVariable [[VAR1:@.*]] bind(0, 1) : !spirv.ptr, stride=16> [0])>, StorageBuffer> + // CHECK-DAG: spirv.GlobalVariable [[VAR2:@.*]] bind(0, 2) : !spirv.ptr, stride=16> [0])>, StorageBuffer> + // CHECK-DAG: spirv.GlobalVariable [[VAR3:@.*]] bind(0, 3) : !spirv.ptr, StorageBuffer> + // CHECK-DAG: spirv.GlobalVariable [[VAR4:@.*]] bind(0, 4) : !spirv.ptr, StorageBuffer> + // CHECK-DAG: spirv.GlobalVariable [[VAR5:@.*]] bind(0, 5) : !spirv.ptr, StorageBuffer> + // CHECK-DAG: spirv.GlobalVariable [[VAR6:@.*]] bind(0, 6) : !spirv.ptr, StorageBuffer> + // CHECK: spirv.func [[FN:@.*]]() + spirv.func @load_store_kernel( + %arg0: !spirv.ptr>)>, StorageBuffer> + {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 0)>}, + %arg1: !spirv.ptr>)>, StorageBuffer> + {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1)>}, + %arg2: !spirv.ptr>)>, StorageBuffer> + {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 2)>}, %arg3: i32 - {spv.interface_var_abi = #spv.interface_var_abi<(0, 3), StorageBuffer>}, + {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 3), StorageBuffer>}, %arg4: i32 - {spv.interface_var_abi = #spv.interface_var_abi<(0, 4), StorageBuffer>}, + {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 4), StorageBuffer>}, %arg5: i32 - {spv.interface_var_abi = #spv.interface_var_abi<(0, 5), StorageBuffer>}, + {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 5), StorageBuffer>}, %arg6: i32 - {spv.interface_var_abi = #spv.interface_var_abi<(0, 6), StorageBuffer>}) "None" - attributes {spv.entry_point_abi = #spv.entry_point_abi : vector<3xi32>>} { - // CHECK: [[ADDRESSARG6:%.*]] = spv.mlir.addressof [[VAR6]] - // CHECK: [[CONST6:%.*]] = spv.Constant 0 : i32 - // CHECK: [[ARG6PTR:%.*]] = spv.AccessChain [[ADDRESSARG6]]{{\[}}[[CONST6]] - // CHECK: {{%.*}} = spv.Load "StorageBuffer" [[ARG6PTR]] - // CHECK: [[ADDRESSARG5:%.*]] = spv.mlir.addressof [[VAR5]] - // CHECK: [[CONST5:%.*]] = spv.Constant 0 : i32 - // CHECK: [[ARG5PTR:%.*]] = spv.AccessChain [[ADDRESSARG5]]{{\[}}[[CONST5]] - // CHECK: {{%.*}} = spv.Load "StorageBuffer" [[ARG5PTR]] - // CHECK: [[ADDRESSARG4:%.*]] = spv.mlir.addressof [[VAR4]] - // CHECK: [[CONST4:%.*]] = spv.Constant 0 : i32 - // CHECK: [[ARG4PTR:%.*]] = spv.AccessChain [[ADDRESSARG4]]{{\[}}[[CONST4]] - // CHECK: [[ARG4:%.*]] = spv.Load "StorageBuffer" [[ARG4PTR]] - // CHECK: [[ADDRESSARG3:%.*]] = spv.mlir.addressof [[VAR3]] - // CHECK: [[CONST3:%.*]] = spv.Constant 0 : i32 - // CHECK: [[ARG3PTR:%.*]] = spv.AccessChain [[ADDRESSARG3]]{{\[}}[[CONST3]] - // CHECK: [[ARG3:%.*]] = spv.Load "StorageBuffer" [[ARG3PTR]] - // CHECK: [[ADDRESSARG2:%.*]] = spv.mlir.addressof [[VAR2]] - // CHECK: [[ARG2:%.*]] = spv.Bitcast [[ADDRESSARG2]] - // CHECK: [[ADDRESSARG1:%.*]] = spv.mlir.addressof [[VAR1]] - // CHECK: [[ARG1:%.*]] = spv.Bitcast [[ADDRESSARG1]] - // CHECK: [[ADDRESSARG0:%.*]] = spv.mlir.addressof [[VAR0]] - // CHECK: [[ARG0:%.*]] = spv.Bitcast [[ADDRESSARG0]] - %0 = spv.mlir.addressof @__builtin_var_WorkgroupId__ : !spv.ptr, Input> - %1 = spv.Load "Input" %0 : vector<3xi32> - %2 = spv.CompositeExtract %1[0 : i32] : vector<3xi32> - %3 = spv.mlir.addressof @__builtin_var_WorkgroupId__ : !spv.ptr, Input> - %4 = spv.Load "Input" %3 : vector<3xi32> - %5 = spv.CompositeExtract %4[1 : i32] : vector<3xi32> - %6 = spv.mlir.addressof @__builtin_var_WorkgroupId__ : !spv.ptr, Input> - %7 = spv.Load "Input" %6 : vector<3xi32> - %8 = spv.CompositeExtract %7[2 : i32] : vector<3xi32> - %9 = spv.mlir.addressof @__builtin_var_LocalInvocationId__ : !spv.ptr, Input> - %10 = spv.Load "Input" %9 : vector<3xi32> - %11 = spv.CompositeExtract %10[0 : i32] : vector<3xi32> - %12 = spv.mlir.addressof @__builtin_var_LocalInvocationId__ : !spv.ptr, Input> - %13 = spv.Load "Input" %12 : vector<3xi32> - %14 = spv.CompositeExtract %13[1 : i32] : vector<3xi32> - %15 = spv.mlir.addressof @__builtin_var_LocalInvocationId__ : !spv.ptr, Input> - %16 = spv.Load "Input" %15 : vector<3xi32> - %17 = spv.CompositeExtract %16[2 : i32] : vector<3xi32> - %18 = spv.mlir.addressof @__builtin_var_NumWorkgroups__ : !spv.ptr, Input> - %19 = spv.Load "Input" %18 : vector<3xi32> - %20 = spv.CompositeExtract %19[0 : i32] : vector<3xi32> - %21 = spv.mlir.addressof @__builtin_var_NumWorkgroups__ : !spv.ptr, Input> - %22 = spv.Load "Input" %21 : vector<3xi32> - %23 = spv.CompositeExtract %22[1 : i32] : vector<3xi32> - %24 = spv.mlir.addressof @__builtin_var_NumWorkgroups__ : !spv.ptr, Input> - %25 = spv.Load "Input" %24 : vector<3xi32> - %26 = spv.CompositeExtract %25[2 : i32] : vector<3xi32> - %27 = spv.mlir.addressof @__builtin_var_WorkgroupSize__ : !spv.ptr, Input> - %28 = spv.Load "Input" %27 : vector<3xi32> - %29 = spv.CompositeExtract %28[0 : i32] : vector<3xi32> - %30 = spv.mlir.addressof @__builtin_var_WorkgroupSize__ : !spv.ptr, Input> - %31 = spv.Load "Input" %30 : vector<3xi32> - %32 = spv.CompositeExtract %31[1 : i32] : vector<3xi32> - %33 = spv.mlir.addressof @__builtin_var_WorkgroupSize__ : !spv.ptr, Input> - %34 = spv.Load "Input" %33 : vector<3xi32> - %35 = spv.CompositeExtract %34[2 : i32] : vector<3xi32> - // CHECK: spv.IAdd [[ARG3]] - %36 = spv.IAdd %arg3, %2 : i32 - // CHECK: spv.IAdd [[ARG4]] - %37 = spv.IAdd %arg4, %11 : i32 - // CHECK: spv.AccessChain [[ARG0]] - %c0 = spv.Constant 0 : i32 - %38 = spv.AccessChain %arg0[%c0, %36, %37] : !spv.ptr>)>, StorageBuffer>, i32, i32, i32 - %39 = spv.Load "StorageBuffer" %38 : f32 - // CHECK: spv.AccessChain [[ARG1]] - %40 = spv.AccessChain %arg1[%c0, %36, %37] : !spv.ptr>)>, StorageBuffer>, i32, i32, i32 - %41 = spv.Load "StorageBuffer" %40 : f32 - %42 = spv.FAdd %39, %41 : f32 - // CHECK: spv.AccessChain [[ARG2]] - %43 = spv.AccessChain %arg2[%c0, %36, %37] : !spv.ptr>)>, StorageBuffer>, i32, i32, i32 - spv.Store "StorageBuffer" %43, %42 : f32 - spv.Return + {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 6), StorageBuffer>}) "None" + attributes {spirv.entry_point_abi = #spirv.entry_point_abi : vector<3xi32>>} { + // CHECK: [[ADDRESSARG6:%.*]] = spirv.mlir.addressof [[VAR6]] + // CHECK: [[CONST6:%.*]] = spirv.Constant 0 : i32 + // CHECK: [[ARG6PTR:%.*]] = spirv.AccessChain [[ADDRESSARG6]]{{\[}}[[CONST6]] + // CHECK: {{%.*}} = spirv.Load "StorageBuffer" [[ARG6PTR]] + // CHECK: [[ADDRESSARG5:%.*]] = spirv.mlir.addressof [[VAR5]] + // CHECK: [[CONST5:%.*]] = spirv.Constant 0 : i32 + // CHECK: [[ARG5PTR:%.*]] = spirv.AccessChain [[ADDRESSARG5]]{{\[}}[[CONST5]] + // CHECK: {{%.*}} = spirv.Load "StorageBuffer" [[ARG5PTR]] + // CHECK: [[ADDRESSARG4:%.*]] = spirv.mlir.addressof [[VAR4]] + // CHECK: [[CONST4:%.*]] = spirv.Constant 0 : i32 + // CHECK: [[ARG4PTR:%.*]] = spirv.AccessChain [[ADDRESSARG4]]{{\[}}[[CONST4]] + // CHECK: [[ARG4:%.*]] = spirv.Load "StorageBuffer" [[ARG4PTR]] + // CHECK: [[ADDRESSARG3:%.*]] = spirv.mlir.addressof [[VAR3]] + // CHECK: [[CONST3:%.*]] = spirv.Constant 0 : i32 + // CHECK: [[ARG3PTR:%.*]] = spirv.AccessChain [[ADDRESSARG3]]{{\[}}[[CONST3]] + // CHECK: [[ARG3:%.*]] = spirv.Load "StorageBuffer" [[ARG3PTR]] + // CHECK: [[ADDRESSARG2:%.*]] = spirv.mlir.addressof [[VAR2]] + // CHECK: [[ARG2:%.*]] = spirv.Bitcast [[ADDRESSARG2]] + // CHECK: [[ADDRESSARG1:%.*]] = spirv.mlir.addressof [[VAR1]] + // CHECK: [[ARG1:%.*]] = spirv.Bitcast [[ADDRESSARG1]] + // CHECK: [[ADDRESSARG0:%.*]] = spirv.mlir.addressof [[VAR0]] + // CHECK: [[ARG0:%.*]] = spirv.Bitcast [[ADDRESSARG0]] + %0 = spirv.mlir.addressof @__builtin_var_WorkgroupId__ : !spirv.ptr, Input> + %1 = spirv.Load "Input" %0 : vector<3xi32> + %2 = spirv.CompositeExtract %1[0 : i32] : vector<3xi32> + %3 = spirv.mlir.addressof @__builtin_var_WorkgroupId__ : !spirv.ptr, Input> + %4 = spirv.Load "Input" %3 : vector<3xi32> + %5 = spirv.CompositeExtract %4[1 : i32] : vector<3xi32> + %6 = spirv.mlir.addressof @__builtin_var_WorkgroupId__ : !spirv.ptr, Input> + %7 = spirv.Load "Input" %6 : vector<3xi32> + %8 = spirv.CompositeExtract %7[2 : i32] : vector<3xi32> + %9 = spirv.mlir.addressof @__builtin_var_LocalInvocationId__ : !spirv.ptr, Input> + %10 = spirv.Load "Input" %9 : vector<3xi32> + %11 = spirv.CompositeExtract %10[0 : i32] : vector<3xi32> + %12 = spirv.mlir.addressof @__builtin_var_LocalInvocationId__ : !spirv.ptr, Input> + %13 = spirv.Load "Input" %12 : vector<3xi32> + %14 = spirv.CompositeExtract %13[1 : i32] : vector<3xi32> + %15 = spirv.mlir.addressof @__builtin_var_LocalInvocationId__ : !spirv.ptr, Input> + %16 = spirv.Load "Input" %15 : vector<3xi32> + %17 = spirv.CompositeExtract %16[2 : i32] : vector<3xi32> + %18 = spirv.mlir.addressof @__builtin_var_NumWorkgroups__ : !spirv.ptr, Input> + %19 = spirv.Load "Input" %18 : vector<3xi32> + %20 = spirv.CompositeExtract %19[0 : i32] : vector<3xi32> + %21 = spirv.mlir.addressof @__builtin_var_NumWorkgroups__ : !spirv.ptr, Input> + %22 = spirv.Load "Input" %21 : vector<3xi32> + %23 = spirv.CompositeExtract %22[1 : i32] : vector<3xi32> + %24 = spirv.mlir.addressof @__builtin_var_NumWorkgroups__ : !spirv.ptr, Input> + %25 = spirv.Load "Input" %24 : vector<3xi32> + %26 = spirv.CompositeExtract %25[2 : i32] : vector<3xi32> + %27 = spirv.mlir.addressof @__builtin_var_WorkgroupSize__ : !spirv.ptr, Input> + %28 = spirv.Load "Input" %27 : vector<3xi32> + %29 = spirv.CompositeExtract %28[0 : i32] : vector<3xi32> + %30 = spirv.mlir.addressof @__builtin_var_WorkgroupSize__ : !spirv.ptr, Input> + %31 = spirv.Load "Input" %30 : vector<3xi32> + %32 = spirv.CompositeExtract %31[1 : i32] : vector<3xi32> + %33 = spirv.mlir.addressof @__builtin_var_WorkgroupSize__ : !spirv.ptr, Input> + %34 = spirv.Load "Input" %33 : vector<3xi32> + %35 = spirv.CompositeExtract %34[2 : i32] : vector<3xi32> + // CHECK: spirv.IAdd [[ARG3]] + %36 = spirv.IAdd %arg3, %2 : i32 + // CHECK: spirv.IAdd [[ARG4]] + %37 = spirv.IAdd %arg4, %11 : i32 + // CHECK: spirv.AccessChain [[ARG0]] + %c0 = spirv.Constant 0 : i32 + %38 = spirv.AccessChain %arg0[%c0, %36, %37] : !spirv.ptr>)>, StorageBuffer>, i32, i32, i32 + %39 = spirv.Load "StorageBuffer" %38 : f32 + // CHECK: spirv.AccessChain [[ARG1]] + %40 = spirv.AccessChain %arg1[%c0, %36, %37] : !spirv.ptr>)>, StorageBuffer>, i32, i32, i32 + %41 = spirv.Load "StorageBuffer" %40 : f32 + %42 = spirv.FAdd %39, %41 : f32 + // CHECK: spirv.AccessChain [[ARG2]] + %43 = spirv.AccessChain %arg2[%c0, %36, %37] : !spirv.ptr>)>, StorageBuffer>, i32, i32, i32 + spirv.Store "StorageBuffer" %43, %42 : f32 + spirv.Return } - // CHECK: spv.EntryPoint "GLCompute" [[FN]], [[WORKGROUPID]], [[LOCALINVOCATIONID]], [[NUMWORKGROUPS]], [[WORKGROUPSIZE]] - // CHECK-NEXT: spv.ExecutionMode [[FN]] "LocalSize", 32, 1, 1 -} // end spv.module + // CHECK: spirv.EntryPoint "GLCompute" [[FN]], [[WORKGROUPID]], [[LOCALINVOCATIONID]], [[NUMWORKGROUPS]], [[WORKGROUPSIZE]] + // CHECK-NEXT: spirv.ExecutionMode [[FN]] "LocalSize", 32, 1, 1 +} // end spirv.module } // end module diff --git a/mlir/test/Dialect/SPIRV/Transforms/canonicalize.mlir b/mlir/test/Dialect/SPIRV/Transforms/canonicalize.mlir --- a/mlir/test/Dialect/SPIRV/Transforms/canonicalize.mlir +++ b/mlir/test/Dialect/SPIRV/Transforms/canonicalize.mlir @@ -1,104 +1,104 @@ // RUN: mlir-opt %s -split-input-file -pass-pipeline='func.func(canonicalize)' | FileCheck %s //===----------------------------------------------------------------------===// -// spv.AccessChain +// spirv.AccessChain //===----------------------------------------------------------------------===// func.func @combine_full_access_chain() -> f32 { - // CHECK: %[[INDEX:.*]] = spv.Constant 0 - // CHECK-NEXT: %[[VAR:.*]] = spv.Variable - // CHECK-NEXT: %[[PTR:.*]] = spv.AccessChain %[[VAR]][%[[INDEX]], %[[INDEX]], %[[INDEX]]] - // CHECK-NEXT: spv.Load "Function" %[[PTR]] - %c0 = spv.Constant 0: i32 - %0 = spv.Variable : !spv.ptr>, !spv.array<4xi32>)>, Function> - %1 = spv.AccessChain %0[%c0] : !spv.ptr>, !spv.array<4xi32>)>, Function>, i32 - %2 = spv.AccessChain %1[%c0, %c0] : !spv.ptr>, Function>, i32, i32 - %3 = spv.Load "Function" %2 : f32 - spv.ReturnValue %3 : f32 + // CHECK: %[[INDEX:.*]] = spirv.Constant 0 + // CHECK-NEXT: %[[VAR:.*]] = spirv.Variable + // CHECK-NEXT: %[[PTR:.*]] = spirv.AccessChain %[[VAR]][%[[INDEX]], %[[INDEX]], %[[INDEX]]] + // CHECK-NEXT: spirv.Load "Function" %[[PTR]] + %c0 = spirv.Constant 0: i32 + %0 = spirv.Variable : !spirv.ptr>, !spirv.array<4xi32>)>, Function> + %1 = spirv.AccessChain %0[%c0] : !spirv.ptr>, !spirv.array<4xi32>)>, Function>, i32 + %2 = spirv.AccessChain %1[%c0, %c0] : !spirv.ptr>, Function>, i32, i32 + %3 = spirv.Load "Function" %2 : f32 + spirv.ReturnValue %3 : f32 } // ----- -func.func @combine_access_chain_multi_use() -> !spv.array<4xf32> { - // CHECK: %[[INDEX:.*]] = spv.Constant 0 - // CHECK-NEXT: %[[VAR:.*]] = spv.Variable - // CHECK-NEXT: %[[PTR_0:.*]] = spv.AccessChain %[[VAR]][%[[INDEX]], %[[INDEX]]] - // CHECK-NEXT: %[[PTR_1:.*]] = spv.AccessChain %[[VAR]][%[[INDEX]], %[[INDEX]], %[[INDEX]]] - // CHECK-NEXT: spv.Load "Function" %[[PTR_0]] - // CHECK-NEXT: spv.Load "Function" %[[PTR_1]] - %c0 = spv.Constant 0: i32 - %0 = spv.Variable : !spv.ptr>, !spv.array<4xi32>)>, Function> - %1 = spv.AccessChain %0[%c0] : !spv.ptr>, !spv.array<4xi32>)>, Function>, i32 - %2 = spv.AccessChain %1[%c0] : !spv.ptr>, Function>, i32 - %3 = spv.AccessChain %2[%c0] : !spv.ptr, Function>, i32 - %4 = spv.Load "Function" %2 : !spv.array<4xf32> - %5 = spv.Load "Function" %3 : f32 - spv.ReturnValue %4: !spv.array<4xf32> +func.func @combine_access_chain_multi_use() -> !spirv.array<4xf32> { + // CHECK: %[[INDEX:.*]] = spirv.Constant 0 + // CHECK-NEXT: %[[VAR:.*]] = spirv.Variable + // CHECK-NEXT: %[[PTR_0:.*]] = spirv.AccessChain %[[VAR]][%[[INDEX]], %[[INDEX]]] + // CHECK-NEXT: %[[PTR_1:.*]] = spirv.AccessChain %[[VAR]][%[[INDEX]], %[[INDEX]], %[[INDEX]]] + // CHECK-NEXT: spirv.Load "Function" %[[PTR_0]] + // CHECK-NEXT: spirv.Load "Function" %[[PTR_1]] + %c0 = spirv.Constant 0: i32 + %0 = spirv.Variable : !spirv.ptr>, !spirv.array<4xi32>)>, Function> + %1 = spirv.AccessChain %0[%c0] : !spirv.ptr>, !spirv.array<4xi32>)>, Function>, i32 + %2 = spirv.AccessChain %1[%c0] : !spirv.ptr>, Function>, i32 + %3 = spirv.AccessChain %2[%c0] : !spirv.ptr, Function>, i32 + %4 = spirv.Load "Function" %2 : !spirv.array<4xf32> + %5 = spirv.Load "Function" %3 : f32 + spirv.ReturnValue %4: !spirv.array<4xf32> } // ----- -func.func @dont_combine_access_chain_without_common_base() -> !spv.array<4xi32> { - // CHECK: %[[INDEX:.*]] = spv.Constant 1 - // CHECK-NEXT: %[[VAR_0:.*]] = spv.Variable - // CHECK-NEXT: %[[VAR_1:.*]] = spv.Variable - // CHECK-NEXT: %[[VAR_0_PTR:.*]] = spv.AccessChain %[[VAR_0]][%[[INDEX]]] - // CHECK-NEXT: %[[VAR_1_PTR:.*]] = spv.AccessChain %[[VAR_1]][%[[INDEX]]] - // CHECK-NEXT: spv.Load "Function" %[[VAR_0_PTR]] - // CHECK-NEXT: spv.Load "Function" %[[VAR_1_PTR]] - %c1 = spv.Constant 1: i32 - %0 = spv.Variable : !spv.ptr>, !spv.array<4xi32>)>, Function> - %1 = spv.Variable : !spv.ptr>, !spv.array<4xi32>)>, Function> - %2 = spv.AccessChain %0[%c1] : !spv.ptr>, !spv.array<4xi32>)>, Function>, i32 - %3 = spv.AccessChain %1[%c1] : !spv.ptr>, !spv.array<4xi32>)>, Function>, i32 - %4 = spv.Load "Function" %2 : !spv.array<4xi32> - %5 = spv.Load "Function" %3 : !spv.array<4xi32> - spv.ReturnValue %4 : !spv.array<4xi32> +func.func @dont_combine_access_chain_without_common_base() -> !spirv.array<4xi32> { + // CHECK: %[[INDEX:.*]] = spirv.Constant 1 + // CHECK-NEXT: %[[VAR_0:.*]] = spirv.Variable + // CHECK-NEXT: %[[VAR_1:.*]] = spirv.Variable + // CHECK-NEXT: %[[VAR_0_PTR:.*]] = spirv.AccessChain %[[VAR_0]][%[[INDEX]]] + // CHECK-NEXT: %[[VAR_1_PTR:.*]] = spirv.AccessChain %[[VAR_1]][%[[INDEX]]] + // CHECK-NEXT: spirv.Load "Function" %[[VAR_0_PTR]] + // CHECK-NEXT: spirv.Load "Function" %[[VAR_1_PTR]] + %c1 = spirv.Constant 1: i32 + %0 = spirv.Variable : !spirv.ptr>, !spirv.array<4xi32>)>, Function> + %1 = spirv.Variable : !spirv.ptr>, !spirv.array<4xi32>)>, Function> + %2 = spirv.AccessChain %0[%c1] : !spirv.ptr>, !spirv.array<4xi32>)>, Function>, i32 + %3 = spirv.AccessChain %1[%c1] : !spirv.ptr>, !spirv.array<4xi32>)>, Function>, i32 + %4 = spirv.Load "Function" %2 : !spirv.array<4xi32> + %5 = spirv.Load "Function" %3 : !spirv.array<4xi32> + spirv.ReturnValue %4 : !spirv.array<4xi32> } // ----- //===----------------------------------------------------------------------===// -// spv.Bitcast +// spirv.Bitcast //===----------------------------------------------------------------------===// func.func @convert_bitcast_full(%arg0 : vector<2xf32>) -> f64 { - // CHECK: %[[RESULT:.*]] = spv.Bitcast {{%.*}} : vector<2xf32> to f64 - // CHECK-NEXT: spv.ReturnValue %[[RESULT]] - %0 = spv.Bitcast %arg0 : vector<2xf32> to vector<2xi32> - %1 = spv.Bitcast %0 : vector<2xi32> to i64 - %2 = spv.Bitcast %1 : i64 to f64 - spv.ReturnValue %2 : f64 + // CHECK: %[[RESULT:.*]] = spirv.Bitcast {{%.*}} : vector<2xf32> to f64 + // CHECK-NEXT: spirv.ReturnValue %[[RESULT]] + %0 = spirv.Bitcast %arg0 : vector<2xf32> to vector<2xi32> + %1 = spirv.Bitcast %0 : vector<2xi32> to i64 + %2 = spirv.Bitcast %1 : i64 to f64 + spirv.ReturnValue %2 : f64 } // ----- -func.func @convert_bitcast_multi_use(%arg0 : vector<2xf32>, %arg1 : !spv.ptr) -> f64 { - // CHECK: %[[RESULT_0:.*]] = spv.Bitcast {{%.*}} : vector<2xf32> to i64 - // CHECK-NEXT: %[[RESULT_1:.*]] = spv.Bitcast {{%.*}} : vector<2xf32> to f64 - // CHECK-NEXT: spv.Store {{".*"}} {{%.*}}, %[[RESULT_0]] - // CHECK-NEXT: spv.ReturnValue %[[RESULT_1]] - %0 = spv.Bitcast %arg0 : vector<2xf32> to i64 - %1 = spv.Bitcast %0 : i64 to f64 - spv.Store "Uniform" %arg1, %0 : i64 - spv.ReturnValue %1 : f64 +func.func @convert_bitcast_multi_use(%arg0 : vector<2xf32>, %arg1 : !spirv.ptr) -> f64 { + // CHECK: %[[RESULT_0:.*]] = spirv.Bitcast {{%.*}} : vector<2xf32> to i64 + // CHECK-NEXT: %[[RESULT_1:.*]] = spirv.Bitcast {{%.*}} : vector<2xf32> to f64 + // CHECK-NEXT: spirv.Store {{".*"}} {{%.*}}, %[[RESULT_0]] + // CHECK-NEXT: spirv.ReturnValue %[[RESULT_1]] + %0 = spirv.Bitcast %arg0 : vector<2xf32> to i64 + %1 = spirv.Bitcast %0 : i64 to f64 + spirv.Store "Uniform" %arg1, %0 : i64 + spirv.ReturnValue %1 : f64 } // ----- //===----------------------------------------------------------------------===// -// spv.CompositeExtract +// spirv.CompositeExtract //===----------------------------------------------------------------------===// // CHECK-LABEL: extract_vector func.func @extract_vector() -> (i32, i32, i32) { - // CHECK-DAG: spv.Constant 6 : i32 - // CHECK-DAG: spv.Constant -33 : i32 - // CHECK-DAG: spv.Constant 42 : i32 - %0 = spv.Constant dense<[42, -33, 6]> : vector<3xi32> - %1 = spv.CompositeExtract %0[0 : i32] : vector<3xi32> - %2 = spv.CompositeExtract %0[1 : i32] : vector<3xi32> - %3 = spv.CompositeExtract %0[2 : i32] : vector<3xi32> + // CHECK-DAG: spirv.Constant 6 : i32 + // CHECK-DAG: spirv.Constant -33 : i32 + // CHECK-DAG: spirv.Constant 42 : i32 + %0 = spirv.Constant dense<[42, -33, 6]> : vector<3xi32> + %1 = spirv.CompositeExtract %0[0 : i32] : vector<3xi32> + %2 = spirv.CompositeExtract %0[1 : i32] : vector<3xi32> + %3 = spirv.CompositeExtract %0[2 : i32] : vector<3xi32> return %1, %2, %3 : i32, i32, i32 } @@ -106,11 +106,11 @@ // CHECK-LABEL: extract_array_final func.func @extract_array_final() -> (i32, i32) { - // CHECK-DAG: spv.Constant -5 : i32 - // CHECK-DAG: spv.Constant 4 : i32 - %0 = spv.Constant [dense<[4, -5]> : vector<2xi32>] : !spv.array<1 x vector<2xi32>> - %1 = spv.CompositeExtract %0[0 : i32, 0 : i32] : !spv.array<1 x vector<2 x i32>> - %2 = spv.CompositeExtract %0[0 : i32, 1 : i32] : !spv.array<1 x vector<2 x i32>> + // CHECK-DAG: spirv.Constant -5 : i32 + // CHECK-DAG: spirv.Constant 4 : i32 + %0 = spirv.Constant [dense<[4, -5]> : vector<2xi32>] : !spirv.array<1 x vector<2xi32>> + %1 = spirv.CompositeExtract %0[0 : i32, 0 : i32] : !spirv.array<1 x vector<2 x i32>> + %2 = spirv.CompositeExtract %0[0 : i32, 1 : i32] : !spirv.array<1 x vector<2 x i32>> return %1, %2 : i32, i32 } @@ -118,9 +118,9 @@ // CHECK-LABEL: extract_array_interm func.func @extract_array_interm() -> (vector<2xi32>) { - // CHECK: spv.Constant dense<[4, -5]> : vector<2xi32> - %0 = spv.Constant [dense<[4, -5]> : vector<2xi32>] : !spv.array<1 x vector<2xi32>> - %1 = spv.CompositeExtract %0[0 : i32] : !spv.array<1 x vector<2 x i32>> + // CHECK: spirv.Constant dense<[4, -5]> : vector<2xi32> + %0 = spirv.Constant [dense<[4, -5]> : vector<2xi32>] : !spirv.array<1 x vector<2xi32>> + %1 = spirv.CompositeExtract %0[0 : i32] : !spirv.array<1 x vector<2 x i32>> return %1 : vector<2xi32> } @@ -128,23 +128,23 @@ // CHECK-LABEL: extract_from_not_constant func.func @extract_from_not_constant() -> i32 { - %0 = spv.Variable : !spv.ptr, Function> - %1 = spv.Load "Function" %0 : vector<3xi32> - // CHECK: spv.CompositeExtract - %2 = spv.CompositeExtract %1[0 : i32] : vector<3xi32> - spv.ReturnValue %2 : i32 + %0 = spirv.Variable : !spirv.ptr, Function> + %1 = spirv.Load "Function" %0 : vector<3xi32> + // CHECK: spirv.CompositeExtract + %2 = spirv.CompositeExtract %1[0 : i32] : vector<3xi32> + spirv.ReturnValue %2 : i32 } // ----- // CHECK-LABEL: extract_insert -// CHECK-SAME: (%[[COMP:.+]]: !spv.array<1 x vector<2xf32>>, %[[VAL:.+]]: f32) -func.func @extract_insert(%composite: !spv.array<1xvector<2xf32>>, %val: f32) -> (f32, f32) { - // CHECK: %[[INSERT:.+]] = spv.CompositeInsert %[[VAL]], %[[COMP]] - %insert = spv.CompositeInsert %val, %composite[0 : i32, 1 : i32] : f32 into !spv.array<1xvector<2xf32>> - %1 = spv.CompositeExtract %insert[0 : i32, 0 : i32] : !spv.array<1xvector<2xf32>> - // CHECK: %[[S:.+]] = spv.CompositeExtract %[[INSERT]][0 : i32, 0 : i32] - %2 = spv.CompositeExtract %insert[0 : i32, 1 : i32] : !spv.array<1xvector<2xf32>> +// CHECK-SAME: (%[[COMP:.+]]: !spirv.array<1 x vector<2xf32>>, %[[VAL:.+]]: f32) +func.func @extract_insert(%composite: !spirv.array<1xvector<2xf32>>, %val: f32) -> (f32, f32) { + // CHECK: %[[INSERT:.+]] = spirv.CompositeInsert %[[VAL]], %[[COMP]] + %insert = spirv.CompositeInsert %val, %composite[0 : i32, 1 : i32] : f32 into !spirv.array<1xvector<2xf32>> + %1 = spirv.CompositeExtract %insert[0 : i32, 0 : i32] : !spirv.array<1xvector<2xf32>> + // CHECK: %[[S:.+]] = spirv.CompositeExtract %[[INSERT]][0 : i32, 0 : i32] + %2 = spirv.CompositeExtract %insert[0 : i32, 1 : i32] : !spirv.array<1xvector<2xf32>> // CHECK: return %[[S]], %[[VAL]] return %1, %2 : f32, f32 } @@ -154,9 +154,9 @@ // CHECK-LABEL: extract_construct // CHECK-SAME: (%[[VAL1:.+]]: vector<2xf32>, %[[VAL2:.+]]: vector<2xf32>) func.func @extract_construct(%val1: vector<2xf32>, %val2: vector<2xf32>) -> (vector<2xf32>, vector<2xf32>) { - %construct = spv.CompositeConstruct %val1, %val2 : (vector<2xf32>, vector<2xf32>) -> !spv.array<2xvector<2xf32>> - %1 = spv.CompositeExtract %construct[0 : i32] : !spv.array<2xvector<2xf32>> - %2 = spv.CompositeExtract %construct[1 : i32] : !spv.array<2xvector<2xf32>> + %construct = spirv.CompositeConstruct %val1, %val2 : (vector<2xf32>, vector<2xf32>) -> !spirv.array<2xvector<2xf32>> + %1 = spirv.CompositeExtract %construct[0 : i32] : !spirv.array<2xvector<2xf32>> + %2 = spirv.CompositeExtract %construct[1 : i32] : !spirv.array<2xvector<2xf32>> // CHECK: return %[[VAL1]], %[[VAL2]] return %1, %2 : vector<2xf32>, vector<2xf32> } @@ -167,27 +167,27 @@ // CHECK-LABEL: extract_construct func.func @extract_construct(%val1: vector<3xf32>, %val2: f32) -> (f32, f32) { - // CHECK: spv.CompositeConstruct - %construct = spv.CompositeConstruct %val1, %val2 : (vector<3xf32>, f32) -> vector<4xf32> - // CHECK: spv.CompositeExtract - %1 = spv.CompositeExtract %construct[0 : i32] : vector<4xf32> - // CHECK: spv.CompositeExtract - %2 = spv.CompositeExtract %construct[1 : i32] : vector<4xf32> + // CHECK: spirv.CompositeConstruct + %construct = spirv.CompositeConstruct %val1, %val2 : (vector<3xf32>, f32) -> vector<4xf32> + // CHECK: spirv.CompositeExtract + %1 = spirv.CompositeExtract %construct[0 : i32] : vector<4xf32> + // CHECK: spirv.CompositeExtract + %2 = spirv.CompositeExtract %construct[1 : i32] : vector<4xf32> return %1, %2 : f32, f32 } // ----- //===----------------------------------------------------------------------===// -// spv.Constant +// spirv.Constant //===----------------------------------------------------------------------===// // TODO: test constants in different blocks func.func @deduplicate_scalar_constant() -> (i32, i32) { - // CHECK: %[[CST:.*]] = spv.Constant 42 : i32 - %0 = spv.Constant 42 : i32 - %1 = spv.Constant 42 : i32 + // CHECK: %[[CST:.*]] = spirv.Constant 42 : i32 + %0 = spirv.Constant 42 : i32 + %1 = spirv.Constant 42 : i32 // CHECK-NEXT: return %[[CST]], %[[CST]] return %0, %1 : i32, i32 } @@ -195,136 +195,136 @@ // ----- func.func @deduplicate_vector_constant() -> (vector<3xi32>, vector<3xi32>) { - // CHECK: %[[CST:.*]] = spv.Constant dense<[1, 2, 3]> : vector<3xi32> - %0 = spv.Constant dense<[1, 2, 3]> : vector<3xi32> - %1 = spv.Constant dense<[1, 2, 3]> : vector<3xi32> + // CHECK: %[[CST:.*]] = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> + %0 = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> + %1 = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> // CHECK-NEXT: return %[[CST]], %[[CST]] return %0, %1 : vector<3xi32>, vector<3xi32> } // ----- -func.func @deduplicate_composite_constant() -> (!spv.array<1 x vector<2xi32>>, !spv.array<1 x vector<2xi32>>) { - // CHECK: %[[CST:.*]] = spv.Constant [dense<5> : vector<2xi32>] : !spv.array<1 x vector<2xi32>> - %0 = spv.Constant [dense<5> : vector<2xi32>] : !spv.array<1 x vector<2xi32>> - %1 = spv.Constant [dense<5> : vector<2xi32>] : !spv.array<1 x vector<2xi32>> +func.func @deduplicate_composite_constant() -> (!spirv.array<1 x vector<2xi32>>, !spirv.array<1 x vector<2xi32>>) { + // CHECK: %[[CST:.*]] = spirv.Constant [dense<5> : vector<2xi32>] : !spirv.array<1 x vector<2xi32>> + %0 = spirv.Constant [dense<5> : vector<2xi32>] : !spirv.array<1 x vector<2xi32>> + %1 = spirv.Constant [dense<5> : vector<2xi32>] : !spirv.array<1 x vector<2xi32>> // CHECK-NEXT: return %[[CST]], %[[CST]] - return %0, %1 : !spv.array<1 x vector<2xi32>>, !spv.array<1 x vector<2xi32>> + return %0, %1 : !spirv.array<1 x vector<2xi32>>, !spirv.array<1 x vector<2xi32>> } // ----- //===----------------------------------------------------------------------===// -// spv.IAdd +// spirv.IAdd //===----------------------------------------------------------------------===// // CHECK-LABEL: @iadd_zero // CHECK-SAME: (%[[ARG:.*]]: i32) func.func @iadd_zero(%arg0: i32) -> (i32, i32) { - %zero = spv.Constant 0 : i32 - %0 = spv.IAdd %arg0, %zero : i32 - %1 = spv.IAdd %zero, %arg0 : i32 + %zero = spirv.Constant 0 : i32 + %0 = spirv.IAdd %arg0, %zero : i32 + %1 = spirv.IAdd %zero, %arg0 : i32 // CHECK: return %[[ARG]], %[[ARG]] return %0, %1: i32, i32 } // CHECK-LABEL: @const_fold_scalar_iadd_normal func.func @const_fold_scalar_iadd_normal() -> (i32, i32, i32) { - %c5 = spv.Constant 5 : i32 - %cn8 = spv.Constant -8 : i32 - - // CHECK-DAG: spv.Constant -3 - // CHECK-DAG: spv.Constant -16 - // CHECK-DAG: spv.Constant 10 - %0 = spv.IAdd %c5, %c5 : i32 - %1 = spv.IAdd %cn8, %cn8 : i32 - %2 = spv.IAdd %c5, %cn8 : i32 + %c5 = spirv.Constant 5 : i32 + %cn8 = spirv.Constant -8 : i32 + + // CHECK-DAG: spirv.Constant -3 + // CHECK-DAG: spirv.Constant -16 + // CHECK-DAG: spirv.Constant 10 + %0 = spirv.IAdd %c5, %c5 : i32 + %1 = spirv.IAdd %cn8, %cn8 : i32 + %2 = spirv.IAdd %c5, %cn8 : i32 return %0, %1, %2: i32, i32, i32 } // CHECK-LABEL: @const_fold_scalar_iadd_flow func.func @const_fold_scalar_iadd_flow() -> (i32, i32, i32, i32) { - %c1 = spv.Constant 1 : i32 - %c2 = spv.Constant 2 : i32 - %c3 = spv.Constant 4294967295 : i32 // 2^32 - 1: 0xffff ffff - %c4 = spv.Constant -2147483648 : i32 // -2^31 : 0x8000 0000 - %c5 = spv.Constant -1 : i32 // : 0xffff ffff - %c6 = spv.Constant -2 : i32 // : 0xffff fffe + %c1 = spirv.Constant 1 : i32 + %c2 = spirv.Constant 2 : i32 + %c3 = spirv.Constant 4294967295 : i32 // 2^32 - 1: 0xffff ffff + %c4 = spirv.Constant -2147483648 : i32 // -2^31 : 0x8000 0000 + %c5 = spirv.Constant -1 : i32 // : 0xffff ffff + %c6 = spirv.Constant -2 : i32 // : 0xffff fffe // 0x8000 0000 + 0xffff fffe = 0x1 7fff fffe -> 0x7fff fffe - // CHECK-DAG: spv.Constant 2147483646 + // CHECK-DAG: spirv.Constant 2147483646 // 0x8000 0000 + 0xffff ffff = 0x1 7fff ffff -> 0x7fff ffff - // CHECK-DAG: spv.Constant 2147483647 + // CHECK-DAG: spirv.Constant 2147483647 // 0x0000 0002 + 0xffff ffff = 0x1 0000 0001 -> 0x0000 0001 - // CHECK-DAG: spv.Constant 1 + // CHECK-DAG: spirv.Constant 1 // 0x0000 0001 + 0xffff ffff = 0x1 0000 0000 -> 0x0000 0000 - // CHECK-DAG: spv.Constant 0 - %0 = spv.IAdd %c1, %c3 : i32 - %1 = spv.IAdd %c2, %c3 : i32 - %2 = spv.IAdd %c4, %c5 : i32 - %3 = spv.IAdd %c4, %c6 : i32 + // CHECK-DAG: spirv.Constant 0 + %0 = spirv.IAdd %c1, %c3 : i32 + %1 = spirv.IAdd %c2, %c3 : i32 + %2 = spirv.IAdd %c4, %c5 : i32 + %3 = spirv.IAdd %c4, %c6 : i32 return %0, %1, %2, %3: i32, i32, i32, i32 } // CHECK-LABEL: @const_fold_vector_iadd func.func @const_fold_vector_iadd() -> vector<3xi32> { - %vc1 = spv.Constant dense<[42, -55, 127]> : vector<3xi32> - %vc2 = spv.Constant dense<[-3, -15, 28]> : vector<3xi32> + %vc1 = spirv.Constant dense<[42, -55, 127]> : vector<3xi32> + %vc2 = spirv.Constant dense<[-3, -15, 28]> : vector<3xi32> - // CHECK: spv.Constant dense<[39, -70, 155]> - %0 = spv.IAdd %vc1, %vc2 : vector<3xi32> + // CHECK: spirv.Constant dense<[39, -70, 155]> + %0 = spirv.IAdd %vc1, %vc2 : vector<3xi32> return %0: vector<3xi32> } // ----- //===----------------------------------------------------------------------===// -// spv.IMul +// spirv.IMul //===----------------------------------------------------------------------===// // CHECK-LABEL: @imul_zero_one // CHECK-SAME: (%[[ARG:.*]]: i32) func.func @imul_zero_one(%arg0: i32) -> (i32, i32) { - // CHECK: %[[ZERO:.*]] = spv.Constant 0 - %zero = spv.Constant 0 : i32 - %one = spv.Constant 1: i32 - %0 = spv.IMul %arg0, %zero : i32 - %1 = spv.IMul %one, %arg0 : i32 + // CHECK: %[[ZERO:.*]] = spirv.Constant 0 + %zero = spirv.Constant 0 : i32 + %one = spirv.Constant 1: i32 + %0 = spirv.IMul %arg0, %zero : i32 + %1 = spirv.IMul %one, %arg0 : i32 // CHECK: return %[[ZERO]], %[[ARG]] return %0, %1: i32, i32 } // CHECK-LABEL: @const_fold_scalar_imul_normal func.func @const_fold_scalar_imul_normal() -> (i32, i32, i32) { - %c5 = spv.Constant 5 : i32 - %cn8 = spv.Constant -8 : i32 - %c7 = spv.Constant 7 : i32 - - // CHECK-DAG: spv.Constant -56 - // CHECK-DAG: spv.Constant -40 - // CHECK-DAG: spv.Constant 35 - %0 = spv.IMul %c7, %c5 : i32 - %1 = spv.IMul %c5, %cn8 : i32 - %2 = spv.IMul %cn8, %c7 : i32 + %c5 = spirv.Constant 5 : i32 + %cn8 = spirv.Constant -8 : i32 + %c7 = spirv.Constant 7 : i32 + + // CHECK-DAG: spirv.Constant -56 + // CHECK-DAG: spirv.Constant -40 + // CHECK-DAG: spirv.Constant 35 + %0 = spirv.IMul %c7, %c5 : i32 + %1 = spirv.IMul %c5, %cn8 : i32 + %2 = spirv.IMul %cn8, %c7 : i32 return %0, %1, %2: i32, i32, i32 } // CHECK-LABEL: @const_fold_scalar_imul_flow func.func @const_fold_scalar_imul_flow() -> (i32, i32, i32) { - %c1 = spv.Constant 2 : i32 - %c2 = spv.Constant 4 : i32 - %c3 = spv.Constant 4294967295 : i32 // 2^32 - 1 : 0xffff ffff - %c4 = spv.Constant 2147483647 : i32 // 2^31 - 1 : 0x7fff ffff + %c1 = spirv.Constant 2 : i32 + %c2 = spirv.Constant 4 : i32 + %c3 = spirv.Constant 4294967295 : i32 // 2^32 - 1 : 0xffff ffff + %c4 = spirv.Constant 2147483647 : i32 // 2^31 - 1 : 0x7fff ffff // (0x7fff ffff << 2) = 0x1 ffff fffc -> 0xffff fffc - // CHECK-DAG: %[[CST4:.*]] = spv.Constant -4 + // CHECK-DAG: %[[CST4:.*]] = spirv.Constant -4 // (0xffff ffff << 1) = 0x1 ffff fffe -> 0xffff fffe - // CHECK-DAG: %[[CST2:.*]] = spv.Constant -2 - %0 = spv.IMul %c1, %c3 : i32 + // CHECK-DAG: %[[CST2:.*]] = spirv.Constant -2 + %0 = spirv.IMul %c1, %c3 : i32 // (0x7fff ffff << 1) = 0x0 ffff fffe -> 0xffff fffe - %1 = spv.IMul %c1, %c4 : i32 - %2 = spv.IMul %c4, %c2 : i32 + %1 = spirv.IMul %c1, %c4 : i32 + %2 = spirv.IMul %c4, %c2 : i32 // CHECK: return %[[CST2]], %[[CST2]], %[[CST4]] return %0, %1, %2: i32, i32, i32 } @@ -332,90 +332,90 @@ // CHECK-LABEL: @const_fold_vector_imul func.func @const_fold_vector_imul() -> vector<3xi32> { - %vc1 = spv.Constant dense<[42, -55, 127]> : vector<3xi32> - %vc2 = spv.Constant dense<[-3, -15, 28]> : vector<3xi32> + %vc1 = spirv.Constant dense<[42, -55, 127]> : vector<3xi32> + %vc2 = spirv.Constant dense<[-3, -15, 28]> : vector<3xi32> - // CHECK: spv.Constant dense<[-126, 825, 3556]> - %0 = spv.IMul %vc1, %vc2 : vector<3xi32> + // CHECK: spirv.Constant dense<[-126, 825, 3556]> + %0 = spirv.IMul %vc1, %vc2 : vector<3xi32> return %0: vector<3xi32> } // ----- //===----------------------------------------------------------------------===// -// spv.ISub +// spirv.ISub //===----------------------------------------------------------------------===// // CHECK-LABEL: @isub_x_x func.func @isub_x_x(%arg0: i32) -> i32 { - // CHECK: spv.Constant 0 - %0 = spv.ISub %arg0, %arg0: i32 + // CHECK: spirv.Constant 0 + %0 = spirv.ISub %arg0, %arg0: i32 return %0: i32 } // CHECK-LABEL: @const_fold_scalar_isub_normal func.func @const_fold_scalar_isub_normal() -> (i32, i32, i32) { - %c5 = spv.Constant 5 : i32 - %cn8 = spv.Constant -8 : i32 - %c7 = spv.Constant 7 : i32 - - // CHECK-DAG: spv.Constant -15 - // CHECK-DAG: spv.Constant 13 - // CHECK-DAG: spv.Constant 2 - %0 = spv.ISub %c7, %c5 : i32 - %1 = spv.ISub %c5, %cn8 : i32 - %2 = spv.ISub %cn8, %c7 : i32 + %c5 = spirv.Constant 5 : i32 + %cn8 = spirv.Constant -8 : i32 + %c7 = spirv.Constant 7 : i32 + + // CHECK-DAG: spirv.Constant -15 + // CHECK-DAG: spirv.Constant 13 + // CHECK-DAG: spirv.Constant 2 + %0 = spirv.ISub %c7, %c5 : i32 + %1 = spirv.ISub %c5, %cn8 : i32 + %2 = spirv.ISub %cn8, %c7 : i32 return %0, %1, %2: i32, i32, i32 } // CHECK-LABEL: @const_fold_scalar_isub_flow func.func @const_fold_scalar_isub_flow() -> (i32, i32, i32, i32) { - %c1 = spv.Constant 0 : i32 - %c2 = spv.Constant 1 : i32 - %c3 = spv.Constant 4294967295 : i32 // 2^32 - 1 : 0xffff ffff - %c4 = spv.Constant 2147483647 : i32 // 2^31 : 0x7fff ffff - %c5 = spv.Constant -1 : i32 // : 0xffff ffff - %c6 = spv.Constant -2 : i32 // : 0xffff fffe + %c1 = spirv.Constant 0 : i32 + %c2 = spirv.Constant 1 : i32 + %c3 = spirv.Constant 4294967295 : i32 // 2^32 - 1 : 0xffff ffff + %c4 = spirv.Constant 2147483647 : i32 // 2^31 : 0x7fff ffff + %c5 = spirv.Constant -1 : i32 // : 0xffff ffff + %c6 = spirv.Constant -2 : i32 // : 0xffff fffe // 0xffff ffff - 0x7fff ffff -> 0xffff ffff + 0x8000 0001 = 0x1 8000 0000 - // CHECK-DAG: spv.Constant -2147483648 + // CHECK-DAG: spirv.Constant -2147483648 // 0x0000 0001 - 0xffff ffff -> 0x0000 0001 + 0x0000 0001 = 0x0000 0002 - // CHECK-DAG: spv.Constant 2 : + // CHECK-DAG: spirv.Constant 2 : // 0x0000 0000 - 0xffff ffff -> 0x0000 0000 + 0x0000 0001 = 0x0000 0001 - // CHECK-DAG: spv.Constant 1 : + // CHECK-DAG: spirv.Constant 1 : // 0xffff fffe - 0x7fff ffff -> 0xffff fffe + 0x8000 0001 = 0x1 7fff ffff - // CHECK-DAG: spv.Constant 2147483647 - %0 = spv.ISub %c1, %c3 : i32 - %1 = spv.ISub %c2, %c3 : i32 - %2 = spv.ISub %c5, %c4 : i32 - %3 = spv.ISub %c6, %c4 : i32 + // CHECK-DAG: spirv.Constant 2147483647 + %0 = spirv.ISub %c1, %c3 : i32 + %1 = spirv.ISub %c2, %c3 : i32 + %2 = spirv.ISub %c5, %c4 : i32 + %3 = spirv.ISub %c6, %c4 : i32 return %0, %1, %2, %3: i32, i32, i32, i32 } // CHECK-LABEL: @const_fold_vector_isub func.func @const_fold_vector_isub() -> vector<3xi32> { - %vc1 = spv.Constant dense<[42, -55, 127]> : vector<3xi32> - %vc2 = spv.Constant dense<[-3, -15, 28]> : vector<3xi32> + %vc1 = spirv.Constant dense<[42, -55, 127]> : vector<3xi32> + %vc2 = spirv.Constant dense<[-3, -15, 28]> : vector<3xi32> - // CHECK: spv.Constant dense<[45, -40, 99]> - %0 = spv.ISub %vc1, %vc2 : vector<3xi32> + // CHECK: spirv.Constant dense<[45, -40, 99]> + %0 = spirv.ISub %vc1, %vc2 : vector<3xi32> return %0: vector<3xi32> } // ----- //===----------------------------------------------------------------------===// -// spv.LogicalAnd +// spirv.LogicalAnd //===----------------------------------------------------------------------===// // CHECK-LABEL: @convert_logical_and_true_false_scalar // CHECK-SAME: %[[ARG:.+]]: i1 func.func @convert_logical_and_true_false_scalar(%arg: i1) -> (i1, i1) { - %true = spv.Constant true - // CHECK: %[[FALSE:.+]] = spv.Constant false - %false = spv.Constant false - %0 = spv.LogicalAnd %true, %arg: i1 - %1 = spv.LogicalAnd %arg, %false: i1 + %true = spirv.Constant true + // CHECK: %[[FALSE:.+]] = spirv.Constant false + %false = spirv.Constant false + %0 = spirv.LogicalAnd %true, %arg: i1 + %1 = spirv.LogicalAnd %arg, %false: i1 // CHECK: return %[[ARG]], %[[FALSE]] return %0, %1: i1, i1 } @@ -423,11 +423,11 @@ // CHECK-LABEL: @convert_logical_and_true_false_vector // CHECK-SAME: %[[ARG:.+]]: vector<3xi1> func.func @convert_logical_and_true_false_vector(%arg: vector<3xi1>) -> (vector<3xi1>, vector<3xi1>) { - %true = spv.Constant dense : vector<3xi1> - // CHECK: %[[FALSE:.+]] = spv.Constant dense - %false = spv.Constant dense : vector<3xi1> - %0 = spv.LogicalAnd %true, %arg: vector<3xi1> - %1 = spv.LogicalAnd %arg, %false: vector<3xi1> + %true = spirv.Constant dense : vector<3xi1> + // CHECK: %[[FALSE:.+]] = spirv.Constant dense + %false = spirv.Constant dense : vector<3xi1> + %0 = spirv.LogicalAnd %true, %arg: vector<3xi1> + %1 = spirv.LogicalAnd %arg, %false: vector<3xi1> // CHECK: return %[[ARG]], %[[FALSE]] return %0, %1: vector<3xi1>, vector<3xi1> } @@ -435,74 +435,74 @@ // ----- //===----------------------------------------------------------------------===// -// spv.LogicalNot +// spirv.LogicalNot //===----------------------------------------------------------------------===// func.func @convert_logical_not_to_not_equal(%arg0: vector<3xi64>, %arg1: vector<3xi64>) -> vector<3xi1> { - // CHECK: %[[RESULT:.*]] = spv.INotEqual {{%.*}}, {{%.*}} : vector<3xi64> - // CHECK-NEXT: spv.ReturnValue %[[RESULT]] : vector<3xi1> - %2 = spv.IEqual %arg0, %arg1 : vector<3xi64> - %3 = spv.LogicalNot %2 : vector<3xi1> - spv.ReturnValue %3 : vector<3xi1> + // CHECK: %[[RESULT:.*]] = spirv.INotEqual {{%.*}}, {{%.*}} : vector<3xi64> + // CHECK-NEXT: spirv.ReturnValue %[[RESULT]] : vector<3xi1> + %2 = spirv.IEqual %arg0, %arg1 : vector<3xi64> + %3 = spirv.LogicalNot %2 : vector<3xi1> + spirv.ReturnValue %3 : vector<3xi1> } // ----- func.func @convert_logical_not_to_equal(%arg0: vector<3xi64>, %arg1: vector<3xi64>) -> vector<3xi1> { - // CHECK: %[[RESULT:.*]] = spv.IEqual {{%.*}}, {{%.*}} : vector<3xi64> - // CHECK-NEXT: spv.ReturnValue %[[RESULT]] : vector<3xi1> - %2 = spv.INotEqual %arg0, %arg1 : vector<3xi64> - %3 = spv.LogicalNot %2 : vector<3xi1> - spv.ReturnValue %3 : vector<3xi1> + // CHECK: %[[RESULT:.*]] = spirv.IEqual {{%.*}}, {{%.*}} : vector<3xi64> + // CHECK-NEXT: spirv.ReturnValue %[[RESULT]] : vector<3xi1> + %2 = spirv.INotEqual %arg0, %arg1 : vector<3xi64> + %3 = spirv.LogicalNot %2 : vector<3xi1> + spirv.ReturnValue %3 : vector<3xi1> } // ----- -func.func @convert_logical_not_parent_multi_use(%arg0: vector<3xi64>, %arg1: vector<3xi64>, %arg2: !spv.ptr, Uniform>) -> vector<3xi1> { - // CHECK: %[[RESULT_0:.*]] = spv.INotEqual {{%.*}}, {{%.*}} : vector<3xi64> - // CHECK-NEXT: %[[RESULT_1:.*]] = spv.IEqual {{%.*}}, {{%.*}} : vector<3xi64> - // CHECK-NEXT: spv.Store "Uniform" {{%.*}}, %[[RESULT_0]] - // CHECK-NEXT: spv.ReturnValue %[[RESULT_1]] - %0 = spv.INotEqual %arg0, %arg1 : vector<3xi64> - %1 = spv.LogicalNot %0 : vector<3xi1> - spv.Store "Uniform" %arg2, %0 : vector<3xi1> - spv.ReturnValue %1 : vector<3xi1> +func.func @convert_logical_not_parent_multi_use(%arg0: vector<3xi64>, %arg1: vector<3xi64>, %arg2: !spirv.ptr, Uniform>) -> vector<3xi1> { + // CHECK: %[[RESULT_0:.*]] = spirv.INotEqual {{%.*}}, {{%.*}} : vector<3xi64> + // CHECK-NEXT: %[[RESULT_1:.*]] = spirv.IEqual {{%.*}}, {{%.*}} : vector<3xi64> + // CHECK-NEXT: spirv.Store "Uniform" {{%.*}}, %[[RESULT_0]] + // CHECK-NEXT: spirv.ReturnValue %[[RESULT_1]] + %0 = spirv.INotEqual %arg0, %arg1 : vector<3xi64> + %1 = spirv.LogicalNot %0 : vector<3xi1> + spirv.Store "Uniform" %arg2, %0 : vector<3xi1> + spirv.ReturnValue %1 : vector<3xi1> } // ----- func.func @convert_logical_not_to_logical_not_equal(%arg0: vector<3xi1>, %arg1: vector<3xi1>) -> vector<3xi1> { - // CHECK: %[[RESULT:.*]] = spv.LogicalNotEqual {{%.*}}, {{%.*}} : vector<3xi1> - // CHECK-NEXT: spv.ReturnValue %[[RESULT]] : vector<3xi1> - %2 = spv.LogicalEqual %arg0, %arg1 : vector<3xi1> - %3 = spv.LogicalNot %2 : vector<3xi1> - spv.ReturnValue %3 : vector<3xi1> + // CHECK: %[[RESULT:.*]] = spirv.LogicalNotEqual {{%.*}}, {{%.*}} : vector<3xi1> + // CHECK-NEXT: spirv.ReturnValue %[[RESULT]] : vector<3xi1> + %2 = spirv.LogicalEqual %arg0, %arg1 : vector<3xi1> + %3 = spirv.LogicalNot %2 : vector<3xi1> + spirv.ReturnValue %3 : vector<3xi1> } // ----- func.func @convert_logical_not_to_logical_equal(%arg0: vector<3xi1>, %arg1: vector<3xi1>) -> vector<3xi1> { - // CHECK: %[[RESULT:.*]] = spv.LogicalEqual {{%.*}}, {{%.*}} : vector<3xi1> - // CHECK-NEXT: spv.ReturnValue %[[RESULT]] : vector<3xi1> - %2 = spv.LogicalNotEqual %arg0, %arg1 : vector<3xi1> - %3 = spv.LogicalNot %2 : vector<3xi1> - spv.ReturnValue %3 : vector<3xi1> + // CHECK: %[[RESULT:.*]] = spirv.LogicalEqual {{%.*}}, {{%.*}} : vector<3xi1> + // CHECK-NEXT: spirv.ReturnValue %[[RESULT]] : vector<3xi1> + %2 = spirv.LogicalNotEqual %arg0, %arg1 : vector<3xi1> + %3 = spirv.LogicalNot %2 : vector<3xi1> + spirv.ReturnValue %3 : vector<3xi1> } // ----- //===----------------------------------------------------------------------===// -// spv.LogicalOr +// spirv.LogicalOr //===----------------------------------------------------------------------===// // CHECK-LABEL: @convert_logical_or_true_false_scalar // CHECK-SAME: %[[ARG:.+]]: i1 func.func @convert_logical_or_true_false_scalar(%arg: i1) -> (i1, i1) { - // CHECK: %[[TRUE:.+]] = spv.Constant true - %true = spv.Constant true - %false = spv.Constant false - %0 = spv.LogicalOr %true, %arg: i1 - %1 = spv.LogicalOr %arg, %false: i1 + // CHECK: %[[TRUE:.+]] = spirv.Constant true + %true = spirv.Constant true + %false = spirv.Constant false + %0 = spirv.LogicalOr %true, %arg: i1 + %1 = spirv.LogicalOr %arg, %false: i1 // CHECK: return %[[TRUE]], %[[ARG]] return %0, %1: i1, i1 } @@ -510,11 +510,11 @@ // CHECK-LABEL: @convert_logical_or_true_false_vector // CHECK-SAME: %[[ARG:.+]]: vector<3xi1> func.func @convert_logical_or_true_false_vector(%arg: vector<3xi1>) -> (vector<3xi1>, vector<3xi1>) { - // CHECK: %[[TRUE:.+]] = spv.Constant dense - %true = spv.Constant dense : vector<3xi1> - %false = spv.Constant dense : vector<3xi1> - %0 = spv.LogicalOr %true, %arg: vector<3xi1> - %1 = spv.LogicalOr %arg, %false: vector<3xi1> + // CHECK: %[[TRUE:.+]] = spirv.Constant dense + %true = spirv.Constant dense : vector<3xi1> + %false = spirv.Constant dense : vector<3xi1> + %0 = spirv.LogicalOr %true, %arg: vector<3xi1> + %1 = spirv.LogicalOr %arg, %false: vector<3xi1> // CHECK: return %[[TRUE]], %[[ARG]] return %0, %1: vector<3xi1>, vector<3xi1> } @@ -522,67 +522,67 @@ // ----- //===----------------------------------------------------------------------===// -// spv.mlir.selection +// spirv.mlir.selection //===----------------------------------------------------------------------===// func.func @canonicalize_selection_op_scalar_type(%cond: i1) -> () { - %0 = spv.Constant 0: i32 - // CHECK-DAG: %[[TRUE_VALUE:.*]] = spv.Constant 1 : i32 - %1 = spv.Constant 1: i32 - // CHECK-DAG: %[[FALSE_VALUE:.*]] = spv.Constant 2 : i32 - %2 = spv.Constant 2: i32 - // CHECK: %[[DST_VAR:.*]] = spv.Variable init({{%.*}}) : !spv.ptr - %3 = spv.Variable init(%0) : !spv.ptr - - // CHECK: %[[SRC_VALUE:.*]] = spv.Select {{%.*}}, %[[TRUE_VALUE]], %[[FALSE_VALUE]] : i1, i32 - // CHECK-NEXT: spv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE]] ["Aligned", 4] : i32 - // CHECK-NEXT: spv.Return - spv.mlir.selection { - spv.BranchConditional %cond, ^then, ^else + %0 = spirv.Constant 0: i32 + // CHECK-DAG: %[[TRUE_VALUE:.*]] = spirv.Constant 1 : i32 + %1 = spirv.Constant 1: i32 + // CHECK-DAG: %[[FALSE_VALUE:.*]] = spirv.Constant 2 : i32 + %2 = spirv.Constant 2: i32 + // CHECK: %[[DST_VAR:.*]] = spirv.Variable init({{%.*}}) : !spirv.ptr + %3 = spirv.Variable init(%0) : !spirv.ptr + + // CHECK: %[[SRC_VALUE:.*]] = spirv.Select {{%.*}}, %[[TRUE_VALUE]], %[[FALSE_VALUE]] : i1, i32 + // CHECK-NEXT: spirv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE]] ["Aligned", 4] : i32 + // CHECK-NEXT: spirv.Return + spirv.mlir.selection { + spirv.BranchConditional %cond, ^then, ^else ^else: - spv.Store "Function" %3, %2 ["Aligned", 4]: i32 - spv.Branch ^merge + spirv.Store "Function" %3, %2 ["Aligned", 4]: i32 + spirv.Branch ^merge ^then: - spv.Store "Function" %3, %1 ["Aligned", 4]: i32 - spv.Branch ^merge + spirv.Store "Function" %3, %1 ["Aligned", 4]: i32 + spirv.Branch ^merge ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // ----- func.func @canonicalize_selection_op_vector_type(%cond: i1) -> () { - %0 = spv.Constant dense<[0, 1, 2]> : vector<3xi32> - // CHECK-DAG: %[[TRUE_VALUE:.*]] = spv.Constant dense<[1, 2, 3]> : vector<3xi32> - %1 = spv.Constant dense<[1, 2, 3]> : vector<3xi32> - // CHECK-DAG: %[[FALSE_VALUE:.*]] = spv.Constant dense<[2, 3, 4]> : vector<3xi32> - %2 = spv.Constant dense<[2, 3, 4]> : vector<3xi32> - // CHECK: %[[DST_VAR:.*]] = spv.Variable init({{%.*}}) : !spv.ptr, Function> - %3 = spv.Variable init(%0) : !spv.ptr, Function> - - // CHECK: %[[SRC_VALUE:.*]] = spv.Select {{%.*}}, %[[TRUE_VALUE]], %[[FALSE_VALUE]] : i1, vector<3xi32> - // CHECK-NEXT: spv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE]] ["Aligned", 8] : vector<3xi32> - // CHECK-NEXT: spv.Return - spv.mlir.selection { - spv.BranchConditional %cond, ^then, ^else + %0 = spirv.Constant dense<[0, 1, 2]> : vector<3xi32> + // CHECK-DAG: %[[TRUE_VALUE:.*]] = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> + %1 = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> + // CHECK-DAG: %[[FALSE_VALUE:.*]] = spirv.Constant dense<[2, 3, 4]> : vector<3xi32> + %2 = spirv.Constant dense<[2, 3, 4]> : vector<3xi32> + // CHECK: %[[DST_VAR:.*]] = spirv.Variable init({{%.*}}) : !spirv.ptr, Function> + %3 = spirv.Variable init(%0) : !spirv.ptr, Function> + + // CHECK: %[[SRC_VALUE:.*]] = spirv.Select {{%.*}}, %[[TRUE_VALUE]], %[[FALSE_VALUE]] : i1, vector<3xi32> + // CHECK-NEXT: spirv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE]] ["Aligned", 8] : vector<3xi32> + // CHECK-NEXT: spirv.Return + spirv.mlir.selection { + spirv.BranchConditional %cond, ^then, ^else ^then: - spv.Store "Function" %3, %1 ["Aligned", 8]: vector<3xi32> - spv.Branch ^merge + spirv.Store "Function" %3, %1 ["Aligned", 8]: vector<3xi32> + spirv.Branch ^merge ^else: - spv.Store "Function" %3, %2 ["Aligned", 8] : vector<3xi32> - spv.Branch ^merge + spirv.Store "Function" %3, %2 ["Aligned", 8] : vector<3xi32> + spirv.Branch ^merge ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // ----- @@ -591,37 +591,37 @@ // Store to a different variables. func.func @cannot_canonicalize_selection_op_0(%cond: i1) -> () { - %0 = spv.Constant dense<[0, 1, 2]> : vector<3xi32> - // CHECK-DAG: %[[SRC_VALUE_1:.*]] = spv.Constant dense<[2, 3, 4]> : vector<3xi32> - // CHECK-DAG: %[[SRC_VALUE_0:.*]] = spv.Constant dense<[1, 2, 3]> : vector<3xi32> - %1 = spv.Constant dense<[1, 2, 3]> : vector<3xi32> - %2 = spv.Constant dense<[2, 3, 4]> : vector<3xi32> - // CHECK: %[[DST_VAR_0:.*]] = spv.Variable init({{%.*}}) : !spv.ptr, Function> - %3 = spv.Variable init(%0) : !spv.ptr, Function> - // CHECK: %[[DST_VAR_1:.*]] = spv.Variable init({{%.*}}) : !spv.ptr, Function> - %4 = spv.Variable init(%0) : !spv.ptr, Function> - - // CHECK: spv.mlir.selection { - spv.mlir.selection { - // CHECK: spv.BranchConditional + %0 = spirv.Constant dense<[0, 1, 2]> : vector<3xi32> + // CHECK-DAG: %[[SRC_VALUE_1:.*]] = spirv.Constant dense<[2, 3, 4]> : vector<3xi32> + // CHECK-DAG: %[[SRC_VALUE_0:.*]] = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> + %1 = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> + %2 = spirv.Constant dense<[2, 3, 4]> : vector<3xi32> + // CHECK: %[[DST_VAR_0:.*]] = spirv.Variable init({{%.*}}) : !spirv.ptr, Function> + %3 = spirv.Variable init(%0) : !spirv.ptr, Function> + // CHECK: %[[DST_VAR_1:.*]] = spirv.Variable init({{%.*}}) : !spirv.ptr, Function> + %4 = spirv.Variable init(%0) : !spirv.ptr, Function> + + // CHECK: spirv.mlir.selection { + spirv.mlir.selection { + // CHECK: spirv.BranchConditional // CHECK-SAME: ^bb1(%[[DST_VAR_0]], %[[SRC_VALUE_0]] // CHECK-SAME: ^bb1(%[[DST_VAR_1]], %[[SRC_VALUE_1]] - spv.BranchConditional %cond, ^then, ^else + spirv.BranchConditional %cond, ^then, ^else ^then: - // CHECK: ^bb1(%[[ARG0:.*]]: !spv.ptr, Function>, %[[ARG1:.*]]: vector<3xi32>): - // CHECK: spv.Store "Function" %[[ARG0]], %[[ARG1]] ["Aligned", 8] : vector<3xi32> - spv.Store "Function" %3, %1 ["Aligned", 8]: vector<3xi32> - spv.Branch ^merge + // CHECK: ^bb1(%[[ARG0:.*]]: !spirv.ptr, Function>, %[[ARG1:.*]]: vector<3xi32>): + // CHECK: spirv.Store "Function" %[[ARG0]], %[[ARG1]] ["Aligned", 8] : vector<3xi32> + spirv.Store "Function" %3, %1 ["Aligned", 8]: vector<3xi32> + spirv.Branch ^merge ^else: - spv.Store "Function" %4, %2 ["Aligned", 8] : vector<3xi32> - spv.Branch ^merge + spirv.Store "Function" %4, %2 ["Aligned", 8] : vector<3xi32> + spirv.Branch ^merge ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // ----- @@ -630,36 +630,36 @@ // A conditional block consists of more than 2 operations. func.func @cannot_canonicalize_selection_op_1(%cond: i1) -> () { - %0 = spv.Constant dense<[0, 1, 2]> : vector<3xi32> - // CHECK-DAG: %[[SRC_VALUE_0:.*]] = spv.Constant dense<[1, 2, 3]> : vector<3xi32> - %1 = spv.Constant dense<[1, 2, 3]> : vector<3xi32> - // CHECK-DAG: %[[SRC_VALUE_1:.*]] = spv.Constant dense<[2, 3, 4]> : vector<3xi32> - %2 = spv.Constant dense<[2, 3, 4]> : vector<3xi32> - // CHECK: %[[DST_VAR_0:.*]] = spv.Variable init({{%.*}}) : !spv.ptr, Function> - %3 = spv.Variable init(%0) : !spv.ptr, Function> - // CHECK: %[[DST_VAR_1:.*]] = spv.Variable init({{%.*}}) : !spv.ptr, Function> - %4 = spv.Variable init(%0) : !spv.ptr, Function> - - // CHECK: spv.mlir.selection { - spv.mlir.selection { - spv.BranchConditional %cond, ^then, ^else + %0 = spirv.Constant dense<[0, 1, 2]> : vector<3xi32> + // CHECK-DAG: %[[SRC_VALUE_0:.*]] = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> + %1 = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> + // CHECK-DAG: %[[SRC_VALUE_1:.*]] = spirv.Constant dense<[2, 3, 4]> : vector<3xi32> + %2 = spirv.Constant dense<[2, 3, 4]> : vector<3xi32> + // CHECK: %[[DST_VAR_0:.*]] = spirv.Variable init({{%.*}}) : !spirv.ptr, Function> + %3 = spirv.Variable init(%0) : !spirv.ptr, Function> + // CHECK: %[[DST_VAR_1:.*]] = spirv.Variable init({{%.*}}) : !spirv.ptr, Function> + %4 = spirv.Variable init(%0) : !spirv.ptr, Function> + + // CHECK: spirv.mlir.selection { + spirv.mlir.selection { + spirv.BranchConditional %cond, ^then, ^else ^then: - // CHECK: spv.Store "Function" %[[DST_VAR_0]], %[[SRC_VALUE_0]] ["Aligned", 8] : vector<3xi32> - spv.Store "Function" %3, %1 ["Aligned", 8] : vector<3xi32> - // CHECK: spv.Store "Function" %[[DST_VAR_1]], %[[SRC_VALUE_0]] ["Aligned", 8] : vector<3xi32> - spv.Store "Function" %4, %1 ["Aligned", 8]: vector<3xi32> - spv.Branch ^merge + // CHECK: spirv.Store "Function" %[[DST_VAR_0]], %[[SRC_VALUE_0]] ["Aligned", 8] : vector<3xi32> + spirv.Store "Function" %3, %1 ["Aligned", 8] : vector<3xi32> + // CHECK: spirv.Store "Function" %[[DST_VAR_1]], %[[SRC_VALUE_0]] ["Aligned", 8] : vector<3xi32> + spirv.Store "Function" %4, %1 ["Aligned", 8]: vector<3xi32> + spirv.Branch ^merge ^else: - // CHECK: spv.Store "Function" %[[DST_VAR_1]], %[[SRC_VALUE_1]] ["Aligned", 8] : vector<3xi32> - spv.Store "Function" %4, %2 ["Aligned", 8] : vector<3xi32> - spv.Branch ^merge + // CHECK: spirv.Store "Function" %[[DST_VAR_1]], %[[SRC_VALUE_1]] ["Aligned", 8] : vector<3xi32> + spirv.Store "Function" %4, %2 ["Aligned", 8] : vector<3xi32> + spirv.Branch ^merge ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // ----- @@ -668,66 +668,66 @@ // A control-flow goes into `^then` block from `^else` block. func.func @cannot_canonicalize_selection_op_2(%cond: i1) -> () { - %0 = spv.Constant dense<[0, 1, 2]> : vector<3xi32> - // CHECK-DAG: %[[SRC_VALUE_0:.*]] = spv.Constant dense<[1, 2, 3]> : vector<3xi32> - %1 = spv.Constant dense<[1, 2, 3]> : vector<3xi32> - // CHECK-DAG: %[[SRC_VALUE_1:.*]] = spv.Constant dense<[2, 3, 4]> : vector<3xi32> - %2 = spv.Constant dense<[2, 3, 4]> : vector<3xi32> - // CHECK: %[[DST_VAR:.*]] = spv.Variable init({{%.*}}) : !spv.ptr, Function> - %3 = spv.Variable init(%0) : !spv.ptr, Function> - - // CHECK: spv.mlir.selection { - spv.mlir.selection { - spv.BranchConditional %cond, ^then, ^else + %0 = spirv.Constant dense<[0, 1, 2]> : vector<3xi32> + // CHECK-DAG: %[[SRC_VALUE_0:.*]] = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> + %1 = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> + // CHECK-DAG: %[[SRC_VALUE_1:.*]] = spirv.Constant dense<[2, 3, 4]> : vector<3xi32> + %2 = spirv.Constant dense<[2, 3, 4]> : vector<3xi32> + // CHECK: %[[DST_VAR:.*]] = spirv.Variable init({{%.*}}) : !spirv.ptr, Function> + %3 = spirv.Variable init(%0) : !spirv.ptr, Function> + + // CHECK: spirv.mlir.selection { + spirv.mlir.selection { + spirv.BranchConditional %cond, ^then, ^else ^then: - // CHECK: spv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE_0]] ["Aligned", 8] : vector<3xi32> - spv.Store "Function" %3, %1 ["Aligned", 8]: vector<3xi32> - spv.Branch ^merge + // CHECK: spirv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE_0]] ["Aligned", 8] : vector<3xi32> + spirv.Store "Function" %3, %1 ["Aligned", 8]: vector<3xi32> + spirv.Branch ^merge ^else: - // CHECK: spv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE_1]] ["Aligned", 8] : vector<3xi32> - spv.Store "Function" %3, %2 ["Aligned", 8] : vector<3xi32> - spv.Branch ^then + // CHECK: spirv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE_1]] ["Aligned", 8] : vector<3xi32> + spirv.Store "Function" %3, %2 ["Aligned", 8] : vector<3xi32> + spirv.Branch ^then ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // ----- // CHECK-LABEL: cannot_canonicalize_selection_op_3 -// `spv.Return` as a block terminator. +// `spirv.Return` as a block terminator. func.func @cannot_canonicalize_selection_op_3(%cond: i1) -> () { - %0 = spv.Constant dense<[0, 1, 2]> : vector<3xi32> - %1 = spv.Constant dense<[1, 2, 3]> : vector<3xi32> - // CHECK-DAG: %[[SRC_VALUE_0:.*]] = spv.Constant dense<[1, 2, 3]> : vector<3xi32> - // CHECK-DAG: %[[SRC_VALUE_1:.*]] = spv.Constant dense<[2, 3, 4]> : vector<3xi32> - %2 = spv.Constant dense<[2, 3, 4]> : vector<3xi32> - // CHECK: %[[DST_VAR:.*]] = spv.Variable init({{%.*}}) : !spv.ptr, Function> - %3 = spv.Variable init(%0) : !spv.ptr, Function> - - // CHECK: spv.mlir.selection { - spv.mlir.selection { - spv.BranchConditional %cond, ^then, ^else + %0 = spirv.Constant dense<[0, 1, 2]> : vector<3xi32> + %1 = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> + // CHECK-DAG: %[[SRC_VALUE_0:.*]] = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> + // CHECK-DAG: %[[SRC_VALUE_1:.*]] = spirv.Constant dense<[2, 3, 4]> : vector<3xi32> + %2 = spirv.Constant dense<[2, 3, 4]> : vector<3xi32> + // CHECK: %[[DST_VAR:.*]] = spirv.Variable init({{%.*}}) : !spirv.ptr, Function> + %3 = spirv.Variable init(%0) : !spirv.ptr, Function> + + // CHECK: spirv.mlir.selection { + spirv.mlir.selection { + spirv.BranchConditional %cond, ^then, ^else ^then: - // CHECK: spv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE_0]] ["Aligned", 8] : vector<3xi32> - spv.Store "Function" %3, %1 ["Aligned", 8]: vector<3xi32> - spv.Return + // CHECK: spirv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE_0]] ["Aligned", 8] : vector<3xi32> + spirv.Store "Function" %3, %1 ["Aligned", 8]: vector<3xi32> + spirv.Return ^else: - // CHECK: spv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE_1]] ["Aligned", 8] : vector<3xi32> - spv.Store "Function" %3, %2 ["Aligned", 8] : vector<3xi32> - spv.Branch ^merge + // CHECK: spirv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE_1]] ["Aligned", 8] : vector<3xi32> + spirv.Store "Function" %3, %2 ["Aligned", 8] : vector<3xi32> + spirv.Branch ^merge ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // ----- @@ -736,30 +736,30 @@ // Different memory access attributes. func.func @cannot_canonicalize_selection_op_4(%cond: i1) -> () { - %0 = spv.Constant dense<[0, 1, 2]> : vector<3xi32> - // CHECK-DAG: %[[SRC_VALUE_0:.*]] = spv.Constant dense<[1, 2, 3]> : vector<3xi32> - %1 = spv.Constant dense<[1, 2, 3]> : vector<3xi32> - // CHECK-DAG: %[[SRC_VALUE_1:.*]] = spv.Constant dense<[2, 3, 4]> : vector<3xi32> - %2 = spv.Constant dense<[2, 3, 4]> : vector<3xi32> - // CHECK: %[[DST_VAR:.*]] = spv.Variable init({{%.*}}) : !spv.ptr, Function> - %3 = spv.Variable init(%0) : !spv.ptr, Function> - - // CHECK: spv.mlir.selection { - spv.mlir.selection { - spv.BranchConditional %cond, ^then, ^else + %0 = spirv.Constant dense<[0, 1, 2]> : vector<3xi32> + // CHECK-DAG: %[[SRC_VALUE_0:.*]] = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> + %1 = spirv.Constant dense<[1, 2, 3]> : vector<3xi32> + // CHECK-DAG: %[[SRC_VALUE_1:.*]] = spirv.Constant dense<[2, 3, 4]> : vector<3xi32> + %2 = spirv.Constant dense<[2, 3, 4]> : vector<3xi32> + // CHECK: %[[DST_VAR:.*]] = spirv.Variable init({{%.*}}) : !spirv.ptr, Function> + %3 = spirv.Variable init(%0) : !spirv.ptr, Function> + + // CHECK: spirv.mlir.selection { + spirv.mlir.selection { + spirv.BranchConditional %cond, ^then, ^else ^then: - // CHECK: spv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE_0]] ["Aligned", 4] : vector<3xi32> - spv.Store "Function" %3, %1 ["Aligned", 4]: vector<3xi32> - spv.Branch ^merge + // CHECK: spirv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE_0]] ["Aligned", 4] : vector<3xi32> + spirv.Store "Function" %3, %1 ["Aligned", 4]: vector<3xi32> + spirv.Branch ^merge ^else: - // CHECK: spv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE_1]] ["Aligned", 8] : vector<3xi32> - spv.Store "Function" %3, %2 ["Aligned", 8] : vector<3xi32> - spv.Branch ^merge + // CHECK: spirv.Store "Function" %[[DST_VAR]], %[[SRC_VALUE_1]] ["Aligned", 8] : vector<3xi32> + spirv.Store "Function" %3, %2 ["Aligned", 8] : vector<3xi32> + spirv.Branch ^merge ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } diff --git a/mlir/test/Dialect/SPIRV/Transforms/gl-canonicalize.mlir b/mlir/test/Dialect/SPIRV/Transforms/gl-canonicalize.mlir --- a/mlir/test/Dialect/SPIRV/Transforms/gl-canonicalize.mlir +++ b/mlir/test/Dialect/SPIRV/Transforms/gl-canonicalize.mlir @@ -3,14 +3,14 @@ // CHECK-LABEL: func @clamp_fordlessthan // CHECK-SAME: (%[[INPUT:.*]]: f32, %[[MIN:.*]]: f32, %[[MAX:.*]]: f32) func.func @clamp_fordlessthan(%input: f32, %min: f32, %max: f32) -> f32 { - // CHECK: [[RES:%.*]] = spv.GL.FClamp %[[INPUT]], %[[MIN]], %[[MAX]] - %0 = spv.FOrdLessThan %min, %input : f32 - %mid = spv.Select %0, %input, %min : i1, f32 - %1 = spv.FOrdLessThan %mid, %max : f32 - %2 = spv.Select %1, %mid, %max : i1, f32 - - // CHECK-NEXT: spv.ReturnValue [[RES]] - spv.ReturnValue %2 : f32 + // CHECK: [[RES:%.*]] = spirv.GL.FClamp %[[INPUT]], %[[MIN]], %[[MAX]] + %0 = spirv.FOrdLessThan %min, %input : f32 + %mid = spirv.Select %0, %input, %min : i1, f32 + %1 = spirv.FOrdLessThan %mid, %max : f32 + %2 = spirv.Select %1, %mid, %max : i1, f32 + + // CHECK-NEXT: spirv.ReturnValue [[RES]] + spirv.ReturnValue %2 : f32 } // ----- @@ -18,14 +18,14 @@ // CHECK-LABEL: func @clamp_fordlessthan // CHECK-SAME: (%[[INPUT:.*]]: f32, %[[MIN:.*]]: f32, %[[MAX:.*]]: f32) func.func @clamp_fordlessthan(%input: f32, %min: f32, %max: f32) -> f32 { - // CHECK: [[RES:%.*]] = spv.GL.FClamp %[[INPUT]], %[[MIN]], %[[MAX]] - %0 = spv.FOrdLessThan %input, %min : f32 - %mid = spv.Select %0, %min, %input : i1, f32 - %1 = spv.FOrdLessThan %max, %input : f32 - %2 = spv.Select %1, %max, %mid : i1, f32 - - // CHECK-NEXT: spv.ReturnValue [[RES]] - spv.ReturnValue %2 : f32 + // CHECK: [[RES:%.*]] = spirv.GL.FClamp %[[INPUT]], %[[MIN]], %[[MAX]] + %0 = spirv.FOrdLessThan %input, %min : f32 + %mid = spirv.Select %0, %min, %input : i1, f32 + %1 = spirv.FOrdLessThan %max, %input : f32 + %2 = spirv.Select %1, %max, %mid : i1, f32 + + // CHECK-NEXT: spirv.ReturnValue [[RES]] + spirv.ReturnValue %2 : f32 } // ----- @@ -33,14 +33,14 @@ // CHECK-LABEL: func @clamp_fordlessthanequal // CHECK-SAME: (%[[INPUT:.*]]: f32, %[[MIN:.*]]: f32, %[[MAX:.*]]: f32) func.func @clamp_fordlessthanequal(%input: f32, %min: f32, %max: f32) -> f32 { - // CHECK: [[RES:%.*]] = spv.GL.FClamp %[[INPUT]], %[[MIN]], %[[MAX]] - %0 = spv.FOrdLessThanEqual %min, %input : f32 - %mid = spv.Select %0, %input, %min : i1, f32 - %1 = spv.FOrdLessThanEqual %mid, %max : f32 - %2 = spv.Select %1, %mid, %max : i1, f32 - - // CHECK-NEXT: spv.ReturnValue [[RES]] - spv.ReturnValue %2 : f32 + // CHECK: [[RES:%.*]] = spirv.GL.FClamp %[[INPUT]], %[[MIN]], %[[MAX]] + %0 = spirv.FOrdLessThanEqual %min, %input : f32 + %mid = spirv.Select %0, %input, %min : i1, f32 + %1 = spirv.FOrdLessThanEqual %mid, %max : f32 + %2 = spirv.Select %1, %mid, %max : i1, f32 + + // CHECK-NEXT: spirv.ReturnValue [[RES]] + spirv.ReturnValue %2 : f32 } // ----- @@ -48,14 +48,14 @@ // CHECK-LABEL: func @clamp_fordlessthanequal // CHECK-SAME: (%[[INPUT:.*]]: f32, %[[MIN:.*]]: f32, %[[MAX:.*]]: f32) func.func @clamp_fordlessthanequal(%input: f32, %min: f32, %max: f32) -> f32 { - // CHECK: [[RES:%.*]] = spv.GL.FClamp %[[INPUT]], %[[MIN]], %[[MAX]] - %0 = spv.FOrdLessThanEqual %input, %min : f32 - %mid = spv.Select %0, %min, %input : i1, f32 - %1 = spv.FOrdLessThanEqual %max, %input : f32 - %2 = spv.Select %1, %max, %mid : i1, f32 - - // CHECK-NEXT: spv.ReturnValue [[RES]] - spv.ReturnValue %2 : f32 + // CHECK: [[RES:%.*]] = spirv.GL.FClamp %[[INPUT]], %[[MIN]], %[[MAX]] + %0 = spirv.FOrdLessThanEqual %input, %min : f32 + %mid = spirv.Select %0, %min, %input : i1, f32 + %1 = spirv.FOrdLessThanEqual %max, %input : f32 + %2 = spirv.Select %1, %max, %mid : i1, f32 + + // CHECK-NEXT: spirv.ReturnValue [[RES]] + spirv.ReturnValue %2 : f32 } // ----- @@ -63,14 +63,14 @@ // CHECK-LABEL: func @clamp_slessthan // CHECK-SAME: (%[[INPUT:.*]]: si32, %[[MIN:.*]]: si32, %[[MAX:.*]]: si32) func.func @clamp_slessthan(%input: si32, %min: si32, %max: si32) -> si32 { - // CHECK: [[RES:%.*]] = spv.GL.SClamp %[[INPUT]], %[[MIN]], %[[MAX]] - %0 = spv.SLessThan %min, %input : si32 - %mid = spv.Select %0, %input, %min : i1, si32 - %1 = spv.SLessThan %mid, %max : si32 - %2 = spv.Select %1, %mid, %max : i1, si32 - - // CHECK-NEXT: spv.ReturnValue [[RES]] - spv.ReturnValue %2 : si32 + // CHECK: [[RES:%.*]] = spirv.GL.SClamp %[[INPUT]], %[[MIN]], %[[MAX]] + %0 = spirv.SLessThan %min, %input : si32 + %mid = spirv.Select %0, %input, %min : i1, si32 + %1 = spirv.SLessThan %mid, %max : si32 + %2 = spirv.Select %1, %mid, %max : i1, si32 + + // CHECK-NEXT: spirv.ReturnValue [[RES]] + spirv.ReturnValue %2 : si32 } // ----- @@ -78,14 +78,14 @@ // CHECK-LABEL: func @clamp_slessthan // CHECK-SAME: (%[[INPUT:.*]]: si32, %[[MIN:.*]]: si32, %[[MAX:.*]]: si32) func.func @clamp_slessthan(%input: si32, %min: si32, %max: si32) -> si32 { - // CHECK: [[RES:%.*]] = spv.GL.SClamp %[[INPUT]], %[[MIN]], %[[MAX]] - %0 = spv.SLessThan %input, %min : si32 - %mid = spv.Select %0, %min, %input : i1, si32 - %1 = spv.SLessThan %max, %input : si32 - %2 = spv.Select %1, %max, %mid : i1, si32 - - // CHECK-NEXT: spv.ReturnValue [[RES]] - spv.ReturnValue %2 : si32 + // CHECK: [[RES:%.*]] = spirv.GL.SClamp %[[INPUT]], %[[MIN]], %[[MAX]] + %0 = spirv.SLessThan %input, %min : si32 + %mid = spirv.Select %0, %min, %input : i1, si32 + %1 = spirv.SLessThan %max, %input : si32 + %2 = spirv.Select %1, %max, %mid : i1, si32 + + // CHECK-NEXT: spirv.ReturnValue [[RES]] + spirv.ReturnValue %2 : si32 } // ----- @@ -93,14 +93,14 @@ // CHECK-LABEL: func @clamp_slessthanequal // CHECK-SAME: (%[[INPUT:.*]]: si32, %[[MIN:.*]]: si32, %[[MAX:.*]]: si32) func.func @clamp_slessthanequal(%input: si32, %min: si32, %max: si32) -> si32 { - // CHECK: [[RES:%.*]] = spv.GL.SClamp %[[INPUT]], %[[MIN]], %[[MAX]] - %0 = spv.SLessThanEqual %min, %input : si32 - %mid = spv.Select %0, %input, %min : i1, si32 - %1 = spv.SLessThanEqual %mid, %max : si32 - %2 = spv.Select %1, %mid, %max : i1, si32 - - // CHECK-NEXT: spv.ReturnValue [[RES]] - spv.ReturnValue %2 : si32 + // CHECK: [[RES:%.*]] = spirv.GL.SClamp %[[INPUT]], %[[MIN]], %[[MAX]] + %0 = spirv.SLessThanEqual %min, %input : si32 + %mid = spirv.Select %0, %input, %min : i1, si32 + %1 = spirv.SLessThanEqual %mid, %max : si32 + %2 = spirv.Select %1, %mid, %max : i1, si32 + + // CHECK-NEXT: spirv.ReturnValue [[RES]] + spirv.ReturnValue %2 : si32 } // ----- @@ -108,14 +108,14 @@ // CHECK-LABEL: func @clamp_slessthanequal // CHECK-SAME: (%[[INPUT:.*]]: si32, %[[MIN:.*]]: si32, %[[MAX:.*]]: si32) func.func @clamp_slessthanequal(%input: si32, %min: si32, %max: si32) -> si32 { - // CHECK: [[RES:%.*]] = spv.GL.SClamp %[[INPUT]], %[[MIN]], %[[MAX]] - %0 = spv.SLessThanEqual %input, %min : si32 - %mid = spv.Select %0, %min, %input : i1, si32 - %1 = spv.SLessThanEqual %max, %input : si32 - %2 = spv.Select %1, %max, %mid : i1, si32 - - // CHECK-NEXT: spv.ReturnValue [[RES]] - spv.ReturnValue %2 : si32 + // CHECK: [[RES:%.*]] = spirv.GL.SClamp %[[INPUT]], %[[MIN]], %[[MAX]] + %0 = spirv.SLessThanEqual %input, %min : si32 + %mid = spirv.Select %0, %min, %input : i1, si32 + %1 = spirv.SLessThanEqual %max, %input : si32 + %2 = spirv.Select %1, %max, %mid : i1, si32 + + // CHECK-NEXT: spirv.ReturnValue [[RES]] + spirv.ReturnValue %2 : si32 } // ----- @@ -123,14 +123,14 @@ // CHECK-LABEL: func @clamp_ulessthan // CHECK-SAME: (%[[INPUT:.*]]: i32, %[[MIN:.*]]: i32, %[[MAX:.*]]: i32) func.func @clamp_ulessthan(%input: i32, %min: i32, %max: i32) -> i32 { - // CHECK: [[RES:%.*]] = spv.GL.UClamp %[[INPUT]], %[[MIN]], %[[MAX]] - %0 = spv.ULessThan %min, %input : i32 - %mid = spv.Select %0, %input, %min : i1, i32 - %1 = spv.ULessThan %mid, %max : i32 - %2 = spv.Select %1, %mid, %max : i1, i32 - - // CHECK-NEXT: spv.ReturnValue [[RES]] - spv.ReturnValue %2 : i32 + // CHECK: [[RES:%.*]] = spirv.GL.UClamp %[[INPUT]], %[[MIN]], %[[MAX]] + %0 = spirv.ULessThan %min, %input : i32 + %mid = spirv.Select %0, %input, %min : i1, i32 + %1 = spirv.ULessThan %mid, %max : i32 + %2 = spirv.Select %1, %mid, %max : i1, i32 + + // CHECK-NEXT: spirv.ReturnValue [[RES]] + spirv.ReturnValue %2 : i32 } // ----- @@ -138,14 +138,14 @@ // CHECK-LABEL: func @clamp_ulessthan // CHECK-SAME: (%[[INPUT:.*]]: i32, %[[MIN:.*]]: i32, %[[MAX:.*]]: i32) func.func @clamp_ulessthan(%input: i32, %min: i32, %max: i32) -> i32 { - // CHECK: [[RES:%.*]] = spv.GL.UClamp %[[INPUT]], %[[MIN]], %[[MAX]] - %0 = spv.ULessThan %input, %min : i32 - %mid = spv.Select %0, %min, %input : i1, i32 - %1 = spv.ULessThan %max, %input : i32 - %2 = spv.Select %1, %max, %mid : i1, i32 - - // CHECK-NEXT: spv.ReturnValue [[RES]] - spv.ReturnValue %2 : i32 + // CHECK: [[RES:%.*]] = spirv.GL.UClamp %[[INPUT]], %[[MIN]], %[[MAX]] + %0 = spirv.ULessThan %input, %min : i32 + %mid = spirv.Select %0, %min, %input : i1, i32 + %1 = spirv.ULessThan %max, %input : i32 + %2 = spirv.Select %1, %max, %mid : i1, i32 + + // CHECK-NEXT: spirv.ReturnValue [[RES]] + spirv.ReturnValue %2 : i32 } // ----- @@ -153,14 +153,14 @@ // CHECK-LABEL: func @clamp_ulessthanequal // CHECK-SAME: (%[[INPUT:.*]]: i32, %[[MIN:.*]]: i32, %[[MAX:.*]]: i32) func.func @clamp_ulessthanequal(%input: i32, %min: i32, %max: i32) -> i32 { - // CHECK: [[RES:%.*]] = spv.GL.UClamp %[[INPUT]], %[[MIN]], %[[MAX]] - %0 = spv.ULessThanEqual %min, %input : i32 - %mid = spv.Select %0, %input, %min : i1, i32 - %1 = spv.ULessThanEqual %mid, %max : i32 - %2 = spv.Select %1, %mid, %max : i1, i32 - - // CHECK-NEXT: spv.ReturnValue [[RES]] - spv.ReturnValue %2 : i32 + // CHECK: [[RES:%.*]] = spirv.GL.UClamp %[[INPUT]], %[[MIN]], %[[MAX]] + %0 = spirv.ULessThanEqual %min, %input : i32 + %mid = spirv.Select %0, %input, %min : i1, i32 + %1 = spirv.ULessThanEqual %mid, %max : i32 + %2 = spirv.Select %1, %mid, %max : i1, i32 + + // CHECK-NEXT: spirv.ReturnValue [[RES]] + spirv.ReturnValue %2 : i32 } // ----- @@ -168,12 +168,12 @@ // CHECK-LABEL: func @clamp_ulessthanequal // CHECK-SAME: (%[[INPUT:.*]]: i32, %[[MIN:.*]]: i32, %[[MAX:.*]]: i32) func.func @clamp_ulessthanequal(%input: i32, %min: i32, %max: i32) -> i32 { - // CHECK: [[RES:%.*]] = spv.GL.UClamp %[[INPUT]], %[[MIN]], %[[MAX]] - %0 = spv.ULessThanEqual %input, %min : i32 - %mid = spv.Select %0, %min, %input : i1, i32 - %1 = spv.ULessThanEqual %max, %input : i32 - %2 = spv.Select %1, %max, %mid : i1, i32 - - // CHECK-NEXT: spv.ReturnValue [[RES]] - spv.ReturnValue %2 : i32 + // CHECK: [[RES:%.*]] = spirv.GL.UClamp %[[INPUT]], %[[MIN]], %[[MAX]] + %0 = spirv.ULessThanEqual %input, %min : i32 + %mid = spirv.Select %0, %min, %input : i1, i32 + %1 = spirv.ULessThanEqual %max, %input : i32 + %2 = spirv.Select %1, %max, %mid : i1, i32 + + // CHECK-NEXT: spirv.ReturnValue [[RES]] + spirv.ReturnValue %2 : i32 } diff --git a/mlir/test/Dialect/SPIRV/Transforms/inlining.mlir b/mlir/test/Dialect/SPIRV/Transforms/inlining.mlir --- a/mlir/test/Dialect/SPIRV/Transforms/inlining.mlir +++ b/mlir/test/Dialect/SPIRV/Transforms/inlining.mlir @@ -1,65 +1,65 @@ -// RUN: mlir-opt %s -split-input-file -pass-pipeline='spv.module(inline{default-pipeline=''})' | FileCheck %s +// RUN: mlir-opt %s -split-input-file -pass-pipeline='spirv.module(inline{default-pipeline=''})' | FileCheck %s -spv.module Logical GLSL450 { - spv.func @callee() "None" { - spv.Return +spirv.module Logical GLSL450 { + spirv.func @callee() "None" { + spirv.Return } // CHECK-LABEL: @calling_single_block_ret_func - spv.func @calling_single_block_ret_func() "None" { - // CHECK-NEXT: spv.Return - spv.FunctionCall @callee() : () -> () - spv.Return + spirv.func @calling_single_block_ret_func() "None" { + // CHECK-NEXT: spirv.Return + spirv.FunctionCall @callee() : () -> () + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.func @callee() -> i32 "None" { - %0 = spv.Constant 42 : i32 - spv.ReturnValue %0 : i32 +spirv.module Logical GLSL450 { + spirv.func @callee() -> i32 "None" { + %0 = spirv.Constant 42 : i32 + spirv.ReturnValue %0 : i32 } // CHECK-LABEL: @calling_single_block_retval_func - spv.func @calling_single_block_retval_func() -> i32 "None" { - // CHECK-NEXT: %[[CST:.*]] = spv.Constant 42 - %0 = spv.FunctionCall @callee() : () -> (i32) - // CHECK-NEXT: spv.ReturnValue %[[CST]] - spv.ReturnValue %0 : i32 + spirv.func @calling_single_block_retval_func() -> i32 "None" { + // CHECK-NEXT: %[[CST:.*]] = spirv.Constant 42 + %0 = spirv.FunctionCall @callee() : () -> (i32) + // CHECK-NEXT: spirv.ReturnValue %[[CST]] + spirv.ReturnValue %0 : i32 } } // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @data bind(0, 0) : !spv.ptr [0])>, StorageBuffer> - spv.func @callee() "None" { - %0 = spv.mlir.addressof @data : !spv.ptr [0])>, StorageBuffer> - %1 = spv.Constant 0: i32 - %2 = spv.AccessChain %0[%1, %1] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - spv.Branch ^next +spirv.module Logical GLSL450 { + spirv.GlobalVariable @data bind(0, 0) : !spirv.ptr [0])>, StorageBuffer> + spirv.func @callee() "None" { + %0 = spirv.mlir.addressof @data : !spirv.ptr [0])>, StorageBuffer> + %1 = spirv.Constant 0: i32 + %2 = spirv.AccessChain %0[%1, %1] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + spirv.Branch ^next ^next: - %3 = spv.Constant 42: i32 - spv.Store "StorageBuffer" %2, %3 : i32 - spv.Return + %3 = spirv.Constant 42: i32 + spirv.Store "StorageBuffer" %2, %3 : i32 + spirv.Return } // CHECK-LABEL: @calling_multi_block_ret_func - spv.func @calling_multi_block_ret_func() "None" { - // CHECK-NEXT: spv.mlir.addressof - // CHECK-NEXT: spv.Constant 0 - // CHECK-NEXT: spv.AccessChain - // CHECK-NEXT: spv.Branch ^bb1 + spirv.func @calling_multi_block_ret_func() "None" { + // CHECK-NEXT: spirv.mlir.addressof + // CHECK-NEXT: spirv.Constant 0 + // CHECK-NEXT: spirv.AccessChain + // CHECK-NEXT: spirv.Branch ^bb1 // CHECK-NEXT: ^bb1: - // CHECK-NEXT: spv.Constant - // CHECK-NEXT: spv.Store - // CHECK-NEXT: spv.Branch ^bb2 - spv.FunctionCall @callee() : () -> () + // CHECK-NEXT: spirv.Constant + // CHECK-NEXT: spirv.Store + // CHECK-NEXT: spirv.Branch ^bb2 + spirv.FunctionCall @callee() : () -> () // CHECK-NEXT: ^bb2: - // CHECK-NEXT: spv.Return - spv.Return + // CHECK-NEXT: spirv.Return + spirv.Return } } @@ -67,161 +67,161 @@ // ----- -spv.module Logical GLSL450 { - spv.func @callee(%cond : i1) -> () "None" { - spv.mlir.selection { - spv.BranchConditional %cond, ^then, ^merge +spirv.module Logical GLSL450 { + spirv.func @callee(%cond : i1) -> () "None" { + spirv.mlir.selection { + spirv.BranchConditional %cond, ^then, ^merge ^then: - spv.Return + spirv.Return ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // CHECK-LABEL: @calling_selection_ret_func - spv.func @calling_selection_ret_func() "None" { - %0 = spv.Constant true - // CHECK: spv.FunctionCall - spv.FunctionCall @callee(%0) : (i1) -> () - spv.Return + spirv.func @calling_selection_ret_func() "None" { + %0 = spirv.Constant true + // CHECK: spirv.FunctionCall + spirv.FunctionCall @callee(%0) : (i1) -> () + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.func @callee(%cond : i1) -> () "None" { - spv.mlir.selection { - spv.BranchConditional %cond, ^then, ^merge +spirv.module Logical GLSL450 { + spirv.func @callee(%cond : i1) -> () "None" { + spirv.mlir.selection { + spirv.BranchConditional %cond, ^then, ^merge ^then: - spv.Branch ^merge + spirv.Branch ^merge ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // CHECK-LABEL: @calling_selection_no_ret_func - spv.func @calling_selection_no_ret_func() "None" { - // CHECK-NEXT: %[[TRUE:.*]] = spv.Constant true - %0 = spv.Constant true - // CHECK-NEXT: spv.mlir.selection - // CHECK-NEXT: spv.BranchConditional %[[TRUE]], ^bb1, ^bb2 + spirv.func @calling_selection_no_ret_func() "None" { + // CHECK-NEXT: %[[TRUE:.*]] = spirv.Constant true + %0 = spirv.Constant true + // CHECK-NEXT: spirv.mlir.selection + // CHECK-NEXT: spirv.BranchConditional %[[TRUE]], ^bb1, ^bb2 // CHECK-NEXT: ^bb1: - // CHECK-NEXT: spv.Branch ^bb2 + // CHECK-NEXT: spirv.Branch ^bb2 // CHECK-NEXT: ^bb2: - // CHECK-NEXT: spv.mlir.merge - spv.FunctionCall @callee(%0) : (i1) -> () - spv.Return + // CHECK-NEXT: spirv.mlir.merge + spirv.FunctionCall @callee(%0) : (i1) -> () + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.func @callee(%cond : i1) -> () "None" { - spv.mlir.loop { - spv.Branch ^header +spirv.module Logical GLSL450 { + spirv.func @callee(%cond : i1) -> () "None" { + spirv.mlir.loop { + spirv.Branch ^header ^header: - spv.BranchConditional %cond, ^body, ^merge + spirv.BranchConditional %cond, ^body, ^merge ^body: - spv.Return + spirv.Return ^continue: - spv.Branch ^header + spirv.Branch ^header ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // CHECK-LABEL: @calling_loop_ret_func - spv.func @calling_loop_ret_func() "None" { - %0 = spv.Constant true - // CHECK: spv.FunctionCall - spv.FunctionCall @callee(%0) : (i1) -> () - spv.Return + spirv.func @calling_loop_ret_func() "None" { + %0 = spirv.Constant true + // CHECK: spirv.FunctionCall + spirv.FunctionCall @callee(%0) : (i1) -> () + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.func @callee(%cond : i1) -> () "None" { - spv.mlir.loop { - spv.Branch ^header +spirv.module Logical GLSL450 { + spirv.func @callee(%cond : i1) -> () "None" { + spirv.mlir.loop { + spirv.Branch ^header ^header: - spv.BranchConditional %cond, ^body, ^merge + spirv.BranchConditional %cond, ^body, ^merge ^body: - spv.Branch ^continue + spirv.Branch ^continue ^continue: - spv.Branch ^header + spirv.Branch ^header ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } // CHECK-LABEL: @calling_loop_no_ret_func - spv.func @calling_loop_no_ret_func() "None" { - // CHECK-NEXT: %[[TRUE:.*]] = spv.Constant true - %0 = spv.Constant true - // CHECK-NEXT: spv.mlir.loop - // CHECK-NEXT: spv.Branch ^bb1 + spirv.func @calling_loop_no_ret_func() "None" { + // CHECK-NEXT: %[[TRUE:.*]] = spirv.Constant true + %0 = spirv.Constant true + // CHECK-NEXT: spirv.mlir.loop + // CHECK-NEXT: spirv.Branch ^bb1 // CHECK-NEXT: ^bb1: - // CHECK-NEXT: spv.BranchConditional %[[TRUE]], ^bb2, ^bb4 + // CHECK-NEXT: spirv.BranchConditional %[[TRUE]], ^bb2, ^bb4 // CHECK-NEXT: ^bb2: - // CHECK-NEXT: spv.Branch ^bb3 + // CHECK-NEXT: spirv.Branch ^bb3 // CHECK-NEXT: ^bb3: - // CHECK-NEXT: spv.Branch ^bb1 + // CHECK-NEXT: spirv.Branch ^bb1 // CHECK-NEXT: ^bb4: - // CHECK-NEXT: spv.mlir.merge - spv.FunctionCall @callee(%0) : (i1) -> () - spv.Return + // CHECK-NEXT: spirv.mlir.merge + spirv.FunctionCall @callee(%0) : (i1) -> () + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @arg_0 bind(0, 0) : !spv.ptr, StorageBuffer> - spv.GlobalVariable @arg_1 bind(0, 1) : !spv.ptr, StorageBuffer> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @arg_0 bind(0, 0) : !spirv.ptr, StorageBuffer> + spirv.GlobalVariable @arg_1 bind(0, 1) : !spirv.ptr, StorageBuffer> // CHECK: @inline_into_selection_region - spv.func @inline_into_selection_region() "None" { - %1 = spv.Constant 0 : i32 - // CHECK-DAG: [[ADDRESS_ARG0:%.*]] = spv.mlir.addressof @arg_0 - // CHECK-DAG: [[ADDRESS_ARG1:%.*]] = spv.mlir.addressof @arg_1 - // CHECK-DAG: [[LOADPTR:%.*]] = spv.AccessChain [[ADDRESS_ARG0]] - // CHECK: [[VAL:%.*]] = spv.Load "StorageBuffer" [[LOADPTR]] - %2 = spv.mlir.addressof @arg_0 : !spv.ptr, StorageBuffer> - %3 = spv.mlir.addressof @arg_1 : !spv.ptr, StorageBuffer> - %4 = spv.AccessChain %2[%1] : !spv.ptr, StorageBuffer>, i32 - %5 = spv.Load "StorageBuffer" %4 : i32 - %6 = spv.SGreaterThan %5, %1 : i32 - // CHECK: spv.mlir.selection - spv.mlir.selection { - spv.BranchConditional %6, ^bb1, ^bb2 + spirv.func @inline_into_selection_region() "None" { + %1 = spirv.Constant 0 : i32 + // CHECK-DAG: [[ADDRESS_ARG0:%.*]] = spirv.mlir.addressof @arg_0 + // CHECK-DAG: [[ADDRESS_ARG1:%.*]] = spirv.mlir.addressof @arg_1 + // CHECK-DAG: [[LOADPTR:%.*]] = spirv.AccessChain [[ADDRESS_ARG0]] + // CHECK: [[VAL:%.*]] = spirv.Load "StorageBuffer" [[LOADPTR]] + %2 = spirv.mlir.addressof @arg_0 : !spirv.ptr, StorageBuffer> + %3 = spirv.mlir.addressof @arg_1 : !spirv.ptr, StorageBuffer> + %4 = spirv.AccessChain %2[%1] : !spirv.ptr, StorageBuffer>, i32 + %5 = spirv.Load "StorageBuffer" %4 : i32 + %6 = spirv.SGreaterThan %5, %1 : i32 + // CHECK: spirv.mlir.selection + spirv.mlir.selection { + spirv.BranchConditional %6, ^bb1, ^bb2 ^bb1: // pred: ^bb0 - // CHECK: [[STOREPTR:%.*]] = spv.AccessChain [[ADDRESS_ARG1]] - %7 = spv.AccessChain %3[%1] : !spv.ptr, StorageBuffer>, i32 - // CHECK-NOT: spv.FunctionCall - // CHECK: spv.AtomicIAdd "Device" "AcquireRelease" [[STOREPTR]], [[VAL]] - // CHECK: spv.Branch - spv.FunctionCall @atomic_add(%5, %7) : (i32, !spv.ptr) -> () - spv.Branch ^bb2 + // CHECK: [[STOREPTR:%.*]] = spirv.AccessChain [[ADDRESS_ARG1]] + %7 = spirv.AccessChain %3[%1] : !spirv.ptr, StorageBuffer>, i32 + // CHECK-NOT: spirv.FunctionCall + // CHECK: spirv.AtomicIAdd "Device" "AcquireRelease" [[STOREPTR]], [[VAL]] + // CHECK: spirv.Branch + spirv.FunctionCall @atomic_add(%5, %7) : (i32, !spirv.ptr) -> () + spirv.Branch ^bb2 ^bb2 : // 2 preds: ^bb0, ^bb1 - spv.mlir.merge + spirv.mlir.merge } - // CHECK: spv.Return - spv.Return + // CHECK: spirv.Return + spirv.Return } - spv.func @atomic_add(%arg0: i32, %arg1: !spv.ptr) "None" { - %0 = spv.AtomicIAdd "Device" "AcquireRelease" %arg1, %arg0 : !spv.ptr - spv.Return + spirv.func @atomic_add(%arg0: i32, %arg1: !spirv.ptr) "None" { + %0 = spirv.AtomicIAdd "Device" "AcquireRelease" %arg1, %arg0 : !spirv.ptr + spirv.Return } - spv.EntryPoint "GLCompute" @inline_into_selection_region - spv.ExecutionMode @inline_into_selection_region "LocalSize", 32, 1, 1 + spirv.EntryPoint "GLCompute" @inline_into_selection_region + spirv.ExecutionMode @inline_into_selection_region "LocalSize", 32, 1, 1 } // TODO: Add tests for inlining structured control flow into diff --git a/mlir/test/Dialect/SPIRV/Transforms/layout-decoration.mlir b/mlir/test/Dialect/SPIRV/Transforms/layout-decoration.mlir --- a/mlir/test/Dialect/SPIRV/Transforms/layout-decoration.mlir +++ b/mlir/test/Dialect/SPIRV/Transforms/layout-decoration.mlir @@ -1,99 +1,99 @@ // RUN: mlir-opt -decorate-spirv-composite-type-layout -split-input-file -verify-diagnostics %s -o - | FileCheck %s -spv.module Logical GLSL450 { - // CHECK: spv.GlobalVariable @var0 bind(0, 1) : !spv.ptr [4], f32 [12])>, Uniform> - spv.GlobalVariable @var0 bind(0,1) : !spv.ptr, f32)>, Uniform> +spirv.module Logical GLSL450 { + // CHECK: spirv.GlobalVariable @var0 bind(0, 1) : !spirv.ptr [4], f32 [12])>, Uniform> + spirv.GlobalVariable @var0 bind(0,1) : !spirv.ptr, f32)>, Uniform> - // CHECK: spv.GlobalVariable @var1 bind(0, 2) : !spv.ptr [0], f32 [256])>, StorageBuffer> - spv.GlobalVariable @var1 bind(0,2) : !spv.ptr, f32)>, StorageBuffer> + // CHECK: spirv.GlobalVariable @var1 bind(0, 2) : !spirv.ptr [0], f32 [256])>, StorageBuffer> + spirv.GlobalVariable @var1 bind(0,2) : !spirv.ptr, f32)>, StorageBuffer> - // CHECK: spv.GlobalVariable @var2 bind(1, 0) : !spv.ptr [0], f32 [256])> [0], i32 [260])>, StorageBuffer> - spv.GlobalVariable @var2 bind(1,0) : !spv.ptr, f32)>, i32)>, StorageBuffer> + // CHECK: spirv.GlobalVariable @var2 bind(1, 0) : !spirv.ptr [0], f32 [256])> [0], i32 [260])>, StorageBuffer> + spirv.GlobalVariable @var2 bind(1,0) : !spirv.ptr, f32)>, i32)>, StorageBuffer> - // CHECK: spv.GlobalVariable @var3 : !spv.ptr [8])>, stride=72> [0], f32 [1152])>, StorageBuffer> - spv.GlobalVariable @var3 : !spv.ptr)>>, f32)>, StorageBuffer> + // CHECK: spirv.GlobalVariable @var3 : !spirv.ptr [8])>, stride=72> [0], f32 [1152])>, StorageBuffer> + spirv.GlobalVariable @var3 : !spirv.ptr)>>, f32)>, StorageBuffer> - // CHECK: spv.GlobalVariable @var4 bind(1, 2) : !spv.ptr [0], f32 [16], i1 [20])> [0], i1 [24])>, StorageBuffer> - spv.GlobalVariable @var4 bind(1,2) : !spv.ptr, f32, i1)>, i1)>, StorageBuffer> + // CHECK: spirv.GlobalVariable @var4 bind(1, 2) : !spirv.ptr [0], f32 [16], i1 [20])> [0], i1 [24])>, StorageBuffer> + spirv.GlobalVariable @var4 bind(1,2) : !spirv.ptr, f32, i1)>, i1)>, StorageBuffer> - // CHECK: spv.GlobalVariable @var5 bind(1, 3) : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @var5 bind(1,3) : !spv.ptr)>, StorageBuffer> + // CHECK: spirv.GlobalVariable @var5 bind(1, 3) : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @var5 bind(1,3) : !spirv.ptr)>, StorageBuffer> - spv.func @kernel() -> () "None" { - %c0 = spv.Constant 0 : i32 - // CHECK: {{%.*}} = spv.mlir.addressof @var0 : !spv.ptr [4], f32 [12])>, Uniform> - %0 = spv.mlir.addressof @var0 : !spv.ptr, f32)>, Uniform> - // CHECK: {{%.*}} = spv.AccessChain {{%.*}}[{{%.*}}] : !spv.ptr [4], f32 [12])>, Uniform> - %1 = spv.AccessChain %0[%c0] : !spv.ptr, f32)>, Uniform>, i32 - spv.Return + spirv.func @kernel() -> () "None" { + %c0 = spirv.Constant 0 : i32 + // CHECK: {{%.*}} = spirv.mlir.addressof @var0 : !spirv.ptr [4], f32 [12])>, Uniform> + %0 = spirv.mlir.addressof @var0 : !spirv.ptr, f32)>, Uniform> + // CHECK: {{%.*}} = spirv.AccessChain {{%.*}}[{{%.*}}] : !spirv.ptr [4], f32 [12])>, Uniform> + %1 = spirv.AccessChain %0[%c0] : !spirv.ptr, f32)>, Uniform>, i32 + spirv.Return } } // ----- -spv.module Logical GLSL450 { - // CHECK: spv.GlobalVariable @var0 : !spv.ptr [0], i1 [16])> [0], i1 [24])> [0], i1 [32])> [0], i1 [40])>, Uniform> - spv.GlobalVariable @var0 : !spv.ptr, i1)>, i1)>, i1)>, i1)>, Uniform> +spirv.module Logical GLSL450 { + // CHECK: spirv.GlobalVariable @var0 : !spirv.ptr [0], i1 [16])> [0], i1 [24])> [0], i1 [32])> [0], i1 [40])>, Uniform> + spirv.GlobalVariable @var0 : !spirv.ptr, i1)>, i1)>, i1)>, i1)>, Uniform> - // CHECK: spv.GlobalVariable @var1 : !spv.ptr [8], f32 [24])> [0], f32 [32])>, Uniform> - spv.GlobalVariable @var1 : !spv.ptr, f32)>, f32)>, Uniform> + // CHECK: spirv.GlobalVariable @var1 : !spirv.ptr [8], f32 [24])> [0], f32 [32])>, Uniform> + spirv.GlobalVariable @var1 : !spirv.ptr, f32)>, f32)>, Uniform> - // CHECK: spv.GlobalVariable @var2 : !spv.ptr, stride=128> [8])> [8], f32 [2064])> [0], f32 [2072])>, Uniform> - spv.GlobalVariable @var2 : !spv.ptr>)>, f32)>, f32)>, Uniform> + // CHECK: spirv.GlobalVariable @var2 : !spirv.ptr, stride=128> [8])> [8], f32 [2064])> [0], f32 [2072])>, Uniform> + spirv.GlobalVariable @var2 : !spirv.ptr>)>, f32)>, f32)>, Uniform> - // CHECK: spv.GlobalVariable @var3 : !spv.ptr [0], i1 [512])> [0], i1 [520])>, Uniform> - spv.GlobalVariable @var3 : !spv.ptr, i1)>, i1)>, Uniform> + // CHECK: spirv.GlobalVariable @var3 : !spirv.ptr [0], i1 [512])> [0], i1 [520])>, Uniform> + spirv.GlobalVariable @var3 : !spirv.ptr, i1)>, i1)>, Uniform> - // CHECK: spv.GlobalVariable @var4 : !spv.ptr [8], i1 [24])>, Uniform> - spv.GlobalVariable @var4 : !spv.ptr, i1)>, Uniform> + // CHECK: spirv.GlobalVariable @var4 : !spirv.ptr [8], i1 [24])>, Uniform> + spirv.GlobalVariable @var4 : !spirv.ptr, i1)>, Uniform> - // CHECK: spv.GlobalVariable @var5 : !spv.ptr [8], i1 [24])>, Uniform> - spv.GlobalVariable @var5 : !spv.ptr, i1)>, Uniform> + // CHECK: spirv.GlobalVariable @var5 : !spirv.ptr [8], i1 [24])>, Uniform> + spirv.GlobalVariable @var5 : !spirv.ptr, i1)>, Uniform> - // CHECK: spv.GlobalVariable @var6 : !spv.ptr [8], i1 [24])>, Uniform> - spv.GlobalVariable @var6 : !spv.ptr, i1)>, Uniform> + // CHECK: spirv.GlobalVariable @var6 : !spirv.ptr [8], i1 [24])>, Uniform> + spirv.GlobalVariable @var6 : !spirv.ptr, i1)>, Uniform> - // CHECK: spv.GlobalVariable @var7 : !spv.ptr [0], i1 [16])> [8], i1 [32])>, Uniform> - spv.GlobalVariable @var7 : !spv.ptr, i1)>, i1)>, Uniform> + // CHECK: spirv.GlobalVariable @var7 : !spirv.ptr [0], i1 [16])> [8], i1 [32])>, Uniform> + spirv.GlobalVariable @var7 : !spirv.ptr, i1)>, i1)>, Uniform> } // ----- -spv.module Logical GLSL450 { - // CHECK: spv.GlobalVariable @var0 : !spv.ptr [0], f32 [8])>, StorageBuffer> - spv.GlobalVariable @var0 : !spv.ptr, f32)>, StorageBuffer> +spirv.module Logical GLSL450 { + // CHECK: spirv.GlobalVariable @var0 : !spirv.ptr [0], f32 [8])>, StorageBuffer> + spirv.GlobalVariable @var0 : !spirv.ptr, f32)>, StorageBuffer> - // CHECK: spv.GlobalVariable @var1 : !spv.ptr [0], f32 [12])>, StorageBuffer> - spv.GlobalVariable @var1 : !spv.ptr, f32)>, StorageBuffer> + // CHECK: spirv.GlobalVariable @var1 : !spirv.ptr [0], f32 [12])>, StorageBuffer> + spirv.GlobalVariable @var1 : !spirv.ptr, f32)>, StorageBuffer> - // CHECK: spv.GlobalVariable @var2 : !spv.ptr [0], f32 [16])>, StorageBuffer> - spv.GlobalVariable @var2 : !spv.ptr, f32)>, StorageBuffer> + // CHECK: spirv.GlobalVariable @var2 : !spirv.ptr [0], f32 [16])>, StorageBuffer> + spirv.GlobalVariable @var2 : !spirv.ptr, f32)>, StorageBuffer> } // ----- -spv.module Logical GLSL450 { - // CHECK: spv.GlobalVariable @emptyStructAsMember : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @emptyStructAsMember : !spv.ptr)>, StorageBuffer> +spirv.module Logical GLSL450 { + // CHECK: spirv.GlobalVariable @emptyStructAsMember : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @emptyStructAsMember : !spirv.ptr)>, StorageBuffer> - // CHECK: spv.GlobalVariable @arrayType : !spv.ptr>, StorageBuffer> - spv.GlobalVariable @arrayType : !spv.ptr>, StorageBuffer> + // CHECK: spirv.GlobalVariable @arrayType : !spirv.ptr>, StorageBuffer> + spirv.GlobalVariable @arrayType : !spirv.ptr>, StorageBuffer> - // CHECK: spv.GlobalVariable @InputStorage : !spv.ptr)>, Input> - spv.GlobalVariable @InputStorage : !spv.ptr)>, Input> + // CHECK: spirv.GlobalVariable @InputStorage : !spirv.ptr)>, Input> + spirv.GlobalVariable @InputStorage : !spirv.ptr)>, Input> - // CHECK: spv.GlobalVariable @customLayout : !spv.ptr, Uniform> - spv.GlobalVariable @customLayout : !spv.ptr, Uniform> + // CHECK: spirv.GlobalVariable @customLayout : !spirv.ptr, Uniform> + spirv.GlobalVariable @customLayout : !spirv.ptr, Uniform> - // CHECK: spv.GlobalVariable @emptyStruct : !spv.ptr, Uniform> - spv.GlobalVariable @emptyStruct : !spv.ptr, Uniform> + // CHECK: spirv.GlobalVariable @emptyStruct : !spirv.ptr, Uniform> + spirv.GlobalVariable @emptyStruct : !spirv.ptr, Uniform> } // ----- -spv.module Logical GLSL450 { - // CHECK: spv.GlobalVariable @var0 : !spv.ptr, PushConstant> - spv.GlobalVariable @var0 : !spv.ptr, PushConstant> - // CHECK: spv.GlobalVariable @var1 : !spv.ptr, PhysicalStorageBuffer> - spv.GlobalVariable @var1 : !spv.ptr, PhysicalStorageBuffer> +spirv.module Logical GLSL450 { + // CHECK: spirv.GlobalVariable @var0 : !spirv.ptr, PushConstant> + spirv.GlobalVariable @var0 : !spirv.ptr, PushConstant> + // CHECK: spirv.GlobalVariable @var1 : !spirv.ptr, PhysicalStorageBuffer> + spirv.GlobalVariable @var1 : !spirv.ptr, PhysicalStorageBuffer> } diff --git a/mlir/test/Dialect/SPIRV/Transforms/rewrite-inserts.mlir b/mlir/test/Dialect/SPIRV/Transforms/rewrite-inserts.mlir --- a/mlir/test/Dialect/SPIRV/Transforms/rewrite-inserts.mlir +++ b/mlir/test/Dialect/SPIRV/Transforms/rewrite-inserts.mlir @@ -1,31 +1,31 @@ // RUN: mlir-opt -spirv-rewrite-inserts -split-input-file -verify-diagnostics %s -o - | FileCheck %s -spv.module Logical GLSL450 { - spv.func @rewrite(%value0 : f32, %value1 : f32, %value2 : f32, %value3 : i32, %value4: !spv.array<3xf32>) -> vector<3xf32> "None" { - %0 = spv.Undef : vector<3xf32> - // CHECK: spv.CompositeConstruct {{%.*}}, {{%.*}}, {{%.*}} : (f32, f32, f32) -> vector<3xf32> - %1 = spv.CompositeInsert %value0, %0[0 : i32] : f32 into vector<3xf32> - %2 = spv.CompositeInsert %value1, %1[1 : i32] : f32 into vector<3xf32> - %3 = spv.CompositeInsert %value2, %2[2 : i32] : f32 into vector<3xf32> +spirv.module Logical GLSL450 { + spirv.func @rewrite(%value0 : f32, %value1 : f32, %value2 : f32, %value3 : i32, %value4: !spirv.array<3xf32>) -> vector<3xf32> "None" { + %0 = spirv.Undef : vector<3xf32> + // CHECK: spirv.CompositeConstruct {{%.*}}, {{%.*}}, {{%.*}} : (f32, f32, f32) -> vector<3xf32> + %1 = spirv.CompositeInsert %value0, %0[0 : i32] : f32 into vector<3xf32> + %2 = spirv.CompositeInsert %value1, %1[1 : i32] : f32 into vector<3xf32> + %3 = spirv.CompositeInsert %value2, %2[2 : i32] : f32 into vector<3xf32> - %4 = spv.Undef : !spv.array<4xf32> - // CHECK: spv.CompositeConstruct {{%.*}}, {{%.*}}, {{%.*}}, {{%.*}} : (f32, f32, f32, f32) -> !spv.array<4 x f32> - %5 = spv.CompositeInsert %value0, %4[0 : i32] : f32 into !spv.array<4xf32> - %6 = spv.CompositeInsert %value1, %5[1 : i32] : f32 into !spv.array<4xf32> - %7 = spv.CompositeInsert %value2, %6[2 : i32] : f32 into !spv.array<4xf32> - %8 = spv.CompositeInsert %value0, %7[3 : i32] : f32 into !spv.array<4xf32> + %4 = spirv.Undef : !spirv.array<4xf32> + // CHECK: spirv.CompositeConstruct {{%.*}}, {{%.*}}, {{%.*}}, {{%.*}} : (f32, f32, f32, f32) -> !spirv.array<4 x f32> + %5 = spirv.CompositeInsert %value0, %4[0 : i32] : f32 into !spirv.array<4xf32> + %6 = spirv.CompositeInsert %value1, %5[1 : i32] : f32 into !spirv.array<4xf32> + %7 = spirv.CompositeInsert %value2, %6[2 : i32] : f32 into !spirv.array<4xf32> + %8 = spirv.CompositeInsert %value0, %7[3 : i32] : f32 into !spirv.array<4xf32> - %9 = spv.Undef : !spv.struct<(f32, i32, f32)> - // CHECK: spv.CompositeConstruct {{%.*}}, {{%.*}}, {{%.*}} : (f32, i32, f32) -> !spv.struct<(f32, i32, f32)> - %10 = spv.CompositeInsert %value0, %9[0 : i32] : f32 into !spv.struct<(f32, i32, f32)> - %11 = spv.CompositeInsert %value3, %10[1 : i32] : i32 into !spv.struct<(f32, i32, f32)> - %12 = spv.CompositeInsert %value1, %11[2 : i32] : f32 into !spv.struct<(f32, i32, f32)> + %9 = spirv.Undef : !spirv.struct<(f32, i32, f32)> + // CHECK: spirv.CompositeConstruct {{%.*}}, {{%.*}}, {{%.*}} : (f32, i32, f32) -> !spirv.struct<(f32, i32, f32)> + %10 = spirv.CompositeInsert %value0, %9[0 : i32] : f32 into !spirv.struct<(f32, i32, f32)> + %11 = spirv.CompositeInsert %value3, %10[1 : i32] : i32 into !spirv.struct<(f32, i32, f32)> + %12 = spirv.CompositeInsert %value1, %11[2 : i32] : f32 into !spirv.struct<(f32, i32, f32)> - %13 = spv.Undef : !spv.struct<(f32, !spv.array<3xf32>)> - // CHECK: spv.CompositeConstruct {{%.*}}, {{%.*}} : (f32, !spv.array<3 x f32>) -> !spv.struct<(f32, !spv.array<3 x f32>)> - %14 = spv.CompositeInsert %value0, %13[0 : i32] : f32 into !spv.struct<(f32, !spv.array<3xf32>)> - %15 = spv.CompositeInsert %value4, %14[1 : i32] : !spv.array<3xf32> into !spv.struct<(f32, !spv.array<3xf32>)> + %13 = spirv.Undef : !spirv.struct<(f32, !spirv.array<3xf32>)> + // CHECK: spirv.CompositeConstruct {{%.*}}, {{%.*}} : (f32, !spirv.array<3 x f32>) -> !spirv.struct<(f32, !spirv.array<3 x f32>)> + %14 = spirv.CompositeInsert %value0, %13[0 : i32] : f32 into !spirv.struct<(f32, !spirv.array<3xf32>)> + %15 = spirv.CompositeInsert %value4, %14[1 : i32] : !spirv.array<3xf32> into !spirv.struct<(f32, !spirv.array<3xf32>)> - spv.ReturnValue %3 : vector<3xf32> + spirv.ReturnValue %3 : vector<3xf32> } } diff --git a/mlir/test/Dialect/SPIRV/Transforms/unify-aliased-resource.mlir b/mlir/test/Dialect/SPIRV/Transforms/unify-aliased-resource.mlir --- a/mlir/test/Dialect/SPIRV/Transforms/unify-aliased-resource.mlir +++ b/mlir/test/Dialect/SPIRV/Transforms/unify-aliased-resource.mlir @@ -1,450 +1,450 @@ // RUN: mlir-opt -split-input-file -spirv-unify-aliased-resource -verify-diagnostics %s | FileCheck %s -spv.module Logical GLSL450 { - spv.GlobalVariable @var01s bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @var01v bind(0, 1) {aliased} : !spv.ptr, stride=16> [0])>, StorageBuffer> - - spv.func @load_store_scalar(%index: i32) -> f32 "None" { - %c0 = spv.Constant 0 : i32 - %addr = spv.mlir.addressof @var01s : !spv.ptr [0])>, StorageBuffer> - %ac = spv.AccessChain %addr[%c0, %index] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %value = spv.Load "StorageBuffer" %ac : f32 - spv.Store "StorageBuffer" %ac, %value : f32 - spv.ReturnValue %value : f32 +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var01s bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @var01v bind(0, 1) {aliased} : !spirv.ptr, stride=16> [0])>, StorageBuffer> + + spirv.func @load_store_scalar(%index: i32) -> f32 "None" { + %c0 = spirv.Constant 0 : i32 + %addr = spirv.mlir.addressof @var01s : !spirv.ptr [0])>, StorageBuffer> + %ac = spirv.AccessChain %addr[%c0, %index] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %value = spirv.Load "StorageBuffer" %ac : f32 + spirv.Store "StorageBuffer" %ac, %value : f32 + spirv.ReturnValue %value : f32 } } -// CHECK-LABEL: spv.module +// CHECK-LABEL: spirv.module // CHECK-NOT: @var01s -// CHECK: spv.GlobalVariable @var01v bind(0, 1) : !spv.ptr, stride=16> [0])>, StorageBuffer> +// CHECK: spirv.GlobalVariable @var01v bind(0, 1) : !spirv.ptr, stride=16> [0])>, StorageBuffer> // CHECK-NOT: @var01s -// CHECK: spv.func @load_store_scalar(%[[INDEX:.+]]: i32) -// CHECK-DAG: %[[C0:.+]] = spv.Constant 0 : i32 -// CHECK-DAG: %[[C4:.+]] = spv.Constant 4 : i32 -// CHECK-DAG: %[[ADDR:.+]] = spv.mlir.addressof @var01v -// CHECK: %[[DIV:.+]] = spv.SDiv %[[INDEX]], %[[C4]] : i32 -// CHECK: %[[MOD:.+]] = spv.SMod %[[INDEX]], %[[C4]] : i32 -// CHECK: %[[AC:.+]] = spv.AccessChain %[[ADDR]][%[[C0]], %[[DIV]], %[[MOD]]] -// CHECK: spv.Load "StorageBuffer" %[[AC]] -// CHECK: spv.Store "StorageBuffer" %[[AC]] +// CHECK: spirv.func @load_store_scalar(%[[INDEX:.+]]: i32) +// CHECK-DAG: %[[C0:.+]] = spirv.Constant 0 : i32 +// CHECK-DAG: %[[C4:.+]] = spirv.Constant 4 : i32 +// CHECK-DAG: %[[ADDR:.+]] = spirv.mlir.addressof @var01v +// CHECK: %[[DIV:.+]] = spirv.SDiv %[[INDEX]], %[[C4]] : i32 +// CHECK: %[[MOD:.+]] = spirv.SMod %[[INDEX]], %[[C4]] : i32 +// CHECK: %[[AC:.+]] = spirv.AccessChain %[[ADDR]][%[[C0]], %[[DIV]], %[[MOD]]] +// CHECK: spirv.Load "StorageBuffer" %[[AC]] +// CHECK: spirv.Store "StorageBuffer" %[[AC]] // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var01s bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @var01v bind(0, 1) {aliased} : !spv.ptr, stride=16> [0])>, StorageBuffer> - - spv.func @multiple_uses(%i0: i32, %i1: i32) -> f32 "None" { - %c0 = spv.Constant 0 : i32 - %addr = spv.mlir.addressof @var01s : !spv.ptr [0])>, StorageBuffer> - %ac0 = spv.AccessChain %addr[%c0, %i0] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %val0 = spv.Load "StorageBuffer" %ac0 : f32 - %ac1 = spv.AccessChain %addr[%c0, %i1] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %val1 = spv.Load "StorageBuffer" %ac1 : f32 - %value = spv.FAdd %val0, %val1 : f32 - spv.ReturnValue %value : f32 +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var01s bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @var01v bind(0, 1) {aliased} : !spirv.ptr, stride=16> [0])>, StorageBuffer> + + spirv.func @multiple_uses(%i0: i32, %i1: i32) -> f32 "None" { + %c0 = spirv.Constant 0 : i32 + %addr = spirv.mlir.addressof @var01s : !spirv.ptr [0])>, StorageBuffer> + %ac0 = spirv.AccessChain %addr[%c0, %i0] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %val0 = spirv.Load "StorageBuffer" %ac0 : f32 + %ac1 = spirv.AccessChain %addr[%c0, %i1] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %val1 = spirv.Load "StorageBuffer" %ac1 : f32 + %value = spirv.FAdd %val0, %val1 : f32 + spirv.ReturnValue %value : f32 } } -// CHECK-LABEL: spv.module +// CHECK-LABEL: spirv.module // CHECK-NOT: @var01s -// CHECK: spv.GlobalVariable @var01v bind(0, 1) : !spv.ptr, stride=16> [0])>, StorageBuffer> +// CHECK: spirv.GlobalVariable @var01v bind(0, 1) : !spirv.ptr, stride=16> [0])>, StorageBuffer> // CHECK-NOT: @var01s -// CHECK: spv.func @multiple_uses -// CHECK: %[[ADDR:.+]] = spv.mlir.addressof @var01v -// CHECK: spv.AccessChain %[[ADDR]][%{{.+}}, %{{.+}}, %{{.+}}] -// CHECK: spv.AccessChain %[[ADDR]][%{{.+}}, %{{.+}}, %{{.+}}] +// CHECK: spirv.func @multiple_uses +// CHECK: %[[ADDR:.+]] = spirv.mlir.addressof @var01v +// CHECK: spirv.AccessChain %[[ADDR]][%{{.+}}, %{{.+}}, %{{.+}}] +// CHECK: spirv.AccessChain %[[ADDR]][%{{.+}}, %{{.+}}, %{{.+}}] // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var01s bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @var01v bind(0, 1) {aliased} : !spv.ptr, stride=16> [0])>, StorageBuffer> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var01s bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @var01v bind(0, 1) {aliased} : !spirv.ptr, stride=16> [0])>, StorageBuffer> - spv.func @vector3(%index: i32) -> f32 "None" { - %c0 = spv.Constant 0 : i32 - %addr = spv.mlir.addressof @var01s : !spv.ptr [0])>, StorageBuffer> - %ac = spv.AccessChain %addr[%c0, %index] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %value = spv.Load "StorageBuffer" %ac : f32 - spv.ReturnValue %value : f32 + spirv.func @vector3(%index: i32) -> f32 "None" { + %c0 = spirv.Constant 0 : i32 + %addr = spirv.mlir.addressof @var01s : !spirv.ptr [0])>, StorageBuffer> + %ac = spirv.AccessChain %addr[%c0, %index] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %value = spirv.Load "StorageBuffer" %ac : f32 + spirv.ReturnValue %value : f32 } } -// CHECK-LABEL: spv.module +// CHECK-LABEL: spirv.module -// CHECK: spv.GlobalVariable @var01s bind(0, 1) {aliased} -// CHECK: spv.GlobalVariable @var01v bind(0, 1) {aliased} -// CHECK: spv.func @vector3 +// CHECK: spirv.GlobalVariable @var01s bind(0, 1) {aliased} +// CHECK: spirv.GlobalVariable @var01v bind(0, 1) {aliased} +// CHECK: spirv.func @vector3 // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var01s bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @var01v bind(1, 0) {aliased} : !spv.ptr, stride=16> [0])>, StorageBuffer> - - spv.func @not_aliased(%index: i32) -> f32 "None" { - %c0 = spv.Constant 0 : i32 - %addr = spv.mlir.addressof @var01s : !spv.ptr [0])>, StorageBuffer> - %ac = spv.AccessChain %addr[%c0, %index] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %value = spv.Load "StorageBuffer" %ac : f32 - spv.Store "StorageBuffer" %ac, %value : f32 - spv.ReturnValue %value : f32 +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var01s bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @var01v bind(1, 0) {aliased} : !spirv.ptr, stride=16> [0])>, StorageBuffer> + + spirv.func @not_aliased(%index: i32) -> f32 "None" { + %c0 = spirv.Constant 0 : i32 + %addr = spirv.mlir.addressof @var01s : !spirv.ptr [0])>, StorageBuffer> + %ac = spirv.AccessChain %addr[%c0, %index] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %value = spirv.Load "StorageBuffer" %ac : f32 + spirv.Store "StorageBuffer" %ac, %value : f32 + spirv.ReturnValue %value : f32 } } -// CHECK-LABEL: spv.module +// CHECK-LABEL: spirv.module -// CHECK: spv.GlobalVariable @var01s bind(0, 1) : !spv.ptr [0])>, StorageBuffer> -// CHECK: spv.GlobalVariable @var01v bind(1, 0) : !spv.ptr, stride=16> [0])>, StorageBuffer> -// CHECK: spv.func @not_aliased +// CHECK: spirv.GlobalVariable @var01s bind(0, 1) : !spirv.ptr [0])>, StorageBuffer> +// CHECK: spirv.GlobalVariable @var01v bind(1, 0) : !spirv.ptr, stride=16> [0])>, StorageBuffer> +// CHECK: spirv.func @not_aliased // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var01s bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @var01s_1 bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @var01v bind(0, 1) {aliased} : !spv.ptr, stride=16> [0])>, StorageBuffer> - spv.GlobalVariable @var01v_1 bind(0, 1) {aliased} : !spv.ptr, stride=16> [0])>, StorageBuffer> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var01s bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @var01s_1 bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @var01v bind(0, 1) {aliased} : !spirv.ptr, stride=16> [0])>, StorageBuffer> + spirv.GlobalVariable @var01v_1 bind(0, 1) {aliased} : !spirv.ptr, stride=16> [0])>, StorageBuffer> - spv.func @multiple_aliases(%index: i32) -> f32 "None" { - %c0 = spv.Constant 0 : i32 + spirv.func @multiple_aliases(%index: i32) -> f32 "None" { + %c0 = spirv.Constant 0 : i32 - %addr0 = spv.mlir.addressof @var01s : !spv.ptr [0])>, StorageBuffer> - %ac0 = spv.AccessChain %addr0[%c0, %index] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %val0 = spv.Load "StorageBuffer" %ac0 : f32 + %addr0 = spirv.mlir.addressof @var01s : !spirv.ptr [0])>, StorageBuffer> + %ac0 = spirv.AccessChain %addr0[%c0, %index] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %val0 = spirv.Load "StorageBuffer" %ac0 : f32 - %addr1 = spv.mlir.addressof @var01s_1 : !spv.ptr [0])>, StorageBuffer> - %ac1 = spv.AccessChain %addr1[%c0, %index] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %val1 = spv.Load "StorageBuffer" %ac1 : f32 + %addr1 = spirv.mlir.addressof @var01s_1 : !spirv.ptr [0])>, StorageBuffer> + %ac1 = spirv.AccessChain %addr1[%c0, %index] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %val1 = spirv.Load "StorageBuffer" %ac1 : f32 - %addr2 = spv.mlir.addressof @var01v_1 : !spv.ptr, stride=16> [0])>, StorageBuffer> - %ac2 = spv.AccessChain %addr2[%c0, %index, %c0] : !spv.ptr, stride=16> [0])>, StorageBuffer>, i32, i32, i32 - %val2 = spv.Load "StorageBuffer" %ac2 : f32 + %addr2 = spirv.mlir.addressof @var01v_1 : !spirv.ptr, stride=16> [0])>, StorageBuffer> + %ac2 = spirv.AccessChain %addr2[%c0, %index, %c0] : !spirv.ptr, stride=16> [0])>, StorageBuffer>, i32, i32, i32 + %val2 = spirv.Load "StorageBuffer" %ac2 : f32 - %add0 = spv.FAdd %val0, %val1 : f32 - %add1 = spv.FAdd %add0, %val2 : f32 - spv.ReturnValue %add1 : f32 + %add0 = spirv.FAdd %val0, %val1 : f32 + %add1 = spirv.FAdd %add0, %val2 : f32 + spirv.ReturnValue %add1 : f32 } } -// CHECK-LABEL: spv.module +// CHECK-LABEL: spirv.module // CHECK-NOT: @var01s -// CHECK: spv.GlobalVariable @var01v bind(0, 1) : !spv.ptr, stride=16> [0])>, StorageBuffer> +// CHECK: spirv.GlobalVariable @var01v bind(0, 1) : !spirv.ptr, stride=16> [0])>, StorageBuffer> // CHECK-NOT: @var01v_1 -// CHECK: spv.func @multiple_aliases -// CHECK: %[[ADDR0:.+]] = spv.mlir.addressof @var01v : -// CHECK: spv.AccessChain %[[ADDR0]][%{{.+}}, %{{.+}}, %{{.+}}] -// CHECK: %[[ADDR1:.+]] = spv.mlir.addressof @var01v : -// CHECK: spv.AccessChain %[[ADDR1]][%{{.+}}, %{{.+}}, %{{.+}}] -// CHECK: %[[ADDR2:.+]] = spv.mlir.addressof @var01v : -// CHECK: spv.AccessChain %[[ADDR2]][%{{.+}}, %{{.+}}, %{{.+}}] +// CHECK: spirv.func @multiple_aliases +// CHECK: %[[ADDR0:.+]] = spirv.mlir.addressof @var01v : +// CHECK: spirv.AccessChain %[[ADDR0]][%{{.+}}, %{{.+}}, %{{.+}}] +// CHECK: %[[ADDR1:.+]] = spirv.mlir.addressof @var01v : +// CHECK: spirv.AccessChain %[[ADDR1]][%{{.+}}, %{{.+}}, %{{.+}}] +// CHECK: %[[ADDR2:.+]] = spirv.mlir.addressof @var01v : +// CHECK: spirv.AccessChain %[[ADDR2]][%{{.+}}, %{{.+}}, %{{.+}}] // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var01s_i32 bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @var01s_f32 bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var01s_i32 bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @var01s_f32 bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> - spv.func @different_scalar_type(%index: i32, %val1: f32) -> i32 "None" { - %c0 = spv.Constant 0 : i32 + spirv.func @different_scalar_type(%index: i32, %val1: f32) -> i32 "None" { + %c0 = spirv.Constant 0 : i32 - %addr0 = spv.mlir.addressof @var01s_i32 : !spv.ptr [0])>, StorageBuffer> - %ac0 = spv.AccessChain %addr0[%c0, %index] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %val0 = spv.Load "StorageBuffer" %ac0 : i32 + %addr0 = spirv.mlir.addressof @var01s_i32 : !spirv.ptr [0])>, StorageBuffer> + %ac0 = spirv.AccessChain %addr0[%c0, %index] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %val0 = spirv.Load "StorageBuffer" %ac0 : i32 - %addr1 = spv.mlir.addressof @var01s_f32 : !spv.ptr [0])>, StorageBuffer> - %ac1 = spv.AccessChain %addr1[%c0, %index] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - spv.Store "StorageBuffer" %ac1, %val1 : f32 + %addr1 = spirv.mlir.addressof @var01s_f32 : !spirv.ptr [0])>, StorageBuffer> + %ac1 = spirv.AccessChain %addr1[%c0, %index] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + spirv.Store "StorageBuffer" %ac1, %val1 : f32 - spv.ReturnValue %val0 : i32 + spirv.ReturnValue %val0 : i32 } } -// CHECK-LABEL: spv.module +// CHECK-LABEL: spirv.module // CHECK-NOT: @var01s_f32 -// CHECK: spv.GlobalVariable @var01s_i32 bind(0, 1) : !spv.ptr [0])>, StorageBuffer> +// CHECK: spirv.GlobalVariable @var01s_i32 bind(0, 1) : !spirv.ptr [0])>, StorageBuffer> // CHECK-NOT: @var01s_f32 -// CHECK: spv.func @different_scalar_type(%[[INDEX:.+]]: i32, %[[VAL1:.+]]: f32) +// CHECK: spirv.func @different_scalar_type(%[[INDEX:.+]]: i32, %[[VAL1:.+]]: f32) -// CHECK: %[[IADDR:.+]] = spv.mlir.addressof @var01s_i32 -// CHECK: %[[IAC:.+]] = spv.AccessChain %[[IADDR]][%{{.+}}, %[[INDEX]]] -// CHECK: spv.Load "StorageBuffer" %[[IAC]] : i32 +// CHECK: %[[IADDR:.+]] = spirv.mlir.addressof @var01s_i32 +// CHECK: %[[IAC:.+]] = spirv.AccessChain %[[IADDR]][%{{.+}}, %[[INDEX]]] +// CHECK: spirv.Load "StorageBuffer" %[[IAC]] : i32 -// CHECK: %[[FADDR:.+]] = spv.mlir.addressof @var01s_i32 -// CHECK: %[[FAC:.+]] = spv.AccessChain %[[FADDR]][%cst0_i32, %[[INDEX]]] -// CHECK: %[[CAST:.+]] = spv.Bitcast %[[VAL1]] : f32 to i32 -// CHECK: spv.Store "StorageBuffer" %[[FAC]], %[[CAST]] : i32 +// CHECK: %[[FADDR:.+]] = spirv.mlir.addressof @var01s_i32 +// CHECK: %[[FAC:.+]] = spirv.AccessChain %[[FADDR]][%cst0_i32, %[[INDEX]]] +// CHECK: %[[CAST:.+]] = spirv.Bitcast %[[VAL1]] : f32 to i32 +// CHECK: spirv.Store "StorageBuffer" %[[FAC]], %[[CAST]] : i32 // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var01s bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @var01v bind(0, 1) {aliased} : !spv.ptr, stride=16> [0])>, StorageBuffer> - - spv.func @different_primitive_type(%index: i32, %val0: i32) -> i32 "None" { - %c0 = spv.Constant 0 : i32 - %addr = spv.mlir.addressof @var01s : !spv.ptr [0])>, StorageBuffer> - %ac = spv.AccessChain %addr[%c0, %index] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %val1 = spv.Load "StorageBuffer" %ac : i32 - spv.Store "StorageBuffer" %ac, %val0 : i32 - spv.ReturnValue %val1 : i32 +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var01s bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @var01v bind(0, 1) {aliased} : !spirv.ptr, stride=16> [0])>, StorageBuffer> + + spirv.func @different_primitive_type(%index: i32, %val0: i32) -> i32 "None" { + %c0 = spirv.Constant 0 : i32 + %addr = spirv.mlir.addressof @var01s : !spirv.ptr [0])>, StorageBuffer> + %ac = spirv.AccessChain %addr[%c0, %index] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %val1 = spirv.Load "StorageBuffer" %ac : i32 + spirv.Store "StorageBuffer" %ac, %val0 : i32 + spirv.ReturnValue %val1 : i32 } } -// CHECK-LABEL: spv.module +// CHECK-LABEL: spirv.module // CHECK-NOT: @var01s -// CHECK: spv.GlobalVariable @var01v bind(0, 1) : !spv.ptr, stride=16> [0])>, StorageBuffer> +// CHECK: spirv.GlobalVariable @var01v bind(0, 1) : !spirv.ptr, stride=16> [0])>, StorageBuffer> // CHECK-NOT: @var01s -// CHECK: spv.func @different_primitive_type(%{{.+}}: i32, %[[VAL0:.+]]: i32) -// CHECK: %[[ADDR:.+]] = spv.mlir.addressof @var01v -// CHECK: %[[AC:.+]] = spv.AccessChain %[[ADDR]][%{{.+}}, %{{.+}}, %{{.+}}] -// CHECK: %[[VAL1:.+]] = spv.Load "StorageBuffer" %[[AC]] : f32 -// CHECK: %[[CAST1:.+]] = spv.Bitcast %[[VAL1]] : f32 to i32 -// CHECK: %[[CAST2:.+]] = spv.Bitcast %[[VAL0]] : i32 to f32 -// CHECK: spv.Store "StorageBuffer" %[[AC]], %[[CAST2]] : f32 -// CHECK: spv.ReturnValue %[[CAST1]] : i32 +// CHECK: spirv.func @different_primitive_type(%{{.+}}: i32, %[[VAL0:.+]]: i32) +// CHECK: %[[ADDR:.+]] = spirv.mlir.addressof @var01v +// CHECK: %[[AC:.+]] = spirv.AccessChain %[[ADDR]][%{{.+}}, %{{.+}}, %{{.+}}] +// CHECK: %[[VAL1:.+]] = spirv.Load "StorageBuffer" %[[AC]] : f32 +// CHECK: %[[CAST1:.+]] = spirv.Bitcast %[[VAL1]] : f32 to i32 +// CHECK: %[[CAST2:.+]] = spirv.Bitcast %[[VAL0]] : i32 to f32 +// CHECK: spirv.Store "StorageBuffer" %[[AC]], %[[CAST2]] : f32 +// CHECK: spirv.ReturnValue %[[CAST1]] : i32 // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var01s_i64 bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @var01s_f32 bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var01s_i64 bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @var01s_f32 bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> - spv.func @load_different_scalar_bitwidth(%index: i32) -> i64 "None" { - %c0 = spv.Constant 0 : i32 + spirv.func @load_different_scalar_bitwidth(%index: i32) -> i64 "None" { + %c0 = spirv.Constant 0 : i32 - %addr0 = spv.mlir.addressof @var01s_i64 : !spv.ptr [0])>, StorageBuffer> - %ac0 = spv.AccessChain %addr0[%c0, %index] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %val0 = spv.Load "StorageBuffer" %ac0 : i64 + %addr0 = spirv.mlir.addressof @var01s_i64 : !spirv.ptr [0])>, StorageBuffer> + %ac0 = spirv.AccessChain %addr0[%c0, %index] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %val0 = spirv.Load "StorageBuffer" %ac0 : i64 - spv.ReturnValue %val0 : i64 + spirv.ReturnValue %val0 : i64 } } -// CHECK-LABEL: spv.module +// CHECK-LABEL: spirv.module // CHECK-NOT: @var01s_i64 -// CHECK: spv.GlobalVariable @var01s_f32 bind(0, 1) : !spv.ptr [0])>, StorageBuffer> +// CHECK: spirv.GlobalVariable @var01s_f32 bind(0, 1) : !spirv.ptr [0])>, StorageBuffer> // CHECK-NOT: @var01s_i64 -// CHECK: spv.func @load_different_scalar_bitwidth(%[[INDEX:.+]]: i32) -// CHECK: %[[ZERO:.+]] = spv.Constant 0 : i32 -// CHECK: %[[ADDR:.+]] = spv.mlir.addressof @var01s_f32 +// CHECK: spirv.func @load_different_scalar_bitwidth(%[[INDEX:.+]]: i32) +// CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32 +// CHECK: %[[ADDR:.+]] = spirv.mlir.addressof @var01s_f32 -// CHECK: %[[TWO:.+]] = spv.Constant 2 : i32 -// CHECK: %[[BASE:.+]] = spv.IMul %[[INDEX]], %[[TWO]] : i32 -// CHECK: %[[AC0:.+]] = spv.AccessChain %[[ADDR]][%[[ZERO]], %[[BASE]]] -// CHECK: %[[LOAD0:.+]] = spv.Load "StorageBuffer" %[[AC0]] : f32 +// CHECK: %[[TWO:.+]] = spirv.Constant 2 : i32 +// CHECK: %[[BASE:.+]] = spirv.IMul %[[INDEX]], %[[TWO]] : i32 +// CHECK: %[[AC0:.+]] = spirv.AccessChain %[[ADDR]][%[[ZERO]], %[[BASE]]] +// CHECK: %[[LOAD0:.+]] = spirv.Load "StorageBuffer" %[[AC0]] : f32 -// CHECK: %[[ONE:.+]] = spv.Constant 1 : i32 -// CHECK: %[[ADD:.+]] = spv.IAdd %[[BASE]], %[[ONE]] : i32 -// CHECK: %[[AC1:.+]] = spv.AccessChain %[[ADDR]][%[[ZERO]], %[[ADD]]] -// CHECK: %[[LOAD1:.+]] = spv.Load "StorageBuffer" %[[AC1]] : f32 +// CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32 +// CHECK: %[[ADD:.+]] = spirv.IAdd %[[BASE]], %[[ONE]] : i32 +// CHECK: %[[AC1:.+]] = spirv.AccessChain %[[ADDR]][%[[ZERO]], %[[ADD]]] +// CHECK: %[[LOAD1:.+]] = spirv.Load "StorageBuffer" %[[AC1]] : f32 -// CHECK: %[[CC:.+]] = spv.CompositeConstruct %[[LOAD0]], %[[LOAD1]] -// CHECK: %[[CAST:.+]] = spv.Bitcast %[[CC]] : vector<2xf32> to i64 -// CHECK: spv.ReturnValue %[[CAST]] +// CHECK: %[[CC:.+]] = spirv.CompositeConstruct %[[LOAD0]], %[[LOAD1]] +// CHECK: %[[CAST:.+]] = spirv.Bitcast %[[CC]] : vector<2xf32> to i64 +// CHECK: spirv.ReturnValue %[[CAST]] // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var01s_i64 bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @var01s_f32 bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var01s_i64 bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @var01s_f32 bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> - spv.func @store_different_scalar_bitwidth(%i0: i32, %i1: i32) "None" { - %c0 = spv.Constant 0 : i32 + spirv.func @store_different_scalar_bitwidth(%i0: i32, %i1: i32) "None" { + %c0 = spirv.Constant 0 : i32 - %addr0 = spv.mlir.addressof @var01s_f32 : !spv.ptr [0])>, StorageBuffer> - %ac0 = spv.AccessChain %addr0[%c0, %i0] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %f32val = spv.Load "StorageBuffer" %ac0 : f32 - %f64val = spv.FConvert %f32val : f32 to f64 - %i64val = spv.Bitcast %f64val : f64 to i64 + %addr0 = spirv.mlir.addressof @var01s_f32 : !spirv.ptr [0])>, StorageBuffer> + %ac0 = spirv.AccessChain %addr0[%c0, %i0] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %f32val = spirv.Load "StorageBuffer" %ac0 : f32 + %f64val = spirv.FConvert %f32val : f32 to f64 + %i64val = spirv.Bitcast %f64val : f64 to i64 - %addr1 = spv.mlir.addressof @var01s_i64 : !spv.ptr [0])>, StorageBuffer> - %ac1 = spv.AccessChain %addr1[%c0, %i1] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - // expected-error@+1 {{failed to legalize operation 'spv.Store'}} - spv.Store "StorageBuffer" %ac1, %i64val : i64 + %addr1 = spirv.mlir.addressof @var01s_i64 : !spirv.ptr [0])>, StorageBuffer> + %ac1 = spirv.AccessChain %addr1[%c0, %i1] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + // expected-error@+1 {{failed to legalize operation 'spirv.Store'}} + spirv.Store "StorageBuffer" %ac1, %i64val : i64 - spv.Return + spirv.Return } } // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var01_scalar bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @var01_vec2 bind(0, 1) {aliased} : !spv.ptr, stride=8> [0])>, StorageBuffer> - spv.GlobalVariable @var01_vec4 bind(0, 1) {aliased} : !spv.ptr, stride=16> [0])>, StorageBuffer> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var01_scalar bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @var01_vec2 bind(0, 1) {aliased} : !spirv.ptr, stride=8> [0])>, StorageBuffer> + spirv.GlobalVariable @var01_vec4 bind(0, 1) {aliased} : !spirv.ptr, stride=16> [0])>, StorageBuffer> - spv.func @load_different_vector_sizes(%i0: i32) -> vector<4xf32> "None" { - %c0 = spv.Constant 0 : i32 + spirv.func @load_different_vector_sizes(%i0: i32) -> vector<4xf32> "None" { + %c0 = spirv.Constant 0 : i32 - %addr0 = spv.mlir.addressof @var01_vec4 : !spv.ptr, stride=16> [0])>, StorageBuffer> - %ac0 = spv.AccessChain %addr0[%c0, %i0] : !spv.ptr, stride=16> [0])>, StorageBuffer>, i32, i32 - %vec4val = spv.Load "StorageBuffer" %ac0 : vector<4xf32> + %addr0 = spirv.mlir.addressof @var01_vec4 : !spirv.ptr, stride=16> [0])>, StorageBuffer> + %ac0 = spirv.AccessChain %addr0[%c0, %i0] : !spirv.ptr, stride=16> [0])>, StorageBuffer>, i32, i32 + %vec4val = spirv.Load "StorageBuffer" %ac0 : vector<4xf32> - %addr1 = spv.mlir.addressof @var01_scalar : !spv.ptr [0])>, StorageBuffer> - %ac1 = spv.AccessChain %addr1[%c0, %i0] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %scalarval = spv.Load "StorageBuffer" %ac1 : f32 + %addr1 = spirv.mlir.addressof @var01_scalar : !spirv.ptr [0])>, StorageBuffer> + %ac1 = spirv.AccessChain %addr1[%c0, %i0] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %scalarval = spirv.Load "StorageBuffer" %ac1 : f32 - %val = spv.CompositeInsert %scalarval, %vec4val[0 : i32] : f32 into vector<4xf32> - spv.ReturnValue %val : vector<4xf32> + %val = spirv.CompositeInsert %scalarval, %vec4val[0 : i32] : f32 into vector<4xf32> + spirv.ReturnValue %val : vector<4xf32> } } -// CHECK-LABEL: spv.module +// CHECK-LABEL: spirv.module // CHECK-NOT: @var01_scalar // CHECK-NOT: @var01_vec4 -// CHECK: spv.GlobalVariable @var01_vec2 bind(0, 1) : !spv.ptr<{{.+}}> +// CHECK: spirv.GlobalVariable @var01_vec2 bind(0, 1) : !spirv.ptr<{{.+}}> // CHECK-NOT: @var01_scalar // CHECK-NOT: @var01_vec4 -// CHECK: spv.func @load_different_vector_sizes(%[[IDX:.+]]: i32) -// CHECK: %[[ZERO:.+]] = spv.Constant 0 : i32 -// CHECK: %[[ADDR:.+]] = spv.mlir.addressof @var01_vec2 -// CHECK: %[[TWO:.+]] = spv.Constant 2 : i32 -// CHECK: %[[IDX0:.+]] = spv.IMul %[[IDX]], %[[TWO]] : i32 -// CHECK: %[[AC0:.+]] = spv.AccessChain %[[ADDR]][%[[ZERO]], %[[IDX0]]] -// CHECK: %[[LD0:.+]] = spv.Load "StorageBuffer" %[[AC0]] : vector<2xf32> -// CHECK: %[[ONE:.+]] = spv.Constant 1 : i32 -// CHECK: %[[IDX1:.+]] = spv.IAdd %0, %[[ONE]] : i32 -// CHECK: %[[AC1:.+]] = spv.AccessChain %[[ADDR]][%[[ZERO]], %[[IDX1]]] -// CHECK: %[[LD1:.+]] = spv.Load "StorageBuffer" %[[AC1]] : vector<2xf32> -// CHECK: spv.CompositeConstruct %[[LD0]], %[[LD1]] : (vector<2xf32>, vector<2xf32>) -> vector<4xf32> - -// CHECK: %[[ADDR:.+]] = spv.mlir.addressof @var01_vec2 -// CHECK: %[[TWO:.+]] = spv.Constant 2 : i32 -// CHECK: %[[DIV:.+]] = spv.SDiv %[[IDX]], %[[TWO]] : i32 -// CHECK: %[[MOD:.+]] = spv.SMod %[[IDX]], %[[TWO]] : i32 -// CHECK: %[[AC:.+]] = spv.AccessChain %[[ADDR]][%[[ZERO]], %[[DIV]], %[[MOD]]] -// CHECK: %[[LD:.+]] = spv.Load "StorageBuffer" %[[AC]] : f32 +// CHECK: spirv.func @load_different_vector_sizes(%[[IDX:.+]]: i32) +// CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32 +// CHECK: %[[ADDR:.+]] = spirv.mlir.addressof @var01_vec2 +// CHECK: %[[TWO:.+]] = spirv.Constant 2 : i32 +// CHECK: %[[IDX0:.+]] = spirv.IMul %[[IDX]], %[[TWO]] : i32 +// CHECK: %[[AC0:.+]] = spirv.AccessChain %[[ADDR]][%[[ZERO]], %[[IDX0]]] +// CHECK: %[[LD0:.+]] = spirv.Load "StorageBuffer" %[[AC0]] : vector<2xf32> +// CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32 +// CHECK: %[[IDX1:.+]] = spirv.IAdd %0, %[[ONE]] : i32 +// CHECK: %[[AC1:.+]] = spirv.AccessChain %[[ADDR]][%[[ZERO]], %[[IDX1]]] +// CHECK: %[[LD1:.+]] = spirv.Load "StorageBuffer" %[[AC1]] : vector<2xf32> +// CHECK: spirv.CompositeConstruct %[[LD0]], %[[LD1]] : (vector<2xf32>, vector<2xf32>) -> vector<4xf32> + +// CHECK: %[[ADDR:.+]] = spirv.mlir.addressof @var01_vec2 +// CHECK: %[[TWO:.+]] = spirv.Constant 2 : i32 +// CHECK: %[[DIV:.+]] = spirv.SDiv %[[IDX]], %[[TWO]] : i32 +// CHECK: %[[MOD:.+]] = spirv.SMod %[[IDX]], %[[TWO]] : i32 +// CHECK: %[[AC:.+]] = spirv.AccessChain %[[ADDR]][%[[ZERO]], %[[DIV]], %[[MOD]]] +// CHECK: %[[LD:.+]] = spirv.Load "StorageBuffer" %[[AC]] : f32 // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var01_v4f32 bind(0, 1) {aliased} : !spv.ptr, stride=16> [0])>, StorageBuffer> - spv.GlobalVariable @var01_f32 bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @var01_i64 bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var01_v4f32 bind(0, 1) {aliased} : !spirv.ptr, stride=16> [0])>, StorageBuffer> + spirv.GlobalVariable @var01_f32 bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @var01_i64 bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> - spv.func @load_mixed_scalar_vector_primitive_types(%i0: i32) -> vector<4xf32> "None" { - %c0 = spv.Constant 0 : i32 + spirv.func @load_mixed_scalar_vector_primitive_types(%i0: i32) -> vector<4xf32> "None" { + %c0 = spirv.Constant 0 : i32 - %addr0 = spv.mlir.addressof @var01_v4f32 : !spv.ptr, stride=16> [0])>, StorageBuffer> - %ac0 = spv.AccessChain %addr0[%c0, %i0] : !spv.ptr, stride=16> [0])>, StorageBuffer>, i32, i32 - %vec4val = spv.Load "StorageBuffer" %ac0 : vector<4xf32> + %addr0 = spirv.mlir.addressof @var01_v4f32 : !spirv.ptr, stride=16> [0])>, StorageBuffer> + %ac0 = spirv.AccessChain %addr0[%c0, %i0] : !spirv.ptr, stride=16> [0])>, StorageBuffer>, i32, i32 + %vec4val = spirv.Load "StorageBuffer" %ac0 : vector<4xf32> - %addr1 = spv.mlir.addressof @var01_f32 : !spv.ptr [0])>, StorageBuffer> - %ac1 = spv.AccessChain %addr1[%c0, %i0] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %f32val = spv.Load "StorageBuffer" %ac1 : f32 + %addr1 = spirv.mlir.addressof @var01_f32 : !spirv.ptr [0])>, StorageBuffer> + %ac1 = spirv.AccessChain %addr1[%c0, %i0] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %f32val = spirv.Load "StorageBuffer" %ac1 : f32 - %addr2 = spv.mlir.addressof @var01_i64 : !spv.ptr [0])>, StorageBuffer> - %ac2 = spv.AccessChain %addr2[%c0, %i0] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %i64val = spv.Load "StorageBuffer" %ac2 : i64 - %i32val = spv.SConvert %i64val : i64 to i32 - %castval = spv.Bitcast %i32val : i32 to f32 + %addr2 = spirv.mlir.addressof @var01_i64 : !spirv.ptr [0])>, StorageBuffer> + %ac2 = spirv.AccessChain %addr2[%c0, %i0] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %i64val = spirv.Load "StorageBuffer" %ac2 : i64 + %i32val = spirv.SConvert %i64val : i64 to i32 + %castval = spirv.Bitcast %i32val : i32 to f32 - %val1 = spv.CompositeInsert %f32val, %vec4val[0 : i32] : f32 into vector<4xf32> - %val2 = spv.CompositeInsert %castval, %val1[1 : i32] : f32 into vector<4xf32> - spv.ReturnValue %val2 : vector<4xf32> + %val1 = spirv.CompositeInsert %f32val, %vec4val[0 : i32] : f32 into vector<4xf32> + %val2 = spirv.CompositeInsert %castval, %val1[1 : i32] : f32 into vector<4xf32> + spirv.ReturnValue %val2 : vector<4xf32> } } -// CHECK-LABEL: spv.module +// CHECK-LABEL: spirv.module // CHECK-NOT: @var01_f32 // CHECK-NOT: @var01_i64 -// CHECK: spv.GlobalVariable @var01_v4f32 bind(0, 1) : !spv.ptr<{{.+}}> +// CHECK: spirv.GlobalVariable @var01_v4f32 bind(0, 1) : !spirv.ptr<{{.+}}> // CHECK-NOT: @var01_f32 // CHECK-NOT: @var01_i64 -// CHECK: spv.func @load_mixed_scalar_vector_primitive_types(%[[IDX:.+]]: i32) - -// CHECK: %[[ZERO:.+]] = spv.Constant 0 : i32 -// CHECK: %[[ADDR0:.+]] = spv.mlir.addressof @var01_v4f32 -// CHECK: %[[AC0:.+]] = spv.AccessChain %[[ADDR0]][%[[ZERO]], %[[IDX]]] -// CHECK: spv.Load "StorageBuffer" %[[AC0]] : vector<4xf32> - -// CHECK: %[[ADDR1:.+]] = spv.mlir.addressof @var01_v4f32 -// CHECK: %[[FOUR:.+]] = spv.Constant 4 : i32 -// CHECK: %[[DIV:.+]] = spv.SDiv %[[IDX]], %[[FOUR]] : i32 -// CHECK: %[[MOD:.+]] = spv.SMod %[[IDX]], %[[FOUR]] : i32 -// CHECK: %[[AC1:.+]] = spv.AccessChain %[[ADDR1]][%[[ZERO]], %[[DIV]], %[[MOD]]] -// CHECK: spv.Load "StorageBuffer" %[[AC1]] : f32 - -// CHECK: %[[ADDR2:.+]] = spv.mlir.addressof @var01_v4f32 -// CHECK: %[[TWO:.+]] = spv.Constant 2 : i32 -// CHECK: %[[DIV0:.+]] = spv.SDiv %[[IDX]], %[[TWO]] : i32 -// CHECK: %[[MOD0:.+]] = spv.SMod %[[IDX]], %[[TWO]] : i32 -// CHECK: %[[AC2:.+]] = spv.AccessChain %[[ADDR2]][%[[ZERO]], %[[DIV0]], %[[MOD0]]] -// CHECK: %[[LD0:.+]] = spv.Load "StorageBuffer" %[[AC2]] : f32 - -// CHECK: %[[ONE:.+]] = spv.Constant 1 : i32 -// CHECK: %[[MOD1:.+]] = spv.IAdd %[[MOD0]], %[[ONE]] -// CHECK: %[[AC3:.+]] = spv.AccessChain %[[ADDR2]][%[[ZERO]], %[[DIV0]], %[[MOD1]]] -// CHECK: %[[LD1:.+]] = spv.Load "StorageBuffer" %[[AC3]] : f32 -// CHECK: %[[CC:.+]] = spv.CompositeConstruct %[[LD0]], %[[LD1]] -// CHECK: %[[BC:.+]] = spv.Bitcast %[[CC]] : vector<2xf32> to i64 +// CHECK: spirv.func @load_mixed_scalar_vector_primitive_types(%[[IDX:.+]]: i32) + +// CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32 +// CHECK: %[[ADDR0:.+]] = spirv.mlir.addressof @var01_v4f32 +// CHECK: %[[AC0:.+]] = spirv.AccessChain %[[ADDR0]][%[[ZERO]], %[[IDX]]] +// CHECK: spirv.Load "StorageBuffer" %[[AC0]] : vector<4xf32> + +// CHECK: %[[ADDR1:.+]] = spirv.mlir.addressof @var01_v4f32 +// CHECK: %[[FOUR:.+]] = spirv.Constant 4 : i32 +// CHECK: %[[DIV:.+]] = spirv.SDiv %[[IDX]], %[[FOUR]] : i32 +// CHECK: %[[MOD:.+]] = spirv.SMod %[[IDX]], %[[FOUR]] : i32 +// CHECK: %[[AC1:.+]] = spirv.AccessChain %[[ADDR1]][%[[ZERO]], %[[DIV]], %[[MOD]]] +// CHECK: spirv.Load "StorageBuffer" %[[AC1]] : f32 + +// CHECK: %[[ADDR2:.+]] = spirv.mlir.addressof @var01_v4f32 +// CHECK: %[[TWO:.+]] = spirv.Constant 2 : i32 +// CHECK: %[[DIV0:.+]] = spirv.SDiv %[[IDX]], %[[TWO]] : i32 +// CHECK: %[[MOD0:.+]] = spirv.SMod %[[IDX]], %[[TWO]] : i32 +// CHECK: %[[AC2:.+]] = spirv.AccessChain %[[ADDR2]][%[[ZERO]], %[[DIV0]], %[[MOD0]]] +// CHECK: %[[LD0:.+]] = spirv.Load "StorageBuffer" %[[AC2]] : f32 + +// CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32 +// CHECK: %[[MOD1:.+]] = spirv.IAdd %[[MOD0]], %[[ONE]] +// CHECK: %[[AC3:.+]] = spirv.AccessChain %[[ADDR2]][%[[ZERO]], %[[DIV0]], %[[MOD1]]] +// CHECK: %[[LD1:.+]] = spirv.Load "StorageBuffer" %[[AC3]] : f32 +// CHECK: %[[CC:.+]] = spirv.CompositeConstruct %[[LD0]], %[[LD1]] +// CHECK: %[[BC:.+]] = spirv.Bitcast %[[CC]] : vector<2xf32> to i64 // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var01_v2f2 bind(0, 1) {aliased} : !spv.ptr, stride=16> [0])>, StorageBuffer> - spv.GlobalVariable @var01_i64 bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var01_v2f2 bind(0, 1) {aliased} : !spirv.ptr, stride=16> [0])>, StorageBuffer> + spirv.GlobalVariable @var01_i64 bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> - spv.func @load_mixed_scalar_vector_primitive_types(%i0: i32) -> i64 "None" { - %c0 = spv.Constant 0 : i32 + spirv.func @load_mixed_scalar_vector_primitive_types(%i0: i32) -> i64 "None" { + %c0 = spirv.Constant 0 : i32 - %addr = spv.mlir.addressof @var01_i64 : !spv.ptr [0])>, StorageBuffer> - %ac = spv.AccessChain %addr[%c0, %i0] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %val = spv.Load "StorageBuffer" %ac : i64 + %addr = spirv.mlir.addressof @var01_i64 : !spirv.ptr [0])>, StorageBuffer> + %ac = spirv.AccessChain %addr[%c0, %i0] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %val = spirv.Load "StorageBuffer" %ac : i64 - spv.ReturnValue %val : i64 + spirv.ReturnValue %val : i64 } } -// CHECK-LABEL: spv.module +// CHECK-LABEL: spirv.module -// CHECK: spv.func @load_mixed_scalar_vector_primitive_types(%[[IDX:.+]]: i32) +// CHECK: spirv.func @load_mixed_scalar_vector_primitive_types(%[[IDX:.+]]: i32) -// CHECK: %[[ADDR:.+]] = spv.mlir.addressof @var01_v2f2 -// CHECK: %[[ONE:.+]] = spv.Constant 1 : i32 -// CHECK: %[[DIV:.+]] = spv.SDiv %[[IDX]], %[[ONE]] : i32 -// CHECK: %[[MOD:.+]] = spv.SMod %[[IDX]], %[[ONE]] : i32 -// CHECK: spv.AccessChain %[[ADDR]][%{{.+}}, %[[DIV]], %[[MOD]]] -// CHECK: spv.Load -// CHECK: spv.Load +// CHECK: %[[ADDR:.+]] = spirv.mlir.addressof @var01_v2f2 +// CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32 +// CHECK: %[[DIV:.+]] = spirv.SDiv %[[IDX]], %[[ONE]] : i32 +// CHECK: %[[MOD:.+]] = spirv.SMod %[[IDX]], %[[ONE]] : i32 +// CHECK: spirv.AccessChain %[[ADDR]][%{{.+}}, %[[DIV]], %[[MOD]]] +// CHECK: spirv.Load +// CHECK: spirv.Load // ----- -spv.module Logical GLSL450 { - spv.GlobalVariable @var01_v2f2 bind(0, 1) {aliased} : !spv.ptr, stride=16> [0])>, StorageBuffer> - spv.GlobalVariable @var01_i16 bind(0, 1) {aliased} : !spv.ptr [0])>, StorageBuffer> +spirv.module Logical GLSL450 { + spirv.GlobalVariable @var01_v2f2 bind(0, 1) {aliased} : !spirv.ptr, stride=16> [0])>, StorageBuffer> + spirv.GlobalVariable @var01_i16 bind(0, 1) {aliased} : !spirv.ptr [0])>, StorageBuffer> - spv.func @scalar_type_bitwidth_smaller_than_vector(%i0: i32) -> i16 "None" { - %c0 = spv.Constant 0 : i32 + spirv.func @scalar_type_bitwidth_smaller_than_vector(%i0: i32) -> i16 "None" { + %c0 = spirv.Constant 0 : i32 - %addr = spv.mlir.addressof @var01_i16 : !spv.ptr [0])>, StorageBuffer> - %ac = spv.AccessChain %addr[%c0, %i0] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %val = spv.Load "StorageBuffer" %ac : i16 + %addr = spirv.mlir.addressof @var01_i16 : !spirv.ptr [0])>, StorageBuffer> + %ac = spirv.AccessChain %addr[%c0, %i0] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %val = spirv.Load "StorageBuffer" %ac : i16 - spv.ReturnValue %val : i16 + spirv.ReturnValue %val : i16 } } -// CHECK-LABEL: spv.module +// CHECK-LABEL: spirv.module -// CHECK: spv.GlobalVariable @var01_v2f2 bind(0, 1) {aliased} -// CHECK: spv.GlobalVariable @var01_i16 bind(0, 1) {aliased} +// CHECK: spirv.GlobalVariable @var01_v2f2 bind(0, 1) {aliased} +// CHECK: spirv.GlobalVariable @var01_i16 bind(0, 1) {aliased} -// CHECK: spv.func @scalar_type_bitwidth_smaller_than_vector +// CHECK: spirv.func @scalar_type_bitwidth_smaller_than_vector diff --git a/mlir/test/Dialect/SPIRV/Transforms/vce-deduction.mlir b/mlir/test/Dialect/SPIRV/Transforms/vce-deduction.mlir --- a/mlir/test/Dialect/SPIRV/Transforms/vce-deduction.mlir +++ b/mlir/test/Dialect/SPIRV/Transforms/vce-deduction.mlir @@ -5,30 +5,30 @@ //===----------------------------------------------------------------------===// // Test deducing minimal version. -// spv.IAdd is available from v1.0. +// spirv.IAdd is available from v1.0. -// CHECK: requires #spv.vce -spv.module Logical GLSL450 attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> +// CHECK: requires #spirv.vce +spirv.module Logical GLSL450 attributes { + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { - spv.func @iadd(%val : i32) -> i32 "None" { - %0 = spv.IAdd %val, %val: i32 - spv.ReturnValue %0: i32 + spirv.func @iadd(%val : i32) -> i32 "None" { + %0 = spirv.IAdd %val, %val: i32 + spirv.ReturnValue %0: i32 } } // Test deducing minimal version. -// spv.GroupNonUniformBallot is available since v1.3. +// spirv.GroupNonUniformBallot is available since v1.3. -// CHECK: requires #spv.vce -spv.module Logical GLSL450 attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> +// CHECK: requires #spirv.vce +spirv.module Logical GLSL450 attributes { + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { - spv.func @group_non_uniform_ballot(%predicate : i1) -> vector<4xi32> "None" { - %0 = spv.GroupNonUniformBallot %predicate : vector<4xi32> - spv.ReturnValue %0: vector<4xi32> + spirv.func @group_non_uniform_ballot(%predicate : i1) -> vector<4xi32> "None" { + %0 = spirv.GroupNonUniformBallot %predicate : vector<4xi32> + spirv.ReturnValue %0: vector<4xi32> } } @@ -38,45 +38,45 @@ // Test minimal capabilities. -// CHECK: requires #spv.vce -spv.module Logical GLSL450 attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> +// CHECK: requires #spirv.vce +spirv.module Logical GLSL450 attributes { + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { - spv.func @iadd(%val : i32) -> i32 "None" { - %0 = spv.IAdd %val, %val: i32 - spv.ReturnValue %0: i32 + spirv.func @iadd(%val : i32) -> i32 "None" { + %0 = spirv.IAdd %val, %val: i32 + spirv.ReturnValue %0: i32 } } // Test Physical Storage Buffers are deduced correctly. -// CHECK: spv.module PhysicalStorageBuffer64 GLSL450 requires #spv.vce -spv.module PhysicalStorageBuffer64 GLSL450 attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> +// CHECK: spirv.module PhysicalStorageBuffer64 GLSL450 requires #spirv.vce +spirv.module PhysicalStorageBuffer64 GLSL450 attributes { + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { - spv.func @physical_ptr(%val : !spv.ptr) "None" { - spv.Return + spirv.func @physical_ptr(%val : !spirv.ptr) "None" { + spirv.Return } } // Test deducing implied capability. // AtomicStorage implies Shader. -// CHECK: requires #spv.vce -spv.module Logical GLSL450 attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> +// CHECK: requires #spirv.vce +spirv.module Logical GLSL450 attributes { + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { - spv.func @iadd(%val : i32) -> i32 "None" { - %0 = spv.IAdd %val, %val: i32 - spv.ReturnValue %0: i32 + spirv.func @iadd(%val : i32) -> i32 "None" { + %0 = spirv.IAdd %val, %val: i32 + spirv.ReturnValue %0: i32 } } // Test selecting the capability available in the target environment. -// spv.GroupNonUniform op itself can be enabled via any of +// spirv.GroupNonUniform op itself can be enabled via any of // * GroupNonUniformArithmetic // * GroupNonUniformClustered // * GroupNonUniformPartitionedNV @@ -85,63 +85,63 @@ // * GroupNonUniformArithmetic // * GroupNonUniformBallot -// CHECK: requires #spv.vce -spv.module Logical GLSL450 attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> +// CHECK: requires #spirv.vce +spirv.module Logical GLSL450 attributes { + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { - spv.func @group_non_uniform_iadd(%val : i32) -> i32 "None" { - %0 = spv.GroupNonUniformIAdd "Subgroup" "Reduce" %val : i32 - spv.ReturnValue %0: i32 + spirv.func @group_non_uniform_iadd(%val : i32) -> i32 "None" { + %0 = spirv.GroupNonUniformIAdd "Subgroup" "Reduce" %val : i32 + spirv.ReturnValue %0: i32 } } -// CHECK: requires #spv.vce -spv.module Logical GLSL450 attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> +// CHECK: requires #spirv.vce +spirv.module Logical GLSL450 attributes { + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { - spv.func @group_non_uniform_iadd(%val : i32) -> i32 "None" { - %0 = spv.GroupNonUniformIAdd "Subgroup" "Reduce" %val : i32 - spv.ReturnValue %0: i32 + spirv.func @group_non_uniform_iadd(%val : i32) -> i32 "None" { + %0 = spirv.GroupNonUniformIAdd "Subgroup" "Reduce" %val : i32 + spirv.ReturnValue %0: i32 } } // Test type required capabilities // Using 8-bit integers in non-interface storage class requires Int8. -// CHECK: requires #spv.vce -spv.module Logical GLSL450 attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> +// CHECK: requires #spirv.vce +spirv.module Logical GLSL450 attributes { + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { - spv.func @iadd_function(%val : i8) -> i8 "None" { - %0 = spv.IAdd %val, %val : i8 - spv.ReturnValue %0: i8 + spirv.func @iadd_function(%val : i8) -> i8 "None" { + %0 = spirv.IAdd %val, %val : i8 + spirv.ReturnValue %0: i8 } } // Using 16-bit floats in non-interface storage class requires Float16. -// CHECK: requires #spv.vce -spv.module Logical GLSL450 attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> +// CHECK: requires #spirv.vce +spirv.module Logical GLSL450 attributes { + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { - spv.func @fadd_function(%val : f16) -> f16 "None" { - %0 = spv.FAdd %val, %val : f16 - spv.ReturnValue %0: f16 + spirv.func @fadd_function(%val : f16) -> f16 "None" { + %0 = spirv.FAdd %val, %val : f16 + spirv.ReturnValue %0: f16 } } // Using 16-element vectors requires Vector16. -// CHECK: requires #spv.vce -spv.module Logical GLSL450 attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> +// CHECK: requires #spirv.vce +spirv.module Logical GLSL450 attributes { + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { - spv.func @iadd_v16_function(%val : vector<16xi32>) -> vector<16xi32> "None" { - %0 = spv.IAdd %val, %val : vector<16xi32> - spv.ReturnValue %0: vector<16xi32> + spirv.func @iadd_v16_function(%val : vector<16xi32>) -> vector<16xi32> "None" { + %0 = spirv.IAdd %val, %val : vector<16xi32> + spirv.ReturnValue %0: vector<16xi32> } } @@ -150,17 +150,17 @@ //===----------------------------------------------------------------------===// // Test deducing minimal extensions. -// spv.KHR.SubgroupBallot requires the SPV_KHR_shader_ballot extension. +// spirv.KHR.SubgroupBallot requires the SPV_KHR_shader_ballot extension. -// CHECK: requires #spv.vce -spv.module Logical GLSL450 attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> +// CHECK: requires #spirv.vce +spirv.module Logical GLSL450 attributes { + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { - spv.func @subgroup_ballot(%predicate : i1) -> vector<4xi32> "None" { - %0 = spv.KHR.SubgroupBallot %predicate: vector<4xi32> - spv.ReturnValue %0: vector<4xi32> + spirv.func @subgroup_ballot(%predicate : i1) -> vector<4xi32> "None" { + %0 = spirv.KHR.SubgroupBallot %predicate: vector<4xi32> + spirv.ReturnValue %0: vector<4xi32> } } @@ -168,14 +168,14 @@ // Vulkan memory model requires SPV_KHR_vulkan_memory_model, which is enabled // implicitly by v1.5. -// CHECK: requires #spv.vce -spv.module Logical Vulkan attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> +// CHECK: requires #spirv.vce +spirv.module Logical Vulkan attributes { + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { - spv.func @iadd(%val : i32) -> i32 "None" { - %0 = spv.IAdd %val, %val: i32 - spv.ReturnValue %0: i32 + spirv.func @iadd(%val : i32) -> i32 "None" { + %0 = spirv.IAdd %val, %val: i32 + spirv.ReturnValue %0: i32 } } @@ -183,27 +183,27 @@ // Using 8-bit integers in interface storage class requires additional // extensions and capabilities. -// CHECK: requires #spv.vce -spv.module Logical GLSL450 attributes { - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> +// CHECK: requires #spirv.vce +spirv.module Logical GLSL450 attributes { + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { - spv.func @iadd_storage_buffer(%ptr : !spv.ptr) -> i16 "None" { - %0 = spv.Load "StorageBuffer" %ptr : i16 - %1 = spv.IAdd %0, %0 : i16 - spv.ReturnValue %1: i16 + spirv.func @iadd_storage_buffer(%ptr : !spirv.ptr) -> i16 "None" { + %0 = spirv.Load "StorageBuffer" %ptr : i16 + %1 = spirv.IAdd %0, %0 : i16 + spirv.ReturnValue %1: i16 } } // Complicated nested types // * Buffer requires ImageBuffer or SampledBuffer. // * Rg32f requires StorageImageExtendedFormats. -// CHECK: requires #spv.vce -spv.module Logical GLSL450 attributes { - spv.target_env = #spv.target_env< - #spv.vce, - #spv.resource_limits<>> +// CHECK: requires #spirv.vce +spirv.module Logical GLSL450 attributes { + spirv.target_env = #spirv.target_env< + #spirv.vce, + #spirv.resource_limits<>> } { - spv.GlobalVariable @data : !spv.ptr, Uniform> - spv.GlobalVariable @img : !spv.ptr, UniformConstant> + spirv.GlobalVariable @data : !spirv.ptr, Uniform> + spirv.GlobalVariable @img : !spirv.ptr, UniformConstant> } diff --git a/mlir/test/Target/SPIRV/arithmetic-ops.mlir b/mlir/test/Target/SPIRV/arithmetic-ops.mlir --- a/mlir/test/Target/SPIRV/arithmetic-ops.mlir +++ b/mlir/test/Target/SPIRV/arithmetic-ops.mlir @@ -1,89 +1,89 @@ // RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - spv.func @fmul(%arg0 : f32, %arg1 : f32) "None" { - // CHECK: {{%.*}}= spv.FMul {{%.*}}, {{%.*}} : f32 - %0 = spv.FMul %arg0, %arg1 : f32 - spv.Return - } - spv.func @fadd(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) "None" { - // CHECK: {{%.*}} = spv.FAdd {{%.*}}, {{%.*}} : vector<4xf32> - %0 = spv.FAdd %arg0, %arg1 : vector<4xf32> - spv.Return - } - spv.func @fdiv(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) "None" { - // CHECK: {{%.*}} = spv.FDiv {{%.*}}, {{%.*}} : vector<4xf32> - %0 = spv.FDiv %arg0, %arg1 : vector<4xf32> - spv.Return - } - spv.func @fmod(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) "None" { - // CHECK: {{%.*}} = spv.FMod {{%.*}}, {{%.*}} : vector<4xf32> - %0 = spv.FMod %arg0, %arg1 : vector<4xf32> - spv.Return - } - spv.func @fnegate(%arg0 : vector<4xf32>) "None" { - // CHECK: {{%.*}} = spv.FNegate {{%.*}} : vector<4xf32> - %0 = spv.FNegate %arg0 : vector<4xf32> - spv.Return - } - spv.func @fsub(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) "None" { - // CHECK: {{%.*}} = spv.FSub {{%.*}}, {{%.*}} : vector<4xf32> - %0 = spv.FSub %arg0, %arg1 : vector<4xf32> - spv.Return - } - spv.func @frem(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) "None" { - // CHECK: {{%.*}} = spv.FRem {{%.*}}, {{%.*}} : vector<4xf32> - %0 = spv.FRem %arg0, %arg1 : vector<4xf32> - spv.Return - } - spv.func @iadd(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { - // CHECK: {{%.*}} = spv.IAdd {{%.*}}, {{%.*}} : vector<4xi32> - %0 = spv.IAdd %arg0, %arg1 : vector<4xi32> - spv.Return - } - spv.func @isub(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { - // CHECK: {{%.*}} = spv.ISub {{%.*}}, {{%.*}} : vector<4xi32> - %0 = spv.ISub %arg0, %arg1 : vector<4xi32> - spv.Return - } - spv.func @imul(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { - // CHECK: {{%.*}} = spv.IMul {{%.*}}, {{%.*}} : vector<4xi32> - %0 = spv.IMul %arg0, %arg1 : vector<4xi32> - spv.Return - } - spv.func @udiv(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { - // CHECK: {{%.*}} = spv.UDiv {{%.*}}, {{%.*}} : vector<4xi32> - %0 = spv.UDiv %arg0, %arg1 : vector<4xi32> - spv.Return - } - spv.func @umod(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { - // CHECK: {{%.*}} = spv.UMod {{%.*}}, {{%.*}} : vector<4xi32> - %0 = spv.UMod %arg0, %arg1 : vector<4xi32> - spv.Return - } - spv.func @sdiv(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { - // CHECK: {{%.*}} = spv.SDiv {{%.*}}, {{%.*}} : vector<4xi32> - %0 = spv.SDiv %arg0, %arg1 : vector<4xi32> - spv.Return - } - spv.func @smod(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { - // CHECK: {{%.*}} = spv.SMod {{%.*}}, {{%.*}} : vector<4xi32> - %0 = spv.SMod %arg0, %arg1 : vector<4xi32> - spv.Return - } - spv.func @snegate(%arg0 : vector<4xi32>) "None" { - // CHECK: {{%.*}} = spv.SNegate {{%.*}} : vector<4xi32> - %0 = spv.SNegate %arg0 : vector<4xi32> - spv.Return - } - spv.func @srem(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { - // CHECK: {{%.*}} = spv.SRem {{%.*}}, {{%.*}} : vector<4xi32> - %0 = spv.SRem %arg0, %arg1 : vector<4xi32> - spv.Return - } - spv.func @vector_times_scalar(%arg0 : vector<4xf32>, %arg1 : f32) "None" { - // CHECK: {{%.*}} = spv.VectorTimesScalar {{%.*}}, {{%.*}} : (vector<4xf32>, f32) -> vector<4xf32> - %0 = spv.VectorTimesScalar %arg0, %arg1 : (vector<4xf32>, f32) -> vector<4xf32> - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @fmul(%arg0 : f32, %arg1 : f32) "None" { + // CHECK: {{%.*}}= spirv.FMul {{%.*}}, {{%.*}} : f32 + %0 = spirv.FMul %arg0, %arg1 : f32 + spirv.Return + } + spirv.func @fadd(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) "None" { + // CHECK: {{%.*}} = spirv.FAdd {{%.*}}, {{%.*}} : vector<4xf32> + %0 = spirv.FAdd %arg0, %arg1 : vector<4xf32> + spirv.Return + } + spirv.func @fdiv(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) "None" { + // CHECK: {{%.*}} = spirv.FDiv {{%.*}}, {{%.*}} : vector<4xf32> + %0 = spirv.FDiv %arg0, %arg1 : vector<4xf32> + spirv.Return + } + spirv.func @fmod(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) "None" { + // CHECK: {{%.*}} = spirv.FMod {{%.*}}, {{%.*}} : vector<4xf32> + %0 = spirv.FMod %arg0, %arg1 : vector<4xf32> + spirv.Return + } + spirv.func @fnegate(%arg0 : vector<4xf32>) "None" { + // CHECK: {{%.*}} = spirv.FNegate {{%.*}} : vector<4xf32> + %0 = spirv.FNegate %arg0 : vector<4xf32> + spirv.Return + } + spirv.func @fsub(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) "None" { + // CHECK: {{%.*}} = spirv.FSub {{%.*}}, {{%.*}} : vector<4xf32> + %0 = spirv.FSub %arg0, %arg1 : vector<4xf32> + spirv.Return + } + spirv.func @frem(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) "None" { + // CHECK: {{%.*}} = spirv.FRem {{%.*}}, {{%.*}} : vector<4xf32> + %0 = spirv.FRem %arg0, %arg1 : vector<4xf32> + spirv.Return + } + spirv.func @iadd(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { + // CHECK: {{%.*}} = spirv.IAdd {{%.*}}, {{%.*}} : vector<4xi32> + %0 = spirv.IAdd %arg0, %arg1 : vector<4xi32> + spirv.Return + } + spirv.func @isub(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { + // CHECK: {{%.*}} = spirv.ISub {{%.*}}, {{%.*}} : vector<4xi32> + %0 = spirv.ISub %arg0, %arg1 : vector<4xi32> + spirv.Return + } + spirv.func @imul(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { + // CHECK: {{%.*}} = spirv.IMul {{%.*}}, {{%.*}} : vector<4xi32> + %0 = spirv.IMul %arg0, %arg1 : vector<4xi32> + spirv.Return + } + spirv.func @udiv(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { + // CHECK: {{%.*}} = spirv.UDiv {{%.*}}, {{%.*}} : vector<4xi32> + %0 = spirv.UDiv %arg0, %arg1 : vector<4xi32> + spirv.Return + } + spirv.func @umod(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { + // CHECK: {{%.*}} = spirv.UMod {{%.*}}, {{%.*}} : vector<4xi32> + %0 = spirv.UMod %arg0, %arg1 : vector<4xi32> + spirv.Return + } + spirv.func @sdiv(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { + // CHECK: {{%.*}} = spirv.SDiv {{%.*}}, {{%.*}} : vector<4xi32> + %0 = spirv.SDiv %arg0, %arg1 : vector<4xi32> + spirv.Return + } + spirv.func @smod(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { + // CHECK: {{%.*}} = spirv.SMod {{%.*}}, {{%.*}} : vector<4xi32> + %0 = spirv.SMod %arg0, %arg1 : vector<4xi32> + spirv.Return + } + spirv.func @snegate(%arg0 : vector<4xi32>) "None" { + // CHECK: {{%.*}} = spirv.SNegate {{%.*}} : vector<4xi32> + %0 = spirv.SNegate %arg0 : vector<4xi32> + spirv.Return + } + spirv.func @srem(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) "None" { + // CHECK: {{%.*}} = spirv.SRem {{%.*}}, {{%.*}} : vector<4xi32> + %0 = spirv.SRem %arg0, %arg1 : vector<4xi32> + spirv.Return + } + spirv.func @vector_times_scalar(%arg0 : vector<4xf32>, %arg1 : f32) "None" { + // CHECK: {{%.*}} = spirv.VectorTimesScalar {{%.*}}, {{%.*}} : (vector<4xf32>, f32) -> vector<4xf32> + %0 = spirv.VectorTimesScalar %arg0, %arg1 : (vector<4xf32>, f32) -> vector<4xf32> + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/array.mlir b/mlir/test/Target/SPIRV/array.mlir --- a/mlir/test/Target/SPIRV/array.mlir +++ b/mlir/test/Target/SPIRV/array.mlir @@ -1,18 +1,18 @@ // RUN: mlir-translate -split-input-file -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - spv.func @array_stride(%arg0 : !spv.ptr, stride=128>, StorageBuffer>, %arg1 : i32, %arg2 : i32) "None" { - // CHECK: {{%.*}} = spv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spv.ptr, stride=128>, StorageBuffer>, i32, i32 - %2 = spv.AccessChain %arg0[%arg1, %arg2] : !spv.ptr, stride=128>, StorageBuffer>, i32, i32 - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @array_stride(%arg0 : !spirv.ptr, stride=128>, StorageBuffer>, %arg1 : i32, %arg2 : i32) "None" { + // CHECK: {{%.*}} = spirv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spirv.ptr, stride=128>, StorageBuffer>, i32, i32 + %2 = spirv.AccessChain %arg0[%arg1, %arg2] : !spirv.ptr, stride=128>, StorageBuffer>, i32, i32 + spirv.Return } } // ----- -spv.module Logical GLSL450 requires #spv.vce { - // CHECK: spv.GlobalVariable {{@.*}} : !spv.ptr, StorageBuffer> - spv.GlobalVariable @var0 : !spv.ptr, StorageBuffer> - // CHECK: spv.GlobalVariable {{@.*}} : !spv.ptr>, Input> - spv.GlobalVariable @var1 : !spv.ptr>, Input> +spirv.module Logical GLSL450 requires #spirv.vce { + // CHECK: spirv.GlobalVariable {{@.*}} : !spirv.ptr, StorageBuffer> + spirv.GlobalVariable @var0 : !spirv.ptr, StorageBuffer> + // CHECK: spirv.GlobalVariable {{@.*}} : !spirv.ptr>, Input> + spirv.GlobalVariable @var1 : !spirv.ptr>, Input> } diff --git a/mlir/test/Target/SPIRV/atomic-ops.mlir b/mlir/test/Target/SPIRV/atomic-ops.mlir --- a/mlir/test/Target/SPIRV/atomic-ops.mlir +++ b/mlir/test/Target/SPIRV/atomic-ops.mlir @@ -1,43 +1,43 @@ // RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK-LABEL: @test_int_atomics - spv.func @test_int_atomics(%ptr: !spv.ptr, %value: i32, %comparator: i32) -> i32 "None" { - // CHECK: spv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %{{.*}}, %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spv.ptr - // CHECK: spv.AtomicAnd "Device" "None" %{{.*}}, %{{.*}} : !spv.ptr - %1 = spv.AtomicAnd "Device" "None" %ptr, %value : !spv.ptr - // CHECK: spv.AtomicIAdd "Workgroup" "Acquire" %{{.*}}, %{{.*}} : !spv.ptr - %2 = spv.AtomicIAdd "Workgroup" "Acquire" %ptr, %value : !spv.ptr - // CHECK: spv.AtomicIDecrement "Workgroup" "Acquire" %{{.*}} : !spv.ptr - %3 = spv.AtomicIDecrement "Workgroup" "Acquire" %ptr : !spv.ptr - // CHECK: spv.AtomicIIncrement "Device" "Release" %{{.*}} : !spv.ptr - %4 = spv.AtomicIIncrement "Device" "Release" %ptr : !spv.ptr - // CHECK: spv.AtomicISub "Workgroup" "Acquire" %{{.*}}, %{{.*}} : !spv.ptr - %5 = spv.AtomicISub "Workgroup" "Acquire" %ptr, %value : !spv.ptr - // CHECK: spv.AtomicOr "Workgroup" "AcquireRelease" %{{.*}}, %{{.*}} : !spv.ptr - %6 = spv.AtomicOr "Workgroup" "AcquireRelease" %ptr, %value : !spv.ptr - // CHECK: spv.AtomicSMax "Subgroup" "None" %{{.*}}, %{{.*}} : !spv.ptr - %7 = spv.AtomicSMax "Subgroup" "None" %ptr, %value : !spv.ptr - // CHECK: spv.AtomicSMin "Device" "Release" %{{.*}}, %{{.*}} : !spv.ptr - %8 = spv.AtomicSMin "Device" "Release" %ptr, %value : !spv.ptr - // CHECK: spv.AtomicUMax "Subgroup" "None" %{{.*}}, %{{.*}} : !spv.ptr - %9 = spv.AtomicUMax "Subgroup" "None" %ptr, %value : !spv.ptr - // CHECK: spv.AtomicUMin "Device" "Release" %{{.*}}, %{{.*}} : !spv.ptr - %10 = spv.AtomicUMin "Device" "Release" %ptr, %value : !spv.ptr - // CHECK: spv.AtomicXor "Workgroup" "AcquireRelease" %{{.*}}, %{{.*}} : !spv.ptr - %11 = spv.AtomicXor "Workgroup" "AcquireRelease" %ptr, %value : !spv.ptr - // CHECK: spv.AtomicCompareExchange "Workgroup" "Release" "Acquire" %{{.*}}, %{{.*}}, %{{.*}} : !spv.ptr - %12 = spv.AtomicCompareExchange "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spv.ptr - // CHECK: spv.AtomicExchange "Workgroup" "Release" %{{.*}}, %{{.*}} : !spv.ptr - %13 = spv.AtomicExchange "Workgroup" "Release" %ptr, %value: !spv.ptr - spv.ReturnValue %0: i32 + spirv.func @test_int_atomics(%ptr: !spirv.ptr, %value: i32, %comparator: i32) -> i32 "None" { + // CHECK: spirv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %{{.*}}, %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spirv.ptr + // CHECK: spirv.AtomicAnd "Device" "None" %{{.*}}, %{{.*}} : !spirv.ptr + %1 = spirv.AtomicAnd "Device" "None" %ptr, %value : !spirv.ptr + // CHECK: spirv.AtomicIAdd "Workgroup" "Acquire" %{{.*}}, %{{.*}} : !spirv.ptr + %2 = spirv.AtomicIAdd "Workgroup" "Acquire" %ptr, %value : !spirv.ptr + // CHECK: spirv.AtomicIDecrement "Workgroup" "Acquire" %{{.*}} : !spirv.ptr + %3 = spirv.AtomicIDecrement "Workgroup" "Acquire" %ptr : !spirv.ptr + // CHECK: spirv.AtomicIIncrement "Device" "Release" %{{.*}} : !spirv.ptr + %4 = spirv.AtomicIIncrement "Device" "Release" %ptr : !spirv.ptr + // CHECK: spirv.AtomicISub "Workgroup" "Acquire" %{{.*}}, %{{.*}} : !spirv.ptr + %5 = spirv.AtomicISub "Workgroup" "Acquire" %ptr, %value : !spirv.ptr + // CHECK: spirv.AtomicOr "Workgroup" "AcquireRelease" %{{.*}}, %{{.*}} : !spirv.ptr + %6 = spirv.AtomicOr "Workgroup" "AcquireRelease" %ptr, %value : !spirv.ptr + // CHECK: spirv.AtomicSMax "Subgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr + %7 = spirv.AtomicSMax "Subgroup" "None" %ptr, %value : !spirv.ptr + // CHECK: spirv.AtomicSMin "Device" "Release" %{{.*}}, %{{.*}} : !spirv.ptr + %8 = spirv.AtomicSMin "Device" "Release" %ptr, %value : !spirv.ptr + // CHECK: spirv.AtomicUMax "Subgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr + %9 = spirv.AtomicUMax "Subgroup" "None" %ptr, %value : !spirv.ptr + // CHECK: spirv.AtomicUMin "Device" "Release" %{{.*}}, %{{.*}} : !spirv.ptr + %10 = spirv.AtomicUMin "Device" "Release" %ptr, %value : !spirv.ptr + // CHECK: spirv.AtomicXor "Workgroup" "AcquireRelease" %{{.*}}, %{{.*}} : !spirv.ptr + %11 = spirv.AtomicXor "Workgroup" "AcquireRelease" %ptr, %value : !spirv.ptr + // CHECK: spirv.AtomicCompareExchange "Workgroup" "Release" "Acquire" %{{.*}}, %{{.*}}, %{{.*}} : !spirv.ptr + %12 = spirv.AtomicCompareExchange "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spirv.ptr + // CHECK: spirv.AtomicExchange "Workgroup" "Release" %{{.*}}, %{{.*}} : !spirv.ptr + %13 = spirv.AtomicExchange "Workgroup" "Release" %ptr, %value: !spirv.ptr + spirv.ReturnValue %0: i32 } // CHECK-LABEL: @test_float_atomics - spv.func @test_float_atomics(%ptr: !spv.ptr, %value: f32) -> f32 "None" { - // CHECK: spv.EXT.AtomicFAdd "Workgroup" "Acquire" %{{.*}}, %{{.*}} : !spv.ptr - %0 = spv.EXT.AtomicFAdd "Workgroup" "Acquire" %ptr, %value : !spv.ptr - spv.ReturnValue %0: f32 + spirv.func @test_float_atomics(%ptr: !spirv.ptr, %value: f32) -> f32 "None" { + // CHECK: spirv.EXT.AtomicFAdd "Workgroup" "Acquire" %{{.*}}, %{{.*}} : !spirv.ptr + %0 = spirv.EXT.AtomicFAdd "Workgroup" "Acquire" %ptr, %value : !spirv.ptr + spirv.ReturnValue %0: f32 } } diff --git a/mlir/test/Target/SPIRV/barrier-ops.mlir b/mlir/test/Target/SPIRV/barrier-ops.mlir --- a/mlir/test/Target/SPIRV/barrier-ops.mlir +++ b/mlir/test/Target/SPIRV/barrier-ops.mlir @@ -1,24 +1,24 @@ // RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - spv.func @memory_barrier_0() -> () "None" { - // CHECK: spv.MemoryBarrier , - spv.MemoryBarrier , - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @memory_barrier_0() -> () "None" { + // CHECK: spirv.MemoryBarrier , + spirv.MemoryBarrier , + spirv.Return } - spv.func @memory_barrier_1() -> () "None" { - // CHECK: spv.MemoryBarrier , - spv.MemoryBarrier , - spv.Return + spirv.func @memory_barrier_1() -> () "None" { + // CHECK: spirv.MemoryBarrier , + spirv.MemoryBarrier , + spirv.Return } - spv.func @control_barrier_0() -> () "None" { - // CHECK: spv.ControlBarrier , , - spv.ControlBarrier , , - spv.Return + spirv.func @control_barrier_0() -> () "None" { + // CHECK: spirv.ControlBarrier , , + spirv.ControlBarrier , , + spirv.Return } - spv.func @control_barrier_1() -> () "None" { - // CHECK: spv.ControlBarrier , , - spv.ControlBarrier , , - spv.Return + spirv.func @control_barrier_1() -> () "None" { + // CHECK: spirv.ControlBarrier , , + spirv.ControlBarrier , , + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/bit-ops.mlir b/mlir/test/Target/SPIRV/bit-ops.mlir --- a/mlir/test/Target/SPIRV/bit-ops.mlir +++ b/mlir/test/Target/SPIRV/bit-ops.mlir @@ -1,58 +1,58 @@ // RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - spv.func @bitcount(%arg: i32) -> i32 "None" { - // CHECK: spv.BitCount {{%.*}} : i32 - %0 = spv.BitCount %arg : i32 - spv.ReturnValue %0 : i32 - } - spv.func @bit_field_insert(%base: vector<3xi32>, %insert: vector<3xi32>, %offset: i32, %count: i16) -> vector<3xi32> "None" { - // CHECK: {{%.*}} = spv.BitFieldInsert {{%.*}}, {{%.*}}, {{%.*}}, {{%.*}} : vector<3xi32>, i32, i16 - %0 = spv.BitFieldInsert %base, %insert, %offset, %count : vector<3xi32>, i32, i16 - spv.ReturnValue %0 : vector<3xi32> - } - spv.func @bit_field_s_extract(%base: vector<3xi32>, %offset: i8, %count: i8) -> vector<3xi32> "None" { - // CHECK: {{%.*}} = spv.BitFieldSExtract {{%.*}}, {{%.*}}, {{%.*}} : vector<3xi32>, i8, i8 - %0 = spv.BitFieldSExtract %base, %offset, %count : vector<3xi32>, i8, i8 - spv.ReturnValue %0 : vector<3xi32> - } - spv.func @bit_field_u_extract(%base: vector<3xi32>, %offset: i8, %count: i8) -> vector<3xi32> "None" { - // CHECK: {{%.*}} = spv.BitFieldUExtract {{%.*}}, {{%.*}}, {{%.*}} : vector<3xi32>, i8, i8 - %0 = spv.BitFieldUExtract %base, %offset, %count : vector<3xi32>, i8, i8 - spv.ReturnValue %0 : vector<3xi32> - } - spv.func @bitreverse(%arg: i32) -> i32 "None" { - // CHECK: spv.BitReverse {{%.*}} : i32 - %0 = spv.BitReverse %arg : i32 - spv.ReturnValue %0 : i32 - } - spv.func @not(%arg: i32) -> i32 "None" { - // CHECK: spv.Not {{%.*}} : i32 - %0 = spv.Not %arg : i32 - spv.ReturnValue %0 : i32 - } - spv.func @bitwise_scalar(%arg0 : i32, %arg1 : i32) "None" { - // CHECK: spv.BitwiseAnd - %0 = spv.BitwiseAnd %arg0, %arg1 : i32 - // CHECK: spv.BitwiseOr - %1 = spv.BitwiseOr %arg0, %arg1 : i32 - // CHECK: spv.BitwiseXor - %2 = spv.BitwiseXor %arg0, %arg1 : i32 - spv.Return - } - spv.func @shift_left_logical(%arg0: i32, %arg1 : i16) -> i32 "None" { - // CHECK: {{%.*}} = spv.ShiftLeftLogical {{%.*}}, {{%.*}} : i32, i16 - %0 = spv.ShiftLeftLogical %arg0, %arg1: i32, i16 - spv.ReturnValue %0 : i32 - } - spv.func @shift_right_arithmetic(%arg0: vector<4xi32>, %arg1 : vector<4xi8>) -> vector<4xi32> "None" { - // CHECK: {{%.*}} = spv.ShiftRightArithmetic {{%.*}}, {{%.*}} : vector<4xi32>, vector<4xi8> - %0 = spv.ShiftRightArithmetic %arg0, %arg1: vector<4xi32>, vector<4xi8> - spv.ReturnValue %0 : vector<4xi32> - } - spv.func @shift_right_logical(%arg0: vector<2xi32>, %arg1 : vector<2xi8>) -> vector<2xi32> "None" { - // CHECK: {{%.*}} = spv.ShiftRightLogical {{%.*}}, {{%.*}} : vector<2xi32>, vector<2xi8> - %0 = spv.ShiftRightLogical %arg0, %arg1: vector<2xi32>, vector<2xi8> - spv.ReturnValue %0 : vector<2xi32> +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @bitcount(%arg: i32) -> i32 "None" { + // CHECK: spirv.BitCount {{%.*}} : i32 + %0 = spirv.BitCount %arg : i32 + spirv.ReturnValue %0 : i32 + } + spirv.func @bit_field_insert(%base: vector<3xi32>, %insert: vector<3xi32>, %offset: i32, %count: i16) -> vector<3xi32> "None" { + // CHECK: {{%.*}} = spirv.BitFieldInsert {{%.*}}, {{%.*}}, {{%.*}}, {{%.*}} : vector<3xi32>, i32, i16 + %0 = spirv.BitFieldInsert %base, %insert, %offset, %count : vector<3xi32>, i32, i16 + spirv.ReturnValue %0 : vector<3xi32> + } + spirv.func @bit_field_s_extract(%base: vector<3xi32>, %offset: i8, %count: i8) -> vector<3xi32> "None" { + // CHECK: {{%.*}} = spirv.BitFieldSExtract {{%.*}}, {{%.*}}, {{%.*}} : vector<3xi32>, i8, i8 + %0 = spirv.BitFieldSExtract %base, %offset, %count : vector<3xi32>, i8, i8 + spirv.ReturnValue %0 : vector<3xi32> + } + spirv.func @bit_field_u_extract(%base: vector<3xi32>, %offset: i8, %count: i8) -> vector<3xi32> "None" { + // CHECK: {{%.*}} = spirv.BitFieldUExtract {{%.*}}, {{%.*}}, {{%.*}} : vector<3xi32>, i8, i8 + %0 = spirv.BitFieldUExtract %base, %offset, %count : vector<3xi32>, i8, i8 + spirv.ReturnValue %0 : vector<3xi32> + } + spirv.func @bitreverse(%arg: i32) -> i32 "None" { + // CHECK: spirv.BitReverse {{%.*}} : i32 + %0 = spirv.BitReverse %arg : i32 + spirv.ReturnValue %0 : i32 + } + spirv.func @not(%arg: i32) -> i32 "None" { + // CHECK: spirv.Not {{%.*}} : i32 + %0 = spirv.Not %arg : i32 + spirv.ReturnValue %0 : i32 + } + spirv.func @bitwise_scalar(%arg0 : i32, %arg1 : i32) "None" { + // CHECK: spirv.BitwiseAnd + %0 = spirv.BitwiseAnd %arg0, %arg1 : i32 + // CHECK: spirv.BitwiseOr + %1 = spirv.BitwiseOr %arg0, %arg1 : i32 + // CHECK: spirv.BitwiseXor + %2 = spirv.BitwiseXor %arg0, %arg1 : i32 + spirv.Return + } + spirv.func @shift_left_logical(%arg0: i32, %arg1 : i16) -> i32 "None" { + // CHECK: {{%.*}} = spirv.ShiftLeftLogical {{%.*}}, {{%.*}} : i32, i16 + %0 = spirv.ShiftLeftLogical %arg0, %arg1: i32, i16 + spirv.ReturnValue %0 : i32 + } + spirv.func @shift_right_arithmetic(%arg0: vector<4xi32>, %arg1 : vector<4xi8>) -> vector<4xi32> "None" { + // CHECK: {{%.*}} = spirv.ShiftRightArithmetic {{%.*}}, {{%.*}} : vector<4xi32>, vector<4xi8> + %0 = spirv.ShiftRightArithmetic %arg0, %arg1: vector<4xi32>, vector<4xi8> + spirv.ReturnValue %0 : vector<4xi32> + } + spirv.func @shift_right_logical(%arg0: vector<2xi32>, %arg1 : vector<2xi8>) -> vector<2xi32> "None" { + // CHECK: {{%.*}} = spirv.ShiftRightLogical {{%.*}}, {{%.*}} : vector<2xi32>, vector<2xi8> + %0 = spirv.ShiftRightLogical %arg0, %arg1: vector<2xi32>, vector<2xi8> + spirv.ReturnValue %0 : vector<2xi32> } } diff --git a/mlir/test/Target/SPIRV/cast-ops.mlir b/mlir/test/Target/SPIRV/cast-ops.mlir --- a/mlir/test/Target/SPIRV/cast-ops.mlir +++ b/mlir/test/Target/SPIRV/cast-ops.mlir @@ -1,93 +1,93 @@ // RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - spv.func @bit_cast(%arg0 : f32) "None" { - // CHECK: {{%.*}} = spv.Bitcast {{%.*}} : f32 to i32 - %0 = spv.Bitcast %arg0 : f32 to i32 - // CHECK: {{%.*}} = spv.Bitcast {{%.*}} : i32 to si32 - %1 = spv.Bitcast %0 : i32 to si32 - // CHECK: {{%.*}} = spv.Bitcast {{%.*}} : si32 to i32 - %2 = spv.Bitcast %1 : si32 to ui32 - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @bit_cast(%arg0 : f32) "None" { + // CHECK: {{%.*}} = spirv.Bitcast {{%.*}} : f32 to i32 + %0 = spirv.Bitcast %arg0 : f32 to i32 + // CHECK: {{%.*}} = spirv.Bitcast {{%.*}} : i32 to si32 + %1 = spirv.Bitcast %0 : i32 to si32 + // CHECK: {{%.*}} = spirv.Bitcast {{%.*}} : si32 to i32 + %2 = spirv.Bitcast %1 : si32 to ui32 + spirv.Return } } // ----- -spv.module Logical GLSL450 requires #spv.vce { - spv.func @convert_f_to_s(%arg0 : f32) -> i32 "None" { - // CHECK: {{%.*}} = spv.ConvertFToS {{%.*}} : f32 to i32 - %0 = spv.ConvertFToS %arg0 : f32 to i32 - spv.ReturnValue %0 : i32 +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @convert_f_to_s(%arg0 : f32) -> i32 "None" { + // CHECK: {{%.*}} = spirv.ConvertFToS {{%.*}} : f32 to i32 + %0 = spirv.ConvertFToS %arg0 : f32 to i32 + spirv.ReturnValue %0 : i32 } - spv.func @convert_f64_to_s32(%arg0 : f64) -> i32 "None" { - // CHECK: {{%.*}} = spv.ConvertFToS {{%.*}} : f64 to i32 - %0 = spv.ConvertFToS %arg0 : f64 to i32 - spv.ReturnValue %0 : i32 + spirv.func @convert_f64_to_s32(%arg0 : f64) -> i32 "None" { + // CHECK: {{%.*}} = spirv.ConvertFToS {{%.*}} : f64 to i32 + %0 = spirv.ConvertFToS %arg0 : f64 to i32 + spirv.ReturnValue %0 : i32 } - spv.func @convert_f_to_u(%arg0 : f32) -> i32 "None" { - // CHECK: {{%.*}} = spv.ConvertFToU {{%.*}} : f32 to i32 - %0 = spv.ConvertFToU %arg0 : f32 to i32 - spv.ReturnValue %0 : i32 + spirv.func @convert_f_to_u(%arg0 : f32) -> i32 "None" { + // CHECK: {{%.*}} = spirv.ConvertFToU {{%.*}} : f32 to i32 + %0 = spirv.ConvertFToU %arg0 : f32 to i32 + spirv.ReturnValue %0 : i32 } - spv.func @convert_f64_to_u32(%arg0 : f64) -> i32 "None" { - // CHECK: {{%.*}} = spv.ConvertFToU {{%.*}} : f64 to i32 - %0 = spv.ConvertFToU %arg0 : f64 to i32 - spv.ReturnValue %0 : i32 + spirv.func @convert_f64_to_u32(%arg0 : f64) -> i32 "None" { + // CHECK: {{%.*}} = spirv.ConvertFToU {{%.*}} : f64 to i32 + %0 = spirv.ConvertFToU %arg0 : f64 to i32 + spirv.ReturnValue %0 : i32 } - spv.func @convert_s_to_f(%arg0 : i32) -> f32 "None" { - // CHECK: {{%.*}} = spv.ConvertSToF {{%.*}} : i32 to f32 - %0 = spv.ConvertSToF %arg0 : i32 to f32 - spv.ReturnValue %0 : f32 + spirv.func @convert_s_to_f(%arg0 : i32) -> f32 "None" { + // CHECK: {{%.*}} = spirv.ConvertSToF {{%.*}} : i32 to f32 + %0 = spirv.ConvertSToF %arg0 : i32 to f32 + spirv.ReturnValue %0 : f32 } - spv.func @convert_s64_to_f32(%arg0 : i64) -> f32 "None" { - // CHECK: {{%.*}} = spv.ConvertSToF {{%.*}} : i64 to f32 - %0 = spv.ConvertSToF %arg0 : i64 to f32 - spv.ReturnValue %0 : f32 + spirv.func @convert_s64_to_f32(%arg0 : i64) -> f32 "None" { + // CHECK: {{%.*}} = spirv.ConvertSToF {{%.*}} : i64 to f32 + %0 = spirv.ConvertSToF %arg0 : i64 to f32 + spirv.ReturnValue %0 : f32 } - spv.func @convert_u_to_f(%arg0 : i32) -> f32 "None" { - // CHECK: {{%.*}} = spv.ConvertUToF {{%.*}} : i32 to f32 - %0 = spv.ConvertUToF %arg0 : i32 to f32 - spv.ReturnValue %0 : f32 + spirv.func @convert_u_to_f(%arg0 : i32) -> f32 "None" { + // CHECK: {{%.*}} = spirv.ConvertUToF {{%.*}} : i32 to f32 + %0 = spirv.ConvertUToF %arg0 : i32 to f32 + spirv.ReturnValue %0 : f32 } - spv.func @convert_u64_to_f32(%arg0 : i64) -> f32 "None" { - // CHECK: {{%.*}} = spv.ConvertUToF {{%.*}} : i64 to f32 - %0 = spv.ConvertUToF %arg0 : i64 to f32 - spv.ReturnValue %0 : f32 + spirv.func @convert_u64_to_f32(%arg0 : i64) -> f32 "None" { + // CHECK: {{%.*}} = spirv.ConvertUToF {{%.*}} : i64 to f32 + %0 = spirv.ConvertUToF %arg0 : i64 to f32 + spirv.ReturnValue %0 : f32 } - spv.func @f_convert(%arg0 : f32) -> f64 "None" { - // CHECK: {{%.*}} = spv.FConvert {{%.*}} : f32 to f64 - %0 = spv.FConvert %arg0 : f32 to f64 - spv.ReturnValue %0 : f64 + spirv.func @f_convert(%arg0 : f32) -> f64 "None" { + // CHECK: {{%.*}} = spirv.FConvert {{%.*}} : f32 to f64 + %0 = spirv.FConvert %arg0 : f32 to f64 + spirv.ReturnValue %0 : f64 } - spv.func @s_convert(%arg0 : i32) -> i64 "None" { - // CHECK: {{%.*}} = spv.SConvert {{%.*}} : i32 to i64 - %0 = spv.SConvert %arg0 : i32 to i64 - spv.ReturnValue %0 : i64 + spirv.func @s_convert(%arg0 : i32) -> i64 "None" { + // CHECK: {{%.*}} = spirv.SConvert {{%.*}} : i32 to i64 + %0 = spirv.SConvert %arg0 : i32 to i64 + spirv.ReturnValue %0 : i64 } - spv.func @u_convert(%arg0 : i32) -> i64 "None" { - // CHECK: {{%.*}} = spv.UConvert {{%.*}} : i32 to i64 - %0 = spv.UConvert %arg0 : i32 to i64 - spv.ReturnValue %0 : i64 + spirv.func @u_convert(%arg0 : i32) -> i64 "None" { + // CHECK: {{%.*}} = spirv.UConvert {{%.*}} : i32 to i64 + %0 = spirv.UConvert %arg0 : i32 to i64 + spirv.ReturnValue %0 : i64 } } // ----- -spv.module Logical GLSL450 requires #spv.vce { - spv.func @ptr_cast_to_generic(%arg0 : !spv.ptr) "None" { - // CHECK: {{%.*}} = spv.PtrCastToGeneric {{%.*}} : !spv.ptr to !spv.ptr - %0 = spv.PtrCastToGeneric %arg0 : !spv.ptr to !spv.ptr - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @ptr_cast_to_generic(%arg0 : !spirv.ptr) "None" { + // CHECK: {{%.*}} = spirv.PtrCastToGeneric {{%.*}} : !spirv.ptr to !spirv.ptr + %0 = spirv.PtrCastToGeneric %arg0 : !spirv.ptr to !spirv.ptr + spirv.Return } - spv.func @generic_cast_to_ptr(%arg0 : !spv.ptr, Generic>) "None" { - // CHECK: {{%.*}} = spv.GenericCastToPtr {{%.*}} : !spv.ptr, Generic> to !spv.ptr, CrossWorkgroup> - %0 = spv.GenericCastToPtr %arg0 : !spv.ptr, Generic> to !spv.ptr, CrossWorkgroup> - spv.Return + spirv.func @generic_cast_to_ptr(%arg0 : !spirv.ptr, Generic>) "None" { + // CHECK: {{%.*}} = spirv.GenericCastToPtr {{%.*}} : !spirv.ptr, Generic> to !spirv.ptr, CrossWorkgroup> + %0 = spirv.GenericCastToPtr %arg0 : !spirv.ptr, Generic> to !spirv.ptr, CrossWorkgroup> + spirv.Return } - spv.func @generic_cast_to_ptr_explicit(%arg0 : !spv.ptr, Generic>) "None" { - // CHECK: {{%.*}} = spv.GenericCastToPtrExplicit {{%.*}} : !spv.ptr, Generic> to !spv.ptr, CrossWorkgroup> - %0 = spv.GenericCastToPtrExplicit %arg0 : !spv.ptr, Generic> to !spv.ptr, CrossWorkgroup> - spv.Return + spirv.func @generic_cast_to_ptr_explicit(%arg0 : !spirv.ptr, Generic>) "None" { + // CHECK: {{%.*}} = spirv.GenericCastToPtrExplicit {{%.*}} : !spirv.ptr, Generic> to !spirv.ptr, CrossWorkgroup> + %0 = spirv.GenericCastToPtrExplicit %arg0 : !spirv.ptr, Generic> to !spirv.ptr, CrossWorkgroup> + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/composite-op.mlir b/mlir/test/Target/SPIRV/composite-op.mlir --- a/mlir/test/Target/SPIRV/composite-op.mlir +++ b/mlir/test/Target/SPIRV/composite-op.mlir @@ -1,29 +1,29 @@ // RUN: mlir-translate -split-input-file -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - spv.func @composite_insert(%arg0 : !spv.struct<(f32, !spv.struct<(!spv.array<4xf32>, f32)>)>, %arg1: !spv.array<4xf32>) -> !spv.struct<(f32, !spv.struct<(!spv.array<4xf32>, f32)>)> "None" { - // CHECK: spv.CompositeInsert {{%.*}}, {{%.*}}[1 : i32, 0 : i32] : !spv.array<4 x f32> into !spv.struct<(f32, !spv.struct<(!spv.array<4 x f32>, f32)>)> - %0 = spv.CompositeInsert %arg1, %arg0[1 : i32, 0 : i32] : !spv.array<4xf32> into !spv.struct<(f32, !spv.struct<(!spv.array<4xf32>, f32)>)> - spv.ReturnValue %0: !spv.struct<(f32, !spv.struct<(!spv.array<4xf32>, f32)>)> +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @composite_insert(%arg0 : !spirv.struct<(f32, !spirv.struct<(!spirv.array<4xf32>, f32)>)>, %arg1: !spirv.array<4xf32>) -> !spirv.struct<(f32, !spirv.struct<(!spirv.array<4xf32>, f32)>)> "None" { + // CHECK: spirv.CompositeInsert {{%.*}}, {{%.*}}[1 : i32, 0 : i32] : !spirv.array<4 x f32> into !spirv.struct<(f32, !spirv.struct<(!spirv.array<4 x f32>, f32)>)> + %0 = spirv.CompositeInsert %arg1, %arg0[1 : i32, 0 : i32] : !spirv.array<4xf32> into !spirv.struct<(f32, !spirv.struct<(!spirv.array<4xf32>, f32)>)> + spirv.ReturnValue %0: !spirv.struct<(f32, !spirv.struct<(!spirv.array<4xf32>, f32)>)> } - spv.func @composite_construct_vector(%arg0: f32, %arg1: f32, %arg2 : f32) -> vector<3xf32> "None" { - // CHECK: spv.CompositeConstruct {{%.*}}, {{%.*}}, {{%.*}} : (f32, f32, f32) -> vector<3xf32> - %0 = spv.CompositeConstruct %arg0, %arg1, %arg2 : (f32, f32, f32) -> vector<3xf32> - spv.ReturnValue %0: vector<3xf32> + spirv.func @composite_construct_vector(%arg0: f32, %arg1: f32, %arg2 : f32) -> vector<3xf32> "None" { + // CHECK: spirv.CompositeConstruct {{%.*}}, {{%.*}}, {{%.*}} : (f32, f32, f32) -> vector<3xf32> + %0 = spirv.CompositeConstruct %arg0, %arg1, %arg2 : (f32, f32, f32) -> vector<3xf32> + spirv.ReturnValue %0: vector<3xf32> } - spv.func @vector_dynamic_extract(%vec: vector<4xf32>, %id : i32) -> f32 "None" { - // CHECK: spv.VectorExtractDynamic %{{.*}}[%{{.*}}] : vector<4xf32>, i32 - %0 = spv.VectorExtractDynamic %vec[%id] : vector<4xf32>, i32 - spv.ReturnValue %0: f32 + spirv.func @vector_dynamic_extract(%vec: vector<4xf32>, %id : i32) -> f32 "None" { + // CHECK: spirv.VectorExtractDynamic %{{.*}}[%{{.*}}] : vector<4xf32>, i32 + %0 = spirv.VectorExtractDynamic %vec[%id] : vector<4xf32>, i32 + spirv.ReturnValue %0: f32 } - spv.func @vector_dynamic_insert(%val: f32, %vec: vector<4xf32>, %id : i32) -> vector<4xf32> "None" { - // CHECK: spv.VectorInsertDynamic %{{.*}}, %{{.*}}[%{{.*}}] : vector<4xf32>, i32 - %0 = spv.VectorInsertDynamic %val, %vec[%id] : vector<4xf32>, i32 - spv.ReturnValue %0: vector<4xf32> + spirv.func @vector_dynamic_insert(%val: f32, %vec: vector<4xf32>, %id : i32) -> vector<4xf32> "None" { + // CHECK: spirv.VectorInsertDynamic %{{.*}}, %{{.*}}[%{{.*}}] : vector<4xf32>, i32 + %0 = spirv.VectorInsertDynamic %val, %vec[%id] : vector<4xf32>, i32 + spirv.ReturnValue %0: vector<4xf32> } - spv.func @vector_shuffle(%vector1: vector<4xf32>, %vector2: vector<2xf32>) -> vector<3xf32> "None" { - // CHECK: %{{.+}} = spv.VectorShuffle [1 : i32, 3 : i32, -1 : i32] %{{.+}} : vector<4xf32>, %arg1 : vector<2xf32> -> vector<3xf32> - %0 = spv.VectorShuffle [1: i32, 3: i32, 0xffffffff: i32] %vector1: vector<4xf32>, %vector2: vector<2xf32> -> vector<3xf32> - spv.ReturnValue %0: vector<3xf32> + spirv.func @vector_shuffle(%vector1: vector<4xf32>, %vector2: vector<2xf32>) -> vector<3xf32> "None" { + // CHECK: %{{.+}} = spirv.VectorShuffle [1 : i32, 3 : i32, -1 : i32] %{{.+}} : vector<4xf32>, %arg1 : vector<2xf32> -> vector<3xf32> + %0 = spirv.VectorShuffle [1: i32, 3: i32, 0xffffffff: i32] %vector1: vector<4xf32>, %vector2: vector<2xf32> -> vector<3xf32> + spirv.ReturnValue %0: vector<3xf32> } } diff --git a/mlir/test/Target/SPIRV/constant.mlir b/mlir/test/Target/SPIRV/constant.mlir --- a/mlir/test/Target/SPIRV/constant.mlir +++ b/mlir/test/Target/SPIRV/constant.mlir @@ -1,267 +1,267 @@ // RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK-LABEL: @bool_const - spv.func @bool_const() -> () "None" { - // CHECK: spv.Constant true - %0 = spv.Constant true - // CHECK: spv.Constant false - %1 = spv.Constant false - - %2 = spv.Variable init(%0): !spv.ptr - %3 = spv.Variable init(%1): !spv.ptr - spv.Return + spirv.func @bool_const() -> () "None" { + // CHECK: spirv.Constant true + %0 = spirv.Constant true + // CHECK: spirv.Constant false + %1 = spirv.Constant false + + %2 = spirv.Variable init(%0): !spirv.ptr + %3 = spirv.Variable init(%1): !spirv.ptr + spirv.Return } // CHECK-LABEL: @i32_const - spv.func @i32_const() -> () "None" { - // CHECK: spv.Constant 0 : i32 - %0 = spv.Constant 0 : i32 - // CHECK: spv.Constant 10 : i32 - %1 = spv.Constant 10 : i32 - // CHECK: spv.Constant -5 : i32 - %2 = spv.Constant -5 : i32 - - %3 = spv.IAdd %0, %1 : i32 - %4 = spv.IAdd %2, %3 : i32 - spv.Return + spirv.func @i32_const() -> () "None" { + // CHECK: spirv.Constant 0 : i32 + %0 = spirv.Constant 0 : i32 + // CHECK: spirv.Constant 10 : i32 + %1 = spirv.Constant 10 : i32 + // CHECK: spirv.Constant -5 : i32 + %2 = spirv.Constant -5 : i32 + + %3 = spirv.IAdd %0, %1 : i32 + %4 = spirv.IAdd %2, %3 : i32 + spirv.Return } // CHECK-LABEL: @si32_const - spv.func @si32_const() -> () "None" { - // CHECK: spv.Constant 0 : si32 - %0 = spv.Constant 0 : si32 - // CHECK: spv.Constant 10 : si32 - %1 = spv.Constant 10 : si32 - // CHECK: spv.Constant -5 : si32 - %2 = spv.Constant -5 : si32 - - %3 = spv.IAdd %0, %1 : si32 - %4 = spv.IAdd %2, %3 : si32 - spv.Return + spirv.func @si32_const() -> () "None" { + // CHECK: spirv.Constant 0 : si32 + %0 = spirv.Constant 0 : si32 + // CHECK: spirv.Constant 10 : si32 + %1 = spirv.Constant 10 : si32 + // CHECK: spirv.Constant -5 : si32 + %2 = spirv.Constant -5 : si32 + + %3 = spirv.IAdd %0, %1 : si32 + %4 = spirv.IAdd %2, %3 : si32 + spirv.Return } // CHECK-LABEL: @ui32_const // We cannot differentiate signless vs. unsigned integers in SPIR-V blob // because they all use 1 as the signedness bit. So we always treat them // as signless integers. - spv.func @ui32_const() -> () "None" { - // CHECK: spv.Constant 0 : i32 - %0 = spv.Constant 0 : ui32 - // CHECK: spv.Constant 10 : i32 - %1 = spv.Constant 10 : ui32 - // CHECK: spv.Constant -5 : i32 - %2 = spv.Constant 4294967291 : ui32 - - %3 = spv.IAdd %0, %1 : ui32 - %4 = spv.IAdd %2, %3 : ui32 - spv.Return + spirv.func @ui32_const() -> () "None" { + // CHECK: spirv.Constant 0 : i32 + %0 = spirv.Constant 0 : ui32 + // CHECK: spirv.Constant 10 : i32 + %1 = spirv.Constant 10 : ui32 + // CHECK: spirv.Constant -5 : i32 + %2 = spirv.Constant 4294967291 : ui32 + + %3 = spirv.IAdd %0, %1 : ui32 + %4 = spirv.IAdd %2, %3 : ui32 + spirv.Return } // CHECK-LABEL: @i64_const - spv.func @i64_const() -> () "None" { - // CHECK: spv.Constant 4294967296 : i64 - %0 = spv.Constant 4294967296 : i64 // 2^32 - // CHECK: spv.Constant -4294967296 : i64 - %1 = spv.Constant -4294967296 : i64 // -2^32 - // CHECK: spv.Constant 9223372036854775807 : i64 - %2 = spv.Constant 9223372036854775807 : i64 // 2^63 - 1 - // CHECK: spv.Constant -9223372036854775808 : i64 - %3 = spv.Constant -9223372036854775808 : i64 // -2^63 - - %4 = spv.IAdd %0, %1 : i64 - %5 = spv.IAdd %2, %3 : i64 - spv.Return + spirv.func @i64_const() -> () "None" { + // CHECK: spirv.Constant 4294967296 : i64 + %0 = spirv.Constant 4294967296 : i64 // 2^32 + // CHECK: spirv.Constant -4294967296 : i64 + %1 = spirv.Constant -4294967296 : i64 // -2^32 + // CHECK: spirv.Constant 9223372036854775807 : i64 + %2 = spirv.Constant 9223372036854775807 : i64 // 2^63 - 1 + // CHECK: spirv.Constant -9223372036854775808 : i64 + %3 = spirv.Constant -9223372036854775808 : i64 // -2^63 + + %4 = spirv.IAdd %0, %1 : i64 + %5 = spirv.IAdd %2, %3 : i64 + spirv.Return } // CHECK-LABEL: @i16_const - spv.func @i16_const() -> () "None" { - // CHECK: spv.Constant -32768 : i16 - %0 = spv.Constant -32768 : i16 // -2^15 - // CHECK: spv.Constant 32767 : i16 - %1 = spv.Constant 32767 : i16 // 2^15 - 1 - - %2 = spv.IAdd %0, %1 : i16 - spv.Return + spirv.func @i16_const() -> () "None" { + // CHECK: spirv.Constant -32768 : i16 + %0 = spirv.Constant -32768 : i16 // -2^15 + // CHECK: spirv.Constant 32767 : i16 + %1 = spirv.Constant 32767 : i16 // 2^15 - 1 + + %2 = spirv.IAdd %0, %1 : i16 + spirv.Return } // CHECK-LABEL: @i8_const - spv.func @i8_const() -> () "None" { - // CHECK: spv.Constant 0 : i8 - %0 = spv.Constant 0 : i8 - // CHECK: spv.Constant -1 : i8 - %1 = spv.Constant 255 : i8 - - // CHECK: spv.Constant 0 : si8 - %2 = spv.Constant 0 : si8 - // CHECK: spv.Constant 127 : si8 - %3 = spv.Constant 127 : si8 - // CHECK: spv.Constant -128 : si8 - %4 = spv.Constant -128 : si8 - - // CHECK: spv.Constant 0 : i8 - %5 = spv.Constant 0 : ui8 - // CHECK: spv.Constant -1 : i8 - %6 = spv.Constant 255 : ui8 - - %10 = spv.IAdd %0, %1: i8 - %11 = spv.IAdd %2, %3: si8 - %12 = spv.IAdd %3, %4: si8 - %13 = spv.IAdd %5, %6: ui8 - spv.Return + spirv.func @i8_const() -> () "None" { + // CHECK: spirv.Constant 0 : i8 + %0 = spirv.Constant 0 : i8 + // CHECK: spirv.Constant -1 : i8 + %1 = spirv.Constant 255 : i8 + + // CHECK: spirv.Constant 0 : si8 + %2 = spirv.Constant 0 : si8 + // CHECK: spirv.Constant 127 : si8 + %3 = spirv.Constant 127 : si8 + // CHECK: spirv.Constant -128 : si8 + %4 = spirv.Constant -128 : si8 + + // CHECK: spirv.Constant 0 : i8 + %5 = spirv.Constant 0 : ui8 + // CHECK: spirv.Constant -1 : i8 + %6 = spirv.Constant 255 : ui8 + + %10 = spirv.IAdd %0, %1: i8 + %11 = spirv.IAdd %2, %3: si8 + %12 = spirv.IAdd %3, %4: si8 + %13 = spirv.IAdd %5, %6: ui8 + spirv.Return } // CHECK-LABEL: @float_const - spv.func @float_const() -> () "None" { - // CHECK: spv.Constant 0.000000e+00 : f32 - %0 = spv.Constant 0. : f32 - // CHECK: spv.Constant 1.000000e+00 : f32 - %1 = spv.Constant 1. : f32 - // CHECK: spv.Constant -0.000000e+00 : f32 - %2 = spv.Constant -0. : f32 - // CHECK: spv.Constant -1.000000e+00 : f32 - %3 = spv.Constant -1. : f32 - // CHECK: spv.Constant 7.500000e-01 : f32 - %4 = spv.Constant 0.75 : f32 - // CHECK: spv.Constant -2.500000e-01 : f32 - %5 = spv.Constant -0.25 : f32 - - %6 = spv.FAdd %0, %1 : f32 - %7 = spv.FAdd %2, %3 : f32 - %8 = spv.FAdd %4, %5 : f32 - spv.Return + spirv.func @float_const() -> () "None" { + // CHECK: spirv.Constant 0.000000e+00 : f32 + %0 = spirv.Constant 0. : f32 + // CHECK: spirv.Constant 1.000000e+00 : f32 + %1 = spirv.Constant 1. : f32 + // CHECK: spirv.Constant -0.000000e+00 : f32 + %2 = spirv.Constant -0. : f32 + // CHECK: spirv.Constant -1.000000e+00 : f32 + %3 = spirv.Constant -1. : f32 + // CHECK: spirv.Constant 7.500000e-01 : f32 + %4 = spirv.Constant 0.75 : f32 + // CHECK: spirv.Constant -2.500000e-01 : f32 + %5 = spirv.Constant -0.25 : f32 + + %6 = spirv.FAdd %0, %1 : f32 + %7 = spirv.FAdd %2, %3 : f32 + %8 = spirv.FAdd %4, %5 : f32 + spirv.Return } // CHECK-LABEL: @double_const - spv.func @double_const() -> () "None" { + spirv.func @double_const() -> () "None" { // TODO: test range boundary values - // CHECK: spv.Constant 1.024000e+03 : f64 - %0 = spv.Constant 1024. : f64 - // CHECK: spv.Constant -1.024000e+03 : f64 - %1 = spv.Constant -1024. : f64 + // CHECK: spirv.Constant 1.024000e+03 : f64 + %0 = spirv.Constant 1024. : f64 + // CHECK: spirv.Constant -1.024000e+03 : f64 + %1 = spirv.Constant -1024. : f64 - %2 = spv.FAdd %0, %1 : f64 - spv.Return + %2 = spirv.FAdd %0, %1 : f64 + spirv.Return } // CHECK-LABEL: @half_const - spv.func @half_const() -> () "None" { - // CHECK: spv.Constant 5.120000e+02 : f16 - %0 = spv.Constant 512. : f16 - // CHECK: spv.Constant -5.120000e+02 : f16 - %1 = spv.Constant -512. : f16 - - %2 = spv.FAdd %0, %1 : f16 - spv.Return + spirv.func @half_const() -> () "None" { + // CHECK: spirv.Constant 5.120000e+02 : f16 + %0 = spirv.Constant 512. : f16 + // CHECK: spirv.Constant -5.120000e+02 : f16 + %1 = spirv.Constant -512. : f16 + + %2 = spirv.FAdd %0, %1 : f16 + spirv.Return } // CHECK-LABEL: @bool_vector_const - spv.func @bool_vector_const() -> () "None" { - // CHECK: spv.Constant dense : vector<2xi1> - %0 = spv.Constant dense : vector<2xi1> - // CHECK: spv.Constant dense : vector<3xi1> - %1 = spv.Constant dense : vector<3xi1> - // CHECK: spv.Constant dense<[false, true]> : vector<2xi1> - %2 = spv.Constant dense<[false, true]> : vector<2xi1> - - %3 = spv.Variable init(%0): !spv.ptr, Function> - %4 = spv.Variable init(%1): !spv.ptr, Function> - %5 = spv.Variable init(%2): !spv.ptr, Function> - spv.Return + spirv.func @bool_vector_const() -> () "None" { + // CHECK: spirv.Constant dense : vector<2xi1> + %0 = spirv.Constant dense : vector<2xi1> + // CHECK: spirv.Constant dense : vector<3xi1> + %1 = spirv.Constant dense : vector<3xi1> + // CHECK: spirv.Constant dense<[false, true]> : vector<2xi1> + %2 = spirv.Constant dense<[false, true]> : vector<2xi1> + + %3 = spirv.Variable init(%0): !spirv.ptr, Function> + %4 = spirv.Variable init(%1): !spirv.ptr, Function> + %5 = spirv.Variable init(%2): !spirv.ptr, Function> + spirv.Return } // CHECK-LABEL: @int_vector_const - spv.func @int_vector_const() -> () "None" { - // CHECK: spv.Constant dense<0> : vector<3xi32> - %0 = spv.Constant dense<0> : vector<3xi32> - // CHECK: spv.Constant dense<1> : vector<3xi32> - %1 = spv.Constant dense<1> : vector<3xi32> - // CHECK: spv.Constant dense<[2, -3, 4]> : vector<3xi32> - %2 = spv.Constant dense<[2, -3, 4]> : vector<3xi32> - - %3 = spv.IAdd %0, %1 : vector<3xi32> - %4 = spv.IAdd %2, %3 : vector<3xi32> - spv.Return + spirv.func @int_vector_const() -> () "None" { + // CHECK: spirv.Constant dense<0> : vector<3xi32> + %0 = spirv.Constant dense<0> : vector<3xi32> + // CHECK: spirv.Constant dense<1> : vector<3xi32> + %1 = spirv.Constant dense<1> : vector<3xi32> + // CHECK: spirv.Constant dense<[2, -3, 4]> : vector<3xi32> + %2 = spirv.Constant dense<[2, -3, 4]> : vector<3xi32> + + %3 = spirv.IAdd %0, %1 : vector<3xi32> + %4 = spirv.IAdd %2, %3 : vector<3xi32> + spirv.Return } // CHECK-LABEL: @fp_vector_const - spv.func @fp_vector_const() -> () "None" { - // CHECK: spv.Constant dense<0.000000e+00> : vector<4xf32> - %0 = spv.Constant dense<0.> : vector<4xf32> - // CHECK: spv.Constant dense<-1.500000e+01> : vector<4xf32> - %1 = spv.Constant dense<-15.> : vector<4xf32> - // CHECK: spv.Constant dense<[7.500000e-01, -2.500000e-01, 1.000000e+01, 4.200000e+01]> : vector<4xf32> - %2 = spv.Constant dense<[0.75, -0.25, 10., 42.]> : vector<4xf32> - - %3 = spv.FAdd %0, %1 : vector<4xf32> - %4 = spv.FAdd %2, %3 : vector<4xf32> - spv.Return + spirv.func @fp_vector_const() -> () "None" { + // CHECK: spirv.Constant dense<0.000000e+00> : vector<4xf32> + %0 = spirv.Constant dense<0.> : vector<4xf32> + // CHECK: spirv.Constant dense<-1.500000e+01> : vector<4xf32> + %1 = spirv.Constant dense<-15.> : vector<4xf32> + // CHECK: spirv.Constant dense<[7.500000e-01, -2.500000e-01, 1.000000e+01, 4.200000e+01]> : vector<4xf32> + %2 = spirv.Constant dense<[0.75, -0.25, 10., 42.]> : vector<4xf32> + + %3 = spirv.FAdd %0, %1 : vector<4xf32> + %4 = spirv.FAdd %2, %3 : vector<4xf32> + spirv.Return } // CHECK-LABEL: @ui64_array_const - spv.func @ui64_array_const() -> (!spv.array<3xui64>) "None" { - // CHECK: spv.Constant [5, 6, 7] : !spv.array<3 x i64> - %0 = spv.Constant [5 : ui64, 6 : ui64, 7 : ui64] : !spv.array<3 x ui64> + spirv.func @ui64_array_const() -> (!spirv.array<3xui64>) "None" { + // CHECK: spirv.Constant [5, 6, 7] : !spirv.array<3 x i64> + %0 = spirv.Constant [5 : ui64, 6 : ui64, 7 : ui64] : !spirv.array<3 x ui64> - spv.ReturnValue %0: !spv.array<3xui64> + spirv.ReturnValue %0: !spirv.array<3xui64> } // CHECK-LABEL: @si32_array_const - spv.func @si32_array_const() -> (!spv.array<3xsi32>) "None" { - // CHECK: spv.Constant [5 : si32, 6 : si32, 7 : si32] : !spv.array<3 x si32> - %0 = spv.Constant [5 : si32, 6 : si32, 7 : si32] : !spv.array<3 x si32> + spirv.func @si32_array_const() -> (!spirv.array<3xsi32>) "None" { + // CHECK: spirv.Constant [5 : si32, 6 : si32, 7 : si32] : !spirv.array<3 x si32> + %0 = spirv.Constant [5 : si32, 6 : si32, 7 : si32] : !spirv.array<3 x si32> - spv.ReturnValue %0 : !spv.array<3xsi32> + spirv.ReturnValue %0 : !spirv.array<3xsi32> } // CHECK-LABEL: @float_array_const - spv.func @float_array_const() -> (!spv.array<2 x vector<2xf32>>) "None" { - // CHECK: spv.Constant [dense<3.000000e+00> : vector<2xf32>, dense<[4.000000e+00, 5.000000e+00]> : vector<2xf32>] : !spv.array<2 x vector<2xf32>> - %0 = spv.Constant [dense<3.0> : vector<2xf32>, dense<[4., 5.]> : vector<2xf32>] : !spv.array<2 x vector<2xf32>> + spirv.func @float_array_const() -> (!spirv.array<2 x vector<2xf32>>) "None" { + // CHECK: spirv.Constant [dense<3.000000e+00> : vector<2xf32>, dense<[4.000000e+00, 5.000000e+00]> : vector<2xf32>] : !spirv.array<2 x vector<2xf32>> + %0 = spirv.Constant [dense<3.0> : vector<2xf32>, dense<[4., 5.]> : vector<2xf32>] : !spirv.array<2 x vector<2xf32>> - spv.ReturnValue %0 : !spv.array<2 x vector<2xf32>> + spirv.ReturnValue %0 : !spirv.array<2 x vector<2xf32>> } // CHECK-LABEL: @ignore_not_used_const - spv.func @ignore_not_used_const() -> () "None" { - %0 = spv.Constant false - // CHECK-NEXT: spv.Return - spv.Return + spirv.func @ignore_not_used_const() -> () "None" { + %0 = spirv.Constant false + // CHECK-NEXT: spirv.Return + spirv.Return } // CHECK-LABEL: @materialize_const_at_each_use - spv.func @materialize_const_at_each_use() -> (i32) "None" { - // CHECK: %[[USE1:.*]] = spv.Constant 42 : i32 - // CHECK: %[[USE2:.*]] = spv.Constant 42 : i32 - // CHECK: spv.IAdd %[[USE1]], %[[USE2]] - %0 = spv.Constant 42 : i32 - %1 = spv.IAdd %0, %0 : i32 - spv.ReturnValue %1 : i32 + spirv.func @materialize_const_at_each_use() -> (i32) "None" { + // CHECK: %[[USE1:.*]] = spirv.Constant 42 : i32 + // CHECK: %[[USE2:.*]] = spirv.Constant 42 : i32 + // CHECK: spirv.IAdd %[[USE1]], %[[USE2]] + %0 = spirv.Constant 42 : i32 + %1 = spirv.IAdd %0, %0 : i32 + spirv.ReturnValue %1 : i32 } // CHECK-LABEL: @const_variable - spv.func @const_variable(%arg0 : i32, %arg1 : i32) -> () "None" { - // CHECK: %[[CONST:.*]] = spv.Constant 5 : i32 - // CHECK: spv.Variable init(%[[CONST]]) : !spv.ptr - // CHECK: spv.IAdd %arg0, %arg1 - %0 = spv.IAdd %arg0, %arg1 : i32 - %1 = spv.Constant 5 : i32 - %2 = spv.Variable init(%1) : !spv.ptr - %3 = spv.Load "Function" %2 : i32 - %4 = spv.IAdd %0, %3 : i32 - spv.Return + spirv.func @const_variable(%arg0 : i32, %arg1 : i32) -> () "None" { + // CHECK: %[[CONST:.*]] = spirv.Constant 5 : i32 + // CHECK: spirv.Variable init(%[[CONST]]) : !spirv.ptr + // CHECK: spirv.IAdd %arg0, %arg1 + %0 = spirv.IAdd %arg0, %arg1 : i32 + %1 = spirv.Constant 5 : i32 + %2 = spirv.Variable init(%1) : !spirv.ptr + %3 = spirv.Load "Function" %2 : i32 + %4 = spirv.IAdd %0, %3 : i32 + spirv.Return } // CHECK-LABEL: @multi_dimensions_const - spv.func @multi_dimensions_const() -> (!spv.array<2 x !spv.array<2 x !spv.array<3 x i32, stride=4>, stride=12>, stride=24>) "None" { - // CHECK: spv.Constant {{\[}}{{\[}}[1 : i32, 2 : i32, 3 : i32], [4 : i32, 5 : i32, 6 : i32]], {{\[}}[7 : i32, 8 : i32, 9 : i32], [10 : i32, 11 : i32, 12 : i32]]] : !spv.array<2 x !spv.array<2 x !spv.array<3 x i32, stride=4>, stride=12>, stride=24> - %0 = spv.Constant dense<[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]> : tensor<2x2x3xi32> : !spv.array<2 x !spv.array<2 x !spv.array<3 x i32, stride=4>, stride=12>, stride=24> - spv.ReturnValue %0 : !spv.array<2 x !spv.array<2 x !spv.array<3 x i32, stride=4>, stride=12>, stride=24> + spirv.func @multi_dimensions_const() -> (!spirv.array<2 x !spirv.array<2 x !spirv.array<3 x i32, stride=4>, stride=12>, stride=24>) "None" { + // CHECK: spirv.Constant {{\[}}{{\[}}[1 : i32, 2 : i32, 3 : i32], [4 : i32, 5 : i32, 6 : i32]], {{\[}}[7 : i32, 8 : i32, 9 : i32], [10 : i32, 11 : i32, 12 : i32]]] : !spirv.array<2 x !spirv.array<2 x !spirv.array<3 x i32, stride=4>, stride=12>, stride=24> + %0 = spirv.Constant dense<[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]> : tensor<2x2x3xi32> : !spirv.array<2 x !spirv.array<2 x !spirv.array<3 x i32, stride=4>, stride=12>, stride=24> + spirv.ReturnValue %0 : !spirv.array<2 x !spirv.array<2 x !spirv.array<3 x i32, stride=4>, stride=12>, stride=24> } // CHECK-LABEL: @multi_dimensions_splat_const - spv.func @multi_dimensions_splat_const() -> (!spv.array<2 x !spv.array<2 x !spv.array<3 x i32, stride=4>, stride=12>, stride=24>) "None" { - // CHECK: spv.Constant {{\[}}{{\[}}[1 : i32, 1 : i32, 1 : i32], [1 : i32, 1 : i32, 1 : i32]], {{\[}}[1 : i32, 1 : i32, 1 : i32], [1 : i32, 1 : i32, 1 : i32]]] : !spv.array<2 x !spv.array<2 x !spv.array<3 x i32, stride=4>, stride=12>, stride=24> - %0 = spv.Constant dense<1> : tensor<2x2x3xi32> : !spv.array<2 x !spv.array<2 x !spv.array<3 x i32, stride=4>, stride=12>, stride=24> - spv.ReturnValue %0 : !spv.array<2 x !spv.array<2 x !spv.array<3 x i32, stride=4>, stride=12>, stride=24> + spirv.func @multi_dimensions_splat_const() -> (!spirv.array<2 x !spirv.array<2 x !spirv.array<3 x i32, stride=4>, stride=12>, stride=24>) "None" { + // CHECK: spirv.Constant {{\[}}{{\[}}[1 : i32, 1 : i32, 1 : i32], [1 : i32, 1 : i32, 1 : i32]], {{\[}}[1 : i32, 1 : i32, 1 : i32], [1 : i32, 1 : i32, 1 : i32]]] : !spirv.array<2 x !spirv.array<2 x !spirv.array<3 x i32, stride=4>, stride=12>, stride=24> + %0 = spirv.Constant dense<1> : tensor<2x2x3xi32> : !spirv.array<2 x !spirv.array<2 x !spirv.array<3 x i32, stride=4>, stride=12>, stride=24> + spirv.ReturnValue %0 : !spirv.array<2 x !spirv.array<2 x !spirv.array<3 x i32, stride=4>, stride=12>, stride=24> } } diff --git a/mlir/test/Target/SPIRV/cooperative-matrix-ops.mlir b/mlir/test/Target/SPIRV/cooperative-matrix-ops.mlir --- a/mlir/test/Target/SPIRV/cooperative-matrix-ops.mlir +++ b/mlir/test/Target/SPIRV/cooperative-matrix-ops.mlir @@ -1,102 +1,102 @@ // RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK-LABEL: @cooperative_matrix_load - spv.func @cooperative_matrix_load(%ptr : !spv.ptr, %stride : i32, %b : i1) "None" { - // CHECK: {{%.*}} = spv.NV.CooperativeMatrixLoad {{%.*}}, {{%.*}}, {{%.*}} : !spv.ptr as !spv.coopmatrix<16x8xi32, Workgroup> - %0 = spv.NV.CooperativeMatrixLoad %ptr, %stride, %b : !spv.ptr as !spv.coopmatrix<16x8xi32, Workgroup> - spv.Return + spirv.func @cooperative_matrix_load(%ptr : !spirv.ptr, %stride : i32, %b : i1) "None" { + // CHECK: {{%.*}} = spirv.NV.CooperativeMatrixLoad {{%.*}}, {{%.*}}, {{%.*}} : !spirv.ptr as !spirv.coopmatrix<16x8xi32, Workgroup> + %0 = spirv.NV.CooperativeMatrixLoad %ptr, %stride, %b : !spirv.ptr as !spirv.coopmatrix<16x8xi32, Workgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_load_memaccess - spv.func @cooperative_matrix_load_memaccess(%ptr : !spv.ptr, %stride : i32, %b : i1) "None" { - // CHECK: {{%.*}} = spv.NV.CooperativeMatrixLoad {{%.*}}, {{%.*}}, {{%.*}} ["Volatile"] : !spv.ptr as !spv.coopmatrix<8x16xi32, Subgroup> - %0 = spv.NV.CooperativeMatrixLoad %ptr, %stride, %b ["Volatile"] : !spv.ptr as !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return + spirv.func @cooperative_matrix_load_memaccess(%ptr : !spirv.ptr, %stride : i32, %b : i1) "None" { + // CHECK: {{%.*}} = spirv.NV.CooperativeMatrixLoad {{%.*}}, {{%.*}}, {{%.*}} ["Volatile"] : !spirv.ptr as !spirv.coopmatrix<8x16xi32, Subgroup> + %0 = spirv.NV.CooperativeMatrixLoad %ptr, %stride, %b ["Volatile"] : !spirv.ptr as !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_store - spv.func @cooperative_matrix_store(%ptr : !spv.ptr, %stride : i32, %m : !spv.coopmatrix<16x8xi32, Workgroup>, %b : i1) "None" { - // CHECK: spv.NV.CooperativeMatrixStore {{%.*}}, {{%.*}}, {{%.*}} : !spv.ptr, !spv.coopmatrix<16x8xi32, Workgroup> - spv.NV.CooperativeMatrixStore %ptr, %m, %stride, %b : !spv.ptr, !spv.coopmatrix<16x8xi32, Workgroup> - spv.Return + spirv.func @cooperative_matrix_store(%ptr : !spirv.ptr, %stride : i32, %m : !spirv.coopmatrix<16x8xi32, Workgroup>, %b : i1) "None" { + // CHECK: spirv.NV.CooperativeMatrixStore {{%.*}}, {{%.*}}, {{%.*}} : !spirv.ptr, !spirv.coopmatrix<16x8xi32, Workgroup> + spirv.NV.CooperativeMatrixStore %ptr, %m, %stride, %b : !spirv.ptr, !spirv.coopmatrix<16x8xi32, Workgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_store_memaccess - spv.func @cooperative_matrix_store_memaccess(%ptr : !spv.ptr, %m : !spv.coopmatrix<8x16xi32, Subgroup>, %stride : i32, %b : i1) "None" { - // CHECK: spv.NV.CooperativeMatrixStore {{%.*}}, {{%.*}}, {{%.*}} ["Volatile"] : !spv.ptr, !spv.coopmatrix<8x16xi32, Subgroup> - spv.NV.CooperativeMatrixStore %ptr, %m, %stride, %b ["Volatile"] : !spv.ptr, !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return + spirv.func @cooperative_matrix_store_memaccess(%ptr : !spirv.ptr, %m : !spirv.coopmatrix<8x16xi32, Subgroup>, %stride : i32, %b : i1) "None" { + // CHECK: spirv.NV.CooperativeMatrixStore {{%.*}}, {{%.*}}, {{%.*}} ["Volatile"] : !spirv.ptr, !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.NV.CooperativeMatrixStore %ptr, %m, %stride, %b ["Volatile"] : !spirv.ptr, !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_length - spv.func @cooperative_matrix_length() -> i32 "None" { - // CHECK: {{%.*}} = spv.NV.CooperativeMatrixLength : !spv.coopmatrix<8x16xi32, Subgroup> - %0 = spv.NV.CooperativeMatrixLength : !spv.coopmatrix<8x16xi32, Subgroup> - spv.ReturnValue %0 : i32 + spirv.func @cooperative_matrix_length() -> i32 "None" { + // CHECK: {{%.*}} = spirv.NV.CooperativeMatrixLength : !spirv.coopmatrix<8x16xi32, Subgroup> + %0 = spirv.NV.CooperativeMatrixLength : !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.ReturnValue %0 : i32 } // CHECK-LABEL: @cooperative_matrix_muladd - spv.func @cooperative_matrix_muladd(%a : !spv.coopmatrix<8x16xi32, Subgroup>, %b : !spv.coopmatrix<16x8xi32, Subgroup>, %c : !spv.coopmatrix<8x8xi32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.NV.CooperativeMatrixMulAdd {{%.*}}, {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xi32, Subgroup>, !spv.coopmatrix<16x8xi32, Subgroup> -> !spv.coopmatrix<8x8xi32, Subgroup> - %r = spv.NV.CooperativeMatrixMulAdd %a, %b, %c : !spv.coopmatrix<8x16xi32, Subgroup>, !spv.coopmatrix<16x8xi32, Subgroup> -> !spv.coopmatrix<8x8xi32, Subgroup> - spv.Return + spirv.func @cooperative_matrix_muladd(%a : !spirv.coopmatrix<8x16xi32, Subgroup>, %b : !spirv.coopmatrix<16x8xi32, Subgroup>, %c : !spirv.coopmatrix<8x8xi32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.NV.CooperativeMatrixMulAdd {{%.*}}, {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xi32, Subgroup>, !spirv.coopmatrix<16x8xi32, Subgroup> -> !spirv.coopmatrix<8x8xi32, Subgroup> + %r = spirv.NV.CooperativeMatrixMulAdd %a, %b, %c : !spirv.coopmatrix<8x16xi32, Subgroup>, !spirv.coopmatrix<16x8xi32, Subgroup> -> !spirv.coopmatrix<8x8xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_add - spv.func @cooperative_matrix_add(%a : !spv.coopmatrix<8x16xi32, Subgroup>, %b : !spv.coopmatrix<8x16xi32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.IAdd {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xi32, Subgroup> - %r = spv.IAdd %a, %b : !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return + spirv.func @cooperative_matrix_add(%a : !spirv.coopmatrix<8x16xi32, Subgroup>, %b : !spirv.coopmatrix<8x16xi32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.IAdd {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xi32, Subgroup> + %r = spirv.IAdd %a, %b : !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_sub - spv.func @cooperative_matrix_sub(%a : !spv.coopmatrix<8x16xi32, Subgroup>, %b : !spv.coopmatrix<8x16xi32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.ISub {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xi32, Subgroup> - %r = spv.ISub %a, %b : !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return + spirv.func @cooperative_matrix_sub(%a : !spirv.coopmatrix<8x16xi32, Subgroup>, %b : !spirv.coopmatrix<8x16xi32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.ISub {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xi32, Subgroup> + %r = spirv.ISub %a, %b : !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_sdiv - spv.func @cooperative_matrix_sdiv(%a : !spv.coopmatrix<8x16xi32, Subgroup>, %b : !spv.coopmatrix<8x16xi32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.SDiv {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xi32, Subgroup> - %r = spv.SDiv %a, %b : !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return + spirv.func @cooperative_matrix_sdiv(%a : !spirv.coopmatrix<8x16xi32, Subgroup>, %b : !spirv.coopmatrix<8x16xi32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.SDiv {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xi32, Subgroup> + %r = spirv.SDiv %a, %b : !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_udiv - spv.func @cooperative_matrix_udiv(%a : !spv.coopmatrix<8x16xi32, Subgroup>, %b : !spv.coopmatrix<8x16xi32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.UDiv {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xi32, Subgroup> - %r = spv.UDiv %a, %b : !spv.coopmatrix<8x16xi32, Subgroup> - spv.Return + spirv.func @cooperative_matrix_udiv(%a : !spirv.coopmatrix<8x16xi32, Subgroup>, %b : !spirv.coopmatrix<8x16xi32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.UDiv {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xi32, Subgroup> + %r = spirv.UDiv %a, %b : !spirv.coopmatrix<8x16xi32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_fadd - spv.func @cooperative_matrix_fadd(%a : !spv.coopmatrix<8x16xf32, Subgroup>, %b : !spv.coopmatrix<8x16xf32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.FAdd {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xf32, Subgroup> - %r = spv.FAdd %a, %b : !spv.coopmatrix<8x16xf32, Subgroup> - spv.Return + spirv.func @cooperative_matrix_fadd(%a : !spirv.coopmatrix<8x16xf32, Subgroup>, %b : !spirv.coopmatrix<8x16xf32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.FAdd {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xf32, Subgroup> + %r = spirv.FAdd %a, %b : !spirv.coopmatrix<8x16xf32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_fsub - spv.func @cooperative_matrix_fsub(%a : !spv.coopmatrix<8x16xf32, Subgroup>, %b : !spv.coopmatrix<8x16xf32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.FSub {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xf32, Subgroup> - %r = spv.FSub %a, %b : !spv.coopmatrix<8x16xf32, Subgroup> - spv.Return + spirv.func @cooperative_matrix_fsub(%a : !spirv.coopmatrix<8x16xf32, Subgroup>, %b : !spirv.coopmatrix<8x16xf32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.FSub {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xf32, Subgroup> + %r = spirv.FSub %a, %b : !spirv.coopmatrix<8x16xf32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_fdiv - spv.func @cooperative_matrix_fdiv(%a : !spv.coopmatrix<8x16xf32, Subgroup>, %b : !spv.coopmatrix<8x16xf32, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.FDiv {{%.*}}, {{%.*}} : !spv.coopmatrix<8x16xf32, Subgroup> - %r = spv.FDiv %a, %b : !spv.coopmatrix<8x16xf32, Subgroup> - spv.Return + spirv.func @cooperative_matrix_fdiv(%a : !spirv.coopmatrix<8x16xf32, Subgroup>, %b : !spirv.coopmatrix<8x16xf32, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.FDiv {{%.*}}, {{%.*}} : !spirv.coopmatrix<8x16xf32, Subgroup> + %r = spirv.FDiv %a, %b : !spirv.coopmatrix<8x16xf32, Subgroup> + spirv.Return } // CHECK-LABEL: @cooperative_matrix_access_chain - spv.func @cooperative_matrix_access_chain(%a : !spv.ptr, Function>) -> !spv.ptr "None" { - %0 = spv.Constant 0: i32 - // CHECK: {{%.*}} = spv.AccessChain {{%.*}}[{{%.*}}] : !spv.ptr, Function>, i32 - %1 = spv.AccessChain %a[%0] : !spv.ptr, Function>, i32 - spv.ReturnValue %1 : !spv.ptr + spirv.func @cooperative_matrix_access_chain(%a : !spirv.ptr, Function>) -> !spirv.ptr "None" { + %0 = spirv.Constant 0: i32 + // CHECK: {{%.*}} = spirv.AccessChain {{%.*}}[{{%.*}}] : !spirv.ptr, Function>, i32 + %1 = spirv.AccessChain %a[%0] : !spirv.ptr, Function>, i32 + spirv.ReturnValue %1 : !spirv.ptr } } diff --git a/mlir/test/Target/SPIRV/debug.mlir b/mlir/test/Target/SPIRV/debug.mlir --- a/mlir/test/Target/SPIRV/debug.mlir +++ b/mlir/test/Target/SPIRV/debug.mlir @@ -1,146 +1,146 @@ // RUN: mlir-translate -test-spirv-roundtrip-debug -mlir-print-debuginfo -mlir-print-local-scope %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK: loc({{".*debug.mlir"}}:5:3) - spv.GlobalVariable @var0 bind(0, 1) : !spv.ptr - spv.func @arithmetic(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) "None" { + spirv.GlobalVariable @var0 bind(0, 1) : !spirv.ptr + spirv.func @arithmetic(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) "None" { // CHECK: loc({{".*debug.mlir"}}:8:10) - %0 = spv.FAdd %arg0, %arg1 : vector<4xf32> + %0 = spirv.FAdd %arg0, %arg1 : vector<4xf32> // CHECK: loc({{".*debug.mlir"}}:10:10) - %1 = spv.FNegate %arg0 : vector<4xf32> - spv.Return + %1 = spirv.FNegate %arg0 : vector<4xf32> + spirv.Return } - spv.func @atomic(%ptr: !spv.ptr, %value: i32, %comparator: i32) "None" { + spirv.func @atomic(%ptr: !spirv.ptr, %value: i32, %comparator: i32) "None" { // CHECK: loc({{".*debug.mlir"}}:16:10) - %1 = spv.AtomicAnd "Device" "None" %ptr, %value : !spv.ptr - spv.Return + %1 = spirv.AtomicAnd "Device" "None" %ptr, %value : !spirv.ptr + spirv.Return } - spv.func @bitwiser(%arg0 : i32, %arg1 : i32) "None" { + spirv.func @bitwiser(%arg0 : i32, %arg1 : i32) "None" { // CHECK: loc({{".*debug.mlir"}}:22:10) - %0 = spv.BitwiseAnd %arg0, %arg1 : i32 - spv.Return + %0 = spirv.BitwiseAnd %arg0, %arg1 : i32 + spirv.Return } - spv.func @convert(%arg0 : f32) "None" { + spirv.func @convert(%arg0 : f32) "None" { // CHECK: loc({{".*debug.mlir"}}:28:10) - %0 = spv.ConvertFToU %arg0 : f32 to i32 - spv.Return + %0 = spirv.ConvertFToU %arg0 : f32 to i32 + spirv.Return } - spv.func @composite(%arg0 : !spv.struct<(f32, !spv.struct<(!spv.array<4xf32>, f32)>)>, %arg1: !spv.array<4xf32>, %arg2 : f32, %arg3 : f32) "None" { + spirv.func @composite(%arg0 : !spirv.struct<(f32, !spirv.struct<(!spirv.array<4xf32>, f32)>)>, %arg1: !spirv.array<4xf32>, %arg2 : f32, %arg3 : f32) "None" { // CHECK: loc({{".*debug.mlir"}}:34:10) - %0 = spv.CompositeInsert %arg1, %arg0[1 : i32, 0 : i32] : !spv.array<4xf32> into !spv.struct<(f32, !spv.struct<(!spv.array<4xf32>, f32)>)> + %0 = spirv.CompositeInsert %arg1, %arg0[1 : i32, 0 : i32] : !spirv.array<4xf32> into !spirv.struct<(f32, !spirv.struct<(!spirv.array<4xf32>, f32)>)> // CHECK: loc({{".*debug.mlir"}}:36:10) - %1 = spv.CompositeConstruct %arg2, %arg3 : (f32, f32) -> vector<2xf32> - spv.Return + %1 = spirv.CompositeConstruct %arg2, %arg3 : (f32, f32) -> vector<2xf32> + spirv.Return } - spv.func @group_non_uniform(%val: f32) "None" { + spirv.func @group_non_uniform(%val: f32) "None" { // CHECK: loc({{".*debug.mlir"}}:42:10) - %0 = spv.GroupNonUniformFAdd "Workgroup" "Reduce" %val : f32 - spv.Return + %0 = spirv.GroupNonUniformFAdd "Workgroup" "Reduce" %val : f32 + spirv.Return } - spv.func @local_var() "None" { - %zero = spv.Constant 0: i32 + spirv.func @local_var() "None" { + %zero = spirv.Constant 0: i32 // CHECK: loc({{".*debug.mlir"}}:49:12) - %var = spv.Variable init(%zero) : !spv.ptr - spv.Return + %var = spirv.Variable init(%zero) : !spirv.ptr + spirv.Return } - spv.func @logical(%arg0: i32, %arg1: i32) "None" { + spirv.func @logical(%arg0: i32, %arg1: i32) "None" { // CHECK: loc({{".*debug.mlir"}}:55:10) - %0 = spv.IEqual %arg0, %arg1 : i32 - spv.Return + %0 = spirv.IEqual %arg0, %arg1 : i32 + spirv.Return } - spv.func @memory_accesses(%arg0 : !spv.ptr>, StorageBuffer>, %arg1 : i32, %arg2 : i32) "None" { + spirv.func @memory_accesses(%arg0 : !spirv.ptr>, StorageBuffer>, %arg1 : i32, %arg2 : i32) "None" { // CHECK: loc({{".*debug.mlir"}}:61:10) - %2 = spv.AccessChain %arg0[%arg1, %arg2] : !spv.ptr>, StorageBuffer>, i32, i32 + %2 = spirv.AccessChain %arg0[%arg1, %arg2] : !spirv.ptr>, StorageBuffer>, i32, i32 // CHECK: loc({{".*debug.mlir"}}:63:10) - %3 = spv.Load "StorageBuffer" %2 : f32 + %3 = spirv.Load "StorageBuffer" %2 : f32 // CHECK: loc({{.*debug.mlir"}}:65:5) - spv.Store "StorageBuffer" %2, %3 : f32 + spirv.Store "StorageBuffer" %2, %3 : f32 // CHECK: loc({{".*debug.mlir"}}:67:5) - spv.Return + spirv.Return } - spv.func @loop(%count : i32) -> () "None" { - %zero = spv.Constant 0: i32 - %one = spv.Constant 1: i32 - %ivar = spv.Variable init(%zero) : !spv.ptr - %jvar = spv.Variable init(%zero) : !spv.ptr - spv.mlir.loop { + spirv.func @loop(%count : i32) -> () "None" { + %zero = spirv.Constant 0: i32 + %one = spirv.Constant 1: i32 + %ivar = spirv.Variable init(%zero) : !spirv.ptr + %jvar = spirv.Variable init(%zero) : !spirv.ptr + spirv.mlir.loop { // CHECK: loc({{".*debug.mlir"}}:75:5) - spv.Branch ^header + spirv.Branch ^header ^header: - %ival0 = spv.Load "Function" %ivar : i32 - %icmp = spv.SLessThan %ival0, %count : i32 + %ival0 = spirv.Load "Function" %ivar : i32 + %icmp = spirv.SLessThan %ival0, %count : i32 // CHECK: loc({{".*debug.mlir"}}:75:5) - spv.BranchConditional %icmp, ^body, ^merge + spirv.BranchConditional %icmp, ^body, ^merge ^body: - spv.Store "Function" %jvar, %zero : i32 - spv.mlir.loop { + spirv.Store "Function" %jvar, %zero : i32 + spirv.mlir.loop { // CHECK: loc({{".*debug.mlir"}}:85:7) - spv.Branch ^header + spirv.Branch ^header ^header: - %jval0 = spv.Load "Function" %jvar : i32 - %jcmp = spv.SLessThan %jval0, %count : i32 + %jval0 = spirv.Load "Function" %jvar : i32 + %jcmp = spirv.SLessThan %jval0, %count : i32 // CHECK: loc({{".*debug.mlir"}}:85:7) - spv.BranchConditional %jcmp, ^body, ^merge + spirv.BranchConditional %jcmp, ^body, ^merge ^body: // CHECK: loc({{".*debug.mlir"}}:95:9) - spv.Branch ^continue + spirv.Branch ^continue ^continue: - %jval1 = spv.Load "Function" %jvar : i32 - %add = spv.IAdd %jval1, %one : i32 - spv.Store "Function" %jvar, %add : i32 + %jval1 = spirv.Load "Function" %jvar : i32 + %add = spirv.IAdd %jval1, %one : i32 + spirv.Store "Function" %jvar, %add : i32 // CHECK: loc({{".*debug.mlir"}}:101:9) - spv.Branch ^header + spirv.Branch ^header ^merge: // CHECK: loc({{".*debug.mlir"}}:85:7) - spv.mlir.merge + spirv.mlir.merge // CHECK: loc({{".*debug.mlir"}}:85:7) } // CHECK: loc({{".*debug.mlir"}}:108:7) - spv.Branch ^continue + spirv.Branch ^continue ^continue: - %ival1 = spv.Load "Function" %ivar : i32 - %add = spv.IAdd %ival1, %one : i32 - spv.Store "Function" %ivar, %add : i32 + %ival1 = spirv.Load "Function" %ivar : i32 + %add = spirv.IAdd %ival1, %one : i32 + spirv.Store "Function" %ivar, %add : i32 // CHECK: loc({{".*debug.mlir"}}:114:7) - spv.Branch ^header + spirv.Branch ^header ^merge: // CHECK: loc({{".*debug.mlir"}}:75:5) - spv.mlir.merge + spirv.mlir.merge // CHECK: loc({{".*debug.mlir"}}:75:5) } - spv.Return + spirv.Return } - spv.func @selection(%cond: i1) -> () "None" { - %zero = spv.Constant 0: i32 - %one = spv.Constant 1: i32 - %two = spv.Constant 2: i32 - %var = spv.Variable init(%zero) : !spv.ptr - spv.mlir.selection { + spirv.func @selection(%cond: i1) -> () "None" { + %zero = spirv.Constant 0: i32 + %one = spirv.Constant 1: i32 + %two = spirv.Constant 2: i32 + %var = spirv.Variable init(%zero) : !spirv.ptr + spirv.mlir.selection { // CHECK: loc({{".*debug.mlir"}}:128:5) - spv.BranchConditional %cond [5, 10], ^then, ^else + spirv.BranchConditional %cond [5, 10], ^then, ^else ^then: - spv.Store "Function" %var, %one : i32 + spirv.Store "Function" %var, %one : i32 // CHECK: loc({{".*debug.mlir"}}:134:7) - spv.Branch ^merge + spirv.Branch ^merge ^else: - spv.Store "Function" %var, %two : i32 + spirv.Store "Function" %var, %two : i32 // CHECK: loc({{".*debug.mlir"}}:138:7) - spv.Branch ^merge + spirv.Branch ^merge ^merge: // CHECK: loc({{".*debug.mlir"}}:128:5) - spv.mlir.merge + spirv.mlir.merge // CHECK: loc({{".*debug.mlir"}}:128:5) } - spv.Return + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/decorations.mlir b/mlir/test/Target/SPIRV/decorations.mlir --- a/mlir/test/Target/SPIRV/decorations.mlir +++ b/mlir/test/Target/SPIRV/decorations.mlir @@ -1,58 +1,58 @@ // RUN: mlir-translate -split-input-file -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK: location = 0 : i32 - spv.GlobalVariable @var {location = 0 : i32} : !spv.ptr, Input> + spirv.GlobalVariable @var {location = 0 : i32} : !spirv.ptr, Input> } // ----- -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK: no_perspective - spv.GlobalVariable @var {no_perspective} : !spv.ptr, Input> + spirv.GlobalVariable @var {no_perspective} : !spirv.ptr, Input> } // ----- -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK: flat - spv.GlobalVariable @var {flat} : !spv.ptr + spirv.GlobalVariable @var {flat} : !spirv.ptr } // ----- -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK: aliased // CHECK: aliased - spv.GlobalVariable @var1 bind(0, 0) {aliased} : !spv.ptr[0])>, StorageBuffer> - spv.GlobalVariable @var2 bind(0, 0) {aliased} : !spv.ptr[0])>, StorageBuffer> + spirv.GlobalVariable @var1 bind(0, 0) {aliased} : !spirv.ptr[0])>, StorageBuffer> + spirv.GlobalVariable @var2 bind(0, 0) {aliased} : !spirv.ptr[0])>, StorageBuffer> } // ----- -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK: non_readable - spv.GlobalVariable @var bind(0, 0) {non_readable} : !spv.ptr[0])>, StorageBuffer> + spirv.GlobalVariable @var bind(0, 0) {non_readable} : !spirv.ptr[0])>, StorageBuffer> } // ----- -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK: non_writable - spv.GlobalVariable @var bind(0, 0) {non_writable} : !spv.ptr[0])>, StorageBuffer> + spirv.GlobalVariable @var bind(0, 0) {non_writable} : !spirv.ptr[0])>, StorageBuffer> } // ----- -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK: restrict - spv.GlobalVariable @var bind(0, 0) {restrict} : !spv.ptr[0])>, StorageBuffer> + spirv.GlobalVariable @var bind(0, 0) {restrict} : !spirv.ptr[0])>, StorageBuffer> } // ----- -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK: relaxed_precision - spv.GlobalVariable @var {location = 0 : i32, relaxed_precision} : !spv.ptr, Output> + spirv.GlobalVariable @var {location = 0 : i32, relaxed_precision} : !spirv.ptr, Output> } diff --git a/mlir/test/Target/SPIRV/entry-point.mlir b/mlir/test/Target/SPIRV/entry-point.mlir --- a/mlir/test/Target/SPIRV/entry-point.mlir +++ b/mlir/test/Target/SPIRV/entry-point.mlir @@ -1,27 +1,27 @@ // RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - spv.func @noop() -> () "None" { - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @noop() -> () "None" { + spirv.Return } - // CHECK: spv.EntryPoint "GLCompute" @noop - // CHECK-NEXT: spv.ExecutionMode @noop "ContractionOff" - spv.EntryPoint "GLCompute" @noop - spv.ExecutionMode @noop "ContractionOff" + // CHECK: spirv.EntryPoint "GLCompute" @noop + // CHECK-NEXT: spirv.ExecutionMode @noop "ContractionOff" + spirv.EntryPoint "GLCompute" @noop + spirv.ExecutionMode @noop "ContractionOff" } // ----- -spv.module Logical GLSL450 requires #spv.vce { - // CHECK: spv.GlobalVariable @var2 : !spv.ptr - // CHECK-NEXT: spv.GlobalVariable @var3 : !spv.ptr - // CHECK-NEXT: spv.func @noop({{%.*}}: !spv.ptr, {{%.*}}: !spv.ptr) "None" - // CHECK: spv.EntryPoint "GLCompute" @noop, @var2, @var3 - spv.GlobalVariable @var2 : !spv.ptr - spv.GlobalVariable @var3 : !spv.ptr - spv.func @noop(%arg0 : !spv.ptr, %arg1 : !spv.ptr) -> () "None" { - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + // CHECK: spirv.GlobalVariable @var2 : !spirv.ptr + // CHECK-NEXT: spirv.GlobalVariable @var3 : !spirv.ptr + // CHECK-NEXT: spirv.func @noop({{%.*}}: !spirv.ptr, {{%.*}}: !spirv.ptr) "None" + // CHECK: spirv.EntryPoint "GLCompute" @noop, @var2, @var3 + spirv.GlobalVariable @var2 : !spirv.ptr + spirv.GlobalVariable @var3 : !spirv.ptr + spirv.func @noop(%arg0 : !spirv.ptr, %arg1 : !spirv.ptr) -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @noop, @var2, @var3 - spv.ExecutionMode @noop "ContractionOff" + spirv.EntryPoint "GLCompute" @noop, @var2, @var3 + spirv.ExecutionMode @noop "ContractionOff" } diff --git a/mlir/test/Target/SPIRV/execution-mode.mlir b/mlir/test/Target/SPIRV/execution-mode.mlir --- a/mlir/test/Target/SPIRV/execution-mode.mlir +++ b/mlir/test/Target/SPIRV/execution-mode.mlir @@ -1,10 +1,10 @@ // RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - spv.func @foo() -> () "None" { - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @foo() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @foo - // CHECK: spv.ExecutionMode @foo "LocalSizeHint", 3, 4, 5 - spv.ExecutionMode @foo "LocalSizeHint", 3, 4, 5 + spirv.EntryPoint "GLCompute" @foo + // CHECK: spirv.ExecutionMode @foo "LocalSizeHint", 3, 4, 5 + spirv.ExecutionMode @foo "LocalSizeHint", 3, 4, 5 } diff --git a/mlir/test/Target/SPIRV/function-call.mlir b/mlir/test/Target/SPIRV/function-call.mlir --- a/mlir/test/Target/SPIRV/function-call.mlir +++ b/mlir/test/Target/SPIRV/function-call.mlir @@ -1,53 +1,53 @@ // RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - spv.GlobalVariable @var1 : !spv.ptr, Input> - spv.func @fmain() -> i32 "None" { - %0 = spv.Constant 16 : i32 - %1 = spv.mlir.addressof @var1 : !spv.ptr, Input> - // CHECK: {{%.*}} = spv.FunctionCall @f_0({{%.*}}) : (i32) -> i32 - %3 = spv.FunctionCall @f_0(%0) : (i32) -> i32 - // CHECK: spv.FunctionCall @f_1({{%.*}}, {{%.*}}) : (i32, !spv.ptr, Input>) -> () - spv.FunctionCall @f_1(%3, %1) : (i32, !spv.ptr, Input>) -> () - // CHECK: {{%.*}} = spv.FunctionCall @f_2({{%.*}}) : (!spv.ptr, Input>) -> !spv.ptr, Input> - %4 = spv.FunctionCall @f_2(%1) : (!spv.ptr, Input>) -> !spv.ptr, Input> - spv.ReturnValue %3 : i32 +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.GlobalVariable @var1 : !spirv.ptr, Input> + spirv.func @fmain() -> i32 "None" { + %0 = spirv.Constant 16 : i32 + %1 = spirv.mlir.addressof @var1 : !spirv.ptr, Input> + // CHECK: {{%.*}} = spirv.FunctionCall @f_0({{%.*}}) : (i32) -> i32 + %3 = spirv.FunctionCall @f_0(%0) : (i32) -> i32 + // CHECK: spirv.FunctionCall @f_1({{%.*}}, {{%.*}}) : (i32, !spirv.ptr, Input>) -> () + spirv.FunctionCall @f_1(%3, %1) : (i32, !spirv.ptr, Input>) -> () + // CHECK: {{%.*}} = spirv.FunctionCall @f_2({{%.*}}) : (!spirv.ptr, Input>) -> !spirv.ptr, Input> + %4 = spirv.FunctionCall @f_2(%1) : (!spirv.ptr, Input>) -> !spirv.ptr, Input> + spirv.ReturnValue %3 : i32 } - spv.func @f_0(%arg0 : i32) -> i32 "None" { - spv.ReturnValue %arg0 : i32 + spirv.func @f_0(%arg0 : i32) -> i32 "None" { + spirv.ReturnValue %arg0 : i32 } - spv.func @f_1(%arg0 : i32, %arg1 : !spv.ptr, Input>) -> () "None" { - spv.Return + spirv.func @f_1(%arg0 : i32, %arg1 : !spirv.ptr, Input>) -> () "None" { + spirv.Return } - spv.func @f_2(%arg0 : !spv.ptr, Input>) -> !spv.ptr, Input> "None" { - spv.ReturnValue %arg0 : !spv.ptr, Input> + spirv.func @f_2(%arg0 : !spirv.ptr, Input>) -> !spirv.ptr, Input> "None" { + spirv.ReturnValue %arg0 : !spirv.ptr, Input> } - spv.func @f_loop_with_function_call(%count : i32) -> () "None" { - %zero = spv.Constant 0: i32 - %var = spv.Variable init(%zero) : !spv.ptr - spv.mlir.loop { - spv.Branch ^header + spirv.func @f_loop_with_function_call(%count : i32) -> () "None" { + %zero = spirv.Constant 0: i32 + %var = spirv.Variable init(%zero) : !spirv.ptr + spirv.mlir.loop { + spirv.Branch ^header ^header: - %val0 = spv.Load "Function" %var : i32 - %cmp = spv.SLessThan %val0, %count : i32 - spv.BranchConditional %cmp, ^body, ^merge + %val0 = spirv.Load "Function" %var : i32 + %cmp = spirv.SLessThan %val0, %count : i32 + spirv.BranchConditional %cmp, ^body, ^merge ^body: - spv.Branch ^continue + spirv.Branch ^continue ^continue: - // CHECK: spv.FunctionCall @f_inc({{%.*}}) : (!spv.ptr) -> () - spv.FunctionCall @f_inc(%var) : (!spv.ptr) -> () - spv.Branch ^header + // CHECK: spirv.FunctionCall @f_inc({{%.*}}) : (!spirv.ptr) -> () + spirv.FunctionCall @f_inc(%var) : (!spirv.ptr) -> () + spirv.Branch ^header ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } - spv.func @f_inc(%arg0 : !spv.ptr) -> () "None" { - %one = spv.Constant 1 : i32 - %0 = spv.Load "Function" %arg0 : i32 - %1 = spv.IAdd %0, %one : i32 - spv.Store "Function" %arg0, %1 : i32 - spv.Return + spirv.func @f_inc(%arg0 : !spirv.ptr) -> () "None" { + %one = spirv.Constant 1 : i32 + %0 = spirv.Load "Function" %arg0 : i32 + %1 = spirv.IAdd %0, %one : i32 + spirv.Store "Function" %arg0, %1 : i32 + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/gl-ops.mlir b/mlir/test/Target/SPIRV/gl-ops.mlir --- a/mlir/test/Target/SPIRV/gl-ops.mlir +++ b/mlir/test/Target/SPIRV/gl-ops.mlir @@ -1,84 +1,84 @@ // RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - spv.func @math(%arg0 : f32, %arg1 : f32, %arg2 : i32) "None" { - // CHECK: {{%.*}} = spv.GL.Exp {{%.*}} : f32 - %0 = spv.GL.Exp %arg0 : f32 - // CHECK: {{%.*}} = spv.GL.Sqrt {{%.*}} : f32 - %2 = spv.GL.Sqrt %arg0 : f32 - // CHECK: {{%.*}} = spv.GL.Cos {{%.*}} : f32 - %3 = spv.GL.Cos %arg0 : f32 - // CHECK: {{%.*}} = spv.GL.Sin {{%.*}} : f32 - %4 = spv.GL.Sin %arg0 : f32 - // CHECK: {{%.*}} = spv.GL.Tan {{%.*}} : f32 - %5 = spv.GL.Tan %arg0 : f32 - // CHECK: {{%.*}} = spv.GL.Acos {{%.*}} : f32 - %6 = spv.GL.Acos %arg0 : f32 - // CHECK: {{%.*}} = spv.GL.Asin {{%.*}} : f32 - %7 = spv.GL.Asin %arg0 : f32 - // CHECK: {{%.*}} = spv.GL.Atan {{%.*}} : f32 - %8 = spv.GL.Atan %arg0 : f32 - // CHECK: {{%.*}} = spv.GL.Sinh {{%.*}} : f32 - %9 = spv.GL.Sinh %arg0 : f32 - // CHECK: {{%.*}} = spv.GL.Cosh {{%.*}} : f32 - %10 = spv.GL.Cosh %arg0 : f32 - // CHECK: {{%.*}} = spv.GL.Pow {{%.*}} : f32 - %11 = spv.GL.Pow %arg0, %arg1 : f32 - // CHECK: {{%.*}} = spv.GL.Round {{%.*}} : f32 - %12 = spv.GL.Round %arg0 : f32 - // CHECK: {{%.*}} = spv.GL.FrexpStruct {{%.*}} : f32 -> !spv.struct<(f32, i32)> - %13 = spv.GL.FrexpStruct %arg0 : f32 -> !spv.struct<(f32, i32)> - // CHECK: {{%.*}} = spv.GL.Ldexp {{%.*}} : f32, {{%.*}} : i32 -> f32 - %14 = spv.GL.Ldexp %arg0 : f32, %arg2 : i32 -> f32 - // CHECK: {{%.*}} = spv.GL.FMix {{%.*}} : f32, {{%.*}} : f32, {{%.*}} : f32 -> f32 - %15 = spv.GL.FMix %arg0 : f32, %arg1 : f32, %arg0 : f32 -> f32 - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @math(%arg0 : f32, %arg1 : f32, %arg2 : i32) "None" { + // CHECK: {{%.*}} = spirv.GL.Exp {{%.*}} : f32 + %0 = spirv.GL.Exp %arg0 : f32 + // CHECK: {{%.*}} = spirv.GL.Sqrt {{%.*}} : f32 + %2 = spirv.GL.Sqrt %arg0 : f32 + // CHECK: {{%.*}} = spirv.GL.Cos {{%.*}} : f32 + %3 = spirv.GL.Cos %arg0 : f32 + // CHECK: {{%.*}} = spirv.GL.Sin {{%.*}} : f32 + %4 = spirv.GL.Sin %arg0 : f32 + // CHECK: {{%.*}} = spirv.GL.Tan {{%.*}} : f32 + %5 = spirv.GL.Tan %arg0 : f32 + // CHECK: {{%.*}} = spirv.GL.Acos {{%.*}} : f32 + %6 = spirv.GL.Acos %arg0 : f32 + // CHECK: {{%.*}} = spirv.GL.Asin {{%.*}} : f32 + %7 = spirv.GL.Asin %arg0 : f32 + // CHECK: {{%.*}} = spirv.GL.Atan {{%.*}} : f32 + %8 = spirv.GL.Atan %arg0 : f32 + // CHECK: {{%.*}} = spirv.GL.Sinh {{%.*}} : f32 + %9 = spirv.GL.Sinh %arg0 : f32 + // CHECK: {{%.*}} = spirv.GL.Cosh {{%.*}} : f32 + %10 = spirv.GL.Cosh %arg0 : f32 + // CHECK: {{%.*}} = spirv.GL.Pow {{%.*}} : f32 + %11 = spirv.GL.Pow %arg0, %arg1 : f32 + // CHECK: {{%.*}} = spirv.GL.Round {{%.*}} : f32 + %12 = spirv.GL.Round %arg0 : f32 + // CHECK: {{%.*}} = spirv.GL.FrexpStruct {{%.*}} : f32 -> !spirv.struct<(f32, i32)> + %13 = spirv.GL.FrexpStruct %arg0 : f32 -> !spirv.struct<(f32, i32)> + // CHECK: {{%.*}} = spirv.GL.Ldexp {{%.*}} : f32, {{%.*}} : i32 -> f32 + %14 = spirv.GL.Ldexp %arg0 : f32, %arg2 : i32 -> f32 + // CHECK: {{%.*}} = spirv.GL.FMix {{%.*}} : f32, {{%.*}} : f32, {{%.*}} : f32 -> f32 + %15 = spirv.GL.FMix %arg0 : f32, %arg1 : f32, %arg0 : f32 -> f32 + spirv.Return } - spv.func @maxmin(%arg0 : f32, %arg1 : f32, %arg2 : i32, %arg3 : i32) "None" { - // CHECK: {{%.*}} = spv.GL.FMax {{%.*}}, {{%.*}} : f32 - %1 = spv.GL.FMax %arg0, %arg1 : f32 - // CHECK: {{%.*}} = spv.GL.SMax {{%.*}}, {{%.*}} : i32 - %2 = spv.GL.SMax %arg2, %arg3 : i32 - // CHECK: {{%.*}} = spv.GL.UMax {{%.*}}, {{%.*}} : i32 - %3 = spv.GL.UMax %arg2, %arg3 : i32 + spirv.func @maxmin(%arg0 : f32, %arg1 : f32, %arg2 : i32, %arg3 : i32) "None" { + // CHECK: {{%.*}} = spirv.GL.FMax {{%.*}}, {{%.*}} : f32 + %1 = spirv.GL.FMax %arg0, %arg1 : f32 + // CHECK: {{%.*}} = spirv.GL.SMax {{%.*}}, {{%.*}} : i32 + %2 = spirv.GL.SMax %arg2, %arg3 : i32 + // CHECK: {{%.*}} = spirv.GL.UMax {{%.*}}, {{%.*}} : i32 + %3 = spirv.GL.UMax %arg2, %arg3 : i32 - // CHECK: {{%.*}} = spv.GL.FMin {{%.*}}, {{%.*}} : f32 - %4 = spv.GL.FMin %arg0, %arg1 : f32 - // CHECK: {{%.*}} = spv.GL.SMin {{%.*}}, {{%.*}} : i32 - %5 = spv.GL.SMin %arg2, %arg3 : i32 - // CHECK: {{%.*}} = spv.GL.UMin {{%.*}}, {{%.*}} : i32 - %6 = spv.GL.UMin %arg2, %arg3 : i32 - spv.Return + // CHECK: {{%.*}} = spirv.GL.FMin {{%.*}}, {{%.*}} : f32 + %4 = spirv.GL.FMin %arg0, %arg1 : f32 + // CHECK: {{%.*}} = spirv.GL.SMin {{%.*}}, {{%.*}} : i32 + %5 = spirv.GL.SMin %arg2, %arg3 : i32 + // CHECK: {{%.*}} = spirv.GL.UMin {{%.*}}, {{%.*}} : i32 + %6 = spirv.GL.UMin %arg2, %arg3 : i32 + spirv.Return } - spv.func @fclamp(%arg0 : f32, %arg1 : f32, %arg2 : f32) "None" { - // CHECK: spv.GL.FClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32 - %13 = spv.GL.FClamp %arg0, %arg1, %arg2 : f32 - spv.Return + spirv.func @fclamp(%arg0 : f32, %arg1 : f32, %arg2 : f32) "None" { + // CHECK: spirv.GL.FClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32 + %13 = spirv.GL.FClamp %arg0, %arg1, %arg2 : f32 + spirv.Return } - spv.func @uclamp(%arg0 : ui32, %arg1 : ui32, %arg2 : ui32) "None" { - // CHECK: spv.GL.UClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : i32 - %13 = spv.GL.UClamp %arg0, %arg1, %arg2 : ui32 - spv.Return + spirv.func @uclamp(%arg0 : ui32, %arg1 : ui32, %arg2 : ui32) "None" { + // CHECK: spirv.GL.UClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : i32 + %13 = spirv.GL.UClamp %arg0, %arg1, %arg2 : ui32 + spirv.Return } - spv.func @sclamp(%arg0 : si32, %arg1 : si32, %arg2 : si32) "None" { - // CHECK: spv.GL.SClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : si32 - %13 = spv.GL.SClamp %arg0, %arg1, %arg2 : si32 - spv.Return + spirv.func @sclamp(%arg0 : si32, %arg1 : si32, %arg2 : si32) "None" { + // CHECK: spirv.GL.SClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : si32 + %13 = spirv.GL.SClamp %arg0, %arg1, %arg2 : si32 + spirv.Return } - spv.func @fma(%arg0 : f32, %arg1 : f32, %arg2 : f32) "None" { - // CHECK: spv.GL.Fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32 - %13 = spv.GL.Fma %arg0, %arg1, %arg2 : f32 - spv.Return + spirv.func @fma(%arg0 : f32, %arg1 : f32, %arg2 : f32) "None" { + // CHECK: spirv.GL.Fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32 + %13 = spirv.GL.Fma %arg0, %arg1, %arg2 : f32 + spirv.Return } - spv.func @findumsb(%arg0 : i32) "None" { - // CHECK: spv.GL.FindUMsb {{%.*}} : i32 - %2 = spv.GL.FindUMsb %arg0 : i32 - spv.Return + spirv.func @findumsb(%arg0 : i32) "None" { + // CHECK: spirv.GL.FindUMsb {{%.*}} : i32 + %2 = spirv.GL.FindUMsb %arg0 : i32 + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/global-variable.mlir b/mlir/test/Target/SPIRV/global-variable.mlir --- a/mlir/test/Target/SPIRV/global-variable.mlir +++ b/mlir/test/Target/SPIRV/global-variable.mlir @@ -1,36 +1,36 @@ // RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s -// CHECK: spv.GlobalVariable @var0 bind(1, 0) : !spv.ptr -// CHECK-NEXT: spv.GlobalVariable @var1 bind(0, 1) : !spv.ptr -// CHECK-NEXT: spv.GlobalVariable @var2 built_in("GlobalInvocationId") : !spv.ptr, Input> -// CHECK-NEXT: spv.GlobalVariable @var3 built_in("GlobalInvocationId") : !spv.ptr, Input> +// CHECK: spirv.GlobalVariable @var0 bind(1, 0) : !spirv.ptr +// CHECK-NEXT: spirv.GlobalVariable @var1 bind(0, 1) : !spirv.ptr +// CHECK-NEXT: spirv.GlobalVariable @var2 built_in("GlobalInvocationId") : !spirv.ptr, Input> +// CHECK-NEXT: spirv.GlobalVariable @var3 built_in("GlobalInvocationId") : !spirv.ptr, Input> -spv.module Logical GLSL450 requires #spv.vce { - spv.GlobalVariable @var0 bind(1, 0) : !spv.ptr - spv.GlobalVariable @var1 bind(0, 1) : !spv.ptr - spv.GlobalVariable @var2 {built_in = "GlobalInvocationId"} : !spv.ptr, Input> - spv.GlobalVariable @var3 built_in("GlobalInvocationId") : !spv.ptr, Input> +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.GlobalVariable @var0 bind(1, 0) : !spirv.ptr + spirv.GlobalVariable @var1 bind(0, 1) : !spirv.ptr + spirv.GlobalVariable @var2 {built_in = "GlobalInvocationId"} : !spirv.ptr, Input> + spirv.GlobalVariable @var3 built_in("GlobalInvocationId") : !spirv.ptr, Input> } // ----- -spv.module Logical GLSL450 requires #spv.vce { - // CHECK: spv.GlobalVariable @var1 : !spv.ptr - // CHECK-NEXT: spv.GlobalVariable @var2 initializer(@var1) bind(1, 0) : !spv.ptr - spv.GlobalVariable @var1 : !spv.ptr - spv.GlobalVariable @var2 initializer(@var1) bind(1, 0) : !spv.ptr +spirv.module Logical GLSL450 requires #spirv.vce { + // CHECK: spirv.GlobalVariable @var1 : !spirv.ptr + // CHECK-NEXT: spirv.GlobalVariable @var2 initializer(@var1) bind(1, 0) : !spirv.ptr + spirv.GlobalVariable @var1 : !spirv.ptr + spirv.GlobalVariable @var2 initializer(@var1) bind(1, 0) : !spirv.ptr } // ----- -spv.module Logical GLSL450 requires #spv.vce { - spv.GlobalVariable @globalInvocationID built_in("GlobalInvocationId") : !spv.ptr, Input> - spv.func @foo() "None" { - // CHECK: %[[ADDR:.*]] = spv.mlir.addressof @globalInvocationID : !spv.ptr, Input> - %0 = spv.mlir.addressof @globalInvocationID : !spv.ptr, Input> - %1 = spv.Constant 0: i32 - // CHECK: spv.AccessChain %[[ADDR]] - %2 = spv.AccessChain %0[%1] : !spv.ptr, Input>, i32 - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.GlobalVariable @globalInvocationID built_in("GlobalInvocationId") : !spirv.ptr, Input> + spirv.func @foo() "None" { + // CHECK: %[[ADDR:.*]] = spirv.mlir.addressof @globalInvocationID : !spirv.ptr, Input> + %0 = spirv.mlir.addressof @globalInvocationID : !spirv.ptr, Input> + %1 = spirv.Constant 0: i32 + // CHECK: spirv.AccessChain %[[ADDR]] + %2 = spirv.AccessChain %0[%1] : !spirv.ptr, Input>, i32 + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/group-ops.mlir b/mlir/test/Target/SPIRV/group-ops.mlir --- a/mlir/test/Target/SPIRV/group-ops.mlir +++ b/mlir/test/Target/SPIRV/group-ops.mlir @@ -1,46 +1,46 @@ // RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK-LABEL: @subgroup_ballot - spv.func @subgroup_ballot(%predicate: i1) -> vector<4xi32> "None" { - // CHECK: %{{.*}} = spv.KHR.SubgroupBallot %{{.*}}: vector<4xi32> - %0 = spv.KHR.SubgroupBallot %predicate: vector<4xi32> - spv.ReturnValue %0: vector<4xi32> + spirv.func @subgroup_ballot(%predicate: i1) -> vector<4xi32> "None" { + // CHECK: %{{.*}} = spirv.KHR.SubgroupBallot %{{.*}}: vector<4xi32> + %0 = spirv.KHR.SubgroupBallot %predicate: vector<4xi32> + spirv.ReturnValue %0: vector<4xi32> } // CHECK-LABEL: @group_broadcast_1 - spv.func @group_broadcast_1(%value: f32, %localid: i32 ) -> f32 "None" { - // CHECK: spv.GroupBroadcast %{{.*}}, %{{.*}} : f32, i32 - %0 = spv.GroupBroadcast %value, %localid : f32, i32 - spv.ReturnValue %0: f32 + spirv.func @group_broadcast_1(%value: f32, %localid: i32 ) -> f32 "None" { + // CHECK: spirv.GroupBroadcast %{{.*}}, %{{.*}} : f32, i32 + %0 = spirv.GroupBroadcast %value, %localid : f32, i32 + spirv.ReturnValue %0: f32 } // CHECK-LABEL: @group_broadcast_2 - spv.func @group_broadcast_2(%value: f32, %localid: vector<3xi32> ) -> f32 "None" { - // CHECK: spv.GroupBroadcast %{{.*}}, %{{.*}} : f32, vector<3xi32> - %0 = spv.GroupBroadcast %value, %localid : f32, vector<3xi32> - spv.ReturnValue %0: f32 + spirv.func @group_broadcast_2(%value: f32, %localid: vector<3xi32> ) -> f32 "None" { + // CHECK: spirv.GroupBroadcast %{{.*}}, %{{.*}} : f32, vector<3xi32> + %0 = spirv.GroupBroadcast %value, %localid : f32, vector<3xi32> + spirv.ReturnValue %0: f32 } // CHECK-LABEL: @subgroup_block_read_intel - spv.func @subgroup_block_read_intel(%ptr : !spv.ptr) -> i32 "None" { - // CHECK: spv.INTEL.SubgroupBlockRead %{{.*}} : i32 - %0 = spv.INTEL.SubgroupBlockRead "StorageBuffer" %ptr : i32 - spv.ReturnValue %0: i32 + spirv.func @subgroup_block_read_intel(%ptr : !spirv.ptr) -> i32 "None" { + // CHECK: spirv.INTEL.SubgroupBlockRead %{{.*}} : i32 + %0 = spirv.INTEL.SubgroupBlockRead "StorageBuffer" %ptr : i32 + spirv.ReturnValue %0: i32 } // CHECK-LABEL: @subgroup_block_read_intel_vector - spv.func @subgroup_block_read_intel_vector(%ptr : !spv.ptr) -> vector<3xi32> "None" { - // CHECK: spv.INTEL.SubgroupBlockRead %{{.*}} : vector<3xi32> - %0 = spv.INTEL.SubgroupBlockRead "StorageBuffer" %ptr : vector<3xi32> - spv.ReturnValue %0: vector<3xi32> + spirv.func @subgroup_block_read_intel_vector(%ptr : !spirv.ptr) -> vector<3xi32> "None" { + // CHECK: spirv.INTEL.SubgroupBlockRead %{{.*}} : vector<3xi32> + %0 = spirv.INTEL.SubgroupBlockRead "StorageBuffer" %ptr : vector<3xi32> + spirv.ReturnValue %0: vector<3xi32> } // CHECK-LABEL: @subgroup_block_write_intel - spv.func @subgroup_block_write_intel(%ptr : !spv.ptr, %value: i32) -> () "None" { - // CHECK: spv.INTEL.SubgroupBlockWrite %{{.*}}, %{{.*}} : i32 - spv.INTEL.SubgroupBlockWrite "StorageBuffer" %ptr, %value : i32 - spv.Return + spirv.func @subgroup_block_write_intel(%ptr : !spirv.ptr, %value: i32) -> () "None" { + // CHECK: spirv.INTEL.SubgroupBlockWrite %{{.*}}, %{{.*}} : i32 + spirv.INTEL.SubgroupBlockWrite "StorageBuffer" %ptr, %value : i32 + spirv.Return } // CHECK-LABEL: @subgroup_block_write_intel_vector - spv.func @subgroup_block_write_intel_vector(%ptr : !spv.ptr, %value: vector<3xi32>) -> () "None" { - // CHECK: spv.INTEL.SubgroupBlockWrite %{{.*}}, %{{.*}} : vector<3xi32> - spv.INTEL.SubgroupBlockWrite "StorageBuffer" %ptr, %value : vector<3xi32> - spv.Return + spirv.func @subgroup_block_write_intel_vector(%ptr : !spirv.ptr, %value: vector<3xi32>) -> () "None" { + // CHECK: spirv.INTEL.SubgroupBlockWrite %{{.*}}, %{{.*}} : vector<3xi32> + spirv.INTEL.SubgroupBlockWrite "StorageBuffer" %ptr, %value : vector<3xi32> + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/image-ops.mlir b/mlir/test/Target/SPIRV/image-ops.mlir --- a/mlir/test/Target/SPIRV/image-ops.mlir +++ b/mlir/test/Target/SPIRV/image-ops.mlir @@ -1,16 +1,16 @@ // RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - spv.func @image(%arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) "None" { - // CHECK: {{%.*}} = spv.Image {{%.*}} : !spv.sampled_image> - %0 = spv.Image %arg0 : !spv.sampled_image> - // CHECK: {{%.*}} = spv.ImageDrefGather {{%.*}} : !spv.sampled_image>, {{%.*}} : vector<4xf32>, {{%.*}} : f32 -> vector<4xf32> - %1 = spv.ImageDrefGather %arg0 : !spv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 -> vector<4xf32> - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @image(%arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32) "None" { + // CHECK: {{%.*}} = spirv.Image {{%.*}} : !spirv.sampled_image> + %0 = spirv.Image %arg0 : !spirv.sampled_image> + // CHECK: {{%.*}} = spirv.ImageDrefGather {{%.*}} : !spirv.sampled_image>, {{%.*}} : vector<4xf32>, {{%.*}} : f32 -> vector<4xf32> + %1 = spirv.ImageDrefGather %arg0 : !spirv.sampled_image>, %arg1 : vector<4xf32>, %arg2 : f32 -> vector<4xf32> + spirv.Return } - spv.func @image_query_size(%arg0 : !spv.image) "None" { - // CHECK: {{%.*}} = spv.ImageQuerySize %arg0 : !spv.image -> vector<2xi32> - %0 = spv.ImageQuerySize %arg0 : !spv.image -> vector<2xi32> - spv.Return + spirv.func @image_query_size(%arg0 : !spirv.image) "None" { + // CHECK: {{%.*}} = spirv.ImageQuerySize %arg0 : !spirv.image -> vector<2xi32> + %0 = spirv.ImageQuerySize %arg0 : !spirv.image -> vector<2xi32> + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/image.mlir b/mlir/test/Target/SPIRV/image.mlir --- a/mlir/test/Target/SPIRV/image.mlir +++ b/mlir/test/Target/SPIRV/image.mlir @@ -1,12 +1,12 @@ // RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - // CHECK: !spv.ptr, UniformConstant> - spv.GlobalVariable @var0 bind(0, 1) : !spv.ptr, UniformConstant> +spirv.module Logical GLSL450 requires #spirv.vce { + // CHECK: !spirv.ptr, UniformConstant> + spirv.GlobalVariable @var0 bind(0, 1) : !spirv.ptr, UniformConstant> - // CHECK: !spv.ptr, UniformConstant> - spv.GlobalVariable @var1 : !spv.ptr, UniformConstant> + // CHECK: !spirv.ptr, UniformConstant> + spirv.GlobalVariable @var1 : !spirv.ptr, UniformConstant> - // CHECK: !spv.ptr, UniformConstant> - spv.GlobalVariable @var2 : !spv.ptr, UniformConstant> + // CHECK: !spirv.ptr, UniformConstant> + spirv.GlobalVariable @var2 : !spirv.ptr, UniformConstant> } diff --git a/mlir/test/Target/SPIRV/joint-matrix-ops.mlir b/mlir/test/Target/SPIRV/joint-matrix-ops.mlir --- a/mlir/test/Target/SPIRV/joint-matrix-ops.mlir +++ b/mlir/test/Target/SPIRV/joint-matrix-ops.mlir @@ -1,45 +1,45 @@ // RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK-LABEL: @joint_matrix_load - spv.func @joint_matrix_load(%ptr : !spv.ptr, %stride : i32) "None" { - // CHECK: {{%.*}} = spv.INTEL.JointMatrixLoad {{%.*}}, {{%.*}} : (!spv.ptr, i32) -> !spv.jointmatrix<16x8xi32, RowMajor, Workgroup> - %0 = spv.INTEL.JointMatrixLoad %ptr, %stride : (!spv.ptr, i32) -> !spv.jointmatrix<16x8xi32, RowMajor, Workgroup> - spv.Return + spirv.func @joint_matrix_load(%ptr : !spirv.ptr, %stride : i32) "None" { + // CHECK: {{%.*}} = spirv.INTEL.JointMatrixLoad {{%.*}}, {{%.*}} : (!spirv.ptr, i32) -> !spirv.jointmatrix<16x8xi32, RowMajor, Workgroup> + %0 = spirv.INTEL.JointMatrixLoad %ptr, %stride : (!spirv.ptr, i32) -> !spirv.jointmatrix<16x8xi32, RowMajor, Workgroup> + spirv.Return } // CHECK-LABEL: @joint_matrix_load_memaccess - spv.func @joint_matrix_load_memaccess(%ptr : !spv.ptr, %stride : i32) "None" { - // CHECK: {{%.*}} = spv.INTEL.JointMatrixLoad {{%.*}}, {{%.*}} {memory_access = #spv.memory_access} : (!spv.ptr, i32) -> !spv.jointmatrix<8x16xi32, RowMajor, Subgroup> - %0 = spv.INTEL.JointMatrixLoad %ptr, %stride {memory_access = #spv.memory_access} : (!spv.ptr, i32) -> !spv.jointmatrix<8x16xi32, RowMajor, Subgroup> - spv.Return + spirv.func @joint_matrix_load_memaccess(%ptr : !spirv.ptr, %stride : i32) "None" { + // CHECK: {{%.*}} = spirv.INTEL.JointMatrixLoad {{%.*}}, {{%.*}} {memory_access = #spirv.memory_access} : (!spirv.ptr, i32) -> !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup> + %0 = spirv.INTEL.JointMatrixLoad %ptr, %stride {memory_access = #spirv.memory_access} : (!spirv.ptr, i32) -> !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup> + spirv.Return } // CHECK-LABEL: @joint_matrix_store - spv.func @joint_matrix_store(%ptr : !spv.ptr, %stride : i32, %m : !spv.jointmatrix<16x8xi32, RowMajor, Workgroup>) "None" { - // CHECK: spv.INTEL.JointMatrixStore {{%.*}}, {{%.*}}, {{%.*}} : (!spv.ptr, !spv.jointmatrix<16x8xi32, RowMajor, Workgroup>, i32) - spv.INTEL.JointMatrixStore %ptr, %m, %stride : (!spv.ptr, !spv.jointmatrix<16x8xi32, RowMajor, Workgroup>, i32) - spv.Return + spirv.func @joint_matrix_store(%ptr : !spirv.ptr, %stride : i32, %m : !spirv.jointmatrix<16x8xi32, RowMajor, Workgroup>) "None" { + // CHECK: spirv.INTEL.JointMatrixStore {{%.*}}, {{%.*}}, {{%.*}} : (!spirv.ptr, !spirv.jointmatrix<16x8xi32, RowMajor, Workgroup>, i32) + spirv.INTEL.JointMatrixStore %ptr, %m, %stride : (!spirv.ptr, !spirv.jointmatrix<16x8xi32, RowMajor, Workgroup>, i32) + spirv.Return } // CHECK-LABEL: @joint_matrix_store_memaccess - spv.func @joint_matrix_store_memaccess(%ptr : !spv.ptr, %m : !spv.jointmatrix<8x16xi32, RowMajor, Subgroup>, %stride : i32) "None" { - // CHECK: spv.INTEL.JointMatrixStore {{%.*}}, {{%.*}}, {{%.*}} {memory_access = #spv.memory_access} : (!spv.ptr, !spv.jointmatrix<8x16xi32, RowMajor, Subgroup>, i32) - spv.INTEL.JointMatrixStore %ptr, %m, %stride {memory_access = #spv.memory_access} : (!spv.ptr, !spv.jointmatrix<8x16xi32, RowMajor, Subgroup>, i32) - spv.Return + spirv.func @joint_matrix_store_memaccess(%ptr : !spirv.ptr, %m : !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, %stride : i32) "None" { + // CHECK: spirv.INTEL.JointMatrixStore {{%.*}}, {{%.*}}, {{%.*}} {memory_access = #spirv.memory_access} : (!spirv.ptr, !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, i32) + spirv.INTEL.JointMatrixStore %ptr, %m, %stride {memory_access = #spirv.memory_access} : (!spirv.ptr, !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, i32) + spirv.Return } // CHECK-LABEL: @joint_matrix_length - spv.func @joint_matrix_length() -> i32 "None" { - // CHECK: {{%.*}} = spv.INTEL.JointMatrixWorkItemLength : !spv.jointmatrix<8x16xi32, RowMajor, Subgroup> - %0 = spv.INTEL.JointMatrixWorkItemLength : !spv.jointmatrix<8x16xi32, RowMajor, Subgroup> - spv.ReturnValue %0 : i32 + spirv.func @joint_matrix_length() -> i32 "None" { + // CHECK: {{%.*}} = spirv.INTEL.JointMatrixWorkItemLength : !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup> + %0 = spirv.INTEL.JointMatrixWorkItemLength : !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup> + spirv.ReturnValue %0 : i32 } // CHECK-LABEL: @joint_matrix_muladd - spv.func @joint_matrix_muladd(%a : !spv.jointmatrix<8x16xi32, RowMajor, Subgroup>, %b : !spv.jointmatrix<16x8xi32, RowMajor, Subgroup>, %c : !spv.jointmatrix<8x8xi32, RowMajor, Subgroup>) "None" { - // CHECK: {{%.*}} = spv.INTEL.JointMatrixMad {{%.*}}, {{%.*}}, {{%.*}} : !spv.jointmatrix<8x16xi32, RowMajor, Subgroup>, !spv.jointmatrix<16x8xi32, RowMajor, Subgroup> -> !spv.jointmatrix<8x8xi32, RowMajor, Subgroup> - %r = spv.INTEL.JointMatrixMad %a, %b, %c : !spv.jointmatrix<8x16xi32, RowMajor, Subgroup>, !spv.jointmatrix<16x8xi32, RowMajor, Subgroup> -> !spv.jointmatrix<8x8xi32, RowMajor, Subgroup> - spv.Return + spirv.func @joint_matrix_muladd(%a : !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, %b : !spirv.jointmatrix<16x8xi32, RowMajor, Subgroup>, %c : !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup>) "None" { + // CHECK: {{%.*}} = spirv.INTEL.JointMatrixMad {{%.*}}, {{%.*}}, {{%.*}} : !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, !spirv.jointmatrix<16x8xi32, RowMajor, Subgroup> -> !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup> + %r = spirv.INTEL.JointMatrixMad %a, %b, %c : !spirv.jointmatrix<8x16xi32, RowMajor, Subgroup>, !spirv.jointmatrix<16x8xi32, RowMajor, Subgroup> -> !spirv.jointmatrix<8x8xi32, RowMajor, Subgroup> + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/logical-ops.mlir b/mlir/test/Target/SPIRV/logical-ops.mlir --- a/mlir/test/Target/SPIRV/logical-ops.mlir +++ b/mlir/test/Target/SPIRV/logical-ops.mlir @@ -1,110 +1,110 @@ // RUN: mlir-translate -split-input-file -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - spv.func @iequal_scalar(%arg0: i32, %arg1: i32) "None" { - // CHECK: {{.*}} = spv.IEqual {{.*}}, {{.*}} : i32 - %0 = spv.IEqual %arg0, %arg1 : i32 - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @iequal_scalar(%arg0: i32, %arg1: i32) "None" { + // CHECK: {{.*}} = spirv.IEqual {{.*}}, {{.*}} : i32 + %0 = spirv.IEqual %arg0, %arg1 : i32 + spirv.Return } - spv.func @inotequal_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { - // CHECK: {{.*}} = spv.INotEqual {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.INotEqual %arg0, %arg1 : vector<4xi32> - spv.Return + spirv.func @inotequal_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { + // CHECK: {{.*}} = spirv.INotEqual {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.INotEqual %arg0, %arg1 : vector<4xi32> + spirv.Return } - spv.func @sgt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { - // CHECK: {{.*}} = spv.SGreaterThan {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.SGreaterThan %arg0, %arg1 : vector<4xi32> - spv.Return + spirv.func @sgt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { + // CHECK: {{.*}} = spirv.SGreaterThan {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.SGreaterThan %arg0, %arg1 : vector<4xi32> + spirv.Return } - spv.func @sge_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { - // CHECK: {{.*}} = spv.SGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.SGreaterThanEqual %arg0, %arg1 : vector<4xi32> - spv.Return + spirv.func @sge_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { + // CHECK: {{.*}} = spirv.SGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.SGreaterThanEqual %arg0, %arg1 : vector<4xi32> + spirv.Return } - spv.func @slt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { - // CHECK: {{.*}} = spv.SLessThan {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.SLessThan %arg0, %arg1 : vector<4xi32> - spv.Return + spirv.func @slt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { + // CHECK: {{.*}} = spirv.SLessThan {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.SLessThan %arg0, %arg1 : vector<4xi32> + spirv.Return } - spv.func @slte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { - // CHECK: {{.*}} = spv.SLessThanEqual {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.SLessThanEqual %arg0, %arg1 : vector<4xi32> - spv.Return + spirv.func @slte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { + // CHECK: {{.*}} = spirv.SLessThanEqual {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.SLessThanEqual %arg0, %arg1 : vector<4xi32> + spirv.Return } - spv.func @ugt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { - // CHECK: {{.*}} = spv.UGreaterThan {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.UGreaterThan %arg0, %arg1 : vector<4xi32> - spv.Return + spirv.func @ugt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { + // CHECK: {{.*}} = spirv.UGreaterThan {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.UGreaterThan %arg0, %arg1 : vector<4xi32> + spirv.Return } - spv.func @ugte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { - // CHECK: {{.*}} = spv.UGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.UGreaterThanEqual %arg0, %arg1 : vector<4xi32> - spv.Return + spirv.func @ugte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { + // CHECK: {{.*}} = spirv.UGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.UGreaterThanEqual %arg0, %arg1 : vector<4xi32> + spirv.Return } - spv.func @ult_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { - // CHECK: {{.*}} = spv.ULessThan {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.ULessThan %arg0, %arg1 : vector<4xi32> - spv.Return + spirv.func @ult_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { + // CHECK: {{.*}} = spirv.ULessThan {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.ULessThan %arg0, %arg1 : vector<4xi32> + spirv.Return } - spv.func @ulte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { - // CHECK: {{.*}} = spv.ULessThanEqual {{.*}}, {{.*}} : vector<4xi32> - %0 = spv.ULessThanEqual %arg0, %arg1 : vector<4xi32> - spv.Return + spirv.func @ulte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { + // CHECK: {{.*}} = spirv.ULessThanEqual {{.*}}, {{.*}} : vector<4xi32> + %0 = spirv.ULessThanEqual %arg0, %arg1 : vector<4xi32> + spirv.Return } - spv.func @cmpf(%arg0 : f32, %arg1 : f32) "None" { - // CHECK: spv.FOrdEqual - %1 = spv.FOrdEqual %arg0, %arg1 : f32 - // CHECK: spv.FOrdGreaterThan - %2 = spv.FOrdGreaterThan %arg0, %arg1 : f32 - // CHECK: spv.FOrdGreaterThanEqual - %3 = spv.FOrdGreaterThanEqual %arg0, %arg1 : f32 - // CHECK: spv.FOrdLessThan - %4 = spv.FOrdLessThan %arg0, %arg1 : f32 - // CHECK: spv.FOrdLessThanEqual - %5 = spv.FOrdLessThanEqual %arg0, %arg1 : f32 - // CHECK: spv.FOrdNotEqual - %6 = spv.FOrdNotEqual %arg0, %arg1 : f32 - // CHECK: spv.FUnordEqual - %7 = spv.FUnordEqual %arg0, %arg1 : f32 - // CHECK: spv.FUnordGreaterThan - %8 = spv.FUnordGreaterThan %arg0, %arg1 : f32 - // CHECK: spv.FUnordGreaterThanEqual - %9 = spv.FUnordGreaterThanEqual %arg0, %arg1 : f32 - // CHECK: spv.FUnordLessThan - %10 = spv.FUnordLessThan %arg0, %arg1 : f32 - // CHECK: spv.FUnordLessThanEqual - %11 = spv.FUnordLessThanEqual %arg0, %arg1 : f32 - // CHECK: spv.FUnordNotEqual - %12 = spv.FUnordNotEqual %arg0, %arg1 : f32 - // CHECK: spv.Ordered - %13 = spv.Ordered %arg0, %arg1 : f32 - // CHECK: spv.Unordered - %14 = spv.Unordered %arg0, %arg1 : f32 - // CHCK: spv.IsNan - %15 = spv.IsNan %arg0 : f32 - // CHCK: spv.IsInf - %16 = spv.IsInf %arg1 : f32 - spv.Return + spirv.func @cmpf(%arg0 : f32, %arg1 : f32) "None" { + // CHECK: spirv.FOrdEqual + %1 = spirv.FOrdEqual %arg0, %arg1 : f32 + // CHECK: spirv.FOrdGreaterThan + %2 = spirv.FOrdGreaterThan %arg0, %arg1 : f32 + // CHECK: spirv.FOrdGreaterThanEqual + %3 = spirv.FOrdGreaterThanEqual %arg0, %arg1 : f32 + // CHECK: spirv.FOrdLessThan + %4 = spirv.FOrdLessThan %arg0, %arg1 : f32 + // CHECK: spirv.FOrdLessThanEqual + %5 = spirv.FOrdLessThanEqual %arg0, %arg1 : f32 + // CHECK: spirv.FOrdNotEqual + %6 = spirv.FOrdNotEqual %arg0, %arg1 : f32 + // CHECK: spirv.FUnordEqual + %7 = spirv.FUnordEqual %arg0, %arg1 : f32 + // CHECK: spirv.FUnordGreaterThan + %8 = spirv.FUnordGreaterThan %arg0, %arg1 : f32 + // CHECK: spirv.FUnordGreaterThanEqual + %9 = spirv.FUnordGreaterThanEqual %arg0, %arg1 : f32 + // CHECK: spirv.FUnordLessThan + %10 = spirv.FUnordLessThan %arg0, %arg1 : f32 + // CHECK: spirv.FUnordLessThanEqual + %11 = spirv.FUnordLessThanEqual %arg0, %arg1 : f32 + // CHECK: spirv.FUnordNotEqual + %12 = spirv.FUnordNotEqual %arg0, %arg1 : f32 + // CHECK: spirv.Ordered + %13 = spirv.Ordered %arg0, %arg1 : f32 + // CHECK: spirv.Unordered + %14 = spirv.Unordered %arg0, %arg1 : f32 + // CHCK: spirv.IsNan + %15 = spirv.IsNan %arg0 : f32 + // CHCK: spirv.IsInf + %16 = spirv.IsInf %arg1 : f32 + spirv.Return } } // ----- -spv.module Logical GLSL450 requires #spv.vce { - spv.SpecConstant @condition_scalar = true - spv.func @select() -> () "None" { - %0 = spv.Constant 4.0 : f32 - %1 = spv.Constant 5.0 : f32 - %2 = spv.mlir.referenceof @condition_scalar : i1 - // CHECK: spv.Select {{.*}}, {{.*}}, {{.*}} : i1, f32 - %3 = spv.Select %2, %0, %1 : i1, f32 - %4 = spv.Constant dense<[2.0, 3.0, 4.0, 5.0]> : vector<4xf32> - %5 = spv.Constant dense<[6.0, 7.0, 8.0, 9.0]> : vector<4xf32> - // CHECK: spv.Select {{.*}}, {{.*}}, {{.*}} : i1, vector<4xf32> - %6 = spv.Select %2, %4, %5 : i1, vector<4xf32> - %7 = spv.Constant dense<[true, true, true, true]> : vector<4xi1> - // CHECK: spv.Select {{.*}}, {{.*}}, {{.*}} : vector<4xi1>, vector<4xf32> - %8 = spv.Select %7, %4, %5 : vector<4xi1>, vector<4xf32> - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.SpecConstant @condition_scalar = true + spirv.func @select() -> () "None" { + %0 = spirv.Constant 4.0 : f32 + %1 = spirv.Constant 5.0 : f32 + %2 = spirv.mlir.referenceof @condition_scalar : i1 + // CHECK: spirv.Select {{.*}}, {{.*}}, {{.*}} : i1, f32 + %3 = spirv.Select %2, %0, %1 : i1, f32 + %4 = spirv.Constant dense<[2.0, 3.0, 4.0, 5.0]> : vector<4xf32> + %5 = spirv.Constant dense<[6.0, 7.0, 8.0, 9.0]> : vector<4xf32> + // CHECK: spirv.Select {{.*}}, {{.*}}, {{.*}} : i1, vector<4xf32> + %6 = spirv.Select %2, %4, %5 : i1, vector<4xf32> + %7 = spirv.Constant dense<[true, true, true, true]> : vector<4xi1> + // CHECK: spirv.Select {{.*}}, {{.*}}, {{.*}} : vector<4xi1>, vector<4xf32> + %8 = spirv.Select %7, %4, %5 : vector<4xi1>, vector<4xf32> + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/loop.mlir b/mlir/test/Target/SPIRV/loop.mlir --- a/mlir/test/Target/SPIRV/loop.mlir +++ b/mlir/test/Target/SPIRV/loop.mlir @@ -2,214 +2,214 @@ // Single loop -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // for (int i = 0; i < count; ++i) {} // CHECK-LABEL: @loop - spv.func @loop(%count : i32) -> () "None" { - %zero = spv.Constant 0: i32 - %one = spv.Constant 1: i32 - %var = spv.Variable init(%zero) : !spv.ptr + spirv.func @loop(%count : i32) -> () "None" { + %zero = spirv.Constant 0: i32 + %one = spirv.Constant 1: i32 + %var = spirv.Variable init(%zero) : !spirv.ptr -// CHECK: spv.Branch ^bb1 +// CHECK: spirv.Branch ^bb1 // CHECK-NEXT: ^bb1: -// CHECK-NEXT: spv.mlir.loop - spv.mlir.loop { -// CHECK-NEXT: spv.Branch ^bb1 - spv.Branch ^header +// CHECK-NEXT: spirv.mlir.loop + spirv.mlir.loop { +// CHECK-NEXT: spirv.Branch ^bb1 + spirv.Branch ^header // CHECK-NEXT: ^bb1: ^header: -// CHECK-NEXT: spv.Load - %val0 = spv.Load "Function" %var : i32 -// CHECK-NEXT: spv.SLessThan - %cmp = spv.SLessThan %val0, %count : i32 -// CHECK-NEXT: spv.BranchConditional %{{.*}} [1, 1], ^bb2, ^bb4 - spv.BranchConditional %cmp [1, 1], ^body, ^merge +// CHECK-NEXT: spirv.Load + %val0 = spirv.Load "Function" %var : i32 +// CHECK-NEXT: spirv.SLessThan + %cmp = spirv.SLessThan %val0, %count : i32 +// CHECK-NEXT: spirv.BranchConditional %{{.*}} [1, 1], ^bb2, ^bb4 + spirv.BranchConditional %cmp [1, 1], ^body, ^merge // CHECK-NEXT: ^bb2: ^body: // Do nothing -// CHECK-NEXT: spv.Branch ^bb3 - spv.Branch ^continue +// CHECK-NEXT: spirv.Branch ^bb3 + spirv.Branch ^continue // CHECK-NEXT: ^bb3: ^continue: -// CHECK-NEXT: spv.Load - %val1 = spv.Load "Function" %var : i32 -// CHECK-NEXT: spv.Constant 1 -// CHECK-NEXT: spv.IAdd - %add = spv.IAdd %val1, %one : i32 -// CHECK-NEXT: spv.Store - spv.Store "Function" %var, %add : i32 -// CHECK-NEXT: spv.Branch ^bb1 - spv.Branch ^header +// CHECK-NEXT: spirv.Load + %val1 = spirv.Load "Function" %var : i32 +// CHECK-NEXT: spirv.Constant 1 +// CHECK-NEXT: spirv.IAdd + %add = spirv.IAdd %val1, %one : i32 +// CHECK-NEXT: spirv.Store + spirv.Store "Function" %var, %add : i32 +// CHECK-NEXT: spirv.Branch ^bb1 + spirv.Branch ^header // CHECK-NEXT: ^bb4: -// CHECK-NEXT: spv.mlir.merge +// CHECK-NEXT: spirv.mlir.merge ^merge: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } - spv.func @main() -> () "None" { - spv.Return + spirv.func @main() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @main + spirv.EntryPoint "GLCompute" @main } // ----- // Single loop with block arguments -spv.module Logical GLSL450 requires #spv.vce { - spv.GlobalVariable @GV1 bind(0, 0) : !spv.ptr [0])>, StorageBuffer> - spv.GlobalVariable @GV2 bind(0, 1) : !spv.ptr [0])>, StorageBuffer> +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.GlobalVariable @GV1 bind(0, 0) : !spirv.ptr [0])>, StorageBuffer> + spirv.GlobalVariable @GV2 bind(0, 1) : !spirv.ptr [0])>, StorageBuffer> // CHECK-LABEL: @loop_kernel - spv.func @loop_kernel() "None" { - %0 = spv.mlir.addressof @GV1 : !spv.ptr [0])>, StorageBuffer> - %1 = spv.Constant 0 : i32 - %2 = spv.AccessChain %0[%1] : !spv.ptr [0])>, StorageBuffer>, i32 - %3 = spv.mlir.addressof @GV2 : !spv.ptr [0])>, StorageBuffer> - %5 = spv.AccessChain %3[%1] : !spv.ptr [0])>, StorageBuffer>, i32 - %6 = spv.Constant 4 : i32 - %7 = spv.Constant 42 : i32 - %8 = spv.Constant 2 : i32 -// CHECK: spv.Branch ^bb1(%{{.*}} : i32) + spirv.func @loop_kernel() "None" { + %0 = spirv.mlir.addressof @GV1 : !spirv.ptr [0])>, StorageBuffer> + %1 = spirv.Constant 0 : i32 + %2 = spirv.AccessChain %0[%1] : !spirv.ptr [0])>, StorageBuffer>, i32 + %3 = spirv.mlir.addressof @GV2 : !spirv.ptr [0])>, StorageBuffer> + %5 = spirv.AccessChain %3[%1] : !spirv.ptr [0])>, StorageBuffer>, i32 + %6 = spirv.Constant 4 : i32 + %7 = spirv.Constant 42 : i32 + %8 = spirv.Constant 2 : i32 +// CHECK: spirv.Branch ^bb1(%{{.*}} : i32) // CHECK-NEXT: ^bb1(%[[OUTARG:.*]]: i32): -// CHECK-NEXT: spv.mlir.loop { - spv.mlir.loop { -// CHECK-NEXT: spv.Branch ^bb1(%[[OUTARG]] : i32) - spv.Branch ^header(%6 : i32) +// CHECK-NEXT: spirv.mlir.loop { + spirv.mlir.loop { +// CHECK-NEXT: spirv.Branch ^bb1(%[[OUTARG]] : i32) + spirv.Branch ^header(%6 : i32) // CHECK-NEXT: ^bb1(%[[HEADARG:.*]]: i32): ^header(%9: i32): - %10 = spv.SLessThan %9, %7 : i32 -// CHECK: spv.BranchConditional %{{.*}}, ^bb2, ^bb3 - spv.BranchConditional %10, ^body, ^merge + %10 = spirv.SLessThan %9, %7 : i32 +// CHECK: spirv.BranchConditional %{{.*}}, ^bb2, ^bb3 + spirv.BranchConditional %10, ^body, ^merge // CHECK-NEXT: ^bb2: // pred: ^bb1 ^body: - %11 = spv.AccessChain %2[%9] : !spv.ptr, StorageBuffer>, i32 - %12 = spv.Load "StorageBuffer" %11 : f32 - %13 = spv.AccessChain %5[%9] : !spv.ptr, StorageBuffer>, i32 - spv.Store "StorageBuffer" %13, %12 : f32 -// CHECK: %[[ADD:.*]] = spv.IAdd - %14 = spv.IAdd %9, %8 : i32 -// CHECK-NEXT: spv.Branch ^bb1(%[[ADD]] : i32) - spv.Branch ^header(%14 : i32) + %11 = spirv.AccessChain %2[%9] : !spirv.ptr, StorageBuffer>, i32 + %12 = spirv.Load "StorageBuffer" %11 : f32 + %13 = spirv.AccessChain %5[%9] : !spirv.ptr, StorageBuffer>, i32 + spirv.Store "StorageBuffer" %13, %12 : f32 +// CHECK: %[[ADD:.*]] = spirv.IAdd + %14 = spirv.IAdd %9, %8 : i32 +// CHECK-NEXT: spirv.Branch ^bb1(%[[ADD]] : i32) + spirv.Branch ^header(%14 : i32) // CHECK-NEXT: ^bb3: ^merge: -// CHECK-NEXT: spv.mlir.merge - spv.mlir.merge +// CHECK-NEXT: spirv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } - spv.EntryPoint "GLCompute" @loop_kernel - spv.ExecutionMode @loop_kernel "LocalSize", 1, 1, 1 + spirv.EntryPoint "GLCompute" @loop_kernel + spirv.ExecutionMode @loop_kernel "LocalSize", 1, 1, 1 } // ----- // Nested loop -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // for (int i = 0; i < count; ++i) { // for (int j = 0; j < count; ++j) { } // } // CHECK-LABEL: @loop - spv.func @loop(%count : i32) -> () "None" { - %zero = spv.Constant 0: i32 - %one = spv.Constant 1: i32 - %ivar = spv.Variable init(%zero) : !spv.ptr - %jvar = spv.Variable init(%zero) : !spv.ptr + spirv.func @loop(%count : i32) -> () "None" { + %zero = spirv.Constant 0: i32 + %one = spirv.Constant 1: i32 + %ivar = spirv.Variable init(%zero) : !spirv.ptr + %jvar = spirv.Variable init(%zero) : !spirv.ptr -// CHECK: spv.Branch ^bb1 +// CHECK: spirv.Branch ^bb1 // CHECK-NEXT: ^bb1: -// CHECK-NEXT: spv.mlir.loop control(Unroll) - spv.mlir.loop control(Unroll) { -// CHECK-NEXT: spv.Branch ^bb1 - spv.Branch ^header +// CHECK-NEXT: spirv.mlir.loop control(Unroll) + spirv.mlir.loop control(Unroll) { +// CHECK-NEXT: spirv.Branch ^bb1 + spirv.Branch ^header // CHECK-NEXT: ^bb1: ^header: -// CHECK-NEXT: spv.Load - %ival0 = spv.Load "Function" %ivar : i32 -// CHECK-NEXT: spv.SLessThan - %icmp = spv.SLessThan %ival0, %count : i32 -// CHECK-NEXT: spv.BranchConditional %{{.*}}, ^bb2, ^bb5 - spv.BranchConditional %icmp, ^body, ^merge +// CHECK-NEXT: spirv.Load + %ival0 = spirv.Load "Function" %ivar : i32 +// CHECK-NEXT: spirv.SLessThan + %icmp = spirv.SLessThan %ival0, %count : i32 +// CHECK-NEXT: spirv.BranchConditional %{{.*}}, ^bb2, ^bb5 + spirv.BranchConditional %icmp, ^body, ^merge // CHECK-NEXT: ^bb2: ^body: -// CHECK-NEXT: spv.Constant 0 -// CHECK-NEXT: spv.Store - spv.Store "Function" %jvar, %zero : i32 -// CHECK-NEXT: spv.Branch ^bb3 +// CHECK-NEXT: spirv.Constant 0 +// CHECK-NEXT: spirv.Store + spirv.Store "Function" %jvar, %zero : i32 +// CHECK-NEXT: spirv.Branch ^bb3 // CHECK-NEXT: ^bb3: -// CHECK-NEXT: spv.mlir.loop control(DontUnroll) - spv.mlir.loop control(DontUnroll) { -// CHECK-NEXT: spv.Branch ^bb1 - spv.Branch ^header +// CHECK-NEXT: spirv.mlir.loop control(DontUnroll) + spirv.mlir.loop control(DontUnroll) { +// CHECK-NEXT: spirv.Branch ^bb1 + spirv.Branch ^header // CHECK-NEXT: ^bb1: ^header: -// CHECK-NEXT: spv.Load - %jval0 = spv.Load "Function" %jvar : i32 -// CHECK-NEXT: spv.SLessThan - %jcmp = spv.SLessThan %jval0, %count : i32 -// CHECK-NEXT: spv.BranchConditional %{{.*}}, ^bb2, ^bb4 - spv.BranchConditional %jcmp, ^body, ^merge +// CHECK-NEXT: spirv.Load + %jval0 = spirv.Load "Function" %jvar : i32 +// CHECK-NEXT: spirv.SLessThan + %jcmp = spirv.SLessThan %jval0, %count : i32 +// CHECK-NEXT: spirv.BranchConditional %{{.*}}, ^bb2, ^bb4 + spirv.BranchConditional %jcmp, ^body, ^merge // CHECK-NEXT: ^bb2: ^body: // Do nothing -// CHECK-NEXT: spv.Branch ^bb3 - spv.Branch ^continue +// CHECK-NEXT: spirv.Branch ^bb3 + spirv.Branch ^continue // CHECK-NEXT: ^bb3: ^continue: -// CHECK-NEXT: spv.Load - %jval1 = spv.Load "Function" %jvar : i32 -// CHECK-NEXT: spv.Constant 1 -// CHECK-NEXT: spv.IAdd - %add = spv.IAdd %jval1, %one : i32 -// CHECK-NEXT: spv.Store - spv.Store "Function" %jvar, %add : i32 -// CHECK-NEXT: spv.Branch ^bb1 - spv.Branch ^header +// CHECK-NEXT: spirv.Load + %jval1 = spirv.Load "Function" %jvar : i32 +// CHECK-NEXT: spirv.Constant 1 +// CHECK-NEXT: spirv.IAdd + %add = spirv.IAdd %jval1, %one : i32 +// CHECK-NEXT: spirv.Store + spirv.Store "Function" %jvar, %add : i32 +// CHECK-NEXT: spirv.Branch ^bb1 + spirv.Branch ^header // CHECK-NEXT: ^bb4: ^merge: -// CHECK-NEXT: spv.mlir.merge - spv.mlir.merge +// CHECK-NEXT: spirv.mlir.merge + spirv.mlir.merge } // end inner loop -// CHECK: spv.Branch ^bb4 - spv.Branch ^continue +// CHECK: spirv.Branch ^bb4 + spirv.Branch ^continue // CHECK-NEXT: ^bb4: ^continue: -// CHECK-NEXT: spv.Load - %ival1 = spv.Load "Function" %ivar : i32 -// CHECK-NEXT: spv.Constant 1 -// CHECK-NEXT: spv.IAdd - %add = spv.IAdd %ival1, %one : i32 -// CHECK-NEXT: spv.Store - spv.Store "Function" %ivar, %add : i32 -// CHECK-NEXT: spv.Branch ^bb1 - spv.Branch ^header +// CHECK-NEXT: spirv.Load + %ival1 = spirv.Load "Function" %ivar : i32 +// CHECK-NEXT: spirv.Constant 1 +// CHECK-NEXT: spirv.IAdd + %add = spirv.IAdd %ival1, %one : i32 +// CHECK-NEXT: spirv.Store + spirv.Store "Function" %ivar, %add : i32 +// CHECK-NEXT: spirv.Branch ^bb1 + spirv.Branch ^header // CHECK-NEXT: ^bb5: -// CHECK-NEXT: spv.mlir.merge +// CHECK-NEXT: spirv.mlir.merge ^merge: - spv.mlir.merge + spirv.mlir.merge } // end outer loop - spv.Return + spirv.Return } - spv.func @main() -> () "None" { - spv.Return + spirv.func @main() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @main + spirv.EntryPoint "GLCompute" @main } @@ -217,74 +217,74 @@ // Loop with selection in its header -spv.module Physical64 OpenCL requires #spv.vce { +spirv.module Physical64 OpenCL requires #spirv.vce { // CHECK-LABEL: @kernel // CHECK-SAME: (%[[INPUT0:.+]]: i64) - spv.func @kernel(%input: i64) "None" { -// CHECK-NEXT: %[[VAR:.+]] = spv.Variable : !spv.ptr -// CHECK-NEXT: spv.Branch ^[[BB0:.+]](%[[INPUT0]] : i64) + spirv.func @kernel(%input: i64) "None" { +// CHECK-NEXT: %[[VAR:.+]] = spirv.Variable : !spirv.ptr +// CHECK-NEXT: spirv.Branch ^[[BB0:.+]](%[[INPUT0]] : i64) // CHECK-NEXT: ^[[BB0]](%[[INPUT1:.+]]: i64): - %cst0_i64 = spv.Constant 0 : i64 - %true = spv.Constant true - %false = spv.Constant false -// CHECK-NEXT: spv.mlir.loop { - spv.mlir.loop { -// CHECK-NEXT: spv.Branch ^[[LOOP_HEADER:.+]](%[[INPUT1]] : i64) - spv.Branch ^loop_header(%input : i64) + %cst0_i64 = spirv.Constant 0 : i64 + %true = spirv.Constant true + %false = spirv.Constant false +// CHECK-NEXT: spirv.mlir.loop { + spirv.mlir.loop { +// CHECK-NEXT: spirv.Branch ^[[LOOP_HEADER:.+]](%[[INPUT1]] : i64) + spirv.Branch ^loop_header(%input : i64) // CHECK-NEXT: ^[[LOOP_HEADER]](%[[ARG1:.+]]: i64): ^loop_header(%arg1: i64): -// CHECK-NEXT: spv.Branch ^[[LOOP_BODY:.+]] +// CHECK-NEXT: spirv.Branch ^[[LOOP_BODY:.+]] // CHECK-NEXT: ^[[LOOP_BODY]]: -// CHECK-NEXT: %[[C0:.+]] = spv.Constant 0 : i64 - %gt = spv.SGreaterThan %arg1, %cst0_i64 : i64 -// CHECK-NEXT: %[[GT:.+]] = spv.SGreaterThan %[[ARG1]], %[[C0]] : i64 -// CHECK-NEXT: spv.Branch ^[[BB1:.+]] +// CHECK-NEXT: %[[C0:.+]] = spirv.Constant 0 : i64 + %gt = spirv.SGreaterThan %arg1, %cst0_i64 : i64 +// CHECK-NEXT: %[[GT:.+]] = spirv.SGreaterThan %[[ARG1]], %[[C0]] : i64 +// CHECK-NEXT: spirv.Branch ^[[BB1:.+]] // CHECK-NEXT: ^[[BB1]]: - %var = spv.Variable : !spv.ptr -// CHECK-NEXT: spv.mlir.selection { - spv.mlir.selection { -// CHECK-NEXT: spv.BranchConditional %[[GT]], ^[[THEN:.+]], ^[[ELSE:.+]] - spv.BranchConditional %gt, ^then, ^else + %var = spirv.Variable : !spirv.ptr +// CHECK-NEXT: spirv.mlir.selection { + spirv.mlir.selection { +// CHECK-NEXT: spirv.BranchConditional %[[GT]], ^[[THEN:.+]], ^[[ELSE:.+]] + spirv.BranchConditional %gt, ^then, ^else // CHECK-NEXT: ^[[THEN]]: ^then: -// CHECK-NEXT: %true = spv.Constant true -// CHECK-NEXT: spv.Store "Function" %[[VAR]], %true : i1 - spv.Store "Function" %var, %true : i1 -// CHECK-NEXT: spv.Branch ^[[SELECTION_MERGE:.+]] - spv.Branch ^selection_merge +// CHECK-NEXT: %true = spirv.Constant true +// CHECK-NEXT: spirv.Store "Function" %[[VAR]], %true : i1 + spirv.Store "Function" %var, %true : i1 +// CHECK-NEXT: spirv.Branch ^[[SELECTION_MERGE:.+]] + spirv.Branch ^selection_merge // CHECK-NEXT: ^[[ELSE]]: ^else: -// CHECK-NEXT: %false = spv.Constant false -// CHECK-NEXT: spv.Store "Function" %[[VAR]], %false : i1 - spv.Store "Function" %var, %false : i1 -// CHECK-NEXT: spv.Branch ^[[SELECTION_MERGE]] - spv.Branch ^selection_merge +// CHECK-NEXT: %false = spirv.Constant false +// CHECK-NEXT: spirv.Store "Function" %[[VAR]], %false : i1 + spirv.Store "Function" %var, %false : i1 +// CHECK-NEXT: spirv.Branch ^[[SELECTION_MERGE]] + spirv.Branch ^selection_merge // CHECK-NEXT: ^[[SELECTION_MERGE]]: ^selection_merge: -// CHECK-NEXT: spv.mlir.merge - spv.mlir.merge +// CHECK-NEXT: spirv.mlir.merge + spirv.mlir.merge // CHECK-NEXT: } } -// CHECK-NEXT: %[[LOAD:.+]] = spv.Load "Function" %[[VAR]] : i1 - %load = spv.Load "Function" %var : i1 -// CHECK-NEXT: spv.BranchConditional %[[LOAD]], ^[[CONTINUE:.+]](%[[ARG1]] : i64), ^[[LOOP_MERGE:.+]] - spv.BranchConditional %load, ^continue(%arg1 : i64), ^loop_merge +// CHECK-NEXT: %[[LOAD:.+]] = spirv.Load "Function" %[[VAR]] : i1 + %load = spirv.Load "Function" %var : i1 +// CHECK-NEXT: spirv.BranchConditional %[[LOAD]], ^[[CONTINUE:.+]](%[[ARG1]] : i64), ^[[LOOP_MERGE:.+]] + spirv.BranchConditional %load, ^continue(%arg1 : i64), ^loop_merge // CHECK-NEXT: ^[[CONTINUE]](%[[ARG2:.+]]: i64): ^continue(%arg2: i64): -// CHECK-NEXT: %[[C0:.+]] = spv.Constant 0 : i64 -// CHECK-NEXT: %[[LT:.+]] = spv.SLessThan %[[ARG2]], %[[C0]] : i64 - %lt = spv.SLessThan %arg2, %cst0_i64 : i64 -// CHECK-NEXT: spv.Store "Function" %[[VAR]], %[[LT]] : i1 - spv.Store "Function" %var, %lt : i1 -// CHECK-NEXT: spv.Branch ^[[LOOP_HEADER]](%[[ARG2]] : i64) - spv.Branch ^loop_header(%arg2 : i64) +// CHECK-NEXT: %[[C0:.+]] = spirv.Constant 0 : i64 +// CHECK-NEXT: %[[LT:.+]] = spirv.SLessThan %[[ARG2]], %[[C0]] : i64 + %lt = spirv.SLessThan %arg2, %cst0_i64 : i64 +// CHECK-NEXT: spirv.Store "Function" %[[VAR]], %[[LT]] : i1 + spirv.Store "Function" %var, %lt : i1 +// CHECK-NEXT: spirv.Branch ^[[LOOP_HEADER]](%[[ARG2]] : i64) + spirv.Branch ^loop_header(%arg2 : i64) // CHECK-NEXT: ^[[LOOP_MERGE]]: ^loop_merge: -// CHECK-NEXT: spv.mlir.merge - spv.mlir.merge +// CHECK-NEXT: spirv.mlir.merge + spirv.mlir.merge // CHECK-NEXT: } } -// CHECK-NEXT: spv.Return - spv.Return +// CHECK-NEXT: spirv.Return + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/matrix.mlir b/mlir/test/Target/SPIRV/matrix.mlir --- a/mlir/test/Target/SPIRV/matrix.mlir +++ b/mlir/test/Target/SPIRV/matrix.mlir @@ -1,59 +1,59 @@ // RUN: mlir-translate -split-input-file -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK-LABEL: @matrix_access_chain - spv.func @matrix_access_chain(%arg0 : !spv.ptr>, Function>, %arg1 : i32) -> !spv.ptr, Function> "None" { - // CHECK: {{%.*}} = spv.AccessChain {{%.*}}[{{%.*}}] : !spv.ptr>, Function> - %0 = spv.AccessChain %arg0[%arg1] : !spv.ptr>,Function>, i32 - spv.ReturnValue %0 : !spv.ptr, Function> + spirv.func @matrix_access_chain(%arg0 : !spirv.ptr>, Function>, %arg1 : i32) -> !spirv.ptr, Function> "None" { + // CHECK: {{%.*}} = spirv.AccessChain {{%.*}}[{{%.*}}] : !spirv.ptr>, Function> + %0 = spirv.AccessChain %arg0[%arg1] : !spirv.ptr>,Function>, i32 + spirv.ReturnValue %0 : !spirv.ptr, Function> } // CHECK-LABEL: @matrix_times_scalar_1 - spv.func @matrix_times_scalar_1(%arg0 : !spv.matrix<3 x vector<3xf32>>, %arg1 : f32) -> !spv.matrix<3 x vector<3xf32>> "None" { - // CHECK: {{%.*}} = spv.MatrixTimesScalar {{%.*}}, {{%.*}} : !spv.matrix<3 x vector<3xf32>>, f32 -> !spv.matrix<3 x vector<3xf32>> - %result = spv.MatrixTimesScalar %arg0, %arg1 : !spv.matrix<3 x vector<3xf32>>, f32 -> !spv.matrix<3 x vector<3xf32>> - spv.ReturnValue %result : !spv.matrix<3 x vector<3xf32>> + spirv.func @matrix_times_scalar_1(%arg0 : !spirv.matrix<3 x vector<3xf32>>, %arg1 : f32) -> !spirv.matrix<3 x vector<3xf32>> "None" { + // CHECK: {{%.*}} = spirv.MatrixTimesScalar {{%.*}}, {{%.*}} : !spirv.matrix<3 x vector<3xf32>>, f32 -> !spirv.matrix<3 x vector<3xf32>> + %result = spirv.MatrixTimesScalar %arg0, %arg1 : !spirv.matrix<3 x vector<3xf32>>, f32 -> !spirv.matrix<3 x vector<3xf32>> + spirv.ReturnValue %result : !spirv.matrix<3 x vector<3xf32>> } // CHECK-LABEL: @matrix_times_scalar_2 - spv.func @matrix_times_scalar_2(%arg0 : !spv.matrix<3 x vector<3xf16>>, %arg1 : f16) -> !spv.matrix<3 x vector<3xf16>> "None" { - // CHECK: {{%.*}} = spv.MatrixTimesScalar {{%.*}}, {{%.*}} : !spv.matrix<3 x vector<3xf16>>, f16 -> !spv.matrix<3 x vector<3xf16>> - %result = spv.MatrixTimesScalar %arg0, %arg1 : !spv.matrix<3 x vector<3xf16>>, f16 -> !spv.matrix<3 x vector<3xf16>> - spv.ReturnValue %result : !spv.matrix<3 x vector<3xf16>> + spirv.func @matrix_times_scalar_2(%arg0 : !spirv.matrix<3 x vector<3xf16>>, %arg1 : f16) -> !spirv.matrix<3 x vector<3xf16>> "None" { + // CHECK: {{%.*}} = spirv.MatrixTimesScalar {{%.*}}, {{%.*}} : !spirv.matrix<3 x vector<3xf16>>, f16 -> !spirv.matrix<3 x vector<3xf16>> + %result = spirv.MatrixTimesScalar %arg0, %arg1 : !spirv.matrix<3 x vector<3xf16>>, f16 -> !spirv.matrix<3 x vector<3xf16>> + spirv.ReturnValue %result : !spirv.matrix<3 x vector<3xf16>> } // CHECK-LABEL: @matrix_transpose_1 - spv.func @matrix_transpose_1(%arg0 : !spv.matrix<3 x vector<2xf32>>) -> !spv.matrix<2 x vector<3xf32>> "None" { - // CHECK: {{%.*}} = spv.Transpose {{%.*}} : !spv.matrix<3 x vector<2xf32>> -> !spv.matrix<2 x vector<3xf32>> - %result = spv.Transpose %arg0 : !spv.matrix<3 x vector<2xf32>> -> !spv.matrix<2 x vector<3xf32>> - spv.ReturnValue %result : !spv.matrix<2 x vector<3xf32>> + spirv.func @matrix_transpose_1(%arg0 : !spirv.matrix<3 x vector<2xf32>>) -> !spirv.matrix<2 x vector<3xf32>> "None" { + // CHECK: {{%.*}} = spirv.Transpose {{%.*}} : !spirv.matrix<3 x vector<2xf32>> -> !spirv.matrix<2 x vector<3xf32>> + %result = spirv.Transpose %arg0 : !spirv.matrix<3 x vector<2xf32>> -> !spirv.matrix<2 x vector<3xf32>> + spirv.ReturnValue %result : !spirv.matrix<2 x vector<3xf32>> } // CHECK-LABEL: @matrix_times_matrix_1 - spv.func @matrix_times_matrix_1(%arg0: !spv.matrix<3 x vector<3xf32>>, %arg1: !spv.matrix<3 x vector<3xf32>>) -> !spv.matrix<3 x vector<3xf32>> "None"{ - // CHECK: {{%.*}} = spv.MatrixTimesMatrix {{%.*}}, {{%.*}} : !spv.matrix<3 x vector<3xf32>>, !spv.matrix<3 x vector<3xf32>> -> !spv.matrix<3 x vector<3xf32>> - %result = spv.MatrixTimesMatrix %arg0, %arg1 : !spv.matrix<3 x vector<3xf32>>, !spv.matrix<3 x vector<3xf32>> -> !spv.matrix<3 x vector<3xf32>> - spv.ReturnValue %result : !spv.matrix<3 x vector<3xf32>> + spirv.func @matrix_times_matrix_1(%arg0: !spirv.matrix<3 x vector<3xf32>>, %arg1: !spirv.matrix<3 x vector<3xf32>>) -> !spirv.matrix<3 x vector<3xf32>> "None"{ + // CHECK: {{%.*}} = spirv.MatrixTimesMatrix {{%.*}}, {{%.*}} : !spirv.matrix<3 x vector<3xf32>>, !spirv.matrix<3 x vector<3xf32>> -> !spirv.matrix<3 x vector<3xf32>> + %result = spirv.MatrixTimesMatrix %arg0, %arg1 : !spirv.matrix<3 x vector<3xf32>>, !spirv.matrix<3 x vector<3xf32>> -> !spirv.matrix<3 x vector<3xf32>> + spirv.ReturnValue %result : !spirv.matrix<3 x vector<3xf32>> } // CHECK-LABEL: @matrix_times_matrix_2 - spv.func @matrix_times_matrix_2(%arg0: !spv.matrix<3 x vector<2xf32>>, %arg1: !spv.matrix<2 x vector<3xf32>>) -> !spv.matrix<2 x vector<2xf32>> "None"{ - // CHECK: {{%.*}} = spv.MatrixTimesMatrix {{%.*}}, {{%.*}} : !spv.matrix<3 x vector<2xf32>>, !spv.matrix<2 x vector<3xf32>> -> !spv.matrix<2 x vector<2xf32>> - %result = spv.MatrixTimesMatrix %arg0, %arg1 : !spv.matrix<3 x vector<2xf32>>, !spv.matrix<2 x vector<3xf32>> -> !spv.matrix<2 x vector<2xf32>> - spv.ReturnValue %result : !spv.matrix<2 x vector<2xf32>> + spirv.func @matrix_times_matrix_2(%arg0: !spirv.matrix<3 x vector<2xf32>>, %arg1: !spirv.matrix<2 x vector<3xf32>>) -> !spirv.matrix<2 x vector<2xf32>> "None"{ + // CHECK: {{%.*}} = spirv.MatrixTimesMatrix {{%.*}}, {{%.*}} : !spirv.matrix<3 x vector<2xf32>>, !spirv.matrix<2 x vector<3xf32>> -> !spirv.matrix<2 x vector<2xf32>> + %result = spirv.MatrixTimesMatrix %arg0, %arg1 : !spirv.matrix<3 x vector<2xf32>>, !spirv.matrix<2 x vector<3xf32>> -> !spirv.matrix<2 x vector<2xf32>> + spirv.ReturnValue %result : !spirv.matrix<2 x vector<2xf32>> } } // ----- -spv.module Logical GLSL450 requires #spv.vce { - // CHECK: spv.GlobalVariable {{@.*}} : !spv.ptr>, StorageBuffer> - spv.GlobalVariable @var0 : !spv.ptr>, StorageBuffer> +spirv.module Logical GLSL450 requires #spirv.vce { + // CHECK: spirv.GlobalVariable {{@.*}} : !spirv.ptr>, StorageBuffer> + spirv.GlobalVariable @var0 : !spirv.ptr>, StorageBuffer> - // CHECK: spv.GlobalVariable {{@.*}} : !spv.ptr>, StorageBuffer> - spv.GlobalVariable @var1 : !spv.ptr>, StorageBuffer> + // CHECK: spirv.GlobalVariable {{@.*}} : !spirv.ptr>, StorageBuffer> + spirv.GlobalVariable @var1 : !spirv.ptr>, StorageBuffer> - // CHECK: spv.GlobalVariable {{@.*}} : !spv.ptr>, StorageBuffer> - spv.GlobalVariable @var2 : !spv.ptr>, StorageBuffer> + // CHECK: spirv.GlobalVariable {{@.*}} : !spirv.ptr>, StorageBuffer> + spirv.GlobalVariable @var2 : !spirv.ptr>, StorageBuffer> } diff --git a/mlir/test/Target/SPIRV/memory-ops.mlir b/mlir/test/Target/SPIRV/memory-ops.mlir --- a/mlir/test/Target/SPIRV/memory-ops.mlir +++ b/mlir/test/Target/SPIRV/memory-ops.mlir @@ -1,121 +1,121 @@ // RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - // CHECK-LABEL: spv.func @load_store - // CHECK-SAME: ([[ARG1:%.*]]: !spv.ptr, [[ARG2:%.*]]: !spv.ptr) - spv.func @load_store(%arg0 : !spv.ptr, %arg1 : !spv.ptr) "None" { - // CHECK-NEXT: [[VALUE:%.*]] = spv.Load "Input" [[ARG1]] : f32 - %1 = spv.Load "Input" %arg0 : f32 - // CHECK-NEXT: spv.Store "Output" [[ARG2]], [[VALUE]] : f32 - spv.Store "Output" %arg1, %1 : f32 - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + // CHECK-LABEL: spirv.func @load_store + // CHECK-SAME: ([[ARG1:%.*]]: !spirv.ptr, [[ARG2:%.*]]: !spirv.ptr) + spirv.func @load_store(%arg0 : !spirv.ptr, %arg1 : !spirv.ptr) "None" { + // CHECK-NEXT: [[VALUE:%.*]] = spirv.Load "Input" [[ARG1]] : f32 + %1 = spirv.Load "Input" %arg0 : f32 + // CHECK-NEXT: spirv.Store "Output" [[ARG2]], [[VALUE]] : f32 + spirv.Store "Output" %arg1, %1 : f32 + spirv.Return } - // CHECK-LABEL: spv.func @load_store_memory_operands - spv.func @load_store_memory_operands(%arg0 : !spv.ptr, %arg1 : !spv.ptr) "None" { - // CHECK: spv.Load "Input" %{{.+}} ["Volatile|Aligned", 4] : f32 - %1 = spv.Load "Input" %arg0 ["Volatile|Aligned", 4]: f32 - // CHECK: spv.Store "Output" %{{.+}}, %{{.+}} ["Volatile|Aligned", 4] : f32 - spv.Store "Output" %arg1, %1 ["Volatile|Aligned", 4]: f32 - spv.Return + // CHECK-LABEL: spirv.func @load_store_memory_operands + spirv.func @load_store_memory_operands(%arg0 : !spirv.ptr, %arg1 : !spirv.ptr) "None" { + // CHECK: spirv.Load "Input" %{{.+}} ["Volatile|Aligned", 4] : f32 + %1 = spirv.Load "Input" %arg0 ["Volatile|Aligned", 4]: f32 + // CHECK: spirv.Store "Output" %{{.+}}, %{{.+}} ["Volatile|Aligned", 4] : f32 + spirv.Store "Output" %arg1, %1 ["Volatile|Aligned", 4]: f32 + spirv.Return } } // ----- -spv.module Logical GLSL450 requires #spv.vce { - spv.func @access_chain(%arg0 : !spv.ptr>, Function>, %arg1 : i32, %arg2 : i32) "None" { - // CHECK: {{%.*}} = spv.AccessChain {{%.*}}[{{%.*}}] : !spv.ptr>, Function> - // CHECK-NEXT: {{%.*}} = spv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spv.ptr>, Function> - %1 = spv.AccessChain %arg0[%arg1] : !spv.ptr>, Function>, i32 - %2 = spv.AccessChain %arg0[%arg1, %arg2] : !spv.ptr>, Function>, i32, i32 - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @access_chain(%arg0 : !spirv.ptr>, Function>, %arg1 : i32, %arg2 : i32) "None" { + // CHECK: {{%.*}} = spirv.AccessChain {{%.*}}[{{%.*}}] : !spirv.ptr>, Function> + // CHECK-NEXT: {{%.*}} = spirv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spirv.ptr>, Function> + %1 = spirv.AccessChain %arg0[%arg1] : !spirv.ptr>, Function>, i32 + %2 = spirv.AccessChain %arg0[%arg1, %arg2] : !spirv.ptr>, Function>, i32, i32 + spirv.Return } } // ----- -spv.module Logical GLSL450 requires #spv.vce { - spv.func @load_store_zero_rank_float(%arg0: !spv.ptr [0])>, StorageBuffer>, %arg1: !spv.ptr [0])>, StorageBuffer>) "None" { - // CHECK: [[LOAD_PTR:%.*]] = spv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spv.ptr [0])> - // CHECK-NEXT: [[VAL:%.*]] = spv.Load "StorageBuffer" [[LOAD_PTR]] : f32 - %0 = spv.Constant 0 : i32 - %1 = spv.AccessChain %arg0[%0, %0] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %2 = spv.Load "StorageBuffer" %1 : f32 - - // CHECK: [[STORE_PTR:%.*]] = spv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spv.ptr [0])> - // CHECK-NEXT: spv.Store "StorageBuffer" [[STORE_PTR]], [[VAL]] : f32 - %3 = spv.Constant 0 : i32 - %4 = spv.AccessChain %arg1[%3, %3] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - spv.Store "StorageBuffer" %4, %2 : f32 - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @load_store_zero_rank_float(%arg0: !spirv.ptr [0])>, StorageBuffer>, %arg1: !spirv.ptr [0])>, StorageBuffer>) "None" { + // CHECK: [[LOAD_PTR:%.*]] = spirv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spirv.ptr [0])> + // CHECK-NEXT: [[VAL:%.*]] = spirv.Load "StorageBuffer" [[LOAD_PTR]] : f32 + %0 = spirv.Constant 0 : i32 + %1 = spirv.AccessChain %arg0[%0, %0] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %2 = spirv.Load "StorageBuffer" %1 : f32 + + // CHECK: [[STORE_PTR:%.*]] = spirv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spirv.ptr [0])> + // CHECK-NEXT: spirv.Store "StorageBuffer" [[STORE_PTR]], [[VAL]] : f32 + %3 = spirv.Constant 0 : i32 + %4 = spirv.AccessChain %arg1[%3, %3] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + spirv.Store "StorageBuffer" %4, %2 : f32 + spirv.Return } - spv.func @load_store_zero_rank_int(%arg0: !spv.ptr [0])>, StorageBuffer>, %arg1: !spv.ptr [0])>, StorageBuffer>) "None" { - // CHECK: [[LOAD_PTR:%.*]] = spv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spv.ptr [0])> - // CHECK-NEXT: [[VAL:%.*]] = spv.Load "StorageBuffer" [[LOAD_PTR]] : i32 - %0 = spv.Constant 0 : i32 - %1 = spv.AccessChain %arg0[%0, %0] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - %2 = spv.Load "StorageBuffer" %1 : i32 - - // CHECK: [[STORE_PTR:%.*]] = spv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spv.ptr [0])> - // CHECK-NEXT: spv.Store "StorageBuffer" [[STORE_PTR]], [[VAL]] : i32 - %3 = spv.Constant 0 : i32 - %4 = spv.AccessChain %arg1[%3, %3] : !spv.ptr [0])>, StorageBuffer>, i32, i32 - spv.Store "StorageBuffer" %4, %2 : i32 - spv.Return + spirv.func @load_store_zero_rank_int(%arg0: !spirv.ptr [0])>, StorageBuffer>, %arg1: !spirv.ptr [0])>, StorageBuffer>) "None" { + // CHECK: [[LOAD_PTR:%.*]] = spirv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spirv.ptr [0])> + // CHECK-NEXT: [[VAL:%.*]] = spirv.Load "StorageBuffer" [[LOAD_PTR]] : i32 + %0 = spirv.Constant 0 : i32 + %1 = spirv.AccessChain %arg0[%0, %0] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + %2 = spirv.Load "StorageBuffer" %1 : i32 + + // CHECK: [[STORE_PTR:%.*]] = spirv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spirv.ptr [0])> + // CHECK-NEXT: spirv.Store "StorageBuffer" [[STORE_PTR]], [[VAL]] : i32 + %3 = spirv.Constant 0 : i32 + %4 = spirv.AccessChain %arg1[%3, %3] : !spirv.ptr [0])>, StorageBuffer>, i32, i32 + spirv.Store "StorageBuffer" %4, %2 : i32 + spirv.Return } } // ----- -spv.module Logical GLSL450 requires #spv.vce { - spv.func @copy_memory_simple() "None" { - %0 = spv.Variable : !spv.ptr - %1 = spv.Variable : !spv.ptr - // CHECK: spv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} : f32 - spv.CopyMemory "Function" %0, "Function" %1 : f32 - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @copy_memory_simple() "None" { + %0 = spirv.Variable : !spirv.ptr + %1 = spirv.Variable : !spirv.ptr + // CHECK: spirv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} : f32 + spirv.CopyMemory "Function" %0, "Function" %1 : f32 + spirv.Return } } // ----- -spv.module Logical GLSL450 requires #spv.vce { - spv.func @copy_memory_different_storage_classes(%in : !spv.ptr, Input>, %out : !spv.ptr, Output>) "None" { - // CHECK: spv.CopyMemory "Output" %{{.*}}, "Input" %{{.*}} : !spv.array<4 x f32> - spv.CopyMemory "Output" %out, "Input" %in : !spv.array<4xf32> - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @copy_memory_different_storage_classes(%in : !spirv.ptr, Input>, %out : !spirv.ptr, Output>) "None" { + // CHECK: spirv.CopyMemory "Output" %{{.*}}, "Input" %{{.*}} : !spirv.array<4 x f32> + spirv.CopyMemory "Output" %out, "Input" %in : !spirv.array<4xf32> + spirv.Return } } // ----- -spv.module Logical GLSL450 requires #spv.vce { - spv.func @copy_memory_with_access_operands() "None" { - %0 = spv.Variable : !spv.ptr - %1 = spv.Variable : !spv.ptr - // CHECK: spv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Aligned", 4] : f32 - spv.CopyMemory "Function" %0, "Function" %1 ["Aligned", 4] : f32 +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @copy_memory_with_access_operands() "None" { + %0 = spirv.Variable : !spirv.ptr + %1 = spirv.Variable : !spirv.ptr + // CHECK: spirv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Aligned", 4] : f32 + spirv.CopyMemory "Function" %0, "Function" %1 ["Aligned", 4] : f32 - // CHECK: spv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Volatile"] : f32 - spv.CopyMemory "Function" %0, "Function" %1 ["Volatile"] : f32 + // CHECK: spirv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Volatile"] : f32 + spirv.CopyMemory "Function" %0, "Function" %1 ["Volatile"] : f32 - // CHECK: spv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Volatile"], ["Volatile"] : f32 - spv.CopyMemory "Function" %0, "Function" %1 ["Volatile"], ["Volatile"] : f32 + // CHECK: spirv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Volatile"], ["Volatile"] : f32 + spirv.CopyMemory "Function" %0, "Function" %1 ["Volatile"], ["Volatile"] : f32 - // CHECK: spv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Aligned", 4], ["Volatile"] : f32 - spv.CopyMemory "Function" %0, "Function" %1 ["Aligned", 4], ["Volatile"] : f32 + // CHECK: spirv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Aligned", 4], ["Volatile"] : f32 + spirv.CopyMemory "Function" %0, "Function" %1 ["Aligned", 4], ["Volatile"] : f32 - // CHECK: spv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Volatile"], ["Aligned", 4] : f32 - spv.CopyMemory "Function" %0, "Function" %1 ["Volatile"], ["Aligned", 4] : f32 + // CHECK: spirv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Volatile"], ["Aligned", 4] : f32 + spirv.CopyMemory "Function" %0, "Function" %1 ["Volatile"], ["Aligned", 4] : f32 - // CHECK: spv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Aligned", 8], ["Aligned", 4] : f32 - spv.CopyMemory "Function" %0, "Function" %1 ["Aligned", 8], ["Aligned", 4] : f32 + // CHECK: spirv.CopyMemory "Function" %{{.*}}, "Function" %{{.*}} ["Aligned", 8], ["Aligned", 4] : f32 + spirv.CopyMemory "Function" %0, "Function" %1 ["Aligned", 8], ["Aligned", 4] : f32 - spv.Return + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/module.mlir b/mlir/test/Target/SPIRV/module.mlir --- a/mlir/test/Target/SPIRV/module.mlir +++ b/mlir/test/Target/SPIRV/module.mlir @@ -1,32 +1,32 @@ // RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s -// CHECK: spv.module Logical GLSL450 requires #spv.vce { -// CHECK-NEXT: spv.func @foo() "Inline" { -// CHECK-NEXT: spv.Return +// CHECK: spirv.module Logical GLSL450 requires #spirv.vce { +// CHECK-NEXT: spirv.func @foo() "Inline" { +// CHECK-NEXT: spirv.Return // CHECK-NEXT: } // CHECK-NEXT: } -spv.module Logical GLSL450 requires #spv.vce { - spv.func @foo() -> () "Inline" { - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @foo() -> () "Inline" { + spirv.Return } } // ----- // CHECK: v1.5 -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { } // ----- // CHECK: [Shader, Float16] -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { } // ----- // CHECK: [SPV_KHR_float_controls, SPV_KHR_subgroup_vote] -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { } diff --git a/mlir/test/Target/SPIRV/non-uniform-ops.mlir b/mlir/test/Target/SPIRV/non-uniform-ops.mlir --- a/mlir/test/Target/SPIRV/non-uniform-ops.mlir +++ b/mlir/test/Target/SPIRV/non-uniform-ops.mlir @@ -1,127 +1,127 @@ // RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK-LABEL: @group_non_uniform_ballot - spv.func @group_non_uniform_ballot(%predicate: i1) -> vector<4xi32> "None" { - // CHECK: %{{.*}} = spv.GroupNonUniformBallot %{{.*}}: vector<4xi32> - %0 = spv.GroupNonUniformBallot %predicate : vector<4xi32> - spv.ReturnValue %0: vector<4xi32> + spirv.func @group_non_uniform_ballot(%predicate: i1) -> vector<4xi32> "None" { + // CHECK: %{{.*}} = spirv.GroupNonUniformBallot %{{.*}}: vector<4xi32> + %0 = spirv.GroupNonUniformBallot %predicate : vector<4xi32> + spirv.ReturnValue %0: vector<4xi32> } // CHECK-LABEL: @group_non_uniform_broadcast - spv.func @group_non_uniform_broadcast(%value: f32) -> f32 "None" { - %one = spv.Constant 1 : i32 - // CHECK: spv.GroupNonUniformBroadcast %{{.*}}, %{{.*}} : f32, i32 - %0 = spv.GroupNonUniformBroadcast %value, %one : f32, i32 - spv.ReturnValue %0: f32 + spirv.func @group_non_uniform_broadcast(%value: f32) -> f32 "None" { + %one = spirv.Constant 1 : i32 + // CHECK: spirv.GroupNonUniformBroadcast %{{.*}}, %{{.*}} : f32, i32 + %0 = spirv.GroupNonUniformBroadcast %value, %one : f32, i32 + spirv.ReturnValue %0: f32 } // CHECK-LABEL: @group_non_uniform_elect - spv.func @group_non_uniform_elect() -> i1 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformElect : i1 - %0 = spv.GroupNonUniformElect : i1 - spv.ReturnValue %0: i1 + spirv.func @group_non_uniform_elect() -> i1 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformElect : i1 + %0 = spirv.GroupNonUniformElect : i1 + spirv.ReturnValue %0: i1 } // CHECK-LABEL: @group_non_uniform_fadd_reduce - spv.func @group_non_uniform_fadd_reduce(%val: f32) -> f32 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformFAdd "Workgroup" "Reduce" %{{.+}} : f32 - %0 = spv.GroupNonUniformFAdd "Workgroup" "Reduce" %val : f32 - spv.ReturnValue %0: f32 + spirv.func @group_non_uniform_fadd_reduce(%val: f32) -> f32 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformFAdd "Workgroup" "Reduce" %{{.+}} : f32 + %0 = spirv.GroupNonUniformFAdd "Workgroup" "Reduce" %val : f32 + spirv.ReturnValue %0: f32 } // CHECK-LABEL: @group_non_uniform_fmax_reduce - spv.func @group_non_uniform_fmax_reduce(%val: f32) -> f32 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformFMax "Workgroup" "Reduce" %{{.+}} : f32 - %0 = spv.GroupNonUniformFMax "Workgroup" "Reduce" %val : f32 - spv.ReturnValue %0: f32 + spirv.func @group_non_uniform_fmax_reduce(%val: f32) -> f32 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformFMax "Workgroup" "Reduce" %{{.+}} : f32 + %0 = spirv.GroupNonUniformFMax "Workgroup" "Reduce" %val : f32 + spirv.ReturnValue %0: f32 } // CHECK-LABEL: @group_non_uniform_fmin_reduce - spv.func @group_non_uniform_fmin_reduce(%val: f32) -> f32 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformFMin "Workgroup" "Reduce" %{{.+}} : f32 - %0 = spv.GroupNonUniformFMin "Workgroup" "Reduce" %val : f32 - spv.ReturnValue %0: f32 + spirv.func @group_non_uniform_fmin_reduce(%val: f32) -> f32 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformFMin "Workgroup" "Reduce" %{{.+}} : f32 + %0 = spirv.GroupNonUniformFMin "Workgroup" "Reduce" %val : f32 + spirv.ReturnValue %0: f32 } // CHECK-LABEL: @group_non_uniform_fmul_reduce - spv.func @group_non_uniform_fmul_reduce(%val: f32) -> f32 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformFMul "Workgroup" "Reduce" %{{.+}} : f32 - %0 = spv.GroupNonUniformFMul "Workgroup" "Reduce" %val : f32 - spv.ReturnValue %0: f32 + spirv.func @group_non_uniform_fmul_reduce(%val: f32) -> f32 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformFMul "Workgroup" "Reduce" %{{.+}} : f32 + %0 = spirv.GroupNonUniformFMul "Workgroup" "Reduce" %val : f32 + spirv.ReturnValue %0: f32 } // CHECK-LABEL: @group_non_uniform_iadd_reduce - spv.func @group_non_uniform_iadd_reduce(%val: i32) -> i32 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformIAdd "Workgroup" "Reduce" %{{.+}} : i32 - %0 = spv.GroupNonUniformIAdd "Workgroup" "Reduce" %val : i32 - spv.ReturnValue %0: i32 + spirv.func @group_non_uniform_iadd_reduce(%val: i32) -> i32 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformIAdd "Workgroup" "Reduce" %{{.+}} : i32 + %0 = spirv.GroupNonUniformIAdd "Workgroup" "Reduce" %val : i32 + spirv.ReturnValue %0: i32 } // CHECK-LABEL: @group_non_uniform_iadd_clustered_reduce - spv.func @group_non_uniform_iadd_clustered_reduce(%val: vector<2xi32>) -> vector<2xi32> "None" { - %four = spv.Constant 4 : i32 - // CHECK: %{{.+}} = spv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xi32> - %0 = spv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xi32> - spv.ReturnValue %0: vector<2xi32> + spirv.func @group_non_uniform_iadd_clustered_reduce(%val: vector<2xi32>) -> vector<2xi32> "None" { + %four = spirv.Constant 4 : i32 + // CHECK: %{{.+}} = spirv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xi32> + %0 = spirv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xi32> + spirv.ReturnValue %0: vector<2xi32> } // CHECK-LABEL: @group_non_uniform_imul_reduce - spv.func @group_non_uniform_imul_reduce(%val: i32) -> i32 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformIMul "Workgroup" "Reduce" %{{.+}} : i32 - %0 = spv.GroupNonUniformIMul "Workgroup" "Reduce" %val : i32 - spv.ReturnValue %0: i32 + spirv.func @group_non_uniform_imul_reduce(%val: i32) -> i32 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformIMul "Workgroup" "Reduce" %{{.+}} : i32 + %0 = spirv.GroupNonUniformIMul "Workgroup" "Reduce" %val : i32 + spirv.ReturnValue %0: i32 } // CHECK-LABEL: @group_non_uniform_smax_reduce - spv.func @group_non_uniform_smax_reduce(%val: i32) -> i32 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformSMax "Workgroup" "Reduce" %{{.+}} : i32 - %0 = spv.GroupNonUniformSMax "Workgroup" "Reduce" %val : i32 - spv.ReturnValue %0: i32 + spirv.func @group_non_uniform_smax_reduce(%val: i32) -> i32 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformSMax "Workgroup" "Reduce" %{{.+}} : i32 + %0 = spirv.GroupNonUniformSMax "Workgroup" "Reduce" %val : i32 + spirv.ReturnValue %0: i32 } // CHECK-LABEL: @group_non_uniform_smin_reduce - spv.func @group_non_uniform_smin_reduce(%val: i32) -> i32 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformSMin "Workgroup" "Reduce" %{{.+}} : i32 - %0 = spv.GroupNonUniformSMin "Workgroup" "Reduce" %val : i32 - spv.ReturnValue %0: i32 + spirv.func @group_non_uniform_smin_reduce(%val: i32) -> i32 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformSMin "Workgroup" "Reduce" %{{.+}} : i32 + %0 = spirv.GroupNonUniformSMin "Workgroup" "Reduce" %val : i32 + spirv.ReturnValue %0: i32 } // CHECK-LABEL: @group_non_uniform_umax_reduce - spv.func @group_non_uniform_umax_reduce(%val: i32) -> i32 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformUMax "Workgroup" "Reduce" %{{.+}} : i32 - %0 = spv.GroupNonUniformUMax "Workgroup" "Reduce" %val : i32 - spv.ReturnValue %0: i32 + spirv.func @group_non_uniform_umax_reduce(%val: i32) -> i32 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformUMax "Workgroup" "Reduce" %{{.+}} : i32 + %0 = spirv.GroupNonUniformUMax "Workgroup" "Reduce" %val : i32 + spirv.ReturnValue %0: i32 } // CHECK-LABEL: @group_non_uniform_umin_reduce - spv.func @group_non_uniform_umin_reduce(%val: i32) -> i32 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformUMin "Workgroup" "Reduce" %{{.+}} : i32 - %0 = spv.GroupNonUniformUMin "Workgroup" "Reduce" %val : i32 - spv.ReturnValue %0: i32 + spirv.func @group_non_uniform_umin_reduce(%val: i32) -> i32 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformUMin "Workgroup" "Reduce" %{{.+}} : i32 + %0 = spirv.GroupNonUniformUMin "Workgroup" "Reduce" %val : i32 + spirv.ReturnValue %0: i32 } - spv.func @group_non_uniform_shuffle(%val: f32, %id: i32) -> f32 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformShuffle %{{.+}}, %{{.+}} : f32, i32 - %0 = spv.GroupNonUniformShuffle %val, %id : f32, i32 - spv.ReturnValue %0: f32 + spirv.func @group_non_uniform_shuffle(%val: f32, %id: i32) -> f32 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformShuffle %{{.+}}, %{{.+}} : f32, i32 + %0 = spirv.GroupNonUniformShuffle %val, %id : f32, i32 + spirv.ReturnValue %0: f32 } - spv.func @group_non_uniform_shuffle_up(%val: f32, %id: i32) -> f32 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformShuffleUp %{{.+}}, %{{.+}} : f32, i32 - %0 = spv.GroupNonUniformShuffleUp %val, %id : f32, i32 - spv.ReturnValue %0: f32 + spirv.func @group_non_uniform_shuffle_up(%val: f32, %id: i32) -> f32 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformShuffleUp %{{.+}}, %{{.+}} : f32, i32 + %0 = spirv.GroupNonUniformShuffleUp %val, %id : f32, i32 + spirv.ReturnValue %0: f32 } - spv.func @group_non_uniform_shuffle_down(%val: f32, %id: i32) -> f32 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformShuffleDown %{{.+}}, %{{.+}} : f32, i32 - %0 = spv.GroupNonUniformShuffleDown %val, %id : f32, i32 - spv.ReturnValue %0: f32 + spirv.func @group_non_uniform_shuffle_down(%val: f32, %id: i32) -> f32 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformShuffleDown %{{.+}}, %{{.+}} : f32, i32 + %0 = spirv.GroupNonUniformShuffleDown %val, %id : f32, i32 + spirv.ReturnValue %0: f32 } - spv.func @group_non_uniform_shuffle_xor(%val: f32, %id: i32) -> f32 "None" { - // CHECK: %{{.+}} = spv.GroupNonUniformShuffleXor %{{.+}}, %{{.+}} : f32, i32 - %0 = spv.GroupNonUniformShuffleXor %val, %id : f32, i32 - spv.ReturnValue %0: f32 + spirv.func @group_non_uniform_shuffle_xor(%val: f32, %id: i32) -> f32 "None" { + // CHECK: %{{.+}} = spirv.GroupNonUniformShuffleXor %{{.+}}, %{{.+}} : f32, i32 + %0 = spirv.GroupNonUniformShuffleXor %val, %id : f32, i32 + spirv.ReturnValue %0: f32 } } diff --git a/mlir/test/Target/SPIRV/ocl-ops.mlir b/mlir/test/Target/SPIRV/ocl-ops.mlir --- a/mlir/test/Target/SPIRV/ocl-ops.mlir +++ b/mlir/test/Target/SPIRV/ocl-ops.mlir @@ -1,64 +1,64 @@ // RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s -spv.module Physical64 OpenCL requires #spv.vce { - spv.func @float_insts(%arg0 : f32) "None" { - // CHECK: {{%.*}} = spv.CL.exp {{%.*}} : f32 - %0 = spv.CL.exp %arg0 : f32 - // CHECK: {{%.*}} = spv.CL.fabs {{%.*}} : f32 - %1 = spv.CL.fabs %arg0 : f32 - // CHECK: {{%.*}} = spv.CL.sin {{%.*}} : f32 - %2 = spv.CL.sin %arg0 : f32 - // CHECK: {{%.*}} = spv.CL.cos {{%.*}} : f32 - %3 = spv.CL.cos %arg0 : f32 - // CHECK: {{%.*}} = spv.CL.log {{%.*}} : f32 - %4 = spv.CL.log %arg0 : f32 - // CHECK: {{%.*}} = spv.CL.sqrt {{%.*}} : f32 - %5 = spv.CL.sqrt %arg0 : f32 - // CHECK: {{%.*}} = spv.CL.ceil {{%.*}} : f32 - %6 = spv.CL.ceil %arg0 : f32 - // CHECK: {{%.*}} = spv.CL.floor {{%.*}} : f32 - %7 = spv.CL.floor %arg0 : f32 - // CHECK: {{%.*}} = spv.CL.pow {{%.*}}, {{%.*}} : f32 - %8 = spv.CL.pow %arg0, %arg0 : f32 - // CHECK: {{%.*}} = spv.CL.rsqrt {{%.*}} : f32 - %9 = spv.CL.rsqrt %arg0 : f32 - // CHECK: {{%.*}} = spv.CL.erf {{%.*}} : f32 - %10 = spv.CL.erf %arg0 : f32 - spv.Return +spirv.module Physical64 OpenCL requires #spirv.vce { + spirv.func @float_insts(%arg0 : f32) "None" { + // CHECK: {{%.*}} = spirv.CL.exp {{%.*}} : f32 + %0 = spirv.CL.exp %arg0 : f32 + // CHECK: {{%.*}} = spirv.CL.fabs {{%.*}} : f32 + %1 = spirv.CL.fabs %arg0 : f32 + // CHECK: {{%.*}} = spirv.CL.sin {{%.*}} : f32 + %2 = spirv.CL.sin %arg0 : f32 + // CHECK: {{%.*}} = spirv.CL.cos {{%.*}} : f32 + %3 = spirv.CL.cos %arg0 : f32 + // CHECK: {{%.*}} = spirv.CL.log {{%.*}} : f32 + %4 = spirv.CL.log %arg0 : f32 + // CHECK: {{%.*}} = spirv.CL.sqrt {{%.*}} : f32 + %5 = spirv.CL.sqrt %arg0 : f32 + // CHECK: {{%.*}} = spirv.CL.ceil {{%.*}} : f32 + %6 = spirv.CL.ceil %arg0 : f32 + // CHECK: {{%.*}} = spirv.CL.floor {{%.*}} : f32 + %7 = spirv.CL.floor %arg0 : f32 + // CHECK: {{%.*}} = spirv.CL.pow {{%.*}}, {{%.*}} : f32 + %8 = spirv.CL.pow %arg0, %arg0 : f32 + // CHECK: {{%.*}} = spirv.CL.rsqrt {{%.*}} : f32 + %9 = spirv.CL.rsqrt %arg0 : f32 + // CHECK: {{%.*}} = spirv.CL.erf {{%.*}} : f32 + %10 = spirv.CL.erf %arg0 : f32 + spirv.Return } - spv.func @integer_insts(%arg0 : i32) "None" { - // CHECK: {{%.*}} = spv.CL.s_abs {{%.*}} : i32 - %0 = spv.CL.s_abs %arg0 : i32 - spv.Return + spirv.func @integer_insts(%arg0 : i32) "None" { + // CHECK: {{%.*}} = spirv.CL.s_abs {{%.*}} : i32 + %0 = spirv.CL.s_abs %arg0 : i32 + spirv.Return } - spv.func @vector_size16(%arg0 : vector<16xf32>) "None" { - // CHECK: {{%.*}} = spv.CL.fabs {{%.*}} : vector<16xf32> - %0 = spv.CL.fabs %arg0 : vector<16xf32> - spv.Return + spirv.func @vector_size16(%arg0 : vector<16xf32>) "None" { + // CHECK: {{%.*}} = spirv.CL.fabs {{%.*}} : vector<16xf32> + %0 = spirv.CL.fabs %arg0 : vector<16xf32> + spirv.Return } - spv.func @fma(%arg0 : f32, %arg1 : f32, %arg2 : f32) "None" { - // CHECK: spv.CL.fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32 - %13 = spv.CL.fma %arg0, %arg1, %arg2 : f32 - spv.Return + spirv.func @fma(%arg0 : f32, %arg1 : f32, %arg2 : f32) "None" { + // CHECK: spirv.CL.fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32 + %13 = spirv.CL.fma %arg0, %arg1, %arg2 : f32 + spirv.Return } - spv.func @maxmin(%arg0 : f32, %arg1 : f32, %arg2 : i32, %arg3 : i32) "None" { - // CHECK: {{%.*}} = spv.CL.fmax {{%.*}}, {{%.*}} : f32 - %1 = spv.CL.fmax %arg0, %arg1 : f32 - // CHECK: {{%.*}} = spv.CL.s_max {{%.*}}, {{%.*}} : i32 - %2 = spv.CL.s_max %arg2, %arg3 : i32 - // CHECK: {{%.*}} = spv.CL.u_max {{%.*}}, {{%.*}} : i32 - %3 = spv.CL.u_max %arg2, %arg3 : i32 + spirv.func @maxmin(%arg0 : f32, %arg1 : f32, %arg2 : i32, %arg3 : i32) "None" { + // CHECK: {{%.*}} = spirv.CL.fmax {{%.*}}, {{%.*}} : f32 + %1 = spirv.CL.fmax %arg0, %arg1 : f32 + // CHECK: {{%.*}} = spirv.CL.s_max {{%.*}}, {{%.*}} : i32 + %2 = spirv.CL.s_max %arg2, %arg3 : i32 + // CHECK: {{%.*}} = spirv.CL.u_max {{%.*}}, {{%.*}} : i32 + %3 = spirv.CL.u_max %arg2, %arg3 : i32 - // CHECK: {{%.*}} = spv.CL.fmin {{%.*}}, {{%.*}} : f32 - %4 = spv.CL.fmin %arg0, %arg1 : f32 - // CHECK: {{%.*}} = spv.CL.s_min {{%.*}}, {{%.*}} : i32 - %5 = spv.CL.s_min %arg2, %arg3 : i32 - // CHECK: {{%.*}} = spv.CL.u_min {{%.*}}, {{%.*}} : i32 - %6 = spv.CL.u_min %arg2, %arg3 : i32 - spv.Return + // CHECK: {{%.*}} = spirv.CL.fmin {{%.*}}, {{%.*}} : f32 + %4 = spirv.CL.fmin %arg0, %arg1 : f32 + // CHECK: {{%.*}} = spirv.CL.s_min {{%.*}}, {{%.*}} : i32 + %5 = spirv.CL.s_min %arg2, %arg3 : i32 + // CHECK: {{%.*}} = spirv.CL.u_min {{%.*}}, {{%.*}} : i32 + %6 = spirv.CL.u_min %arg2, %arg3 : i32 + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/phi.mlir b/mlir/test/Target/SPIRV/phi.mlir --- a/mlir/test/Target/SPIRV/phi.mlir +++ b/mlir/test/Target/SPIRV/phi.mlir @@ -2,344 +2,344 @@ // Test branch with one block argument -spv.module Logical GLSL450 requires #spv.vce { - spv.func @foo() -> () "None" { -// CHECK: %[[CST:.*]] = spv.Constant 0 - %zero = spv.Constant 0 : i32 -// CHECK-NEXT: spv.Branch ^bb1(%[[CST]] : i32) - spv.Branch ^bb1(%zero : i32) +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @foo() -> () "None" { +// CHECK: %[[CST:.*]] = spirv.Constant 0 + %zero = spirv.Constant 0 : i32 +// CHECK-NEXT: spirv.Branch ^bb1(%[[CST]] : i32) + spirv.Branch ^bb1(%zero : i32) // CHECK-NEXT: ^bb1(%{{.*}}: i32): ^bb1(%arg0: i32): - spv.Return + spirv.Return } - spv.func @main() -> () "None" { - spv.Return + spirv.func @main() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @main + spirv.EntryPoint "GLCompute" @main } // ----- // Test branch with multiple block arguments -spv.module Logical GLSL450 requires #spv.vce { - spv.func @foo() -> () "None" { -// CHECK: %[[ZERO:.*]] = spv.Constant 0 - %zero = spv.Constant 0 : i32 -// CHECK-NEXT: %[[ONE:.*]] = spv.Constant 1 - %one = spv.Constant 1.0 : f32 -// CHECK-NEXT: spv.Branch ^bb1(%[[ZERO]], %[[ONE]] : i32, f32) - spv.Branch ^bb1(%zero, %one : i32, f32) +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @foo() -> () "None" { +// CHECK: %[[ZERO:.*]] = spirv.Constant 0 + %zero = spirv.Constant 0 : i32 +// CHECK-NEXT: %[[ONE:.*]] = spirv.Constant 1 + %one = spirv.Constant 1.0 : f32 +// CHECK-NEXT: spirv.Branch ^bb1(%[[ZERO]], %[[ONE]] : i32, f32) + spirv.Branch ^bb1(%zero, %one : i32, f32) // CHECK-NEXT: ^bb1(%{{.*}}: i32, %{{.*}}: f32): // pred: ^bb0 ^bb1(%arg0: i32, %arg1: f32): - spv.Return + spirv.Return } - spv.func @main() -> () "None" { - spv.Return + spirv.func @main() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @main + spirv.EntryPoint "GLCompute" @main } // ----- // Test using block arguments within branch -spv.module Logical GLSL450 requires #spv.vce { - spv.func @foo() -> () "None" { -// CHECK: %[[CST0:.*]] = spv.Constant 0 - %zero = spv.Constant 0 : i32 -// CHECK-NEXT: spv.Branch ^bb1(%[[CST0]] : i32) - spv.Branch ^bb1(%zero : i32) +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @foo() -> () "None" { +// CHECK: %[[CST0:.*]] = spirv.Constant 0 + %zero = spirv.Constant 0 : i32 +// CHECK-NEXT: spirv.Branch ^bb1(%[[CST0]] : i32) + spirv.Branch ^bb1(%zero : i32) // CHECK-NEXT: ^bb1(%[[ARG:.*]]: i32): ^bb1(%arg0: i32): -// CHECK-NEXT: %[[ADD:.*]] = spv.IAdd %[[ARG]], %[[ARG]] : i32 - %0 = spv.IAdd %arg0, %arg0 : i32 -// CHECK-NEXT: %[[CST1:.*]] = spv.Constant 0 -// CHECK-NEXT: spv.Branch ^bb2(%[[CST1]], %[[ADD]] : i32, i32) - spv.Branch ^bb2(%zero, %0 : i32, i32) +// CHECK-NEXT: %[[ADD:.*]] = spirv.IAdd %[[ARG]], %[[ARG]] : i32 + %0 = spirv.IAdd %arg0, %arg0 : i32 +// CHECK-NEXT: %[[CST1:.*]] = spirv.Constant 0 +// CHECK-NEXT: spirv.Branch ^bb2(%[[CST1]], %[[ADD]] : i32, i32) + spirv.Branch ^bb2(%zero, %0 : i32, i32) // CHECK-NEXT: ^bb2(%{{.*}}: i32, %{{.*}}: i32): ^bb2(%arg1: i32, %arg2: i32): - spv.Return + spirv.Return } - spv.func @main() -> () "None" { - spv.Return + spirv.func @main() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @main + spirv.EntryPoint "GLCompute" @main } // ----- // Test block not following domination order -spv.module Logical GLSL450 requires #spv.vce { - spv.func @foo() -> () "None" { -// CHECK: spv.Branch ^bb1 - spv.Branch ^bb1 +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @foo() -> () "None" { +// CHECK: spirv.Branch ^bb1 + spirv.Branch ^bb1 // CHECK-NEXT: ^bb1: -// CHECK-NEXT: %[[ZERO:.*]] = spv.Constant 0 -// CHECK-NEXT: %[[ONE:.*]] = spv.Constant 1 -// CHECK-NEXT: spv.Branch ^bb2(%[[ZERO]], %[[ONE]] : i32, f32) +// CHECK-NEXT: %[[ZERO:.*]] = spirv.Constant 0 +// CHECK-NEXT: %[[ONE:.*]] = spirv.Constant 1 +// CHECK-NEXT: spirv.Branch ^bb2(%[[ZERO]], %[[ONE]] : i32, f32) // CHECK-NEXT: ^bb2(%{{.*}}: i32, %{{.*}}: f32): ^bb2(%arg0: i32, %arg1: f32): -// CHECK-NEXT: spv.Return - spv.Return +// CHECK-NEXT: spirv.Return + spirv.Return // This block is reordered to follow domination order. ^bb1: - %zero = spv.Constant 0 : i32 - %one = spv.Constant 1.0 : f32 - spv.Branch ^bb2(%zero, %one : i32, f32) + %zero = spirv.Constant 0 : i32 + %one = spirv.Constant 1.0 : f32 + spirv.Branch ^bb2(%zero, %one : i32, f32) } - spv.func @main() -> () "None" { - spv.Return + spirv.func @main() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @main + spirv.EntryPoint "GLCompute" @main } // ----- // Test multiple predecessors -spv.module Logical GLSL450 requires #spv.vce { - spv.func @foo() -> () "None" { - %var = spv.Variable : !spv.ptr +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @foo() -> () "None" { + %var = spirv.Variable : !spirv.ptr -// CHECK: spv.mlir.selection - spv.mlir.selection { - %true = spv.Constant true -// CHECK: spv.BranchConditional %{{.*}}, ^bb1, ^bb2 - spv.BranchConditional %true, ^true, ^false +// CHECK: spirv.mlir.selection + spirv.mlir.selection { + %true = spirv.Constant true +// CHECK: spirv.BranchConditional %{{.*}}, ^bb1, ^bb2 + spirv.BranchConditional %true, ^true, ^false // CHECK-NEXT: ^bb1: ^true: -// CHECK-NEXT: %[[ZERO:.*]] = spv.Constant 0 - %zero = spv.Constant 0 : i32 -// CHECK-NEXT: spv.Branch ^bb3(%[[ZERO]] : i32) - spv.Branch ^phi(%zero: i32) +// CHECK-NEXT: %[[ZERO:.*]] = spirv.Constant 0 + %zero = spirv.Constant 0 : i32 +// CHECK-NEXT: spirv.Branch ^bb3(%[[ZERO]] : i32) + spirv.Branch ^phi(%zero: i32) // CHECK-NEXT: ^bb2: ^false: -// CHECK-NEXT: %[[ONE:.*]] = spv.Constant 1 - %one = spv.Constant 1 : i32 -// CHECK-NEXT: spv.Branch ^bb3(%[[ONE]] : i32) - spv.Branch ^phi(%one: i32) +// CHECK-NEXT: %[[ONE:.*]] = spirv.Constant 1 + %one = spirv.Constant 1 : i32 +// CHECK-NEXT: spirv.Branch ^bb3(%[[ONE]] : i32) + spirv.Branch ^phi(%one: i32) // CHECK-NEXT: ^bb3(%[[ARG:.*]]: i32): ^phi(%arg: i32): -// CHECK-NEXT: spv.Store "Function" %{{.*}}, %[[ARG]] : i32 - spv.Store "Function" %var, %arg : i32 -// CHECK-NEXT: spv.Return - spv.Return +// CHECK-NEXT: spirv.Store "Function" %{{.*}}, %[[ARG]] : i32 + spirv.Store "Function" %var, %arg : i32 +// CHECK-NEXT: spirv.Return + spirv.Return // CHECK-NEXT: ^bb4: ^merge: -// CHECK-NEXT: spv.mlir.merge - spv.mlir.merge +// CHECK-NEXT: spirv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } - spv.func @main() -> () "None" { - spv.Return + spirv.func @main() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @main + spirv.EntryPoint "GLCompute" @main } // ----- // Test nested loops with block arguments -spv.module Logical GLSL450 requires #spv.vce { - spv.GlobalVariable @__builtin_var_NumWorkgroups__ built_in("NumWorkgroups") : !spv.ptr, Input> - spv.GlobalVariable @__builtin_var_WorkgroupId__ built_in("WorkgroupId") : !spv.ptr, Input> - spv.func @fmul_kernel() "None" { - %3 = spv.Constant 12 : i32 - %4 = spv.Constant 32 : i32 - %5 = spv.Constant 4 : i32 - %6 = spv.mlir.addressof @__builtin_var_WorkgroupId__ : !spv.ptr, Input> - %7 = spv.Load "Input" %6 : vector<3xi32> - %8 = spv.CompositeExtract %7[0 : i32] : vector<3xi32> - %9 = spv.mlir.addressof @__builtin_var_WorkgroupId__ : !spv.ptr, Input> - %10 = spv.Load "Input" %9 : vector<3xi32> - %11 = spv.CompositeExtract %10[1 : i32] : vector<3xi32> - %18 = spv.mlir.addressof @__builtin_var_NumWorkgroups__ : !spv.ptr, Input> - %19 = spv.Load "Input" %18 : vector<3xi32> - %20 = spv.CompositeExtract %19[0 : i32] : vector<3xi32> - %21 = spv.mlir.addressof @__builtin_var_NumWorkgroups__ : !spv.ptr, Input> - %22 = spv.Load "Input" %21 : vector<3xi32> - %23 = spv.CompositeExtract %22[1 : i32] : vector<3xi32> - %30 = spv.IMul %11, %4 : i32 - %31 = spv.IMul %23, %4 : i32 - -// CHECK: spv.Branch ^[[FN_BB:.*]](%{{.*}} : i32) +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.GlobalVariable @__builtin_var_NumWorkgroups__ built_in("NumWorkgroups") : !spirv.ptr, Input> + spirv.GlobalVariable @__builtin_var_WorkgroupId__ built_in("WorkgroupId") : !spirv.ptr, Input> + spirv.func @fmul_kernel() "None" { + %3 = spirv.Constant 12 : i32 + %4 = spirv.Constant 32 : i32 + %5 = spirv.Constant 4 : i32 + %6 = spirv.mlir.addressof @__builtin_var_WorkgroupId__ : !spirv.ptr, Input> + %7 = spirv.Load "Input" %6 : vector<3xi32> + %8 = spirv.CompositeExtract %7[0 : i32] : vector<3xi32> + %9 = spirv.mlir.addressof @__builtin_var_WorkgroupId__ : !spirv.ptr, Input> + %10 = spirv.Load "Input" %9 : vector<3xi32> + %11 = spirv.CompositeExtract %10[1 : i32] : vector<3xi32> + %18 = spirv.mlir.addressof @__builtin_var_NumWorkgroups__ : !spirv.ptr, Input> + %19 = spirv.Load "Input" %18 : vector<3xi32> + %20 = spirv.CompositeExtract %19[0 : i32] : vector<3xi32> + %21 = spirv.mlir.addressof @__builtin_var_NumWorkgroups__ : !spirv.ptr, Input> + %22 = spirv.Load "Input" %21 : vector<3xi32> + %23 = spirv.CompositeExtract %22[1 : i32] : vector<3xi32> + %30 = spirv.IMul %11, %4 : i32 + %31 = spirv.IMul %23, %4 : i32 + +// CHECK: spirv.Branch ^[[FN_BB:.*]](%{{.*}} : i32) // CHECK: ^[[FN_BB]](%[[FN_BB_ARG:.*]]: i32): -// CHECK: spv.mlir.loop { - spv.mlir.loop { -// CHECK: spv.Branch ^bb1(%[[FN_BB_ARG]] : i32) - spv.Branch ^bb1(%30 : i32) +// CHECK: spirv.mlir.loop { + spirv.mlir.loop { +// CHECK: spirv.Branch ^bb1(%[[FN_BB_ARG]] : i32) + spirv.Branch ^bb1(%30 : i32) // CHECK: ^[[LP1_HDR:.*]](%[[LP1_HDR_ARG:.*]]: i32): ^bb1(%32: i32): -// CHECK: spv.SLessThan - %33 = spv.SLessThan %32, %3 : i32 -// CHECK: spv.BranchConditional %{{.*}}, ^[[LP1_BDY:.*]], ^[[LP1_MG:.*]] - spv.BranchConditional %33, ^bb2, ^bb3 +// CHECK: spirv.SLessThan + %33 = spirv.SLessThan %32, %3 : i32 +// CHECK: spirv.BranchConditional %{{.*}}, ^[[LP1_BDY:.*]], ^[[LP1_MG:.*]] + spirv.BranchConditional %33, ^bb2, ^bb3 // CHECK: ^[[LP1_BDY]]: ^bb2: -// CHECK: %[[MUL:.*]] = spv.IMul - %34 = spv.IMul %8, %5 : i32 -// CHECK: spv.IMul - %35 = spv.IMul %20, %5 : i32 -// CHECK: spv.Branch ^[[LP1_CNT:.*]](%[[MUL]] : i32) +// CHECK: %[[MUL:.*]] = spirv.IMul + %34 = spirv.IMul %8, %5 : i32 +// CHECK: spirv.IMul + %35 = spirv.IMul %20, %5 : i32 +// CHECK: spirv.Branch ^[[LP1_CNT:.*]](%[[MUL]] : i32) // CHECK: ^[[LP1_CNT]](%[[LP1_CNT_ARG:.*]]: i32): -// CHECK: spv.mlir.loop { - spv.mlir.loop { -// CHECK: spv.Branch ^[[LP2_HDR:.*]](%[[LP1_CNT_ARG]] : i32) - spv.Branch ^bb1(%34 : i32) +// CHECK: spirv.mlir.loop { + spirv.mlir.loop { +// CHECK: spirv.Branch ^[[LP2_HDR:.*]](%[[LP1_CNT_ARG]] : i32) + spirv.Branch ^bb1(%34 : i32) // CHECK: ^[[LP2_HDR]](%[[LP2_HDR_ARG:.*]]: i32): ^bb1(%37: i32): -// CHECK: spv.SLessThan %[[LP2_HDR_ARG]] - %38 = spv.SLessThan %37, %5 : i32 -// CHECK: spv.BranchConditional %{{.*}}, ^[[LP2_BDY:.*]], ^[[LP2_MG:.*]] - spv.BranchConditional %38, ^bb2, ^bb3 +// CHECK: spirv.SLessThan %[[LP2_HDR_ARG]] + %38 = spirv.SLessThan %37, %5 : i32 +// CHECK: spirv.BranchConditional %{{.*}}, ^[[LP2_BDY:.*]], ^[[LP2_MG:.*]] + spirv.BranchConditional %38, ^bb2, ^bb3 // CHECK: ^[[LP2_BDY]]: ^bb2: -// CHECK: %[[ADD1:.*]] = spv.IAdd - %48 = spv.IAdd %37, %35 : i32 -// CHECK: spv.Branch ^[[LP2_HDR]](%[[ADD1]] : i32) - spv.Branch ^bb1(%48 : i32) +// CHECK: %[[ADD1:.*]] = spirv.IAdd + %48 = spirv.IAdd %37, %35 : i32 +// CHECK: spirv.Branch ^[[LP2_HDR]](%[[ADD1]] : i32) + spirv.Branch ^bb1(%48 : i32) // CHECK: ^[[LP2_MG]]: ^bb3: -// CHECK: spv.mlir.merge - spv.mlir.merge +// CHECK: spirv.mlir.merge + spirv.mlir.merge } -// CHECK: %[[ADD2:.*]] = spv.IAdd %[[LP1_HDR_ARG]] - %36 = spv.IAdd %32, %31 : i32 -// CHECK: spv.Branch ^[[LP1_HDR]](%[[ADD2]] : i32) - spv.Branch ^bb1(%36 : i32) +// CHECK: %[[ADD2:.*]] = spirv.IAdd %[[LP1_HDR_ARG]] + %36 = spirv.IAdd %32, %31 : i32 +// CHECK: spirv.Branch ^[[LP1_HDR]](%[[ADD2]] : i32) + spirv.Branch ^bb1(%36 : i32) // CHECK: ^[[LP1_MG]]: ^bb3: -// CHECK: spv.mlir.merge - spv.mlir.merge +// CHECK: spirv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } - spv.EntryPoint "GLCompute" @fmul_kernel, @__builtin_var_WorkgroupId__, @__builtin_var_NumWorkgroups__ - spv.ExecutionMode @fmul_kernel "LocalSize", 32, 1, 1 + spirv.EntryPoint "GLCompute" @fmul_kernel, @__builtin_var_WorkgroupId__, @__builtin_var_NumWorkgroups__ + spirv.ExecutionMode @fmul_kernel "LocalSize", 32, 1, 1 } // ----- // Test back-to-back loops with block arguments -spv.module Logical GLSL450 requires #spv.vce { - spv.func @fmul_kernel() "None" { - %cst4 = spv.Constant 4 : i32 +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @fmul_kernel() "None" { + %cst4 = spirv.Constant 4 : i32 - %val1 = spv.Constant 43 : i32 - %val2 = spv.Constant 44 : i32 + %val1 = spirv.Constant 43 : i32 + %val2 = spirv.Constant 44 : i32 -// CHECK: spv.Constant 43 -// CHECK-NEXT: spv.Branch ^[[BB1:.+]](%{{.+}} : i32) +// CHECK: spirv.Constant 43 +// CHECK-NEXT: spirv.Branch ^[[BB1:.+]](%{{.+}} : i32) // CHECK-NEXT: ^[[BB1]](%{{.+}}: i32): -// CHECK-NEXT: spv.mlir.loop - spv.mlir.loop { // loop 1 - spv.Branch ^bb1(%val1 : i32) +// CHECK-NEXT: spirv.mlir.loop + spirv.mlir.loop { // loop 1 + spirv.Branch ^bb1(%val1 : i32) ^bb1(%loop1_bb_arg: i32): - %loop1_lt = spv.SLessThan %loop1_bb_arg, %cst4 : i32 - spv.BranchConditional %loop1_lt, ^bb2, ^bb3 + %loop1_lt = spirv.SLessThan %loop1_bb_arg, %cst4 : i32 + spirv.BranchConditional %loop1_lt, ^bb2, ^bb3 ^bb2: - %loop1_add = spv.IAdd %loop1_bb_arg, %cst4 : i32 - spv.Branch ^bb1(%loop1_add : i32) + %loop1_add = spirv.IAdd %loop1_bb_arg, %cst4 : i32 + spirv.Branch ^bb1(%loop1_add : i32) ^bb3: - spv.mlir.merge + spirv.mlir.merge } -// CHECK: spv.Constant 44 -// CHECK-NEXT: spv.Branch ^[[BB2:.+]](%{{.+}} : i32) +// CHECK: spirv.Constant 44 +// CHECK-NEXT: spirv.Branch ^[[BB2:.+]](%{{.+}} : i32) // CHECK-NEXT: ^[[BB2]](%{{.+}}: i32): -// CHECK-NEXT: spv.mlir.loop - spv.mlir.loop { // loop 2 - spv.Branch ^bb1(%val2 : i32) +// CHECK-NEXT: spirv.mlir.loop + spirv.mlir.loop { // loop 2 + spirv.Branch ^bb1(%val2 : i32) ^bb1(%loop2_bb_arg: i32): - %loop2_lt = spv.SLessThan %loop2_bb_arg, %cst4 : i32 - spv.BranchConditional %loop2_lt, ^bb2, ^bb3 + %loop2_lt = spirv.SLessThan %loop2_bb_arg, %cst4 : i32 + spirv.BranchConditional %loop2_lt, ^bb2, ^bb3 ^bb2: - %loop2_add = spv.IAdd %loop2_bb_arg, %cst4 : i32 - spv.Branch ^bb1(%loop2_add : i32) + %loop2_add = spirv.IAdd %loop2_bb_arg, %cst4 : i32 + spirv.Branch ^bb1(%loop2_add : i32) ^bb3: - spv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } - spv.EntryPoint "GLCompute" @fmul_kernel - spv.ExecutionMode @fmul_kernel "LocalSize", 32, 1, 1 + spirv.EntryPoint "GLCompute" @fmul_kernel + spirv.ExecutionMode @fmul_kernel "LocalSize", 32, 1, 1 } // ----- -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK-LABEL: @cond_branch_true_argument - spv.func @cond_branch_true_argument() -> () "None" { - %true = spv.Constant true - %zero = spv.Constant 0 : i32 - %one = spv.Constant 1 : i32 -// CHECK: spv.BranchConditional %{{.*}}, ^[[true1:.*]](%{{.*}}, %{{.*}} : i32, i32), ^[[false1:.*]] - spv.BranchConditional %true, ^true1(%zero, %zero: i32, i32), ^false1 + spirv.func @cond_branch_true_argument() -> () "None" { + %true = spirv.Constant true + %zero = spirv.Constant 0 : i32 + %one = spirv.Constant 1 : i32 +// CHECK: spirv.BranchConditional %{{.*}}, ^[[true1:.*]](%{{.*}}, %{{.*}} : i32, i32), ^[[false1:.*]] + spirv.BranchConditional %true, ^true1(%zero, %zero: i32, i32), ^false1 // CHECK: [[true1]](%{{.*}}: i32, %{{.*}}: i32) ^true1(%arg0: i32, %arg1: i32): - spv.Return + spirv.Return // CHECK: [[false1]]: ^false1: - spv.Return + spirv.Return } } // ----- -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK-LABEL: @cond_branch_false_argument - spv.func @cond_branch_false_argument() -> () "None" { - %true = spv.Constant true - %zero = spv.Constant 0 : i32 - %one = spv.Constant 1 : i32 -// CHECK: spv.BranchConditional %{{.*}}, ^[[true1:.*]], ^[[false1:.*]](%{{.*}}, %{{.*}} : i32, i32) - spv.BranchConditional %true, ^true1, ^false1(%zero, %zero: i32, i32) + spirv.func @cond_branch_false_argument() -> () "None" { + %true = spirv.Constant true + %zero = spirv.Constant 0 : i32 + %one = spirv.Constant 1 : i32 +// CHECK: spirv.BranchConditional %{{.*}}, ^[[true1:.*]], ^[[false1:.*]](%{{.*}}, %{{.*}} : i32, i32) + spirv.BranchConditional %true, ^true1, ^false1(%zero, %zero: i32, i32) // CHECK: [[true1]]: ^true1: - spv.Return + spirv.Return // CHECK: [[false1]](%{{.*}}: i32, %{{.*}}: i32): ^false1(%arg0: i32, %arg1: i32): - spv.Return + spirv.Return } } // ----- -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK-LABEL: @cond_branch_true_and_false_argument - spv.func @cond_branch_true_and_false_argument() -> () "None" { - %true = spv.Constant true - %zero = spv.Constant 0 : i32 - %one = spv.Constant 1 : i32 -// CHECK: spv.BranchConditional %{{.*}}, ^[[true1:.*]](%{{.*}} : i32), ^[[false1:.*]](%{{.*}}, %{{.*}} : i32, i32) - spv.BranchConditional %true, ^true1(%one: i32), ^false1(%zero, %zero: i32, i32) + spirv.func @cond_branch_true_and_false_argument() -> () "None" { + %true = spirv.Constant true + %zero = spirv.Constant 0 : i32 + %one = spirv.Constant 1 : i32 +// CHECK: spirv.BranchConditional %{{.*}}, ^[[true1:.*]](%{{.*}} : i32), ^[[false1:.*]](%{{.*}}, %{{.*}} : i32, i32) + spirv.BranchConditional %true, ^true1(%one: i32), ^false1(%zero, %zero: i32, i32) // CHECK: [[true1]](%{{.*}}: i32): ^true1(%arg0: i32): - spv.Return + spirv.Return // CHECK: [[false1]](%{{.*}}: i32, %{{.*}}: i32): ^false1(%arg1: i32, %arg2: i32): - spv.Return + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/sampled-image.mlir b/mlir/test/Target/SPIRV/sampled-image.mlir --- a/mlir/test/Target/SPIRV/sampled-image.mlir +++ b/mlir/test/Target/SPIRV/sampled-image.mlir @@ -1,12 +1,12 @@ // RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - // CHECK: !spv.ptr>, UniformConstant> - spv.GlobalVariable @var0 bind(0, 1) : !spv.ptr>, UniformConstant> +spirv.module Logical GLSL450 requires #spirv.vce { + // CHECK: !spirv.ptr>, UniformConstant> + spirv.GlobalVariable @var0 bind(0, 1) : !spirv.ptr>, UniformConstant> - // CHECK: !spv.ptr>, UniformConstant> - spv.GlobalVariable @var1 bind(0, 0) : !spv.ptr>, UniformConstant> + // CHECK: !spirv.ptr>, UniformConstant> + spirv.GlobalVariable @var1 bind(0, 0) : !spirv.ptr>, UniformConstant> - // CHECK: !spv.ptr>, UniformConstant> - spv.GlobalVariable @var2 bind(0, 0) : !spv.ptr>, UniformConstant> + // CHECK: !spirv.ptr>, UniformConstant> + spirv.GlobalVariable @var2 bind(0, 0) : !spirv.ptr>, UniformConstant> } diff --git a/mlir/test/Target/SPIRV/selection.mlir b/mlir/test/Target/SPIRV/selection.mlir --- a/mlir/test/Target/SPIRV/selection.mlir +++ b/mlir/test/Target/SPIRV/selection.mlir @@ -2,53 +2,53 @@ // Selection with both then and else branches -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK-LABEL: @selection - spv.func @selection(%cond: i1) -> () "None" { -// CHECK-NEXT: spv.Constant 0 -// CHECK-NEXT: spv.Variable -// CHECK: spv.Branch ^[[BB:.+]] + spirv.func @selection(%cond: i1) -> () "None" { +// CHECK-NEXT: spirv.Constant 0 +// CHECK-NEXT: spirv.Variable +// CHECK: spirv.Branch ^[[BB:.+]] // CHECK-NEXT: ^[[BB]]: - %zero = spv.Constant 0: i32 - %one = spv.Constant 1: i32 - %two = spv.Constant 2: i32 - %var = spv.Variable init(%zero) : !spv.ptr + %zero = spirv.Constant 0: i32 + %one = spirv.Constant 1: i32 + %two = spirv.Constant 2: i32 + %var = spirv.Variable init(%zero) : !spirv.ptr -// CHECK-NEXT: spv.mlir.selection control(Flatten) - spv.mlir.selection control(Flatten) { -// CHECK-NEXT: spv.BranchConditional %{{.*}} [5, 10], ^[[THEN:.+]], ^[[ELSE:.+]] - spv.BranchConditional %cond [5, 10], ^then, ^else +// CHECK-NEXT: spirv.mlir.selection control(Flatten) + spirv.mlir.selection control(Flatten) { +// CHECK-NEXT: spirv.BranchConditional %{{.*}} [5, 10], ^[[THEN:.+]], ^[[ELSE:.+]] + spirv.BranchConditional %cond [5, 10], ^then, ^else // CHECK-NEXT: ^[[THEN]]: ^then: -// CHECK-NEXT: spv.Constant 1 -// CHECK-NEXT: spv.Store - spv.Store "Function" %var, %one : i32 -// CHECK-NEXT: spv.Branch ^[[MERGE:.+]] - spv.Branch ^merge +// CHECK-NEXT: spirv.Constant 1 +// CHECK-NEXT: spirv.Store + spirv.Store "Function" %var, %one : i32 +// CHECK-NEXT: spirv.Branch ^[[MERGE:.+]] + spirv.Branch ^merge // CHECK-NEXT: ^[[ELSE]]: ^else: -// CHECK-NEXT: spv.Constant 2 -// CHECK-NEXT: spv.Store - spv.Store "Function" %var, %two : i32 -// CHECK-NEXT: spv.Branch ^[[MERGE]] - spv.Branch ^merge +// CHECK-NEXT: spirv.Constant 2 +// CHECK-NEXT: spirv.Store + spirv.Store "Function" %var, %two : i32 +// CHECK-NEXT: spirv.Branch ^[[MERGE]] + spirv.Branch ^merge // CHECK-NEXT: ^[[MERGE]]: ^merge: -// CHECK-NEXT: spv.mlir.merge - spv.mlir.merge +// CHECK-NEXT: spirv.mlir.merge + spirv.mlir.merge } - spv.Return + spirv.Return } - spv.func @main() -> () "None" { - spv.Return + spirv.func @main() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @main - spv.ExecutionMode @main "LocalSize", 1, 1, 1 + spirv.EntryPoint "GLCompute" @main + spirv.ExecutionMode @main "LocalSize", 1, 1, 1 } // ----- @@ -56,37 +56,37 @@ // Selection with only then branch // Selection in function entry block -spv.module Logical GLSL450 requires #spv.vce { -// CHECK-LABEL: spv.func @selection +spirv.module Logical GLSL450 requires #spirv.vce { +// CHECK-LABEL: spirv.func @selection // CHECK-SAME: (%[[ARG:.*]]: i1) - spv.func @selection(%cond: i1) -> (i32) "None" { -// CHECK: spv.Branch ^[[BB:.+]] + spirv.func @selection(%cond: i1) -> (i32) "None" { +// CHECK: spirv.Branch ^[[BB:.+]] // CHECK-NEXT: ^[[BB]]: -// CHECK-NEXT: spv.mlir.selection - spv.mlir.selection { -// CHECK-NEXT: spv.BranchConditional %[[ARG]], ^[[THEN:.+]], ^[[ELSE:.+]] - spv.BranchConditional %cond, ^then, ^merge +// CHECK-NEXT: spirv.mlir.selection + spirv.mlir.selection { +// CHECK-NEXT: spirv.BranchConditional %[[ARG]], ^[[THEN:.+]], ^[[ELSE:.+]] + spirv.BranchConditional %cond, ^then, ^merge // CHECK: ^[[THEN]]: ^then: - %zero = spv.Constant 0 : i32 - spv.ReturnValue %zero : i32 + %zero = spirv.Constant 0 : i32 + spirv.ReturnValue %zero : i32 // CHECK: ^[[ELSE]]: ^merge: -// CHECK-NEXT: spv.mlir.merge - spv.mlir.merge +// CHECK-NEXT: spirv.mlir.merge + spirv.mlir.merge } - %one = spv.Constant 1 : i32 - spv.ReturnValue %one : i32 + %one = spirv.Constant 1 : i32 + spirv.ReturnValue %one : i32 } - spv.func @main() -> () "None" { - spv.Return + spirv.func @main() -> () "None" { + spirv.Return } - spv.EntryPoint "GLCompute" @main - spv.ExecutionMode @main "LocalSize", 1, 1, 1 + spirv.EntryPoint "GLCompute" @main + spirv.ExecutionMode @main "LocalSize", 1, 1, 1 } // ----- @@ -94,57 +94,57 @@ // Selection with control flow afterwards // SSA value def before selection and use after selection -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK-LABEL: @selection_cf() - spv.func @selection_cf() -> () "None" { - %true = spv.Constant true - %false = spv.Constant false - %zero = spv.Constant 0 : i32 - %one = spv.Constant 1 : i32 -// CHECK-NEXT: %[[VAR:.+]] = spv.Variable - %var = spv.Variable : !spv.ptr -// CHECK-NEXT: spv.Branch ^[[BB:.+]] + spirv.func @selection_cf() -> () "None" { + %true = spirv.Constant true + %false = spirv.Constant false + %zero = spirv.Constant 0 : i32 + %one = spirv.Constant 1 : i32 +// CHECK-NEXT: %[[VAR:.+]] = spirv.Variable + %var = spirv.Variable : !spirv.ptr +// CHECK-NEXT: spirv.Branch ^[[BB:.+]] // CHECK-NEXT: ^[[BB]]: -// CHECK-NEXT: spv.mlir.selection { - spv.mlir.selection { -// CHECK: spv.BranchConditional %{{.+}}, ^[[THEN0:.+]], ^[[ELSE0:.+]] - spv.BranchConditional %true, ^then0, ^else0 +// CHECK-NEXT: spirv.mlir.selection { + spirv.mlir.selection { +// CHECK: spirv.BranchConditional %{{.+}}, ^[[THEN0:.+]], ^[[ELSE0:.+]] + spirv.BranchConditional %true, ^then0, ^else0 // CHECK-NEXT: ^[[THEN0]]: -// CHECK: spv.Store "Function" %[[VAR]] -// CHECK-NEXT: spv.Branch ^[[MERGE:.+]] +// CHECK: spirv.Store "Function" %[[VAR]] +// CHECK-NEXT: spirv.Branch ^[[MERGE:.+]] ^then0: - spv.Store "Function" %var, %true : i1 - spv.Branch ^merge + spirv.Store "Function" %var, %true : i1 + spirv.Branch ^merge // CHECK-NEXT: ^[[ELSE0]]: -// CHECK: spv.Store "Function" %[[VAR]] -// CHECK-NEXT: spv.Branch ^[[MERGE]] +// CHECK: spirv.Store "Function" %[[VAR]] +// CHECK-NEXT: spirv.Branch ^[[MERGE]] ^else0: - spv.Store "Function" %var, %false : i1 - spv.Branch ^merge + spirv.Store "Function" %var, %false : i1 + spirv.Branch ^merge // CHECK-NEXT: ^[[MERGE]]: -// CHECK-NEXT: spv.mlir.merge +// CHECK-NEXT: spirv.mlir.merge ^merge: - spv.mlir.merge + spirv.mlir.merge // CHECK-NEXT: } } -// CHECK-NEXT: spv.Load "Function" %[[VAR]] - %cond = spv.Load "Function" %var : i1 -// CHECK: spv.BranchConditional %1, ^[[THEN1:.+]](%{{.+}} : i32), ^[[ELSE1:.+]](%{{.+}}, %{{.+}} : i32, i32) - spv.BranchConditional %cond, ^then1(%one: i32), ^else1(%zero, %zero: i32, i32) +// CHECK-NEXT: spirv.Load "Function" %[[VAR]] + %cond = spirv.Load "Function" %var : i1 +// CHECK: spirv.BranchConditional %1, ^[[THEN1:.+]](%{{.+}} : i32), ^[[ELSE1:.+]](%{{.+}}, %{{.+}} : i32, i32) + spirv.BranchConditional %cond, ^then1(%one: i32), ^else1(%zero, %zero: i32, i32) // CHECK-NEXT: ^[[THEN1]](%{{.+}}: i32): -// CHECK-NEXT: spv.Return +// CHECK-NEXT: spirv.Return ^then1(%arg0: i32): - spv.Return + spirv.Return // CHECK-NEXT: ^[[ELSE1]](%{{.+}}: i32, %{{.+}}: i32): -// CHECK-NEXT: spv.Return +// CHECK-NEXT: spirv.Return ^else1(%arg1: i32, %arg2: i32): - spv.Return + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/spec-constant.mlir b/mlir/test/Target/SPIRV/spec-constant.mlir --- a/mlir/test/Target/SPIRV/spec-constant.mlir +++ b/mlir/test/Target/SPIRV/spec-constant.mlir @@ -1,118 +1,118 @@ // RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - // CHECK: spv.SpecConstant @sc_true = true - spv.SpecConstant @sc_true = true - // CHECK: spv.SpecConstant @sc_false spec_id(1) = false - spv.SpecConstant @sc_false spec_id(1) = false +spirv.module Logical GLSL450 requires #spirv.vce { + // CHECK: spirv.SpecConstant @sc_true = true + spirv.SpecConstant @sc_true = true + // CHECK: spirv.SpecConstant @sc_false spec_id(1) = false + spirv.SpecConstant @sc_false spec_id(1) = false - // CHECK: spv.SpecConstant @sc_int = -5 : i32 - spv.SpecConstant @sc_int = -5 : i32 + // CHECK: spirv.SpecConstant @sc_int = -5 : i32 + spirv.SpecConstant @sc_int = -5 : i32 - // CHECK: spv.SpecConstant @sc_float spec_id(5) = 1.000000e+00 : f32 - spv.SpecConstant @sc_float spec_id(5) = 1. : f32 + // CHECK: spirv.SpecConstant @sc_float spec_id(5) = 1.000000e+00 : f32 + spirv.SpecConstant @sc_float spec_id(5) = 1. : f32 - // CHECK: spv.SpecConstantComposite @scc (@sc_int, @sc_int) : !spv.array<2 x i32> - spv.SpecConstantComposite @scc (@sc_int, @sc_int) : !spv.array<2 x i32> + // CHECK: spirv.SpecConstantComposite @scc (@sc_int, @sc_int) : !spirv.array<2 x i32> + spirv.SpecConstantComposite @scc (@sc_int, @sc_int) : !spirv.array<2 x i32> // CHECK-LABEL: @use - spv.func @use() -> (i32) "None" { - // We materialize a `spv.mlir.referenceof` op at every use of a + spirv.func @use() -> (i32) "None" { + // We materialize a `spirv.mlir.referenceof` op at every use of a // specialization constant in the deserializer. So two ops here. - // CHECK: %[[USE1:.*]] = spv.mlir.referenceof @sc_int : i32 - // CHECK: %[[USE2:.*]] = spv.mlir.referenceof @sc_int : i32 - // CHECK: spv.IAdd %[[USE1]], %[[USE2]] + // CHECK: %[[USE1:.*]] = spirv.mlir.referenceof @sc_int : i32 + // CHECK: %[[USE2:.*]] = spirv.mlir.referenceof @sc_int : i32 + // CHECK: spirv.IAdd %[[USE1]], %[[USE2]] - %0 = spv.mlir.referenceof @sc_int : i32 - %1 = spv.IAdd %0, %0 : i32 - spv.ReturnValue %1 : i32 + %0 = spirv.mlir.referenceof @sc_int : i32 + %1 = spirv.IAdd %0, %0 : i32 + spirv.ReturnValue %1 : i32 } // CHECK-LABEL: @use - spv.func @use_composite() -> (i32) "None" { - // We materialize a `spv.mlir.referenceof` op at every use of a + spirv.func @use_composite() -> (i32) "None" { + // We materialize a `spirv.mlir.referenceof` op at every use of a // specialization constant in the deserializer. So two ops here. - // CHECK: %[[USE1:.*]] = spv.mlir.referenceof @scc : !spv.array<2 x i32> - // CHECK: %[[ITM0:.*]] = spv.CompositeExtract %[[USE1]][0 : i32] : !spv.array<2 x i32> - // CHECK: %[[USE2:.*]] = spv.mlir.referenceof @scc : !spv.array<2 x i32> - // CHECK: %[[ITM1:.*]] = spv.CompositeExtract %[[USE2]][1 : i32] : !spv.array<2 x i32> - // CHECK: spv.IAdd %[[ITM0]], %[[ITM1]] - - %0 = spv.mlir.referenceof @scc : !spv.array<2 x i32> - %1 = spv.CompositeExtract %0[0 : i32] : !spv.array<2 x i32> - %2 = spv.CompositeExtract %0[1 : i32] : !spv.array<2 x i32> - %3 = spv.IAdd %1, %2 : i32 - spv.ReturnValue %3 : i32 + // CHECK: %[[USE1:.*]] = spirv.mlir.referenceof @scc : !spirv.array<2 x i32> + // CHECK: %[[ITM0:.*]] = spirv.CompositeExtract %[[USE1]][0 : i32] : !spirv.array<2 x i32> + // CHECK: %[[USE2:.*]] = spirv.mlir.referenceof @scc : !spirv.array<2 x i32> + // CHECK: %[[ITM1:.*]] = spirv.CompositeExtract %[[USE2]][1 : i32] : !spirv.array<2 x i32> + // CHECK: spirv.IAdd %[[ITM0]], %[[ITM1]] + + %0 = spirv.mlir.referenceof @scc : !spirv.array<2 x i32> + %1 = spirv.CompositeExtract %0[0 : i32] : !spirv.array<2 x i32> + %2 = spirv.CompositeExtract %0[1 : i32] : !spirv.array<2 x i32> + %3 = spirv.IAdd %1, %2 : i32 + spirv.ReturnValue %3 : i32 } } // ----- -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { - spv.SpecConstant @sc_f32_1 = 1.5 : f32 - spv.SpecConstant @sc_f32_2 = 2.5 : f32 - spv.SpecConstant @sc_f32_3 = 3.5 : f32 + spirv.SpecConstant @sc_f32_1 = 1.5 : f32 + spirv.SpecConstant @sc_f32_2 = 2.5 : f32 + spirv.SpecConstant @sc_f32_3 = 3.5 : f32 - spv.SpecConstant @sc_i32_1 = 1 : i32 + spirv.SpecConstant @sc_i32_1 = 1 : i32 - // CHECK: spv.SpecConstantComposite @scc_array (@sc_f32_1, @sc_f32_2, @sc_f32_3) : !spv.array<3 x f32> - spv.SpecConstantComposite @scc_array (@sc_f32_1, @sc_f32_2, @sc_f32_3) : !spv.array<3 x f32> + // CHECK: spirv.SpecConstantComposite @scc_array (@sc_f32_1, @sc_f32_2, @sc_f32_3) : !spirv.array<3 x f32> + spirv.SpecConstantComposite @scc_array (@sc_f32_1, @sc_f32_2, @sc_f32_3) : !spirv.array<3 x f32> - // CHECK: spv.SpecConstantComposite @scc_struct (@sc_i32_1, @sc_f32_2, @sc_f32_3) : !spv.struct<(i32, f32, f32)> - spv.SpecConstantComposite @scc_struct (@sc_i32_1, @sc_f32_2, @sc_f32_3) : !spv.struct<(i32, f32, f32)> + // CHECK: spirv.SpecConstantComposite @scc_struct (@sc_i32_1, @sc_f32_2, @sc_f32_3) : !spirv.struct<(i32, f32, f32)> + spirv.SpecConstantComposite @scc_struct (@sc_i32_1, @sc_f32_2, @sc_f32_3) : !spirv.struct<(i32, f32, f32)> - // CHECK: spv.SpecConstantComposite @scc_vector (@sc_f32_1, @sc_f32_2, @sc_f32_3) : vector<3xf32> - spv.SpecConstantComposite @scc_vector (@sc_f32_1, @sc_f32_2, @sc_f32_3) : vector<3 x f32> + // CHECK: spirv.SpecConstantComposite @scc_vector (@sc_f32_1, @sc_f32_2, @sc_f32_3) : vector<3xf32> + spirv.SpecConstantComposite @scc_vector (@sc_f32_1, @sc_f32_2, @sc_f32_3) : vector<3 x f32> } // ----- -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { - spv.SpecConstant @sc_f32_1 = 1.5 : f32 - spv.SpecConstant @sc_f32_2 = 2.5 : f32 - spv.SpecConstant @sc_f32_3 = 3.5 : f32 + spirv.SpecConstant @sc_f32_1 = 1.5 : f32 + spirv.SpecConstant @sc_f32_2 = 2.5 : f32 + spirv.SpecConstant @sc_f32_3 = 3.5 : f32 - spv.SpecConstant @sc_i32_1 = 1 : i32 + spirv.SpecConstant @sc_i32_1 = 1 : i32 - // CHECK: spv.SpecConstantComposite @scc_array (@sc_f32_1, @sc_f32_2, @sc_f32_3) : !spv.array<3 x f32> - spv.SpecConstantComposite @scc_array (@sc_f32_1, @sc_f32_2, @sc_f32_3) : !spv.array<3 x f32> + // CHECK: spirv.SpecConstantComposite @scc_array (@sc_f32_1, @sc_f32_2, @sc_f32_3) : !spirv.array<3 x f32> + spirv.SpecConstantComposite @scc_array (@sc_f32_1, @sc_f32_2, @sc_f32_3) : !spirv.array<3 x f32> - // CHECK: spv.SpecConstantComposite @scc_struct (@sc_i32_1, @sc_f32_2, @sc_f32_3) : !spv.struct<(i32, f32, f32)> - spv.SpecConstantComposite @scc_struct (@sc_i32_1, @sc_f32_2, @sc_f32_3) : !spv.struct<(i32, f32, f32)> + // CHECK: spirv.SpecConstantComposite @scc_struct (@sc_i32_1, @sc_f32_2, @sc_f32_3) : !spirv.struct<(i32, f32, f32)> + spirv.SpecConstantComposite @scc_struct (@sc_i32_1, @sc_f32_2, @sc_f32_3) : !spirv.struct<(i32, f32, f32)> - // CHECK: spv.SpecConstantComposite @scc_vector (@sc_f32_1, @sc_f32_2, @sc_f32_3) : vector<3xf32> - spv.SpecConstantComposite @scc_vector (@sc_f32_1, @sc_f32_2, @sc_f32_3) : vector<3 x f32> + // CHECK: spirv.SpecConstantComposite @scc_vector (@sc_f32_1, @sc_f32_2, @sc_f32_3) : vector<3xf32> + spirv.SpecConstantComposite @scc_vector (@sc_f32_1, @sc_f32_2, @sc_f32_3) : vector<3 x f32> } // ----- -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { - spv.SpecConstant @sc_i32_1 = 1 : i32 + spirv.SpecConstant @sc_i32_1 = 1 : i32 - spv.func @use_composite() -> (i32) "None" { - // CHECK: [[USE1:%.*]] = spv.mlir.referenceof @sc_i32_1 : i32 - // CHECK: [[USE2:%.*]] = spv.Constant 0 : i32 + spirv.func @use_composite() -> (i32) "None" { + // CHECK: [[USE1:%.*]] = spirv.mlir.referenceof @sc_i32_1 : i32 + // CHECK: [[USE2:%.*]] = spirv.Constant 0 : i32 - // CHECK: [[RES1:%.*]] = spv.SpecConstantOperation wraps "spv.ISub"([[USE1]], [[USE2]]) : (i32, i32) -> i32 + // CHECK: [[RES1:%.*]] = spirv.SpecConstantOperation wraps "spirv.ISub"([[USE1]], [[USE2]]) : (i32, i32) -> i32 - // CHECK: [[USE3:%.*]] = spv.mlir.referenceof @sc_i32_1 : i32 - // CHECK: [[USE4:%.*]] = spv.Constant 0 : i32 + // CHECK: [[USE3:%.*]] = spirv.mlir.referenceof @sc_i32_1 : i32 + // CHECK: [[USE4:%.*]] = spirv.Constant 0 : i32 - // CHECK: [[RES2:%.*]] = spv.SpecConstantOperation wraps "spv.ISub"([[USE3]], [[USE4]]) : (i32, i32) -> i32 + // CHECK: [[RES2:%.*]] = spirv.SpecConstantOperation wraps "spirv.ISub"([[USE3]], [[USE4]]) : (i32, i32) -> i32 - %0 = spv.mlir.referenceof @sc_i32_1 : i32 - %1 = spv.Constant 0 : i32 - %2 = spv.SpecConstantOperation wraps "spv.ISub"(%0, %1) : (i32, i32) -> i32 + %0 = spirv.mlir.referenceof @sc_i32_1 : i32 + %1 = spirv.Constant 0 : i32 + %2 = spirv.SpecConstantOperation wraps "spirv.ISub"(%0, %1) : (i32, i32) -> i32 - // CHECK: [[RES3:%.*]] = spv.SpecConstantOperation wraps "spv.IMul"([[RES1]], [[RES2]]) : (i32, i32) -> i32 - %3 = spv.SpecConstantOperation wraps "spv.IMul"(%2, %2) : (i32, i32) -> i32 + // CHECK: [[RES3:%.*]] = spirv.SpecConstantOperation wraps "spirv.IMul"([[RES1]], [[RES2]]) : (i32, i32) -> i32 + %3 = spirv.SpecConstantOperation wraps "spirv.IMul"(%2, %2) : (i32, i32) -> i32 // Make sure deserialization continues from the right place after creating // the previous op. - // CHECK: spv.ReturnValue [[RES3]] - spv.ReturnValue %3 : i32 + // CHECK: spirv.ReturnValue [[RES3]] + spirv.ReturnValue %3 : i32 } } diff --git a/mlir/test/Target/SPIRV/struct.mlir b/mlir/test/Target/SPIRV/struct.mlir --- a/mlir/test/Target/SPIRV/struct.mlir +++ b/mlir/test/Target/SPIRV/struct.mlir @@ -1,52 +1,52 @@ // RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - // CHECK: !spv.ptr [0])>, Input> - spv.GlobalVariable @var0 bind(0, 1) : !spv.ptr [0])>, Input> +spirv.module Logical GLSL450 requires #spirv.vce { + // CHECK: !spirv.ptr [0])>, Input> + spirv.GlobalVariable @var0 bind(0, 1) : !spirv.ptr [0])>, Input> - // CHECK: !spv.ptr [4])> [4])>, Input> - spv.GlobalVariable @var1 bind(0, 2) : !spv.ptr [4])> [4])>, Input> + // CHECK: !spirv.ptr [4])> [4])>, Input> + spirv.GlobalVariable @var1 bind(0, 2) : !spirv.ptr [4])> [4])>, Input> - // CHECK: !spv.ptr, StorageBuffer> - spv.GlobalVariable @var2 : !spv.ptr, StorageBuffer> + // CHECK: !spirv.ptr, StorageBuffer> + spirv.GlobalVariable @var2 : !spirv.ptr, StorageBuffer> - // CHECK: !spv.ptr [0])>, stride=512> [0])>, StorageBuffer> - spv.GlobalVariable @var3 : !spv.ptr [0])>, stride=512> [0])>, StorageBuffer> + // CHECK: !spirv.ptr [0])>, stride=512> [0])>, StorageBuffer> + spirv.GlobalVariable @var3 : !spirv.ptr [0])>, stride=512> [0])>, StorageBuffer> - // CHECK: !spv.ptr, StorageBuffer> - spv.GlobalVariable @var4 : !spv.ptr, StorageBuffer> + // CHECK: !spirv.ptr, StorageBuffer> + spirv.GlobalVariable @var4 : !spirv.ptr, StorageBuffer> - // CHECK: !spv.ptr, StorageBuffer> - spv.GlobalVariable @var5 : !spv.ptr, StorageBuffer> + // CHECK: !spirv.ptr, StorageBuffer> + spirv.GlobalVariable @var5 : !spirv.ptr, StorageBuffer> - // CHECK: !spv.ptr, StorageBuffer> - spv.GlobalVariable @var6 : !spv.ptr, StorageBuffer> + // CHECK: !spirv.ptr, StorageBuffer> + spirv.GlobalVariable @var6 : !spirv.ptr, StorageBuffer> - // CHECK: !spv.ptr> [0, ColMajor, MatrixStride=16])>, StorageBuffer> - spv.GlobalVariable @var7 : !spv.ptr> [0, ColMajor, MatrixStride=16])>, StorageBuffer> + // CHECK: !spirv.ptr> [0, ColMajor, MatrixStride=16])>, StorageBuffer> + spirv.GlobalVariable @var7 : !spirv.ptr> [0, ColMajor, MatrixStride=16])>, StorageBuffer> - // CHECK: !spv.ptr, StorageBuffer> - spv.GlobalVariable @empty : !spv.ptr, StorageBuffer> + // CHECK: !spirv.ptr, StorageBuffer> + spirv.GlobalVariable @empty : !spirv.ptr, StorageBuffer> - // CHECK: !spv.ptr, StorageBuffer> - spv.GlobalVariable @id_empty : !spv.ptr, StorageBuffer> + // CHECK: !spirv.ptr, StorageBuffer> + spirv.GlobalVariable @id_empty : !spirv.ptr, StorageBuffer> - // CHECK: !spv.ptr [0])>, Input> - spv.GlobalVariable @id_var0 : !spv.ptr [0])>, Input> + // CHECK: !spirv.ptr [0])>, Input> + spirv.GlobalVariable @id_var0 : !spirv.ptr [0])>, Input> - // CHECK: !spv.ptr, StorageBuffer>)>, StorageBuffer> - spv.GlobalVariable @recursive_simple : !spv.ptr, StorageBuffer>)>, StorageBuffer> + // CHECK: !spirv.ptr, StorageBuffer>)>, StorageBuffer> + spirv.GlobalVariable @recursive_simple : !spirv.ptr, StorageBuffer>)>, StorageBuffer> - // CHECK: !spv.ptr, Uniform>)>, Uniform>)>, Uniform> - spv.GlobalVariable @recursive_2 : !spv.ptr, Uniform>)>, Uniform>)>, Uniform> + // CHECK: !spirv.ptr, Uniform>)>, Uniform>)>, Uniform> + spirv.GlobalVariable @recursive_2 : !spirv.ptr, Uniform>)>, Uniform>)>, Uniform> - // CHECK: !spv.ptr, Uniform>, !spv.ptr, Uniform>)>, Uniform>)>, Uniform> - spv.GlobalVariable @recursive_3 : !spv.ptr, Uniform>, !spv.ptr, Uniform>)>, Uniform>)>, Uniform> + // CHECK: !spirv.ptr, Uniform>, !spirv.ptr, Uniform>)>, Uniform>)>, Uniform> + spirv.GlobalVariable @recursive_3 : !spirv.ptr, Uniform>, !spirv.ptr, Uniform>)>, Uniform>)>, Uniform> - // CHECK: !spv.ptr [0])>, Input>, - // CHECK-SAME: !spv.ptr [0])>, Output> - spv.func @kernel(%arg0: !spv.ptr [0])>, Input>, %arg1: !spv.ptr [0])>, Output>) -> () "None" { - spv.Return + // CHECK: !spirv.ptr [0])>, Input>, + // CHECK-SAME: !spirv.ptr [0])>, Output> + spirv.func @kernel(%arg0: !spirv.ptr [0])>, Input>, %arg1: !spirv.ptr [0])>, Output>) -> () "None" { + spirv.Return } } diff --git a/mlir/test/Target/SPIRV/terminator.mlir b/mlir/test/Target/SPIRV/terminator.mlir --- a/mlir/test/Target/SPIRV/terminator.mlir +++ b/mlir/test/Target/SPIRV/terminator.mlir @@ -1,27 +1,27 @@ // RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { // CHECK-LABEL: @ret - spv.func @ret() -> () "None" { - // CHECK: spv.Return - spv.Return + spirv.func @ret() -> () "None" { + // CHECK: spirv.Return + spirv.Return } // CHECK-LABEL: @ret_val - spv.func @ret_val() -> (i32) "None" { - %0 = spv.Variable : !spv.ptr - %1 = spv.Load "Function" %0 : i32 - // CHECK: spv.ReturnValue {{.*}} : i32 - spv.ReturnValue %1 : i32 + spirv.func @ret_val() -> (i32) "None" { + %0 = spirv.Variable : !spirv.ptr + %1 = spirv.Load "Function" %0 : i32 + // CHECK: spirv.ReturnValue {{.*}} : i32 + spirv.ReturnValue %1 : i32 } // CHECK-LABEL: @unreachable - spv.func @unreachable() "None" { - spv.Return + spirv.func @unreachable() "None" { + spirv.Return // CHECK-NOT: ^bb ^bb1: // Unreachable blocks will be dropped during serialization. - // CHECK-NOT: spv.Unreachable - spv.Unreachable + // CHECK-NOT: spirv.Unreachable + spirv.Unreachable } } diff --git a/mlir/test/Target/SPIRV/undef.mlir b/mlir/test/Target/SPIRV/undef.mlir --- a/mlir/test/Target/SPIRV/undef.mlir +++ b/mlir/test/Target/SPIRV/undef.mlir @@ -1,33 +1,33 @@ // RUN: mlir-translate -split-input-file -test-spirv-roundtrip %s | FileCheck %s -spv.module Logical GLSL450 requires #spv.vce { - spv.func @foo() -> () "None" { - // CHECK: {{%.*}} = spv.Undef : f32 - // CHECK-NEXT: {{%.*}} = spv.Undef : f32 - %0 = spv.Undef : f32 - %1 = spv.Undef : f32 - %2 = spv.FAdd %0, %1 : f32 - // CHECK: {{%.*}} = spv.Undef : vector<4xi32> - %3 = spv.Undef : vector<4xi32> - %4 = spv.CompositeExtract %3[1 : i32] : vector<4xi32> - // CHECK: {{%.*}} = spv.Undef : !spv.array<4 x !spv.array<4 x i32>> - %5 = spv.Undef : !spv.array<4x!spv.array<4xi32>> - %6 = spv.CompositeExtract %5[1 : i32, 2 : i32] : !spv.array<4x!spv.array<4xi32>> - // CHECK: {{%.*}} = spv.Undef : !spv.ptr, StorageBuffer> - %7 = spv.Undef : !spv.ptr, StorageBuffer> - %8 = spv.Constant 0 : i32 - %9 = spv.AccessChain %7[%8] : !spv.ptr, StorageBuffer>, i32 - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + spirv.func @foo() -> () "None" { + // CHECK: {{%.*}} = spirv.Undef : f32 + // CHECK-NEXT: {{%.*}} = spirv.Undef : f32 + %0 = spirv.Undef : f32 + %1 = spirv.Undef : f32 + %2 = spirv.FAdd %0, %1 : f32 + // CHECK: {{%.*}} = spirv.Undef : vector<4xi32> + %3 = spirv.Undef : vector<4xi32> + %4 = spirv.CompositeExtract %3[1 : i32] : vector<4xi32> + // CHECK: {{%.*}} = spirv.Undef : !spirv.array<4 x !spirv.array<4 x i32>> + %5 = spirv.Undef : !spirv.array<4x!spirv.array<4xi32>> + %6 = spirv.CompositeExtract %5[1 : i32, 2 : i32] : !spirv.array<4x!spirv.array<4xi32>> + // CHECK: {{%.*}} = spirv.Undef : !spirv.ptr, StorageBuffer> + %7 = spirv.Undef : !spirv.ptr, StorageBuffer> + %8 = spirv.Constant 0 : i32 + %9 = spirv.AccessChain %7[%8] : !spirv.ptr, StorageBuffer>, i32 + spirv.Return } } // ----- -spv.module Logical GLSL450 requires #spv.vce { - // CHECK: spv.func {{@.*}} - spv.func @ignore_unused_undef() -> () "None" { - // CHECK-NEXT: spv.Return - %0 = spv.Undef : f32 - spv.Return +spirv.module Logical GLSL450 requires #spirv.vce { + // CHECK: spirv.func {{@.*}} + spirv.func @ignore_unused_undef() -> () "None" { + // CHECK-NEXT: spirv.Return + %0 = spirv.Undef : f32 + spirv.Return } } diff --git a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp --- a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp +++ b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp @@ -37,10 +37,10 @@ auto f = getOperation(); llvm::outs() << f.getName() << "\n"; - Dialect *spvDialect = getContext().getLoadedDialect("spv"); + Dialect *spirvDialect = getContext().getLoadedDialect("spirv"); f->walk([&](Operation *op) { - if (op->getDialect() != spvDialect) + if (op->getDialect() != spirvDialect) return WalkResult::advance(); auto opName = op->getName(); @@ -155,7 +155,7 @@ ->getAttr(spirv::getTargetEnvAttrName()) .cast(); if (!targetEnv) { - fn.emitError("missing 'spv.target_env' attribute"); + fn.emitError("missing 'spirv.target_env' attribute"); return signalPassFailure(); } @@ -172,7 +172,7 @@ ConvertToAtomCmpExchangeWeak::ConvertToAtomCmpExchangeWeak(MLIRContext *context) : RewritePattern("test.convert_to_atomic_compare_exchange_weak_op", 1, - context, {"spv.AtomicCompareExchangeWeak"}) {} + context, {"spirv.AtomicCompareExchangeWeak"}) {} LogicalResult ConvertToAtomCmpExchangeWeak::matchAndRewrite(Operation *op, @@ -181,8 +181,8 @@ Value value = op->getOperand(1); Value comparator = op->getOperand(2); - // Create a spv.AtomicCompareExchangeWeak op with AtomicCounterMemory bits in - // memory semantics to additionally require AtomicStorage capability. + // Create a spirv.AtomicCompareExchangeWeak op with AtomicCounterMemory bits + // in memory semantics to additionally require AtomicStorage capability. rewriter.replaceOpWithNewOp( op, value.getType(), ptr, spirv::Scope::Workgroup, spirv::MemorySemantics::AcquireRelease | @@ -193,7 +193,7 @@ ConvertToBitReverse::ConvertToBitReverse(MLIRContext *context) : RewritePattern("test.convert_to_bit_reverse_op", 1, context, - {"spv.BitReverse"}) {} + {"spirv.BitReverse"}) {} LogicalResult ConvertToBitReverse::matchAndRewrite(Operation *op, @@ -208,7 +208,7 @@ ConvertToGroupNonUniformBallot::ConvertToGroupNonUniformBallot( MLIRContext *context) : RewritePattern("test.convert_to_group_non_uniform_ballot_op", 1, context, - {"spv.GroupNonUniformBallot"}) {} + {"spirv.GroupNonUniformBallot"}) {} LogicalResult ConvertToGroupNonUniformBallot::matchAndRewrite( Operation *op, PatternRewriter &rewriter) const { @@ -220,7 +220,8 @@ } ConvertToModule::ConvertToModule(MLIRContext *context) - : RewritePattern("test.convert_to_module_op", 1, context, {"spv.module"}) {} + : RewritePattern("test.convert_to_module_op", 1, context, + {"spirv.module"}) {} LogicalResult ConvertToModule::matchAndRewrite(Operation *op, @@ -233,7 +234,7 @@ ConvertToSubgroupBallot::ConvertToSubgroupBallot(MLIRContext *context) : RewritePattern("test.convert_to_subgroup_ballot_op", 1, context, - {"spv.KHR.SubgroupBallot"}) {} + {"spirv.KHR.SubgroupBallot"}) {} LogicalResult ConvertToSubgroupBallot::matchAndRewrite(Operation *op, diff --git a/mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp b/mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp --- a/mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp +++ b/mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// // -// This file implements a pass that sets the spv.entry_point_abi attribute on +// This file implements a pass that sets the spirv.entry_point_abi attribute on // functions that are to be lowered as entry point functions. // //===----------------------------------------------------------------------===// @@ -19,7 +19,7 @@ using namespace mlir; namespace { -/// Pass to set the spv.entry_point_abi +/// Pass to set the spirv.entry_point_abi struct TestSpirvEntryPointABIPass : public PassWrapper> { @@ -27,7 +27,7 @@ StringRef getArgument() const final { return "test-spirv-entry-point-abi"; } StringRef getDescription() const final { - return "Set the spv.entry_point_abi attribute on GPU kernel function " + return "Set the spirv.entry_point_abi attribute on GPU kernel function " "within the " "module, intended for testing only"; } diff --git a/mlir/test/mlir-opt/commandline.mlir b/mlir/test/mlir-opt/commandline.mlir --- a/mlir/test/mlir-opt/commandline.mlir +++ b/mlir/test/mlir-opt/commandline.mlir @@ -31,7 +31,7 @@ // CHECK-NEXT: scf // CHECK-NEXT: shape // CHECK-NEXT: sparse_tensor -// CHECK-NEXT: spv +// CHECK-NEXT: spirv // CHECK-NEXT: tensor // CHECK-NEXT: test // CHECK-NEXT: test_dyn diff --git a/mlir/test/mlir-spirv-cpu-runner/double.mlir b/mlir/test/mlir-spirv-cpu-runner/double.mlir --- a/mlir/test/mlir-spirv-cpu-runner/double.mlir +++ b/mlir/test/mlir-spirv-cpu-runner/double.mlir @@ -3,15 +3,15 @@ // CHECK: [8, 8, 8, 8, 8, 8] module attributes { gpu.container_module, - spv.target_env = #spv.target_env< - #spv.vce, - #spv.resource_limits< + spirv.target_env = #spirv.target_env< + #spirv.vce, + #spirv.resource_limits< max_compute_workgroup_invocations = 128, max_compute_workgroup_size = [128, 128, 64]>> } { gpu.module @kernels { gpu.func @double(%arg0 : memref<6xi32>, %arg1 : memref<6xi32>) - kernel attributes { spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { + kernel attributes { spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { %factor = arith.constant 2 : i32 %i0 = arith.constant 0 : index diff --git a/mlir/test/mlir-spirv-cpu-runner/simple_add.mlir b/mlir/test/mlir-spirv-cpu-runner/simple_add.mlir --- a/mlir/test/mlir-spirv-cpu-runner/simple_add.mlir +++ b/mlir/test/mlir-spirv-cpu-runner/simple_add.mlir @@ -3,15 +3,15 @@ // CHECK: [[[7.7, 0, 0], [7.7, 0, 0], [7.7, 0, 0]], [[0, 7.7, 0], [0, 7.7, 0], [0, 7.7, 0]], [[0, 0, 7.7], [0, 0, 7.7], [0, 0, 7.7]]] module attributes { gpu.container_module, - spv.target_env = #spv.target_env< - #spv.vce, - #spv.resource_limits< + spirv.target_env = #spirv.target_env< + #spirv.vce, + #spirv.resource_limits< max_compute_workgroup_invocations = 128, max_compute_workgroup_size = [128, 128, 64]>> } { gpu.module @kernels { gpu.func @sum(%arg0 : memref<3xf32>, %arg1 : memref<3x3xf32>, %arg2 : memref<3x3x3xf32>) - kernel attributes { spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { + kernel attributes { spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { %i0 = arith.constant 0 : index %i1 = arith.constant 1 : index %i2 = arith.constant 2 : index diff --git a/mlir/test/mlir-vulkan-runner/addf.mlir b/mlir/test/mlir-vulkan-runner/addf.mlir --- a/mlir/test/mlir-vulkan-runner/addf.mlir +++ b/mlir/test/mlir-vulkan-runner/addf.mlir @@ -3,12 +3,12 @@ // CHECK: [3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3] module attributes { gpu.container_module, - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { gpu.module @kernels { gpu.func @kernel_add(%arg0 : memref<8xf32>, %arg1 : memref<8xf32>, %arg2 : memref<8xf32>) - kernel attributes { spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { + kernel attributes { spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { %0 = gpu.block_id x %1 = memref.load %arg0[%0] : memref<8xf32> %2 = memref.load %arg1[%0] : memref<8xf32> diff --git a/mlir/test/mlir-vulkan-runner/addi.mlir b/mlir/test/mlir-vulkan-runner/addi.mlir --- a/mlir/test/mlir-vulkan-runner/addi.mlir +++ b/mlir/test/mlir-vulkan-runner/addi.mlir @@ -3,12 +3,12 @@ // CHECK-COUNT-64: [3, 3, 3, 3, 3, 3, 3, 3] module attributes { gpu.container_module, - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { gpu.module @kernels { gpu.func @kernel_addi(%arg0 : memref<8xi32>, %arg1 : memref<8x8xi32>, %arg2 : memref<8x8x8xi32>) - kernel attributes { spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { + kernel attributes { spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { %x = gpu.block_id x %y = gpu.block_id y %z = gpu.block_id z diff --git a/mlir/test/mlir-vulkan-runner/addi8.mlir b/mlir/test/mlir-vulkan-runner/addi8.mlir --- a/mlir/test/mlir-vulkan-runner/addi8.mlir +++ b/mlir/test/mlir-vulkan-runner/addi8.mlir @@ -3,12 +3,12 @@ // CHECK-COUNT-64: [3, 3, 3, 3, 3, 3, 3, 3] module attributes { gpu.container_module, - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { gpu.module @kernels { gpu.func @kernel_addi(%arg0 : memref<8xi8>, %arg1 : memref<8x8xi8>, %arg2 : memref<8x8x8xi32>) - kernel attributes { spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { + kernel attributes { spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { %x = gpu.block_id x %y = gpu.block_id y %z = gpu.block_id z diff --git a/mlir/test/mlir-vulkan-runner/mulf.mlir b/mlir/test/mlir-vulkan-runner/mulf.mlir --- a/mlir/test/mlir-vulkan-runner/mulf.mlir +++ b/mlir/test/mlir-vulkan-runner/mulf.mlir @@ -3,12 +3,12 @@ // CHECK-COUNT-4: [6, 6, 6, 6] module attributes { gpu.container_module, - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { gpu.module @kernels { gpu.func @kernel_mul(%arg0 : memref<4x4xf32>, %arg1 : memref<4x4xf32>, %arg2 : memref<4x4xf32>) - kernel attributes { spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { + kernel attributes { spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { %x = gpu.block_id x %y = gpu.block_id y %1 = memref.load %arg0[%x, %y] : memref<4x4xf32> diff --git a/mlir/test/mlir-vulkan-runner/subf.mlir b/mlir/test/mlir-vulkan-runner/subf.mlir --- a/mlir/test/mlir-vulkan-runner/subf.mlir +++ b/mlir/test/mlir-vulkan-runner/subf.mlir @@ -3,13 +3,13 @@ // CHECK-COUNT-32: [2.2, 2.2, 2.2, 2.2] module attributes { gpu.container_module, - spv.target_env = #spv.target_env< - #spv.vce, - #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, + #spirv.resource_limits<>> } { gpu.module @kernels { gpu.func @kernel_sub(%arg0 : memref<8x4x4xf32>, %arg1 : memref<4x4xf32>, %arg2 : memref<8x4x4xf32>) - kernel attributes { spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { + kernel attributes { spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { %x = gpu.block_id x %y = gpu.block_id y %z = gpu.block_id z diff --git a/mlir/test/mlir-vulkan-runner/time.mlir b/mlir/test/mlir-vulkan-runner/time.mlir --- a/mlir/test/mlir-vulkan-runner/time.mlir +++ b/mlir/test/mlir-vulkan-runner/time.mlir @@ -6,12 +6,12 @@ module attributes { gpu.container_module, - spv.target_env = #spv.target_env< - #spv.vce, #spv.resource_limits<>> + spirv.target_env = #spirv.target_env< + #spirv.vce, #spirv.resource_limits<>> } { gpu.module @kernels { gpu.func @kernel_add(%arg0 : memref<16384xf32>, %arg1 : memref<16384xf32>, %arg2 : memref<16384xf32>) - kernel attributes { spv.entry_point_abi = #spv.entry_point_abi: vector<3xi32>>} { + kernel attributes { spirv.entry_point_abi = #spirv.entry_point_abi: vector<3xi32>>} { %bid = gpu.block_id x %tid = gpu.thread_id x %cst = arith.constant 128 : index diff --git a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp --- a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp +++ b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp @@ -43,7 +43,7 @@ }); } - /// Performs deserialization and returns the constructed spv.module op. + /// Performs deserialization and returns the constructed spirv.module op. OwningOpRef deserialize() { return spirv::deserialize(binary, &context); }