mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 16:49:20 +02:00
* MIPS: handle restoring GP after calls without GAS macro processing, removes ugly workaround for GAS bug.
git-svn-id: trunk@25130 -
This commit is contained in:
parent
4afefd6cbe
commit
9a6edd0fb8
@ -378,21 +378,16 @@ begin
|
|||||||
href.refaddr:=addr_low;
|
href.refaddr:=addr_low;
|
||||||
list.concat(taicpu.op_reg_ref(A_ADDIU,NR_PIC_FUNC,href));
|
list.concat(taicpu.op_reg_ref(A_ADDIU,NR_PIC_FUNC,href));
|
||||||
end;
|
end;
|
||||||
{ JAL handled as macro provides delay slot and correct restoring of GP. }
|
list.concat(taicpu.op_reg(A_JALR,NR_PIC_FUNC));
|
||||||
{ Doing it ourselves requires a fixup pass, because GP restore location
|
{ Delay slot }
|
||||||
becomes known only in g_proc_entry, when all code is already generated. }
|
list.concat(taicpu.op_none(A_NOP));
|
||||||
|
{ Restore GP if in PIC mode }
|
||||||
{ GAS <2.21 is buggy, it doesn't add delay slot in noreorder mode. As a result,
|
if (cs_create_pic in current_settings.moduleswitches) then
|
||||||
the code will crash if dealing with stack frame size >32767 or if calling
|
begin
|
||||||
into shared library.
|
if TMIPSProcinfo(current_procinfo).save_gp_ref.offset=0 then
|
||||||
This can be remedied by enabling instruction reordering, but then we also
|
InternalError(2013071001);
|
||||||
have to emit .set macro/.set nomacro pair and exclude JAL from the
|
list.concat(taicpu.op_reg_ref(A_LW,NR_GP,TMIPSProcinfo(current_procinfo).save_gp_ref));
|
||||||
list of macro instructions (because noreorder is not allowed after nomacro) }
|
end;
|
||||||
list.concat(taicpu.op_none(A_P_SET_MACRO));
|
|
||||||
list.concat(taicpu.op_none(A_P_SET_REORDER));
|
|
||||||
list.concat(taicpu.op_reg(A_JAL,NR_PIC_FUNC));
|
|
||||||
list.concat(taicpu.op_none(A_P_SET_NOREORDER));
|
|
||||||
list.concat(taicpu.op_none(A_P_SET_NOMACRO));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -425,22 +420,18 @@ begin
|
|||||||
if assigned(current_procinfo) and
|
if assigned(current_procinfo) and
|
||||||
not (pi_do_call in current_procinfo.flags) then
|
not (pi_do_call in current_procinfo.flags) then
|
||||||
InternalError(2013022102);
|
InternalError(2013022102);
|
||||||
// if (cs_create_pic in current_settings.moduleswitches) then
|
|
||||||
|
if (Reg <> NR_PIC_FUNC) then
|
||||||
|
list.concat(taicpu.op_reg_reg(A_MOVE,NR_PIC_FUNC,reg));
|
||||||
|
list.concat(taicpu.op_reg(A_JALR,NR_PIC_FUNC));
|
||||||
|
{ Delay slot }
|
||||||
|
list.concat(taicpu.op_none(A_NOP));
|
||||||
|
{ Restore GP if in PIC mode }
|
||||||
|
if (cs_create_pic in current_settings.moduleswitches) then
|
||||||
begin
|
begin
|
||||||
if (Reg <> NR_PIC_FUNC) then
|
if TMIPSProcinfo(current_procinfo).save_gp_ref.offset=0 then
|
||||||
list.concat(taicpu.op_reg_reg(A_MOVE,NR_PIC_FUNC,reg));
|
InternalError(2013071002);
|
||||||
{ See comments in a_call_name }
|
list.concat(taicpu.op_reg_ref(A_LW,NR_GP,TMIPSProcinfo(current_procinfo).save_gp_ref));
|
||||||
list.concat(taicpu.op_none(A_P_SET_MACRO));
|
|
||||||
list.concat(taicpu.op_none(A_P_SET_REORDER));
|
|
||||||
list.concat(taicpu.op_reg(A_JAL,NR_PIC_FUNC));
|
|
||||||
list.concat(taicpu.op_none(A_P_SET_NOREORDER));
|
|
||||||
list.concat(taicpu.op_none(A_P_SET_NOMACRO));
|
|
||||||
(* end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
list.concat(taicpu.op_reg(A_JALR, reg));
|
|
||||||
{ Delay slot }
|
|
||||||
list.concat(taicpu.op_none(A_NOP)); *)
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user