Skip to content

Commit 2c754ec

Browse files
authored
[SPIRV] Added Packed Vector Format for SPV_KHR_integer_dot_product (#160088)
Added Packed Vector Format PackedVectorFormat4x8Bit and modified existing test file.
1 parent 3f8c7e9 commit 2c754ec

File tree

4 files changed

+45
-10
lines changed

4 files changed

+45
-10
lines changed

llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVInstPrinter.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,21 @@ void SPIRVInstPrinter::printInst(const MCInst *MI, uint64_t Address,
269269
}
270270
break;
271271
}
272+
case SPIRV::OpSDot:
273+
case SPIRV::OpUDot:
274+
case SPIRV::OpSUDot:
275+
case SPIRV::OpSDotAccSat:
276+
case SPIRV::OpUDotAccSat:
277+
case SPIRV::OpSUDotAccSat: {
278+
const unsigned NumOps = MI->getNumOperands();
279+
if (NumOps > NumFixedOps) {
280+
OS << ' ';
281+
printSymbolicOperand<OperandCategory::PackedVectorFormatsOperand>(
282+
MI, NumOps - 1, OS);
283+
break;
284+
}
285+
break;
286+
}
272287
default:
273288
printRemainingVariableOps(MI, NumFixedOps, OS);
274289
break;

llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ static bool generateDotOrFMulInst(const StringRef DemangledCall,
17781778
// Add Packed Vector Format for Integer dot product builtins if arguments are
17791779
// scalar
17801780
if (!IsVec && OC != SPIRV::OpFMulS)
1781-
MIB.addImm(0);
1781+
MIB.addImm(SPIRV::PackedVectorFormat4x8Bit);
17821782

17831783
return true;
17841784
}

llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def CooperativeMatrixOperandsOperand : OperandCategory;
211211
def SpecConstantOpOperandsOperand : OperandCategory;
212212
def MatrixMultiplyAccumulateOperandsOperand : OperandCategory;
213213
def FPEncodingOperand : OperandCategory;
214+
def PackedVectorFormatsOperand : OperandCategory;
214215

215216
//===----------------------------------------------------------------------===//
216217
// Definition of the Environments
@@ -2026,3 +2027,22 @@ multiclass FPEncodingOperand<bits<32> value, list<Extension> reqExtensions>{
20262027
}
20272028

20282029
defm BFloat16KHR : FPEncodingOperand<0, [SPV_KHR_bfloat16]>;
2030+
2031+
def PackedVectorFormats : GenericEnum, Operand<i32> {
2032+
let FilterClass = "PackedVectorFormats";
2033+
let NameField = "Name";
2034+
let ValueField = "Value";
2035+
let PrintMethod = !strconcat("printSymbolicOperand<OperandCategory::", FilterClass, "Operand>");
2036+
}
2037+
2038+
class PackedVectorFormats<string name, bits<32> value> {
2039+
string Name = name;
2040+
bits<32> Value = value;
2041+
}
2042+
2043+
multiclass PackedVectorFormatsOperand<bits<32> value, list<Extension> reqExtensions> {
2044+
def NAME : BuiltIn<NAME, value>;
2045+
defm : SymbolicOperandWithRequirements<PackedVectorFormatsOperand, value, NAME, 0, 0, reqExtensions, [], []>;
2046+
}
2047+
2048+
defm PackedVectorFormat4x8Bit : PackedVectorFormatsOperand<0, [SPV_KHR_integer_dot_product]>;

llvm/test/CodeGen/SPIRV/extensions/SPV_KHR_integer_dot_product/SPV_KHR_integer_dot_product_OCLtoSPIRV_int.ll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
; CHECK: Name %[[#SignedB:]] "ib"
1414
; CHECK: Name %[[#UnsignedB:]] "ub"
1515

16-
; CHECK: SDot %[[#]] %[[#SignedA]] %[[#SignedB]] 0
17-
; CHECK: SUDot %[[#]] %[[#SignedA]] %[[#UnsignedB]] 0
18-
; CHECK: SUDot %[[#]] %[[#SignedB]] %[[#UnsignedA]] 0
19-
; CHECK: UDot %[[#]] %[[#UnsignedA]] %[[#UnsignedB]] 0
20-
21-
; CHECK: SDotAccSat %[[#]] %[[#SignedA]] %[[#SignedB]] %[[#]] 0
22-
; CHECK: SUDotAccSat %[[#]] %[[#SignedA]] %[[#UnsignedB]] %[[#]] 0
23-
; CHECK: SUDotAccSat %[[#]] %[[#SignedB]] %[[#UnsignedA]] %[[#]] 0
24-
; CHECK: UDotAccSat %[[#]] %[[#UnsignedA]] %[[#UnsignedB]] %[[#]] 0
16+
; CHECK: SDot %[[#]] %[[#SignedA]] %[[#SignedB]] PackedVectorFormat4x8Bit
17+
; CHECK: SUDot %[[#]] %[[#SignedA]] %[[#UnsignedB]] PackedVectorFormat4x8Bit
18+
; CHECK: SUDot %[[#]] %[[#SignedB]] %[[#UnsignedA]] PackedVectorFormat4x8Bit
19+
; CHECK: UDot %[[#]] %[[#UnsignedA]] %[[#UnsignedB]] PackedVectorFormat4x8Bit
20+
21+
; CHECK: SDotAccSat %[[#]] %[[#SignedA]] %[[#SignedB]] %[[#]] PackedVectorFormat4x8Bit
22+
; CHECK: SUDotAccSat %[[#]] %[[#SignedA]] %[[#UnsignedB]] %[[#]] PackedVectorFormat4x8Bit
23+
; CHECK: SUDotAccSat %[[#]] %[[#SignedB]] %[[#UnsignedA]] %[[#]] PackedVectorFormat4x8Bit
24+
; CHECK: UDotAccSat %[[#]] %[[#UnsignedA]] %[[#UnsignedB]] %[[#]] PackedVectorFormat4x8Bit
2525

2626
define spir_kernel void @test(i32 %ia, i32 %ua, i32 %ib, i32 %ub, i32 %ires, i32 %ures) {
2727
entry:

0 commit comments

Comments
 (0)