'How to create Abstract Semantic Graph from Abstract Syntax Tree?

I'm studying compiler design, following Modern Compiler Implementation in Java, Second Edition. Searching online for the benefits of different intermediate representations I've found out that using an Abstract Semantic Graph can simplify the production of three address code by removing redundant branches. I would like to know what algorithms can I use to transform my AST into an ASG.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source