Skip to content

Commit a73a84c

Browse files
committed
[HLSL] add -I option for dxc mode.
A new option -I is added for dxc mode. It is just alias of existing cc1 -I option. Reviewed By: beanz Differential Revision: https://reviews.llvm.org/D128462
1 parent d76c8f5 commit a73a84c

File tree

6 files changed

+23
-3
lines changed

6 files changed

+23
-3
lines changed

clang-tools-extra/clangd/CompileCommands.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ unsigned char getModes(const llvm::opt::Option &Opt) {
423423
if (!Opt.hasFlag(driver::options::NoDriverOption)) {
424424
if (Opt.hasFlag(driver::options::CLOption)) {
425425
Result |= DM_CL;
426+
} else if (Opt.hasFlag(driver::options::CLDXCOption)) {
427+
Result |= DM_CL;
426428
} else {
427429
Result |= DM_GCC;
428430
if (Opt.hasFlag(driver::options::CoreOption)) {

clang/include/clang/Driver/Options.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ enum ClangFlags {
3636
FC1Option = (1 << 15),
3737
FlangOnlyOption = (1 << 16),
3838
DXCOption = (1 << 17),
39-
Ignored = (1 << 18),
39+
CLDXCOption = (1 << 18),
40+
Ignored = (1 << 19),
4041
};
4142

4243
enum ID {

clang/include/clang/Driver/Options.td

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ def CC1AsOption : OptionFlag;
5353
// are made available when the driver is running in DXC compatibility mode.
5454
def DXCOption : OptionFlag;
5555

56+
// CLDXCOption - This is a cl.exe/dxc.exe compatibility option. Options with this flag
57+
// are made available when the driver is running in CL/DXC compatibility mode.
58+
def CLDXCOption : OptionFlag;
59+
5660
// NoDriverOption - This option should not be accepted by the driver.
5761
def NoDriverOption : OptionFlag;
5862

@@ -6355,7 +6359,7 @@ def defsym : Separate<["-"], "defsym">,
63556359
// clang-cl Options
63566360
//===----------------------------------------------------------------------===//
63576361

6358-
def cl_Group : OptionGroup<"<clang-cl options>">, Flags<[CLOption]>,
6362+
def cl_Group : OptionGroup<"<clang-cl options>">, Flags<[CLDXCOption]>,
63596363
HelpText<"CL.EXE COMPATIBILITY OPTIONS">;
63606364

63616365
def cl_compile_Group : OptionGroup<"<clang-cl compile-only options>">,
@@ -6385,6 +6389,9 @@ class CLIgnoredJoined<string name> : Option<["/", "-"], name, KIND_JOINED>,
63856389
class CLJoinedOrSeparate<string name> : Option<["/", "-"], name,
63866390
KIND_JOINED_OR_SEPARATE>, Group<cl_Group>, Flags<[CLOption, NoXarchOption]>;
63876391

6392+
class CLDXCJoinedOrSeparate<string name> : Option<["/", "-"], name,
6393+
KIND_JOINED_OR_SEPARATE>, Group<cl_Group>, Flags<[CLDXCOption, NoXarchOption]>;
6394+
63886395
class CLCompileJoinedOrSeparate<string name> : Option<["/", "-"], name,
63896396
KIND_JOINED_OR_SEPARATE>, Group<cl_compile_Group>,
63906397
Flags<[CLOption, NoXarchOption]>;
@@ -6462,7 +6469,7 @@ def _SLASH_help : CLFlag<"help">, Alias<help>,
64626469
def _SLASH_HELP : CLFlag<"HELP">, Alias<help>;
64636470
def _SLASH_hotpatch : CLFlag<"hotpatch">, Alias<fms_hotpatch>,
64646471
HelpText<"Create hotpatchable image">;
6465-
def _SLASH_I : CLJoinedOrSeparate<"I">,
6472+
def _SLASH_I : CLDXCJoinedOrSeparate<"I">,
64666473
HelpText<"Add directory to include search path">, MetaVarName<"<dir>">,
64676474
Alias<I>;
64686475
def _SLASH_J : CLFlag<"J">, HelpText<"Make char type unsigned">,

clang/lib/Driver/Driver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6262,17 +6262,22 @@ Driver::getIncludeExcludeOptionFlagMasks(bool IsClCompatMode) const {
62626262
if (IsClCompatMode) {
62636263
// Include CL and Core options.
62646264
IncludedFlagsBitmask |= options::CLOption;
6265+
IncludedFlagsBitmask |= options::CLDXCOption;
62656266
IncludedFlagsBitmask |= options::CoreOption;
62666267
} else {
62676268
ExcludedFlagsBitmask |= options::CLOption;
62686269
}
62696270
if (IsDXCMode()) {
62706271
// Include DXC and Core options.
62716272
IncludedFlagsBitmask |= options::DXCOption;
6273+
IncludedFlagsBitmask |= options::CLDXCOption;
62726274
IncludedFlagsBitmask |= options::CoreOption;
62736275
} else {
62746276
ExcludedFlagsBitmask |= options::DXCOption;
62756277
}
6278+
if (!IsClCompatMode && !IsDXCMode())
6279+
ExcludedFlagsBitmask |= options::CLDXCOption;
6280+
62766281
return std::make_pair(IncludedFlagsBitmask, ExcludedFlagsBitmask);
62776282
}
62786283

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3511,6 +3511,7 @@ static void RenderHLSLOptions(const ArgList &Args, ArgStringList &CmdArgs,
35113511
types::ID InputType) {
35123512
const unsigned ForwardedArguments[] = {options::OPT_dxil_validator_version,
35133513
options::OPT_D,
3514+
options::OPT_I,
35143515
options::OPT_S,
35153516
options::OPT_emit_llvm,
35163517
options::OPT_disable_llvm_passes,

clang/test/Driver/dxc_I.hlsl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: %clang_dxc -I test -### %s 2>&1 | FileCheck %s
2+
3+
// Make sure -I send to cc1.
4+
// CHECK:"-I" "test"

0 commit comments

Comments
 (0)