Skip to content

Commit 0976db3

Browse files
WIP v1: Implement a recursive convert_to_ast implementation (works better with lesser LOC)
1 parent 1ab9eac commit 0976db3

File tree

5 files changed

+824
-577
lines changed

5 files changed

+824
-577
lines changed

include/blocks/basic_blocks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class basic_block {
1616
block::expr::Ptr branch_expr;
1717
std::shared_ptr<basic_block> then_branch;
1818
std::shared_ptr<basic_block> else_branch;
19+
std::shared_ptr<basic_block> exit_block;
1920
bool is_exit_block;
2021
block::stmt::Ptr parent;
2122
unsigned int ast_index;

include/blocks/loops.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ using namespace block;
1010
class loop {
1111
public:
1212
loop(std::shared_ptr<basic_block> header): header_block(header) {}
13+
stmt::Ptr convert_to_ast_impl(dominator_analysis &dta_);
1314

14-
// private:
1515
struct loop_bounds_ {
1616
stmt::Ptr ind_var;
1717
// MISS: intial value of ind var
@@ -28,6 +28,7 @@ class loop {
2828
std::unordered_set<int> blocks_id_map;
2929
std::shared_ptr<loop> parent_loop;
3030
std::shared_ptr<basic_block> header_block;
31+
std::shared_ptr<basic_block> condition_block;
3132
std::shared_ptr<basic_block> unique_exit_block;
3233
basic_block::cfg_block loop_latch_blocks;
3334
basic_block::cfg_block loop_exit_blocks;

src/blocks/basic_blocks.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ basic_block::cfg_block generate_basic_blocks(block::stmt_block::Ptr ast) {
137137
if (!bb->then_branch) bb->then_branch = exit_bb;
138138
else if (!bb->else_branch) bb->else_branch = exit_bb;
139139

140+
// set the exit block of this if stmt
141+
bb->exit_block = exit_bb;
142+
140143
return_list.push_back(bb);
141144
}
142145
else if (isa<block::expr_stmt>(bb->parent)) {

0 commit comments

Comments
 (0)