SlideShare a Scribd company logo
1 of 1
Register Allocation: 
In compiler optimization, register allocation is the process of assigning a 
large number of target program variables onto a small number of CPU registers. 
Register allocation can happen over a basic block (local register allocation), 
over a whole function/procedure (global register allocation), or across function 
boundaries traversed via call-graph (interprocedural register allocation). When 
done per function/procedure the calling convention may require insertion of 
save/restore around each call-site. 
In many programming languages, the programmer has the illusion of allocating 
arbitrarily many variables. However, during compilation, the compiler must 
decide how to allocate these variables to a small, finite set of registers. Not 
all variables are in use (or "live") at the same time, so some registers may be 
assigned to more than one variable. However, two variables in use at the same 
time cannot be assigned to the same register without corrupting its value. 
Variables which cannot be assigned to some register must be kept in RAM and 
loaded in/out for every read/write, a process called spilling. Accessing RAM is 
significantly slower than accessing registers and slows down the execution speed 
of the compiled program, so an optimizing compiler aims to assign as many 
variables to registers as possible. 
In addition, programs can be further optimized by assigning the same register to 
a source and destination of a move instruction whenever possible.

More Related Content

What's hot

Lecture2 1 types of programming languages
Lecture2 1 types of programming languagesLecture2 1 types of programming languages
Lecture2 1 types of programming languages
Yog Maya
 

What's hot (9)

Parallel language & compilers
Parallel language & compilersParallel language & compilers
Parallel language & compilers
 
Unit 3 part2
Unit 3 part2Unit 3 part2
Unit 3 part2
 
FUNDAMENTAL.pptx
FUNDAMENTAL.pptxFUNDAMENTAL.pptx
FUNDAMENTAL.pptx
 
Flux: A Language for Programming High-Performance Servers
Flux: A Language for Programming High-Performance ServersFlux: A Language for Programming High-Performance Servers
Flux: A Language for Programming High-Performance Servers
 
parallel language and compiler
parallel language and compilerparallel language and compiler
parallel language and compiler
 
SAP Post Copy Automation
SAP Post Copy AutomationSAP Post Copy Automation
SAP Post Copy Automation
 
SAP LVM Custom Instances
SAP LVM Custom InstancesSAP LVM Custom Instances
SAP LVM Custom Instances
 
Lecture2 1 types of programming languages
Lecture2 1 types of programming languagesLecture2 1 types of programming languages
Lecture2 1 types of programming languages
 
Introduction to reactive programming
Introduction to reactive programmingIntroduction to reactive programming
Introduction to reactive programming
 

Similar to Register allocation

1 Describe different types of Assemblers.Assembly language.docx
 1 Describe different types of Assemblers.Assembly language.docx 1 Describe different types of Assemblers.Assembly language.docx
1 Describe different types of Assemblers.Assembly language.docx
aryan532920
 
Language translators
Language translatorsLanguage translators
Language translators
Aditya Sharat
 
Dsm (Distributed computing)
Dsm (Distributed computing)Dsm (Distributed computing)
Dsm (Distributed computing)
Sri Prasanna
 

Similar to Register allocation (20)

Lecture20-21-22.ppt
Lecture20-21-22.pptLecture20-21-22.ppt
Lecture20-21-22.ppt
 
1 Describe different types of Assemblers.Assembly language.docx
 1 Describe different types of Assemblers.Assembly language.docx 1 Describe different types of Assemblers.Assembly language.docx
1 Describe different types of Assemblers.Assembly language.docx
 
Assembly language
Assembly languageAssembly language
Assembly language
 
Bab 4
Bab 4Bab 4
Bab 4
 
Language translators
Language translatorsLanguage translators
Language translators
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management
 
Code scheduling constraints
Code scheduling constraintsCode scheduling constraints
Code scheduling constraints
 
Memory management
Memory managementMemory management
Memory management
 
Dsm (Distributed computing)
Dsm (Distributed computing)Dsm (Distributed computing)
Dsm (Distributed computing)
 
Interpreting the Data:Parallel Analysis with Sawzall
Interpreting the Data:Parallel Analysis with SawzallInterpreting the Data:Parallel Analysis with Sawzall
Interpreting the Data:Parallel Analysis with Sawzall
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
 
Code generation errors and recovery
Code generation errors and recoveryCode generation errors and recovery
Code generation errors and recovery
 
adaptive-destager
adaptive-destageradaptive-destager
adaptive-destager
 
Parallel Processing (Part 2)
Parallel Processing (Part 2)Parallel Processing (Part 2)
Parallel Processing (Part 2)
 
Porcorn tutorial
Porcorn tutorialPorcorn tutorial
Porcorn tutorial
 
Software for embedded systems complete
Software for embedded systems completeSoftware for embedded systems complete
Software for embedded systems complete
 
Shared memory Parallelism (NOTES)
Shared memory Parallelism (NOTES)Shared memory Parallelism (NOTES)
Shared memory Parallelism (NOTES)
 
01-MessagePassingFundamentals.ppt
01-MessagePassingFundamentals.ppt01-MessagePassingFundamentals.ppt
01-MessagePassingFundamentals.ppt
 
Load balancing
Load balancingLoad balancing
Load balancing
 

More from JK Knowledge (6)

Introduction to weka
Introduction to wekaIntroduction to weka
Introduction to weka
 
UNIX INTERNALS UNIT-I
UNIX INTERNALS UNIT-IUNIX INTERNALS UNIT-I
UNIX INTERNALS UNIT-I
 
Symbol table format
Symbol table formatSymbol table format
Symbol table format
 
Object code
Object codeObject code
Object code
 
Yacc topic beyond syllabus
Yacc   topic beyond syllabusYacc   topic beyond syllabus
Yacc topic beyond syllabus
 
Make your analysis or thoughts to be positive
Make your analysis or thoughts to be positiveMake your analysis or thoughts to be positive
Make your analysis or thoughts to be positive
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Recently uploaded (20)

Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 

Register allocation

  • 1. Register Allocation: In compiler optimization, register allocation is the process of assigning a large number of target program variables onto a small number of CPU registers. Register allocation can happen over a basic block (local register allocation), over a whole function/procedure (global register allocation), or across function boundaries traversed via call-graph (interprocedural register allocation). When done per function/procedure the calling convention may require insertion of save/restore around each call-site. In many programming languages, the programmer has the illusion of allocating arbitrarily many variables. However, during compilation, the compiler must decide how to allocate these variables to a small, finite set of registers. Not all variables are in use (or "live") at the same time, so some registers may be assigned to more than one variable. However, two variables in use at the same time cannot be assigned to the same register without corrupting its value. Variables which cannot be assigned to some register must be kept in RAM and loaded in/out for every read/write, a process called spilling. Accessing RAM is significantly slower than accessing registers and slows down the execution speed of the compiled program, so an optimizing compiler aims to assign as many variables to registers as possible. In addition, programs can be further optimized by assigning the same register to a source and destination of a move instruction whenever possible.