JP2000029716A - Register allocating method - Google Patents

Register allocating method

Info

Publication number
JP2000029716A
JP2000029716A JP10195355A JP19535598A JP2000029716A JP 2000029716 A JP2000029716 A JP 2000029716A JP 10195355 A JP10195355 A JP 10195355A JP 19535598 A JP19535598 A JP 19535598A JP 2000029716 A JP2000029716 A JP 2000029716A
Authority
JP
Japan
Prior art keywords
variable
register
variables
reference point
information table
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
JP10195355A
Other languages
Japanese (ja)
Inventor
Hiroyuki Hashimoto
博幸 橋本
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 JP10195355A priority Critical patent/JP2000029716A/en
Publication of JP2000029716A publication Critical patent/JP2000029716A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PROBLEM TO BE SOLVED: To shorten compilation times by decreasing the number of variables to be allocated by substituting variable which are defined at the same time with another certain variable, regarding the substitutive variable as an object of register allocation. SOLUTION: In a compiler 10, a register allocation part 203 inputs an intermediate code 40 for the generation of a variable information table and generates the variable information table for storing reference point information, etc., on respective variables. To replace variable which are defined at a definition points at the same time with another certain variable, a substitution table is generated. When registers are searched, the variable information table allocates the registers to the generated variables, while checking the reference point information, etc. When a reference point is converted, a variable table substitute the reference by a register for reference by a variable to which the register is allocated for the generated variable. For a variable to which no register is allocated, the reference by the variable is replaced with reference from a memory.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明はコンパイラのレジス
タ割り付け方法に関する。
The present invention relates to a compiler register allocating method.

【0002】[0002]

【従来の技術】ソースプログラムを目的コードに変換す
るコンパイラにおいて、目的コードの実行性能を向上さ
せるための最適化方式は、これまでにも数多く開発され
ており、A.V.エイホ、R.セシィ、J.D.ウルマ
ン著「コンパイラ」等で詳しく述べられている。
2. Description of the Related Art In a compiler for converting a source program into a target code, many optimization methods for improving the execution performance of the target code have been developed so far. V. Eiho, R.A. Cessy, J.M. D. This is described in detail in Ullman's "Compiler".

【0003】その中の最適化方式の1つとして、ソース
プログラム中で参照されている変数に対し、メモリへの
参照回数を削減し、限られた資源であるレジスタにデー
タを乗せたまま実行を行い、目的コードの実行時間を向
上させるための処理として、レジスタ割り付けと呼ばれ
る処理が存在する。
[0003] One of the optimization methods is to reduce the number of references to a memory for a variable referred to in a source program, and execute the program with data loaded in a register which is a limited resource. As a process for improving the execution time of the target code, there is a process called register allocation.

【0004】このレジスタ割り付けの方法として、Ch
aitin, G.J.の「Register All
ocation and Spilling via
Graph Coloring」:Proc. of
ACM SIGPLAN ’82 Compiler
Construction, 98−105(198
2)という論文で、レジスタの割り付け手法が説明され
ている。この論文の手法では、割り付け対象となる変数
がn個存在する場合に、コンパイル時間がn2だけ必要
になる。
As a method of register allocation, Ch
aitin, G .; J. "Register All
location and Spilling via
Graph Coloring ": Proc. of
ACM SIGGPLAN '82 Compiler
Construction, 98-105 (198
The paper 2) describes a register allocation method. In the method of this paper, when there are n variables to be assigned, the compilation time is required by n 2 .

【0005】[0005]

【発明が解決しようとする課題】上記従来技術で図10
に示すソースプログラムをコンパイルする場合のレジス
タ割り付け部での処理手順を図12、図13、図14を
用いて説明する。レジスタ割り付け処理では、まずソー
スプログラム上に出現する変数の変数情報テーブルを作
成した後、変数情報テーブルが生成された変数に対し割
り付けられるレジスタを探すことになる。変数情報テー
ブルの生成処理では、中間コードから文を取り出し(ス
テップ1201)、文が存在するかどうかを調べる(ス
テップ1202)。文が存在する場合は、文の中に参照
点として出現している変数の変数情報テーブルが生成さ
れているかどうかを調べる。変数情報テーブルが生成さ
れていない場合は、この時点でその変数の変数情報テー
ブルを生成する(ステップ1203)。図10では4つ
の変数(a,b,c,d)が出現しているので、図14
に示すように4つの変数情報テーブルが生成される。次
に、レジスタの探索処理を行うが、これは図12の処理
で生成された変数情報テーブルの数だけ繰り返すことに
なる(ステップ1301、1302)。このレジスタの
探索処理は、一般に変数情報テーブルなどを作成する時
間に比べ、処理時間が長くかかる。
FIG. 10 shows the above-mentioned prior art.
The processing procedure in the register allocating unit when compiling the source program shown in FIG. 1 will be described with reference to FIGS. 12, 13, and 14. In the register allocation process, first, a variable information table of variables appearing in the source program is created, and then a register to be allocated to the variable for which the variable information table has been generated is searched. In the generation process of the variable information table, a sentence is extracted from the intermediate code (step 1201), and it is checked whether or not the sentence exists (step 1202). If a statement exists, it is checked whether a variable information table of a variable appearing as a reference point in the statement has been generated. If the variable information table has not been generated, a variable information table for the variable is generated at this point (step 1203). In FIG. 10, since four variables (a, b, c, d) appear, FIG.
The four variable information tables are generated as shown in FIG. Next, register search processing is performed, which is repeated by the number of variable information tables generated in the processing of FIG. 12 (steps 1301 and 1302). This register search process generally takes longer than the time to create a variable information table or the like.

【0006】上記従来技術の課題は、図10に示すよう
な一度に複数の変数が定義される文が複数個出現した場
合に、レジスタ割り付けの対象となる変数の数が増えコ
ンパイル時間が増大してしまうことである。
[0006] The problem of the prior art is that when a plurality of statements in which a plurality of variables are defined at a time appear as shown in FIG. 10, the number of variables to be allocated to registers increases and the compilation time increases. It is to be.

【0007】本発明の目的は、複数の変数の定義をある
1つの別の変数に置き換え、割り付け対象となる変数の
数を削減することによりコンパイル時間を削減すること
にある。
[0007] It is an object of the present invention to reduce the compile time by replacing the definitions of a plurality of variables with one other variable and reducing the number of variables to be assigned.

【0008】[0008]

【課題を解決するための手段】上記目的は、複数の変数
の定義をある別の変数の定義に置き換え、置き換えた後
の変数のみをレジスタ割り付けの対象とすることで、変
数の数を削減することにより達成することができる。
SUMMARY OF THE INVENTION An object of the present invention is to reduce the number of variables by replacing the definition of a plurality of variables with the definition of another variable and assigning only the replaced variables to registers. This can be achieved by:

【0009】[0009]

【発明の実施の形態】本発明は、コンパイラにおけるレ
ジスタ割り付け方法に関するものである。
DESCRIPTION OF THE PREFERRED EMBODIMENTS The present invention relates to a register allocating method in a compiler.

【0010】以下では、本発明の一実施例を図面を用い
て説明する。なお、これにより本発明が限定されるもの
ではない。
An embodiment of the present invention will be described below with reference to the drawings. Note that the present invention is not limited by this.

【0011】図1は、本発明のレジスタ割り付け方法の
一実施例のシステム構成図である。
FIG. 1 is a system configuration diagram of an embodiment of a register allocating method according to the present invention.

【0012】本システムは、CPU装置1、メモリ装置
2、入力装置3、表示装置4から構成されている。コン
パイラ10はCPU装置1により処理、実行される。コ
ンパイラ10は、ソースプログラム30を入力し、幾度
か中間コード40を生成しながら、最終的に目的コード
50を生成する。目的コード50は、実行20で実行さ
れ結果を表示装置4に表示したり、実行結果60に結果
を出力する。
This system comprises a CPU device 1, a memory device 2, an input device 3, and a display device 4. The compiler 10 is processed and executed by the CPU device 1. The compiler 10 inputs the source program 30 and generates the intermediate code 40 several times, and finally generates the target code 50. The purpose code 50 is executed in the execution 20 and displays the result on the display device 4 or outputs the result to the execution result 60.

【0013】図2は、コンパイラ10における処理構成
図である。
FIG. 2 is a processing configuration diagram in the compiler 10.

【0014】コンパイラ10は、中間コード生成部20
1、中間コード最適化生成部202、レジスタ割り付け
部203、目的コード生成部204からなる。中間コー
ド生成部201では、ソースプログラム30を入力し、
字句解析と構文解析を行った後中間コード40を生成す
る。中間コード最適化生成部202は、中間コード40
を入力し、いくつかの最適化を行った後中間コード40
を生成する。レジスタ割り付け部203は、中間コード
40を入力し各変数の参照をレジスタの参照またはメモ
リからの参照にした中間コード40を生成する。目的コ
ード生成部204は、中間コード40を入力しそれぞれ
のマシンで実行させるための目的コード50を生成す
る。
The compiler 10 includes an intermediate code generator 20
1. An intermediate code optimization generation unit 202, a register allocation unit 203, and a target code generation unit 204. In the intermediate code generation unit 201, the source program 30 is input,
After performing lexical analysis and syntax analysis, an intermediate code 40 is generated. The intermediate code optimization generation unit 202 outputs the intermediate code 40
And after performing some optimizations, the intermediate code 40
Generate The register allocating unit 203 receives the intermediate code 40 and generates the intermediate code 40 in which each variable is referred to as a register or a memory. The target code generation unit 204 receives the intermediate code 40 and generates a target code 50 to be executed by each machine.

【0015】図7は、変数情報テーブル700のテーブ
ル構造を示したものである。
FIG. 7 shows a table structure of the variable information table 700.

【0016】このテーブルは、置換された変数かどうか
を示す置換フラグフィールド701と、置換された変数
の場合に置換前変数との対応を取るための置換テーブル
を示すポインタフィールド702と、参照点情報テーブ
ルを示すポインタフィールド703と、変数に割り付け
られたレジスタ番号を記憶するための割り付けレジスタ
番号フィールド704と、次の変数情報テーブルを示す
ポインタフィールド705からなる。
This table includes a replacement flag field 701 indicating whether a variable is replaced, a pointer field 702 indicating a replacement table for associating a replaced variable with a variable before replacement, and reference point information. It comprises a pointer field 703 indicating a table, an assigned register number field 704 for storing a register number assigned to a variable, and a pointer field 705 indicating the next variable information table.

【0017】図8は、参照点テーブル800のテーブル
構造を示したものである。
FIG. 8 shows a table structure of the reference point table 800.

【0018】このテーブルは、中間コードを示すポイン
タフィールド801と、参照点の属性を記憶する参照点
の属性フィールド802と、次の参照点テーブルを示す
ポインタフィールド803からなる。
This table includes a pointer field 801 indicating an intermediate code, a reference point attribute field 802 for storing the attribute of the reference point, and a pointer field 803 indicating the next reference point table.

【0019】図9は、置換テーブル900のテーブル構
造を示したものである。
FIG. 9 shows a table structure of the replacement table 900.

【0020】このテーブルは、置換前変数の集合を示す
フィールド901と、置換後変数の変数情報テーブルを
示すポインタフィールド902と、置換前変数に割り付
けるレジスタの条件がある場合に、その条件を示す割り
付け条件フィールド903と、次の置換テーブルを示す
ポインタフィールド904からなる。
This table includes a field 901 indicating a set of variables before replacement, a pointer field 902 indicating a variable information table of variables after replacement, and an allocation indicating conditions of registers to be assigned to variables before replacement, if any. It consists of a condition field 903 and a pointer field 904 indicating the next replacement table.

【0021】図3は、レジスタ割り付け部203の処理
の一例を示したものである。
FIG. 3 shows an example of the processing of the register allocating section 203.

【0022】ステップ301の変数情報テーブルの生成
では、中間コード40を入力し、各変数の参照点情報な
どを格納するための変数情報テーブルを生成する。ま
た、定義点で同時に複数定義される変数をある1つの別
の変数に置換するために、置換テーブルを生成する。
In generating a variable information table in step 301, the intermediate code 40 is input, and a variable information table for storing reference point information of each variable is generated. In addition, a substitution table is generated to replace a plurality of variables simultaneously defined at the definition point with one different variable.

【0023】ステップ302のレジスタの探索では、変
数情報テーブルが生成されている変数に対し、参照点情
報などを調べながらレジスタを割り付けていく。
In the search for the registers in step 302, registers are allocated to the variables for which the variable information table has been generated, while checking reference point information and the like.

【0024】ステップ303の参照点の変換では、変数
情報テーブルが生成されている変数に対し、レジスタが
割り付いている変数は、変数での参照をレジスタでの参
照に置き換える。そして、レジスタが割り付いてない変
数は、変数での参照をメモリからの参照に置き換える。
In the conversion of the reference point in step 303, the variable in which the register is assigned to the variable for which the variable information table has been generated replaces the variable reference with the register reference. For a variable to which no register is assigned, the reference in the variable is replaced with the reference from the memory.

【0025】図4は、変数情報テーブルの生成301の
処理の一例を示したものである。
FIG. 4 shows an example of the processing of the generation 301 of the variable information table.

【0026】変数情報テーブルの生成では、中間コード
40から文を取り出し(ステップ401)、文があるか
どうかを調べ(ステップ402)、文がある場合はステ
ップ410を実行する。ステップ410では、その文の
定義点で複数の変数が同時に定義される場合、その定義
点をある1つの別の変数に置換し、その置換情報を置換
テーブル700に登録し、定義点の参照情報を置換後変
数の定義であるとする。そして、置換前変数にレジスタ
を割り付ける条件を置換テーブルの割り付け条件フィー
ルド903に設定する。
In the generation of the variable information table, a sentence is extracted from the intermediate code 40 (step 401), and it is checked whether or not there is a sentence (step 402). In step 410, when a plurality of variables are simultaneously defined at the definition point of the sentence, the definition point is replaced with one other variable, the replacement information is registered in the replacement table 700, and the reference information of the definition point is registered. Is the definition of the variable after substitution. Then, the condition for allocating the register to the variable before replacement is set in the allocation condition field 903 of the replacement table.

【0027】次に、文の使用点と定義点で参照される変
数の変数情報テーブルが生成されているかどうかを調
べ、生成されてない場合は、その変数の変数情報テーブ
ルを生成する(ステップ403)。
Next, it is checked whether or not a variable information table of the variable referred to by the use point and the definition point of the statement has been generated. If not, a variable information table of the variable is generated (step 403). ).

【0028】登録した変数が、ステップ410の置換後
変数の場合は、変数情報テーブルの置換フラグフィール
ド701に印を付けて、登録されている変数が通常の変
数か、置換されている変数かを区別できるようにする
(ステップ411)。
If the registered variable is a variable after replacement in step 410, the replacement flag field 701 of the variable information table is marked to determine whether the registered variable is a normal variable or a variable that has been replaced. A distinction is made (step 411).

【0029】最後に、使用点と定義点の参照点情報を、
それぞれの変数情報テーブルの参照点テーブルフィール
ド703に登録する(ステップ404)。
Finally, the reference point information of the use point and the definition point is
It is registered in the reference point table field 703 of each variable information table (step 404).

【0030】図5は、レジスタの探索処理302の処理
の一例を示したものである。
FIG. 5 shows an example of the register search process 302.

【0031】レジスタの探索処理では、変数情報テーブ
ルから変数情報を1つ取り出し(ステップ501)、変
数情報が存在するかどうかを調べ(ステップ502)、
変数情報テーブルが存在する場合は、その変数が置換さ
れた変数であるかどうかを調べる(ステップ503)。
置換された変数かどうかは、変数情報テーブルの置換フ
ラグフィールド703を調べれば分かる。
In the register search processing, one variable information is taken out from the variable information table (step 501), and it is checked whether the variable information exists (step 502).
If the variable information table exists, it is checked whether the variable is a replaced variable (step 503).
Whether a variable has been replaced can be determined by examining the replacement flag field 703 of the variable information table.

【0032】置換変数でない場合は、その変数に割り付
けられるレジスタを探し(ステップ503)、割り付け
られるレジスタが存在する場合は、そのレジスタ番号を
変数情報テーブルの割り付けレジスタ番号フィールド7
04に登録する。
If it is not a substitution variable, a search is made for a register to be assigned to the variable (step 503). If there is a register to be assigned, the register number is assigned to the assigned register number field 7 of the variable information table.
Register in 04.

【0033】置換変数の場合は、置換テーブルの割り付
け条件フィールド903を調べ、条件が設定されていれ
ばその条件にしたがって割り付けられるレジスタを探
す。条件が設定されていない場合は、置換前変数の個数
分だけの割り付けられるレジスタを探す(ステップ51
1)。
In the case of a substitution variable, the assignment condition field 903 of the substitution table is examined, and if a condition is set, a register to be assigned according to the condition is searched. If the condition is not set, a search is made for registers to be allocated by the number of variables before replacement (step 51).
1).

【0034】図6は、参照点の変換処理303の処理の
一例を示したものである。
FIG. 6 shows an example of the reference point conversion processing 303.

【0035】参照点の変換処理は、それぞれの変数に割
り付けられたレジスタ情報を元に、各参照点をレジスタ
での参照に変換する処理である。
The reference point conversion process is a process of converting each reference point into a reference in a register based on the register information assigned to each variable.

【0036】まず、参照点の変換処理では、変数情報テ
ーブルから変数情報を1つ取り出し(ステップ60
1)、変数情報が存在するかどうかを調べる(ステップ
602)。変数情報が存在する場合は、変数の参照点を
1つ取り出し(ステップ603)、参照点が存在するか
どうかを調べる(ステップ604)。参照点が存在する
場合は、その参照点が複数の変数が同時に定義されてい
る定義点、つまり、置換対象となった参照点かどうかを
調べる(ステップ605)。置換対象となった参照点の
場合は、その置換変数にレジスタが割り付いているかど
うかを調べる(ステップ606)。
First, in the reference point conversion process, one variable information is extracted from the variable information table (step 60).
1) Check whether variable information exists (step 602). If the variable information exists, one reference point of the variable is extracted (step 603), and it is checked whether or not the reference point exists (step 604). If there is a reference point, it is checked whether the reference point is a definition point in which a plurality of variables are simultaneously defined, that is, a reference point to be replaced (step 605). In the case of the reference point to be replaced, it is checked whether a register is allocated to the replacement variable (step 606).

【0037】レジスタが割り付いている場合は、その割
り付けられたレジスタが、置換テーブルの割り付け条件
フィールドに設定されている条件を満たしているかどう
かを調べる(ステップ607)。条件を満たしている場
合は、元の参照点を割り付けたレジスタでの参照に変換
する(ステップ608)。ステップ607で条件を満た
すレジスタが割り付けられていない場合は、条件を満た
すリザーブレジスタを取り出し、元の参照点をリザーブ
レジスタの参照に変換する(ステップ609)。
If a register has been assigned, it is checked whether the assigned register satisfies the condition set in the assignment condition field of the replacement table (step 607). If the condition is satisfied, the original reference point is converted into a reference in the allocated register (step 608). If a register satisfying the condition is not allocated in step 607, a reserve register satisfying the condition is taken out, and the original reference point is converted into a reference of the reserve register (step 609).

【0038】参照点が使用点の場合は、割り付けたレジ
スタからリザーブレジスタへのコピー命令を生成し、元
の参照点の直前の文として挿入する。参照点が定義点の
場合は、リザーブレジスタから割り付けたレジスタへの
コピー命令を生成し、元の参照点の直後の文として挿入
する(ステップ610)。ステップ606でレジスタが
割り付いてない場合は、条件を満たすリザーブレジスタ
を取り出し、元の参照点をリザーブレジスタの参照に変
換する(ステップ615)。
If the reference point is a use point, a copy instruction from the allocated register to the reserved register is generated and inserted as a statement immediately before the original reference point. If the reference point is a definition point, a copy instruction from the reserved register to the allocated register is generated and inserted as a statement immediately after the original reference point (step 610). If no register is allocated in step 606, a reserved register satisfying the condition is taken out, and the original reference point is converted into a reference of the reserved register (step 615).

【0039】参照点が使用点の場合は、メモリからリザ
ーブレジスタへのロード命令を生成し、元の参照点の直
前の文として挿入する。参照点が定義点の場合は、リザ
ーブレジスタからメモリへのストア命令を生成し、元の
参照点の直後の文として挿入する(ステップ616)。
ステップ605で、置換対象となった参照点でない場合
は、通常の参照点変換処理を行う。レジスタが割り付い
ているかどうかを調べ(ステップ611)、レジスタが
割り付いている場合は、元の参照点を割り付けたレジス
タの参照に変換する(ステップ612)。
If the reference point is a use point, a load instruction from the memory to the reserve register is generated and inserted as a statement immediately before the original reference point. If the reference point is a definition point, a store instruction from the reserved register to the memory is generated and inserted as a statement immediately after the original reference point (step 616).
If it is determined in step 605 that the reference point has not been replaced, a normal reference point conversion process is performed. It is checked whether or not a register is allocated (step 611). If the register is allocated, the original reference point is converted into a reference of the allocated register (step 612).

【0040】ステップ611でレジスタが割り付いてい
ない場合は、リザーブレジスタを取り出し、元の参照点
をリザーブレジスタでの参照に変換する(ステップ61
3)。参照点が使用点の場合は、メモリからリザーブレ
ジスタへのロード命令を生成し、元の参照点の直前の文
として挿入する。元の参照点が定義点の場合は、リザー
ブレジスタからメモリへのストア命令を生成し、元の参
照点の直後の文として挿入する(ステップ614)。
If no register is assigned in step 611, the reserved register is taken out and the original reference point is converted into a reference in the reserved register (step 61).
3). If the reference point is a use point, a load instruction from the memory to the reserved register is generated and inserted as a statement immediately before the original reference point. If the original reference point is a definition point, a store instruction from the reserved register to the memory is generated and inserted as a statement immediately after the original reference point (step 614).

【0041】図11は、図10のソースプログラムを処
理した場合の変数情報テーブル700と置換テーブル9
00と参照点テーブル800と中間コード40の結合状
態を示した概念図である。
FIG. 11 shows the variable information table 700 and the replacement table 9 when the source program of FIG.
FIG. 5 is a conceptual diagram showing a connection state of a reference point table 800 and an intermediate code 40.

【0042】図10のソースプログラムを読み込んでか
ら、図11の図が作成されるまでの手順について説明す
る。まず、ソースプログラムは使用点から処理していく
ため、最初に変数cの変数情報テーブルが作成される。
変数cは、置換変数ではないので置換フラグは'FALSE'
に設定される。そして、使用点であることを示すための
参照テーブルが作成され、変数情報テーブルからこのテ
ーブルが指されることになる。また、参照点テーブルの
中間コードへのポインタフィールドは、中間コード40
内の文を指すことになる。変数dの各種テーブルも同様
に作成される。
The procedure from the reading of the source program of FIG. 10 to the creation of the diagram of FIG. 11 will be described. First, since the source program processes from the point of use, first, a variable information table of the variable c is created.
Since the variable c is not a substitution variable, the substitution flag is 'FALSE'
Is set to Then, a reference table for indicating the use point is created, and this table is pointed to from the variable information table. The pointer field to the intermediate code of the reference point table is an intermediate code 40
Will point to the sentence inside. Various tables of the variable d are similarly created.

【0043】定義点は、複数の変数が定義されているの
で別の変数に置換する。置換後変数名をreplace
1とすると、まずreplace1の変数情報テーブル
が作成される。そして、置換前変数(a,b)と置換後
変数replace1を関連付けるために置換テーブル
が作成される。置換テーブルの置換前変数の集合フィー
ルドには置換前変数(a,b)が設定され、置換後変数
の変数情報テーブルへのポインタフィールドに、rep
lace1の変数情報テーブルが設定される。また、r
eplace1の変数情報テーブルから置換テーブルが
指される。これらのテーブルの結合状態により、置換前
変数と置換後変数の関係を関連付けることができる。
The definition point is replaced by another variable because a plurality of variables are defined. Replace the variable name after replacement
If it is set to 1, first, a variable information table of replace1 is created. Then, a substitution table is created to associate the variable (a, b) before substitution with the variable replace1 after substitution. The pre-replacement variables (a, b) are set in the set fields of the pre-replacement variables in the substitution table, and rep is stored in the pointer field to the variable information table of the post-replacement variables.
The variable information table of the place1 is set. Also, r
The replacement table is pointed out from the variable information table of replace1. The relationship between the variable before replacement and the variable after replacement can be associated with each other by the connection state of these tables.

【0044】図15は、図10のソースプログラムに従
来のレジスタ割り付け方式を行った場合の結果例であ
る。ここで変数aと変数bには、連続するレジスタを割
り付ける必要があるとする。従来の割り付け方式では、
変数aと変数bに連続するレジスタを割り付ける条件と
いうのを考慮しないため、連続するレジスタが割り付く
可能性が低くなる。例えば、連続するレジスタが割り付
かなかった場合は、1500に示す元の参照点をリザー
ブレジスタでの参照に変換し(ステップ609)、15
10,1520で示すリザーブレジスタから割り付けた
レジスタへのコピー命令が必要になる(ステップ61
0)。
FIG. 15 shows an example of the result when the conventional register allocation method is applied to the source program of FIG. Here, it is assumed that continuous registers need to be allocated to the variables a and b. In the conventional allocation method,
Since the condition for allocating consecutive registers to the variable a and the variable b is not considered, the possibility of allocating consecutive registers is reduced. For example, when consecutive registers are not allocated, the original reference point indicated by 1500 is converted into a reference in the reserved register (step 609), and 15
A copy instruction from the reserved register indicated by 10, 1520 to the allocated register is required (step 61).
0).

【0045】図16は、図10のソースプログラムにお
ける変数aと変数bを変数replace1に置換して
レジスタを割り付けた場合の結果例である。置換変数r
eplace1に割り付けるレジスタを探索する場合、
条件を満たすような連続するレジスタを探すようにする
(ステップ511)ので、元の変数aと変数bの定義点
は割り付けたレジスタでの参照に変換(ステップ60
8)できる可能性が大きくなる。そのため、従来の方式
ではリザーブレジスタから割り付けたレジスタへのコピ
ー命令が必要になっていたが、今回の方式ではコピー命
令が生成される可能性が低くなるため、コピー命令を実
行しない分だけ実行時間が向上することになる。
FIG. 16 shows an example of the result when the variables a and b in the source program of FIG. 10 are replaced with the variable replace1, and the registers are allocated. Substitution variable r
When searching for a register to be assigned to eplace1,
Since a continuous register that satisfies the condition is searched for (step 511), the definition points of the original variables a and b are converted into references in the allocated registers (step 60).
8) The possibility of doing it increases. For this reason, in the conventional method, a copy instruction from the reserved register to the allocated register was required.However, in this method, the possibility of generating a copy instruction is reduced, and the execution time is reduced by the amount of time that the copy instruction is not executed. Will be improved.

【0046】なお、この例では、reg1とreg2が
連続するレジスタであるとした。
In this example, it is assumed that reg1 and reg2 are consecutive registers.

【0047】[0047]

【発明の効果】同時に定義される複数の変数をある1つ
の別の変数に置換して、その置換後変数をレジスタ割り
付け対象とすることにより、割り付け対象変数の数を削
減することができるため、コンパイル時間の削減をする
ことができる。
According to the present invention, the number of variables to be allocated can be reduced by replacing a plurality of variables defined at the same time with one other variable and making the replaced variables the registers to be allocated. Compile time can be reduced.

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

【図1】本発明の一実施例であるレジスタ割り付けのシ
ステム構成図。
FIG. 1 is a system configuration diagram of register allocation according to an embodiment of the present invention.

【図2】図1のコンパイラの処理構成図。FIG. 2 is a processing configuration diagram of a compiler of FIG. 1;

【図3】レジスタ割り付け処理手順を示すフローチャー
ト図。
FIG. 3 is a flowchart illustrating a procedure of register allocation processing.

【図4】変数情報テーブルの生成処理手順を示すフロー
チャート図。
FIG. 4 is a flowchart illustrating a procedure of generating a variable information table.

【図5】レジスタの探索処理手順を示すフローチャート
図。
FIG. 5 is a flowchart showing a register search processing procedure.

【図6】参照点変換処理手順を示すフローチャート図。FIG. 6 is a flowchart illustrating a reference point conversion processing procedure.

【図7】変数情報テーブルの構成図。FIG. 7 is a configuration diagram of a variable information table.

【図8】参照点テーブルの構成図。FIG. 8 is a configuration diagram of a reference point table.

【図9】置換テーブルの構成図。FIG. 9 is a configuration diagram of a replacement table.

【図10】ソースプログラム例を示す図。FIG. 10 is a diagram showing an example of a source program.

【図11】各種テーブルと中間コードの結合状態を示す
概念図。
FIG. 11 is a conceptual diagram showing a connection state between various tables and an intermediate code.

【図12】従来の変数情報テーブルの生成処理手順を示
すフローチャート図。
FIG. 12 is a flowchart illustrating a conventional variable information table generation processing procedure.

【図13】従来のレジスタの探索処理手順を示すフロー
チャート図。
FIG. 13 is a flowchart showing a conventional register search processing procedure.

【図14】従来の手順による各種テーブルと中間コード
の結合状態を示す概念図。
FIG. 14 is a conceptual diagram showing a connection state of various tables and intermediate codes according to a conventional procedure.

【図15】レジスタ割り付け結果(その1)を示す図。FIG. 15 is a diagram showing a register allocation result (1).

【図16】レジスタ割り付け結果(その2)を示す図。FIG. 16 is a diagram showing a register allocation result (No. 2).

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

1…CPU装置、2…メモリ装置、3…入力装置、4…
表示装置、10…コンパイラ。
DESCRIPTION OF SYMBOLS 1 ... CPU apparatus, 2 ... memory apparatus, 3 ... input apparatus, 4 ...
Display device, 10 ... Compiler.

Claims (2)

【特許請求の範囲】[Claims] 【請求項1】ある演算により複数の変数が定義される文
において、複数の変数の定義をある別の変数の定義に置
き換える処理と、置き換えた後の変数に対するレジスタ
割り付け処理により、コンパイル時間を削減することを
特徴とするレジスタ割り付け方法。
In a statement in which a plurality of variables are defined by a certain operation, compile time is reduced by a process of replacing the definitions of a plurality of variables with a definition of another variable and a process of allocating registers to the replaced variables. Register allocation method.
【請求項2】請求項1において、複数の変数の定義をあ
る別の変数の定義に置き換えるときに、元の複数の変数
に対するレジスタの割り付け条件を登録する処理と、該
条件にしたがってレジスタを割り付ける処理により、複
数の変数に条件にしたがったレジスタを割り付けること
を特徴とするレジスタ割り付け方法。
2. A process according to claim 1, wherein when replacing the definition of a plurality of variables with the definition of another variable, a process for registering a condition for allocating registers to the original plurality of variables, and allocating registers according to the conditions. A register allocating method characterized by allocating registers according to conditions to a plurality of variables by processing.
JP10195355A 1998-07-10 1998-07-10 Register allocating method Pending JP2000029716A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP10195355A JP2000029716A (en) 1998-07-10 1998-07-10 Register allocating method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP10195355A JP2000029716A (en) 1998-07-10 1998-07-10 Register allocating method

Publications (1)

Publication Number Publication Date
JP2000029716A true JP2000029716A (en) 2000-01-28

Family

ID=16339802

Family Applications (1)

Application Number Title Priority Date Filing Date
JP10195355A Pending JP2000029716A (en) 1998-07-10 1998-07-10 Register allocating method

Country Status (1)

Country Link
JP (1) JP2000029716A (en)

Similar Documents

Publication Publication Date Title
US7571427B2 (en) Methods for comparing versions of a program
EP0428084B1 (en) Method and apparatus for compiling computer programs with interprocedural register allocation
US5048018A (en) Debugging parallel programs by serialization
US5768592A (en) Method and apparatus for managing profile data
US6901579B1 (en) Generation of source code from classes and maintaining the comment that indicates the role of the class in the generated source code
US6286133B1 (en) Method and apparatus for strategic compilation of source programs into two or more target languages
US20030028860A1 (en) Compiler and debugging device
US7111287B2 (en) Global processor resource assignment in an assembler
US5367684A (en) Register allocation using an improved register candidate usage matrix
JPH10161884A (en) Improved code optimizer for pipeline computer
US20020166115A1 (en) System and method for computer program compilation using scalar register promotion and static single assignment representation
US6675377B1 (en) Program conversion apparatus
JPH0926884A (en) Method and apparatus for making required flow information usable during task requiring binary information
Chakrabarti et al. Structure layout optimizations in the open64 compiler: Design, implementation and measurements
US7185324B2 (en) Compiler apparatus and method for determining locations for data in memory area
US6721945B1 (en) Optimization of calls in programming languages using pointers for passing reference parameters
JP2000029716A (en) Register allocating method
JP3239907B2 (en) Register allocation method
JPH11345127A (en) Compiler
Xi The ATS Programming Language
JPH08212081A (en) Memory allocation method, compiling method and compiler
JPS62163145A (en) Compiler device
JPH05197565A (en) Constant area allocation processing method
JP2001142719A (en) Compiler device and recording medium with recorded compiler program
JP3167386B2 (en) Automatic program parallelization method