refactor(furc): improve the SSA optimization class
Improve and rename the SSA optimization class to post process. Refs: #12
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#ifndef FURC_FRONT_POST_PROCESS_HPP
|
||||
#define FURC_FRONT_POST_PROCESS_HPP
|
||||
|
||||
#include "furlang/ir/module.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace furc {
|
||||
namespace front {
|
||||
|
||||
/**
|
||||
* @brief Post process pipeline.
|
||||
*/
|
||||
class post_process {
|
||||
public:
|
||||
enum stage { // NOLINT
|
||||
Ssa,
|
||||
DeSsa,
|
||||
};
|
||||
public:
|
||||
post_process() = default;
|
||||
~post_process() = default;
|
||||
|
||||
post_process(post_process&&) noexcept = default;
|
||||
post_process& operator=(post_process&&) noexcept = default;
|
||||
post_process(const post_process&) = delete;
|
||||
post_process& operator=(const post_process&) = delete;
|
||||
public:
|
||||
void push_stage(stage stage) { m_stages.push_back(stage); }
|
||||
public:
|
||||
void process(furlang::ir::mod& mod);
|
||||
private:
|
||||
std::vector<stage> m_stages;
|
||||
};
|
||||
|
||||
} // namespace front
|
||||
} // namespace furc
|
||||
|
||||
#endif // FURC_FRONT_POST_PROCESS_HPP
|
||||
@@ -1,40 +0,0 @@
|
||||
#ifndef FURC_FRONT_SSA_HPP
|
||||
#define FURC_FRONT_SSA_HPP
|
||||
|
||||
#include "furlang/ir/function.hpp"
|
||||
#include "furlang/ir/instruction.hpp"
|
||||
#include "furlang/ir/module.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace furc {
|
||||
namespace front {
|
||||
|
||||
class ssa {
|
||||
using block_map_t = std::unordered_map<furlang::ir::block_index, std::vector<furlang::ir::block_index>>;
|
||||
public:
|
||||
static void optimize(furlang::ir::mod& mod);
|
||||
private:
|
||||
static void optimize(const std::unique_ptr<furlang::ir::function>& func);
|
||||
|
||||
static void de_ssa(const std::unique_ptr<furlang::ir::function>& func);
|
||||
|
||||
static void constant_propagation(const std::unique_ptr<furlang::ir::function>& func);
|
||||
|
||||
static void dead_code_elimination(const std::unique_ptr<furlang::ir::function>& func);
|
||||
|
||||
static void copy_propagation(const std::unique_ptr<furlang::ir::function>& func);
|
||||
|
||||
static void dfs_rpo(furlang::ir::block_index block,
|
||||
const block_map_t& successors,
|
||||
std::unordered_set<furlang::ir::block_index>& visited,
|
||||
std::vector<furlang::ir::block_index>& rpo);
|
||||
};
|
||||
|
||||
} // namespace front
|
||||
} // namespace furc
|
||||
|
||||
#endif // FURC_FRONT_SSA_HPP
|
||||
Reference in New Issue
Block a user