mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 17:29:21 +02:00
* when inserting pc relative data blocks on arm thumb, avoid negative pc offsets, if needed, the data is copied
a short test with the rtl shows that this happens exactly once in the rtl, so it is feasible to do so git-svn-id: trunk@24413 -
This commit is contained in:
parent
1f8192b6da
commit
cec28ef512
@ -488,6 +488,9 @@ interface
|
|||||||
{ set to true when the label has been moved by insertpcrelativedata to the correct location
|
{ set to true when the label has been moved by insertpcrelativedata to the correct location
|
||||||
so one label can be used multiple times }
|
so one label can be used multiple times }
|
||||||
moved : boolean;
|
moved : boolean;
|
||||||
|
{ true, if a label has been already inserted, this is important for arm thumb where no negative
|
||||||
|
pc relative offsets are allowed }
|
||||||
|
inserted : boolean;
|
||||||
{$endif arm}
|
{$endif arm}
|
||||||
constructor Create(_labsym : tasmlabel);
|
constructor Create(_labsym : tasmlabel);
|
||||||
constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
|
constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
|
||||||
@ -1945,7 +1948,7 @@ implementation
|
|||||||
TAI_LABEL
|
TAI_LABEL
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
|
||||||
constructor tai_label.create(_labsym : tasmlabel);
|
constructor tai_label.Create(_labsym : tasmlabel);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
typ:=ait_label;
|
typ:=ait_label;
|
||||||
@ -1976,7 +1979,6 @@ implementation
|
|||||||
labsym.is_set:=true;
|
labsym.is_set:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{****************************************************************************
|
{****************************************************************************
|
||||||
tai_comment comment to be inserted in the assembler file
|
tai_comment comment to be inserted in the assembler file
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
@ -873,6 +873,7 @@ implementation
|
|||||||
limit: longint;
|
limit: longint;
|
||||||
curop : longint;
|
curop : longint;
|
||||||
curtai : tai;
|
curtai : tai;
|
||||||
|
ai_label : tai_label;
|
||||||
curdatatai,hp,hp2 : tai;
|
curdatatai,hp,hp2 : tai;
|
||||||
curdata : TAsmList;
|
curdata : TAsmList;
|
||||||
l : tasmlabel;
|
l : tasmlabel;
|
||||||
@ -910,12 +911,31 @@ implementation
|
|||||||
begin
|
begin
|
||||||
{ pc relative symbol? }
|
{ pc relative symbol? }
|
||||||
curdatatai:=tai(taicpu(curtai).oper[curop]^.ref^.symboldata);
|
curdatatai:=tai(taicpu(curtai).oper[curop]^.ref^.symboldata);
|
||||||
if assigned(curdatatai) and
|
if assigned(curdatatai) then
|
||||||
|
begin
|
||||||
|
{ create a new copy of a data entry on arm thumb if the entry has been inserted already
|
||||||
|
before because arm thumb does not allow pc relative negative offsets }
|
||||||
|
if (current_settings.cputype in cpu_thumb) and
|
||||||
|
tai_label(curdatatai).inserted then
|
||||||
|
begin
|
||||||
|
current_asmdata.getjumplabel(l);
|
||||||
|
hp:=tai_label.create(l);
|
||||||
|
listtoinsert.Concat(hp);
|
||||||
|
hp2:=tai(curdatatai.Next.GetCopy);
|
||||||
|
hp2.Next:=nil;
|
||||||
|
hp2.Previous:=nil;
|
||||||
|
listtoinsert.Concat(hp2);
|
||||||
|
taicpu(curtai).oper[curop]^.ref^.symboldata:=hp;
|
||||||
|
taicpu(curtai).oper[curop]^.ref^.symbol:=l;
|
||||||
|
curdatatai:=hp;
|
||||||
|
end;
|
||||||
|
|
||||||
{ move only if we're at the first reference of a label }
|
{ move only if we're at the first reference of a label }
|
||||||
not(tai_label(curdatatai).moved) then
|
if not(tai_label(curdatatai).moved) then
|
||||||
begin
|
begin
|
||||||
tai_label(curdatatai).moved:=true;
|
tai_label(curdatatai).moved:=true;
|
||||||
{ check if symbol already used. }
|
{ check if symbol already used. }
|
||||||
|
|
||||||
{ if yes, reuse the symbol }
|
{ if yes, reuse the symbol }
|
||||||
hp:=tai(curdatatai.next);
|
hp:=tai(curdatatai.next);
|
||||||
removeref:=false;
|
removeref:=false;
|
||||||
@ -937,12 +957,13 @@ implementation
|
|||||||
inc(extradataoffset,2*multiplier);
|
inc(extradataoffset,2*multiplier);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
{ check if the same constant has been already inserted into the currently handled list,
|
||||||
|
if yes, reuse it }
|
||||||
if (hp.typ=ait_const) then
|
if (hp.typ=ait_const) then
|
||||||
begin
|
begin
|
||||||
hp2:=tai(curdata.first);
|
hp2:=tai(curdata.first);
|
||||||
while assigned(hp2) do
|
while assigned(hp2) do
|
||||||
begin
|
begin
|
||||||
{ if armconstequal(hp2,hp) then }
|
|
||||||
if (hp2.typ=ait_const) and (tai_const(hp2).sym=tai_const(hp).sym)
|
if (hp2.typ=ait_const) and (tai_const(hp2).sym=tai_const(hp).sym)
|
||||||
and (tai_const(hp2).value=tai_const(hp).value) and (tai(hp2.previous).typ=ait_label)
|
and (tai_const(hp2).value=tai_const(hp).value) and (tai(hp2.previous).typ=ait_label)
|
||||||
then
|
then
|
||||||
@ -974,6 +995,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
inc(curinspos,multiplier);
|
inc(curinspos,multiplier);
|
||||||
end;
|
end;
|
||||||
ait_align:
|
ait_align:
|
||||||
@ -1065,6 +1087,18 @@ implementation
|
|||||||
curdata.Insert(tai_align.Create(4));
|
curdata.Insert(tai_align.Create(4));
|
||||||
curdata.insert(taicpu.op_sym(A_B,l));
|
curdata.insert(taicpu.op_sym(A_B,l));
|
||||||
curdata.concat(tai_label.create(l));
|
curdata.concat(tai_label.create(l));
|
||||||
|
|
||||||
|
{ mark all labels as inserted, arm thumb
|
||||||
|
needs this, so data referencing an already inserted label can be
|
||||||
|
duplicated because arm thumb does not allow negative pc relative offset }
|
||||||
|
hp2:=tai(curdata.first);
|
||||||
|
while assigned(hp2) do
|
||||||
|
begin
|
||||||
|
if hp2.typ=ait_label then
|
||||||
|
tai_label(hp2).inserted:=true;
|
||||||
|
hp2:=tai(hp2.next);
|
||||||
|
end;
|
||||||
|
|
||||||
list.insertlistafter(curtai,curdata);
|
list.insertlistafter(curtai,curdata);
|
||||||
curtai:=hp;
|
curtai:=hp;
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user