diff --git a/compiler/aasm.pas b/compiler/aasm.pas index cf94fbcf66..6563cc1b05 100644 --- a/compiler/aasm.pas +++ b/compiler/aasm.pas @@ -64,8 +64,8 @@ unit aasm; ait_force_line, ait_stab_function_name, ait_cut, { used to split into tiny assembler files } - ait_regalloc, - ait_regdealloc, + ait_regalloc, { for register,temp allocation debugging } + ait_tempalloc, ait_marker, { never used, makes insertation of new ait_ easier to type } ait_dummy); @@ -1013,7 +1013,11 @@ uses end. { $Log$ - Revision 1.38 1999-04-14 09:14:44 peter + Revision 1.39 1999-04-16 11:49:36 peter + + tempalloc + + -at to show temp alloc info in .s file + + Revision 1.38 1999/04/14 09:14:44 peter * first things to store the symbol/def number in the ppu Revision 1.37 1999/03/10 13:25:42 pierre diff --git a/compiler/ag386int.pas b/compiler/ag386int.pas index 0e92a6efef..11db826ecc 100644 --- a/compiler/ag386int.pas +++ b/compiler/ag386int.pas @@ -391,8 +391,8 @@ unit ag386int; AsmWritePChar(pai_asm_comment(hp)^.str); AsmLn; End; - ait_regalloc, - ait_regdealloc :; + ait_regalloc, + ait_tempalloc : ; ait_section : begin if LastSec<>sec_none then AsmWriteLn('_'+ait_section2masmstr[LastSec]+#9#9'ENDS'); @@ -795,7 +795,11 @@ ait_stab_function_name : ; end. { $Log$ - Revision 1.31 1999-04-16 10:00:55 pierre + Revision 1.32 1999-04-16 11:49:39 peter + + tempalloc + + -at to show temp alloc info in .s file + + Revision 1.31 1999/04/16 10:00:55 pierre + ifdef USE_OP3 code : added all missing op_... constructors for tai386 needed for SHRD,SHLD and IMUL code in assembler readers diff --git a/compiler/ag386nsm.pas b/compiler/ag386nsm.pas index f360703427..bfa28bd294 100644 --- a/compiler/ag386nsm.pas +++ b/compiler/ag386nsm.pas @@ -402,8 +402,8 @@ unit ag386nsm; AsmWritePChar(pai_asm_comment(hp)^.str); AsmLn; End; - ait_regalloc, - ait_regdealloc :; + ait_regalloc, + ait_tempalloc : ; ait_section : begin if pai_section(hp)^.sec<>sec_none then begin @@ -740,7 +740,11 @@ ait_stab_function_name : ; end. { $Log$ - Revision 1.26 1999-04-16 10:00:56 pierre + Revision 1.27 1999-04-16 11:49:40 peter + + tempalloc + + -at to show temp alloc info in .s file + + Revision 1.26 1999/04/16 10:00:56 pierre + ifdef USE_OP3 code : added all missing op_... constructors for tai386 needed for SHRD,SHLD and IMUL code in assembler readers diff --git a/compiler/daopt386.pas b/compiler/daopt386.pas index 957b5ec8af..1553aaa8a6 100644 --- a/compiler/daopt386.pas +++ b/compiler/daopt386.pas @@ -87,7 +87,7 @@ Const {$ifdef GDB} ,ait_stabs, ait_stabn, ait_stab_function_name {$endif GDB} - ,ait_regalloc, ait_regdealloc + ,ait_regalloc,ait_tempalloc ]; {the maximum number of things (registers, memory, ...) a single instruction @@ -756,26 +756,29 @@ Begin End; Function FindRegAlloc(Reg: TRegister; StartPai: Pai): Boolean; -{Returns true if a ait_regalloc object for Reg is found in the block of Pai's +{Returns true if a ait_alloc object for Reg is found in the block of Pai's starting with StartPai and ending with the next "real" instruction} -Var TmpResult: Boolean; Begin - TmpResult := False; + FindRegAlloc:=False; Repeat While Assigned(StartPai) And - ((StartPai^.typ in (SkipInstr - [ait_RegAlloc])) Or + ((StartPai^.typ in (SkipInstr - [ait_regAlloc])) Or ((StartPai^.typ = ait_label) and Not(Pai_Label(StartPai)^.l^.Is_Used))) Do StartPai := Pai(StartPai^.Next); If Assigned(StartPai) And - (StartPai^.typ = ait_RegAlloc) Then + (StartPai^.typ = ait_regAlloc) and (PairegAlloc(StartPai)^.allocation) Then Begin - TmpResult := (PaiRegAlloc(StartPai)^.Reg = Reg); + if PairegAlloc(StartPai)^.Reg = Reg then + begin + FindRegAlloc:=true; + exit; + end; StartPai := Pai(StartPai^.Next); - End; - Until Not(Assigned(StartPai)) Or - Not(StartPai^.typ in SkipInstr) or TmpResult; - FindRegAlloc := TmpResult; + End + else + exit; + Until false; End; Procedure BuildLabelTableAndFixRegAlloc(AsmL: PAasmOutput; Var LabelTable: PLabelTable; LowLabel: Longint; @@ -802,45 +805,48 @@ Begin ait_Label: If Pai_Label(p)^.l^.is_used Then LabelTable^[Pai_Label(p)^.l^.nb-LowLabel].PaiObj := p; - ait_RegAlloc: - Begin - If Not(PaiRegAlloc(p)^.Reg in UsedRegs) Then - UsedRegs := UsedRegs + [PaiRegAlloc(p)^.Reg] - Else + ait_regAlloc: + begin + if PairegAlloc(p)^.Allocation then Begin + If Not(PaiRegAlloc(p)^.Reg in UsedRegs) Then + UsedRegs := UsedRegs + [PaiRegAlloc(p)^.Reg] + Else + Begin + hp1 := p; + hp2 := nil; + While GetLastInstruction(hp1, hp1) And + Not(RegInInstruction(PaiRegAlloc(p)^.Reg, hp1)) Do + hp2 := hp1; + If hp2 <> nil Then + Begin + hp1 := New(PaiRegAlloc, DeAlloc(PaiRegAlloc(p)^.Reg)); + InsertLLItem(AsmL, Pai(hp2^.previous), hp2, hp1); + End; + End; + End + else + Begin + UsedRegs := UsedRegs - [PaiRegAlloc(p)^.Reg]; hp1 := p; hp2 := nil; - While GetLastInstruction(hp1, hp1) And - Not(RegInInstruction(PaiRegAlloc(p)^.Reg, hp1)) Do + While Not(FindRegAlloc(PaiRegAlloc(p)^.Reg, Pai(hp1^.Next))) And + GetNextInstruction(hp1, hp1) And + RegInInstruction(PaiRegAlloc(p)^.Reg, hp1) Do hp2 := hp1; - If hp2 <> nil Then - Begin - hp1 := New(PaiRegDeAlloc, Init(PaiRegAlloc(p)^.Reg)); - InsertLLItem(AsmL, Pai(hp2^.previous), hp2, hp1); - End; + If hp2 <> nil Then + Begin + hp1 := Pai(p^.previous); + AsmL^.Remove(p); + InsertLLItem(AsmL, hp2, Pai(hp2^.Next), p); + p := hp1; + End; End; - End; - ait_RegDeAlloc: - Begin - UsedRegs := UsedRegs - [PaiRegDeAlloc(p)^.Reg]; - hp1 := p; - hp2 := nil; - While Not(FindRegAlloc(PaiRegDeAlloc(p)^.Reg, Pai(hp1^.Next))) And - GetNextInstruction(hp1, hp1) And - RegInInstruction(PaiRegDeAlloc(p)^.Reg, hp1) Do - hp2 := hp1; - If hp2 <> nil Then - Begin - hp1 := Pai(p^.previous); - AsmL^.Remove(p); - InsertLLItem(AsmL, hp2, Pai(hp2^.Next), p); - p := hp1; - End; - End; + end; End; P := Pai(p^.Next); While Assigned(p) And - (p^.typ in (SkipInstr - [ait_regdealloc,ait_regalloc])) Do + (p^.typ in (SkipInstr - [ait_regalloc])) Do P := Pai(P^.Next); End; {$IfDef TP} @@ -1240,17 +1246,17 @@ Procedure UpdateUsedRegs(Var UsedRegs: TRegSet; p: Pai); Begin Repeat While Assigned(p) And - ((p^.typ in (SkipInstr - [ait_RegAlloc, ait_RegDealloc])) or + ((p^.typ in (SkipInstr - [ait_RegAlloc])) or ((p^.typ = ait_label) And Not(Pai_Label(p)^.l^.is_used))) Do p := Pai(p^.next); While Assigned(p) And - (p^.typ in [ait_RegAlloc, ait_RegDealloc]) Do + (p^.typ=ait_RegAlloc) Do Begin - Case p^.typ Of - ait_RegAlloc: UsedRegs := UsedRegs + [PaiRegAlloc(p)^.Reg]; - ait_regdealloc: UsedRegs := UsedRegs - [PaiRegDeAlloc(p)^.Reg]; - End; + if pairegalloc(p)^.allocation then + UsedRegs := UsedRegs + [PaiRegAlloc(p)^.Reg] + else + UsedRegs := UsedRegs - [PaiRegAlloc(p)^.Reg]; p := pai(p^.next); End; Until Not(Assigned(p)) Or @@ -2227,7 +2233,11 @@ End. { $Log$ - Revision 1.39 1999-02-26 00:48:18 peter + Revision 1.40 1999-04-16 11:49:41 peter + + tempalloc + + -at to show temp alloc info in .s file + + Revision 1.39 1999/02/26 00:48:18 peter * assembler writers fixed for ag386bin Revision 1.38 1999/02/25 21:02:34 peter diff --git a/compiler/globtype.pas b/compiler/globtype.pas index ebf7d18d55..9f789183ac 100644 --- a/compiler/globtype.pas +++ b/compiler/globtype.pas @@ -66,7 +66,8 @@ interface { debugger } cs_gdb_dbx,cs_gdb_gsym,cs_gdb_heaptrc, { assembling } - cs_asm_leave,cs_asm_extern,cs_asm_pipe,cs_asm_source,cs_asm_regalloc, + cs_asm_leave,cs_asm_extern,cs_asm_pipe,cs_asm_source, + cs_asm_regalloc,cs_asm_tempalloc, { linking } cs_link_extern,cs_link_shared,cs_link_static,cs_link_deffile ); @@ -108,7 +109,11 @@ begin end. { $Log$ - Revision 1.5 1999-04-10 16:15:01 peter + Revision 1.6 1999-04-16 11:49:42 peter + + tempalloc + + -at to show temp alloc info in .s file + + Revision 1.5 1999/04/10 16:15:01 peter * fixed browcol + -ar to show regalloc info in .s file diff --git a/compiler/i386.pas b/compiler/i386.pas index c71cc29d07..870da82f43 100644 --- a/compiler/i386.pas +++ b/compiler/i386.pas @@ -1,4 +1,4 @@ -{ +{ $Id$ Copyright (c) 1995-98 by Florian Klaempfl @@ -381,21 +381,23 @@ unit i386; end; pairegalloc = ^tairegalloc; - tairegalloc = object(tai) - reg : tregister; - constructor init(r : tregister); + allocation : boolean; + reg : tregister; + constructor alloc(r : tregister); + constructor dealloc(r : tregister); end; - pairegdealloc = ^tairegdealloc; - - tairegdealloc = object(tai) - reg : tregister; - constructor init(r : tregister); + paitempalloc = ^taitempalloc; + taitempalloc = object(tai) + allocation : boolean; + temppos, + tempsize : longint; + constructor alloc(pos,size:longint); + constructor dealloc(pos,size:longint); end; pai386 = ^tai386; - tai386 = object(tai) opcode : tasmop; opsize:topsize; @@ -1399,22 +1401,45 @@ unit i386; objects for register de/allocation ****************************************************************************} - constructor tairegalloc.init(r : tregister); + constructor tairegalloc.alloc(r : tregister); begin - inherited init; - typ:=ait_regalloc; - reg:=r; + inherited init; + typ:=ait_regalloc; + allocation:=true; + reg:=r; end; - constructor tairegdealloc.init(r : tregister); + constructor tairegalloc.dealloc(r : tregister); begin - inherited init; - typ:=ait_regdealloc; - reg:=r; + inherited init; + typ:=ait_regalloc; + allocation:=false; + reg:=r; end; + + constructor taitempalloc.alloc(pos,size:longint); + begin + inherited init; + typ:=ait_tempalloc; + allocation:=true; + temppos:=pos; + tempsize:=size; + end; + + + constructor taitempalloc.dealloc(pos,size:longint); + begin + inherited init; + typ:=ait_tempalloc; + allocation:=false; + temppos:=pos; + tempsize:=size; + end; + + {**************************************************************************** TAI386 ****************************************************************************} @@ -2041,7 +2066,11 @@ Begin end. { $Log$ - Revision 1.40 1999-04-16 10:00:57 pierre + Revision 1.41 1999-04-16 11:49:43 peter + + tempalloc + + -at to show temp alloc info in .s file + + Revision 1.40 1999/04/16 10:00:57 pierre + ifdef USE_OP3 code : added all missing op_... constructors for tai386 needed for SHRD,SHLD and IMUL code in assembler readers diff --git a/compiler/temp_gen.pas b/compiler/temp_gen.pas index f7b90dbf89..817c87c9cf 100644 --- a/compiler/temp_gen.pas +++ b/compiler/temp_gen.pas @@ -27,7 +27,7 @@ unit temp_gen; uses {$ifdef i386} {$ifdef ag386bin} - i386base, + i386base,i386asm, {$else} i386, {$endif} @@ -236,6 +236,7 @@ unit temp_gen; {$ifdef EXTDEBUG} tl^.posinfo:=aktfilepos; {$endif} + exprasmlist^.concat(new(paitempalloc,alloc(ofs,size))); gettempofsize:=ofs; end; @@ -424,7 +425,7 @@ unit temp_gen; size:=size+(4-(size mod 4)); if size = 0 then exit; - + exprasmlist^.concat(new(paitempalloc,dealloc(pos,size))); if pos<=lastoccupied then if pos=lastoccupied then begin @@ -635,7 +636,11 @@ begin end. { $Log$ - Revision 1.16 1999-04-14 09:10:46 peter + Revision 1.17 1999-04-16 11:49:45 peter + + tempalloc + + -at to show temp alloc info in .s file + + Revision 1.16 1999/04/14 09:10:46 peter * fixed tempansi which set wrong pos in free temp Revision 1.15 1999/04/09 13:05:45 pierre diff --git a/compiler/tgeni386.pas b/compiler/tgeni386.pas index eff0b53465..173282096b 100644 --- a/compiler/tgeni386.pas +++ b/compiler/tgeni386.pas @@ -214,7 +214,7 @@ implementation unused:=unused+[r]; inc(usablereg32); end; - exprasmlist^.concat(new(pairegdealloc,init(r))); + exprasmlist^.concat(new(pairegalloc,dealloc(r))); end; {$ifdef SUPPORT_MMX} @@ -287,28 +287,28 @@ implementation unused:=unused-[R_EAX]; usedinproc:=usedinproc or ($80 shr byte(R_EAX)); getregister32:=R_EAX; - exprasmlist^.concat(new(pairegalloc,init(R_EAX))); + exprasmlist^.concat(new(pairegalloc,alloc(R_EAX))); end else if R_EDX in unused then begin unused:=unused-[R_EDX]; usedinproc:=usedinproc or ($80 shr byte(R_EDX)); getregister32:=R_EDX; - exprasmlist^.concat(new(pairegalloc,init(R_EDX))); + exprasmlist^.concat(new(pairegalloc,alloc(R_EDX))); end else if R_EBX in unused then begin unused:=unused-[R_EBX]; usedinproc:=usedinproc or ($80 shr byte(R_EBX)); getregister32:=R_EBX; - exprasmlist^.concat(new(pairegalloc,init(R_EBX))); + exprasmlist^.concat(new(pairegalloc,alloc(R_EBX))); end else if R_ECX in unused then begin unused:=unused-[R_ECX]; usedinproc:=usedinproc or ($80 shr byte(R_ECX)); getregister32:=R_ECX; - exprasmlist^.concat(new(pairegalloc,init(R_ECX))); + exprasmlist^.concat(new(pairegalloc,alloc(R_ECX))); end else internalerror(10); end; @@ -322,7 +322,7 @@ implementation unused:=unused-[r]; usedinproc:=usedinproc or ($80 shr byte(r)); getexplicitregister32:=R_ECX; - exprasmlist^.concat(new(pairegalloc,init(r))); + exprasmlist^.concat(new(pairegalloc,alloc(r))); getexplicitregister32:=r; end else @@ -373,7 +373,11 @@ begin end. { $Log$ - Revision 1.20 1999-02-25 21:02:55 peter + Revision 1.21 1999-04-16 11:49:47 peter + + tempalloc + + -at to show temp alloc info in .s file + + Revision 1.20 1999/02/25 21:02:55 peter * ag386bin updates + coff writer