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

Side by Side Diff: src/IceGlobalContext.h

Issue 641193002: Introduce the notion of function addresses in Subzero. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nit in test. Created 6 years, 2 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
« no previous file with comments | « src/IceDefs.h ('k') | src/IceGlobalContext.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/IceGlobalContext.h - Global context defs -----*- C++ -*-===// 1 //===- subzero/src/IceGlobalContext.h - Global context defs -----*- C++ -*-===//
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 declares aspects of the compilation that persist across 10 // This file declares aspects of the compilation that persist across
11 // multiple functions. 11 // multiple functions.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #ifndef SUBZERO_SRC_ICEGLOBALCONTEXT_H 15 #ifndef SUBZERO_SRC_ICEGLOBALCONTEXT_H
16 #define SUBZERO_SRC_ICEGLOBALCONTEXT_H 16 #define SUBZERO_SRC_ICEGLOBALCONTEXT_H
17 17
18 #include <memory> 18 #include <memory>
19 19
20 #include "llvm/Support/Allocator.h" 20 #include "llvm/Support/Allocator.h"
21 #include "llvm/Support/raw_ostream.h" 21 #include "llvm/Support/raw_ostream.h"
22 22
23 #include "IceDefs.h" 23 #include "IceDefs.h"
24 #include "IceClFlags.h"
24 #include "IceIntrinsics.h" 25 #include "IceIntrinsics.h"
25 #include "IceRNG.h" 26 #include "IceRNG.h"
26 #include "IceTimerTree.h" 27 #include "IceTimerTree.h"
27 #include "IceTypes.h" 28 #include "IceTypes.h"
28 29
29 namespace Ice { 30 namespace Ice {
30 31
31 class ClFlags; 32 class ClFlags;
33 class FuncSigType;
32 34
33 // This class collects rudimentary statistics during translation. 35 // This class collects rudimentary statistics during translation.
34 class CodeStats { 36 class CodeStats {
35 public: 37 public:
36 CodeStats() 38 CodeStats()
37 : InstructionsEmitted(0), RegistersSaved(0), FrameBytes(0), Spills(0), 39 : InstructionsEmitted(0), RegistersSaved(0), FrameBytes(0), Spills(0),
38 Fills(0) {} 40 Fills(0) {}
39 void reset() { *this = CodeStats(); } 41 void reset() { *this = CodeStats(); }
40 void updateEmitted(uint32_t InstCount) { InstructionsEmitted += InstCount; } 42 void updateEmitted(uint32_t InstCount) { InstructionsEmitted += InstCount; }
41 void updateRegistersSaved(uint32_t Num) { RegistersSaved += Num; } 43 void updateRegistersSaved(uint32_t Num) { RegistersSaved += Num; }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // Returns a symbolic constant. 112 // Returns a symbolic constant.
111 Constant *getConstantSym(Type Ty, int64_t Offset, const IceString &Name = "", 113 Constant *getConstantSym(Type Ty, int64_t Offset, const IceString &Name = "",
112 bool SuppressMangling = false); 114 bool SuppressMangling = false);
113 // Returns an undef. 115 // Returns an undef.
114 Constant *getConstantUndef(Type Ty); 116 Constant *getConstantUndef(Type Ty);
115 // Returns a zero value. 117 // Returns a zero value.
116 Constant *getConstantZero(Type Ty); 118 Constant *getConstantZero(Type Ty);
117 // getConstantPool() returns a copy of the constant pool for 119 // getConstantPool() returns a copy of the constant pool for
118 // constants of a given type. 120 // constants of a given type.
119 ConstantList getConstantPool(Type Ty) const; 121 ConstantList getConstantPool(Type Ty) const;
122 // Returns a new function declaration, allocated in an internal
123 // memory pool. Ownership of the function is maintained by this
124 // class instance.
125 FunctionDeclaration *newFunctionDeclaration(const FuncSigType *Signature,
126 unsigned CallingConv,
127 unsigned Linkage, bool IsProto);
128
129 // Returns a new global variable declaration, allocated in an
130 // internal memory pool. Ownership of the function is maintained by
131 // this class instance.
132 VariableDeclaration *newVariableDeclaration();
120 133
121 const ClFlags &getFlags() const { return Flags; } 134 const ClFlags &getFlags() const { return Flags; }
122 135
123 // Allocate data of type T using the global allocator. 136 // Allocate data of type T using the global allocator.
124 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } 137 template <typename T> T *allocate() { return Allocator.Allocate<T>(); }
125 138
126 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } 139 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; }
127 140
128 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded 141 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded
129 // translation. 142 // translation.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 Intrinsics IntrinsicsInfo; 192 Intrinsics IntrinsicsInfo;
180 const TargetArch Arch; 193 const TargetArch Arch;
181 const OptLevel Opt; 194 const OptLevel Opt;
182 const IceString TestPrefix; 195 const IceString TestPrefix;
183 const ClFlags &Flags; 196 const ClFlags &Flags;
184 bool HasEmittedFirstMethod; 197 bool HasEmittedFirstMethod;
185 RandomNumberGenerator RNG; 198 RandomNumberGenerator RNG;
186 CodeStats StatsFunction; 199 CodeStats StatsFunction;
187 CodeStats StatsCumulative; 200 CodeStats StatsCumulative;
188 std::vector<TimerStack> Timers; 201 std::vector<TimerStack> Timers;
202 std::vector<GlobalDeclaration *> GlobalDeclarations;
189 GlobalContext(const GlobalContext &) = delete; 203 GlobalContext(const GlobalContext &) = delete;
190 GlobalContext &operator=(const GlobalContext &) = delete; 204 GlobalContext &operator=(const GlobalContext &) = delete;
191 205
192 // Private helpers for mangleName() 206 // Private helpers for mangleName()
193 typedef llvm::SmallVector<char, 32> ManglerVector; 207 typedef llvm::SmallVector<char, 32> ManglerVector;
194 void incrementSubstitutions(ManglerVector &OldName) const; 208 void incrementSubstitutions(ManglerVector &OldName) const;
195 }; 209 };
196 210
197 // Helper class to push and pop a timer marker. The constructor 211 // Helper class to push and pop a timer marker. The constructor
198 // pushes a marker, and the destructor pops it. This is for 212 // pushes a marker, and the destructor pops it. This is for
(...skipping 17 matching lines...) Expand all
216 230
217 private: 231 private:
218 TimerIdT ID; 232 TimerIdT ID;
219 GlobalContext *const Ctx; 233 GlobalContext *const Ctx;
220 const bool Active; 234 const bool Active;
221 }; 235 };
222 236
223 } // end of namespace Ice 237 } // end of namespace Ice
224 238
225 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H 239 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H
OLDNEW
« no previous file with comments | « src/IceDefs.h ('k') | src/IceGlobalContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698