blob: f02c13f0765402513f24ef378b12b9b32da7f957 [file] [log] [blame]
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/intrinsic-gen to generate intrinsic_type.cc
See:
* tools/cmd/intrinsic-gen/gen for structures used by this template
* https://golang.org/pkg/text/template/ for documentation on the template syntax
--------------------------------------------------------------------------------
*/ -}}
#include "src/sem/intrinsic_type.h"
#include <sstream>
namespace tint {
namespace sem {
IntrinsicType ParseIntrinsicType(const std::string& name) {
{{- range .Sem.Functions }}
if (name == "{{.Name}}") {
return IntrinsicType::k{{Title .Name}};
}
{{- end }}
return IntrinsicType::kNone;
}
const char* str(IntrinsicType i) {
switch (i) {
case IntrinsicType::kNone:
return "<none>";
{{- range .Sem.Functions }}
case IntrinsicType::k{{Title .Name}}:
return "{{.Name}}";
{{- end }}
}
return "<unknown>";
}
std::ostream& operator<<(std::ostream& out, IntrinsicType i) {
out << str(i);
return out;
}
} // namespace sem
} // namespace tint