Translation Models Machine-dependent Generate Machine Code - - PowerPoint PPT Presentation

translation models
SMART_READER_LITE
LIVE PREVIEW

Translation Models Machine-dependent Generate Machine Code - - PowerPoint PPT Presentation

Translation Models Machine-dependent Generate Machine Code Directly Through Intermediate Code Machine-independent Interpret the source code Generate intermediate code and then interpret the intermediate code Single


slide-1
SLIDE 1

Translation Models

  • Machine-dependent

– Generate Machine Code

  • Directly
  • Through Intermediate Code
  • Machine-independent

– Interpret the source code – Generate intermediate code and then interpret the intermediate code

slide-2
SLIDE 2

Single Pass vs. Multi-pass

  • Single pass

– No intermediate code – Limited code optimization – No intermediate files

  • Multi-pass

– Intermediate code could be generated – Optimizations could be done on the intermediate code and the target code – Intermediate files created

slide-3
SLIDE 3

Implementing Compilers (1/3)

  • Bootstrap a compiler for L to run on a bare

machine M

1. Choose S subset of L 2. Write a Compiler for S to run on M 3. Write a Compiler for L in S

  • 4. Compile L written in S using the S-Compiler

S M M L S M L S M S M M L M M

slide-4
SLIDE 4

Implementing Compilers (2/3)

  • Write a Cross Compiler for Language L that runs on machine

(M) and generates code for machine (N). Assume that you have a compiler for L running on M

1. Write a compiler in L in L that generate code for N 2. Compile the compiler produced in step 1 on the compiler of L on M L L N L M M L L N L M N L M N

slide-5
SLIDE 5

Implementing Compilers (3/3)

  • Cascading is the process of conducting

compilation in two steps:

  • 1. Compile a program written in L to produced

Intermediate Code I

  • 2. Compile the program produced in code I into

machine code M

L M I I M M