From 28323135f8ce77a8cd01fa2df2cd2aa473d1f66b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A1roly=20Balogh?= Date: Sun, 25 May 2014 01:34:00 +0000 Subject: [PATCH] m68k: minor optimizations to g_proc_exit() - use LEA for stackpointer math which is better than ADDing large constants, also only modify the SP reg once git-svn-id: trunk@27817 - --- compiler/m68k/cgcpu.pas | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/compiler/m68k/cgcpu.pas b/compiler/m68k/cgcpu.pas index 11a83b3a32..2f2389259e 100644 --- a/compiler/m68k/cgcpu.pas +++ b/compiler/m68k/cgcpu.pas @@ -1716,9 +1716,8 @@ unit cgcpu; procedure tcg68k.g_proc_exit(list : TAsmList; parasize: longint; nostackframe: boolean); var r,hregister : TRegister; - spr : TRegister; - fpr : TRegister; ref : TReference; + ref2: TReference; begin if not nostackframe then begin @@ -1752,15 +1751,23 @@ unit cgcpu; hregister:=NR_A0; cg.a_reg_alloc(list,hregister); reference_reset_base(ref,NR_STACK_POINTER_REG,0,4); - ref.direction:=dir_inc; list.concat(taicpu.op_ref_reg(A_MOVE,S_L,ref,hregister)); + { instead of using a postincrement above (which also writes the } + { stackpointer reg) simply add 4 to the parasize, the instructions } + { below then take that size into account as well, so SP reg is only } + { written once (KB) } + parasize:=parasize+4; + r:=NR_SP; { can we do a quick addition ... } - if (parasize > 0) and (parasize < 9) then + if (parasize < 9) then list.concat(taicpu.op_const_reg(A_ADDQ,S_L,parasize,r)) else { nope ... } - list.concat(taicpu.op_const_reg(A_ADD,S_L,parasize,r)); + begin + reference_reset_base(ref2,NR_STACK_POINTER_REG,parasize,4); + list.concat(taicpu.op_ref_reg(A_LEA,S_NO,ref2,r)); + end; reference_reset_base(ref,hregister,0,4); list.concat(taicpu.op_ref(A_JMP,S_NO,ref));