Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!world!iecc!compilers-sender From: megatest!djones@decwrl.dec.com (Dave Jones) Newsgroups: comp.compilers Subject: Re: Squashing C Source Keywords: optimize Message-ID: <14662@goofy.megatest.UUCP> Date: 14 Dec 90 00:16:35 GMT References: <10767.9012051639@subnode.sari.ed.ac.uk> Sender: compilers-sender@iecc.cambridge.ma.us Reply-To: megatest!djones@decwrl.dec.com (Dave Jones) Organization: Megatest Corporation, San Jose, Ca Lines: 25 Approved: compilers@iecc.cambridge.ma.us > I'm after a preprocessor that will do in-line expansion of procedure > calls IN SOURCE for C to produce one lovely long main() procedure, > something capable of dealing intelligently with parameters and local > variables. Anyone out there got any ideas before I start writing ? You might look for inspiration in "cfront" or some other C++ to C compiler that does in-line procedure expansion. Look at the C code that it produces for in-line calls and you'll get the flavor of it. Now then, please tell us why in the world you would want to make an entire program into one procedure. That will certainly make the resulting object code slower. For one thing, on most machines, the procedure call/return is an efficient way to save and restore registers. For another, unless the program is a rather simple one with most procedures being called from only one place, the program will be larger. On machines that do paging, larger usually means slower, sometimes much slower. If you are trying to get around some system limitation, tell us what it is and maybe someone will come up with an alterative method. I will leave you with one last word: "recursion". You will have to reinvent procedure calls to handle recursion. -- Send compilers articles to compilers@iecc.cambridge.ma.us or {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.