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

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: Use non-anonymous structs so that array_lengthof works 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
« no previous file with comments | « src/IceOperand.h ('k') | src/IceTypes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceOperand.cpp
diff --git a/src/IceOperand.cpp b/src/IceOperand.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1009a33d2cb1664e57ce1de882d3eb11ef0b4d7b
--- /dev/null
+++ b/src/IceOperand.cpp
@@ -0,0 +1,91 @@
+//===- 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 {
+
+bool operator<(const RelocatableTuple &A, const RelocatableTuple &B) {
+ if (A.Offset != B.Offset)
+ return A.Offset < B.Offset;
+ if (A.SuppressMangling != B.SuppressMangling)
+ return A.SuppressMangling < B.SuppressMangling;
+ return A.Name < B.Name;
+}
+
+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(Cfg *Func) {
+ IsArgument = true;
+ if (DefNode == NULL)
+ return;
+ CfgNode *Entry = Func->getEntryNode();
+ if (DefNode == Entry)
+ return;
+ DefNode = NULL;
+}
+
+IceString Variable::getName() const {
+ if (!Name.empty())
+ return Name;
+ char buf[30];
+ snprintf(buf, llvm::array_lengthof(buf), "__%u", getIndex());
+ return buf;
+}
+
+// ======================== dump routines ======================== //
+
+void Variable::dump(const Cfg *Func) const {
+ Ostream &Str = Func->getContext()->getStrDump();
+ const CfgNode *CurrentNode = Func->getCurrentNode();
+ (void)CurrentNode; // used only in assert()
+ assert(CurrentNode == NULL || DefNode == NULL || DefNode == CurrentNode);
+ Str << "%" << getName();
+}
+
+void Operand::dump(const Cfg *Func) const {
+ Ostream &Str = Func->getContext()->getStrDump();
+ Str << "Operand<?>";
+}
+
+void ConstantRelocatable::dump(const Cfg *Func) const {
+ Ostream &Str = Func->getContext()->getStrDump();
+ Str << "@" << Name;
+ if (Offset)
+ Str << "+" << Offset;
+}
+
+} // end of namespace Ice
« no previous file with comments | « src/IceOperand.h ('k') | src/IceTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698