Browse Source

* use localalign info for alignment for locals and temps
* sparc fpu flags branching added
* moved powerpc copy_valye_openarray to generic

peter 21 years ago
parent
commit
47f08937e4

+ 7 - 2
compiler/cgbase.pas

@@ -191,7 +191,7 @@ interface
         shuffles : array[1..1] of byte;
         shuffles : array[1..1] of byte;
       end;
       end;
 
 
-      Tsuperregisterarray=array[0..$ff] of Tsuperregister;
+      Tsuperregisterarray=array[0..$ffff] of Tsuperregister;
       Psuperregisterarray=^Tsuperregisterarray;
       Psuperregisterarray=^Tsuperregisterarray;
 
 
       Tsuperregisterworklist=object
       Tsuperregisterworklist=object
@@ -583,7 +583,12 @@ finalization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.85  2004-01-12 16:35:05  peter
+  Revision 1.86  2004-01-12 22:11:38  peter
+    * use localalign info for alignment for locals and temps
+    * sparc fpu flags branching added
+    * moved powerpc copy_valye_openarray to generic
+
+  Revision 1.85  2004/01/12 16:35:05  peter
     * R_SUB_FS added to make a difference between double and single
     * R_SUB_FS added to make a difference between double and single
       floats, required for sparc only
       floats, required for sparc only
 
 

+ 77 - 3
compiler/cgobj.pas

@@ -387,7 +387,7 @@ unit cgobj;
           {# Generates overflow checking code for a node }
           {# Generates overflow checking code for a node }
           procedure g_overflowcheck(list: taasmoutput; const l:tlocation; def:tdef); virtual; abstract;
           procedure g_overflowcheck(list: taasmoutput; const l:tlocation; def:tdef); virtual; abstract;
 
 
-          procedure g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aword);virtual;abstract;
+          procedure g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aword);virtual;
           procedure g_releasevaluepara_openarray(list : taasmoutput;const ref:treference);virtual;
           procedure g_releasevaluepara_openarray(list : taasmoutput;const ref:treference);virtual;
           {# Emits instructions which should be emitted when entering
           {# Emits instructions which should be emitted when entering
              a routine declared as @var(interrupt). The default
              a routine declared as @var(interrupt). The default
@@ -1905,8 +1905,77 @@ implementation
                             Entry/Exit Code Functions
                             Entry/Exit Code Functions
 *****************************************************************************}
 *****************************************************************************}
 
 
-    procedure tcg.g_releasevaluepara_openarray(list : taasmoutput;const ref:treference);
+    procedure tcg.g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aword);
+      var
+        sizereg,sourcereg,destreg : tregister;
+        paraloc1,paraloc2,paraloc3 : tparalocation;
       begin
       begin
+        { because ppc abi doesn't support dynamic stack allocation properly
+          open array value parameters are copied onto the heap
+        }
+        { allocate two registers for len and source }
+        sizereg:=getintregister(list,OS_INT);
+        sourcereg:=getintregister(list,OS_ADDR);
+        destreg:=getintregister(list,OS_ADDR);
+
+        { calculate necessary memory }
+        a_load_ref_reg(list,OS_INT,OS_INT,lenref,sizereg);
+        a_op_const_reg_reg(list,OP_ADD,OS_INT,1,sizereg,sizereg);
+        a_op_const_reg_reg(list,OP_MUL,OS_INT,elesize,sizereg,sizereg);
+        { load source }
+        a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,sourcereg);
+
+        { do getmem call }
+        paraloc1:=paramanager.getintparaloc(pocall_default,1);
+        paramanager.allocparaloc(list,paraloc1);
+        a_param_reg(list,OS_INT,sizereg,paraloc1);
+        paramanager.freeparaloc(list,paraloc1);
+        allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
+        a_call_name(list,'FPC_GETMEM');
+        deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
+	a_load_reg_reg(list,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,destreg);
+	a_load_reg_ref(list,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,ref);
+
+        { do move call }
+        paraloc1:=paramanager.getintparaloc(pocall_default,1);
+        paraloc2:=paramanager.getintparaloc(pocall_default,2);
+        paraloc3:=paramanager.getintparaloc(pocall_default,3);
+        { load size }
+        paramanager.allocparaloc(list,paraloc3);
+        a_param_reg(list,OS_INT,sizereg,paraloc3);
+        { load destination }
+        paramanager.allocparaloc(list,paraloc2);
+        a_param_reg(list,OS_ADDR,destreg,paraloc2);
+        { load source }
+        paramanager.allocparaloc(list,paraloc1);
+        a_param_reg(list,OS_ADDR,sourcereg,paraloc1);
+        paramanager.freeparaloc(list,paraloc3);
+        paramanager.freeparaloc(list,paraloc2);
+        paramanager.freeparaloc(list,paraloc1);
+        allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
+        a_call_name(list,'FPC_MOVE');
+        deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
+
+        { release used registers }
+        ungetregister(list,sizereg);
+        ungetregister(list,sourcereg);
+        ungetregister(list,destreg);
+      end;
+
+
+    procedure tcg.g_releasevaluepara_openarray(list : taasmoutput;const ref:treference);
+      var
+        paraloc : tparalocation;
+      begin
+        { do move call }
+        paraloc:=paramanager.getintparaloc(pocall_default,1);
+        { load source }
+        paramanager.allocparaloc(list,paraloc);
+        a_param_ref(list,OS_ADDR,ref,paraloc);
+        paramanager.freeparaloc(list,paraloc);
+        allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
+        a_call_name(list,'FPC_FREEMEM');
+        deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
       end;
       end;
 
 
 
 
@@ -2066,7 +2135,12 @@ finalization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.147  2004-01-11 23:56:19  daniel
+  Revision 1.148  2004-01-12 22:11:38  peter
+    * use localalign info for alignment for locals and temps
+    * sparc fpu flags branching added
+    * moved powerpc copy_valye_openarray to generic
+
+  Revision 1.147  2004/01/11 23:56:19  daniel
     * Experiment: Compress strings to save memory
     * Experiment: Compress strings to save memory
       Did not save a single byte of mem; clearly the core size is boosted by
       Did not save a single byte of mem; clearly the core size is boosted by
       temporary memory usage...
       temporary memory usage...

+ 9 - 3
compiler/ncgflw.pas

@@ -85,7 +85,7 @@ implementation
 
 
     uses
     uses
       verbose,globals,systems,globtype,
       verbose,globals,systems,globtype,
-      symconst,symsym,aasmbase,aasmtai,aasmcpu,defutil,
+      symconst,symdef,symsym,aasmbase,aasmtai,aasmcpu,defutil,
       procinfo,cgbase,pass_2,
       procinfo,cgbase,pass_2,
       cpubase,cpuinfo,
       cpubase,cpuinfo,
       nld,ncon,
       nld,ncon,
@@ -1200,7 +1200,8 @@ implementation
          if assigned(exceptsymtable) then
          if assigned(exceptsymtable) then
            begin
            begin
              tvarsym(exceptsymtable.symindex.first).localloc.loc:=LOC_REFERENCE;
              tvarsym(exceptsymtable.symindex.first).localloc.loc:=LOC_REFERENCE;
-             tg.GetLocal(exprasmlist,POINTER_SIZE,tvarsym(exceptsymtable.symindex.first).localloc.reference);
+             tg.GetLocal(exprasmlist,POINTER_SIZE,voidpointertype.def,
+                tvarsym(exceptsymtable.symindex.first).localloc.reference);
              reference_reset_base(href,tvarsym(exceptsymtable.symindex.first).localloc.reference.index,
              reference_reset_base(href,tvarsym(exceptsymtable.symindex.first).localloc.reference.index,
                 tvarsym(exceptsymtable.symindex.first).localloc.reference.offset);
                 tvarsym(exceptsymtable.symindex.first).localloc.reference.offset);
              cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,href);
              cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,href);
@@ -1480,7 +1481,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.88  2004-01-01 17:23:16  florian
+  Revision 1.89  2004-01-12 22:11:38  peter
+    * use localalign info for alignment for locals and temps
+    * sparc fpu flags branching added
+    * moved powerpc copy_valye_openarray to generic
+
+  Revision 1.88  2004/01/01 17:23:16  florian
     * fixed wrong temp. usage in generic exception handling
     * fixed wrong temp. usage in generic exception handling
 
 
   Revision 1.87  2003/12/06 01:15:22  florian
   Revision 1.87  2003/12/06 01:15:22  florian

+ 10 - 5
compiler/ncgutil.pas

@@ -788,7 +788,7 @@ implementation
               l:=tvarsym(p).getvaluesize;
               l:=tvarsym(p).getvaluesize;
               localcopyloc.loc:=LOC_REFERENCE;
               localcopyloc.loc:=LOC_REFERENCE;
               localcopyloc.size:=int_cgsize(l);
               localcopyloc.size:=int_cgsize(l);
-              tg.GetLocal(list,l,localcopyloc.reference);
+              tg.GetLocal(list,l,tvarsym(p).vartype.def,localcopyloc.reference);
               { Copy data }
               { Copy data }
               reference_reset_base(href2,localcopyloc.reference.index,localcopyloc.reference.offset);
               reference_reset_base(href2,localcopyloc.reference.index,localcopyloc.reference.offset);
               if is_shortstring(tvarsym(p).vartype.def) then
               if is_shortstring(tvarsym(p).vartype.def) then
@@ -1861,7 +1861,7 @@ implementation
                   begin
                   begin
 {$warning TODO Add support for register variables}
 {$warning TODO Add support for register variables}
                     localloc.loc:=LOC_REFERENCE;
                     localloc.loc:=LOC_REFERENCE;
-                    tg.GetLocal(list,getvaluesize,localloc.reference);
+                    tg.GetLocal(list,getvaluesize,vartype.def,localloc.reference);
                     if cs_asm_source in aktglobalswitches then
                     if cs_asm_source in aktglobalswitches then
                       list.concat(Tai_comment.Create(strpnew('Local '+realname+' located at '+
                       list.concat(Tai_comment.Create(strpnew('Local '+realname+' located at '+
                           std_regname(localloc.reference.index)+tostr_with_plus(localloc.reference.offset))));
                           std_regname(localloc.reference.index)+tostr_with_plus(localloc.reference.offset))));
@@ -1959,7 +1959,7 @@ implementation
                                 *)
                                 *)
                               localloc.loc:=LOC_REFERENCE;
                               localloc.loc:=LOC_REFERENCE;
                               localloc.size:=paraitem.paraloc[calleeside].size;
                               localloc.size:=paraitem.paraloc[calleeside].size;
-                              tg.GetLocal(list,tcgsize2size[localloc.size],localloc.reference);
+                              tg.GetLocal(list,tcgsize2size[localloc.size],vartype.def,localloc.reference);
                             end
                             end
                           else
                           else
                             localloc:=paraitem.paraloc[calleeside];
                             localloc:=paraitem.paraloc[calleeside];
@@ -1996,7 +1996,7 @@ implementation
 {$warning TODO Allocate register paras}
 {$warning TODO Allocate register paras}
                     localloc.loc:=LOC_REFERENCE;
                     localloc.loc:=LOC_REFERENCE;
                     localloc.size:=int_cgsize(paramanager.push_size(vs_value,vartype.def,pocall_inline));
                     localloc.size:=int_cgsize(paramanager.push_size(vs_value,vartype.def,pocall_inline));
-                    tg.GetLocal(list,tcgsize2size[localloc.size],localloc.reference);
+                    tg.GetLocal(list,tcgsize2size[localloc.size],vartype.def,localloc.reference);
                     if cs_asm_source in aktglobalswitches then
                     if cs_asm_source in aktglobalswitches then
                       begin
                       begin
                         case localloc.loc of
                         case localloc.loc of
@@ -2057,7 +2057,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.180  2003-12-28 21:57:43  jonas
+  Revision 1.181  2004-01-12 22:11:38  peter
+    * use localalign info for alignment for locals and temps
+    * sparc fpu flags branching added
+    * moved powerpc copy_valye_openarray to generic
+
+  Revision 1.180  2003/12/28 21:57:43  jonas
     * fixed procedures declared as "interrupt" for non-x86
     * fixed procedures declared as "interrupt" for non-x86
 
 
   Revision 1.179  2003/12/26 13:19:16  florian
   Revision 1.179  2003/12/26 13:19:16  florian

+ 6 - 78
compiler/powerpc/cgcpu.pas

@@ -81,9 +81,6 @@ unit cgcpu;
 
 
         procedure g_flags2reg(list: taasmoutput; size: TCgSize; const f: TResFlags; reg: TRegister); override;
         procedure g_flags2reg(list: taasmoutput; size: TCgSize; const f: TResFlags; reg: TRegister); override;
 
 
-        procedure g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aword);override;
-        procedure g_releasevaluepara_openarray(list : taasmoutput;const ref:treference);override;
-
         procedure g_stackframe_entry(list : taasmoutput;localsize : longint);override;
         procedure g_stackframe_entry(list : taasmoutput;localsize : longint);override;
         procedure g_return_from_proc(list : taasmoutput;parasize : aword); override;
         procedure g_return_from_proc(list : taasmoutput;parasize : aword); override;
         procedure g_restore_frame_pointer(list : taasmoutput);override;
         procedure g_restore_frame_pointer(list : taasmoutput);override;
@@ -1950,80 +1947,6 @@ const
       end;
       end;
 
 
 
 
-    procedure tcgppc.g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aword);
-      var
-        sizereg,sourcereg,destreg : tregister;
-        paraloc1,paraloc2,paraloc3 : tparalocation;
-      begin
-        { because ppc abi doesn't support dynamic stack allocation properly
-          open array value parameters are copied onto the heap
-        }
-        { allocate two registers for len and source }
-        sizereg:=getintregister(list,OS_INT);
-        sourcereg:=getintregister(list,OS_ADDR);
-        destreg:=getintregister(list,OS_ADDR);
-        
-        { calculate necessary memory }
-        a_load_ref_reg(list,OS_INT,OS_INT,lenref,sizereg);
-        a_op_const_reg_reg(list,OP_ADD,OS_INT,1,sizereg,sizereg);
-        a_op_const_reg_reg(list,OP_MUL,OS_INT,elesize,sizereg,sizereg);
-        { load source }
-        a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,sourcereg);
-
-        { do getmem call }
-        paraloc1:=paramanager.getintparaloc(pocall_default,1);
-        paramanager.allocparaloc(list,paraloc1);
-        a_param_reg(list,OS_INT,sizereg,paraloc1);
-        paramanager.freeparaloc(list,paraloc1);
-        allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
-        a_call_name(list,'FPC_GETMEM');
-        deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
-	a_load_reg_reg(list,OS_ADDR,OS_ADDR,NR_R3,destreg);
-	a_load_reg_ref(list,OS_ADDR,OS_ADDR,NR_R3,ref);
-	
-        { do move call }
-        paraloc1:=paramanager.getintparaloc(pocall_default,1);
-        paraloc2:=paramanager.getintparaloc(pocall_default,2);
-        paraloc3:=paramanager.getintparaloc(pocall_default,3);
-        { load size }
-        paramanager.allocparaloc(list,paraloc3);
-        a_param_reg(list,OS_INT,sizereg,paraloc3);
-        { load destination }
-        paramanager.allocparaloc(list,paraloc2);
-        a_param_reg(list,OS_ADDR,destreg,paraloc2);
-        { load source }
-        paramanager.allocparaloc(list,paraloc1);
-        a_param_reg(list,OS_ADDR,sourcereg,paraloc1);
-        paramanager.freeparaloc(list,paraloc3);
-        paramanager.freeparaloc(list,paraloc2);
-        paramanager.freeparaloc(list,paraloc1);
-        allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
-        a_call_name(list,'FPC_MOVE');
-        deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
-
-        { release used registers }
-        ungetregister(list,sizereg);
-        ungetregister(list,sourcereg);
-        ungetregister(list,destreg);
-      end;
-
-
-    procedure tcgppc.g_releasevaluepara_openarray(list : taasmoutput;const ref:treference);
-      var
-        paraloc : tparalocation;
-      begin
-        { do move call }
-        paraloc:=paramanager.getintparaloc(pocall_default,1);
-        { load source }
-        paramanager.allocparaloc(list,paraloc);
-        a_param_ref(list,OS_ADDR,ref,paraloc);
-        paramanager.freeparaloc(list,paraloc);
-        allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
-        a_call_name(list,'FPC_FREEMEM');
-        deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
-      end;
-
-
     procedure tcgppc.g_overflowcheck(list: taasmoutput; const l: tlocation; def: tdef);
     procedure tcgppc.g_overflowcheck(list: taasmoutput; const l: tlocation; def: tdef);
       var
       var
          hl : tasmlabel;
          hl : tasmlabel;
@@ -2381,7 +2304,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.154  2003-12-29 14:17:50  jonas
+  Revision 1.155  2004-01-12 22:11:38  peter
+    * use localalign info for alignment for locals and temps
+    * sparc fpu flags branching added
+    * moved powerpc copy_valye_openarray to generic
+
+  Revision 1.154  2003/12/29 14:17:50  jonas
     * fixed saving/restoring of volatile fpu registers under sysv
     * fixed saving/restoring of volatile fpu registers under sysv
     + better provisions for abi differences regarding fpu registers that have
     + better provisions for abi differences regarding fpu registers that have
       to be saved
       to be saved

+ 15 - 5
compiler/sparc/cgcpu.pas

@@ -98,8 +98,8 @@ interface
       TOpCG2AsmOp : array[topcg] of TAsmOp=(
       TOpCG2AsmOp : array[topcg] of TAsmOp=(
         A_NONE,A_ADD,A_AND,A_UDIV,A_SDIV,A_UMUL,A_SMUL,A_NEG,A_NOT,A_OR,A_SRA,A_SLL,A_SRL,A_SUB,A_XOR
         A_NONE,A_ADD,A_AND,A_UDIV,A_SDIV,A_UMUL,A_SMUL,A_NEG,A_NOT,A_OR,A_SRA,A_SLL,A_SRL,A_SUB,A_XOR
       );
       );
-      TOpCmp2AsmCond : array[topcmp] of TAsmCond=(
-        C_NONE,C_E,C_G,C_L,C_GE,C_LE,C_NE,C_BE,C_B,C_AE,C_A
+      TOpCmp2AsmCond : array[topcmp] of TAsmCond=(C_NONE,
+        C_E,C_G,C_L,C_GE,C_LE,C_NE,C_BE,C_B,C_AE,C_A
       );
       );
 
 
 
 
@@ -748,9 +748,14 @@ implementation
 
 
     procedure TCgSparc.a_jmp_flags(list:TAasmOutput;const f:TResFlags;l:tasmlabel);
     procedure TCgSparc.a_jmp_flags(list:TAasmOutput;const f:TResFlags;l:tasmlabel);
       var
       var
-        ai:taicpu;
+        ai : taicpu;
+        op : tasmop;
       begin
       begin
-        ai := Taicpu.op_sym(A_Bxx,l);
+        if f in [F_FE,F_FNE,F_FG,F_FL,F_FGE,F_FLE] then
+          op:=A_FBxx
+        else
+          op:=A_Bxx;
+        ai := Taicpu.op_sym(op,l);
         ai.SetCondition(flags_to_cond(f));
         ai.SetCondition(flags_to_cond(f));
         list.Concat(ai);
         list.Concat(ai);
         { Delay slot }
         { Delay slot }
@@ -1102,7 +1107,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.76  2004-01-12 16:39:40  peter
+  Revision 1.77  2004-01-12 22:11:38  peter
+    * use localalign info for alignment for locals and temps
+    * sparc fpu flags branching added
+    * moved powerpc copy_valye_openarray to generic
+
+  Revision 1.76  2004/01/12 16:39:40  peter
     * sparc updates, mostly float related
     * sparc updates, mostly float related
 
 
   Revision 1.75  2003/12/26 14:02:30  peter
   Revision 1.75  2003/12/26 14:02:30  peter

+ 30 - 12
compiler/sparc/cpubase.pas

@@ -94,29 +94,32 @@ uses
       TAsmCond=(C_None,
       TAsmCond=(C_None,
         C_A,C_AE,C_B,C_BE,C_C,C_E,C_G,C_GE,C_L,C_LE,C_NA,C_NAE,
         C_A,C_AE,C_B,C_BE,C_C,C_E,C_G,C_GE,C_L,C_LE,C_NA,C_NAE,
         C_NB,C_NBE,C_NC,C_NE,C_NG,C_NGE,C_NL,C_NLE,C_NO,C_NP,
         C_NB,C_NBE,C_NC,C_NE,C_NG,C_NGE,C_NL,C_NLE,C_NO,C_NP,
-        C_NS,C_NZ,C_O,C_P,C_PE,C_PO,C_S,C_Z
+        C_NS,C_NZ,C_O,C_P,C_PE,C_PO,C_S,C_Z,
+        C_FE,C_FG,C_FL,C_FGE,C_FLE,C_FNE
       );
       );
 
 
     const
     const
       cond2str:array[TAsmCond] of string[3]=('',
       cond2str:array[TAsmCond] of string[3]=('',
         'gu','cc','cs','leu','cs','e','g','ge','l','le','leu','cs',
         'gu','cc','cs','leu','cs','e','g','ge','l','le','leu','cs',
         'cc','gu','cc','ne','le','l','ge','g','vc','XX',
         'cc','gu','cc','ne','le','l','ge','g','vc','XX',
-        'pos','ne','vs','XX','XX','XX','vs','e'
+        'pos','ne','vs','XX','XX','XX','vs','e',
+        'e','g','l','ge','le','ne'
       );
       );
 
 
       inverse_cond:array[TAsmCond] of TAsmCond=(C_None,
       inverse_cond:array[TAsmCond] of TAsmCond=(C_None,
         C_NA,C_NAE,C_NB,C_NBE,C_NC,C_NE,C_NG,C_NGE,C_NL,C_NLE,C_A,C_AE,
         C_NA,C_NAE,C_NB,C_NBE,C_NC,C_NE,C_NG,C_NGE,C_NL,C_NLE,C_A,C_AE,
         C_B,C_BE,C_C,C_E,C_G,C_GE,C_L,C_LE,C_O,C_P,
         C_B,C_BE,C_C,C_E,C_G,C_GE,C_L,C_LE,C_O,C_P,
-        C_S,C_Z,C_NO,C_NP,C_NP,C_P,C_NS,C_NZ
+        C_S,C_Z,C_NO,C_NP,C_NP,C_P,C_NS,C_NZ,
+        C_FNE,C_FLE,C_FGE,C_FL,C_FG,C_FE
       );
       );
 
 
     const
     const
-      CondAsmOps=1;
+      CondAsmOps=2;
       CondAsmOp:array[0..CondAsmOps-1] of TAsmOp=(
       CondAsmOp:array[0..CondAsmOps-1] of TAsmOp=(
-        A_Bxx
+        A_Bxx,A_FBxx
       );
       );
       CondAsmOpStr:array[0..CondAsmOps-1] of string[7]=(
       CondAsmOpStr:array[0..CondAsmOps-1] of string[7]=(
-        'B'
+        'B','FB'
       );
       );
 
 
 {*****************************************************************************
 {*****************************************************************************
@@ -125,18 +128,26 @@ uses
 
 
     type
     type
       TResFlags=(
       TResFlags=(
+        { Integer results }
         F_E,  {Equal}
         F_E,  {Equal}
         F_NE, {Not Equal}
         F_NE, {Not Equal}
         F_G,  {Greater}
         F_G,  {Greater}
         F_L,  {Less}
         F_L,  {Less}
         F_GE, {Greater or Equal}
         F_GE, {Greater or Equal}
         F_LE, {Less or Equal}
         F_LE, {Less or Equal}
-        F_C,  {Carry}
-        F_NC, {Not Carry}
         F_A,  {Above}
         F_A,  {Above}
         F_AE, {Above or Equal}
         F_AE, {Above or Equal}
         F_B,  {Below}
         F_B,  {Below}
-        F_BE  {Below or Equal}
+        F_BE, {Below or Equal}
+        F_C,  {Carry}
+        F_NC, {Not Carry}
+        { Floating point results }
+        F_FE,  {Equal}
+        F_FNE, {Not Equal}
+        F_FG,  {Greater}
+        F_FL,  {Less}
+        F_FGE, {Greater or Equal}
+        F_FLE  {Less or Equal}
       );
       );
 
 
 {*****************************************************************************
 {*****************************************************************************
@@ -490,7 +501,8 @@ implementation
     procedure inverse_flags(var f: TResFlags);
     procedure inverse_flags(var f: TResFlags);
       const
       const
         inv_flags: array[TResFlags] of TResFlags =
         inv_flags: array[TResFlags] of TResFlags =
-          (F_NE,F_E,F_LE,F_GE,F_L,F_G,F_NC,F_C,F_BE,F_B,F_AE,F_A);
+          (F_NE,F_E,F_LE,F_GE,F_L,F_G,F_BE,F_B,F_AE,F_A,F_NC,F_C,
+           F_FNE,F_FE,F_FLE,F_FGE,F_FL,F_FG);
       begin
       begin
         f:=inv_flags[f];
         f:=inv_flags[f];
       end;
       end;
@@ -499,7 +511,8 @@ implementation
    function flags_to_cond(const f:TResFlags):TAsmCond;
    function flags_to_cond(const f:TResFlags):TAsmCond;
       const
       const
         flags_2_cond:array[TResFlags] of TAsmCond=
         flags_2_cond:array[TResFlags] of TAsmCond=
-          (C_E,C_NE,C_G,C_L,C_GE,C_LE,C_C,C_NC,C_A,C_AE,C_B,C_BE);
+          (C_E,C_NE,C_G,C_L,C_GE,C_LE,C_A,C_AE,C_B,C_BE,C_C,C_NC,
+           C_FE,C_FNE,C_FG,C_FL,C_FGE,C_FLE);
       begin
       begin
         result:=flags_2_cond[f];
         result:=flags_2_cond[f];
       end;
       end;
@@ -538,7 +551,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.59  2004-01-12 16:39:40  peter
+  Revision 1.60  2004-01-12 22:11:39  peter
+    * use localalign info for alignment for locals and temps
+    * sparc fpu flags branching added
+    * moved powerpc copy_valye_openarray to generic
+
+  Revision 1.59  2004/01/12 16:39:40  peter
     * sparc updates, mostly float related
     * sparc updates, mostly float related
 
 
   Revision 1.58  2003/12/19 14:38:03  mazen
   Revision 1.58  2003/12/19 14:38:03  mazen

+ 11 - 3
compiler/sparc/cpupi.pas

@@ -44,7 +44,7 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-      globtype,systems,
+      globtype,systems,globals,
       tgobj,paramgr,symconst,symsym;
       tgobj,paramgr,symconst,symsym;
 
 
     constructor tsparcprocinfo.create(aparent:tprocinfo);
     constructor tsparcprocinfo.create(aparent:tprocinfo);
@@ -76,8 +76,11 @@ implementation
             <return pointer for calling>
             <return pointer for calling>
             <register window save area for calling>
             <register window save area for calling>
           %sp
           %sp
+
+          Alignment must be the max available, as doubles require
+          8 byte alignment
         }
         }
-        result:=Align(tg.direction*tg.lasttemp+savearea+target_info.first_parm_offset,4);
+        result:=Align(tg.direction*tg.lasttemp+savearea+target_info.first_parm_offset,aktalignment.localalignmax);
       end;
       end;
 
 
 
 
@@ -86,7 +89,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.22  2003-10-01 20:34:50  peter
+  Revision 1.23  2004-01-12 22:11:39  peter
+    * use localalign info for alignment for locals and temps
+    * sparc fpu flags branching added
+    * moved powerpc copy_valye_openarray to generic
+
+  Revision 1.22  2003/10/01 20:34:50  peter
     * procinfo unit contains tprocinfo
     * procinfo unit contains tprocinfo
     * cginfo renamed to cgbase
     * cginfo renamed to cgbase
     * moved cgmessage to verbose
     * moved cgmessage to verbose

+ 52 - 4
compiler/sparc/ncpuadd.pas

@@ -33,6 +33,7 @@ interface
        tsparcaddnode = class(tcgaddnode)
        tsparcaddnode = class(tcgaddnode)
        private
        private
           function  GetResFlags(unsigned:Boolean):TResFlags;
           function  GetResFlags(unsigned:Boolean):TResFlags;
+          function  GetFPUResFlags:TResFlags;
        protected
        protected
           procedure second_addfloat;override;
           procedure second_addfloat;override;
           procedure second_cmpfloat;override;
           procedure second_cmpfloat;override;
@@ -120,6 +121,42 @@ interface
       end;
       end;
 
 
 
 
+    function TSparcAddNode.GetFPUResFlags:TResFlags;
+      begin
+        case NodeType of
+          equaln:
+            result:=F_FE;
+          unequaln:
+            result:=F_FNE;
+          else
+            begin
+              if nf_swaped in Flags then
+                case NodeType of
+                  ltn:
+                    result:=F_FG;
+                  lten:
+                    result:=F_FGE;
+                  gtn:
+                    result:=F_FL;
+                  gten:
+                    result:=F_FLE;
+                end
+              else
+                case NodeType of
+                  ltn:
+                    result:=F_FL;
+                  lten:
+                    result:=F_FLE;
+                  gtn:
+                    result:=F_FG;
+                  gten:
+                    result:=F_FGE;
+                end;
+            end;
+        end;
+      end;
+
+
     procedure tsparcaddnode.second_addfloat;
     procedure tsparcaddnode.second_addfloat;
       var
       var
         op : TAsmOp;
         op : TAsmOp;
@@ -180,6 +217,8 @@ interface
 
 
 
 
     procedure tsparcaddnode.second_cmpfloat;
     procedure tsparcaddnode.second_cmpfloat;
+      var
+        op : tasmop;
       begin
       begin
         pass_left_right;
         pass_left_right;
         if (nf_swaped in flags) then
         if (nf_swaped in flags) then
@@ -191,10 +230,14 @@ interface
         location_force_fpureg(exprasmlist,right.location,true);
         location_force_fpureg(exprasmlist,right.location,true);
 
 
         location_reset(location,LOC_FLAGS,OS_NO);
         location_reset(location,LOC_FLAGS,OS_NO);
-        location.resflags:=getresflags(true);
+        location.resflags:=getfpuresflags;
 
 
-        exprasmlist.concat(taicpu.op_reg_reg(A_FCMPs,
-           left.location.register,right.location.register));
+        if left.location.size=OS_F64 then
+          op:=A_FCMPd
+        else
+          op:=A_FCMPs;
+        exprasmlist.concat(taicpu.op_reg_reg(op,
+             left.location.register,right.location.register));
         { Delay slot (can only contain integer operation) }
         { Delay slot (can only contain integer operation) }
         exprasmlist.concat(taicpu.op_none(A_NOP));
         exprasmlist.concat(taicpu.op_none(A_NOP));
 
 
@@ -277,7 +320,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.22  2004-01-12 16:39:41  peter
+  Revision 1.23  2004-01-12 22:11:39  peter
+    * use localalign info for alignment for locals and temps
+    * sparc fpu flags branching added
+    * moved powerpc copy_valye_openarray to generic
+
+  Revision 1.22  2004/01/12 16:39:41  peter
     * sparc updates, mostly float related
     * sparc updates, mostly float related
 
 
   Revision 1.21  2003/10/24 11:28:35  mazen
   Revision 1.21  2003/10/24 11:28:35  mazen

+ 91 - 66
compiler/sparc/ncpucnv.pas

@@ -50,7 +50,6 @@ interface
          { procedure second_pchar_to_string;override; }
          { procedure second_pchar_to_string;override; }
          { procedure second_class_to_intf;override; }
          { procedure second_class_to_intf;override; }
          { procedure second_char_to_char;override; }
          { procedure second_char_to_char;override; }
-          procedure pass_2;override;
        end;
        end;
 
 
 implementation
 implementation
@@ -121,85 +120,111 @@ implementation
 
 
 
 
     procedure TSparctypeconvnode.second_real_to_real;
     procedure TSparctypeconvnode.second_real_to_real;
+      const
+        conv_op : array[tfloattype,tfloattype] of tasmop = (
+          {    from:   s32     s64     s80     c64     cur    f128 }
+          { s32 }  ( A_FMOVS,A_FDTOS,A_NONE, A_NONE, A_NONE, A_NONE ),
+          { s64 }  ( A_FSTOD,A_FMOVD,A_NONE, A_NONE, A_NONE, A_NONE ),
+          { s80 }  ( A_NONE, A_NONE, A_NONE, A_NONE, A_NONE, A_NONE ),
+          { c64 }  ( A_NONE, A_NONE, A_NONE, A_NONE, A_NONE, A_NONE ),
+          { cur }  ( A_NONE, A_NONE, A_NONE, A_NONE, A_NONE, A_NONE ),
+          { f128 } ( A_NONE, A_NONE, A_NONE, A_NONE, A_NONE, A_NONE )
+        );
+      var
+        op : tasmop;
       begin
       begin
-        inherited second_real_to_real;
+        location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
+        location_force_fpureg(exprasmlist,left.location,false);
+        { Convert value in fpu register from integer to float }
+        op:=conv_op[tfloatdef(resulttype.def).typ,tfloatdef(left.resulttype.def).typ];
+        if op=A_NONE then
+          internalerror(200401121);
+        location_release(exprasmlist,left.location);
+        location.register:=cg.getfpuregister(exprasmlist,location.size);
+        exprasmlist.concat(taicpu.op_reg_reg(A_FsTOd,left.location.register,location.register));
       end;
       end;
 
 
 
 
-procedure TSparctypeconvnode.second_int_to_bool;
-  var
-    hreg1,hreg2:tregister;
-    resflags : tresflags;
-    opsize   : tcgsize;
-  begin
-    { byte(boolean) or word(wordbool) or longint(longbool) must }
-    { be accepted for var parameters                            }
-    if(nf_explicit in flags)and
-      (left.resulttype.def.size=resulttype.def.size)and
-      (left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER])
-    then
+    procedure TSparctypeconvnode.second_int_to_bool;
+      var
+        hreg1,hreg2 : tregister;
+        resflags : tresflags;
+        opsize   : tcgsize;
+        hlabel,oldtruelabel,oldfalselabel : tasmlabel;
       begin
       begin
-        location_copy(location,left.location);
-        exit;
-      end;
-    location_reset(location,LOC_REGISTER,def_cgsize(left.resulttype.def));
-    opsize := def_cgsize(left.resulttype.def);
-    case left.location.loc of
-      LOC_CREFERENCE,LOC_REFERENCE,LOC_REGISTER,LOC_CREGISTER:
-        begin
-          if left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]
-          then
+        oldtruelabel:=truelabel;
+        oldfalselabel:=falselabel;
+        objectlibrary.getlabel(truelabel);
+        objectlibrary.getlabel(falselabel);
+        secondpass(left);
+        if codegenerror then
+         exit;
+        { byte(boolean) or word(wordbool) or longint(longbool) must }
+        { be accepted for var parameters                            }
+        if (nf_explicit in flags)and
+           (left.resulttype.def.size=resulttype.def.size)and
+           (left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER]) then
+          begin
+            location_copy(location,left.location);
+            truelabel:=oldtruelabel;
+            falselabel:=oldfalselabel;
+            exit;
+          end;
+        location_reset(location,LOC_REGISTER,def_cgsize(left.resulttype.def));
+        opsize := def_cgsize(left.resulttype.def);
+        case left.location.loc of
+          LOC_CREFERENCE,LOC_REFERENCE,LOC_REGISTER,LOC_CREGISTER:
+            begin
+              if left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
+                begin
+                  reference_release(exprasmlist,left.location.reference);
+                  hreg2:=cg.GetIntRegister(exprasmlist,opsize);
+                  cg.a_load_ref_reg(exprasmlist,OpSize,OpSize,left.location.reference,hreg2);
+                end
+              else
+                hreg2 := left.location.register;
+                hreg1 := cg.GetIntRegister(exprasmlist,opsize);
+                exprasmlist.concat(taicpu.op_reg_const_reg(A_SUB,hreg1,1,hreg2));
+                exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUB,hreg1,hreg1,hreg2));
+                cg.UnGetRegister(exprasmlist,hreg2);
+            end;
+          LOC_FLAGS :
+            begin
+              hreg1:=cg.GetIntRegister(exprasmlist,location.size);
+              resflags:=left.location.resflags;
+              cg.g_flags2reg(exprasmlist,location.size,resflags,hreg1);
+            end;
+          LOC_JUMP :
             begin
             begin
-              reference_release(exprasmlist,left.location.reference);
-              hreg2:=cg.GetIntRegister(exprasmlist,opsize);
-              cg.a_load_ref_reg(exprasmlist,OpSize,OpSize,left.location.reference,hreg2);
-            end
+              hreg1:=cg.getintregister(exprasmlist,OS_INT);
+              objectlibrary.getlabel(hlabel);
+              cg.a_label(exprasmlist,truelabel);
+              cg.a_load_const_reg(exprasmlist,OS_INT,1,hreg1);
+              cg.a_jmp_always(exprasmlist,hlabel);
+              cg.a_label(exprasmlist,falselabel);
+              cg.a_load_const_reg(exprasmlist,OS_INT,0,hreg1);
+              cg.a_label(exprasmlist,hlabel);
+            end;
           else
           else
-            hreg2 := left.location.register;
-            hreg1 := cg.GetIntRegister(exprasmlist,opsize);
-            exprasmlist.concat(taicpu.op_reg_const_reg(A_SUB,hreg1,1,hreg2));
-            exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUB,hreg1,hreg1,hreg2));
-            cg.UnGetRegister(exprasmlist,hreg2);
+            internalerror(10062);
         end;
         end;
-      LOC_FLAGS :
-        begin
-          hreg1:=cg.GetIntRegister(exprasmlist,location.size);
-          resflags:=left.location.resflags;
-          cg.g_flags2reg(exprasmlist,location.size,resflags,hreg1);
-        end;
-      else
-        internalerror(10062);
-    end;
-    location.register := hreg1;
-  end;
-
-
-procedure TSparctypeconvnode.pass_2;
-{$ifdef TESTOBJEXT2}
-  var
-    r : preference;
-    nillabel : plabel;
-{$endif TESTOBJEXT2}
-  begin
-    { this isn't good coding, I think tc_bool_2_int, shouldn't be }
-    { type conversion (FK)                                 }
-    if not(convtype in [tc_bool_2_int,tc_bool_2_bool])
-    then
-      begin
-        secondpass(left);
-        location_copy(location,left.location);
-        if codegenerror
-        then
-          exit;
+        location.register := hreg1;
+        truelabel:=oldtruelabel;
+        falselabel:=oldfalselabel;
       end;
       end;
-      second_call_helper(convtype);
-  end;
+
+
 begin
 begin
    ctypeconvnode:=TSparctypeconvnode;
    ctypeconvnode:=TSparctypeconvnode;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.21  2003-11-04 22:30:15  florian
+  Revision 1.22  2004-01-12 22:11:39  peter
+    * use localalign info for alignment for locals and temps
+    * sparc fpu flags branching added
+    * moved powerpc copy_valye_openarray to generic
+
+  Revision 1.21  2003/11/04 22:30:15  florian
     + type cast variant<->enum
     + type cast variant<->enum
     * cnv. node second pass uses now as well helper wrappers
     * cnv. node second pass uses now as well helper wrappers
 
 

+ 7 - 4
compiler/sparc/opcode.inc

@@ -8,9 +8,7 @@ A_AND,A_ANDcc,A_ANDN,A_ADDNcc,
 {Branching instructions}
 {Branching instructions}
 A_JMPL,
 A_JMPL,
 A_CALL,
 A_CALL,
-A_BA,A_Bxx,
-A_FBN,A_FBU,A_FBG,A_FBUG,A_FBL,A_FBUL,A_FBLG,A_FBNE,
-A_FBE,A_FBUE,A_FBGE,A_FBUGE,A_FBLE,A_FBULE,A_FBO,A_FBA,
+A_BA,A_Bxx,A_FBA,A_FBxx,
 A_CBccc,
 A_CBccc,
 A_FLUSH,
 A_FLUSH,
 {Load instructions}
 {Load instructions}
@@ -73,7 +71,12 @@ A_FMOVD
 
 
 {
 {
         $Log$
         $Log$
-        Revision 1.11  2004-01-12 16:39:41  peter
+        Revision 1.12  2004-01-12 22:11:39  peter
+          * use localalign info for alignment for locals and temps
+          * sparc fpu flags branching added
+          * moved powerpc copy_valye_openarray to generic
+
+        Revision 1.11  2004/01/12 16:39:41  peter
           * sparc updates, mostly float related
           * sparc updates, mostly float related
 
 
         Revision 1.10  2003/12/08 13:02:21  mazen
         Revision 1.10  2003/12/08 13:02:21  mazen

+ 12 - 3
compiler/sparc/racpugas.pas

@@ -548,11 +548,15 @@ Interface
             is_asmopcode:=true;
             is_asmopcode:=true;
           end
           end
         { not found, check branch instructions }
         { not found, check branch instructions }
-        else if Upcase(s[1])='B' then
+        else if (Upcase(s[1])='B') or
+                ((Upcase(s[1])='F') and (Upcase(s[2])='B')) then
           begin
           begin
   { we can search here without an extra table which is sorted by string length
   { we can search here without an extra table which is sorted by string length
     because we take the whole remaining string without the leading B }
     because we take the whole remaining string without the leading B }
-            actopcode := A_Bxx;
+            if (Upcase(s[1])='F') then
+              actopcode := A_FBxx
+            else
+              actopcode := A_Bxx;
             for cond:=low(TAsmCond) to high(TAsmCond) do
             for cond:=low(TAsmCond) to high(TAsmCond) do
               if (Upper(copy(s,2,length(s)-1))=Upper(Cond2Str[cond])) then
               if (Upper(copy(s,2,length(s)-1))=Upper(Cond2Str[cond])) then
                 begin
                 begin
@@ -622,7 +626,12 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2004-01-12 16:39:41  peter
+  Revision 1.6  2004-01-12 22:11:39  peter
+    * use localalign info for alignment for locals and temps
+    * sparc fpu flags branching added
+    * moved powerpc copy_valye_openarray to generic
+
+  Revision 1.5  2004/01/12 16:39:41  peter
     * sparc updates, mostly float related
     * sparc updates, mostly float related
 
 
   Revision 1.4  2003/12/26 14:02:30  peter
   Revision 1.4  2003/12/26 14:02:30  peter

+ 7 - 4
compiler/sparc/strinst.inc

@@ -7,9 +7,7 @@
           'and','andcc','andn','addncc',
           'and','andcc','andn','addncc',
           'jmpl',
           'jmpl',
           'call',
           'call',
-          'ba','b',
-          'fbn','fbu','fbg','fbug','fbl','fbul','fblg','fbne',
-          'fbe','fbue','fbge','fbuge','fble','fbule','fbo','fba',
+          'ba','b','fba','fb',
           'cbccc',
           'cbccc',
           'flush',
           'flush',
           'ldsb','ldsh','ldstub',
           'ldsb','ldsh','ldstub',
@@ -70,7 +68,12 @@
 	  'fmovd'
 	  'fmovd'
 {
 {
         $Log$
         $Log$
-        Revision 1.10  2004-01-12 16:39:41  peter
+        Revision 1.11  2004-01-12 22:11:39  peter
+          * use localalign info for alignment for locals and temps
+          * sparc fpu flags branching added
+          * moved powerpc copy_valye_openarray to generic
+
+        Revision 1.10  2004/01/12 16:39:41  peter
           * sparc updates, mostly float related
           * sparc updates, mostly float related
 
 
         Revision 1.9  2003/12/08 13:02:21  mazen
         Revision 1.9  2003/12/08 13:02:21  mazen

+ 12 - 7
compiler/systems/i_linux.pas

@@ -78,7 +78,7 @@ unit i_linux;
                 constalignmax   : 4;
                 constalignmax   : 4;
                 varalignmin     : 0;
                 varalignmin     : 0;
                 varalignmax     : 4;
                 varalignmax     : 4;
-                localalignmin   : 0;
+                localalignmin   : 4;
                 localalignmax   : 4;
                 localalignmax   : 4;
                 recordalignmin  : 0;
                 recordalignmin  : 0;
                 recordalignmax  : 2;
                 recordalignmax  : 2;
@@ -141,7 +141,7 @@ unit i_linux;
                 constalignmax   : 4;
                 constalignmax   : 4;
                 varalignmin     : 0;
                 varalignmin     : 0;
                 varalignmax     : 4;
                 varalignmax     : 4;
-                localalignmin   : 0;
+                localalignmin   : 4;
                 localalignmax   : 4;
                 localalignmax   : 4;
                 recordalignmin  : 0;
                 recordalignmin  : 0;
                 recordalignmax  : 2;
                 recordalignmax  : 2;
@@ -204,7 +204,7 @@ unit i_linux;
                 constalignmax   : 4;
                 constalignmax   : 4;
                 varalignmin     : 0;
                 varalignmin     : 0;
                 varalignmax     : 4;
                 varalignmax     : 4;
-                localalignmin   : 0;
+                localalignmin   : 4;
                 localalignmax   : 4;
                 localalignmax   : 4;
                 recordalignmin  : 0;
                 recordalignmin  : 0;
                 recordalignmax  : 2;
                 recordalignmax  : 2;
@@ -268,7 +268,7 @@ unit i_linux;
                 constalignmax   : 4;
                 constalignmax   : 4;
                 varalignmin     : 0;
                 varalignmin     : 0;
                 varalignmax     : 4;
                 varalignmax     : 4;
-                localalignmin   : 0;
+                localalignmin   : 4;
                 localalignmax   : 4;
                 localalignmax   : 4;
                 recordalignmin  : 0;
                 recordalignmin  : 0;
                 recordalignmax  : 2;
                 recordalignmax  : 2;
@@ -394,7 +394,7 @@ unit i_linux;
                 constalignmax   : 8;
                 constalignmax   : 8;
                 varalignmin     : 0;
                 varalignmin     : 0;
                 varalignmax     : 8;
                 varalignmax     : 8;
-                localalignmin   : 0;
+                localalignmin   : 4;
                 localalignmax   : 8;
                 localalignmax   : 8;
                 recordalignmin  : 0;
                 recordalignmin  : 0;
                 recordalignmax  : 8;
                 recordalignmax  : 8;
@@ -457,7 +457,7 @@ unit i_linux;
                 constalignmax   : 4;
                 constalignmax   : 4;
                 varalignmin     : 0;
                 varalignmin     : 0;
                 varalignmax     : 4;
                 varalignmax     : 4;
-                localalignmin   : 0;
+                localalignmin   : 4;
                 localalignmax   : 4;
                 localalignmax   : 4;
                 recordalignmin  : 4;
                 recordalignmin  : 4;
                 recordalignmax  : 4;
                 recordalignmax  : 4;
@@ -514,7 +514,12 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.19  2004-01-12 16:39:41  peter
+  Revision 1.20  2004-01-12 22:11:39  peter
+    * use localalign info for alignment for locals and temps
+    * sparc fpu flags branching added
+    * moved powerpc copy_valye_openarray to generic
+
+  Revision 1.19  2004/01/12 16:39:41  peter
     * sparc updates, mostly float related
     * sparc updates, mostly float related
 
 
   Revision 1.18  2003/12/31 17:28:19  jonas
   Revision 1.18  2003/12/31 17:28:19  jonas

+ 7 - 2
compiler/systems/i_win32.pas

@@ -86,7 +86,7 @@ unit i_win32;
                 constalignmax   : 4;
                 constalignmax   : 4;
                 varalignmin     : 0;
                 varalignmin     : 0;
                 varalignmax     : 4;
                 varalignmax     : 4;
-                localalignmin   : 0;
+                localalignmin   : 4;
                 localalignmax   : 4;
                 localalignmax   : 4;
                 recordalignmin  : 0;
                 recordalignmin  : 0;
                 recordalignmax  : 2;
                 recordalignmax  : 2;
@@ -112,7 +112,12 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2003-10-03 22:09:49  peter
+  Revision 1.6  2004-01-12 22:11:39  peter
+    * use localalign info for alignment for locals and temps
+    * sparc fpu flags branching added
+    * moved powerpc copy_valye_openarray to generic
+
+  Revision 1.5  2003/10/03 22:09:49  peter
     * removed paraalign
     * removed paraalign
 
 
   Revision 1.4  2003/10/02 21:17:08  peter
   Revision 1.4  2003/10/02 21:17:08  peter

+ 39 - 19
compiler/tgobj.pas

@@ -62,7 +62,7 @@ unit tgobj;
        private
        private
           { contains all free temps using nextfree links }
           { contains all free temps using nextfree links }
           tempfreelist  : ptemprecord;
           tempfreelist  : ptemprecord;
-          function alloctemp(list: taasmoutput; size : longint; temptype : ttemptype; def:tdef) : longint;
+          function alloctemp(list: taasmoutput; size,alignment : longint; temptype : ttemptype; def:tdef) : longint;
           procedure freetemp(list: taasmoutput; pos:longint;temptypes:ttemptypeset);
           procedure freetemp(list: taasmoutput; pos:longint;temptypes:ttemptypeset);
        public
        public
           { contains all temps }
           { contains all temps }
@@ -103,7 +103,7 @@ unit tgobj;
           procedure ungetiftemp(list: taasmoutput; const ref : treference);
           procedure ungetiftemp(list: taasmoutput; const ref : treference);
 
 
           { Allocate space for a local }
           { Allocate space for a local }
-          procedure getlocal(list: taasmoutput; size : longint;var ref : tparareference);
+          procedure getlocal(list: taasmoutput; size : longint;def:tdef;var ref : tparareference);
           procedure UnGetLocal(list: taasmoutput; const ref : tparareference);
           procedure UnGetLocal(list: taasmoutput; const ref : tparareference);
        end;
        end;
 
 
@@ -198,7 +198,7 @@ unit tgobj;
       end;
       end;
 
 
 
 
-    function ttgobj.AllocTemp(list: taasmoutput; size : longint; temptype : ttemptype;def : tdef) : longint;
+    function ttgobj.AllocTemp(list: taasmoutput; size,alignment : longint; temptype : ttemptype;def : tdef) : longint;
       var
       var
          tl,
          tl,
          bestslot,bestprev,
          bestslot,bestprev,
@@ -223,14 +223,12 @@ unit tgobj;
          freetype:=Used2Free[temptype];
          freetype:=Used2Free[temptype];
          if freetype=tt_none then
          if freetype=tt_none then
            internalerror(200208201);
            internalerror(200208201);
-         { Align needed size on 4 bytes }
-         size:=align(size,4);
+         size:=align(size,alignment);
          { First check the tmpfreelist, but not when
          { First check the tmpfreelist, but not when
            we don't want to reuse an already allocated block }
            we don't want to reuse an already allocated block }
          if assigned(tempfreelist) and
          if assigned(tempfreelist) and
             (temptype<>tt_noreuse) then
             (temptype<>tt_noreuse) then
           begin
           begin
-            { Check for a slot with the same size first }
             hprev:=nil;
             hprev:=nil;
             hp:=tempfreelist;
             hp:=tempfreelist;
             while assigned(hp) do
             while assigned(hp) do
@@ -239,12 +237,18 @@ unit tgobj;
                if not(hp^.temptype in FreeTempTypes) then
                if not(hp^.temptype in FreeTempTypes) then
                  Comment(V_Warning,'tgobj: (AllocTemp) temp at pos '+tostr(hp^.pos)+ ' in freelist is not set to tt_free !');
                  Comment(V_Warning,'tgobj: (AllocTemp) temp at pos '+tostr(hp^.pos)+ ' in freelist is not set to tt_free !');
 {$endif}
 {$endif}
+               { Check only slots that are
+                  - free
+                  - share the same type
+                  - contain enough space
+                  - has a correct alignment }
                if (hp^.temptype=freetype) and
                if (hp^.temptype=freetype) and
                   (hp^.def=def) and
                   (hp^.def=def) and
-                  (hp^.size>=size) then
+                  (hp^.size>=size) and
+                  (hp^.pos=align(hp^.pos,alignment)) then
                 begin
                 begin
-                  { Slot is the same size, then leave immediatly }
-                  if hp^.size=size then
+                  { Slot is the same size then leave immediatly }
+                  if (hp^.size=size) then
                    begin
                    begin
                      bestprev:=hprev;
                      bestprev:=hprev;
                      bestslot:=hp;
                      bestslot:=hp;
@@ -314,17 +318,16 @@ unit tgobj;
             tl^.temptype:=temptype;
             tl^.temptype:=temptype;
             tl^.def:=def;
             tl^.def:=def;
 
 
+            { Extend the temp }
             if direction=-1 then
             if direction=-1 then
               begin
               begin
-                 { Extend the temp }
-                 dec(lasttemp,size);
+                 lasttemp:=(-align(-lasttemp,alignment))-size;
                  tl^.pos:=lasttemp;
                  tl^.pos:=lasttemp;
               end
               end
             else
             else
               begin
               begin
-                 tl^.pos:=lasttemp;
-                 { Extend the temp }
-                 inc(lasttemp,size);
+                 tl^.pos:=align(lasttemp,alignment);
+                 lasttemp:=tl^.pos+size;
               end;
               end;
 
 
             tl^.size:=size;
             tl^.size:=size;
@@ -432,22 +435,30 @@ unit tgobj;
 
 
 
 
     procedure ttgobj.gettemp(list: taasmoutput; size : longint;temptype:ttemptype;var ref : treference);
     procedure ttgobj.gettemp(list: taasmoutput; size : longint;temptype:ttemptype;var ref : treference);
+      var
+        varalign : longint;
       begin
       begin
+        varalign:=size_2_align(size);
+        varalign:=used_align(varalign,aktalignment.localalignmin,aktalignment.localalignmax);
         { can't use reference_reset_base, because that will let tgobj depend
         { can't use reference_reset_base, because that will let tgobj depend
           on cgobj (PFV) }
           on cgobj (PFV) }
         fillchar(ref,sizeof(ref),0);
         fillchar(ref,sizeof(ref),0);
         ref.base:=current_procinfo.framepointer;
         ref.base:=current_procinfo.framepointer;
-        ref.offset:=alloctemp(list,size,temptype,nil);
+        ref.offset:=alloctemp(list,size,varalign,temptype,nil);
       end;
       end;
 
 
 
 
     procedure ttgobj.gettemptyped(list: taasmoutput; def:tdef;temptype:ttemptype;var ref : treference);
     procedure ttgobj.gettemptyped(list: taasmoutput; def:tdef;temptype:ttemptype;var ref : treference);
+      var
+        varalign : longint;
       begin
       begin
+        varalign:=def.alignment;
+        varalign:=used_align(varalign,aktalignment.localalignmin,aktalignment.localalignmax);
         { can't use reference_reset_base, because that will let tgobj depend
         { can't use reference_reset_base, because that will let tgobj depend
           on cgobj (PFV) }
           on cgobj (PFV) }
         fillchar(ref,sizeof(ref),0);
         fillchar(ref,sizeof(ref),0);
         ref.base:=current_procinfo.framepointer;
         ref.base:=current_procinfo.framepointer;
-        ref.offset:=alloctemp(list,def.size,temptype,def);
+        ref.offset:=alloctemp(list,def.size,varalign,temptype,def);
       end;
       end;
 
 
 
 
@@ -547,10 +558,14 @@ unit tgobj;
       end;
       end;
 
 
 
 
-    procedure ttgobj.getlocal(list: taasmoutput; size : longint;var ref : tparareference);
+    procedure ttgobj.getlocal(list: taasmoutput; size : longint;def:tdef;var ref : tparareference);
+      var
+        varalign : longint;
       begin
       begin
+        varalign:=def.alignment;
+        varalign:=used_align(varalign,aktalignment.localalignmin,aktalignment.localalignmax);
         ref.index:=current_procinfo.framepointer;
         ref.index:=current_procinfo.framepointer;
-        ref.offset:=alloctemp(list,size,tt_persistent,nil);
+        ref.offset:=alloctemp(list,size,varalign,tt_persistent,nil);
       end;
       end;
 
 
 
 
@@ -563,7 +578,12 @@ unit tgobj;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.42  2003-11-04 19:03:54  peter
+  Revision 1.43  2004-01-12 22:11:38  peter
+    * use localalign info for alignment for locals and temps
+    * sparc fpu flags branching added
+    * moved powerpc copy_valye_openarray to generic
+
+  Revision 1.42  2003/11/04 19:03:54  peter
     * fixes for temp type patch
     * fixes for temp type patch
 
 
   Revision 1.41  2003/11/04 15:35:13  peter
   Revision 1.41  2003/11/04 15:35:13  peter