blob: c656961ed74a4daf3a631d5b37ce13c097ffc763 [file] [log] [blame]
Jim Stichnothf7c9a142014-04-29 10:52:43 -07001//===- subzero/src/IceCfg.h - Control flow graph ----------------*- C++ -*-===//
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//===----------------------------------------------------------------------===//
Andrew Scull9612d322015-07-06 14:53:25 -07009///
10/// \file
Jim Stichnoth92a6e5b2015-12-02 16:52:44 -080011/// \brief Declares the Cfg class, which represents the control flow graph and
12/// the overall per-function compilation context.
Andrew Scull9612d322015-07-06 14:53:25 -070013///
Jim Stichnothf7c9a142014-04-29 10:52:43 -070014//===----------------------------------------------------------------------===//
15
16#ifndef SUBZERO_SRC_ICECFG_H
17#define SUBZERO_SRC_ICECFG_H
18
John Portoaff4ccf2015-06-10 16:35:06 -070019#include "IceAssembler.h"
Jan Voung8acded02014-09-22 18:02:25 -070020#include "IceClFlags.h"
Jim Stichnotha18cc9c2014-09-30 19:10:22 -070021#include "IceDefs.h"
Jim Stichnothf7c9a142014-04-29 10:52:43 -070022#include "IceGlobalContext.h"
Jim Stichnoth467ffe52016-03-29 15:01:06 -070023#include "IceStringPool.h"
Jim Stichnotha18cc9c2014-09-30 19:10:22 -070024#include "IceTypes.h"
Jim Stichnothf7c9a142014-04-29 10:52:43 -070025
26namespace Ice {
27
28class Cfg {
Jim Stichnothc6ead202015-02-24 09:30:30 -080029 Cfg() = delete;
Jim Stichnoth7b451a92014-10-15 14:39:23 -070030 Cfg(const Cfg &) = delete;
31 Cfg &operator=(const Cfg &) = delete;
32
Jim Stichnothf7c9a142014-04-29 10:52:43 -070033public:
Jim Stichnothf7c9a142014-04-29 10:52:43 -070034 ~Cfg();
35
Jim Stichnothbbca7542015-02-11 16:08:31 -080036 static std::unique_ptr<Cfg> create(GlobalContext *Ctx,
37 uint32_t SequenceNumber) {
38 return std::unique_ptr<Cfg>(new Cfg(Ctx, SequenceNumber));
Jim Stichnoth31c95592014-12-19 12:51:35 -080039 }
Jim Stichnoth31c95592014-12-19 12:51:35 -080040
Jim Stichnothf7c9a142014-04-29 10:52:43 -070041 GlobalContext *getContext() const { return Ctx; }
Jim Stichnothbbca7542015-02-11 16:08:31 -080042 uint32_t getSequenceNumber() const { return SequenceNumber; }
Jim Stichnothdd6dcfa2016-04-18 12:52:09 -070043 OptLevel getOptLevel() const { return OptimizationLevel; }
Jim Stichnothf7c9a142014-04-29 10:52:43 -070044
Jim Stichnotha5229652015-11-12 10:25:21 -080045 static constexpr VerboseMask defaultVerboseMask() {
Jim Stichnoth9f9aa2c2016-03-07 08:25:24 -080046 return (IceV_NO_PER_PASS_DUMP_BEYOND << 1) - 1;
Jim Stichnotha5229652015-11-12 10:25:21 -080047 }
Andrew Scull57e12682015-09-16 11:30:19 -070048 /// Returns true if any of the specified options in the verbose mask are set.
49 /// If the argument is omitted, it checks if any verbose options at all are
50 /// set.
Jim Stichnotha5229652015-11-12 10:25:21 -080051 bool isVerbose(VerboseMask Mask = defaultVerboseMask()) const {
52 return VMask & Mask;
53 }
Jim Stichnothfa4efea2015-01-27 05:06:03 -080054 void setVerbose(VerboseMask Mask) { VMask = Mask; }
55
Andrew Scull9612d322015-07-06 14:53:25 -070056 /// \name Manage the name and return type of the function being translated.
57 /// @{
Jim Stichnoth467ffe52016-03-29 15:01:06 -070058 void setFunctionName(GlobalString Name) { FunctionName = Name; }
59 GlobalString getFunctionName() const { return FunctionName; }
60 std::string getFunctionNameAndSize() const;
Jim Stichnothf7c9a142014-04-29 10:52:43 -070061 void setReturnType(Type Ty) { ReturnType = Ty; }
David Sehr0d9cf482015-11-16 17:00:38 -080062 Type getReturnType() const { return ReturnType; }
Andrew Scull9612d322015-07-06 14:53:25 -070063 /// @}
Jim Stichnothf7c9a142014-04-29 10:52:43 -070064
Andrew Scull9612d322015-07-06 14:53:25 -070065 /// \name Manage the "internal" attribute of the function.
66 /// @{
Jim Stichnothf7c9a142014-04-29 10:52:43 -070067 void setInternal(bool Internal) { IsInternalLinkage = Internal; }
68 bool getInternal() const { return IsInternalLinkage; }
Andrew Scull9612d322015-07-06 14:53:25 -070069 /// @}
Jim Stichnothf7c9a142014-04-29 10:52:43 -070070
Andrew Scull9612d322015-07-06 14:53:25 -070071 /// \name Manage errors.
72 /// @{
73
Andrew Scull57e12682015-09-16 11:30:19 -070074 /// Translation error flagging. If support for some construct is known to be
75 /// missing, instead of an assertion failure, setError() should be called and
76 /// the error should be propagated back up. This way, we can gracefully fail
77 /// to translate and let a fallback translator handle the function.
Jim Stichnoth467ffe52016-03-29 15:01:06 -070078 void setError(const std::string &Message);
Jim Stichnothf7c9a142014-04-29 10:52:43 -070079 bool hasError() const { return HasError; }
Jim Stichnoth467ffe52016-03-29 15:01:06 -070080 std::string getError() const { return ErrorMessage; }
Andrew Scull9612d322015-07-06 14:53:25 -070081 /// @}
Jim Stichnothf7c9a142014-04-29 10:52:43 -070082
Andrew Scull9612d322015-07-06 14:53:25 -070083 /// \name Manage nodes (a.k.a. basic blocks, CfgNodes).
84 /// @{
Jim Stichnothf7c9a142014-04-29 10:52:43 -070085 void setEntryNode(CfgNode *EntryNode) { Entry = EntryNode; }
86 CfgNode *getEntryNode() const { return Entry; }
Andrew Scullaa6c1092015-09-03 17:50:30 -070087 /// Create a node and append it to the end of the linearized list. The loop
88 /// nest depth of the new node may not be valid if it is created after
89 /// computeLoopNestDepth.
Jim Stichnoth668a7a32014-12-10 15:32:25 -080090 CfgNode *makeNode();
Jim Stichnothf7c9a142014-04-29 10:52:43 -070091 SizeT getNumNodes() const { return Nodes.size(); }
92 const NodeList &getNodes() const { return Nodes; }
Jim Stichnothe7dbc0b2015-09-15 10:09:24 -070093 /// Swap nodes of Cfg with given list of nodes. The number of nodes must
94 /// remain unchanged.
Karl Schimpfac7d7342015-08-06 12:55:23 -070095 void swapNodes(NodeList &NewNodes);
Andrew Scull9612d322015-07-06 14:53:25 -070096 /// @}
Jim Stichnoth9a04c072014-12-11 15:51:42 -080097
Jim Stichnoth467ffe52016-03-29 15:01:06 -070098 /// String pool for CfgNode::Name values.
99 StringPool *getNodeStrings() const { return NodeStrings.get(); }
100 /// String pool for Variable::Name values.
101 StringPool *getVarStrings() const { return VarStrings.get(); }
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700102
Andrew Scull9612d322015-07-06 14:53:25 -0700103 /// \name Manage instruction numbering.
104 /// @{
Jim Stichnothd97c7df2014-06-04 11:57:08 -0700105 InstNumberT newInstNumber() { return NextInstNumber++; }
Jim Stichnoth47752552014-10-13 17:15:08 -0700106 InstNumberT getNextInstNumber() const { return NextInstNumber; }
Andrew Scull9612d322015-07-06 14:53:25 -0700107 /// @}
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700108
Andrew Scull9612d322015-07-06 14:53:25 -0700109 /// \name Manage Variables.
110 /// @{
111
Andrew Scull57e12682015-09-16 11:30:19 -0700112 /// Create a new Variable with a particular type and an optional name. The
113 /// Node argument is the node where the variable is defined.
Jan Voung28068ad2015-07-31 12:58:46 -0700114 // TODO(jpp): untemplate this with separate methods: makeVariable,
115 // makeSpillVariable, and makeStackVariable.
Jim Stichnoth9a04c072014-12-11 15:51:42 -0800116 template <typename T = Variable> T *makeVariable(Type Ty) {
Jim Stichnoth800dab22014-09-20 12:25:02 -0700117 SizeT Index = Variables.size();
Jim Stichnoth54f3d512015-12-11 09:53:00 -0800118 auto *Var = T::create(this, Ty, Index);
Jim Stichnoth800dab22014-09-20 12:25:02 -0700119 Variables.push_back(Var);
120 return Var;
121 }
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700122 SizeT getNumVariables() const { return Variables.size(); }
123 const VarList &getVariables() const { return Variables; }
Andrew Scull9612d322015-07-06 14:53:25 -0700124 /// @}
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700125
Andrew Scull9612d322015-07-06 14:53:25 -0700126 /// \name Manage arguments to the function.
127 /// @{
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700128 void addArg(Variable *Arg);
129 const VarList &getArgs() const { return Args; }
Matt Wala45a06232014-07-09 16:33:22 -0700130 VarList &getArgs() { return Args; }
Jim Stichnoth144cdce2014-09-22 16:02:59 -0700131 void addImplicitArg(Variable *Arg);
132 const VarList &getImplicitArgs() const { return ImplicitArgs; }
Andrew Scull9612d322015-07-06 14:53:25 -0700133 /// @}
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700134
Andrew Scull86df4e92015-07-30 13:54:44 -0700135 /// \name Manage the jump tables.
136 /// @{
137 void addJumpTable(InstJumpTable *JumpTable) {
138 JumpTables.emplace_back(JumpTable);
139 }
140 /// @}
141
John Portodc619252016-02-10 15:57:16 -0800142 /// \name Manage the Globals used by this function.
143 /// @{
144 std::unique_ptr<VariableDeclarationList> getGlobalInits() {
145 return std::move(GlobalInits);
146 }
147 void addGlobal(VariableDeclaration *Global) {
148 if (GlobalInits == nullptr) {
149 GlobalInits.reset(new VariableDeclarationList);
150 }
151 GlobalInits->push_back(Global);
152 }
John Portoa78e4ba2016-03-15 09:28:04 -0700153 VariableDeclarationList *getGlobalPool() {
154 if (GlobalInits == nullptr) {
155 GlobalInits.reset(new VariableDeclarationList);
156 }
157 return GlobalInits.get();
158 }
John Portodc619252016-02-10 15:57:16 -0800159 /// @}
160
Andrew Scull9612d322015-07-06 14:53:25 -0700161 /// \name Miscellaneous accessors.
162 /// @{
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700163 TargetLowering *getTarget() const { return Target.get(); }
Jim Stichnoth144cdce2014-09-22 16:02:59 -0700164 VariablesMetadata *getVMetadata() const { return VMetadata.get(); }
Jim Stichnothd97c7df2014-06-04 11:57:08 -0700165 Liveness *getLiveness() const { return Live.get(); }
Jim Stichnothbbca7542015-02-11 16:08:31 -0800166 template <typename T = Assembler> T *getAssembler() const {
John Porto2da710c2015-06-29 07:57:02 -0700167 return llvm::dyn_cast<T>(TargetAssembler.get());
Jan Voung8acded02014-09-22 18:02:25 -0700168 }
John Portobd2e2312016-03-15 11:06:25 -0700169 std::unique_ptr<Assembler> releaseAssembler() {
170 return std::move(TargetAssembler);
171 }
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700172 bool hasComputedFrame() const;
Jim Stichnoth8363a062014-10-07 10:02:38 -0700173 bool getFocusedTiming() const { return FocusedTiming; }
174 void setFocusedTiming() { FocusedTiming = true; }
Qining Luaee5fa82015-08-20 14:59:03 -0700175 uint32_t getConstantBlindingCookie() const { return ConstantBlindingCookie; }
Andrew Scull9612d322015-07-06 14:53:25 -0700176 /// @}
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700177
Andrew Scull9612d322015-07-06 14:53:25 -0700178 /// Returns true if Var is a global variable that is used by the profiling
179 /// code.
John Portof8b4cc82015-06-09 18:06:19 -0700180 static bool isProfileGlobal(const VariableDeclaration &Var);
181
Andrew Scull9612d322015-07-06 14:53:25 -0700182 /// Passes over the CFG.
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700183 void translate();
Andrew Scull57e12682015-09-16 11:30:19 -0700184 /// After the CFG is fully constructed, iterate over the nodes and compute the
185 /// predecessor and successor edges, in the form of CfgNode::InEdges[] and
186 /// CfgNode::OutEdges[].
Jim Stichnoth69d3f9c2015-03-23 10:33:38 -0700187 void computeInOutEdges();
Jim Stichnoth76719b42016-03-14 08:37:52 -0700188 /// Renumber the non-deleted instructions in the Cfg. This needs to be done
189 /// in preparation for live range analysis. The instruction numbers in a
190 /// block must be monotonically increasing. The range of instruction numbers
191 /// in a block, from lowest to highest, must not overlap with the range of any
192 /// other block.
193 ///
194 /// Also, if the configuration specifies to do so, remove/unlink all deleted
195 /// instructions from the Cfg, to speed up later passes over the instructions.
Jim Stichnothd97c7df2014-06-04 11:57:08 -0700196 void renumberInstructions();
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700197 void placePhiLoads();
198 void placePhiStores();
199 void deletePhis();
Jim Stichnoth336f6c42014-10-30 15:01:31 -0700200 void advancedPhiLowering();
201 void reorderNodes();
Qining Lu969f6a32015-07-31 09:58:34 -0700202 void shuffleNodes();
Manasij Mukherjee032c3152016-05-24 14:25:04 -0700203 void localCSE();
David Sehr4318a412015-11-11 15:01:55 -0800204
David Sehr4318a412015-11-11 15:01:55 -0800205 /// Scan allocas to determine whether we need to use a frame pointer.
206 /// If SortAndCombine == true, merge all the fixed-size allocas in the
207 /// entry block and emit stack or frame pointer-relative addressing.
208 void processAllocas(bool SortAndCombine);
Jim Stichnothd97c7df2014-06-04 11:57:08 -0700209 void doAddressOpt();
John Portoa47c11c2016-04-21 05:53:42 -0700210 /// Find clusters of insertelement/extractelement instructions that can be
211 /// replaced by a shufflevector instruction.
212 void materializeVectorShuffles();
Matt Wala45a06232014-07-09 16:33:22 -0700213 void doArgLowering();
Matt Walac3302742014-08-15 16:21:56 -0700214 void doNopInsertion();
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700215 void genCode();
216 void genFrame();
Andrew Scullaa6c1092015-09-03 17:50:30 -0700217 void computeLoopNestDepth();
Jim Stichnothd97c7df2014-06-04 11:57:08 -0700218 void livenessLightweight();
219 void liveness(LivenessMode Mode);
220 bool validateLiveness() const;
Jim Stichnoth336f6c42014-10-30 15:01:31 -0700221 void contractEmptyNodes();
Jim Stichnothff9c7062014-09-18 04:50:49 -0700222 void doBranchOpt();
Andrew Scull86df4e92015-07-30 13:54:44 -0700223 void markNodesForSandboxing();
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700224
Andrew Scull9612d322015-07-06 14:53:25 -0700225 /// \name Manage the CurrentNode field.
226 /// CurrentNode is used for validating the Variable::DefNode field during
227 /// dumping/emitting.
228 /// @{
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700229 void setCurrentNode(const CfgNode *Node) { CurrentNode = Node; }
Jim Stichnothae953202014-12-20 06:17:49 -0800230 void resetCurrentNode() { setCurrentNode(nullptr); }
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700231 const CfgNode *getCurrentNode() const { return CurrentNode; }
Andrew Scull9612d322015-07-06 14:53:25 -0700232 /// @}
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700233
John Portoa3984a12016-04-01 11:14:30 -0700234 /// Get the total amount of memory held by the per-Cfg allocator.
235 size_t getTotalMemoryMB() const;
236
237 /// Get the current memory usage due to liveness data structures.
238 size_t getLivenessMemoryMB() const;
Jim Stichnoth1bdb7352016-02-29 16:58:15 -0800239
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700240 void emit();
Jan Voung0faec4c2014-11-05 17:29:56 -0800241 void emitIAS();
Jim Stichnoth467ffe52016-03-29 15:01:06 -0700242 static void emitTextHeader(GlobalString Name, GlobalContext *Ctx,
Jim Stichnothbbca7542015-02-11 16:08:31 -0800243 const Assembler *Asm);
Jim Stichnothb88d8c82016-03-11 15:33:00 -0800244 void dump(const char *Message = "");
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700245
Andrew Scull9612d322015-07-06 14:53:25 -0700246 /// Allocate data of type T using the per-Cfg allocator.
Jim Stichnoth31c95592014-12-19 12:51:35 -0800247 template <typename T> T *allocate() { return Allocator->Allocate<T>(); }
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700248
Andrew Scull9612d322015-07-06 14:53:25 -0700249 /// Allocate an array of data of type T using the per-Cfg allocator.
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700250 template <typename T> T *allocateArrayOf(size_t NumElems) {
Jim Stichnoth31c95592014-12-19 12:51:35 -0800251 return Allocator->Allocate<T>(NumElems);
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700252 }
253
Andrew Scull9612d322015-07-06 14:53:25 -0700254 /// Deallocate data that was allocated via allocate<T>().
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700255 template <typename T> void deallocate(T *Object) {
Jim Stichnoth31c95592014-12-19 12:51:35 -0800256 Allocator->Deallocate(Object);
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700257 }
258
Andrew Scull9612d322015-07-06 14:53:25 -0700259 /// Deallocate data that was allocated via allocateArrayOf<T>().
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700260 template <typename T> void deallocateArrayOf(T *Array) {
Jim Stichnoth31c95592014-12-19 12:51:35 -0800261 Allocator->Deallocate(Array);
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700262 }
263
Eric Holk16f80612016-04-04 17:07:42 -0700264 /// Update Phi labels with InEdges.
265 ///
266 /// The WASM translator cannot always determine the right incoming edge for a
267 /// value due to the CFG being built incrementally. The fixPhiNodes pass fills
268 /// in the correct information once everything is known.
269 void fixPhiNodes();
270
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700271private:
John Portoe82b5602016-02-24 15:58:55 -0800272 friend class CfgAllocatorTraits; // for Allocator access.
273
Jim Stichnothbbca7542015-02-11 16:08:31 -0800274 Cfg(GlobalContext *Ctx, uint32_t SequenceNumber);
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700275
Andrew Scull9612d322015-07-06 14:53:25 -0700276 /// Adds a call to the ProfileSummary runtime function as the first
277 /// instruction in this CFG's entry block.
John Portof8b4cc82015-06-09 18:06:19 -0700278 void addCallToProfileSummary();
279
Andrew Scull9612d322015-07-06 14:53:25 -0700280 /// Iterates over the basic blocks in this CFG, adding profiling code to each
281 /// one of them. It returns a list with all the globals that the profiling
282 /// code needs to be defined.
John Portof8b4cc82015-06-09 18:06:19 -0700283 void profileBlocks();
284
Jim Stichnoth467ffe52016-03-29 15:01:06 -0700285 void createNodeNameDeclaration(const std::string &NodeAsmName);
John Portoa78e4ba2016-03-15 09:28:04 -0700286 void
Jim Stichnoth467ffe52016-03-29 15:01:06 -0700287 createBlockProfilingInfoDeclaration(const std::string &NodeAsmName,
John Portoa78e4ba2016-03-15 09:28:04 -0700288 VariableDeclaration *NodeNameDeclaration);
289
Andrew Scull86df4e92015-07-30 13:54:44 -0700290 /// Iterate through the registered jump tables and emit them.
291 void emitJumpTables();
292
Jim Stichnoth3607b6c2015-11-13 14:28:23 -0800293 enum AllocaBaseVariableType {
294 BVT_StackPointer,
295 BVT_FramePointer,
296 BVT_UserPointer
297 };
Thomas Lively1fd80c72016-06-27 14:47:21 -0700298 void sortAndCombineAllocas(CfgVector<InstAlloca *> &Allocas,
Jim Stichnoth3607b6c2015-11-13 14:28:23 -0800299 uint32_t CombinedAlignment, InstList &Insts,
300 AllocaBaseVariableType BaseVariableType);
301 void findRematerializable();
302
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700303 GlobalContext *Ctx;
Jim Stichnothdd6dcfa2016-04-18 12:52:09 -0700304 uint32_t SequenceNumber; /// output order for emission
305 OptLevel OptimizationLevel = Opt_m1;
Qining Luaee5fa82015-08-20 14:59:03 -0700306 uint32_t ConstantBlindingCookie = 0; /// cookie for constant blinding
Jim Stichnothfa4efea2015-01-27 05:06:03 -0800307 VerboseMask VMask;
Jim Stichnoth467ffe52016-03-29 15:01:06 -0700308 GlobalString FunctionName;
Jim Stichnotheafb56c2015-06-22 10:35:22 -0700309 Type ReturnType = IceType_void;
310 bool IsInternalLinkage = false;
311 bool HasError = false;
312 bool FocusedTiming = false;
Jim Stichnoth467ffe52016-03-29 15:01:06 -0700313 std::string ErrorMessage = "";
Andrew Scull9612d322015-07-06 14:53:25 -0700314 CfgNode *Entry = nullptr; /// entry basic block
315 NodeList Nodes; /// linearized node list; Entry should be first
Jim Stichnothd97c7df2014-06-04 11:57:08 -0700316 InstNumberT NextInstNumber;
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700317 VarList Variables;
Andrew Scull9612d322015-07-06 14:53:25 -0700318 VarList Args; /// subset of Variables, in argument order
319 VarList ImplicitArgs; /// subset of Variables
John Portoe82b5602016-02-24 15:58:55 -0800320 std::unique_ptr<ArenaAllocator> Allocator;
Jim Stichnoth467ffe52016-03-29 15:01:06 -0700321 // Separate string pools for CfgNode and Variable names, due to a combination
322 // of the uniqueness requirement, and assumptions in lit tests.
323 std::unique_ptr<StringPool> NodeStrings;
324 std::unique_ptr<StringPool> VarStrings;
Jim Stichnotha18cc9c2014-09-30 19:10:22 -0700325 std::unique_ptr<Liveness> Live;
326 std::unique_ptr<TargetLowering> Target;
327 std::unique_ptr<VariablesMetadata> VMetadata;
328 std::unique_ptr<Assembler> TargetAssembler;
Andrew Scull9612d322015-07-06 14:53:25 -0700329 /// Globals required by this CFG. Mostly used for the profiler's globals.
John Portof8b4cc82015-06-09 18:06:19 -0700330 std::unique_ptr<VariableDeclarationList> GlobalInits;
Andrew Scull00741a02015-09-16 19:04:09 -0700331 CfgVector<InstJumpTable *> JumpTables;
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700332
Andrew Scull57e12682015-09-16 11:30:19 -0700333 /// CurrentNode is maintained during dumping/emitting just for validating
334 /// Variable::DefNode. Normally, a traversal over CfgNodes maintains this, but
335 /// before global operations like register allocation, resetCurrentNode()
336 /// should be called to avoid spurious validation failures.
Jim Stichnotheafb56c2015-06-22 10:35:22 -0700337 const CfgNode *CurrentNode = nullptr;
Jim Stichnoth31c95592014-12-19 12:51:35 -0800338
Jim Stichnotha5fe17a2015-01-26 11:10:03 -0800339public:
John Portoe82b5602016-02-24 15:58:55 -0800340 static void TlsInit() { CfgAllocatorTraits::init(); }
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700341};
342
Andrew Scull6d47bcd2015-09-17 17:10:05 -0700343template <> Variable *Cfg::makeVariable<Variable>(Type Ty);
344
Jim Stichnoth467ffe52016-03-29 15:01:06 -0700345struct NodeStringPoolTraits {
346 using OwnerType = Cfg;
347 static StringPool *getStrings(const OwnerType *PoolOwner) {
348 return PoolOwner->getNodeStrings();
349 }
350};
351using NodeString = StringID<NodeStringPoolTraits>;
352
353struct VariableStringPoolTraits {
354 using OwnerType = Cfg;
355 static StringPool *getStrings(const OwnerType *PoolOwner) {
356 return PoolOwner->getVarStrings();
357 }
358};
359using VariableString = StringID<VariableStringPoolTraits>;
360
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700361} // end of namespace Ice
362
363#endif // SUBZERO_SRC_ICECFG_H