blob: d8e29400890938ffc6e72239a932d2b3641dbb3f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*****************************************************************************/
#ifndef _PHASE_H_
#define _PHASE_H_
class Phase
{
public:
virtual void Run();
protected:
Phase(Compiler* _comp, const char* _name, Phases _phase = PHASE_NUMBER_OF) : comp(_comp), name(_name), phase(_phase)
{
}
virtual void PrePhase();
virtual void DoPhase() = 0;
virtual void PostPhase();
Compiler* comp;
const 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_ */
|