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

Side by Side Diff: src/IceCfg.cpp

Issue 205613002: Initial skeleton of Subzero. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Fix omissions from previous patchset. 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 unified diff | Download patch
OLDNEW
(Empty)
1 //===- subzero/src/IceCfg.cpp - Control flow graph 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 IceCfg class, including constant pool
11 // management.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "IceCfg.h"
16 #include "IceCfgNode.h"
17 #include "IceDefs.h"
18 #include "IceInst.h"
19 #include "IceOperand.h"
20
21 namespace Ice {
22
23 IceCfg::IceCfg(GlobalContext *Ctx)
24 : Ctx(Ctx), FunctionName(""), ReturnType(IceType_void),
25 IsInternalLinkage(false), HasError(false), ErrorMessage(""), Entry(NULL),
26 NextInstNumber(1), CurrentNode(NULL) {}
27
28 IceCfg::~IceCfg() {}
29
30 void IceCfg::setError(const IceString &Message) {
31 HasError = true;
32 ErrorMessage = Message;
33 Ctx->getStrDump() << "ICE translation error: " << ErrorMessage << "\n";
34 }
35
36 CfgNode *IceCfg::makeNode(const IceString &Name) {
37 IceSize_t LabelIndex = Nodes.size();
38 CfgNode *Node = CfgNode::create(this, LabelIndex, Name);
39 Nodes.push_back(Node);
40 return Node;
41 }
42
43 // Create a new Variable with a particular type and an optional
44 // name. The Node argument is the node where the variable is defined.
JF 2014/04/23 03:51:28 Silly comment... Two spaces after a period? You kn
Jim Stichnoth 2014/04/26 15:02:11 Two spaces is how I always write prose... maybe fi
45 Variable *IceCfg::makeVariable(IceType Type, const CfgNode *Node,
46 const IceString &Name) {
47 IceSize_t Index = Variables.size();
48 Variables.push_back(Variable::create(this, Type, Node, Index, Name));
49 return Variables[Index];
50 }
51
52 void IceCfg::addArg(Variable *Arg) {
53 Arg->setIsArg(this);
54 Args.push_back(Arg);
55 }
56
57 void IceCfg::computePredecessors() {
58 for (NodeList::iterator I = Nodes.begin(), E = Nodes.end(); I != E; ++I) {
59 (*I)->computePredecessors();
60 }
61 }
62
63 // ======================== Dump routines ======================== //
64
65 void IceCfg::dump() {
66 IceOstream &Str = Ctx->getStrDump();
67 setCurrentNode(getEntryNode());
68 // Print function name+args
69 if (getContext()->isVerbose(IceV_Instructions)) {
70 Str << "define ";
71 if (getInternal())
72 Str << "internal ";
73 Str << ReturnType << " @" << getFunctionName() << "(";
74 for (IceSize_t i = 0; i < Args.size(); ++i) {
75 if (i > 0)
76 Str << ", ";
77 Str << Args[i]->getType() << " ";
78 Args[i]->dump(this);
79 }
80 Str << ") {\n";
81 }
82 setCurrentNode(NULL);
83 // Print each basic block
84 for (NodeList::const_iterator I = Nodes.begin(), E = Nodes.end(); I != E;
85 ++I) {
86 (*I)->dump(this);
87 }
88 if (getContext()->isVerbose(IceV_Instructions)) {
89 Str << "}\n";
90 }
91 }
92
93 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfg.h ('k') | src/IceCfgNode.h » ('j') | src/IceCfgNode.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698