mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 20:09:27 +02:00
Change branch and jump destinations to byte based distances.
This commit is contained in:
parent
4200ebd748
commit
a43f1bc1d0
@ -478,8 +478,8 @@ implementation
|
|||||||
firstinstruction:=curtai;
|
firstinstruction:=curtai;
|
||||||
case taicpu(curtai).opcode of
|
case taicpu(curtai).opcode of
|
||||||
A_BRxx:
|
A_BRxx:
|
||||||
if (taicpu(curtai).oper[0]^.typ=top_ref) and ((taicpu(curtai).InsOffset-taicpu(curtai).oper[0]^.ref^.symbol.offset>64) or
|
if (taicpu(curtai).oper[0]^.typ=top_ref) and ((taicpu(curtai).InsOffset-taicpu(curtai).oper[0]^.ref^.symbol.offset>63*2) or
|
||||||
(taicpu(curtai).InsOffset-taicpu(curtai).oper[0]^.ref^.symbol.offset<-63)) then
|
(taicpu(curtai).InsOffset-taicpu(curtai).oper[0]^.ref^.symbol.offset<-64*2)) then
|
||||||
begin
|
begin
|
||||||
if inasmblock then
|
if inasmblock then
|
||||||
Message(asmw_e_brxx_out_of_range)
|
Message(asmw_e_brxx_out_of_range)
|
||||||
@ -499,9 +499,12 @@ implementation
|
|||||||
end;
|
end;
|
||||||
A_JMP:
|
A_JMP:
|
||||||
{ replace JMP by RJMP? ...
|
{ replace JMP by RJMP? ...
|
||||||
... but do not mess with asm block }
|
... but do not mess with asm block.
|
||||||
if not(inasmblock) and (taicpu(curtai).InsOffset-taicpu(curtai).oper[0]^.ref^.symbol.offset<=2048) and
|
Replacing JMP with RJMP shorten the distance to the destination
|
||||||
(taicpu(curtai).InsOffset-taicpu(curtai).oper[0]^.ref^.symbol.offset>=-2047) and
|
in the reverse direction by 2 bytes, hence checking against a
|
||||||
|
distance of -2049*2 bytes. }
|
||||||
|
if not(inasmblock) and (taicpu(curtai).InsOffset-taicpu(curtai).oper[0]^.ref^.symbol.offset<=2047*2) and
|
||||||
|
(taicpu(curtai).InsOffset-taicpu(curtai).oper[0]^.ref^.symbol.offset>=-2049*2) and
|
||||||
{ jmps to function go outside the currently considered scope, so do not mess with them.
|
{ jmps to function go outside the currently considered scope, so do not mess with them.
|
||||||
Those are generated by the peephole optimizer from call/ret sequences }
|
Those are generated by the peephole optimizer from call/ret sequences }
|
||||||
not(taicpu(curtai).oper[0]^.ref^.symbol.typ=AT_FUNCTION) then
|
not(taicpu(curtai).oper[0]^.ref^.symbol.typ=AT_FUNCTION) then
|
||||||
|
Loading…
Reference in New Issue
Block a user