Re: IR Representation

anton@mips.complang.tuwien.ac.at (Anton Ertl)
Tue, 08 Sep 2015 07:49:21 GMT

          From comp.compilers

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)
| List of all articles for this month |

From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.compilers
Date: Tue, 08 Sep 2015 07:49:21 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
References: 15-09-005 15-09-006 15-09-010
Keywords: optimize, design
Posted-Date: 08 Sep 2015 15:32:00 EDT

>This linear representation is really just an array of IR instructions,
>something on these lines: vector<Instruction*>; As operands
>instructions have pointers to entries in the symbol table.


Sounds like quadruples.


>However, my initial understanding of linear was really an array of
>instructions... and from that to construct a tree it seemed a little
>complex, it seems like trying to reconstruct an AST from an assembly
>stream of instructions.


Creating a DAG from quadruples is easy: If you have an instruction


a = b+c


create a + tree node, with the tree nodes stored in b and c as
operands, and store a pointer to the resulting + node in a.


If you want trees instead of DAGs, a way to do it is to have a parent
count in each node, and if the parent count exceeds 1, create a store
node as parent of the multi-parent node, and use a reference to the
place where the result was stored as child of the node that would
otherwise be parents of the multi-parent node.


>I did not understand how can you represent the program using just a
>single tree, because sometimes the computations are just
>independent... What would be the a single tree for these programs:
>
>a = b[5];
>c = a + 1;
>d = a * c;
>e = a + a;


As our moderator writes, insert artificial nodes for connecting them.
E.g.,


s1 s2
  \ /
    ; s3
      \ /
        ;


where s1, s2, s3 are the trees for the statements.


- anton
--
M. Anton Ertl
anton@mips.complang.tuwien.ac.at
http://www.complang.tuwien.ac.at/anton/


Post a followup to this message

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