Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1294)

Unified Diff: src/IceOperand.cpp

Issue 205613002: Initial skeleton of Subzero. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Address Jan's latest comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceOperand.cpp
diff --git a/src/IceOperand.cpp b/src/IceOperand.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..38cd21b6db37361965c8e31e68a8e1a1eb492f15
--- /dev/null
+++ b/src/IceOperand.cpp
@@ -0,0 +1,82 @@
+//===- 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 IceOperand class and its
+// target-independent subclasses, primarily for the methods of the
+// IceVariable class.
+//
+//===----------------------------------------------------------------------===//
+
+#include "IceCfg.h"
+#include "IceInst.h"
+#include "IceOperand.h"
+
+void IceVariable::setUse(const IceInst *Inst, const IceCfgNode *Node) {
+ if (DefNode == NULL)
+ return;
+ if (llvm::isa<IceInstPhi>(Inst) || Node != DefNode)
+ DefNode = NULL;
+}
+
+void IceVariable::setDefinition(IceInst *Inst, const IceCfgNode *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 IceVariable::replaceDefinition(IceInst *Inst, const IceCfgNode *Node) {
+ DefInst = NULL;
+ setDefinition(Inst, Node);
+}
+
+void IceVariable::setIsArg(IceCfg *Cfg) {
+ IsArgument = true;
+ if (DefNode == NULL)
+ return;
+ IceCfgNode *Entry = Cfg->getEntryNode();
+ if (DefNode == Entry)
+ return;
+ DefNode = NULL;
+}
+
+IceString IceVariable::getName() const {
+ if (Name != "")
+ return Name;
+ char buf[30];
+ sprintf(buf, "__%u", getIndex());
+ return buf;
+}
+
+// ======================== dump routines ======================== //
+
+IceOstream &operator<<(IceOstream &Str, const IceOperand *O) {
+ if (O)
+ O->dump(Str);
+ else
+ Str << "<NULL>";
+ return Str;
+}
+
+void IceVariable::dump(IceOstream &Str) const {
+ const IceCfgNode *CurrentNode = Str.getCurrentNode();
+ (void)CurrentNode; // used only in assert()
+ assert(CurrentNode == NULL || DefNode == NULL || DefNode == CurrentNode);
+ Str << "%" << getName();
+}
+
+void IceOperand::dump(IceOstream &Str) const { Str << "IceOperand<?>"; }
+
+void IceConstantRelocatable::dump(IceOstream &Str) const {
+ Str << "@" << Name;
+ if (Offset)
+ Str << "+" << Offset;
+}

Powered by Google App Engine
This is Rietveld 408576698