SlideShare a Scribd company logo
1 of 18
Presented by
INDUMATHI.A (BP150517)
 The advantage of generating code for a basic block
from its dag representation is that, from a dag we can
easily see how to rearrange the order of the final
computation sequence than we can starting from a
linear sequence of three-address statements or
quadruples
 t1 := a + b
 t2 := c + d
 t3 := e - t2
 t4 := t1 - t3
(1) MOV a, R0
(2) ADD b, R0
(3) MOV c, R1
(4) ADD d, R1
(5) MOV R0, t1
(6) MOV e, R0
(7) SUB R1, R0
(8) MOV t1, R1
(9) SUB R0, R1
(10) MOV R1, t4
-
+ -
+a0 b0 e0
c0 d0
t1
t2
t3
t4
 t2 := c + d
 t3 := e - t2
 t1 := a + b
 t4 := t1 - t3
(1) MOV c, R0
(2) ADD d, R0
(3) MOV e, R1
(4) SUB R0, R1
(5) MOV a, R0
(6) ADD b, R0
(7) SUB R1, R0
(8) MOV R0, t4
-
+ -
+a0 b0 e0
c0 d0
t1
t2
t3
t4
The heuristic ordering algorithm attempts to make
the evaluation of a node immediately follow the
evaluation of its leftmost argument.
 while unlisted interior nodes remain do begin
 select an unlisted node n, all of whose
 parents have been listed;
 list n;
 while the leftmost child m of n has no
unlisted
 parents and is not a leaf do begin
 list m;
 n := m;
 end
 end
32
1
-
+
*
a0 b0
c0
+
d0 e0
6
-+
*
4
5 7
t7 := d + e
t6 := a + b
t5 := t6 - c
t4 := t5 * t7
t3 := t4 - e
t2 := t6 + t4
t1 := t2 * t3
 Label each node of the tree bottom-up with an
integer denoting fewest number of registers
required to evaluate the tree with no stores of
immediate results
 Generate code during a tree traversal by first
evaluating the operand requiring more registers
 if n is a leaf then
 if n is the leftmost child of its parent then
 label(n) := 1
 else
 label(n) := 0
 else begin
 let n1, n2, …, nk be the children of n ordered
by label so that label(n1)  label(n2)  … 
label(nk);
label(n) := max1 i  k(label(ni) + i - 1)
 end
label(n) = max(l1, l2), if l1  l2
l1 + 1, if l1 = l2
t1
t4
t2a b
c
t3
d
e
1
2
1 2
0
1 0
11
For binary interior nodes:
 Use a stack rstack to allocate registers R0,
R1, …, R(r-1)
 The value of a tree is always computed in
the top register on rstack
 The function swap(rstack) interchanges the
top two registers on rstack
 Use a stack tstack to allocate temporary
memory locations T0, T1, ...
op
n1 n2
op
n1 n2
op
n1 n2
label(n1) < label(n2) label(n2)  label(n1) both labels  r
op
n1 n2n name
name
/* case 1 */
begin
let name be the operand represented by n2;
gencode(n1);
print op || name || ',' || top(rstack)
end
/* case 2 */
begin
swap(rstack); gencode(n2);
R := pop(rstack); gencode(n1);
print op || R || ',' || top(rstack);
push(rstack, R); swap(rstack);
end
/* case 3 */
begin
gencode(n1);
R := pop(rstack); gencode(n2);
print op || R || ',' || top(rstack);
push(rstack, R);
end
/* case 4 */
begin
gencode(n2); T := pop(tstack);
print 'MOV' || top(rstack) || ',' || T;
gencode(n1); push(tstack, T);
print op || T || ',' || top(rstack);
end
gencode(t4) [R1, R0] /* 2 */
gencode(t3) [R0, R1] /* 3 */
gencode(e) [R0, R1] /* 0 */
print MOV e, R1
gencode(t2) [R0] /* 1 */
gencode(c) [R0] /* 0 */
print MOV c, R0
print ADD d, R0
print SUB R0, R1
gencode(t1) [R0] /* 1 */
gencode(a) [R0] /* 0 */
print MOV a, R0
print ADD b, R0
print SUB R1, R0
t1
t4
t2a b
c
t3
d
e
1
2
1 2
0
1 0
11
 Some operations like multiplication, division,
or a function call normally require more than
one register
 The labeling algorithm needs to ensure that
label(n) is always at least the number of
registers required by the operation
label(n) = max(2, l1, l2), if l1  l2
l1 + 1, if l1 = l2
+
T1
+
T1
1 l
max(2, l)
l 0
l
+
T1
T4
+
T2 T3
+
Ti3
+
Ti1 Ti2
+
Ti4
+
associative
commutative
largest
commutative
 Nodes with more than one parent in a dag
are called shared nodes
 Optimal code generation for dags on both a
one-register machine or an unlimited number
of registers machine are NP-complete

More Related Content

What's hot

Principle source of optimazation
Principle source of optimazationPrinciple source of optimazation
Principle source of optimazationSiva Sathya
 
Relationship Among Token, Lexeme & Pattern
Relationship Among Token, Lexeme & PatternRelationship Among Token, Lexeme & Pattern
Relationship Among Token, Lexeme & PatternBharat Rathore
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocksJothi Lakshmi
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler designKuppusamy P
 
Directed Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksDirected Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksMohammad Vaseem Akaram
 
Issues in knowledge representation
Issues in knowledge representationIssues in knowledge representation
Issues in knowledge representationSravanthi Emani
 
program flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architectureprogram flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architecturePankaj Kumar Jain
 
Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design MAHASREEM
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignKuppusamy P
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler DesignKuppusamy P
 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code GeneratorDarshan sai Reddy
 
Three Address code
Three Address code Three Address code
Three Address code Pooja Dixit
 

What's hot (20)

Principle source of optimazation
Principle source of optimazationPrinciple source of optimazation
Principle source of optimazation
 
Relationship Among Token, Lexeme & Pattern
Relationship Among Token, Lexeme & PatternRelationship Among Token, Lexeme & Pattern
Relationship Among Token, Lexeme & Pattern
 
Code generation
Code generationCode generation
Code generation
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocks
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
 
Directed Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksDirected Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocks
 
Issues in knowledge representation
Issues in knowledge representationIssues in knowledge representation
Issues in knowledge representation
 
Input-Buffering
Input-BufferingInput-Buffering
Input-Buffering
 
program flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architectureprogram flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architecture
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Analysis of the source program
Analysis of the source programAnalysis of the source program
Analysis of the source program
 
Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler Design
 
Gsm radio-interface
Gsm radio-interfaceGsm radio-interface
Gsm radio-interface
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code Generator
 
Three Address code
Three Address code Three Address code
Three Address code
 
Run time storage
Run time storageRun time storage
Run time storage
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
 
Transport layer
Transport layerTransport layer
Transport layer
 

Viewers also liked

MULTIPHASE SIMULATION OF AUTOMOTIVE HVAC EVAPORATOR USING R134A AND R1234YF R...
MULTIPHASE SIMULATION OF AUTOMOTIVE HVAC EVAPORATOR USING R134A AND R1234YF R...MULTIPHASE SIMULATION OF AUTOMOTIVE HVAC EVAPORATOR USING R134A AND R1234YF R...
MULTIPHASE SIMULATION OF AUTOMOTIVE HVAC EVAPORATOR USING R134A AND R1234YF R...IAEME Publication
 
Guru Panitia Pendidikan Islam SK Taman Selasih 1438H/2017M
Guru Panitia Pendidikan Islam SK Taman Selasih 1438H/2017MGuru Panitia Pendidikan Islam SK Taman Selasih 1438H/2017M
Guru Panitia Pendidikan Islam SK Taman Selasih 1438H/2017MWaalid Aisya
 
04 norma manejo y tratamiento de its - 2008
04   norma  manejo y tratamiento de its - 200804   norma  manejo y tratamiento de its - 2008
04 norma manejo y tratamiento de its - 2008Carmen Salazar
 
COMPUTATIONAL ANALYSIS OF STEPPED AND STRAIGHT MICROCHANNEL HEAT SINK
COMPUTATIONAL ANALYSIS OF STEPPED AND STRAIGHT MICROCHANNEL HEAT SINK COMPUTATIONAL ANALYSIS OF STEPPED AND STRAIGHT MICROCHANNEL HEAT SINK
COMPUTATIONAL ANALYSIS OF STEPPED AND STRAIGHT MICROCHANNEL HEAT SINK IAEME Publication
 
Ejercicios Gantt Pertcmp
Ejercicios Gantt PertcmpEjercicios Gantt Pertcmp
Ejercicios Gantt PertcmpJonas Oraa
 
MANUFACTURING AND FORCE DETERMINATION OF COMPOSITE DISC BRAKE
MANUFACTURING AND FORCE DETERMINATION OF COMPOSITE DISC BRAKEMANUFACTURING AND FORCE DETERMINATION OF COMPOSITE DISC BRAKE
MANUFACTURING AND FORCE DETERMINATION OF COMPOSITE DISC BRAKEIAEME Publication
 
Ruta de implementación del modelo educativo
Ruta de implementación del modelo educativoRuta de implementación del modelo educativo
Ruta de implementación del modelo educativoLucy Galán
 
Сервис StatKino_Хакатон
Сервис StatKino_ХакатонСервис StatKino_Хакатон
Сервис StatKino_ХакатонKsu Vinogradova
 
Glass material is used as fine aggregates
Glass material is used as fine aggregatesGlass material is used as fine aggregates
Glass material is used as fine aggregatesjerry vasoya
 
NUMERICAL SOLUTIONS FOR PERFORMANCE PREDICTION OF CENTRIFUGAL COMPRESSOR
NUMERICAL SOLUTIONS FOR PERFORMANCE PREDICTION OF CENTRIFUGAL COMPRESSORNUMERICAL SOLUTIONS FOR PERFORMANCE PREDICTION OF CENTRIFUGAL COMPRESSOR
NUMERICAL SOLUTIONS FOR PERFORMANCE PREDICTION OF CENTRIFUGAL COMPRESSORIAEME Publication
 
Jornada Movilidad internacional de trabajadores (AGM Abogados & Wills Towers ...
Jornada Movilidad internacional de trabajadores (AGM Abogados & Wills Towers ...Jornada Movilidad internacional de trabajadores (AGM Abogados & Wills Towers ...
Jornada Movilidad internacional de trabajadores (AGM Abogados & Wills Towers ...AGM Abogados
 
Brochure AGM Abogados 2016 English – Legal services
Brochure AGM Abogados 2016 English – Legal servicesBrochure AGM Abogados 2016 English – Legal services
Brochure AGM Abogados 2016 English – Legal servicesAGM Abogados
 
робота з графічними об
робота з графічними обробота з графічними об
робота з графічними обmarunasorokina
 
Medicolegal aspects in obstetrics
Medicolegal aspects in obstetricsMedicolegal aspects in obstetrics
Medicolegal aspects in obstetricsAziza Negm
 

Viewers also liked (20)

La frase III
La frase IIILa frase III
La frase III
 
MULTIPHASE SIMULATION OF AUTOMOTIVE HVAC EVAPORATOR USING R134A AND R1234YF R...
MULTIPHASE SIMULATION OF AUTOMOTIVE HVAC EVAPORATOR USING R134A AND R1234YF R...MULTIPHASE SIMULATION OF AUTOMOTIVE HVAC EVAPORATOR USING R134A AND R1234YF R...
MULTIPHASE SIMULATION OF AUTOMOTIVE HVAC EVAPORATOR USING R134A AND R1234YF R...
 
Guru Panitia Pendidikan Islam SK Taman Selasih 1438H/2017M
Guru Panitia Pendidikan Islam SK Taman Selasih 1438H/2017MGuru Panitia Pendidikan Islam SK Taman Selasih 1438H/2017M
Guru Panitia Pendidikan Islam SK Taman Selasih 1438H/2017M
 
04 norma manejo y tratamiento de its - 2008
04   norma  manejo y tratamiento de its - 200804   norma  manejo y tratamiento de its - 2008
04 norma manejo y tratamiento de its - 2008
 
COMPUTATIONAL ANALYSIS OF STEPPED AND STRAIGHT MICROCHANNEL HEAT SINK
COMPUTATIONAL ANALYSIS OF STEPPED AND STRAIGHT MICROCHANNEL HEAT SINK COMPUTATIONAL ANALYSIS OF STEPPED AND STRAIGHT MICROCHANNEL HEAT SINK
COMPUTATIONAL ANALYSIS OF STEPPED AND STRAIGHT MICROCHANNEL HEAT SINK
 
marorapa
marorapamarorapa
marorapa
 
Ejercicios Gantt Pertcmp
Ejercicios Gantt PertcmpEjercicios Gantt Pertcmp
Ejercicios Gantt Pertcmp
 
MANUFACTURING AND FORCE DETERMINATION OF COMPOSITE DISC BRAKE
MANUFACTURING AND FORCE DETERMINATION OF COMPOSITE DISC BRAKEMANUFACTURING AND FORCE DETERMINATION OF COMPOSITE DISC BRAKE
MANUFACTURING AND FORCE DETERMINATION OF COMPOSITE DISC BRAKE
 
Ruta de implementación del modelo educativo
Ruta de implementación del modelo educativoRuta de implementación del modelo educativo
Ruta de implementación del modelo educativo
 
Сервис StatKino_Хакатон
Сервис StatKino_ХакатонСервис StatKino_Хакатон
Сервис StatKino_Хакатон
 
Glass material is used as fine aggregates
Glass material is used as fine aggregatesGlass material is used as fine aggregates
Glass material is used as fine aggregates
 
NUMERICAL SOLUTIONS FOR PERFORMANCE PREDICTION OF CENTRIFUGAL COMPRESSOR
NUMERICAL SOLUTIONS FOR PERFORMANCE PREDICTION OF CENTRIFUGAL COMPRESSORNUMERICAL SOLUTIONS FOR PERFORMANCE PREDICTION OF CENTRIFUGAL COMPRESSOR
NUMERICAL SOLUTIONS FOR PERFORMANCE PREDICTION OF CENTRIFUGAL COMPRESSOR
 
MSB kureha Cots and Apron
MSB  kureha Cots and ApronMSB  kureha Cots and Apron
MSB kureha Cots and Apron
 
Jornada Movilidad internacional de trabajadores (AGM Abogados & Wills Towers ...
Jornada Movilidad internacional de trabajadores (AGM Abogados & Wills Towers ...Jornada Movilidad internacional de trabajadores (AGM Abogados & Wills Towers ...
Jornada Movilidad internacional de trabajadores (AGM Abogados & Wills Towers ...
 
Brochure AGM Abogados 2016 English – Legal services
Brochure AGM Abogados 2016 English – Legal servicesBrochure AGM Abogados 2016 English – Legal services
Brochure AGM Abogados 2016 English – Legal services
 
ÉTS - Cours GES840 - Atelier de recherche de brevets
ÉTS - Cours GES840 - Atelier de recherche de brevetsÉTS - Cours GES840 - Atelier de recherche de brevets
ÉTS - Cours GES840 - Atelier de recherche de brevets
 
ÉTS - Cours MEC200 - Atelier de recherche documentaire
ÉTS - Cours MEC200 - Atelier de recherche documentaireÉTS - Cours MEC200 - Atelier de recherche documentaire
ÉTS - Cours MEC200 - Atelier de recherche documentaire
 
робота з графічними об
робота з графічними обробота з графічними об
робота з графічними об
 
La computadora
La computadoraLa computadora
La computadora
 
Medicolegal aspects in obstetrics
Medicolegal aspects in obstetricsMedicolegal aspects in obstetrics
Medicolegal aspects in obstetrics
 

Similar to Code generation from DAG representation by evaluating more register intensive nodes first

pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqPradeep Bisht
 
CS330-Lectures Statistics And Probability
CS330-Lectures Statistics And ProbabilityCS330-Lectures Statistics And Probability
CS330-Lectures Statistics And Probabilitybryan111472
 
15-CAT-2 answer key discussion-04-07-2023.pdf
15-CAT-2 answer key discussion-04-07-2023.pdf15-CAT-2 answer key discussion-04-07-2023.pdf
15-CAT-2 answer key discussion-04-07-2023.pdfvenkatapranaykumarGa
 
time_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdftime_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdfSrinivasaReddyPolamR
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generationVipul Naik
 
LR parsing
LR parsingLR parsing
LR parsingichikaz3
 
12IRGeneration.pdf
12IRGeneration.pdf12IRGeneration.pdf
12IRGeneration.pdfSHUJEHASSAN
 
Graph for Coulomb damped oscillation
Graph for Coulomb damped oscillationGraph for Coulomb damped oscillation
Graph for Coulomb damped oscillationphanhung20
 
Contemporary communication systems 1st edition mesiya solutions manual
Contemporary communication systems 1st edition mesiya solutions manualContemporary communication systems 1st edition mesiya solutions manual
Contemporary communication systems 1st edition mesiya solutions manualto2001
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptxSajalFayyaz
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1Shashwat Shriparv
 
Tele4653 l5
Tele4653 l5Tele4653 l5
Tele4653 l5Vin Voro
 
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価Kota Abe
 

Similar to Code generation from DAG representation by evaluating more register intensive nodes first (20)

Ch8a
Ch8aCh8a
Ch8a
 
Mergesort
MergesortMergesort
Mergesort
 
Compiler Design Unit 3
Compiler Design Unit 3Compiler Design Unit 3
Compiler Design Unit 3
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conq
 
Ch5b.ppt
Ch5b.pptCh5b.ppt
Ch5b.ppt
 
CS330-Lectures Statistics And Probability
CS330-Lectures Statistics And ProbabilityCS330-Lectures Statistics And Probability
CS330-Lectures Statistics And Probability
 
15-CAT-2 answer key discussion-04-07-2023.pdf
15-CAT-2 answer key discussion-04-07-2023.pdf15-CAT-2 answer key discussion-04-07-2023.pdf
15-CAT-2 answer key discussion-04-07-2023.pdf
 
time_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdftime_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdf
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generation
 
Polyphase
PolyphasePolyphase
Polyphase
 
Ch5b
Ch5bCh5b
Ch5b
 
LR parsing
LR parsingLR parsing
LR parsing
 
12IRGeneration.pdf
12IRGeneration.pdf12IRGeneration.pdf
12IRGeneration.pdf
 
Graph for Coulomb damped oscillation
Graph for Coulomb damped oscillationGraph for Coulomb damped oscillation
Graph for Coulomb damped oscillation
 
Contemporary communication systems 1st edition mesiya solutions manual
Contemporary communication systems 1st edition mesiya solutions manualContemporary communication systems 1st edition mesiya solutions manual
Contemporary communication systems 1st edition mesiya solutions manual
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptx
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1
 
Tele4653 l5
Tele4653 l5Tele4653 l5
Tele4653 l5
 
Ch8b
Ch8bCh8b
Ch8b
 
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
 

Recently uploaded

How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 

Recently uploaded (20)

How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 

Code generation from DAG representation by evaluating more register intensive nodes first

  • 2.  The advantage of generating code for a basic block from its dag representation is that, from a dag we can easily see how to rearrange the order of the final computation sequence than we can starting from a linear sequence of three-address statements or quadruples
  • 3.  t1 := a + b  t2 := c + d  t3 := e - t2  t4 := t1 - t3 (1) MOV a, R0 (2) ADD b, R0 (3) MOV c, R1 (4) ADD d, R1 (5) MOV R0, t1 (6) MOV e, R0 (7) SUB R1, R0 (8) MOV t1, R1 (9) SUB R0, R1 (10) MOV R1, t4 - + - +a0 b0 e0 c0 d0 t1 t2 t3 t4
  • 4.  t2 := c + d  t3 := e - t2  t1 := a + b  t4 := t1 - t3 (1) MOV c, R0 (2) ADD d, R0 (3) MOV e, R1 (4) SUB R0, R1 (5) MOV a, R0 (6) ADD b, R0 (7) SUB R1, R0 (8) MOV R0, t4 - + - +a0 b0 e0 c0 d0 t1 t2 t3 t4
  • 5. The heuristic ordering algorithm attempts to make the evaluation of a node immediately follow the evaluation of its leftmost argument.
  • 6.  while unlisted interior nodes remain do begin  select an unlisted node n, all of whose  parents have been listed;  list n;  while the leftmost child m of n has no unlisted  parents and is not a leaf do begin  list m;  n := m;  end  end
  • 7. 32 1 - + * a0 b0 c0 + d0 e0 6 -+ * 4 5 7 t7 := d + e t6 := a + b t5 := t6 - c t4 := t5 * t7 t3 := t4 - e t2 := t6 + t4 t1 := t2 * t3
  • 8.  Label each node of the tree bottom-up with an integer denoting fewest number of registers required to evaluate the tree with no stores of immediate results  Generate code during a tree traversal by first evaluating the operand requiring more registers
  • 9.  if n is a leaf then  if n is the leftmost child of its parent then  label(n) := 1  else  label(n) := 0  else begin  let n1, n2, …, nk be the children of n ordered by label so that label(n1)  label(n2)  …  label(nk); label(n) := max1 i  k(label(ni) + i - 1)  end
  • 10. label(n) = max(l1, l2), if l1  l2 l1 + 1, if l1 = l2 t1 t4 t2a b c t3 d e 1 2 1 2 0 1 0 11 For binary interior nodes:
  • 11.  Use a stack rstack to allocate registers R0, R1, …, R(r-1)  The value of a tree is always computed in the top register on rstack  The function swap(rstack) interchanges the top two registers on rstack  Use a stack tstack to allocate temporary memory locations T0, T1, ...
  • 12. op n1 n2 op n1 n2 op n1 n2 label(n1) < label(n2) label(n2)  label(n1) both labels  r op n1 n2n name name
  • 13. /* case 1 */ begin let name be the operand represented by n2; gencode(n1); print op || name || ',' || top(rstack) end /* case 2 */ begin swap(rstack); gencode(n2); R := pop(rstack); gencode(n1); print op || R || ',' || top(rstack); push(rstack, R); swap(rstack); end
  • 14. /* case 3 */ begin gencode(n1); R := pop(rstack); gencode(n2); print op || R || ',' || top(rstack); push(rstack, R); end /* case 4 */ begin gencode(n2); T := pop(tstack); print 'MOV' || top(rstack) || ',' || T; gencode(n1); push(tstack, T); print op || T || ',' || top(rstack); end
  • 15. gencode(t4) [R1, R0] /* 2 */ gencode(t3) [R0, R1] /* 3 */ gencode(e) [R0, R1] /* 0 */ print MOV e, R1 gencode(t2) [R0] /* 1 */ gencode(c) [R0] /* 0 */ print MOV c, R0 print ADD d, R0 print SUB R0, R1 gencode(t1) [R0] /* 1 */ gencode(a) [R0] /* 0 */ print MOV a, R0 print ADD b, R0 print SUB R1, R0 t1 t4 t2a b c t3 d e 1 2 1 2 0 1 0 11
  • 16.  Some operations like multiplication, division, or a function call normally require more than one register  The labeling algorithm needs to ensure that label(n) is always at least the number of registers required by the operation label(n) = max(2, l1, l2), if l1  l2 l1 + 1, if l1 = l2
  • 17. + T1 + T1 1 l max(2, l) l 0 l + T1 T4 + T2 T3 + Ti3 + Ti1 Ti2 + Ti4 + associative commutative largest commutative
  • 18.  Nodes with more than one parent in a dag are called shared nodes  Optimal code generation for dags on both a one-register machine or an unlimited number of registers machine are NP-complete