编译_apter11.pptxVIP

  • 5
  • 0
  • 约1.4万字
  • 约 66页
  • 2017-08-22 发布于江苏
  • 举报
编译_apter11

Global Register Allocation 邱锡鹏 复旦大学计算机科学技术学院 xpqiu@ /~xpqiu/compiler 2017-4-8 1 References /class/cs143/ Partial contents are copied from the slides of Alex Aiken 2 Outline Register Interference Graph Coloring by Simplification Coalesce Precolored Nodes Register Allocation for Trees 2017-4-8 3 Register Interference Graph 2017-4-8 4 The Register Interference Graph Two temporaries that are live simultaneously cannot be allocated in the same register We construct an undirected graph A node for each temporary An edge between t1 and t2 if they are live simultaneously at some point in the program This is the register interference graph (RIG) Two temporaries can be allocated to the same register if there is no edge connecting them 2017-4-8 5 Build the Register Interference Graph For our example: 2017-4-8 6 a f e d c b E.g., b and c cannot be in the same register E.g., b and d can be in the same register Register Interference Graph. Properties. It extracts exactly the information needed to characterize legal register assignments It gives a global (i.e., over the entire flow graph) picture of the register requirements After RIG construction the register allocation algorithm is architecture independent 2017-4-8 7 Graph Coloring. Definitions. A coloring of a graph is an assignment of colors to nodes, such that nodes connected by an edge have different colors A graph is k-colorable if it has a coloring with k colors 2017-4-8 8 Coloring by Simplification 2017-4-8 9 Register Allocation Through Graph Coloring In our problem, colors = registers We need to assign colors (registers) to graph nodes (temporaries) Let k = number of machine registers If the RIG is k-colorable then there is a register assignment that uses no more than k registers 2017-4-8 10 Previous Example 2017-4-8 11 Graph Coloring. Example. Consider the example RIG 2017-4-8 12 There is no coloring with less than 4 colors There are 4-colorings of this graph Graph Coloring. Example. Under this coloring the code becomes

文档评论(0)

1亿VIP精品文档

相关文档