OLD | NEW |
(Empty) | |
| 1 //===------ subzero/src/IcePhiLoweringImpl.h - Phi lowering -----*- C++ -*-===// |
| 2 // |
| 3 // The Subzero Code Generator |
| 4 // |
| 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. |
| 7 // |
| 8 //===----------------------------------------------------------------------===// |
| 9 /// |
| 10 /// \file |
| 11 /// This contains utilities for targets to lower Phis. |
| 12 /// |
| 13 //===----------------------------------------------------------------------===// |
| 14 |
| 15 #ifndef SUBZERO_SRC_ICEPHILOWERINGIMPL_H |
| 16 #define SUBZERO_SRC_ICEPHILOWERINGIMPL_H |
| 17 |
| 18 #include "IceCfg.h" |
| 19 #include "IceCfgNode.h" |
| 20 #include "IceDefs.h" |
| 21 #include "IceInst.h" |
| 22 #include "IceOperand.h" |
| 23 |
| 24 namespace Ice { |
| 25 namespace PhiLowering { |
| 26 |
| 27 // Turn an i64 Phi instruction into a pair of i32 Phi instructions, to |
| 28 // preserve integrity of liveness analysis. This is needed for 32-bit |
| 29 // targets. This assumes the 32-bit target has loOperand, hiOperand, |
| 30 // and legalizeUndef methods. Undef values are also legalized, since |
| 31 // loOperand() and hiOperand() don't expect Undef input. |
| 32 template <class TargetT> |
| 33 void prelowerPhis32Bit(TargetT *Target, CfgNode *Node, Cfg *Func) { |
| 34 for (Inst &I : Node->getPhis()) { |
| 35 auto Phi = llvm::dyn_cast<InstPhi>(&I); |
| 36 if (Phi->isDeleted()) |
| 37 continue; |
| 38 Variable *Dest = Phi->getDest(); |
| 39 if (Dest->getType() == IceType_i64) { |
| 40 Variable *DestLo = llvm::cast<Variable>(Target->loOperand(Dest)); |
| 41 Variable *DestHi = llvm::cast<Variable>(Target->hiOperand(Dest)); |
| 42 InstPhi *PhiLo = InstPhi::create(Func, Phi->getSrcSize(), DestLo); |
| 43 InstPhi *PhiHi = InstPhi::create(Func, Phi->getSrcSize(), DestHi); |
| 44 for (SizeT I = 0; I < Phi->getSrcSize(); ++I) { |
| 45 Operand *Src = Phi->getSrc(I); |
| 46 CfgNode *Label = Phi->getLabel(I); |
| 47 Src = Target->legalizeUndef(Src); |
| 48 PhiLo->addArgument(Target->loOperand(Src), Label); |
| 49 PhiHi->addArgument(Target->hiOperand(Src), Label); |
| 50 } |
| 51 Node->getPhis().push_back(PhiLo); |
| 52 Node->getPhis().push_back(PhiHi); |
| 53 Phi->setDeleted(); |
| 54 } |
| 55 } |
| 56 } |
| 57 |
| 58 } // end of namespace PhiLowering |
| 59 } // end of namespace Ice |
| 60 |
| 61 #endif // SUBZERO_SRC_ICEPHILOWERINGIMPL_H |
OLD | NEW |