This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: forcing tail/sibling call optimization

On Mon, 27 Nov 2000 09:26:06 -0700, Jeffrey A Law wrote:

  If you _must_ have tail calls optimized to gotos, then write them that way
  or use a language which guarantees tail calls will turn into gotos.  If
  tail call optimizations are merely convenience, then write them as calls :-)

The original request by Fergus Henderson was:

<<This feature is important for compilers of high-level functional and
  logic programming languages that target C.  For such languages,
  recursion is the primary form of iteration, and it is important that
  sibling calls be optimized.  Often the high-level language compiler has
  more information about when it is safe to do tail calls than gcc has,
  but currently there is no way for the high-level language compiler to
  communicate that to gcc.

  The language C-- (see <>), which is designed to be
  ideal as a target language, provides this feature.  I would like GNU C
  to provide it too.>>

I think that adding extentions to GNU C in order to support the (changing) 
C-- language is a bad idea.  On the other hand, extending GCC to allow 
front-ends to implement such a language seems like a worthwhile goal.  

In order to write a GCC front-end for any language with proper 
tail-recursion,  there should be a way in the tree to represent a tail call. 
If the GCC backend is not able to compile this on a certain architecture,
it abandons the compilation with an error.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]