|
@@ -34,6 +34,9 @@ unit cgobj;
|
|
|
|
|
|
pcg = ^tcg;
|
|
|
tcg = object
|
|
|
+ constructor init;
|
|
|
+ destructor done;virtual;
|
|
|
+
|
|
|
procedure a_call_name_ext(list : paasmoutput;const s : string;
|
|
|
offset : longint;m : texternal_typ);
|
|
|
|
|
@@ -75,7 +78,7 @@ unit cgobj;
|
|
|
procedure a_load_const64_ref(list : paasmoutput;q : qword;const ref : treference);virtual;
|
|
|
|
|
|
|
|
|
- procedure g_stackframe_entry(list : paasmoutput;localsize : longint);
|
|
|
+ procedure g_stackframe_entry(list : paasmoutput;localsize : longint);virtual;
|
|
|
procedure g_maybe_loadself(list : paasmoutput);virtual;
|
|
|
|
|
|
{********************************************************}
|
|
@@ -113,6 +116,16 @@ unit cgobj;
|
|
|
{$endif i386}
|
|
|
;
|
|
|
|
|
|
+ constructor tcg.init;
|
|
|
+
|
|
|
+ begin
|
|
|
+ end;
|
|
|
+
|
|
|
+ destructor tcg.done;
|
|
|
+
|
|
|
+ begin
|
|
|
+ end;
|
|
|
+
|
|
|
{*****************************************************************************
|
|
|
per default, this methods nothing, can overriden
|
|
|
*****************************************************************************}
|
|
@@ -534,7 +547,7 @@ unit cgobj;
|
|
|
var
|
|
|
hs : string;
|
|
|
hp : pused_unit;
|
|
|
- unitinits,initcode : taasmoutput;
|
|
|
+ initcode : taasmoutput;
|
|
|
{$ifdef GDB}
|
|
|
stab_function_name : Pai_stab_function_name;
|
|
|
{$endif GDB}
|
|
@@ -552,6 +565,52 @@ unit cgobj;
|
|
|
if not(cs_littlesize in aktglobalswitches) then
|
|
|
list^.insert(new(pai_align,init(4)));
|
|
|
end;
|
|
|
+ { save registers on cdecl }
|
|
|
+ if ((aktprocsym^.definition^.options and pocdecl)<>0) then
|
|
|
+ begin
|
|
|
+ for r:=firstregister to lastregister do
|
|
|
+ begin
|
|
|
+ if (r in registers_saved_on_cdecl) then
|
|
|
+ if (r in general_registers) then
|
|
|
+ begin
|
|
|
+ if not(r in unused) then
|
|
|
+ a_push_reg(list,r)
|
|
|
+ end
|
|
|
+ else
|
|
|
+ a_push_reg(list,r);
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ { omit stack frame ? }
|
|
|
+ if not inlined then
|
|
|
+ if procinfo.framepointer=stack_pointer then
|
|
|
+ begin
|
|
|
+ CGMessage(cg_d_stackframe_omited);
|
|
|
+ nostackframe:=true;
|
|
|
+ if (aktprocsym^.definition^.options and (pounitinit or poproginit or pounitfinalize)<>0) then
|
|
|
+ parasize:=0
|
|
|
+ else
|
|
|
+ parasize:=aktprocsym^.definition^.parast^.datasize+procinfo.call_offset-4;
|
|
|
+ end
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ if (aktprocsym^.definition^.options and (pounitinit or poproginit or pounitfinalize)<>0) then
|
|
|
+ parasize:=0
|
|
|
+ else
|
|
|
+ parasize:=aktprocsym^.definition^.parast^.datasize+procinfo.call_offset-8;
|
|
|
+ nostackframe:=false;
|
|
|
+
|
|
|
+ if (aktprocsym^.definition^.options and pointerrupt)<>0 then
|
|
|
+ g_interrupt_stackframe_entry(list);
|
|
|
+
|
|
|
+ g_stackframe_entry(list,stackframe);
|
|
|
+
|
|
|
+ if (cs_check_stack in aktlocalswitches) and
|
|
|
+ (tf_supports_stack_checking in target_info.flags) then
|
|
|
+ g_stackcheck(@initcode,stackframe);
|
|
|
+ end;
|
|
|
+
|
|
|
+ if cs_profile in aktmoduleswitches then
|
|
|
+ g_profilecode(@initcode);
|
|
|
if (not inlined) and ((aktprocsym^.definition^.options and poproginit)<>0) then
|
|
|
begin
|
|
|
|
|
@@ -566,20 +625,15 @@ unit cgobj;
|
|
|
stringdispose(hr.symbol);
|
|
|
end;
|
|
|
|
|
|
- { Call the unit init procedures }
|
|
|
- unitinits.init;
|
|
|
-
|
|
|
hp:=pused_unit(usedunits.first);
|
|
|
while assigned(hp) do
|
|
|
begin
|
|
|
{ call the unit init code and make it external }
|
|
|
if (hp^.u^.flags and uf_init)<>0 then
|
|
|
- a_call_name_ext(@unitinits,
|
|
|
+ a_call_name_ext(list,
|
|
|
'INIT$$'+hp^.u^.modulename^,0,EXT_NEAR);
|
|
|
hp:=Pused_unit(hp^.next);
|
|
|
end;
|
|
|
- list^.insertlist(@unitinits);
|
|
|
- unitinits.done;
|
|
|
end;
|
|
|
|
|
|
{ a constructor needs a help procedure }
|
|
@@ -607,54 +661,6 @@ unit cgobj;
|
|
|
list^.insert(new(pai_force_line,init));
|
|
|
{$endif GDB}
|
|
|
|
|
|
- { save registers on cdecl }
|
|
|
- if ((aktprocsym^.definition^.options and pocdecl)<>0) then
|
|
|
- begin
|
|
|
- for r:=firstregister to lastregister do
|
|
|
- begin
|
|
|
- if (r in registers_saved_on_cdecl) then
|
|
|
- if (r in general_registers) then
|
|
|
- begin
|
|
|
- if not(r in unused) then
|
|
|
- a_push_reg(list,r)
|
|
|
- end
|
|
|
- else
|
|
|
- a_push_reg(list,r);
|
|
|
- end;
|
|
|
- end;
|
|
|
-
|
|
|
- { omit stack frame ? }
|
|
|
- if not inlined then
|
|
|
- if procinfo.framepointer=stack_pointer then
|
|
|
- begin
|
|
|
- CGMessage(cg_d_stackframe_omited);
|
|
|
- nostackframe:=true;
|
|
|
- if (aktprocsym^.definition^.options and (pounitinit or poproginit or pounitfinalize)<>0) then
|
|
|
- parasize:=0
|
|
|
- else
|
|
|
- parasize:=aktprocsym^.definition^.parast^.datasize+procinfo.call_offset-4;
|
|
|
- end
|
|
|
- else
|
|
|
- begin
|
|
|
- if (aktprocsym^.definition^.options and (pounitinit or poproginit or pounitfinalize)<>0) then
|
|
|
- parasize:=0
|
|
|
- else
|
|
|
- parasize:=aktprocsym^.definition^.parast^.datasize+procinfo.call_offset-8;
|
|
|
- nostackframe:=false;
|
|
|
-
|
|
|
- if (aktprocsym^.definition^.options and pointerrupt)<>0 then
|
|
|
- g_interrupt_stackframe_entry(list);
|
|
|
-
|
|
|
- g_stackframe_entry(list,stackframe);
|
|
|
-
|
|
|
- if (cs_check_stack in aktlocalswitches) and
|
|
|
- (tf_supports_stack_checking in target_info.flags) then
|
|
|
- g_stackcheck(@initcode,stackframe);
|
|
|
- end;
|
|
|
-
|
|
|
- if cs_profile in aktmoduleswitches then
|
|
|
- g_profilecode(@initcode);
|
|
|
-
|
|
|
{ initialize return value }
|
|
|
if is_ansistring(procinfo.retdef) or
|
|
|
is_widestring(procinfo.retdef) then
|
|
@@ -925,7 +931,11 @@ unit cgobj;
|
|
|
end.
|
|
|
{
|
|
|
$Log$
|
|
|
- Revision 1.4 1999-01-13 22:52:36 florian
|
|
|
+ Revision 1.5 1999-01-23 23:29:46 florian
|
|
|
+ * first running version of the new code generator
|
|
|
+ * when compiling exceptions under Linux fixed
|
|
|
+
|
|
|
+ Revision 1.4 1999/01/13 22:52:36 florian
|
|
|
+ YES, finally the new code generator is compilable, but it doesn't run yet :(
|
|
|
|
|
|
Revision 1.3 1998/12/26 15:20:30 florian
|