From 995f7e0f11d3379b8f68f59402cdf3ccf7733d08 Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 23 May 2003 22:33:48 +0000 Subject: [PATCH] * fix some small flaws which prevent sparc linux system unit from compiling * some reformatting done --- compiler/globals.pas | 14 +++++- compiler/pstatmnt.pas | 7 ++- compiler/sparc/cgcpu.pas | 94 ++++++++++++++++++++++--------------- compiler/sparc/cpuinfo.pas | 11 +++-- compiler/sparc/cpupi.pas | 64 ++++++++++++++----------- compiler/sparc/radirect.pas | 11 +++-- 6 files changed, 125 insertions(+), 76 deletions(-) diff --git a/compiler/globals.pas b/compiler/globals.pas index 4b0c4a66ed..4e25242622 100644 --- a/compiler/globals.pas +++ b/compiler/globals.pas @@ -1560,6 +1560,14 @@ implementation {$ENDIF} initasmmode:=asmmode_direct; {$endif powerpc} +{$ifdef sparc} + initoptprocessor:=SPARC_V8; + initpackenum:=4; + {$IFDEF testvarsets} + initsetalloc:=0; + {$ENDIF} + initasmmode:=asmmode_direct; +{$endif sparc} initinterfacetype:=it_interfacecom; initdefproccall:=pocall_none; initdefines:=TStringList.Create; @@ -1575,7 +1583,11 @@ implementation end. { $Log$ - Revision 1.91 2003-05-23 15:03:31 peter + Revision 1.92 2003-05-23 22:33:48 florian + * fix some small flaws which prevent sparc linux system unit from compiling + * some reformatting done + + Revision 1.91 2003/05/23 15:03:31 peter * fix previous commit for unix Revision 1.90 2003/05/23 14:39:56 peter diff --git a/compiler/pstatmnt.pas b/compiler/pstatmnt.pas index 69aeacff01..662bb4b396 100644 --- a/compiler/pstatmnt.pas +++ b/compiler/pstatmnt.pas @@ -794,7 +794,6 @@ implementation End; asmstat:=tasmnode(radirect.assemble); end; - else Message(parser_f_assembler_reader_not_supported); end; @@ -1175,7 +1174,11 @@ implementation end. { $Log$ - Revision 1.101 2003-05-23 15:15:36 peter + Revision 1.102 2003-05-23 22:33:48 florian + * fix some small flaws which prevent sparc linux system unit from compiling + * some reformatting done + + Revision 1.101 2003/05/23 15:15:36 peter * better error for undefined ordinal labels Revision 1.100 2003/05/17 13:30:08 jonas diff --git a/compiler/sparc/cgcpu.pas b/compiler/sparc/cgcpu.pas index 3b63cc81ba..ac18780edb 100644 --- a/compiler/sparc/cgcpu.pas +++ b/compiler/sparc/cgcpu.pas @@ -962,74 +962,86 @@ procedure TCgSparc.g_overflowCheck(List:TAasmOutput;const p:TNode); a_call_name(list,'FPC_OVERFLOW'); a_label(list,hl); end; + { *********** entry/exit code and address loading ************ } procedure TCgSparc.g_stackframe_entry(list:TAasmOutput;LocalSize:LongInt); var - href:TReference; - r:Tregister; - i:integer; - again:tasmlabel; + r : tregister; begin -{Althogh the SPARC architecture require only word alignment, software -convention and the operating system require every stack frame to be double word -aligned} - LocalSize:=(LocalSize+7)and $FFFFFFF8; -{Execute the SAVE instruction to get a new register window and create a new -stack frame. In the "SAVE %i6,size,%i6" the first %i6 is related to the state -before execution of the SAVE instrucion so it is the caller %i6, when the %i6 -after execution of that instruction is the called function stack pointer} - r.enum:=stack_pointer_reg; - with list do - concat(Taicpu.Op_reg_const_reg(A_SAVE,r,-LocalSize,r)); + { Althogh the SPARC architecture require only word alignment, software + convention and the operating system require every stack frame to be double word + aligned } + LocalSize:=align(LocalSize,8); + { Execute the SAVE instruction to get a new register window and create a new + stack frame. In the "SAVE %i6,size,%i6" the first %i6 is related to the state + before execution of the SAVE instrucion so it is the caller %i6, when the %i6 + after execution of that instruction is the called function stack pointer} + r.enum:=R_INTREGISTER; + r.number:=NR_STACK_POINTER_REG; + list.concat(Taicpu.Op_reg_const_reg(A_SAVE,r,-LocalSize,r)); end; + + procedure TCgSparc.g_restore_all_registers(list:TaasmOutput;accused,acchiused:boolean); begin - {$warning FIX ME TCgSparc.g_restore_all_registers} + { The sparc port uses the sparc standard calling convetions so this function has no used } end; + + procedure TCgSparc.g_restore_frame_pointer(list:TAasmOutput); begin -{This function intontionally does nothing as frame pointer is restored in the -delay slot of the return instrucion done in g_return_from_proc} + { This function intontionally does nothing as frame pointer is restored in the + delay slot of the return instrucion done in g_return_from_proc} end; + + procedure TCgSparc.g_restore_standard_registers(list:taasmoutput;usedinproc:Tsupregset); begin - {$WARNING FIX ME TCgSparc.g_restore_standard_registers} + { The sparc port uses the sparc standard calling convetions so this function has no used } end; + + procedure TCgSparc.g_return_from_proc(list:TAasmOutput;parasize:aword); - -var r,r2:Tregister; - + var + r,r2:Tregister; begin -{According to the SPARC ABI, the stack is cleared using the RESTORE instruction -which is genereted in the g_restore_frame_pointer. Notice that SPARC has no -RETURN instruction and that JMPL is used instead. The JMPL instrucion have one -delay slot, so an inversion is possible such as - JMPL %i7+8,%g0 - RESTORE %g0,0,%g0 -If no inversion we can use just - RESTORE %g0,0,%g0 - JMPL %i7+8,%g0 - NOP} + { According to the SPARC ABI, the stack is cleared using the RESTORE instruction + which is genereted in the g_restore_frame_pointer. Notice that SPARC has no + RETURN instruction and that JMPL is used instead. The JMPL instrucion have one + delay slot, so an inversion is possible such as + JMPL %i7+8,%g0 + RESTORE %g0,0,%g0 + If no inversion we can use just + RESTORE %g0,0,%g0 + JMPL %i7+8,%g0 + NOP + } with list do begin -{Return address is computed by adding 8 to the CALL address saved onto %i6} + { Return address is computed by adding 8 to the CALL address saved onto %i6} r.enum:=R_G0; r2.enum:=R_I7; concat(Taicpu.Op_caddr_reg(A_JMPL,r,8,r)); -{We use trivial restore in the delay slot of the JMPL instruction, as we -already set result onto %i0} + { We use trivial restore in the delay slot of the JMPL instruction, as we + already set result onto %i0 } concat(Taicpu.Op_reg_const_reg(A_RESTORE,r,0,r)); - end + end end; + + procedure TCgSparc.g_save_all_registers(list : taasmoutput); begin - {$warning FIX ME TCgSparc.g_save_all_registers} + { The sparc port uses the sparc standard calling convetions so this function has no used } end; + + procedure TCgSparc.g_save_standard_registers(list : taasmoutput; usedinproc:Tsupregset); begin - {$warning FIX ME tcgppc.g_save_standard_registers} + { The sparc port uses the sparc standard calling convetions so this function has no used } end; + + procedure TCgSparc.a_loadaddr_ref_reg(list:TAasmOutput;CONST ref:TReference;r:tregister); begin @@ -1449,7 +1461,11 @@ BEGIN END. { $Log$ - Revision 1.49 2003-05-22 16:11:22 florian + Revision 1.50 2003-05-23 22:33:48 florian + * fix some small flaws which prevent sparc linux system unit from compiling + * some reformatting done + + Revision 1.49 2003/05/22 16:11:22 florian * fixed sparc compilation partially Revision 1.48 2003/05/07 15:04:30 mazen diff --git a/compiler/sparc/cpuinfo.pas b/compiler/sparc/cpuinfo.pas index 9ed1178066..b893c7eed3 100644 --- a/compiler/sparc/cpuinfo.pas +++ b/compiler/sparc/cpuinfo.pas @@ -39,9 +39,10 @@ TYPE ts64comp = extended; pbestreal=^bestreal; -{ possible supported processors for this target } + { possible supported processors for this target } tprocessors=(no_processor,SPARC_V8,SPARC_V9); -CONST + +const {# Size of native extended floating point type } {SPARC architecture uses IEEE double floating point numbers} extended_size = 8; @@ -61,7 +62,11 @@ IMPLEMENTATION END. { $Log$ - Revision 1.6 2002-11-16 20:07:57 florian + Revision 1.7 2003-05-23 22:33:48 florian + * fix some small flaws which prevent sparc linux system unit from compiling + * some reformatting done + + Revision 1.6 2002/11/16 20:07:57 florian * made target_cpu_name lowercase Revision 1.5 2002/10/16 12:36:54 mazen diff --git a/compiler/sparc/cpupi.pas b/compiler/sparc/cpupi.pas index 68147d660c..de761f590c 100644 --- a/compiler/sparc/cpupi.pas +++ b/compiler/sparc/cpupi.pas @@ -21,33 +21,39 @@ ****************************************************************************} { This unit contains the CPU specific part of tprocinfo. } unit cpupi; -{$INCLUDE fpcdefs.inc} + +{$I fpcdefs.inc} + interface -uses - cutils, - cgbase,cpuinfo; -type - TSparcProcInfo=class(TProcInfo) - {overall size of allocated stack space, currently this is used for the - PowerPC only} - LocalSize:aword; - {max of space need for parameters, currently used by the PowerPC port only} - maxpushedparasize:aword; - constructor create(aparent:tprocinfo);override; -{According the the SPARC ABI the standard stack frame must include : - * 16 word save for the in and local registers in case of overflow/underflow. -this save area always must exist at the %o6+0, - * software conventions requires space for the aggregate return value pointer, even if the word is not used, - * althogh the first six words of arguments reside in registers, the standard -stack frame reserves space for them. Arguments beond the sixth reside on the -stack as in the Intel architecture, - * other areas depend on the compiler and the code being compiled. The -standard calling sequence does not define a maximum stack frame size, nor does -it restrict how a language system uses the "unspecified" areas of the standard -stack frame.} - procedure after_header;override; - procedure after_pass1;override; - end; + + uses + cutils, + cgbase,cpuinfo, + psub; + + type + TSparcProcInfo=class(tcgprocinfo) + { overall size of allocated stack space, currently this is used for the + PowerPC only } + LocalSize:aword; + {max of space need for parameters, currently used by the PowerPC port only} + maxpushedparasize:aword; + constructor create(aparent:tprocinfo);override; + { According the the SPARC ABI the standard stack frame must include : + * 16 word save for the in and local registers in case of overflow/underflow. + this save area always must exist at the %o6+0, + * software conventions requires space for the aggregate return value pointer, even if the word is not used, + * althogh the first six words of arguments reside in registers, the standard + stack frame reserves space for them. Arguments beond the sixth reside on the + stack as in the Intel architecture, + * other areas depend on the compiler and the code being compiled. The + standard calling sequence does not define a maximum stack frame size, nor does + it restrict how a language system uses the "unspecified" areas of the standard + stack frame.} + procedure after_header;override; + procedure after_pass1;override; + end; + implementation uses tgobj,paramgr,symsym,systems; @@ -95,7 +101,11 @@ begin end. { $Log$ - Revision 1.14 2003-04-27 11:21:36 peter + Revision 1.15 2003-05-23 22:33:48 florian + * fix some small flaws which prevent sparc linux system unit from compiling + * some reformatting done + + Revision 1.14 2003/04/27 11:21:36 peter * aktprocdef renamed to current_procdef * procinfo renamed to current_procinfo * procinfo will now be stored in current_module so it can be diff --git a/compiler/sparc/radirect.pas b/compiler/sparc/radirect.pas index 6935562e91..18a1ef6a89 100644 --- a/compiler/sparc/radirect.pas +++ b/compiler/sparc/radirect.pas @@ -338,19 +338,22 @@ interface *****************************************************************************} const - asmmode_i386_direct_info : tasmmodeinfo = + asmmode_sparc_direct_info : tasmmodeinfo = ( id : asmmode_direct; idtxt : 'DIRECT' ); initialization - RegisterAsmMode(asmmode_i386_direct_info); - + RegisterAsmMode(asmmode_sparc_direct_info); end. { $Log$ - Revision 1.9 2003-05-23 21:10:50 florian + Revision 1.10 2003-05-23 22:33:48 florian + * fix some small flaws which prevent sparc linux system unit from compiling + * some reformatting done + + Revision 1.9 2003/05/23 21:10:50 florian * fixed sparc compiler compilation Revision 1.8 2003/05/22 16:11:22 florian