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

Side by Side Diff: src/IceGlobalContext.h

Issue 905463003: Adds accessor methods to class ClFlags. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits in patchset 2. Created 5 years, 10 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/IceELFObjectWriter.cpp ('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
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 Constant *getConstantZero(Type Ty); 195 Constant *getConstantZero(Type Ty);
196 // getConstantPool() returns a copy of the constant pool for 196 // getConstantPool() returns a copy of the constant pool for
197 // constants of a given type. 197 // constants of a given type.
198 ConstantList getConstantPool(Type Ty); 198 ConstantList getConstantPool(Type Ty);
199 // Returns a copy of the list of external symbols. 199 // Returns a copy of the list of external symbols.
200 ConstantList getConstantExternSyms(); 200 ConstantList getConstantExternSyms();
201 201
202 const ClFlags &getFlags() const { return Flags; } 202 const ClFlags &getFlags() const { return Flags; }
203 203
204 bool isIRGenerationDisabled() const { 204 bool isIRGenerationDisabled() const {
205 return ALLOW_DISABLE_IR_GEN ? getFlags().DisableIRGeneration : false; 205 return getFlags().getDisableIRGeneration();
206 } 206 }
207 207
208 // Allocate data of type T using the global allocator. 208 // Allocate data of type T using the global allocator.
209 template <typename T> T *allocate() { return getAllocator()->Allocate<T>(); } 209 template <typename T> T *allocate() { return getAllocator()->Allocate<T>(); }
210 210
211 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } 211 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; }
212 212
213 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded 213 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded
214 // translation. 214 // translation.
215 RandomNumberGenerator &getRNG() { return RNG; } 215 RandomNumberGenerator &getRNG() { return RNG; }
216 216
217 ELFObjectWriter *getObjectWriter() const { return ObjectWriter.get(); } 217 ELFObjectWriter *getObjectWriter() const { return ObjectWriter.get(); }
218 218
219 // Reset stats at the beginning of a function. 219 // Reset stats at the beginning of a function.
220 void resetStats() { 220 void resetStats() {
221 if (ALLOW_DUMP) 221 if (ALLOW_DUMP)
222 ICE_TLS_GET_FIELD(TLS)->StatsFunction.reset(); 222 ICE_TLS_GET_FIELD(TLS)->StatsFunction.reset();
223 } 223 }
224 void dumpStats(const IceString &Name, bool Final = false); 224 void dumpStats(const IceString &Name, bool Final = false);
225 void statsUpdateEmitted(uint32_t InstCount) { 225 void statsUpdateEmitted(uint32_t InstCount) {
226 if (!ALLOW_DUMP || !getFlags().DumpStats) 226 if (!getFlags().getDumpStats())
227 return; 227 return;
228 ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS); 228 ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS);
229 TLS->StatsFunction.update(CodeStats::CS_InstCount, InstCount); 229 TLS->StatsFunction.update(CodeStats::CS_InstCount, InstCount);
230 TLS->StatsCumulative.update(CodeStats::CS_InstCount, InstCount); 230 TLS->StatsCumulative.update(CodeStats::CS_InstCount, InstCount);
231 } 231 }
232 void statsUpdateRegistersSaved(uint32_t Num) { 232 void statsUpdateRegistersSaved(uint32_t Num) {
233 if (!ALLOW_DUMP || !getFlags().DumpStats) 233 if (!getFlags().getDumpStats())
234 return; 234 return;
235 ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS); 235 ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS);
236 TLS->StatsFunction.update(CodeStats::CS_RegsSaved, Num); 236 TLS->StatsFunction.update(CodeStats::CS_RegsSaved, Num);
237 TLS->StatsCumulative.update(CodeStats::CS_RegsSaved, Num); 237 TLS->StatsCumulative.update(CodeStats::CS_RegsSaved, Num);
238 } 238 }
239 void statsUpdateFrameBytes(uint32_t Bytes) { 239 void statsUpdateFrameBytes(uint32_t Bytes) {
240 if (!ALLOW_DUMP || !getFlags().DumpStats) 240 if (!getFlags().getDumpStats())
241 return; 241 return;
242 ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS); 242 ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS);
243 TLS->StatsFunction.update(CodeStats::CS_FrameByte, Bytes); 243 TLS->StatsFunction.update(CodeStats::CS_FrameByte, Bytes);
244 TLS->StatsCumulative.update(CodeStats::CS_FrameByte, Bytes); 244 TLS->StatsCumulative.update(CodeStats::CS_FrameByte, Bytes);
245 } 245 }
246 void statsUpdateSpills() { 246 void statsUpdateSpills() {
247 if (!ALLOW_DUMP || !getFlags().DumpStats) 247 if (!getFlags().getDumpStats())
248 return; 248 return;
249 ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS); 249 ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS);
250 TLS->StatsFunction.update(CodeStats::CS_NumSpills); 250 TLS->StatsFunction.update(CodeStats::CS_NumSpills);
251 TLS->StatsCumulative.update(CodeStats::CS_NumSpills); 251 TLS->StatsCumulative.update(CodeStats::CS_NumSpills);
252 } 252 }
253 void statsUpdateFills() { 253 void statsUpdateFills() {
254 if (!ALLOW_DUMP || !getFlags().DumpStats) 254 if (!getFlags().getDumpStats())
255 return; 255 return;
256 ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS); 256 ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS);
257 TLS->StatsFunction.update(CodeStats::CS_NumFills); 257 TLS->StatsFunction.update(CodeStats::CS_NumFills);
258 TLS->StatsCumulative.update(CodeStats::CS_NumFills); 258 TLS->StatsCumulative.update(CodeStats::CS_NumFills);
259 } 259 }
260 260
261 // These are predefined TimerStackIdT values. 261 // These are predefined TimerStackIdT values.
262 enum TimerStackKind { TSK_Default = 0, TSK_Funcs, TSK_Num }; 262 enum TimerStackKind { TSK_Default = 0, TSK_Funcs, TSK_Num };
263 263
264 // newTimerStackID() creates a new TimerStack in the global space. 264 // newTimerStackID() creates a new TimerStack in the global space.
(...skipping 18 matching lines...) Expand all
283 void cfgQueueBlockingPush(std::unique_ptr<Cfg> Func); 283 void cfgQueueBlockingPush(std::unique_ptr<Cfg> Func);
284 // Takes a Cfg from the work queue for translating. May block if 284 // Takes a Cfg from the work queue for translating. May block if
285 // the work queue is currently empty. Returns nullptr if there is 285 // the work queue is currently empty. Returns nullptr if there is
286 // no more work - the queue is empty and either end() has been 286 // no more work - the queue is empty and either end() has been
287 // called or the Sequential flag was set. 287 // called or the Sequential flag was set.
288 std::unique_ptr<Cfg> cfgQueueBlockingPop(); 288 std::unique_ptr<Cfg> cfgQueueBlockingPop();
289 // Notifies that no more work will be added to the work queue. 289 // Notifies that no more work will be added to the work queue.
290 void cfgQueueNotifyEnd() { CfgQ.notifyEnd(); } 290 void cfgQueueNotifyEnd() { CfgQ.notifyEnd(); }
291 291
292 void startWorkerThreads() { 292 void startWorkerThreads() {
293 size_t NumWorkers = getFlags().NumTranslationThreads; 293 size_t NumWorkers = getFlags().getNumTranslationThreads();
294 auto Timers = getTimers(); 294 auto Timers = getTimers();
295 for (size_t i = 0; i < NumWorkers; ++i) { 295 for (size_t i = 0; i < NumWorkers; ++i) {
296 ThreadContext *WorkerTLS = new ThreadContext(); 296 ThreadContext *WorkerTLS = new ThreadContext();
297 Timers->initInto(WorkerTLS->Timers); 297 Timers->initInto(WorkerTLS->Timers);
298 AllThreadContexts.push_back(WorkerTLS); 298 AllThreadContexts.push_back(WorkerTLS);
299 TranslationThreads.push_back(std::thread( 299 TranslationThreads.push_back(std::thread(
300 &GlobalContext::translateFunctionsWrapper, this, WorkerTLS)); 300 &GlobalContext::translateFunctionsWrapper, this, WorkerTLS));
301 } 301 }
302 if (NumWorkers) { 302 if (NumWorkers) {
303 // TODO(stichnot): start a new thread for the emitter queue worker. 303 // TODO(stichnot): start a new thread for the emitter queue worker.
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } 467 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); }
468 ~OstreamLocker() { Ctx->unlockStr(); } 468 ~OstreamLocker() { Ctx->unlockStr(); }
469 469
470 private: 470 private:
471 GlobalContext *const Ctx; 471 GlobalContext *const Ctx;
472 }; 472 };
473 473
474 } // end of namespace Ice 474 } // end of namespace Ice
475 475
476 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H 476 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H
OLDNEW
« no previous file with comments | « src/IceELFObjectWriter.cpp ('k') | src/IceGlobalContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698