[clang] [HLSL] Add validation for the -enable-16bit-types option (PR #85340)

Damyan Pepper via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 21 15:01:08 PDT 2024


================
@@ -4258,6 +4258,18 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
       } else {
         llvm_unreachable("expected DXIL or SPIR-V target");
       }
+      // validate that if fnative-half-type is given, that
+      // the language standard is at least hlsl2021, and that
+      // the target shader model is at least 6.2
+      if (Args.getLastArg(OPT_fnative_half_type)) {
+        bool LangStdArgIsValid = Opts.LangStd >= LangStandard::lang_hlsl2021;
+        bool TPArgIsValid = T.getOSVersion() >= VersionTuple(6, 2);
----------------
damyanp wrote:

What does the `TP` prefix mean in this context?

nits on the naming here: neither of these bools really indicate if these arguments are "valid".  The first one is "IsAtLeastHLSL2021" and the second is "IsAtLeastShaderModel62".  It may even be clearer just to inline these into the if condition.

https://github.com/llvm/llvm-project/pull/85340


More information about the cfe-commits mailing list