Applied fix for binutils 2.41 for loongarch64 suggested by Jinyang He

32fa3e9eb1
  with modifications reported in comments.
This commit is contained in:
Pierre Muller 2023-08-11 08:56:02 +00:00
parent ff673eadac
commit 22a1acd610
4 changed files with 20 additions and 11 deletions

View File

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

View File

@ -28,7 +28,7 @@ R17,$01,$00,$11,$t5,$r17,17,17
R18,$01,$00,$12,$t6,$r18,18,18
R19,$01,$00,$13,$t7,$r19,19,19
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
R23,$01,$00,$17,$s0,$r23,23,23
R24,$01,$00,$18,$s1,$r24,24,24

View File

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

View File

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