Re: [?] Trees vs. Tuples for IRs

"Peter Klausler" <>
26 Sep 1998 01:53:40 -0400

          From comp.compilers

Related articles
[?] Trees vs. Tuples for IRs (Nick Shaffner) (1998-09-13)
Re: [?] Trees vs. Tuples for IRs (Chris Clark USG) (1998-09-18)
Re: [?] Trees vs. Tuples for IRs (1998-09-18)
Re: [?] Trees vs. Tuples for IRs (1998-09-19)
Re: [?] Trees vs. Tuples for IRs (Clifford Click) (1998-09-22)
Re: [?] Trees vs. Tuples for IRs (William D Clinger) (1998-09-26)
Re: [?] Trees vs. Tuples for IRs (Peter Klausler) (1998-09-26)
| List of all articles for this month |

From: "Peter Klausler" <>
Newsgroups: comp.compilers
Date: 26 Sep 1998 01:53:40 -0400
Organization: Silicon Graphics, Inc.
References: 98-09-042 98-09-058
Keywords: optimize

>> What are the pros and cons of using trees versus tuples for a
>> compiler's intermediete representation?

Generally, when I use trees for an IR, I wish I were using tuples, and
vice versa. But I believe that tuples have an edge when developing an
optimizing compiler, for several reasons.

First, the final program is going to be a sequential list of machine
instructions. If you use basic blocks of tuples, you may be able to
design a single IR for your target machine that can represent the
input to the optimizer, the output of the code generator, and all
stages in between. Having fewer IRs in a compiler lends itself to
reliability and speed. You can't do this for all machines, but it's
nice when it's possible.

Second, when doing data dependence analysis, your focus will more
naturally be on the dependences between memory references rather than
statements. Your "statement splitting" will already have been done.

Third, your compiler is likely to be faster, simply because you'll be
traversing arrays or lists with iterative loops rather than trees with
recursive functions. Real compilers are real programs, and the choice
of an IR always involves issues of memory management. How you
allocate, insert, delete, and copy your text will significantly affect
the speed of compilation.

A related issue is that of the representation of data flow between
operations. The choice is between using explicit "compiler temps" to
link operations, or using the position (address, or tuple index, or
whatever) of an operation to denote its result. There are complex
tradeoffs between the two approaches.

Post a followup to this message

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