[spirv-reader] Store to module-scope variables
Bug: tint:3 Change-Id: Ib4dbb976268999529c2a1c55531aa8293e565b9c Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19222 Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
parent
b39dabd0cd
commit
2a3e79cf8c
|
@ -209,6 +209,10 @@ std::unique_ptr<ast::Expression> FunctionEmitter::MakeExpression(uint32_t id) {
|
|||
return nullptr;
|
||||
}
|
||||
switch (inst->opcode()) {
|
||||
case SpvOpVariable:
|
||||
// This occurs for module-scope variables.
|
||||
return std::make_unique<ast::IdentifierExpression>(
|
||||
namer_.Name(inst->result_id()));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -257,6 +257,28 @@ Assignment{
|
|||
)"));
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_StoreToModuleScopeVar) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeInt 32 0
|
||||
%val = OpConstant %ty 42
|
||||
%ptr_ty = OpTypePointer Workgroup %ty
|
||||
%1 = OpVariable %ptr_ty Workgroup
|
||||
%100 = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
OpStore %1 %val
|
||||
OpReturn
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
Identifier{x_1}
|
||||
ScalarConstructor{42}
|
||||
})"));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace spirv
|
||||
} // namespace reader
|
||||
|
|
Loading…
Reference in New Issue