Browse Source

* reworked cpuflags for avr
+ define cpuflags in options unit so user programs can access them

git-svn-id: trunk@22089 -

florian 13 years ago
parent
commit
895aa0d752
2 changed files with 30 additions and 27 deletions
  1. 14 24
      compiler/avr/cpuinfo.pas
  2. 16 3
      compiler/options.pas

+ 14 - 24
compiler/avr/cpuinfo.pas

@@ -44,18 +44,6 @@ Type
        cpu_avr6
       );
 
-   tcpuflags =
-      (AVR_HAS_JMP_CALL,
-       AVR_HAS_MOVW,
-       AVR_HAS_LPMX,
-       AVR_HAS_MUL,
-       AVR_HAS_RAMPZ,
-       AVR_HAS_ELPM,
-       AVR_HAS_ELPMX,
-       AVR_2_BYTE_PC,
-       AVR_3_BYTE_PC
-      );
-
    tfputype =
      (fpu_none,
       fpu_soft,
@@ -190,24 +178,26 @@ Const
                                  [cs_opt_regvar,cs_opt_loopunroll,cs_opt_tailrecursion,
                                   cs_opt_stackframe,cs_opt_nodecse,cs_opt_reorder_fields,cs_opt_fastmath];
 
-   cpuflagsstr : array[tcpuflags] of string[20] =
-      ('CPUAVR_HAS_JMP_CALL',
-       'CPUAVR_HAS_MOVW',
-       'CPUAVR_HAS_LPMX',
-       'CPUAVR_HAS_MUL',
-       'CPUAVR_HAS_RAMPZ',
-       'CPUAVR_HAS_ELPM',
-       'CPUAVR_HAS_ELPMX',
-       'CPUAVR_2_BYTE_PC',
-       'CPUAVR_3_BYTE_PC'
-      );
-
    level1optimizerswitches = genericlevel1optimizerswitches;
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
    level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
 
+ type
+   tcpuflags =
+      (CPUAVR_HAS_JMP_CALL,
+       CPUAVR_HAS_MOVW,
+       CPUAVR_HAS_LPMX,
+       CPUAVR_HAS_MUL,
+       CPUAVR_HAS_RAMPZ,
+       CPUAVR_HAS_ELPM,
+       CPUAVR_HAS_ELPMX,
+       CPUAVR_2_BYTE_PC,
+       CPUAVR_3_BYTE_PC
+      );
+
+ const
    cpu_capabilities : array[tcputype] of set of tcpuflags =
      ( { cpu_none } [],
        { cpu_avr1 } [],

+ 16 - 3
compiler/options.pas

@@ -284,7 +284,7 @@ begin
       end
      else if pos('$CONTROLLERTYPES',s)>0 then
       begin
-{$if defined(arm) or defined(avr)}
+        {$if defined(arm) or defined(avr)}
         for controllertype:=low(tcontrollertype) to high(tcontrollertype) do
           begin
 {           currently all whole program optimizations are platform-independent
@@ -300,8 +300,8 @@ begin
                   end;
               end;
           end
-{$else defined(arm) or defined(avr)}
-{$endif defined(arm) or defined(avr)}
+        {$else defined(arm) or defined(avr)}
+        {$endif defined(arm) or defined(avr)}
       end
      else
       Comment(V_Normal,s);
@@ -2686,6 +2686,8 @@ var
   env: ansistring;
   i : tfeature;
   abi : tabi;
+  cpuflag : tcpuflags;
+  hs : string;
 begin
   option:=coption.create;
   disable_configfile:=false;
@@ -3210,6 +3212,17 @@ if (target_info.abi = abi_eabihf) then
 
   def_system_macro('FPU'+fputypestr[init_settings.fputype]);
 
+  {$if defined(arm) or defined(avr)}
+  for cpuflag:=low(cpuflag) to high(cpuflag) do
+    begin
+      str(cpuflag,hs);
+      if cpuflag in cpu_capabilities[init_settings.cputype] then
+        def_system_macro(hs)
+      else
+        undef_system_macro(hs);
+    end;
+  {$endif defined(arm) or defined(avr)}
+
   if init_settings.fputype<>fpu_none then
     begin
 {$if defined(i386)}