Skip to content

Commit 36f68cc

Browse files
committed
--Added support for the extension SPV_INTEL_fpga_argument_interfaces
--Added test files for the extension SPV_INTEL_fpga_argument_interfaces
1 parent 7454098 commit 36f68cc

File tree

6 files changed

+86
-5
lines changed

6 files changed

+86
-5
lines changed

llvm/docs/SPIRVUsage.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ list of supported SPIR-V extensions, sorted alphabetically by their extension na
217217
- Adds an instruction to compute the matrix product of an M x K matrix with a K x N matrix and then add an M x N matrix.
218218
* - ``SPV_INTEL_int4``
219219
- Adds support for 4-bit integer type, and allow this type to be used in cooperative matrices.
220+
* - ``SPV_INTEL_fpga_argument_interfaces``
221+
- Adds kernel argument decorations that influence the interfaces built for for Field Programmable Gate Array (FPGA) kernel arguments.
220222

221223
To enable multiple extensions, list them separated by comma. For example, to enable support for atomic operations on floating-point numbers and arbitrary precision integers, use:
222224

llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,18 @@ getExecutionModel(const SPIRVSubtarget &STI, const Function &F) {
283283
report_fatal_error("This HLSL entry point is not supported by this backend.");
284284
}
285285

286+
static bool shouldSkipOperands(SPIRV::Decoration::Decoration Dec) {
287+
switch (Dec) {
288+
case SPIRV::Decoration::StableKernelArgumentINTEL:
289+
case SPIRV::Decoration::RegisterMapKernelArgumentINTEL:
290+
case SPIRV::Decoration::ConduitKernelArgumentINTEL:
291+
case SPIRV::Decoration::Restrict:
292+
return true;
293+
default:
294+
return false;
295+
}
296+
}
297+
286298
bool SPIRVCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
287299
const Function &F,
288300
ArrayRef<ArrayRef<Register>> VRegs,
@@ -375,10 +387,12 @@ bool SPIRVCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
375387
auto Dec =
376388
static_cast<SPIRV::Decoration::Decoration>(Const->getZExtValue());
377389
std::vector<uint32_t> DecVec;
378-
for (unsigned j = 1; j < MD2->getNumOperands(); j++) {
379-
ConstantInt *Const = getConstInt(MD2, j);
380-
assert(Const && "MDOperand should be ConstantInt");
381-
DecVec.push_back(static_cast<uint32_t>(Const->getZExtValue()));
390+
if (!shouldSkipOperands(Dec)) {
391+
for (unsigned j = 1; j < MD2->getNumOperands(); j++) {
392+
ConstantInt *Const = getConstInt(MD2, j);
393+
assert(Const && "MDOperand should be ConstantInt");
394+
DecVec.push_back(static_cast<uint32_t>(Const->getZExtValue()));
395+
}
382396
}
383397
buildOpDecorate(VRegs[i][0], MIRBuilder, Dec, DecVec);
384398
}

llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ static const std::map<std::string, SPIRV::Extension::Extension, std::less<>>
100100
SPIRV::Extension::Extension::SPV_INTEL_ternary_bitwise_function},
101101
{"SPV_INTEL_2d_block_io",
102102
SPIRV::Extension::Extension::SPV_INTEL_2d_block_io},
103-
{"SPV_INTEL_int4", SPIRV::Extension::Extension::SPV_INTEL_int4}};
103+
{"SPV_INTEL_int4", SPIRV::Extension::Extension::SPV_INTEL_int4},
104+
{"SPV_INTEL_fpga_argument_interfaces",
105+
SPIRV::Extension::Extension::SPV_INTEL_fpga_argument_interfaces}};
104106

105107
bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName,
106108
StringRef ArgValue,

llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,17 @@ static void addOpDecorateReqs(const MachineInstr &MI, unsigned DecIndex,
920920
} else if (Dec == SPIRV::Decoration::FPMaxErrorDecorationINTEL) {
921921
Reqs.addRequirements(SPIRV::Capability::FPMaxErrorINTEL);
922922
Reqs.addExtension(SPIRV::Extension::SPV_INTEL_fp_max_error);
923+
} else if (Dec == SPIRV::Decoration::ConduitKernelArgumentINTEL ||
924+
Dec == SPIRV::Decoration::RegisterMapKernelArgumentINTEL ||
925+
Dec == SPIRV::Decoration::MMHostInterfaceAddressWidthINTEL ||
926+
Dec == SPIRV::Decoration::MMHostInterfaceDataWidthINTEL ||
927+
Dec == SPIRV::Decoration::MMHostInterfaceLatencyINTEL ||
928+
Dec == SPIRV::Decoration::MMHostInterfaceReadWriteModeINTEL ||
929+
Dec == SPIRV::Decoration::MMHostInterfaceMaxBurstINTEL ||
930+
Dec == SPIRV::Decoration::MMHostInterfaceWaitRequestINTEL ||
931+
Dec == SPIRV::Decoration::StableKernelArgumentINTEL) {
932+
Reqs.addRequirements(SPIRV::Capability::FPGAArgumentInterfacesINTEL);
933+
Reqs.addExtension(SPIRV::Extension::SPV_INTEL_fpga_argument_interfaces);
923934
}
924935
}
925936

llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ defm Subgroup2DBlockTransformINTEL : CapabilityOperand<6229, 0, 0, [SPV_INTEL_2d
525525
defm Subgroup2DBlockTransposeINTEL : CapabilityOperand<6230, 0, 0, [SPV_INTEL_2d_block_io], [Subgroup2DBlockIOINTEL]>;
526526
defm Int4TypeINTEL : CapabilityOperand<5112, 0, 0, [SPV_INTEL_int4], []>;
527527
defm Int4CooperativeMatrixINTEL : CapabilityOperand<5114, 0, 0, [SPV_INTEL_int4], [Int4TypeINTEL, CooperativeMatrixKHR]>;
528+
defm FPGAArgumentInterfacesINTEL : CapabilityOperand<6174, 0, 0, [SPV_INTEL_fpga_argument_interfaces], []>;
528529

529530
//===----------------------------------------------------------------------===//
530531
// Multiclass used to define SourceLanguage enum values and at the same time
@@ -1276,6 +1277,15 @@ defm FunctionFloatingPointModeINTEL : DecorationOperand<6080, 0, 0, [], [Functio
12761277
defm AliasScopeINTEL : DecorationOperand<5914, 0, 0, [], [MemoryAccessAliasingINTEL]>;
12771278
defm NoAliasINTEL : DecorationOperand<5915, 0, 0, [], [MemoryAccessAliasingINTEL]>;
12781279
defm FPMaxErrorDecorationINTEL : DecorationOperand<6170, 0, 0, [], [FPMaxErrorINTEL]>;
1280+
defm ConduitKernelArgumentINTEL : DecorationOperand<6175, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1281+
defm RegisterMapKernelArgumentINTEL: DecorationOperand<6176, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1282+
defm MMHostInterfaceAddressWidthINTEL: DecorationOperand<6177, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1283+
defm MMHostInterfaceDataWidthINTEL: DecorationOperand<6178, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1284+
defm MMHostInterfaceLatencyINTEL: DecorationOperand<6179, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1285+
defm MMHostInterfaceReadWriteModeINTEL: DecorationOperand<6180, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1286+
defm MMHostInterfaceMaxBurstINTEL: DecorationOperand<6181, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1287+
defm MMHostInterfaceWaitRequestINTEL: DecorationOperand<6182, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1288+
defm StableKernelArgumentINTEL: DecorationOperand<6183, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
12791289

12801290
//===----------------------------------------------------------------------===//
12811291
// Multiclass used to define BuiltIn enum values and at the same time
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=+SPV_INTEL_fpga_argument_interfaces %s -o - | FileCheck %s
2+
; TODO: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3+
4+
; CHECK: OpCapability FPGAArgumentInterfacesINTEL
5+
; CHECK: OpExtension "SPV_INTEL_fpga_argument_interfaces"
6+
; CHECK: OpName %[[ID:[0-9]+]] "_arg_p"
7+
; CHECK: OpDecorate %[[ID]] Alignment 4
8+
; CHECK: OpDecorate %[[ID]] MMHostInterfaceAddressWidthINTEL 32
9+
; CHECK: OpDecorate %[[ID]] ConduitKernelArgumentINTEL
10+
; CHECK: OpDecorate %[[ID]] MMHostInterfaceDataWidthINTEL 64
11+
; CHECK: OpDecorate %[[ID]] MMHostInterfaceLatencyINTEL 1
12+
; CHECK: OpDecorate %[[ID]] MMHostInterfaceMaxBurstINTEL 3
13+
; CHECK: OpDecorate %[[ID]] MMHostInterfaceReadWriteModeINTEL 2
14+
; CHECK: OpDecorate %[[ID]] RegisterMapKernelArgumentINTEL
15+
; CHECK: OpDecorate %[[ID]] StableKernelArgumentINTEL
16+
; CHECK: OpDecorate %[[ID]] Restrict
17+
; CHECK: OpDecorate %[[ID]] MMHostInterfaceWaitRequestINTEL 5
18+
19+
$_ZTS4MyIP = comdat any
20+
21+
; Function Attrs: convergent mustprogress norecurse
22+
define weak_odr dso_local spir_kernel void @_ZTS4MyIP(ptr addrspace(4) noundef %_arg_p) #0 comdat !spirv.ParameterDecorations !1588
23+
; CHECK-LLVM-DAG: !spirv.ParameterDecorations ![[PARMDECOR:[0-9]+]]
24+
{
25+
entry:
26+
ret void
27+
}
28+
29+
!1587 = !{i32 -1}
30+
!1588 = !{!1589}
31+
!1589 = !{!1590, !1591, !1593, !1594, !1595, !1596, !1597, !1598, !1599, !1600, !1601}
32+
!1590 = !{i32 44, i32 4}
33+
!1591 = !{i32 6177, i32 32}
34+
!1593 = !{i32 6175, i32 1}
35+
!1594 = !{i32 6178, i32 64}
36+
!1595 = !{i32 6179, i32 1}
37+
!1596 = !{i32 6181, i32 3}
38+
!1597 = !{i32 6180, i32 2}
39+
!1598 = !{i32 6176, i32 1}
40+
!1599 = !{i32 6183, i32 1}
41+
!1600 = !{i32 19, i32 1}
42+
!1601 = !{i32 6182, i32 5}

0 commit comments

Comments
 (0)