mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-07 07:03:42 +00:00
Move sem::Constant to constant::Constant
This CL splits the base constant code out of sem into their own folder. This will allow re-using the constants in the IR. The concrete implementations from the resolver will move in followup CLs. Bug: tint:1718 Change-Id: Ic370db76dce34e3e6eca56a9c2a8df607492b4a6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113802 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
28483ef6dc
commit
10182c46d9
@ -366,6 +366,7 @@ libtint_source_set("libtint_core_all_src") {
|
|||||||
"castable.h",
|
"castable.h",
|
||||||
"clone_context.cc",
|
"clone_context.cc",
|
||||||
"clone_context.h",
|
"clone_context.h",
|
||||||
|
"constant/constant.h",
|
||||||
"debug.cc",
|
"debug.cc",
|
||||||
"debug.h",
|
"debug.h",
|
||||||
"demangler.cc",
|
"demangler.cc",
|
||||||
@ -421,7 +422,6 @@ libtint_source_set("libtint_core_all_src") {
|
|||||||
"sem/builtin_type.h",
|
"sem/builtin_type.h",
|
||||||
"sem/call.h",
|
"sem/call.h",
|
||||||
"sem/call_target.h",
|
"sem/call_target.h",
|
||||||
"sem/constant.h",
|
|
||||||
"sem/evaluation_stage.h",
|
"sem/evaluation_stage.h",
|
||||||
"sem/expression.h",
|
"sem/expression.h",
|
||||||
"sem/for_loop_statement.h",
|
"sem/for_loop_statement.h",
|
||||||
@ -649,8 +649,6 @@ libtint_source_set("libtint_sem_src") {
|
|||||||
"sem/call.h",
|
"sem/call.h",
|
||||||
"sem/call_target.cc",
|
"sem/call_target.cc",
|
||||||
"sem/call_target.h",
|
"sem/call_target.h",
|
||||||
"sem/constant.cc",
|
|
||||||
"sem/constant.h",
|
|
||||||
"sem/evaluation_stage.h",
|
"sem/evaluation_stage.h",
|
||||||
"sem/expression.cc",
|
"sem/expression.cc",
|
||||||
"sem/expression.h",
|
"sem/expression.h",
|
||||||
@ -758,8 +756,17 @@ libtint_source_set("libtint_type_src") {
|
|||||||
public_deps = [ ":libtint_core_all_src" ]
|
public_deps = [ ":libtint_core_all_src" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
libtint_source_set("libtint_constant_src") {
|
||||||
|
sources = [
|
||||||
|
"constant/constant.cc",
|
||||||
|
"constant/constant.h",
|
||||||
|
]
|
||||||
|
public_deps = [ ":libtint_core_all_src" ]
|
||||||
|
}
|
||||||
|
|
||||||
libtint_source_set("libtint_core_src") {
|
libtint_source_set("libtint_core_src") {
|
||||||
public_deps = [
|
public_deps = [
|
||||||
|
":libtint_constant_src",
|
||||||
":libtint_core_all_src",
|
":libtint_core_all_src",
|
||||||
":libtint_sem_src",
|
":libtint_sem_src",
|
||||||
":libtint_type_src",
|
":libtint_type_src",
|
||||||
|
@ -254,6 +254,8 @@ list(APPEND TINT_LIB_SRCS
|
|||||||
castable.h
|
castable.h
|
||||||
clone_context.cc
|
clone_context.cc
|
||||||
clone_context.h
|
clone_context.h
|
||||||
|
constant/constant.cc
|
||||||
|
constant/constant.h
|
||||||
demangler.cc
|
demangler.cc
|
||||||
demangler.h
|
demangler.h
|
||||||
inspector/entry_point.cc
|
inspector/entry_point.cc
|
||||||
@ -306,8 +308,6 @@ list(APPEND TINT_LIB_SRCS
|
|||||||
sem/call_target.h
|
sem/call_target.h
|
||||||
sem/call.cc
|
sem/call.cc
|
||||||
sem/call.h
|
sem/call.h
|
||||||
sem/constant.cc
|
|
||||||
sem/constant.h
|
|
||||||
sem/evaluation_stage.h
|
sem/evaluation_stage.h
|
||||||
sem/expression.cc
|
sem/expression.cc
|
||||||
sem/expression.h
|
sem/expression.h
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/tint/sem/constant.h"
|
#include "src/tint/constant/constant.h"
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::constant {
|
||||||
|
|
||||||
Constant::Constant() = default;
|
Constant::Constant() = default;
|
||||||
|
|
||||||
Constant::~Constant() = default;
|
Constant::~Constant() = default;
|
||||||
|
|
||||||
} // namespace tint::sem
|
} // namespace tint::constant
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 The Tint Authors.
|
// Copyright 2022 The Tint Authors.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0(the "License");
|
// Licensed under the Apache License, Version 2.0(the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@ -12,15 +12,15 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef SRC_TINT_SEM_CONSTANT_H_
|
#ifndef SRC_TINT_CONSTANT_CONSTANT_H_
|
||||||
#define SRC_TINT_SEM_CONSTANT_H_
|
#define SRC_TINT_CONSTANT_CONSTANT_H_
|
||||||
|
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
#include "src/tint/number.h"
|
#include "src/tint/number.h"
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
|
||||||
namespace tint::sem {
|
namespace tint::constant {
|
||||||
|
|
||||||
/// Constant is the interface to a compile-time evaluated expression value.
|
/// Constant is the interface to a compile-time evaluated expression value.
|
||||||
class Constant {
|
class Constant {
|
||||||
@ -73,6 +73,6 @@ class Constant {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint::sem
|
} // namespace tint::constant
|
||||||
|
|
||||||
#endif // SRC_TINT_SEM_CONSTANT_H_
|
#endif // SRC_TINT_CONSTANT_CONSTANT_H_
|
@ -19,8 +19,8 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
#include "src/tint/ast/function.h"
|
#include "src/tint/ast/function.h"
|
||||||
|
#include "src/tint/constant/constant.h"
|
||||||
#include "src/tint/program_id.h"
|
#include "src/tint/program_id.h"
|
||||||
#include "src/tint/sem/constant.h"
|
|
||||||
#include "src/tint/sem/info.h"
|
#include "src/tint/sem/info.h"
|
||||||
#include "src/tint/symbol_table.h"
|
#include "src/tint/symbol_table.h"
|
||||||
#include "src/tint/type/manager.h"
|
#include "src/tint/type/manager.h"
|
||||||
@ -44,8 +44,8 @@ class Program {
|
|||||||
/// SemNodeAllocator is an alias to BlockAllocator<sem::Node>
|
/// SemNodeAllocator is an alias to BlockAllocator<sem::Node>
|
||||||
using SemNodeAllocator = utils::BlockAllocator<sem::Node>;
|
using SemNodeAllocator = utils::BlockAllocator<sem::Node>;
|
||||||
|
|
||||||
/// ConstantAllocator is an alias to BlockAllocator<sem::Constant>
|
/// ConstantAllocator is an alias to BlockAllocator<constant::Constant>
|
||||||
using ConstantAllocator = utils::BlockAllocator<sem::Constant>;
|
using ConstantAllocator = utils::BlockAllocator<constant::Constant>;
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
Program();
|
Program();
|
||||||
|
@ -87,11 +87,11 @@
|
|||||||
#include "src/tint/ast/void.h"
|
#include "src/tint/ast/void.h"
|
||||||
#include "src/tint/ast/while_statement.h"
|
#include "src/tint/ast/while_statement.h"
|
||||||
#include "src/tint/ast/workgroup_attribute.h"
|
#include "src/tint/ast/workgroup_attribute.h"
|
||||||
|
#include "src/tint/constant/constant.h"
|
||||||
#include "src/tint/number.h"
|
#include "src/tint/number.h"
|
||||||
#include "src/tint/program.h"
|
#include "src/tint/program.h"
|
||||||
#include "src/tint/program_id.h"
|
#include "src/tint/program_id.h"
|
||||||
#include "src/tint/sem/array_count.h"
|
#include "src/tint/sem/array_count.h"
|
||||||
#include "src/tint/sem/constant.h"
|
|
||||||
#include "src/tint/sem/struct.h"
|
#include "src/tint/sem/struct.h"
|
||||||
#include "src/tint/type/array.h"
|
#include "src/tint/type/array.h"
|
||||||
#include "src/tint/type/bool.h"
|
#include "src/tint/type/bool.h"
|
||||||
@ -265,8 +265,8 @@ class ProgramBuilder {
|
|||||||
/// SemNodeAllocator is an alias to BlockAllocator<sem::Node>
|
/// SemNodeAllocator is an alias to BlockAllocator<sem::Node>
|
||||||
using SemNodeAllocator = utils::BlockAllocator<sem::Node>;
|
using SemNodeAllocator = utils::BlockAllocator<sem::Node>;
|
||||||
|
|
||||||
/// ConstantAllocator is an alias to BlockAllocator<sem::Constant>
|
/// ConstantAllocator is an alias to BlockAllocator<constant::Constant>
|
||||||
using ConstantAllocator = utils::BlockAllocator<sem::Constant>;
|
using ConstantAllocator = utils::BlockAllocator<constant::Constant>;
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
ProgramBuilder();
|
ProgramBuilder();
|
||||||
@ -465,12 +465,12 @@ class ProgramBuilder {
|
|||||||
return sem_nodes_.Create<T>(std::forward<ARGS>(args)...);
|
return sem_nodes_.Create<T>(std::forward<ARGS>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new sem::Constant owned by the ProgramBuilder.
|
/// Creates a new constant::Constant owned by the ProgramBuilder.
|
||||||
/// When the ProgramBuilder is destructed, the sem::Node will also be destructed.
|
/// When the ProgramBuilder is destructed, the sem::Node will also be destructed.
|
||||||
/// @param args the arguments to pass to the constructor
|
/// @param args the arguments to pass to the constructor
|
||||||
/// @returns the node pointer
|
/// @returns the node pointer
|
||||||
template <typename T, typename... ARGS>
|
template <typename T, typename... ARGS>
|
||||||
traits::EnableIf<traits::IsTypeOrDerived<T, sem::Constant>, T>* create(ARGS&&... args) {
|
traits::EnableIf<traits::IsTypeOrDerived<T, constant::Constant>, T>* create(ARGS&&... args) {
|
||||||
AssertNotMoved();
|
AssertNotMoved();
|
||||||
return constant_nodes_.Create<T>(std::forward<ARGS>(args)...);
|
return constant_nodes_.Create<T>(std::forward<ARGS>(args)...);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -30,8 +30,10 @@ class Source;
|
|||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
class LiteralExpression;
|
class LiteralExpression;
|
||||||
} // namespace tint::ast
|
} // namespace tint::ast
|
||||||
namespace tint::sem {
|
namespace tint::constant {
|
||||||
class Constant;
|
class Constant;
|
||||||
|
} // namespace tint::constant
|
||||||
|
namespace tint::sem {
|
||||||
class Expression;
|
class Expression;
|
||||||
} // namespace tint::sem
|
} // namespace tint::sem
|
||||||
namespace tint::type {
|
namespace tint::type {
|
||||||
@ -48,18 +50,20 @@ class ConstEval {
|
|||||||
public:
|
public:
|
||||||
/// The result type of a method that may raise a diagnostic error and the caller should abort
|
/// 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:
|
/// resolving. Can be one of three distinct values:
|
||||||
/// * A non-null sem::Constant pointer. Returned when a expression resolves to a creation time
|
/// * A non-null constant::Constant pointer. Returned when a expression resolves to a creation
|
||||||
|
/// time
|
||||||
/// value.
|
/// value.
|
||||||
/// * A null sem::Constant pointer. Returned when a expression cannot resolve to a creation time
|
/// * A null constant::Constant pointer. Returned when a expression cannot resolve to a creation
|
||||||
|
/// time
|
||||||
/// value, but is otherwise legal.
|
/// value, but is otherwise legal.
|
||||||
/// * `utils::Failure`. Returned when there was a resolver error. In this situation the method
|
/// * `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
|
/// will have already reported a diagnostic error message, and the caller should abort
|
||||||
/// resolving.
|
/// resolving.
|
||||||
using Result = utils::Result<const sem::Constant*>;
|
using Result = utils::Result<const constant::Constant*>;
|
||||||
|
|
||||||
/// Typedef for a constant evaluation function
|
/// Typedef for a constant evaluation function
|
||||||
using Function = Result (ConstEval::*)(const type::Type* result_ty,
|
using Function = Result (ConstEval::*)(const type::Type* result_ty,
|
||||||
utils::VectorRef<const sem::Constant*>,
|
utils::VectorRef<const constant::Constant*>,
|
||||||
const Source&);
|
const Source&);
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
@ -109,7 +113,7 @@ class ConstEval {
|
|||||||
/// @param value the value being converted
|
/// @param value the value being converted
|
||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the converted value, or null if the value cannot be calculated
|
/// @return the converted value, or null if the value cannot be calculated
|
||||||
Result Convert(const type::Type* ty, const sem::Constant* value, const Source& source);
|
Result Convert(const type::Type* ty, const constant::Constant* value, const Source& source);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constant value evaluation methods, to be indirectly called via the intrinsic table
|
// Constant value evaluation methods, to be indirectly called via the intrinsic table
|
||||||
@ -121,7 +125,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the converted value, or null if the value cannot be calculated
|
/// @return the converted value, or null if the value cannot be calculated
|
||||||
Result Conv(const type::Type* ty,
|
Result Conv(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Zero value type initializer
|
/// Zero value type initializer
|
||||||
@ -130,7 +134,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the constructed value, or null if the value cannot be calculated
|
/// @return the constructed value, or null if the value cannot be calculated
|
||||||
Result Zero(const type::Type* ty,
|
Result Zero(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Identity value type initializer
|
/// Identity value type initializer
|
||||||
@ -139,7 +143,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the constructed value, or null if the value cannot be calculated
|
/// @return the constructed value, or null if the value cannot be calculated
|
||||||
Result Identity(const type::Type* ty,
|
Result Identity(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Vector splat initializer
|
/// Vector splat initializer
|
||||||
@ -148,7 +152,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the constructed value, or null if the value cannot be calculated
|
/// @return the constructed value, or null if the value cannot be calculated
|
||||||
Result VecSplat(const type::Type* ty,
|
Result VecSplat(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Vector initializer using scalars
|
/// Vector initializer using scalars
|
||||||
@ -157,7 +161,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the constructed value, or null if the value cannot be calculated
|
/// @return the constructed value, or null if the value cannot be calculated
|
||||||
Result VecInitS(const type::Type* ty,
|
Result VecInitS(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Vector initializer using a mix of scalars and smaller vectors
|
/// Vector initializer using a mix of scalars and smaller vectors
|
||||||
@ -166,7 +170,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the constructed value, or null if the value cannot be calculated
|
/// @return the constructed value, or null if the value cannot be calculated
|
||||||
Result VecInitM(const type::Type* ty,
|
Result VecInitM(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Matrix initializer using scalar values
|
/// Matrix initializer using scalar values
|
||||||
@ -175,7 +179,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the constructed value, or null if the value cannot be calculated
|
/// @return the constructed value, or null if the value cannot be calculated
|
||||||
Result MatInitS(const type::Type* ty,
|
Result MatInitS(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Matrix initializer using column vectors
|
/// Matrix initializer using column vectors
|
||||||
@ -184,7 +188,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the constructed value, or null if the value cannot be calculated
|
/// @return the constructed value, or null if the value cannot be calculated
|
||||||
Result MatInitV(const type::Type* ty,
|
Result MatInitV(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -197,7 +201,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpComplement(const type::Type* ty,
|
Result OpComplement(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Unary minus operator '-'
|
/// Unary minus operator '-'
|
||||||
@ -206,7 +210,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpUnaryMinus(const type::Type* ty,
|
Result OpUnaryMinus(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Unary not operator '!'
|
/// Unary not operator '!'
|
||||||
@ -215,7 +219,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpNot(const type::Type* ty,
|
Result OpNot(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -228,7 +232,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpPlus(const type::Type* ty,
|
Result OpPlus(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Minus operator '-'
|
/// Minus operator '-'
|
||||||
@ -237,7 +241,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpMinus(const type::Type* ty,
|
Result OpMinus(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Multiply operator '*' for the same type on the LHS and RHS
|
/// Multiply operator '*' for the same type on the LHS and RHS
|
||||||
@ -246,7 +250,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpMultiply(const type::Type* ty,
|
Result OpMultiply(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Multiply operator '*' for matCxR<T> * vecC<T>
|
/// Multiply operator '*' for matCxR<T> * vecC<T>
|
||||||
@ -255,7 +259,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpMultiplyMatVec(const type::Type* ty,
|
Result OpMultiplyMatVec(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Multiply operator '*' for vecR<T> * matCxR<T>
|
/// Multiply operator '*' for vecR<T> * matCxR<T>
|
||||||
@ -264,7 +268,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpMultiplyVecMat(const type::Type* ty,
|
Result OpMultiplyVecMat(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Multiply operator '*' for matKxR<T> * matCxK<T>
|
/// Multiply operator '*' for matKxR<T> * matCxK<T>
|
||||||
@ -273,7 +277,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpMultiplyMatMat(const type::Type* ty,
|
Result OpMultiplyMatMat(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Divide operator '/'
|
/// Divide operator '/'
|
||||||
@ -282,7 +286,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpDivide(const type::Type* ty,
|
Result OpDivide(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Modulo operator '%'
|
/// Modulo operator '%'
|
||||||
@ -291,7 +295,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpModulo(const type::Type* ty,
|
Result OpModulo(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Equality operator '=='
|
/// Equality operator '=='
|
||||||
@ -300,7 +304,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpEqual(const type::Type* ty,
|
Result OpEqual(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Inequality operator '!='
|
/// Inequality operator '!='
|
||||||
@ -309,7 +313,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpNotEqual(const type::Type* ty,
|
Result OpNotEqual(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Less than operator '<'
|
/// Less than operator '<'
|
||||||
@ -318,7 +322,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpLessThan(const type::Type* ty,
|
Result OpLessThan(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Greater than operator '>'
|
/// Greater than operator '>'
|
||||||
@ -327,7 +331,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpGreaterThan(const type::Type* ty,
|
Result OpGreaterThan(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Less than or equal operator '<='
|
/// Less than or equal operator '<='
|
||||||
@ -336,7 +340,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpLessThanEqual(const type::Type* ty,
|
Result OpLessThanEqual(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Greater than or equal operator '>='
|
/// Greater than or equal operator '>='
|
||||||
@ -345,7 +349,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpGreaterThanEqual(const type::Type* ty,
|
Result OpGreaterThanEqual(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Logical and operator '&&'
|
/// Logical and operator '&&'
|
||||||
@ -354,7 +358,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpLogicalAnd(const type::Type* ty,
|
Result OpLogicalAnd(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Logical or operator '||'
|
/// Logical or operator '||'
|
||||||
@ -363,7 +367,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpLogicalOr(const type::Type* ty,
|
Result OpLogicalOr(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Bitwise and operator '&'
|
/// Bitwise and operator '&'
|
||||||
@ -372,7 +376,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpAnd(const type::Type* ty,
|
Result OpAnd(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Bitwise or operator '|'
|
/// Bitwise or operator '|'
|
||||||
@ -381,7 +385,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpOr(const type::Type* ty,
|
Result OpOr(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Bitwise xor operator '^'
|
/// Bitwise xor operator '^'
|
||||||
@ -390,7 +394,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpXor(const type::Type* ty,
|
Result OpXor(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Bitwise shift left operator '<<'
|
/// Bitwise shift left operator '<<'
|
||||||
@ -399,7 +403,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpShiftLeft(const type::Type* ty,
|
Result OpShiftLeft(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// Bitwise shift right operator '<<'
|
/// Bitwise shift right operator '<<'
|
||||||
@ -408,7 +412,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result OpShiftRight(const type::Type* ty,
|
Result OpShiftRight(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -421,7 +425,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result abs(const type::Type* ty,
|
Result abs(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// acos builtin
|
/// acos builtin
|
||||||
@ -430,7 +434,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result acos(const type::Type* ty,
|
Result acos(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// acosh builtin
|
/// acosh builtin
|
||||||
@ -439,7 +443,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result acosh(const type::Type* ty,
|
Result acosh(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// all builtin
|
/// all builtin
|
||||||
@ -448,7 +452,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result all(const type::Type* ty,
|
Result all(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// any builtin
|
/// any builtin
|
||||||
@ -457,7 +461,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result any(const type::Type* ty,
|
Result any(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// asin builtin
|
/// asin builtin
|
||||||
@ -466,7 +470,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result asin(const type::Type* ty,
|
Result asin(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// asinh builtin
|
/// asinh builtin
|
||||||
@ -475,7 +479,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result asinh(const type::Type* ty,
|
Result asinh(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// atan builtin
|
/// atan builtin
|
||||||
@ -484,7 +488,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result atan(const type::Type* ty,
|
Result atan(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// atanh builtin
|
/// atanh builtin
|
||||||
@ -493,7 +497,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result atanh(const type::Type* ty,
|
Result atanh(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// atan2 builtin
|
/// atan2 builtin
|
||||||
@ -502,7 +506,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result atan2(const type::Type* ty,
|
Result atan2(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// ceil builtin
|
/// ceil builtin
|
||||||
@ -511,7 +515,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result ceil(const type::Type* ty,
|
Result ceil(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// clamp builtin
|
/// clamp builtin
|
||||||
@ -520,7 +524,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result clamp(const type::Type* ty,
|
Result clamp(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// cos builtin
|
/// cos builtin
|
||||||
@ -529,7 +533,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result cos(const type::Type* ty,
|
Result cos(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// cosh builtin
|
/// cosh builtin
|
||||||
@ -538,7 +542,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result cosh(const type::Type* ty,
|
Result cosh(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// countLeadingZeros builtin
|
/// countLeadingZeros builtin
|
||||||
@ -547,7 +551,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result countLeadingZeros(const type::Type* ty,
|
Result countLeadingZeros(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// countOneBits builtin
|
/// countOneBits builtin
|
||||||
@ -556,7 +560,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result countOneBits(const type::Type* ty,
|
Result countOneBits(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// countTrailingZeros builtin
|
/// countTrailingZeros builtin
|
||||||
@ -565,7 +569,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result countTrailingZeros(const type::Type* ty,
|
Result countTrailingZeros(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// cross builtin
|
/// cross builtin
|
||||||
@ -574,7 +578,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result cross(const type::Type* ty,
|
Result cross(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// degrees builtin
|
/// degrees builtin
|
||||||
@ -583,7 +587,7 @@ class ConstEval {
|
|||||||
/// @param source the source location of the conversion
|
/// @param source the source location of the conversion
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result degrees(const type::Type* ty,
|
Result degrees(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// determinant builtin
|
/// determinant builtin
|
||||||
@ -592,7 +596,7 @@ class ConstEval {
|
|||||||
/// @param source the source location of the conversion
|
/// @param source the source location of the conversion
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result determinant(const type::Type* ty,
|
Result determinant(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// distance builtin
|
/// distance builtin
|
||||||
@ -601,7 +605,7 @@ class ConstEval {
|
|||||||
/// @param source the source location of the conversion
|
/// @param source the source location of the conversion
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result distance(const type::Type* ty,
|
Result distance(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// dot builtin
|
/// dot builtin
|
||||||
@ -610,7 +614,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result dot(const type::Type* ty,
|
Result dot(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// exp builtin
|
/// exp builtin
|
||||||
@ -619,7 +623,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result exp(const type::Type* ty,
|
Result exp(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// exp2 builtin
|
/// exp2 builtin
|
||||||
@ -628,7 +632,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result exp2(const type::Type* ty,
|
Result exp2(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// extractBits builtin
|
/// extractBits builtin
|
||||||
@ -637,7 +641,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result extractBits(const type::Type* ty,
|
Result extractBits(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// faceForward builtin
|
/// faceForward builtin
|
||||||
@ -646,7 +650,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result faceForward(const type::Type* ty,
|
Result faceForward(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// firstLeadingBit builtin
|
/// firstLeadingBit builtin
|
||||||
@ -655,7 +659,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result firstLeadingBit(const type::Type* ty,
|
Result firstLeadingBit(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// firstTrailingBit builtin
|
/// firstTrailingBit builtin
|
||||||
@ -664,7 +668,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result firstTrailingBit(const type::Type* ty,
|
Result firstTrailingBit(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// floor builtin
|
/// floor builtin
|
||||||
@ -673,7 +677,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result floor(const type::Type* ty,
|
Result floor(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// fma builtin
|
/// fma builtin
|
||||||
@ -682,7 +686,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result fma(const type::Type* ty,
|
Result fma(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// frexp builtin
|
/// frexp builtin
|
||||||
@ -691,7 +695,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result frexp(const type::Type* ty,
|
Result frexp(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// insertBits builtin
|
/// insertBits builtin
|
||||||
@ -700,7 +704,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result insertBits(const type::Type* ty,
|
Result insertBits(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// inverseSqrt builtin
|
/// inverseSqrt builtin
|
||||||
@ -709,7 +713,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result inverseSqrt(const type::Type* ty,
|
Result inverseSqrt(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// length builtin
|
/// length builtin
|
||||||
@ -718,7 +722,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result length(const type::Type* ty,
|
Result length(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// log builtin
|
/// log builtin
|
||||||
@ -727,7 +731,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result log(const type::Type* ty,
|
Result log(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// log2 builtin
|
/// log2 builtin
|
||||||
@ -736,7 +740,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result log2(const type::Type* ty,
|
Result log2(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// max builtin
|
/// max builtin
|
||||||
@ -745,7 +749,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result max(const type::Type* ty,
|
Result max(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// min builtin
|
/// min builtin
|
||||||
@ -754,7 +758,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @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
|
Result min(const type::Type* ty, // NOLINT(build/include_what_you_use) -- confused by min
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// mix builtin
|
/// mix builtin
|
||||||
@ -763,7 +767,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result mix(const type::Type* ty,
|
Result mix(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// modf builtin
|
/// modf builtin
|
||||||
@ -772,7 +776,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result modf(const type::Type* ty,
|
Result modf(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// normalize builtin
|
/// normalize builtin
|
||||||
@ -781,7 +785,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result normalize(const type::Type* ty,
|
Result normalize(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// pack2x16float builtin
|
/// pack2x16float builtin
|
||||||
@ -790,7 +794,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result pack2x16float(const type::Type* ty,
|
Result pack2x16float(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// pack2x16snorm builtin
|
/// pack2x16snorm builtin
|
||||||
@ -799,7 +803,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result pack2x16snorm(const type::Type* ty,
|
Result pack2x16snorm(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// pack2x16unorm builtin
|
/// pack2x16unorm builtin
|
||||||
@ -808,7 +812,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result pack2x16unorm(const type::Type* ty,
|
Result pack2x16unorm(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// pack4x8snorm builtin
|
/// pack4x8snorm builtin
|
||||||
@ -817,7 +821,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result pack4x8snorm(const type::Type* ty,
|
Result pack4x8snorm(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// pack4x8unorm builtin
|
/// pack4x8unorm builtin
|
||||||
@ -826,7 +830,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result pack4x8unorm(const type::Type* ty,
|
Result pack4x8unorm(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// radians builtin
|
/// radians builtin
|
||||||
@ -835,7 +839,7 @@ class ConstEval {
|
|||||||
/// @param source the source location of the conversion
|
/// @param source the source location of the conversion
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result radians(const type::Type* ty,
|
Result radians(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// reflect builtin
|
/// reflect builtin
|
||||||
@ -844,7 +848,7 @@ class ConstEval {
|
|||||||
/// @param source the source location of the conversion
|
/// @param source the source location of the conversion
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result reflect(const type::Type* ty,
|
Result reflect(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// refract builtin
|
/// refract builtin
|
||||||
@ -853,7 +857,7 @@ class ConstEval {
|
|||||||
/// @param source the source location of the conversion
|
/// @param source the source location of the conversion
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result refract(const type::Type* ty,
|
Result refract(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// reverseBits builtin
|
/// reverseBits builtin
|
||||||
@ -862,7 +866,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result reverseBits(const type::Type* ty,
|
Result reverseBits(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// round builtin
|
/// round builtin
|
||||||
@ -871,7 +875,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result round(const type::Type* ty,
|
Result round(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// saturate builtin
|
/// saturate builtin
|
||||||
@ -880,7 +884,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result saturate(const type::Type* ty,
|
Result saturate(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// select builtin with single bool third arg
|
/// select builtin with single bool third arg
|
||||||
@ -889,7 +893,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result select_bool(const type::Type* ty,
|
Result select_bool(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// select builtin with vector of bool third arg
|
/// select builtin with vector of bool third arg
|
||||||
@ -898,7 +902,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result select_boolvec(const type::Type* ty,
|
Result select_boolvec(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// sign builtin
|
/// sign builtin
|
||||||
@ -907,7 +911,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result sign(const type::Type* ty,
|
Result sign(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// sin builtin
|
/// sin builtin
|
||||||
@ -916,7 +920,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result sin(const type::Type* ty,
|
Result sin(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// sinh builtin
|
/// sinh builtin
|
||||||
@ -925,7 +929,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result sinh(const type::Type* ty,
|
Result sinh(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// smoothstep builtin
|
/// smoothstep builtin
|
||||||
@ -934,7 +938,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result smoothstep(const type::Type* ty,
|
Result smoothstep(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// step builtin
|
/// step builtin
|
||||||
@ -943,7 +947,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result step(const type::Type* ty,
|
Result step(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// sqrt builtin
|
/// sqrt builtin
|
||||||
@ -952,7 +956,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result sqrt(const type::Type* ty,
|
Result sqrt(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// tan builtin
|
/// tan builtin
|
||||||
@ -961,7 +965,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result tan(const type::Type* ty,
|
Result tan(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// tanh builtin
|
/// tanh builtin
|
||||||
@ -970,7 +974,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result tanh(const type::Type* ty,
|
Result tanh(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// transpose builtin
|
/// transpose builtin
|
||||||
@ -979,7 +983,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result transpose(const type::Type* ty,
|
Result transpose(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// trunc builtin
|
/// trunc builtin
|
||||||
@ -988,7 +992,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result trunc(const type::Type* ty,
|
Result trunc(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// unpack2x16float builtin
|
/// unpack2x16float builtin
|
||||||
@ -997,7 +1001,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result unpack2x16float(const type::Type* ty,
|
Result unpack2x16float(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// unpack2x16snorm builtin
|
/// unpack2x16snorm builtin
|
||||||
@ -1006,7 +1010,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result unpack2x16snorm(const type::Type* ty,
|
Result unpack2x16snorm(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// unpack2x16unorm builtin
|
/// unpack2x16unorm builtin
|
||||||
@ -1015,7 +1019,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result unpack2x16unorm(const type::Type* ty,
|
Result unpack2x16unorm(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// unpack4x8snorm builtin
|
/// unpack4x8snorm builtin
|
||||||
@ -1024,7 +1028,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result unpack4x8snorm(const type::Type* ty,
|
Result unpack4x8snorm(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// unpack4x8unorm builtin
|
/// unpack4x8unorm builtin
|
||||||
@ -1033,7 +1037,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result unpack4x8unorm(const type::Type* ty,
|
Result unpack4x8unorm(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
/// quantizeToF16 builtin
|
/// quantizeToF16 builtin
|
||||||
@ -1042,7 +1046,7 @@ class ConstEval {
|
|||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @return the result value, or null if the value cannot be calculated
|
/// @return the result value, or null if the value cannot be calculated
|
||||||
Result quantizeToF16(const type::Type* ty,
|
Result quantizeToF16(const type::Type* ty,
|
||||||
utils::VectorRef<const sem::Constant*> args,
|
utils::VectorRef<const constant::Constant*> args,
|
||||||
const Source& source);
|
const Source& source);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -1339,14 +1343,14 @@ class ConstEval {
|
|||||||
/// @param v1 the first vector
|
/// @param v1 the first vector
|
||||||
/// @param v2 the second vector
|
/// @param v2 the second vector
|
||||||
/// @returns the dot product
|
/// @returns the dot product
|
||||||
Result Dot(const Source& source, const sem::Constant* v1, const sem::Constant* v2);
|
Result Dot(const Source& source, const constant::Constant* v1, const constant::Constant* v2);
|
||||||
|
|
||||||
/// Returns the length of c0
|
/// Returns the length of c0
|
||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
/// @param ty the return type
|
/// @param ty the return type
|
||||||
/// @param c0 the constant to calculate the length of
|
/// @param c0 the constant to calculate the length of
|
||||||
/// @returns the length of c0
|
/// @returns the length of c0
|
||||||
Result Length(const Source& source, const type::Type* ty, const sem::Constant* c0);
|
Result Length(const Source& source, const type::Type* ty, const constant::Constant* c0);
|
||||||
|
|
||||||
/// Returns the product of v1 and v2
|
/// Returns the product of v1 and v2
|
||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
@ -1356,8 +1360,8 @@ class ConstEval {
|
|||||||
/// @returns the product of v1 and v2
|
/// @returns the product of v1 and v2
|
||||||
Result Mul(const Source& source,
|
Result Mul(const Source& source,
|
||||||
const type::Type* ty,
|
const type::Type* ty,
|
||||||
const sem::Constant* v1,
|
const constant::Constant* v1,
|
||||||
const sem::Constant* v2);
|
const constant::Constant* v2);
|
||||||
|
|
||||||
/// Returns the difference between v2 and v1
|
/// Returns the difference between v2 and v1
|
||||||
/// @param source the source location
|
/// @param source the source location
|
||||||
@ -1367,8 +1371,8 @@ class ConstEval {
|
|||||||
/// @returns the difference between v2 and v1
|
/// @returns the difference between v2 and v1
|
||||||
Result Sub(const Source& source,
|
Result Sub(const Source& source,
|
||||||
const type::Type* ty,
|
const type::Type* ty,
|
||||||
const sem::Constant* v1,
|
const constant::Constant* v1,
|
||||||
const sem::Constant* v2);
|
const constant::Constant* v2);
|
||||||
|
|
||||||
ProgramBuilder& builder;
|
ProgramBuilder& builder;
|
||||||
};
|
};
|
||||||
|
@ -99,7 +99,7 @@ TEST_P(ResolverConstEvalBinaryOpTest, Test) {
|
|||||||
auto& expected = expected_case.value;
|
auto& expected = expected_case.value;
|
||||||
|
|
||||||
auto* sem = Sem().Get(expr);
|
auto* sem = Sem().Get(expr);
|
||||||
const sem::Constant* value = sem->ConstantValue();
|
const constant::Constant* value = sem->ConstantValue();
|
||||||
ASSERT_NE(value, nullptr);
|
ASSERT_NE(value, nullptr);
|
||||||
EXPECT_TYPE(value->Type(), sem->Type());
|
EXPECT_TYPE(value->Type(), sem->Type());
|
||||||
|
|
||||||
@ -892,19 +892,20 @@ TEST_F(ResolverConstEvalTest, NotAndOrOfVecs) {
|
|||||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
auto* sem = Sem().Get(expr);
|
auto* sem = Sem().Get(expr);
|
||||||
const sem::Constant* value = sem->ConstantValue();
|
const constant::Constant* value = sem->ConstantValue();
|
||||||
ASSERT_NE(value, nullptr);
|
ASSERT_NE(value, nullptr);
|
||||||
EXPECT_TYPE(value->Type(), sem->Type());
|
EXPECT_TYPE(value->Type(), sem->Type());
|
||||||
|
|
||||||
auto* expected_sem = Sem().Get(expected_expr);
|
auto* expected_sem = Sem().Get(expected_expr);
|
||||||
const sem::Constant* expected_value = expected_sem->ConstantValue();
|
const constant::Constant* expected_value = expected_sem->ConstantValue();
|
||||||
ASSERT_NE(expected_value, nullptr);
|
ASSERT_NE(expected_value, nullptr);
|
||||||
EXPECT_TYPE(expected_value->Type(), expected_sem->Type());
|
EXPECT_TYPE(expected_value->Type(), expected_sem->Type());
|
||||||
|
|
||||||
ForEachElemPair(value, expected_value, [&](const sem::Constant* a, const sem::Constant* b) {
|
ForEachElemPair(value, expected_value,
|
||||||
EXPECT_EQ(a->As<bool>(), b->As<bool>());
|
[&](const constant::Constant* a, const constant::Constant* b) {
|
||||||
return HasFailure() ? Action::kStop : Action::kContinue;
|
EXPECT_EQ(a->As<bool>(), b->As<bool>());
|
||||||
});
|
return HasFailure() ? Action::kStop : Action::kContinue;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -162,7 +162,7 @@ TEST_P(ResolverConstEvalBuiltinTest, Test) {
|
|||||||
|
|
||||||
auto* sem = Sem().Get(expr);
|
auto* sem = Sem().Get(expr);
|
||||||
ASSERT_NE(sem, nullptr);
|
ASSERT_NE(sem, nullptr);
|
||||||
const sem::Constant* value = sem->ConstantValue();
|
const constant::Constant* value = sem->ConstantValue();
|
||||||
ASSERT_NE(value, nullptr);
|
ASSERT_NE(value, nullptr);
|
||||||
EXPECT_TYPE(value->Type(), sem->Type());
|
EXPECT_TYPE(value->Type(), sem->Type());
|
||||||
|
|
||||||
|
@ -36,9 +36,10 @@ inline const auto kPiOver4 = T(UnwrapNumber<T>(0.785398163397448309616));
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
inline const auto k3PiOver4 = T(UnwrapNumber<T>(2.356194490192344928846));
|
inline const auto k3PiOver4 = T(UnwrapNumber<T>(2.356194490192344928846));
|
||||||
|
|
||||||
/// Walks the sem::Constant @p c, accumulating all the inner-most scalar values into @p args
|
/// Walks the constant::Constant @p c, accumulating all the inner-most scalar values into @p args
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
inline void CollectScalars(const sem::Constant* c, utils::Vector<builder::Scalar, N>& scalars) {
|
inline void CollectScalars(const constant::Constant* c,
|
||||||
|
utils::Vector<builder::Scalar, N>& scalars) {
|
||||||
Switch(
|
Switch(
|
||||||
c->Type(), //
|
c->Type(), //
|
||||||
[&](const type::AbstractInt*) { scalars.Push(c->As<AInt>()); },
|
[&](const type::AbstractInt*) { scalars.Push(c->As<AInt>()); },
|
||||||
@ -56,8 +57,8 @@ inline void CollectScalars(const sem::Constant* c, utils::Vector<builder::Scalar
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Walks the sem::Constant @p c, returning all the inner-most scalar values.
|
/// Walks the constant::Constant @p c, returning all the inner-most scalar values.
|
||||||
inline utils::Vector<builder::Scalar, 16> ScalarsFrom(const sem::Constant* c) {
|
inline utils::Vector<builder::Scalar, 16> ScalarsFrom(const constant::Constant* c) {
|
||||||
utils::Vector<builder::Scalar, 16> out;
|
utils::Vector<builder::Scalar, 16> out;
|
||||||
CollectScalars(c, out);
|
CollectScalars(c, out);
|
||||||
return out;
|
return out;
|
||||||
@ -88,7 +89,7 @@ struct CheckConstantFlags {
|
|||||||
/// @param got_constant the constant value evaluated by the resolver
|
/// @param got_constant the constant value evaluated by the resolver
|
||||||
/// @param expected_value the expected value for the test
|
/// @param expected_value the expected value for the test
|
||||||
/// @param flags optional flags for controlling the comparisons
|
/// @param flags optional flags for controlling the comparisons
|
||||||
inline void CheckConstant(const sem::Constant* got_constant,
|
inline void CheckConstant(const constant::Constant* got_constant,
|
||||||
const builder::Value& expected_value,
|
const builder::Value& expected_value,
|
||||||
CheckConstantFlags flags = {}) {
|
CheckConstantFlags flags = {}) {
|
||||||
auto values_flat = ScalarsFrom(got_constant);
|
auto values_flat = ScalarsFrom(got_constant);
|
||||||
@ -257,7 +258,7 @@ using builder::Vec;
|
|||||||
// TODO(amaiorano): Move to Constant.h?
|
// TODO(amaiorano): Move to Constant.h?
|
||||||
enum class Action { kStop, kContinue };
|
enum class Action { kStop, kContinue };
|
||||||
template <typename Func>
|
template <typename Func>
|
||||||
inline Action ForEachElemPair(const sem::Constant* a, const sem::Constant* b, Func&& f) {
|
inline Action ForEachElemPair(const constant::Constant* a, const constant::Constant* b, Func&& f) {
|
||||||
EXPECT_EQ(a->Type(), b->Type());
|
EXPECT_EQ(a->Type(), b->Type());
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -57,7 +57,7 @@ TEST_P(ResolverConstEvalUnaryOpTest, Test) {
|
|||||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
auto* sem = Sem().Get(expr);
|
auto* sem = Sem().Get(expr);
|
||||||
const sem::Constant* value = sem->ConstantValue();
|
const constant::Constant* value = sem->ConstantValue();
|
||||||
ASSERT_NE(value, nullptr);
|
ASSERT_NE(value, nullptr);
|
||||||
EXPECT_TYPE(value->Type(), sem->Type());
|
EXPECT_TYPE(value->Type(), sem->Type());
|
||||||
|
|
||||||
|
@ -1285,7 +1285,7 @@ sem::CaseStatement* Resolver::CaseStatement(const ast::CaseStatement* stmt, cons
|
|||||||
ExprEvalStageConstraint constraint{sem::EvaluationStage::kConstant, "case selector"};
|
ExprEvalStageConstraint constraint{sem::EvaluationStage::kConstant, "case selector"};
|
||||||
TINT_SCOPED_ASSIGNMENT(expr_eval_stage_constraint_, constraint);
|
TINT_SCOPED_ASSIGNMENT(expr_eval_stage_constraint_, constraint);
|
||||||
|
|
||||||
const sem::Constant* const_value = nullptr;
|
const constant::Constant* const_value = nullptr;
|
||||||
if (!sel->IsDefault()) {
|
if (!sel->IsDefault()) {
|
||||||
// The sem statement was created in the switch when attempting to determine the
|
// The sem statement was created in the switch when attempting to determine the
|
||||||
// common type.
|
// common type.
|
||||||
@ -1804,7 +1804,7 @@ const sem::Expression* Resolver::Materialize(const sem::Expression* expr,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sem::Constant* materialized_val = nullptr;
|
const constant::Constant* materialized_val = nullptr;
|
||||||
if (!skip_const_eval_.Contains(decl)) {
|
if (!skip_const_eval_.Contains(decl)) {
|
||||||
auto expr_val = expr->ConstantValue();
|
auto expr_val = expr->ConstantValue();
|
||||||
if (!expr_val) {
|
if (!expr_val) {
|
||||||
@ -1856,7 +1856,9 @@ bool Resolver::ShouldMaterializeArgument(const type::Type* parameter_ty) const {
|
|||||||
return param_el_ty && !param_el_ty->Is<type::AbstractNumeric>();
|
return param_el_ty && !param_el_ty->Is<type::AbstractNumeric>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Resolver::Convert(const sem::Constant*& c, const type::Type* target_ty, const Source& source) {
|
bool Resolver::Convert(const constant::Constant*& c,
|
||||||
|
const type::Type* target_ty,
|
||||||
|
const Source& source) {
|
||||||
auto r = const_eval_.Convert(target_ty, c, source);
|
auto r = const_eval_.Convert(target_ty, c, source);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
return false;
|
return false;
|
||||||
@ -1866,7 +1868,7 @@ bool Resolver::Convert(const sem::Constant*& c, const type::Type* target_ty, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
utils::Result<utils::Vector<const sem::Constant*, N>> Resolver::ConvertArguments(
|
utils::Result<utils::Vector<const constant::Constant*, N>> Resolver::ConvertArguments(
|
||||||
const utils::Vector<const sem::Expression*, N>& args,
|
const utils::Vector<const sem::Expression*, N>& args,
|
||||||
const sem::CallTarget* target) {
|
const sem::CallTarget* target) {
|
||||||
auto const_args = utils::Transform(args, [](auto* arg) { return arg->ConstantValue(); });
|
auto const_args = utils::Transform(args, [](auto* arg) { return arg->ConstantValue(); });
|
||||||
@ -1924,7 +1926,7 @@ sem::Expression* Resolver::IndexAccessor(const ast::IndexAccessorExpression* exp
|
|||||||
ty = builder_->create<type::Reference>(ty, ref->AddressSpace(), ref->Access());
|
ty = builder_->create<type::Reference>(ty, ref->AddressSpace(), ref->Access());
|
||||||
}
|
}
|
||||||
|
|
||||||
const sem::Constant* val = nullptr;
|
const constant::Constant* val = nullptr;
|
||||||
auto stage = sem::EarliestStage(obj->Stage(), idx->Stage());
|
auto stage = sem::EarliestStage(obj->Stage(), idx->Stage());
|
||||||
if (stage == sem::EvaluationStage::kConstant && skip_const_eval_.Contains(expr)) {
|
if (stage == sem::EvaluationStage::kConstant && skip_const_eval_.Contains(expr)) {
|
||||||
stage = sem::EvaluationStage::kNotEvaluated;
|
stage = sem::EvaluationStage::kNotEvaluated;
|
||||||
@ -1955,7 +1957,7 @@ sem::Expression* Resolver::Bitcast(const ast::BitcastExpression* expr) {
|
|||||||
|
|
||||||
RegisterLoadIfNeeded(inner);
|
RegisterLoadIfNeeded(inner);
|
||||||
|
|
||||||
const sem::Constant* val = nullptr;
|
const constant::Constant* val = nullptr;
|
||||||
// TODO(crbug.com/tint/1582): short circuit 'expr' once const eval of Bitcast is implemented.
|
// TODO(crbug.com/tint/1582): short circuit 'expr' once const eval of Bitcast is implemented.
|
||||||
if (auto r = const_eval_.Bitcast(ty, inner)) {
|
if (auto r = const_eval_.Bitcast(ty, inner)) {
|
||||||
val = r.Get();
|
val = r.Get();
|
||||||
@ -2017,7 +2019,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sem::Constant* value = nullptr;
|
const constant::Constant* value = nullptr;
|
||||||
auto stage = sem::EarliestStage(ctor_or_conv.target->Stage(), args_stage);
|
auto stage = sem::EarliestStage(ctor_or_conv.target->Stage(), args_stage);
|
||||||
if (stage == sem::EvaluationStage::kConstant && skip_const_eval_.Contains(expr)) {
|
if (stage == sem::EvaluationStage::kConstant && skip_const_eval_.Contains(expr)) {
|
||||||
stage = sem::EvaluationStage::kNotEvaluated;
|
stage = sem::EvaluationStage::kNotEvaluated;
|
||||||
@ -2047,7 +2049,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto stage = args_stage; // The evaluation stage of the call
|
auto stage = args_stage; // The evaluation stage of the call
|
||||||
const sem::Constant* value = nullptr; // The constant value for the call
|
const constant::Constant* value = nullptr; // The constant value for the call
|
||||||
if (stage == sem::EvaluationStage::kConstant) {
|
if (stage == sem::EvaluationStage::kConstant) {
|
||||||
if (auto r = const_eval_.ArrayOrStructInit(ty, args)) {
|
if (auto r = const_eval_.ArrayOrStructInit(ty, args)) {
|
||||||
value = r.Get();
|
value = r.Get();
|
||||||
@ -2341,7 +2343,7 @@ sem::Call* Resolver::BuiltinCall(const ast::CallExpression* expr,
|
|||||||
|
|
||||||
// If the builtin is @const, and all arguments have constant values, evaluate the builtin
|
// If the builtin is @const, and all arguments have constant values, evaluate the builtin
|
||||||
// now.
|
// now.
|
||||||
const sem::Constant* value = nullptr;
|
const constant::Constant* value = nullptr;
|
||||||
auto stage = sem::EarliestStage(arg_stage, builtin.sem->Stage());
|
auto stage = sem::EarliestStage(arg_stage, builtin.sem->Stage());
|
||||||
if (stage == sem::EvaluationStage::kConstant && skip_const_eval_.Contains(expr)) {
|
if (stage == sem::EvaluationStage::kConstant && skip_const_eval_.Contains(expr)) {
|
||||||
stage = sem::EvaluationStage::kNotEvaluated;
|
stage = sem::EvaluationStage::kNotEvaluated;
|
||||||
@ -2559,7 +2561,7 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sem::Constant* val = nullptr;
|
const constant::Constant* val = nullptr;
|
||||||
if (auto r = const_eval_.Literal(ty, literal)) {
|
if (auto r = const_eval_.Literal(ty, literal)) {
|
||||||
val = r.Get();
|
val = r.Get();
|
||||||
} else {
|
} else {
|
||||||
@ -2827,7 +2829,7 @@ sem::Expression* Resolver::Binary(const ast::BinaryExpression* expr) {
|
|||||||
RegisterLoadIfNeeded(lhs);
|
RegisterLoadIfNeeded(lhs);
|
||||||
RegisterLoadIfNeeded(rhs);
|
RegisterLoadIfNeeded(rhs);
|
||||||
|
|
||||||
const sem::Constant* value = nullptr;
|
const constant::Constant* value = nullptr;
|
||||||
if (stage == sem::EvaluationStage::kConstant) {
|
if (stage == sem::EvaluationStage::kConstant) {
|
||||||
if (op.const_eval_fn) {
|
if (op.const_eval_fn) {
|
||||||
if (skip_const_eval_.Contains(expr)) {
|
if (skip_const_eval_.Contains(expr)) {
|
||||||
@ -2872,7 +2874,7 @@ sem::Expression* Resolver::UnaryOp(const ast::UnaryOpExpression* unary) {
|
|||||||
|
|
||||||
const type::Type* ty = nullptr;
|
const type::Type* ty = nullptr;
|
||||||
const sem::Variable* root_ident = nullptr;
|
const sem::Variable* root_ident = nullptr;
|
||||||
const sem::Constant* value = nullptr;
|
const constant::Constant* value = nullptr;
|
||||||
auto stage = sem::EvaluationStage::kRuntime;
|
auto stage = sem::EvaluationStage::kRuntime;
|
||||||
|
|
||||||
switch (unary->op) {
|
switch (unary->op) {
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "src/tint/constant/constant.h"
|
||||||
#include "src/tint/program_builder.h"
|
#include "src/tint/program_builder.h"
|
||||||
#include "src/tint/resolver/const_eval.h"
|
#include "src/tint/resolver/const_eval.h"
|
||||||
#include "src/tint/resolver/dependency_graph.h"
|
#include "src/tint/resolver/dependency_graph.h"
|
||||||
@ -32,7 +33,6 @@
|
|||||||
#include "src/tint/scope_stack.h"
|
#include "src/tint/scope_stack.h"
|
||||||
#include "src/tint/sem/binding_point.h"
|
#include "src/tint/sem/binding_point.h"
|
||||||
#include "src/tint/sem/block_statement.h"
|
#include "src/tint/sem/block_statement.h"
|
||||||
#include "src/tint/sem/constant.h"
|
|
||||||
#include "src/tint/sem/function.h"
|
#include "src/tint/sem/function.h"
|
||||||
#include "src/tint/sem/struct.h"
|
#include "src/tint/sem/struct.h"
|
||||||
#include "src/tint/utils/bitset.h"
|
#include "src/tint/utils/bitset.h"
|
||||||
@ -197,13 +197,13 @@ class Resolver {
|
|||||||
|
|
||||||
/// Converts `c` to `target_ty`
|
/// Converts `c` to `target_ty`
|
||||||
/// @returns true on success, false on failure.
|
/// @returns true on success, false on failure.
|
||||||
bool Convert(const sem::Constant*& c, const type::Type* target_ty, const Source& source);
|
bool Convert(const constant::Constant*& c, const type::Type* target_ty, const Source& source);
|
||||||
|
|
||||||
/// Transforms `args` to a vector of constants, and converts each constant to the call target's
|
/// Transforms `args` to a vector of constants, and converts each constant to the call target's
|
||||||
/// parameter type.
|
/// parameter type.
|
||||||
/// @returns the vector of constants, `utils::Failure` on failure.
|
/// @returns the vector of constants, `utils::Failure` on failure.
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
utils::Result<utils::Vector<const sem::Constant*, N>> ConvertArguments(
|
utils::Result<utils::Vector<const constant::Constant*, N>> ConvertArguments(
|
||||||
const utils::Vector<const sem::Expression*, N>& args,
|
const utils::Vector<const sem::Expression*, N>& args,
|
||||||
const sem::CallTarget* target);
|
const sem::CallTarget* target);
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ Call::Call(const ast::CallExpression* declaration,
|
|||||||
EvaluationStage stage,
|
EvaluationStage stage,
|
||||||
utils::VectorRef<const sem::Expression*> arguments,
|
utils::VectorRef<const sem::Expression*> arguments,
|
||||||
const Statement* statement,
|
const Statement* statement,
|
||||||
const Constant* constant,
|
const constant::Constant* constant,
|
||||||
bool has_side_effects)
|
bool has_side_effects)
|
||||||
: Base(declaration, target->ReturnType(), stage, statement, constant, has_side_effects),
|
: Base(declaration, target->ReturnType(), stage, statement, constant, has_side_effects),
|
||||||
target_(target),
|
target_(target),
|
||||||
|
@ -41,7 +41,7 @@ class Call final : public Castable<Call, Expression> {
|
|||||||
EvaluationStage stage,
|
EvaluationStage stage,
|
||||||
utils::VectorRef<const sem::Expression*> arguments,
|
utils::VectorRef<const sem::Expression*> arguments,
|
||||||
const Statement* statement,
|
const Statement* statement,
|
||||||
const Constant* constant,
|
const constant::Constant* constant,
|
||||||
bool has_side_effects);
|
bool has_side_effects);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
|
@ -26,7 +26,7 @@ Expression::Expression(const ast::Expression* declaration,
|
|||||||
const type::Type* type,
|
const type::Type* type,
|
||||||
EvaluationStage stage,
|
EvaluationStage stage,
|
||||||
const Statement* statement,
|
const Statement* statement,
|
||||||
const Constant* constant,
|
const constant::Constant* constant,
|
||||||
bool has_side_effects,
|
bool has_side_effects,
|
||||||
const Variable* root_ident /* = nullptr */)
|
const Variable* root_ident /* = nullptr */)
|
||||||
: declaration_(declaration),
|
: declaration_(declaration),
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
#define SRC_TINT_SEM_EXPRESSION_H_
|
#define SRC_TINT_SEM_EXPRESSION_H_
|
||||||
|
|
||||||
#include "src/tint/ast/expression.h"
|
#include "src/tint/ast/expression.h"
|
||||||
|
#include "src/tint/constant/constant.h"
|
||||||
#include "src/tint/sem/behavior.h"
|
#include "src/tint/sem/behavior.h"
|
||||||
#include "src/tint/sem/constant.h"
|
|
||||||
#include "src/tint/sem/evaluation_stage.h"
|
#include "src/tint/sem/evaluation_stage.h"
|
||||||
#include "src/tint/sem/node.h"
|
#include "src/tint/sem/node.h"
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ class Expression : public Castable<Expression, Node> {
|
|||||||
const type::Type* type,
|
const type::Type* type,
|
||||||
EvaluationStage stage,
|
EvaluationStage stage,
|
||||||
const Statement* statement,
|
const Statement* statement,
|
||||||
const Constant* constant,
|
const constant::Constant* constant,
|
||||||
bool has_side_effects,
|
bool has_side_effects,
|
||||||
const Variable* root_ident = nullptr);
|
const Variable* root_ident = nullptr);
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ class Expression : public Castable<Expression, Node> {
|
|||||||
const Statement* Stmt() const { return statement_; }
|
const Statement* Stmt() const { return statement_; }
|
||||||
|
|
||||||
/// @return the constant value of this expression
|
/// @return the constant value of this expression
|
||||||
const Constant* ConstantValue() const { return constant_; }
|
const constant::Constant* ConstantValue() const { return constant_; }
|
||||||
|
|
||||||
/// Returns the variable or parameter that this expression derives from.
|
/// Returns the variable or parameter that this expression derives from.
|
||||||
/// For reference and pointer expressions, this will either be the originating
|
/// 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 type::Type* const type_;
|
||||||
const EvaluationStage stage_;
|
const EvaluationStage stage_;
|
||||||
const Statement* const statement_;
|
const Statement* const statement_;
|
||||||
const Constant* const constant_;
|
const constant::Constant* const constant_;
|
||||||
sem::Behaviors behaviors_{sem::Behavior::kNext};
|
sem::Behaviors behaviors_{sem::Behavior::kNext};
|
||||||
const bool has_side_effects_;
|
const bool has_side_effects_;
|
||||||
};
|
};
|
||||||
|
@ -23,13 +23,13 @@ using namespace tint::number_suffixes; // NOLINT
|
|||||||
namespace tint::sem {
|
namespace tint::sem {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class MockConstant : public sem::Constant {
|
class MockConstant : public constant::Constant {
|
||||||
public:
|
public:
|
||||||
explicit MockConstant(const type::Type* ty) : type(ty) {}
|
explicit MockConstant(const type::Type* ty) : type(ty) {}
|
||||||
~MockConstant() override {}
|
~MockConstant() override {}
|
||||||
const type::Type* Type() const override { return type; }
|
const type::Type* Type() const override { return type; }
|
||||||
std::variant<std::monostate, AInt, AFloat> Value() const override { return {}; }
|
std::variant<std::monostate, AInt, AFloat> Value() const override { return {}; }
|
||||||
const Constant* Index(size_t) const override { return {}; }
|
const constant::Constant* Index(size_t) const override { return {}; }
|
||||||
bool AllZero() const override { return {}; }
|
bool AllZero() const override { return {}; }
|
||||||
bool AnyZero() const override { return {}; }
|
bool AnyZero() const override { return {}; }
|
||||||
bool AllEqual() const override { return {}; }
|
bool AllEqual() const override { return {}; }
|
||||||
|
@ -28,7 +28,7 @@ IndexAccessorExpression::IndexAccessorExpression(const ast::IndexAccessorExpress
|
|||||||
const Expression* object,
|
const Expression* object,
|
||||||
const Expression* index,
|
const Expression* index,
|
||||||
const Statement* statement,
|
const Statement* statement,
|
||||||
const Constant* constant,
|
const constant::Constant* constant,
|
||||||
bool has_side_effects,
|
bool has_side_effects,
|
||||||
const Variable* root_ident /* = nullptr */)
|
const Variable* root_ident /* = nullptr */)
|
||||||
: Base(declaration, type, stage, statement, constant, has_side_effects, root_ident),
|
: 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* object,
|
||||||
const Expression* index,
|
const Expression* index,
|
||||||
const Statement* statement,
|
const Statement* statement,
|
||||||
const Constant* constant,
|
const constant::Constant* constant,
|
||||||
bool has_side_effects,
|
bool has_side_effects,
|
||||||
const Variable* root_ident = nullptr);
|
const Variable* root_ident = nullptr);
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace tint::sem {
|
|||||||
Materialize::Materialize(const Expression* expr,
|
Materialize::Materialize(const Expression* expr,
|
||||||
const Statement* statement,
|
const Statement* statement,
|
||||||
const type::Type* type,
|
const type::Type* type,
|
||||||
const Constant* constant)
|
const constant::Constant* constant)
|
||||||
: Base(/* declaration */ expr->Declaration(),
|
: Base(/* declaration */ expr->Declaration(),
|
||||||
/* type */ type,
|
/* type */ type,
|
||||||
/* stage */ constant ? EvaluationStage::kConstant : EvaluationStage::kNotEvaluated,
|
/* stage */ constant ? EvaluationStage::kConstant : EvaluationStage::kNotEvaluated,
|
||||||
|
@ -35,7 +35,7 @@ class Materialize final : public Castable<Materialize, Expression> {
|
|||||||
Materialize(const Expression* expr,
|
Materialize(const Expression* expr,
|
||||||
const Statement* statement,
|
const Statement* statement,
|
||||||
const type::Type* type,
|
const type::Type* type,
|
||||||
const Constant* constant);
|
const constant::Constant* constant);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~Materialize() override;
|
~Materialize() override;
|
||||||
|
@ -27,7 +27,7 @@ MemberAccessorExpression::MemberAccessorExpression(const ast::MemberAccessorExpr
|
|||||||
const type::Type* type,
|
const type::Type* type,
|
||||||
EvaluationStage stage,
|
EvaluationStage stage,
|
||||||
const Statement* statement,
|
const Statement* statement,
|
||||||
const Constant* constant,
|
const constant::Constant* constant,
|
||||||
const Expression* object,
|
const Expression* object,
|
||||||
bool has_side_effects,
|
bool has_side_effects,
|
||||||
const Variable* root_ident /* = nullptr */)
|
const Variable* root_ident /* = nullptr */)
|
||||||
@ -39,7 +39,7 @@ MemberAccessorExpression::~MemberAccessorExpression() = default;
|
|||||||
StructMemberAccess::StructMemberAccess(const ast::MemberAccessorExpression* declaration,
|
StructMemberAccess::StructMemberAccess(const ast::MemberAccessorExpression* declaration,
|
||||||
const type::Type* type,
|
const type::Type* type,
|
||||||
const Statement* statement,
|
const Statement* statement,
|
||||||
const Constant* constant,
|
const constant::Constant* constant,
|
||||||
const Expression* object,
|
const Expression* object,
|
||||||
const StructMember* member,
|
const StructMember* member,
|
||||||
bool has_side_effects,
|
bool has_side_effects,
|
||||||
@ -59,7 +59,7 @@ StructMemberAccess::~StructMemberAccess() = default;
|
|||||||
Swizzle::Swizzle(const ast::MemberAccessorExpression* declaration,
|
Swizzle::Swizzle(const ast::MemberAccessorExpression* declaration,
|
||||||
const type::Type* type,
|
const type::Type* type,
|
||||||
const Statement* statement,
|
const Statement* statement,
|
||||||
const Constant* constant,
|
const constant::Constant* constant,
|
||||||
const Expression* object,
|
const Expression* object,
|
||||||
utils::VectorRef<uint32_t> indices,
|
utils::VectorRef<uint32_t> indices,
|
||||||
bool has_side_effects,
|
bool has_side_effects,
|
||||||
|
@ -52,7 +52,7 @@ class MemberAccessorExpression : public Castable<MemberAccessorExpression, Expre
|
|||||||
const type::Type* type,
|
const type::Type* type,
|
||||||
EvaluationStage stage,
|
EvaluationStage stage,
|
||||||
const Statement* statement,
|
const Statement* statement,
|
||||||
const Constant* constant,
|
const constant::Constant* constant,
|
||||||
const Expression* object,
|
const Expression* object,
|
||||||
bool has_side_effects,
|
bool has_side_effects,
|
||||||
const Variable* root_ident = nullptr);
|
const Variable* root_ident = nullptr);
|
||||||
@ -78,7 +78,7 @@ class StructMemberAccess final : public Castable<StructMemberAccess, MemberAcces
|
|||||||
StructMemberAccess(const ast::MemberAccessorExpression* declaration,
|
StructMemberAccess(const ast::MemberAccessorExpression* declaration,
|
||||||
const type::Type* type,
|
const type::Type* type,
|
||||||
const Statement* statement,
|
const Statement* statement,
|
||||||
const Constant* constant,
|
const constant::Constant* constant,
|
||||||
const Expression* object,
|
const Expression* object,
|
||||||
const StructMember* member,
|
const StructMember* member,
|
||||||
bool has_side_effects,
|
bool has_side_effects,
|
||||||
@ -110,7 +110,7 @@ class Swizzle final : public Castable<Swizzle, MemberAccessorExpression> {
|
|||||||
Swizzle(const ast::MemberAccessorExpression* declaration,
|
Swizzle(const ast::MemberAccessorExpression* declaration,
|
||||||
const type::Type* type,
|
const type::Type* type,
|
||||||
const Statement* statement,
|
const Statement* statement,
|
||||||
const Constant* constant,
|
const constant::Constant* constant,
|
||||||
const Expression* object,
|
const Expression* object,
|
||||||
utils::VectorRef<uint32_t> indices,
|
utils::VectorRef<uint32_t> indices,
|
||||||
bool has_side_effects,
|
bool has_side_effects,
|
||||||
|
@ -49,7 +49,7 @@ const ast::CaseStatement* CaseStatement::Declaration() const {
|
|||||||
return static_cast<const ast::CaseStatement*>(Base::Declaration());
|
return static_cast<const ast::CaseStatement*>(Base::Declaration());
|
||||||
}
|
}
|
||||||
|
|
||||||
CaseSelector::CaseSelector(const ast::CaseSelector* decl, const Constant* val)
|
CaseSelector::CaseSelector(const ast::CaseSelector* decl, const constant::Constant* val)
|
||||||
: Base(), decl_(decl), val_(val) {}
|
: Base(), decl_(decl), val_(val) {}
|
||||||
|
|
||||||
CaseSelector::~CaseSelector() = default;
|
CaseSelector::~CaseSelector() = default;
|
||||||
|
@ -25,10 +25,12 @@ class CaseStatement;
|
|||||||
class CaseSelector;
|
class CaseSelector;
|
||||||
class SwitchStatement;
|
class SwitchStatement;
|
||||||
} // namespace tint::ast
|
} // namespace tint::ast
|
||||||
|
namespace tint::constant {
|
||||||
|
class Constant;
|
||||||
|
} // namespace tint::constant
|
||||||
namespace tint::sem {
|
namespace tint::sem {
|
||||||
class CaseStatement;
|
class CaseStatement;
|
||||||
class CaseSelector;
|
class CaseSelector;
|
||||||
class Constant;
|
|
||||||
class Expression;
|
class Expression;
|
||||||
} // namespace tint::sem
|
} // namespace tint::sem
|
||||||
|
|
||||||
@ -101,7 +103,7 @@ class CaseSelector final : public Castable<CaseSelector, Node> {
|
|||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param decl the selector declaration
|
/// @param decl the selector declaration
|
||||||
/// @param val the case selector value, nullptr for a default selector
|
/// @param val the case selector value, nullptr for a default selector
|
||||||
explicit CaseSelector(const ast::CaseSelector* decl, const Constant* val = nullptr);
|
explicit CaseSelector(const ast::CaseSelector* decl, const constant::Constant* val = nullptr);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~CaseSelector() override;
|
~CaseSelector() override;
|
||||||
@ -113,11 +115,11 @@ class CaseSelector final : public Castable<CaseSelector, Node> {
|
|||||||
const ast::CaseSelector* Declaration() const;
|
const ast::CaseSelector* Declaration() const;
|
||||||
|
|
||||||
/// @returns the selector constant value, or nullptr if this is the default selector
|
/// @returns the selector constant value, or nullptr if this is the default selector
|
||||||
const Constant* Value() const { return val_; }
|
const constant::Constant* Value() const { return val_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ast::CaseSelector* const decl_;
|
const ast::CaseSelector* const decl_;
|
||||||
const Constant* const val_;
|
const constant::Constant* const val_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint::sem
|
} // namespace tint::sem
|
||||||
|
@ -33,7 +33,7 @@ Variable::Variable(const ast::Variable* declaration,
|
|||||||
EvaluationStage stage,
|
EvaluationStage stage,
|
||||||
ast::AddressSpace address_space,
|
ast::AddressSpace address_space,
|
||||||
ast::Access access,
|
ast::Access access,
|
||||||
const Constant* constant_value)
|
const constant::Constant* constant_value)
|
||||||
: declaration_(declaration),
|
: declaration_(declaration),
|
||||||
type_(type),
|
type_(type),
|
||||||
stage_(stage),
|
stage_(stage),
|
||||||
@ -49,7 +49,7 @@ LocalVariable::LocalVariable(const ast::Variable* declaration,
|
|||||||
ast::AddressSpace address_space,
|
ast::AddressSpace address_space,
|
||||||
ast::Access access,
|
ast::Access access,
|
||||||
const sem::Statement* statement,
|
const sem::Statement* statement,
|
||||||
const Constant* constant_value)
|
const constant::Constant* constant_value)
|
||||||
: Base(declaration, type, stage, address_space, access, constant_value),
|
: Base(declaration, type, stage, address_space, access, constant_value),
|
||||||
statement_(statement) {}
|
statement_(statement) {}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ GlobalVariable::GlobalVariable(const ast::Variable* declaration,
|
|||||||
EvaluationStage stage,
|
EvaluationStage stage,
|
||||||
ast::AddressSpace address_space,
|
ast::AddressSpace address_space,
|
||||||
ast::Access access,
|
ast::Access access,
|
||||||
const Constant* constant_value,
|
const constant::Constant* constant_value,
|
||||||
sem::BindingPoint binding_point,
|
sem::BindingPoint binding_point,
|
||||||
std::optional<uint32_t> location)
|
std::optional<uint32_t> location)
|
||||||
: Base(declaration, type, stage, address_space, access, constant_value),
|
: Base(declaration, type, stage, address_space, access, constant_value),
|
||||||
|
@ -59,7 +59,7 @@ class Variable : public Castable<Variable, Node> {
|
|||||||
EvaluationStage stage,
|
EvaluationStage stage,
|
||||||
ast::AddressSpace address_space,
|
ast::AddressSpace address_space,
|
||||||
ast::Access access,
|
ast::Access access,
|
||||||
const Constant* constant_value);
|
const constant::Constant* constant_value);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~Variable() override;
|
~Variable() override;
|
||||||
@ -80,7 +80,7 @@ class Variable : public Castable<Variable, Node> {
|
|||||||
ast::Access Access() const { return access_; }
|
ast::Access Access() const { return access_; }
|
||||||
|
|
||||||
/// @return the constant value of this expression
|
/// @return the constant value of this expression
|
||||||
const Constant* ConstantValue() const { return constant_value_; }
|
const constant::Constant* ConstantValue() const { return constant_value_; }
|
||||||
|
|
||||||
/// @returns the variable initializer expression, or nullptr if the variable
|
/// @returns the variable initializer expression, or nullptr if the variable
|
||||||
/// does not have one.
|
/// does not have one.
|
||||||
@ -102,7 +102,7 @@ class Variable : public Castable<Variable, Node> {
|
|||||||
const EvaluationStage stage_;
|
const EvaluationStage stage_;
|
||||||
const ast::AddressSpace address_space_;
|
const ast::AddressSpace address_space_;
|
||||||
const ast::Access access_;
|
const ast::Access access_;
|
||||||
const Constant* constant_value_;
|
const constant::Constant* constant_value_;
|
||||||
const Expression* initializer_ = nullptr;
|
const Expression* initializer_ = nullptr;
|
||||||
std::vector<const VariableUser*> users_;
|
std::vector<const VariableUser*> users_;
|
||||||
};
|
};
|
||||||
@ -124,7 +124,7 @@ class LocalVariable final : public Castable<LocalVariable, Variable> {
|
|||||||
ast::AddressSpace address_space,
|
ast::AddressSpace address_space,
|
||||||
ast::Access access,
|
ast::Access access,
|
||||||
const sem::Statement* statement,
|
const sem::Statement* statement,
|
||||||
const Constant* constant_value);
|
const constant::Constant* constant_value);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~LocalVariable() override;
|
~LocalVariable() override;
|
||||||
@ -164,7 +164,7 @@ class GlobalVariable final : public Castable<GlobalVariable, Variable> {
|
|||||||
EvaluationStage stage,
|
EvaluationStage stage,
|
||||||
ast::AddressSpace address_space,
|
ast::AddressSpace address_space,
|
||||||
ast::Access access,
|
ast::Access access,
|
||||||
const Constant* constant_value,
|
const constant::Constant* constant_value,
|
||||||
sem::BindingPoint binding_point = {},
|
sem::BindingPoint binding_point = {},
|
||||||
std::optional<uint32_t> location = std::nullopt);
|
std::optional<uint32_t> location = std::nullopt);
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@
|
|||||||
<DisplayString>vec{width_}<{*subtype_}></DisplayString>
|
<DisplayString>vec{width_}<{*subtype_}></DisplayString>
|
||||||
</Type>
|
</Type>
|
||||||
|
|
||||||
<Type Name="tint::sem::Constant">
|
<Type Name="tint::constant::Constant">
|
||||||
<DisplayString>Type={*Type()} Value={Value()}</DisplayString>
|
<DisplayString>Type={*Type()} Value={Value()}</DisplayString>
|
||||||
</Type>
|
</Type>
|
||||||
|
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
#include "src/tint/ast/internal_attribute.h"
|
#include "src/tint/ast/internal_attribute.h"
|
||||||
#include "src/tint/ast/interpolate_attribute.h"
|
#include "src/tint/ast/interpolate_attribute.h"
|
||||||
#include "src/tint/ast/variable_decl_statement.h"
|
#include "src/tint/ast/variable_decl_statement.h"
|
||||||
|
#include "src/tint/constant/constant.h"
|
||||||
#include "src/tint/debug.h"
|
#include "src/tint/debug.h"
|
||||||
#include "src/tint/sem/block_statement.h"
|
#include "src/tint/sem/block_statement.h"
|
||||||
#include "src/tint/sem/call.h"
|
#include "src/tint/sem/call.h"
|
||||||
#include "src/tint/sem/constant.h"
|
|
||||||
#include "src/tint/sem/function.h"
|
#include "src/tint/sem/function.h"
|
||||||
#include "src/tint/sem/member_accessor_expression.h"
|
#include "src/tint/sem/member_accessor_expression.h"
|
||||||
#include "src/tint/sem/module.h"
|
#include "src/tint/sem/module.h"
|
||||||
@ -2294,7 +2294,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeneratorImpl::EmitConstant(std::ostream& out, const sem::Constant* constant) {
|
bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Constant* constant) {
|
||||||
return Switch(
|
return Switch(
|
||||||
constant->Type(), //
|
constant->Type(), //
|
||||||
[&](const type::Bool*) {
|
[&](const type::Bool*) {
|
||||||
|
@ -363,7 +363,7 @@ class GeneratorImpl : public TextGenerator {
|
|||||||
/// @param out the output stream
|
/// @param out the output stream
|
||||||
/// @param constant the constant value to emit
|
/// @param constant the constant value to emit
|
||||||
/// @returns true if the constant value was successfully emitted
|
/// @returns true if the constant value was successfully emitted
|
||||||
bool EmitConstant(std::ostream& out, const sem::Constant* constant);
|
bool EmitConstant(std::ostream& out, const constant::Constant* constant);
|
||||||
/// Handles a literal
|
/// Handles a literal
|
||||||
/// @param out the output stream
|
/// @param out the output stream
|
||||||
/// @param lit the literal to emit
|
/// @param lit the literal to emit
|
||||||
|
@ -27,10 +27,10 @@
|
|||||||
#include "src/tint/ast/internal_attribute.h"
|
#include "src/tint/ast/internal_attribute.h"
|
||||||
#include "src/tint/ast/interpolate_attribute.h"
|
#include "src/tint/ast/interpolate_attribute.h"
|
||||||
#include "src/tint/ast/variable_decl_statement.h"
|
#include "src/tint/ast/variable_decl_statement.h"
|
||||||
|
#include "src/tint/constant/constant.h"
|
||||||
#include "src/tint/debug.h"
|
#include "src/tint/debug.h"
|
||||||
#include "src/tint/sem/block_statement.h"
|
#include "src/tint/sem/block_statement.h"
|
||||||
#include "src/tint/sem/call.h"
|
#include "src/tint/sem/call.h"
|
||||||
#include "src/tint/sem/constant.h"
|
|
||||||
#include "src/tint/sem/function.h"
|
#include "src/tint/sem/function.h"
|
||||||
#include "src/tint/sem/member_accessor_expression.h"
|
#include "src/tint/sem/member_accessor_expression.h"
|
||||||
#include "src/tint/sem/module.h"
|
#include "src/tint/sem/module.h"
|
||||||
@ -3263,7 +3263,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GeneratorImpl::EmitConstant(std::ostream& out,
|
bool GeneratorImpl::EmitConstant(std::ostream& out,
|
||||||
const sem::Constant* constant,
|
const constant::Constant* constant,
|
||||||
bool is_variable_initializer) {
|
bool is_variable_initializer) {
|
||||||
return Switch(
|
return Switch(
|
||||||
constant->Type(), //
|
constant->Type(), //
|
||||||
|
@ -352,7 +352,7 @@ class GeneratorImpl : public TextGenerator {
|
|||||||
/// initializer
|
/// initializer
|
||||||
/// @returns true if the constant value was successfully emitted
|
/// @returns true if the constant value was successfully emitted
|
||||||
bool EmitConstant(std::ostream& out,
|
bool EmitConstant(std::ostream& out,
|
||||||
const sem::Constant* constant,
|
const constant::Constant* constant,
|
||||||
bool is_variable_initializer);
|
bool is_variable_initializer);
|
||||||
/// Handles a literal
|
/// Handles a literal
|
||||||
/// @param out the output stream
|
/// @param out the output stream
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
#include "src/tint/ast/module.h"
|
#include "src/tint/ast/module.h"
|
||||||
#include "src/tint/ast/variable_decl_statement.h"
|
#include "src/tint/ast/variable_decl_statement.h"
|
||||||
#include "src/tint/ast/void.h"
|
#include "src/tint/ast/void.h"
|
||||||
|
#include "src/tint/constant/constant.h"
|
||||||
#include "src/tint/sem/call.h"
|
#include "src/tint/sem/call.h"
|
||||||
#include "src/tint/sem/constant.h"
|
|
||||||
#include "src/tint/sem/function.h"
|
#include "src/tint/sem/function.h"
|
||||||
#include "src/tint/sem/member_accessor_expression.h"
|
#include "src/tint/sem/member_accessor_expression.h"
|
||||||
#include "src/tint/sem/module.h"
|
#include "src/tint/sem/module.h"
|
||||||
@ -1658,7 +1658,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeneratorImpl::EmitConstant(std::ostream& out, const sem::Constant* constant) {
|
bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Constant* constant) {
|
||||||
return Switch(
|
return Switch(
|
||||||
constant->Type(), //
|
constant->Type(), //
|
||||||
[&](const type::Bool*) {
|
[&](const type::Bool*) {
|
||||||
|
@ -260,7 +260,7 @@ class GeneratorImpl : public TextGenerator {
|
|||||||
/// @param out the output stream
|
/// @param out the output stream
|
||||||
/// @param constant the constant value to emit
|
/// @param constant the constant value to emit
|
||||||
/// @returns true if the constant value was successfully emitted
|
/// @returns true if the constant value was successfully emitted
|
||||||
bool EmitConstant(std::ostream& out, const sem::Constant* constant);
|
bool EmitConstant(std::ostream& out, const constant::Constant* constant);
|
||||||
/// Handles a literal
|
/// Handles a literal
|
||||||
/// @param out the output of the expression stream
|
/// @param out the output of the expression stream
|
||||||
/// @param lit the literal to emit
|
/// @param lit the literal to emit
|
||||||
|
@ -22,9 +22,9 @@
|
|||||||
#include "src/tint/ast/id_attribute.h"
|
#include "src/tint/ast/id_attribute.h"
|
||||||
#include "src/tint/ast/internal_attribute.h"
|
#include "src/tint/ast/internal_attribute.h"
|
||||||
#include "src/tint/ast/traverse_expressions.h"
|
#include "src/tint/ast/traverse_expressions.h"
|
||||||
|
#include "src/tint/constant/constant.h"
|
||||||
#include "src/tint/sem/builtin.h"
|
#include "src/tint/sem/builtin.h"
|
||||||
#include "src/tint/sem/call.h"
|
#include "src/tint/sem/call.h"
|
||||||
#include "src/tint/sem/constant.h"
|
|
||||||
#include "src/tint/sem/function.h"
|
#include "src/tint/sem/function.h"
|
||||||
#include "src/tint/sem/materialize.h"
|
#include "src/tint/sem/materialize.h"
|
||||||
#include "src/tint/sem/member_accessor_expression.h"
|
#include "src/tint/sem/member_accessor_expression.h"
|
||||||
@ -1641,7 +1641,7 @@ uint32_t Builder::GenerateLiteralIfNeeded(const ast::LiteralExpression* lit) {
|
|||||||
return GenerateConstantIfNeeded(constant);
|
return GenerateConstantIfNeeded(constant);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Builder::GenerateConstantIfNeeded(const sem::Constant* constant) {
|
uint32_t Builder::GenerateConstantIfNeeded(const constant::Constant* constant) {
|
||||||
if (constant->AllZero()) {
|
if (constant->AllZero()) {
|
||||||
return GenerateConstantNullIfNeeded(constant->Type());
|
return GenerateConstantNullIfNeeded(constant->Type());
|
||||||
}
|
}
|
||||||
|
@ -559,7 +559,7 @@ class Builder {
|
|||||||
/// Generates a constant value if needed
|
/// Generates a constant value if needed
|
||||||
/// @param constant the constant to generate.
|
/// @param constant the constant to generate.
|
||||||
/// @returns the ID on success or 0 on failure
|
/// @returns the ID on success or 0 on failure
|
||||||
uint32_t GenerateConstantIfNeeded(const sem::Constant* constant);
|
uint32_t GenerateConstantIfNeeded(const constant::Constant* constant);
|
||||||
|
|
||||||
/// Generates a scalar constant if needed
|
/// Generates a scalar constant if needed
|
||||||
/// @param constant the constant to generate.
|
/// @param constant the constant to generate.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user