diff options
Diffstat (limited to 'backend/src/ir/function.hpp')
-rw-r--r-- | backend/src/ir/function.hpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/backend/src/ir/function.hpp b/backend/src/ir/function.hpp index 60679f17..f8e37a5d 100644 --- a/backend/src/ir/function.hpp +++ b/backend/src/ir/function.hpp @@ -81,8 +81,19 @@ namespace ir { functor(*curr); } } - void insertPhiReg(Register reg) { phiRegs.insert(reg); } - bool isPhiReg(Register reg) { return phiRegs.find(reg) != phiRegs.end(); } + void insertPhiReg(Register reg, bool isDef = true) { + if (isDef) + phiRegs.insert(reg); + else + phiUseRegs.insert(reg); + } + bool isPhiReg(Register reg, bool isDef = true) + { return isDef ? (phiRegs.find(reg) != phiRegs.end()) + : (phiUseRegs.find(reg) != phiUseRegs.end()); } + template <bool isDef, typename T> + INLINE void foreachPhiReg(const T &functor) const { + for (auto reg : isDef ? phiRegs : phiUseRegs) functor(reg); + } private: friend class Function; //!< Owns the basic blocks BlockSet predecessors; //!< Incoming blocks @@ -90,7 +101,7 @@ namespace ir { BasicBlock *nextBlock; //!< Block allocated just after this one BasicBlock *prevBlock; //!< Block allocated just before this one Function &fn; //!< Function the block belongs to - set<Register> phiRegs; + set<Register> phiMovRegs, phiRegs; GBE_CLASS(BasicBlock); }; @@ -322,6 +333,7 @@ namespace ir { /*! Push stack size. */ INLINE void pushStackSize(uint32_t step) { this->stackSize += step; } private: + /*! Get block from its label */ friend class Context; //!< Can freely modify a function std::string name; //!< Function name const Unit &unit; //!< Function belongs to this unit |