tint: Add abstract AInt and AFloat typedefs
Add ProgramBuilder expression helpers for these. Bug: tint:1504 Change-Id: I921dc4ebe0b97a5e451d98a19ad97df7f60384b3 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89032 Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
b7bbe7cbbb
commit
508e4a5a82
|
@ -72,6 +72,11 @@ bool operator==(A a, Number<B> b) {
|
||||||
return Number<A>(a) == b;
|
return Number<A>(a) == b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `AInt` is a type alias to `Number<int64_t>`.
|
||||||
|
using AInt = Number<int64_t>;
|
||||||
|
/// `AFloat` is a type alias to `Number<double>`.
|
||||||
|
using AFloat = Number<double>;
|
||||||
|
|
||||||
/// `i32` is a type alias to `Number<int32_t>`.
|
/// `i32` is a type alias to `Number<int32_t>`.
|
||||||
using i32 = Number<int32_t>;
|
using i32 = Number<int32_t>;
|
||||||
/// `u32` is a type alias to `Number<uint32_t>`.
|
/// `u32` is a type alias to `Number<uint32_t>`.
|
||||||
|
@ -83,6 +88,16 @@ using f32 = Number<float>;
|
||||||
|
|
||||||
namespace tint::number_suffixes {
|
namespace tint::number_suffixes {
|
||||||
|
|
||||||
|
/// Literal suffix for abstract integer literals
|
||||||
|
inline AInt operator"" _a(unsigned long long int value) { // NOLINT
|
||||||
|
return AInt(static_cast<int64_t>(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Literal suffix for abstract float literals
|
||||||
|
inline AFloat operator"" _a(long double value) { // NOLINT
|
||||||
|
return AFloat(static_cast<double>(value));
|
||||||
|
}
|
||||||
|
|
||||||
/// Literal suffix for i32 literals
|
/// Literal suffix for i32 literals
|
||||||
inline i32 operator"" _i(unsigned long long int value) { // NOLINT
|
inline i32 operator"" _i(unsigned long long int value) { // NOLINT
|
||||||
return i32(static_cast<int32_t>(value));
|
return i32(static_cast<int32_t>(value));
|
||||||
|
|
|
@ -1004,6 +1004,35 @@ class ProgramBuilder {
|
||||||
ast::FloatLiteralExpression::Suffix::kF);
|
ast::FloatLiteralExpression::Suffix::kF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @param source the source information
|
||||||
|
/// @param value the integer value
|
||||||
|
/// @return an unsuffixed IntLiteralExpression for the AInt value
|
||||||
|
const ast::IntLiteralExpression* Expr(const Source& source, AInt value) {
|
||||||
|
return create<ast::IntLiteralExpression>(source, value,
|
||||||
|
ast::IntLiteralExpression::Suffix::kNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @param value the integer value
|
||||||
|
/// @return an unsuffixed IntLiteralExpression for the AInt value
|
||||||
|
const ast::IntLiteralExpression* Expr(AInt value) {
|
||||||
|
return create<ast::IntLiteralExpression>(value, ast::IntLiteralExpression::Suffix::kNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @param source the source information
|
||||||
|
/// @param value the integer value
|
||||||
|
/// @return an unsuffixed FloatLiteralExpression for the AFloat value
|
||||||
|
const ast::FloatLiteralExpression* Expr(const Source& source, AFloat value) {
|
||||||
|
return create<ast::FloatLiteralExpression>(source, value.value,
|
||||||
|
ast::FloatLiteralExpression::Suffix::kNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @param value the integer value
|
||||||
|
/// @return an unsuffixed FloatLiteralExpression for the AFloat value
|
||||||
|
const ast::FloatLiteralExpression* Expr(AFloat value) {
|
||||||
|
return create<ast::FloatLiteralExpression>(value.value,
|
||||||
|
ast::FloatLiteralExpression::Suffix::kNone);
|
||||||
|
}
|
||||||
|
|
||||||
/// @param source the source information
|
/// @param source the source information
|
||||||
/// @param value the integer value
|
/// @param value the integer value
|
||||||
/// @return a signed 'i'-suffixed IntLiteralExpression for the i32 value
|
/// @return a signed 'i'-suffixed IntLiteralExpression for the i32 value
|
||||||
|
|
Loading…
Reference in New Issue