The main goal of register allocation and assignment is to reduce or minimize the memory accesses because the instruction involving only the register operands are shorter and faster than those involving memory operands.
Register Allocation :
The register allocation is the process of deciding what names in a program should reside in registers. The allocation involves assigning symbolic registers to operations that require destination resources within the machine.
Register Assignment :
The register assignment is the process of determining in which register each name should reside. The assignment defines the process whereby the symbolic registers are mapped onto actual machine resources. The register allocation and assignment process occurs in four phases,
1 Code Selection :
uses an unbounded number of symbolic registers during the early parts of compilation to represent the program variables and compiler generated temporaries. A unique name usually represents each symbolic register, generally an increasing numerical sequence.
2 Allocation :
chooses which of the unbounded number of symbolic registers will reside in actual machine registers.
3 Assignment :
maps the chosen symbolic registers to actual hardware registers.
4 Spilling :
occurs when there is an insufficient number of hardware registers to cover symbolic register requirements. One approach to register allocation and assignment is to assign specific types of quantities is an object program to certain registers. For example, a decision can be made to assign:
- Subroutine links to one group of registers.
- Base addresses to another group of registers
- Arithmetic computations to another group of registers.
- The run-time stack pointer to a fixed register, and so on.
This approach simplifies the design of a compiler however, it uses the registers inefficiently.
Global Registers Allocation :
We are forced to store the values at the end of each block. Therefore, in ()icier to save some of these stores and corresponding loads, we must assign registers to frequently used•variables and keep these registers consistent across block boundaries. This process is known as global register allocation.
The global register allocation strategy is based on the assumption that some fixed number of registers (say three) will be assigned to hold the most active names in each inner loop. The selected names may differ in different loops. The main drawback of this approach is that no given number of registers will be universally the right number to make available for global register allocation.
- What is Schema Markup and what is its impact on SEO | Schema markup benefits | Role of schema in SEO
- Compare SLR, CLR, and LALR parsers.
- Top 10 Best Motivational Speakers in India 2021
- Syntax Directed Translation & intermediate code generation
- What are the basic aspects of storage management? Discuss them in brief?