|IR Representation email@example.com (=?UTF-8?B?Q8Opc2Fy?=) (2015-09-04)|
|Re: IR Representation firstname.lastname@example.org (2015-09-05)|
|Re: IR Representation email@example.com (=?UTF-8?B?Q8Opc2Fy?=) (2015-09-07)|
|Re: IR Representation firstname.lastname@example.org (2015-09-08)|
|Re: IR Representation email@example.com (George Neuner) (2015-09-08)|
|Re: IR Representation firstname.lastname@example.org (=?UTF-8?B?Q8Opc2Fy?=) (2015-09-11)|
|Re: IR Representation DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2015-09-12)|
|From:||email@example.com (Anton Ertl)|
|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|
|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;
>c = a + 1;
>d = a * c;
>e = a + a;
As our moderator writes, insert artificial nodes for connecting them.
where s1, s2, s3 are the trees for the statements.
M. Anton Ertl
Return to the
Search the comp.compilers archives again.