diff options
author | Zhigang Gong <zhigang.gong@gmail.com> | 2014-03-17 00:57:54 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@gmail.com> | 2014-03-17 00:57:54 +0800 |
commit | cbff5aa17d95269856445ca6ee90807ec5362e19 (patch) | |
tree | a32395724946765453db11bf2951b9e258350b57 /backend/src/ir/function.hpp | |
parent | 124e9905f908b19b5a3e0030d3917d2a39c9e6cd (diff) |
draft fix liveness.fixliveness
Signed-off-by: Zhigang Gong <zhigang.gong@gmail.com>
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 |