|
@@ -59,8 +59,10 @@ Unit aopt;
|
|
Implementation
|
|
Implementation
|
|
|
|
|
|
uses
|
|
uses
|
|
|
|
+ cutils,
|
|
globtype, globals,
|
|
globtype, globals,
|
|
verbose,
|
|
verbose,
|
|
|
|
+ cpubase,
|
|
cgbase,
|
|
cgbase,
|
|
aoptda,aoptcpu,aoptcpud;
|
|
aoptda,aoptcpu,aoptcpud;
|
|
|
|
|
|
@@ -145,9 +147,12 @@ Unit aopt;
|
|
Else
|
|
Else
|
|
Begin
|
|
Begin
|
|
hp1 := tai(p.previous);
|
|
hp1 := tai(p.previous);
|
|
|
|
+{$ifdef DEBUG_OPTALLOC}
|
|
|
|
+ AsmL.InsertAfter(tai_comment.Create(strpnew('Removed allocation of '+std_regname(tai_regalloc(p).Reg))),p);
|
|
|
|
+{$endif DEBUG_OPTALLOC}
|
|
AsmL.remove(p);
|
|
AsmL.remove(p);
|
|
p.free;
|
|
p.free;
|
|
- p := hp1;
|
|
|
|
|
|
+ p := hp1;
|
|
{ not sure if this is useful, it even skips previous deallocs of the register (FK)
|
|
{ not sure if this is useful, it even skips previous deallocs of the register (FK)
|
|
hp1 := p;
|
|
hp1 := p;
|
|
hp2 := nil;
|
|
hp2 := nil;
|
|
@@ -160,9 +165,9 @@ Unit aopt;
|
|
InsertLLItem(tai(hp2.previous), hp2, hp1);
|
|
InsertLLItem(tai(hp2.previous), hp2, hp1);
|
|
End;
|
|
End;
|
|
}
|
|
}
|
|
- End;
|
|
|
|
|
|
+ End;
|
|
End
|
|
End
|
|
- else
|
|
|
|
|
|
+ else if tai_regalloc(p).ratype=ra_dealloc then
|
|
Begin
|
|
Begin
|
|
ExcludeRegFromUsedRegs(tai_regalloc(p).Reg,Regs);
|
|
ExcludeRegFromUsedRegs(tai_regalloc(p).Reg,Regs);
|
|
hp1 := p;
|
|
hp1 := p;
|
|
@@ -174,14 +179,23 @@ Unit aopt;
|
|
If hp2 <> nil Then
|
|
If hp2 <> nil Then
|
|
Begin
|
|
Begin
|
|
hp1 := tai(p.previous);
|
|
hp1 := tai(p.previous);
|
|
|
|
+{$ifdef DEBUG_OPTALLOC}
|
|
|
|
+ AsmL.InsertAfter(tai_comment.Create(strpnew('Moved deallocation of '+std_regname(tai_regalloc(p).Reg))),p);
|
|
|
|
+{$endif DEBUG_OPTALLOC}
|
|
AsmL.Remove(p);
|
|
AsmL.Remove(p);
|
|
InsertLLItem(hp2, tai(hp2.Next), p);
|
|
InsertLLItem(hp2, tai(hp2.Next), p);
|
|
|
|
+{$ifdef DEBUG_OPTALLOC}
|
|
|
|
+ AsmL.InsertAfter(tai_comment.Create(strpnew('Moved deallocation of '+std_regname(tai_regalloc(p).Reg)+' here')),hp2);
|
|
|
|
+{$endif DEBUG_OPTALLOC}
|
|
p := hp1;
|
|
p := hp1;
|
|
End
|
|
End
|
|
else if findregalloc(tai_regalloc(p).reg, tai(p.next))
|
|
else if findregalloc(tai_regalloc(p).reg, tai(p.next))
|
|
and getnextinstruction(p,hp1) then
|
|
and getnextinstruction(p,hp1) then
|
|
begin
|
|
begin
|
|
hp1 := tai(p.previous);
|
|
hp1 := tai(p.previous);
|
|
|
|
+{$ifdef DEBUG_OPTALLOC}
|
|
|
|
+ AsmL.InsertAfter(tai_comment.Create(strpnew('Removed deallocation of '+std_regname(tai_regalloc(p).Reg))),p);
|
|
|
|
+{$endif DEBUG_OPTALLOC}
|
|
AsmL.remove(p);
|
|
AsmL.remove(p);
|
|
p.free;
|
|
p.free;
|
|
p := hp1;
|
|
p := hp1;
|