Вы находитесь на странице: 1из 6

Compiler Design

BOOTSTRAPPING AND CROSS COMPILER


AWDHESH KUMAR(ASST. PROF.)
( AWADESH.KUMAR@HCST.CO.IN )

Third Language for Compiler Construction


2

y Machine language
{ compiler to execute immediately;

y Another language with existed compiler on the


same target machine : (First Scenario)
{ Compile the new compiler with existing compiler
y Another language with existed compiler on
different machine : (Second Scenario)
{ Compilation produce a cross compiler

1
T-Diagram Describing Complex Situation
3

y A compiler written in language H that translates


language S into language T.
S T
H
y T-Diagram can be combined in two basic ways.

The First T-diagram Combination


4

A B B C A C
H H H

y Two compilers run on the same machine H


{ First from A to B

{ Second from B to C

{ Result from A to C on H

2
The Second T-diagram Combination
5

A B A B
H H K K
M

y Translate implementation language of a compiler


from H to K
y Use another compiler from H to K

The First Scenario


6

A H A H
B B H H
H

y Translate a compiler from A to H written in B


{ Use an existing compiler for language B on machine H

3
The Second Scenario
7

A H A H
B B K K
K

y Use an existing compiler for language B on different


machine K
{ Result in a cross compiler

Process of Bootstrapping
8

y Write a compiler in the same language


S T
S
y No compiler for source language yet
y Porting to a new host machine

4
The First step in bootstrap
9

A H A H
A A H H
H

y “quick and dirty” compiler written in machine


language H
y Compiler written in its own language A
y Result in running but inefficient compiler

The Second step in bootstrap


10

A H A H
A A H H
H

y Running but inefficient compiler


y Compiler written in its own language A
y Result in final version of the compiler

5
The step 1 in porting
11

A K A K
A A H H
H

y Original compiler
y Compiler source code retargeted to K
y Result in Cross Compiler

The step 2 in porting


12

A K A K
A A K K
H

y Cross compiler
y Compiler source code retargeted to K
y Result in Retargeted Compiler

Вам также может понравиться