Sema type-checks a parsed translation unit: an interned type table, scopes
and symbols, declarations, statements and expressions, implicit and explicit
conversions, user-function overload resolution, and intrinsic / builtin
method matching driven by dxc's gen_intrin_main.txt (vendored, turned into a
Zig table at build time by tools/gen_intrinsics.zig).
Rules ported from dxc where it matters for exact agreement:
- operator result types (CombineBasicTypes, shift and bool rules)
- literal suffix types and diagnostics, including `1.#INF`
- declaration modifier validity and conflicts (DiagnoseHLSLDecl) and
row_major / column_major checks, using source-ordered qualifier words
- constant folding of asuint / max / min
- `_Static_assert`, `__decltype` and `std::is_same` builtins
(`static_assert` is an ordinary identifier in HLSL 2021)
Templates, operator overloading and bitfields report "not supported yet
(planned for milestone 0.2)".
Oracles:
- zig build oracle-sema: no false errors on the 1604 dxc-valid corpus
files (1537 clean, 67 need milestone 0.2 features)
- zig build oracle-verify: error-line agreement with dxc's SemaHLSL
-verify tests under HLSL 2021 (53% of expected error lines caught,
80 false error lines)
Also fixes the provenance commit of gen_intrin_main.txt (55a61aa79).
zdxc now accepts dxc's command line as-is, so it can replace dxc in build
scripts.
- vendor/dxc/HLSLOptions.td (dxc's option definitions) is turned into a
Zig table at build time by tools/gen_options.zig (no tablegen/Python).
- src/options.zig parses with LLVM OptTable's rules, as dxc does: `-`,
`/` and `--` prefixes; flags, joined, separate, joined-or-separate,
multi-arg and comma-joined options; longest spelling first; aliases;
case-sensitive; `/`-prefixed non-options are input paths; the last input
wins. `-T cs_6_0`, `/T cs_6_0` and `-Tcs_6_0` are all accepted.
- Every dxc option has a support level:
- implemented (-T -E -Fo -D -I -P -Fi -HV -spirv -enable-16bit-types
-WX -no-warnings -W[no-]x -fdiagnostics-format= -ferror-limit=
-fdiagnostics-color[=] -O0..3 -Od -Vd -help --version -nologo ...),
- accepted with a one-line note, no effect yet (-Zpr, -Gis, -Qstrip_*,
-Fh, -fvk-*, -fspv-target-env=, ... ),
- rejected with a reason: dropped features (-Zi/-Fd debug info,
-Fc/-dumpbin disassembly, -recompile, -link, -verify, -ast-dump, LLVM
internals) or "not supported by zdxc yet".
- Errors match dxc's: "unknown argument: '-x'", "argument to '-T' is
missing"; exit codes 1 (command line / I/O) and 5 (compile errors).
- -help lists dxc's groups and help text for what zdxc accepts.
- zdxc-only options (-zdxc-*, -f[no-]color-diagnostics) use names dxc
does not define.
- `zig build oracle-cli`: all 5873 `RUN: %dxc` command lines in the DXC
test corpus parse; 3392 are accepted and 2481 rejected only for
deliberately unsupported features, with 0 unknown/missing arguments.