3 address code ujjwal matoliya.pptx

ujjwalmatoliya 98 views 23 slides Jun 10, 2023
Slide 1
Slide 1 of 23
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23

About This Presentation

Intermediate code can translate the source program into the machine program. Intermediate code is generated because the compiler can’t generate machine code directly in one pass. Therefore, first, it converts the source program into intermediate code, which performs efficient generation of machine...


Slide Content

DEPARTMENT OF COMPUTER SCIENCE & APPLICALION ATAL BIHARI VAJPAYEE VISHWAVIDYALAYA Assignment Three address code Submitted By Ujjwal matoliya MCA 2 nd sem

INDEX Compil er Phase Intermediate Code Generation Three address code Three address code is used in compiler applications s

Compiler Phases

INPUT OUTPUT

Intermediate Code Generation Intermediate code can translate the source program into the machine program. Intermediate code is generated because the compiler can’t generate machine code directly in one pass. Therefore, first, it converts the source program into intermediate code, which performs efficient generation of machine code further. The intermediate code can be represented in the form of postfix notation, syntax tree, directed acyclic graph, three address codes, Quadruples, and triples .

Application Three Address Code Postfix Notation Syntax Trees   Quadruples representation   Triples representation  

Three address code Three-address code is an intermediate code. It is used by the optimizing compilers. In three-address code, the given expression is broken down into several separate instructions. These instructions can easily translate into assembly language. Each Three address code instruction has at most three operands. It is a combination of assignment and a binary operator.

Example

Example a  := (-c * b) + (-c * d) 

Example a  := (-c * b) + (-c * d)  t 1 := -c

Example a  := (-c * b) + (-c * d)  t 1 := -c t 2 := b*t 1

Example a  := (-c * b) + (-c * d)  t 1 := -c t 2 := b*t 1 t 3 := -c

Example a  := (-c * b) + (-c * d)  t 1 := -c t 2 := b*t 1 t 3 := -c t 4 := d * t 3  

Example a  := (-c * b) + (-c * d)  t 1 := -c t 2 := b*t 1 t 3 := -c t 4 := d * t 3 t 5 := t 2 + t 4

Example a  := (-c * b) + (-c * d)  t 1 := -c t 2 := b*t 1 t 3 := -c t 4 := d * t 3 t 5 := t 2 + t 4 a := t 5  

Three address code is used in compiler applications:

Three address code is used in compiler applications : Optimization:  Three address code is often used as an intermediate representation of code during optimization phases of the compilation process. The three address code allows the compiler to analyze the code and perform optimizations that can improve the performance of the generated code.

Three address code is used in compiler applications : Optimization:  Three address code is often used as an intermediate representation of code during optimization phases of the compilation process. The three address code allows the compiler to analyze the code and perform optimizations that can improve the performance of the generated code . Code generation:  Three address code can also be used as an intermediate representation of code during the code generation phase of the compilation process. The three address code allows the compiler to generate code that is specific to the target platform, while also ensuring that the generated code is correct and efficient.

Three address code is used in compiler applications : Optimization:  Three address code is often used as an intermediate representation of code during optimization phases of the compilation process. The three address code allows the compiler to analyze the code and perform optimizations that can improve the performance of the generated code . Code generation:  Three address code can also be used as an intermediate representation of code during the code generation phase of the compilation process. The three address code allows the compiler to generate code that is specific to the target platform, while also ensuring that the generated code is correct and efficient . Debugging:  Three address code can be helpful in debugging the code generated by the compiler. Since three address code is a low-level language, it is often easier to read and understand than the final generated code.

Three address code is used in compiler applications : Optimization:  Three address code is often used as an intermediate representation of code during optimization phases of the compilation process. The three address code allows the compiler to analyze the code and perform optimizations that can improve the performance of the generated code. Code generation:  Three address code can also be used as an intermediate representation of code during the code generation phase of the compilation process. The three address code allows the compiler to generate code that is specific to the target platform, while also ensuring that the generated code is correct and efficient. Debugging:  Three address code can be helpful in debugging the code generated by the compiler. Since three address code is a low-level language, it is often easier to read and understand than the final generated code.

Intermediate code can translate the source program into the machine program. Intermediate code is generated because the compiler can’t generate machine code directly in one pass. Therefore, first, it converts the source program into intermediate code, which performs efficient generation of machine code further. The intermediate code can be represented in the form of postfix notation, syntax tree, directed acyclic graph, three address codes, Quadruples, and triples .