@@ -24,8 +24,25 @@ class SPIRV_ArithmeticBinaryOp<string mnemonic, Type type,
2424 SPIRV_BinaryOp<mnemonic, type, type,
2525 !listconcat(traits,
2626 [Pure, AllTypesMatch<["operand1", "operand2", "result"]>])> {
27- // In addition to normal types arithmetic instructions can support cooperative
28- // matrix.
27+ let arguments = (ins
28+ SPIRV_ScalarOrVectorOf<type>:$operand1,
29+ SPIRV_ScalarOrVectorOf<type>:$operand2
30+ );
31+
32+ let results = (outs
33+ SPIRV_ScalarOrVectorOf<type>:$result
34+ );
35+ let assemblyFormat = "operands attr-dict `:` type($result)";
36+ }
37+
38+ class SPIRV_ArithmeticBinaryOpWithCoopMatrix<string mnemonic, Type type,
39+ list<Trait> traits = []> :
40+ // Operands type same as result type.
41+ SPIRV_BinaryOp<mnemonic, type, type,
42+ !listconcat(traits,
43+ [Pure, AllTypesMatch<["operand1", "operand2", "result"]>])> {
44+ // In addition to normal types these arithmetic instructions can support
45+ // cooperative matrix.
2946 let arguments = (ins
3047 SPIRV_ScalarOrVectorOrCoopMatrixOf<type>:$operand1,
3148 SPIRV_ScalarOrVectorOrCoopMatrixOf<type>:$operand2
@@ -82,7 +99,7 @@ class SPIRV_ArithmeticExtendedBinaryOp<string mnemonic,
8299
83100// -----
84101
85- def SPIRV_FAddOp : SPIRV_ArithmeticBinaryOp <"FAdd", SPIRV_Float, [Commutative]> {
102+ def SPIRV_FAddOp : SPIRV_ArithmeticBinaryOpWithCoopMatrix <"FAdd", SPIRV_Float, [Commutative]> {
86103 let summary = "Floating-point addition of Operand 1 and Operand 2.";
87104
88105 let description = [{
@@ -104,7 +121,7 @@ def SPIRV_FAddOp : SPIRV_ArithmeticBinaryOp<"FAdd", SPIRV_Float, [Commutative]>
104121
105122// -----
106123
107- def SPIRV_FDivOp : SPIRV_ArithmeticBinaryOp <"FDiv", SPIRV_Float, []> {
124+ def SPIRV_FDivOp : SPIRV_ArithmeticBinaryOpWithCoopMatrix <"FDiv", SPIRV_Float, []> {
108125 let summary = "Floating-point division of Operand 1 divided by Operand 2.";
109126
110127 let description = [{
@@ -154,7 +171,7 @@ def SPIRV_FModOp : SPIRV_ArithmeticBinaryOp<"FMod", SPIRV_Float, []> {
154171
155172// -----
156173
157- def SPIRV_FMulOp : SPIRV_ArithmeticBinaryOp <"FMul", SPIRV_Float, [Commutative]> {
174+ def SPIRV_FMulOp : SPIRV_ArithmeticBinaryOpWithCoopMatrix <"FMul", SPIRV_Float, [Commutative]> {
158175 let summary = "Floating-point multiplication of Operand 1 and Operand 2.";
159176
160177 let description = [{
@@ -229,7 +246,7 @@ def SPIRV_FRemOp : SPIRV_ArithmeticBinaryOp<"FRem", SPIRV_Float, []> {
229246
230247// -----
231248
232- def SPIRV_FSubOp : SPIRV_ArithmeticBinaryOp <"FSub", SPIRV_Float, []> {
249+ def SPIRV_FSubOp : SPIRV_ArithmeticBinaryOpWithCoopMatrix <"FSub", SPIRV_Float, []> {
233250 let summary = "Floating-point subtraction of Operand 2 from Operand 1.";
234251
235252 let description = [{
@@ -251,9 +268,9 @@ def SPIRV_FSubOp : SPIRV_ArithmeticBinaryOp<"FSub", SPIRV_Float, []> {
251268
252269// -----
253270
254- def SPIRV_IAddOp : SPIRV_ArithmeticBinaryOp <"IAdd",
255- SPIRV_Integer,
256- [Commutative, UsableInSpecConstantOp]> {
271+ def SPIRV_IAddOp : SPIRV_ArithmeticBinaryOpWithCoopMatrix <"IAdd",
272+ SPIRV_Integer,
273+ [Commutative, UsableInSpecConstantOp]> {
257274 let summary = "Integer addition of Operand 1 and Operand 2.";
258275
259276 let description = [{
@@ -322,9 +339,9 @@ def SPIRV_IAddCarryOp : SPIRV_ArithmeticExtendedBinaryOp<"IAddCarry",
322339
323340// -----
324341
325- def SPIRV_IMulOp : SPIRV_ArithmeticBinaryOp <"IMul",
326- SPIRV_Integer,
327- [Commutative, UsableInSpecConstantOp]> {
342+ def SPIRV_IMulOp : SPIRV_ArithmeticBinaryOpWithCoopMatrix <"IMul",
343+ SPIRV_Integer,
344+ [Commutative, UsableInSpecConstantOp]> {
328345 let summary = "Integer multiplication of Operand 1 and Operand 2.";
329346
330347 let description = [{
@@ -354,9 +371,9 @@ def SPIRV_IMulOp : SPIRV_ArithmeticBinaryOp<"IMul",
354371
355372// -----
356373
357- def SPIRV_ISubOp : SPIRV_ArithmeticBinaryOp <"ISub",
358- SPIRV_Integer,
359- [UsableInSpecConstantOp]> {
374+ def SPIRV_ISubOp : SPIRV_ArithmeticBinaryOpWithCoopMatrix <"ISub",
375+ SPIRV_Integer,
376+ [UsableInSpecConstantOp]> {
360377 let summary = "Integer subtraction of Operand 2 from Operand 1.";
361378
362379 let description = [{
@@ -460,9 +477,9 @@ def SPIRV_DotOp : SPIRV_Op<"Dot",
460477
461478// -----
462479
463- def SPIRV_SDivOp : SPIRV_ArithmeticBinaryOp <"SDiv",
464- SPIRV_Integer,
465- [UsableInSpecConstantOp]> {
480+ def SPIRV_SDivOp : SPIRV_ArithmeticBinaryOpWithCoopMatrix <"SDiv",
481+ SPIRV_Integer,
482+ [UsableInSpecConstantOp]> {
466483 let summary = "Signed-integer division of Operand 1 divided by Operand 2.";
467484
468485 let description = [{
@@ -622,9 +639,9 @@ def SPIRV_SRemOp : SPIRV_ArithmeticBinaryOp<"SRem",
622639
623640// -----
624641
625- def SPIRV_UDivOp : SPIRV_ArithmeticBinaryOp <"UDiv",
626- SPIRV_Integer,
627- [UnsignedOp, UsableInSpecConstantOp]> {
642+ def SPIRV_UDivOp : SPIRV_ArithmeticBinaryOpWithCoopMatrix <"UDiv",
643+ SPIRV_Integer,
644+ [UnsignedOp, UsableInSpecConstantOp]> {
628645 let summary = "Unsigned-integer division of Operand 1 divided by Operand 2.";
629646
630647 let description = [{
0 commit comments