* the main branch psub.pas is now used for

newcg compiler
This commit is contained in:
florian 1999-08-02 21:28:56 +00:00
parent 4f74c54c09
commit eac806034d
9 changed files with 153 additions and 1475 deletions

View File

@ -41,12 +41,12 @@
{$ifdef FPC} {$ifdef FPC}
{ One of Alpha, I386 or M68K must be defined } { One of Alpha, I386 or M68K must be defined }
{$UNDEFINE CPUOK} {$UNDEF CPUOK}
{$ifdef I386} {$ifdef I386}
{$define CPUOK} {$define CPUOK}
{$endif} {$endif}
{$ifdef M68K} {$ifdef M68K}
{$ifndef CPUOK} {$ifndef CPUOK}
{$DEFINE CPUOK} {$DEFINE CPUOK}
@ -290,7 +290,11 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.26 1999-08-02 20:46:57 michael Revision 1.27 1999-08-02 21:28:56 florian
* the main branch psub.pas is now used for
newcg compiler
Revision 1.26 1999/08/02 20:46:57 michael
* Alpha aware switch detection * Alpha aware switch detection
Revision 1.25 1999/07/18 14:47:22 florian Revision 1.25 1999/07/18 14:47:22 florian

View File

@ -464,24 +464,6 @@ const
{$endif} {$endif}
{*****************************************************************************
Operands
*****************************************************************************}
{ Types of operand }
toptype=(top_none,top_reg,top_ref,top_const,top_symbol);
toper=record
ot : longint;
case typ : toptype of
top_none : ();
top_reg : (reg:tregister);
top_ref : (ref:preference);
top_const : (val:longint);
top_symbol : (sym:pasmsymbol;symofs:longint);
end;
{***************************************************************************** {*****************************************************************************
Conditions Conditions
*****************************************************************************} *****************************************************************************}
@ -656,7 +638,22 @@ type
options : trefoptions; options : trefoptions;
end; end;
{*****************************************************************************
Operands
*****************************************************************************}
{ Types of operand }
toptype=(top_none,top_reg,top_ref,top_const,top_symbol);
toper=record
ot : longint;
case typ : toptype of
top_none : ();
top_reg : (reg:tregister);
top_ref : (ref:preference);
top_const : (val:longint);
top_symbol : (sym:pasmsymbol;symofs:longint);
end;
{***************************************************************************** {*****************************************************************************
Generic Location Generic Location
@ -1007,7 +1004,11 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.9 1999-08-02 21:01:45 michael Revision 1.10 1999-08-02 21:28:58 florian
* the main branch psub.pas is now used for
newcg compiler
Revision 1.9 1999/08/02 21:01:45 michael
* Moved toperand type back =( * Moved toperand type back =(
Revision 1.8 1999/08/02 20:45:49 michael Revision 1.8 1999/08/02 20:45:49 michael

View File

@ -57,7 +57,7 @@
{$endif GDB} {$endif GDB}
{ One of Alpha, I386 or M68K must be defined } { One of Alpha, I386 or M68K must be defined }
{$UNDEFINE CPUOK} {$UNDEF CPUOK}
{$ifdef I386} {$ifdef I386}
{$define CPUOK} {$define CPUOK}
@ -270,7 +270,11 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.4 1999-08-02 17:15:03 michael Revision 1.5 1999-08-02 21:29:06 florian
* the main branch psub.pas is now used for
newcg compiler
Revision 1.4 1999/08/02 17:15:03 michael
+ CPU check better + CPU check better
Revision 1.3 1999/08/02 17:14:10 florian Revision 1.3 1999/08/02 17:14:10 florian

File diff suppressed because it is too large Load Diff

View File

@ -24,12 +24,34 @@ unit tgeni386;
interface interface
procedure cleartempgen;
procedure resettempgen;
implementation implementation
uses
tgcpu;
procedure cleartempgen;
begin
tg.cleartempgen;
end;
procedure resettempgen;
begin
tg.resettempgen;
end;
end. end.
{ {
$Log$ $Log$
Revision 1.1 1999-08-02 17:15:05 florian Revision 1.2 1999-08-02 21:29:09 florian
* the main branch psub.pas is now used for
newcg compiler
Revision 1.1 1999/08/02 17:15:05 florian
* dummy implementation * dummy implementation
} }

View File

@ -727,6 +727,7 @@ unit pstatmnt;
{ Read first the _ASM statement } { Read first the _ASM statement }
consume(_ASM); consume(_ASM);
{$ifndef newcg}
{ END is read } { END is read }
if try_to_consume(LECKKLAMMER) then if try_to_consume(LECKKLAMMER) then
begin begin
@ -773,6 +774,7 @@ unit pstatmnt;
consume(RECKKLAMMER); consume(RECKKLAMMER);
end end
else usedinproc:=$ff; else usedinproc:=$ff;
{$endif newcg}
{ mark the start and the end of the assembler block for the optimizer } { mark the start and the end of the assembler block for the optimizer }
@ -1169,6 +1171,7 @@ unit pstatmnt;
{opsym^.address:=procinfo.call_offset; is wrong PM } {opsym^.address:=procinfo.call_offset; is wrong PM }
opsym^.address:=-procinfo.retoffset; opsym^.address:=-procinfo.retoffset;
{ eax is modified by a function } { eax is modified by a function }
{$ifndef newcg}
{$ifdef i386} {$ifdef i386}
usedinproc:=usedinproc or ($80 shr byte(R_EAX)); usedinproc:=usedinproc or ($80 shr byte(R_EAX));
@ -1181,6 +1184,7 @@ unit pstatmnt;
if is_64bitint(procinfo.retdef) then if is_64bitint(procinfo.retdef) then
usedinproc:=usedinproc or ($800 shr byte(R_D1)) usedinproc:=usedinproc or ($800 shr byte(R_D1))
{$endif} {$endif}
{$endif newcg}
end; end;
end; end;
@ -1238,12 +1242,14 @@ unit pstatmnt;
procinfo.retoffset:=procinfo.firsttemp-procinfo.retdef^.size; procinfo.retoffset:=procinfo.firsttemp-procinfo.retdef^.size;
procinfo.firsttemp:=procinfo.retoffset; } procinfo.firsttemp:=procinfo.retoffset; }
{$ifndef newcg}
{$ifdef i386} {$ifdef i386}
usedinproc:=usedinproc or ($80 shr byte(R_EAX)) usedinproc:=usedinproc or ($80 shr byte(R_EAX))
{$endif} {$endif}
{$ifdef m68k} {$ifdef m68k}
usedinproc:=usedinproc or ($800 shr word(R_D0)) usedinproc:=usedinproc or ($800 shr word(R_D0))
{$endif} {$endif}
{$endif newcg}
end end
{ {
else if not is_fpu(procinfo.retdef) then else if not is_fpu(procinfo.retdef) then
@ -1278,7 +1284,11 @@ unit pstatmnt;
end. end.
{ {
$Log$ $Log$
Revision 1.92 1999-07-26 09:42:14 florian Revision 1.93 1999-08-02 21:28:59 florian
* the main branch psub.pas is now used for
newcg compiler
Revision 1.92 1999/07/26 09:42:14 florian
* bugs 494-496 fixed * bugs 494-496 fixed
Revision 1.91 1999/06/30 22:16:22 florian Revision 1.91 1999/06/30 22:16:22 florian

View File

@ -62,7 +62,10 @@ uses
{$ifdef dummy} {$ifdef dummy}
end { avoid the stupid highlighting of the TP IDE } end { avoid the stupid highlighting of the TP IDE }
{$endif dummy} {$endif dummy}
,tgeni386,cgai386 ,tgeni386
{$ifndef newcg}
,cgai386
{$endif newcg}
{$ifndef NoOpt} {$ifndef NoOpt}
,aopt386 ,aopt386
{$endif} {$endif}
@ -72,6 +75,9 @@ uses
{$endif} {$endif}
{ parser specific stuff } { parser specific stuff }
,pbase,pdecl,pexpr,pstatmnt ,pbase,pdecl,pexpr,pstatmnt
{$ifdef newcg}
,tgcpu,convtree,cgobj
{$endif newcg}
; ;
var var
@ -1367,7 +1373,11 @@ var
{ switches can change inside the procedure } { switches can change inside the procedure }
entryswitches, exitswitches : tlocalswitches; entryswitches, exitswitches : tlocalswitches;
{ code for the subroutine as tree } { code for the subroutine as tree }
{$ifdef newcg}
code:pnode;
{$else newcg}
code:ptree; code:ptree;
{$endif newcg}
{ size of the local strackframe } { size of the local strackframe }
stackframe:longint; stackframe:longint;
{ true when no stackframe is required } { true when no stackframe is required }
@ -1438,18 +1448,29 @@ begin
{ reset the temporary memory } { reset the temporary memory }
cleartempgen; cleartempgen;
{$ifdef newcg}
tg.usedinproc:=[];
{$else newcg}
{ no registers are used } { no registers are used }
usedinproc:=0; usedinproc:=0;
{$endif newcg}
{ save entry info } { save entry info }
entrypos:=aktfilepos; entrypos:=aktfilepos;
entryswitches:=aktlocalswitches; entryswitches:=aktlocalswitches;
{$ifdef newcg}
{ parse the code ... }
if (aktprocsym^.definition^.options and poassembler)<> 0 then
code:=convtree2node(assembler_block)
else
code:=convtree2node(block(current_module^.islibrary));
{$else newcg}
{ parse the code ... } { parse the code ... }
if (aktprocsym^.definition^.options and poassembler)<> 0 then if (aktprocsym^.definition^.options and poassembler)<> 0 then
code:=assembler_block code:=assembler_block
else else
code:=block(current_module^.islibrary); code:=block(current_module^.islibrary);
{$endif newcg}
{ get a better entry point } { get a better entry point }
if assigned(code) then if assigned(code) then
@ -1470,14 +1491,22 @@ begin
{ set the framepointer to esp for assembler functions } { set the framepointer to esp for assembler functions }
{ but only if the are no local variables } { but only if the are no local variables }
{ already done in assembler_block } { already done in assembler_block }
{$ifdef newcg}
tg.setfirsttemp(procinfo.firsttemp);
{$else newcg}
setfirsttemp(procinfo.firsttemp); setfirsttemp(procinfo.firsttemp);
{$endif newcg}
{ ... and generate assembler } { ... and generate assembler }
{ but set the right switches for entry !! } { but set the right switches for entry !! }
aktlocalswitches:=entryswitches; aktlocalswitches:=entryswitches;
{$ifndef NOPASS2} {$ifndef NOPASS2}
{$ifdef newcg}
tg.setfirsttemp(procinfo.firsttemp);
{$else newcg}
if assigned(code) then if assigned(code) then
generatecode(code); generatecode(code);
{$endif newcg}
{ set switches to status at end of procedure } { set switches to status at end of procedure }
aktlocalswitches:=exitswitches; aktlocalswitches:=exitswitches;
@ -1487,23 +1516,40 @@ begin
{ the procedure is now defined } { the procedure is now defined }
aktprocsym^.definition^.forwarddef:=false; aktprocsym^.definition^.forwarddef:=false;
{$ifdef newcg}
aktprocsym^.definition^.usedregisters:=tg.usedinproc;
{$else newcg}
aktprocsym^.definition^.usedregisters:=usedinproc; aktprocsym^.definition^.usedregisters:=usedinproc;
{$endif newcg}
end; end;
{$ifdef newcg}
stackframe:=tg.gettempsize;
{$else newcg}
stackframe:=gettempsize; stackframe:=gettempsize;
{$endif newcg}
{ first generate entry code with the correct position and switches } { first generate entry code with the correct position and switches }
aktfilepos:=entrypos; aktfilepos:=entrypos;
aktlocalswitches:=entryswitches; aktlocalswitches:=entryswitches;
{$ifdef newcg}
if assigned(code) then
cg^.g_entrycode(procinfo.aktentrycode,proc_names,make_global,stackframe,parasize,nostackframe,false);
{$else newcg}
if assigned(code) then if assigned(code) then
genentrycode(procinfo.aktentrycode,proc_names,make_global,stackframe,parasize,nostackframe,false); genentrycode(procinfo.aktentrycode,proc_names,make_global,stackframe,parasize,nostackframe,false);
{$endif newcg}
{ now generate exit code with the correct position and switches } { now generate exit code with the correct position and switches }
aktfilepos:=exitpos; aktfilepos:=exitpos;
aktlocalswitches:=exitswitches; aktlocalswitches:=exitswitches;
if assigned(code) then if assigned(code) then
begin begin
{$ifdef newcg}
cg^.g_exitcode(procinfo.aktexitcode,parasize,nostackframe,false);
{$else newcg}
genexitcode(procinfo.aktexitcode,parasize,nostackframe,false); genexitcode(procinfo.aktexitcode,parasize,nostackframe,false);
{$endif newcg}
procinfo.aktproccode^.insertlist(procinfo.aktentrycode); procinfo.aktproccode^.insertlist(procinfo.aktentrycode);
procinfo.aktproccode^.concatlist(procinfo.aktexitcode); procinfo.aktproccode^.concatlist(procinfo.aktexitcode);
{$ifdef i386} {$ifdef i386}
@ -1581,7 +1627,11 @@ begin
{ remove code tree, if not inline procedure } { remove code tree, if not inline procedure }
if assigned(code) and ((aktprocsym^.definition^.options and poinline)=0) then if assigned(code) and ((aktprocsym^.definition^.options and poinline)=0) then
{$ifdef newcg}
dispose(code,done);
{$else newcg}
disposetree(code); disposetree(code);
{$endif newcg}
{ remove class member symbol tables } { remove class member symbol tables }
while symtablestack^.symtabletype=objectsymtable do while symtablestack^.symtabletype=objectsymtable do
@ -1854,7 +1904,11 @@ end.
{ {
$Log$ $Log$
Revision 1.6 1999-07-27 23:42:16 peter Revision 1.7 1999-08-02 21:29:01 florian
* the main branch psub.pas is now used for
newcg compiler
Revision 1.6 1999/07/27 23:42:16 peter
* indirect type referencing is now allowed * indirect type referencing is now allowed
Revision 1.5 1999/07/26 09:42:15 florian Revision 1.5 1999/07/26 09:42:15 florian

View File

@ -2376,6 +2376,9 @@
end; end;
lastref:=defref; lastref:=defref;
{ first, we assume that all registers are used } { first, we assume that all registers are used }
{$ifdef newcg}
usedregisters:=[firstreg..lastreg];
{$else newcg}
{$ifdef i386} {$ifdef i386}
usedregisters:=$ff; usedregisters:=$ff;
{$endif i386} {$endif i386}
@ -2386,6 +2389,7 @@
usedregisters_int:=$ffffffff; usedregisters_int:=$ffffffff;
usedregisters_fpu:=$ffffffff; usedregisters_fpu:=$ffffffff;
{$endif alpha} {$endif alpha}
{$endif newcg}
forwarddef:=true; forwarddef:=true;
interfacedef:=false; interfacedef:=false;
_class := nil; _class := nil;
@ -2401,6 +2405,10 @@
begin begin
inherited load; inherited load;
deftype:=procdef; deftype:=procdef;
{$ifdef newcg}
readnormalset(usedregisters);
{$else newcg}
{$ifdef i386} {$ifdef i386}
usedregisters:=readbyte; usedregisters:=readbyte;
{$endif i386} {$endif i386}
@ -2411,7 +2419,7 @@
usedregisters_int:=readlong; usedregisters_int:=readlong;
usedregisters_fpu:=readlong; usedregisters_fpu:=readlong;
{$endif alpha} {$endif alpha}
{$endif newcg}
s:=readstring; s:=readstring;
setstring(_mangledname,s); setstring(_mangledname,s);
@ -2600,6 +2608,9 @@ Const local_symtable_index : longint = $8001;
begin begin
inherited write; inherited write;
current_ppu^.do_interface_crc:=false; current_ppu^.do_interface_crc:=false;
{$ifdef newcg}
writenormalset(usedregisters);
{$else newcg}
{$ifdef i386} {$ifdef i386}
writebyte(usedregisters); writebyte(usedregisters);
{$endif i386} {$endif i386}
@ -2610,6 +2621,7 @@ Const local_symtable_index : longint = $8001;
writelong(usedregisters_int); writelong(usedregisters_int);
writelong(usedregisters_fpu); writelong(usedregisters_fpu);
{$endif alpha} {$endif alpha}
{$endif newcg}
writestring(mangledname); writestring(mangledname);
current_ppu^.do_interface_crc:=true; current_ppu^.do_interface_crc:=true;
writelong(extnumber); writelong(extnumber);
@ -3531,7 +3543,11 @@ Const local_symtable_index : longint = $8001;
{ {
$Log$ $Log$
Revision 1.137 1999-07-31 22:37:17 michael Revision 1.138 1999-08-02 21:29:02 florian
* the main branch psub.pas is now used for
newcg compiler
Revision 1.137 1999/07/31 22:37:17 michael
* Fix of initialization information generation * Fix of initialization information generation
Revision 1.136 1999/07/29 20:54:07 peter Revision 1.136 1999/07/29 20:54:07 peter

View File

@ -418,6 +418,9 @@
count : boolean; count : boolean;
is_used : boolean; is_used : boolean;
{ set which contains the modified registers } { set which contains the modified registers }
{$ifdef newcg}
usedregisters : tregisterset;
{$else newcg}
{$ifdef i386} {$ifdef i386}
usedregisters : byte; usedregisters : byte;
{$endif} {$endif}
@ -428,6 +431,7 @@
usedregisters_int : longint; usedregisters_int : longint;
usedregisters_fpu : longint; usedregisters_fpu : longint;
{$endif} {$endif}
{$endif newcg}
constructor init; constructor init;
destructor done;virtual; destructor done;virtual;
constructor load; constructor load;
@ -527,7 +531,11 @@
{ {
$Log$ $Log$
Revision 1.35 1999-07-27 23:42:20 peter Revision 1.36 1999-08-02 21:29:04 florian
* the main branch psub.pas is now used for
newcg compiler
Revision 1.35 1999/07/27 23:42:20 peter
* indirect type referencing is now allowed * indirect type referencing is now allowed
Revision 1.34 1999/07/23 16:05:30 peter Revision 1.34 1999/07/23 16:05:30 peter