page_title: Register allocation
section_title: Components of register allocation
hierarchical_section_title: Register allocation / Context / Components of register allocation
caption_attribution_description: English: CPU i386 registers
context_page_description: 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, over a whole function/procedure, or across function boundaries traversed via call-graph. When done per function/procedure the calling convention may require insertion of save/restore around each call-site.
context_section_description: Register allocation consists therefore in choosing where to store the variables at runtime, i.e. inside or outside registers. If the variable is to be stored in registers, then the allocator needs to determine in which register(s) this variable will be stored. Eventually, another challenge is to determine the duration for which a variable should stay at the same location.
  A register allocator, disregarding the chosen allocation strategy, can rely on a set of core actions to address these challenges. These actions can be gathered in three different categories:
  Move insertion
  This action consists in increasing the number of move instructions between registers, i.e. make a variable live in different registers during its lifetime, instead of one. This occurs in the split live range approach.
  Spilling
  This action consists of storing a variable into memory instead of registers.
  Assignment
  This action consists of assigning a register to a variable.
  Coalescing
  This action consists of limiting the number of moves between registers, thus limiting the total number of instructions. For instance, by identifying a variable live across different methods, and storing it into one register during its whole lifetime.
  Mostly, a lot of register allocation approaches try to specifically optimize one or the other category of actions.
caption: Intel 386 registers
exif: {}