From a28d6a84a70941cf7725b8413365a9888d5fb706 Mon Sep 17 00:00:00 2001 From: sergei Date: Sat, 2 Aug 2014 12:46:34 +0000 Subject: [PATCH] + m68k, a_load_const_reg: use MOV3Q if applicable for data registers as well, since it allows spilling replacement of destination. + a_load_const_ref: use CLR and MOV3Q if possible. * a_cmp_reg_reg_label: force size to 32 bits for ISA_A and ISA_A+ targets. + support for stack frames larger than 32767 bytes. git-svn-id: trunk@28298 - --- compiler/m68k/cgcpu.pas | 51 +++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/compiler/m68k/cgcpu.pas b/compiler/m68k/cgcpu.pas index 6bff0a2ecd..1edd342d3d 100644 --- a/compiler/m68k/cgcpu.pas +++ b/compiler/m68k/cgcpu.pas @@ -752,7 +752,11 @@ unit cgcpu; list.concat(taicpu.op_reg(A_CLR,S_L,register)) else begin - if (longint(a) >= low(shortint)) and (longint(a) <= high(shortint)) then + { Prefer MOV3Q if applicable, it allows replacement spilling for register } + if (current_settings.cputype in [cpu_isa_b,cpu_isa_c]) and + ((longint(a)=-1) or ((longint(a)>0) and (longint(a)<8))) then + list.concat(taicpu.op_const_reg(A_MOV3Q,S_L,longint(a),register)) + else if (longint(a) >= low(shortint)) and (longint(a) <= high(shortint)) then list.concat(taicpu.op_const_reg(A_MOVEQ,S_L,longint(a),register)) else begin @@ -787,11 +791,18 @@ unit cgcpu; hreg : tregister; href : treference; begin + a:=longint(a); href:=ref; fixref(list,href); + if (a=0) then + list.concat(taicpu.op_ref(A_CLR,tcgsize2opsize[tosize],href)) + else if (tcgsize2opsize[tosize]=S_L) and + (current_settings.cputype in [cpu_isa_b,cpu_isa_c]) and + ((a=-1) or ((a>0) and (a<8))) then + list.concat(taicpu.op_const_ref(A_MOV3Q,S_L,a,href)) { for coldfire we need to go through a temporary register if we have a offset, index or symbol given } - if (current_settings.cputype in cpu_coldfire) and + else if (current_settings.cputype in cpu_coldfire) and ( (href.offset<>0) or { TODO : check whether we really need this second condition } @@ -1399,6 +1410,13 @@ unit cgcpu; procedure tcg68k.a_cmp_reg_reg_label(list : TAsmList;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel); begin + if (current_settings.cputype in cpu_coldfire-[cpu_isa_b,cpu_isa_c]) then + begin + sign_extend(list,size,reg1); + sign_extend(list,size,reg2); + size:=OS_INT; + end; + list.concat(taicpu.op_reg_reg(A_CMP,tcgsize2opsize[size],reg1,reg2)); { emit the actual jump to the label } a_jmp_cond(list,cmp_op,l); @@ -1604,13 +1622,13 @@ unit cgcpu; if (localsize < 0) then internalerror(2006122601); - { Not to complicate the code generator too much, and since some } - { of the systems only support this format, the localsize cannot } - { exceed 32K in size. } if (localsize > high(smallint)) then - CGMessage(cg_e_localsize_too_big); - - list.concat(taicpu.op_reg_const(A_LINK,S_W,NR_FRAME_POINTER_REG,-localsize)); + begin + list.concat(taicpu.op_reg_const(A_LINK,S_W,NR_FRAME_POINTER_REG,0)); + list.concat(taicpu.op_const_reg(A_SUBA,S_L,localsize,NR_STACK_POINTER_REG)); + end + else + list.concat(taicpu.op_reg_const(A_LINK,S_W,NR_FRAME_POINTER_REG,-localsize)); end; end; @@ -1746,9 +1764,16 @@ unit cgcpu; include(current_procinfo.flags,pi_has_saved_regs); { Copy registers to temp } + { NOTE: virtual registers allocated here won't be translated --> no higher-level stuff. } href:=current_procinfo.save_regs_ref; + if (href.offset