Register Allocation

Why Trust Techopedia

What Does Register Allocation Mean?

Register allocation refers to the practice of assigning variables to registers as well as handling transfer of data into and out of registers. Register allocation may occur:

Advertisements
  • On a basic block, known as local register allocation
  • Over an entire function or procedure, known as global register allocation
  • Over function boundaries traversed by means of a call graph, known as inter-procedural register allocation

Techopedia Explains Register Allocation

During the course of compilation, the compiler should determine the way in which variables are allocated to a small, specific range of registers. Some of the variables may not be in use or are said to be "live" simultaneously. This leads to assigning some registers to multiple variables. Nonetheless, no two simultaneous live variables can be allotted to the exact same register without corrupting the value.

Variables that cannot be allotted to some registers need to be stored in RAM and should be loaded in and out for each read and write, respectively, a procedure known as spilling. Accessing registers is much faster than accessing RAM. In addition, it speeds up the execution time of the compiled program; therefore, efficient compilers aim at assigning as many variables to registers as they can.

Generally, most register allocators assign every variable to main memory or a central processing unit (CPU) register. Speed is the key benefit when using a register. Computers feature a finite range of registers, which means that not all the available variables can be allotted to registers. The process of shifting a variable from a register to the memory is known as spilling, whereas the reverse procedure of moving a variable from memory to a register is known as filling. Intelligent register allocation is a crucial step for any compilers.

There are two types of register allocation:

  • Local register allocation: This is a process of allocating one basic block (or hyper block or super block) at a time. Local register allocation boosts speed.
  • Global register allocation: If the register utilization is poor using local allocation, it is important to make use of global register allocation. In simple global register allocation, the most active values are allocated in every inner loop. Full global register allocation uses a procedure to identify live ranges in a control flow graph, assign live ranges and also split ranges as required.
Advertisements

Related Terms

Margaret Rouse
Editor

Margaret jest nagradzaną technical writerką, nauczycielką i wykładowczynią. Jest znana z tego, że potrafi w prostych słowach pzybliżyć złożone pojęcia techniczne słuchaczom ze świata biznesu. Od dwudziestu lat jej definicje pojęć z dziedziny IT są publikowane przez Que w encyklopedii terminów technologicznych, a także cytowane w artykułach ukazujących się w New York Times, w magazynie Time, USA Today, ZDNet, a także w magazynach PC i Discovery. Margaret dołączyła do zespołu Techopedii w roku 2011. Margaret lubi pomagać znaleźć wspólny język specjalistom ze świata biznesu i IT. W swojej pracy, jak sama mówi, buduje mosty między tymi dwiema domenami, w ten…