Skip to content

Commit 1cece41

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 9a1bfc1 commit 1cece41

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
@@ -213,6 +213,8 @@ list of supported SPIR-V extensions, sorted alphabetically by their extension na
213213
- Adds a bitwise instruction on three operands and a look-up table index for specifying the bitwise operation to perform.
214214
* - ``SPV_INTEL_subgroup_matrix_multiply_accumulate``
215215
- 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.
216+
* - ``SPV_INTEL_fpga_argument_interfaces``
217+
- Adds kernel argument decorations that influence the interfaces built for for Field Programmable Gate Array (FPGA) kernel arguments.
216218

217219
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:
218220

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
@@ -97,7 +97,9 @@ static const std::map<std::string, SPIRV::Extension::Extension, std::less<>>
9797
SPIRV::Extension::Extension::
9898
SPV_INTEL_subgroup_matrix_multiply_accumulate},
9999
{"SPV_INTEL_ternary_bitwise_function",
100-
SPIRV::Extension::Extension::SPV_INTEL_ternary_bitwise_function}};
100+
SPIRV::Extension::Extension::SPV_INTEL_ternary_bitwise_function},
101+
{"SPV_INTEL_fpga_argument_interfaces",
102+
SPIRV::Extension::Extension::SPV_INTEL_fpga_argument_interfaces}};
101103

102104
bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName,
103105
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
@@ -517,6 +517,7 @@ defm MemoryAccessAliasingINTEL : CapabilityOperand<5910, 0, 0, [SPV_INTEL_memory
517517
defm FPMaxErrorINTEL : CapabilityOperand<6169, 0, 0, [SPV_INTEL_fp_max_error], []>;
518518
defm TernaryBitwiseFunctionINTEL : CapabilityOperand<6241, 0, 0, [SPV_INTEL_ternary_bitwise_function], []>;
519519
defm SubgroupMatrixMultiplyAccumulateINTEL : CapabilityOperand<6236, 0, 0, [SPV_INTEL_subgroup_matrix_multiply_accumulate], []>;
520+
defm FPGAArgumentInterfacesINTEL : CapabilityOperand<6174, 0, 0, [SPV_INTEL_fpga_argument_interfaces], []>;
520521

521522
//===----------------------------------------------------------------------===//
522523
// Multiclass used to define SourceLanguage enum values and at the same time
@@ -1268,6 +1269,15 @@ defm FunctionFloatingPointModeINTEL : DecorationOperand<6080, 0, 0, [], [Functio
12681269
defm AliasScopeINTEL : DecorationOperand<5914, 0, 0, [], [MemoryAccessAliasingINTEL]>;
12691270
defm NoAliasINTEL : DecorationOperand<5915, 0, 0, [], [MemoryAccessAliasingINTEL]>;
12701271
defm FPMaxErrorDecorationINTEL : DecorationOperand<6170, 0, 0, [], [FPMaxErrorINTEL]>;
1272+
defm ConduitKernelArgumentINTEL : DecorationOperand<6175, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1273+
defm RegisterMapKernelArgumentINTEL: DecorationOperand<6176, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1274+
defm MMHostInterfaceAddressWidthINTEL: DecorationOperand<6177, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1275+
defm MMHostInterfaceDataWidthINTEL: DecorationOperand<6178, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1276+
defm MMHostInterfaceLatencyINTEL: DecorationOperand<6179, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1277+
defm MMHostInterfaceReadWriteModeINTEL: DecorationOperand<6180, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1278+
defm MMHostInterfaceMaxBurstINTEL: DecorationOperand<6181, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1279+
defm MMHostInterfaceWaitRequestINTEL: DecorationOperand<6182, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
1280+
defm StableKernelArgumentINTEL: DecorationOperand<6183, 0, 0, [], [FPGAArgumentInterfacesINTEL]>;
12711281

12721282
//===----------------------------------------------------------------------===//
12731283
// 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)