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

Side by Side Diff: 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: 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 unified diff | Download patch
« IceCfg.h ('K') | « IceOperand.h ('k') | IceTypes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* Copyright 2014 The Native Client Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can
3 * be found in the LICENSE file.
4 */
5
6 #include "IceCfg.h"
7 #include "IceInst.h"
8 #include "IceOperand.h"
9
10 void IceVariable::setUse(const IceInst *Inst, const IceCfgNode *Node) {
11 if (DefNode == NULL)
12 return;
13 if (llvm::isa<IceInstPhi>(Inst) || Node != DefNode)
14 DefNode = NULL;
15 }
16
17 void IceVariable::setDefinition(IceInst *Inst, const IceCfgNode *Node) {
18 if (DefNode == NULL)
19 return;
20 // Can first check preexisting DefInst if we care about multi-def vars.
21 DefInst = Inst;
22 if (Node != DefNode)
23 DefNode = NULL;
24 }
25
26 void IceVariable::replaceDefinition(IceInst *Inst, const IceCfgNode *Node) {
27 DefInst = NULL;
28 setDefinition(Inst, Node);
29 }
30
31 void IceVariable::setIsArg(IceCfg *Cfg) {
32 IsArgument = true;
33 if (DefNode == NULL)
34 return;
35 IceCfgNode *Entry = Cfg->getEntryNode();
36 if (DefNode == Entry)
37 return;
38 DefNode = NULL;
39 }
40
41 IceString IceVariable::getName(void) const {
42 if (Name != "")
43 return Name;
44 char buf[30];
45 sprintf(buf, "__%u", getIndex());
46 return buf;
47 }
48
49 // ======================== dump routines ======================== //
50
51 IceOstream &operator<<(IceOstream &Str, const IceOperand *O) {
52 if (O)
53 O->dump(Str);
54 else
55 Str << "<NULL>";
56 return Str;
57 }
58
59 void IceVariable::dump(IceOstream &Str) const {
60 const IceCfgNode *CurrentNode = Str.getCurrentNode();
61 (void)CurrentNode;
62 assert(CurrentNode == NULL || DefNode == NULL || DefNode == CurrentNode);
63 Str << "%" << getName();
64 }
65
66 void IceOperand::dump(IceOstream &Str) const { Str << "IceOperand<?>"; }
67
68 void IceConstantRelocatable::dump(IceOstream &Str) const {
69 Str << "@" << Name;
70 if (Offset)
71 Str << "+" << Offset;
72 }
OLDNEW
« IceCfg.h ('K') | « IceOperand.h ('k') | IceTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698