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:
parent
eb29f81883
commit
0d757d2fad
|
@ -85,13 +85,12 @@
|
||||||
|
|
||||||
namespace tint::resolver {
|
namespace tint::resolver {
|
||||||
|
|
||||||
Resolver::Resolver(ProgramBuilder* builder, bool enable_abstract_numerics)
|
Resolver::Resolver(ProgramBuilder* builder)
|
||||||
: builder_(builder),
|
: builder_(builder),
|
||||||
diagnostics_(builder->Diagnostics()),
|
diagnostics_(builder->Diagnostics()),
|
||||||
intrinsic_table_(IntrinsicTable::Create(*builder)),
|
intrinsic_table_(IntrinsicTable::Create(*builder)),
|
||||||
sem_(builder, dependencies_),
|
sem_(builder, dependencies_),
|
||||||
validator_(builder, sem_),
|
validator_(builder, sem_) {}
|
||||||
enable_abstract_numerics_(enable_abstract_numerics) {}
|
|
||||||
|
|
||||||
Resolver::~Resolver() = default;
|
Resolver::~Resolver() = default;
|
||||||
|
|
||||||
|
@ -1632,10 +1631,7 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) {
|
||||||
[&](const ast::IntLiteralExpression* i) -> sem::Type* {
|
[&](const ast::IntLiteralExpression* i) -> sem::Type* {
|
||||||
switch (i->suffix) {
|
switch (i->suffix) {
|
||||||
case ast::IntLiteralExpression::Suffix::kNone:
|
case ast::IntLiteralExpression::Suffix::kNone:
|
||||||
if (enable_abstract_numerics_) {
|
|
||||||
return builder_->create<sem::AbstractInt>();
|
return builder_->create<sem::AbstractInt>();
|
||||||
}
|
|
||||||
return builder_->create<sem::I32>();
|
|
||||||
case ast::IntLiteralExpression::Suffix::kI:
|
case ast::IntLiteralExpression::Suffix::kI:
|
||||||
return builder_->create<sem::I32>();
|
return builder_->create<sem::I32>();
|
||||||
case ast::IntLiteralExpression::Suffix::kU:
|
case ast::IntLiteralExpression::Suffix::kU:
|
||||||
|
@ -1644,8 +1640,7 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
},
|
},
|
||||||
[&](const ast::FloatLiteralExpression* f) -> sem::Type* {
|
[&](const ast::FloatLiteralExpression* f) -> sem::Type* {
|
||||||
if (f->suffix == ast::FloatLiteralExpression::Suffix::kNone &&
|
if (f->suffix == ast::FloatLiteralExpression::Suffix::kNone) {
|
||||||
enable_abstract_numerics_) {
|
|
||||||
return builder_->create<sem::AbstractFloat>();
|
return builder_->create<sem::AbstractFloat>();
|
||||||
}
|
}
|
||||||
return builder_->create<sem::F32>();
|
return builder_->create<sem::F32>();
|
||||||
|
|
|
@ -76,10 +76,7 @@ class Resolver {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param builder the program builder
|
/// @param builder the program builder
|
||||||
/// @param enable_abstract_numerics if true, then treat unsuffixed integers as abstract integers
|
explicit Resolver(ProgramBuilder* builder);
|
||||||
/// 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);
|
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~Resolver();
|
~Resolver();
|
||||||
|
@ -399,8 +396,6 @@ class Resolver {
|
||||||
sem::Statement* current_statement_ = nullptr;
|
sem::Statement* current_statement_ = nullptr;
|
||||||
sem::CompoundStatement* current_compound_statement_ = nullptr;
|
sem::CompoundStatement* current_compound_statement_ = nullptr;
|
||||||
sem::BlockStatement* current_block_ = nullptr;
|
sem::BlockStatement* current_block_ = nullptr;
|
||||||
|
|
||||||
bool enable_abstract_numerics_ = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint::resolver
|
} // namespace tint::resolver
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
|
|
||||||
namespace tint::resolver {
|
namespace tint::resolver {
|
||||||
|
|
||||||
TestHelper::TestHelper()
|
TestHelper::TestHelper() : resolver_(std::make_unique<Resolver>(this)) {}
|
||||||
: resolver_(std::make_unique<Resolver>(this, /* enable_abstract_numerics */ true)) {}
|
|
||||||
|
|
||||||
TestHelper::~TestHelper() = default;
|
TestHelper::~TestHelper() = default;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue