OLD | NEW |
(Empty) | |
| 1 //===- subzero/src/IceOperand.cpp - High-level operand implementation -----===// |
| 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 // This file implements the Operand class and its |
| 11 // target-independent subclasses, primarily for the methods of the |
| 12 // Variable class. |
| 13 // |
| 14 //===----------------------------------------------------------------------===// |
| 15 |
| 16 #include "IceCfg.h" |
| 17 #include "IceInst.h" |
| 18 #include "IceOperand.h" |
| 19 |
| 20 namespace Ice { |
| 21 |
| 22 void Variable::setUse(const Inst *Inst, const CfgNode *Node) { |
| 23 if (DefNode == NULL) |
| 24 return; |
| 25 if (llvm::isa<InstPhi>(Inst) || Node != DefNode) |
| 26 DefNode = NULL; |
| 27 } |
| 28 |
| 29 void Variable::setDefinition(Inst *Inst, const CfgNode *Node) { |
| 30 if (DefNode == NULL) |
| 31 return; |
| 32 // Can first check preexisting DefInst if we care about multi-def vars. |
| 33 DefInst = Inst; |
| 34 if (Node != DefNode) |
| 35 DefNode = NULL; |
| 36 } |
| 37 |
| 38 void Variable::replaceDefinition(Inst *Inst, const CfgNode *Node) { |
| 39 DefInst = NULL; |
| 40 setDefinition(Inst, Node); |
| 41 } |
| 42 |
| 43 void Variable::setIsArg(IceCfg *Cfg) { |
| 44 IsArgument = true; |
| 45 if (DefNode == NULL) |
| 46 return; |
| 47 CfgNode *Entry = Cfg->getEntryNode(); |
| 48 if (DefNode == Entry) |
| 49 return; |
| 50 DefNode = NULL; |
| 51 } |
| 52 |
| 53 IceString Variable::getName() const { |
| 54 if (Name != "") |
| 55 return Name; |
| 56 const static size_t BufLen = 30; |
| 57 char buf[BufLen]; |
| 58 snprintf(buf, BufLen, "__%u", getIndex()); |
| 59 return buf; |
| 60 } |
| 61 |
| 62 // ======================== dump routines ======================== // |
| 63 |
| 64 void Variable::dump(const IceCfg *Cfg) const { |
| 65 IceOstream &Str = Cfg->getContext()->getStrDump(); |
| 66 const CfgNode *CurrentNode = Cfg->getCurrentNode(); |
| 67 (void)CurrentNode; // used only in assert() |
| 68 assert(CurrentNode == NULL || DefNode == NULL || DefNode == CurrentNode); |
| 69 Str << "%" << getName(); |
| 70 } |
| 71 |
| 72 void Operand::dump(const IceCfg *Cfg) const { |
| 73 IceOstream &Str = Cfg->getContext()->getStrDump(); |
| 74 Str << "Operand<?>"; |
| 75 } |
| 76 |
| 77 void ConstantRelocatable::dump(const IceCfg *Cfg) const { |
| 78 IceOstream &Str = Cfg->getContext()->getStrDump(); |
| 79 Str << "@" << Name; |
| 80 if (Offset) |
| 81 Str << "+" << Offset; |
| 82 } |
| 83 |
| 84 } // end of namespace Ice |
OLD | NEW |