JP2002312179A - Method for determining number of register to be allocated - Google Patents

Method for determining number of register to be allocated

Info

Publication number
JP2002312179A
JP2002312179A JP2001119021A JP2001119021A JP2002312179A JP 2002312179 A JP2002312179 A JP 2002312179A JP 2001119021 A JP2001119021 A JP 2001119021A JP 2001119021 A JP2001119021 A JP 2001119021A JP 2002312179 A JP2002312179 A JP 2002312179A
Authority
JP
Japan
Prior art keywords
registers
register
node
allocated
program
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
JP2001119021A
Other languages
Japanese (ja)
Inventor
Tomoya Ota
智也 太田
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.)
Hitachi Ltd
Original Assignee
Hitachi Ltd
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 Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP2001119021A priority Critical patent/JP2002312179A/en
Publication of JP2002312179A publication Critical patent/JP2002312179A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PROBLEM TO BE SOLVED: To effectively use registers left over, when an end function in a function call is executed in an architecture having a register stack. SOLUTION: After conventional register allocation is executed, the calling relation for functions and the number of registers required are examined, and when there are unused registers, these registers are reallocated within a range which do not cause register shortage in the execution of the other functions.

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は最適化コンパイラに
おけるレジスタ割り当ての適用方法に関し、特に、コン
パイラにおける他の最適化処理の適用向上を目的とした
レジスタ割り当て数の決定方法に関するものである。
The present invention relates to a method of applying register allocation in an optimizing compiler, and more particularly to a method of determining the number of register allocations for improving the application of other optimizing processes in a compiler.

【0002】[0002]

【従来の技術】近年の多くのコンピュータアーキテクチ
ャは、大量のレジスタを装備しているものがある。ま
た、そのうちのいくつかのアーキテクチャでは、レジス
タをスタックとして利用するレジスタスタックを備えて
いる。インテル社製のプロセッサでは、一部のレジスタ
に対してレジスタスタックを備えている。このレジスタ
スタックの構成は、 「Intel、IA−64 Application Dev
eloper's Architecutre Guide、1999」の4.1節に記載さ
れており、その部分を参照して、本明細書の一部とす
る。
2. Description of the Related Art Many modern computer architectures are equipped with a large number of registers. Some of the architectures have a register stack that uses a register as a stack. Intel processors have a register stack for some registers. The structure of this register stack is described in “Intel, IA-64 Application Dev.
eloper's Architecutre Guide, 1999, section 4.1, which is hereby incorporated by reference.

【0003】コンパイラのレジスタ割り当て技術は、主
に、レジスタスタック機能を備えないアーキテクチャを
対象に発展してきた。レジスタ割り当て手法は、大きく
2つに分類できる。その一つが、プログラムのある決ま
った範囲、例えば、手続きやループ等に対して、できる
だけ少ない数のレジスタを割り当てることを目的とした
手法(手法A)である。この様な手法は、「中田育男、コ
ンパイラの構成と最適化、朝倉書店、1999」の12.5節で
論じられている。その部分を参照して本明細の一部とす
る。これらの手法では、レジスタ割り付け単位に対して
効率のよい割り付けを行なえるが、必ずしもプログラム
全体などより大きな単位で最適である保証はない。ま
た、レジスタ割り付け対象部分間でのレジスタ割り付け
情報の受け渡しがないため、プログラムを実行するアー
キテクチャで利用できるレジスタを最大に利用すること
難しい。
The compiler's register allocation technique has been developed mainly for architectures that do not have a register stack function. Register allocation techniques can be broadly classified into two types. One of them is a method (method A) aimed at allocating as few registers as possible to a certain fixed range of a program, for example, a procedure or a loop. Such a method is discussed in Section 12.5 of "Ikuo Nakada, Compiler Configuration and Optimization, Asakura Shoten, 1999". This part is incorporated herein by reference. In these methods, efficient allocation can be performed for the register allocation unit, but there is no guarantee that the optimization is performed in a larger unit such as the entire program. Further, since there is no transfer of register allocation information between register allocation target portions, it is difficult to maximize the use of registers that can be used in an architecture for executing a program.

【0004】一方で、「Vatsa Santhanam他、Register
allocation across procedure andmodule boundarie
s.、SIGPLAN90 」などでは、レジスタ割り当て前に手続
き間解析を行ない、その情報を元に、手続きを越えた大
きな単位でレジスタ割り当てを行なう手法(手法B)が提
案されている。この方法では、プログラム全体での変数
の情報を収集した上でレジスタ割り付けを行なうため、
各手続きに対して、効率善くレジスタを割り付けること
が可能となる。
On the other hand, "Vatsa Santhanam et al., Register
allocation across procedure andmodule boundarie
s., SIGPLAN90 ”, etc., proposes a method (method B) of performing inter-procedure analysis before register allocation and performing register allocation in large units beyond procedures based on the information. In this method, registers are allocated after collecting information on variables in the entire program.
Registers can be efficiently allocated to each procedure.

【0005】コンパイラで利用されるプログラム解析情
報の一つとして、関数あるいは手続き間の呼び出し関係
の情報がある。そして、この情報の表現技術の一つとし
て、コールグラフがある。コールグラフとは、各関数を
グラフのノードとし、関数の呼び出し元から、呼び出し
先へエッジをつなげたグラフ構造である。コールグラフ
に関しては、「D.F.Jerding et. al、Visualizing inte
ractions in programexecutins.、ICSE97」で詳しく述
べられている。その部分を参照して本明細の一部とす
る。
[0005] As one of the program analysis information used by the compiler, there is information on a call relationship between functions or procedures. One of the techniques for expressing this information is a call graph. The call graph is a graph structure in which each function is a node of the graph and edges are connected from the function caller to the callee. For the call graph, see "DFJerding et. Al, Visualizing inte
ractions in programexecutins., ICSE97 ". This part is incorporated herein by reference.

【0006】[0006]

【発明が解決しようとする課題】従来のレジスタ割り付
け手法Aでは、プログラム全体のレジスタ割り当て終了
時点で、物理レジスタが余ることがある。しかし、プロ
グラムに対しより多くのレジスタを割り当てた方が、他
の最適化の適用を促進し、プログラムの実行性能が向上
する可能性がある。
In the conventional register allocating method A, physical registers may be left at the end of register allocation of the entire program. However, allocating more registers to the program may facilitate the application of other optimizations and improve program execution performance.

【0007】また、あらかじめ必要レジスタ数に加えて
最適化用のレジスタを割り当ててしまう方法を取ると、
残りのプログラム部分に対するレジスタ割り当て時に、
レジスタ不足が生じ、レジスタの内容の退避・復帰コー
ドが作成され、却ってプログラムの実行性能を悪化させ
る場合が発生する。
Further, if a method of allocating a register for optimization in addition to the required number of registers in advance is adopted,
When allocating registers for the rest of the program,
A register shortage occurs, and a save / restore code for the register contents is created, which may worsen the execution performance of the program.

【0008】従来のレジスタ割り付け手法Bでは、レジ
スタ割り付けに先立ち、プログラムの各変数のライブ情
報などを手続き間に跨って行なう必要があり、解析にか
なりの時間を要する。
In the conventional register allocation method B, prior to register allocation, it is necessary to perform live information of each variable of a program across procedures, which requires a considerable amount of time for analysis.

【0009】本発明の目的は、プログラム全体で必要と
なるレジスタ数が全レジスタ数より少なくなる場合に、
余りのレジスタをプログラムの各部に再割り当てするこ
とで、手続き間の解析に要する時間を低くおさえなが
ら、レジスタを有効利用する方法を提供することであ
る。
An object of the present invention is to solve the problem that the number of registers required for the entire program is smaller than the total number of registers.
An object of the present invention is to provide a method of effectively using registers while reallocating surplus registers to respective parts of a program while reducing the time required for analysis between procedures.

【0010】[0010]

【課題を解決するための手段】上記の目的は、従来のレ
ジスタ割り付け処理の適用後に、利用可能レジスタに余
りがある場合に、それらのレジスタの再割り当て処理を
行なうことで達成される。 (1) プログラムの処理単位に対してレジスタ割り当てを
行なう。 (2) 未割り当てのレジスタが残っている場合のみ、以下
の処理を行なう。 (3) プログラム中の手続きの依存関係を表すコールグラ
フを作成する。 (4) 未割り当てレジスタを、再割り当てする。 (5) 必要ならば、処理(4)を繰り返す。
The above object is achieved by performing a reassignment process of available registers after the application of the conventional register allocation process, when there are remaining available registers. (1) Allocate registers to the processing units of the program. (2) The following processing is performed only when unassigned registers remain. (3) Create a call graph representing the dependencies of the procedures in the program. (4) Reassign unassigned registers. (5) If necessary, repeat the process (4).

【0011】この処理により、未割り当てのレジスタ数
を最小にできるため、他の最適化処理の適用を促進さ
せ、プログラムの高速な実行が可能となる。
By this processing, the number of unallocated registers can be minimized, so that application of other optimization processing is promoted, and high-speed execution of the program becomes possible.

【0012】[0012]

【発明の実施の形態】以下、本発明の1実施例を図面を
用いて説明する。
DESCRIPTION OF THE PREFERRED EMBODIMENTS One embodiment of the present invention will be described below with reference to the drawings.

【0013】なお、以下の説明により、本発明の適用が
限定されるものではない。
The following description does not limit the application of the present invention.

【0014】図1は、本発明の適用対象である計算機シ
ステムを表す概略構成図である。本発明であるレジスタ
割り当て数の決定方法は、最適化コンパイラに実装さ
れ、主記憶102もしくはディスク装置103に格納され、CP
U101で実行される。
FIG. 1 is a schematic configuration diagram showing a computer system to which the present invention is applied. The method for determining the number of register allocations according to the present invention is implemented in an optimizing compiler, stored in the main storage 102 or the disk device 103, and
Executed in U101.

【0015】図2は、本発明が実装される最適化コンパ
イラの構成を示している。プログラム201は、最適化コ
ンパイラ202へ入力され、例えば図1で示される計算機
で実行されるオブジェクトコード206に変換される。最
適化コンパイラ202は、入力されたプログラム201に対し
て、構文解析203などの前処理を行ない、中間語204を生
成する。その後、中間語204に対して、最適化処理205を
行ない、オブジェクトコード206を生成する。
FIG. 2 shows a configuration of an optimizing compiler in which the present invention is implemented. The program 201 is input to the optimizing compiler 202 and converted into, for example, an object code 206 executed by the computer shown in FIG. The optimizing compiler 202 performs preprocessing such as syntax analysis 203 on the input program 201, and generates an intermediate language 204. After that, an optimization process 205 is performed on the intermediate language 204 to generate an object code 206.

【0016】図3は、最適化処理部205内のレジスタ割
り当て部301の構成を示したものである。
FIG. 3 shows the configuration of the register allocator 301 in the optimization processor 205.

【0017】レジスタ初期割り当て部302では、入力プ
ログラム305をレジスタ割り当て単位にプログラム片に
区切り、そのプログラム片に対してレジスタ割り当てを
行なう。これにより、各関数での最小必要レジスタ数等
のレジスタ割り当て情報306を求める。
The register initial allocation unit 302 divides the input program 305 into program pieces in units of register allocation, and allocates registers to the program pieces. As a result, register allocation information 306 such as the minimum number of required registers for each function is obtained.

【0018】コールグラフ作成部303では、プログラム
全体に対する関数の呼び出し関係を表すコールグラフ30
7を作成する。
The call graph creation unit 303 includes a call graph 30 representing a function calling relationship with respect to the entire program.
Create 7.

【0019】レジスタ再割り当て部304では、レジスタ
割り当て情報306、コールグラフ307を用いて、未使用レ
ジスタを適当な関数に割り当てる。なお、処理302、303
で行なう各処理は、すべて既存の技術をそのまま利用す
る。
The register reallocation unit 304 allocates unused registers to appropriate functions using the register allocation information 306 and the call graph 307. Processing 302, 303
All the processes performed in the above use the existing technology as it is.

【0020】以下では、本発明における特徴的な処理で
ある、レジスタ再割り当て部304について説明する。
In the following, a description will be given of the register reallocation unit 304, which is a characteristic process of the present invention.

【0021】図4は、図3におけるレジスタ再割り当て
部304の動作をフローチャートを用いて表したものであ
る。レジスタ再割り当て部への入力は図3における、レ
ジスタ割り当て情報306およびコールグラフ307である。
以下の説明では、コールグラフのノードのうち呼び出し
元関数のノードがないノードをルートノード、呼び出し
先関数のノードがないノードをリーフノードと呼ぶ。
FIG. 4 is a flowchart showing the operation of the register reassignment unit 304 in FIG. The inputs to the register reassignment unit are the register assignment information 306 and the call graph 307 in FIG.
In the following description, a node having no caller function node among the nodes of the call graph is called a root node, and a node having no callee function node is called a leaf node.

【0022】処理401では、末尾ノード集合とその経路
での未使用レジスタ数の合計を求める。なお、末尾ノー
ドとは、リーフノードであり、かつ、ルートノードから
そのリーフノードまでに循環路がないノードのことであ
る。
In the process 401, the sum of the last node set and the number of unused registers on the route is obtained. Note that the end node is a leaf node that has no circulation path from the root node to the leaf node.

【0023】処理402では、処理401で求めた未使用レジ
スタを割り当てる候補となる関数の集合である再割り当
て対象関数集合を求める。
In step 402, a set of functions to be reallocated, which is a set of functions that are candidates for allocating unused registers obtained in step 401, is obtained.

【0024】処理403では、処理401で求めた未使用レジ
スタを処理402で求めた候補関数に再割り当てを行な
い、新たなレジスタ割り当て数を求める。
In the process 403, the unused registers obtained in the process 401 are reassigned to the candidate functions obtained in the process 402, and a new register allocation number is obtained.

【0025】処理404では、上記の処理を、レジスタの
割り当て数が変化しなくなるまで繰り返す。ただし、こ
の繰り返しは、コンパイル時間などの要因によっても打
ち切ることができる。
In the process 404, the above process is repeated until the number of allocated registers no longer changes. However, this repetition can be terminated depending on factors such as the compile time.

【0026】図5は、処理401の処理の1例を示すフロー
チャートである。
FIG. 5 is a flowchart showing an example of the process 401.

【0027】処理501により、各リーフノードに対し
て、処理502から処理505の処理を適用する。
By the process 501, the processes from the process 502 to the process 505 are applied to each leaf node.

【0028】処理502では、ルートノードから、処理対
象のリーフノードに至る経路に循環路がある場合、その
経路を処理対象からはずしている。これは、コールグラ
フに循環路が現れた場合、リーフノードの関数の実行時
における必要レジスタ数を特定できないためである。
In the process 502, if there is a circulation route on the route from the root node to the leaf node to be processed, the route is excluded from the process target. This is because, when a circulation path appears in the call graph, the number of required registers at the time of executing the function of the leaf node cannot be specified.

【0029】処理503では、リーフノード実行時におけ
る未使用レジスタ数を求める。これは、ルートノードか
らリーフノードまでの経路上のノード(関数)の必要レジ
スタ数の合計を、全レジスタ数から引くことで求めるこ
とができる。ただし、0以下の場合は、0とする。
In step 503, the number of unused registers at the time of executing the leaf node is obtained. This can be obtained by subtracting the total number of required registers of the nodes (functions) on the path from the root node to the leaf node from the total number of registers. However, if it is 0 or less, it is set to 0.

【0030】処理504では、未使用レジスタが無い場合
は、その経路を処理の対象からはずしている。
In the process 504, when there is no unused register, the route is excluded from the target of the process.

【0031】処理505では、未使用レジスタがある場合
に、その経路を覚えておくために、処理中のリーフノー
ドを、末尾ノード集合に登録する。処理506、処理507で
は、そのノードがレジスタ再割り当て対象か否かを判別
するために、処理507であらかじめすべてのノードに印
をつけておき、条件を満たさないものを、処理506で除
いている。
In the process 505, if there is an unused register, the leaf node being processed is registered in the end node set in order to remember the route. In Steps 506 and 507, all nodes are marked in advance in Step 507 to determine whether the node is a target of register reassignment, and those that do not satisfy the conditions are excluded in Step 506. .

【0032】図6は、処理402の処理の1例を示すフロー
チャートである。処理601により、各関数について、処
理602、処理603が適用される。処理602では、処理対象
の関数に対応するすべてのノードに、処理505でつけた
印があるか確認する。もし、1つでも印のないノードが
あった場合、その関数は、再割り当て対象からはずすた
め、処理603で、その関数に対応するすべてのノードに
おける印を取り除く。また、処理604、605で、印を取り
除くノードが末尾ノード集合に含まれる場合は、そのノ
ードを集合から取り除く。もし、すべての対応するノー
ドに印があった場合は、処理606で、再割り当て対象関
数集合に登録する。
FIG. 6 is a flowchart showing an example of the processing of the processing 402. By the process 601, the processes 602 and 603 are applied to each function. In the process 602, it is checked whether or not all the nodes corresponding to the function to be processed have the mark added in the process 505. If there is at least one node without a mark, the function is removed from the re-allocation target, and in step 603, the marks on all nodes corresponding to the function are removed. Also, in the processes 604 and 605, if the node whose mark is to be removed is included in the last node set, the node is removed from the set. If all the corresponding nodes are marked, in process 606, they are registered in the reassignment target function set.

【0033】図7は、処理403の処理の1例を示すフロー
チャートである。
FIG. 7 is a flowchart showing an example of the process 403.

【0034】処理701、702では、すべての末尾ノードに
ついて、ルートノードからそのノードまでの経路上にあ
る再割り当て対象ノードに対して、その経路に対応する
未使用レジスタを、割り振る。なお、ここでは、未使用
レジスタを再割り当て対象ノードに均等に割り振るが、
プロファイル情報等が利用でき、関数に対して実行頻度
等で優先度をつけることが可能な場合は、その優先度の
割合にしたがって割り振り数を設定することも可能であ
る。
In the processes 701 and 702, an unused register corresponding to the route is allocated to the reassignment target node on the route from the root node to the last node. Note that, here, unused registers are evenly allocated to the reassignment target nodes.
When profile information and the like can be used and a priority can be assigned to a function by an execution frequency or the like, the number of allocations can be set according to the ratio of the priority.

【0035】処理703、704では、すべての再割り当て候
補関数に対して、新たなレジスタ割当数を求める。
In steps 703 and 704, new register allocation numbers are obtained for all the reallocation candidate functions.

【0036】もし、対応するコールグラフのノードが複
数ある場合は、本実施例では、それそれのノードの割り
振り値の最小値を選択する。これにより、複数の呼び出
し点がある関数に対する割り当てに対しても、割り当て
数が全レジスタ数を越えることを防ぐことが可能とな
る。また、本処理は、コールグラフの特定の経路を優先
させたい場合は、その経路に含まれるノードの値を選択
することなどが可能である。最後に、割り振り値と、現
在のレジスタの割り当て数を足したものを新たなレジス
タ割り当て数とする。
If there are a plurality of nodes in the corresponding call graph, in this embodiment, the minimum value of the allocation value of each node is selected. This makes it possible to prevent the number of assignments from exceeding the total number of registers even for an assignment to a function having a plurality of call points. Further, in the present processing, when priority is given to a specific route of the call graph, it is possible to select a value of a node included in the route. Finally, the sum of the allocation value and the current number of allocated registers is set as a new register allocated number.

【0037】以上のレジスタ割り当て数決定方法を簡単
な例題に適用して、その機能と効果を確認する。
The above-described method for determining the number of registers to be assigned is applied to a simple example, and its functions and effects are confirmed.

【0038】図8に示す関数をもつプログラムを例とす
る。列801は、関数の名称である。ここでは、AからHま
での8個の関数が定義されているとする。列802は、関数
が呼び出す関数の集合である。例えば、関数A は、関数
B、D、F、G を呼び出す。これらのプログラムに対し
て、処理302により、レジスタ割り当てを行なった結
果、各関数に対するレジスタ割当数が列803に示す数と
なるとする。なお、このプログラムが実行される計算機
にはレジスタが100個あるものとする。
A program having a function shown in FIG. 8 is taken as an example. Column 801 is the name of the function. Here, it is assumed that eight functions from A to H are defined. Column 802 is a set of functions called by the function. For example, function A is
Call B, D, F, G. It is assumed that as a result of register allocation for these programs by the process 302, the number of register allocations for each function becomes the number shown in the column 803. It is assumed that the computer on which this program is executed has 100 registers.

【0039】処理303により作成される、このプログラ
ムに対するコールグラフを図9に示す。このコールグラ
フでは、ルートノードは、901、リーフノードは、903、
905、908、912である。
FIG. 9 shows a call graph for this program created by the process 303. In this call graph, the root node is 901, the leaf node is 903,
905, 908 and 912.

【0040】以下に、レジスタ再割り当て処理部305の
処理例を示す。まず、処理401が適用される。そのた
め、各リーフノードに対して、処理502から処理505が適
用される。リーフノード903の処理では、ルートノード9
01との経路上に循環路がなく、また、ノード903の関数
の実行時に必要なレジスタ数は85(50+30+5)であるた
め、未使用レジスタが15個ある。そのため、ノード903
は、末尾ノード集合に登録さる。リーフノード(911の処
理では、経路上にノード909(関数G)の呼び出しの循環路
があるため、経路上のすべてのノードから再割り当て対
象関数の印を取り除く。同様にして、他のリーフノード
に対して適用した結果を図10に示す。なお、図中のノー
ドの右肩にある*印は、再割り当て対象関数のマークを
示し、括弧の中の数字はそのリーフノードに至る経路で
の未使用レジスタ数を示している。また、この時点での
末尾ノード集合には、ノード1003、1005、1008が登録さ
れている。
The following is an example of processing performed by the register reallocation processing unit 305. First, the process 401 is applied. Therefore, the processes 502 to 505 are applied to each leaf node. In the processing of leaf node 903, root node 9
Since there is no circulation path on the path to 01 and the number of registers required when executing the function of the node 903 is 85 (50 + 30 + 5), there are 15 unused registers. Therefore, node 903
Is registered in the tail node set. In the processing of the leaf node (911, since the path of the call of the node 909 (function G) is on the path, the marks of the functions to be reassigned are removed from all the nodes on the path. Is shown in Fig. 10. Note that the asterisk (*) at the right shoulder of the node in the figure indicates the mark of the function to be reassigned, and the number in parentheses indicates the path to the leaf node. The number of unused registers is shown, and nodes 1003, 1005, and 1008 are registered in the last node set at this time.

【0041】次に、図10で示される結果に対して、図
6で示される処理が適用される。関数Dに対するノード
は、ノード1004と1011の2個所有り、ノード911は印を持
たないため、1004の印も除かれる。関数Cでは、対応す
るノード1003、1008に共に印がついているので、再割り
当て対象関数集合に加えられる。同様に、他の関数に対
する処理を行なうと、図11の結果が得られる。また、
作成される再割り当て対象関数集合には、関数B、C、F
が登録される。
Next, the processing shown in FIG. 6 is applied to the result shown in FIG. The node for the function D has two nodes 1004 and 1011, and since the node 911 has no mark, the mark of 1004 is also removed. In the function C, since the corresponding nodes 1003 and 1008 are both marked, they are added to the reassignment target function set. Similarly, when processing for another function is performed, the result of FIG. 11 is obtained. Also,
Functions B, C, F
Is registered.

【0042】次に、図11の結果に対して、図7で示さ
れる処理が適用される。図5で示した処理により、末尾
ノード集合として、ノード1103、1108が求められてい
る。ノード1103の処理では、未使用レジスタが15個あ
り、経路上の再割り当てマークがついているのは、ノー
ド1102、1103なので、ノード1102に7個、ノード1103に8
が割り振られる。同様にノード1108の処理では、ノード
1106に3、ノード1107に3、ノード1108に4が割り振られ
る。次に、処理703、704により、再割り当て候補関数の
最終的な再割り当て値を求める。処理704より、関数Bの
最終的な割り振り値は、最小値の3となり、新たな割当
数は、33となる。また、関数Cに対する割当数は9、関数
fに対する割当数は8となる。
Next, the processing shown in FIG. 7 is applied to the result shown in FIG. By the processing shown in FIG. 5, the nodes 1103 and 1108 are obtained as the end node set. In the processing of the node 1103, there are 15 unused registers, and the relocation marks on the route are the nodes 1102 and 1103, so that seven nodes 1102 and eight nodes 1103
Is allocated. Similarly, in the processing of the node 1108, the node 1108
3 is allocated to 1106, 3 is allocated to the node 1107, and 4 is allocated to the node 1108. Next, in steps 703 and 704, a final reassignment value of the reassignment candidate function is obtained. From the process 704, the final allocation value of the function B is the minimum value of 3, and the new allocation number is 33. In addition, the number assigned to function C is 9,
The number assigned to f is 8.

【0043】以上で、処理401から処理403が終了する。
処理404によりこの処理を繰り返すと、2度目は割当て数
に変化が起らないので、これで処理が終了する。
Thus, the process 401 to the process 403 are completed.
When this process is repeated in process 404, no change occurs in the number of assignments for the second time, and thus the process ends.

【0044】図12は、この例題に対する最終的結果を
示している。列1203は、本処理の適用により得られるレ
ジスタの割当数を示している。この結果は、適用前に使
用レジスタ数が全レジスタ数より少なかった経路につい
てはそれを保障し、また、使用レジスタ数が全レジスタ
数より多かった経路についても、処理前の必要最小値を
保証している。
FIG. 12 shows the final result for this example. A column 1203 indicates the number of allocated registers obtained by applying this processing. This result guarantees the path where the number of registers used is less than the total number of registers before application, and also guarantees the minimum required value before processing for the path where the number of registers used is larger than the total number of registers. ing.

【0045】[0045]

【発明の効果】本発明によれば、従来のレジスタ割り付
け処理では、未使用となるレジスタを適当な関数に割り
当てることができき、それにより、他の最適化の適用が
促進され、より多くの最適化が適用可能となる。これに
より、計算機プログラムの実行時間を短縮できる。
According to the present invention, in the conventional register allocation process, unused registers can be allocated to appropriate functions, thereby promoting the application of other optimizations and increasing the number of functions. Optimization can be applied. Thus, the execution time of the computer program can be reduced.

【図面の簡単な説明】[Brief description of the drawings]

【図1】本発明による最適化適用方法が実行される計算
機システムの概略構成図。
FIG. 1 is a schematic configuration diagram of a computer system in which an optimization application method according to the present invention is executed.

【図2】本発明による最適化適用方法が実装される最適
化コンパイラの概略構成図。
FIG. 2 is a schematic configuration diagram of an optimizing compiler on which the optimizing application method according to the present invention is implemented.

【図3】本発明のレジスタ割り付け数決定方法の概観を
与える概略構成図。
FIG. 3 is a schematic configuration diagram giving an overview of a register allocation number determination method according to the present invention.

【図4】レジスタ再割り当て処理部の動作を表すフロー
チャート。
FIG. 4 is a flowchart illustrating an operation of a register reallocation processing unit.

【図5】末尾ノード集合を求めるフローチャート。FIG. 5 is a flowchart for obtaining a tail node set.

【図6】再割り当て候補関数集合を求めるフローチャー
ト。
FIG. 6 is a flowchart for obtaining a reassignment candidate function set.

【図7】再割当数決定処理のフローチャート。FIG. 7 is a flowchart of a reassignment number determination process.

【図8】具体例として取り上げるプログラムの概要図。FIG. 8 is a schematic diagram of a program taken as a specific example.

【図9】図8で取り上げたプログラムに対するコールグ
ラフを示す図。
FIG. 9 is a diagram showing a call graph for the program taken up in FIG. 8;

【図10】図9のコールグラフに対して図5の処理を適
用したコールグラフを示す図。
FIG. 10 is a diagram showing a call graph obtained by applying the processing of FIG. 5 to the call graph of FIG. 9;

【図11】図10のコールグラフに対して図6の処理を
適用したコールグラフを示す図。
11 is a diagram showing a call graph obtained by applying the processing of FIG. 6 to the call graph of FIG.

【図12】図11のコールグラフに対して図7の処理を
適用した結果得られる割り当て数を示す図。
12 is a diagram showing the number of assignments obtained as a result of applying the processing of FIG. 7 to the call graph of FIG. 11;

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

101…CPU、102…主記憶、103…ディスク装置、201…
ソースプログラム、202…最適化コンパイラ、206…オブ
ジェクト。
101 CPU, 102 main memory, 103 disk device, 201
Source program, 202 ... optimizing compiler, 206 ... object.

Claims (5)

【特許請求の範囲】[Claims] 【請求項1】 最適化コンパイラにおいてレジスタ割り
当て数を決定する処理方法であって、 a) 各部分プログラムに対して、必要レジスタ数が最小
になるようにレジスタを割り当てるステップと b) コールグラフを作成するステップと c) コールグラフのある経路で未使用レジスタがある場
合に、未使用レジスタの再割り当てを行なうステップ、
からなるレジスタ割り当て数の決定方法。
1. A processing method for determining the number of registers to be allocated in an optimizing compiler, comprising the steps of: a) allocating registers to each partial program so as to minimize the required number of registers; and b) creating a call graph. And c) reallocating unused registers when there is an unused register on a certain path in the call graph;
Method for determining the number of allocated registers.
【請求項2】 請求項1のレジスタ割り当て数の決定方
法であって、ステップc)での未使用レジスタの管理に、
レジスタの集合を利用するレジスタ割り当て数の決定方
法。
2. The method for determining the number of allocated registers according to claim 1, wherein:
A method for determining the number of allocated registers using a set of registers.
【請求項3】 プログラムの部分に対して利用可能なレ
ジスタを制限できる機能を有するアーキテクチャ向けの
最適化コンパイラにおいてレジスタ割り当て数を決定す
る処理方法であって、請求項目1の各ステップからなる
レジスタ割り当て数の決定方法であって、レジスタ数の
管理にプログラム部分が利用可能なレジスタ数を利用す
るレジスタ割り当て数の決定方法。
3. A processing method for deciding the number of register allocations in an optimizing compiler for an architecture having a function capable of restricting registers available for a part of a program, the register allocation comprising each step of claim 1 A method of determining a number, wherein the number of registers is determined by using the number of registers available to a program part for managing the number of registers.
【請求項4】 請求項1のレジスタ割り当て数の決定方
法を利用して処理を行なうコンパイラ。
4. A compiler that performs processing using the method for determining the number of registers to be allocated according to claim 1.
【請求項5】 請求項1のレジスタ割り当て数の決定方
法の実装を格納したメディア。
5. A medium storing the implementation of the method for determining the number of registers allocated according to claim 1.
JP2001119021A 2001-04-18 2001-04-18 Method for determining number of register to be allocated Pending JP2002312179A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2001119021A JP2002312179A (en) 2001-04-18 2001-04-18 Method for determining number of register to be allocated

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2001119021A JP2002312179A (en) 2001-04-18 2001-04-18 Method for determining number of register to be allocated

Publications (1)

Publication Number Publication Date
JP2002312179A true JP2002312179A (en) 2002-10-25

Family

ID=18969308

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2001119021A Pending JP2002312179A (en) 2001-04-18 2001-04-18 Method for determining number of register to be allocated

Country Status (1)

Country Link
JP (1) JP2002312179A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10970056B2 (en) 2019-02-25 2021-04-06 Fujitsu Limited Compiler and information processing method for deleting spill instructions

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10970056B2 (en) 2019-02-25 2021-04-06 Fujitsu Limited Compiler and information processing method for deleting spill instructions

Similar Documents

Publication Publication Date Title
US5761514A (en) Register allocation method and apparatus for truncating runaway lifetimes of program variables in a computer system
US6725448B1 (en) System to optimally create parallel processes and recording medium
EP0428084B1 (en) Method and apparatus for compiling computer programs with interprocedural register allocation
CN111427681A (en) Real-time task matching scheduling system and method based on resource monitoring in edge computing
US8161467B2 (en) Compiling method and storage medium therefor
US20080134151A1 (en) Compiler register allocation and compilation
US7111287B2 (en) Global processor resource assignment in an assembler
US5946491A (en) Register allocation method and apparatus for gernerating spill code as a function of register pressure compared to dual thresholds
US5774730A (en) Method and apparatus for improving colorability of constrained nodes in an interference graph within a computer system
US6925639B2 (en) Method and system for register allocation
JP2008009957A (en) Compiling device
US5367696A (en) Register allocation technique in a program translating apparatus
CN108139929B (en) Task scheduling apparatus and method for scheduling a plurality of tasks
EP0947922B1 (en) Compiler
KR100846451B1 (en) Method for allocation stack in multi-threaded sensor operating systems environment
US20080140979A1 (en) Method of allocating stack in multi-threaded sensor operating system environment
JP2002312179A (en) Method for determining number of register to be allocated
JPH09293057A (en) Task allocation method in hierarchical structure type multiprocessor system
JP2003256215A (en) Program conversion method, data processor using the same, and program
Nakaike et al. Profile-based global live-range splitting
JPH08314727A (en) Resource allocation device
JPH11175351A (en) Program converter, assembler expression method inside high level language program and recording medium
JPH06242963A (en) Register allocation system
JP2003271392A (en) Register allocation method
JPH0371233A (en) Optimum data allocating system for compiler