Re: Intermediate code design

gclind01@spd.louisville.edu (George C. Lindauer)
6 Jan 1998 22:40:57 -0500

          From comp.compilers

Related articles
INTERMEDIATE CODE DESIGN stephen.suryaputra@icon.singnet.com.sg (1995-06-24)
Intermediate code design david.stone@cambridge.simoco.com (David Stone 5887) (1998-01-05)
Re: Intermediate code design gclind01@spd.louisville.edu (1998-01-06)
Re: Intermediate code design chase@world.std.com (David Chase) (1998-01-06)
Re: Intermediate code design cef@geodesic.com (Charles Fiterman) (1998-01-08)
Re: Intermediate code design roques@scalar.pond.sub.org (Christian von Roques) (1998-01-08)
| List of all articles for this month |

From: gclind01@spd.louisville.edu (George C. Lindauer)
Newsgroups: comp.compilers
Date: 6 Jan 1998 22:40:57 -0500
Organization: University of Louisville
References: 98-01-019
Keywords: design, optimize

David Stone (david.stone@cambridge.simoco.com) wrote:
> (1) Updating operations.


> Suppose the source language supports updating operations, for example
> x += y in C.


> Should this become


> x = x + y


depends. If you are not doing GCSE analysis then make up an extra
three-op code for the += operand as it will help you generate better
code. If you ARE doing GCSE then keep the icode as simple as possible,
the GCSE will catch such relationships when they need to be caught.




> destination 1st operand operation 2nd operand


> arglist = make_empty [no operands]
> arglist = arglist append arg1
> arglist = arglist append arg2
> ...
> retval = functionname apply arglist


I wouldn't touch that design myself. It makes much more sense to me
to define a three-op code similar to 'push' and then the argument can
be handled only once as a special type of statement. And the function
call because another simple-twp-op statement, no need to clutter up
the dataflow analysis and the actual code-generate with this type of
special case.


And I think ASU is where I read that the basic problem you are going
to have is if you pass a pointer to a function. If this happens you
do NOT need to stop the global dataflow analysis, but to be safe you
DO have to mark anything the pointer can possibly point to as changed
in the same way you would mark things on any normal pointer
assignment. This means to handle a language like C satisfactorily you
almost have to do a dataflow analysis on pointers, or you are going to
have to mark all active variables as changed any time any pointer gets
assigned to or passed to a function. Note I am talking about analysis
which is limited to the scope of a single function; if you are doing
hefty inter-procedural analysis I suppose you could get things even
better but I don't know anything about that.


By the way when you are doing lcse analysis whether you stop at
function calls is highly processor dependent. On cisc architectures
with few registers you are probably going to have to since you are
probably going to allow functions to wipe out all temps. On risc
architectures with lots of registers you could design it to keep a lot
of temps, but, you probably need lots of interprocedural analysis to
be effective in this.


David
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.