[resolver]: Begin constant value evaluation

Move the bulk of the constant evaulation logic out of transform::FoldConstants and into Resolver and sem::Expression.

transform::FoldConstants now replace TypeConstructor nodes that have a constant value on the expression.

This is ground work to:
* Cleaning up the HLSL uniform buffer indexing, which is `/` and `%` arithmatic heavy
* Prepares us to handle `constexpr` when it lands in the spec
* Provide a centralized place to do constant evaluation, instead of the
  having similar logic scattered around the codebase.

Change-Id: I3e2f542be692046a8d243b62a82556db519953e7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57426
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton
2021-07-13 12:18:13 +00:00
parent c6bcab02fd
commit 71f619b6f1
22 changed files with 992 additions and 398 deletions

View File

@@ -30,6 +30,7 @@ Matrix::Matrix(ProgramID program_id,
subtype_(subtype),
rows_(rows),
columns_(columns) {
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, subtype, program_id);
TINT_ASSERT(AST, rows > 1);
TINT_ASSERT(AST, rows < 5);
TINT_ASSERT(AST, columns > 1);

View File

@@ -26,6 +26,7 @@ Vector::Vector(ProgramID program_id,
Type const* subtype,
uint32_t size)
: Base(program_id, source), subtype_(subtype), size_(size) {
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, subtype, program_id);
TINT_ASSERT(AST, size_ > 1);
TINT_ASSERT(AST, size_ < 5);
}