From 47f6af4416d8ef3d46b315a80fcfd9c9f8e5c574 Mon Sep 17 00:00:00 2001 From: florian Date: Thu, 26 Mar 2020 21:54:40 +0000 Subject: [PATCH] * Xtensa: improve tcgcpu.fixref git-svn-id: trunk@44368 - --- compiler/xtensa/cgcpu.pas | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/compiler/xtensa/cgcpu.pas b/compiler/xtensa/cgcpu.pas index 86d33b2af0..b31ca1e745 100644 --- a/compiler/xtensa/cgcpu.pas +++ b/compiler/xtensa/cgcpu.pas @@ -292,7 +292,7 @@ implementation l : tasmlabel; begin { create consts entry } - if assigned(ref.symbol) or (ref.offset<>0) then + if assigned(ref.symbol) or (ref.offset<-2048) or (ref.offset>2047) then begin reference_reset(tmpref,4,[]); current_asmdata.getjumplabel(l); @@ -321,7 +321,33 @@ implementation end else ref.base:=tmpreg; + end + else if ref.offset<>0 then + begin + tmpreg:=getintregister(list,OS_INT); + if (ref.offset>=-128) and (ref.offset<=127) then + begin + list.concat(taicpu.op_reg_reg_const(A_ADDI,tmpreg,ref.base,ref.offset)); + ref.base:=tmpreg; + end + else + begin + list.concat(taicpu.op_reg_const(A_MOVI,tmpreg,ref.offset)); + if ref.base<>NR_NO then + begin + if ref.index<>NR_NO then + begin + list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg,ref.base,tmpreg)); + ref.base:=tmpreg; + end + else + ref.index:=tmpreg; + end + else + ref.base:=tmpreg; + end; end; + if ref.index<>NR_NO then begin if ref.base<>NR_NO then