Skip to content

Commit 56cf3ff

Browse files
authored
[mlir][spirv][doc] Remove duplicate syntax formats (#73386)
Some operations defined their syntax both in the documentation and via `assemblyFormat`. This leads to two syntax descriptions in the documentation for SPIR-V, see for example the documentation for [`spirv.mlir.yield`](https://mlir.llvm.org/docs/Dialects/SPIR-V/#spirvmliryield-spirvyieldop). Since the `assemblyFormat` is used to generate the actual parsers and printer implementations, this PR removes the manual syntax descriptions. (Similar to #73343.) The strategy that I used to find the duplicates was pretty uncomplicated. I scrolled through the [SPIR-V Dialect](https://mlir.llvm.org/docs/Dialects/SPIR-V) to find all duplicates and then remove the duplicate text from the `td` file. Note that the `Syntax:` block in the docs is a good proxy for whether `assemblyFormat` is defined because it will only be generated if the op has defined `assemblyFormat` (`op.hasAssemblyFormat()`): https://github.com/llvm/llvm-project/blob/e970652776bd07dbe42be557bf98722749230653/mlir/tools/mlir-tblgen/OpDocGen.cpp#L108-L124 https://github.com/llvm/llvm-project/blob/e970652776bd07dbe42be557bf98722749230653/mlir/tools/mlir-tblgen/OpDocGen.cpp#L197-L199 Related issue #73359.
1 parent 272085f commit 56cf3ff

18 files changed

+128
-1487
lines changed

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

Lines changed: 30 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,11 @@ def SPIRV_FAddOp : SPIRV_ArithmeticBinaryOp<"FAdd", SPIRV_Float, [Commutative]>
8888
let description = [{
8989
Result Type must be a scalar or vector of floating-point type.
9090

91-
The types of Operand 1 and Operand 2 both must be the same as Result
91+
The types of Operand 1 and Operand 2 both must be the same as Result
9292
Type.
9393

94-
Results are computed per component.
94+
Results are computed per component.
9595

96-
<!-- End of AutoGen section -->
97-
```
98-
float-scalar-vector-type ::= float-type |
99-
`vector<` integer-literal `x` float-type `>`
100-
fadd-op ::= ssa-id `=` `spirv.FAdd` ssa-use, ssa-use
101-
`:` float-scalar-vector-type
102-
```
10396
#### Example:
10497

10598
```mlir
@@ -117,20 +110,12 @@ def SPIRV_FDivOp : SPIRV_ArithmeticBinaryOp<"FDiv", SPIRV_Float, []> {
117110
let description = [{
118111
Result Type must be a scalar or vector of floating-point type.
119112

120-
The types of Operand 1 and Operand 2 both must be the same as Result
113+
The types of Operand 1 and Operand 2 both must be the same as Result
121114
Type.
122115

123-
Results are computed per component. The resulting value is undefined
116+
Results are computed per component. The resulting value is undefined
124117
if Operand 2 is 0.
125118

126-
<!-- End of AutoGen section -->
127-
```
128-
float-scalar-vector-type ::= float-type |
129-
`vector<` integer-literal `x` float-type `>`
130-
fdiv-op ::= ssa-id `=` `spirv.FDiv` ssa-use, ssa-use
131-
`:` float-scalar-vector-type
132-
```
133-
134119
#### Example:
135120

136121
```mlir
@@ -150,21 +135,14 @@ def SPIRV_FModOp : SPIRV_ArithmeticBinaryOp<"FMod", SPIRV_Float, []> {
150135
let description = [{
151136
Result Type must be a scalar or vector of floating-point type.
152137

153-
The types of Operand 1 and Operand 2 both must be the same as Result
138+
The types of Operand 1 and Operand 2 both must be the same as Result
154139
Type.
155140

156-
Results are computed per component. The resulting value is undefined
141+
Results are computed per component. The resulting value is undefined
157142
if Operand 2 is 0. Otherwise, the result is the remainder r of Operand
158143
1 divided by Operand 2 where if r ≠ 0, the sign of r is the same as the
159144
sign of Operand 2.
160145

161-
<!-- End of AutoGen section -->
162-
```
163-
float-scalar-vector-type ::= float-type |
164-
`vector<` integer-literal `x` float-type `>`
165-
fmod-op ::= ssa-id `=` `spirv.FMod` ssa-use, ssa-use
166-
`:` float-scalar-vector-type
167-
```
168146
#### Example:
169147

170148
```mlir
@@ -182,19 +160,10 @@ def SPIRV_FMulOp : SPIRV_ArithmeticBinaryOp<"FMul", SPIRV_Float, [Commutative]>
182160
let description = [{
183161
Result Type must be a scalar or vector of floating-point type.
184162

185-
The types of Operand 1 and Operand 2 both must be the same as Result
163+
The types of Operand 1 and Operand 2 both must be the same as Result
186164
Type.
187165

188-
Results are computed per component.
189-
190-
<!-- End of AutoGen section -->
191-
192-
```
193-
float-scalar-vector-type ::= float-type |
194-
`vector<` integer-literal `x` float-type `>`
195-
fmul-op ::= `spirv.FMul` ssa-use, ssa-use
196-
`:` float-scalar-vector-type
197-
```
166+
Results are computed per component.
198167

199168
#### Example:
200169

@@ -218,17 +187,9 @@ def SPIRV_FNegateOp : SPIRV_ArithmeticUnaryOp<"FNegate", SPIRV_Float, []> {
218187
let description = [{
219188
Result Type must be a scalar or vector of floating-point type.
220189

221-
The type of Operand must be the same as Result Type.
222-
223-
Results are computed per component.
224-
225-
<!-- End of AutoGen section -->
190+
The type of Operand must be the same as Result Type.
226191

227-
```
228-
float-scalar-vector-type ::= float-type |
229-
`vector<` integer-literal `x` float-type `>`
230-
fmul-op ::= `spirv.FNegate` ssa-use `:` float-scalar-vector-type
231-
```
192+
Results are computed per component.
232193

233194
#### Example:
234195

@@ -249,22 +210,14 @@ def SPIRV_FRemOp : SPIRV_ArithmeticBinaryOp<"FRem", SPIRV_Float, []> {
249210
let description = [{
250211
Result Type must be a scalar or vector of floating-point type.
251212

252-
The types of Operand 1 and Operand 2 both must be the same as Result
213+
The types of Operand 1 and Operand 2 both must be the same as Result
253214
Type.
254215

255-
Results are computed per component. The resulting value is undefined
216+
Results are computed per component. The resulting value is undefined
256217
if Operand 2 is 0. Otherwise, the result is the remainder r of Operand
257218
1 divided by Operand 2 where if r ≠ 0, the sign of r is the same as the
258219
sign of Operand 1.
259220

260-
<!-- End of AutoGen section -->
261-
```
262-
float-scalar-vector-type ::= float-type |
263-
`vector<` integer-literal `x` float-type `>`
264-
frem-op ::= ssa-id `=` `spirv.FRemOp` ssa-use, ssa-use
265-
`:` float-scalar-vector-type
266-
```
267-
268221
#### Example:
269222

270223
```mlir
@@ -282,18 +235,10 @@ def SPIRV_FSubOp : SPIRV_ArithmeticBinaryOp<"FSub", SPIRV_Float, []> {
282235
let description = [{
283236
Result Type must be a scalar or vector of floating-point type.
284237

285-
The types of Operand 1 and Operand 2 both must be the same as Result
238+
The types of Operand 1 and Operand 2 both must be the same as Result
286239
Type.
287240

288-
Results are computed per component.
289-
290-
<!-- End of AutoGen section -->
291-
```
292-
float-scalar-vector-type ::= float-type |
293-
`vector<` integer-literal `x` float-type `>`
294-
fsub-op ::= ssa-id `=` `spirv.FRemOp` ssa-use, ssa-use
295-
`:` float-scalar-vector-type
296-
```
241+
Results are computed per component.
297242

298243
#### Example:
299244

@@ -314,23 +259,15 @@ def SPIRV_IAddOp : SPIRV_ArithmeticBinaryOp<"IAdd",
314259
let description = [{
315260
Result Type must be a scalar or vector of integer type.
316261

317-
The type of Operand 1 and Operand 2 must be a scalar or vector of
262+
The type of Operand 1 and Operand 2 must be a scalar or vector of
318263
integer type. They must have the same number of components as Result
319264
Type. They must have the same component width as Result Type.
320265

321266
The resulting value will equal the low-order N bits of the correct
322267
result R, where N is the component width and R is computed with enough
323268
precision to avoid overflow and underflow.
324269

325-
Results are computed per component.
326-
327-
<!-- End of AutoGen section -->
328-
```
329-
integer-scalar-vector-type ::= integer-type |
330-
`vector<` integer-literal `x` integer-type `>`
331-
iadd-op ::= ssa-id `=` `spirv.IAdd` ssa-use, ssa-use
332-
`:` integer-scalar-vector-type
333-
```
270+
Results are computed per component.
334271

335272
#### Example:
336273

@@ -391,23 +328,15 @@ def SPIRV_IMulOp : SPIRV_ArithmeticBinaryOp<"IMul",
391328
let description = [{
392329
Result Type must be a scalar or vector of integer type.
393330

394-
The type of Operand 1 and Operand 2 must be a scalar or vector of
331+
The type of Operand 1 and Operand 2 must be a scalar or vector of
395332
integer type. They must have the same number of components as Result
396333
Type. They must have the same component width as Result Type.
397334

398335
The resulting value will equal the low-order N bits of the correct
399336
result R, where N is the component width and R is computed with enough
400337
precision to avoid overflow and underflow.
401338

402-
Results are computed per component.
403-
404-
<!-- End of AutoGen section -->
405-
```
406-
integer-scalar-vector-type ::= integer-type |
407-
`vector<` integer-literal `x` integer-type `>`
408-
imul-op ::= ssa-id `=` `spirv.IMul` ssa-use, ssa-use
409-
`:` integer-scalar-vector-type
410-
```
339+
Results are computed per component.
411340

412341
#### Example:
413342

@@ -431,23 +360,15 @@ def SPIRV_ISubOp : SPIRV_ArithmeticBinaryOp<"ISub",
431360
let description = [{
432361
Result Type must be a scalar or vector of integer type.
433362

434-
The type of Operand 1 and Operand 2 must be a scalar or vector of
363+
The type of Operand 1 and Operand 2 must be a scalar or vector of
435364
integer type. They must have the same number of components as Result
436365
Type. They must have the same component width as Result Type.
437366

438367
The resulting value will equal the low-order N bits of the correct
439368
result R, where N is the component width and R is computed with enough
440369
precision to avoid overflow and underflow.
441370

442-
Results are computed per component.
443-
444-
<!-- End of AutoGen section -->
445-
```
446-
integer-scalar-vector-type ::= integer-type |
447-
`vector<` integer-literal `x` integer-type `>`
448-
isub-op ::= `spirv.ISub` ssa-use, ssa-use
449-
`:` integer-scalar-vector-type
450-
```
371+
Results are computed per component.
451372

452373
#### Example:
453374

@@ -545,21 +466,13 @@ def SPIRV_SDivOp : SPIRV_ArithmeticBinaryOp<"SDiv",
545466
let description = [{
546467
Result Type must be a scalar or vector of integer type.
547468

548-
The type of Operand 1 and Operand 2 must be a scalar or vector of
469+
The type of Operand 1 and Operand 2 must be a scalar or vector of
549470
integer type. They must have the same number of components as Result
550471
Type. They must have the same component width as Result Type.
551472

552-
Results are computed per component. The resulting value is undefined
473+
Results are computed per component. The resulting value is undefined
553474
if Operand 2 is 0.
554475

555-
<!-- End of AutoGen section -->
556-
```
557-
integer-scalar-vector-type ::= integer-type |
558-
`vector<` integer-literal `x` integer-type `>`
559-
sdiv-op ::= ssa-id `=` `spirv.SDiv` ssa-use, ssa-use
560-
`:` integer-scalar-vector-type
561-
```
562-
563476
#### Example:
564477

565478
```mlir
@@ -583,22 +496,15 @@ def SPIRV_SModOp : SPIRV_ArithmeticBinaryOp<"SMod",
583496
let description = [{
584497
Result Type must be a scalar or vector of integer type.
585498

586-
The type of Operand 1 and Operand 2 must be a scalar or vector of
499+
The type of Operand 1 and Operand 2 must be a scalar or vector of
587500
integer type. They must have the same number of components as Result
588501
Type. They must have the same component width as Result Type.
589502

590-
Results are computed per component. The resulting value is undefined
503+
Results are computed per component. The resulting value is undefined
591504
if Operand 2 is 0. Otherwise, the result is the remainder r of Operand
592505
1 divided by Operand 2 where if r ≠ 0, the sign of r is the same as the
593506
sign of Operand 2.
594507

595-
<!-- End of AutoGen section -->
596-
```
597-
integer-scalar-vector-type ::= integer-type |
598-
`vector<` integer-literal `x` integer-type `>`
599-
smod-op ::= ssa-id `=` `spirv.SMod` ssa-use, ssa-use
600-
`:` integer-scalar-vector-type
601-
```
602508
#### Example:
603509

604510
```mlir
@@ -683,22 +589,15 @@ def SPIRV_SRemOp : SPIRV_ArithmeticBinaryOp<"SRem",
683589
let description = [{
684590
Result Type must be a scalar or vector of integer type.
685591

686-
The type of Operand 1 and Operand 2 must be a scalar or vector of
592+
The type of Operand 1 and Operand 2 must be a scalar or vector of
687593
integer type. They must have the same number of components as Result
688594
Type. They must have the same component width as Result Type.
689595

690-
Results are computed per component. The resulting value is undefined
596+
Results are computed per component. The resulting value is undefined
691597
if Operand 2 is 0. Otherwise, the result is the remainder r of Operand
692598
1 divided by Operand 2 where if r ≠ 0, the sign of r is the same as the
693599
sign of Operand 1.
694600

695-
<!-- End of AutoGen section -->
696-
```
697-
integer-scalar-vector-type ::= integer-type |
698-
`vector<` integer-literal `x` integer-type `>`
699-
srem-op ::= ssa-id `=` `spirv.SRem` ssa-use, ssa-use
700-
`:` integer-scalar-vector-type
701-
```
702601
#### Example:
703602

704603
```mlir
@@ -720,25 +619,17 @@ def SPIRV_UDivOp : SPIRV_ArithmeticBinaryOp<"UDiv",
720619
Result Type must be a scalar or vector of integer type, whose Signedness
721620
operand is 0.
722621

723-
The types of Operand 1 and Operand 2 both must be the same as Result
622+
The types of Operand 1 and Operand 2 both must be the same as Result
724623
Type.
725624

726-
Results are computed per component. The resulting value is undefined
625+
Results are computed per component. The resulting value is undefined
727626
if Operand 2 is 0.
728627

729-
<!-- End of AutoGen section -->
730-
```
731-
integer-scalar-vector-type ::= integer-type |
732-
`vector<` integer-literal `x` integer-type `>`
733-
udiv-op ::= ssa-id `=` `spirv.UDiv` ssa-use, ssa-use
734-
`:` integer-scalar-vector-type
735-
```
736628
#### Example:
737629

738630
```mlir
739631
%4 = spirv.UDiv %0, %1 : i32
740632
%5 = spirv.UDiv %2, %3 : vector<4xi32>
741-
742633
```
743634
}];
744635
}
@@ -823,25 +714,17 @@ def SPIRV_UModOp : SPIRV_ArithmeticBinaryOp<"UMod",
823714
Result Type must be a scalar or vector of integer type, whose Signedness
824715
operand is 0.
825716

826-
The types of Operand 1 and Operand 2 both must be the same as Result
717+
The types of Operand 1 and Operand 2 both must be the same as Result
827718
Type.
828719

829-
Results are computed per component. The resulting value is undefined
720+
Results are computed per component. The resulting value is undefined
830721
if Operand 2 is 0.
831722

832-
<!-- End of AutoGen section -->
833-
```
834-
integer-scalar-vector-type ::= integer-type |
835-
`vector<` integer-literal `x` integer-type `>`
836-
umod-op ::= ssa-id `=` `spirv.UMod` ssa-use, ssa-use
837-
`:` integer-scalar-vector-type
838-
```
839723
#### Example:
840724

841725
```mlir
842726
%4 = spirv.UMod %0, %1 : i32
843727
%5 = spirv.UMod %2, %3 : vector<4xi32>
844-
845728
```
846729
}];
847730

0 commit comments

Comments
 (0)