Move type base classes into type/ folder.
This CL moves sem/type and copies sem/node into the type/ folder. The
type subclasses are moved over to using type::Type while remaining in
the sem:: namespace. They will be moved over in followup CLs.
Bug: tint:1718
Change-Id: I3f3495328d734f88e4fc2dfbc6705343f1198dc5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113180
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc
index 4b33064..c5cd274 100644
--- a/src/tint/resolver/builtin_test.cc
+++ b/src/tint/resolver/builtin_test.cc
@@ -34,8 +34,8 @@
#include "src/tint/sem/member_accessor_expression.h"
#include "src/tint/sem/sampled_texture.h"
#include "src/tint/sem/statement.h"
-#include "src/tint/sem/test_helper.h"
#include "src/tint/sem/variable.h"
+#include "src/tint/type/test_helper.h"
using ::testing::ElementsAre;
using ::testing::HasSubstr;
diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc
index cd2dec4..14841fe 100644
--- a/src/tint/resolver/const_eval.cc
+++ b/src/tint/resolver/const_eval.cc
@@ -147,14 +147,14 @@
}
/// ZeroTypeDispatch is a helper for calling the function `f`, passing a single zero-value argument
-/// of the C++ type that corresponds to the sem::Type `type`. For example, calling
+/// of the C++ type that corresponds to the type::Type `type`. For example, calling
/// `ZeroTypeDispatch()` with a type of `sem::I32*` will call the function f with a single argument
/// of `i32(0)`.
/// @returns the value returned by calling `f`.
/// @note `type` must be a scalar or abstract numeric type. Other types will not call `f`, and will
/// return the zero-initialized value of the return type for `f`.
template <typename F>
-auto ZeroTypeDispatch(const sem::Type* type, F&& f) {
+auto ZeroTypeDispatch(const type::Type* type, F&& f) {
return Switch(
type, //
[&](const sem::AbstractInt*) { return f(AInt(0)); }, //
@@ -250,7 +250,7 @@
/// Convert attempts to convert the constant value to the given type. On error, Convert()
/// creates a new diagnostic message and returns a Failure.
virtual utils::Result<const ImplConstant*> Convert(ProgramBuilder& builder,
- const sem::Type* target_ty,
+ const type::Type* target_ty,
const Source& source) const = 0;
};
@@ -259,7 +259,7 @@
// Forward declaration
const ImplConstant* CreateComposite(ProgramBuilder& builder,
- const sem::Type* type,
+ const type::Type* type,
utils::VectorRef<const sem::Constant*> elements);
/// Element holds a single scalar or abstract-numeric value.
@@ -269,13 +269,13 @@
static_assert(!std::is_same_v<UnwrapNumber<T>, T> || std::is_same_v<T, bool>,
"T must be a Number or bool");
- Element(const sem::Type* t, T v) : type(t), value(v) {
+ Element(const type::Type* t, T v) : type(t), value(v) {
if constexpr (IsFloatingPoint<T>) {
TINT_ASSERT(Resolver, std::isfinite(v.value));
}
}
~Element() override = default;
- const sem::Type* Type() const override { return type; }
+ const type::Type* Type() const override { return type; }
std::variant<std::monostate, AInt, AFloat> Value() const override {
if constexpr (IsFloatingPoint<UnwrapNumber<T>>) {
return static_cast<AFloat>(value);
@@ -290,7 +290,7 @@
size_t Hash() const override { return utils::Hash(type, ValueOf(value)); }
ImplResult Convert(ProgramBuilder& builder,
- const sem::Type* target_ty,
+ const type::Type* target_ty,
const Source& source) const override {
TINT_BEGIN_DISABLE_WARNING(UNREACHABLE_CODE);
if (target_ty == type) {
@@ -345,7 +345,7 @@
TINT_END_DISABLE_WARNING(UNREACHABLE_CODE);
}
- sem::Type const* const type;
+ type::Type const* const type;
const T value;
};
@@ -354,9 +354,9 @@
/// identical. Splat may be of a vector, matrix or array type.
/// Splat implements the Constant interface.
struct Splat : ImplConstant {
- Splat(const sem::Type* t, const sem::Constant* e, size_t n) : type(t), el(e), count(n) {}
+ Splat(const type::Type* t, const sem::Constant* e, size_t n) : type(t), el(e), count(n) {}
~Splat() override = default;
- const sem::Type* Type() const override { return type; }
+ const type::Type* Type() const override { return type; }
std::variant<std::monostate, AInt, AFloat> Value() const override { return {}; }
const sem::Constant* Index(size_t i) const override { return i < count ? el : nullptr; }
bool AllZero() const override { return el->AllZero(); }
@@ -365,13 +365,13 @@
size_t Hash() const override { return utils::Hash(type, el->Hash(), count); }
ImplResult Convert(ProgramBuilder& builder,
- const sem::Type* target_ty,
+ const type::Type* target_ty,
const Source& source) const override {
// Convert the single splatted element type.
// Note: This file is the only place where `sem::Constant`s are created, so this static_cast
// is safe.
auto conv_el = static_cast<const ImplConstant*>(el)->Convert(
- builder, sem::Type::ElementOf(target_ty), source);
+ builder, type::Type::ElementOf(target_ty), source);
if (!conv_el) {
return utils::Failure;
}
@@ -381,7 +381,7 @@
return builder.create<Splat>(target_ty, conv_el.Get(), count);
}
- sem::Type const* const type;
+ type::Type const* const type;
const sem::Constant* el;
const size_t count;
};
@@ -392,13 +392,13 @@
/// implementation. Use CreateComposite() to create the appropriate Constant type.
/// Composite implements the Constant interface.
struct Composite : ImplConstant {
- Composite(const sem::Type* t,
+ Composite(const type::Type* t,
utils::VectorRef<const sem::Constant*> els,
bool all_0,
bool any_0)
: type(t), elements(std::move(els)), all_zero(all_0), any_zero(any_0), hash(CalcHash()) {}
~Composite() override = default;
- const sem::Type* Type() const override { return type; }
+ const type::Type* Type() const override { return type; }
std::variant<std::monostate, AInt, AFloat> Value() const override { return {}; }
const sem::Constant* Index(size_t i) const override {
return i < elements.Length() ? elements[i] : nullptr;
@@ -409,12 +409,12 @@
size_t Hash() const override { return hash; }
ImplResult Convert(ProgramBuilder& builder,
- const sem::Type* target_ty,
+ const type::Type* target_ty,
const Source& source) const override {
// Convert each of the composite element types.
utils::Vector<const sem::Constant*, 4> conv_els;
conv_els.Reserve(elements.Length());
- std::function<const sem::Type*(size_t idx)> target_el_ty;
+ std::function<const type::Type*(size_t idx)> target_el_ty;
if (auto* str = target_ty->As<sem::Struct>()) {
if (str->Members().Length() != elements.Length()) {
TINT_ICE(Resolver, builder.Diagnostics())
@@ -423,7 +423,7 @@
}
target_el_ty = [str](size_t idx) { return str->Members()[idx]->Type(); };
} else {
- auto* el_ty = sem::Type::ElementOf(target_ty);
+ auto* el_ty = type::Type::ElementOf(target_ty);
target_el_ty = [el_ty](size_t) { return el_ty; };
}
@@ -451,7 +451,7 @@
return h;
}
- sem::Type const* const type;
+ type::Type const* const type;
const utils::Vector<const sem::Constant*, 8> elements;
const bool all_zero;
const bool any_zero;
@@ -460,7 +460,7 @@
/// CreateElement constructs and returns an Element<T>.
template <typename T>
-ImplResult CreateElement(ProgramBuilder& builder, const Source& source, const sem::Type* t, T v) {
+ImplResult CreateElement(ProgramBuilder& builder, const Source& source, const type::Type* t, T v) {
TINT_ASSERT(Resolver, t->is_scalar());
if constexpr (IsFloatingPoint<T>) {
@@ -474,7 +474,7 @@
}
/// ZeroValue returns a Constant for the zero-value of the type `type`.
-const ImplConstant* ZeroValue(ProgramBuilder& builder, const sem::Type* type) {
+const ImplConstant* ZeroValue(ProgramBuilder& builder, const type::Type* type) {
return Switch(
type, //
[&](const sem::Vector* v) -> const ImplConstant* {
@@ -494,7 +494,7 @@
return nullptr;
},
[&](const sem::Struct* s) -> const ImplConstant* {
- utils::Hashmap<const sem::Type*, const ImplConstant*, 8> zero_by_type;
+ utils::Hashmap<const type::Type*, const ImplConstant*, 8> zero_by_type;
utils::Vector<const sem::Constant*, 4> zeros;
zeros.Reserve(s->Members().Length());
for (auto* member : s->Members()) {
@@ -565,7 +565,7 @@
/// CreateComposite examines the element values and will return either a Composite or a Splat,
/// depending on the element types and values.
const ImplConstant* CreateComposite(ProgramBuilder& builder,
- const sem::Type* type,
+ const type::Type* type,
utils::VectorRef<const sem::Constant*> elements) {
if (elements.IsEmpty()) {
return nullptr;
@@ -601,13 +601,13 @@
/// Implementation of TransformElements
template <typename F, typename... CONSTANTS>
ImplResult TransformElements(ProgramBuilder& builder,
- const sem::Type* composite_ty,
+ const type::Type* composite_ty,
F&& f,
size_t index,
CONSTANTS&&... cs) {
uint32_t n = 0;
auto* ty = First(cs...)->Type();
- auto* el_ty = sem::Type::ElementOf(ty, &n);
+ auto* el_ty = type::Type::ElementOf(ty, &n);
if (el_ty == ty) {
constexpr bool kHasIndexParam = traits::IsType<size_t, traits::LastParameterType<F>>;
if constexpr (kHasIndexParam) {
@@ -619,7 +619,7 @@
utils::Vector<const sem::Constant*, 8> els;
els.Reserve(n);
for (uint32_t i = 0; i < n; i++) {
- if (auto el = detail::TransformElements(builder, sem::Type::ElementOf(composite_ty),
+ if (auto el = detail::TransformElements(builder, type::Type::ElementOf(composite_ty),
std::forward<F>(f), index + i, cs->Index(i)...)) {
els.Push(el.Get());
@@ -638,7 +638,7 @@
/// the most deeply nested aggregate type will be passed in.
template <typename F, typename... CONSTANTS>
ImplResult TransformElements(ProgramBuilder& builder,
- const sem::Type* composite_ty,
+ const type::Type* composite_ty,
F&& f,
CONSTANTS&&... cs) {
return detail::TransformElements(builder, composite_ty, f, 0, cs...);
@@ -650,14 +650,14 @@
/// vector-scalar, scalar-vector.
template <typename F>
ImplResult TransformBinaryElements(ProgramBuilder& builder,
- const sem::Type* composite_ty,
+ const type::Type* composite_ty,
F&& f,
const sem::Constant* c0,
const sem::Constant* c1) {
uint32_t n0 = 0;
- sem::Type::ElementOf(c0->Type(), &n0);
+ type::Type::ElementOf(c0->Type(), &n0);
uint32_t n1 = 0;
- sem::Type::ElementOf(c1->Type(), &n1);
+ type::Type::ElementOf(c1->Type(), &n1);
uint32_t max_n = std::max(n0, n1);
// If arity of both constants is 1, invoke callback
if (max_n == 1u) {
@@ -673,7 +673,7 @@
}
return c->Index(i);
};
- if (auto el = TransformBinaryElements(builder, sem::Type::ElementOf(composite_ty),
+ if (auto el = TransformBinaryElements(builder, type::Type::ElementOf(composite_ty),
std::forward<F>(f), nested_or_self(c0, n0),
nested_or_self(c1, n1))) {
els.Push(el.Get());
@@ -1082,7 +1082,7 @@
return NumberT{std::sqrt(v)};
}
-auto ConstEval::SqrtFunc(const Source& source, const sem::Type* elem_ty) {
+auto ConstEval::SqrtFunc(const Source& source, const type::Type* elem_ty) {
return [=](auto v) -> ImplResult {
if (auto r = Sqrt(source, v)) {
return CreateElement(builder, source, elem_ty, r.Get());
@@ -1096,7 +1096,7 @@
return NumberT{std::min(std::max(e, low), high)};
}
-auto ConstEval::ClampFunc(const Source& source, const sem::Type* elem_ty) {
+auto ConstEval::ClampFunc(const Source& source, const type::Type* elem_ty) {
return [=](auto e, auto low, auto high) -> ImplResult {
if (auto r = Clamp(source, e, low, high)) {
return CreateElement(builder, source, elem_ty, r.Get());
@@ -1105,7 +1105,7 @@
};
}
-auto ConstEval::AddFunc(const Source& source, const sem::Type* elem_ty) {
+auto ConstEval::AddFunc(const Source& source, const type::Type* elem_ty) {
return [=](auto a1, auto a2) -> ImplResult {
if (auto r = Add(source, a1, a2)) {
return CreateElement(builder, source, elem_ty, r.Get());
@@ -1114,7 +1114,7 @@
};
}
-auto ConstEval::SubFunc(const Source& source, const sem::Type* elem_ty) {
+auto ConstEval::SubFunc(const Source& source, const type::Type* elem_ty) {
return [=](auto a1, auto a2) -> ImplResult {
if (auto r = Sub(source, a1, a2)) {
return CreateElement(builder, source, elem_ty, r.Get());
@@ -1123,7 +1123,7 @@
};
}
-auto ConstEval::MulFunc(const Source& source, const sem::Type* elem_ty) {
+auto ConstEval::MulFunc(const Source& source, const type::Type* elem_ty) {
return [=](auto a1, auto a2) -> ImplResult {
if (auto r = Mul(source, a1, a2)) {
return CreateElement(builder, source, elem_ty, r.Get());
@@ -1132,7 +1132,7 @@
};
}
-auto ConstEval::DivFunc(const Source& source, const sem::Type* elem_ty) {
+auto ConstEval::DivFunc(const Source& source, const type::Type* elem_ty) {
return [=](auto a1, auto a2) -> ImplResult {
if (auto r = Div(source, a1, a2)) {
return CreateElement(builder, source, elem_ty, r.Get());
@@ -1141,7 +1141,7 @@
};
}
-auto ConstEval::ModFunc(const Source& source, const sem::Type* elem_ty) {
+auto ConstEval::ModFunc(const Source& source, const type::Type* elem_ty) {
return [=](auto a1, auto a2) -> ImplResult {
if (auto r = Mod(source, a1, a2)) {
return CreateElement(builder, source, elem_ty, r.Get());
@@ -1150,7 +1150,7 @@
};
}
-auto ConstEval::Dot2Func(const Source& source, const sem::Type* elem_ty) {
+auto ConstEval::Dot2Func(const Source& source, const type::Type* elem_ty) {
return [=](auto a1, auto a2, auto b1, auto b2) -> ImplResult {
if (auto r = Dot2(source, a1, a2, b1, b2)) {
return CreateElement(builder, source, elem_ty, r.Get());
@@ -1159,7 +1159,7 @@
};
}
-auto ConstEval::Dot3Func(const Source& source, const sem::Type* elem_ty) {
+auto ConstEval::Dot3Func(const Source& source, const type::Type* elem_ty) {
return [=](auto a1, auto a2, auto a3, auto b1, auto b2, auto b3) -> ImplResult {
if (auto r = Dot3(source, a1, a2, a3, b1, b2, b3)) {
return CreateElement(builder, source, elem_ty, r.Get());
@@ -1168,7 +1168,7 @@
};
}
-auto ConstEval::Dot4Func(const Source& source, const sem::Type* elem_ty) {
+auto ConstEval::Dot4Func(const Source& source, const type::Type* elem_ty) {
return
[=](auto a1, auto a2, auto a3, auto a4, auto b1, auto b2, auto b3, auto b4) -> ImplResult {
if (auto r = Dot4(source, a1, a2, a3, a4, b1, b2, b3, b4)) {
@@ -1206,7 +1206,7 @@
}
ConstEval::Result ConstEval::Length(const Source& source,
- const sem::Type* ty,
+ const type::Type* ty,
const sem::Constant* c0) {
auto* vec_ty = c0->Type()->As<sem::Vector>();
// Evaluates to the absolute value of e if T is scalar.
@@ -1227,7 +1227,7 @@
}
ConstEval::Result ConstEval::Mul(const Source& source,
- const sem::Type* ty,
+ const type::Type* ty,
const sem::Constant* v1,
const sem::Constant* v2) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
@@ -1237,7 +1237,7 @@
}
ConstEval::Result ConstEval::Sub(const Source& source,
- const sem::Type* ty,
+ const type::Type* ty,
const sem::Constant* v1,
const sem::Constant* v2) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
@@ -1246,7 +1246,7 @@
return TransformBinaryElements(builder, ty, transform, v1, v2);
}
-auto ConstEval::Det2Func(const Source& source, const sem::Type* elem_ty) {
+auto ConstEval::Det2Func(const Source& source, const type::Type* elem_ty) {
return [=](auto a, auto b, auto c, auto d) -> ImplResult {
if (auto r = Det2(source, a, b, c, d)) {
return CreateElement(builder, source, elem_ty, r.Get());
@@ -1255,7 +1255,7 @@
};
}
-auto ConstEval::Det3Func(const Source& source, const sem::Type* elem_ty) {
+auto ConstEval::Det3Func(const Source& source, const type::Type* elem_ty) {
return
[=](auto a, auto b, auto c, auto d, auto e, auto f, auto g, auto h, auto i) -> ImplResult {
if (auto r = Det3(source, a, b, c, d, e, f, g, h, i)) {
@@ -1265,7 +1265,7 @@
};
}
-auto ConstEval::Det4Func(const Source& source, const sem::Type* elem_ty) {
+auto ConstEval::Det4Func(const Source& source, const type::Type* elem_ty) {
return [=](auto a, auto b, auto c, auto d, auto e, auto f, auto g, auto h, auto i, auto j,
auto k, auto l, auto m, auto n, auto o, auto p) -> ImplResult {
if (auto r = Det4(source, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)) {
@@ -1275,7 +1275,7 @@
};
}
-ConstEval::Result ConstEval::Literal(const sem::Type* ty, const ast::LiteralExpression* literal) {
+ConstEval::Result ConstEval::Literal(const type::Type* ty, const ast::LiteralExpression* literal) {
auto& source = literal->source;
return Switch(
literal,
@@ -1306,7 +1306,7 @@
});
}
-ConstEval::Result ConstEval::ArrayOrStructInit(const sem::Type* ty,
+ConstEval::Result ConstEval::ArrayOrStructInit(const type::Type* ty,
utils::VectorRef<const sem::Expression*> args) {
if (args.IsEmpty()) {
return ZeroValue(builder, ty);
@@ -1326,11 +1326,11 @@
return CreateComposite(builder, ty, std::move(els));
}
-ConstEval::Result ConstEval::Conv(const sem::Type* ty,
+ConstEval::Result ConstEval::Conv(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
uint32_t el_count = 0;
- auto* el_ty = sem::Type::ElementOf(ty, &el_count);
+ auto* el_ty = type::Type::ElementOf(ty, &el_count);
if (!el_ty) {
return nullptr;
}
@@ -1342,19 +1342,19 @@
return Convert(ty, args[0], source);
}
-ConstEval::Result ConstEval::Zero(const sem::Type* ty,
+ConstEval::Result ConstEval::Zero(const type::Type* ty,
utils::VectorRef<const sem::Constant*>,
const Source&) {
return ZeroValue(builder, ty);
}
-ConstEval::Result ConstEval::Identity(const sem::Type*,
+ConstEval::Result ConstEval::Identity(const type::Type*,
utils::VectorRef<const sem::Constant*> args,
const Source&) {
return args[0];
}
-ConstEval::Result ConstEval::VecSplat(const sem::Type* ty,
+ConstEval::Result ConstEval::VecSplat(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source&) {
if (auto* arg = args[0]) {
@@ -1363,13 +1363,13 @@
return nullptr;
}
-ConstEval::Result ConstEval::VecInitS(const sem::Type* ty,
+ConstEval::Result ConstEval::VecInitS(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source&) {
return CreateComposite(builder, ty, args);
}
-ConstEval::Result ConstEval::VecInitM(const sem::Type* ty,
+ConstEval::Result ConstEval::VecInitM(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source&) {
utils::Vector<const sem::Constant*, 4> els;
@@ -1395,7 +1395,7 @@
return CreateComposite(builder, ty, std::move(els));
}
-ConstEval::Result ConstEval::MatInitS(const sem::Type* ty,
+ConstEval::Result ConstEval::MatInitS(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source&) {
auto* m = static_cast<const sem::Matrix*>(ty);
@@ -1412,7 +1412,7 @@
return CreateComposite(builder, ty, std::move(els));
}
-ConstEval::Result ConstEval::MatInitV(const sem::Type* ty,
+ConstEval::Result ConstEval::MatInitV(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source&) {
return CreateComposite(builder, ty, args);
@@ -1426,7 +1426,7 @@
}
uint32_t el_count = 0;
- sem::Type::ElementOf(obj_expr->Type()->UnwrapRef(), &el_count);
+ type::Type::ElementOf(obj_expr->Type()->UnwrapRef(), &el_count);
AInt idx = idx_val->As<AInt>();
if (idx < 0 || (el_count > 0 && idx >= el_count)) {
@@ -1456,7 +1456,7 @@
return obj_val->Index(static_cast<size_t>(member->Index()));
}
-ConstEval::Result ConstEval::Swizzle(const sem::Type* ty,
+ConstEval::Result ConstEval::Swizzle(const type::Type* ty,
const sem::Expression* vec_expr,
utils::VectorRef<uint32_t> indices) {
auto* vec_val = vec_expr->ConstantValue();
@@ -1471,12 +1471,12 @@
return CreateComposite(builder, ty, std::move(values));
}
-ConstEval::Result ConstEval::Bitcast(const sem::Type*, const sem::Expression*) {
+ConstEval::Result ConstEval::Bitcast(const type::Type*, const sem::Expression*) {
// TODO(crbug.com/tint/1581): Implement @const intrinsics
return nullptr;
}
-ConstEval::Result ConstEval::OpComplement(const sem::Type* ty,
+ConstEval::Result ConstEval::OpComplement(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c) {
@@ -1488,7 +1488,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::OpUnaryMinus(const sem::Type* ty,
+ConstEval::Result ConstEval::OpUnaryMinus(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c) {
@@ -1513,7 +1513,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::OpNot(const sem::Type* ty,
+ConstEval::Result ConstEval::OpNot(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c) {
@@ -1525,7 +1525,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::OpPlus(const sem::Type* ty,
+ConstEval::Result ConstEval::OpPlus(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
@@ -1535,19 +1535,19 @@
return TransformBinaryElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpMinus(const sem::Type* ty,
+ConstEval::Result ConstEval::OpMinus(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
return Sub(source, ty, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpMultiply(const sem::Type* ty,
+ConstEval::Result ConstEval::OpMultiply(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
return Mul(source, ty, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpMultiplyMatVec(const sem::Type* ty,
+ConstEval::Result ConstEval::OpMultiplyMatVec(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto* mat_ty = args[0]->Type()->As<sem::Matrix>();
@@ -1597,7 +1597,7 @@
}
return CreateComposite(builder, ty, result);
}
-ConstEval::Result ConstEval::OpMultiplyVecMat(const sem::Type* ty,
+ConstEval::Result ConstEval::OpMultiplyVecMat(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto* vec_ty = args[0]->Type()->As<sem::Vector>();
@@ -1648,7 +1648,7 @@
return CreateComposite(builder, ty, result);
}
-ConstEval::Result ConstEval::OpMultiplyMatMat(const sem::Type* ty,
+ConstEval::Result ConstEval::OpMultiplyMatMat(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto* mat1 = args[0];
@@ -1712,7 +1712,7 @@
return CreateComposite(builder, ty, result_mat);
}
-ConstEval::Result ConstEval::OpDivide(const sem::Type* ty,
+ConstEval::Result ConstEval::OpDivide(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
@@ -1722,7 +1722,7 @@
return TransformBinaryElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpModulo(const sem::Type* ty,
+ConstEval::Result ConstEval::OpModulo(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
@@ -1732,12 +1732,12 @@
return TransformBinaryElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpEqual(const sem::Type* ty,
+ConstEval::Result ConstEval::OpEqual(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
auto create = [&](auto i, auto j) -> ImplResult {
- return CreateElement(builder, source, sem::Type::DeepestElementOf(ty), i == j);
+ return CreateElement(builder, source, type::Type::DeepestElementOf(ty), i == j);
};
return Dispatch_fia_fiu32_f16_bool(create, c0, c1);
};
@@ -1745,12 +1745,12 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpNotEqual(const sem::Type* ty,
+ConstEval::Result ConstEval::OpNotEqual(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
auto create = [&](auto i, auto j) -> ImplResult {
- return CreateElement(builder, source, sem::Type::DeepestElementOf(ty), i != j);
+ return CreateElement(builder, source, type::Type::DeepestElementOf(ty), i != j);
};
return Dispatch_fia_fiu32_f16_bool(create, c0, c1);
};
@@ -1758,12 +1758,12 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpLessThan(const sem::Type* ty,
+ConstEval::Result ConstEval::OpLessThan(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
auto create = [&](auto i, auto j) -> ImplResult {
- return CreateElement(builder, source, sem::Type::DeepestElementOf(ty), i < j);
+ return CreateElement(builder, source, type::Type::DeepestElementOf(ty), i < j);
};
return Dispatch_fia_fiu32_f16(create, c0, c1);
};
@@ -1771,12 +1771,12 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpGreaterThan(const sem::Type* ty,
+ConstEval::Result ConstEval::OpGreaterThan(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
auto create = [&](auto i, auto j) -> ImplResult {
- return CreateElement(builder, source, sem::Type::DeepestElementOf(ty), i > j);
+ return CreateElement(builder, source, type::Type::DeepestElementOf(ty), i > j);
};
return Dispatch_fia_fiu32_f16(create, c0, c1);
};
@@ -1784,12 +1784,12 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpLessThanEqual(const sem::Type* ty,
+ConstEval::Result ConstEval::OpLessThanEqual(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
auto create = [&](auto i, auto j) -> ImplResult {
- return CreateElement(builder, source, sem::Type::DeepestElementOf(ty), i <= j);
+ return CreateElement(builder, source, type::Type::DeepestElementOf(ty), i <= j);
};
return Dispatch_fia_fiu32_f16(create, c0, c1);
};
@@ -1797,12 +1797,12 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpGreaterThanEqual(const sem::Type* ty,
+ConstEval::Result ConstEval::OpGreaterThanEqual(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
auto create = [&](auto i, auto j) -> ImplResult {
- return CreateElement(builder, source, sem::Type::DeepestElementOf(ty), i >= j);
+ return CreateElement(builder, source, type::Type::DeepestElementOf(ty), i >= j);
};
return Dispatch_fia_fiu32_f16(create, c0, c1);
};
@@ -1810,19 +1810,19 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpLogicalAnd(const sem::Type* ty,
+ConstEval::Result ConstEval::OpLogicalAnd(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
return CreateElement(builder, source, ty, args[0]->As<bool>() && args[1]->As<bool>());
}
-ConstEval::Result ConstEval::OpLogicalOr(const sem::Type* ty,
+ConstEval::Result ConstEval::OpLogicalOr(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
return CreateElement(builder, source, ty, args[0]->As<bool>() || args[1]->As<bool>());
}
-ConstEval::Result ConstEval::OpAnd(const sem::Type* ty,
+ConstEval::Result ConstEval::OpAnd(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
@@ -1834,7 +1834,7 @@
} else { // integral
result = i & j;
}
- return CreateElement(builder, source, sem::Type::DeepestElementOf(ty), result);
+ return CreateElement(builder, source, type::Type::DeepestElementOf(ty), result);
};
return Dispatch_ia_iu32_bool(create, c0, c1);
};
@@ -1842,7 +1842,7 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpOr(const sem::Type* ty,
+ConstEval::Result ConstEval::OpOr(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
@@ -1854,7 +1854,7 @@
} else { // integral
result = i | j;
}
- return CreateElement(builder, source, sem::Type::DeepestElementOf(ty), result);
+ return CreateElement(builder, source, type::Type::DeepestElementOf(ty), result);
};
return Dispatch_ia_iu32_bool(create, c0, c1);
};
@@ -1862,12 +1862,12 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpXor(const sem::Type* ty,
+ConstEval::Result ConstEval::OpXor(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
auto create = [&](auto i, auto j) -> ImplResult {
- return CreateElement(builder, source, sem::Type::DeepestElementOf(ty),
+ return CreateElement(builder, source, type::Type::DeepestElementOf(ty),
decltype(i){i ^ j});
};
return Dispatch_ia_iu32(create, c0, c1);
@@ -1876,7 +1876,7 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpShiftLeft(const sem::Type* ty,
+ConstEval::Result ConstEval::OpShiftLeft(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
@@ -1948,12 +1948,13 @@
// Avoid UB by left shifting as unsigned value
auto result = static_cast<T>(static_cast<UT>(e1) << e2);
- return CreateElement(builder, source, sem::Type::DeepestElementOf(ty), NumberT{result});
+ return CreateElement(builder, source, type::Type::DeepestElementOf(ty),
+ NumberT{result});
};
return Dispatch_ia_iu32(create, c0, c1);
};
- if (!sem::Type::DeepestElementOf(args[1]->Type())->Is<sem::U32>()) {
+ if (!type::Type::DeepestElementOf(args[1]->Type())->Is<sem::U32>()) {
TINT_ICE(Resolver, builder.Diagnostics())
<< "Element type of rhs of ShiftLeft must be a u32";
return utils::Failure;
@@ -1962,7 +1963,7 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::OpShiftRight(const sem::Type* ty,
+ConstEval::Result ConstEval::OpShiftRight(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
@@ -2012,12 +2013,13 @@
result = e1 >> e2;
}
}
- return CreateElement(builder, source, sem::Type::DeepestElementOf(ty), NumberT{result});
+ return CreateElement(builder, source, type::Type::DeepestElementOf(ty),
+ NumberT{result});
};
return Dispatch_ia_iu32(create, c0, c1);
};
- if (!sem::Type::DeepestElementOf(args[1]->Type())->Is<sem::U32>()) {
+ if (!type::Type::DeepestElementOf(args[1]->Type())->Is<sem::U32>()) {
TINT_ICE(Resolver, builder.Diagnostics())
<< "Element type of rhs of ShiftLeft must be a u32";
return utils::Failure;
@@ -2026,7 +2028,7 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::abs(const sem::Type* ty,
+ConstEval::Result ConstEval::abs(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2051,7 +2053,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::acos(const sem::Type* ty,
+ConstEval::Result ConstEval::acos(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2069,7 +2071,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::acosh(const sem::Type* ty,
+ConstEval::Result ConstEval::acosh(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2087,19 +2089,19 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::all(const sem::Type* ty,
+ConstEval::Result ConstEval::all(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
return CreateElement(builder, source, ty, !args[0]->AnyZero());
}
-ConstEval::Result ConstEval::any(const sem::Type* ty,
+ConstEval::Result ConstEval::any(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
return CreateElement(builder, source, ty, !args[0]->AllZero());
}
-ConstEval::Result ConstEval::asin(const sem::Type* ty,
+ConstEval::Result ConstEval::asin(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2117,7 +2119,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::asinh(const sem::Type* ty,
+ConstEval::Result ConstEval::asinh(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2130,7 +2132,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::atan(const sem::Type* ty,
+ConstEval::Result ConstEval::atan(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2142,7 +2144,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::atanh(const sem::Type* ty,
+ConstEval::Result ConstEval::atanh(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2161,7 +2163,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::atan2(const sem::Type* ty,
+ConstEval::Result ConstEval::atan2(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
@@ -2174,7 +2176,7 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::ceil(const sem::Type* ty,
+ConstEval::Result ConstEval::ceil(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2186,7 +2188,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::clamp(const sem::Type* ty,
+ConstEval::Result ConstEval::clamp(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1,
@@ -2196,7 +2198,7 @@
return TransformElements(builder, ty, transform, args[0], args[1], args[2]);
}
-ConstEval::Result ConstEval::cos(const sem::Type* ty,
+ConstEval::Result ConstEval::cos(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2209,7 +2211,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::cosh(const sem::Type* ty,
+ConstEval::Result ConstEval::cosh(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2222,7 +2224,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::countLeadingZeros(const sem::Type* ty,
+ConstEval::Result ConstEval::countLeadingZeros(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2237,7 +2239,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::countOneBits(const sem::Type* ty,
+ConstEval::Result ConstEval::countOneBits(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2261,7 +2263,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::countTrailingZeros(const sem::Type* ty,
+ConstEval::Result ConstEval::countTrailingZeros(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2276,7 +2278,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::cross(const sem::Type* ty,
+ConstEval::Result ConstEval::cross(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto* u = args[0];
@@ -2319,7 +2321,7 @@
utils::Vector<const sem::Constant*, 3>{x.Get(), y.Get(), z.Get()});
}
-ConstEval::Result ConstEval::degrees(const sem::Type* ty,
+ConstEval::Result ConstEval::degrees(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2345,7 +2347,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::determinant(const sem::Type* ty,
+ConstEval::Result ConstEval::determinant(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto calculate = [&]() -> ConstEval::Result {
@@ -2381,7 +2383,7 @@
return r;
}
-ConstEval::Result ConstEval::distance(const sem::Type* ty,
+ConstEval::Result ConstEval::distance(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto err = [&]() -> ImplResult {
@@ -2401,7 +2403,7 @@
return len;
}
-ConstEval::Result ConstEval::dot(const sem::Type*,
+ConstEval::Result ConstEval::dot(const type::Type*,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto r = Dot(source, args[0], args[1]);
@@ -2411,7 +2413,7 @@
return r;
}
-ConstEval::Result ConstEval::exp(const sem::Type* ty,
+ConstEval::Result ConstEval::exp(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2429,7 +2431,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::exp2(const sem::Type* ty,
+ConstEval::Result ConstEval::exp2(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2447,7 +2449,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::extractBits(const sem::Type* ty,
+ConstEval::Result ConstEval::extractBits(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2502,7 +2504,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::faceForward(const sem::Type* ty,
+ConstEval::Result ConstEval::faceForward(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
// Returns e1 if dot(e2, e3) is negative, and -e1 otherwise.
@@ -2521,7 +2523,7 @@
return OpUnaryMinus(ty, utils::Vector{e1}, source);
}
-ConstEval::Result ConstEval::firstLeadingBit(const sem::Type* ty,
+ConstEval::Result ConstEval::firstLeadingBit(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2565,7 +2567,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::firstTrailingBit(const sem::Type* ty,
+ConstEval::Result ConstEval::firstTrailingBit(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2591,7 +2593,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::floor(const sem::Type* ty,
+ConstEval::Result ConstEval::floor(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2603,7 +2605,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::fma(const sem::Type* ty,
+ConstEval::Result ConstEval::fma(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c1, const sem::Constant* c2,
@@ -2630,7 +2632,7 @@
return TransformElements(builder, ty, transform, args[0], args[1], args[2]);
}
-ConstEval::Result ConstEval::frexp(const sem::Type* ty,
+ConstEval::Result ConstEval::frexp(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto* arg = args[0];
@@ -2703,7 +2705,7 @@
}
}
-ConstEval::Result ConstEval::insertBits(const sem::Type* ty,
+ConstEval::Result ConstEval::insertBits(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
@@ -2755,7 +2757,7 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::inverseSqrt(const sem::Type* ty,
+ConstEval::Result ConstEval::inverseSqrt(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2789,7 +2791,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::length(const sem::Type* ty,
+ConstEval::Result ConstEval::length(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto r = Length(source, ty, args[0]);
@@ -2799,7 +2801,7 @@
return r;
}
-ConstEval::Result ConstEval::log(const sem::Type* ty,
+ConstEval::Result ConstEval::log(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2816,7 +2818,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::log2(const sem::Type* ty,
+ConstEval::Result ConstEval::log2(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -2833,7 +2835,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::max(const sem::Type* ty,
+ConstEval::Result ConstEval::max(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
@@ -2845,7 +2847,7 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::min(const sem::Type* ty,
+ConstEval::Result ConstEval::min(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
@@ -2857,7 +2859,7 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::modf(const sem::Type* ty,
+ConstEval::Result ConstEval::modf(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform_fract = [&](const sem::Constant* c) {
@@ -2891,10 +2893,10 @@
return CreateComposite(builder, ty, std::move(fields));
}
-ConstEval::Result ConstEval::normalize(const sem::Type* ty,
+ConstEval::Result ConstEval::normalize(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
- auto* len_ty = sem::Type::DeepestElementOf(ty);
+ auto* len_ty = type::Type::DeepestElementOf(ty);
auto len = Length(source, len_ty, args[0]);
if (!len) {
AddNote("when calculating normalize", source);
@@ -2908,7 +2910,7 @@
return OpDivide(ty, utils::Vector{args[0], v}, source);
}
-ConstEval::Result ConstEval::pack2x16float(const sem::Type* ty,
+ConstEval::Result ConstEval::pack2x16float(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto convert = [&](f32 val) -> utils::Result<uint32_t> {
@@ -2936,7 +2938,7 @@
return CreateElement(builder, source, ty, ret);
}
-ConstEval::Result ConstEval::pack2x16snorm(const sem::Type* ty,
+ConstEval::Result ConstEval::pack2x16snorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto calc = [&](f32 val) -> u32 {
@@ -2953,7 +2955,7 @@
return CreateElement(builder, source, ty, ret);
}
-ConstEval::Result ConstEval::pack2x16unorm(const sem::Type* ty,
+ConstEval::Result ConstEval::pack2x16unorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto calc = [&](f32 val) -> u32 {
@@ -2969,7 +2971,7 @@
return CreateElement(builder, source, ty, ret);
}
-ConstEval::Result ConstEval::pack4x8snorm(const sem::Type* ty,
+ConstEval::Result ConstEval::pack4x8snorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto calc = [&](f32 val) -> u32 {
@@ -2989,7 +2991,7 @@
return CreateElement(builder, source, ty, ret);
}
-ConstEval::Result ConstEval::pack4x8unorm(const sem::Type* ty,
+ConstEval::Result ConstEval::pack4x8unorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto calc = [&](f32 val) -> u32 {
@@ -3008,7 +3010,7 @@
return CreateElement(builder, source, ty, ret);
}
-ConstEval::Result ConstEval::radians(const sem::Type* ty,
+ConstEval::Result ConstEval::radians(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -3034,7 +3036,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::reflect(const sem::Type* ty,
+ConstEval::Result ConstEval::reflect(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto calculate = [&]() -> ConstEval::Result {
@@ -3077,7 +3079,7 @@
return r;
}
-ConstEval::Result ConstEval::refract(const sem::Type* ty,
+ConstEval::Result ConstEval::refract(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto* vec_ty = ty->As<sem::Vector>();
@@ -3175,7 +3177,7 @@
return r;
}
-ConstEval::Result ConstEval::reverseBits(const sem::Type* ty,
+ConstEval::Result ConstEval::reverseBits(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -3202,7 +3204,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::round(const sem::Type* ty,
+ConstEval::Result ConstEval::round(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -3238,7 +3240,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::saturate(const sem::Type* ty,
+ConstEval::Result ConstEval::saturate(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -3252,13 +3254,13 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::select_bool(const sem::Type* ty,
+ConstEval::Result ConstEval::select_bool(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto cond = args[2]->As<bool>();
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
auto create = [&](auto f, auto t) -> ImplResult {
- return CreateElement(builder, source, sem::Type::DeepestElementOf(ty), cond ? t : f);
+ return CreateElement(builder, source, type::Type::DeepestElementOf(ty), cond ? t : f);
};
return Dispatch_fia_fiu32_f16_bool(create, c0, c1);
};
@@ -3266,14 +3268,14 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::select_boolvec(const sem::Type* ty,
+ConstEval::Result ConstEval::select_boolvec(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1, size_t index) {
auto create = [&](auto f, auto t) -> ImplResult {
// Get corresponding bool value at the current vector value index
auto cond = args[2]->Index(index)->As<bool>();
- return CreateElement(builder, source, sem::Type::DeepestElementOf(ty), cond ? t : f);
+ return CreateElement(builder, source, type::Type::DeepestElementOf(ty), cond ? t : f);
};
return Dispatch_fia_fiu32_f16_bool(create, c0, c1);
};
@@ -3281,7 +3283,7 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::sign(const sem::Type* ty,
+ConstEval::Result ConstEval::sign(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -3303,7 +3305,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::sin(const sem::Type* ty,
+ConstEval::Result ConstEval::sin(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -3316,7 +3318,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::sinh(const sem::Type* ty,
+ConstEval::Result ConstEval::sinh(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -3329,7 +3331,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::smoothstep(const sem::Type* ty,
+ConstEval::Result ConstEval::smoothstep(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1,
@@ -3380,7 +3382,7 @@
return TransformElements(builder, ty, transform, args[0], args[1], args[2]);
}
-ConstEval::Result ConstEval::step(const sem::Type* ty,
+ConstEval::Result ConstEval::step(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
@@ -3394,7 +3396,7 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
-ConstEval::Result ConstEval::sqrt(const sem::Type* ty,
+ConstEval::Result ConstEval::sqrt(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -3404,7 +3406,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::tan(const sem::Type* ty,
+ConstEval::Result ConstEval::tan(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -3417,7 +3419,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::tanh(const sem::Type* ty,
+ConstEval::Result ConstEval::tanh(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -3430,7 +3432,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::transpose(const sem::Type* ty,
+ConstEval::Result ConstEval::transpose(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source&) {
auto* m = args[0];
@@ -3450,7 +3452,7 @@
return CreateComposite(builder, ty, result_mat);
}
-ConstEval::Result ConstEval::trunc(const sem::Type* ty,
+ConstEval::Result ConstEval::trunc(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
@@ -3462,10 +3464,10 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::unpack2x16float(const sem::Type* ty,
+ConstEval::Result ConstEval::unpack2x16float(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
- auto* inner_ty = sem::Type::DeepestElementOf(ty);
+ auto* inner_ty = type::Type::DeepestElementOf(ty);
auto e = args[0]->As<u32>().value;
utils::Vector<const sem::Constant*, 2> els;
@@ -3486,10 +3488,10 @@
return CreateComposite(builder, ty, std::move(els));
}
-ConstEval::Result ConstEval::unpack2x16snorm(const sem::Type* ty,
+ConstEval::Result ConstEval::unpack2x16snorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
- auto* inner_ty = sem::Type::DeepestElementOf(ty);
+ auto* inner_ty = type::Type::DeepestElementOf(ty);
auto e = args[0]->As<u32>().value;
utils::Vector<const sem::Constant*, 2> els;
@@ -3506,10 +3508,10 @@
return CreateComposite(builder, ty, std::move(els));
}
-ConstEval::Result ConstEval::unpack2x16unorm(const sem::Type* ty,
+ConstEval::Result ConstEval::unpack2x16unorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
- auto* inner_ty = sem::Type::DeepestElementOf(ty);
+ auto* inner_ty = type::Type::DeepestElementOf(ty);
auto e = args[0]->As<u32>().value;
utils::Vector<const sem::Constant*, 2> els;
@@ -3525,10 +3527,10 @@
return CreateComposite(builder, ty, std::move(els));
}
-ConstEval::Result ConstEval::unpack4x8snorm(const sem::Type* ty,
+ConstEval::Result ConstEval::unpack4x8snorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
- auto* inner_ty = sem::Type::DeepestElementOf(ty);
+ auto* inner_ty = type::Type::DeepestElementOf(ty);
auto e = args[0]->As<u32>().value;
utils::Vector<const sem::Constant*, 4> els;
@@ -3545,10 +3547,10 @@
return CreateComposite(builder, ty, std::move(els));
}
-ConstEval::Result ConstEval::unpack4x8unorm(const sem::Type* ty,
+ConstEval::Result ConstEval::unpack4x8unorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
- auto* inner_ty = sem::Type::DeepestElementOf(ty);
+ auto* inner_ty = type::Type::DeepestElementOf(ty);
auto e = args[0]->As<u32>().value;
utils::Vector<const sem::Constant*, 4> els;
@@ -3564,7 +3566,7 @@
return CreateComposite(builder, ty, std::move(els));
}
-ConstEval::Result ConstEval::quantizeToF16(const sem::Type* ty,
+ConstEval::Result ConstEval::quantizeToF16(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c) -> ImplResult {
@@ -3579,7 +3581,7 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::Convert(const sem::Type* target_ty,
+ConstEval::Result ConstEval::Convert(const type::Type* target_ty,
const sem::Constant* value,
const Source& source) {
if (value->Type() == target_ty) {
diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h
index ed8b6b1..81e4575 100644
--- a/src/tint/resolver/const_eval.h
+++ b/src/tint/resolver/const_eval.h
@@ -18,6 +18,7 @@
#include <stddef.h>
#include <string>
+#include "src/tint/type/type.h"
#include "src/tint/utils/result.h"
#include "src/tint/utils/vector.h"
@@ -33,7 +34,6 @@
class Constant;
class Expression;
class StructMember;
-class Type;
} // namespace tint::sem
namespace tint::resolver {
@@ -56,7 +56,7 @@
using Result = utils::Result<const sem::Constant*>;
/// Typedef for a constant evaluation function
- using Function = Result (ConstEval::*)(const sem::Type* result_ty,
+ using Function = Result (ConstEval::*)(const type::Type* result_ty,
utils::VectorRef<const sem::Constant*>,
const Source&);
@@ -71,13 +71,13 @@
/// @param ty the target type - must be an array or initializer
/// @param args the input arguments
/// @return the constructed value, or null if the value cannot be calculated
- Result ArrayOrStructInit(const sem::Type* ty, utils::VectorRef<const sem::Expression*> args);
+ Result ArrayOrStructInit(const type::Type* ty, utils::VectorRef<const sem::Expression*> args);
/// @param ty the target type
/// @param expr the input expression
/// @return the bit-cast of the given expression to the given type, or null if the value cannot
/// be calculated
- Result Bitcast(const sem::Type* ty, const sem::Expression* expr);
+ Result Bitcast(const type::Type* ty, const sem::Expression* expr);
/// @param obj the object being indexed
/// @param idx the index expression
@@ -87,7 +87,7 @@
/// @param ty the result type
/// @param lit the literal AST node
/// @return the constant value of the literal
- Result Literal(const sem::Type* ty, const ast::LiteralExpression* lit);
+ Result Literal(const type::Type* ty, const ast::LiteralExpression* lit);
/// @param obj the object being accessed
/// @param member the member
@@ -98,7 +98,7 @@
/// @param vector the vector being swizzled
/// @param indices the swizzle indices
/// @return the result of the swizzle, or null if the value cannot be calculated
- Result Swizzle(const sem::Type* ty,
+ Result Swizzle(const type::Type* ty,
const sem::Expression* vector,
utils::VectorRef<uint32_t> indices);
@@ -107,7 +107,7 @@
/// @param value the value being converted
/// @param source the source location
/// @return the converted value, or null if the value cannot be calculated
- Result Convert(const sem::Type* ty, const sem::Constant* value, const Source& source);
+ Result Convert(const type::Type* ty, const sem::Constant* value, const Source& source);
////////////////////////////////////////////////////////////////////////////////////////////////
// Constant value evaluation methods, to be indirectly called via the intrinsic table
@@ -118,7 +118,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the converted value, or null if the value cannot be calculated
- Result Conv(const sem::Type* ty,
+ Result Conv(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -127,7 +127,7 @@
/// @param args the input arguments (no arguments provided)
/// @param source the source location
/// @return the constructed value, or null if the value cannot be calculated
- Result Zero(const sem::Type* ty,
+ Result Zero(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -136,7 +136,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the constructed value, or null if the value cannot be calculated
- Result Identity(const sem::Type* ty,
+ Result Identity(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -145,7 +145,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the constructed value, or null if the value cannot be calculated
- Result VecSplat(const sem::Type* ty,
+ Result VecSplat(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -154,7 +154,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the constructed value, or null if the value cannot be calculated
- Result VecInitS(const sem::Type* ty,
+ Result VecInitS(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -163,7 +163,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the constructed value, or null if the value cannot be calculated
- Result VecInitM(const sem::Type* ty,
+ Result VecInitM(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -172,7 +172,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the constructed value, or null if the value cannot be calculated
- Result MatInitS(const sem::Type* ty,
+ Result MatInitS(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -181,7 +181,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the constructed value, or null if the value cannot be calculated
- Result MatInitV(const sem::Type* ty,
+ Result MatInitV(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -194,7 +194,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpComplement(const sem::Type* ty,
+ Result OpComplement(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -203,7 +203,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpUnaryMinus(const sem::Type* ty,
+ Result OpUnaryMinus(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -212,7 +212,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpNot(const sem::Type* ty,
+ Result OpNot(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -225,7 +225,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpPlus(const sem::Type* ty,
+ Result OpPlus(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -234,7 +234,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpMinus(const sem::Type* ty,
+ Result OpMinus(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -243,7 +243,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpMultiply(const sem::Type* ty,
+ Result OpMultiply(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -252,7 +252,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpMultiplyMatVec(const sem::Type* ty,
+ Result OpMultiplyMatVec(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -261,7 +261,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpMultiplyVecMat(const sem::Type* ty,
+ Result OpMultiplyVecMat(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -270,7 +270,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpMultiplyMatMat(const sem::Type* ty,
+ Result OpMultiplyMatMat(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -279,7 +279,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpDivide(const sem::Type* ty,
+ Result OpDivide(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -288,7 +288,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpModulo(const sem::Type* ty,
+ Result OpModulo(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -297,7 +297,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpEqual(const sem::Type* ty,
+ Result OpEqual(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -306,7 +306,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpNotEqual(const sem::Type* ty,
+ Result OpNotEqual(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -315,7 +315,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpLessThan(const sem::Type* ty,
+ Result OpLessThan(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -324,7 +324,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpGreaterThan(const sem::Type* ty,
+ Result OpGreaterThan(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -333,7 +333,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpLessThanEqual(const sem::Type* ty,
+ Result OpLessThanEqual(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -342,7 +342,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpGreaterThanEqual(const sem::Type* ty,
+ Result OpGreaterThanEqual(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -351,7 +351,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpLogicalAnd(const sem::Type* ty,
+ Result OpLogicalAnd(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -360,7 +360,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpLogicalOr(const sem::Type* ty,
+ Result OpLogicalOr(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -369,7 +369,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpAnd(const sem::Type* ty,
+ Result OpAnd(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -378,7 +378,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpOr(const sem::Type* ty,
+ Result OpOr(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -387,7 +387,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpXor(const sem::Type* ty,
+ Result OpXor(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -396,7 +396,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpShiftLeft(const sem::Type* ty,
+ Result OpShiftLeft(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -405,7 +405,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result OpShiftRight(const sem::Type* ty,
+ Result OpShiftRight(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -418,7 +418,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result abs(const sem::Type* ty,
+ Result abs(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -427,7 +427,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result acos(const sem::Type* ty,
+ Result acos(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -436,7 +436,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result acosh(const sem::Type* ty,
+ Result acosh(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -445,7 +445,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result all(const sem::Type* ty,
+ Result all(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -454,7 +454,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result any(const sem::Type* ty,
+ Result any(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -463,7 +463,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result asin(const sem::Type* ty,
+ Result asin(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -472,7 +472,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result asinh(const sem::Type* ty,
+ Result asinh(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -481,7 +481,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result atan(const sem::Type* ty,
+ Result atan(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -490,7 +490,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result atanh(const sem::Type* ty,
+ Result atanh(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -499,7 +499,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result atan2(const sem::Type* ty,
+ Result atan2(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -508,7 +508,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result ceil(const sem::Type* ty,
+ Result ceil(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -517,7 +517,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result clamp(const sem::Type* ty,
+ Result clamp(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -526,7 +526,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result cos(const sem::Type* ty,
+ Result cos(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -535,7 +535,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result cosh(const sem::Type* ty,
+ Result cosh(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -544,7 +544,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result countLeadingZeros(const sem::Type* ty,
+ Result countLeadingZeros(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -553,7 +553,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result countOneBits(const sem::Type* ty,
+ Result countOneBits(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -562,7 +562,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result countTrailingZeros(const sem::Type* ty,
+ Result countTrailingZeros(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -571,7 +571,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result cross(const sem::Type* ty,
+ Result cross(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -580,7 +580,7 @@
/// @param args the input arguments
/// @param source the source location of the conversion
/// @return the result value, or null if the value cannot be calculated
- Result degrees(const sem::Type* ty,
+ Result degrees(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -589,7 +589,7 @@
/// @param args the input arguments
/// @param source the source location of the conversion
/// @return the result value, or null if the value cannot be calculated
- Result determinant(const sem::Type* ty,
+ Result determinant(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -598,7 +598,7 @@
/// @param args the input arguments
/// @param source the source location of the conversion
/// @return the result value, or null if the value cannot be calculated
- Result distance(const sem::Type* ty,
+ Result distance(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -607,7 +607,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result dot(const sem::Type* ty,
+ Result dot(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -616,7 +616,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result exp(const sem::Type* ty,
+ Result exp(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -625,7 +625,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result exp2(const sem::Type* ty,
+ Result exp2(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -634,7 +634,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result extractBits(const sem::Type* ty,
+ Result extractBits(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -643,7 +643,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result faceForward(const sem::Type* ty,
+ Result faceForward(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -652,7 +652,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result firstLeadingBit(const sem::Type* ty,
+ Result firstLeadingBit(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -661,7 +661,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result firstTrailingBit(const sem::Type* ty,
+ Result firstTrailingBit(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -670,7 +670,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result floor(const sem::Type* ty,
+ Result floor(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -679,7 +679,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result fma(const sem::Type* ty,
+ Result fma(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -688,7 +688,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result frexp(const sem::Type* ty,
+ Result frexp(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -697,7 +697,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result insertBits(const sem::Type* ty,
+ Result insertBits(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -706,7 +706,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result inverseSqrt(const sem::Type* ty,
+ Result inverseSqrt(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -715,7 +715,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result length(const sem::Type* ty,
+ Result length(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -724,7 +724,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result log(const sem::Type* ty,
+ Result log(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -733,7 +733,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result log2(const sem::Type* ty,
+ Result log2(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -742,7 +742,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result max(const sem::Type* ty,
+ Result max(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -751,7 +751,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result min(const sem::Type* ty, // NOLINT(build/include_what_you_use) -- confused by min
+ Result min(const type::Type* ty, // NOLINT(build/include_what_you_use) -- confused by min
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -760,7 +760,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result modf(const sem::Type* ty,
+ Result modf(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -769,7 +769,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result normalize(const sem::Type* ty,
+ Result normalize(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -778,7 +778,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result pack2x16float(const sem::Type* ty,
+ Result pack2x16float(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -787,7 +787,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result pack2x16snorm(const sem::Type* ty,
+ Result pack2x16snorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -796,7 +796,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result pack2x16unorm(const sem::Type* ty,
+ Result pack2x16unorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -805,7 +805,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result pack4x8snorm(const sem::Type* ty,
+ Result pack4x8snorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -814,7 +814,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result pack4x8unorm(const sem::Type* ty,
+ Result pack4x8unorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -823,7 +823,7 @@
/// @param args the input arguments
/// @param source the source location of the conversion
/// @return the result value, or null if the value cannot be calculated
- Result radians(const sem::Type* ty,
+ Result radians(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -832,7 +832,7 @@
/// @param args the input arguments
/// @param source the source location of the conversion
/// @return the result value, or null if the value cannot be calculated
- Result reflect(const sem::Type* ty,
+ Result reflect(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -841,7 +841,7 @@
/// @param args the input arguments
/// @param source the source location of the conversion
/// @return the result value, or null if the value cannot be calculated
- Result refract(const sem::Type* ty,
+ Result refract(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -850,7 +850,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result reverseBits(const sem::Type* ty,
+ Result reverseBits(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -859,7 +859,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result round(const sem::Type* ty,
+ Result round(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -868,7 +868,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result saturate(const sem::Type* ty,
+ Result saturate(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -877,7 +877,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result select_bool(const sem::Type* ty,
+ Result select_bool(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -886,7 +886,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result select_boolvec(const sem::Type* ty,
+ Result select_boolvec(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -895,7 +895,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result sign(const sem::Type* ty,
+ Result sign(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -904,7 +904,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result sin(const sem::Type* ty,
+ Result sin(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -913,7 +913,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result sinh(const sem::Type* ty,
+ Result sinh(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -922,7 +922,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result smoothstep(const sem::Type* ty,
+ Result smoothstep(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -931,7 +931,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result step(const sem::Type* ty,
+ Result step(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -940,7 +940,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result sqrt(const sem::Type* ty,
+ Result sqrt(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -949,7 +949,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result tan(const sem::Type* ty,
+ Result tan(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -958,7 +958,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result tanh(const sem::Type* ty,
+ Result tanh(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -967,7 +967,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result transpose(const sem::Type* ty,
+ Result transpose(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -976,7 +976,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result trunc(const sem::Type* ty,
+ Result trunc(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -985,7 +985,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result unpack2x16float(const sem::Type* ty,
+ Result unpack2x16float(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -994,7 +994,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result unpack2x16snorm(const sem::Type* ty,
+ Result unpack2x16snorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -1003,7 +1003,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result unpack2x16unorm(const sem::Type* ty,
+ Result unpack2x16unorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -1012,7 +1012,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result unpack4x8snorm(const sem::Type* ty,
+ Result unpack4x8snorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -1021,7 +1021,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result unpack4x8unorm(const sem::Type* ty,
+ Result unpack4x8unorm(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -1030,7 +1030,7 @@
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
- Result quantizeToF16(const sem::Type* ty,
+ Result quantizeToF16(const type::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
@@ -1237,91 +1237,91 @@
/// @param source the source location
/// @param elem_ty the element type of the Constant to create on success
/// @returns the callable function
- auto AddFunc(const Source& source, const sem::Type* elem_ty);
+ auto AddFunc(const Source& source, const type::Type* elem_ty);
/// Returns a callable that calls Sub, and creates a Constant with its result of type `elem_ty`
/// if successful, or returns Failure otherwise.
/// @param source the source location
/// @param elem_ty the element type of the Constant to create on success
/// @returns the callable function
- auto SubFunc(const Source& source, const sem::Type* elem_ty);
+ auto SubFunc(const Source& source, const type::Type* elem_ty);
/// Returns a callable that calls Mul, and creates a Constant with its result of type `elem_ty`
/// if successful, or returns Failure otherwise.
/// @param source the source location
/// @param elem_ty the element type of the Constant to create on success
/// @returns the callable function
- auto MulFunc(const Source& source, const sem::Type* elem_ty);
+ auto MulFunc(const Source& source, const type::Type* elem_ty);
/// Returns a callable that calls Div, and creates a Constant with its result of type `elem_ty`
/// if successful, or returns Failure otherwise.
/// @param source the source location
/// @param elem_ty the element type of the Constant to create on success
/// @returns the callable function
- auto DivFunc(const Source& source, const sem::Type* elem_ty);
+ auto DivFunc(const Source& source, const type::Type* elem_ty);
/// Returns a callable that calls Mod, and creates a Constant with its result of type `elem_ty`
/// if successful, or returns Failure otherwise.
/// @param source the source location
/// @param elem_ty the element type of the Constant to create on success
/// @returns the callable function
- auto ModFunc(const Source& source, const sem::Type* elem_ty);
+ auto ModFunc(const Source& source, const type::Type* elem_ty);
/// Returns a callable that calls Dot2, and creates a Constant with its result of type `elem_ty`
/// if successful, or returns Failure otherwise.
/// @param source the source location
/// @param elem_ty the element type of the Constant to create on success
/// @returns the callable function
- auto Dot2Func(const Source& source, const sem::Type* elem_ty);
+ auto Dot2Func(const Source& source, const type::Type* elem_ty);
/// Returns a callable that calls Dot3, and creates a Constant with its result of type `elem_ty`
/// if successful, or returns Failure otherwise.
/// @param source the source location
/// @param elem_ty the element type of the Constant to create on success
/// @returns the callable function
- auto Dot3Func(const Source& source, const sem::Type* elem_ty);
+ auto Dot3Func(const Source& source, const type::Type* elem_ty);
/// Returns a callable that calls Dot4, and creates a Constant with its result of type `elem_ty`
/// if successful, or returns Failure otherwise.
/// @param source the source location
/// @param elem_ty the element type of the Constant to create on success
/// @returns the callable function
- auto Dot4Func(const Source& source, const sem::Type* elem_ty);
+ auto Dot4Func(const Source& source, const type::Type* elem_ty);
/// Returns a callable that calls Det2, and creates a Constant with its result of type `elem_ty`
/// if successful, or returns Failure otherwise.
/// @param source the source location
/// @param elem_ty the element type of the Constant to create on success
/// @returns the callable function
- auto Det2Func(const Source& source, const sem::Type* elem_ty);
+ auto Det2Func(const Source& source, const type::Type* elem_ty);
/// Returns a callable that calls Det3, and creates a Constant with its result of type `elem_ty`
/// if successful, or returns Failure otherwise.
/// @param source the source location
/// @param elem_ty the element type of the Constant to create on success
/// @returns the callable function
- auto Det3Func(const Source& source, const sem::Type* elem_ty);
+ auto Det3Func(const Source& source, const type::Type* elem_ty);
/// Returns a callable that calls Det4, and creates a Constant with its result of type `elem_ty`
/// if successful, or returns Failure otherwise.
/// @param source the source location
/// @param elem_ty the element type of the Constant to create on success
/// @returns the callable function
- auto Det4Func(const Source& source, const sem::Type* elem_ty);
+ auto Det4Func(const Source& source, const type::Type* elem_ty);
/// Returns a callable that calls Clamp, and creates a Constant with its result of type
/// `elem_ty` if successful, or returns Failure otherwise.
/// @param source the source location
/// @param elem_ty the element type of the Constant to create on success
/// @returns the callable function
- auto ClampFunc(const Source& source, const sem::Type* elem_ty);
+ auto ClampFunc(const Source& source, const type::Type* elem_ty);
/// Returns a callable that calls SqrtFunc, and creates a Constant with its
/// result of type `elem_ty` if successful, or returns Failure otherwise.
/// @param source the source location
/// @param elem_ty the element type of the Constant to create on success
/// @returns the callable function
- auto SqrtFunc(const Source& source, const sem::Type* elem_ty);
+ auto SqrtFunc(const Source& source, const type::Type* elem_ty);
/// Returns the dot product of v1 and v2.
/// @param source the source location
@@ -1335,7 +1335,7 @@
/// @param ty the return type
/// @param c0 the constant to calculate the length of
/// @returns the length of c0
- Result Length(const Source& source, const sem::Type* ty, const sem::Constant* c0);
+ Result Length(const Source& source, const type::Type* ty, const sem::Constant* c0);
/// Returns the product of v1 and v2
/// @param source the source location
@@ -1344,7 +1344,7 @@
/// @param v2 rhs value
/// @returns the product of v1 and v2
Result Mul(const Source& source,
- const sem::Type* ty,
+ const type::Type* ty,
const sem::Constant* v1,
const sem::Constant* v2);
@@ -1355,7 +1355,7 @@
/// @param v2 rhs value
/// @returns the difference between v2 and v1
Result Sub(const Source& source,
- const sem::Type* ty,
+ const type::Type* ty,
const sem::Constant* v1,
const sem::Constant* v2);
diff --git a/src/tint/resolver/const_eval_test.h b/src/tint/resolver/const_eval_test.h
index 42b6f92..27b5e54 100644
--- a/src/tint/resolver/const_eval_test.h
+++ b/src/tint/resolver/const_eval_test.h
@@ -23,7 +23,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "src/tint/resolver/resolver_test_helper.h"
-#include "src/tint/sem/test_helper.h"
+#include "src/tint/type/test_helper.h"
namespace tint::resolver {
diff --git a/src/tint/resolver/inferred_type_test.cc b/src/tint/resolver/inferred_type_test.cc
index 025ea95..4b3100b 100644
--- a/src/tint/resolver/inferred_type_test.cc
+++ b/src/tint/resolver/inferred_type_test.cc
@@ -136,7 +136,7 @@
TEST_F(ResolverInferredTypeTest, InferArray_Pass) {
auto* type = ty.array(ty.u32(), 10_u);
auto* expected_type = create<sem::Array>(
- create<sem::U32>(), create<sem::ConstantArrayCount>(10u), 4u, 4u * 10u, 4u, 4u);
+ create<sem::U32>(), create<type::ConstantArrayCount>(10u), 4u, 4u * 10u, 4u, 4u);
auto* ctor_expr = Construct(type);
auto* var = Var("a", ast::AddressSpace::kFunction, ctor_expr);
diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc
index 2578881..f2fb2ce 100644
--- a/src/tint/resolver/intrinsic_table.cc
+++ b/src/tint/resolver/intrinsic_table.cc
@@ -55,14 +55,14 @@
constexpr static const size_t kNumFixedCandidates = 8;
/// A special type that matches all TypeMatchers
-class Any final : public Castable<Any, sem::Type> {
+class Any final : public Castable<Any, type::Type> {
public:
- Any() : Base(sem::TypeFlags{}) {}
+ Any() : Base(type::TypeFlags{}) {}
~Any() override = default;
- // Stub implementations for sem::Type conformance.
+ // Stub implementations for type::Type conformance.
size_t Hash() const override { return 0; }
- bool Equals(const sem::Type&) const override { return false; }
+ bool Equals(const type::Type&) const override { return false; }
std::string FriendlyName(const SymbolTable&) const override { return "<any>"; }
};
@@ -122,7 +122,7 @@
/// template type is replaced with `ty`, and `ty` is returned.
/// If none of the above applies, then `ty` is a type mismatch for the template type, and
/// nullptr is returned.
- const sem::Type* Type(size_t idx, const sem::Type* ty) {
+ const type::Type* Type(size_t idx, const type::Type* ty) {
if (idx >= types_.Length()) {
types_.Resize(idx + 1);
}
@@ -131,7 +131,7 @@
t = ty;
return ty;
}
- ty = sem::Type::Common(utils::Vector{t, ty});
+ ty = type::Type::Common(utils::Vector{t, ty});
if (ty) {
t = ty;
}
@@ -154,7 +154,7 @@
}
/// Type returns the template type with index `idx`, or nullptr if the type was not defined.
- const sem::Type* Type(size_t idx) const {
+ const type::Type* Type(size_t idx) const {
if (idx >= types_.Length()) {
return nullptr;
}
@@ -162,7 +162,7 @@
}
/// SetType replaces the template type with index `idx` with type `ty`.
- void SetType(size_t idx, const sem::Type* ty) {
+ void SetType(size_t idx, const type::Type* ty) {
if (idx >= types_.Length()) {
types_.Resize(idx + 1);
}
@@ -178,7 +178,7 @@
}
private:
- utils::Vector<const sem::Type*, 4> types_;
+ utils::Vector<const type::Type*, 4> types_;
utils::Vector<Number, 2> numbers_;
};
@@ -219,7 +219,7 @@
/// `ty`. If the type matches, the canonical expected type is returned. If the
/// type `ty` does not match, then nullptr is returned.
/// @note: The matcher indices are progressed on calling.
- const sem::Type* Type(const sem::Type* ty);
+ const type::Type* Type(const type::Type* ty);
/// Num uses the next NumMatcher from the matcher indices to match the number
/// `num`. If the number matches, the canonical expected number is returned.
@@ -253,7 +253,7 @@
/// Match may define and refine the template types and numbers in state.
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- virtual const sem::Type* Match(MatchState& state, const sem::Type* type) const = 0;
+ virtual const type::Type* Match(MatchState& state, const type::Type* type) const = 0;
/// @return a string representation of the matcher. Used for printing error
/// messages when no overload is found.
@@ -286,7 +286,7 @@
/// Constructor
explicit TemplateTypeMatcher(size_t index) : index_(index) {}
- const sem::Type* Match(MatchState& state, const sem::Type* type) const override {
+ const type::Type* Match(MatchState& state, const type::Type* type) const override {
if (type->Is<Any>()) {
return state.templates.Type(index_);
}
@@ -348,7 +348,7 @@
// An enum set of OverloadFlag, used by OperatorInfo
using OverloadFlags = utils::EnumSet<OverloadFlag>;
-bool match_bool(MatchState&, const sem::Type* ty) {
+bool match_bool(MatchState&, const type::Type* ty) {
return ty->IsAnyOf<Any, sem::Bool>();
}
@@ -356,7 +356,7 @@
return state.builder.create<sem::AbstractFloat>();
}
-bool match_fa(MatchState& state, const sem::Type* ty) {
+bool match_fa(MatchState& state, const type::Type* ty) {
return (state.earliest_eval_stage == sem::EvaluationStage::kConstant) &&
ty->IsAnyOf<Any, sem::AbstractNumeric>();
}
@@ -365,7 +365,7 @@
return state.builder.create<sem::AbstractInt>();
}
-bool match_ia(MatchState& state, const sem::Type* ty) {
+bool match_ia(MatchState& state, const type::Type* ty) {
return (state.earliest_eval_stage == sem::EvaluationStage::kConstant) &&
ty->IsAnyOf<Any, sem::AbstractInt>();
}
@@ -378,7 +378,7 @@
return state.builder.create<sem::F16>();
}
-bool match_f16(MatchState&, const sem::Type* ty) {
+bool match_f16(MatchState&, const type::Type* ty) {
return ty->IsAnyOf<Any, sem::F16, sem::AbstractNumeric>();
}
@@ -386,7 +386,7 @@
return state.builder.create<sem::F32>();
}
-bool match_f32(MatchState&, const sem::Type* ty) {
+bool match_f32(MatchState&, const type::Type* ty) {
return ty->IsAnyOf<Any, sem::F32, sem::AbstractNumeric>();
}
@@ -394,7 +394,7 @@
return state.builder.create<sem::I32>();
}
-bool match_i32(MatchState&, const sem::Type* ty) {
+bool match_i32(MatchState&, const type::Type* ty) {
return ty->IsAnyOf<Any, sem::I32, sem::AbstractInt>();
}
@@ -402,11 +402,11 @@
return state.builder.create<sem::U32>();
}
-bool match_u32(MatchState&, const sem::Type* ty) {
+bool match_u32(MatchState&, const type::Type* ty) {
return ty->IsAnyOf<Any, sem::U32, sem::AbstractInt>();
}
-bool match_vec(MatchState&, const sem::Type* ty, Number& N, const sem::Type*& T) {
+bool match_vec(MatchState&, const type::Type* ty, Number& N, const type::Type*& T) {
if (ty->Is<Any>()) {
N = Number::any;
T = ty;
@@ -422,7 +422,7 @@
}
template <uint32_t N>
-bool match_vec(MatchState&, const sem::Type* ty, const sem::Type*& T) {
+bool match_vec(MatchState&, const type::Type* ty, const type::Type*& T) {
if (ty->Is<Any>()) {
T = ty;
return true;
@@ -437,12 +437,12 @@
return false;
}
-const sem::Vector* build_vec(MatchState& state, Number N, const sem::Type* el) {
+const sem::Vector* build_vec(MatchState& state, Number N, const type::Type* el) {
return state.builder.create<sem::Vector>(el, N.Value());
}
template <uint32_t N>
-const sem::Vector* build_vec(MatchState& state, const sem::Type* el) {
+const sem::Vector* build_vec(MatchState& state, const type::Type* el) {
return state.builder.create<sem::Vector>(el, N);
}
@@ -454,7 +454,7 @@
constexpr auto build_vec3 = build_vec<3>;
constexpr auto build_vec4 = build_vec<4>;
-bool match_mat(MatchState&, const sem::Type* ty, Number& M, Number& N, const sem::Type*& T) {
+bool match_mat(MatchState&, const type::Type* ty, Number& M, Number& N, const type::Type*& T) {
if (ty->Is<Any>()) {
M = Number::any;
N = Number::any;
@@ -471,7 +471,7 @@
}
template <uint32_t C, uint32_t R>
-bool match_mat(MatchState&, const sem::Type* ty, const sem::Type*& T) {
+bool match_mat(MatchState&, const type::Type* ty, const type::Type*& T) {
if (ty->Is<Any>()) {
T = ty;
return true;
@@ -485,13 +485,13 @@
return false;
}
-const sem::Matrix* build_mat(MatchState& state, Number C, Number R, const sem::Type* T) {
+const sem::Matrix* build_mat(MatchState& state, Number C, Number R, const type::Type* T) {
auto* column_type = state.builder.create<sem::Vector>(T, R.Value());
return state.builder.create<sem::Matrix>(column_type, C.Value());
}
template <uint32_t C, uint32_t R>
-const sem::Matrix* build_mat(MatchState& state, const sem::Type* T) {
+const sem::Matrix* build_mat(MatchState& state, const type::Type* T) {
auto* column_type = state.builder.create<sem::Vector>(T, R);
return state.builder.create<sem::Matrix>(column_type, C);
}
@@ -516,14 +516,14 @@
constexpr auto match_mat4x3 = match_mat<4, 3>;
constexpr auto match_mat4x4 = match_mat<4, 4>;
-bool match_array(MatchState&, const sem::Type* ty, const sem::Type*& T) {
+bool match_array(MatchState&, const type::Type* ty, const type::Type*& T) {
if (ty->Is<Any>()) {
T = ty;
return true;
}
if (auto* a = ty->As<sem::Array>()) {
- if (a->Count()->Is<sem::RuntimeArrayCount>()) {
+ if (a->Count()->Is<type::RuntimeArrayCount>()) {
T = a->ElemType();
return true;
}
@@ -531,17 +531,17 @@
return false;
}
-const sem::Array* build_array(MatchState& state, const sem::Type* el) {
+const sem::Array* build_array(MatchState& state, const type::Type* el) {
return state.builder.create<sem::Array>(
el,
- /* count */ state.builder.create<sem::RuntimeArrayCount>(),
+ /* count */ state.builder.create<type::RuntimeArrayCount>(),
/* align */ 0u,
/* size */ 0u,
/* stride */ 0u,
/* stride_implicit */ 0u);
}
-bool match_ptr(MatchState&, const sem::Type* ty, Number& S, const sem::Type*& T, Number& A) {
+bool match_ptr(MatchState&, const type::Type* ty, Number& S, const type::Type*& T, Number& A) {
if (ty->Is<Any>()) {
S = Number::any;
T = ty;
@@ -558,12 +558,12 @@
return false;
}
-const sem::Pointer* build_ptr(MatchState& state, Number S, const sem::Type* T, Number& A) {
+const sem::Pointer* build_ptr(MatchState& state, Number S, const type::Type* T, Number& A) {
return state.builder.create<sem::Pointer>(T, static_cast<ast::AddressSpace>(S.Value()),
static_cast<ast::Access>(A.Value()));
}
-bool match_atomic(MatchState&, const sem::Type* ty, const sem::Type*& T) {
+bool match_atomic(MatchState&, const type::Type* ty, const type::Type*& T) {
if (ty->Is<Any>()) {
T = ty;
return true;
@@ -576,11 +576,11 @@
return false;
}
-const sem::Atomic* build_atomic(MatchState& state, const sem::Type* T) {
+const sem::Atomic* build_atomic(MatchState& state, const type::Type* T) {
return state.builder.create<sem::Atomic>(T);
}
-bool match_sampler(MatchState&, const sem::Type* ty) {
+bool match_sampler(MatchState&, const type::Type* ty) {
if (ty->Is<Any>()) {
return true;
}
@@ -591,7 +591,7 @@
return state.builder.create<sem::Sampler>(ast::SamplerKind::kSampler);
}
-bool match_sampler_comparison(MatchState&, const sem::Type* ty) {
+bool match_sampler_comparison(MatchState&, const type::Type* ty) {
if (ty->Is<Any>()) {
return true;
}
@@ -604,9 +604,9 @@
}
bool match_texture(MatchState&,
- const sem::Type* ty,
+ const type::Type* ty,
ast::TextureDimension dim,
- const sem::Type*& T) {
+ const type::Type*& T) {
if (ty->Is<Any>()) {
T = ty;
return true;
@@ -622,14 +622,14 @@
#define JOIN(a, b) a##b
-#define DECLARE_SAMPLED_TEXTURE(suffix, dim) \
- bool JOIN(match_texture_, suffix)(MatchState & state, const sem::Type* ty, \
- const sem::Type*& T) { \
- return match_texture(state, ty, dim, T); \
- } \
- const sem::SampledTexture* JOIN(build_texture_, suffix)(MatchState & state, \
- const sem::Type* T) { \
- return state.builder.create<sem::SampledTexture>(dim, T); \
+#define DECLARE_SAMPLED_TEXTURE(suffix, dim) \
+ bool JOIN(match_texture_, suffix)(MatchState & state, const type::Type* ty, \
+ const type::Type*& T) { \
+ return match_texture(state, ty, dim, T); \
+ } \
+ const sem::SampledTexture* JOIN(build_texture_, suffix)(MatchState & state, \
+ const type::Type* T) { \
+ return state.builder.create<sem::SampledTexture>(dim, T); \
}
DECLARE_SAMPLED_TEXTURE(1d, ast::TextureDimension::k1d)
@@ -641,9 +641,9 @@
#undef DECLARE_SAMPLED_TEXTURE
bool match_texture_multisampled(MatchState&,
- const sem::Type* ty,
+ const type::Type* ty,
ast::TextureDimension dim,
- const sem::Type*& T) {
+ const type::Type*& T) {
if (ty->Is<Any>()) {
T = ty;
return true;
@@ -657,32 +657,32 @@
return false;
}
-#define DECLARE_MULTISAMPLED_TEXTURE(suffix, dim) \
- bool JOIN(match_texture_multisampled_, suffix)(MatchState & state, const sem::Type* ty, \
- const sem::Type*& T) { \
- return match_texture_multisampled(state, ty, dim, T); \
- } \
- const sem::MultisampledTexture* JOIN(build_texture_multisampled_, suffix)( \
- MatchState & state, const sem::Type* T) { \
- return state.builder.create<sem::MultisampledTexture>(dim, T); \
+#define DECLARE_MULTISAMPLED_TEXTURE(suffix, dim) \
+ bool JOIN(match_texture_multisampled_, suffix)(MatchState & state, const type::Type* ty, \
+ const type::Type*& T) { \
+ return match_texture_multisampled(state, ty, dim, T); \
+ } \
+ const sem::MultisampledTexture* JOIN(build_texture_multisampled_, suffix)( \
+ MatchState & state, const type::Type* T) { \
+ return state.builder.create<sem::MultisampledTexture>(dim, T); \
}
DECLARE_MULTISAMPLED_TEXTURE(2d, ast::TextureDimension::k2d)
#undef DECLARE_MULTISAMPLED_TEXTURE
-bool match_texture_depth(MatchState&, const sem::Type* ty, ast::TextureDimension dim) {
+bool match_texture_depth(MatchState&, const type::Type* ty, ast::TextureDimension dim) {
if (ty->Is<Any>()) {
return true;
}
return ty->Is([&](const sem::DepthTexture* t) { return t->dim() == dim; });
}
-#define DECLARE_DEPTH_TEXTURE(suffix, dim) \
- bool JOIN(match_texture_depth_, suffix)(MatchState & state, const sem::Type* ty) { \
- return match_texture_depth(state, ty, dim); \
- } \
- const sem::DepthTexture* JOIN(build_texture_depth_, suffix)(MatchState & state) { \
- return state.builder.create<sem::DepthTexture>(dim); \
+#define DECLARE_DEPTH_TEXTURE(suffix, dim) \
+ bool JOIN(match_texture_depth_, suffix)(MatchState & state, const type::Type* ty) { \
+ return match_texture_depth(state, ty, dim); \
+ } \
+ const sem::DepthTexture* JOIN(build_texture_depth_, suffix)(MatchState & state) { \
+ return state.builder.create<sem::DepthTexture>(dim); \
}
DECLARE_DEPTH_TEXTURE(2d, ast::TextureDimension::k2d)
@@ -691,7 +691,7 @@
DECLARE_DEPTH_TEXTURE(cube_array, ast::TextureDimension::kCubeArray)
#undef DECLARE_DEPTH_TEXTURE
-bool match_texture_depth_multisampled_2d(MatchState&, const sem::Type* ty) {
+bool match_texture_depth_multisampled_2d(MatchState&, const type::Type* ty) {
if (ty->Is<Any>()) {
return true;
}
@@ -705,7 +705,7 @@
}
bool match_texture_storage(MatchState&,
- const sem::Type* ty,
+ const type::Type* ty,
ast::TextureDimension dim,
Number& F,
Number& A) {
@@ -724,17 +724,17 @@
return false;
}
-#define DECLARE_STORAGE_TEXTURE(suffix, dim) \
- bool JOIN(match_texture_storage_, suffix)(MatchState & state, const sem::Type* ty, Number& F, \
- Number& A) { \
- return match_texture_storage(state, ty, dim, F, A); \
- } \
- const sem::StorageTexture* JOIN(build_texture_storage_, suffix)(MatchState & state, Number F, \
- Number A) { \
- auto format = static_cast<TexelFormat>(F.Value()); \
- auto access = static_cast<Access>(A.Value()); \
- auto* T = sem::StorageTexture::SubtypeFor(format, state.builder.Types()); \
- return state.builder.create<sem::StorageTexture>(dim, format, access, T); \
+#define DECLARE_STORAGE_TEXTURE(suffix, dim) \
+ bool JOIN(match_texture_storage_, suffix)(MatchState & state, const type::Type* ty, Number& F, \
+ Number& A) { \
+ return match_texture_storage(state, ty, dim, F, A); \
+ } \
+ const sem::StorageTexture* JOIN(build_texture_storage_, suffix)(MatchState & state, Number F, \
+ Number A) { \
+ auto format = static_cast<TexelFormat>(F.Value()); \
+ auto access = static_cast<Access>(A.Value()); \
+ auto* T = sem::StorageTexture::SubtypeFor(format, state.builder.Types()); \
+ return state.builder.create<sem::StorageTexture>(dim, format, access, T); \
}
DECLARE_STORAGE_TEXTURE(1d, ast::TextureDimension::k1d)
@@ -743,7 +743,7 @@
DECLARE_STORAGE_TEXTURE(3d, ast::TextureDimension::k3d)
#undef DECLARE_STORAGE_TEXTURE
-bool match_texture_external(MatchState&, const sem::Type* ty) {
+bool match_texture_external(MatchState&, const type::Type* ty) {
return ty->IsAnyOf<Any, sem::ExternalTexture>();
}
@@ -754,14 +754,14 @@
// Builtin types starting with a _ prefix cannot be declared in WGSL, so they
// can only be used as return types. Because of this, they must only match Any,
// which is used as the return type matcher.
-bool match_modf_result(MatchState&, const sem::Type* ty, const sem::Type*& T) {
+bool match_modf_result(MatchState&, const type::Type* ty, const type::Type*& T) {
if (!ty->Is<Any>()) {
return false;
}
T = ty;
return true;
}
-bool match_modf_result_vec(MatchState&, const sem::Type* ty, Number& N, const sem::Type*& T) {
+bool match_modf_result_vec(MatchState&, const type::Type* ty, Number& N, const type::Type*& T) {
if (!ty->Is<Any>()) {
return false;
}
@@ -769,14 +769,14 @@
T = ty;
return true;
}
-bool match_frexp_result(MatchState&, const sem::Type* ty, const sem::Type*& T) {
+bool match_frexp_result(MatchState&, const type::Type* ty, const type::Type*& T) {
if (!ty->Is<Any>()) {
return false;
}
T = ty;
return true;
}
-bool match_frexp_result_vec(MatchState&, const sem::Type* ty, Number& N, const sem::Type*& T) {
+bool match_frexp_result_vec(MatchState&, const type::Type* ty, Number& N, const type::Type*& T) {
if (!ty->Is<Any>()) {
return false;
}
@@ -785,7 +785,7 @@
return true;
}
-bool match_atomic_compare_exchange_result(MatchState&, const sem::Type* ty, const sem::Type*& T) {
+bool match_atomic_compare_exchange_result(MatchState&, const type::Type* ty, const type::Type*& T) {
if (ty->Is<Any>()) {
T = ty;
return true;
@@ -795,7 +795,7 @@
struct NameAndType {
std::string name;
- const sem::Type* type;
+ const type::Type* type;
};
sem::Struct* build_struct(ProgramBuilder& b,
std::string name,
@@ -832,7 +832,7 @@
/* size_no_padding */ size_without_padding);
}
-const sem::Struct* build_modf_result(MatchState& state, const sem::Type* el) {
+const sem::Struct* build_modf_result(MatchState& state, const type::Type* el) {
auto build_f32 = [&] {
auto* ty = state.builder.create<sem::F32>();
return build_struct(state.builder, "__modf_result_f32", {{"fract", ty}, {"whole", ty}});
@@ -859,7 +859,7 @@
});
}
-const sem::Struct* build_modf_result_vec(MatchState& state, Number& n, const sem::Type* el) {
+const sem::Struct* build_modf_result_vec(MatchState& state, Number& n, const type::Type* el) {
auto prefix = "__modf_result_vec" + std::to_string(n.Value());
auto build_f32 = [&] {
auto* vec = state.builder.create<sem::Vector>(state.builder.create<sem::F32>(), n.Value());
@@ -888,7 +888,7 @@
});
}
-const sem::Struct* build_frexp_result(MatchState& state, const sem::Type* el) {
+const sem::Struct* build_frexp_result(MatchState& state, const type::Type* el) {
auto build_f32 = [&] {
auto* f = state.builder.create<sem::F32>();
auto* i = state.builder.create<sem::I32>();
@@ -918,7 +918,7 @@
});
}
-const sem::Struct* build_frexp_result_vec(MatchState& state, Number& n, const sem::Type* el) {
+const sem::Struct* build_frexp_result_vec(MatchState& state, Number& n, const type::Type* el) {
auto prefix = "__frexp_result_vec" + std::to_string(n.Value());
auto build_f32 = [&] {
auto* f = state.builder.create<sem::Vector>(state.builder.create<sem::F32>(), n.Value());
@@ -951,11 +951,11 @@
});
}
-const sem::Struct* build_atomic_compare_exchange_result(MatchState& state, const sem::Type* ty) {
+const sem::Struct* build_atomic_compare_exchange_result(MatchState& state, const type::Type* ty) {
return build_struct(
state.builder,
"__atomic_compare_exchange_result" + ty->FriendlyName(state.builder.Symbols()),
- {{"old_value", const_cast<sem::Type*>(ty)},
+ {{"old_value", const_cast<type::Type*>(ty)},
{"exchanged", state.builder.create<sem::Bool>()}});
}
@@ -1028,7 +1028,7 @@
/// Parameter describes a single parameter
struct Parameter {
/// Parameter type
- const sem::Type* const type;
+ const type::Type* const type;
/// Parameter usage
ParameterUsage const usage = ParameterUsage::kNone;
};
@@ -1047,7 +1047,7 @@
};
const OverloadInfo* overload = nullptr;
- sem::Type const* return_type = nullptr;
+ type::Type const* return_type = nullptr;
utils::Vector<Parameter, kNumFixedParams> parameters;
};
@@ -1073,25 +1073,25 @@
explicit Impl(ProgramBuilder& builder);
Builtin Lookup(sem::BuiltinType builtin_type,
- utils::VectorRef<const sem::Type*> args,
+ utils::VectorRef<const type::Type*> args,
sem::EvaluationStage earliest_eval_stage,
const Source& source) override;
UnaryOperator Lookup(ast::UnaryOp op,
- const sem::Type* arg,
+ const type::Type* arg,
sem::EvaluationStage earliest_eval_stage,
const Source& source) override;
BinaryOperator Lookup(ast::BinaryOp op,
- const sem::Type* lhs,
- const sem::Type* rhs,
+ const type::Type* lhs,
+ const type::Type* rhs,
sem::EvaluationStage earliest_eval_stage,
const Source& source,
bool is_compound) override;
InitOrConv Lookup(InitConvIntrinsic type,
- const sem::Type* template_arg,
- utils::VectorRef<const sem::Type*> args,
+ const type::Type* template_arg,
+ utils::VectorRef<const type::Type*> args,
sem::EvaluationStage earliest_eval_stage,
const Source& source) override;
@@ -1137,7 +1137,7 @@
/// IntrinsicPrototype::return_type.
IntrinsicPrototype MatchIntrinsic(const IntrinsicInfo& intrinsic,
const char* intrinsic_name,
- utils::VectorRef<const sem::Type*> args,
+ utils::VectorRef<const type::Type*> args,
sem::EvaluationStage earliest_eval_stage,
TemplateState templates,
OnNoMatch on_no_match) const;
@@ -1150,7 +1150,7 @@
/// template as `f32`.
/// @returns the evaluated Candidate information.
Candidate ScoreOverload(const OverloadInfo* overload,
- utils::VectorRef<const sem::Type*> args,
+ utils::VectorRef<const type::Type*> args,
sem::EvaluationStage earliest_eval_stage,
TemplateState templates) const;
@@ -1166,7 +1166,7 @@
/// @returns the resolved Candidate.
Candidate ResolveCandidate(Candidates&& candidates,
const char* intrinsic_name,
- utils::VectorRef<const sem::Type*> args,
+ utils::VectorRef<const type::Type*> args,
TemplateState templates) const;
/// Match constructs a new MatchState
@@ -1190,7 +1190,7 @@
/// Raises an error when no overload is a clear winner of overload resolution
void ErrAmbiguousOverload(const char* intrinsic_name,
- utils::VectorRef<const sem::Type*> args,
+ utils::VectorRef<const type::Type*> args,
TemplateState templates,
utils::VectorRef<Candidate> candidates) const;
@@ -1207,8 +1207,8 @@
/// types.
std::string CallSignature(ProgramBuilder& builder,
const char* intrinsic_name,
- utils::VectorRef<const sem::Type*> args,
- const sem::Type* template_arg = nullptr) {
+ utils::VectorRef<const type::Type*> args,
+ const type::Type* template_arg = nullptr) {
std::stringstream ss;
ss << intrinsic_name;
if (template_arg) {
@@ -1241,7 +1241,7 @@
Impl::Impl(ProgramBuilder& b) : builder(b) {}
Impl::Builtin Impl::Lookup(sem::BuiltinType builtin_type,
- utils::VectorRef<const sem::Type*> args,
+ utils::VectorRef<const type::Type*> args,
sem::EvaluationStage earliest_eval_stage,
const Source& source) {
const char* intrinsic_name = sem::str(builtin_type);
@@ -1295,7 +1295,7 @@
}
IntrinsicTable::UnaryOperator Impl::Lookup(ast::UnaryOp op,
- const sem::Type* arg,
+ const type::Type* arg,
sem::EvaluationStage earliest_eval_stage,
const Source& source) {
auto [intrinsic_index, intrinsic_name] = [&]() -> std::pair<size_t, const char*> {
@@ -1341,8 +1341,8 @@
}
IntrinsicTable::BinaryOperator Impl::Lookup(ast::BinaryOp op,
- const sem::Type* lhs,
- const sem::Type* rhs,
+ const type::Type* lhs,
+ const type::Type* rhs,
sem::EvaluationStage earliest_eval_stage,
const Source& source,
bool is_compound) {
@@ -1420,8 +1420,8 @@
}
IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type,
- const sem::Type* template_arg,
- utils::VectorRef<const sem::Type*> args,
+ const type::Type* template_arg,
+ utils::VectorRef<const type::Type*> args,
sem::EvaluationStage earliest_eval_stage,
const Source& source) {
auto name = str(type);
@@ -1499,7 +1499,7 @@
IntrinsicPrototype Impl::MatchIntrinsic(const IntrinsicInfo& intrinsic,
const char* intrinsic_name,
- utils::VectorRef<const sem::Type*> args,
+ utils::VectorRef<const type::Type*> args,
sem::EvaluationStage earliest_eval_stage,
TemplateState templates,
OnNoMatch on_no_match) const {
@@ -1539,7 +1539,7 @@
}
// Build the return type
- const sem::Type* return_type = nullptr;
+ const type::Type* return_type = nullptr;
if (auto* indices = match.overload->return_matcher_indices) {
Any any;
return_type =
@@ -1556,7 +1556,7 @@
}
Impl::Candidate Impl::ScoreOverload(const OverloadInfo* overload,
- utils::VectorRef<const sem::Type*> args,
+ utils::VectorRef<const type::Type*> args,
sem::EvaluationStage earliest_eval_stage,
TemplateState templates) const {
// Penalty weights for overload mismatching.
@@ -1656,7 +1656,7 @@
Impl::Candidate Impl::ResolveCandidate(Impl::Candidates&& candidates,
const char* intrinsic_name,
- utils::VectorRef<const sem::Type*> args,
+ utils::VectorRef<const type::Type*> args,
TemplateState templates) const {
utils::Vector<uint32_t, kNumFixedParams> best_ranks;
best_ranks.Resize(args.Length(), 0xffffffff);
@@ -1669,7 +1669,7 @@
bool some_won = false; // An argument ranked less than the 'best' overload's argument
bool some_lost = false; // An argument ranked more than the 'best' overload's argument
for (size_t i = 0; i < args.Length(); i++) {
- auto rank = sem::Type::ConversionRank(args[i], candidate.parameters[i].type);
+ auto rank = type::Type::ConversionRank(args[i], candidate.parameters[i].type);
if (best_ranks[i] > rank) {
best_ranks[i] = rank;
some_won = true;
@@ -1808,7 +1808,7 @@
}
}
-const sem::Type* MatchState::Type(const sem::Type* ty) {
+const type::Type* MatchState::Type(const type::Type* ty) {
MatcherIndex matcher_index = *matcher_indices_++;
auto* matcher = matchers.type[matcher_index];
return matcher->Match(*this, ty);
@@ -1833,7 +1833,7 @@
}
void Impl::ErrAmbiguousOverload(const char* intrinsic_name,
- utils::VectorRef<const sem::Type*> args,
+ utils::VectorRef<const type::Type*> args,
TemplateState templates,
utils::VectorRef<Candidate> candidates) const {
std::stringstream ss;
diff --git a/src/tint/resolver/intrinsic_table.h b/src/tint/resolver/intrinsic_table.h
index 05ca8d2..c49ed50 100644
--- a/src/tint/resolver/intrinsic_table.h
+++ b/src/tint/resolver/intrinsic_table.h
@@ -53,9 +53,9 @@
/// UnaryOperator describes a resolved unary operator
struct UnaryOperator {
/// The result type of the unary operator
- const sem::Type* result = nullptr;
+ const type::Type* result = nullptr;
/// The type of the parameter of the unary operator
- const sem::Type* parameter = nullptr;
+ const type::Type* parameter = nullptr;
/// The constant evaluation function
ConstEval::Function const_eval_fn = nullptr;
};
@@ -63,11 +63,11 @@
/// BinaryOperator describes a resolved binary operator
struct BinaryOperator {
/// The result type of the binary operator
- const sem::Type* result = nullptr;
+ const type::Type* result = nullptr;
/// The type of LHS parameter of the binary operator
- const sem::Type* lhs = nullptr;
+ const type::Type* lhs = nullptr;
/// The type of RHS parameter of the binary operator
- const sem::Type* rhs = nullptr;
+ const type::Type* rhs = nullptr;
/// The constant evaluation function
ConstEval::Function const_eval_fn = nullptr;
};
@@ -93,7 +93,7 @@
/// @param source the source of the builtin call
/// @return the semantic builtin if found, otherwise nullptr
virtual Builtin Lookup(sem::BuiltinType type,
- utils::VectorRef<const sem::Type*> args,
+ utils::VectorRef<const type::Type*> args,
sem::EvaluationStage earliest_eval_stage,
const Source& source) = 0;
@@ -111,7 +111,7 @@
/// @return the operator call target signature. If the operator was not found
/// UnaryOperator::result will be nullptr.
virtual UnaryOperator Lookup(ast::UnaryOp op,
- const sem::Type* arg,
+ const type::Type* arg,
sem::EvaluationStage earliest_eval_stage,
const Source& source) = 0;
@@ -131,8 +131,8 @@
/// @return the operator call target signature. If the operator was not found
/// BinaryOperator::result will be nullptr.
virtual BinaryOperator Lookup(ast::BinaryOp op,
- const sem::Type* lhs,
- const sem::Type* rhs,
+ const type::Type* lhs,
+ const type::Type* rhs,
sem::EvaluationStage earliest_eval_stage,
const Source& source,
bool is_compound) = 0;
@@ -151,8 +151,8 @@
/// @param source the source of the call
/// @return a sem::TypeInitializer, sem::TypeConversion or nullptr if nothing matched
virtual InitOrConv Lookup(InitConvIntrinsic type,
- const sem::Type* template_arg,
- utils::VectorRef<const sem::Type*> args,
+ const type::Type* template_arg,
+ utils::VectorRef<const type::Type*> args,
sem::EvaluationStage earliest_eval_stage,
const Source& source) = 0;
};
diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl
index 226b16b..3ca1d07 100644
--- a/src/tint/resolver/intrinsic_table.inl
+++ b/src/tint/resolver/intrinsic_table.inl
@@ -30,14 +30,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Bool::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* Bool::Match(MatchState& state, const type::Type* ty) const {
if (!match_bool(state, ty)) {
return nullptr;
}
@@ -56,14 +56,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Ia::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* Ia::Match(MatchState& state, const type::Type* ty) const {
if (!match_ia(state, ty)) {
return nullptr;
}
@@ -84,14 +84,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Fa::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* Fa::Match(MatchState& state, const type::Type* ty) const {
if (!match_fa(state, ty)) {
return nullptr;
}
@@ -112,14 +112,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* I32::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* I32::Match(MatchState& state, const type::Type* ty) const {
if (!match_i32(state, ty)) {
return nullptr;
}
@@ -138,14 +138,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* U32::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* U32::Match(MatchState& state, const type::Type* ty) const {
if (!match_u32(state, ty)) {
return nullptr;
}
@@ -164,14 +164,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* F32::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* F32::Match(MatchState& state, const type::Type* ty) const {
if (!match_f32(state, ty)) {
return nullptr;
}
@@ -190,14 +190,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* F16::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* F16::Match(MatchState& state, const type::Type* ty) const {
if (!match_f16(state, ty)) {
return nullptr;
}
@@ -216,15 +216,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Vec2::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Vec2::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_vec2(state, ty, T)) {
return nullptr;
}
@@ -248,15 +248,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Vec3::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Vec3::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_vec3(state, ty, T)) {
return nullptr;
}
@@ -280,15 +280,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Vec4::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Vec4::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_vec4(state, ty, T)) {
return nullptr;
}
@@ -312,15 +312,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Mat2X2::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Mat2X2::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_mat2x2(state, ty, T)) {
return nullptr;
}
@@ -344,15 +344,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Mat2X3::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Mat2X3::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_mat2x3(state, ty, T)) {
return nullptr;
}
@@ -376,15 +376,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Mat2X4::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Mat2X4::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_mat2x4(state, ty, T)) {
return nullptr;
}
@@ -408,15 +408,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Mat3X2::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Mat3X2::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_mat3x2(state, ty, T)) {
return nullptr;
}
@@ -440,15 +440,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Mat3X3::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Mat3X3::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_mat3x3(state, ty, T)) {
return nullptr;
}
@@ -472,15 +472,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Mat3X4::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Mat3X4::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_mat3x4(state, ty, T)) {
return nullptr;
}
@@ -504,15 +504,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Mat4X2::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Mat4X2::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_mat4x2(state, ty, T)) {
return nullptr;
}
@@ -536,15 +536,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Mat4X3::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Mat4X3::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_mat4x3(state, ty, T)) {
return nullptr;
}
@@ -568,15 +568,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Mat4X4::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Mat4X4::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_mat4x4(state, ty, T)) {
return nullptr;
}
@@ -600,16 +600,16 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Vec::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* Vec::Match(MatchState& state, const type::Type* ty) const {
Number N = Number::invalid;
- const sem::Type* T = nullptr;
+ const type::Type* T = nullptr;
if (!match_vec(state, ty, N, T)) {
return nullptr;
}
@@ -640,17 +640,17 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Mat::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* Mat::Match(MatchState& state, const type::Type* ty) const {
Number N = Number::invalid;
Number M = Number::invalid;
- const sem::Type* T = nullptr;
+ const type::Type* T = nullptr;
if (!match_mat(state, ty, N, M, T)) {
return nullptr;
}
@@ -686,16 +686,16 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Ptr::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* Ptr::Match(MatchState& state, const type::Type* ty) const {
Number S = Number::invalid;
- const sem::Type* T = nullptr;
+ const type::Type* T = nullptr;
Number A = Number::invalid;
if (!match_ptr(state, ty, S, T, A)) {
return nullptr;
@@ -730,15 +730,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Atomic::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Atomic::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_atomic(state, ty, T)) {
return nullptr;
}
@@ -762,15 +762,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Array::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Array::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_array(state, ty, T)) {
return nullptr;
}
@@ -794,14 +794,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Sampler::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* Sampler::Match(MatchState& state, const type::Type* ty) const {
if (!match_sampler(state, ty)) {
return nullptr;
}
@@ -820,14 +820,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* SamplerComparison::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* SamplerComparison::Match(MatchState& state, const type::Type* ty) const {
if (!match_sampler_comparison(state, ty)) {
return nullptr;
}
@@ -846,15 +846,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Texture1D::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Texture1D::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_texture_1d(state, ty, T)) {
return nullptr;
}
@@ -878,15 +878,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Texture2D::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Texture2D::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_texture_2d(state, ty, T)) {
return nullptr;
}
@@ -910,15 +910,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Texture2DArray::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Texture2DArray::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_texture_2d_array(state, ty, T)) {
return nullptr;
}
@@ -942,15 +942,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Texture3D::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* Texture3D::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_texture_3d(state, ty, T)) {
return nullptr;
}
@@ -974,15 +974,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* TextureCube::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* TextureCube::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_texture_cube(state, ty, T)) {
return nullptr;
}
@@ -1006,15 +1006,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* TextureCubeArray::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* TextureCubeArray::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_texture_cube_array(state, ty, T)) {
return nullptr;
}
@@ -1038,15 +1038,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* TextureMultisampled2D::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* TextureMultisampled2D::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_texture_multisampled_2d(state, ty, T)) {
return nullptr;
}
@@ -1070,14 +1070,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* TextureDepth2D::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* TextureDepth2D::Match(MatchState& state, const type::Type* ty) const {
if (!match_texture_depth_2d(state, ty)) {
return nullptr;
}
@@ -1096,14 +1096,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* TextureDepth2DArray::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* TextureDepth2DArray::Match(MatchState& state, const type::Type* ty) const {
if (!match_texture_depth_2d_array(state, ty)) {
return nullptr;
}
@@ -1122,14 +1122,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* TextureDepthCube::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* TextureDepthCube::Match(MatchState& state, const type::Type* ty) const {
if (!match_texture_depth_cube(state, ty)) {
return nullptr;
}
@@ -1148,14 +1148,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* TextureDepthCubeArray::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* TextureDepthCubeArray::Match(MatchState& state, const type::Type* ty) const {
if (!match_texture_depth_cube_array(state, ty)) {
return nullptr;
}
@@ -1174,14 +1174,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* TextureDepthMultisampled2D::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* TextureDepthMultisampled2D::Match(MatchState& state, const type::Type* ty) const {
if (!match_texture_depth_multisampled_2d(state, ty)) {
return nullptr;
}
@@ -1200,14 +1200,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* TextureStorage1D::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* TextureStorage1D::Match(MatchState& state, const type::Type* ty) const {
Number F = Number::invalid;
Number A = Number::invalid;
if (!match_texture_storage_1d(state, ty, F, A)) {
@@ -1238,14 +1238,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* TextureStorage2D::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* TextureStorage2D::Match(MatchState& state, const type::Type* ty) const {
Number F = Number::invalid;
Number A = Number::invalid;
if (!match_texture_storage_2d(state, ty, F, A)) {
@@ -1276,14 +1276,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* TextureStorage2DArray::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* TextureStorage2DArray::Match(MatchState& state, const type::Type* ty) const {
Number F = Number::invalid;
Number A = Number::invalid;
if (!match_texture_storage_2d_array(state, ty, F, A)) {
@@ -1314,14 +1314,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* TextureStorage3D::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* TextureStorage3D::Match(MatchState& state, const type::Type* ty) const {
Number F = Number::invalid;
Number A = Number::invalid;
if (!match_texture_storage_3d(state, ty, F, A)) {
@@ -1352,14 +1352,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* TextureExternal::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* TextureExternal::Match(MatchState& state, const type::Type* ty) const {
if (!match_texture_external(state, ty)) {
return nullptr;
}
@@ -1378,15 +1378,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* ModfResult::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* ModfResult::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_modf_result(state, ty, T)) {
return nullptr;
}
@@ -1412,16 +1412,16 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* ModfResultVec::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* ModfResultVec::Match(MatchState& state, const type::Type* ty) const {
Number N = Number::invalid;
- const sem::Type* T = nullptr;
+ const type::Type* T = nullptr;
if (!match_modf_result_vec(state, ty, N, T)) {
return nullptr;
}
@@ -1452,15 +1452,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* FrexpResult::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* FrexpResult::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_frexp_result(state, ty, T)) {
return nullptr;
}
@@ -1486,16 +1486,16 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* FrexpResultVec::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* FrexpResultVec::Match(MatchState& state, const type::Type* ty) const {
Number N = Number::invalid;
- const sem::Type* T = nullptr;
+ const type::Type* T = nullptr;
if (!match_frexp_result_vec(state, ty, N, T)) {
return nullptr;
}
@@ -1526,15 +1526,15 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* AtomicCompareExchangeResult::Match(MatchState& state, const sem::Type* ty) const {
- const sem::Type* T = nullptr;
+const type::Type* AtomicCompareExchangeResult::Match(MatchState& state, const type::Type* ty) const {
+ const type::Type* T = nullptr;
if (!match_atomic_compare_exchange_result(state, ty, T)) {
return nullptr;
}
@@ -1559,14 +1559,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Scalar::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* Scalar::Match(MatchState& state, const type::Type* ty) const {
if (match_ia(state, ty)) {
return build_ia(state);
}
@@ -1608,14 +1608,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* ConcreteScalar::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* ConcreteScalar::Match(MatchState& state, const type::Type* ty) const {
if (match_i32(state, ty)) {
return build_i32(state);
}
@@ -1651,14 +1651,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* ScalarNoF32::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* ScalarNoF32::Match(MatchState& state, const type::Type* ty) const {
if (match_ia(state, ty)) {
return build_ia(state);
}
@@ -1697,14 +1697,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* ScalarNoF16::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* ScalarNoF16::Match(MatchState& state, const type::Type* ty) const {
if (match_ia(state, ty)) {
return build_ia(state);
}
@@ -1743,14 +1743,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* ScalarNoI32::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* ScalarNoI32::Match(MatchState& state, const type::Type* ty) const {
if (match_ia(state, ty)) {
return build_ia(state);
}
@@ -1789,14 +1789,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* ScalarNoU32::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* ScalarNoU32::Match(MatchState& state, const type::Type* ty) const {
if (match_ia(state, ty)) {
return build_ia(state);
}
@@ -1835,14 +1835,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* ScalarNoBool::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* ScalarNoBool::Match(MatchState& state, const type::Type* ty) const {
if (match_ia(state, ty)) {
return build_ia(state);
}
@@ -1881,14 +1881,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* FiaFiu32F16::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* FiaFiu32F16::Match(MatchState& state, const type::Type* ty) const {
if (match_ia(state, ty)) {
return build_ia(state);
}
@@ -1927,14 +1927,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* FiaFi32F16::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* FiaFi32F16::Match(MatchState& state, const type::Type* ty) const {
if (match_ia(state, ty)) {
return build_ia(state);
}
@@ -1970,14 +1970,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* FiaFiu32::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* FiaFiu32::Match(MatchState& state, const type::Type* ty) const {
if (match_ia(state, ty)) {
return build_ia(state);
}
@@ -2013,14 +2013,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* FaF32::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* FaF32::Match(MatchState& state, const type::Type* ty) const {
if (match_fa(state, ty)) {
return build_fa(state);
}
@@ -2047,14 +2047,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* FaF32F16::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* FaF32F16::Match(MatchState& state, const type::Type* ty) const {
if (match_fa(state, ty)) {
return build_fa(state);
}
@@ -2084,14 +2084,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* IaIu32::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* IaIu32::Match(MatchState& state, const type::Type* ty) const {
if (match_ia(state, ty)) {
return build_ia(state);
}
@@ -2121,14 +2121,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Fiu32F16::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* Fiu32F16::Match(MatchState& state, const type::Type* ty) const {
if (match_i32(state, ty)) {
return build_i32(state);
}
@@ -2161,14 +2161,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Fiu32::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* Fiu32::Match(MatchState& state, const type::Type* ty) const {
if (match_i32(state, ty)) {
return build_i32(state);
}
@@ -2198,14 +2198,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Fi32F16::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* Fi32F16::Match(MatchState& state, const type::Type* ty) const {
if (match_i32(state, ty)) {
return build_i32(state);
}
@@ -2235,14 +2235,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Fi32::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* Fi32::Match(MatchState& state, const type::Type* ty) const {
if (match_i32(state, ty)) {
return build_i32(state);
}
@@ -2269,14 +2269,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* F32F16::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* F32F16::Match(MatchState& state, const type::Type* ty) const {
if (match_f32(state, ty)) {
return build_f32(state);
}
@@ -2303,14 +2303,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* Iu32::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* Iu32::Match(MatchState& state, const type::Type* ty) const {
if (match_i32(state, ty)) {
return build_i32(state);
}
diff --git a/src/tint/resolver/intrinsic_table.inl.tmpl b/src/tint/resolver/intrinsic_table.inl.tmpl
index 834d300..e8f87b8 100644
--- a/src/tint/resolver/intrinsic_table.inl.tmpl
+++ b/src/tint/resolver/intrinsic_table.inl.tmpl
@@ -190,14 +190,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* {{$class}}::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* {{$class}}::Match(MatchState& state, const type::Type* ty) const {
{{- range .TemplateParams }}
{{- template "DeclareLocalTemplateParam" . }}
{{- end }}
@@ -245,14 +245,14 @@
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
- const sem::Type* Match(MatchState& state,
- const sem::Type* type) const override;
+ const type::Type* Match(MatchState& state,
+ const type::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
-const sem::Type* {{$class}}::Match(MatchState& state, const sem::Type* ty) const {
+const type::Type* {{$class}}::Match(MatchState& state, const type::Type* ty) const {
{{- range .PrecedenceSortedTypes }}
if (match_{{.Name}}(state, ty)) {
return build_{{.Name}}(state);
@@ -400,7 +400,7 @@
{{- define "DeclareLocalTemplateParam" -}}
{{- /* ------------------------------------------------------------------ */ -}}
{{- if IsTemplateTypeParam . }}
- const sem::Type* {{.Name}} = nullptr;
+ const type::Type* {{.Name}} = nullptr;
{{- else if IsTemplateNumberParam . }}
Number {{.Name}} = Number::invalid;
{{- else if IsTemplateEnumParam . }}
diff --git a/src/tint/resolver/intrinsic_table_test.cc b/src/tint/resolver/intrinsic_table_test.cc
index 03255df..d96fcd7 100644
--- a/src/tint/resolver/intrinsic_table_test.cc
+++ b/src/tint/resolver/intrinsic_table_test.cc
@@ -27,9 +27,9 @@
#include "src/tint/sem/reference.h"
#include "src/tint/sem/sampled_texture.h"
#include "src/tint/sem/storage_texture.h"
-#include "src/tint/sem/test_helper.h"
#include "src/tint/sem/type_conversion.h"
#include "src/tint/sem/type_initializer.h"
+#include "src/tint/type/test_helper.h"
namespace tint::resolver {
namespace {
@@ -253,7 +253,7 @@
TEST_F(IntrinsicTableTest, MatchArray) {
auto* arr =
- create<sem::Array>(create<sem::U32>(), create<sem::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
+ create<sem::Array>(create<sem::U32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
auto* arr_ptr = create<sem::Pointer>(arr, ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto result = table->Lookup(BuiltinType::kArrayLength, utils::Vector{arr_ptr},
sem::EvaluationStage::kConstant, Source{});
@@ -957,7 +957,7 @@
TEST_F(IntrinsicTableTest, MismatchTypeConversion) {
auto* arr =
- create<sem::Array>(create<sem::U32>(), create<sem::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
+ create<sem::Array>(create<sem::U32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
auto* f32 = create<sem::F32>();
auto result = table->Lookup(InitConvIntrinsic::kVec3, f32, utils::Vector{arr},
sem::EvaluationStage::kConstant, Source{{12, 34}});
@@ -1017,7 +1017,7 @@
TEST_F(IntrinsicTableTest, Err257Arguments) { // crbug.com/1323605
auto* f32 = create<sem::F32>();
- utils::Vector<const sem::Type*, 0> arg_tys;
+ utils::Vector<const type::Type*, 0> arg_tys;
arg_tys.Resize(257, f32);
auto result = table->Lookup(BuiltinType::kAbs, std::move(arg_tys),
sem::EvaluationStage::kConstant, Source{});
diff --git a/src/tint/resolver/is_host_shareable_test.cc b/src/tint/resolver/is_host_shareable_test.cc
index 5e1555b..c106020 100644
--- a/src/tint/resolver/is_host_shareable_test.cc
+++ b/src/tint/resolver/is_host_shareable_test.cc
@@ -106,14 +106,14 @@
}
TEST_F(ResolverIsHostShareable, ArraySizedOfHostShareable) {
- auto* arr = create<sem::Array>(create<sem::I32>(), create<sem::ConstantArrayCount>(5u), 4u, 20u,
- 4u, 4u);
+ auto* arr = create<sem::Array>(create<sem::I32>(), create<type::ConstantArrayCount>(5u), 4u,
+ 20u, 4u, 4u);
EXPECT_TRUE(r()->IsHostShareable(arr));
}
TEST_F(ResolverIsHostShareable, ArrayUnsizedOfHostShareable) {
auto* arr =
- create<sem::Array>(create<sem::I32>(), create<sem::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
+ create<sem::Array>(create<sem::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
EXPECT_TRUE(r()->IsHostShareable(arr));
}
diff --git a/src/tint/resolver/is_storeable_test.cc b/src/tint/resolver/is_storeable_test.cc
index 6618199..9c80e0a 100644
--- a/src/tint/resolver/is_storeable_test.cc
+++ b/src/tint/resolver/is_storeable_test.cc
@@ -89,14 +89,14 @@
}
TEST_F(ResolverIsStorableTest, ArraySizedOfStorable) {
- auto* arr = create<sem::Array>(create<sem::I32>(), create<sem::ConstantArrayCount>(5u), 4u, 20u,
- 4u, 4u);
+ auto* arr = create<sem::Array>(create<sem::I32>(), create<type::ConstantArrayCount>(5u), 4u,
+ 20u, 4u, 4u);
EXPECT_TRUE(r()->IsStorable(arr));
}
TEST_F(ResolverIsStorableTest, ArrayUnsizedOfStorable) {
auto* arr =
- create<sem::Array>(create<sem::I32>(), create<sem::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
+ create<sem::Array>(create<sem::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
EXPECT_TRUE(r()->IsStorable(arr));
}
diff --git a/src/tint/resolver/materialize_test.cc b/src/tint/resolver/materialize_test.cc
index be8d400..24d9999 100644
--- a/src/tint/resolver/materialize_test.cc
+++ b/src/tint/resolver/materialize_test.cc
@@ -16,7 +16,7 @@
#include "src/tint/resolver/resolver.h"
#include "src/tint/resolver/resolver_test_helper.h"
-#include "src/tint/sem/test_helper.h"
+#include "src/tint/type/test_helper.h"
#include "gmock/gmock.h"
@@ -77,7 +77,7 @@
using ProgramBuilder::FriendlyName;
void CheckTypesAndValues(const sem::Expression* expr,
- const tint::sem::Type* expected_sem_ty,
+ const tint::type::Type* expected_sem_ty,
const std::variant<AInt, AFloat>& expected_value) {
std::visit([&](auto v) { CheckTypesAndValuesImpl(expr, expected_sem_ty, v); },
expected_value);
@@ -86,7 +86,7 @@
private:
template <typename T>
void CheckTypesAndValuesImpl(const sem::Expression* expr,
- const tint::sem::Type* expected_sem_ty,
+ const tint::type::Type* expected_sem_ty,
T expected_value) {
EXPECT_TYPE(expr->Type(), expected_sem_ty);
diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc
index e47f83c..ee4f628 100644
--- a/src/tint/resolver/resolver.cc
+++ b/src/tint/resolver/resolver.cc
@@ -199,7 +199,7 @@
return result;
}
-sem::Type* Resolver::Type(const ast::Type* ty) {
+type::Type* Resolver::Type(const ast::Type* ty) {
Mark(ty);
auto* s = Switch(
ty, //
@@ -317,7 +317,7 @@
auto* resolved = sem_.ResolvedSymbol(ty);
return Switch(
resolved, //
- [&](sem::Type* type) { return type; },
+ [&](type::Type* type) { return type; },
[&](sem::Variable* var) {
auto name = builder_->Symbols().NameFor(var->Declaration()->symbol);
AddError("cannot use variable '" + name + "' as type", ty->source);
@@ -330,7 +330,7 @@
AddNote("'" + name + "' declared here", func->Declaration()->source);
return nullptr;
},
- [&](Default) -> sem::Type* {
+ [&](Default) -> type::Type* {
if (auto* tn = ty->As<ast::TypeName>()) {
if (IsBuiltin(tn->name)) {
auto name = builder_->Symbols().NameFor(tn->name);
@@ -371,7 +371,7 @@
}
sem::Variable* Resolver::Let(const ast::Let* v, bool is_global) {
- const sem::Type* ty = nullptr;
+ const type::Type* ty = nullptr;
// If the variable has a declared type, resolve it.
if (v->type) {
@@ -402,7 +402,7 @@
return nullptr;
}
- if (!ApplyAddressSpaceUsageToType(ast::AddressSpace::kNone, const_cast<sem::Type*>(ty),
+ if (!ApplyAddressSpaceUsageToType(ast::AddressSpace::kNone, const_cast<type::Type*>(ty),
v->source)) {
AddNote("while instantiating 'let' " + builder_->Symbols().NameFor(v->symbol), v->source);
return nullptr;
@@ -427,7 +427,7 @@
}
sem::Variable* Resolver::Override(const ast::Override* v) {
- const sem::Type* ty = nullptr;
+ const type::Type* ty = nullptr;
// If the variable has a declared type, resolve it.
if (v->type) {
@@ -461,7 +461,7 @@
return nullptr;
}
- if (!ApplyAddressSpaceUsageToType(ast::AddressSpace::kNone, const_cast<sem::Type*>(ty),
+ if (!ApplyAddressSpaceUsageToType(ast::AddressSpace::kNone, const_cast<type::Type*>(ty),
v->source)) {
AddNote("while instantiating 'override' " + builder_->Symbols().NameFor(v->symbol),
v->source);
@@ -511,7 +511,7 @@
}
sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) {
- const sem::Type* ty = nullptr;
+ const type::Type* ty = nullptr;
// If the variable has a declared type, resolve it.
if (c->type) {
@@ -551,7 +551,7 @@
return nullptr;
}
- if (!ApplyAddressSpaceUsageToType(ast::AddressSpace::kNone, const_cast<sem::Type*>(ty),
+ if (!ApplyAddressSpaceUsageToType(ast::AddressSpace::kNone, const_cast<type::Type*>(ty),
c->source)) {
AddNote("while instantiating 'const' " + builder_->Symbols().NameFor(c->symbol), c->source);
return nullptr;
@@ -571,7 +571,7 @@
}
sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) {
- const sem::Type* storage_ty = nullptr;
+ const type::Type* storage_ty = nullptr;
// If the variable has a declared type, resolve it.
if (auto* ty = var->type) {
@@ -738,7 +738,7 @@
return nullptr;
}
- sem::Type* ty = Type(param->type);
+ type::Type* ty = Type(param->type);
if (!ty) {
return nullptr;
}
@@ -752,7 +752,7 @@
// For MSL, we push module-scope variables into the entry point as pointer
// parameters, so we also need to handle their store type.
if (!ApplyAddressSpaceUsageToType(
- ptr->AddressSpace(), const_cast<sem::Type*>(ptr->StoreType()), param->source)) {
+ ptr->AddressSpace(), const_cast<type::Type*>(ptr->StoreType()), param->source)) {
add_note();
return nullptr;
}
@@ -887,10 +887,18 @@
void Resolver::SetShadows() {
for (auto it : dependencies_.shadows) {
+ CastableBase* b = sem_.Get(it.value);
+ if (!b) {
+ TINT_ICE(Resolver, builder_->Diagnostics())
+ << "AST node '" << it.value->TypeInfo().name << "' had no semantic info\n"
+ << "At: " << it.value->source << "\n"
+ << "Pointer: " << it.value;
+ }
+
Switch(
sem_.Get(it.key), //
- [&](sem::LocalVariable* local) { local->SetShadows(sem_.Get(it.value)); },
- [&](sem::Parameter* param) { param->SetShadows(sem_.Get(it.value)); });
+ [&](sem::LocalVariable* local) { local->SetShadows(b); },
+ [&](sem::Parameter* param) { param->SetShadows(b); });
}
}
@@ -984,7 +992,7 @@
parameters.Push(p);
- auto* p_ty = const_cast<sem::Type*>(p->Type());
+ auto* p_ty = const_cast<type::Type*>(p->Type());
if (auto* str = p_ty->As<sem::Struct>()) {
switch (decl->PipelineStage()) {
case ast::PipelineStage::kVertex:
@@ -1003,7 +1011,7 @@
}
// Resolve the return type
- sem::Type* return_type = nullptr;
+ type::Type* return_type = nullptr;
if (auto* ty = decl->return_type) {
return_type = Type(ty);
if (!return_type) {
@@ -1129,7 +1137,7 @@
auto values = attr->Values();
utils::Vector<const sem::Expression*, 3> args;
- utils::Vector<const sem::Type*, 3> arg_tys;
+ utils::Vector<const type::Type*, 3> arg_tys;
constexpr const char* kErrBadExpr =
"workgroup_size argument must be a constant or override-expression of type "
@@ -1162,7 +1170,7 @@
arg_tys.Push(ty);
}
- auto* common_ty = sem::Type::Common(arg_tys);
+ auto* common_ty = type::Type::Common(arg_tys);
if (!common_ty) {
AddError("workgroup_size arguments must be of the same type, either i32 or u32",
attr->source);
@@ -1266,7 +1274,7 @@
});
}
-sem::CaseStatement* Resolver::CaseStatement(const ast::CaseStatement* stmt, const sem::Type* ty) {
+sem::CaseStatement* Resolver::CaseStatement(const ast::CaseStatement* stmt, const type::Type* ty) {
auto* sem =
builder_->create<sem::CaseStatement>(stmt, current_compound_statement_, current_function_);
return StatementScope(stmt, sem, [&] {
@@ -1705,9 +1713,9 @@
return true;
}
-const sem::Type* Resolver::ConcreteType(const sem::Type* ty,
- const sem::Type* target_ty,
- const Source& source) {
+const type::Type* Resolver::ConcreteType(const type::Type* ty,
+ const type::Type* target_ty,
+ const Source& source) {
auto i32 = [&] { return builder_->create<sem::I32>(); };
auto f32 = [&] { return builder_->create<sem::F32>(); };
auto i32v = [&](uint32_t width) { return builder_->create<sem::Vector>(i32(), width); };
@@ -1734,8 +1742,8 @@
return target_ty ? target_ty : f32m(m->columns(), m->rows());
});
},
- [&](const sem::Array* a) -> const sem::Type* {
- const sem::Type* target_el_ty = nullptr;
+ [&](const sem::Array* a) -> const type::Type* {
+ const type::Type* target_el_ty = nullptr;
if (auto* target_arr_ty = As<sem::Array>(target_ty)) {
target_el_ty = target_arr_ty->ElemType();
}
@@ -1744,7 +1752,7 @@
}
return nullptr;
},
- [&](const sem::Struct* s) -> const sem::Type* {
+ [&](const sem::Struct* s) -> const type::Type* {
if (auto tys = s->ConcreteTypes(); !tys.IsEmpty()) {
return target_ty ? target_ty : tys[0];
}
@@ -1753,7 +1761,7 @@
}
const sem::Expression* Resolver::Materialize(const sem::Expression* expr,
- const sem::Type* target_type /* = nullptr */) {
+ const type::Type* target_type /* = nullptr */) {
if (!expr) {
// Allow for Materialize(Expression(blah)), where failures pass through Materialize()
return nullptr;
@@ -1813,12 +1821,12 @@
return true;
}
-bool Resolver::ShouldMaterializeArgument(const sem::Type* parameter_ty) const {
- const auto* param_el_ty = sem::Type::DeepestElementOf(parameter_ty);
+bool Resolver::ShouldMaterializeArgument(const type::Type* parameter_ty) const {
+ const auto* param_el_ty = type::Type::DeepestElementOf(parameter_ty);
return param_el_ty && !param_el_ty->Is<sem::AbstractNumeric>();
}
-bool Resolver::Convert(const sem::Constant*& c, const sem::Type* target_ty, const Source& source) {
+bool Resolver::Convert(const sem::Constant*& c, const type::Type* target_ty, const Source& source) {
auto r = const_eval_.Convert(target_ty, c, source);
if (!r) {
return false;
@@ -1963,7 +1971,7 @@
// ct_init_or_conv is a helper for building either a sem::TypeInitializer or
// sem::TypeConversion call for a InitConvIntrinsic with an optional template argument type.
- auto ct_init_or_conv = [&](InitConvIntrinsic ty, const sem::Type* template_arg) -> sem::Call* {
+ auto ct_init_or_conv = [&](InitConvIntrinsic ty, const type::Type* template_arg) -> sem::Call* {
auto arg_tys = utils::Transform(args, [](auto* arg) { return arg->Type(); });
auto ctor_or_conv =
intrinsic_table_->Lookup(ty, template_arg, arg_tys, args_stage, expr->source);
@@ -1993,7 +2001,7 @@
// arr_or_str_init is a helper for building a sem::TypeInitializer for an array or structure
// initializer call target.
- auto arr_or_str_init = [&](const sem::Type* ty,
+ auto arr_or_str_init = [&](const type::Type* ty,
const sem::CallTarget* call_target) -> sem::Call* {
if (!MaybeMaterializeArguments(args, call_target)) {
return nullptr;
@@ -2023,7 +2031,7 @@
// ty_init_or_conv is a helper for building either a sem::TypeInitializer or
// sem::TypeConversion call for the given semantic type.
- auto ty_init_or_conv = [&](const sem::Type* ty) {
+ auto ty_init_or_conv = [&](const type::Type* ty) {
return Switch(
ty, //
[&](const sem::Vector* v) {
@@ -2110,7 +2118,7 @@
[&](const ast::Vector* v) -> sem::Call* {
Mark(v);
// vector element type must be inferred if it was not specified.
- sem::Type* template_arg = nullptr;
+ type::Type* template_arg = nullptr;
if (v->type) {
template_arg = Type(v->type);
if (!template_arg) {
@@ -2126,7 +2134,7 @@
[&](const ast::Matrix* m) -> sem::Call* {
Mark(m);
// matrix element type must be inferred if it was not specified.
- sem::Type* template_arg = nullptr;
+ type::Type* template_arg = nullptr;
if (m->type) {
template_arg = Type(m->type);
if (!template_arg) {
@@ -2143,8 +2151,8 @@
[&](const ast::Array* a) -> sem::Call* {
Mark(a);
// array element type must be inferred if it was not specified.
- const sem::ArrayCount* el_count = nullptr;
- const sem::Type* el_ty = nullptr;
+ const type::ArrayCount* el_count = nullptr;
+ const type::Type* el_ty = nullptr;
if (a->type) {
el_ty = Type(a->type);
if (!el_ty) {
@@ -2161,16 +2169,16 @@
// Note: validation later will detect any mismatches between explicit array
// size and number of initializer expressions.
} else {
- el_count = builder_->create<sem::ConstantArrayCount>(
+ el_count = builder_->create<type::ConstantArrayCount>(
static_cast<uint32_t>(args.Length()));
auto arg_tys =
utils::Transform(args, [](auto* arg) { return arg->Type()->UnwrapRef(); });
- el_ty = sem::Type::Common(arg_tys);
+ el_ty = type::Type::Common(arg_tys);
if (!el_ty) {
AddError(
"cannot infer common array element type from initializer arguments",
expr->source);
- utils::Hashset<const sem::Type*, 8> types;
+ utils::Hashset<const type::Type*, 8> types;
for (size_t i = 0; i < args.Length(); i++) {
if (types.Add(args[i]->Type())) {
AddNote("argument " + std::to_string(i) + " is of type '" +
@@ -2216,16 +2224,17 @@
// conversion.
auto* ident = expr->target.name;
Mark(ident);
- auto* resolved = sem_.ResolvedSymbol(ident);
+ if (auto* resolved = sem_.ResolvedSymbol<type::Type>(ident)) {
+ // A type initializer or conversions.
+ // Note: Unlike the code path where we're resolving the call target from an
+ // ast::Type, all types must already have the element type explicitly specified,
+ // so there's no need to infer element types.
+ return ty_init_or_conv(resolved);
+ }
+
+ auto* resolved = sem_.ResolvedSymbol<sem::Node>(ident);
call = Switch<sem::Call*>(
resolved, //
- [&](sem::Type* ty) {
- // A type initializer or conversions.
- // Note: Unlike the code path where we're resolving the call target from an
- // ast::Type, all types must already have the element type explicitly specified,
- // so there's no need to infer element types.
- return ty_init_or_conv(ty);
- },
[&](sem::Function* func) { return FunctionCall(expr, func, args, arg_behaviors); },
[&](sem::Variable* var) {
auto name = builder_->Symbols().NameFor(var->Declaration()->symbol);
@@ -2337,7 +2346,7 @@
return call;
}
-sem::Type* Resolver::BuiltinTypeAlias(Symbol sym) const {
+type::Type* Resolver::BuiltinTypeAlias(Symbol sym) const {
auto name = builder_->Symbols().NameFor(sym);
auto& b = *builder_;
switch (ParseTypeAlias(name)) {
@@ -2471,7 +2480,7 @@
sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) {
auto* ty = Switch(
literal,
- [&](const ast::IntLiteralExpression* i) -> sem::Type* {
+ [&](const ast::IntLiteralExpression* i) -> type::Type* {
switch (i->suffix) {
case ast::IntLiteralExpression::Suffix::kNone:
return builder_->create<sem::AbstractInt>();
@@ -2482,7 +2491,7 @@
}
return nullptr;
},
- [&](const ast::FloatLiteralExpression* f) -> sem::Type* {
+ [&](const ast::FloatLiteralExpression* f) -> type::Type* {
switch (f->suffix) {
case ast::FloatLiteralExpression::Suffix::kNone:
return builder_->create<sem::AbstractFloat>();
@@ -2520,8 +2529,8 @@
sem::Expression* Resolver::Identifier(const ast::IdentifierExpression* expr) {
auto symbol = expr->symbol;
- auto* resolved = sem_.ResolvedSymbol(expr);
- if (auto* variable = As<sem::Variable>(resolved)) {
+ auto* sem_resolved = sem_.ResolvedSymbol<sem::Node>(expr);
+ if (auto* variable = As<sem::Variable>(sem_resolved)) {
auto* user = builder_->create<sem::VariableUser>(expr, current_statement_, variable);
if (current_statement_) {
@@ -2589,7 +2598,7 @@
return user;
}
- if (Is<sem::Function>(resolved)) {
+ if (Is<sem::Function>(sem_resolved)) {
AddError("missing '(' for function call", expr->source.End());
return nullptr;
}
@@ -2599,14 +2608,14 @@
return nullptr;
}
- if (resolved->Is<sem::Type>() || BuiltinTypeAlias(symbol)) {
+ if (sem_.ResolvedSymbol<type::Type>(expr)) {
AddError("missing '(' for type initializer or cast", expr->source.End());
return nullptr;
}
TINT_ICE(Resolver, diagnostics_)
<< expr->source << " unresolved identifier:\n"
- << "resolved: " << (resolved ? resolved->TypeInfo().name : "<null>") << "\n"
+ << "resolved: " << (sem_resolved ? sem_resolved->TypeInfo().name : "<null>") << "\n"
<< "name: " << builder_->Symbols().NameFor(symbol);
return nullptr;
}
@@ -2617,7 +2626,7 @@
auto* object = sem_.Get(expr->structure);
auto* root_ident = object->RootIdentifier();
- const sem::Type* ty = nullptr;
+ const type::Type* ty = nullptr;
// Object may be a side-effecting expression (e.g. function call).
bool has_side_effects = object && object->HasSideEffects();
@@ -2812,7 +2821,7 @@
return nullptr;
}
- const sem::Type* ty = nullptr;
+ const type::Type* ty = nullptr;
const sem::Variable* root_ident = nullptr;
const sem::Constant* value = nullptr;
auto stage = sem::EvaluationStage::kRuntime;
@@ -2898,8 +2907,8 @@
return true;
}
-sem::Type* Resolver::TypeDecl(const ast::TypeDecl* named_type) {
- sem::Type* result = nullptr;
+type::Type* Resolver::TypeDecl(const ast::TypeDecl* named_type) {
+ type::Type* result = nullptr;
if (auto* alias = named_type->As<ast::Alias>()) {
result = Alias(alias);
} else if (auto* str = named_type->As<ast::Struct>()) {
@@ -2936,7 +2945,7 @@
return nullptr;
}
- const sem::ArrayCount* el_count = nullptr;
+ const type::ArrayCount* el_count = nullptr;
// Evaluate the constant array count expression.
if (auto* count_expr = arr->count) {
@@ -2945,7 +2954,7 @@
return nullptr;
}
} else {
- el_count = builder_->create<sem::RuntimeArrayCount>();
+ el_count = builder_->create<type::RuntimeArrayCount>();
}
auto* out = Array(arr->type->source, //
@@ -2972,7 +2981,7 @@
return out;
}
-const sem::ArrayCount* Resolver::ArrayCount(const ast::Expression* count_expr) {
+const type::ArrayCount* Resolver::ArrayCount(const ast::Expression* count_expr) {
// Evaluate the constant array count expression.
const auto* count_sem = Materialize(Expression(count_expr));
if (!count_sem) {
@@ -3011,11 +3020,11 @@
return nullptr;
}
- return builder_->create<sem::ConstantArrayCount>(static_cast<uint32_t>(count));
+ return builder_->create<type::ConstantArrayCount>(static_cast<uint32_t>(count));
}
bool Resolver::ArrayAttributes(utils::VectorRef<const ast::Attribute*> attributes,
- const sem::Type* el_ty,
+ const type::Type* el_ty,
uint32_t& explicit_stride) {
if (!validator_.NoDuplicateAttributes(attributes)) {
return false;
@@ -3046,8 +3055,8 @@
sem::Array* Resolver::Array(const Source& el_source,
const Source& count_source,
- const sem::Type* el_ty,
- const sem::ArrayCount* el_count,
+ const type::Type* el_ty,
+ const type::ArrayCount* el_count,
uint32_t explicit_stride) {
uint32_t el_align = el_ty->Align();
uint32_t el_size = el_ty->Size();
@@ -3055,7 +3064,7 @@
uint64_t stride = explicit_stride ? explicit_stride : implicit_stride;
uint64_t size = 0;
- if (auto const_count = el_count->As<sem::ConstantArrayCount>()) {
+ if (auto const_count = el_count->As<type::ConstantArrayCount>()) {
size = const_count->value * stride;
if (size > std::numeric_limits<uint32_t>::max()) {
std::stringstream msg;
@@ -3064,7 +3073,7 @@
AddError(msg.str(), count_source);
return nullptr;
}
- } else if (el_count->Is<sem::RuntimeArrayCount>()) {
+ } else if (el_count->Is<type::RuntimeArrayCount>()) {
size = stride;
}
auto* out = builder_->create<sem::Array>(el_ty, el_count, el_align, static_cast<uint32_t>(size),
@@ -3078,7 +3087,7 @@
return out;
}
-sem::Type* Resolver::Alias(const ast::Alias* alias) {
+type::Type* Resolver::Alias(const ast::Alias* alias) {
auto* ty = Type(alias->type);
if (!ty) {
return nullptr;
@@ -3329,7 +3338,7 @@
auto& behaviors = current_statement_->Behaviors();
behaviors = sem::Behavior::kReturn;
- const sem::Type* value_ty = nullptr;
+ const type::Type* value_ty = nullptr;
if (auto* value = stmt->value) {
const auto* expr = Expression(value);
if (!expr) {
@@ -3374,7 +3383,7 @@
// Determine the common type across all selectors and the switch expression
// This must materialize to an integer scalar (non-abstract).
- utils::Vector<const sem::Type*, 8> types;
+ utils::Vector<const type::Type*, 8> types;
types.Push(cond_ty);
for (auto* case_stmt : stmt->body) {
for (auto* sel : case_stmt->selectors) {
@@ -3388,7 +3397,7 @@
types.Push(sem_expr->Type()->UnwrapRef());
}
}
- auto* common_ty = sem::Type::Common(types);
+ auto* common_ty = type::Type::Common(types);
if (!common_ty || !common_ty->is_integer_scalar()) {
// No common type found or the common type was abstract.
// Pick i32 and let validation deal with any mismatches.
@@ -3607,9 +3616,9 @@
}
bool Resolver::ApplyAddressSpaceUsageToType(ast::AddressSpace address_space,
- sem::Type* ty,
+ type::Type* ty,
const Source& usage) {
- ty = const_cast<sem::Type*>(ty->UnwrapRef());
+ ty = const_cast<type::Type*>(ty->UnwrapRef());
if (auto* str = ty->As<sem::Struct>()) {
if (str->AddressSpaceUsage().count(address_space)) {
@@ -3621,8 +3630,8 @@
for (auto* member : str->Members()) {
auto decl = member->Declaration();
if (decl &&
- !ApplyAddressSpaceUsageToType(address_space, const_cast<sem::Type*>(member->Type()),
- decl->type->source)) {
+ !ApplyAddressSpaceUsageToType(
+ address_space, const_cast<type::Type*>(member->Type()), decl->type->source)) {
std::stringstream err;
err << "while analyzing structure member " << sem_.TypeNameOf(str) << "."
<< builder_->Symbols().NameFor(member->Name());
@@ -3635,7 +3644,7 @@
if (auto* arr = ty->As<sem::Array>()) {
if (address_space != ast::AddressSpace::kStorage) {
- if (arr->Count()->Is<sem::RuntimeArrayCount>()) {
+ if (arr->Count()->Is<type::RuntimeArrayCount>()) {
AddError("runtime-sized arrays can only be used in the <storage> address space",
usage);
return false;
@@ -3649,7 +3658,7 @@
return false;
}
}
- return ApplyAddressSpaceUsageToType(address_space, const_cast<sem::Type*>(arr->ElemType()),
+ return ApplyAddressSpaceUsageToType(address_space, const_cast<type::Type*>(arr->ElemType()),
usage);
}
diff --git a/src/tint/resolver/resolver.h b/src/tint/resolver/resolver.h
index 0deef5f..5592405 100644
--- a/src/tint/resolver/resolver.h
+++ b/src/tint/resolver/resolver.h
@@ -93,19 +93,21 @@
/// @param type the given type
/// @returns true if the given type is a plain type
- bool IsPlain(const sem::Type* type) const { return validator_.IsPlain(type); }
+ bool IsPlain(const type::Type* type) const { return validator_.IsPlain(type); }
/// @param type the given type
/// @returns true if the given type is a fixed-footprint type
- bool IsFixedFootprint(const sem::Type* type) const { return validator_.IsFixedFootprint(type); }
+ bool IsFixedFootprint(const type::Type* type) const {
+ return validator_.IsFixedFootprint(type);
+ }
/// @param type the given type
/// @returns true if the given type is storable
- bool IsStorable(const sem::Type* type) const { return validator_.IsStorable(type); }
+ bool IsStorable(const type::Type* type) const { return validator_.IsStorable(type); }
/// @param type the given type
/// @returns true if the given type is host-shareable
- bool IsHostShareable(const sem::Type* type) const { return validator_.IsHostShareable(type); }
+ bool IsHostShareable(const type::Type* type) const { return validator_.IsHostShareable(type); }
/// @returns the validator for testing
const Validator* GetValidatorForTesting() const { return &validator_; }
@@ -179,7 +181,7 @@
/// materialized type.
/// If `expr` is nullptr, then Materialize() will also return nullptr.
const sem::Expression* Materialize(const sem::Expression* expr,
- const sem::Type* target_type = nullptr);
+ const type::Type* target_type = nullptr);
/// Materializes all the arguments in `args` to the parameter types of `target`.
/// @returns true on success, false on failure.
@@ -189,11 +191,11 @@
/// @returns true if an argument of an abstract numeric type, passed to a parameter of type
/// `parameter_ty` should be materialized.
- bool ShouldMaterializeArgument(const sem::Type* parameter_ty) const;
+ bool ShouldMaterializeArgument(const type::Type* parameter_ty) const;
/// Converts `c` to `target_ty`
/// @returns true on success, false on failure.
- bool Convert(const sem::Constant*& c, const sem::Type* target_ty, const Source& source);
+ bool Convert(const sem::Constant*& c, const type::Type* target_ty, const Source& source);
/// Transforms `args` to a vector of constants, and converts each constant to the call target's
/// parameter type.
@@ -209,9 +211,9 @@
/// @param source the source of the expression requiring materialization
/// @returns the concrete (materialized) type for the given type, or nullptr if the type is
/// already concrete.
- const sem::Type* ConcreteType(const sem::Type* ty,
- const sem::Type* target_ty,
- const Source& source);
+ const type::Type* ConcreteType(const type::Type* ty,
+ const type::Type* target_ty,
+ const Source& source);
// Statement resolving methods
// Each return true on success, false on failure.
@@ -220,7 +222,7 @@
sem::Statement* BreakStatement(const ast::BreakStatement*);
sem::Statement* BreakIfStatement(const ast::BreakIfStatement*);
sem::Statement* CallStatement(const ast::CallStatement*);
- sem::CaseStatement* CaseStatement(const ast::CaseStatement*, const sem::Type*);
+ sem::CaseStatement* CaseStatement(const ast::CaseStatement*, const type::Type*);
sem::Statement* CompoundAssignmentStatement(const ast::CompoundAssignmentStatement*);
sem::Statement* ContinueStatement(const ast::ContinueStatement*);
sem::Statement* DiscardStatement(const ast::DiscardStatement*);
@@ -249,11 +251,11 @@
/// current_function_
bool WorkgroupSize(const ast::Function*);
- /// @returns the sem::Type for the ast::Type `ty`, building it if it
+ /// @returns the type::Type for the ast::Type `ty`, building it if it
/// hasn't been constructed already. If an error is raised, nullptr is
/// returned.
/// @param ty the ast::Type
- sem::Type* Type(const ast::Type* ty);
+ type::Type* Type(const ast::Type* ty);
/// @param enable the enable declaration
/// @returns the resolved extension
@@ -261,7 +263,7 @@
/// @param named_type the named type to resolve
/// @returns the resolved semantic type
- sem::Type* TypeDecl(const ast::TypeDecl* named_type);
+ type::Type* TypeDecl(const ast::TypeDecl* named_type);
/// Builds and returns the semantic information for the AST array `arr`.
/// This method does not mark the ast::Array node, nor attach the generated semantic information
@@ -273,7 +275,7 @@
/// Resolves and validates the expression used as the count parameter of an array.
/// @param count_expr the expression used as the second template parameter to an array<>.
/// @returns the number of elements in the array.
- const sem::ArrayCount* ArrayCount(const ast::Expression* count_expr);
+ const type::ArrayCount* ArrayCount(const ast::Expression* count_expr);
/// Resolves and validates the attributes on an array.
/// @param attributes the attributes on the array type.
@@ -281,7 +283,7 @@
/// @param explicit_stride assigned the specified stride of the array in bytes.
/// @returns true on success, false on failure
bool ArrayAttributes(utils::VectorRef<const ast::Attribute*> attributes,
- const sem::Type* el_ty,
+ const type::Type* el_ty,
uint32_t& explicit_stride);
/// Builds and returns the semantic information for an array.
@@ -295,15 +297,15 @@
/// @param explicit_stride the explicit byte stride of the array. Zero means implicit stride.
sem::Array* Array(const Source& el_source,
const Source& count_source,
- const sem::Type* el_ty,
- const sem::ArrayCount* el_count,
+ const type::Type* el_ty,
+ const type::ArrayCount* el_count,
uint32_t explicit_stride);
/// Builds and returns the semantic information for the alias `alias`.
/// This method does not mark the ast::Alias node, nor attach the generated
/// semantic information to the AST node.
/// @returns the aliased type, or nullptr if an error is raised.
- sem::Type* Alias(const ast::Alias* alias);
+ type::Type* Alias(const ast::Alias* alias);
/// Builds and returns the semantic information for the structure `str`.
/// This method does not mark the ast::Struct node, nor attach the generated
@@ -371,7 +373,7 @@
/// given type and address space. Used for generating sensible error
/// messages.
/// @returns true on success, false on error
- bool ApplyAddressSpaceUsageToType(ast::AddressSpace sc, sem::Type* ty, const Source& usage);
+ bool ApplyAddressSpaceUsageToType(ast::AddressSpace sc, type::Type* ty, const Source& usage);
/// @param address_space the address space
/// @returns the default access control for the given address space
@@ -417,7 +419,7 @@
bool IsBuiltin(Symbol) const;
/// @returns the builtin type alias for the given symbol
- sem::Type* BuiltinTypeAlias(Symbol) const;
+ type::Type* BuiltinTypeAlias(Symbol) const;
// ArrayInitializerSig represents a unique array initializer signature.
// It is a tuple of the array type, number of arguments provided and earliest evaluation stage.
@@ -461,7 +463,7 @@
Validator validator_;
ast::Extensions enabled_extensions_;
utils::Vector<sem::Function*, 8> entry_points_;
- utils::Hashmap<const sem::Type*, const Source*, 8> atomic_composite_info_;
+ utils::Hashmap<const type::Type*, const Source*, 8> atomic_composite_info_;
utils::Bitset<0> marked_;
ExprEvalStageConstraint expr_eval_stage_constraint_;
std::unordered_map<const sem::Function*, AliasAnalysisInfo> alias_analysis_infos_;
diff --git a/src/tint/resolver/resolver_test.cc b/src/tint/resolver/resolver_test.cc
index 2a88249..1ac1369 100644
--- a/src/tint/resolver/resolver_test.cc
+++ b/src/tint/resolver/resolver_test.cc
@@ -440,7 +440,7 @@
auto* ref = TypeOf(a)->As<sem::Reference>();
ASSERT_NE(ref, nullptr);
auto* ary = ref->StoreType()->As<sem::Array>();
- EXPECT_EQ(ary->Count(), create<sem::ConstantArrayCount>(10u));
+ EXPECT_EQ(ary->Count(), create<type::ConstantArrayCount>(10u));
}
TEST_F(ResolverTest, ArraySize_SignedLiteral) {
@@ -453,7 +453,7 @@
auto* ref = TypeOf(a)->As<sem::Reference>();
ASSERT_NE(ref, nullptr);
auto* ary = ref->StoreType()->As<sem::Array>();
- EXPECT_EQ(ary->Count(), create<sem::ConstantArrayCount>(10u));
+ EXPECT_EQ(ary->Count(), create<type::ConstantArrayCount>(10u));
}
TEST_F(ResolverTest, ArraySize_UnsignedConst) {
@@ -468,7 +468,7 @@
auto* ref = TypeOf(a)->As<sem::Reference>();
ASSERT_NE(ref, nullptr);
auto* ary = ref->StoreType()->As<sem::Array>();
- EXPECT_EQ(ary->Count(), create<sem::ConstantArrayCount>(10u));
+ EXPECT_EQ(ary->Count(), create<type::ConstantArrayCount>(10u));
}
TEST_F(ResolverTest, ArraySize_SignedConst) {
@@ -483,7 +483,7 @@
auto* ref = TypeOf(a)->As<sem::Reference>();
ASSERT_NE(ref, nullptr);
auto* ary = ref->StoreType()->As<sem::Array>();
- EXPECT_EQ(ary->Count(), create<sem::ConstantArrayCount>(10u));
+ EXPECT_EQ(ary->Count(), create<type::ConstantArrayCount>(10u));
}
TEST_F(ResolverTest, ArraySize_NamedOverride) {
@@ -1767,7 +1767,7 @@
const ast::Type* lhs_type = nullptr;
const ast::Type* rhs_type = nullptr;
- const sem::Type* result_type = nullptr;
+ const type::Type* result_type = nullptr;
bool is_valid_expr;
if (vec_by_mat) {
diff --git a/src/tint/resolver/resolver_test_helper.h b/src/tint/resolver/resolver_test_helper.h
index f2567c8..f47719f 100644
--- a/src/tint/resolver/resolver_test_helper.h
+++ b/src/tint/resolver/resolver_test_helper.h
@@ -114,7 +114,7 @@
/// @param type a type
/// @returns the name for `type` that closely resembles how it would be
/// declared in WGSL.
- std::string FriendlyName(const sem::Type* type) { return type->FriendlyName(Symbols()); }
+ std::string FriendlyName(const type::Type* type) { return type->FriendlyName(Symbols()); }
private:
std::unique_ptr<Resolver> resolver_;
@@ -194,7 +194,7 @@
using ast_expr_func_ptr = const ast::Expression* (*)(ProgramBuilder& b,
utils::VectorRef<Scalar> args);
using ast_expr_from_double_func_ptr = const ast::Expression* (*)(ProgramBuilder& b, double v);
-using sem_type_func_ptr = const sem::Type* (*)(ProgramBuilder& b);
+using sem_type_func_ptr = const type::Type* (*)(ProgramBuilder& b);
using type_name_func_ptr = std::string (*)();
struct UnspecializedElementType {};
@@ -215,7 +215,7 @@
/// @return nullptr
static inline const ast::Type* AST(ProgramBuilder&) { return nullptr; }
/// @return nullptr
- static inline const sem::Type* Sem(ProgramBuilder&) { return nullptr; }
+ static inline const type::Type* Sem(ProgramBuilder&) { return nullptr; }
};
/// Helper for building bool types and expressions
@@ -232,7 +232,7 @@
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.bool_(); }
/// @param b the ProgramBuilder
/// @return the semantic bool type
- static inline const sem::Type* Sem(ProgramBuilder& b) { return b.create<sem::Bool>(); }
+ static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<sem::Bool>(); }
/// @param b the ProgramBuilder
/// @param args args of size 1 with the boolean value to init with
/// @return a new AST expression of the bool type
@@ -263,7 +263,7 @@
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.i32(); }
/// @param b the ProgramBuilder
/// @return the semantic i32 type
- static inline const sem::Type* Sem(ProgramBuilder& b) { return b.create<sem::I32>(); }
+ static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<sem::I32>(); }
/// @param b the ProgramBuilder
/// @param args args of size 1 with the i32 value to init with
/// @return a new AST i32 literal value expression
@@ -294,7 +294,7 @@
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.u32(); }
/// @param b the ProgramBuilder
/// @return the semantic u32 type
- static inline const sem::Type* Sem(ProgramBuilder& b) { return b.create<sem::U32>(); }
+ static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<sem::U32>(); }
/// @param b the ProgramBuilder
/// @param args args of size 1 with the u32 value to init with
/// @return a new AST u32 literal value expression
@@ -325,7 +325,7 @@
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.f32(); }
/// @param b the ProgramBuilder
/// @return the semantic f32 type
- static inline const sem::Type* Sem(ProgramBuilder& b) { return b.create<sem::F32>(); }
+ static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<sem::F32>(); }
/// @param b the ProgramBuilder
/// @param args args of size 1 with the f32 value to init with
/// @return a new AST f32 literal value expression
@@ -356,7 +356,7 @@
static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.f16(); }
/// @param b the ProgramBuilder
/// @return the semantic f16 type
- static inline const sem::Type* Sem(ProgramBuilder& b) { return b.create<sem::F16>(); }
+ static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<sem::F16>(); }
/// @param b the ProgramBuilder
/// @param args args of size 1 with the f16 value to init with
/// @return a new AST f16 literal value expression
@@ -386,7 +386,9 @@
static inline const ast::Type* AST(ProgramBuilder&) { return nullptr; }
/// @param b the ProgramBuilder
/// @return the semantic abstract-float type
- static inline const sem::Type* Sem(ProgramBuilder& b) { return b.create<sem::AbstractFloat>(); }
+ static inline const type::Type* Sem(ProgramBuilder& b) {
+ return b.create<sem::AbstractFloat>();
+ }
/// @param b the ProgramBuilder
/// @param args args of size 1 with the abstract-float value to init with
/// @return a new AST abstract-float literal value expression
@@ -416,7 +418,7 @@
static inline const ast::Type* AST(ProgramBuilder&) { return nullptr; }
/// @param b the ProgramBuilder
/// @return the semantic abstract-int type
- static inline const sem::Type* Sem(ProgramBuilder& b) { return b.create<sem::AbstractInt>(); }
+ static inline const type::Type* Sem(ProgramBuilder& b) { return b.create<sem::AbstractInt>(); }
/// @param b the ProgramBuilder
/// @param args args of size 1 with the abstract-int value to init with
/// @return a new AST abstract-int literal value expression
@@ -449,7 +451,7 @@
}
/// @param b the ProgramBuilder
/// @return the semantic vector type
- static inline const sem::Type* Sem(ProgramBuilder& b) {
+ static inline const type::Type* Sem(ProgramBuilder& b) {
return b.create<sem::Vector>(DataType<T>::Sem(b), N);
}
/// @param b the ProgramBuilder
@@ -497,7 +499,7 @@
}
/// @param b the ProgramBuilder
/// @return the semantic matrix type
- static inline const sem::Type* Sem(ProgramBuilder& b) {
+ static inline const type::Type* Sem(ProgramBuilder& b) {
auto* column_type = b.create<sem::Vector>(DataType<T>::Sem(b), M);
return b.create<sem::Matrix>(column_type, N);
}
@@ -561,7 +563,7 @@
}
/// @param b the ProgramBuilder
/// @return the semantic aliased type
- static inline const sem::Type* Sem(ProgramBuilder& b) { return DataType<T>::Sem(b); }
+ static inline const type::Type* Sem(ProgramBuilder& b) { return DataType<T>::Sem(b); }
/// @param b the ProgramBuilder
/// @param args the value nested elements will be initialized with
@@ -613,7 +615,7 @@
}
/// @param b the ProgramBuilder
/// @return the semantic aliased type
- static inline const sem::Type* Sem(ProgramBuilder& b) {
+ static inline const type::Type* Sem(ProgramBuilder& b) {
return b.create<sem::Pointer>(DataType<T>::Sem(b), ast::AddressSpace::kPrivate,
ast::Access::kReadWrite);
}
@@ -657,13 +659,13 @@
}
/// @param b the ProgramBuilder
/// @return the semantic array type
- static inline const sem::Type* Sem(ProgramBuilder& b) {
+ static inline const type::Type* Sem(ProgramBuilder& b) {
auto* el = DataType<T>::Sem(b);
- const sem::ArrayCount* count = nullptr;
+ const type::ArrayCount* count = nullptr;
if (N == 0) {
- count = b.create<sem::RuntimeArrayCount>();
+ count = b.create<type::RuntimeArrayCount>();
} else {
- count = b.create<sem::ConstantArrayCount>(N);
+ count = b.create<type::ConstantArrayCount>(N);
}
return b.create<sem::Array>(
/* element */ el,
diff --git a/src/tint/resolver/sem_helper.cc b/src/tint/resolver/sem_helper.cc
index 01a5480..db253a7 100644
--- a/src/tint/resolver/sem_helper.cc
+++ b/src/tint/resolver/sem_helper.cc
@@ -23,17 +23,17 @@
SemHelper::~SemHelper() = default;
-std::string SemHelper::TypeNameOf(const sem::Type* ty) const {
+std::string SemHelper::TypeNameOf(const type::Type* ty) const {
return RawTypeNameOf(ty->UnwrapRef());
}
-std::string SemHelper::RawTypeNameOf(const sem::Type* ty) const {
+std::string SemHelper::RawTypeNameOf(const type::Type* ty) const {
return ty->FriendlyName(builder_->Symbols());
}
-sem::Type* SemHelper::TypeOf(const ast::Expression* expr) const {
+type::Type* SemHelper::TypeOf(const ast::Expression* expr) const {
auto* sem = Get(expr);
- return sem ? const_cast<sem::Type*>(sem->Type()) : nullptr;
+ return sem ? const_cast<type::Type*>(sem->Type()) : nullptr;
}
} // namespace tint::resolver
diff --git a/src/tint/resolver/sem_helper.h b/src/tint/resolver/sem_helper.h
index 2e557d9..8e4a5b6 100644
--- a/src/tint/resolver/sem_helper.h
+++ b/src/tint/resolver/sem_helper.h
@@ -49,10 +49,10 @@
return const_cast<T*>(As<T>(sem));
}
- /// @returns the resolved symbol (function, type or variable) for the given
- /// ast::Identifier or ast::TypeName cast to the given semantic type.
+ /// @returns the resolved symbol (function, type or variable) for the given ast::Identifier or
+ /// ast::TypeName cast to the given semantic type.
/// @param node the node to retrieve
- template <typename SEM = sem::Node>
+ template <typename SEM = CastableBase>
SEM* ResolvedSymbol(const ast::Node* node) const {
auto resolved = dependencies_.resolved_symbols.Find(node);
return resolved ? const_cast<SEM*>(builder_->Sem().Get<SEM>(*resolved)) : nullptr;
@@ -60,17 +60,17 @@
/// @returns the resolved type of the ast::Expression `expr`
/// @param expr the expression
- sem::Type* TypeOf(const ast::Expression* expr) const;
+ type::Type* TypeOf(const ast::Expression* expr) const;
/// @returns the type name of the given semantic type, unwrapping
/// references.
/// @param ty the type to look up
- std::string TypeNameOf(const sem::Type* ty) const;
+ std::string TypeNameOf(const type::Type* ty) const;
/// @returns the type name of the given semantic type, without unwrapping
/// references.
/// @param ty the type to look up
- std::string RawTypeNameOf(const sem::Type* ty) const;
+ std::string RawTypeNameOf(const type::Type* ty) const;
private:
ProgramBuilder* builder_;
diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc
index 558217d..7d1f94b 100644
--- a/src/tint/resolver/validator.cc
+++ b/src/tint/resolver/validator.cc
@@ -157,7 +157,7 @@
ProgramBuilder* builder,
SemHelper& sem,
const ast::Extensions& enabled_extensions,
- const utils::Hashmap<const sem::Type*, const Source*, 8>& atomic_composite_info,
+ const utils::Hashmap<const type::Type*, const Source*, 8>& atomic_composite_info,
utils::Hashset<TypeAndAddressSpace, 8>& valid_type_storage_layouts)
: symbols_(builder->Symbols()),
diagnostics_(builder->Diagnostics()),
@@ -181,20 +181,21 @@
}
// https://gpuweb.github.io/gpuweb/wgsl/#plain-types-section
-bool Validator::IsPlain(const sem::Type* type) const {
+bool Validator::IsPlain(const type::Type* type) const {
return type->is_scalar() ||
type->IsAnyOf<sem::Atomic, sem::Vector, sem::Matrix, sem::Array, sem::Struct>();
}
// https://gpuweb.github.io/gpuweb/wgsl/#fixed-footprint-types
-bool Validator::IsFixedFootprint(const sem::Type* type) const {
+bool Validator::IsFixedFootprint(const type::Type* type) const {
return Switch(
type, //
[&](const sem::Vector*) { return true; }, //
[&](const sem::Matrix*) { return true; }, //
[&](const sem::Atomic*) { return true; },
[&](const sem::Array* arr) {
- return !arr->Count()->Is<sem::RuntimeArrayCount>() && IsFixedFootprint(arr->ElemType());
+ return !arr->Count()->Is<type::RuntimeArrayCount>() &&
+ IsFixedFootprint(arr->ElemType());
},
[&](const sem::Struct* str) {
for (auto* member : str->Members()) {
@@ -208,7 +209,7 @@
}
// https://gpuweb.github.io/gpuweb/wgsl.html#host-shareable-types
-bool Validator::IsHostShareable(const sem::Type* type) const {
+bool Validator::IsHostShareable(const type::Type* type) const {
if (type->IsAnyOf<sem::I32, sem::U32, sem::F32, sem::F16>()) {
return true;
}
@@ -229,7 +230,7 @@
}
// https://gpuweb.github.io/gpuweb/wgsl.html#storable-types
-bool Validator::IsStorable(const sem::Type* type) const {
+bool Validator::IsStorable(const type::Type* type) const {
return IsPlain(type) || type->IsAnyOf<sem::Texture, sem::Sampler>();
}
@@ -341,10 +342,10 @@
return true;
}
-bool Validator::Materialize(const sem::Type* to,
- const sem::Type* from,
+bool Validator::Materialize(const type::Type* to,
+ const type::Type* from,
const Source& source) const {
- if (sem::Type::ConversionRank(from, to) == sem::Type::kNoConversion) {
+ if (type::Type::ConversionRank(from, to) == type::Type::kNoConversion) {
AddError("cannot convert value of type '" + sem_.TypeNameOf(from) + "' to type '" +
sem_.TypeNameOf(to) + "'",
source);
@@ -355,7 +356,7 @@
bool Validator::VariableInitializer(const ast::Variable* v,
ast::AddressSpace address_space,
- const sem::Type* storage_ty,
+ const type::Type* storage_ty,
const sem::Expression* initializer) const {
auto* initializer_ty = initializer->Type();
auto* value_type = initializer_ty->UnwrapRef(); // Implicit load of RHS
@@ -389,21 +390,21 @@
return true;
}
-bool Validator::AddressSpaceLayout(const sem::Type* store_ty,
+bool Validator::AddressSpaceLayout(const type::Type* store_ty,
ast::AddressSpace address_space,
Source source) const {
// https://gpuweb.github.io/gpuweb/wgsl/#storage-class-layout-constraints
- auto is_uniform_struct_or_array = [address_space](const sem::Type* ty) {
+ auto is_uniform_struct_or_array = [address_space](const type::Type* ty) {
return address_space == ast::AddressSpace::kUniform &&
ty->IsAnyOf<sem::Array, sem::Struct>();
};
- auto is_uniform_struct = [address_space](const sem::Type* ty) {
+ auto is_uniform_struct = [address_space](const type::Type* ty) {
return address_space == ast::AddressSpace::kUniform && ty->Is<sem::Struct>();
};
- auto required_alignment_of = [&](const sem::Type* ty) {
+ auto required_alignment_of = [&](const type::Type* ty) {
uint32_t actual_align = ty->Align();
uint32_t required_align = actual_align;
if (is_uniform_struct_or_array(ty)) {
@@ -433,7 +434,7 @@
// Among three host-shareable address spaces, f16 is supported in "uniform" and
// "storage" address space, but not "push_constant" address space yet.
- if (Is<sem::F16>(sem::Type::DeepestElementOf(store_ty)) &&
+ if (Is<sem::F16>(type::Type::DeepestElementOf(store_ty)) &&
address_space == ast::AddressSpace::kPushConstant) {
AddError("using f16 types in 'push_constant' address space is not implemented yet", source);
return false;
@@ -840,7 +841,7 @@
}
bool Validator::BuiltinAttribute(const ast::BuiltinAttribute* attr,
- const sem::Type* storage_ty,
+ const type::Type* storage_ty,
ast::PipelineStage stage,
const bool is_input) const {
auto* type = storage_ty->UnwrapRef();
@@ -950,7 +951,7 @@
}
bool Validator::InterpolateAttribute(const ast::InterpolateAttribute* attr,
- const sem::Type* storage_ty) const {
+ const type::Type* storage_ty) const {
auto* type = storage_ty->UnwrapRef();
if (type->is_integer_scalar_or_vector() && attr->type != ast::InterpolationType::kFlat) {
@@ -1064,7 +1065,7 @@
// Inner lambda that is applied to a type and all of its members.
auto validate_entry_point_attributes_inner = [&](utils::VectorRef<const ast::Attribute*> attrs,
- const sem::Type* ty, Source source,
+ const type::Type* ty, Source source,
ParamOrRetType param_or_ret,
bool is_struct_member,
std::optional<uint32_t> location) {
@@ -1207,7 +1208,7 @@
// Outer lambda for validating the entry point attributes for a type.
auto validate_entry_point_attributes = [&](utils::VectorRef<const ast::Attribute*> attrs,
- const sem::Type* ty, Source source,
+ const type::Type* ty, Source source,
ParamOrRetType param_or_ret,
std::optional<uint32_t> location) {
if (!validate_entry_point_attributes_inner(attrs, ty, source, param_or_ret,
@@ -1357,7 +1358,7 @@
return true;
}
-bool Validator::Bitcast(const ast::BitcastExpression* cast, const sem::Type* to) const {
+bool Validator::Bitcast(const ast::BitcastExpression* cast, const type::Type* to) const {
auto* from = sem_.TypeOf(cast->expr)->UnwrapRef();
if (!from->is_numeric_scalar_or_vector()) {
AddError("'" + sem_.TypeNameOf(from) + "' cannot be bitcast", cast->expr->source);
@@ -1368,7 +1369,7 @@
return false;
}
- auto width = [&](const sem::Type* ty) {
+ auto width = [&](const type::Type* ty) {
if (auto* vec = ty->As<sem::Vector>()) {
return vec->Width();
}
@@ -1672,7 +1673,7 @@
auto* root_ptr_ty = root->Type()->As<sem::Pointer>();
auto* root_ref_ty = root->Type()->As<sem::Reference>();
TINT_ASSERT(Resolver, root_ptr_ty || root_ref_ty);
- const sem::Type* root_store_type;
+ const type::Type* root_store_type;
if (root_ptr_ty) {
root_store_type = root_ptr_ty->StoreType();
} else {
@@ -1747,7 +1748,7 @@
auto* elem_ty = array_type->ElemType();
for (auto* value : values) {
auto* value_ty = sem_.TypeOf(value)->UnwrapRef();
- if (sem::Type::ConversionRank(value_ty, elem_ty) == sem::Type::kNoConversion) {
+ if (type::Type::ConversionRank(value_ty, elem_ty) == type::Type::kNoConversion) {
AddError("'" + sem_.TypeNameOf(value_ty) +
"' cannot be used to construct an array of '" + sem_.TypeNameOf(elem_ty) +
"'",
@@ -1757,7 +1758,7 @@
}
auto* c = array_type->Count();
- if (c->Is<sem::RuntimeArrayCount>()) {
+ if (c->Is<type::RuntimeArrayCount>()) {
AddError("cannot construct a runtime-sized array", ctor->source);
return false;
}
@@ -1772,12 +1773,12 @@
return false;
}
- if (!c->Is<sem::ConstantArrayCount>()) {
+ if (!c->Is<type::ConstantArrayCount>()) {
TINT_ICE(Resolver, diagnostics_) << "Invalid ArrayCount found";
return false;
}
- const auto count = c->As<sem::ConstantArrayCount>()->value;
+ const auto count = c->As<type::ConstantArrayCount>()->value;
if (!values.IsEmpty() && (values.Length() != count)) {
std::string fm = values.Length() < count ? "few" : "many";
AddError("array initializer has too " + fm + " elements: expected " +
@@ -2020,7 +2021,7 @@
utils::Hashset<uint32_t, 8> locations;
for (auto* member : str->Members()) {
if (auto* r = member->Type()->As<sem::Array>()) {
- if (r->Count()->Is<sem::RuntimeArrayCount>()) {
+ if (r->Count()->Is<type::RuntimeArrayCount>()) {
if (member != str->Members().Back()) {
AddError("runtime arrays may only appear as the last member of a struct",
member->Source());
@@ -2134,7 +2135,7 @@
bool Validator::LocationAttribute(const ast::LocationAttribute* loc_attr,
uint32_t location,
- const sem::Type* type,
+ const type::Type* type,
utils::Hashset<uint32_t, 8>& locations,
ast::PipelineStage stage,
const Source& source,
@@ -2166,8 +2167,8 @@
}
bool Validator::Return(const ast::ReturnStatement* ret,
- const sem::Type* func_type,
- const sem::Type* ret_type,
+ const type::Type* func_type,
+ const type::Type* ret_type,
sem::Statement* current_statement) const {
if (func_type->UnwrapRef() != ret_type) {
AddError("return statement type must match its function return type, returned '" +
@@ -2246,7 +2247,7 @@
return true;
}
-bool Validator::Assignment(const ast::Statement* a, const sem::Type* rhs_ty) const {
+bool Validator::Assignment(const ast::Statement* a, const type::Type* rhs_ty) const {
const ast::Expression* lhs;
const ast::Expression* rhs;
if (auto* assign = a->As<ast::AssignmentStatement>()) {
@@ -2390,7 +2391,7 @@
return !IsValidationDisabled(attributes, validation);
}
-bool Validator::IsArrayWithOverrideCount(const sem::Type* ty) const {
+bool Validator::IsArrayWithOverrideCount(const type::Type* ty) const {
if (auto* arr = ty->UnwrapRef()->As<sem::Array>()) {
if (arr->Count()->IsAnyOf<sem::NamedOverrideArrayCount, sem::UnnamedOverrideArrayCount>()) {
return true;
@@ -2406,13 +2407,13 @@
source);
}
-std::string Validator::VectorPretty(uint32_t size, const sem::Type* element_type) const {
+std::string Validator::VectorPretty(uint32_t size, const type::Type* element_type) const {
sem::Vector vec_type(element_type, size);
return vec_type.FriendlyName(symbols_);
}
bool Validator::CheckTypeAccessAddressSpace(
- const sem::Type* store_ty,
+ const type::Type* store_ty,
ast::Access access,
ast::AddressSpace address_space,
utils::VectorRef<const tint::ast::Attribute*> attributes,
diff --git a/src/tint/resolver/validator.h b/src/tint/resolver/validator.h
index 9f0664c..99db201 100644
--- a/src/tint/resolver/validator.h
+++ b/src/tint/resolver/validator.h
@@ -70,7 +70,7 @@
/// TypeAndAddressSpace is a pair of type and address space
struct TypeAndAddressSpace {
/// The type
- const sem::Type* type;
+ const type::Type* type;
/// The address space
ast::AddressSpace address_space;
@@ -97,7 +97,7 @@
Validator(ProgramBuilder* builder,
SemHelper& helper,
const ast::Extensions& enabled_extensions,
- const utils::Hashmap<const sem::Type*, const Source*, 8>& atomic_composite_info,
+ const utils::Hashmap<const type::Type*, const Source*, 8>& atomic_composite_info,
utils::Hashset<TypeAndAddressSpace, 8>& valid_type_storage_layouts);
~Validator();
@@ -118,19 +118,19 @@
/// @param type the given type
/// @returns true if the given type is a plain type
- bool IsPlain(const sem::Type* type) const;
+ bool IsPlain(const type::Type* type) const;
/// @param type the given type
/// @returns true if the given type is a fixed-footprint type
- bool IsFixedFootprint(const sem::Type* type) const;
+ bool IsFixedFootprint(const type::Type* type) const;
/// @param type the given type
/// @returns true if the given type is storable
- bool IsStorable(const sem::Type* type) const;
+ bool IsStorable(const type::Type* type) const;
/// @param type the given type
/// @returns true if the given type is host-shareable
- bool IsHostShareable(const sem::Type* type) const;
+ bool IsHostShareable(const type::Type* type) const;
/// Validates pipeline stages
/// @param entry_points the entry points to the module
@@ -179,13 +179,13 @@
/// @param a the assignment statement
/// @param rhs_ty the type of the right hand side
/// @returns true on success, false otherwise.
- bool Assignment(const ast::Statement* a, const sem::Type* rhs_ty) const;
+ bool Assignment(const ast::Statement* a, const type::Type* rhs_ty) const;
/// Validates a bitcase
/// @param cast the bitcast expression
/// @param to the destination type
/// @returns true on success, false otherwise
- bool Bitcast(const ast::BitcastExpression* cast, const sem::Type* to) const;
+ bool Bitcast(const ast::BitcastExpression* cast, const type::Type* to) const;
/// Validates a break statement
/// @param stmt the break statement to validate
@@ -200,7 +200,7 @@
/// @param is_input true if this is an input attribute
/// @returns true on success, false otherwise.
bool BuiltinAttribute(const ast::BuiltinAttribute* attr,
- const sem::Type* storage_type,
+ const type::Type* storage_type,
ast::PipelineStage stage,
const bool is_input) const;
@@ -283,7 +283,7 @@
/// @param storage_type the storage type of the attached variable
/// @returns true on succes, false otherwise
bool InterpolateAttribute(const ast::InterpolateAttribute* attr,
- const sem::Type* storage_type) const;
+ const type::Type* storage_type) const;
/// Validates a builtin call
/// @param call the builtin call to validate
@@ -306,7 +306,7 @@
/// @returns true on success, false otherwise.
bool LocationAttribute(const ast::LocationAttribute* loc_attr,
uint32_t location,
- const sem::Type* type,
+ const type::Type* type,
utils::Hashset<uint32_t, 8>& locations,
ast::PipelineStage stage,
const Source& source,
@@ -322,7 +322,7 @@
/// @param from the abstract numeric type
/// @param source the source of the materialization
/// @returns true on success, false otherwise
- bool Materialize(const sem::Type* to, const sem::Type* from, const Source& source) const;
+ bool Materialize(const type::Type* to, const type::Type* from, const Source& source) const;
/// Validates a matrix
/// @param ty the matrix to validate
@@ -343,8 +343,8 @@
/// @param current_statement the current statement being resolved
/// @returns true on success, false otherwise
bool Return(const ast::ReturnStatement* ret,
- const sem::Type* func_type,
- const sem::Type* ret_type,
+ const type::Type* func_type,
+ const type::Type* ret_type,
sem::Statement* current_statement) const;
/// Validates a list of statements
@@ -417,7 +417,7 @@
/// @returns true on succes, false otherwise
bool VariableInitializer(const ast::Variable* v,
ast::AddressSpace address_space,
- const sem::Type* storage_type,
+ const type::Type* storage_type,
const sem::Expression* initializer) const;
/// Validates a vector
@@ -452,7 +452,7 @@
/// @param sc the address space
/// @param source the source of the type
/// @returns true on success, false otherwise
- bool AddressSpaceLayout(const sem::Type* type, ast::AddressSpace sc, Source source) const;
+ bool AddressSpaceLayout(const type::Type* type, ast::AddressSpace sc, Source source) const;
/// @returns true if the attribute list contains a
/// ast::DisableValidationAttribute with the validation mode equal to
@@ -474,7 +474,7 @@
/// @param ty the type to check
/// @returns true if @p ty is an array with an `override` expression element count, otherwise
/// false.
- bool IsArrayWithOverrideCount(const sem::Type* ty) const;
+ bool IsArrayWithOverrideCount(const type::Type* ty) const;
/// Raises an error about an array type using an `override` expression element count, outside
/// the single allowed use of a `var<workgroup>`.
@@ -496,7 +496,7 @@
/// @param size the vector dimension
/// @param element_type scalar vector sub-element type
/// @return pretty string representation
- std::string VectorPretty(uint32_t size, const sem::Type* element_type) const;
+ std::string VectorPretty(uint32_t size, const type::Type* element_type) const;
/// Raises an error if combination of @p store_ty, @p access and @p address_space are not valid
/// for a `var` or `ptr` declaration.
@@ -505,7 +505,7 @@
/// @param address_space the var or pointer address space
/// @param source the source for the error
/// @returns true on success, false if an error was raised.
- bool CheckTypeAccessAddressSpace(const sem::Type* store_ty,
+ bool CheckTypeAccessAddressSpace(const type::Type* store_ty,
ast::Access access,
ast::AddressSpace address_space,
utils::VectorRef<const tint::ast::Attribute*> attributes,
@@ -514,7 +514,7 @@
diag::List& diagnostics_;
SemHelper& sem_;
const ast::Extensions& enabled_extensions_;
- const utils::Hashmap<const sem::Type*, const Source*, 8>& atomic_composite_info_;
+ const utils::Hashmap<const type::Type*, const Source*, 8>& atomic_composite_info_;
utils::Hashset<TypeAndAddressSpace, 8>& valid_type_storage_layouts_;
};
diff --git a/src/tint/resolver/validator_is_storeable_test.cc b/src/tint/resolver/validator_is_storeable_test.cc
index cd079ce..3dd144c 100644
--- a/src/tint/resolver/validator_is_storeable_test.cc
+++ b/src/tint/resolver/validator_is_storeable_test.cc
@@ -89,14 +89,14 @@
}
TEST_F(ValidatorIsStorableTest, ArraySizedOfStorable) {
- auto* arr = create<sem::Array>(create<sem::I32>(), create<sem::ConstantArrayCount>(5u), 4u, 20u,
- 4u, 4u);
+ auto* arr = create<sem::Array>(create<sem::I32>(), create<type::ConstantArrayCount>(5u), 4u,
+ 20u, 4u, 4u);
EXPECT_TRUE(v()->IsStorable(arr));
}
TEST_F(ValidatorIsStorableTest, ArrayUnsizedOfStorable) {
auto* arr =
- create<sem::Array>(create<sem::I32>(), create<sem::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
+ create<sem::Array>(create<sem::I32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
EXPECT_TRUE(v()->IsStorable(arr));
}