Update some language usage.
This CL updates a few bits of language to be inline with the Android respectful code rules [1]. 1- https://source.android.com/setup/contribute/respectful-code Change-Id: Ia35b58d9003df64eeb1e9196c9c194f8955c11c1 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25941 Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
d35e4e1bbe
commit
bf4614e252
|
@ -630,7 +630,7 @@ ast::type::Type* FunctionEmitter::GetVariableStoreType(
|
||||||
bool FunctionEmitter::EmitBody() {
|
bool FunctionEmitter::EmitBody() {
|
||||||
RegisterBasicBlocks();
|
RegisterBasicBlocks();
|
||||||
|
|
||||||
if (!TerminatorsAreSane()) {
|
if (!TerminatorsAreValid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!RegisterMerges()) {
|
if (!RegisterMerges()) {
|
||||||
|
@ -674,7 +674,7 @@ void FunctionEmitter::RegisterBasicBlocks() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FunctionEmitter::TerminatorsAreSane() {
|
bool FunctionEmitter::TerminatorsAreValid() {
|
||||||
if (failed()) {
|
if (failed()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1261,7 +1261,7 @@ bool FunctionEmitter::ClassifyCFGEdges() {
|
||||||
|
|
||||||
for (const auto dest : successors) {
|
for (const auto dest : successors) {
|
||||||
const auto* dest_info = GetBlockInfo(dest);
|
const auto* dest_info = GetBlockInfo(dest);
|
||||||
// We've already checked terminators are sane.
|
// We've already checked terminators are valid.
|
||||||
assert(dest_info);
|
assert(dest_info);
|
||||||
const auto dest_pos = dest_info->pos;
|
const auto dest_pos = dest_info->pos;
|
||||||
|
|
||||||
|
|
|
@ -319,13 +319,13 @@ class FunctionEmitter {
|
||||||
|
|
||||||
/// Verifies that terminators only branch to labels in the current function.
|
/// Verifies that terminators only branch to labels in the current function.
|
||||||
/// Assumes basic blocks have been registered.
|
/// Assumes basic blocks have been registered.
|
||||||
/// @returns true if terminators are sane
|
/// @returns true if terminators are valid
|
||||||
bool TerminatorsAreSane();
|
bool TerminatorsAreValid();
|
||||||
|
|
||||||
/// Populates merge-header cross-links and the |is_continue_entire_loop|
|
/// Populates merge-header cross-links and the |is_continue_entire_loop|
|
||||||
/// member of BlockInfo. Also verifies that merge instructions go to blocks
|
/// member of BlockInfo. Also verifies that merge instructions go to blocks
|
||||||
/// in the same function. Assumes basic blocks have been registered, and
|
/// in the same function. Assumes basic blocks have been registered, and
|
||||||
/// terminators are sane.
|
/// terminators are valid.
|
||||||
/// @returns false if registration fails
|
/// @returns false if registration fails
|
||||||
bool RegisterMerges();
|
bool RegisterMerges();
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ class FunctionEmitter {
|
||||||
|
|
||||||
/// Labels each basic block with its nearest enclosing structured construct.
|
/// Labels each basic block with its nearest enclosing structured construct.
|
||||||
/// Populates the |construct| member of BlockInfo, and the |constructs_| list.
|
/// Populates the |construct| member of BlockInfo, and the |constructs_| list.
|
||||||
/// Assumes terminators are sane and merges have been registered, block
|
/// Assumes terminators are valid and merges have been registered, block
|
||||||
/// order has been computed, and each block is labeled with its position.
|
/// order has been computed, and each block is labeled with its position.
|
||||||
/// Checks nesting of structured control flow constructs.
|
/// Checks nesting of structured control flow constructs.
|
||||||
/// @returns false if bad nesting has been detected
|
/// @returns false if bad nesting has been detected
|
||||||
|
|
|
@ -122,7 +122,7 @@ bool FlowFindIfSelectionInternalHeaders(FunctionEmitter* fe) {
|
||||||
return fe->FindIfSelectionInternalHeaders();
|
return fe->FindIfSelectionInternalHeaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, TerminatorsAreSane_SingleBlock) {
|
TEST_F(SpvParserTest, TerminatorsAreValid_SingleBlock) {
|
||||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -134,10 +134,10 @@ TEST_F(SpvParserTest, TerminatorsAreSane_SingleBlock) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
fe.RegisterBasicBlocks();
|
fe.RegisterBasicBlocks();
|
||||||
EXPECT_TRUE(fe.TerminatorsAreSane());
|
EXPECT_TRUE(fe.TerminatorsAreValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, TerminatorsAreSane_Sequence) {
|
TEST_F(SpvParserTest, TerminatorsAreValid_Sequence) {
|
||||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -152,10 +152,10 @@ TEST_F(SpvParserTest, TerminatorsAreSane_Sequence) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
fe.RegisterBasicBlocks();
|
fe.RegisterBasicBlocks();
|
||||||
EXPECT_TRUE(fe.TerminatorsAreSane()) << p->error();
|
EXPECT_TRUE(fe.TerminatorsAreValid()) << p->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, TerminatorsAreSane_If) {
|
TEST_F(SpvParserTest, TerminatorsAreValid_If) {
|
||||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -177,10 +177,10 @@ TEST_F(SpvParserTest, TerminatorsAreSane_If) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
fe.RegisterBasicBlocks();
|
fe.RegisterBasicBlocks();
|
||||||
EXPECT_TRUE(fe.TerminatorsAreSane()) << p->error();
|
EXPECT_TRUE(fe.TerminatorsAreValid()) << p->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, TerminatorsAreSane_Switch) {
|
TEST_F(SpvParserTest, TerminatorsAreValid_Switch) {
|
||||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -205,10 +205,10 @@ TEST_F(SpvParserTest, TerminatorsAreSane_Switch) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
fe.RegisterBasicBlocks();
|
fe.RegisterBasicBlocks();
|
||||||
EXPECT_TRUE(fe.TerminatorsAreSane());
|
EXPECT_TRUE(fe.TerminatorsAreValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, TerminatorsAreSane_Loop_SingleBlock) {
|
TEST_F(SpvParserTest, TerminatorsAreValid_Loop_SingleBlock) {
|
||||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -227,10 +227,10 @@ TEST_F(SpvParserTest, TerminatorsAreSane_Loop_SingleBlock) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
fe.RegisterBasicBlocks();
|
fe.RegisterBasicBlocks();
|
||||||
EXPECT_TRUE(fe.TerminatorsAreSane());
|
EXPECT_TRUE(fe.TerminatorsAreValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, TerminatorsAreSane_Loop_Simple) {
|
TEST_F(SpvParserTest, TerminatorsAreValid_Loop_Simple) {
|
||||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -255,10 +255,10 @@ TEST_F(SpvParserTest, TerminatorsAreSane_Loop_Simple) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
fe.RegisterBasicBlocks();
|
fe.RegisterBasicBlocks();
|
||||||
EXPECT_TRUE(fe.TerminatorsAreSane());
|
EXPECT_TRUE(fe.TerminatorsAreValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, TerminatorsAreSane_Kill) {
|
TEST_F(SpvParserTest, TerminatorsAreValid_Kill) {
|
||||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -270,10 +270,10 @@ TEST_F(SpvParserTest, TerminatorsAreSane_Kill) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
fe.RegisterBasicBlocks();
|
fe.RegisterBasicBlocks();
|
||||||
EXPECT_TRUE(fe.TerminatorsAreSane());
|
EXPECT_TRUE(fe.TerminatorsAreValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, TerminatorsAreSane_Unreachable) {
|
TEST_F(SpvParserTest, TerminatorsAreValid_Unreachable) {
|
||||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -285,10 +285,10 @@ TEST_F(SpvParserTest, TerminatorsAreSane_Unreachable) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
fe.RegisterBasicBlocks();
|
fe.RegisterBasicBlocks();
|
||||||
EXPECT_TRUE(fe.TerminatorsAreSane());
|
EXPECT_TRUE(fe.TerminatorsAreValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, TerminatorsAreSane_MissingTerminator) {
|
TEST_F(SpvParserTest, TerminatorsAreValid_MissingTerminator) {
|
||||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ TEST_F(SpvParserTest, TerminatorsAreSane_MissingTerminator) {
|
||||||
EXPECT_FALSE(p->BuildAndParseInternalModuleExceptFunctions());
|
EXPECT_FALSE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, TerminatorsAreSane_DisallowLoopToEntryBlock) {
|
TEST_F(SpvParserTest, TerminatorsAreValid_DisallowLoopToEntryBlock) {
|
||||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -315,11 +315,11 @@ TEST_F(SpvParserTest, TerminatorsAreSane_DisallowLoopToEntryBlock) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
fe.RegisterBasicBlocks();
|
fe.RegisterBasicBlocks();
|
||||||
EXPECT_FALSE(fe.TerminatorsAreSane());
|
EXPECT_FALSE(fe.TerminatorsAreValid());
|
||||||
EXPECT_THAT(p->error(), Eq("Block 20 branches to function entry block 10"));
|
EXPECT_THAT(p->error(), Eq("Block 20 branches to function entry block 10"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, TerminatorsAreSane_DisallowNonBlock) {
|
TEST_F(SpvParserTest, TerminatorsAreValid_DisallowNonBlock) {
|
||||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -331,13 +331,13 @@ TEST_F(SpvParserTest, TerminatorsAreSane_DisallowNonBlock) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
fe.RegisterBasicBlocks();
|
fe.RegisterBasicBlocks();
|
||||||
EXPECT_FALSE(fe.TerminatorsAreSane());
|
EXPECT_FALSE(fe.TerminatorsAreValid());
|
||||||
EXPECT_THAT(p->error(),
|
EXPECT_THAT(p->error(),
|
||||||
Eq("Block 10 in function 100 branches to 999 which is "
|
Eq("Block 10 in function 100 branches to 999 which is "
|
||||||
"not a block in the function"));
|
"not a block in the function"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, TerminatorsAreSane_DisallowBlockInDifferentFunction) {
|
TEST_F(SpvParserTest, TerminatorsAreValid_DisallowBlockInDifferentFunction) {
|
||||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ TEST_F(SpvParserTest, TerminatorsAreSane_DisallowBlockInDifferentFunction) {
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
fe.RegisterBasicBlocks();
|
fe.RegisterBasicBlocks();
|
||||||
EXPECT_FALSE(fe.TerminatorsAreSane());
|
EXPECT_FALSE(fe.TerminatorsAreValid());
|
||||||
EXPECT_THAT(p->error(), Eq("Block 10 in function 100 branches to 210 which "
|
EXPECT_THAT(p->error(), Eq("Block 10 in function 100 branches to 210 which "
|
||||||
"is not a block in the function"));
|
"is not a block in the function"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ using DecorationList = std::vector<Decoration>;
|
||||||
|
|
||||||
/// An AST expression with its type.
|
/// An AST expression with its type.
|
||||||
struct TypedExpression {
|
struct TypedExpression {
|
||||||
/// Dummy constructor
|
/// Constructor
|
||||||
TypedExpression();
|
TypedExpression();
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param t the type
|
/// @param t the type
|
||||||
|
|
Loading…
Reference in New Issue