Page MenuHomePhabricator

[SPIR-V] Add translator tool
ClosedPublic

Authored by linjamaki on Oct 24 2021, 11:52 PM.

Details

Summary

Add a tool for constructing commands for translating LLVM IR to
SPIR-V.

Used by HIPSPV tool chain (D110618).

Diff Detail

Event Timeline

linjamaki created this revision.Oct 24 2021, 11:52 PM
linjamaki requested review of this revision.Oct 24 2021, 11:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 24 2021, 11:52 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

This direction of creating a common translator tool makes sense to me! Thanks!

clang/include/clang/Driver/Options.td
1534 ↗(On Diff #381848)

Is this flag expected to be similar to -cl-ext?

https://clang.llvm.org/docs/OpenCLSupport.html#cmdoption-cl-ext

It might be good to see how those can align? I imagine for HIP you haven't used such flags yet?

linjamaki marked an inline comment as done.Oct 27 2021, 11:39 PM
linjamaki added inline comments.
clang/include/clang/Driver/Options.td
1534 ↗(On Diff #381848)

Is this flag expected to be similar to -cl-ext?

https://clang.llvm.org/docs/OpenCLSupport.html#cmdoption-cl-ext

It might be good to see how those can align?

It is similar to -cl-ext. I thought it would make sense to have --spirv-ext for defining allowed SPIR-V extensions via the clang driver. I did not think that having both the -cl-ext and the --spirv-ext at the same time may conflict and/or contradict so I’ll remove the options here (--spirv-max-version too). Let’s introduce them in D112410 if needed.

I imagine for HIP you haven't used such flags yet?

HIPSPV tool chain passes --spirv-max-version and --spirv-ext options to the LLVM-SPIR-V translator for overriding its defaults.

linjamaki marked an inline comment as done.

Remove --spirv-ext and --spirv-max-version.

bader accepted this revision.Oct 28 2021, 5:07 AM

This part looks good to me. Just a couple of minor style comments.

clang/lib/Driver/ToolChains/SPIRV.cpp
19

If this function is going to be used only by SPIRV::Translator::ConstructJob, it's better to make it static or manually inline into 4-line SPIRV::Translator::ConstructJob.

clang/lib/Driver/ToolChains/SPIRV.h
32

I think using just "translator" as a short name might be ambiguous.

This revision is now accepted and ready to land.Oct 28 2021, 5:07 AM
linjamaki updated this revision to Diff 383001.Oct 28 2021, 5:40 AM

Rename SPIRV::Translator's tool names as suggested by bader.

linjamaki marked an inline comment as done.Oct 28 2021, 5:45 AM

Thanks for the review.

clang/lib/Driver/ToolChains/SPIRV.cpp
19

This function is used by HIPSPV tool chain too (D110618) by the HIPSPV::Linker::constructLinkAndEmitSpirvCommand() function.

clang/lib/Driver/ToolChains/SPIRV.h
32

Updated.

linjamaki marked an inline comment as done.

Rebase.

Hi @Anastasia and @bader,

This patch should be ready to land, I think. Could you please push it to the LLVM for us? Thanks.

This revision was automatically updated to reflect the committed changes.

Thanks for the help!