Преглед на файлове

* handle the asd_cpu asd_cpu directive and keep track of the currently selected
CPU in the internal assembler

git-svn-id: trunk@33123 -

nickysn преди 9 години
родител
ревизия
5576caada6
променени са 2 файла, в които са добавени 43 реда и са изтрити 4 реда
  1. 34 3
      compiler/assemble.pas
  2. 9 1
      compiler/ogbase.pas

+ 34 - 3
compiler/assemble.pas

@@ -248,9 +248,7 @@ Implementation
       cclasses,
 {$endif memdebug}
       script,fmodule,verbose,
-{$if defined(m68k) or defined(arm)}
       cpuinfo,
-{$endif m68k or arm}
       aasmcpu,
       owar,owomflib
       ;
@@ -1482,6 +1480,7 @@ Implementation
       var
         objsym,
         objsymend : TObjSymbol;
+        cpu: tcputype;
       begin
         while assigned(hp) do
          begin
@@ -1562,6 +1561,16 @@ Implementation
                    asd_reference:
                      { ignore for now, but should be added}
                      ;
+                   asd_cpu:
+                     begin
+                       ObjData.CPUType:=cpu_none;
+                       for cpu:=low(tcputype) to high(tcputype) do
+                         if cputypestr[cpu]=tai_directive(hp).name then
+                           begin
+                             ObjData.CPUType:=cpu;
+                             break;
+                           end;
+                     end;
 {$ifdef ARM}
                    asd_thumb_func:
                      ObjData.ThumbFunc:=true;
@@ -1610,6 +1619,7 @@ Implementation
       var
         objsym,
         objsymend : TObjSymbol;
+        cpu: tcputype;
       begin
         while assigned(hp) do
          begin
@@ -1714,6 +1724,16 @@ Implementation
                    asd_code:
                      { ignore for now, but should be added}
                      ;
+                   asd_cpu:
+                     begin
+                       ObjData.CPUType:=cpu_none;
+                       for cpu:=low(tcputype) to high(tcputype) do
+                         if cputypestr[cpu]=tai_directive(hp).name then
+                           begin
+                             ObjData.CPUType:=cpu;
+                             break;
+                           end;
+                     end;
                    else
                      internalerror(2010011102);
                  end;
@@ -1743,6 +1763,7 @@ Implementation
         {$endif}
         ccomp : comp;
         tmp    : word;
+        cpu: tcputype;
       begin
         fillchar(zerobuf,sizeof(zerobuf),0);
         fillchar(objsym,sizeof(objsym),0);
@@ -1943,7 +1964,17 @@ Implementation
                          { TODO: should become a weak definition; for now, do
                              the same as what was done for ait_weak }
                          objsym.bind:=AB_WEAK_EXTERNAL;
-                     end
+                     end;
+                   asd_cpu:
+                     begin
+                       ObjData.CPUType:=cpu_none;
+                       for cpu:=low(tcputype) to high(tcputype) do
+                         if cputypestr[cpu]=tai_directive(hp).name then
+                           begin
+                             ObjData.CPUType:=cpu;
+                             break;
+                           end;
+                     end;
                  end
                end;
              ait_symbolpair:

+ 9 - 1
compiler/ogbase.pas

@@ -34,7 +34,8 @@ interface
       { outputwriters }
       owbase,
       { assembler }
-      aasmbase;
+      aasmbase,
+      cpuinfo;
 
     type
       TObjSection = class;
@@ -329,6 +330,7 @@ interface
        FStabsObjSec,
        FStabStrObjSec : TObjSection;
        FGroupsList : TFPHashObjectList;
+       FCPUType : tcputype;
        procedure section_reset(p:TObject;arg:pointer);
        procedure section_afteralloc(p:TObject;arg:pointer);
        procedure section_afterwrite(p:TObject;arg:pointer);
@@ -380,6 +382,10 @@ interface
        property StabsSec:TObjSection read FStabsObjSec write FStabsObjSec;
        property StabStrSec:TObjSection read FStabStrObjSec write FStabStrObjSec;
        property CObjSymbol: TObjSymbolClass read FCObjSymbol write FCObjSymbol;
+       { Current CPU type for the internal asm writer.
+         Instructions, not supported by the given CPU should produce an error.
+         A value of 'cpu_none' means no restrictions (all instructions should be accepted) }
+       property CPUType : tcputype read FCPUType write FCPUType;
      end;
      TObjDataClass = class of TObjData;
 
@@ -1427,6 +1433,7 @@ implementation
 
     procedure TObjData.beforealloc;
       begin
+        FCPUType:=cpu_none;
         { create stabs sections if debugging }
         if assigned(StabsSec) then
           begin
@@ -1438,6 +1445,7 @@ implementation
 
     procedure TObjData.beforewrite;
       begin
+        FCPUType:=cpu_none;
         { create stabs sections if debugging }
         if assigned(StabsSec) then
          begin