[PATCH] D110685: [HIPSPV][4/4] Add option to use llc to emit SPIR-V
Henry Linjamäki via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 25 00:06:30 PDT 2021
linjamaki updated this revision to Diff 381857.
linjamaki added a comment.
Rebase.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110685/new/
https://reviews.llvm.org/D110685
Files:
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/HIPSPV.cpp
clang/test/Driver/hipspv-options.hip
Index: clang/test/Driver/hipspv-options.hip
===================================================================
--- /dev/null
+++ clang/test/Driver/hipspv-options.hip
@@ -0,0 +1,12 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// UNSUPPORTED: system-windows
+
+// RUN: %clang -### -target x86_64-linux-gnu --offload=spirv64 \
+// RUN: --hip-path=%S/Inputs/hipspv -nogpuinc -nogpulib %s \
+// RUN: --spirv-use-llc=/foo/bar/llc 2>&1 | FileCheck %s
+
+// CHECK-NOT: llvm-spirv
+// CHECK: "/foo/bar/llc" "--mattr=+spirv1.1" "--filetype=obj" "{{.*}}.bc"
+// CHECK-SAME: "-o" "{{.*}}.out"
+
Index: clang/lib/Driver/ToolChains/HIPSPV.cpp
===================================================================
--- clang/lib/Driver/ToolChains/HIPSPV.cpp
+++ clang/lib/Driver/ToolChains/HIPSPV.cpp
@@ -97,6 +97,25 @@
// Emit SPIR-V binary.
+ // Use llc. Meant for testing out LLVM SPIR-V backend. Eventually HIPSPV will
+ // switch to use in-tree SPIR-V backend for binary emission.
+ if (auto *A = Args.getLastArg(options::OPT_spirv_use_llc,
+ options::OPT_spirv_use_llc_EQ)) {
+ assert(A->getNumValues() <= 1);
+ const char *LlcExe = nullptr;
+ if (A->getNumValues() == 1 && !StringRef(A->getValue()).empty())
+ LlcExe = A->getValue();
+ else
+ LlcExe = Args.MakeArgString(getToolChain().GetProgramPath("llc"));
+ ArgStringList LlcArgs{"--mattr=+spirv1.1", "--filetype=obj", TempFile, "-o",
+ Output.getFilename()};
+ C.addCommand(std::make_unique<Command>(JA, *this,
+ ResponseFileSupport::None(), LlcExe,
+ LlcArgs, Inputs, Output));
+ return;
+ }
+
+ // Use SPIRV-LLVM Translator.
llvm::opt::ArgStringList TrArgs;
SPIRV::addTranslatorArgs(Args, TrArgs);
if (!Args.hasArg(options::OPT_spirv_max_version_EQ))
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1541,6 +1541,13 @@
HelpText<"Specify comma separated list of allowed/disallowed SPIR-V "
"extensions prefixed with '+' or '-'. '+' and '-' allows and disallows "
"the extension, respectively. Special value 'all' affects all extensions">;
+def spirv_use_llc : Flag<["--"], "spirv-use-llc">, Flags<[HelpHidden]>,
+ HelpText<"Use (in-tree) llc to emit SPIR-V. Use for development and "
+ "testing only.">;
+def spirv_use_llc_EQ : Joined<["--"], "spirv-use-llc=">,
+ MetaVarName<"<path>">, Flags<[HelpHidden]>,
+ HelpText<"Use speficied llc to emit SPIR-V. Use for development and "
+ "testing only.">;
// Begin sanitizer flags. These should all be core options exposed in all driver
// modes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110685.381857.patch
Type: text/x-patch
Size: 2841 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211025/aa3f38e1/attachment.bin>
More information about the cfe-commits
mailing list