소스 검색

+ be able to add single cpu capabilites by the command line
+ AArch64: SHA2 capability

florian 3 년 전
부모
커밋
c1d43df4a1
3개의 변경된 파일66개의 추가작업 그리고 4개의 파일을 삭제
  1. 19 3
      compiler/aarch64/agcpugas.pas
  2. 2 1
      compiler/aarch64/cpuinfo.pas
  3. 45 0
      compiler/options.pas

+ 19 - 3
compiler/aarch64/agcpugas.pas

@@ -68,7 +68,7 @@ unit agcpugas;
     const
       cputype_to_gas_march : array[tcputype] of string = (
         '', // cpu_none
-        '', // armv8 is not accepted by GNU assembler
+        'armv8-a', // armv8 is not accepted by GNU assembler
         'armv8-a',
         'armv8.1-a',
         'armv8.2-a',
@@ -99,6 +99,22 @@ unit agcpugas;
        cgbase,cgutils;
 
 
+    function GetmarchStr : String;
+      var
+        cf: tcpuflags;
+      begin
+        Result:='-march='+cputype_to_gas_march[current_settings.cputype];
+        for cf in cpu_capabilities[current_settings.cputype] do
+          begin
+            case cf of
+              CPUAARCH64_HAS_SHA2:
+                Result:=Result+'+sha2';
+              else
+                ;
+            end
+          end;
+      end;
+
 {****************************************************************************}
 {                      AArch64 Assembler writer                              }
 {****************************************************************************}
@@ -113,7 +129,7 @@ unit agcpugas;
       begin
         result:=inherited MakeCmdLine;
         if cputype_to_gas_march[current_settings.cputype] <> '' then
-	  Replace(result,'$MARCHOPT','-march='+cputype_to_gas_march[current_settings.cputype])
+          Replace(result,'$MARCHOPT',GetmarchStr)
         else
           Replace(result,'$MARCHOPT','');
       end;
@@ -133,7 +149,7 @@ unit agcpugas;
       begin
         result:=inherited MakeCmdLine;
         if cputype_to_gas_march[current_settings.cputype] <> '' then
-	  Replace(result,'$MARCHOPT','-march='+cputype_to_gas_march[current_settings.cputype])
+          Replace(result,'$MARCHOPT',GetmarchStr)
         else
           Replace(result,'$MARCHOPT','');
       end;

+ 2 - 1
compiler/aarch64/cpuinfo.pas

@@ -135,7 +135,8 @@ Const
 
 type
    tcpuflags =
-     (CPUAARCH64_HAS_LSE       { CPU supports Large System Extensions }
+     (CPUAARCH64_HAS_LSE,     { CPU supports Large System Extensions }
+      CPUAARCH64_HAS_SHA2     { CPU supports SHA2 extension }
      );
 
    tfpuflags =

+ 45 - 0
compiler/options.pas

@@ -1252,6 +1252,11 @@ procedure TOption.interpret_option(const opt:TCmdStr;ispara:boolean);
 var
   code : integer;
   c    : char;
+{$ifdef cpucapabilities}
+  cf   : tcpuflags;
+  cpuflagsstr,
+  extrasettings,
+{$endif cpucapabilities}
   more : TCmdStr;
   major,minor : longint;
   error : integer;
@@ -1588,8 +1593,48 @@ begin
                     'p' :
                       begin
                         s:=upper(copy(more,j+1,length(more)-j));
+{$ifdef cpucapabilities}
+                        if pos('+',s)<>0 then
+                          begin
+                            extrasettings:=Copy(s,Pos('+',s),Length(s));
+                            Delete(s,Pos('+',s),Length(s));
+                          end
+                        else
+                          extrasettings:='';
+{$endif cpucapabilities}
                         if not(Setcputype(s,init_settings)) then
                           IllegalPara(opt);
+{$ifdef cpucapabilities}
+                        while extrasettings<>'' do
+                          begin
+                            Delete(extrasettings,1,1);
+                            if Pos('+',extrasettings)<>0 then
+                              begin
+                                s:=Copy(extrasettings,1,Pos('+',extrasettings)-1);
+                                Delete(extrasettings,1,Pos('+',extrasettings)-1);
+                              end
+                            else
+                              begin
+                                s:=extrasettings;
+                                extrasettings:='';
+                              end;
+                            for cf in tcpuflags do
+                              begin
+                                Str(cf,cpuflagsstr);
+                                { expect that the cpuflagsstr i.e. the enum as well contains _HAS_ }
+                                if Pos('_HAS_',cpuflagsstr)<>0 then
+                                { get rid of prefix include _HAS_ }
+                                  Delete(cpuflagsstr,1,Pos('_HAS_',cpuflagsstr)+4)
+                                else
+                                  Internalerror(2021110601);
+                                if s=cpuflagsstr then
+                                  begin
+                                    Include(cpu_capabilities[init_settings.cputype],cf);
+                                    break;
+                                  end;
+                              end;
+                          end;
+{$endif cpucapabilities}
                         CPUSetExplicitly:=true;
                         break;
                       end;