addressing improvements: fixref can swap base/index registers if better fits 68k pattern, less need to move around registers. also fix reference in a_op_const_ref.

git-svn-id: trunk@27108 -
This commit is contained in:
Károly Balogh 2014-03-12 01:32:44 +00:00
parent 7ea92f48cc
commit 7b05113322

View File

@ -452,6 +452,17 @@ unit cgcpu;
displacement. displacement.
} }
{ first ensure that base is an address register } { first ensure that base is an address register }
if ((ref.base<>NR_NO) and (ref.index<>NR_NO)) and
(not isaddressregister(ref.base) and isaddressregister(ref.index)) then
begin
{ if we have both base and index registers, but base is data and index
is address, we can just swap them, as FPC always uses long index }
hreg:=ref.base;
ref.base:=ref.index;
ref.index:=hreg;
//list.concat(tai_comment.create(strpnew('fixref: base and index swapped')));
end;
if (not assigned (ref.symbol) and (current_settings.cputype<>cpu_MC68000)) and if (not assigned (ref.symbol) and (current_settings.cputype<>cpu_MC68000)) and
(ref.base<>NR_NO) and not isaddressregister(ref.base) then (ref.base<>NR_NO) and not isaddressregister(ref.base) then
begin begin
@ -1176,7 +1187,8 @@ unit cgcpu;
procedure tcg68k.a_op_const_ref(list : TAsmList; Op: TOpCG; size: TCGSize; a: tcgint; const ref: TReference); procedure tcg68k.a_op_const_ref(list : TAsmList; Op: TOpCG; size: TCGSize; a: tcgint; const ref: TReference);
var var
opcode: tasmop; opcode: tasmop;
opsize : topsize; opsize: topsize;
href : treference;
begin begin
optimize_op_const(size, op, a); optimize_op_const(size, op, a);
opcode := topcg2tasmop[op]; opcode := topcg2tasmop[op];
@ -1191,6 +1203,8 @@ unit cgcpu;
exit; exit;
end; end;
href:=ref;
fixref(list,href);
case op of case op of
OP_NONE : OP_NONE :
begin begin
@ -1211,11 +1225,11 @@ unit cgcpu;
opcode:=A_ADDQ opcode:=A_ADDQ
else else
opcode:=A_SUBQ; opcode:=A_SUBQ;
list.concat(taicpu.op_const_ref(opcode, opsize, a, ref)); list.concat(taicpu.op_const_ref(opcode, opsize, a, href));
end end
else else
if current_settings.cputype = cpu_mc68000 then if not(current_settings.cputype in cpu_coldfire) then
list.concat(taicpu.op_const_ref(opcode, opsize, a, ref)) list.concat(taicpu.op_const_ref(opcode, opsize, a, href))
else else
{ on ColdFire, ADDI/SUBI cannot act on memory { on ColdFire, ADDI/SUBI cannot act on memory
so we can only go through a register } so we can only go through a register }