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

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: Introduce IceGlobalContext, and rearrange other things around that Created 6 years, 8 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..01b2facfabfa613164893e7da65ebc5a085850a5
--- /dev/null
+++ b/src/IceOperand.cpp
@@ -0,0 +1,79 @@
+//===- 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());
JF 2014/04/16 01:27:32 snprintf
Jim Stichnoth 2014/04/21 20:26:40 Done.
+ return buf;
+}
+
+// ======================== dump routines ======================== //
+
+void IceVariable::dump(const IceCfg *Cfg) const {
+ IceOstream &Str = Cfg->getContext()->StrDump;
+ const IceCfgNode *CurrentNode = Cfg->getCurrentNode();
+ (void)CurrentNode; // used only in assert()
+ assert(CurrentNode == NULL || DefNode == NULL || DefNode == CurrentNode);
+ Str << "%" << getName();
+}
+
+void IceOperand::dump(const IceCfg *Cfg) const {
+ IceOstream &Str = Cfg->getContext()->StrDump;
+ Str << "IceOperand<?>";
+}
+
+void IceConstantRelocatable::dump(const IceCfg *Cfg) const {
+ IceOstream &Str = Cfg->getContext()->StrDump;
+ Str << "@" << Name;
+ if (Offset)
+ Str << "+" << Offset;
+}

Powered by Google App Engine
This is Rietveld 408576698