ip2k.c (function_epilogue): Optimize stack deallocation.

* config/ip2k/ip2k.c (function_epilogue): Optimize stack
	deallocation.
	* config/ip2k/libgcc.S: Combine routines used by function
	epilogue.

From-SVN: r58027
This commit is contained in:
Denis Chertykov 2002-10-10 19:45:59 +00:00 committed by Denis Chertykov
parent f930bfd067
commit b687818845
4 changed files with 73 additions and 71 deletions

View File

@ -1,3 +1,10 @@
2002-10-10 Denis Chertykov <denisc@overta.ru>
* config/ip2k/ip2k.c (function_epilogue): Optimize stack
deallocation.
* config/ip2k/libgcc.S: Combine routines used by function
epilogue.
2002-10-10 Jim Wilson <wilson@redhat.com>
* cse.c (fold_rtx): Don't perform associative optimization for DIV and

View File

@ -304,6 +304,8 @@ function_epilogue (file, size)
int leaf_func_p;
int reg,savelimit;
rtx operands[2]; /* Dummy used by OUT_ASn */
int args_locals_size = current_function_args_size;
int saved_regs_p = 0;
int need_ret = 1;
/* Use this opportunity to reset the reorg flags! */
@ -325,42 +327,54 @@ function_epilogue (file, size)
epilogue_size = 0;
fprintf (file, "/* epilogue: frame size=%d */\n", size);
savelimit = (CHAIN_FRAMES) ? REG_FP : (REG_FP + 2);
for (reg = 0; reg < savelimit; reg++)
if (regs_ever_live[reg] && ! call_used_regs[reg])
{
saved_regs_p = 1;
break;
}
if (size)
{
operands[0] = GEN_INT (size);
switch (size & 0xff)
if (leaf_func_p && !CHAIN_FRAMES && !saved_regs_p
&& current_function_pops_args)
args_locals_size = current_function_args_size + size;
else
{
default:
OUT_AS2 (mov, w, %L0);
OUT_AS2 (add, spl, w);
epilogue_size += 4;
/* fall-thru */
case 0:
break;
case 1:
OUT_AS1 (inc, spl);
epilogue_size += 2;
}
operands[0] = GEN_INT (size);
switch (size & 0xff00)
{
default:
if ((size & 0xff) != ((size >> 8) & 0xff))
OUT_AS2 (mov, w, %H0);
OUT_AS2 (add, sph, w);
epilogue_size += 4;
/* fall-thru */
case 0:
break;
case 0x100:
OUT_AS1 (inc, sph);
epilogue_size += 2;
switch (size & 0xff)
{
default:
OUT_AS2 (mov, w, %L0);
OUT_AS2 (add, spl, w);
epilogue_size += 4;
/* fall-thru */
case 0:
break;
case 1:
OUT_AS1 (inc, spl);
epilogue_size += 2;
}
switch (size & 0xff00)
{
default:
if ((size & 0xff) != ((size >> 8) & 0xff))
OUT_AS2 (mov, w, %H0);
OUT_AS2 (add, sph, w);
epilogue_size += 4;
/* fall-thru */
case 0:
break;
case 0x100:
OUT_AS1 (inc, sph);
epilogue_size += 2;
}
}
}
savelimit = (CHAIN_FRAMES) ? REG_FP : (REG_FP + 2);
for (reg = 0; reg < savelimit; reg++)
{
if (regs_ever_live[reg] && ! call_used_regs[reg])
@ -428,10 +442,10 @@ function_epilogue (file, size)
else
{
if (current_function_pops_args
&& current_function_args_size >= 2
&& current_function_args_size < 0x100)
&& args_locals_size >= 2
&& args_locals_size < 0x100)
{
if (current_function_args_size == 2)
if (args_locals_size == 2)
{
if (CHAIN_FRAMES)
{
@ -443,7 +457,7 @@ function_epilogue (file, size)
}
else
{
operands[0] = GEN_INT (current_function_args_size);
operands[0] = GEN_INT (args_locals_size);
if (CHAIN_FRAMES)
{
OUT_AS2 (mov, w, %L0);
@ -456,12 +470,11 @@ function_epilogue (file, size)
}
}
if (current_function_pops_args && current_function_args_size
&& need_ret)
if (current_function_pops_args && args_locals_size && need_ret)
{
operands[0] = GEN_INT (current_function_args_size);
operands[0] = GEN_INT (args_locals_size);
switch (current_function_args_size & 0xff)
switch (args_locals_size & 0xff)
{
default:
OUT_AS2 (mov, w, %L0);
@ -477,11 +490,10 @@ function_epilogue (file, size)
epilogue_size += 2;
}
switch (current_function_args_size & 0xff00)
switch (args_locals_size & 0xff00)
{
default:
if ((current_function_args_size & 0xff)
!= ((current_function_args_size >> 8) & 0xff))
if ((args_locals_size & 0xff) != ((args_locals_size >> 8) & 0xff))
OUT_AS2 (mov, w, %H0);
OUT_AS2 (add, sph, w);
epilogue_size += 4;

View File

@ -1,4 +1,3 @@
; libgcc.S for the Ubicom IP2k architecture.
;
; Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
; Contributed by Red Hat, Inc and Ubicom, Inc.
@ -1327,8 +1326,11 @@ __cmpdi2_dp:
.sect .pram.libgcc,"ax"
.global __fp_pop_args_ret
.global __pop_args_ret
.func __fp_pop_args_ret, __fp_pop_args_ret
.global __pop2_args_ret
.func __fp_pop2_args_ret, __fp_pop2_args_ret
__fp_pop2_args_ret:
mov w, #2
__fp_pop_args_ret:
pop 0xfd
pop 0xfe
@ -1341,29 +1343,11 @@ __pop_args_ret:
.endfunc
#endif /* L_fp_pop_args_ret */
#if defined(L_leaf_fp_pop_args_ret)
#if defined(L__pop2_args_ret)
.sect .pram.libgcc,"ax"
.global __leaf_fp_pop_args_ret
.func __leaf_fp_pop_args_ret, __leaf_fp_pop_args_ret
__leaf_fp_pop_args_ret:
pop 0xfd
pop 0xfe
add spl, w
ret
.endfunc
#endif /* L_leaf_fp_pop_args_ret */
#if defined(L_fp_pop2_args_ret)
.sect .pram.libgcc,"ax"
.global __fp_pop2_args_ret
.global __pop2_args_ret
.func __fp_pop2_args_ret, __fp_pop2_args_ret
.func __pop2_args_ret, __pop2_args_ret
__fp_pop2_args_ret:
pop 0xfd
pop 0xfe
__pop2_args_ret:
mov w, #2
pop callh
@ -1372,22 +1356,23 @@ __pop2_args_ret:
ret
.endfunc
#endif /* L_fp_pop2_args_ret */
#endif /* L__pop2_args_ret */
#if defined(L_leaf_fp_pop2_args_ret)
#if defined(L_leaf_fp_pop_args_ret)
.sect .pram.libgcc,"ax"
.global __leaf_fp_pop2_args_ret
.func __leaf_fp_pop2_args_ret, __leaf_fp_pop2_args_ret
.global __leaf_fp_pop_args_ret, __leaf_fp_pop2_args_ret
.func __leaf_fp2_pop_args_ret, __leaf_fp_pop2_args_ret
__leaf_fp_pop2_args_ret:
mov w, #2
__leaf_fp_pop_args_ret:
pop 0xfd
pop 0xfe
mov w, #2
add spl, w
ret
.endfunc
#endif /* L_leaf_fp_pop2_args_ret */
#endif /* L_leaf_fp_pop_args_ret */
#if defined(L_movstrhi_countqi)
.sect .pram.libgcc,"ax"
@ -1529,4 +1514,3 @@ _write:
.endfunc
#endif

View File

@ -17,9 +17,8 @@ LIB1ASMFUNCS = \
_cmpdi2 \
_cmpdi2_dp \
_fp_pop_args_ret \
_pop2_args_ret \
_leaf_fp_pop_args_ret \
_fp_pop2_args_ret \
_leaf_fp_pop2_args_ret \
_movstrhi_countqi \
_movstrhi_counthi \
abort \