tint/resolver: Enable abstract-numerics

Turn on resolving of abstract-integer and abstract-float types, as well
as materialization to their concrete types.

Bug: tint:1504
Bug: chromium:1330805
Fixed: tint:1572
Change-Id: I09c95406e11b64bb0267fe7b1ed08af986dbd553
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91840
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2022-06-01 20:34:40 +00:00 committed by Dawn LUCI CQ
parent eb29f81883
commit 0d757d2fad
3 changed files with 6 additions and 17 deletions

View File

@ -85,13 +85,12 @@
namespace tint::resolver {
Resolver::Resolver(ProgramBuilder* builder, bool enable_abstract_numerics)
Resolver::Resolver(ProgramBuilder* builder)
: builder_(builder),
diagnostics_(builder->Diagnostics()),
intrinsic_table_(IntrinsicTable::Create(*builder)),
sem_(builder, dependencies_),
validator_(builder, sem_),
enable_abstract_numerics_(enable_abstract_numerics) {}
validator_(builder, sem_) {}
Resolver::~Resolver() = default;
@ -1632,10 +1631,7 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) {
[&](const ast::IntLiteralExpression* i) -> sem::Type* {
switch (i->suffix) {
case ast::IntLiteralExpression::Suffix::kNone:
if (enable_abstract_numerics_) {
return builder_->create<sem::AbstractInt>();
}
return builder_->create<sem::I32>();
return builder_->create<sem::AbstractInt>();
case ast::IntLiteralExpression::Suffix::kI:
return builder_->create<sem::I32>();
case ast::IntLiteralExpression::Suffix::kU:
@ -1644,8 +1640,7 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) {
return nullptr;
},
[&](const ast::FloatLiteralExpression* f) -> sem::Type* {
if (f->suffix == ast::FloatLiteralExpression::Suffix::kNone &&
enable_abstract_numerics_) {
if (f->suffix == ast::FloatLiteralExpression::Suffix::kNone) {
return builder_->create<sem::AbstractFloat>();
}
return builder_->create<sem::F32>();

View File

@ -76,10 +76,7 @@ class Resolver {
public:
/// Constructor
/// @param builder the program builder
/// @param enable_abstract_numerics if true, then treat unsuffixed integers as abstract integers
/// and unsuffixed floats as abstract floats. This is a temporary flag while abstract numerics
/// are being developed. Once complete, this will be permanently enabled.
explicit Resolver(ProgramBuilder* builder, bool enable_abstract_numerics = false);
explicit Resolver(ProgramBuilder* builder);
/// Destructor
~Resolver();
@ -399,8 +396,6 @@ class Resolver {
sem::Statement* current_statement_ = nullptr;
sem::CompoundStatement* current_compound_statement_ = nullptr;
sem::BlockStatement* current_block_ = nullptr;
bool enable_abstract_numerics_ = false;
};
} // namespace tint::resolver

View File

@ -18,8 +18,7 @@
namespace tint::resolver {
TestHelper::TestHelper()
: resolver_(std::make_unique<Resolver>(this, /* enable_abstract_numerics */ true)) {}
TestHelper::TestHelper() : resolver_(std::make_unique<Resolver>(this)) {}
TestHelper::~TestHelper() = default;