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

Side by Side Diff: src/IceCfg.cpp

Issue 802183004: Subzero: Use CFG-local arena allocation for relevant containers. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Typo fix Created 6 years 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
« no previous file with comments | « src/IceCfg.h ('k') | src/IceConverter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===// 1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements the Cfg class, including constant pool 10 // This file implements the Cfg class, including constant pool
11 // management. 11 // management.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include "IceCfg.h" 15 #include "IceCfg.h"
16 #include "IceCfgNode.h" 16 #include "IceCfgNode.h"
17 #include "IceClFlags.h" 17 #include "IceClFlags.h"
18 #include "IceDefs.h" 18 #include "IceDefs.h"
19 #include "IceInst.h" 19 #include "IceInst.h"
20 #include "IceLiveness.h" 20 #include "IceLiveness.h"
21 #include "IceOperand.h" 21 #include "IceOperand.h"
22 #include "IceTargetLowering.h" 22 #include "IceTargetLowering.h"
23 23
24 namespace Ice { 24 namespace Ice {
25 25
26 thread_local const Cfg *Cfg::CurrentCfg = NULL;
27
28 ArenaAllocator *getCurrentCfgAllocator() {
29 return Cfg::getCurrentCfgAllocator();
30 }
31
26 Cfg::Cfg(GlobalContext *Ctx) 32 Cfg::Cfg(GlobalContext *Ctx)
27 : Ctx(Ctx), FunctionName(""), ReturnType(IceType_void), 33 : Ctx(Ctx), FunctionName(""), ReturnType(IceType_void),
28 IsInternalLinkage(false), HasError(false), FocusedTiming(false), 34 IsInternalLinkage(false), HasError(false), FocusedTiming(false),
29 ErrorMessage(""), Entry(NULL), NextInstNumber(Inst::NumberInitial), 35 ErrorMessage(""), Entry(NULL), NextInstNumber(Inst::NumberInitial),
30 Live(nullptr), 36 Allocator(new ArenaAllocator()), Live(nullptr),
31 Target(TargetLowering::createLowering(Ctx->getTargetArch(), this)), 37 Target(TargetLowering::createLowering(Ctx->getTargetArch(), this)),
32 VMetadata(new VariablesMetadata(this)), 38 VMetadata(new VariablesMetadata(this)),
33 TargetAssembler( 39 TargetAssembler(
34 TargetLowering::createAssembler(Ctx->getTargetArch(), this)), 40 TargetLowering::createAssembler(Ctx->getTargetArch(), this)),
35 CurrentNode(NULL) { 41 CurrentNode(NULL) {
36 assert(!Ctx->isIRGenerationDisabled() && 42 assert(!Ctx->isIRGenerationDisabled() &&
37 "Attempt to build cfg when IR generation disabled"); 43 "Attempt to build cfg when IR generation disabled");
38 } 44 }
39 45
40 Cfg::~Cfg() {} 46 Cfg::~Cfg() {
47 // TODO(stichnot,kschimpf): Set CurrentCfg=NULL in the dtor for
48 // safety. This can't be done currently because the translator
49 // manages the Cfg by creating a new Cfg (which sets CurrentCfg to
50 // the new value), then deleting the old Cfg (which would then reset
51 // CurrentCfg to NULL).
52 }
41 53
42 void Cfg::setError(const IceString &Message) { 54 void Cfg::setError(const IceString &Message) {
43 HasError = true; 55 HasError = true;
44 ErrorMessage = Message; 56 ErrorMessage = Message;
45 Ctx->getStrDump() << "ICE translation error: " << ErrorMessage << "\n"; 57 Ctx->getStrDump() << "ICE translation error: " << ErrorMessage << "\n";
46 } 58 }
47 59
48 CfgNode *Cfg::makeNode() { 60 CfgNode *Cfg::makeNode() {
49 SizeT LabelIndex = Nodes.size(); 61 SizeT LabelIndex = Nodes.size();
50 CfgNode *Node = CfgNode::create(this, LabelIndex); 62 CfgNode *Node = CfgNode::create(this, LabelIndex);
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 } 521 }
510 } 522 }
511 // Print each basic block 523 // Print each basic block
512 for (CfgNode *Node : Nodes) 524 for (CfgNode *Node : Nodes)
513 Node->dump(this); 525 Node->dump(this);
514 if (getContext()->isVerbose(IceV_Instructions)) 526 if (getContext()->isVerbose(IceV_Instructions))
515 Str << "}\n"; 527 Str << "}\n";
516 } 528 }
517 529
518 } // end of namespace Ice 530 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfg.h ('k') | src/IceConverter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698