mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-22 12:19:28 +01:00
* fix for web bug #1112 and a bit of clean up in csopt386 (merged from
fixes branch)
This commit is contained in:
parent
738c8f905d
commit
bd928ecf72
@ -67,7 +67,7 @@ Var hp2, hp3{, EndMod}: Pai;
|
|||||||
{Cnt,} OldNrOfMods: Longint;
|
{Cnt,} OldNrOfMods: Longint;
|
||||||
OrgRegInfo, HighRegInfo: TRegInfo;
|
OrgRegInfo, HighRegInfo: TRegInfo;
|
||||||
HighFound, OrgRegFound: Byte;
|
HighFound, OrgRegFound: Byte;
|
||||||
RegCounter: TRegister;
|
RegCounter, regCounter2: TRegister;
|
||||||
OrgRegResult: Boolean;
|
OrgRegResult: Boolean;
|
||||||
TmpResult: Boolean;
|
TmpResult: Boolean;
|
||||||
{TmpState: Byte;}
|
{TmpState: Byte;}
|
||||||
@ -101,10 +101,24 @@ Begin {CheckSequence}
|
|||||||
{ old new }
|
{ old new }
|
||||||
InstructionsEquivalent(hp2, hp3, RegInfo) Do
|
InstructionsEquivalent(hp2, hp3, RegInfo) Do
|
||||||
Begin
|
Begin
|
||||||
|
if (hp3^.typ = ait_instruction) and
|
||||||
|
((paicpu(hp3)^.opcode = A_MOV) or
|
||||||
|
(paicpu(hp3)^.opcode = A_MOVZX) or
|
||||||
|
(paicpu(hp3)^.opcode = A_MOVSX)) and
|
||||||
|
(paicpu(hp3)^.oper[0].typ in
|
||||||
|
[top_const,top_ref,top_symbol]) and
|
||||||
|
(paicpu(hp3)^.oper[1].typ = top_reg) then
|
||||||
|
regInfo.lastReload
|
||||||
|
[reg32(paicpu(hp3)^.oper[1].reg)] := hp3;
|
||||||
GetNextInstruction(hp2, hp2);
|
GetNextInstruction(hp2, hp2);
|
||||||
GetNextInstruction(hp3, hp3);
|
GetNextInstruction(hp3, hp3);
|
||||||
Inc(Found)
|
Inc(Found)
|
||||||
End;
|
End;
|
||||||
|
for regCounter2 := R_EAX to R_EDX do
|
||||||
|
if (regInfo.new2OldReg[regCounter2] <> R_NO) and
|
||||||
|
(reg in PPaiProp(hp3^.optInfo)^.usedRegs) and
|
||||||
|
not regLoadedWithNewValue(reg,false,hp3) then
|
||||||
|
include(regInfo.regsStillUsedAfterSeq,regCounter);
|
||||||
If (Found <> OldNrOfMods) or
|
If (Found <> OldNrOfMods) or
|
||||||
{ the following is to avoid problems with rangecheck code (see testcse2) }
|
{ the following is to avoid problems with rangecheck code (see testcse2) }
|
||||||
(assigned(hp3) and
|
(assigned(hp3) and
|
||||||
@ -355,7 +369,7 @@ begin
|
|||||||
if assigned(hp^.previous) then
|
if assigned(hp^.previous) then
|
||||||
hp^.previous^.next := hp;
|
hp^.previous^.next := hp;
|
||||||
{$endif replaceregdebug}
|
{$endif replaceregdebug}
|
||||||
PPaiProp(p^.optInfo)^.Regs[reg] := c;
|
{ PPaiProp(p^.optInfo)^.Regs[reg] := c;}
|
||||||
While (p <> endP) Do
|
While (p <> endP) Do
|
||||||
Begin
|
Begin
|
||||||
PPaiProp(p^.optInfo)^.Regs[reg] := c;
|
PPaiProp(p^.optInfo)^.Regs[reg] := c;
|
||||||
@ -821,7 +835,6 @@ Var Cnt, Cnt2: Longint;
|
|||||||
hp5 : pai;
|
hp5 : pai;
|
||||||
RegInfo: TRegInfo;
|
RegInfo: TRegInfo;
|
||||||
RegCounter: TRegister;
|
RegCounter: TRegister;
|
||||||
TmpState: Byte;
|
|
||||||
Begin
|
Begin
|
||||||
p := First;
|
p := First;
|
||||||
SkipHead(p);
|
SkipHead(p);
|
||||||
@ -881,19 +894,34 @@ Begin
|
|||||||
Cnt2 := 1;
|
Cnt2 := 1;
|
||||||
While Cnt2 <= Cnt Do
|
While Cnt2 <= Cnt Do
|
||||||
Begin
|
Begin
|
||||||
If (hp1 = nil) And
|
If Not(RegInInstruction(reg32(Paicpu(hp2)^.oper[1].reg), p)) then
|
||||||
Not(RegInInstruction(Paicpu(hp2)^.oper[1].reg, p)) And
|
begin
|
||||||
((p^.typ = ait_instruction) And
|
if ((p^.typ = ait_instruction) And
|
||||||
((paicpu(p)^.OpCode = A_MOV) or
|
((paicpu(p)^.OpCode = A_MOV) or
|
||||||
(paicpu(p)^.opcode = A_MOVZX) or
|
(paicpu(p)^.opcode = A_MOVZX) or
|
||||||
(paicpu(p)^.opcode = A_MOVSX)) And
|
(paicpu(p)^.opcode = A_MOVSX)) And
|
||||||
(paicpu(p)^.Oper[0].typ = top_ref)) Then
|
(paicpu(p)^.Oper[0].typ in
|
||||||
hp1 := p;
|
[top_const,top_ref,top_symbol])) and
|
||||||
|
(paicpu(p)^.oper[1].typ = top_reg) then
|
||||||
|
begin
|
||||||
|
regCounter := reg32(paicpu(p)^.oper[1].reg);
|
||||||
|
if (regCounter in reginfo.regsStillUsedAfterSeq) then
|
||||||
|
begin
|
||||||
|
if (hp1 = nil) then
|
||||||
|
hp1 := reginfo.lastReload[regCounter];
|
||||||
|
end
|
||||||
{$ifndef noremove}
|
{$ifndef noremove}
|
||||||
if regInInstruction(Paicpu(hp2)^.oper[1].reg,p) then
|
else
|
||||||
PPaiProp(p^.OptInfo)^.CanBeRemoved := True;
|
PPaiProp(p^.OptInfo)^.CanBeRemoved := True;
|
||||||
{$endif noremove}
|
{$endif noremove}
|
||||||
Inc(Cnt2);
|
end
|
||||||
|
end
|
||||||
|
{$ifndef noremove}
|
||||||
|
else
|
||||||
|
if regInInstruction(Paicpu(hp2)^.oper[1].reg,p) then
|
||||||
|
PPaiProp(p^.OptInfo)^.CanBeRemoved := True
|
||||||
|
{$endif noremove}
|
||||||
|
; Inc(Cnt2);
|
||||||
GetNextInstruction(p, p);
|
GetNextInstruction(p, p);
|
||||||
End;
|
End;
|
||||||
hp3 := New(Pai_Marker,Init(NoPropInfoStart));
|
hp3 := New(Pai_Marker,Init(NoPropInfoStart));
|
||||||
@ -953,56 +981,15 @@ Begin
|
|||||||
{ sequence. }
|
{ sequence. }
|
||||||
If RegCounter in RegInfo.RegsLoadedForRef Then
|
If RegCounter in RegInfo.RegsLoadedForRef Then
|
||||||
Begin
|
Begin
|
||||||
{load Cnt2 with the total number of instructions of this sequence}
|
|
||||||
Cnt2 := PPaiProp(hp4^.OptInfo)^.
|
|
||||||
Regs[RegInfo.New2OldReg[RegCounter]].NrOfMods;
|
|
||||||
|
|
||||||
hp3 := hp2;
|
hp3 := hp2;
|
||||||
For Cnt := 1 to Pred(Cnt2) Do
|
{ cnt still holds the number of instructions }
|
||||||
GetNextInstruction(hp3, hp3);
|
{ of the sequence, so go to the end of it }
|
||||||
TmpState := PPaiProp(hp3^.OptInfo)^.Regs[RegCounter].WState;
|
for cnt2 := 1 to pred(cnt) Do
|
||||||
GetNextInstruction(hp3, hp3);
|
getNextInstruction(hp3,hp3);
|
||||||
{$ifdef csdebug}
|
{ hp4 = instruction prior to start of sequence }
|
||||||
Writeln('Cnt2: ',Cnt2);
|
restoreRegContentsTo(regCounter,
|
||||||
hp5 := new(pai_asm_comment,init(strpnew('starting here...')));
|
PPaiProp(hp4^.OptInfo)^.Regs[RegCounter],
|
||||||
InsertLLItem(AsmL, Pai(hp2^.previous), hp2, hp5);
|
hp2,hp3);
|
||||||
{$endif csdebug}
|
|
||||||
hp3 := hp2;
|
|
||||||
{first change the contents of the register inside the sequence}
|
|
||||||
For Cnt := 1 to Cnt2 Do
|
|
||||||
Begin
|
|
||||||
{save the WState of the last pai object of the sequence for later use}
|
|
||||||
TmpState := PPaiProp(hp3^.OptInfo)^.Regs[RegCounter].WState;
|
|
||||||
{$ifdef csdebug}
|
|
||||||
hp5 := new(pai_asm_comment,init(strpnew('WState for '+att_reg2str[Regcounter]+': '
|
|
||||||
+tostr(tmpstate))));
|
|
||||||
InsertLLItem(AsmL, hp3, pai(hp3^.next), hp5);
|
|
||||||
{$endif csdebug}
|
|
||||||
PPaiProp(hp3^.OptInfo)^.Regs[RegCounter] :=
|
|
||||||
PPaiProp(hp4^.OptInfo)^.Regs[RegCounter];
|
|
||||||
GetNextInstruction(hp3, hp3);
|
|
||||||
End;
|
|
||||||
{here, hp3 = p = Pai object right after the sequence, TmpState = WState of
|
|
||||||
RegCounter at the last Pai object of the sequence}
|
|
||||||
GetLastInstruction(hp3, hp3);
|
|
||||||
While GetNextInstruction(hp3, hp3) And
|
|
||||||
(PPaiProp(hp3^.OptInfo)^.Regs[RegCounter].WState
|
|
||||||
= TmpState) Do
|
|
||||||
{$ifdef csdebug}
|
|
||||||
begin
|
|
||||||
hp5 := new(pai_asm_comment,init(strpnew('WState for '+att_reg2str[Regcounter]+': '+
|
|
||||||
tostr(PPaiProp(hp3^.OptInfo)^.Regs[RegCounter].WState))));
|
|
||||||
InsertLLItem(AsmL, hp3, pai(hp3^.next), hp5);
|
|
||||||
{$endif csdebug}
|
|
||||||
PPaiProp(hp3^.OptInfo)^.Regs[RegCounter] :=
|
|
||||||
PPaiProp(hp4^.OptInfo)^.Regs[RegCounter];
|
|
||||||
{$ifdef csdebug}
|
|
||||||
end;
|
|
||||||
{$endif csdebug}
|
|
||||||
{$ifdef csdebug}
|
|
||||||
hp5 := new(pai_asm_comment,init(strpnew('stopping here...')));
|
|
||||||
InsertLLItem(AsmL, hp3, pai(hp3^.next), hp5);
|
|
||||||
{$endif csdebug}
|
|
||||||
End;
|
End;
|
||||||
End;
|
End;
|
||||||
hp3 := New(Pai_Marker,Init(NoPropInfoEnd));
|
hp3 := New(Pai_Marker,Init(NoPropInfoEnd));
|
||||||
@ -1170,7 +1157,11 @@ End.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.5 2000-08-04 20:08:03 jonas
|
Revision 1.6 2000-08-23 12:55:10 jonas
|
||||||
|
* fix for web bug 1112 and a bit of clean up in csopt386 (merged from
|
||||||
|
fixes branch)
|
||||||
|
|
||||||
|
Revision 1.5 2000/08/04 20:08:03 jonas
|
||||||
* improved detection of range of instructions which use a register
|
* improved detection of range of instructions which use a register
|
||||||
(merged from fixes branch)
|
(merged from fixes branch)
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,8 @@ Type
|
|||||||
TRegInfo = Record
|
TRegInfo = Record
|
||||||
NewRegsEncountered, OldRegsEncountered: TRegSet;
|
NewRegsEncountered, OldRegsEncountered: TRegSet;
|
||||||
RegsLoadedForRef: TRegSet;
|
RegsLoadedForRef: TRegSet;
|
||||||
|
regsStillUsedAfterSeq: TRegSet;
|
||||||
|
lastReload: array[R_EAX..R_EDI] of pai;
|
||||||
New2OldReg: TRegArray;
|
New2OldReg: TRegArray;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
@ -2330,7 +2332,11 @@ End.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.6 2000-08-19 17:53:29 jonas
|
Revision 1.7 2000-08-23 12:55:10 jonas
|
||||||
|
* fix for web bug 1112 and a bit of clean up in csopt386 (merged from
|
||||||
|
fixes branch)
|
||||||
|
|
||||||
|
Revision 1.6 2000/08/19 17:53:29 jonas
|
||||||
* fixed a potential bug in destroyregs regarding the removal of
|
* fixed a potential bug in destroyregs regarding the removal of
|
||||||
unused loads
|
unused loads
|
||||||
* added destroyDependingRegs() procedure and use it for the fix in
|
* added destroyDependingRegs() procedure and use it for the fix in
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user