Przeglądaj źródła

+ system_x86_64_darwin identifier
+ systems_darwin set which collects all darwin variants
+ added support for darwin/ppc64 and darwin/x86_64 where needed in
the generic code

git-svn-id: branches/fpc_2_3@6404 -

Jonas Maebe 18 lat temu
rodzic
commit
4b38989ea0

+ 1 - 1
compiler/aasmdata.pas

@@ -282,7 +282,7 @@ implementation
         for hal:=low(TAsmListType) to high(TAsmListType) do
         for hal:=low(TAsmListType) to high(TAsmListType) do
           AsmLists[hal]:=TAsmList.create;
           AsmLists[hal]:=TAsmList.create;
         { PIC data }
         { PIC data }
-        if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
+        if (target_info.system in systems_darwin) then
           AsmLists[al_picdata].concat(tai_directive.create(asd_non_lazy_symbol_pointer,''));
           AsmLists[al_picdata].concat(tai_directive.create(asd_non_lazy_symbol_pointer,''));
         { CFI }
         { CFI }
         FAsmCFI:=CAsmCFI.Create;
         FAsmCFI:=CAsmCFI.Create;

+ 14 - 10
compiler/aggas.pas

@@ -284,7 +284,7 @@ implementation
         secname : string;
         secname : string;
       begin
       begin
         if (cs_create_pic in current_settings.moduleswitches) and
         if (cs_create_pic in current_settings.moduleswitches) and
-           not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
+           not(target_info.system in systems_darwin) then
           secname:=secnames_pic[atype]
           secname:=secnames_pic[atype]
         else
         else
           secname:=secnames[atype];
           secname:=secnames[atype];
@@ -306,7 +306,7 @@ implementation
         { For bss we need to set some flags that are target dependent,
         { For bss we need to set some flags that are target dependent,
           it is easier to disable it for smartlinking. It doesn't take up
           it is easier to disable it for smartlinking. It doesn't take up
           filespace }
           filespace }
-        if not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) and
+        if not(target_info.system in systems_darwin) and
            use_smartlink_section and
            use_smartlink_section and
            (aname<>'') and
            (aname<>'') and
            (atype <> sec_toc) and
            (atype <> sec_toc) and
@@ -338,7 +338,9 @@ implementation
          system_m68k_amiga,  { amiga has old GNU AS (2.14), which blews up from .section (KB) }
          system_m68k_amiga,  { amiga has old GNU AS (2.14), which blews up from .section (KB) }
          system_m68k_linux: ;
          system_m68k_linux: ;
          system_powerpc_darwin,
          system_powerpc_darwin,
-         system_i386_darwin:
+         system_i386_darwin,
+         system_powerpc64_darwin,
+         system_x86_64_darwin:
            begin
            begin
              if (atype = sec_stub) then
              if (atype = sec_stub) then
                AsmWrite('.section ');
                AsmWrite('.section ');
@@ -358,10 +360,12 @@ implementation
                 { there are processor-independent shortcuts available    }
                 { there are processor-independent shortcuts available    }
                 { for this, namely .symbol_stub and .picsymbol_stub, but }
                 { for this, namely .symbol_stub and .picsymbol_stub, but }
                 { they don't work and gcc doesn't use them either...     }
                 { they don't work and gcc doesn't use them either...     }
-                system_powerpc_darwin:
+                system_powerpc_darwin,
+                system_powerpc64_darwin:
                   AsmWriteln('__TEXT,__symbol_stub1,symbol_stubs,pure_instructions,16');
                   AsmWriteln('__TEXT,__symbol_stub1,symbol_stubs,pure_instructions,16');
                 system_i386_darwin:
                 system_i386_darwin:
                   AsmWriteln('__IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5');
                   AsmWriteln('__IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5');
+                { darwin/x86-64 uses RIP-based GOT addressing }
                 else
                 else
                   internalerror(2006031101);
                   internalerror(2006031101);
               end;
               end;
@@ -547,7 +551,7 @@ implementation
              begin
              begin
                if tai_align_abstract(hp).aligntype>1 then
                if tai_align_abstract(hp).aligntype>1 then
                  begin
                  begin
-                   if not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
+                   if not(target_info.system in systems_darwin) then
                      begin
                      begin
                        AsmWrite(#9'.balign '+tostr(tai_align_abstract(hp).aligntype));
                        AsmWrite(#9'.balign '+tostr(tai_align_abstract(hp).aligntype));
                        if tai_align_abstract(hp).use_op then
                        if tai_align_abstract(hp).use_op then
@@ -585,7 +589,7 @@ implementation
 
 
            ait_datablock :
            ait_datablock :
              begin
              begin
-               if target_info.system in [system_powerpc_darwin,system_i386_darwin] then
+               if (target_info.system in systems_darwin) then
                  begin
                  begin
                    {On Mac OS X you can't have common symbols in a shared
                    {On Mac OS X you can't have common symbols in a shared
                     library, since those are in the TEXT section and the text section is
                     library, since those are in the TEXT section and the text section is
@@ -676,7 +680,7 @@ implementation
                  aitconst_rva_symbol,
                  aitconst_rva_symbol,
                  aitconst_indirect_symbol :
                  aitconst_indirect_symbol :
                    begin
                    begin
-                     if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) and
+                     if (target_info.system in systems_darwin) and
                         (tai_const(hp).consttype in [aitconst_uleb128bit,aitconst_sleb128bit]) then
                         (tai_const(hp).consttype in [aitconst_uleb128bit,aitconst_sleb128bit]) then
                        begin
                        begin
                          AsmWrite(ait_const2str[aitconst_8bit]);
                          AsmWrite(ait_const2str[aitconst_8bit]);
@@ -697,7 +701,7 @@ implementation
                              begin
                              begin
                                if assigned(tai_const(hp).endsym) then
                                if assigned(tai_const(hp).endsym) then
                                  begin
                                  begin
-                                   if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
+                                   if (target_info.system in systems_darwin) then
                                      begin
                                      begin
                                        s := NextSetLabel;
                                        s := NextSetLabel;
                                        t := #9'.set '+s+','+tai_const(hp).endsym.name+'-'+tai_const(hp).sym.name;
                                        t := #9'.set '+s+','+tai_const(hp).endsym.name+'-'+tai_const(hp).sym.name;
@@ -1074,7 +1078,7 @@ implementation
       Result doesn't work properly yet due to a bug in Apple's linker
       Result doesn't work properly yet due to a bug in Apple's linker
 
 
       if (cs_create_smart in current_settings.moduleswitches) and
       if (cs_create_smart in current_settings.moduleswitches) and
-         (target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
+         (target_info.system in systems_darwin) then
         AsmWriteLn(#9'.subsections_via_symbols');
         AsmWriteLn(#9'.subsections_via_symbols');
 }
 }
 
 
@@ -1092,7 +1096,7 @@ implementation
 
 
     function TAppleGNUAssembler.sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;
     function TAppleGNUAssembler.sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;
       begin
       begin
-        if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
+        if (target_info.system in systems_darwin) then
           case atype of
           case atype of
             sec_bss:
             sec_bss:
               { all bss (lcomm) symbols are automatically put in the right }
               { all bss (lcomm) symbols are automatically put in the right }

+ 2 - 1
compiler/cgobj.pas

@@ -3196,7 +3196,8 @@ implementation
         case target_info.system of
         case target_info.system of
           system_powerpc_darwin,
           system_powerpc_darwin,
           system_i386_darwin,
           system_i386_darwin,
-          system_powerpc64_darwin:
+          system_powerpc64_darwin,
+          system_x86_64_darwin:
             begin
             begin
               l:=current_asmdata.getasmsymbol('L'+symname+'$non_lazy_ptr');
               l:=current_asmdata.getasmsymbol('L'+symname+'$non_lazy_ptr');
               if not(assigned(l)) then
               if not(assigned(l)) then

+ 1 - 1
compiler/cgutils.pas

@@ -214,7 +214,7 @@ uses
     function use_fixed_stack: boolean;
     function use_fixed_stack: boolean;
       begin
       begin
 {$ifdef i386}
 {$ifdef i386}
-        result := (target_info.system = system_i386_darwin);
+        result := (target_info.system in [system_i386_darwin,system_x86_64_darwin]);
 {$else i386}
 {$else i386}
 {$ifdef cputargethasfixedstack}
 {$ifdef cputargethasfixedstack}
         result := true;
         result := true;

+ 2 - 2
compiler/cresstr.pas

@@ -133,7 +133,7 @@ uses
           s : pchar;
           s : pchar;
           referencelab: TAsmLabel;
           referencelab: TAsmLabel;
         begin
         begin
-          if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
+          if (target_info.system in systems_darwin) then
             begin
             begin
               current_asmdata.getdatalabel(referencelab);
               current_asmdata.getdatalabel(referencelab);
               current_asmdata.asmlists[al_const].concat(tai_label.create(referencelab));
               current_asmdata.asmlists[al_const].concat(tai_label.create(referencelab));
@@ -143,7 +143,7 @@ uses
           current_asmdata.asmlists[al_const].concat(tai_const.create_aint(-1));
           current_asmdata.asmlists[al_const].concat(tai_const.create_aint(-1));
           current_asmdata.asmlists[al_const].concat(tai_const.create_aint(len));
           current_asmdata.asmlists[al_const].concat(tai_const.create_aint(len));
           current_asmdata.asmlists[al_const].concat(tai_label.create(result));
           current_asmdata.asmlists[al_const].concat(tai_label.create(result));
-          if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
+          if (target_info.system in systems_darwin) then
              current_asmdata.asmlists[al_const].concat(tai_directive.create(asd_reference,referencelab.name));
              current_asmdata.asmlists[al_const].concat(tai_directive.create(asd_reference,referencelab.name));
           getmem(s,len+1);
           getmem(s,len+1);
           move(p^,s^,len);
           move(p^,s^,len);

+ 1 - 1
compiler/dbgdwarf.pas

@@ -2433,7 +2433,7 @@ implementation
                     if (prevlabel = nil) or
                     if (prevlabel = nil) or
                        { darwin's assembler cannot create an uleb128 of the difference }
                        { darwin's assembler cannot create an uleb128 of the difference }
                        { between to symbols                                            }
                        { between to symbols                                            }
-                       (target_info.system in [system_powerpc_darwin,system_powerpc64_darwin,system_i386_darwin]) then
+                       (target_info.system in systems_darwin) then
                       begin
                       begin
                         asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
                         asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
 {$ifdef cpu64bit}
 {$ifdef cpu64bit}

+ 1 - 1
compiler/dbgstabs.pas

@@ -1548,7 +1548,7 @@ implementation
           exit;
           exit;
         list.concat(Tai_section.create(sec_fpc,'links',0));
         list.concat(Tai_section.create(sec_fpc,'links',0));
         { make sure the debuginfo doesn't get stripped out }
         { make sure the debuginfo doesn't get stripped out }
-        if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
+        if (target_info.system in systems_darwin) then
           begin
           begin
             dbgtable:=tai_symbol.createname('DEBUGINFOTABLE',AT_DATA,0);
             dbgtable:=tai_symbol.createname('DEBUGINFOTABLE',AT_DATA,0);
             list.concat(tai_directive.create(asd_no_dead_strip,dbgtable.sym.name));
             list.concat(tai_directive.create(asd_no_dead_strip,dbgtable.sym.name));

+ 2 - 2
compiler/ncgutil.pas

@@ -1965,7 +1965,7 @@ implementation
         current_procinfo.procdef.procendtai:=tai(list.last);
         current_procinfo.procdef.procendtai:=tai(list.last);
 
 
         { finalisation marker for Mac OS X }
         { finalisation marker for Mac OS X }
-        if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) and
+        if (target_info.system in systems_darwin) and
            (current_module.islibrary) and
            (current_module.islibrary) and
            (((current_module.flags and uf_finalize)<>0) or
            (((current_module.flags and uf_finalize)<>0) or
             (current_procinfo.procdef.proctypeoption = potype_proginit)) then
             (current_procinfo.procdef.proctypeoption = potype_proginit)) then
@@ -1980,7 +1980,7 @@ implementation
 
 
         if (current_procinfo.procdef.proctypeoption=potype_proginit) then
         if (current_procinfo.procdef.proctypeoption=potype_proginit) then
           begin
           begin
-           if (target_info.system in [system_powerpc_darwin,system_i386_darwin,system_powerpc_macos]) and
+           if (target_info.system in (systems_darwin+[system_powerpc_macos])) and
               not(current_module.islibrary) then
               not(current_module.islibrary) then
              begin
              begin
               list.concat(tai_section.create(sec_code,'',4));
               list.concat(tai_section.create(sec_code,'',4));

+ 1 - 1
compiler/ogelf.pas

@@ -607,7 +607,7 @@ implementation
         secname : string;
         secname : string;
       begin
       begin
         if (cs_create_pic in current_settings.moduleswitches) and
         if (cs_create_pic in current_settings.moduleswitches) and
-           not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
+           not(target_info.system in systems_darwin) then
           secname:=secnames_pic[atype]
           secname:=secnames_pic[atype]
         else
         else
           secname:=secnames[atype];
           secname:=secnames[atype];

+ 7 - 7
compiler/pdecvar.pas

@@ -916,7 +916,7 @@ implementation
           if is_cdecl or
           if is_cdecl or
              (
              (
               is_dll and
               is_dll and
-              (target_info.system in [system_powerpc_darwin,system_i386_darwin])
+              (target_info.system in systems_darwin)
              ) then
              ) then
             C_Name := target_info.Cprefix+C_Name;
             C_Name := target_info.Cprefix+C_Name;
 
 
@@ -1171,7 +1171,7 @@ implementation
              if maybe_parse_proc_directives(hdef) then
              if maybe_parse_proc_directives(hdef) then
                semicoloneaten:=true;
                semicoloneaten:=true;
 
 
-{$ifdef powerpc}
+{$if defined(powerpc) or defined(powerpc64)}
              { from gcc/gcc/config/rs6000/rs6000.h:
              { from gcc/gcc/config/rs6000/rs6000.h:
               /* APPLE LOCAL begin Macintosh alignment 2002-1-22 ff */
               /* APPLE LOCAL begin Macintosh alignment 2002-1-22 ff */
               /* Return the alignment of a struct based on the Macintosh PowerPC
               /* Return the alignment of a struct based on the Macintosh PowerPC
@@ -1182,7 +1182,7 @@ implementation
                  (32-bit) alignment, in which case the alignment is determined by
                  (32-bit) alignment, in which case the alignment is determined by
                  the alignment of the first field.  */
                  the alignment of the first field.  */
              }
              }
-             if (target_info.system in [system_powerpc_darwin, system_powerpc_macos]) and
+             if (target_info.system in [system_powerpc_darwin, system_powerpc_macos, system_powerpc64_darwin]) and
                 is_first_field and
                 is_first_field and
                 (symtablestack.top.symtabletype = recordsymtable) and
                 (symtablestack.top.symtabletype = recordsymtable) and
                 (trecordsymtable(symtablestack.top).usefieldalignment = -1) then
                 (trecordsymtable(symtablestack.top).usefieldalignment = -1) then
@@ -1200,7 +1200,7 @@ implementation
                    trecordsymtable(symtablestack.top).padalignment := maxpadalign;
                    trecordsymtable(symtablestack.top).padalignment := maxpadalign;
                  is_first_field := false;
                  is_first_field := false;
                end;
                end;
-{$endif powerpc}
+{$endif powerpc or powerpc64}
 
 
              { types that use init/final are not allowed in variant parts, but
              { types that use init/final are not allowed in variant parts, but
                classes are allowed }
                classes are allowed }
@@ -1368,14 +1368,14 @@ implementation
               unionsymtable.datasize:=maxsize;
               unionsymtable.datasize:=maxsize;
               unionsymtable.fieldalignment:=maxalignment;
               unionsymtable.fieldalignment:=maxalignment;
               unionsymtable.addalignmentpadding;
               unionsymtable.addalignmentpadding;
-{$ifdef powerpc}
+{$if defined(powerpc) or defined(powerpc64)}
               { parent inherits the alignment padding if the variant is the first "field" of the parent record/variant }
               { parent inherits the alignment padding if the variant is the first "field" of the parent record/variant }
-              if (target_info.system in [system_powerpc_darwin, system_powerpc_macos]) and
+              if (target_info.system in [system_powerpc_darwin, system_powerpc_macos, system_powerpc64_darwin]) and
                  is_first_field and
                  is_first_field and
                  (recst.usefieldalignment = -1) and
                  (recst.usefieldalignment = -1) and
                  (maxpadalign > recst.padalignment) then
                  (maxpadalign > recst.padalignment) then
                 recst.padalignment:=maxpadalign;
                 recst.padalignment:=maxpadalign;
-{$endif powerpc}
+{$endif powerpc or powerpc64}
               { Align the offset where the union symtable is added }
               { Align the offset where the union symtable is added }
               if (recst.usefieldalignment=-1) then
               if (recst.usefieldalignment=-1) then
                 usedalign:=used_align(unionsymtable.recordalignment,current_settings.alignment.recordalignmin,current_settings.alignment.maxCrecordalign)
                 usedalign:=used_align(unionsymtable.recordalignment,current_settings.alignment.recordalignmin,current_settings.alignment.maxCrecordalign)

+ 2 - 2
compiler/pmodules.pas

@@ -1318,12 +1318,12 @@ implementation
           begin
           begin
             main_procinfo:=create_main_proc(make_mangledname('',current_module.localsymtable,mainaliasname),potype_proginit,current_module.localsymtable);
             main_procinfo:=create_main_proc(make_mangledname('',current_module.localsymtable,mainaliasname),potype_proginit,current_module.localsymtable);
             { Win32 startup code needs a single name }
             { Win32 startup code needs a single name }
-            if not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
+            if not(target_info.system in systems_darwin) then
               main_procinfo.procdef.aliasnames.insert('PASCALMAIN')
               main_procinfo.procdef.aliasnames.insert('PASCALMAIN')
             else
             else
               main_procinfo.procdef.aliasnames.insert(target_info.Cprefix+'PASCALMAIN')
               main_procinfo.procdef.aliasnames.insert(target_info.Cprefix+'PASCALMAIN')
           end
           end
-         else if (target_info.system in [system_i386_netware,system_i386_netwlibc,system_powerpc_macos,system_powerpc_darwin,system_i386_darwin]) then
+         else if (target_info.system in ([system_i386_netware,system_i386_netwlibc,system_powerpc_macos]+systems_darwin)) then
            begin
            begin
              main_procinfo:=create_main_proc('PASCALMAIN',potype_proginit,current_module.localsymtable);
              main_procinfo:=create_main_proc('PASCALMAIN',potype_proginit,current_module.localsymtable);
            end
            end

+ 1 - 1
compiler/symdef.pas

@@ -813,7 +813,7 @@ implementation
         if suffix<>'' then
         if suffix<>'' then
           result:=result+'_'+suffix;
           result:=result+'_'+suffix;
         { the Darwin assembler assumes that all symbols starting with 'L' are local }
         { the Darwin assembler assumes that all symbols starting with 'L' are local }
-        if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) and
+        if (target_info.system in systems_darwin) and
            (result[1] = 'L') then
            (result[1] = 'L') then
           result := '_' + result;
           result := '_' + result;
       end;
       end;

+ 5 - 0
compiler/systems.pas

@@ -142,6 +142,11 @@ interface
              system_x86_64_darwin       { 61 }
              system_x86_64_darwin       { 61 }
        );
        );
 
 
+     const
+       systems_darwin = [system_powerpc_darwin,system_i386_darwin,
+                         system_powerpc64_darwin,system_x86_64_darwin];
+
+     type
        tasm = (as_none
        tasm = (as_none
              ,as_gas                   { standard gnu assembler }
              ,as_gas                   { standard gnu assembler }
              ,as_i386_as_aout
              ,as_i386_as_aout