Skip to content

Commit e22575b

Browse files
committed
[mlir][spirv] Update assembly format for Image operand types
In the example below it is not clear that `(f32)` relates to `%arg2` and not to `vector<2xf32>`: ```mlir %0 = spirv.ImageSampleImplicitLod %arg0, %arg1 ["Lod"](%arg2) : !spirv.sampled_image<...>, vector<2xf32>(f32) -> vector<4xf32> ``` This change applies new format to image operations and image operands that does not use parenthesis and is less ambiguous: ```mlir %0 = spirv.ImageSampleImplicitLod %arg0, %arg1 ["Lod"] %arg2 : !spirv.sampled_image<...>, vector<2xf32>, f32 -> vector<4xf32> ```
1 parent 8bea511 commit e22575b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

mlir/include/mlir/Dialect/SPIRV/IR/SPIRVImageOps.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ def SPIRV_ImageDrefGatherOp : SPIRV_Op<"ImageDrefGather",
114114

115115

116116
let assemblyFormat = [{
117-
$sampled_image `,` $coordinate `,` $dref custom<ImageOperands>($image_operands) ( `(` $operand_arguments^ `)` )? attr-dict
118-
`:` type($sampled_image) `,` type($coordinate) `,` type($dref) ( `(` type($operand_arguments)^ `)` )?
117+
$sampled_image `,` $coordinate `,` $dref custom<ImageOperands>($image_operands) ( `,` $operand_arguments^ )? attr-dict
118+
`:` type($sampled_image) `,` type($coordinate) `,` type($dref) ( `,` type($operand_arguments)^ )?
119119
`->` type($result)
120120
}];
121121

@@ -226,8 +226,8 @@ def SPIRV_ImageWriteOp : SPIRV_Op<"ImageWrite",
226226
let results = (outs);
227227

228228
let assemblyFormat = [{
229-
$image `,` $coordinate `,` $texel custom<ImageOperands>($image_operands) ( `(` $operand_arguments^ `)`)? attr-dict
230-
`:` type($image) `,` type($coordinate) `,` type($texel) ( `(` type($operand_arguments)^ `)`)?
229+
$image `,` $coordinate `,` $texel custom<ImageOperands>($image_operands) ( `,` $operand_arguments^ )? attr-dict
230+
`:` type($image) `,` type($coordinate) `,` type($texel) ( `,` type($operand_arguments)^ )?
231231
}];
232232
}
233233

mlir/test/Dialect/SPIRV/IR/image-ops.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func.func @image_dref_gather_with_single_imageoperands(%arg0 : !spirv.sampled_im
2222

2323
func.func @image_dref_gather_with_mismatch_imageoperands(%arg0 : !spirv.sampled_image<!spirv.image<i32, Dim2D, NoDepth, NonArrayed, SingleSampled, NoSampler, Unknown>>, %arg1 : vector<4xf32>, %arg2 : f32) -> () {
2424
// expected-error @+1 {{the Image Operands should encode what operands follow, as per Image Operands}}
25-
%0 = spirv.ImageDrefGather %arg0, %arg1, %arg2 (%arg2, %arg2) : !spirv.sampled_image<!spirv.image<i32, Dim2D, NoDepth, NonArrayed, SingleSampled, NoSampler, Unknown>>, vector<4xf32>, f32 (f32, f32) -> vector<4xi32>
25+
%0 = spirv.ImageDrefGather %arg0, %arg1, %arg2, %arg2, %arg2 : !spirv.sampled_image<!spirv.image<i32, Dim2D, NoDepth, NonArrayed, SingleSampled, NoSampler, Unknown>>, vector<4xf32>, f32, f32, f32 -> vector<4xi32>
2626
spirv.Return
2727
}
2828

0 commit comments

Comments
 (0)