Skip to content

Commit baae5dd

Browse files
llvm-beanzGreg Roth
andauthored
Remove HLSL 2021 per-feature flags (#4716)
* [NFC] Transform all test cases to use `-HV 2021` This just updates test cases to use `-HV 2021` instead of the per-feature options. * Remove HLSL 2021 per-feature flags This change removes the HLSL 2021 per-feature enabling flags. Now that HLSL 2021 is feature complete we're removing the ability to opt into individual features. Any code relying on a single feature of HLSL 2021 should now adopt HLSL 2021 completely. Co-authored-by: Greg Roth <[email protected]>
1 parent cce6fe0 commit baae5dd

91 files changed

Lines changed: 130 additions & 261 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/dxc/Support/HLSLOptions.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,6 @@ class DxcOpts {
206206
bool ForceZeroStoreLifetimes = false; // OPT_force_zero_store_lifetimes
207207
bool EnableLifetimeMarkers = false; // OPT_enable_lifetime_markers
208208
bool ForceDisableLocTracking = false; // OPT_fdisable_loc_tracking
209-
bool EnableTemplates = false; // OPT_enable_templates
210-
bool EnableOperatorOverloading = false; // OPT_enable_operator_overloading
211-
bool StrictUDTCasting = false; // OPT_strict_udt_casting
212-
213-
// Experimental option to enable short-circuiting operators
214-
bool EnableShortCircuit = false; // OPT_enable_short_circuit
215-
216-
bool EnableBitfields = false; // OPT_enable_bitfields
217209

218210
// Optimization pass enables, disables and selects
219211
std::map<std::string, bool> DxcOptimizationToggles; // OPT_opt_enable & OPT_opt_disable

include/dxc/Support/HLSLOptions.td

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,6 @@ def enable_lifetime_markers : Flag<["-", "/"], "enable-lifetime-markers">, Group
302302
HelpText<"Enable generation of lifetime markers">;
303303
def disable_lifetime_markers : Flag<["-", "/"], "disable-lifetime-markers">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
304304
HelpText<"Disable generation of lifetime markers where they would be otherwise (6.6+)">;
305-
def enable_templates: Flag<["-", "/"], "enable-templates">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
306-
HelpText<"Enable template support for HLSL.">;
307-
def enable_operator_overloading: Flag<["-", "/"], "enable-operator-overloading">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
308-
HelpText<"Enable operator overloading support for HLSL.">;
309-
def strict_udt_casting: Flag<["-", "/"], "strict-udt-casting">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
310-
HelpText<"Require explicit casts between different structure types with compatible layouts.">;
311305
def enable_payload_qualifiers : Flag<["-", "/"], "enable-payload-qualifiers">, Group<hlslcomp_Group>, Flags<[CoreOption, RewriteOption, DriverOption]>,
312306
HelpText<"Enables support for payload access qualifiers for raytracing payloads in SM 6.6.">;
313307
def disable_payload_qualifiers : Flag<["-", "/"], "disable-payload-qualifiers">, Group<hlslcomp_Group>, Flags<[CoreOption, RewriteOption, DriverOption]>,
@@ -483,12 +477,6 @@ def Qstrip_reflect_from_dxil : Flag<["-", "/"], "Qstrip_reflect_from_dxil">,
483477
Flags<[CoreOption, HelpHidden]>, Group<hlslutil_Group>,
484478
HelpText<"Strip reflection data from shader bytecode (must be used with /Fo <file>)">;
485479

486-
def enable_short_circuit : Flag<["-", "/"], "enable-short-circuit">, Flags<[CoreOption, HelpHidden]>, Group<hlslcomp_Group>,
487-
HelpText<"Operators '&&', '||', and '?:' will short circuit, only accepting scalar inputs. Use and(), or(), and select() intrinsics in place of non-short-circuiting vector operators.">;
488-
489-
def enable_bitfields : Flag<["-", "/"], "enable-bitfields">, Flags<[CoreOption, HelpHidden]>, Group<hlslcomp_Group>,
490-
HelpText<"Enables bitfields on struct members">;
491-
492480
/*
493481
def shtemplate : JoinedOrSeparate<["-", "/"], "shtemplate">, MetaVarName<"<file>">, Group<hlslcomp_Group>,
494482
HelpText<"Template shader file for merging/matching resources">;

lib/DxcSupport/HLSLOptions.cpp

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -520,55 +520,6 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
520520
opts.EnableFXCCompatMode = true;
521521
}
522522

523-
// If the HLSL version is 2021, allow the 2021 features by default.
524-
// If the HLSL version is 2016 or 2018, allow them only
525-
// when the individual option is enabled.
526-
// If the HLSL version is 2015, dissallow these features
527-
if (opts.HLSLVersion >= hlsl::LangStd::v2021) {
528-
// Enable operator overloading in structs
529-
opts.EnableOperatorOverloading = true;
530-
// Enable template support
531-
opts.EnableTemplates = true;
532-
// Determine overload matching based on UDT names, not just types
533-
opts.StrictUDTCasting = true;
534-
// Experimental option to enable short-circuiting operators
535-
opts.EnableShortCircuit = true;
536-
// Enable bitfield support
537-
opts.EnableBitfields = true;
538-
539-
} else {
540-
opts.EnableOperatorOverloading = Args.hasFlag(OPT_enable_operator_overloading, OPT_INVALID, false);
541-
opts.EnableTemplates = Args.hasFlag(OPT_enable_templates, OPT_INVALID, false);
542-
opts.StrictUDTCasting = Args.hasFlag(OPT_strict_udt_casting, OPT_INVALID, false);
543-
opts.EnableShortCircuit = Args.hasFlag(OPT_enable_short_circuit, OPT_INVALID, false);
544-
opts.EnableBitfields = Args.hasFlag(OPT_enable_bitfields, OPT_INVALID, false);
545-
546-
if (opts.HLSLVersion <= hlsl::LangStd::v2015) {
547-
548-
if (opts.EnableOperatorOverloading)
549-
errors << "/enable-operator-overloading is not supported with HLSL "
550-
"Version "
551-
<< (unsigned long)opts.HLSLVersion;
552-
if (opts.EnableTemplates)
553-
errors << "/enable-templates is not supported with HLSL Version "
554-
<< (unsigned long)opts.HLSLVersion;
555-
556-
if (opts.StrictUDTCasting)
557-
errors << "/enable-udt-casting is not supported with HLSL Version "
558-
<< (unsigned long)opts.HLSLVersion;
559-
560-
if (opts.EnableShortCircuit)
561-
errors << "/enable-short-circuit is not supported with HLSL Version "
562-
<< (unsigned long)opts.HLSLVersion;
563-
564-
if (opts.EnableBitfields)
565-
errors << "/enable-bitfields is not supported with HLSL Version "
566-
<< (unsigned long)opts.HLSLVersion;
567-
568-
return 1;
569-
}
570-
}
571-
572523
// AssemblyCodeHex not supported (Fx)
573524
// OutputLibrary not supported (Fl)
574525
opts.AssemblyCode = Args.getLastArgValue(OPT_Fc);

tools/clang/include/clang/Basic/LangOptions.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,7 @@ class LangOptions : public LangOptionsBase {
159159
bool UseMinPrecision = true; // use min precision, not native precision.
160160
bool EnableDX9CompatMode = false;
161161
bool EnableFXCCompatMode = false;
162-
bool EnableTemplates = false;
163-
bool EnableOperatorOverloading = false;
164-
bool StrictUDTCasting = false;
165162
bool EnablePayloadAccessQualifiers = false;
166-
bool EnableShortCircuit = false;
167-
bool EnableBitfields = false;
168163
// HLSL Change Ends
169164

170165
bool SPIRV = false; // SPIRV Change

tools/clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -680,14 +680,6 @@ def hlsl_version : Separate<["-", "/"], "HV">, Group<f_Group>, Flags<[DriverOpti
680680
HelpText<"HLSL version (2015, 2016, 2017, 2018, 2021). Default is 2018">; // HLSL Change - mimic the HLSLOptions.td flag
681681
def enable_16bit_types: Flag<["-", "/"], "enable-16bit-types">, Flags<[CoreOption, DriverOption, HelpHidden]>,
682682
HelpText<"Enable 16bit types and disable min precision types.">; // HLSL Change - mimic the HLSLOptions.td flag
683-
def enable_templates: Flag<["-", "/"], "enable-templates">, Flags<[CoreOption, DriverOption, HelpHidden]>,
684-
HelpText<"Enable template support for HLSL.">; // HLSL Change
685-
def enable_operator_overloading: Flag<["-", "/"], "enable-operator-overloading">, Flags<[CoreOption, DriverOption, HelpHidden]>,
686-
HelpText<"Enable operator overloading support for HLSL.">; // HLSL Change
687-
def strict_udt_casting: Flag<["-", "/"], "strict-udt-casting">, Flags<[CoreOption, DriverOption, HelpHidden]>,
688-
HelpText<"Require explicit casts between different structure types with compatible layouts.">; // HLSL Change
689-
def enable_bitfields : Flag<["-", "/"], "enable-bitfields">, Flags<[CoreOption, DriverOption, HelpHidden]>,
690-
HelpText<"Enables bitfields on struct members">; // HLSL Change
691683
def fms_compatibility_version
692684
: Joined<["-"], "fms-compatibility-version=">,
693685
Group<f_Group>,

tools/clang/lib/AST/ExprConstant.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9412,7 +9412,8 @@ static bool EvaluateCPlusPlus11IntegralConstantExpr(const ASTContext &Ctx,
94129412
bool Expr::isIntegerConstantExpr(const ASTContext &Ctx,
94139413
SourceLocation *Loc) const {
94149414
// HLSL Change - if templates are enabled we need to act like C++11 here
9415-
if (Ctx.getLangOpts().CPlusPlus11 || Ctx.getLangOpts().EnableTemplates)
9415+
if (Ctx.getLangOpts().CPlusPlus11 ||
9416+
Ctx.getLangOpts().HLSLVersion >= hlsl::LangStd::v2021)
94169417
return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, nullptr, Loc);
94179418

94189419
ICEDiag D = CheckICE(this, Ctx);
@@ -9426,7 +9427,8 @@ bool Expr::isIntegerConstantExpr(const ASTContext &Ctx,
94269427
bool Expr::isIntegerConstantExpr(llvm::APSInt &Value, const ASTContext &Ctx,
94279428
SourceLocation *Loc, bool isEvaluated) const {
94289429
// HLSL Change - if templates are enabled we need to act like C++11 here
9429-
if (Ctx.getLangOpts().CPlusPlus11 || Ctx.getLangOpts().EnableTemplates)
9430+
if (Ctx.getLangOpts().CPlusPlus11 ||
9431+
Ctx.getLangOpts().HLSLVersion >= hlsl::LangStd::v2021)
94309432
return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value, Loc);
94319433

94329434
if (!isIntegerConstantExpr(Ctx, Loc))

tools/clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3422,7 +3422,8 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) {
34223422
// 0 && RHS: If it is safe, just elide the RHS, and return 0/false.
34233423
if (!CGF.ContainsLabel(E->getRHS())) {
34243424
// HLSL Change Begins.
3425-
if (CGF.getLangOpts().HLSL && !CGF.getLangOpts().EnableShortCircuit) {
3425+
if (CGF.getLangOpts().HLSL &&
3426+
CGF.getLangOpts().HLSLVersion < hlsl::LangStd::v2021) {
34263427
// HLSL does not short circuit by default.
34273428
Visit(E->getRHS());
34283429
}
@@ -3432,7 +3433,8 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) {
34323433
}
34333434

34343435
// HLSL Change Begins.
3435-
if (CGF.getLangOpts().HLSL && !CGF.getLangOpts().EnableShortCircuit) {
3436+
if (CGF.getLangOpts().HLSL &&
3437+
CGF.getLangOpts().HLSLVersion < hlsl::LangStd::v2021) {
34363438
// HLSL does not short circuit by default.
34373439
Value *LHS = Visit(E->getLHS());
34383440
Value *RHS = Visit(E->getRHS());
@@ -3527,7 +3529,8 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) {
35273529
// 1 || RHS: If it is safe, just elide the RHS, and return 1/true.
35283530
if (!CGF.ContainsLabel(E->getRHS())) {
35293531
// HLSL Change Begins.
3530-
if (CGF.getLangOpts().HLSL && !CGF.getLangOpts().EnableShortCircuit) {
3532+
if (CGF.getLangOpts().HLSL &&
3533+
CGF.getLangOpts().HLSLVersion < hlsl::LangStd::v2021) {
35313534
// HLSL does not short circuit by default.
35323535
Visit(E->getRHS());
35333536
}
@@ -3537,7 +3540,8 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) {
35373540
}
35383541

35393542
// HLSL Change Begins.
3540-
if (CGF.getLangOpts().HLSL && !CGF.getLangOpts().EnableShortCircuit) {
3543+
if (CGF.getLangOpts().HLSL &&
3544+
CGF.getLangOpts().HLSLVersion < hlsl::LangStd::v2021) {
35413545
// HLSL does not short circuit by default.
35423546
Value *LHS = Visit(E->getLHS());
35433547
Value *RHS = Visit(E->getRHS());
@@ -3702,7 +3706,8 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
37023706
return tmp5;
37033707
}
37043708
// HLSL Change Starts
3705-
if (CGF.getLangOpts().HLSL && !CGF.getLangOpts().EnableShortCircuit) {
3709+
if (CGF.getLangOpts().HLSL &&
3710+
CGF.getLangOpts().HLSLVersion < hlsl::LangStd::v2021) {
37063711
// HLSL does not short circuit by default before HLSL 2021
37073712
if (hlsl::IsHLSLVecType(E->getType()) || E->getType()->isArithmeticType()) {
37083713
llvm::Value *CondV = CGF.EmitScalarExpr(condExpr);
@@ -3754,7 +3759,8 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
37543759

37553760
// HLSL Change Begins
37563761
llvm::Instruction *ResultAlloca = nullptr;
3757-
if (CGF.getLangOpts().HLSL && CGF.getLangOpts().EnableShortCircuit &&
3762+
if (CGF.getLangOpts().HLSL &&
3763+
CGF.getLangOpts().HLSLVersion >= hlsl::LangStd::v2021 &&
37583764
hlsl::IsHLSLMatType(E->getType())) {
37593765
llvm::Type *MatTy = CGF.ConvertTypeForMem(E->getType());
37603766
ResultAlloca = CGF.CreateTempAlloca(MatTy);

tools/clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,8 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond,
10881088
}
10891089

10901090
// HLSL Change Begins.
1091-
if (getLangOpts().HLSL && !getLangOpts().EnableShortCircuit) {
1091+
if (getLangOpts().HLSL &&
1092+
getLangOpts().HLSLVersion < hlsl::LangStd::v2021) {
10921093
// HLSL does not short circuit by default.
10931094
// Emit the code with the fully general case.
10941095
llvm::Value *CondV;
@@ -1148,7 +1149,8 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond,
11481149
}
11491150

11501151
// HLSL Change Begins.
1151-
if (getLangOpts().HLSL && !getLangOpts().EnableShortCircuit) {
1152+
if (getLangOpts().HLSL &&
1153+
getLangOpts().HLSLVersion < hlsl::LangStd::v2021) {
11521154
// HLSL does not short circuit by default.
11531155
// Emit the code with the fully general case.
11541156
llvm::Value *CondV;

tools/clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,39 +1737,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
17371737
// TODO: should we tie low precision to HLSL2018 only?
17381738
Opts.UseMinPrecision = !Args.hasArg(options::OPT_enable_16bit_types);
17391739

1740-
// If the HLSL version is 2021, allow the 2021 features by default.
1741-
// If the HLSL version is 2016 or 2018, allow them only
1742-
// when the individual option is enabled.
1743-
// If the HLSL version is 2015, dissallow these features
1744-
if (Opts.HLSLVersion >= hlsl::LangStd::v2021) {
1745-
// Enable operator overloading in structs
1746-
Opts.EnableOperatorOverloading = true;
1747-
// Enable template support
1748-
Opts.EnableTemplates = true;
1749-
// Determine overload matching based on UDT names, not just types
1750-
Opts.StrictUDTCasting = true;
1751-
// Experimental option to enable short-circuiting operators
1752-
Opts.EnableShortCircuit = true;
1753-
// Enable bitfield support
1754-
Opts.EnableBitfields = true;
1755-
1756-
} else {
1757-
Opts.EnableOperatorOverloading = Args.hasArg(OPT_enable_operator_overloading);
1758-
Opts.EnableTemplates = Args.hasArg(OPT_enable_templates);
1759-
Opts.StrictUDTCasting = Args.hasArg(OPT_strict_udt_casting);
1760-
Opts.EnableBitfields = Args.hasArg(OPT_enable_bitfields);
1761-
1762-
if (Opts.HLSLVersion <= hlsl::LangStd::v2015) {
1763-
if (Opts.EnableOperatorOverloading)
1764-
Diags.Report(diag::err_hlsl_invalid_drv_for_feature) << "/enable-operator-overloading" << ver;
1765-
if (Opts.EnableTemplates)
1766-
Diags.Report(diag::err_hlsl_invalid_drv_for_feature) << "/enable-templates" << ver;
1767-
if (Opts.StrictUDTCasting)
1768-
Diags.Report(diag::err_hlsl_invalid_drv_for_feature) << "/enable-udt-casting" << ver;
1769-
if (Opts.EnableBitfields)
1770-
Diags.Report(diag::err_hlsl_invalid_drv_for_feature) << "/enable-bitfields" << ver;
1771-
}
1772-
}
17731740
#endif // #ifdef MS_SUPPORT_VARIABLE_LANGOPTS
17741741
}
17751742

tools/clang/lib/Parse/ParseDecl.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,7 +2005,8 @@ Parser::DeclGroupPtrTy Parser::ParseDeclaration(unsigned Context,
20052005
switch (Tok.getKind()) {
20062006
case tok::kw_template:
20072007
// HLSL Change Starts
2008-
if (getLangOpts().HLSL && !getLangOpts().EnableTemplates) {
2008+
if (getLangOpts().HLSL &&
2009+
getLangOpts().HLSLVersion < hlsl::LangStd::v2021) {
20092010
Diag(Tok, diag::err_hlsl_reserved_keyword) << Tok.getName();
20102011
SkipMalformedDecl();
20112012
return DeclGroupPtrTy();
@@ -4169,7 +4170,10 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
41694170

41704171
// C++ typename-specifier:
41714172
case tok::kw_typename:
4172-
if (getLangOpts().HLSL && !getLangOpts().EnableTemplates) { goto HLSLReservedKeyword; } // HLSL Change - reserved for HLSL
4173+
if (getLangOpts().HLSL &&
4174+
getLangOpts().HLSLVersion < hlsl::LangStd::v2021) {
4175+
goto HLSLReservedKeyword;
4176+
} // HLSL Change - reserved for HLSL
41734177
if (TryAnnotateTypeOrScopeToken()) {
41744178
DS.SetTypeSpecError();
41754179
goto DoneWithDeclSpec;

0 commit comments

Comments
 (0)