writer/spirv: Clean up constant generation

Requiring a temporary stack-allocated ast::Literal is an unpleasant requirement to generate a SPIR-V constant value.
GenerateU32Literal() was also creating an invalid AST - the type was U32, yet an an ast::SintLiteral was used.

Instead add Constant for holding a constant value, and use this as the map key.

This also removes the last remaining use of ast::NullLiteral, which will be removed in the next change.

Change-Id: Ia85732784075f153503dbef101ba95018eaa4bf5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45342
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2021-03-22 15:32:35 +00:00
committed by Commit Bot service account
parent d6fe74b01f
commit eae161cd9f
7 changed files with 318 additions and 67 deletions

View File

@@ -336,6 +336,7 @@ source_set("tint_unittests_spv_writer_src") {
"../src/writer/spirv/builder_unary_op_expression_test.cc",
"../src/writer/spirv/instruction_test.cc",
"../src/writer/spirv/operand_test.cc",
"../src/writer/spirv/scalar_constant_test.cc",
"../src/writer/spirv/spv_dump.cc",
"../src/writer/spirv/spv_dump.h",
"../src/writer/spirv/test_helper.h",