Fix reading Time zone rules using Julian days (#17672)
[platform/upstream/coreclr.git] / src / jit / phase.h
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4
5 /*****************************************************************************/
6 #ifndef _PHASE_H_
7 #define _PHASE_H_
8
9 class Phase
10 {
11 public:
12     virtual void Run();
13
14 protected:
15     Phase(Compiler* _comp, const char* _name, Phases _phase = PHASE_NUMBER_OF) : comp(_comp), name(_name), phase(_phase)
16     {
17     }
18
19     virtual void PrePhase();
20     virtual void DoPhase() = 0;
21     virtual void PostPhase();
22
23     Compiler*   comp;
24     const char* name;
25     Phases      phase;
26 };
27
28 inline void Phase::Run()
29 {
30     PrePhase();
31     DoPhase();
32     PostPhase();
33 }
34
35 inline void Phase::PrePhase()
36 {
37 #ifdef DEBUG
38     if (VERBOSE)
39     {
40         printf("*************** In %s\n", name);
41         printf("Trees before %s\n", name);
42         comp->fgDispBasicBlocks(true);
43     }
44
45     if (comp->expensiveDebugCheckLevel >= 2)
46     {
47         // If everyone used the Phase class, this would duplicate the PostPhase() from the previous phase.
48         // But, not everyone does, so go ahead and do the check here, too.
49         comp->fgDebugCheckBBlist();
50         comp->fgDebugCheckLinks();
51     }
52 #endif // DEBUG
53 }
54
55 inline void Phase::PostPhase()
56 {
57 #ifdef DEBUG
58     if (VERBOSE)
59     {
60         printf("*************** Exiting %s\n", name);
61         printf("Trees after %s\n", name);
62         comp->fgDispBasicBlocks(true);
63     }
64 #endif // DEBUG
65
66     if (phase != PHASE_NUMBER_OF)
67     {
68         comp->EndPhase(phase);
69     }
70
71 #ifdef DEBUG
72     comp->fgDebugCheckBBlist();
73     comp->fgDebugCheckLinks();
74 #endif // DEBUG
75 }
76
77 #endif /* End of _PHASE_H_ */