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

@@ -15,7 +15,7 @@ See:
namespace tint::sem {
BuiltinType ParseBuiltinType(const std::string& name) {
{{- range .Sem.Functions }}
{{- range .Sem.Builtins }}
if (name == "{{.Name}}") {
return BuiltinType::k{{Title .Name}};
}
@@ -27,7 +27,7 @@ const char* str(BuiltinType i) {
switch (i) {
case BuiltinType::kNone:
return "<none>";
{{- range .Sem.Functions }}
{{- range .Sem.Builtins }}
case BuiltinType::k{{Title .Name}}:
return "{{.Name}}";
{{- end }}

View File

@@ -19,7 +19,7 @@ namespace tint::sem {
/// Enumerator of all builtin functions
enum class BuiltinType {
kNone = -1,
{{- range .Sem.Functions }}
{{- range .Sem.Builtins }}
k{{Title .Name}},
{{- end }}
};