avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Now to do Tail Recursions?


From: Ned Konz
Subject: Re: [avr-gcc-list] Now to do Tail Recursions?
Date: Mon, 30 Aug 2004 12:04:19 -0700
User-agent: KMail/1.6.2

On Monday 30 August 2004 10:57 am, Bob Paddock wrote:
> Some gcc targets have an option of "-mtail-call" to optimize
> calls followed immediately by a return into a jump to the subroutine.
>
> Example:
>
> rcall hex8
> ret
>
> becomes
>
> rjmp hex8
>
> I tried -mtail-call with avr-gcc and I get "invalid option" from cc1.
>
> Did I not use it correctly, or more likely it is is not implemented?
>

It may be an older option. This is what I get looking at the x86 and AVR 
versions:

$ gcc --version
gcc (GCC) 3.3.4 (Debian 1:3.3.4-2)

$ gcc --help -v 2>&1 | grep tail
  -ftracer                Perform superblock formation via tail duplication
  -foptimize-sibling-calls Optimize sibling and tail recursive calls
  --param tracer-max-code-growth=<value> Maximal code growth caused by tail 
duplication (in percents)

$ avr-gcc --version
avr-gcc (GCC) 3.4.1

$ avr-gcc --help -v 2>&1 | grep tail
  -foptimize-sibling-calls    Optimize sibling and tail recursive calls
  -ftracer                    Perform superblock formation via tail 
duplication
  tracer-max-code-growth      Maximal code growth caused by tail duplication


> Anyone have a AWK or perl script that does it the hard way at hand already?
>
> In a related size question why are there two 'ret' instructions, one right
> after
> the other?  'ret ret' wastes two bytes.

The attached Vim editor script fixes all three patterns in an assembler file. 
However, I've not really used it, so see if you like it.

You can run it in batch mode as:
 
vim -S fixTailCalls.vim myAssemblerFile.s

-- 
Ned Konz
http://bike-nomad.com

Attachment: fixTailCalls.vim
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]