Quellcode durchsuchen

* moved the indirect symbol stuff from nppcld to cgobj and ncgld, since
darwin/x86 needs the same code
- removed now empty nppcld unit

git-svn-id: trunk@2821 -

Jonas Maebe vor 19 Jahren
Ursprung
Commit
7cdf9bbaac
6 geänderte Dateien mit 47 neuen und 114 gelöschten Zeilen
  1. 0 1
      .gitattributes
  2. 31 0
      compiler/cgobj.pas
  3. 13 1
      compiler/ncgld.pas
  4. 1 23
      compiler/powerpc/cgcpu.pas
  5. 2 2
      compiler/powerpc/cpunode.pas
  6. 0 87
      compiler/powerpc/nppcld.pas

+ 0 - 1
.gitattributes

@@ -308,7 +308,6 @@ compiler/powerpc/nppcadd.pas svneol=native#text/plain
 compiler/powerpc/nppccal.pas svneol=native#text/plain
 compiler/powerpc/nppccnv.pas svneol=native#text/plain
 compiler/powerpc/nppcinl.pas svneol=native#text/plain
-compiler/powerpc/nppcld.pas svneol=native#text/plain
 compiler/powerpc/nppcmat.pas svneol=native#text/plain
 compiler/powerpc/nppcset.pas svneol=native#text/plain
 compiler/powerpc/rappc.pas svneol=native#text/plain

+ 31 - 0
compiler/cgobj.pas

@@ -425,6 +425,8 @@ unit cgobj;
           procedure g_restore_standard_registers(list:Taasmoutput);virtual;
           procedure g_intf_wrapper(list: TAAsmoutput; procdef: tprocdef; const labelname: string; ioffset: longint);virtual;abstract;
           procedure g_adjust_self_value(list:taasmoutput;procdef: tprocdef;ioffset: aint);virtual;
+
+          function g_indirect_sym_load(list:taasmoutput;const symname: string): tregister;virtual;
        end;
 
 {$ifndef cpu64bit}
@@ -2093,6 +2095,35 @@ implementation
         a_call_name(list,s);
       end;
 
+
+   function tcg.g_indirect_sym_load(list:taasmoutput;const symname: string): tregister;
+      var
+        l: tasmsymbol;
+        ref: treference;
+      begin
+        result := NR_NO;
+        case target_info.system of
+          system_powerpc_darwin,
+          system_i386_darwin:
+            begin
+              l:=objectlibrary.getasmsymbol('L'+symname+'$non_lazy_ptr');
+              if not(assigned(l)) then
+                begin
+                  l:=objectlibrary.newasmsymbol('L'+symname+'$non_lazy_ptr',AB_COMMON,AT_DATA);
+                  asmlist[al_picdata].concat(tai_symbol.create(l,0));
+                  asmlist[al_picdata].concat(tai_const.create_indirect_sym(objectlibrary.newasmsymbol(symname,AB_EXTERNAL,AT_DATA)));
+                  asmlist[al_picdata].concat(tai_const.create_32bit(0));
+                end;
+              result := cg.getaddressregister(list);
+              reference_reset_symbol(ref,l,0);
+{              ref.base:=current_procinfo.got;
+              ref.relsymbol:=current_procinfo.gotlabel;}
+              cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,result);
+            end;
+          end;
+        end;
+
+
 {*****************************************************************************
                                     TCG64
 *****************************************************************************}

+ 13 - 1
compiler/ncgld.pas

@@ -87,6 +87,7 @@ implementation
         norelocatelab : tasmlabel;
         paraloc1 : tcgpara;
       begin
+         
          { we don't know the size of all arrays }
          newsize:=def_cgsize(resulttype.def);
          location_reset(location,LOC_REFERENCE,newsize);
@@ -124,6 +125,14 @@ implementation
             localvarsym,
             paravarsym :
                begin
+                  if (symtableentry.typ = globalvarsym) and
+                     ([vo_is_dll_var,vo_is_external] * tglobalvarsym(symtableentry).varoptions <> []) then
+                    begin
+                      location.reference.base := cg.g_indirect_sym_load(exprasmlist,tglobalvarsym(symtableentry).mangledname);
+                      if (location.reference.base <> NR_NO) then
+                        exit;
+                    end;
+
                   symtabletype:=symtable.symtabletype;
                   hregister:=NR_NO;
                   if (vo_is_dll_var in tabstractvarsym(symtableentry).varoptions) then
@@ -351,8 +360,11 @@ implementation
                     end
                   else
                     begin
+                       if (po_external in tprocsym(symtableentry).procdef[1].procoptions) then
+                         location.reference.base := cg.g_indirect_sym_load(exprasmlist,tprocsym(symtableentry).procdef[1].mangledname);
                        {!!!!! Be aware, work on virtual methods too }
-                       location.reference.symbol:=objectlibrary.newasmsymbol(procdef.mangledname,AB_EXTERNAL,AT_FUNCTION);
+                       if (location.reference.base = NR_NO) then
+                         location.reference.symbol:=objectlibrary.newasmsymbol(procdef.mangledname,AB_EXTERNAL,AT_FUNCTION);
                     end;
                end;
             typedconstsym :

+ 1 - 23
compiler/powerpc/cgcpu.pas

@@ -98,8 +98,6 @@ unit cgcpu;
 
         procedure g_intf_wrapper(list: TAAsmoutput; procdef: tprocdef; const labelname: string; ioffset: longint);override;
 
-        function g_darwin_indirect_sym_load(list: taasmoutput; const symname: string): tregister;
-
       private
 
         (* NOT IN USE: *)
@@ -2027,26 +2025,6 @@ const
       end;
 
 
-     function tcgppc.g_darwin_indirect_sym_load(list: taasmoutput; const symname: string): tregister;
-        var
-          l: tasmsymbol;
-          ref: treference;
-        begin
-          l:=objectlibrary.getasmsymbol('L'+symname+'$non_lazy_ptr');
-          if not(assigned(l)) then
-            begin
-              l:=objectlibrary.newasmsymbol('L'+symname+'$non_lazy_ptr',AB_COMMON,AT_DATA);
-              asmlist[al_picdata].concat(tai_symbol.create(l,0));
-              asmlist[al_picdata].concat(tai_const.create_indirect_sym(objectlibrary.newasmsymbol(symname,AB_EXTERNAL,AT_DATA)));
-              asmlist[al_picdata].concat(tai_const.create_32bit(0));
-            end;
-          reference_reset_symbol(ref,l,0);
-{         ref.base:=current_procinfo.got;
-          ref.relsymbol:=current_procinfo.gotlabel;}
-          result := cg.getaddressregister(exprasmlist);
-          cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,result);
-        end;
-
     function tcgppc.fixref(list: taasmoutput; var ref: treference): boolean;
 
        var
@@ -2058,7 +2036,7 @@ const
             assigned(ref.symbol) and
             (ref.symbol.bind = AB_EXTERNAL) then
            begin
-             tmpreg := g_darwin_indirect_sym_load(list,ref.symbol.name);
+             tmpreg := g_indirect_sym_load(list,ref.symbol.name);
              if (ref.base = NR_NO) then
                ref.base := tmpreg
              else if (ref.index = NR_NO) then

+ 2 - 2
compiler/powerpc/cpunode.pas

@@ -43,8 +43,8 @@ unit cpunode;
        nppcinl,
 //       nppcopt,
        nppcmat,
-       nppccnv,
-       nppcld
+       nppccnv
+//       nppcld
        ;
 
 end.

+ 0 - 87
compiler/powerpc/nppcld.pas

@@ -1,87 +0,0 @@
-{
-    Copyright (c) 1998-2002 by Florian Klaempfl
-
-    Generate ppc assembler for nodes that handle loads and assignments
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************
-}
-unit nppcld;
-
-{$i fpcdefs.inc}
-
-  interface
-
-    uses
-      node,ncgld;
-
-    type
-      tppcloadnode = class(tcgloadnode)
-        procedure pass_2; override;
-      end;
-
-
-  implementation
-
-    uses
-      verbose,
-      systems,
-      globtype,globals,defutil,
-      cpubase, aasmbase, aasmtai,
-      cgutils,cgbase,cgobj,cgcpu,
-      symconst,symsym,
-      procinfo,
-      nld;
-
-
-    procedure tppcloadnode.pass_2;
-      var
-        l : tasmsymbol;
-        ref : treference;
-        symname: string;
-      begin
-        symname := '';
-        case target_info.system of
-          system_powerpc_darwin:
-            begin
-              case symtableentry.typ of
-                procsym:
-                  begin
-                    if (po_external in tprocsym(symtableentry).procdef[1].procoptions) then
-                      symname := tprocsym(symtableentry).procdef[1].mangledname;
-                  end;
-                globalvarsym:
-                  begin
-                    if ([vo_is_dll_var,vo_is_external] * tglobalvarsym(symtableentry).varoptions <> []) then
-                      symname := tglobalvarsym(symtableentry).mangledname;
-                  end;
-              end;
-            end;
-        end;
-        if (symname = '') then
-          inherited pass_2
-        else
-          begin
-            location_reset(location,LOC_REFERENCE,def_cgsize(resulttype.def));
-            reference_reset_base(location.reference,cg.getaddressregister(exprasmlist),0);
-            location.reference.base := tcgppc(cg).g_darwin_indirect_sym_load(exprasmlist,symname);
-          end;
-      end;
-      
-
-begin
-   cloadnode:=tppcloadnode;
-end.