0% found this document useful (1 vote)
8K views

Bootstrap and Cross Compiler

The document discusses compiler construction using a third language and the process of bootstrapping. It describes two scenarios for using a third language: 1) the new compiler and existing compiler use the same target machine, and 2) they use different machines, resulting in a cross compiler. It also explains two ways that T-diagrams, which depict compiler relationships, can be combined. Finally, it outlines the two step process of bootstrapping to create a compiler for a language from within that same language, and the two step process for porting a compiler to a new host machine to generate a cross compiler.

Uploaded by

ricky_chawla_1
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
8K views

Bootstrap and Cross Compiler

The document discusses compiler construction using a third language and the process of bootstrapping. It describes two scenarios for using a third language: 1) the new compiler and existing compiler use the same target machine, and 2) they use different machines, resulting in a cross compiler. It also explains two ways that T-diagrams, which depict compiler relationships, can be combined. Finally, it outlines the two step process of bootstrapping to create a compiler for a language from within that same language, and the two step process for porting a compiler to a new host machine to generate a cross compiler.

Uploaded by

ricky_chawla_1
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Compiler Design

BOOTSTRAPPING AND CROSS COMPILER


AWDHESH KUMAR(ASST. PROF.)
( [email protected] )

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

You might also like