mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 11:29:16 +02:00
Constrained a number of optimizations and updated reference offsets for ARM Thumb.
Embedded target can now build with optimizations. git-svn-id: trunk@28023 -
This commit is contained in:
parent
36d6fb7868
commit
a1197460e1
@ -1206,6 +1206,12 @@ Implementation
|
|||||||
(taicpu(hp1).oper[1]^.ref^.base = taicpu(p).oper[0]^.reg))
|
(taicpu(hp1).oper[1]^.ref^.base = taicpu(p).oper[0]^.reg))
|
||||||
) and
|
) and
|
||||||
not(RegModifiedBetween(taicpu(p).oper[1]^.reg,p,hp1)) and
|
not(RegModifiedBetween(taicpu(p).oper[1]^.reg,p,hp1)) and
|
||||||
|
|
||||||
|
// Make sure that Thumb code doesn't propagate a high register into a reference
|
||||||
|
((GenerateThumbCode and
|
||||||
|
(getsupreg(taicpu(p).oper[1]^.reg) < RS_R8)) or
|
||||||
|
(not GenerateThumbCode)) and
|
||||||
|
|
||||||
RegEndOfLife(taicpu(p).oper[0]^.reg, taicpu(hp1)) then
|
RegEndOfLife(taicpu(p).oper[0]^.reg, taicpu(hp1)) then
|
||||||
begin
|
begin
|
||||||
DebugMsg('Peephole MovLdr2Ldr done', hp1);
|
DebugMsg('Peephole MovLdr2Ldr done', hp1);
|
||||||
@ -1600,7 +1606,8 @@ Implementation
|
|||||||
to
|
to
|
||||||
str/ldr reg3,[reg1,const2+/-const1]
|
str/ldr reg3,[reg1,const2+/-const1]
|
||||||
}
|
}
|
||||||
if (taicpu(p).opcode in [A_ADD,A_SUB]) and
|
if (not GenerateThumbCode) and
|
||||||
|
(taicpu(p).opcode in [A_ADD,A_SUB]) and
|
||||||
(taicpu(p).ops>2) and
|
(taicpu(p).ops>2) and
|
||||||
(taicpu(p).oper[1]^.typ = top_reg) and
|
(taicpu(p).oper[1]^.typ = top_reg) and
|
||||||
(taicpu(p).oper[2]^.typ = top_const) then
|
(taicpu(p).oper[2]^.typ = top_const) then
|
||||||
|
@ -181,6 +181,8 @@ unit cgcpu;
|
|||||||
procedure a_load_const_reg(list: TAsmList; size: tcgsize; a: tcgint; reg: tregister);override;
|
procedure a_load_const_reg(list: TAsmList; size: tcgsize; a: tcgint; reg: tregister);override;
|
||||||
|
|
||||||
procedure g_adjust_self_value(list:TAsmList;procdef: tprocdef;ioffset: tcgint); override;
|
procedure g_adjust_self_value(list:TAsmList;procdef: tprocdef;ioffset: tcgint); override;
|
||||||
|
|
||||||
|
function handle_load_store(list: TAsmList; op: tasmop; oppostfix: toppostfix; reg: tregister; ref: treference): treference; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
tthumbcg64farm = class(tbasecg64farm)
|
tthumbcg64farm = class(tbasecg64farm)
|
||||||
@ -3866,8 +3868,8 @@ unit cgcpu;
|
|||||||
{ only complicated references need an extra loadaddr }
|
{ only complicated references need an extra loadaddr }
|
||||||
if assigned(ref.symbol) or
|
if assigned(ref.symbol) or
|
||||||
(ref.index<>NR_NO) or
|
(ref.index<>NR_NO) or
|
||||||
(ref.offset<-255) or
|
(ref.offset<-124) or
|
||||||
(ref.offset>4094) or
|
(ref.offset>124) or
|
||||||
{ sometimes the compiler reused registers }
|
{ sometimes the compiler reused registers }
|
||||||
(reg=ref.index) or
|
(reg=ref.index) or
|
||||||
(reg=ref.base) then
|
(reg=ref.base) then
|
||||||
@ -3899,8 +3901,8 @@ unit cgcpu;
|
|||||||
{ only complicated references need an extra loadaddr }
|
{ only complicated references need an extra loadaddr }
|
||||||
if assigned(ref.symbol) or
|
if assigned(ref.symbol) or
|
||||||
(ref.index<>NR_NO) or
|
(ref.index<>NR_NO) or
|
||||||
(ref.offset<-255) or
|
(ref.offset<-124) or
|
||||||
(ref.offset>4092) or
|
(ref.offset>124) or
|
||||||
{ sometimes the compiler reused registers }
|
{ sometimes the compiler reused registers }
|
||||||
(reg=ref.index) or
|
(reg=ref.index) or
|
||||||
(reg=ref.base) then
|
(reg=ref.base) then
|
||||||
@ -4049,6 +4051,54 @@ unit cgcpu;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function tthumbcgarm.handle_load_store(list: TAsmList; op: tasmop; oppostfix: toppostfix; reg: tregister; ref: treference): treference;
|
||||||
|
var
|
||||||
|
href : treference;
|
||||||
|
tmpreg : TRegister;
|
||||||
|
begin
|
||||||
|
href:=ref;
|
||||||
|
if (op in [A_STR,A_STRB,A_STRH]) and
|
||||||
|
(abs(ref.offset)>124) then
|
||||||
|
begin
|
||||||
|
tmpreg:=getintregister(list,OS_ADDR);
|
||||||
|
a_loadaddr_ref_reg(list,ref,tmpreg);
|
||||||
|
|
||||||
|
reference_reset_base(href,tmpreg,0,ref.alignment);
|
||||||
|
end
|
||||||
|
else if (op=A_LDR) and
|
||||||
|
(oppostfix in [PF_None]) and
|
||||||
|
(ref.base<>NR_STACK_POINTER_REG) and
|
||||||
|
(abs(ref.offset)>124) then
|
||||||
|
begin
|
||||||
|
tmpreg:=getintregister(list,OS_ADDR);
|
||||||
|
a_loadaddr_ref_reg(list,ref,tmpreg);
|
||||||
|
|
||||||
|
reference_reset_base(href,tmpreg,0,ref.alignment);
|
||||||
|
end
|
||||||
|
else if (op=A_LDR) and
|
||||||
|
(oppostfix in [PF_None]) and
|
||||||
|
(ref.base=NR_STACK_POINTER_REG) and
|
||||||
|
(abs(ref.offset)>1020) then
|
||||||
|
begin
|
||||||
|
tmpreg:=getintregister(list,OS_ADDR);
|
||||||
|
a_loadaddr_ref_reg(list,ref,tmpreg);
|
||||||
|
|
||||||
|
reference_reset_base(href,tmpreg,0,ref.alignment);
|
||||||
|
end
|
||||||
|
else if (op=A_LDR) and
|
||||||
|
((oppostfix in [PF_SH,PF_SB]) or
|
||||||
|
(abs(ref.offset)>124)) then
|
||||||
|
begin
|
||||||
|
tmpreg:=getintregister(list,OS_ADDR);
|
||||||
|
a_loadaddr_ref_reg(list,ref,tmpreg);
|
||||||
|
|
||||||
|
reference_reset_base(href,tmpreg,0,ref.alignment);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Result:=inherited handle_load_store(list, op, oppostfix, reg, href);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure tthumbcgarm.a_op_reg_reg(list : TAsmList; Op: TOpCG; size: TCGSize; src, dst: TRegister);
|
procedure tthumbcgarm.a_op_reg_reg(list : TAsmList; Op: TOpCG; size: TCGSize; src, dst: TRegister);
|
||||||
var
|
var
|
||||||
tmpreg,overflowreg : tregister;
|
tmpreg,overflowreg : tregister;
|
||||||
|
@ -290,6 +290,10 @@ unit rgcpu;
|
|||||||
if abs(spilltemp.offset)>4095 then
|
if abs(spilltemp.offset)>4095 then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
if GenerateThumbCode and
|
||||||
|
(abs(spilltemp.offset)>1020) then
|
||||||
|
exit;
|
||||||
|
|
||||||
{ Replace 'mov dst,orgreg' with 'ldr dst,spilltemp'
|
{ Replace 'mov dst,orgreg' with 'ldr dst,spilltemp'
|
||||||
and 'mov orgreg,src' with 'str dst,spilltemp' }
|
and 'mov orgreg,src' with 'str dst,spilltemp' }
|
||||||
with instr do
|
with instr do
|
||||||
|
Loading…
Reference in New Issue
Block a user