Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[naga] Builtin function database, for automatic conversions #6833

Draft
wants to merge 7 commits into
base: trunk
Choose a base branch
from

Conversation

jimblandy
Copy link
Member

@jimblandy jimblandy commented Dec 27, 2024

@jimblandy
Copy link
Member Author

Rebased on #7344.

@jimblandy jimblandy force-pushed the naga-function-database branch from 4b0303d to 0218277 Compare March 15, 2025 21:03
@jimblandy jimblandy force-pushed the naga-function-database branch 6 times, most recently from 8c4fb22 to 7e8e60c Compare March 18, 2025 23:57
Add a `special_types` field to `naga::proc::GlobalCtx`, since the
special types table is reasonable to see as part of a module's global
context, and it is needed to construct result types for calls to
`MathFunction::Frexp` and `MathFunction::Modf`.
Make the associated function `TypeInner::automatically_converts_to`
available outside the WGSL front end by moving it into the
`proc::type_methods` module.
@jimblandy jimblandy force-pushed the naga-function-database branch 2 times, most recently from 0e3a549 to c64be95 Compare March 21, 2025 00:02
Add a new module, `naga::common::predeclared`, which implements a new
`struct_name` method on `naga::ir::PredeclaredType`, to produce the
name of the struct type corresponding to that `PredeclaredType` value.
Use this new method in `naga::front::type_gen`.
In the implementation of `TryToWgsl` for `Scalar`, order types within
each representation from smallest to largest. This is just a cleanup;
the change has no effect on behavior.
@jimblandy jimblandy force-pushed the naga-function-database branch 2 times, most recently from 6113f82 to a7b5a89 Compare March 21, 2025 21:31
Define a new trait, `proc::builtins::OverloadSet`, for types that
represent a Naga IR builtin function's set of overloads. The
`OverloadSet` trait includes operations needed to validate calls,
choose automatic type conversions, and generate diagnostics.

Add a new function, `ir::MathFunction::overloads`, which returns the
given `MathFunction`'s set of overloads as an `impl OverloadSet`
value. Use this in the WGSL front end, the validator, and the
typifier.

To support `MathFunction::overloads`, provide several implementations
of `OverloadSet`, some that are very flexible but verbose, and others
that are concise but more restrictive.
@jimblandy jimblandy force-pushed the naga-function-database branch from a7b5a89 to da9c925 Compare March 21, 2025 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant