From b352449eac03cc090900bfa8f06b097b88e80a91 Mon Sep 17 00:00:00 2001 From: florian Date: Sat, 11 Apr 2020 13:18:47 +0000 Subject: [PATCH] * Xtensa: fix flag handling: B0 is considered as default flags git-svn-id: trunk@44687 - --- compiler/hlcgobj.pas | 2 ++ compiler/ncgutil.pas | 4 ---- compiler/xtensa/cgcpu.pas | 4 ++++ compiler/xtensa/cpubase.pas | 8 ++++++-- compiler/xtensa/ncpuadd.pas | 3 ++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/compiler/hlcgobj.pas b/compiler/hlcgobj.pas index 8ebb16c9cc..0cd832faa9 100644 --- a/compiler/hlcgobj.pas +++ b/compiler/hlcgobj.pas @@ -4354,7 +4354,9 @@ implementation LOC_FLAGS : begin a_jmp_flags(list,p.location.resflags,truelabel); +{$ifndef xtensa} a_reg_dealloc(list,NR_DEFAULTFLAGS); +{$endif xtensa} a_jmp_always(list,falselabel); end; {$endif cpuflags} diff --git a/compiler/ncgutil.pas b/compiler/ncgutil.pas index e0e0e6dbc0..ac544bf1b2 100644 --- a/compiler/ncgutil.pas +++ b/compiler/ncgutil.pas @@ -332,11 +332,7 @@ implementation LOC_FLAGS : begin cg.a_jmp_flags(list,p.location.resflags,truelabel); - - { e.g. xtensa has no default flags but uses a boolean register } -{$ifndef xtensa} cg.a_reg_dealloc(list,NR_DEFAULTFLAGS); -{$endif xtensa} cg.a_jmp_always(list,falselabel); end; {$endif cpuflags} diff --git a/compiler/xtensa/cgcpu.pas b/compiler/xtensa/cgcpu.pas index 9a2a40db74..373d0eca02 100644 --- a/compiler/xtensa/cgcpu.pas +++ b/compiler/xtensa/cgcpu.pas @@ -144,6 +144,9 @@ implementation rg[R_FPUREGISTER]:=trgcpu.create(R_FPUREGISTER,R_SUBNONE, [RS_F0,RS_F1,RS_F2,RS_F3,RS_F4,RS_F5,RS_F6,RS_F7,RS_F8,RS_F9, RS_F10,RS_F11,RS_F12,RS_F13,RS_F14,RS_F15],first_fpu_imreg,[]); + rg[R_SPECIALREGISTER]:=trgcpu.create(R_SPECIALREGISTER,R_SUBNONE, + [RS_B0,RS_B1,RS_B2,RS_B3,RS_B4,RS_B5,RS_B6,RS_B7,RS_B8,RS_B9, + RS_B10,RS_B11,RS_B12,RS_B13,RS_B14,RS_B15],first_flag_imreg,[]); end; @@ -151,6 +154,7 @@ implementation begin rg[R_INTREGISTER].free; rg[R_FPUREGISTER].free; + rg[R_SPECIALREGISTER].free; inherited done_register_allocators; end; diff --git a/compiler/xtensa/cpubase.pas b/compiler/xtensa/cpubase.pas index 205da1acd9..5e2741ebd3 100644 --- a/compiler/xtensa/cpubase.pas +++ b/compiler/xtensa/cpubase.pas @@ -84,6 +84,9 @@ unit cpubase; first_mm_supreg = RS_INVALID; first_mm_imreg = $30; + { firs flag imaginary register } + first_flag_imreg = $10; + { TODO: Calculate bsstart} regnumber_count_bsstart = 16; @@ -223,8 +226,9 @@ unit cpubase; { Offset where the parent framepointer is pushed } PARENT_FRAMEPOINTER_OFFSET = 0; - NR_DEFAULTFLAGS = NR_INVALID; - RS_DEFAULTFLAGS = RS_INVALID; + { we consider B0 as the default flag } + NR_DEFAULTFLAGS = NR_B0; + RS_DEFAULTFLAGS = RS_B0; {***************************************************************************** GCC /ABI linking information diff --git a/compiler/xtensa/ncpuadd.pas b/compiler/xtensa/ncpuadd.pas index bce1ba1a8f..f6d7726e72 100644 --- a/compiler/xtensa/ncpuadd.pas +++ b/compiler/xtensa/ncpuadd.pas @@ -283,7 +283,8 @@ interface { emit the actual operation } if cmpop then begin - current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(op,location.register,left.location.register,right.location.register)); + cg.getcpuregister(current_asmdata.CurrAsmList,location.resflags.register); + current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(op,location.resflags.register,left.location.register,right.location.register)); cg.maybe_check_for_fpu_exception(current_asmdata.CurrAsmList); if inv then