[NNNN] Add proposal for writing HLSL intrinsics via TableGen#394
[NNNN] Add proposal for writing HLSL intrinsics via TableGen#394
Conversation
Assisted-by: claude-opus-4.6
Assisted-by: claude-opus-4.6
…ust Type Assisted-by: claude-opus-4.6
…criptions of HLSLBuiltin
s-perron
left a comment
There was a problem hiding this comment.
I think this looks pretty good. It seems like it will cover most of the intrinsics, and will reduce the amount of code to review. Thanks for looking into this.
| | `VaryingVecSizes` | `list<int>` | `[]` | Vector sizes to generate (e.g., `[2, 3, 4]`) for Varying-typed arguments. | | ||
| | `VaryingMatDims` | `list<MatDim>` | `[]` | Matrix dimensions to generate (e.g., `AllMatDims`, `[Mat4x4]`) for Varying-typed arguments. | | ||
| | `DetailFunc` | `string` | `""` | When set, generates an inline function that forwards to `__detail::DetailFunc(args...)`. Mutually exclusive with `Builtin` and `Body`. | | ||
| | `Body` | `string` | `""` | When set, generates an inline function with this literal body text. Mutually exclusive with `Builtin` and `DetailFunc`. | |
There was a problem hiding this comment.
Do you think this will be used enough to be worth implementing? I don't have any insight.
There was a problem hiding this comment.
In the prototype implementation, abs, CheckAccessFullyMapped, and NonUniformResourceIndex are currently implemented using Body since they are defined by simple one-line functions.
There are also a couple one-line intrinsic helper functions like d3d_color_to_ubyte4 and ldexp which could be replaced by an inline Body.
I think that is enough usage to warrant keeping Body as an option, though I suppose it would also be fine to remove the option entirely and introduce more one-line helper functions that get called with DetailFunc.
This PR adds a proposal for addressing issue #393 which regards the use of TableGen to define HLSL intrinsics instead of writing multiple overloads by hand and maintaining a header file consisting of thousands of lines of declarations.
This will be especially useful as matrix support is added for more HLSL intrinsics.
The current prototype implementation lives in https://github.com/Icohedron/llvm-project/tree/tablegen-hlsl-intrinsics
Assisted-by: claude-opus-4.6