Explorar o código

* boolean constant instead of IFDEFs for detection of microcontroller support

git-svn-id: trunk@29052 -
Tomas Hajny %!s(int64=10) %!d(string=hai) anos
pai
achega
3ee3542744

+ 12 - 0
compiler/aarch64/cpuinfo.pas

@@ -47,6 +47,9 @@ Type
 
 
 
 
 Const
 Const
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = false; (* Not yet at least ;-) *)
    {# Size of native extended floating point type }
    {# Size of native extended floating point type }
    extended_size = 8;
    extended_size = 8;
    {# Size of a multimedia register               }
    {# Size of a multimedia register               }
@@ -54,6 +57,15 @@ Const
    { target cpu string (used by compiler options) }
    { target cpu string (used by compiler options) }
    target_cpu_string = 'aarch64';
    target_cpu_string = 'aarch64';
 
 
+   { We know that there are fields after sramsize
+     but we don't care about this warning }
+   {$PUSH}
+    {$WARN 3177 OFF}
+   embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
+   (
+      (controllertypestr:''; controllerunitstr:''; flashbase:0; flashsize:0; srambase:0; sramsize:0));
+   {$POP}
+
    { calling conventions supported by the code generator }
    { calling conventions supported by the code generator }
    supported_calling_conventions : tproccalloptions = [
    supported_calling_conventions : tproccalloptions = [
      pocall_internproc,
      pocall_internproc,

+ 20 - 0
compiler/alpha/cpuinfo.pas

@@ -21,6 +21,9 @@ Unit CPUInfo;
 
 
 Interface
 Interface
 
 
+uses
+ globtype;
+
 Type
 Type
    { Natural integer register type and size for the target machine }
    { Natural integer register type and size for the target machine }
 {$ifdef FPC}
 {$ifdef FPC}
@@ -52,7 +55,15 @@ Type
        ClassEV8
        ClassEV8
       );
       );
 
 
+   tcontrollertype =
+     (ct_none
+     );
+
+
 Const
 Const
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = false;
    { Size of native extended type }
    { Size of native extended type }
    extended_size = 16;
    extended_size = 16;
    {# Size of a pointer                           }
    {# Size of a pointer                           }
@@ -60,6 +71,15 @@ Const
    {# Size of a multimedia register               }
    {# Size of a multimedia register               }
    mmreg_size = 8;
    mmreg_size = 8;
 
 
+   { We know that there are fields after sramsize
+     but we don't care about this warning }
+   {$PUSH}
+    {$WARN 3177 OFF}
+   embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
+   (
+      (controllertypestr:''; controllerunitstr:''; flashbase:0; flashsize:0; srambase:0; sramsize:0));
+   {$POP}
+
    { target cpu string (used by compiler options) }
    { target cpu string (used by compiler options) }
    target_cpu_string = 'alpha';
    target_cpu_string = 'alpha';
 
 

+ 3 - 1
compiler/arm/cpuinfo.pas

@@ -338,8 +338,10 @@ Type
       ct_thumb2bare
       ct_thumb2bare
      );
      );
 
 
-
 Const
 Const
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = true;
    {# Size of native extended floating point type }
    {# Size of native extended floating point type }
    extended_size = 12;
    extended_size = 12;
    {# Size of a multimedia register               }
    {# Size of a multimedia register               }

+ 3 - 0
compiler/avr/cpuinfo.pas

@@ -61,6 +61,9 @@ Type
      );
      );
 
 
 Const
 Const
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = true;
    {# Size of native extended floating point type }
    {# Size of native extended floating point type }
    extended_size = 12;
    extended_size = 12;
    {# Size of a multimedia register               }
    {# Size of a multimedia register               }

+ 17 - 0
compiler/generic/cpuinfo.pas

@@ -42,7 +42,24 @@ Type
       fpu_soft
       fpu_soft
      );
      );
 
 
+   tcontrollertype =
+     (ct_none
+     );
+
 Const
 Const
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = false;
+
+   { We know that there are fields after sramsize
+     but we don't care about this warning }
+   {$PUSH}
+    {$WARN 3177 OFF}
+   embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
+   (
+      (controllertypestr:''; controllerunitstr:''; flashbase:0; flashsize:0; srambase:0; sramsize:0));
+   {$POP}
+
    cputypestr : array[tcputype] of string[8] = ('none');
    cputypestr : array[tcputype] of string[8] = ('none');
    fputypestr : array[tfputype] of string[6] = ('none','soft');
    fputypestr : array[tfputype] of string[6] = ('none','soft');
 
 

+ 24 - 18
compiler/globals.pas

@@ -163,9 +163,8 @@ interface
 {$endif defined(ARM)}
 {$endif defined(ARM)}
 
 
         { CPU targets with microcontroller support can add a controller specific unit }
         { CPU targets with microcontroller support can add a controller specific unit }
-{$if defined(ARM) or defined(AVR) or defined(MIPSEL)}
          controllertype   : tcontrollertype;
          controllertype   : tcontrollertype;
-{$endif defined(ARM) or defined(AVR) or defined(MIPSEL)}
+
          { WARNING: this pointer cannot be written as such in record token }
          { WARNING: this pointer cannot be written as such in record token }
          pmessage : pmessagestaterecord;
          pmessage : pmessagestaterecord;
        end;
        end;
@@ -411,7 +410,7 @@ interface
 {$endif i8086}
 {$endif i8086}
         maxfpuregisters : 0;
         maxfpuregisters : 0;
 
 
-{ Note: GENERIC_CPU is sued together with generic subdirectory to
+{ Note: GENERIC_CPU is used together with generic subdirectory to
   be able to compile some of the units without any real CPU.
   be able to compile some of the units without any real CPU.
   This is used to generate a CPU independant PPUDUMP utility. PM }
   This is used to generate a CPU independant PPUDUMP utility. PM }
 {$ifdef GENERIC_CPU}
 {$ifdef GENERIC_CPU}
@@ -502,9 +501,7 @@ interface
 {$if defined(ARM)}
 {$if defined(ARM)}
         instructionset : is_arm;
         instructionset : is_arm;
 {$endif defined(ARM)}
 {$endif defined(ARM)}
-{$if defined(ARM) or defined(AVR) or defined(MIPSEL)}
         controllertype : ct_none;
         controllertype : ct_none;
-{$endif defined(ARM) or defined(AVR) or defined(MIPSEL)}
         pmessage : nil;
         pmessage : nil;
       );
       );
 
 
@@ -536,9 +533,7 @@ interface
     function Setoptimizecputype(const s:string;var a:tcputype):boolean;
     function Setoptimizecputype(const s:string;var a:tcputype):boolean;
     function Setcputype(const s:string;var a:tsettings):boolean;
     function Setcputype(const s:string;var a:tsettings):boolean;
     function SetFpuType(const s:string;var a:tfputype):boolean;
     function SetFpuType(const s:string;var a:tfputype):boolean;
-{$if defined(arm) or defined(avr) or defined(mipsel)}
     function SetControllerType(const s:string;var a:tcontrollertype):boolean;
     function SetControllerType(const s:string;var a:tcontrollertype):boolean;
-{$endif defined(arm) or defined(avr) or defined(mipsel)}
     function IncludeFeature(const s : string) : boolean;
     function IncludeFeature(const s : string) : boolean;
     function SetMinFPConstPrec(const s: string; var a: tfloattype) : boolean;
     function SetMinFPConstPrec(const s: string; var a: tfloattype) : boolean;
 
 
@@ -1177,23 +1172,34 @@ implementation
       end;
       end;
 
 
 
 
-{$if defined(arm) or defined(avr) or defined(mipsel)}
     function SetControllerType(const s:string;var a:tcontrollertype):boolean;
     function SetControllerType(const s:string;var a:tcontrollertype):boolean;
       var
       var
         t  : tcontrollertype;
         t  : tcontrollertype;
         hs : string;
         hs : string;
       begin
       begin
-        result:=false;
-        hs:=Upper(s);
-        for t:=low(tcontrollertype) to high(tcontrollertype) do
-          if embedded_controllers[t].controllertypestr=hs then
-            begin
-              a:=t;
-              result:=true;
-              break;
-            end;
+{ The following check allows to reduce amount of code for platforms  }
+{ not supporting microcontrollers due to evaluation at compile time. }
+{$PUSH}
+ {$WARN 6018 OFF} (* Unreachable code due to compile time evaluation *)
+        if ControllerSupport then
+         begin
+          result:=false;
+          hs:=Upper(s);
+          for t:=low(tcontrollertype) to high(tcontrollertype) do
+            if embedded_controllers[t].controllertypestr=hs then
+              begin
+                a:=t;
+                result:=true;
+                break;
+              end;
+         end
+        else
+         begin
+          a := ct_none;
+          Result := true;
+         end;
+{$POP}
       end;
       end;
-{$endif defined(arm) or defined(avr) or defined(mipsel)}
 
 
 
 
     function IncludeFeature(const s : string) : boolean;
     function IncludeFeature(const s : string) : boolean;

+ 17 - 0
compiler/i386/cpuinfo.pas

@@ -66,8 +66,25 @@ Type
       fpu_avx2
       fpu_avx2
      );
      );
 
 
+   tcontrollertype =
+     (ct_none
+     );
+
 
 
 Const
 Const
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = false;
+
+   { We know that there are fields after sramsize
+     but we don't care about this warning }
+   {$PUSH}
+    {$WARN 3177 OFF}
+   embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
+   (
+      (controllertypestr:''; controllerunitstr:''; flashbase:0; flashsize:0; srambase:0; sramsize:0));
+   {$POP}
+
    { calling conventions supported by the code generator }
    { calling conventions supported by the code generator }
    supported_calling_conventions : tproccalloptions = [
    supported_calling_conventions : tproccalloptions = [
      pocall_internproc,
      pocall_internproc,

+ 17 - 0
compiler/i8086/cpuinfo.pas

@@ -66,8 +66,25 @@ Type
       fpu_avx2
       fpu_avx2
      );
      );
 
 
+   tcontrollertype =
+     (ct_none
+     );
+
 
 
 Const
 Const
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = false;
+
+   { We know that there are fields after sramsize
+     but we don't care about this warning }
+   {$PUSH}
+    {$WARN 3177 OFF}
+   embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
+   (
+      (controllertypestr:''; controllerunitstr:''; flashbase:0; flashsize:0; srambase:0; sramsize:0));
+   {$POP}
+
    { calling conventions supported by the code generator }
    { calling conventions supported by the code generator }
    supported_calling_conventions : tproccalloptions = [
    supported_calling_conventions : tproccalloptions = [
      pocall_internproc,
      pocall_internproc,

+ 19 - 1
compiler/ia64/cpuinfo.pas

@@ -49,7 +49,25 @@ Type
       fpu_itanium
       fpu_itanium
      );
      );
      
      
-const
+   tcontrollertype =
+     (ct_none
+     );
+
+
+Const
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = false;
+
+   { We know that there are fields after sramsize
+     but we don't care about this warning }
+   {$PUSH}
+    {$WARN 3177 OFF}
+   embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
+   (
+      (controllertypestr:''; controllerunitstr:''; flashbase:0; flashsize:0; srambase:0; sramsize:0));
+   {$POP}
+
    { calling conventions supported by the code generator }
    { calling conventions supported by the code generator }
    supported_calling_conventions : tproccalloptions = [
    supported_calling_conventions : tproccalloptions = [
      pocall_internproc,
      pocall_internproc,

+ 17 - 0
compiler/jvm/cpuinfo.pas

@@ -44,8 +44,25 @@ Type
       fpu_standard
       fpu_standard
      );
      );
 
 
+   tcontrollertype =
+     (ct_none
+     );
+
 
 
 Const
 Const
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = false;
+
+   { We know that there are fields after sramsize
+     but we don't care about this warning }
+   {$PUSH}
+    {$WARN 3177 OFF}
+   embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
+   (
+      (controllertypestr:''; controllerunitstr:''; flashbase:0; flashsize:0; srambase:0; sramsize:0));
+   {$POP}
+
    { calling conventions supported by the code generator }
    { calling conventions supported by the code generator }
    supported_calling_conventions : tproccalloptions = [
    supported_calling_conventions : tproccalloptions = [
      pocall_internproc
      pocall_internproc

+ 18 - 0
compiler/m68k/cpuinfo.pas

@@ -48,7 +48,25 @@ Type
       fpu_68881
       fpu_68881
      );
      );
 
 
+   tcontrollertype =
+     (ct_none
+     );
+
+
 Const
 Const
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = false;
+
+   { We know that there are fields after sramsize
+     but we don't care about this warning }
+   {$PUSH}
+    {$WARN 3177 OFF}
+   embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
+   (
+      (controllertypestr:''; controllerunitstr:''; flashbase:0; flashsize:0; srambase:0; sramsize:0));
+   {$POP}
+
    { calling conventions supported by the code generator }
    { calling conventions supported by the code generator }
    supported_calling_conventions : tproccalloptions = [
    supported_calling_conventions : tproccalloptions = [
      pocall_internproc,
      pocall_internproc,

+ 24 - 1
compiler/mips/cpuinfo.pas

@@ -123,7 +123,30 @@ const
       { cpu_pic32mx }  [CPUMIPS_HAS_CMOV,CPUMIPS_HAS_ISA32R2]
       { cpu_pic32mx }  [CPUMIPS_HAS_CMOV,CPUMIPS_HAS_ISA32R2]
     );
     );
 
 
-{$ifdef MIPSEL}
+{$ifndef MIPSEL}
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = false;
+
+   { We know that there are fields after sramsize
+     but we don't care about this warning }
+   {$PUSH}
+    {$WARN 3177 OFF}
+   embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
+   (
+      (controllertypestr:''; controllerunitstr:''; flashbase:0; flashsize:0; srambase:0; sramsize:0));
+   {$POP}
+
+type
+   tcontrollertype =
+     (ct_none
+     );
+
+{$ELSE MIPSEL}
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = true;
+
 type
 type
    tcontrollertype =
    tcontrollertype =
      (ct_none,
      (ct_none,

+ 34 - 33
compiler/options.pas

@@ -381,44 +381,46 @@ var
   end;
   end;
 
 
   procedure ListControllerTypes (OrigString: string);
   procedure ListControllerTypes (OrigString: string);
-  {$if defined(arm) or defined(avr) or defined(mipsel)}
   var
   var
     controllertype : tcontrollertype;
     controllertype : tcontrollertype;
-  {$endif defined(arm) or defined(avr) or defined(mipsel)}
   begin
   begin
-    {$if defined(arm) or defined(avr) or defined(mipsel)}
-    hs1:='';
-    for controllertype:=low(tcontrollertype) to high(tcontrollertype) do
+{$PUSH}
+ {$WARN 6018 OFF} (* Unreachable code due to compile time evaluation *)
+    if (ControllerSupport) then
      begin
      begin
-      if (OrigString = '') then
+      hs1:='';
+      for controllertype:=low(tcontrollertype) to high(tcontrollertype) do
        begin
        begin
-        if Embedded_Controllers [ControllerType].ControllerTypeStr <> '' then
-         WriteLn (Embedded_Controllers [ControllerType].ControllerTypeStr);
-       end
-      else
-       begin
-        if length(hs1+embedded_controllers[controllertype].ControllerTypeStr)>70 then
+        if (OrigString = '') then
          begin
          begin
-          hs:=OrigString;
-          Replace(hs,'$CONTROLLERTYPES',hs1);
-          Comment(V_Normal,hs);
-          hs1:=''
+          if Embedded_Controllers [ControllerType].ControllerTypeStr <> '' then
+           WriteLn (Embedded_Controllers [ControllerType].ControllerTypeStr);
          end
          end
-        else if hs1<>'' then
-         hs1:=hs1+',';
-        if embedded_controllers[controllertype].ControllerTypeStr<>'' then
-         hs1:=hs1+embedded_controllers[controllertype].ControllerTypeStr;
+        else
+         begin
+          if length(hs1+embedded_controllers[controllertype].ControllerTypeStr)
+                                                                       >70 then
+           begin
+            hs:=OrigString;
+            Replace(hs,'$CONTROLLERTYPES',hs1);
+            Comment(V_Normal,hs);
+            hs1:=''
+           end
+          else if hs1<>'' then
+           hs1:=hs1+',';
+          if embedded_controllers[controllertype].ControllerTypeStr<>'' then
+           hs1:=hs1+embedded_controllers[controllertype].ControllerTypeStr;
+         end;
+       end;
+      if (OrigString <> '') and (hs1<>'') then
+       begin
+        hs:=OrigString;
+        Replace(hs,'$CONTROLLERTYPES',hs1);
+        Comment(V_Normal,hs);
+        hs1:=''
        end;
        end;
      end;
      end;
-    if (OrigString <> '') and (hs1<>'') then
-     begin
-      hs:=OrigString;
-      Replace(hs,'$CONTROLLERTYPES',hs1);
-      Comment(V_Normal,hs);
-      hs1:=''
-     end;
-    {$else defined(arm) or defined(avr) or defined(mipsel)}
-    {$endif defined(arm) or defined(avr) or defined(mipsel)}
+{$POP}
   end;
   end;
 
 
 begin
 begin
@@ -540,7 +542,7 @@ begin
 {$ifdef mipsel}
 {$ifdef mipsel}
       'm',
       'm',
 {$endif}
 {$endif}
-{$ifdef mips}
+{$ifdef mipseb}
       'M',
       'M',
 {$endif}
 {$endif}
 {$ifdef powerpc}
 {$ifdef powerpc}
@@ -2079,8 +2081,8 @@ begin
                       end;
                       end;
                     'p':
                     'p':
                       begin
                       begin
-{$if defined(arm) or defined(avr) or defined(mipsel)}
-                        if (target_info.system in systems_embedded) then
+                        if (target_info.system in systems_embedded) and
+                                                         ControllerSupport then
                           begin
                           begin
                             s:=upper(copy(more,j+1,length(more)-j));
                             s:=upper(copy(more,j+1,length(more)-j));
                             if not(SetControllerType(s,init_settings.controllertype)) then
                             if not(SetControllerType(s,init_settings.controllertype)) then
@@ -2088,7 +2090,6 @@ begin
                             break;
                             break;
                           end
                           end
                         else
                         else
-{$endif defined(arm) or defined(avr) or defined(mipsel)}
                           IllegalPara(opt);
                           IllegalPara(opt);
                       end;
                       end;
                     'P':
                     'P':

+ 2 - 3
compiler/pmodules.pas

@@ -374,11 +374,10 @@ implementation
           end;
           end;
 
 
         { CPU targets with microcontroller support can add a controller specific unit }
         { CPU targets with microcontroller support can add a controller specific unit }
-{$if defined(ARM) or defined(AVR) or defined(MIPSEL)}
-        if (target_info.system in systems_embedded) and (current_settings.controllertype<>ct_none) and
+        if ControllerSupport and (target_info.system in systems_embedded) and
+          (current_settings.controllertype<>ct_none) and
           (embedded_controllers[current_settings.controllertype].controllerunitstr<>'') then
           (embedded_controllers[current_settings.controllertype].controllerunitstr<>'') then
           AddUnit(embedded_controllers[current_settings.controllertype].controllerunitstr);
           AddUnit(embedded_controllers[current_settings.controllertype].controllerunitstr);
-{$endif ARM AVR MIPSEL}
       end;
       end;
 
 
 
 

+ 17 - 0
compiler/powerpc/cpuinfo.pas

@@ -44,8 +44,25 @@ Type
       fpu_standard
       fpu_standard
      );
      );
 
 
+   tcontrollertype =
+     (ct_none
+     );
+
 
 
 Const
 Const
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = false;
+
+   { We know that there are fields after sramsize
+     but we don't care about this warning }
+   {$PUSH}
+    {$WARN 3177 OFF}
+   embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
+   (
+      (controllertypestr:''; controllerunitstr:''; flashbase:0; flashsize:0; srambase:0; sramsize:0));
+   {$POP}
+
    { calling conventions supported by the code generator }
    { calling conventions supported by the code generator }
    supported_calling_conventions : tproccalloptions = [
    supported_calling_conventions : tproccalloptions = [
      pocall_internproc,
      pocall_internproc,

+ 19 - 1
compiler/powerpc64/cpuinfo.pas

@@ -40,7 +40,25 @@ type
     fpu_standard
     fpu_standard
     );
     );
 
 
-const
+   tcontrollertype =
+     (ct_none
+     );
+
+
+Const
+  { Is there support for dealing with multiple microcontrollers available }
+  { for this platform? }
+  ControllerSupport = false;
+
+  { We know that there are fields after sramsize
+    but we don't care about this warning }
+  {$PUSH}
+   {$WARN 3177 OFF}
+  embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
+  (
+     (controllertypestr:''; controllerunitstr:''; flashbase:0; flashsize:0; srambase:0; sramsize:0));
+  {$POP}
+
   { calling conventions supported by the code generator }
   { calling conventions supported by the code generator }
   supported_calling_conventions: tproccalloptions = [
   supported_calling_conventions: tproccalloptions = [
     pocall_internproc,
     pocall_internproc,

+ 18 - 6
compiler/scanner.pas

@@ -2943,9 +2943,18 @@ type
             minfpconstprec:=tfloattype(tokenreadenum(sizeof(tfloattype)));
             minfpconstprec:=tfloattype(tokenreadenum(sizeof(tfloattype)));
 
 
             disabledircache:=boolean(tokenreadbyte);
             disabledircache:=boolean(tokenreadbyte);
-{$if defined(ARM) or defined(AVR) or defined(MIPSEL)}
-            controllertype:=tcontrollertype(tokenreadenum(sizeof(tcontrollertype)));
-{$endif defined(ARM) or defined(AVR) or DEFINED(MIPSEL)}
+{ TH: Since the field was conditional originally, it was not stored in PPUs.  }
+{ While adding ControllerSupport constant, I decided not to store ct_none     }
+{ on targets not supporting controllers, but this might be changed here and   }
+{ in tokenwritesettings in the future to unify the PPU structure and handling }
+{ of this field in the compiler.                                              }
+{$PUSH}
+ {$WARN 6018 OFF} (* Unreachable code due to compile time evaluation *)
+            if ControllerSupport then
+             controllertype:=tcontrollertype(tokenreadenum(sizeof(tcontrollertype)))
+            else
+             ControllerType:=ct_none;
+{$POP}
            endpos:=replaytokenbuf.pos;
            endpos:=replaytokenbuf.pos;
            if endpos-startpos<>expected_size then
            if endpos-startpos<>expected_size then
              Comment(V_Error,'Wrong size of Settings read-in');
              Comment(V_Error,'Wrong size of Settings read-in');
@@ -3012,9 +3021,12 @@ type
             tokenwriteenum(minfpconstprec,sizeof(tfloattype));
             tokenwriteenum(minfpconstprec,sizeof(tfloattype));
 
 
             recordtokenbuf.write(byte(disabledircache),1);
             recordtokenbuf.write(byte(disabledircache),1);
-{$if defined(ARM) or defined(AVR) or defined(MIPSEL)}
-            tokenwriteenum(controllertype,sizeof(tcontrollertype));
-{$endif defined(ARM) or defined(AVR) or defined(MIPSEL)}
+{ TH: See note about controllertype field in tokenreadsettings. }
+{$PUSH}
+ {$WARN 6018 OFF} (* Unreachable code due to compile time evaluation *)
+            if ControllerSupport then
+              tokenwriteenum(controllertype,sizeof(tcontrollertype));
+{$POP}
            endpos:=recordtokenbuf.pos;
            endpos:=recordtokenbuf.pos;
            size:=endpos-startpos;
            size:=endpos-startpos;
            recordtokenbuf.seek(sizepos);
            recordtokenbuf.seek(sizepos);

+ 17 - 1
compiler/sparc/cpuinfo.pas

@@ -49,8 +49,24 @@ type
     fpu_hard
     fpu_hard
   );
   );
 
 
+  tcontrollertype =(ct_none
+  );
+
+
+Const
+  { Is there support for dealing with multiple microcontrollers available }
+  { for this platform? }
+  ControllerSupport = true;
+
+  { We know that there are fields after sramsize
+    but we don't care about this warning }
+  {$PUSH}
+   {$WARN 3177 OFF}
+  embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
+  (
+     (controllertypestr:''; controllerunitstr:''; flashbase:0; flashsize:0; srambase:0; sramsize:0));
+  {$POP}
 
 
-const
   { calling conventions supported by the code generator }
   { calling conventions supported by the code generator }
   supported_calling_conventions : tproccalloptions = [
   supported_calling_conventions : tproccalloptions = [
     pocall_internproc,
     pocall_internproc,

+ 0 - 2
compiler/utils/ppuutils/ppudump.pp

@@ -1102,9 +1102,7 @@ end;
          disabledircache : boolean;
          disabledircache : boolean;
 
 
         { CPU targets with microcontroller support can add a controller specific unit }
         { CPU targets with microcontroller support can add a controller specific unit }
-{$if defined(ARM) or defined(AVR) or defined(MIPSEL)}
         controllertype   : tcontrollertype;
         controllertype   : tcontrollertype;
-{$endif defined(ARM) or defined(AVR) or defined(MIPSEL)}
          { WARNING: this pointer cannot be written as such in record token }
          { WARNING: this pointer cannot be written as such in record token }
          pmessage : pmessagestaterecord;
          pmessage : pmessagestaterecord;
        end;
        end;

+ 20 - 0
compiler/vis/cpuinfo.pas

@@ -16,6 +16,9 @@ Unit CPUInfo;
 
 
 Interface
 Interface
 
 
+uses
+   globtype;
+
 Type
 Type
    { Architecture word - Native unsigned type }
    { Architecture word - Native unsigned type }
    AWord  = Longword;
    AWord  = Longword;
@@ -41,7 +44,15 @@ Type
    { possible supported processors for this target }
    { possible supported processors for this target }
    tcputype = (cpu_none);
    tcputype = (cpu_none);
 
 
+   tcontrollertype =
+     (ct_none
+     );
+
+
 Const
 Const
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = false;
    {# Size of native extended floating point type }
    {# Size of native extended floating point type }
    extended_size = 8;
    extended_size = 8;
    {# Size of a pointer                           }
    {# Size of a pointer                           }
@@ -51,6 +62,15 @@ Const
    { target cpu string (used by compiler options) }
    { target cpu string (used by compiler options) }
    target_cpu_string = 'vis';
    target_cpu_string = 'vis';
 
 
+   { We know that there are fields after sramsize
+     but we don't care about this warning }
+   {$PUSH}
+    {$WARN 3177 OFF}
+   embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
+   (
+      (controllertypestr:''; controllerunitstr:''; flashbase:0; flashsize:0; srambase:0; sramsize:0));
+   {$POP}
+
 Implementation
 Implementation
 
 
 end.
 end.

+ 17 - 0
compiler/x86_64/cpuinfo.pas

@@ -58,7 +58,15 @@ Type
       fpu_avx2
       fpu_avx2
      );
      );
 
 
+   tcontrollertype =
+     (ct_none
+     );
+
+
 Const
 Const
+   { Is there support for dealing with multiple microcontrollers available }
+   { for this platform? }
+   ControllerSupport = true;
    { Size of native extended type }
    { Size of native extended type }
    extended_size = 10;
    extended_size = 10;
    { Size of a multimedia register }
    { Size of a multimedia register }
@@ -66,6 +74,15 @@ Const
    { target cpu string (used by compiler options) }
    { target cpu string (used by compiler options) }
    target_cpu_string = 'x86_64';
    target_cpu_string = 'x86_64';
 
 
+   { We know that there are fields after sramsize
+     but we don't care about this warning }
+   {$PUSH}
+    {$WARN 3177 OFF}
+   embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
+   (
+      (controllertypestr:''; controllerunitstr:''; flashbase:0; flashsize:0; srambase:0; sramsize:0));
+   {$POP}
+
    { calling conventions supported by the code generator }
    { calling conventions supported by the code generator }
    supported_calling_conventions : tproccalloptions = [
    supported_calling_conventions : tproccalloptions = [
      pocall_internproc,
      pocall_internproc,