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

DCC888 :Register Allocation

2022-06-27 22:32:00 Spring river flower moon night morning

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.
 Insert picture description here
 Insert picture description here

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.

 Insert picture description here

register constraints

 Insert picture description here
 Insert picture description here
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
 Insert picture description here
 Insert picture description here
@ = e, c Of this node input yes c -> r1,e-> r2;
c = d, Of this node input yes d->r1, e->r2;
e = a, Of this node input yes d->r1, a->r2; At this point, the discovery and the initial assumption a->r1 Conflict .

Register Assignment is NP-Complete

 Insert picture description here

Chaitin’s proof

 Insert picture description here

the interference graph

 Insert picture description here
 Insert picture description here
 Insert picture description here

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.

 Insert picture description here

Linearization of Basic Blocks

reverse post-order
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
first :r3 ->c
second: r1->a

 Insert picture description here

intervals once spill

spill To memory, Will interrupt variable Life cycle
 Insert picture description here
 Insert picture description here

spill :need store/load placemeng

 Insert picture description here
 Insert picture description here

coalescing

 Insert picture description here
 Insert picture description here
 Insert picture description here

live ranges with holes

 Insert picture description here
 Insert picture description here
 Insert picture description here

graph coloring register allocation

the interference graph

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
simplification When , take node Put it on the stack at one time .
r3 - r1 - r2 - e - c - b - a - d
reverse order : d - a - b - c - e - r2 - r1 - r3

greedy coloring

 Insert picture description here
 Insert picture description here
 Insert picture description here

iterated register coalescing

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

spilling heuristics

 Insert picture description here
 Insert picture description here

spilling

 Insert picture description here
 Insert picture description here
 Insert picture description here
Among them d For example :2 yes d stay loop In addition to the def and use,10 To the power of d Of loop nesting factor yes 1, multiply 2 Because loop Within def and use two ,d Of degree by 4.
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

原网站

版权声明
本文为[Spring river flower moon night morning]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/178/202206271732265426.html

随机推荐