tint: Add operator support to intrinsic-gen

Adapt the builtin parsing and resolving to also support operators.
Will be used to generate intrinsic table entries for operators.

This will simplify maintenance of the operators, and will greatly
simplify the [AbstractInt -> i32|u32] [AbstractFloat -> f32|f16] logic.

Bug: tint:1504
Change-Id: Id75735ea24e501877418812185796f3fba88a521
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89026
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2022-05-09 18:08:23 +00:00
committed by Dawn LUCI CQ
parent d84daed72c
commit e6e96def66
18 changed files with 783 additions and 347 deletions

View File

@@ -9,15 +9,15 @@ See:
--------------------------------------------------------------------------------
*/ -}}
{{- /* For each permutation of each overload of each function... */ -}}
{{- range .Sem.Functions -}}
{{- /* For each permutation of each overload of each builtin... */ -}}
{{- range .Sem.Builtins -}}
{{- /* TODO(crbug.com/tint/1483): Remove the bodge below after smoothStep is removed from builtins.def */}}
{{- if not (eq .Name "smoothStep") }}
{{- range .Overloads -}}
{{- range Permute . -}}
{{- /* Generate a ./gen/<function>/<permuataion-hash>.wgsl file using
the Permutation macro defined below */ -}}
{{- $file := printf "./gen/%v/%v.wgsl" .Function.Name .Hash -}}
{{- $file := printf "./gen/%v/%v.wgsl" .Intrinsic.Name .Hash -}}
{{- $content := Eval "Permutation" . -}}
{{- WriteFile $file $content -}}
{{- end }}
@@ -30,8 +30,8 @@ See:
{{- define "Permutation" -}}
{{- /* Emits the body of the intrinsic permuation .wgsl file */ -}}
{{- /* ------------------------------------------------------------------ */ -}}
{{- $function := .Function.Name -}}
{{- $permutation := printf "%v_%v" $function .Hash -}}
{{- $builtin := .Intrinsic.Name -}}
{{- $permutation := printf "%v_%v" $builtin .Hash -}}
{{- $args := Map -}}
{{- /* Generate RW storage buffer parameters */ -}}
@@ -125,7 +125,7 @@ fn {{$permutation}}() {
{{- if .ReturnType -}}
var res{{if IsDeclarable .ReturnType}}: {{template "Type" .ReturnType}}{{end}} = {{/* preserve space after = */ -}}
{{- end -}}
{{$function}}(
{{$builtin}}(
{{- range $i, $p := .Parameters -}}
{{- if $i -}}, {{end}}{{$args.Get $i -}}
{{- end -}}