diff options
author | John Hodge <tpg@ucc.asn.au> | 2018-01-20 13:15:15 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2018-01-20 13:15:15 +0800 |
commit | 7a6f50e15b3856e07067a32585d194cc82701d39 (patch) | |
tree | 36a27be7477708e94d7282a57237005555892159 /src/mir/helpers.hpp | |
parent | 3ed3449e049596eff2586ceda18143a2640af9b6 (diff) | |
download | mrust-7a6f50e15b3856e07067a32585d194cc82701d39.tar.gz |
MIR Optimise - Only run UnifyTemporaries once, add a new tuple-breaking pass
Diffstat (limited to 'src/mir/helpers.hpp')
-rw-r--r-- | src/mir/helpers.hpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/mir/helpers.hpp b/src/mir/helpers.hpp index c2ffd13b..58eee9b9 100644 --- a/src/mir/helpers.hpp +++ b/src/mir/helpers.hpp @@ -9,6 +9,7 @@ #include <vector> #include <functional> #include <hir_typeck/static.hpp> +#include <mir/mir.hpp> namespace HIR { class Crate; @@ -78,15 +79,30 @@ public: } } + void set_cur_stmt(const ::MIR::BasicBlock& bb, const ::MIR::Statement& stmt) { + assert(&stmt >= &bb.statements.front()); + assert(&stmt <= &bb.statements.back()); + this->set_cur_stmt(bb, &stmt - bb.statements.data()); + } + void set_cur_stmt(const ::MIR::BasicBlock& bb, unsigned int stmt_idx) { + assert(&bb >= &m_fcn.blocks.front()); + assert(&bb <= &m_fcn.blocks.back()); + this->set_cur_stmt(&bb - m_fcn.blocks.data(), stmt_idx); + } void set_cur_stmt(unsigned int bb_idx, unsigned int stmt_idx) { this->bb_idx = bb_idx; this->stmt_idx = stmt_idx; } - unsigned int get_cur_stmt_ofs() const; + void set_cur_stmt_term(const ::MIR::BasicBlock& bb) { + assert(&bb >= &m_fcn.blocks.front()); + assert(&bb <= &m_fcn.blocks.back()); + this->set_cur_stmt_term(&bb - m_fcn.blocks.data()); + } void set_cur_stmt_term(unsigned int bb_idx) { this->bb_idx = bb_idx; this->stmt_idx = STMT_TERM; } + unsigned int get_cur_stmt_ofs() const; void fmt_pos(::std::ostream& os) const; void print_bug(::std::function<void(::std::ostream& os)> cb) const { |