tint: intrinsics.def Support [[precedence]] decoration

Add support for a [[precedence(N)]] decoration on intrinsic table type
declarations. This will be used to ensure the type with the lowest
conversion rank is matched when a matcher could match multiple types
for a given abstract numeric argument type.

Bug: tint:1504
Change-Id: I96475b000c0917bbfa4e2873b1731ce048b96a7d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90664
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton
2022-05-18 18:56:58 +00:00
committed by Dawn LUCI CQ
parent aed7eb4b4c
commit c670018aea
7 changed files with 311 additions and 275 deletions

View File

@@ -62,13 +62,18 @@ enum texel_format {
////////////////////////////////////////////////////////////////////////////////
// WGSL primitive types //
// Types may be decorated with [[precedence(N)]] to prioritize which type //
// will be picked when multiple types of a matcher match. //
// This is used to ensure that abstract numerical types materialize to the //
// concrete type with the lowest conversion rank. //
// Types with higher the precedence values will be matched first. //
////////////////////////////////////////////////////////////////////////////////
// https://gpuweb.github.io/gpuweb/wgsl/#plain-types-section
type bool
type f32
type i32
type u32
[[precedence(2)]] type i32
[[precedence(1)]] type u32
[[precedence(0)]] type f32
type vec2<T>
type vec3<T>
type vec4<T>

File diff suppressed because it is too large Load Diff

View File

@@ -248,7 +248,7 @@ class {{$class}} : public TypeMatcher {
};
const sem::Type* {{$class}}::Match(MatchState& state, const sem::Type* ty) const {
{{- range .Types }}
{{- range .PrecedenceSortedTypes }}
if (match_{{.Name}}(ty)) {
return build_{{.Name}}(state);
}