/
PromoteTempVariablesStage.cs
56 lines (45 loc) · 1.19 KB
/
PromoteTempVariablesStage.cs
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
/*
* (c) 2012 MOSA - The Managed Operating System Alliance
*
* Licensed under the terms of the New BSD License.
*
* Authors:
* Phil Garcia (tgiphil) <phil@thinkedge.com>
*/
namespace Mosa.Compiler.Framework.Stages
{
/// <summary>
///
/// </summary>
public sealed class PromoteTempVariablesStage : PromoteLocalVariablesStage
{
protected override void Run()
{
//HACK!!! HACK!!! HACK!!!
//if (MethodCompiler.Method.FullName.Contains(" Mosa.Platform.Internal.x86.Runtime::GetProtectedRegionEntryByAddress"))
// return;
if (!HasCode)
return;
// Unable to optimize SSA w/ exceptions or finally handlers present
if (HasProtectedRegions)
return;
trace = CreateTraceLog();
foreach (var local in MethodCompiler.LocalVariables)
{
if (local.IsVirtualRegister)
continue;
if (local.IsParameter)
continue;
if (!local.IsStackLocal)
continue;
if (!local.IsReferenceType && !local.IsInteger && !local.IsR && !local.IsChar && !local.IsBoolean && !local.IsPointer)
continue;
if (ContainsAddressOf(local))
continue;
if (local.Definitions.Count == 0 || local.Uses.Count == 0)
continue;
Promote(local);
}
}
}
}