 Chromium Code Reviews
 Chromium Code Reviews Issue 205613002:
  Initial skeleton of Subzero.  (Closed) 
  Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
    
  
    Issue 205613002:
  Initial skeleton of Subzero.  (Closed) 
  Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master| 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 IceOperand class and its | |
| 11 // target-independent subclasses, primarily for the methods of the | |
| 12 // IceVariable class. | |
| 13 // | |
| 14 //===----------------------------------------------------------------------===// | |
| 15 | |
| 16 #include "IceCfg.h" | |
| 17 #include "IceInst.h" | |
| 18 #include "IceOperand.h" | |
| 19 | |
| 20 void IceVariable::setUse(const IceInst *Inst, const IceCfgNode *Node) { | |
| 21 if (DefNode == NULL) | |
| 22 return; | |
| 23 if (llvm::isa<IceInstPhi>(Inst) || Node != DefNode) | |
| 24 DefNode = NULL; | |
| 25 } | |
| 26 | |
| 27 void IceVariable::setDefinition(IceInst *Inst, const IceCfgNode *Node) { | |
| 28 if (DefNode == NULL) | |
| 29 return; | |
| 30 // Can first check preexisting DefInst if we care about multi-def vars. | |
| 31 DefInst = Inst; | |
| 32 if (Node != DefNode) | |
| 33 DefNode = NULL; | |
| 34 } | |
| 35 | |
| 36 void IceVariable::replaceDefinition(IceInst *Inst, const IceCfgNode *Node) { | |
| 37 DefInst = NULL; | |
| 38 setDefinition(Inst, Node); | |
| 39 } | |
| 40 | |
| 41 void IceVariable::setIsArg(IceCfg *Cfg) { | |
| 42 IsArgument = true; | |
| 43 if (DefNode == NULL) | |
| 44 return; | |
| 45 IceCfgNode *Entry = Cfg->getEntryNode(); | |
| 46 if (DefNode == Entry) | |
| 47 return; | |
| 48 DefNode = NULL; | |
| 49 } | |
| 50 | |
| 51 IceString IceVariable::getName() const { | |
| 52 if (Name != "") | |
| 53 return Name; | |
| 54 char buf[30]; | |
| 55 sprintf(buf, "__%u", getIndex()); | |
| 
JF
2014/04/16 01:27:32
snprintf
 
Jim Stichnoth
2014/04/21 20:26:40
Done.
 | |
| 56 return buf; | |
| 57 } | |
| 58 | |
| 59 // ======================== dump routines ======================== // | |
| 60 | |
| 61 void IceVariable::dump(const IceCfg *Cfg) const { | |
| 62 IceOstream &Str = Cfg->getContext()->StrDump; | |
| 63 const IceCfgNode *CurrentNode = Cfg->getCurrentNode(); | |
| 64 (void)CurrentNode; // used only in assert() | |
| 65 assert(CurrentNode == NULL || DefNode == NULL || DefNode == CurrentNode); | |
| 66 Str << "%" << getName(); | |
| 67 } | |
| 68 | |
| 69 void IceOperand::dump(const IceCfg *Cfg) const { | |
| 70 IceOstream &Str = Cfg->getContext()->StrDump; | |
| 71 Str << "IceOperand<?>"; | |
| 72 } | |
| 73 | |
| 74 void IceConstantRelocatable::dump(const IceCfg *Cfg) const { | |
| 75 IceOstream &Str = Cfg->getContext()->StrDump; | |
| 76 Str << "@" << Name; | |
| 77 if (Offset) | |
| 78 Str << "+" << Offset; | |
| 79 } | |
| OLD | NEW |