Skip to content

Commit e155f21

Browse files
committed
rsx/gtest: Add tests for CFG BB succ edges and fix UT failures
1 parent bd1b46b commit e155f21

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

rpcs3/Emu/RSX/Program/Assembler/IR.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ namespace rsx::assembler
7272
{
7373
u32 id = 0;
7474
std::vector<Instruction> instructions; // Program instructions for the RSX processor
75-
std::vector<FlowEdge> succ; // [0] = if/loop, [1] = else
76-
std::vector<FlowEdge> pred; // Back edge.
75+
std::vector<FlowEdge> succ; // Forward edges. Sorted closest first.
76+
std::vector<FlowEdge> pred; // Back edges. Sorted closest first.
7777

7878
std::vector<Instruction> prologue; // Prologue, created by passes
7979
std::vector<Instruction> epilogue; // Epilogue, created by passes

rpcs3/tests/test_rsx_cfg.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ namespace rsx::assembler
7272
EXPECT_EQ(graph.blocks.size(), 1);
7373
EXPECT_EQ(graph.blocks.front().instructions.size(), 2);
7474
EXPECT_EQ(graph.blocks.front().instructions.front().length, 4);
75-
EXPECT_NE(graph.blocks.front().instructions.front().addr, 0);
75+
EXPECT_EQ(graph.blocks.front().instructions[0].addr, 0);
76+
EXPECT_EQ(graph.blocks.front().instructions[1].addr, 16);
7677
}
7778

7879
TEST(CFG, FpToCFG_IF)
@@ -192,6 +193,13 @@ namespace rsx::assembler
192193
EXPECT_EQ(std::find_if(graph.blocks.begin(), graph.blocks.end(), FN(x.id == 6))->pred[0].from->id, 3);
193194
EXPECT_EQ(std::find_if(graph.blocks.begin(), graph.blocks.end(), FN(x.id == 6))->pred[1].type, EdgeType::ENDIF);
194195
EXPECT_EQ(std::find_if(graph.blocks.begin(), graph.blocks.end(), FN(x.id == 6))->pred[1].from->id, 0);
196+
197+
// Successors must also be ordered, closest first
198+
ASSERT_EQ(std::find_if(graph.blocks.begin(), graph.blocks.end(), FN(x.id == 0))->succ.size(), 2);
199+
EXPECT_EQ(std::find_if(graph.blocks.begin(), graph.blocks.end(), FN(x.id == 0))->succ[0].type, EdgeType::IF);
200+
EXPECT_EQ(std::find_if(graph.blocks.begin(), graph.blocks.end(), FN(x.id == 0))->succ[0].to->id, 3);
201+
EXPECT_EQ(std::find_if(graph.blocks.begin(), graph.blocks.end(), FN(x.id == 0))->succ[1].type, EdgeType::ENDIF);
202+
EXPECT_EQ(std::find_if(graph.blocks.begin(), graph.blocks.end(), FN(x.id == 0))->succ[1].to->id, 6);
195203
}
196204

197205
TEST(CFG, FpToCFG_IF_ELSE)

0 commit comments

Comments
 (0)