spirv-reader: treat function parameters as const declarations
Change-Id: I5e5f35be15737c6dc46bb2e9dc1319f7c403eab8 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30921 Reviewed-by: dan sinclair <dsinclair@chromium.org> Commit-Queue: David Neto <dneto@google.com>
This commit is contained in:
parent
e6fda61ef0
commit
9ab6e8b9eb
|
@ -614,8 +614,11 @@ bool FunctionEmitter::EmitFunctionDeclaration() {
|
|||
[this, &ast_params](const spvtools::opt::Instruction* param) {
|
||||
auto* ast_type = parser_impl_.ConvertType(param->type_id());
|
||||
if (ast_type != nullptr) {
|
||||
ast_params.emplace_back(parser_impl_.MakeVariable(
|
||||
param->result_id(), ast::StorageClass::kNone, ast_type));
|
||||
auto ast_param = parser_impl_.MakeVariable(
|
||||
param->result_id(), ast::StorageClass::kNone, ast_type);
|
||||
// Parameters are treated as const declarations.
|
||||
ast_param->set_is_const(true);
|
||||
ast_params.emplace_back(std::move(ast_param));
|
||||
// The value is accessible by name.
|
||||
identifier_values_.insert(param->result_id());
|
||||
} else {
|
||||
|
|
|
@ -219,12 +219,12 @@ TEST_F(SpvParserTest, EmitStatement_CallWithParams) {
|
|||
EXPECT_THAT(module_ast_str, HasSubstr(R"(Module{
|
||||
Function x_50 -> __u32
|
||||
(
|
||||
Variable{
|
||||
VariableConst{
|
||||
x_51
|
||||
none
|
||||
__u32
|
||||
}
|
||||
Variable{
|
||||
VariableConst{
|
||||
x_52
|
||||
none
|
||||
__u32
|
||||
|
|
|
@ -104,17 +104,17 @@ TEST_F(SpvParserTest, EmitFunctionDeclaration_MixedParamTypes) {
|
|||
EXPECT_THAT(p->module().to_str(), HasSubstr(R"(
|
||||
Function x_100 -> __void
|
||||
(
|
||||
Variable{
|
||||
VariableConst{
|
||||
a
|
||||
none
|
||||
__u32
|
||||
}
|
||||
Variable{
|
||||
VariableConst{
|
||||
b
|
||||
none
|
||||
__f32
|
||||
}
|
||||
Variable{
|
||||
VariableConst{
|
||||
c
|
||||
none
|
||||
__i32
|
||||
|
@ -143,17 +143,17 @@ TEST_F(SpvParserTest, EmitFunctionDeclaration_GenerateParamNames) {
|
|||
EXPECT_THAT(p->module().to_str(), HasSubstr(R"(
|
||||
Function x_100 -> __void
|
||||
(
|
||||
Variable{
|
||||
VariableConst{
|
||||
x_14
|
||||
none
|
||||
__u32
|
||||
}
|
||||
Variable{
|
||||
VariableConst{
|
||||
x_15
|
||||
none
|
||||
__f32
|
||||
}
|
||||
Variable{
|
||||
VariableConst{
|
||||
x_16
|
||||
none
|
||||
__i32
|
||||
|
|
|
@ -293,17 +293,17 @@ TEST_F(SpvParserTest, EmitFunctions_MixedParamTypes) {
|
|||
EXPECT_THAT(module_ast, HasSubstr(R"(
|
||||
Function mixed_params -> __void
|
||||
(
|
||||
Variable{
|
||||
VariableConst{
|
||||
a
|
||||
none
|
||||
__u32
|
||||
}
|
||||
Variable{
|
||||
VariableConst{
|
||||
b
|
||||
none
|
||||
__f32
|
||||
}
|
||||
Variable{
|
||||
VariableConst{
|
||||
c
|
||||
none
|
||||
__i32
|
||||
|
@ -332,17 +332,17 @@ TEST_F(SpvParserTest, EmitFunctions_GenerateParamNames) {
|
|||
EXPECT_THAT(module_ast, HasSubstr(R"(
|
||||
Function mixed_params -> __void
|
||||
(
|
||||
Variable{
|
||||
VariableConst{
|
||||
x_14
|
||||
none
|
||||
__u32
|
||||
}
|
||||
Variable{
|
||||
VariableConst{
|
||||
x_15
|
||||
none
|
||||
__f32
|
||||
}
|
||||
Variable{
|
||||
VariableConst{
|
||||
x_16
|
||||
none
|
||||
__i32
|
||||
|
|
Loading…
Reference in New Issue