summaryrefslogtreecommitdiff
path: root/src/jit/phase.h
diff options
context:
space:
mode:
authordotnet-bot <dotnet-bot@microsoft.com>2015-01-30 14:14:42 -0800
committerdotnet-bot <dotnet-bot@microsoft.com>2015-01-30 14:14:42 -0800
commitef1e2ab328087c61a6878c1e84f4fc5d710aebce (patch)
treedee1bbb89e9d722e16b0d1485e3cdd1b6c8e2cfa /src/jit/phase.h
downloadcoreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.gz
coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.bz2
coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.zip
Initial commit to populate CoreCLR repo
[tfs-changeset: 1407945]
Diffstat (limited to 'src/jit/phase.h')
-rw-r--r--src/jit/phase.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/jit/phase.h b/src/jit/phase.h
new file mode 100644
index 0000000000..2ba0dacfaf
--- /dev/null
+++ b/src/jit/phase.h
@@ -0,0 +1,78 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*****************************************************************************/
+#ifndef _PHASE_H_
+#define _PHASE_H_
+
+class Phase
+{
+public:
+ Phase(Compiler *_comp,
+ char *_name,
+ Phases _phase=PHASE_NUMBER_OF)
+ : comp(_comp), name(_name), phase(_phase) {}
+ virtual void Run();
+ virtual void PrePhase();
+ virtual void DoPhase() = 0;
+ virtual void PostPhase();
+
+protected:
+ Compiler *comp;
+ char *name;
+ Phases phase;
+};
+
+inline void Phase::Run()
+{
+ PrePhase();
+ DoPhase();
+ PostPhase();
+}
+
+inline void Phase::PrePhase()
+{
+#ifdef DEBUG
+ if (VERBOSE)
+ {
+ printf("*************** In %s\n", name);
+ printf("Trees before %s\n", name);
+ comp->fgDispBasicBlocks(true);
+ }
+
+ if (comp->expensiveDebugCheckLevel >= 2)
+ {
+ // If everyone used the Phase class, this would duplicate the PostPhase() from the previous phase.
+ // But, not everyone does, so go ahead and do the check here, too.
+ comp->fgDebugCheckBBlist();
+ comp->fgDebugCheckLinks();
+ }
+#endif // DEBUG
+}
+
+inline void Phase::PostPhase()
+{
+#ifdef DEBUG
+ if (VERBOSE)
+ {
+ printf("*************** Exiting %s\n", name);
+ printf("Trees after %s\n", name);
+ comp->fgDispBasicBlocks(true);
+ }
+#endif // DEBUG
+
+ if (phase != PHASE_NUMBER_OF)
+ {
+ comp->EndPhase(phase);
+ }
+
+#ifdef DEBUG
+ comp->fgDebugCheckBBlist();
+ comp->fgDebugCheckLinks();
+#endif // DEBUG
+
+}
+
+#endif /* End of _PHASE_H_ */