Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8600,8 +8600,23 @@ void SPIRVTranslator::ConstructJob(Compilation &C, const JobAction &JA,
TranslatorArgs.push_back("-o");
TranslatorArgs.push_back(Output.getFilename());
if (getToolChain().getTriple().isSYCLDeviceEnvironment()) {
bool isFPGAHardware = false;
if (getToolChain().getTriple().getSubArch() ==
llvm::Triple::SPIRSubArch_fpga) {
for (auto *A : TCArgs) {
if (A->getOption().matches(options::OPT_Xs_separate) ||
A->getOption().matches(options::OPT_Xs)) {
StringRef ArgString(A->getValue());
if (ArgString == "hardware" || ArgString == "simulation")
isFPGAHardware = true;
}
}
}
TranslatorArgs.push_back("-spirv-max-version=1.3");
TranslatorArgs.push_back("-spirv-debug-info-version=ocl-100");
if (!isFPGAHardware)
Comment thread
MrSidims marked this conversation as resolved.
Outdated
TranslatorArgs.push_back("-spirv-debug-info-version=ocl-100");
else
TranslatorArgs.push_back("-spirv-debug-info-version=legacy");
// Prevent crash in the translator if input IR contains DIExpression
// operations which don't have mapping to OpenCL.DebugInfo.100 spec.
TranslatorArgs.push_back("-spirv-allow-extra-diexpressions");
Expand Down Expand Up @@ -8631,23 +8646,14 @@ void SPIRVTranslator::ConstructJob(Compilation &C, const JobAction &JA,
",+SPV_INTEL_fpga_cluster_attributes,+SPV_INTEL_loop_fuse"
",+SPV_INTEL_long_constant_composite";
ExtArg = ExtArg + DefaultExtArg + INTELExtArg;
if (getToolChain().getTriple().getSubArch() ==
llvm::Triple::SPIRSubArch_fpga) {
for (auto *A : TCArgs) {
if (A->getOption().matches(options::OPT_Xs_separate) ||
A->getOption().matches(options::OPT_Xs)) {
StringRef ArgString(A->getValue());
// Enable SPV_INTEL_usm_storage_classes only for FPGA hardware,
// since it adds new storage classes that represent global_device and
// global_host address spaces, which are not supported for all
// targets. With the extension disabled the storage classes will be
// lowered to CrossWorkgroup storage class that is mapped to just
// global address space.
if (ArgString == "hardware" || ArgString == "simulation")
ExtArg += ",+SPV_INTEL_usm_storage_classes";
}
}
}
if (isFPGAHardware)
Comment thread
MrSidims marked this conversation as resolved.
Outdated
// Enable SPV_INTEL_usm_storage_classes only for FPGA hardware,
// since it adds new storage classes that represent global_device and
// global_host address spaces, which are not supported for all
// targets. With the extension disabled the storage classes will be
// lowered to CrossWorkgroup storage class that is mapped to just
// global address space.
ExtArg += ",+SPV_INTEL_usm_storage_classes";
TranslatorArgs.push_back(TCArgs.MakeArgString(ExtArg));
}
for (auto I : Inputs) {
Expand Down
5 changes: 4 additions & 1 deletion clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ const char *SYCL::Linker::constructLLVMSpirvCommand(
} else {
CmdArgs.push_back("-spirv-max-version=1.3");
CmdArgs.push_back("-spirv-ext=+all");
CmdArgs.push_back("-spirv-debug-info-version=ocl-100");
if (!C.getDriver().isFPGAEmulationMode())
CmdArgs.push_back("-spirv-debug-info-version=legacy");
else
CmdArgs.push_back("-spirv-debug-info-version=ocl-100");
CmdArgs.push_back("-spirv-allow-extra-diexpressions");
CmdArgs.push_back("-spirv-allow-unknown-intrinsics=llvm.genx.");
CmdArgs.push_back("-o");
Expand Down
3 changes: 2 additions & 1 deletion clang/test/Driver/sycl-offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,8 @@
// CHK-TOOLS-AOT: file-table-tform{{.*}} "-extract=Code" "-drop_titles" "-o" "[[OUTPUT2_1:.+\.txt]]" "[[OUTPUT2_T]]"
// CHK-TOOLS-CPU: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.3" "-spirv-debug-info-version=ocl-100" "-spirv-allow-extra-diexpressions" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
// CHK-TOOLS-GEN: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.3" "-spirv-debug-info-version=ocl-100" "-spirv-allow-extra-diexpressions" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
// CHK-TOOLS-FPGA: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.3" "-spirv-debug-info-version=ocl-100" "-spirv-allow-extra-diexpressions" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
// CHK-TOOLS-FPGA-HW: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.3" "-spirv-debug-info-version=legacy" "-spirv-allow-extra-diexpressions" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
// CHK-TOOLS-FPGA-EMU: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.3" "-spirv-debug-info-version=ocl-100" "-spirv-allow-extra-diexpressions" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
// CHK-TOOLS-FPGA-HW: aoc{{.*}} "-o" "[[OUTPUT4_T:.+\.aocx]]" "[[OUTPUT3_T]]"
// CHK-TOOLS-FPGA-EMU: opencl-aot{{.*}} "-spv=[[OUTPUT3_T]]" "-ir=[[OUTPUT4_T:.+\.aocx]]"
// CHK-TOOLS-GEN: ocloc{{.*}} "-output" "[[OUTPUT4_T:.+\.out]]" {{.*}} "[[OUTPUT3_T]]"
Expand Down