Intermediate Code Generation
#1

[attachment=7315]
Presented by:Dewan Tanvir Ahmed
Intermediate Code Generation



Intermediate Code Generation
Translating source program into an “intermediate language.”
Simple
CPU Independent,
…yet, close in spirit to machine language.

Or, depending on the application other intermediate languages may be used, but in general, we opt for simple, well structured intermediate forms.

(and this completes the “Front-End” of Compilation).

Benefits
Retargeting is facilitated
Machine independent Code Optimization can be applied.


Intermediate codes are machine independent codes, but they are close to machine instructions.

The given program in a source language is converted to an equivalent program in an intermediate language by the intermediate code generator.

Intermediate language can be many different languages, and the designer of the compiler decides this intermediate language.
syntax trees can be used as an intermediate language.

postfix notation can be used as an intermediate language.

three-address code (Quadraples) can be used as an intermediate language
we will use quadraples to discuss intermediate code generation
quadraples are close to machine instructions, but they are not actual machine instructions.

some programming languages have well defined intermediate languages.
java – java virtual machine
prolog – warren abstract machine
In fact, there are byte-code emulators to execute instructions in these intermediate languages.

Syntax Dir. Definition for Assignment Statements

PRODUCTION Semantic Rule
S  id := E { S.nptr = mknode (‘assign’, mkleaf(id, id.entry), E.nptr) }


E  E1 + E2 {E.nptr = mknode(‘+’, E1.nptr,E2.nptr) }

E  E1 * E2 {E.nptr = mknode(‘*’, E1.nptr,E2.nptr) }

E  - E1 {E.nptr = mknode(‘uminus’,E1.nptr) }

E  ( E1 ) {E.nptr = E1.nptr }

E  id {E.nptr = mkleaf(id, id.entry) }


Three Address Code


Statements of general form x:=y op z

No built-up arithmetic expressions are allowed.

As a result, x:=y + z * w should be represented as t1:=z * w t2:=y + t1 x:=t2

Observe that given the syntax-tree or the dag of the graphical representation we can easily derive a three address code for assignments as above.

In fact three-address code is a linearization of the tree.

Three-address code is useful: related to machine-language/ simple/ optimizable.


Types of Three-Address Statements.


Assignment Statement: x:=y op z
Assignment Statement: x:=op z
Copy Statement: x:=z
Unconditional Jump: goto L
Conditional Jump: if x relop y goto L
Stack Operations: Push/pop
More Advanced:
Procedure:
param x1 param x2 … param xn call p,n

Index Assignments:
x:=y[i]
x[i]:=y

Address and Pointer Assignments:
x:=&y
x:=*y
*x:=y
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: intermediate languages in compiler design, cbse intermediate colleges in vijayawada, intermediate college of health, intermediate secondary education, intermediate, intermediate code generation in compiler design pdf, intermediate code generation in compiler design,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  Next Generation Secure Computing Base (NGSCB) computer science crazy 8 8,133 27-10-2012, 12:22 PM
Last Post: seminar details
  Finding Bugs in Web Applications Using Dynamic Test Generation and Explicit-State Mod seminar surveyer 2 2,300 14-02-2012, 12:55 PM
Last Post: seminar paper
  Seminar Report On ZigBee: Next Generation Wireless Network Computer Science Clay 14 26,991 04-02-2012, 10:37 AM
Last Post: seminar addict
  IPv6 : Next Generation IP computer science crazy 7 5,843 16-07-2011, 03:34 PM
Last Post: smart paper boy
  New Generation Network: Beyond the Internet and NGN seminar class 0 1,526 11-04-2011, 02:59 PM
Last Post: seminar class
  Improving TCP/IP Performance over Third-Generation Wireless Networks Wifi 2 2,372 23-03-2011, 09:04 PM
Last Post: sunil.dsimple
  PASSWORD GENERATION OF OTP SYSTEM USING FINGERPRINT FEATURES seminar class 0 1,199 11-03-2011, 03:12 PM
Last Post: seminar class
  PCA based Eigen Face Generation seminar class 0 1,447 03-03-2011, 10:51 AM
Last Post: seminar class
  Reliability Modeling of Distributed Generation in Conventional Distribution Systems P project report helper 0 1,461 18-10-2010, 02:40 PM
Last Post: project report helper
  Cloud to Cloud: A Framework Model For Next Generation Network Management project report helper 1 1,047 12-10-2010, 03:00 PM
Last Post: project report helper

Forum Jump: