JPH04241630A - System for optimizing register allocation by graph painting - Google Patents

System for optimizing register allocation by graph painting

Info

Publication number
JPH04241630A
JPH04241630A JP1599691A JP1599691A JPH04241630A JP H04241630 A JPH04241630 A JP H04241630A JP 1599691 A JP1599691 A JP 1599691A JP 1599691 A JP1599691 A JP 1599691A JP H04241630 A JPH04241630 A JP H04241630A
Authority
JP
Japan
Prior art keywords
graph
nodes
register
register allocation
variables
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP1599691A
Other languages
Japanese (ja)
Inventor
Takashi Miyamoto
宮本 敬士
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NEC Corp
Original Assignee
NEC Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NEC Corp filed Critical NEC Corp
Priority to JP1599691A priority Critical patent/JPH04241630A/en
Publication of JPH04241630A publication Critical patent/JPH04241630A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PURPOSE:To prepare an object program having a high executive performance. CONSTITUTION:A data conflict analyzing means 41 discriminates the presence/ absence of an overlap and the possibility of damaging the parallelization of instructions caused by the allocation of the same register regarding 'sections where variables hold effective data' in an intermediate code string and calculates an evaluated value in accordance with the presence/absence of the overlap and the potentiality of possibility of damaging parallelization. A graph plotting means 42 plots a graph by connecting the nodes corresponding to the 'sections where variables hold effective data' with sides based on the analyzed results of the means 41 and adding evaluated values to the sides. A graph painting means 43 assigns the different colors of the number corresponding to the number of usable registers to the nodes connected by the sides. A register allocating means 44 allocates the same register to the variables corresponding to the nodes for which the same color is assigned.

Description

【発明の詳細な説明】[Detailed description of the invention]

【0001】0001

【産業上の利用分野】本発明は、与えられたソースプロ
グラムから目的プログラムを生成するコンパイラにおけ
る最適化方式に関し、特に並列に動作する複数の演算部
を持ち各演算部で実行される命令が目的プログラムの生
成時点で確定していることを前提とするプロセッサに対
するコンパイラにおける最適化方式に関し、とりわけ目
的プログラムの生成過程でソースプログラムの展開によ
り生成された中間コード列を対象としてレジスタを効率
良く割り付けるためにグラフ色塗りの手法を採用するグ
ラフ色塗りによるレジスタ割り付け最適化方式に関する
[Industrial Application Field] The present invention relates to an optimization method for a compiler that generates a target program from a given source program. Regarding an optimization method in a compiler for a processor that assumes that the program has been determined at the time of program generation, in particular, in order to efficiently allocate registers for intermediate code strings generated by expanding a source program in the process of generating the target program. This paper concerns a register allocation optimization method using graph coloring, which employs a graph coloring method.

【0002】0002

【従来の技術】単一の演算部からなりその演算部で実行
される命令が目的プログラムの生成時点で確定している
ことを前提とするプロセッサに対するコンパイラで、中
間コード列中の変数に対してレジスタを割り付ける方式
として、グラフ色塗りの手法を用いる方式が知られてい
る。
[Prior Art] A compiler for a processor that consists of a single arithmetic unit and assumes that the instructions executed by the arithmetic unit are fixed at the time of generation of the target program. A method using a graph coloring method is known as a method for allocating registers.

【0003】この方式では、次のような手順で処理が行
われる。
[0003] In this method, processing is performed in the following steps.

【0004】■  各変数が有効なデータを保持してい
る区間をグラフのノードとして表す。
[0004] ■ The interval in which each variable holds valid data is represented as a node in the graph.

【0005】■  2つの区間に重複があることにより
対象となっている2個の変数に同一のレジスタを割り付
けることが不可能な場合には、対応する2個のノードを
グラフの辺で結ぶ。
[0005] If it is impossible to allocate the same register to the two variables in question due to overlap between two intervals, the two corresponding nodes are connected by an edge of the graph.

【0006】■  以上の方法を用いて全ての区間につ
いて重複を解析し、その結果得られたグラフにおいて、
互いに辺で結ばれたノードが同一の色とならないように
色を割り当てる。
[0006] Using the above method, we analyze overlap for all sections, and in the graph obtained as a result,
Assign colors so that nodes connected to each other by edges do not have the same color.

【0007】■  同一の色が割り当てられた複数のノ
ードに対応する複数の変数に対して1本のレジスタを割
り付ける。
■ Allocate one register to a plurality of variables corresponding to a plurality of nodes to which the same color is assigned.

【0008】なお、上述の方式において、ノードにあら
かじめ優先度を与えることにより、上述のレジスタ割り
付けの効果をさらに高める方式がある。この方式では、
あるノードの優先度としてそのノードに対応する変数が
ソースプログラム中で使用される頻度が用いられ、上述
の手順■においてレジスタが割り付けられる段階で優先
度の高いノードから順にレジスタが割り付けてられてい
る(このように従来技術における「優先度」はノードに
対して付与されるものであった)。
[0008] Among the above-mentioned methods, there is a method that further enhances the effect of register allocation by giving priority to nodes in advance. In this method,
The priority of a node is determined by the frequency with which the variable corresponding to that node is used in the source program, and when registers are allocated in step ① above, registers are allocated in order from the node with the highest priority. (In this way, "priority" in the prior art was given to nodes).

【0009】並列に動作する複数の演算部を持ち各演算
部で実行される命令が目的プログラムの生成時点で確定
していることを前提とするプロセッサに対するコンパイ
ラにおいても、従来のグラフ色塗りによるレジスタ割り
付け最適化方式は、単一の演算部からなるプロセッサに
対するコンパイラにおける上述の方式がそのまま適用さ
れて実現されていた。
[0009] Even in a compiler for a processor that has multiple arithmetic units operating in parallel and assumes that the instructions to be executed in each arithmetic unit are determined at the time of generation of the target program, registers using conventional graph coloring are used. The allocation optimization method was realized by directly applying the method described above in a compiler for a processor consisting of a single arithmetic unit.

【0010】0010

【発明が解決しようとする課題】複数の演算部を持つプ
ロセッサに対するコンパイラにおける従来のグラフ色塗
りによるレジスタ割り付け最適化方式では、単一の演算
部からなるプロセッサに対するコンパイラにおける上述
の方式がそのまま適用されており、2つの区間に重複が
ない限りノードを結ぶ辺は作成されないので、ソースプ
ログラム上での位置が近接している2つの変数であって
もそれらの変数に対応する2つの区間に重複がなければ
同一のレジスタが割り付けられ得る。
[Problem to be Solved by the Invention] In the conventional register allocation optimization method using graph coloring in a compiler for a processor having multiple arithmetic units, the above-mentioned method for a compiler for a processor having a single arithmetic unit is applied as is. As long as there is no overlap between the two intervals, an edge connecting the nodes will not be created, so even if two variables are located close to each other in the source program, there will be no overlap between the two intervals corresponding to those variables. Otherwise, the same registers can be allocated.

【0011】ところで、複数の演算部を持つコンパイラ
における命令の並列化処理では、ソースプログラム上で
の位置が近接している命令は可能な限り並列に実行する
ような配置が試みられる。このときに、これらの命令に
含まれる変数に同一のレジスタが割り付けられると、こ
れらの変数を使用している命令を並列に実行できない。
By the way, in the parallelization processing of instructions in a compiler having a plurality of arithmetic units, an attempt is made to arrange instructions so that instructions located close to each other in a source program are executed in parallel as much as possible. At this time, if the same register is allocated to variables included in these instructions, the instructions using these variables cannot be executed in parallel.

【0012】したがって、上述した従来のグラフ色塗り
によるレジスタ割り付け最適化方式では、その方式が適
用されるコンパイラにより生成される目的プログラムの
実行性能が悪くなるという問題点があった。
Therefore, the above-described conventional register allocation optimization method using graph coloring has a problem in that the execution performance of the target program generated by the compiler to which the method is applied deteriorates.

【0013】本発明の目的は、上述の点に鑑み、高い実
行性能を有する目的プログラムを生成することができる
グラフ色塗りによるレジスタ割り付け最適化方式を提供
することにある。
SUMMARY OF THE INVENTION In view of the above points, an object of the present invention is to provide a register allocation optimization method using graph coloring that can generate a target program with high execution performance.

【0014】[0014]

【課題を解決するための手段】本発明のグラフ色塗りに
よるレジスタ割り付け最適化方式は、並列に動作する複
数の演算部を持ち各演算部で実行される命令が目的プロ
グラムの生成時点で確定していることを前提とするプロ
セッサに対する目的プログラムの生成過程で中間コード
列に対してグラフ色塗りの手法を用いてレジスタ割り付
けの最適化を行うコンパイラにおいて、中間コード列中
の「変数が有効なデータを保持している区間」に関して
重複の有無および同一のレジスタを割り付けることによ
り命令の並列化を損なう可能性を判断し重複の有無およ
び並列化を損なう可能性の高さに応じて評価値を算出す
るデータコンフリクト解析手段と、このデータコンフリ
クト解析手段による解析に基づいて「変数が有効なデー
タを保持している区間」に対応するノードを辺で結びそ
の辺に評価値を付加してグラフを作成するグラフ作成手
段と、このグラフ作成手段により辺で結ばれたノードに
利用可能なレジスタ数に応じた数の別の色を割り当てる
グラフ色塗り手段と、このグラフ色塗り手段により同一
の色が割り当てられたノードに対応する変数に同一のレ
ジスタを割り付けるレジスタ割り付け手段とを有する。
[Means for Solving the Problems] The register allocation optimization method using graph coloring of the present invention has a plurality of arithmetic units operating in parallel, and the instructions to be executed in each arithmetic unit are determined at the time of generation of the target program. In the process of generating a target program for a processor that assumes that the For the section that holds , determine whether there is any duplication and the possibility of impairing parallelization of instructions by allocating the same register, and calculate an evaluation value depending on the presence or absence of duplication and the high possibility of impairing parallelization. A graph is created by connecting the nodes corresponding to the "interval where the variable holds valid data" with edges and adding evaluation values to the edges based on the analysis by this data conflict analysis means. a graph coloring means that assigns different colors according to the number of available registers to nodes connected by edges by this graph creation means; and a graph coloring means that assigns the same color to nodes connected by edges by this graph coloring means and register allocation means for allocating the same register to the variable corresponding to the node.

【0015】[0015]

【作用】本発明のグラフ色塗りによるレジスタ割り付け
最適化方式では、データコンフリクト解析手段が中間コ
ード列中の「変数が有効なデータを保持している区間」
に関して重複の有無および同一のレジスタを割り付ける
ことにより命令の並列化を損なう可能性を判断し重複の
有無および並列化を損なう可能性の高さに応じて評価値
を算出し、グラフ作成手段がデータコンフリクト解析手
段による解析に基づいて「変数が有効なデータを保持し
ている区間」に対応するノードを辺で結びその辺に評価
値を付加してグラフを作成し、グラフ色塗り手段がグラ
フ作成手段により辺で結ばれたノードに利用可能なレジ
スタ数に応じた数の別の色を割り当て、レジスタ割り付
け手段がグラフ色塗り手段により同一の色が割り当てら
れたノードに対応する変数に同一のレジスタを割り付け
る。
[Operation] In the register allocation optimization method using graph coloring of the present invention, the data conflict analysis means detects "sections in which variables hold valid data" in the intermediate code string.
The graph creation means calculates the evaluation value according to the existence of duplication and the possibility of impairing parallelization of instructions by allocating the same register. Based on the analysis by the conflict analysis means, a graph is created by connecting nodes corresponding to "intervals in which variables hold valid data" with edges and adding evaluation values to the edges, and the graph coloring means creates the graph. The means assigns a number of different colors corresponding to the number of available registers to the nodes connected by edges, and the register allocation means assigns the same register to variables corresponding to the nodes to which the same color is assigned by the graph coloring means. Assign.

【0016】[0016]

【実施例】次に、本発明について図面を参照して詳細に
説明する。
DESCRIPTION OF THE PREFERRED EMBODIMENTS Next, the present invention will be explained in detail with reference to the drawings.

【0017】図1は、本発明のグラフ色塗りによるレジ
スタ割り付け最適化方式の一実施例の構成を示すブロッ
ク図である。本実施例のグラフ色塗りによるレジスタ割
り付け最適化方式は、二次記憶装置(図示せず)に格納
されているソースプログラム1と、コンパイラ2と、コ
ンパイルされて二次記憶装置に格納される目的プログラ
ム3とを含んで構成されている。
FIG. 1 is a block diagram showing the structure of an embodiment of the register allocation optimization method using graph coloring according to the present invention. The register allocation optimization method using graph coloring of this embodiment uses a source program 1 stored in a secondary storage device (not shown), a compiler 2, and an object that is compiled and stored in the secondary storage device. This program includes Program 3.

【0018】コンパイラ2は、二次記憶装置からソース
プログラム1を取り込み構文解析および意味解析を行い
解析結果を中間コード列5(図2参照)に展開するソー
スプログラム解釈部21と、その中間コード列5に対し
てコード短縮等のための最適化処理を施す最適化部22
と、複数の演算部の各演算部で実行される全ての命令を
一列に並べた形の直列アセンブリ命令列を生成する直列
アセンブリ命令列生成部23と、直列アセンブリ命令列
の並列化を行い目的プログラム3となる並列アセンブリ
命令列を生成する並列アセンブリ命令列生成部24と、
目的プログラム3を二次記憶装置に出力する目的プログ
ラム出力部25とを含んで構成されている。
The compiler 2 includes a source program interpreter 21 that takes in a source program 1 from a secondary storage device, performs syntactic analysis and semantic analysis, and develops the analysis results into an intermediate code string 5 (see FIG. 2); An optimization unit 22 that performs optimization processing for code shortening etc. on 5.
, a serial assembly instruction string generator 23 that generates a serial assembly instruction string in which all the instructions to be executed in each of the plurality of arithmetic units are arranged in a line; and a serial assembly instruction string generator 23 that parallelizes the serial assembly instruction string. a parallel assembly instruction string generation unit 24 that generates a parallel assembly instruction string that becomes the program 3;
The target program output unit 25 outputs the target program 3 to a secondary storage device.

【0019】最適化部22内のレジスタ割り付け処理部
4は、データコンフリクト解析手段41と、グラフ作成
手段42と、グラフ色塗り手段43と、レジスタ割り付
け手段44とを含んで構成されている。このレジスタ割
り付け処理部4によって、本実施例のグラフ色塗りによ
るレジスタ割り付け最適化方式の中枢の処理が実現され
る。
The register allocation processing section 4 in the optimization section 22 includes a data conflict analysis means 41, a graph creation means 42, a graph coloring means 43, and a register allocation means 44. This register allocation processing section 4 realizes the core processing of the register allocation optimization method using graph coloring of this embodiment.

【0020】図2および図3はレジスタ割り付け処理部
4の処理を説明するための図であり、図2は中間コード
列5の一例を示す図であり、図3はグラフ作成手段42
により作成されグラフ色塗り手段43による「グラフ色
塗り」の対象となるグラフ6の一例を示す図である。
2 and 3 are diagrams for explaining the processing of the register allocation processing section 4, FIG. 2 is a diagram showing an example of the intermediate code string 5, and FIG.
6 is a diagram illustrating an example of a graph 6 that is created by the graph coloring means 43 and is subject to "graph coloring" by the graph coloring means 43. FIG.

【0021】次に、このように構成された本実施例のグ
ラフ色塗りによるレジスタ割り付け最適化方式の動作に
ついて説明する。
Next, the operation of the register allocation optimization method using graph coloring of this embodiment configured as described above will be explained.

【0022】レジスタ割付け処理部4では、次のような
処理が行われる。
The register allocation processing section 4 performs the following processing.

【0023】データコンフリクト解析手段41は、中間
コード列5を参照して各変数が有効なデータを保持して
いる区間を検出し、これらの区間相互に重複があるか否
かを解析する。重複がある場合には、その重複を示す評
価値として無限大を算出する。さらに、このような重複
がなくても、後のレジスタ割り付けでこれらの区間に対
応する変数に同一のレジスタが割り付けられると並列性
を損なう可能性があるか否かを解析し、その可能性があ
る場合にはその可能性の大きさに応じた評価値を算出す
る。
The data conflict analysis means 41 refers to the intermediate code string 5, detects sections in which each variable holds valid data, and analyzes whether or not there is overlap between these sections. If there is overlap, infinity is calculated as the evaluation value indicating the overlap. Furthermore, even if there is no such duplication, we analyze whether or not parallelism may be impaired if the same register is allocated to variables corresponding to these intervals in later register allocation, and we examine the possibility of this. If there is, an evaluation value is calculated depending on the size of the possibility.

【0024】グラフ作成手段42は、次のようにしてグ
ラフ6を作成する。すなわち、データコンフリクト解析
手段41によって解析された「変数が有効なデータを保
持している区間」に対してグラフ6のノードを割り当て
る。また、データコンフリクト解析手段41によって「
相互に重複がある」と解析された2つの区間に対応する
2つのノードを辺で結び、データコンフリクト解析手段
41により算出された評価値である無限大(重複を示す
評価値。図3中では「inf」で示す)をその辺に付加
する。また、相互に重複がない2つの区間であっても、
同一のレジスタが割り付けられると並列性を損なう可能
性がある2つの区間に対応する2つのノードを辺で結び
、データコンフリクト解析手段41により算出された評
価値(並列性を損なう可能性に応じた評価値)をその辺
に付加する。
The graph creation means 42 creates the graph 6 in the following manner. In other words, nodes of the graph 6 are assigned to "sections in which variables hold valid data" analyzed by the data conflict analysis means 41. In addition, the data conflict analysis means 41
An edge connects two nodes corresponding to two sections that have been analyzed as ``there is mutual overlap,'' and an evaluation value of infinity (an evaluation value indicating overlap; in FIG. ) is added to that side. Also, even if there are two sections that do not overlap,
The evaluation value calculated by the data conflict analysis means 41 (according to the possibility of impairing parallelism) is evaluation value) is added to that side.

【0025】グラフ色塗り手段43は、グラフ作成手段
42によって作成されたグラフ6の辺に付加された評価
値を優先度として用い、以下のようにグラフ6に対して
グラフ色塗りを行う。最初に、全ての辺を用いてグラフ
色塗りを行い(辺で結ばれたノードに別の色を割り当て
ることを全ての辺について行う)、必要な色の数が利用
可能なレジスタ数以下であるか否かを判断する。必要な
色の数が利用可能なレジスタ数以下である場合には、グ
ラフ色塗りを完了する。必要な色の数が利用可能なレジ
スタ数以下でない場合には、評価値の小さい(優先度の
低い)順に辺をグラフ6から除去して残りの辺を用いて
グラフ色塗りを行い、必要な色の数が利用可能なレジス
タ数以下になるまで以上の処理を繰り返す。
The graph coloring means 43 uses the evaluation value added to the side of the graph 6 created by the graph creation means 42 as a priority, and colors the graph 6 as follows. First, perform graph coloring using all edges (assign different colors to nodes connected by edges for all edges), and ensure that the number of required colors is less than or equal to the number of available registers. Determine whether or not. If the number of required colors is less than or equal to the number of available registers, graph coloring is completed. If the number of required colors is not less than the number of available registers, remove the edges from graph 6 in order of decreasing evaluation value (low priority) and use the remaining edges to color the graph, and then fill in the necessary colors. The above process is repeated until the number of colors is less than or equal to the number of available registers.

【0026】レジスタ割り付け手段44は、グラフ色塗
り手段43によるグラフ色塗りの結果として同一の色が
与えられたノードに同一のレジスタを対応させることに
より、各変数にレジスタを割り付ける。
The register allocation means 44 allocates a register to each variable by associating the same register with the node given the same color as a result of graph coloring by the graph coloring means 43.

【0027】次に、レジスタ割り付け処理部4によるレ
ジスタ割り付け処理を具体例を用いて説明する(図2お
よび図3参照)。
Next, the register allocation processing by the register allocation processing section 4 will be explained using a specific example (see FIGS. 2 and 3).

【0028】図2に示す中間コード列5に対して、グラ
フ作成手段42は、図3に示すようなグラフ6を作成す
る(図3では、簡単のために、変数A,XおよびYに関
する部分のみを示す)。グラフ6中のノード61は変数
Aが有効なデータを保持している区間51(図2参照)
に対応するノードであり、ノード62は変数Xが有効な
データを保持している区間52に対応するノードであり
、ノード63は変数Yが有効なデータを保持している区
間53に対応するノードである。
For the intermediate code string 5 shown in FIG. 2, the graph creation means 42 creates a graph 6 as shown in FIG. (only shown). Node 61 in graph 6 is section 51 where variable A holds valid data (see Figure 2)
The node 62 is a node corresponding to the interval 52 in which the variable X holds valid data, and the node 63 is a node corresponding to the interval 53 in which the variable Y holds valid data. It is.

【0029】中間コード列5において、変数Aが有効な
データを保持している区間51と変数Xが有効なデータ
を保持している区間52とには重複がある。そこで、グ
ラフ作成手段42は、ノード61とノード62とを辺6
4で結び、データコンフリクト解析手段41により算出
された評価値(重複を示す評価値)である無限大(in
f)を辺64に付加する。
In the intermediate code string 5, there is an overlap between the section 51 in which the variable A holds valid data and the section 52 in which the variable X holds valid data. Therefore, the graph creation means 42 connects the node 61 and the node 62 to the side 6.
4, and infinity (in
f) to edge 64.

【0030】変数Aが有効なデータを保持している区間
51と変数Yが有効なデータを保持している区間53と
についても重複があるので、ノード61とノード63と
は辺66で結ばれ、辺66には評価値として無限大(i
nf)が付加される。
Since there is overlap between the interval 51 in which variable A holds valid data and the interval 53 in which variable Y holds valid data, node 61 and node 63 are connected by edge 66. , side 66 has an evaluation value of infinity (i
nf) is added.

【0031】変数Xが有効なデータを保持している区間
52と変数Yが有効なデータを保持している区間53と
には重複はないが、中間コード命令列5(したがって、
ソースプログラム1でも)において近接しているので、
同一のレジスタを割り付けると並列性を損なう可能性が
高い。したがって、データコンフリクト解析手段41は
その可能性の高さに応じた評価値(ここでは「2」とす
る)を与える。この結果、グラフ作成手段42は、ノー
ド62とノード63とを辺65で結び、辺65に評価値
として2を付加する。
Although there is no overlap between the interval 52 in which the variable X holds valid data and the interval 53 in which the variable Y holds valid data, the intermediate code instruction sequence 5 (therefore,
Even in source program 1), they are close to each other, so
Allocating the same register is likely to impair parallelism. Therefore, the data conflict analysis means 41 gives an evaluation value (here, "2") depending on the height of the possibility. As a result, the graph creation means 42 connects the node 62 and the node 63 with the edge 65, and adds 2 to the edge 65 as an evaluation value.

【0032】グラフ色塗り手段43およびレジスタ割り
付け手段44は、次のようにグラフ色塗りおよびレジス
タ割り付けを行う(図4参照)。
The graph coloring means 43 and register allocation means 44 perform graph coloring and register allocation as follows (see FIG. 4).

【0033】グラフ6の構成に基づき、グラフ色塗り手
段43は、辺64〜66で結ばれているノード61〜6
3には全て別の色を割り当てる。したがって、レジスタ
割り付け手段44はレジスタが3本以上利用可能な場合
には各ノード61〜63に別々のレジスタを割り付ける
Based on the configuration of the graph 6, the graph coloring means 43 colors the nodes 61 to 6 connected by the sides 64 to 66.
Assign all 3 different colors. Therefore, the register allocation means 44 allocates separate registers to each node 61 to 63 if three or more registers are available.

【0034】しかし、利用可能なレジスタが2本しかな
い場合には、グラフ色塗り手段43は、付加された評価
値の小さい辺65をグラフ6から除去し、ノード62と
ノード63とに同一の色を割り当て、さらにこれとは別
の色をノード61に割り当てる。この場合には、レジス
タ割り付け手段44はノード62とノード63とに同一
のレジスタを割り付ける(これにより、並列性を損なう
可能性が生じるが、利用可能なレジスタ数の制限からや
むをえない)。
However, if there are only two registers available, the graph coloring means 43 removes the added edge 65 with the smaller evaluation value from the graph 6, and adds the same color to nodes 62 and 63. A color is assigned to the node 61, and another color is assigned to the node 61. In this case, the register allocation means 44 allocates the same register to the nodes 62 and 63 (this may impair parallelism, but this is unavoidable due to the limit on the number of available registers).

【0035】以上の処理により、利用可能なレジスタ数
に余裕がある範囲で、並列性を生かしたレジスタ割り付
けを行うことができる。
[0035] Through the above processing, it is possible to perform register allocation that takes advantage of parallelism within the range of available register numbers.

【0036】[0036]

【発明の効果】以上説明したように本発明は、2つのノ
ードに同一のレジスタを割り付けることによって命令の
並列化処理が妨げられる可能性がある場合に、ノードに
対応する区間に重複がない場合でもこれらのノードを辺
で結ぶことにより、アセンブリ命令列(目的プログラム
)の並列性を高めることができる。また、グラフの辺に
優先度を持たせることにより、利用可能なレジスタ数が
不足する場合にも対処することができる。
[Effects of the Invention] As explained above, the present invention is applicable to cases where there is a possibility that parallelization processing of instructions is hindered by allocating the same register to two nodes, and where there is no overlap in the sections corresponding to the nodes. However, by connecting these nodes with edges, the parallelism of the assembly instruction sequence (target program) can be increased. Furthermore, by giving priority to the edges of the graph, it is possible to deal with the case where there is a shortage of usable registers.

【0037】以上のことにより、単純なグラフ色塗りの
手法によるレジスタ割付け(単一の演算部からなるプロ
セッサに対するコンパイラにおけるグラフ色塗りの手法
を複数の演算部からなるプロセッサに対してそのまま適
用した場合のグラフ色塗りによるレジスタ割り付け)に
よって生成される目的プログラムの実行性能以上の実行
性能を有する目的プログラムを生成することができると
いう効果がある。
As a result of the above, register allocation using a simple graph coloring method (if the compiler's graph coloring method for a processor consisting of a single operation unit is applied as is to a processor consisting of multiple operation units) This method has the effect that it is possible to generate a target program having execution performance higher than that of the target program generated by register allocation using graph coloring.

【図面の簡単な説明】[Brief explanation of the drawing]

【図1】本発明の一実施例の構成を示すブロック図であ
る。
FIG. 1 is a block diagram showing the configuration of an embodiment of the present invention.

【図2】図1中のソースプログラム解釈部により生成さ
れる中間コード列の一例を示す図である。
FIG. 2 is a diagram showing an example of an intermediate code string generated by a source program interpreter in FIG. 1;

【図3】図1中のグラフ作成手段により作成されるグラ
フの一例を示す図である。
FIG. 3 is a diagram showing an example of a graph created by the graph creation means in FIG. 1;

【符号の説明】[Explanation of symbols]

1  ソースプログラム 2  コンパイラ 3  目的プログラム 4  レジスタ割り付け処理部 5  中間コード列 6  グラフ 21  ソースプログラム解釈部 22  最適化部 23  直列アセンブリ命令列生成部 24  並列アセンブリ命令列生成部 25  目的プログラム出力部 41  データコンフリクト解析手段 42  グラフ作成手段 43  グラフ色塗り手段 44  レジスタ割り付け手段 51〜53  区間 61〜63  ノード 64〜66  辺 1 Source program 2 Compiler 3. Purpose program 4 Register allocation processing section 5 Intermediate code string 6 Graph 21 Source program interpretation section 22 Optimization section 23 Serial assembly instruction sequence generator 24 Parallel assembly instruction sequence generator 25 Target program output section 41 Data conflict analysis means 42 Graph creation means 43 Graph coloring means 44 Register allocation means 51-53 section 61-63 Node 64-66 sides

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】  並列に動作する複数の演算部を持ち各
演算部で実行される命令が目的プログラムの生成時点で
確定していることを前提とするプロセッサに対する目的
プログラムの生成過程で中間コード列に対してグラフ色
塗りの手法を用いてレジスタ割り付けの最適化を行うコ
ンパイラにおいて、中間コード列中の「変数が有効なデ
ータを保持している区間」に関して重複の有無および同
一のレジスタを割り付けることにより命令の並列化を損
なう可能性を判断し、重複の有無および並列化を損なう
可能性の高さに応じて評価値を算出するデータコンフリ
クト解析手段と、このデータコンフリクト解析手段によ
る解析に基づいて「変数が有効なデータを保持している
区間」に対応するノードを辺で結びその辺に評価値を付
加してグラフを作成するグラフ作成手段と、このグラフ
作成手段により辺で結ばれたノードに利用可能なレジス
タ数に応じた数の別の色を割り当てるグラフ色塗り手段
と、このグラフ色塗り手段により同一の色が割り当てら
れたノードに対応する変数に同一のレジスタを割り付け
るレジスタ割り付け手段とを有することを特徴とするグ
ラフ色塗りによるレジスタ割り付け最適化方式。
Claim 1: An intermediate code string is generated in the process of generating a target program for a processor that has multiple calculation units operating in parallel and assumes that the instructions executed by each calculation unit are determined at the time of generation of the target program. In a compiler that optimizes register allocation using a graph coloring method, it is possible to determine whether or not there are duplicates and to allocate the same registers for "intervals in which variables hold valid data" in intermediate code strings. A data conflict analysis means that determines the possibility of impairing parallelization of instructions and calculates an evaluation value according to the presence or absence of duplication and the high possibility of impairing parallelization; A graph creation means that creates a graph by connecting nodes corresponding to "intervals in which variables hold valid data" with edges and adding evaluation values to the edges, and nodes connected by edges by this graph creation means. a graph coloring means for allocating a number of different colors according to the number of available registers; and a register allocation means for allocating the same register to variables corresponding to nodes to which the same color is allocated by the graph coloring means. A register allocation optimization method using graph coloring.
JP1599691A 1991-01-14 1991-01-14 System for optimizing register allocation by graph painting Pending JPH04241630A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP1599691A JPH04241630A (en) 1991-01-14 1991-01-14 System for optimizing register allocation by graph painting

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP1599691A JPH04241630A (en) 1991-01-14 1991-01-14 System for optimizing register allocation by graph painting

Publications (1)

Publication Number Publication Date
JPH04241630A true JPH04241630A (en) 1992-08-28

Family

ID=11904258

Family Applications (1)

Application Number Title Priority Date Filing Date
JP1599691A Pending JPH04241630A (en) 1991-01-14 1991-01-14 System for optimizing register allocation by graph painting

Country Status (1)

Country Link
JP (1) JPH04241630A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6317876B1 (en) * 1999-06-08 2001-11-13 Hewlett-Packard Company Method and apparatus for determining a maximum number of live registers

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6317876B1 (en) * 1999-06-08 2001-11-13 Hewlett-Packard Company Method and apparatus for determining a maximum number of live registers
US6609249B2 (en) 1999-06-08 2003-08-19 Hewlett-Packard Development Company, L.P. Determining maximum number of live registers by recording relevant events of the execution of a computer program

Similar Documents

Publication Publication Date Title
KR101360512B1 (en) Register allocation with simd architecture using write masks
JP2004220583A (en) Method and system for executing global processor resource assignment in assembler
CN109460237A (en) The Compilation Method and device of code
JP2002091777A (en) Compiler and register assigning method therefor
JP2002366366A (en) Compiling method, code generation method, stack register using method, compiler, program for realizing them, and storage medium
JPH07110800A (en) Optimized parallel compiling device and optimized parallel compiling method
Zhuang et al. Resolving register bank conflicts for a network processor
JPH04241630A (en) System for optimizing register allocation by graph painting
JP2000353097A (en) Method and device for generating low density interference graph
US6139200A (en) Register resource allocation feedback
JPH04307624A (en) Loop optimization system
JP3028821B2 (en) Parallel compilation method
JPS6182243A (en) Object program generating method
JPH06214802A (en) Register allotment system
JPH047748A (en) Automatic array element assignment processing system based on reference order
JP3004340B2 (en) Program optimization device
JP2003271392A (en) Register allocation method
JPH02105224A (en) Data allocation system in compiler
JPH03242731A (en) Compile processing system
JPH0512033A (en) Parallel compiling system
JPH06324882A (en) Compiler device
JPH0373026A (en) Compile system
JPH07210544A (en) Generating method for target program containing vector instruction
JPS63163636A (en) Executing system for parallel processing
JPH08221276A (en) Compiler