Skip to content

Commit 581cb15

Browse files
author
Xiang Li
committed
Include DXC and Core options.
Added Fo and map hlsl to -xhlsl to make test work without CC1 options.
1 parent 6510acb commit 581cb15

File tree

7 files changed

+20
-34
lines changed

7 files changed

+20
-34
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6660,5 +6660,9 @@ def dxc_help : Option<["/", "-", "--"], "help", KIND_JOINED>,
66606660
Group<dxc_Group>, Flags<[DXCOption, NoXarchOption]>, Alias<help>,
66616661
HelpText<"Display available options">;
66626662

6663+
6664+
def Fo : DXCJoinedOrSeparate<"Fo">, Alias<o>,
6665+
HelpText<"Output object file.">;
6666+
66636667
def target_profile : DXCJoinedOrSeparate<"T">, MetaVarName<"<profile>">,
66646668
HelpText<"Set target profile. \n\t<profile>: ps_6_0, ps_6_1, ps_6_2, ps_6_3, ps_6_4, ps_6_5, ps_6_6, ps_6_7, \n\t\t vs_6_0, vs_6_1, vs_6_2, vs_6_3, vs_6_4, vs_6_5, vs_6_6, vs_6_7, \n\t\t gs_6_0, gs_6_1, gs_6_2, gs_6_3, gs_6_4, gs_6_5, gs_6_6, gs_6_7, \n\t\t hs_6_0, hs_6_1, hs_6_2, hs_6_3, hs_6_4, hs_6_5, hs_6_6, hs_6_7, \n\t\t ds_6_0, ds_6_1, ds_6_2, ds_6_3, ds_6_4, ds_6_5, ds_6_6, ds_6_7, \n\t\t cs_6_0, cs_6_1, cs_6_2, cs_6_3, cs_6_4, cs_6_5, cs_6_6, cs_6_7, \n\t\t lib_6_1, lib_6_2, lib_6_3, lib_6_4, lib_6_5, lib_6_6, lib_6_7, \n\t\t ms_6_5, ms_6_6, ms_6_7, \n\t\t as_6_5, as_6_6, as_6_7, \n\t\t ">;

clang/lib/Driver/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ add_clang_library(clangDriver
4848
ToolChains/CrossWindows.cpp
4949
ToolChains/Cuda.cpp
5050
ToolChains/Darwin.cpp
51-
ToolChains/DragonFly.cpp
5251
ToolChains/DirectX.cpp
52+
ToolChains/DragonFly.cpp
5353
ToolChains/Flang.cpp
5454
ToolChains/FreeBSD.cpp
5555
ToolChains/Fuchsia.cpp

clang/lib/Driver/Driver.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "ToolChains/CrossWindows.h"
2020
#include "ToolChains/Cuda.h"
2121
#include "ToolChains/Darwin.h"
22-
#include "ToolChains/DragonFly.h"
2322
#include "ToolChains/DirectX.h"
23+
#include "ToolChains/DragonFly.h"
2424
#include "ToolChains/FreeBSD.h"
2525
#include "ToolChains/Fuchsia.h"
2626
#include "ToolChains/Gnu.h"
@@ -5901,7 +5901,9 @@ Driver::getIncludeExcludeOptionFlagMasks(bool IsClCompatMode) const {
59015901
ExcludedFlagsBitmask |= options::CLOption;
59025902
}
59035903
if (IsDXCMode()) {
5904-
// TODO: Include DXC and Core options.
5904+
// Include DXC and Core options.
5905+
IncludedFlagsBitmask |= options::DXCOption;
5906+
IncludedFlagsBitmask |= options::CoreOption;
59055907
} else {
59065908
ExcludedFlagsBitmask |= options::DXCOption;
59075909
}

clang/lib/Driver/ToolChains/DirectX.cpp

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -163,30 +163,9 @@ DirectXToolChain::ComputeEffectiveClangTriple(const ArgList &Args,
163163
getDriver().Diag(diag::err_drv_invalid_directx_shader_module) << profile;
164164
triple = ToolChain::ComputeEffectiveClangTriple(Args, InputType);
165165
}
166+
A->claim();
166167
return triple;
167168
} else {
168169
return ToolChain::ComputeEffectiveClangTriple(Args, InputType);
169170
}
170171
}
171-
172-
llvm::opt::DerivedArgList *
173-
DirectXToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
174-
StringRef BoundArch,
175-
Action::OffloadKind OFK) const {
176-
DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
177-
const OptTable &Opts = getDriver().getOpts();
178-
179-
for (Arg *A : Args) {
180-
if (A->getOption().matches(options::OPT_T)) {
181-
// Convert OPT_T to OPT_target_profile for dxc.
182-
StringRef ProfileStr = A->getValue();
183-
DAL->AddJoinedArg(A, Opts.getOption(options::OPT_target_profile),
184-
ProfileStr);
185-
} else {
186-
// HIP Toolchain translates input args by itself.
187-
DAL->append(A);
188-
}
189-
}
190-
191-
return DAL;
192-
}

clang/lib/Driver/ToolChains/DirectX.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ class LLVM_LIBRARY_VISIBILITY DirectXToolChain : public ToolChain {
2424
return false;
2525
}
2626
bool isPICDefaultForced() const override { return false; }
27-
llvm::opt::DerivedArgList *
28-
TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
29-
Action::OffloadKind DeviceOffloadKind) const override;
27+
3028
std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
3129
types::ID InputType) const override;
3230
};

clang/lib/Driver/Types.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ types::ID types::lookupTypeForExtension(llvm::StringRef Ext) {
332332
.Case("c++m", TY_CXXModule)
333333
.Case("cppm", TY_CXXModule)
334334
.Case("cxxm", TY_CXXModule)
335+
.Case("hlsl", TY_HLSL)
335336
.Default(TY_INVALID);
336337
}
337338

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
// RUN: %clang_dxc -Tvs_6_0 -xhlsl --target=dxil -o - %s 2>&1 | FileCheck %s --check-prefix=VS60
1+
// RUN: %clang_dxc -Tvs_6_0 --target=dxil -Fo - %s 2>&1 | FileCheck %s --check-prefix=VS60
22
// VS60:target triple = "dxil-unknown-shadermodel6.0-vertex"
3-
// RUN: %clang_dxc -Ths_6_1 -xhlsl --target=dxil -o - %s 2>&1 | FileCheck %s --check-prefix=HS61
3+
4+
// RUN: %clang_dxc -Ths_6_1 --target=dxil -Fo - %s 2>&1 | FileCheck %s --check-prefix=HS61
45
// HS61:target triple = "dxil-unknown-shadermodel6.1-hull"
56

6-
// RUN: %clang_dxc -Tps_6_1 -xhlsl --target=dxil -o - %s 2>&1 | FileCheck %s --check-prefix=PS61
7+
// RUN: %clang_dxc -Tps_6_1 --target=dxil -Fo - %s 2>&1 | FileCheck %s --check-prefix=PS61
78
// PS61:target triple = "dxil-unknown-shadermodel6.1-pixel"
8-
// RUN: %clang_dxc -Tlib_6_3 -xhlsl --target=dxil -o - %s 2>&1 | FileCheck %s --check-prefix=LIB63
9-
// LIB63:target triple = "dxil-unknown-shadermodel6.3-library"
109

11-
// RUN: %clang_dxc -### -Tps_3_1 -xhlsl --target=dxil -o - %s 2>&1 | FileCheck %s --check-prefix=INVALID
10+
// RUN: %clang_dxc -Tlib_6_x --target=dxil -Fo - %s 2>&1 | FileCheck %s --check-prefix=LIB63
11+
// LIB63:target triple = "dxil-unknown-shadermodel6.15-library"
12+
13+
// RUN: %clang_dxc -### -Tps_3_1 --target=dxil -Fo - %s 2>&1 | FileCheck %s --check-prefix=INVALID
1214
// INVALID:invalid profile : ps_3_1

0 commit comments

Comments
 (0)