Procházet zdrojové kódy

Applied fix for binutils 2.41 for loongarch64 suggested by Jinyang He
https://gitlab.com/MQ-mengqing/source/-/commit/32fa3e9eb1a31fa6c4262623dbe432919f66419c
with modifications reported in comments.

Pierre Muller před 1 rokem
rodič
revize
22a1acd610

+ 16 - 7
compiler/loongarch64/agcpugas.pas

@@ -54,11 +54,10 @@ unit agcpugas;
 
 
     uses
     uses
        cutils,globals,verbose,
        cutils,globals,verbose,
-       cgbase,
+       cgbase,rgbase,
        itcpugas,cpuinfo,
        itcpugas,cpuinfo,
        aasmcpu;
        aasmcpu;
 
 
-
     function getreferencestring(asminfo: pasminfo; var ref : treference) : string;
     function getreferencestring(asminfo: pasminfo; var ref : treference) : string;
     var
     var
       s : string;
       s : string;
@@ -143,13 +142,16 @@ unit agcpugas;
     end;
     end;
 
 
 
 
-    function getopstr(asminfo: pasminfo; const o:toper) : string;
+    function getopstr(asminfo: pasminfo; const o:toper;use_std_regname : boolean) : string;
     var
     var
       hs : string;
       hs : string;
     begin
     begin
       case o.typ of
       case o.typ of
         top_reg:
         top_reg:
-          getopstr:=gas_regname(o.reg);
+          if use_std_regname then
+            getopstr:=std_regname(o.reg)
+          else
+            getopstr:=gas_regname(o.reg);
         top_const:
         top_const:
           getopstr:=tostr(o.val);
           getopstr:=tostr(o.val);
         top_ref:
         top_ref:
@@ -159,11 +161,11 @@ unit agcpugas;
       end;
       end;
     end;
     end;
 
 
-
     Procedure TLoongArch64InstrWriter.WriteInstruction(hp : tai);
     Procedure TLoongArch64InstrWriter.WriteInstruction(hp : tai);
     var op: TAsmOp;
     var op: TAsmOp;
         s: string;
         s: string;
-        i: byte;
+	i : byte;
+	use_std_regname_index : byte;
         sep: string[3];
         sep: string[3];
     begin
     begin
       s:=#9+gas_op2str[taicpu(hp).opcode];
       s:=#9+gas_op2str[taicpu(hp).opcode];
@@ -171,12 +173,19 @@ unit agcpugas;
         s:=s+cond2str[taicpu(hp).condition];
         s:=s+cond2str[taicpu(hp).condition];
 
 
       curop:=taicpu(hp).opcode;
       curop:=taicpu(hp).opcode;
+      if curop=A_MOVFCSR2GR then
+        use_std_regname_index:=1
+      else if curop=A_MOVGR2FCSR then
+        use_std_regname_index:=0
+      else
+        use_std_regname_index:=255;
+
       if taicpu(hp).ops<>0 then
       if taicpu(hp).ops<>0 then
         begin
         begin
           sep:=#9;
           sep:=#9;
           for i:=0 to taicpu(hp).ops-1 do
           for i:=0 to taicpu(hp).ops-1 do
             begin
             begin
-               s:=s+sep+getopstr(owner.asminfo,taicpu(hp).oper[i]^);
+               s:=s+sep+getopstr(owner.asminfo,taicpu(hp).oper[i]^,use_std_regname_index=i);
                sep:=',';
                sep:=',';
             end;
             end;
         end;
         end;

+ 1 - 1
compiler/loongarch64/loongarchreg.dat

@@ -28,7 +28,7 @@ R17,$01,$00,$11,$t5,$r17,17,17
 R18,$01,$00,$12,$t6,$r18,18,18
 R18,$01,$00,$12,$t6,$r18,18,18
 R19,$01,$00,$13,$t7,$r19,19,19
 R19,$01,$00,$13,$t7,$r19,19,19
 R20,$01,$00,$14,$t8,$r20,20,20
 R20,$01,$00,$14,$t8,$r20,20,20
-R21,$01,$00,$15,$x,$r21,21,21
+R21,$01,$00,$15,$r21,$r21,21,21
 R22,$01,$00,$16,$fp,$r22,22,22
 R22,$01,$00,$16,$fp,$r22,22,22
 R23,$01,$00,$17,$s0,$r23,23,23
 R23,$01,$00,$17,$s0,$r23,23,23
 R24,$01,$00,$18,$s1,$r24,24,24
 R24,$01,$00,$18,$s1,$r24,24,24

+ 1 - 1
compiler/loongarch64/rloongarch64abi.inc

@@ -21,7 +21,7 @@
 '$t6',
 '$t6',
 '$t7',
 '$t7',
 '$t8',
 '$t8',
-'$x',
+'$r21',
 '$fp',
 '$fp',
 '$s0',
 '$s0',
 '$s1',
 '$s1',

+ 2 - 2
rtl/loongarch64/setjump.inc

@@ -18,7 +18,7 @@ function fpc_setjmp(var S : jmp_buf) : longint;[Public, alias : 'FPC_SETJMP'];co
   asm
   asm
     st.d $ra, $a0, 0
     st.d $ra, $a0, 0
     st.d $sp, $a0, 8
     st.d $sp, $a0, 8
-    st.d $x, $a0, 16
+    st.d $r21, $a0, 16
     st.d $fp, $a0, 24
     st.d $fp, $a0, 24
     st.d $s0, $a0, 32
     st.d $s0, $a0, 32
     st.d $s1, $a0, 40
     st.d $s1, $a0, 40
@@ -47,7 +47,7 @@ procedure fpc_longjmp(var S : jmp_buf;value : longint);[Public, alias : 'FPC_LON
   asm
   asm
     ld.d $ra, $a0, 0
     ld.d $ra, $a0, 0
     ld.d $sp, $a0, 8
     ld.d $sp, $a0, 8
-    ld.d $x, $a0, 16
+    ld.d $r21, $a0, 16
     ld.d $fp, $a0, 24
     ld.d $fp, $a0, 24
     ld.d $s0, $a0, 32
     ld.d $s0, $a0, 32
     ld.d $s1, $a0, 40
     ld.d $s1, $a0, 40