* 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}
{ One of Alpha, I386 or M68K must be defined }
{$UNDEFINE CPUOK}
{$UNDEF CPUOK}
{$ifdef I386}
{$define CPUOK}
{$endif}
{$ifdef M68K}
{$ifndef CPUOK}
{$DEFINE CPUOK}
@ -290,7 +290,11 @@ end;
end.
{
$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
Revision 1.25 1999/07/18 14:47:22 florian

View File

@ -464,24 +464,6 @@ const
{$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
*****************************************************************************}
@ -656,7 +638,22 @@ type
options : trefoptions;
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
@ -1007,7 +1004,11 @@ begin
end.
{
$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 =(
Revision 1.8 1999/08/02 20:45:49 michael

View File

@ -57,7 +57,7 @@
{$endif GDB}
{ One of Alpha, I386 or M68K must be defined }
{$UNDEFINE CPUOK}
{$UNDEF CPUOK}
{$ifdef I386}
{$define CPUOK}
@ -270,7 +270,11 @@ begin
end.
{
$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
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
procedure cleartempgen;
procedure resettempgen;
implementation
uses
tgcpu;
procedure cleartempgen;
begin
tg.cleartempgen;
end;
procedure resettempgen;
begin
tg.resettempgen;
end;
end.
{
$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
}

View File

@ -727,6 +727,7 @@ unit pstatmnt;
{ Read first the _ASM statement }
consume(_ASM);
{$ifndef newcg}
{ END is read }
if try_to_consume(LECKKLAMMER) then
begin
@ -773,6 +774,7 @@ unit pstatmnt;
consume(RECKKLAMMER);
end
else usedinproc:=$ff;
{$endif newcg}
{ 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.retoffset;
{ eax is modified by a function }
{$ifndef newcg}
{$ifdef i386}
usedinproc:=usedinproc or ($80 shr byte(R_EAX));
@ -1181,6 +1184,7 @@ unit pstatmnt;
if is_64bitint(procinfo.retdef) then
usedinproc:=usedinproc or ($800 shr byte(R_D1))
{$endif}
{$endif newcg}
end;
end;
@ -1238,12 +1242,14 @@ unit pstatmnt;
procinfo.retoffset:=procinfo.firsttemp-procinfo.retdef^.size;
procinfo.firsttemp:=procinfo.retoffset; }
{$ifndef newcg}
{$ifdef i386}
usedinproc:=usedinproc or ($80 shr byte(R_EAX))
{$endif}
{$ifdef m68k}
usedinproc:=usedinproc or ($800 shr word(R_D0))
{$endif}
{$endif newcg}
end
{
else if not is_fpu(procinfo.retdef) then
@ -1278,7 +1284,11 @@ unit pstatmnt;
end.
{
$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
Revision 1.91 1999/06/30 22:16:22 florian

View File

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

View File

@ -2376,6 +2376,9 @@
end;
lastref:=defref;
{ first, we assume that all registers are used }
{$ifdef newcg}
usedregisters:=[firstreg..lastreg];
{$else newcg}
{$ifdef i386}
usedregisters:=$ff;
{$endif i386}
@ -2386,6 +2389,7 @@
usedregisters_int:=$ffffffff;
usedregisters_fpu:=$ffffffff;
{$endif alpha}
{$endif newcg}
forwarddef:=true;
interfacedef:=false;
_class := nil;
@ -2401,6 +2405,10 @@
begin
inherited load;
deftype:=procdef;
{$ifdef newcg}
readnormalset(usedregisters);
{$else newcg}
{$ifdef i386}
usedregisters:=readbyte;
{$endif i386}
@ -2411,7 +2419,7 @@
usedregisters_int:=readlong;
usedregisters_fpu:=readlong;
{$endif alpha}
{$endif newcg}
s:=readstring;
setstring(_mangledname,s);
@ -2600,6 +2608,9 @@ Const local_symtable_index : longint = $8001;
begin
inherited write;
current_ppu^.do_interface_crc:=false;
{$ifdef newcg}
writenormalset(usedregisters);
{$else newcg}
{$ifdef i386}
writebyte(usedregisters);
{$endif i386}
@ -2610,6 +2621,7 @@ Const local_symtable_index : longint = $8001;
writelong(usedregisters_int);
writelong(usedregisters_fpu);
{$endif alpha}
{$endif newcg}
writestring(mangledname);
current_ppu^.do_interface_crc:=true;
writelong(extnumber);
@ -3531,7 +3543,11 @@ Const local_symtable_index : longint = $8001;
{
$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
Revision 1.136 1999/07/29 20:54:07 peter

View File

@ -418,6 +418,9 @@
count : boolean;
is_used : boolean;
{ set which contains the modified registers }
{$ifdef newcg}
usedregisters : tregisterset;
{$else newcg}
{$ifdef i386}
usedregisters : byte;
{$endif}
@ -428,6 +431,7 @@
usedregisters_int : longint;
usedregisters_fpu : longint;
{$endif}
{$endif newcg}
constructor init;
destructor done;virtual;
constructor load;
@ -527,7 +531,11 @@
{
$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
Revision 1.34 1999/07/23 16:05:30 peter