当前位置:网站首页>DCC888 :Register Allocation

DCC888 :Register Allocation

2022-06-27 17:32:00 春江花月夜晨

Register Allocation

(0)These values might be stored either in registers, or in memory.
(1)Registers are fast, but they come in small quantity.
(2)Memory is plenty, but it has slower access time.
(3) A good register allocator should strive to keep in registers the variables used more often.
在这里插入图片描述
在这里插入图片描述

the three aspects of register allocation

register assignment

The task of determining in which register each variable will be kept

spill

If a variable must be mapped into memory, we call it a spill.
Spilling is the task of determining which variables must be mapped to memory.

coalescing

If we can assign the same register to two variables related by a move instruction, then we can eliminate this move. This optimization is called coalescing.

在这里插入图片描述

register constraints

在这里插入图片描述
在这里插入图片描述
maxLive :MaxLive is the maximum number of registers that are simultaneously alive at any program point of the program’s control flow graph.
MinReg :The minimum number of registers that a program needs,
MinReg > MaxLive
在这里插入图片描述
在这里插入图片描述
@ = e, c 该节点的input是c -> r1,e-> r2;
c = d, 该节点的input是d->r1, e->r2;
e = a, 该节点的input是d->r1, a->r2;此时发现与最开始的假设a->r1冲突。

Register Assignment is NP-Complete

在这里插入图片描述

Chaitin’s proof

在这里插入图片描述

the interference graph

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

Linear Scan

It is based on the greedy coloring of interval graphs:
– Given a sequence of intervals, we want to find the minimum number of colors necessary to paint them, so that overlapping intervals are given different colors.

在这里插入图片描述

Linearization of Basic Blocks

reverse post-order
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
first :r3 ->c
second: r1->a

在这里插入图片描述

intervals once spill

spill 到memory,将会打断variable生命周期
在这里插入图片描述
在这里插入图片描述

spill :need store/load placemeng

在这里插入图片描述
在这里插入图片描述

coalescing

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

live ranges with holes

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

graph coloring register allocation

the interference graph

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
simplification的时候,将node一次放入栈中。
r3 - r1 - r2 - e - c - b - a - d
reverse order : d - a - b - c - e - r2 - r1 - r3

greedy coloring

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

iterated register coalescing

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

spilling heuristics

在这里插入图片描述
在这里插入图片描述

spilling

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
其中以d为例:2是d在loop之外的def和use,10的一次方是d的loop nesting factor是1,乘以2是因为loop之内有def和use两次,d的degree为4.
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

原网站

版权声明
本文为[春江花月夜晨]所创,转载请带上原文链接,感谢
https://blog.csdn.net/pc153262603/article/details/125416273