mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 05:09:19 +02:00
*** empty log message ***
This commit is contained in:
parent
4594d7ae04
commit
2f9ba77432
@ -28,55 +28,6 @@ Type TwoWords = Record
|
|||||||
Word1, Word2: Word
|
Word1, Word2: Word
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Function Reg32(Reg: TRegister): TRegister;
|
|
||||||
{Returns the 32 bit component of Reg if it exists, otherwise Reg is returned}
|
|
||||||
Begin
|
|
||||||
Reg32 := Reg;
|
|
||||||
If (Reg >= R_AX)
|
|
||||||
Then
|
|
||||||
If (Reg <= R_DI)
|
|
||||||
Then Reg32 := Reg16ToReg32(Reg)
|
|
||||||
Else
|
|
||||||
If (Reg <= R_BL)
|
|
||||||
Then Reg32 := Reg8toReg32(Reg);
|
|
||||||
End;
|
|
||||||
|
|
||||||
Function RegInRef(Reg: TRegister; Const Ref: TReference): Boolean;
|
|
||||||
Begin {checks whether Ref contains a reference to Reg}
|
|
||||||
Reg := Reg32(Reg);
|
|
||||||
RegInRef := (Ref.Base = Reg) Or (Ref.Index = Reg)
|
|
||||||
End;
|
|
||||||
|
|
||||||
Function RegInInstruction(Reg: TRegister; p1: Pai): Boolean;
|
|
||||||
{checks if Reg is used by the instruction p1}
|
|
||||||
Var TmpResult: Boolean;
|
|
||||||
Begin
|
|
||||||
TmpResult := False;
|
|
||||||
If (Pai(p1)^.typ = ait_instruction) Then
|
|
||||||
Begin
|
|
||||||
Case Pai386(p1)^.op1t Of
|
|
||||||
Top_Reg: TmpResult := Reg = TRegister(Pai386(p1)^.op1);
|
|
||||||
Top_Ref: TmpResult := RegInRef(Reg, TReference(Pai386(p1)^.op1^))
|
|
||||||
End;
|
|
||||||
If Not(TmpResult) Then
|
|
||||||
Case Pai386(p1)^.op2t Of
|
|
||||||
Top_Reg:
|
|
||||||
if Pai386(p1)^.op3t<>Top_reg
|
|
||||||
then TmpResult := Reg = TRegister(Pai386(p1)^.op2)
|
|
||||||
else TmpResult := longint(Reg) = twowords(Pai386(p1)^.op2).word1;
|
|
||||||
Top_Ref: TmpResult := RegInRef(Reg, TReference(Pai386(p1)^.op2^))
|
|
||||||
End;
|
|
||||||
If Not(TmpResult) Then
|
|
||||||
Case Pai386(p1)^.op3t Of
|
|
||||||
Top_Reg: TmpResult := longint(Reg) =twowords(Pai386(p1)^.op2).word2;
|
|
||||||
Top_none:;
|
|
||||||
else
|
|
||||||
internalerror($Da);
|
|
||||||
End
|
|
||||||
End;
|
|
||||||
RegInInstruction := TmpResult
|
|
||||||
End;
|
|
||||||
|
|
||||||
Procedure ReloadOpt(AsmL: PaasmOutput);
|
Procedure ReloadOpt(AsmL: PaasmOutput);
|
||||||
|
|
||||||
Const MaxCh = 3;
|
Const MaxCh = 3;
|
||||||
@ -638,13 +589,18 @@ Function InstructionsEqual(p1, p2: Pai): Boolean;
|
|||||||
Begin {checks whether two Pai386 instructions are equal}
|
Begin {checks whether two Pai386 instructions are equal}
|
||||||
InstructionsEqual :=
|
InstructionsEqual :=
|
||||||
Assigned(p1) And Assigned(p2) And
|
Assigned(p1) And Assigned(p2) And
|
||||||
(Pai(p1)^.typ = ait_instruction) And
|
((((Pai(p1)^.typ = ait_regalloc) And
|
||||||
|
(Pai(p2)^.typ = ait_regalloc)) Or
|
||||||
|
((Pai(p1)^.typ = ait_regdealloc) And
|
||||||
|
(Pai(p2)^.typ = ait_regdealloc))) And
|
||||||
|
(PaiRegAlloc(p1)^.reg = PaiRegAlloc(p2)^.reg)) Or
|
||||||
|
((Pai(p1)^.typ = ait_instruction) And
|
||||||
(Pai(p1)^.typ = ait_instruction) And
|
(Pai(p1)^.typ = ait_instruction) And
|
||||||
(Pai386(p1)^._operator = Pai386(p2)^._operator) And
|
(Pai386(p1)^._operator = Pai386(p2)^._operator) And
|
||||||
(Pai386(p1)^.op1t = Pai386(p2)^.op1t) And
|
(Pai386(p1)^.op1t = Pai386(p2)^.op1t) And
|
||||||
(Pai386(p1)^.op2t = Pai386(p2)^.op2t) And
|
(Pai386(p1)^.op2t = Pai386(p2)^.op2t) And
|
||||||
OpsEqual(Pai386(p1)^.op1t, Pai386(p1)^.op1, Pai386(p2)^.op1) And
|
OpsEqual(Pai386(p1)^.op1t, Pai386(p1)^.op1, Pai386(p2)^.op1) And
|
||||||
OpsEqual(Pai386(p1)^.op2t, Pai386(p1)^.op2, Pai386(p2)^.op2)
|
OpsEqual(Pai386(p1)^.op2t, Pai386(p1)^.op2, Pai386(p2)^.op2))
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Function CheckSequence(p: Pai; Reg: TRegister; Var Found: Longint): Boolean;
|
Function CheckSequence(p: Pai; Reg: TRegister; Var Found: Longint): Boolean;
|
||||||
@ -739,15 +695,15 @@ End;
|
|||||||
Begin {CheckSequence}
|
Begin {CheckSequence}
|
||||||
Reg := Reg32(Reg);
|
Reg := Reg32(Reg);
|
||||||
Found := 0;
|
Found := 0;
|
||||||
hp2 := p;
|
hp2 := PPaiProp(Pai(p^.last)^.line)^.Regs[Reg].StartMod;
|
||||||
hp3 := PPaiProp(Pai(p^.last)^.line)^.Regs[Reg].StartMod;
|
hp3 := p;
|
||||||
EndMod := PPaiProp(Pai(p^.last)^.line)^.Regs[Reg].StartMod;
|
EndMod := PPaiProp(Pai(p^.last)^.line)^.Regs[Reg].StartMod;
|
||||||
RegsNotYetChecked := [R_EAX..R_EDI];
|
RegsNotYetChecked := [R_EAX..R_EDI];
|
||||||
For Counter := 2 to PPaiProp(Pai(p^.last)^.line)^.Regs[Reg].NrOfMods Do
|
For Counter := 2 to PPaiProp(Pai(p^.last)^.line)^.Regs[Reg].NrOfMods Do
|
||||||
EndMod := Pai(EndMod^.Next);
|
EndMod := Pai(EndMod^.Next);
|
||||||
While (Found <> PPaiProp(Pai(p^.last)^.line)^.Regs[Reg].NrOfMods) And
|
While (Found <> PPaiProp(Pai(p^.last)^.line)^.Regs[Reg].NrOfMods) And
|
||||||
InstructionsEqual(hp2, hp3) And
|
InstructionsEqual(hp2, hp3) And
|
||||||
NoChangedRegInRef(EndMod, hp2) Do
|
NoChangedRegInRef(EndMod, hp3) Do
|
||||||
Begin
|
Begin
|
||||||
hp2 := Pai(hp2^.next);
|
hp2 := Pai(hp2^.next);
|
||||||
hp3 := Pai(hp3^.next);
|
hp3 := Pai(hp3^.next);
|
||||||
@ -755,6 +711,61 @@ Begin {CheckSequence}
|
|||||||
End;
|
End;
|
||||||
If (Found <> PPaiProp(Pai(p^.last)^.line)^.Regs[Reg].NrOfMods)
|
If (Found <> PPaiProp(Pai(p^.last)^.line)^.Regs[Reg].NrOfMods)
|
||||||
Then
|
Then
|
||||||
|
Begin
|
||||||
|
If ((Found+1) = PPaiProp(Pai(p^.last)^.line)^.Regs[Reg].NrOfMods) And
|
||||||
|
Assigned(hp2) And
|
||||||
|
(Pai(hp2)^.typ = ait_instruction) And
|
||||||
|
(Pai386(hp2)^._operator In [A_MOV, A_MOVZX]) And
|
||||||
|
(Pai386(hp2)^.op1t = top_ref) And
|
||||||
|
(Pai386(hp2)^.op2t = top_reg) And
|
||||||
|
Assigned(hp3) And
|
||||||
|
(Pai(hp3)^.typ = ait_instruction) And
|
||||||
|
(Pai386(hp3)^._operator In [A_MOV, A_MOVZX]) And
|
||||||
|
(Pai386(hp3)^.op1t = top_ref) And
|
||||||
|
(Pai386(hp3)^.op2t = top_reg) And
|
||||||
|
(Pai386(hp2)^._operator <> Pai386(hp3)^._operator) And
|
||||||
|
RefsEqual(TReference(Pai386(hp2)^.op1^),TReference(Pai386(hp3)^.op1^)) And
|
||||||
|
NoChangedRegInRef(EndMod, hp3)
|
||||||
|
Then
|
||||||
|
If (Pai386(hp2)^._operator = A_MOV)
|
||||||
|
Then
|
||||||
|
Begin
|
||||||
|
If (Pai386(hp2)^.Size = S_B) And
|
||||||
|
(Reg8toReg32(TRegister(Pai386(hp2)^.op2)) =
|
||||||
|
TRegister(Pai386(hp3)^.op2))
|
||||||
|
Then
|
||||||
|
Begin
|
||||||
|
Pai386(hp2)^._operator := A_MOVZX;
|
||||||
|
Pai386(hp2)^.op2 := Pai386(hp3)^.op2;
|
||||||
|
Pai386(hp2)^.Size := S_BL;
|
||||||
|
Inc(Found);
|
||||||
|
CheckSequence := True;
|
||||||
|
End
|
||||||
|
Else
|
||||||
|
Begin
|
||||||
|
CheckSequence := False;
|
||||||
|
If (Found > 0) Then
|
||||||
|
Found := PPaiProp(Pai(p)^.line)^.Regs[Reg].NrOfMods
|
||||||
|
End
|
||||||
|
End
|
||||||
|
Else
|
||||||
|
Begin
|
||||||
|
If (Pai386(hp3)^.Size = S_B) And
|
||||||
|
(Reg8toReg32(TRegister(Pai386(hp3)^.op2)) =
|
||||||
|
TRegister(Pai386(hp2)^.op2))
|
||||||
|
Then
|
||||||
|
Begin
|
||||||
|
CheckSequence := True;
|
||||||
|
Inc(Found)
|
||||||
|
End
|
||||||
|
Else
|
||||||
|
Begin
|
||||||
|
CheckSequence := False;
|
||||||
|
If (Found > 0) Then
|
||||||
|
Found := PPaiProp(Pai(p)^.line)^.Regs[Reg].NrOfMods
|
||||||
|
End
|
||||||
|
End
|
||||||
|
Else
|
||||||
Begin
|
Begin
|
||||||
CheckSequence := False;
|
CheckSequence := False;
|
||||||
If (found > 0) then
|
If (found > 0) then
|
||||||
@ -768,6 +779,7 @@ Begin {CheckSequence}
|
|||||||
check is left out, incorrect optimizations are performed.}
|
check is left out, incorrect optimizations are performed.}
|
||||||
Found := PPaiProp(Pai(p)^.line)^.Regs[Reg].NrOfMods
|
Found := PPaiProp(Pai(p)^.line)^.Regs[Reg].NrOfMods
|
||||||
End
|
End
|
||||||
|
End
|
||||||
Else CheckSequence := True;
|
Else CheckSequence := True;
|
||||||
End; {CheckSequence}
|
End; {CheckSequence}
|
||||||
|
|
||||||
@ -821,6 +833,7 @@ Begin
|
|||||||
ait_label: DestroyAllRegs(p);
|
ait_label: DestroyAllRegs(p);
|
||||||
ait_labeled_instruction, ait_stabs, ait_stabn,
|
ait_labeled_instruction, ait_stabs, ait_stabn,
|
||||||
ait_stab_function_name:; {nothing changes}
|
ait_stab_function_name:; {nothing changes}
|
||||||
|
ait_regalloc, ait_regdealloc:;
|
||||||
ait_instruction:
|
ait_instruction:
|
||||||
Begin
|
Begin
|
||||||
InstrProp := AsmInstr[Pai386(p)^._operator];
|
InstrProp := AsmInstr[Pai386(p)^._operator];
|
||||||
@ -984,7 +997,7 @@ Begin
|
|||||||
(PPaiProp(Pai(p^.last)^.line)^.DirFlag = F_NotSet) Then
|
(PPaiProp(Pai(p^.last)^.line)^.DirFlag = F_NotSet) Then
|
||||||
PPaiProp(Pai(p)^.line)^.CanBeRemoved := True;
|
PPaiProp(Pai(p)^.line)^.CanBeRemoved := True;
|
||||||
{$IfDef OptimizeMovs}
|
{$IfDef OptimizeMovs}
|
||||||
A_MOV{, A_MOVZX, A_MOVSX}:
|
A_MOV, A_MOVZX, A_MOVSX:
|
||||||
Begin
|
Begin
|
||||||
Case Pai386(p)^.op1t Of
|
Case Pai386(p)^.op1t Of
|
||||||
{ Top_Reg:
|
{ Top_Reg:
|
||||||
@ -1178,7 +1191,10 @@ End;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.2 1998-04-06 22:42:32 jonas
|
Revision 1.3 1998-04-16 16:53:56 jonas
|
||||||
|
*** empty log message ***
|
||||||
|
|
||||||
|
Revision 1.2 1998/04/06 22:42:32 jonas
|
||||||
+ removal of superflouos cld/std instructions
|
+ removal of superflouos cld/std instructions
|
||||||
|
|
||||||
Revision 1.1.1.1 1998/03/25 11:18:12 root
|
Revision 1.1.1.1 1998/03/25 11:18:12 root
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user