[HLSL][clang][Driver] Support target profile command line option.
authorXiang Li <python3kgae@outlook.com>
Fri, 15 Apr 2022 19:09:10 +0000 (14:09 -0500)
committerChris Bieneman <chris.bieneman@me.com>
Fri, 15 Apr 2022 19:18:18 +0000 (14:18 -0500)
commit721651be246e26efd767c3ec55c8f06c7b5a9a3d
treed9780ff6caa3c4de5fd43640fa717a5b73a577ea
parent69c1a354885134303a17bac9e36a913cee92996c
[HLSL][clang][Driver] Support target profile command line option.

The target profile option(/T) decide the shader model when compile hlsl.
The format is shaderKind_major_minor like ps_6_1.
The shader model is saved as llvm::Triple is clang/llvm like
dxil-unknown-shadermodel6.1-hull.
The main job to support the option is translating ps_6_1 into
shadermodel6.1-pixel.
That is done inside tryParseProfile  at HLSL.cpp.

To integrate the option into clang Driver, a new DriverMode DxcMode is
created. When DxcMode is enabled, OSType for TargetTriple will be
forced into Triple::ShaderModel. And new ToolChain HLSLToolChain will
be created when OSType is Triple::ShaderModel.

In HLSLToolChain, ComputeEffectiveClangTriple is overridden to call
tryParseProfile when targetProfile option is set.

To make test work, Fo option is added and .hlsl is added for active
-xhlsl.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D122865

Patch by: Xiang Li <python3kgae@outlook.com>
12 files changed:
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Driver.h
clang/include/clang/Driver/Options.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/CMakeLists.txt
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/HLSL.cpp [new file with mode: 0644]
clang/lib/Driver/ToolChains/HLSL.h [new file with mode: 0644]
clang/lib/Driver/Types.cpp
clang/test/lit.cfg.py
clang/unittests/Driver/ToolChainTest.cpp