2020-09-13 21:32:55 -04:00
|
|
|
#pragma once
|
|
|
|
|
2020-08-22 23:30:17 -04:00
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
|
2021-01-12 19:20:08 -05:00
|
|
|
// for RegSet:
|
2021-01-23 16:32:56 -05:00
|
|
|
#include "decompiler/analysis/reg_usage.h"
|
2020-08-22 23:30:17 -04:00
|
|
|
|
2021-01-06 20:04:15 -05:00
|
|
|
namespace decompiler {
|
2020-08-22 23:30:17 -04:00
|
|
|
class LinkedObjectFile;
|
|
|
|
class Function;
|
|
|
|
|
|
|
|
struct BasicBlock {
|
|
|
|
int start_word;
|
|
|
|
int end_word;
|
2020-11-27 16:38:36 -05:00
|
|
|
|
2020-12-17 15:48:07 -05:00
|
|
|
// [start, end)
|
2020-11-27 16:38:36 -05:00
|
|
|
int start_basic_op = -1;
|
|
|
|
int end_basic_op = -1;
|
2020-12-17 15:48:07 -05:00
|
|
|
int basic_op_size() const { return end_basic_op - start_basic_op; }
|
2020-11-27 16:38:36 -05:00
|
|
|
|
|
|
|
std::string label_name;
|
2020-08-22 23:30:17 -04:00
|
|
|
|
2020-10-18 15:44:19 -04:00
|
|
|
std::vector<int> pred;
|
|
|
|
int succ_ft = -1;
|
|
|
|
int succ_branch = -1;
|
|
|
|
|
2020-08-22 23:30:17 -04:00
|
|
|
BasicBlock(int _start_word, int _end_word) : start_word(_start_word), end_word(_end_word) {}
|
|
|
|
};
|
|
|
|
|
2020-11-28 15:35:38 -05:00
|
|
|
struct BlockTopologicalSort {
|
|
|
|
std::vector<int> vist_order;
|
|
|
|
std::unordered_set<int> unreachable;
|
|
|
|
};
|
|
|
|
|
2020-08-22 23:30:17 -04:00
|
|
|
std::vector<BasicBlock> find_blocks_in_function(const LinkedObjectFile& file,
|
|
|
|
int seg,
|
|
|
|
const Function& func);
|
2021-01-06 20:04:15 -05:00
|
|
|
} // namespace decompiler
|