Browse Source

* fixed sparc compilation partially

florian 22 years ago
parent
commit
1770c1db0f
3 changed files with 125 additions and 79 deletions
  1. 6 3
      compiler/sparc/cgcpu.pas
  2. 19 8
      compiler/sparc/cpubase.pas
  3. 100 68
      compiler/sparc/radirect.pas

+ 6 - 3
compiler/sparc/cgcpu.pas

@@ -78,7 +78,7 @@ specific processor ABI. It is overriden for each CPU target.
     procedure g_flags2reg(list:TAasmOutput;Size:TCgSize;CONST f:tresflags;reg:TRegister);override;
     procedure g_overflowCheck(List:TAasmOutput;const p:TNode);override;
     procedure g_stackframe_entry(list:TAasmOutput;localsize:LongInt);override;
-    procedure g_restore_all_registers(list:TAasmOutput;selfused,accused,acchiused:boolean);override;
+    procedure g_restore_all_registers(list:TAasmOutput;accused,acchiused:boolean);override;
     procedure g_restore_frame_pointer(list:TAasmOutput);override;
     procedure g_restore_standard_registers(list:taasmoutput;usedinproc:Tsupregset);override;
     procedure g_return_from_proc(list:TAasmOutput;parasize:aword);override;
@@ -983,7 +983,7 @@ after execution of that instruction is the called function stack pointer}
     with list do
       concat(Taicpu.Op_reg_const_reg(A_SAVE,r,-LocalSize,r));
   end;
-procedure TCgSparc.g_restore_all_registers(list:TaasmOutput;selfused,accused,acchiused:boolean);
+procedure TCgSparc.g_restore_all_registers(list:TaasmOutput;accused,acchiused:boolean);
   begin
     {$warning FIX ME TCgSparc.g_restore_all_registers}
   end;
@@ -1449,7 +1449,10 @@ BEGIN
 END.
 {
   $Log$
-  Revision 1.48  2003-05-07 15:04:30  mazen
+  Revision 1.49  2003-05-22 16:11:22  florian
+    * fixed sparc compilation partially
+
+  Revision 1.48  2003/05/07 15:04:30  mazen
   * invalid genrated code for CASE statement fixed
 
   Revision 1.47  2003/05/06 20:25:20  mazen

+ 19 - 8
compiler/sparc/cpubase.pas

@@ -289,11 +289,19 @@ const
   RS_I5=$16;
   RS_I6=$17;
   RS_I7=$18;
+  RS_G0=$19;
+  RS_G1=$1A;
+  RS_G2=$1B;
+  RS_G3=$1C;
+  RS_G4=$1D;
+  RS_G5=$1E;
+  RS_G6=$1F;
+  RS_G7=$20;
 
   first_supreg = $01;
-  last_supreg = $18;
+  last_supreg = $20;
 
-  first_imreg = $19;
+  first_imreg = $21;
   last_imreg = $ff;
 
   {Subregisters; nothing known about.}
@@ -584,11 +592,11 @@ VAR
 *****************************************************************************}
 const
   maxvarregs=30;
-  VarRegs:array[1..maxvarregs]OF TCpuRegister=(
-             R_G0,R_G1,R_G2,R_G3,R_G4,R_G5,R_G6,R_G7,
-             R_O0,R_O1,R_O2,R_O3,R_O4,R_O5,{R_R14=R_SP}R_O7,
-             R_L0,R_L1,R_L2,R_L3,R_L4,R_L5,R_L6,R_L7,
-             R_I0,R_I1,R_I2,R_I3,R_I4,R_I5,{R_R30=R_FP}R_I7
+  VarRegs:array[1..maxvarregs] of tnewregister = (
+             RS_G0,RS_G1,RS_G2,RS_G3,RS_G4,RS_G5,RS_G6,RS_G7,
+             RS_O0,RS_O1,RS_O2,RS_O3,RS_O4,RS_O5,{RS_R14=RS_SP}RS_O7,
+             RS_L0,RS_L1,RS_L2,RS_L3,RS_L4,RS_L5,RS_L6,RS_L7,
+             RS_I0,RS_I1,RS_I2,RS_I3,RS_I4,RS_I5,{RS_R30=RS_FP}RS_I7
         );
   maxfpuvarregs = 8;
   max_operands = 3;
@@ -670,7 +678,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.30  2003-05-06 14:58:46  mazen
+  Revision 1.31  2003-05-22 16:11:22  florian
+    * fixed sparc compilation partially
+
+  Revision 1.30  2003/05/06 14:58:46  mazen
   - non used constants OT_* removed
   * some keywords moved lower case
 

+ 100 - 68
compiler/sparc/radirect.pas

@@ -59,14 +59,11 @@ interface
        { constants }
        aggas,cpubase,globtype
        ;
-Procedure FWaitWarning;
-begin
-  if (target_info.system=system_i386_GO32V2) and (cs_fp_emulation in aktmoduleswitches) then
-   Message(asmr_w_fwait_emu_prob);
-end;
+
     function assemble : tnode;
 
       var
+         uhs,
          retstr,s,hs : string;
          c : char;
          ende : boolean;
@@ -139,8 +136,6 @@ end;
                                   else
                                     Message(asmr_w_using_defined_as_local);
                               end
-                            else if upper(hs)='FWAIT' then
-                             FwaitWarning
                             else
                             { access to local variables }
                             if assigned(current_procdef) then
@@ -148,7 +143,7 @@ end;
                                  { is the last written character an special }
                                  { char ?                                   }
                                  if (s[length(s)]='%') and
-                                    paramanager.ret_in_acc(current_procdef.rettype.def,current_procdef.proccalloption) and
+                                    (not paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption)) and
                                     ((pos('AX',upper(hs))>0) or
                                     (pos('AL',upper(hs))>0)) then
                                    tvarsym(current_procdef.funcretsym).varstate:=vs_assigned;
@@ -208,70 +203,104 @@ end;
                                                        tvarsym(sym).varstate:=vs_used;
                                                   end;
                                              end
-                                      { I added that but it creates a problem in line.ppi
-                                      because there is a local label wbuffer and
-                                      a static variable WBUFFER ...
-                                      what would you decide, florian ?}
+                                        end
+                                   end
+                                 else
+                                   begin
+                                      uhs:=upper(hs);
+                                      if (uhs='__SELF') then
+                                        begin
+                                          if assigned(current_procdef._class) then
+                                           uhs:='self'
+                                          else
+                                           begin
+                                             Message(asmr_e_cannot_use_SELF_outside_a_method);
+                                             uhs:='';
+                                           end;
+                                        end
                                       else
+                                       if (uhs='__OLDEBP') then
+                                         begin
+                                           if current_procdef.parast.symtablelevel>normal_function_level then
+                                            uhs:='parentframe'
+                                           else
+                                            begin
+                                              Message(asmr_e_cannot_use_OLDEBP_outside_nested_procedure);
+                                              uhs:='';
+                                            end;
+                                         end
+                                       else
+                                         if uhs='__RESULT' then
+                                           begin
+                                             if (not is_void(current_procdef.rettype.def)) then
+                                              uhs:='result'
+                                             else
+                                              begin
+                                                Message(asmr_e_void_function);
+                                                uhs:='';
+                                              end;
+                                           end;
 
-                                        begin
-                                           searchsym(upper(hs),sym,srsymtable);
-                                           if assigned(sym) and (sym.owner.symtabletype in [globalsymtable,staticsymtable]) then
-                                             begin
-                                               case sym.typ of
-                                                 varsym :
-                                                   begin
-                                                     Message2(asmr_h_direct_global_to_mangled,hs,tvarsym(sym).mangledname);
-                                                     hs:=tvarsym(sym).mangledname;
-                                                     inc(tvarsym(sym).refs);
-                                                   end;
-                                                 typedconstsym :
-                                                   begin
-                                                     Message2(asmr_h_direct_global_to_mangled,hs,ttypedconstsym(sym).mangledname);
-                                                     hs:=ttypedconstsym(sym).mangledname;
+                                       if uhs<>'' then
+                                         searchsym(upper(hs),sym,srsymtable)
+                                       else
+                                         sym:=nil;
+
+                                         if assigned(sym) then
+                                           begin
+                                             case sym.owner.symtabletype of
+                                               globalsymtable,
+                                               staticsymtable :
+                                                 begin
+                                                   case sym.typ of
+                                                     varsym :
+                                                       begin
+                                                         Message2(asmr_h_direct_global_to_mangled,hs,tvarsym(sym).mangledname);
+                                                         hs:=tvarsym(sym).mangledname;
+                                                         inc(tvarsym(sym).refs);
+                                                       end;
+                                                     typedconstsym :
+                                                       begin
+                                                         Message2(asmr_h_direct_global_to_mangled,hs,ttypedconstsym(sym).mangledname);
+                                                         hs:=ttypedconstsym(sym).mangledname;
+                                                       end;
+                                                     procsym :
+                                                       begin
+                                                         { procs can be called or the address can be loaded }
+                                                         if ((pos('CALL',upper(s))>0) or (pos('LEA',upper(s))>0)) then
+                                                          begin
+                                                            if tprocsym(sym).procdef_count>1 then
+                                                              Message1(asmr_w_direct_global_is_overloaded_func,hs);
+                                                            Message2(asmr_h_direct_global_to_mangled,hs,tprocsym(sym).first_procdef.mangledname);
+                                                            hs:=tprocsym(sym).first_procdef.mangledname;
+                                                          end;
+                                                       end;
+                                                     else
+                                                       Message(asmr_e_wrong_sym_type);
                                                    end;
-                                                 procsym :
-                                                   begin
-                                                     { procs can be called or the address can be loaded }
-                                                     if ((pos('CALL',upper(s))>0) or (pos('LEA',upper(s))>0)) then
-                                                      begin
-                                                        if assigned(tprocsym(sym).first_procdef) then
-                                                          Message1(asmr_w_direct_global_is_overloaded_func,hs);
-                                                        Message2(asmr_h_direct_global_to_mangled,hs,tprocsym(sym).first_procdef.mangledname);
-                                                        hs:=tprocsym(sym).first_procdef.mangledname;
-                                                      end;
+                                                 end;
+                                               parasymtable,
+                                               localsymtable :
+                                                 begin
+                                                   case sym.typ of
+                                                     varsym :
+                                                       begin
+                                                         hs:=tostr(tvarsym(sym).adjusted_address)+
+                                                             '('+std_reg2str[framereg.enum]+')';
+                                                         inc(tvarsym(sym).refs);
+                                                       end;
+                                                     typedconstsym :
+                                                       begin
+                                                         Message2(asmr_h_direct_global_to_mangled,hs,ttypedconstsym(sym).mangledname);
+                                                         hs:=ttypedconstsym(sym).mangledname;
+                                                       end;
+                                                     else
+                                                       Message(asmr_e_wrong_sym_type);
                                                    end;
-                                                 else
-                                                   Message(asmr_e_wrong_sym_type);
-                                               end;
-                                             end
-                                           else if upper(hs)='__SELF' then
-                                             begin
-                                                if assigned(current_procdef._class) then
-                                                  hs:=tostr(current_procinfo.selfpointer_offset)+
-                                                      '('+std_reg2str[current_procinfo.framepointer.enum]+')'
-                                                else
-                                                 Message(asmr_e_cannot_use_SELF_outside_a_method);
-                                             end
-                                           else if upper(hs)='__RESULT' then
-                                             begin
-                                                if (not is_void(current_procdef.rettype.def)) then
-                                                  hs:=retstr
-                                                else
-                                                  Message(asmr_e_void_function);
-                                             end
-                                           else if upper(hs)='__OLDEBP' then
-                                             begin
-                                                { complicate to check there }
-                                                { we do it: }
-                                                if current_procdef.parast.symtablelevel>normal_function_level then
-                                                  hs:=tostr(current_procinfo.framepointer_offset)+
-                                                    '('+std_reg2str[current_procinfo.framepointer.enum]+')'
-                                                else
-                                                  Message(asmr_e_cannot_use_OLDEBP_outside_nested_procedure);
-                                             end;
+                                                 end;
+                                              end;
                                            end;
-                                        end;
+                                      end;
                                    end;
                               end;
                             s:=s+hs;
@@ -314,7 +343,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.7  2003-04-27 11:21:36  peter
+  Revision 1.8  2003-05-22 16:11:22  florian
+    * fixed sparc compilation partially
+
+  Revision 1.7  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