Index: src/IceOperand.cpp |
diff --git a/src/IceOperand.cpp b/src/IceOperand.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..10f7d45c24f38985fbe8104bdc6801a5834593f8 |
--- /dev/null |
+++ b/src/IceOperand.cpp |
@@ -0,0 +1,84 @@ |
+//===- subzero/src/IceOperand.cpp - High-level operand implementation -----===// |
+// |
+// The Subzero Code Generator |
+// |
+// This file is distributed under the University of Illinois Open Source |
+// License. See LICENSE.TXT for details. |
+// |
+//===----------------------------------------------------------------------===// |
+// |
+// This file implements the Operand class and its |
+// target-independent subclasses, primarily for the methods of the |
+// Variable class. |
+// |
+//===----------------------------------------------------------------------===// |
+ |
+#include "IceCfg.h" |
+#include "IceInst.h" |
+#include "IceOperand.h" |
+ |
+namespace Ice { |
+ |
+void Variable::setUse(const Inst *Inst, const CfgNode *Node) { |
+ if (DefNode == NULL) |
+ return; |
+ if (llvm::isa<InstPhi>(Inst) || Node != DefNode) |
+ DefNode = NULL; |
+} |
+ |
+void Variable::setDefinition(Inst *Inst, const CfgNode *Node) { |
+ if (DefNode == NULL) |
+ return; |
+ // Can first check preexisting DefInst if we care about multi-def vars. |
+ DefInst = Inst; |
+ if (Node != DefNode) |
+ DefNode = NULL; |
+} |
+ |
+void Variable::replaceDefinition(Inst *Inst, const CfgNode *Node) { |
+ DefInst = NULL; |
+ setDefinition(Inst, Node); |
+} |
+ |
+void Variable::setIsArg(IceCfg *Cfg) { |
+ IsArgument = true; |
+ if (DefNode == NULL) |
+ return; |
+ CfgNode *Entry = Cfg->getEntryNode(); |
+ if (DefNode == Entry) |
+ return; |
+ DefNode = NULL; |
+} |
+ |
+IceString Variable::getName() const { |
+ if (Name != "") |
+ return Name; |
+ const static size_t BufLen = 30; |
+ char buf[BufLen]; |
+ snprintf(buf, BufLen, "__%u", getIndex()); |
+ return buf; |
+} |
+ |
+// ======================== dump routines ======================== // |
+ |
+void Variable::dump(const IceCfg *Cfg) const { |
+ IceOstream &Str = Cfg->getContext()->getStrDump(); |
+ const CfgNode *CurrentNode = Cfg->getCurrentNode(); |
+ (void)CurrentNode; // used only in assert() |
+ assert(CurrentNode == NULL || DefNode == NULL || DefNode == CurrentNode); |
+ Str << "%" << getName(); |
+} |
+ |
+void Operand::dump(const IceCfg *Cfg) const { |
+ IceOstream &Str = Cfg->getContext()->getStrDump(); |
+ Str << "Operand<?>"; |
+} |
+ |
+void ConstantRelocatable::dump(const IceCfg *Cfg) const { |
+ IceOstream &Str = Cfg->getContext()->getStrDump(); |
+ Str << "@" << Name; |
+ if (Offset) |
+ Str << "+" << Offset; |
+} |
+ |
+} // end of namespace Ice |