1 / 7

TARGET CODE GENERATION

TARGET CODE GENERATION. A basic block is a sequence of consecutive statements in which flow of control enters at the beginning and exit at the end. Transformation on Basic Blocks. Structure preserving transformation: 1. Common sub-expression elimination . Consider the basic block

bond
Download Presentation

TARGET CODE GENERATION

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TARGET CODE GENERATION A basic block is a sequence of consecutive statements in which flow of control enters at the beginning and exit at the end.

  2. Transformation on Basic Blocks • Structure preserving transformation: • 1. Common sub-expression elimination . Consider the basic block • a = b + c • b = a - d • c = b + c • d = a - d • its equivalent block will be • a = b + c • b = a - d • c = b + c • d = b

  3. 2.dead code elimination. • suppose x = y op z • and x is never used subsequently .therefore x is dead .hence we can remove • this expression. • 3.renaming temporary variables. minimize the no. of temporary variables by • renaming them.for example block1 and block2 are equivalent. • block1: t1 = y + z • x = y + t1 • block2: t2 = y + z • x = y + t2

  4. 3.renaming temporary variables • minimize the no. of temporary variables by • renaming them.for example block1 and block2 are equivalent. • block1: t1 = y + z • x = y + t1 • block2: t2 = y + z • x = y + t2

  5. 4.interchange of independant statements. • independant statements within a block can be interchanged without affecting • the value of the block. it helps in checking the equivalence of 2 blocks. • t1 = b + c • t2 = x + y • and • t2 = b + c • t1 = x + y • are equivalent.

  6. Loops • Loop is a collection of nodes in a flow graph such that • 1. All nodes in the collection are strongly connected; that is, from any node in the loop to any other, there is a path of length one or more, wholly within the loop. • The collection of nodes has a unique entry, that is, a node in the • loop such that the only way to reach a node of the loop from a node outside • the loop is to first go through the entry. • A loop that contains no other loops is called an inner loop.

  7. Prepared By: • Ashish Kumar • 04CS3020

More Related