mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 18:59:21 +00:00
Set function storage class in type determiner.
If a non-const variable in a function has a kNone storage class we update it to kFunction. If there is a storage class other then kFunction we emit an error. Bug: tint:5 Change-Id: If45eb91bd0a0095e625eb1d0e1d1e361c784e35d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19102 Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
committed by
dan sinclair
parent
9459dbf3ab
commit
ee8ae04472
@@ -14,6 +14,8 @@
|
||||
|
||||
#include "src/reader/spirv/function.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "source/opt/basic_block.h"
|
||||
#include "source/opt/function.h"
|
||||
#include "source/opt/instruction.h"
|
||||
@@ -154,7 +156,8 @@ bool FunctionEmitter::EmitFunctionVariables() {
|
||||
parser_impl_.MakeConstantExpression(inst.GetSingleWordInOperand(1)));
|
||||
}
|
||||
// TODO(dneto): Add the initializer via Variable::set_constructor.
|
||||
auto var_decl_stmt = std::make_unique<ast::VariableDeclStatement>(std::move(var));
|
||||
auto var_decl_stmt =
|
||||
std::make_unique<ast::VariableDeclStatement>(std::move(var));
|
||||
ast_body_.emplace_back(std::move(var_decl_stmt));
|
||||
}
|
||||
return success();
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
#ifndef SRC_READER_SPIRV_FUNCTION_H_
|
||||
#define SRC_READER_SPIRV_FUNCTION_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "source/opt/constants.h"
|
||||
#include "source/opt/function.h"
|
||||
#include "source/opt/ir_context.h"
|
||||
@@ -50,7 +53,9 @@ class FunctionEmitter {
|
||||
bool failed() const { return !success(); }
|
||||
|
||||
/// @returns the body of the function.
|
||||
const std::vector<std::unique_ptr<ast::Statement>>& ast_body() { return ast_body_; }
|
||||
const std::vector<std::unique_ptr<ast::Statement>>& ast_body() {
|
||||
return ast_body_;
|
||||
}
|
||||
|
||||
/// Records failure.
|
||||
/// @returns a FailStream on which to emit diagnostics.
|
||||
|
||||
@@ -12,12 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/reader/spirv/function.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/reader/spirv/function.h"
|
||||
#include "src/reader/spirv/parser_impl.h"
|
||||
#include "src/reader/spirv/parser_impl_test_helper.h"
|
||||
#include "src/reader/spirv/spirv_tools_helpers_test.h"
|
||||
|
||||
@@ -800,11 +800,11 @@ std::unique_ptr<ast::Expression> ParserImpl::MakeConstantExpression(
|
||||
std::make_unique<ast::FloatLiteral>(ast_type, spirv_const->GetFloat()));
|
||||
}
|
||||
if (ast_type->IsBool()) {
|
||||
const bool value = spirv_const->AsNullConstant() ? false :
|
||||
spirv_const->AsBoolConstant()->value();
|
||||
const bool value = spirv_const->AsNullConstant()
|
||||
? false
|
||||
: spirv_const->AsBoolConstant()->value();
|
||||
return std::make_unique<ast::ScalarConstructorExpression>(
|
||||
std::make_unique<ast::BoolLiteral>(
|
||||
ast_type, value));
|
||||
std::make_unique<ast::BoolLiteral>(ast_type, value));
|
||||
}
|
||||
auto spirv_composite_const = spirv_const->AsCompositeConstant();
|
||||
if (spirv_composite_const != nullptr) {
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
#define SRC_READER_SPIRV_PARSER_IMPL_TEST_HELPER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
@@ -66,7 +66,8 @@ class SpvParserTest : public testing::Test {
|
||||
/// Returns the string dump of a function body.
|
||||
/// @param body the statement in the body
|
||||
/// @returnss the string dump of a function body.
|
||||
inline std::string ToString(const std::vector<std::unique_ptr<ast::Statement>>& body) {
|
||||
inline std::string ToString(
|
||||
const std::vector<std::unique_ptr<ast::Statement>>& body) {
|
||||
std::ostringstream outs;
|
||||
for (const auto& stmt : body) {
|
||||
stmt->to_str(outs, 0);
|
||||
|
||||
Reference in New Issue
Block a user