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

Unified Diff: src/IceGlobalContext.h

Issue 580633002: Subzero: Add rudimentary statistics on generated code. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Remove SpillsPlusFills and calculate as Spills+Fills Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceClFlags.h ('k') | src/IceGlobalContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceGlobalContext.h
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
index b67a232fc658770fb49b580f99add84c23812346..47272ef1b3a2bcffd295d0e8b859a32d2ac6424b 100644
--- a/src/IceGlobalContext.h
+++ b/src/IceGlobalContext.h
@@ -28,6 +28,35 @@ namespace Ice {
class ClFlags;
+// This class collects rudimentary statistics during translation.
+class CodeStats {
+public:
+ CodeStats()
+ : InstructionsEmitted(0), RegistersSaved(0), FrameBytes(0), Spills(0),
+ Fills(0) {}
+ void reset() { *this = CodeStats(); }
+ void updateEmitted(uint32_t InstCount) { InstructionsEmitted += InstCount; }
+ void updateRegistersSaved(uint32_t Num) { RegistersSaved += Num; }
+ void updateFrameBytes(uint32_t Bytes) { FrameBytes += Bytes; }
+ void updateSpills() { ++Spills; }
+ void updateFills() { ++Fills; }
+ void dump(const IceString &Name, Ostream &Str) {
+ Str << "|" << Name << "|Inst Count |" << InstructionsEmitted << "\n";
+ Str << "|" << Name << "|Regs Saved |" << RegistersSaved << "\n";
+ Str << "|" << Name << "|Frame Bytes |" << FrameBytes << "\n";
+ Str << "|" << Name << "|Spills |" << Spills << "\n";
+ Str << "|" << Name << "|Fills |" << Fills << "\n";
+ Str << "|" << Name << "|Spills+Fills|" << Spills + Fills << "\n";
+ }
+
+private:
+ uint32_t InstructionsEmitted;
+ uint32_t RegistersSaved;
+ uint32_t FrameBytes;
+ uint32_t Spills;
+ uint32_t Fills;
+};
+
// TODO: Accesses to all non-const fields of GlobalContext need to
// be synchronized, especially the constant pool, the allocator, and
// the output streams.
@@ -100,6 +129,30 @@ public:
// translation.
RandomNumberGenerator &getRNG() { return RNG; }
+ // Reset stats at the beginning of a function.
+ void resetStats() { StatsFunction.reset(); }
+ void dumpStats(const IceString &Name);
+ void statsUpdateEmitted(uint32_t InstCount) {
+ StatsFunction.updateEmitted(InstCount);
+ StatsCumulative.updateEmitted(InstCount);
+ }
+ void statsUpdateRegistersSaved(uint32_t Num) {
+ StatsFunction.updateRegistersSaved(Num);
+ StatsCumulative.updateRegistersSaved(Num);
+ }
+ void statsUpdateFrameBytes(uint32_t Bytes) {
+ StatsFunction.updateFrameBytes(Bytes);
+ StatsCumulative.updateFrameBytes(Bytes);
+ }
+ void statsUpdateSpills() {
+ StatsFunction.updateSpills();
+ StatsCumulative.updateSpills();
+ }
+ void statsUpdateFills() {
+ StatsFunction.updateFills();
+ StatsCumulative.updateFills();
+ }
+
private:
Ostream *StrDump; // Stream for dumping / diagnostics
Ostream *StrEmit; // Stream for code emission
@@ -114,6 +167,8 @@ private:
const ClFlags &Flags;
bool HasEmittedFirstMethod;
RandomNumberGenerator RNG;
+ CodeStats StatsFunction;
+ CodeStats StatsCumulative;
GlobalContext(const GlobalContext &) LLVM_DELETED_FUNCTION;
GlobalContext &operator=(const GlobalContext &) LLVM_DELETED_FUNCTION;
« no previous file with comments | « src/IceClFlags.h ('k') | src/IceGlobalContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698