Rename constant::Constant to constant::Value.
This CL renames constant::Constant to constant::Value as it reads a bit nicer. Bug: tint:1718 Change-Id: I3489a271ebe229dabf98e7668bdaef4fec375534 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114361 Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
7bacdfab4c
commit
b53b8cf5be
|
@ -367,10 +367,10 @@ libtint_source_set("libtint_core_all_src") {
|
|||
"clone_context.cc",
|
||||
"clone_context.h",
|
||||
"constant/composite.h",
|
||||
"constant/constant.h",
|
||||
"constant/node.h",
|
||||
"constant/scalar.h",
|
||||
"constant/splat.h",
|
||||
"constant/value.h",
|
||||
"debug.cc",
|
||||
"debug.h",
|
||||
"demangler.cc",
|
||||
|
@ -767,14 +767,14 @@ libtint_source_set("libtint_constant_src") {
|
|||
sources = [
|
||||
"constant/composite.cc",
|
||||
"constant/composite.h",
|
||||
"constant/constant.cc",
|
||||
"constant/constant.h",
|
||||
"constant/node.cc",
|
||||
"constant/node.h",
|
||||
"constant/scalar.cc",
|
||||
"constant/scalar.h",
|
||||
"constant/splat.cc",
|
||||
"constant/splat.h",
|
||||
"constant/value.cc",
|
||||
"constant/value.h",
|
||||
]
|
||||
public_deps = [ ":libtint_core_all_src" ]
|
||||
}
|
||||
|
|
|
@ -256,14 +256,14 @@ list(APPEND TINT_LIB_SRCS
|
|||
clone_context.h
|
||||
constant/composite.cc
|
||||
constant/composite.h
|
||||
constant/constant.cc
|
||||
constant/constant.h
|
||||
constant/scalar.cc
|
||||
constant/scalar.h
|
||||
constant/splat.cc
|
||||
constant/splat.h
|
||||
constant/node.cc
|
||||
constant/node.h
|
||||
constant/value.cc
|
||||
constant/value.h
|
||||
demangler.cc
|
||||
demangler.h
|
||||
inspector/entry_point.cc
|
||||
|
|
|
@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::constant::Composite);
|
|||
namespace tint::constant {
|
||||
|
||||
Composite::Composite(const type::Type* t,
|
||||
utils::VectorRef<const constant::Constant*> els,
|
||||
utils::VectorRef<const constant::Value*> els,
|
||||
bool all_0,
|
||||
bool any_0)
|
||||
: type(t), elements(std::move(els)), all_zero(all_0), any_zero(any_0), hash(CalcHash()) {}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define SRC_TINT_CONSTANT_COMPOSITE_H_
|
||||
|
||||
#include "src/tint/castable.h"
|
||||
#include "src/tint/constant/constant.h"
|
||||
#include "src/tint/constant/value.h"
|
||||
#include "src/tint/number.h"
|
||||
#include "src/tint/type/type.h"
|
||||
#include "src/tint/utils/hash.h"
|
||||
|
@ -24,12 +24,11 @@
|
|||
|
||||
namespace tint::constant {
|
||||
|
||||
/// Composite holds a number of mixed child Constant values.
|
||||
/// Composite holds a number of mixed child values.
|
||||
/// Composite may be of a vector, matrix or array type.
|
||||
/// If each element is the same type and value, then a Splat would be a more efficient constant
|
||||
/// implementation. Use CreateComposite() to create the appropriate Constant type.
|
||||
/// Composite implements the Constant interface.
|
||||
class Composite : public Castable<Composite, constant::Constant> {
|
||||
/// implementation. Use CreateComposite() to create the appropriate type.
|
||||
class Composite : public Castable<Composite, constant::Value> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param t the compsite type
|
||||
|
@ -37,15 +36,14 @@ class Composite : public Castable<Composite, constant::Constant> {
|
|||
/// @param all_0 true if all elements are 0
|
||||
/// @param any_0 true if any element is 0
|
||||
Composite(const type::Type* t,
|
||||
utils::VectorRef<const constant::Constant*> els,
|
||||
utils::VectorRef<const constant::Value*> els,
|
||||
bool all_0,
|
||||
bool any_0);
|
||||
~Composite() override;
|
||||
|
||||
const type::Type* Type() const override { return type; }
|
||||
|
||||
std::variant<std::monostate, AInt, AFloat> Value() const override { return {}; }
|
||||
const constant::Constant* Index(size_t i) const override {
|
||||
const constant::Value* Index(size_t i) const override {
|
||||
return i < elements.Length() ? elements[i] : nullptr;
|
||||
}
|
||||
|
||||
|
@ -57,7 +55,7 @@ class Composite : public Castable<Composite, constant::Constant> {
|
|||
/// The composite type
|
||||
type::Type const* const type;
|
||||
/// The composite elements
|
||||
const utils::Vector<const constant::Constant*, 4> elements;
|
||||
const utils::Vector<const constant::Value*, 4> elements;
|
||||
/// True if all elements are zero
|
||||
const bool all_zero;
|
||||
/// True if any element is zero
|
||||
|
@ -65,6 +63,9 @@ class Composite : public Castable<Composite, constant::Constant> {
|
|||
/// The hash of the composite
|
||||
const size_t hash;
|
||||
|
||||
protected:
|
||||
std::variant<std::monostate, AInt, AFloat> InternalValue() const override { return {}; }
|
||||
|
||||
private:
|
||||
size_t CalcHash() {
|
||||
auto h = utils::Hash(type, all_zero, any_zero);
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
// Copyright 2021 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0(the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/tint/constant/constant.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::constant::Constant);
|
||||
|
||||
namespace tint::constant {
|
||||
|
||||
Constant::Constant() = default;
|
||||
|
||||
Constant::~Constant() = default;
|
||||
|
||||
} // namespace tint::constant
|
|
@ -16,7 +16,7 @@
|
|||
#define SRC_TINT_CONSTANT_SCALAR_H_
|
||||
|
||||
#include "src/tint/castable.h"
|
||||
#include "src/tint/constant/constant.h"
|
||||
#include "src/tint/constant/value.h"
|
||||
#include "src/tint/number.h"
|
||||
#include "src/tint/type/type.h"
|
||||
#include "src/tint/utils/hash.h"
|
||||
|
@ -24,9 +24,8 @@
|
|||
namespace tint::constant {
|
||||
|
||||
/// Scalar holds a single scalar or abstract-numeric value.
|
||||
/// Scalar implements the Constant interface.
|
||||
template <typename T>
|
||||
class Scalar : public Castable<Scalar<T>, constant::Constant> {
|
||||
class Scalar : public Castable<Scalar<T>, constant::Value> {
|
||||
public:
|
||||
static_assert(!std::is_same_v<UnwrapNumber<T>, T> || std::is_same_v<T, bool>,
|
||||
"T must be a Number or bool");
|
||||
|
@ -43,14 +42,7 @@ class Scalar : public Castable<Scalar<T>, constant::Constant> {
|
|||
|
||||
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);
|
||||
} else {
|
||||
return static_cast<AInt>(value);
|
||||
}
|
||||
}
|
||||
const constant::Constant* Index(size_t) const override { return nullptr; }
|
||||
const constant::Value* Index(size_t) const override { return nullptr; }
|
||||
|
||||
bool AllZero() const override { return IsPositiveZero(); }
|
||||
bool AnyZero() const override { return IsPositiveZero(); }
|
||||
|
@ -77,6 +69,15 @@ class Scalar : public Castable<Scalar<T>, constant::Constant> {
|
|||
type::Type const* const type;
|
||||
/// The scalar value
|
||||
const T value;
|
||||
|
||||
protected:
|
||||
std::variant<std::monostate, AInt, AFloat> InternalValue() const override {
|
||||
if constexpr (IsFloatingPoint<UnwrapNumber<T>>) {
|
||||
return static_cast<AFloat>(value);
|
||||
} else {
|
||||
return static_cast<AInt>(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace tint::constant
|
||||
|
|
|
@ -18,8 +18,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::constant::Splat);
|
|||
|
||||
namespace tint::constant {
|
||||
|
||||
Splat::Splat(const type::Type* t, const constant::Constant* e, size_t n)
|
||||
: type(t), el(e), count(n) {}
|
||||
Splat::Splat(const type::Type* t, const constant::Value* e, size_t n) : type(t), el(e), count(n) {}
|
||||
|
||||
Splat::~Splat() = default;
|
||||
|
||||
|
|
|
@ -22,29 +22,26 @@
|
|||
|
||||
namespace tint::constant {
|
||||
|
||||
/// Splat holds a single Constant value, duplicated as all children.
|
||||
/// Splat holds a single value, duplicated as all children.
|
||||
///
|
||||
/// Splat is used for zero-initializers, 'splat' initializers, or initializers where each element is
|
||||
/// identical. Splat may be of a vector, matrix or array type.
|
||||
/// Splat implements the Constant interface.
|
||||
class Splat : public Castable<Splat, constant::Constant> {
|
||||
class Splat : public Castable<Splat, constant::Value> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param t the splat type
|
||||
/// @param e the splat element
|
||||
/// @param n the number of items in the splat
|
||||
Splat(const type::Type* t, const constant::Constant* e, size_t n);
|
||||
Splat(const type::Type* t, const constant::Value* e, size_t n);
|
||||
~Splat() override;
|
||||
|
||||
/// @returns the type of the splat
|
||||
const type::Type* Type() const override { return type; }
|
||||
|
||||
/// @returns a monostate variant.
|
||||
std::variant<std::monostate, AInt, AFloat> Value() const override { return {}; }
|
||||
|
||||
/// Retrieve item at index @p i
|
||||
/// @param i the index to retrieve
|
||||
/// @returns the element, or nullptr if out of bounds
|
||||
const constant::Constant* Index(size_t i) const override { return i < count ? el : nullptr; }
|
||||
const constant::Value* Index(size_t i) const override { return i < count ? el : nullptr; }
|
||||
|
||||
/// @returns true if the element is zero
|
||||
bool AllZero() const override { return el->AllZero(); }
|
||||
|
@ -59,9 +56,13 @@ class Splat : public Castable<Splat, constant::Constant> {
|
|||
/// The type of the splat element
|
||||
type::Type const* const type;
|
||||
/// The element stored in the splat
|
||||
const constant::Constant* el;
|
||||
const constant::Value* el;
|
||||
/// The number of items in the splat
|
||||
const size_t count;
|
||||
|
||||
protected:
|
||||
/// @returns a monostate variant.
|
||||
std::variant<std::monostate, AInt, AFloat> InternalValue() const override { return {}; }
|
||||
};
|
||||
|
||||
} // namespace tint::constant
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
// Copyright 2021 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0(the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/tint/constant/value.h"
|
||||
|
||||
#include "src/tint/type/array.h"
|
||||
#include "src/tint/type/matrix.h"
|
||||
#include "src/tint/type/struct.h"
|
||||
#include "src/tint/type/vector.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::constant::Value);
|
||||
|
||||
namespace tint::constant {
|
||||
|
||||
Value::Value() = default;
|
||||
|
||||
Value::~Value() = default;
|
||||
|
||||
/// Equal returns true if the constants `a` and `b` are of the same type and value.
|
||||
bool Value::Equal(const constant::Value* b) const {
|
||||
if (Hash() != b->Hash()) {
|
||||
return false;
|
||||
}
|
||||
if (Type() != b->Type()) {
|
||||
return false;
|
||||
}
|
||||
return Switch(
|
||||
Type(), //
|
||||
[&](const type::Vector* vec) {
|
||||
for (size_t i = 0; i < vec->Width(); i++) {
|
||||
if (!Index(i)->Equal(b->Index(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
[&](const type::Matrix* mat) {
|
||||
for (size_t i = 0; i < mat->columns(); i++) {
|
||||
if (!Index(i)->Equal(b->Index(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
[&](const type::Array* arr) {
|
||||
if (auto count = arr->ConstantCount()) {
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
if (!Index(i)->Equal(b->Index(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
[&](const type::Struct* str) {
|
||||
auto count = str->Members().Length();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
if (!Index(i)->Equal(b->Index(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
[&](Default) {
|
||||
auto va = InternalValue();
|
||||
auto vb = b->InternalValue();
|
||||
TINT_ASSERT(Resolver, !std::holds_alternative<std::monostate>(va));
|
||||
TINT_ASSERT(Resolver, !std::holds_alternative<std::monostate>(vb));
|
||||
return va == vb;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace tint::constant
|
|
@ -12,8 +12,8 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef SRC_TINT_CONSTANT_CONSTANT_H_
|
||||
#define SRC_TINT_CONSTANT_CONSTANT_H_
|
||||
#ifndef SRC_TINT_CONSTANT_VALUE_H_
|
||||
#define SRC_TINT_CONSTANT_VALUE_H_
|
||||
|
||||
#include <variant>
|
||||
|
||||
|
@ -24,43 +24,40 @@
|
|||
|
||||
namespace tint::constant {
|
||||
|
||||
/// Constant is the interface to a compile-time evaluated expression value.
|
||||
class Constant : public Castable<Constant, Node> {
|
||||
/// Value is the interface to a compile-time evaluated expression value.
|
||||
class Value : public Castable<Value, Node> {
|
||||
public:
|
||||
/// Constructor
|
||||
Constant();
|
||||
Value();
|
||||
|
||||
/// Destructor
|
||||
~Constant() override;
|
||||
~Value() override;
|
||||
|
||||
/// @returns the type of the constant
|
||||
/// @returns the type of the value
|
||||
virtual const type::Type* Type() const = 0;
|
||||
|
||||
/// @returns the value of this Constant, if this constant is of a scalar value or abstract
|
||||
/// numeric, otherwise std::monostate.
|
||||
virtual std::variant<std::monostate, AInt, AFloat> Value() const = 0;
|
||||
|
||||
/// @returns the child constant element with the given index, or nullptr if the constant has no
|
||||
/// children, or the index is out of bounds.
|
||||
/// @returns the child element with the given index, or nullptr if there are no children, or
|
||||
/// the index is out of bounds.
|
||||
///
|
||||
/// For arrays, this returns the i'th element of the array.
|
||||
/// For vectors, this returns the i'th element of the vector.
|
||||
/// For matrices, this returns the i'th column vector of the matrix.
|
||||
/// For structures, this returns the i'th member field of the structure.
|
||||
virtual const Constant* Index(size_t) const = 0;
|
||||
virtual const Value* Index(size_t) const = 0;
|
||||
|
||||
/// @returns true if child elements of this constant are positive-zero valued.
|
||||
/// @returns true if child elements are positive-zero valued.
|
||||
virtual bool AllZero() const = 0;
|
||||
|
||||
/// @returns true if any child elements of this constant are positive-zero valued.
|
||||
/// @returns true if any child elements are positive-zero valued.
|
||||
virtual bool AnyZero() const = 0;
|
||||
|
||||
/// @returns true if all child elements of this constant have the same value and type.
|
||||
/// @returns true if all child elements have the same value and type.
|
||||
virtual bool AllEqual() const = 0;
|
||||
|
||||
/// @returns a hash of the constant.
|
||||
/// @returns a hash of the value.
|
||||
virtual size_t Hash() const = 0;
|
||||
|
||||
/// @returns the value of the constant as the given scalar or abstract value.
|
||||
/// @returns the value as the given scalar or abstract value.
|
||||
template <typename T>
|
||||
T ValueAs() const {
|
||||
return std::visit(
|
||||
|
@ -71,10 +68,19 @@ class Constant : public Castable<Constant, Node> {
|
|||
return static_cast<T>(v);
|
||||
}
|
||||
},
|
||||
Value());
|
||||
InternalValue());
|
||||
}
|
||||
|
||||
/// @param b the value to compare too
|
||||
/// @returns true if this value is equal to @p b
|
||||
bool Equal(const constant::Value* b) const;
|
||||
|
||||
protected:
|
||||
/// @returns the value, if this is of a scalar value or abstract numeric, otherwise
|
||||
/// std::monostate.
|
||||
virtual std::variant<std::monostate, AInt, AFloat> InternalValue() const = 0;
|
||||
};
|
||||
|
||||
} // namespace tint::constant
|
||||
|
||||
#endif // SRC_TINT_CONSTANT_CONSTANT_H_
|
||||
#endif // SRC_TINT_CONSTANT_VALUE_H_
|
|
@ -19,7 +19,7 @@
|
|||
#include <unordered_set>
|
||||
|
||||
#include "src/tint/ast/function.h"
|
||||
#include "src/tint/constant/constant.h"
|
||||
#include "src/tint/constant/value.h"
|
||||
#include "src/tint/program_id.h"
|
||||
#include "src/tint/sem/info.h"
|
||||
#include "src/tint/symbol_table.h"
|
||||
|
@ -44,8 +44,8 @@ class Program {
|
|||
/// SemNodeAllocator is an alias to BlockAllocator<sem::Node>
|
||||
using SemNodeAllocator = utils::BlockAllocator<sem::Node>;
|
||||
|
||||
/// ConstantAllocator is an alias to BlockAllocator<constant::Constant>
|
||||
using ConstantAllocator = utils::BlockAllocator<constant::Constant>;
|
||||
/// ConstantAllocator is an alias to BlockAllocator<constant::Value>
|
||||
using ConstantAllocator = utils::BlockAllocator<constant::Value>;
|
||||
|
||||
/// Constructor
|
||||
Program();
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
#include "src/tint/ast/void.h"
|
||||
#include "src/tint/ast/while_statement.h"
|
||||
#include "src/tint/ast/workgroup_attribute.h"
|
||||
#include "src/tint/constant/constant.h"
|
||||
#include "src/tint/constant/value.h"
|
||||
#include "src/tint/number.h"
|
||||
#include "src/tint/program.h"
|
||||
#include "src/tint/program_id.h"
|
||||
|
@ -265,8 +265,8 @@ class ProgramBuilder {
|
|||
/// SemNodeAllocator is an alias to BlockAllocator<sem::Node>
|
||||
using SemNodeAllocator = utils::BlockAllocator<sem::Node>;
|
||||
|
||||
/// ConstantAllocator is an alias to BlockAllocator<constant::Constant>
|
||||
using ConstantAllocator = utils::BlockAllocator<constant::Constant>;
|
||||
/// ConstantAllocator is an alias to BlockAllocator<constant::Value>
|
||||
using ConstantAllocator = utils::BlockAllocator<constant::Value>;
|
||||
|
||||
/// Constructor
|
||||
ProgramBuilder();
|
||||
|
@ -465,12 +465,12 @@ class ProgramBuilder {
|
|||
return sem_nodes_.Create<T>(std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// Creates a new constant::Constant owned by the ProgramBuilder.
|
||||
/// Creates a new constant::Value owned by the ProgramBuilder.
|
||||
/// When the ProgramBuilder is destructed, the sem::Node will also be destructed.
|
||||
/// @param args the arguments to pass to the constructor
|
||||
/// @returns the node pointer
|
||||
template <typename T, typename... ARGS>
|
||||
traits::EnableIf<traits::IsTypeOrDerived<T, constant::Constant>, T>* create(ARGS&&... args) {
|
||||
traits::EnableIf<traits::IsTypeOrDerived<T, constant::Value>, T>* create(ARGS&&... args) {
|
||||
AssertNotMoved();
|
||||
return constant_nodes_.Create<T>(std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -31,7 +31,7 @@ namespace tint::ast {
|
|||
class LiteralExpression;
|
||||
} // namespace tint::ast
|
||||
namespace tint::constant {
|
||||
class Constant;
|
||||
class Value;
|
||||
} // namespace tint::constant
|
||||
namespace tint::sem {
|
||||
class Expression;
|
||||
|
@ -50,20 +50,20 @@ class ConstEval {
|
|||
public:
|
||||
/// The result type of a method that may raise a diagnostic error and the caller should abort
|
||||
/// resolving. Can be one of three distinct values:
|
||||
/// * A non-null constant::Constant pointer. Returned when a expression resolves to a creation
|
||||
/// * A non-null constant::Value pointer. Returned when a expression resolves to a creation
|
||||
/// time
|
||||
/// value.
|
||||
/// * A null constant::Constant pointer. Returned when a expression cannot resolve to a creation
|
||||
/// * A null constant::Value pointer. Returned when a expression cannot resolve to a creation
|
||||
/// time
|
||||
/// value, but is otherwise legal.
|
||||
/// * `utils::Failure`. Returned when there was a resolver error. In this situation the method
|
||||
/// will have already reported a diagnostic error message, and the caller should abort
|
||||
/// resolving.
|
||||
using Result = utils::Result<const constant::Constant*>;
|
||||
using Result = utils::Result<const constant::Value*>;
|
||||
|
||||
/// Typedef for a constant evaluation function
|
||||
using Function = Result (ConstEval::*)(const type::Type* result_ty,
|
||||
utils::VectorRef<const constant::Constant*>,
|
||||
utils::VectorRef<const constant::Value*>,
|
||||
const Source&);
|
||||
|
||||
/// Constructor
|
||||
|
@ -113,7 +113,7 @@ class ConstEval {
|
|||
/// @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 type::Type* ty, const constant::Constant* value, const Source& source);
|
||||
Result Convert(const type::Type* ty, const constant::Value* value, const Source& source);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constant value evaluation methods, to be indirectly called via the intrinsic table
|
||||
|
@ -125,7 +125,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the converted value, or null if the value cannot be calculated
|
||||
Result Conv(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Zero value type initializer
|
||||
|
@ -134,7 +134,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the constructed value, or null if the value cannot be calculated
|
||||
Result Zero(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Identity value type initializer
|
||||
|
@ -143,7 +143,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the constructed value, or null if the value cannot be calculated
|
||||
Result Identity(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Vector splat initializer
|
||||
|
@ -152,7 +152,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the constructed value, or null if the value cannot be calculated
|
||||
Result VecSplat(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Vector initializer using scalars
|
||||
|
@ -161,7 +161,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the constructed value, or null if the value cannot be calculated
|
||||
Result VecInitS(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Vector initializer using a mix of scalars and smaller vectors
|
||||
|
@ -170,7 +170,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the constructed value, or null if the value cannot be calculated
|
||||
Result VecInitM(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Matrix initializer using scalar values
|
||||
|
@ -179,7 +179,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the constructed value, or null if the value cannot be calculated
|
||||
Result MatInitS(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Matrix initializer using column vectors
|
||||
|
@ -188,7 +188,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the constructed value, or null if the value cannot be calculated
|
||||
Result MatInitV(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -201,7 +201,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpComplement(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Unary minus operator '-'
|
||||
|
@ -210,7 +210,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpUnaryMinus(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Unary not operator '!'
|
||||
|
@ -219,7 +219,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpNot(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -232,7 +232,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpPlus(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Minus operator '-'
|
||||
|
@ -241,7 +241,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpMinus(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Multiply operator '*' for the same type on the LHS and RHS
|
||||
|
@ -250,7 +250,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpMultiply(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Multiply operator '*' for matCxR<T> * vecC<T>
|
||||
|
@ -259,7 +259,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpMultiplyMatVec(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Multiply operator '*' for vecR<T> * matCxR<T>
|
||||
|
@ -268,7 +268,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpMultiplyVecMat(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Multiply operator '*' for matKxR<T> * matCxK<T>
|
||||
|
@ -277,7 +277,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpMultiplyMatMat(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Divide operator '/'
|
||||
|
@ -286,7 +286,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpDivide(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Modulo operator '%'
|
||||
|
@ -295,7 +295,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpModulo(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Equality operator '=='
|
||||
|
@ -304,7 +304,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpEqual(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Inequality operator '!='
|
||||
|
@ -313,7 +313,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpNotEqual(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Less than operator '<'
|
||||
|
@ -322,7 +322,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpLessThan(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Greater than operator '>'
|
||||
|
@ -331,7 +331,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpGreaterThan(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Less than or equal operator '<='
|
||||
|
@ -340,7 +340,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpLessThanEqual(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Greater than or equal operator '>='
|
||||
|
@ -349,7 +349,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpGreaterThanEqual(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Logical and operator '&&'
|
||||
|
@ -358,7 +358,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpLogicalAnd(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Logical or operator '||'
|
||||
|
@ -367,7 +367,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpLogicalOr(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Bitwise and operator '&'
|
||||
|
@ -376,7 +376,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpAnd(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Bitwise or operator '|'
|
||||
|
@ -385,7 +385,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpOr(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Bitwise xor operator '^'
|
||||
|
@ -394,7 +394,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpXor(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Bitwise shift left operator '<<'
|
||||
|
@ -403,7 +403,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpShiftLeft(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Bitwise shift right operator '<<'
|
||||
|
@ -412,7 +412,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result OpShiftRight(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -425,7 +425,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result abs(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// acos builtin
|
||||
|
@ -434,7 +434,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result acos(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// acosh builtin
|
||||
|
@ -443,7 +443,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result acosh(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// all builtin
|
||||
|
@ -452,7 +452,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result all(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// any builtin
|
||||
|
@ -461,7 +461,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result any(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// asin builtin
|
||||
|
@ -470,7 +470,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result asin(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// asinh builtin
|
||||
|
@ -479,7 +479,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result asinh(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// atan builtin
|
||||
|
@ -488,7 +488,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result atan(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// atanh builtin
|
||||
|
@ -497,7 +497,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result atanh(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// atan2 builtin
|
||||
|
@ -506,7 +506,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result atan2(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// ceil builtin
|
||||
|
@ -515,7 +515,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result ceil(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// clamp builtin
|
||||
|
@ -524,7 +524,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result clamp(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// cos builtin
|
||||
|
@ -533,7 +533,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result cos(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// cosh builtin
|
||||
|
@ -542,7 +542,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result cosh(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// countLeadingZeros builtin
|
||||
|
@ -551,7 +551,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result countLeadingZeros(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// countOneBits builtin
|
||||
|
@ -560,7 +560,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result countOneBits(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// countTrailingZeros builtin
|
||||
|
@ -569,7 +569,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result countTrailingZeros(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// cross builtin
|
||||
|
@ -578,7 +578,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result cross(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// degrees builtin
|
||||
|
@ -587,7 +587,7 @@ class ConstEval {
|
|||
/// @param source the source location of the conversion
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result degrees(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// determinant builtin
|
||||
|
@ -596,7 +596,7 @@ class ConstEval {
|
|||
/// @param source the source location of the conversion
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result determinant(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// distance builtin
|
||||
|
@ -605,7 +605,7 @@ class ConstEval {
|
|||
/// @param source the source location of the conversion
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result distance(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// dot builtin
|
||||
|
@ -614,7 +614,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result dot(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// exp builtin
|
||||
|
@ -623,7 +623,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result exp(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// exp2 builtin
|
||||
|
@ -632,7 +632,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result exp2(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// extractBits builtin
|
||||
|
@ -641,7 +641,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result extractBits(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// faceForward builtin
|
||||
|
@ -650,7 +650,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result faceForward(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// firstLeadingBit builtin
|
||||
|
@ -659,7 +659,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result firstLeadingBit(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// firstTrailingBit builtin
|
||||
|
@ -668,7 +668,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result firstTrailingBit(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// floor builtin
|
||||
|
@ -677,7 +677,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result floor(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// fma builtin
|
||||
|
@ -686,7 +686,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result fma(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// fract builtin
|
||||
|
@ -695,7 +695,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result fract(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// frexp builtin
|
||||
|
@ -704,7 +704,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result frexp(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// insertBits builtin
|
||||
|
@ -713,7 +713,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result insertBits(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// inverseSqrt builtin
|
||||
|
@ -722,7 +722,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result inverseSqrt(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// length builtin
|
||||
|
@ -731,7 +731,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result length(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// log builtin
|
||||
|
@ -740,7 +740,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result log(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// log2 builtin
|
||||
|
@ -749,7 +749,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result log2(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// max builtin
|
||||
|
@ -758,7 +758,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result max(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// min builtin
|
||||
|
@ -767,7 +767,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result min(const type::Type* ty, // NOLINT(build/include_what_you_use) -- confused by min
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// mix builtin
|
||||
|
@ -776,7 +776,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result mix(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// modf builtin
|
||||
|
@ -785,7 +785,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result modf(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// normalize builtin
|
||||
|
@ -794,7 +794,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result normalize(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// pack2x16float builtin
|
||||
|
@ -803,7 +803,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result pack2x16float(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// pack2x16snorm builtin
|
||||
|
@ -812,7 +812,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result pack2x16snorm(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// pack2x16unorm builtin
|
||||
|
@ -821,7 +821,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result pack2x16unorm(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// pack4x8snorm builtin
|
||||
|
@ -830,7 +830,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result pack4x8snorm(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// pack4x8unorm builtin
|
||||
|
@ -839,7 +839,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result pack4x8unorm(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// pow builtin
|
||||
|
@ -848,7 +848,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result pow(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// radians builtin
|
||||
|
@ -857,7 +857,7 @@ class ConstEval {
|
|||
/// @param source the source location of the conversion
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result radians(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// reflect builtin
|
||||
|
@ -866,7 +866,7 @@ class ConstEval {
|
|||
/// @param source the source location of the conversion
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result reflect(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// refract builtin
|
||||
|
@ -875,7 +875,7 @@ class ConstEval {
|
|||
/// @param source the source location of the conversion
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result refract(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// reverseBits builtin
|
||||
|
@ -884,7 +884,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result reverseBits(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// round builtin
|
||||
|
@ -893,7 +893,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result round(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// saturate builtin
|
||||
|
@ -902,7 +902,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result saturate(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// select builtin with single bool third arg
|
||||
|
@ -911,7 +911,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result select_bool(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// select builtin with vector of bool third arg
|
||||
|
@ -920,7 +920,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result select_boolvec(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// sign builtin
|
||||
|
@ -929,7 +929,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result sign(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// sin builtin
|
||||
|
@ -938,7 +938,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result sin(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// sinh builtin
|
||||
|
@ -947,7 +947,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result sinh(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// smoothstep builtin
|
||||
|
@ -956,7 +956,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result smoothstep(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// step builtin
|
||||
|
@ -965,7 +965,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result step(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// sqrt builtin
|
||||
|
@ -974,7 +974,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result sqrt(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// tan builtin
|
||||
|
@ -983,7 +983,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result tan(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// tanh builtin
|
||||
|
@ -992,7 +992,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result tanh(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// transpose builtin
|
||||
|
@ -1001,7 +1001,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result transpose(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// trunc builtin
|
||||
|
@ -1010,7 +1010,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result trunc(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// unpack2x16float builtin
|
||||
|
@ -1019,7 +1019,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result unpack2x16float(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// unpack2x16snorm builtin
|
||||
|
@ -1028,7 +1028,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result unpack2x16snorm(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// unpack2x16unorm builtin
|
||||
|
@ -1037,7 +1037,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result unpack2x16unorm(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// unpack4x8snorm builtin
|
||||
|
@ -1046,7 +1046,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result unpack4x8snorm(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// unpack4x8unorm builtin
|
||||
|
@ -1055,7 +1055,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result unpack4x8unorm(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
/// quantizeToF16 builtin
|
||||
|
@ -1064,7 +1064,7 @@ class ConstEval {
|
|||
/// @param source the source location
|
||||
/// @return the result value, or null if the value cannot be calculated
|
||||
Result quantizeToF16(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Constant*> args,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
const Source& source);
|
||||
|
||||
private:
|
||||
|
@ -1361,14 +1361,14 @@ class ConstEval {
|
|||
/// @param v1 the first vector
|
||||
/// @param v2 the second vector
|
||||
/// @returns the dot product
|
||||
Result Dot(const Source& source, const constant::Constant* v1, const constant::Constant* v2);
|
||||
Result Dot(const Source& source, const constant::Value* v1, const constant::Value* v2);
|
||||
|
||||
/// Returns the length of c0
|
||||
/// @param source the source location
|
||||
/// @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 type::Type* ty, const constant::Constant* c0);
|
||||
Result Length(const Source& source, const type::Type* ty, const constant::Value* c0);
|
||||
|
||||
/// Returns the product of v1 and v2
|
||||
/// @param source the source location
|
||||
|
@ -1378,8 +1378,8 @@ class ConstEval {
|
|||
/// @returns the product of v1 and v2
|
||||
Result Mul(const Source& source,
|
||||
const type::Type* ty,
|
||||
const constant::Constant* v1,
|
||||
const constant::Constant* v2);
|
||||
const constant::Value* v1,
|
||||
const constant::Value* v2);
|
||||
|
||||
/// Returns the difference between v2 and v1
|
||||
/// @param source the source location
|
||||
|
@ -1389,8 +1389,8 @@ class ConstEval {
|
|||
/// @returns the difference between v2 and v1
|
||||
Result Sub(const Source& source,
|
||||
const type::Type* ty,
|
||||
const constant::Constant* v1,
|
||||
const constant::Constant* v2);
|
||||
const constant::Value* v1,
|
||||
const constant::Value* v2);
|
||||
|
||||
ProgramBuilder& builder;
|
||||
};
|
||||
|
|
|
@ -99,7 +99,7 @@ TEST_P(ResolverConstEvalBinaryOpTest, Test) {
|
|||
auto& expected = expected_case.value;
|
||||
|
||||
auto* sem = Sem().Get(expr);
|
||||
const constant::Constant* value = sem->ConstantValue();
|
||||
const constant::Value* value = sem->ConstantValue();
|
||||
ASSERT_NE(value, nullptr);
|
||||
EXPECT_TYPE(value->Type(), sem->Type());
|
||||
|
||||
|
@ -892,17 +892,16 @@ TEST_F(ResolverConstEvalTest, NotAndOrOfVecs) {
|
|||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
auto* sem = Sem().Get(expr);
|
||||
const constant::Constant* value = sem->ConstantValue();
|
||||
const constant::Value* value = sem->ConstantValue();
|
||||
ASSERT_NE(value, nullptr);
|
||||
EXPECT_TYPE(value->Type(), sem->Type());
|
||||
|
||||
auto* expected_sem = Sem().Get(expected_expr);
|
||||
const constant::Constant* expected_value = expected_sem->ConstantValue();
|
||||
const constant::Value* expected_value = expected_sem->ConstantValue();
|
||||
ASSERT_NE(expected_value, nullptr);
|
||||
EXPECT_TYPE(expected_value->Type(), expected_sem->Type());
|
||||
|
||||
ForEachElemPair(value, expected_value,
|
||||
[&](const constant::Constant* a, const constant::Constant* b) {
|
||||
ForEachElemPair(value, expected_value, [&](const constant::Value* a, const constant::Value* b) {
|
||||
EXPECT_EQ(a->ValueAs<bool>(), b->ValueAs<bool>());
|
||||
return HasFailure() ? Action::kStop : Action::kContinue;
|
||||
});
|
||||
|
|
|
@ -162,7 +162,7 @@ TEST_P(ResolverConstEvalBuiltinTest, Test) {
|
|||
|
||||
auto* sem = Sem().Get(expr);
|
||||
ASSERT_NE(sem, nullptr);
|
||||
const constant::Constant* value = sem->ConstantValue();
|
||||
const constant::Value* value = sem->ConstantValue();
|
||||
ASSERT_NE(value, nullptr);
|
||||
EXPECT_TYPE(value->Type(), sem->Type());
|
||||
|
||||
|
|
|
@ -89,10 +89,10 @@ TEST_F(ResolverConstEvalTest, Matrix_AFloat_Construct_From_AInt_Vectors) {
|
|||
EXPECT_FALSE(cv->AllZero());
|
||||
auto* c0 = cv->Index(0);
|
||||
auto* c1 = cv->Index(1);
|
||||
EXPECT_EQ(std::get<AFloat>(c0->Index(0)->Value()), 1.0);
|
||||
EXPECT_EQ(std::get<AFloat>(c0->Index(1)->Value()), 2.0);
|
||||
EXPECT_EQ(std::get<AFloat>(c1->Index(0)->Value()), 3.0);
|
||||
EXPECT_EQ(std::get<AFloat>(c1->Index(1)->Value()), 4.0);
|
||||
EXPECT_EQ(c0->Index(0)->ValueAs<AFloat>(), 1.0);
|
||||
EXPECT_EQ(c0->Index(1)->ValueAs<AFloat>(), 2.0);
|
||||
EXPECT_EQ(c1->Index(0)->ValueAs<AFloat>(), 3.0);
|
||||
EXPECT_EQ(c1->Index(1)->ValueAs<AFloat>(), 4.0);
|
||||
}
|
||||
} // namespace
|
||||
} // namespace tint::resolver
|
||||
|
|
|
@ -36,10 +36,9 @@ inline const auto kPiOver4 = T(UnwrapNumber<T>(0.785398163397448309616));
|
|||
template <typename T>
|
||||
inline const auto k3PiOver4 = T(UnwrapNumber<T>(2.356194490192344928846));
|
||||
|
||||
/// Walks the constant::Constant @p c, accumulating all the inner-most scalar values into @p args
|
||||
/// Walks the constant::Value @p c, accumulating all the inner-most scalar values into @p args
|
||||
template <size_t N>
|
||||
inline void CollectScalars(const constant::Constant* c,
|
||||
utils::Vector<builder::Scalar, N>& scalars) {
|
||||
inline void CollectScalars(const constant::Value* c, utils::Vector<builder::Scalar, N>& scalars) {
|
||||
Switch(
|
||||
c->Type(), //
|
||||
[&](const type::AbstractInt*) { scalars.Push(c->ValueAs<AInt>()); },
|
||||
|
@ -57,8 +56,8 @@ inline void CollectScalars(const constant::Constant* c,
|
|||
});
|
||||
}
|
||||
|
||||
/// Walks the constant::Constant @p c, returning all the inner-most scalar values.
|
||||
inline utils::Vector<builder::Scalar, 16> ScalarsFrom(const constant::Constant* c) {
|
||||
/// Walks the constant::Value @p c, returning all the inner-most scalar values.
|
||||
inline utils::Vector<builder::Scalar, 16> ScalarsFrom(const constant::Value* c) {
|
||||
utils::Vector<builder::Scalar, 16> out;
|
||||
CollectScalars(c, out);
|
||||
return out;
|
||||
|
@ -89,7 +88,7 @@ struct CheckConstantFlags {
|
|||
/// @param got_constant the constant value evaluated by the resolver
|
||||
/// @param expected_value the expected value for the test
|
||||
/// @param flags optional flags for controlling the comparisons
|
||||
inline void CheckConstant(const constant::Constant* got_constant,
|
||||
inline void CheckConstant(const constant::Value* got_constant,
|
||||
const builder::Value& expected_value,
|
||||
CheckConstantFlags flags = {}) {
|
||||
auto values_flat = ScalarsFrom(got_constant);
|
||||
|
@ -258,7 +257,7 @@ using builder::Vec;
|
|||
// TODO(amaiorano): Move to Constant.h?
|
||||
enum class Action { kStop, kContinue };
|
||||
template <typename Func>
|
||||
inline Action ForEachElemPair(const constant::Constant* a, const constant::Constant* b, Func&& f) {
|
||||
inline Action ForEachElemPair(const constant::Value* a, const constant::Value* b, Func&& f) {
|
||||
EXPECT_EQ(a->Type(), b->Type());
|
||||
size_t i = 0;
|
||||
while (true) {
|
||||
|
|
|
@ -57,7 +57,7 @@ TEST_P(ResolverConstEvalUnaryOpTest, Test) {
|
|||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
auto* sem = Sem().Get(expr);
|
||||
const constant::Constant* value = sem->ConstantValue();
|
||||
const constant::Value* value = sem->ConstantValue();
|
||||
ASSERT_NE(value, nullptr);
|
||||
EXPECT_TYPE(value->Type(), sem->Type());
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ class MaterializeTest : public resolver::ResolverTestWithParam<CASE> {
|
|||
auto* el = value->Index(i);
|
||||
ASSERT_NE(el, nullptr);
|
||||
EXPECT_TYPE(el->Type(), v->type());
|
||||
EXPECT_EQ(std::get<T>(el->Value()), expected_value);
|
||||
EXPECT_EQ(el->ValueAs<T>(), expected_value);
|
||||
}
|
||||
},
|
||||
[&](const type::Matrix* m) {
|
||||
|
@ -113,7 +113,7 @@ class MaterializeTest : public resolver::ResolverTestWithParam<CASE> {
|
|||
auto* el = column->Index(r);
|
||||
ASSERT_NE(el, nullptr);
|
||||
EXPECT_TYPE(el->Type(), m->type());
|
||||
EXPECT_EQ(std::get<T>(el->Value()), expected_value);
|
||||
EXPECT_EQ(el->ValueAs<T>(), expected_value);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -124,10 +124,10 @@ class MaterializeTest : public resolver::ResolverTestWithParam<CASE> {
|
|||
auto* el = value->Index(i);
|
||||
ASSERT_NE(el, nullptr);
|
||||
EXPECT_TYPE(el->Type(), a->ElemType());
|
||||
EXPECT_EQ(std::get<T>(el->Value()), expected_value);
|
||||
EXPECT_EQ(el->ValueAs<T>(), expected_value);
|
||||
}
|
||||
},
|
||||
[&](Default) { EXPECT_EQ(std::get<T>(value->Value()), expected_value); });
|
||||
[&](Default) { EXPECT_EQ(value->ValueAs<T>(), expected_value); });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1278,7 +1278,7 @@ sem::CaseStatement* Resolver::CaseStatement(const ast::CaseStatement* stmt, cons
|
|||
ExprEvalStageConstraint constraint{sem::EvaluationStage::kConstant, "case selector"};
|
||||
TINT_SCOPED_ASSIGNMENT(expr_eval_stage_constraint_, constraint);
|
||||
|
||||
const constant::Constant* const_value = nullptr;
|
||||
const constant::Value* const_value = nullptr;
|
||||
if (!sel->IsDefault()) {
|
||||
// The sem statement was created in the switch when attempting to determine the
|
||||
// common type.
|
||||
|
@ -1797,7 +1797,7 @@ const sem::Expression* Resolver::Materialize(const sem::Expression* expr,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const constant::Constant* materialized_val = nullptr;
|
||||
const constant::Value* materialized_val = nullptr;
|
||||
if (!skip_const_eval_.Contains(decl)) {
|
||||
auto expr_val = expr->ConstantValue();
|
||||
if (!expr_val) {
|
||||
|
@ -1849,7 +1849,7 @@ bool Resolver::ShouldMaterializeArgument(const type::Type* parameter_ty) const {
|
|||
return param_el_ty && !param_el_ty->Is<type::AbstractNumeric>();
|
||||
}
|
||||
|
||||
bool Resolver::Convert(const constant::Constant*& c,
|
||||
bool Resolver::Convert(const constant::Value*& c,
|
||||
const type::Type* target_ty,
|
||||
const Source& source) {
|
||||
auto r = const_eval_.Convert(target_ty, c, source);
|
||||
|
@ -1861,7 +1861,7 @@ bool Resolver::Convert(const constant::Constant*& c,
|
|||
}
|
||||
|
||||
template <size_t N>
|
||||
utils::Result<utils::Vector<const constant::Constant*, N>> Resolver::ConvertArguments(
|
||||
utils::Result<utils::Vector<const constant::Value*, N>> Resolver::ConvertArguments(
|
||||
const utils::Vector<const sem::Expression*, N>& args,
|
||||
const sem::CallTarget* target) {
|
||||
auto const_args = utils::Transform(args, [](auto* arg) { return arg->ConstantValue(); });
|
||||
|
@ -1919,7 +1919,7 @@ sem::Expression* Resolver::IndexAccessor(const ast::IndexAccessorExpression* exp
|
|||
ty = builder_->create<type::Reference>(ty, ref->AddressSpace(), ref->Access());
|
||||
}
|
||||
|
||||
const constant::Constant* val = nullptr;
|
||||
const constant::Value* val = nullptr;
|
||||
auto stage = sem::EarliestStage(obj->Stage(), idx->Stage());
|
||||
if (stage == sem::EvaluationStage::kConstant && skip_const_eval_.Contains(expr)) {
|
||||
stage = sem::EvaluationStage::kNotEvaluated;
|
||||
|
@ -1950,7 +1950,7 @@ sem::Expression* Resolver::Bitcast(const ast::BitcastExpression* expr) {
|
|||
|
||||
RegisterLoadIfNeeded(inner);
|
||||
|
||||
const constant::Constant* val = nullptr;
|
||||
const constant::Value* val = nullptr;
|
||||
// TODO(crbug.com/tint/1582): short circuit 'expr' once const eval of Bitcast is implemented.
|
||||
if (auto r = const_eval_.Bitcast(ty, inner)) {
|
||||
val = r.Get();
|
||||
|
@ -2012,7 +2012,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const constant::Constant* value = nullptr;
|
||||
const constant::Value* value = nullptr;
|
||||
auto stage = sem::EarliestStage(ctor_or_conv.target->Stage(), args_stage);
|
||||
if (stage == sem::EvaluationStage::kConstant && skip_const_eval_.Contains(expr)) {
|
||||
stage = sem::EvaluationStage::kNotEvaluated;
|
||||
|
@ -2042,7 +2042,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
}
|
||||
|
||||
auto stage = args_stage; // The evaluation stage of the call
|
||||
const constant::Constant* value = nullptr; // The constant value for the call
|
||||
const constant::Value* value = nullptr; // The constant value for the call
|
||||
if (stage == sem::EvaluationStage::kConstant) {
|
||||
if (auto r = const_eval_.ArrayOrStructInit(ty, args)) {
|
||||
value = r.Get();
|
||||
|
@ -2336,7 +2336,7 @@ sem::Call* Resolver::BuiltinCall(const ast::CallExpression* expr,
|
|||
|
||||
// If the builtin is @const, and all arguments have constant values, evaluate the builtin
|
||||
// now.
|
||||
const constant::Constant* value = nullptr;
|
||||
const constant::Value* value = nullptr;
|
||||
auto stage = sem::EarliestStage(arg_stage, builtin.sem->Stage());
|
||||
if (stage == sem::EvaluationStage::kConstant && skip_const_eval_.Contains(expr)) {
|
||||
stage = sem::EvaluationStage::kNotEvaluated;
|
||||
|
@ -2607,7 +2607,7 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const constant::Constant* val = nullptr;
|
||||
const constant::Value* val = nullptr;
|
||||
if (auto r = const_eval_.Literal(ty, literal)) {
|
||||
val = r.Get();
|
||||
} else {
|
||||
|
@ -2875,7 +2875,7 @@ sem::Expression* Resolver::Binary(const ast::BinaryExpression* expr) {
|
|||
RegisterLoadIfNeeded(lhs);
|
||||
RegisterLoadIfNeeded(rhs);
|
||||
|
||||
const constant::Constant* value = nullptr;
|
||||
const constant::Value* value = nullptr;
|
||||
if (stage == sem::EvaluationStage::kConstant) {
|
||||
if (op.const_eval_fn) {
|
||||
if (skip_const_eval_.Contains(expr)) {
|
||||
|
@ -2920,7 +2920,7 @@ sem::Expression* Resolver::UnaryOp(const ast::UnaryOpExpression* unary) {
|
|||
|
||||
const type::Type* ty = nullptr;
|
||||
const sem::Variable* root_ident = nullptr;
|
||||
const constant::Constant* value = nullptr;
|
||||
const constant::Value* value = nullptr;
|
||||
auto stage = sem::EvaluationStage::kRuntime;
|
||||
|
||||
switch (unary->op) {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "src/tint/constant/constant.h"
|
||||
#include "src/tint/constant/value.h"
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/resolver/const_eval.h"
|
||||
#include "src/tint/resolver/dependency_graph.h"
|
||||
|
@ -197,13 +197,13 @@ class Resolver {
|
|||
|
||||
/// Converts `c` to `target_ty`
|
||||
/// @returns true on success, false on failure.
|
||||
bool Convert(const constant::Constant*& c, const type::Type* target_ty, const Source& source);
|
||||
bool Convert(const constant::Value*& 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.
|
||||
/// @returns the vector of constants, `utils::Failure` on failure.
|
||||
template <size_t N>
|
||||
utils::Result<utils::Vector<const constant::Constant*, N>> ConvertArguments(
|
||||
utils::Result<utils::Vector<const constant::Value*, N>> ConvertArguments(
|
||||
const utils::Vector<const sem::Expression*, N>& args,
|
||||
const sem::CallTarget* target);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ Call::Call(const ast::CallExpression* declaration,
|
|||
EvaluationStage stage,
|
||||
utils::VectorRef<const sem::Expression*> arguments,
|
||||
const Statement* statement,
|
||||
const constant::Constant* constant,
|
||||
const constant::Value* constant,
|
||||
bool has_side_effects)
|
||||
: Base(declaration, target->ReturnType(), stage, statement, constant, has_side_effects),
|
||||
target_(target),
|
||||
|
|
|
@ -41,7 +41,7 @@ class Call final : public Castable<Call, Expression> {
|
|||
EvaluationStage stage,
|
||||
utils::VectorRef<const sem::Expression*> arguments,
|
||||
const Statement* statement,
|
||||
const constant::Constant* constant,
|
||||
const constant::Value* constant,
|
||||
bool has_side_effects);
|
||||
|
||||
/// Destructor
|
||||
|
|
|
@ -26,7 +26,7 @@ Expression::Expression(const ast::Expression* declaration,
|
|||
const type::Type* type,
|
||||
EvaluationStage stage,
|
||||
const Statement* statement,
|
||||
const constant::Constant* constant,
|
||||
const constant::Value* constant,
|
||||
bool has_side_effects,
|
||||
const Variable* root_ident /* = nullptr */)
|
||||
: declaration_(declaration),
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define SRC_TINT_SEM_EXPRESSION_H_
|
||||
|
||||
#include "src/tint/ast/expression.h"
|
||||
#include "src/tint/constant/constant.h"
|
||||
#include "src/tint/constant/value.h"
|
||||
#include "src/tint/sem/behavior.h"
|
||||
#include "src/tint/sem/evaluation_stage.h"
|
||||
#include "src/tint/sem/node.h"
|
||||
|
@ -44,7 +44,7 @@ class Expression : public Castable<Expression, Node> {
|
|||
const type::Type* type,
|
||||
EvaluationStage stage,
|
||||
const Statement* statement,
|
||||
const constant::Constant* constant,
|
||||
const constant::Value* constant,
|
||||
bool has_side_effects,
|
||||
const Variable* root_ident = nullptr);
|
||||
|
||||
|
@ -64,7 +64,7 @@ class Expression : public Castable<Expression, Node> {
|
|||
const Statement* Stmt() const { return statement_; }
|
||||
|
||||
/// @return the constant value of this expression
|
||||
const constant::Constant* ConstantValue() const { return constant_; }
|
||||
const constant::Value* ConstantValue() const { return constant_; }
|
||||
|
||||
/// Returns the variable or parameter that this expression derives from.
|
||||
/// For reference and pointer expressions, this will either be the originating
|
||||
|
@ -95,7 +95,7 @@ class Expression : public Castable<Expression, Node> {
|
|||
const type::Type* const type_;
|
||||
const EvaluationStage stage_;
|
||||
const Statement* const statement_;
|
||||
const constant::Constant* const constant_;
|
||||
const constant::Value* const constant_;
|
||||
sem::Behaviors behaviors_{sem::Behavior::kNext};
|
||||
const bool has_side_effects_;
|
||||
};
|
||||
|
|
|
@ -23,18 +23,20 @@ using namespace tint::number_suffixes; // NOLINT
|
|||
namespace tint::sem {
|
||||
namespace {
|
||||
|
||||
class MockConstant : public constant::Constant {
|
||||
class MockConstant : public constant::Value {
|
||||
public:
|
||||
explicit MockConstant(const type::Type* ty) : type(ty) {}
|
||||
~MockConstant() override {}
|
||||
const type::Type* Type() const override { return type; }
|
||||
std::variant<std::monostate, AInt, AFloat> Value() const override { return {}; }
|
||||
const constant::Constant* Index(size_t) const override { return {}; }
|
||||
const constant::Value* Index(size_t) const override { return {}; }
|
||||
bool AllZero() const override { return {}; }
|
||||
bool AnyZero() const override { return {}; }
|
||||
bool AllEqual() const override { return {}; }
|
||||
size_t Hash() const override { return 0; }
|
||||
|
||||
protected:
|
||||
std::variant<std::monostate, AInt, AFloat> InternalValue() const override { return {}; }
|
||||
|
||||
private:
|
||||
const type::Type* type;
|
||||
};
|
||||
|
|
|
@ -28,7 +28,7 @@ IndexAccessorExpression::IndexAccessorExpression(const ast::IndexAccessorExpress
|
|||
const Expression* object,
|
||||
const Expression* index,
|
||||
const Statement* statement,
|
||||
const constant::Constant* constant,
|
||||
const constant::Value* constant,
|
||||
bool has_side_effects,
|
||||
const Variable* root_ident /* = nullptr */)
|
||||
: Base(declaration, type, stage, statement, constant, has_side_effects, root_ident),
|
||||
|
|
|
@ -45,7 +45,7 @@ class IndexAccessorExpression final : public Castable<IndexAccessorExpression, E
|
|||
const Expression* object,
|
||||
const Expression* index,
|
||||
const Statement* statement,
|
||||
const constant::Constant* constant,
|
||||
const constant::Value* constant,
|
||||
bool has_side_effects,
|
||||
const Variable* root_ident = nullptr);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace tint::sem {
|
|||
Materialize::Materialize(const Expression* expr,
|
||||
const Statement* statement,
|
||||
const type::Type* type,
|
||||
const constant::Constant* constant)
|
||||
const constant::Value* constant)
|
||||
: Base(/* declaration */ expr->Declaration(),
|
||||
/* type */ type,
|
||||
/* stage */ constant ? EvaluationStage::kConstant : EvaluationStage::kNotEvaluated,
|
||||
|
|
|
@ -35,7 +35,7 @@ class Materialize final : public Castable<Materialize, Expression> {
|
|||
Materialize(const Expression* expr,
|
||||
const Statement* statement,
|
||||
const type::Type* type,
|
||||
const constant::Constant* constant);
|
||||
const constant::Value* constant);
|
||||
|
||||
/// Destructor
|
||||
~Materialize() override;
|
||||
|
|
|
@ -27,7 +27,7 @@ MemberAccessorExpression::MemberAccessorExpression(const ast::MemberAccessorExpr
|
|||
const type::Type* type,
|
||||
EvaluationStage stage,
|
||||
const Statement* statement,
|
||||
const constant::Constant* constant,
|
||||
const constant::Value* constant,
|
||||
const Expression* object,
|
||||
bool has_side_effects,
|
||||
const Variable* root_ident /* = nullptr */)
|
||||
|
@ -39,7 +39,7 @@ MemberAccessorExpression::~MemberAccessorExpression() = default;
|
|||
StructMemberAccess::StructMemberAccess(const ast::MemberAccessorExpression* declaration,
|
||||
const type::Type* type,
|
||||
const Statement* statement,
|
||||
const constant::Constant* constant,
|
||||
const constant::Value* constant,
|
||||
const Expression* object,
|
||||
const StructMember* member,
|
||||
bool has_side_effects,
|
||||
|
@ -59,7 +59,7 @@ StructMemberAccess::~StructMemberAccess() = default;
|
|||
Swizzle::Swizzle(const ast::MemberAccessorExpression* declaration,
|
||||
const type::Type* type,
|
||||
const Statement* statement,
|
||||
const constant::Constant* constant,
|
||||
const constant::Value* constant,
|
||||
const Expression* object,
|
||||
utils::VectorRef<uint32_t> indices,
|
||||
bool has_side_effects,
|
||||
|
|
|
@ -52,7 +52,7 @@ class MemberAccessorExpression : public Castable<MemberAccessorExpression, Expre
|
|||
const type::Type* type,
|
||||
EvaluationStage stage,
|
||||
const Statement* statement,
|
||||
const constant::Constant* constant,
|
||||
const constant::Value* constant,
|
||||
const Expression* object,
|
||||
bool has_side_effects,
|
||||
const Variable* root_ident = nullptr);
|
||||
|
@ -78,7 +78,7 @@ class StructMemberAccess final : public Castable<StructMemberAccess, MemberAcces
|
|||
StructMemberAccess(const ast::MemberAccessorExpression* declaration,
|
||||
const type::Type* type,
|
||||
const Statement* statement,
|
||||
const constant::Constant* constant,
|
||||
const constant::Value* constant,
|
||||
const Expression* object,
|
||||
const StructMember* member,
|
||||
bool has_side_effects,
|
||||
|
@ -110,7 +110,7 @@ class Swizzle final : public Castable<Swizzle, MemberAccessorExpression> {
|
|||
Swizzle(const ast::MemberAccessorExpression* declaration,
|
||||
const type::Type* type,
|
||||
const Statement* statement,
|
||||
const constant::Constant* constant,
|
||||
const constant::Value* constant,
|
||||
const Expression* object,
|
||||
utils::VectorRef<uint32_t> indices,
|
||||
bool has_side_effects,
|
||||
|
|
|
@ -49,7 +49,7 @@ const ast::CaseStatement* CaseStatement::Declaration() const {
|
|||
return static_cast<const ast::CaseStatement*>(Base::Declaration());
|
||||
}
|
||||
|
||||
CaseSelector::CaseSelector(const ast::CaseSelector* decl, const constant::Constant* val)
|
||||
CaseSelector::CaseSelector(const ast::CaseSelector* decl, const constant::Value* val)
|
||||
: Base(), decl_(decl), val_(val) {}
|
||||
|
||||
CaseSelector::~CaseSelector() = default;
|
||||
|
|
|
@ -26,7 +26,7 @@ class CaseSelector;
|
|||
class SwitchStatement;
|
||||
} // namespace tint::ast
|
||||
namespace tint::constant {
|
||||
class Constant;
|
||||
class Value;
|
||||
} // namespace tint::constant
|
||||
namespace tint::sem {
|
||||
class CaseStatement;
|
||||
|
@ -103,7 +103,7 @@ class CaseSelector final : public Castable<CaseSelector, Node> {
|
|||
/// Constructor
|
||||
/// @param decl the selector declaration
|
||||
/// @param val the case selector value, nullptr for a default selector
|
||||
explicit CaseSelector(const ast::CaseSelector* decl, const constant::Constant* val = nullptr);
|
||||
explicit CaseSelector(const ast::CaseSelector* decl, const constant::Value* val = nullptr);
|
||||
|
||||
/// Destructor
|
||||
~CaseSelector() override;
|
||||
|
@ -115,11 +115,11 @@ class CaseSelector final : public Castable<CaseSelector, Node> {
|
|||
const ast::CaseSelector* Declaration() const;
|
||||
|
||||
/// @returns the selector constant value, or nullptr if this is the default selector
|
||||
const constant::Constant* Value() const { return val_; }
|
||||
const constant::Value* Value() const { return val_; }
|
||||
|
||||
private:
|
||||
const ast::CaseSelector* const decl_;
|
||||
const constant::Constant* const val_;
|
||||
const constant::Value* const val_;
|
||||
};
|
||||
|
||||
} // namespace tint::sem
|
||||
|
|
|
@ -33,7 +33,7 @@ Variable::Variable(const ast::Variable* declaration,
|
|||
EvaluationStage stage,
|
||||
ast::AddressSpace address_space,
|
||||
ast::Access access,
|
||||
const constant::Constant* constant_value)
|
||||
const constant::Value* constant_value)
|
||||
: declaration_(declaration),
|
||||
type_(type),
|
||||
stage_(stage),
|
||||
|
@ -49,7 +49,7 @@ LocalVariable::LocalVariable(const ast::Variable* declaration,
|
|||
ast::AddressSpace address_space,
|
||||
ast::Access access,
|
||||
const sem::Statement* statement,
|
||||
const constant::Constant* constant_value)
|
||||
const constant::Value* constant_value)
|
||||
: Base(declaration, type, stage, address_space, access, constant_value),
|
||||
statement_(statement) {}
|
||||
|
||||
|
@ -60,7 +60,7 @@ GlobalVariable::GlobalVariable(const ast::Variable* declaration,
|
|||
EvaluationStage stage,
|
||||
ast::AddressSpace address_space,
|
||||
ast::Access access,
|
||||
const constant::Constant* constant_value,
|
||||
const constant::Value* constant_value,
|
||||
sem::BindingPoint binding_point,
|
||||
std::optional<uint32_t> location)
|
||||
: Base(declaration, type, stage, address_space, access, constant_value),
|
||||
|
|
|
@ -59,7 +59,7 @@ class Variable : public Castable<Variable, Node> {
|
|||
EvaluationStage stage,
|
||||
ast::AddressSpace address_space,
|
||||
ast::Access access,
|
||||
const constant::Constant* constant_value);
|
||||
const constant::Value* constant_value);
|
||||
|
||||
/// Destructor
|
||||
~Variable() override;
|
||||
|
@ -80,7 +80,7 @@ class Variable : public Castable<Variable, Node> {
|
|||
ast::Access Access() const { return access_; }
|
||||
|
||||
/// @return the constant value of this expression
|
||||
const constant::Constant* ConstantValue() const { return constant_value_; }
|
||||
const constant::Value* ConstantValue() const { return constant_value_; }
|
||||
|
||||
/// @returns the variable initializer expression, or nullptr if the variable
|
||||
/// does not have one.
|
||||
|
@ -102,7 +102,7 @@ class Variable : public Castable<Variable, Node> {
|
|||
const EvaluationStage stage_;
|
||||
const ast::AddressSpace address_space_;
|
||||
const ast::Access access_;
|
||||
const constant::Constant* constant_value_;
|
||||
const constant::Value* constant_value_;
|
||||
const Expression* initializer_ = nullptr;
|
||||
std::vector<const VariableUser*> users_;
|
||||
};
|
||||
|
@ -124,7 +124,7 @@ class LocalVariable final : public Castable<LocalVariable, Variable> {
|
|||
ast::AddressSpace address_space,
|
||||
ast::Access access,
|
||||
const sem::Statement* statement,
|
||||
const constant::Constant* constant_value);
|
||||
const constant::Value* constant_value);
|
||||
|
||||
/// Destructor
|
||||
~LocalVariable() override;
|
||||
|
@ -164,7 +164,7 @@ class GlobalVariable final : public Castable<GlobalVariable, Variable> {
|
|||
EvaluationStage stage,
|
||||
ast::AddressSpace address_space,
|
||||
ast::Access access,
|
||||
const constant::Constant* constant_value,
|
||||
const constant::Value* constant_value,
|
||||
sem::BindingPoint binding_point = {},
|
||||
std::optional<uint32_t> location = std::nullopt);
|
||||
|
||||
|
|
|
@ -256,7 +256,7 @@
|
|||
<DisplayString>vec{width_}<{*subtype_}></DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="tint::constant::Constant">
|
||||
<Type Name="tint::constant::Value">
|
||||
<DisplayString>Type={*Type()} Value={Value()}</DisplayString>
|
||||
</Type>
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "src/tint/ast/internal_attribute.h"
|
||||
#include "src/tint/ast/interpolate_attribute.h"
|
||||
#include "src/tint/ast/variable_decl_statement.h"
|
||||
#include "src/tint/constant/constant.h"
|
||||
#include "src/tint/constant/value.h"
|
||||
#include "src/tint/debug.h"
|
||||
#include "src/tint/sem/block_statement.h"
|
||||
#include "src/tint/sem/call.h"
|
||||
|
@ -2294,7 +2294,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Constant* constant) {
|
||||
bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* constant) {
|
||||
return Switch(
|
||||
constant->Type(), //
|
||||
[&](const type::Bool*) {
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
// Forward declarations
|
||||
namespace tint::sem {
|
||||
class Call;
|
||||
class Constant;
|
||||
class Builtin;
|
||||
class TypeInitializer;
|
||||
class TypeConversion;
|
||||
|
@ -363,7 +362,7 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// @param out the output stream
|
||||
/// @param constant the constant value to emit
|
||||
/// @returns true if the constant value was successfully emitted
|
||||
bool EmitConstant(std::ostream& out, const constant::Constant* constant);
|
||||
bool EmitConstant(std::ostream& out, const constant::Value* constant);
|
||||
/// Handles a literal
|
||||
/// @param out the output stream
|
||||
/// @param lit the literal to emit
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "src/tint/ast/internal_attribute.h"
|
||||
#include "src/tint/ast/interpolate_attribute.h"
|
||||
#include "src/tint/ast/variable_decl_statement.h"
|
||||
#include "src/tint/constant/constant.h"
|
||||
#include "src/tint/constant/value.h"
|
||||
#include "src/tint/debug.h"
|
||||
#include "src/tint/sem/block_statement.h"
|
||||
#include "src/tint/sem/call.h"
|
||||
|
@ -1117,7 +1117,7 @@ bool GeneratorImpl::EmitUniformBufferAccess(
|
|||
|
||||
if (auto* val = offset_arg->ConstantValue()) {
|
||||
TINT_ASSERT(Writer, val->Type()->Is<type::U32>());
|
||||
scalar_offset_bytes = static_cast<uint32_t>(std::get<AInt>(val->Value()));
|
||||
scalar_offset_bytes = static_cast<uint32_t>(val->ValueAs<AInt>());
|
||||
scalar_offset_index = scalar_offset_bytes / 4; // bytes -> scalar index
|
||||
scalar_offset_constant = true;
|
||||
}
|
||||
|
@ -3263,7 +3263,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) {
|
|||
}
|
||||
|
||||
bool GeneratorImpl::EmitConstant(std::ostream& out,
|
||||
const constant::Constant* constant,
|
||||
const constant::Value* constant,
|
||||
bool is_variable_initializer) {
|
||||
return Switch(
|
||||
constant->Type(), //
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
// Forward declarations
|
||||
namespace tint::sem {
|
||||
class Call;
|
||||
class Constant;
|
||||
class Builtin;
|
||||
class TypeInitializer;
|
||||
class TypeConversion;
|
||||
|
@ -352,7 +351,7 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// initializer
|
||||
/// @returns true if the constant value was successfully emitted
|
||||
bool EmitConstant(std::ostream& out,
|
||||
const constant::Constant* constant,
|
||||
const constant::Value* constant,
|
||||
bool is_variable_initializer);
|
||||
/// Handles a literal
|
||||
/// @param out the output stream
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "src/tint/ast/module.h"
|
||||
#include "src/tint/ast/variable_decl_statement.h"
|
||||
#include "src/tint/ast/void.h"
|
||||
#include "src/tint/constant/constant.h"
|
||||
#include "src/tint/constant/value.h"
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/sem/function.h"
|
||||
#include "src/tint/sem/member_accessor_expression.h"
|
||||
|
@ -1658,7 +1658,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
|
|||
});
|
||||
}
|
||||
|
||||
bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Constant* constant) {
|
||||
bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* constant) {
|
||||
return Switch(
|
||||
constant->Type(), //
|
||||
[&](const type::Bool*) {
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
// Forward declarations
|
||||
namespace tint::sem {
|
||||
class Call;
|
||||
class Constant;
|
||||
class Builtin;
|
||||
class TypeInitializer;
|
||||
class TypeConversion;
|
||||
|
@ -260,7 +259,7 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// @param out the output stream
|
||||
/// @param constant the constant value to emit
|
||||
/// @returns true if the constant value was successfully emitted
|
||||
bool EmitConstant(std::ostream& out, const constant::Constant* constant);
|
||||
bool EmitConstant(std::ostream& out, const constant::Value* constant);
|
||||
/// Handles a literal
|
||||
/// @param out the output of the expression stream
|
||||
/// @param lit the literal to emit
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "src/tint/ast/id_attribute.h"
|
||||
#include "src/tint/ast/internal_attribute.h"
|
||||
#include "src/tint/ast/traverse_expressions.h"
|
||||
#include "src/tint/constant/constant.h"
|
||||
#include "src/tint/constant/value.h"
|
||||
#include "src/tint/sem/builtin.h"
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/sem/function.h"
|
||||
|
@ -1641,7 +1641,7 @@ uint32_t Builder::GenerateLiteralIfNeeded(const ast::LiteralExpression* lit) {
|
|||
return GenerateConstantIfNeeded(constant);
|
||||
}
|
||||
|
||||
uint32_t Builder::GenerateConstantIfNeeded(const constant::Constant* constant) {
|
||||
uint32_t Builder::GenerateConstantIfNeeded(const constant::Value* constant) {
|
||||
if (constant->AllZero()) {
|
||||
return GenerateConstantNullIfNeeded(constant->Type());
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
// Forward declarations
|
||||
namespace tint::sem {
|
||||
class Call;
|
||||
class Constant;
|
||||
class TypeInitializer;
|
||||
class TypeConversion;
|
||||
} // namespace tint::sem
|
||||
|
@ -559,7 +558,7 @@ class Builder {
|
|||
/// Generates a constant value if needed
|
||||
/// @param constant the constant to generate.
|
||||
/// @returns the ID on success or 0 on failure
|
||||
uint32_t GenerateConstantIfNeeded(const constant::Constant* constant);
|
||||
uint32_t GenerateConstantIfNeeded(const constant::Value* constant);
|
||||
|
||||
/// Generates a scalar constant if needed
|
||||
/// @param constant the constant to generate.
|
||||
|
|
Loading…
Reference in New Issue