Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #1609

Re: IR Representation

From Hans-Peter Diettrich <DrDiettrich1@netscape.net>
Newsgroups comp.compilers
Subject Re: IR Representation
Date 2015-09-12 19:45 +0200
Organization Compilers Central
Message-ID <15-09-014@comp.compilers> (permalink)
References <15-09-005@comp.compilers> <15-09-006@comp.compilers> <15-09-010@comp.compilers> <15-09-011@comp.compilers> <15-09-013@comp.compilers>

Show all headers | View raw


CC)sar schrieb:

> Now I am wondering, how do you usually represent conditional nodes and
> looping structures using trees?
>
> Eg.:
>
>        c = a + b;
>        if c > 10 goto L1 else goto L2
> L1:  a = 10;
>        goto L3;
> L2:  a = 20;
> L3:

The general representation of control flow forms *graphs*, not *trees*.

In your example control flow branches off in the "if" statement, into
two branches starting at L1 and L2 respectively, which happen to join
again at L3. You can consider each GOTO as a leaf in a tree, so that you
can convert the graph into trees. Then, in the case of well structured
code, L1 and L2 become child nodes of the "if" statement, and L3 will
become its sequential successor (right sibling), as L3 is the common
target reachable by both branches. The compiler can eliminate a GOTO
leaf and replace it by the tree of the GOTO target label, which then
indicates the next instruction during sequential execution. This process
continues until all trees have been merged into one big tree.

DoDi

Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

IR Representation César <divcesar@gmail.com> - 2015-09-04 14:39 -0300
  Re: IR Representation anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-05 16:51 +0000
    Re: IR Representation César <divcesar@gmail.com> - 2015-09-07 23:05 -0300
      Re: IR Representation anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-08 07:49 +0000
        Re: IR Representation César <divcesar@gmail.com> - 2015-09-11 17:01 -0300
          Re: IR Representation Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2015-09-12 19:45 +0200
  Re: IR Representation George Neuner <gneuner2@comcast.net> - 2015-09-08 18:45 -0400

csiph-web