Procházet zdrojové kódy

Merge branch source:main into main

Curtis Hamilton před 1 měsícem
rodič
revize
c05b76d018
3 změnil soubory, kde provedl 43 přidání a 15 odebrání
  1. 8 2
      compiler/loongarch64/cgcpu.pas
  2. 7 2
      compiler/rgobj.pas
  3. 28 11
      compiler/utils/fpc.pp

+ 8 - 2
compiler/loongarch64/cgcpu.pas

@@ -135,10 +135,16 @@ implementation
         inherited init_register_allocators;
         { From GCC REG_ALLOC_ORDER }
         rg[R_INTREGISTER]:=trgintcpu.create(R_INTREGISTER,R_SUBWHOLE,
-          [RS_R12,RS_R13,RS_R14,RS_R16,RS_R16,RS_R17,RS_R18,RS_R19,RS_R20,
+           { scratch registers r12(t0) to r31(t7) }
+          [RS_R12,RS_R13,RS_R14,RS_R15,RS_R16,RS_R17,RS_R18,RS_R19,RS_R20,
+           { parameter registers r4(a0) to r11(a7) }
            RS_R4,RS_R5,RS_R6,RS_R7,RS_R8,RS_R9,RS_R10,RS_R11,
+	   { register r1(ra) }
            RS_R1,
-           RS_R23,RS_R24,RS_R25,RS_R26,RS_R27,RS_R28,RS_R29,RS_R30,RS_R31],first_int_imreg,[]);
+           { callee saved registers r23(s0) to r31(s8) }
+           RS_R23,RS_R24,RS_R25,RS_R26,RS_R27,RS_R28,RS_R29,RS_R30,RS_R31],
+	   first_int_imreg,[]);
+	   { registers r0(zero), r2(tp), r3(sp), r21(x) and r22(sp) are excluded }
         rg[R_FPUREGISTER]:=trgcpu.create(R_FPUREGISTER,R_SUBNONE,
           [RS_F0,RS_F1,RS_F2,RS_F3,RS_F4,RS_F5,RS_F6,RS_F7,RS_F8,
            RS_F9,RS_F10,RS_F11,RS_F12,RS_F13,RS_F14,RS_F15,RS_F16,

+ 7 - 2
compiler/rgobj.pas

@@ -469,9 +469,14 @@ unit rgobj;
          for i:=low(Ausable) to high(Ausable) do
            begin
              usable_registers[i]:=Ausable[i];
-             include(usable_register_set,Ausable[i]);
+	     if (Ausable[i] in usable_register_set) then
+               internalerror(2025112601)
+             else
+               begin
+                 include(usable_register_set,Ausable[i]);
+                 inc(usable_registers_cnt);
+               end;
            end;
-         usable_registers_cnt:=high(Ausable)+1;
          { Initialize Worklists }
          spillednodes.init;
          simplifyworklist.init;

+ 28 - 11
compiler/utils/fpc.pp

@@ -57,14 +57,14 @@ Const
 {$endif not darwin}
 
 
-  procedure error(const s : string);
+  procedure error(const s : string);noreturn;
 
   begin
      writeln('Error: ',s);
      halt(1);
   end;
 
-  function processortosuffix(processorstr : string ) : String;
+  function processortosuffix(const processorstr : string ) : String;
 
   begin
     case processorstr of
@@ -73,11 +73,14 @@ Const
       'avr': Result := 'avr';
       'i386': Result := '386';
       'i8086': Result := '8086';
-      'jvm': Result := 'jvm';  
+      'jvm': Result := 'jvm';
       'loongarch64': Result:='loongarch64';
       'm68k': Result := '68k';
       'mips': Result := 'mips';
       'mipsel': Result := 'mipsel';
+      'mipseb': Result := 'mipseb';
+      'mips64': Result := 'mips64';
+      'mips64el': Result := 'mips64el';
       'powerpc': Result := 'ppc';
       'powerpc64': Result := 'ppc64';
       'riscv32': Result := 'rv32';
@@ -136,9 +139,23 @@ Const
          ppcbin:='ppcmipsel';
          processorname:='mipsel';
     {$else : not mipsel}
-      {$ifdef mips}
-         ppcbin:='ppcmips';
-         processorname:='mips';
+      {$ifdef mipseb}
+          ppcbin:='ppcmipseb';
+          processorname:='mipseb';
+      {$else : not mipseb}
+        {$ifdef mips}
+          ppcbin:='ppcmips';
+          processorname:='mips';
+        {$endif mips}
+      {$endif not mipseb}
+    {$endif not mipsel}
+    {$ifdef mips64el}
+         ppcbin:='ppcmips64el';
+         processorname:='mips64el';
+    {$else : not mips64el}
+      {$ifdef mips64}
+         ppcbin:='ppcmips64';
+         processorname:='mips64';
       {$endif mips}
     {$endif not mipsel}
     {$ifdef riscv32}
@@ -315,7 +332,7 @@ begin
     end;
   if configpath='' then
     begin
-    {  
+    {
       We need to search relative to compiler binary, not relative to FPC binary.
       Beware of symlinks !
     }
@@ -325,7 +342,7 @@ begin
       if copy(sl,1,1)<>'/' then
         hs:=ExpandFileName(ExtractFilePath(hs)+sl)
       else
-        hs:=sl;  
+        hs:=sl;
       end;
     ExePath:=ExtractFilePath(hs);
     configpath:=ExpandFileName(ExePath+'../etc/');
@@ -376,14 +393,14 @@ end;
 
 Procedure ProcessConfigFile(aFileName : String; var ExeSuffix : String);
 
-  Function Stripline(aLine : String) : string;
+  Function Stripline(const aLine : String) : string;
 
   Var
     P : integer;
 
   begin
-    if (aLine<>'') and (aLine[1]=';') then exit;
-    Pos('#',aLine); // no ifdef or include.
+    if (aLine<>'') and (aLine[1]=';') then exit('');
+    P:=Pos('#',aLine); // no ifdef or include.
     if P=0 then
       P:=Length(aLine)+1;
     Result:=Copy(aLine,1,P-1);