Related articles |
---|
IR Representation divcesar@gmail.com (=?UTF-8?B?Q8Opc2Fy?=) (2015-09-04) |
Re: IR Representation anton@mips.complang.tuwien.ac.at (2015-09-05) |
Re: IR Representation divcesar@gmail.com (=?UTF-8?B?Q8Opc2Fy?=) (2015-09-07) |
Re: IR Representation anton@mips.complang.tuwien.ac.at (2015-09-08) |
Re: IR Representation gneuner2@comcast.net (George Neuner) (2015-09-08) |
Re: IR Representation divcesar@gmail.com (=?UTF-8?B?Q8Opc2Fy?=) (2015-09-11) |
Re: IR Representation DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2015-09-12) |
From: | Hans-Peter Diettrich <DrDiettrich1@netscape.net> |
Newsgroups: | comp.compilers |
Date: | Sat, 12 Sep 2015 19:45:09 +0200 |
Organization: | Compilers Central |
References: | 15-09-005 15-09-006 15-09-010 15-09-011 15-09-013 |
Keywords: | optimize, analysis |
Posted-Date: | 12 Sep 2015 15:43:08 EDT |
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
Return to the
comp.compilers page.
Search the
comp.compilers archives again.