blob: 2dc35d3a9b172bf106b3c38e4a37a04cfac11eb9 [file] [log] [blame]
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/src/cmd/gen to generate function.h
To update the generated file, run:
./tools/run gen
See:
* tools/src/cmd/gen for structures used by this template
* https://golang.org/pkg/text/template/ for documentation on the template syntax
--------------------------------------------------------------------------------
*/ -}}
#ifndef SRC_TINT_BUILTIN_FUNCTION_H_
#define SRC_TINT_BUILTIN_FUNCTION_H_
#include <string>
#include "src/tint/utils/string_stream.h"
// \cond DO_NOT_DOCUMENT
namespace tint::builtin {
/// Enumerator of all builtin functions
enum class Function {
kNone = -1,
{{- range Sem.Builtins }}
k{{PascalCase .Name}},
{{- end }}
};
/// Matches the Function by name
/// @param name the builtin name to parse
/// @returns the parsed Function, or Function::kNone if `name` did not
/// match any builtin function.
Function ParseFunction(std::string_view name);
/// @returns the name of the builtin function type. The spelling, including
/// case, matches the name in the WGSL spec.
const char* str(Function i);
/// Emits the name of the builtin function type. The spelling, including case,
/// matches the name in the WGSL spec.
utils::StringStream& operator<<(utils::StringStream& out, Function i);
/// All builtin functions
constexpr Function kFunctions[] = {
{{- range Sem.Builtins }}
Function::k{{PascalCase .Name}},
{{- end }}
};
/// All builtin function names
constexpr const char* kFunctionStrings[] = {
{{- range Sem.Builtins }}
"{{.Name}}",
{{- end }}
};
/// Determines if the given `f` is a coarse derivative.
/// @param f the builtin type
/// @returns true if the given derivative is coarse.
bool IsCoarseDerivativeBuiltin(Function f);
/// Determines if the given `f` is a fine derivative.
/// @param f the builtin type
/// @returns true if the given derivative is fine.
bool IsFineDerivativeBuiltin(Function f);
/// Determine if the given `f` is a derivative builtin.
/// @param f the builtin type
/// @returns true if the given `f` is a derivative builtin
bool IsDerivativeBuiltin(Function f);
/// Determines if the given `f` is a texture operation builtin.
/// @param f the builtin type
/// @returns true if the given `f` is a texture operation builtin
bool IsTextureBuiltin(Function f);
/// Determines if the given `f` is an image query builtin.
/// @param f the builtin type
/// @returns true if the given `f` is an image query builtin
bool IsImageQueryBuiltin(Function f);
/// Determines if the given `f` is a data packing builtin.
/// @param f the builtin type
/// @returns true if the given `f` is a data packing builtin
bool IsDataPackingBuiltin(Function f);
/// Determines if the given `f` is a data unpacking builtin.
/// @param f the builtin type
/// @returns true if the given `f` is a data unpacking builtin
bool IsDataUnpackingBuiltin(Function f);
/// Determines if the given `f` is a barrier builtin.
/// @param f the builtin type
/// @returns true if the given `f` is a barrier builtin
bool IsBarrierBuiltin(Function f);
/// Determines if the given `f` is an atomic builtin.
/// @param f the builtin type
/// @returns true if the given `f` is an atomic builtin
bool IsAtomicBuiltin(Function f);
/// Determines if the given `f` is a DP4a builtin.
/// @param f the builtin type
/// @returns true if the given `f` is a DP4a builtin
bool IsDP4aBuiltin(Function f);
/// Determines if the given `f` may have side-effects (i.e. writes to at least one of its inputs)
/// @returns true if intrinsic may have side-effects
bool HasSideEffects(Function f);
} // namespace tint::builtin
// \endcond
#endif // SRC_TINT_BUILTIN_FUNCTION_H_