DAG representation for basic blocks
A DAG for basic block is a directed acyclic graph with the following labels on nodes:
Algorithm for construction of DAG
Input:It contains a basic block
Output: It contains the following information:
If y operand is undefined then create node(y).
If z operand is undefined then for case(i) create node(z).
For case(i), create node(OP) whose right child is node(z) and left child is node(y).
For case(ii), check whether there is node(OP) with one child node(y).
For case(iii), node n will be node(y).
For node(x) delete x from the list of identifiers. Append x to attached identifiers list for the node n found in step 2. Finally set node(x) to n.
Consider the following three address statement:
Stages in DAG Construction: