Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Próximo SlideShare
gayathri23.pptx
gayathri23.pptx
Cargando en…3
×

Eche un vistazo a continuación

1 de 11 Anuncio
Anuncio

Más Contenido Relacionado

Más reciente (20)

Anuncio

gayathri.p.pptx

  1. 1. NADAR SARASWATHI COLLEGE OF ARTS AND SCIENCE
  2. 2.  Similar terms: Intermediate representation, intermediate language  Ties the front and back ends together  Language and Machine neutral  Many forms  Level depends on how being processed  More than one intermediate language may be used by a compiler
  3. 3. Intermediate language levels High t1  a[i,j+2] Medium t1  j + 2 t2  i * 20 t3  t1 + t2 t4  4 * t3 t5  addr a t6  t5 + t 4 t7  *t6 Low r1 [fp-4] r2  r1 + 2 r3  [fp-8] r4  r3*20 r5  r4 + r2 r6  4 * r5 r7  fp – 216 f1  [r7+r6]
  4. 4. Intermediate Languages Types  Graphical IRs: Abstract Syntax trees, DAGs, Control Flow Graphs  Linear IRs:  Stack based (postfix)  Three address code (quadruples)
  5. 5. ASTs and DAGs: a := b *-c + b*-c a + * * b - (uni) c a + - (uni) b b * - (uni) c c := :=
  6. 6. • If a compiler translates the source language to its target machine language without having the option for generating intermediate code, then for each new machine, a full native compiler is required.  Intermediate code eliminates the need of a new full compiler for every unique machine by keeping the analysis portion same for all the compilers.  The second part of compiler, synthesis, is changed according to the target machine.  It becomes easier to apply the source code modifications to improve code performance by applying code optimization techniques on the intermediate code.
  7. 7. Intermediate Representation Intermediate codes can be represented in a variety of ways and they have their own benefits. •High Level IR - High-level intermediate code representation is very close to the source language itself. They can be easily generated from the source code and we can easily apply code modifications to enhance performance. But for target machine optimization, it is less preferred. •Low Level IR - This one is close to the target machine, which makes it suitable for register and memory allocation, instruction set selection, etc. It is good for machine- dependent optimizations.
  8. 8. Semantic Rule Program fragment E.code = E1.code || E2.code || op print op E.code = E1.code E.code = id print id Example Production 1.E → E1 op E2 2.E → (E1) 3.E → id
  9. 9. Parsetree
  10. 10. A sentence id + id * id would have the following syntax tree:
  11. 11. Thank you

×