JPH08123692A - Method and device for register allocation - Google Patents

Method and device for register allocation

Info

Publication number
JPH08123692A
JPH08123692A JP26555794A JP26555794A JPH08123692A JP H08123692 A JPH08123692 A JP H08123692A JP 26555794 A JP26555794 A JP 26555794A JP 26555794 A JP26555794 A JP 26555794A JP H08123692 A JPH08123692 A JP H08123692A
Authority
JP
Japan
Prior art keywords
register
operand
intermediate code
allocated
allocation
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.)
Withdrawn
Application number
JP26555794A
Other languages
Japanese (ja)
Inventor
Takae Itou
高絵 伊藤
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.)
Fujitsu Ltd
Original Assignee
Fujitsu 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 Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP26555794A priority Critical patent/JPH08123692A/en
Publication of JPH08123692A publication Critical patent/JPH08123692A/en
Withdrawn legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PURPOSE: To provide the register allocating method for generating a compact object program with good execution efficiency and a compiler device which has a function like it. CONSTITUTION: A selection allocation request is set in register information of an intermediate code first (step S1), and an operand register allocating process for the intermediate code is performed (step S2). Then it is checked whether or not a register is allocated to an operand regarding the selection allocation request (step S3) and when the register is allocated, a corresponding work register is not allocated. When no register is allocated to the operand regarding the selection allocation request, the work register is allocated (step S4). Thus, the allocation of an unnecessary work register is omitted to simplify the generated object program.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明はコンパイラに係り、目的
プログラム(オブジェクト・プログラム)を生成するた
めのレジスタ割り付け方式に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a compiler, and more particularly to a register allocation method for generating an object program (object program).

【0002】[0002]

【従来の技術】マイクロプロセッサ等の情報処理装置に
おいて、コンパイラ装置はソースプログラムを解釈し
て、機械語レベルの目的プログラムに翻訳する役割を果
たす。このとき、ソースプログラムを一旦中間言語で記
述された中間コード(中間言)に変換し、中間コードか
ら目的コードを生成することが多い。中間コードから目
的コードを生成する際には、必要に応じてコードの最適
化およびレジスタ割り付けが行われる。
2. Description of the Related Art In an information processing device such as a microprocessor, a compiler device interprets a source program and translates it into a machine language target program. At this time, in many cases, the source program is once converted into an intermediate code (intermediate language) written in an intermediate language, and the target code is generated from the intermediate code. When the target code is generated from the intermediate code, the code is optimized and register allocation is performed as necessary.

【0003】コンパイラ装置におけるレジスタ割り付け
処理においては、中間コード毎に作成されるオブジェク
ト展開に必要なレジスタ割り付け要求情報を基にして、
出現した中間コードに対して使用可能なレジスタの種類
と個数を割り付けている。
In the register allocation process in the compiler device, based on the register allocation request information required for object expansion created for each intermediate code,
The type and number of registers that can be used are assigned to the intermediate code that appears.

【0004】一つの中間コード内において、オブジェク
ト展開に一時的に使用するレジスタ(以後、作業用レジ
スタと呼ぶ)は、オペランドがレジスタに乗った場合に
比べて、乗らなかった場合の方が多く必要とすることが
多々ある。
Within one intermediate code, more registers (temporarily referred to as working registers) temporarily used for object expansion are required when the operand is not loaded than when the operand is loaded in the register. There are many things to do.

【0005】しかし、オペランドがレジスタに乗るか否
かは、実際にレジスタ割り付け処理を行わないと判定で
きない。このため、オペランドがレジスタに乗った場合
と乗らなかった場合の両方を満足する情報が、レジスタ
割り付け要求情報として、オブジェクト展開を行う処理
部に渡されることになる。すなわち、オペランドがレジ
スタに乗らなかった場合に必要となる作業用レジスタの
種類と個数が要求されていた。
However, it cannot be determined whether or not the operand is loaded on the register unless the register allocation processing is actually performed. Therefore, information satisfying both the case where the operand is loaded in the register and the case where the operand is not loaded is passed to the processing unit that performs the object expansion as the register allocation request information. That is, the type and number of work registers required when the operand does not fit in the register are required.

【0006】[0006]

【発明が解決しようとする課題】上述のような従来のレ
ジスタ割り付け要求情報に基づくレジスタ割り付け処理
では、オペランドがレジスタに乗った場合でも、乗らな
かった場合と同じだけの数の作業用レジスタが確保され
る。つまり、必要のない作業用レジスタが余分に割り付
けられることになる。
In the conventional register allocating process based on the register allocating request information as described above, even when the operands are loaded in the registers, the same number of working registers as those when the operands are not loaded are secured. To be done. That is, unnecessary work registers are additionally allocated.

【0007】割り付け確保されるレジスタの個数が増え
ると、目的プログラムの実行時にレジスタの値をメモリ
上に退避する処理が行われる確率が高くなる。退避処理
の出現回数が多いほど、オブジェクトサイズが増加し、
目的プログラムの実行速度が低下する。
As the number of allocated and secured registers increases, the probability that the value of the register will be saved in the memory when the object program is executed will increase. As the number of occurrences of evacuation processing increases, the object size increases,
The execution speed of the target program decreases.

【0008】したがって、従来のレジスタ割り付け処理
においては、作業用レジスタのレジスタ割り付けに無駄
が多く、最適な目的プログラムが生成されないという問
題がある。
Therefore, in the conventional register allocating process, there is a lot of waste in register allocating the working registers, and there is a problem that an optimum object program cannot be generated.

【0009】本発明は、コンパイラ装置においてコンパ
クトで実行効率のよい目的プログラムを生成するための
レジスタ割り付け方法、および、そのような機能を持つ
コンパイラ装置を提供することを目的とする。より具体
的には、無駄な作業用レジスタの割り付けを行わないこ
とを目的とする。
An object of the present invention is to provide a register allocating method for generating a compact and efficient execution target program in a compiler apparatus, and a compiler apparatus having such a function. More specifically, the purpose is to prevent unnecessary work register allocation.

【0010】[0010]

【課題を解決するための手段】図1は本発明のレジスタ
割り付け処理の原理を示すフローチャートである。図1
において処理が開始されると、まず中間コードのオペラ
ンドと該オペランドに対応する作業用レジスタのうちの
一方にレジスタを割り付ける選択割り付け要求を中間コ
ードのレジスタ情報に設定し(ステップS1)、その中
間コードのオペランドレジスタ割り付け処理を行う(ス
テップS2)。
FIG. 1 is a flowchart showing the principle of register allocation processing of the present invention. FIG.
When the processing is started in step 1, first, a selective allocation request for allocating the register to one of the operand of the intermediate code and the work register corresponding to the operand is set in the register information of the intermediate code (step S1), and the intermediate code The operand register allocation processing is performed (step S2).

【0011】そして、次に上記選択割り付け要求に係る
オペランドにレジスタが割り付けられているかどうかを
調べ(ステップS3)、レジスタが割り付けられていれ
ば、対応する作業用レジスタの割り付けを行わない。上
記選択割り付け要求に係るオペランドにレジスタが割り
付けられていなければ、上記作業用レジスタの割り付け
を行う(ステップS4)。
Then, it is checked whether or not a register is allocated to the operand related to the selective allocation request (step S3), and if the register is allocated, the corresponding work register is not allocated. If a register is not allocated to the operand related to the selective allocation request, the work register is allocated (step S4).

【0012】上記レジスタ情報とは、例えば中間コード
毎に作成されるレジスタ割り付け要求情報であり、選択
割り付け要求は例えばフラグにより設定される。また、
このとき、作業用レジスタの要求情報として上記選択割
り付け要求に係るオペランドの識別子が設定される。
The register information is register allocation request information created for each intermediate code, and the selective allocation request is set by a flag, for example. Also,
At this time, the identifier of the operand related to the above selection allocation request is set as the request information of the work register.

【0013】[0013]

【作用】オペランドレジスタおよび作業用レジスタに対
してレジスタ割り付けを行う前に、選択割り付け要求が
レジスタ情報に設定され、次にオペランドレジスタ割り
付け処理が行われる。このオペランドレジスタ割り付け
処理において、上記選択割り付け要求に係るオペランド
または選択割り付け要求に関係しないオペランドについ
てのレジスタ割り付け処理が行われる。
Before the register allocation is performed on the operand register and the work register, the selection allocation request is set in the register information, and then the operand register allocation processing is performed. In this operand register allocating process, register allocating process is performed on the operands related to the selective allocation request or the operands not related to the selective allocation request.

【0014】上記選択割り付け要求に係るオペランドに
レジスタが割り付けば、対応する作業用レジスタにはレ
ジスタを割り付けない。これにより、オペランドにレジ
スタが割り付いたときに作業用レジスタが不要となる中
間コードにおいて、割り付けられるレジスタ数を削減す
ることができる。したがって、レジスタが効率的に利用
され、データの退避処理を減少させることになる。
If a register is allocated to the operand related to the above selection allocation request, the register is not allocated to the corresponding work register. This makes it possible to reduce the number of registers to be allocated in the intermediate code that does not require a work register when registers are allocated to operands. Therefore, the registers are efficiently used and the data saving process is reduced.

【0015】上記選択割り付け要求に係るオペランドに
レジスタが割り付かなければ、対応する作業用レジスタ
にレジスタを割り付ける。つまり、オペランドにレジス
タが割り付いたときに作業用レジスタが不要、レジスタ
が割り付かなかったときに作業用レジスタが必要となる
場合には、結果的にオペランドと作業用レジスタのどち
らか一方にレジスタが割り付けられることになる。
If a register is not allocated to the operand related to the above selection allocation request, the register is allocated to the corresponding work register. In other words, when a register is assigned to an operand, a work register is not needed, and when a register is not assigned, a work register is needed. Will be assigned.

【0016】[0016]

【実施例】以下、図面を参照しながら、本発明の実施例
を詳細に説明する。本実施例のコンパイラ装置は、まず
複数個の実レジスタを備えたマイクロプロセッサ用のソ
ースプログラムの文解釈を行い、それを中間コードに展
開する。次に得られた中間コードにレジスタを割り付
け、目的コード(オブジェクトコード)に展開して、機
械命令で記述された目的プログラムを生成する。
Embodiments of the present invention will now be described in detail with reference to the drawings. The compiler apparatus of this embodiment first interprets a source program for a microprocessor having a plurality of real registers, and expands it into an intermediate code. Next, a register is allocated to the obtained intermediate code and expanded into a target code (object code) to generate a target program described by machine instructions.

【0017】図2は、本実施例のコンパイラ装置による
レジスタ割り付け要求情報の作成処理のフローチャート
である。この処理は各中間コード毎に行われる。レジス
タ割り付け要求情報とは、オブジェクト展開に必要なレ
ジスタの種別、個数、およびオペランド情報などであ
り、オペランドの長さ等に応じて中間コードの種類と塊
を指定するオブジェクト・スケルトンから各中間コード
毎に作成される。コンパイラ装置は、作成されたレジス
タ割り付け要求情報に基づいてレジスタ割り付け処理を
行う。
FIG. 2 is a flow chart of a process of creating register allocation request information by the compiler apparatus of this embodiment. This process is performed for each intermediate code. The register allocation request information is the type, number, and operand information of the registers necessary for object expansion. For each intermediate code from the object skeleton that specifies the type and chunk of the intermediate code according to the length of the operand, etc. Created in. The compiler device performs register allocation processing based on the created register allocation request information.

【0018】図2において処理が開始されると、まず処
理対象の中間コードが要求する作業用レジスタの個数
が、その中間コードのオペランドに対するレジスタ割り
付け結果によって変動するかどうかを判定する(ステッ
プS11)。変動する場合は選択割り付け要求をレジス
タ割り付け要求情報に設定し(ステップS12)、変動
しない場合は選択割り付け要求を設定しない。
When the processing is started in FIG. 2, it is first determined whether or not the number of work registers required by the intermediate code to be processed varies depending on the result of register allocation to the operand of the intermediate code (step S11). . If it changes, the selection allocation request is set in the register allocation request information (step S12). If it does not change, the selection allocation request is not set.

【0019】選択割り付け要求は、ある中間コードのオ
ペランドにレジスタが割り付いたときに作業用レジスタ
が不要、レジスタが割り付かなかったときに作業用レジ
スタが必要になることを表すレジスタ割り付け要求であ
る。言い換えれば、オペランドと作業用レジスタのどち
らか一方にレジスタを割り付ける旨の要求情報である。
The selective allocation request is a register allocation request indicating that the work register is unnecessary when the register is allocated to the operand of a certain intermediate code, and the work register is necessary when the register is not allocated. . In other words, it is request information for allocating a register to either the operand or the work register.

【0020】図3は、ソースプログラムのコンパイル処
理の具体例を示している。図3において、COMPUT
E A=B+Cという演算処理が中間コードADDに変
換された後、−−ADD−−以降に示される一連の目的
コードが生成される。ここで、ADDはCOMPUTE
A=B+Cに対応する中間コードのラベルである。
FIG. 3 shows a concrete example of the compilation process of the source program. In FIG. 3, COMPUT
After the arithmetic processing of EA = B + C is converted into the intermediate code ADD, a series of object codes shown after --ADD-- are generated. Where ADD is COMPUTE
It is a label of the intermediate code corresponding to A = B + C.

【0021】生成された中間コードADDに関するレジ
スタ割り付け要求情報のうち、選択割り付けと要求レジ
スタの情報は、例えば図4のようになる。図4におい
て、OPD1は加算の結果を格納するオペランドを表
し、OPD2、OPD3は加算されるオペランドを表
す。作業用はこの中間コードが要求する作業用レジスタ
を表す。OPD1はREGで示されるレジスタを要求し
ており、OPD2、OPD3は特定のレジスタを要求し
ていない。また、作業用レジスタとしては8バイトのレ
ジスタが1つ要求されている。
Of the register allocation request information relating to the generated intermediate code ADD, the selective allocation and request register information is as shown in FIG. 4, for example. In FIG. 4, OPD1 represents an operand that stores the result of addition, and OPD2 and OPD3 represent operands that are added. Working represents the working register required by this intermediate code. OPD1 requests the register indicated by REG, and OPD2 and OPD3 do not request a specific register. Also, one 8-byte register is required as a working register.

【0022】フラグは選択割り付け要求が設定されてい
るか否かを表す情報フラグで、例えば、ONのとき選択
割り付け要求であることを表し、OFFのとき選択割り
付け以外のレジスタ要求であることを表す。
The flag is an information flag indicating whether or not the selective allocation request is set. For example, when the flag is ON, it represents the selective allocation request, and when it is OFF, it represents the register request other than the selective allocation request.

【0023】ここでは、OPD1とOPD2にレジスタ
が割り付いたかどうかは作業用レジスタの必要性に関係
しないため、これらのフラグはOFFとなっている。こ
れに対して、OPD3にレジスタが割り付いたときには
作業用レジスタが不要となり、OPD3にレジスタが割
り付かなければ作業用レジスタが必要になる。つまり、
OPD3と作業用レジスタのどちらか一方にレジスタを
割り付ければよいので、OPD3のフラグにはONが格
納され、作業用レジスタのフラグとしてはOPD3の識
別番号3が格納される。
Here, since whether or not the registers are allocated to OPD1 and OPD2 is not related to the necessity of the work register, these flags are OFF. On the other hand, when the register is allocated to the OPD 3, the work register becomes unnecessary, and when the register is not allocated to the OPD 3, the work register is necessary. That is,
Since the register may be allocated to either the OPD3 or the work register, ON is stored in the flag of the OPD3, and the identification number 3 of the OPD3 is stored as the flag of the work register.

【0024】このように、作業用レジスタの要否を左右
するオペランドのフラグをONにし、その作業用レジス
タのフラグとして上記オペランドの識別子を格納するこ
とにより、選択割り付け要求が設定される。これは図2
のステップS12の処理に対応する。
As described above, the selection allocation request is set by turning on the flag of the operand that determines the necessity of the work register and storing the identifier of the operand as the flag of the work register. This is Figure 2
This corresponds to the process of step S12.

【0025】図5は、本実施例のコンパイラ装置による
レジスタ割り付け処理のフローチャートである。この処
理もまた、図2の処理と同様に各中間コード毎に行われ
る。図5において処理が開始されると、まずレジスタ割
り付け要求情報を参照しながら、処理対象の中間コード
の各オペランド毎にオペランドレジスタの割り付け処理
を行い(ステップS21)、次のオペランドがある限り
(ステップS22、YES)、これを繰り返す。
FIG. 5 is a flow chart of register allocation processing by the compiler apparatus of this embodiment. This process is also performed for each intermediate code as in the process of FIG. When the processing is started in FIG. 5, the operand register allocation processing is performed for each operand of the intermediate code to be processed while referring to the register allocation request information (step S21), and as long as there is the next operand (step S21). S22, YES), and this is repeated.

【0026】次のオペランドがなくなれば(ステップS
22、NO)、レジスタ割り付け要求情報を参照しなが
ら、各作業用レジスタ毎に作業用レジスタの割り付け処
理を行う(ステップS23)。次の作業用レジスタがあ
る限り(ステップS24、YES)、これを繰り返し、
次の作業用レジスタがなくなれば(ステップS24、N
O)、処理を終了する。
When the next operand is exhausted (step S
No. 22, No), the work register allocation process is performed for each work register with reference to the register allocation request information (step S23). As long as there is a next work register (step S24, YES), repeat this,
If the next work register is exhausted (step S24, N
O), the process ends.

【0027】次に図6および図7を参照しながら、図5
のオペランドレジスタ割り付け処理と作業用レジスタ割
り付け処理を詳しく説明する。図6は、本実施例のオペ
ランドレジスタ割り付け処理のフローチャートである。
オペランドレジスタ割り付け処理においては、まずレジ
スタ状態テーブルを参照して、割り付け処理中のオペラ
ンドの値を保持するレジスタが既に存在するかどうかを
調べる(ステップS31)。
Next, referring to FIGS. 6 and 7, FIG.
The operand register allocation processing and the work register allocation processing of will be described in detail. FIG. 6 is a flowchart of the operand register allocation process of this embodiment.
In the operand register allocation process, first, the register state table is referred to check whether or not there is already a register that holds the value of the operand being allocated (step S31).

【0028】レジスタ状態テーブルは現在のレジスタの
割り付け状態を保持するテーブルである。例えば、現在
の処理対象となっている中間コードより前に処理された
中間コードのオペランドに対してあるレジスタが割り付
けられている場合は、そのレジスタの状態は使用状態で
あり、その内容は対応するオペランドの内容であること
がレジスタ状態テーブルに記されている。したがって、
レジスタ状態テーブルを参照することにより、割り付け
処理中のオペランドが既にレジスタ上に存在するか否か
がわかる。
The register status table is a table for holding the current allocation status of registers. For example, when a register is assigned to the operand of the intermediate code that is processed before the intermediate code that is the current processing target, the state of the register is the usage state and the contents correspond to it. It is written in the register state table that it is the contents of the operand. Therefore,
By referring to the register status table, it is possible to know whether or not the operand under allocation processing already exists in the register.

【0029】そのオペランドの値を保持するレジスタが
存在しているときは、そのレジスタを割り付け処理中の
オペランドに割り付け(ステップS32)、レジスタ割
り付け要求情報においてそのオペランドに選択割り付け
要求が設定されているかどうかを調べる(ステップS3
3)。存在しないときは、直ちにステップS33の処理
を行う。
If a register holding the value of the operand exists, the register is allocated to the operand being allocated (step S32), and whether the selective allocation request is set to the operand in the register allocation request information. Check whether (step S3
3). If it does not exist, the process of step S33 is immediately performed.

【0030】割り付け処理中のオペランドに選択割り付
け要求が設定されているときは、そのオペランド(選択
割り付け対象オペランド)の処理結果の情報を作成して
(ステップS34)、処理を終了し、選択割り付け要求
が設定されていないときは、そのまま処理を終了する。
選択割り付け対象オペランドの処理結果の情報は、レジ
スタ状態テーブルに格納してもよい。
When the selective allocation request is set to the operand during the allocation processing, information of the processing result of the operand (selective allocation target operand) is created (step S34), the processing is terminated, and the selective allocation request is made. If is not set, the process ends as it is.
The information on the processing result of the selective allocation target operand may be stored in the register state table.

【0031】ステップS31で割り付け処理中のオペラ
ンドの値を保持するレジスタが存在せず、レジスタが割
り付かなかったときは、ステップS34でそのオペラン
ドがレジスタに乗らなかったことにより必要となる作業
用レジスタの割り付けを必ず行う旨の情報を作成する。
If there is no register for holding the value of the operand being allocated in step S31 and the register is not allocated, the work register required because the operand was not loaded in the register in step S34. Create the information that the allocation of is always performed.

【0032】また、ステップS31で割り付け処理中の
オペランドの値を保持するレジスタが存在し、ステップ
S32でレジスタが割り付いたときは、ステップS34
でそのオペランドがレジスタに乗ったことにより不必要
となる作業用レジスタの割り付けを行わない旨の情報を
作成する。
If there is a register for holding the value of the operand being allocated in step S31 and the register is allocated in step S32, step S34
Then, the information indicating that the unnecessary work register is not allocated because the operand is loaded in the register is created.

【0033】例えば、図4のレジスタ割り付け要求情報
の場合は、OPD3に選択割り付け要求が設定されてい
るので、OPD3の処理においてステップS34の処理
が行われ、作成された情報が次の作業用レジスタ割り付
け処理に渡される。
For example, in the case of the register allocation request information of FIG. 4, since the selective allocation request is set in the OPD3, the processing of step S34 is performed in the processing of the OPD3, and the created information is the next work register. Passed to allocation process.

【0034】図7は、本実施例の作業用レジスタ割り付
け処理のフローチャートである。作業用レジスタ割り付
け処理では、まずレジスタ割り付け要求情報において、
割り付け処理中の作業用レジスタに選択割り付け要求が
設定されているかどうかを調べる(ステップS41)。
FIG. 7 is a flow chart of the work register allocation process of this embodiment. In the work register allocation process, first, in the register allocation request information,
It is checked whether or not the selective allocation request is set in the work register during the allocation process (step S41).

【0035】選択割り付け要求が設定されている場合
は、次に、オペランドレジスタ割り付け処理で作成され
た対応する選択割り付け対象オペランドの処理結果を参
照して、その選択割り付け対象オペランドにレジスタが
割り付いているかどうかを調べる(ステップS42)。
If the selective allocation request is set, then the processing result of the corresponding selective allocation target operand created by the operand register allocation processing is referred to, and the register is allocated to the selective allocation target operand. It is checked whether or not there is (step S42).

【0036】選択割り付け対象オペランドにレジスタが
割り付いておらず、割り付け処理中の作業用レジスタが
必要になった旨を伝えられた場合は(ステップS42、
NO)、その作業用レジスタにレジスタを割り付け(ス
テップS43)、処理を終了する。
If it is informed that a register is not allocated to the operand to be selectively allocated and that a work register being allocated is needed (step S42,
No), the register is allocated to the work register (step S43), and the process is terminated.

【0037】選択割り付け対象オペランドにレジスタが
割り付いており、割り付け処理中の作業用レジスタが不
要になった旨を伝えられた場合は(ステップS42、Y
ES)、その作業用レジスタにはレジスタを割り付けず
に処理を終了する。
When a register is allocated to the operand to be selectively allocated and it is informed that the work register under allocation is no longer needed (step S42, Y).
ES), the process is terminated without assigning a register to the work register.

【0038】ステップS41で選択割り付け要求が設定
されていない場合は、選択割り付け要求以外に対するレ
ジスタ割り付け処理を続行する(ステップS44)。選
択割り付け以外の作業用レジスタ割り付け要求は、例え
ば、オペランドにレジスタが割り付いたか否かに依らず
無条件にその作業用レジスタを確保したいときに設定さ
れる。この場合、オペランドの処理結果を参照すること
なしに、その作業用レジスタにレジスタを割り付ける。
When the selective allocation request is not set in step S41, the register allocation processing for the requests other than the selective allocation request is continued (step S44). The work register allocation request other than the selective allocation is set, for example, when it is necessary to unconditionally secure the work register regardless of whether the register is allocated to the operand. In this case, the register is assigned to the work register without referring to the processing result of the operand.

【0039】例えば、図4のレジスタ割り付け要求情報
の場合は、作業用レジスタのフラグに選択割り付け対象
オペランドOPD3の識別番号3が設定されているの
で、この作業用レジスタに対して選択割り付けの処理が
行われる(ステップS41、YES)。ここで、OPD
3の処理結果を参照して(ステップS42)、OPD3
にレジスタが割り付けられていればその作業用レジスタ
にレジスタを割り付けず、OPD3にレジスタが割り付
けられていなければ、その作業用レジスタにレジスタを
割り付ける(ステップS43)。
For example, in the case of the register allocation request information of FIG. 4, since the identification number 3 of the operand OPD3 for selective allocation is set in the flag of the working register, the selective allocation process is performed for this working register. It is performed (step S41, YES). Where OPD
Referring to the processing result of step 3 (step S42), OPD3
If the register is allocated to the work register, the register is not allocated to the work register. If the register is not allocated to the OPD 3, the register is allocated to the work register (step S43).

【0040】図4において、作業用レジスタのフラグに
いずれのオペランドの識別番号も格納されておらず、フ
ラグがOFFとなっている場合は、選択割り付け要求が
設定されていないので、例えば無条件にその作業用レジ
スタにレジスタを割り付ける(ステップS44)。
In FIG. 4, when the flag of the work register does not store the identification number of any operand and the flag is OFF, the selective allocation request is not set, so that, for example, unconditionally. Registers are assigned to the work registers (step S44).

【0041】このように、レジスタ割り付け要求情報に
特別な情報フラグを設けて選択割り付け要求を設定する
ことにより、選択割り付け要求に係るオペランドと作業
用レジスタのどちらか一方のみにレジスタを割り付ける
ことができる。
As described above, by providing the special information flag in the register allocation request information and setting the selective allocation request, the register can be allocated to only one of the operand related to the selective allocation request and the working register. .

【0042】尚、図4にはレジスタ割り付け要求情報の
一例を示したが、本発明はこれに限られることはなく、
他の構成のレジスタ割り付け要求情報を用いてもよい。
例えば、作業用レジスタのフラグを2つ用意し、1つは
選択割り付け要求が設定されているか否かを表し、もう
1つが対応する選択割り付け対象オペランドの識別番号
を格納するように構成することもできる。
Although FIG. 4 shows an example of register allocation request information, the present invention is not limited to this.
The register allocation request information having another configuration may be used.
For example, two working register flags may be prepared, one indicating whether or not a selective allocation request is set, and the other storing the identification number of the corresponding selective allocation target operand. it can.

【0043】[0043]

【発明の効果】本発明によれば、コンパイラによる中間
コードのレジスタ割り付け処理において、オペランドと
作業用レジスタのどちらか一方のみに選択的にレジスタ
を割り付けることが可能になる。これにより、割り付け
る作業用レジスタの個数を調整できる。不必要な作業用
レジスタの割り付け処理を省くことによって、目的プロ
グラムのサイズが小さくなり、その実行速度が向上す
る。
According to the present invention, it becomes possible to selectively allocate a register to only one of the operand and the working register in the register allocation process of the intermediate code by the compiler. As a result, the number of work registers to be allocated can be adjusted. By omitting unnecessary work register allocation processing, the size of the target program is reduced and its execution speed is improved.

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

【図1】本発明の原理図である。FIG. 1 is a principle diagram of the present invention.

【図2】本発明の実施例のレジスタ割り付け要求情報作
成処理のフローチャートである。
FIG. 2 is a flowchart of a register allocation request information creation process according to the embodiment of this invention.

【図3】コンパイルの一例を示す図である。FIG. 3 is a diagram showing an example of compilation.

【図4】実施例におけるレジスタ割り付け要求情報の一
例を示す図である。
FIG. 4 is a diagram showing an example of register allocation request information in the embodiment.

【図5】実施例のレジスタ割り付け処理のフローチャー
トである。
FIG. 5 is a flowchart of register allocation processing according to the embodiment.

【図6】オペランドレジスタ割り付け処理のフローチャ
ートである。
FIG. 6 is a flowchart of an operand register allocation process.

【図7】作業用レジスタ割り付け処理のフローチャート
である。
FIG. 7 is a flowchart of work register allocation processing.

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

OPD1、OPD2、OPD3 オペランド OPD1, OPD2, OPD3 operands

Claims (9)

【特許請求の範囲】[Claims] 【請求項1】 与えられたソースプログラムを中間コー
ドに変換し、該中間コードから目的プログラムを生成す
る過程において、該中間コードにレジスタを割り付ける
方法であって、 前記中間コードのオペランドと該オペランドに対応する
作業用レジスタのうちの一方にレジスタを割り付ける選
択割り付け要求を前記中間コードのレジスタ情報に設定
し、 前記オペランドにレジスタを割り付けるための処理を行
い、 前記オペランドにレジスタが割り付けられたかどうかを
調べ、 前記オペランドにレジスタが割り付けられていれば、前
記作業用レジスタにレジスタを割り付けないことを特徴
とするレジスタ割り付け方法。
1. A method of allocating a register to an intermediate code in the process of converting a given source program into an intermediate code and generating an object program from the intermediate code, the method comprising: A selection allocation request for allocating a register to one of the corresponding work registers is set in the register information of the intermediate code, a process for allocating a register to the operand is performed, and it is checked whether a register is allocated to the operand. If the register is allocated to the operand, the register allocation method is characterized in that the register is not allocated to the work register.
【請求項2】 前記オペランドにレジスタが割り付けら
れていなければ、前記作業用レジスタにレジスタを割り
付けることを特徴とする請求項1記載のレジスタ割り付
け方法。
2. The register allocating method according to claim 1, wherein a register is allocated to said work register if no register is allocated to said operand.
【請求項3】 前記選択割り付け要求を設定する処理に
おいて、 前記レジスタ情報内の前記オペランドに対応する位置に
選択割り付け要求を表す第1のフラグを格納し、 前記レジスタ情報内の前記作業用レジスタに対応する位
置に選択割り付け要求を表す第2のフラグを格納するこ
とを特徴とする請求項1または2記載のレジスタ割り付
け方法。
3. In the process of setting the selective allocation request, a first flag representing the selective allocation request is stored in a position corresponding to the operand in the register information, and is stored in the work register in the register information. The register allocating method according to claim 1 or 2, wherein a second flag indicating a selective allocation request is stored in a corresponding position.
【請求項4】 前記第2のフラグとして、前記オペラン
ドの識別子を格納することを特徴とする請求項3記載の
レジスタ割り付け方法。
4. The register allocation method according to claim 3, wherein an identifier of the operand is stored as the second flag.
【請求項5】 前記レジスタ割り付け処理の結果を表す
情報を参照して、前記オペランドにレジスタが割り付け
られたかどうかを調べることを特徴とする請求項1また
は2記載のレジスタ割り付け方法。
5. The register allocating method according to claim 1, wherein it is checked whether or not a register is allocated to the operand by referring to information indicating a result of the register allocating process.
【請求項6】 前記オペランドにレジスタを割り付ける
ための処理において、 前記レジスタ情報を参照して、前記オペランドに前記選
択割り付け要求が設定されているかどうかを調べ、 前記選択割り付け要求が設定されていれば、前記オペラ
ンドに対するレジスタ割り付け処理の結果を表す情報を
生成することを特徴とする請求項1記載のレジスタ割り
付け方法。
6. In a process for allocating a register to the operand, the register information is referred to check whether the selective allocation request is set to the operand, and if the selective allocation request is set, 2. The register allocation method according to claim 1, further comprising: generating information indicating a result of a register allocation process for the operand.
【請求項7】 与えられたソースプログラムを中間コー
ドに変換し、該中間コードから目的プログラムを生成す
る過程において、該中間コードにレジスタを割り付ける
方法であって、 前記中間コードに対する選択割り付け要求を該中間コー
ドのレジスタ情報に設定し、 前記オペランドの状態に応じて、該オペランドと前記作
業用レジスタのうちの一方にレジスタを割り付けること
を特徴とするレジスタ割り付け方法。
7. A method for allocating a register to an intermediate code in the process of converting a given source program into an intermediate code and generating an object program from the intermediate code, wherein a selective allocation request for the intermediate code is issued. A register allocating method characterized by setting the register information in an intermediate code and allocating a register to one of the operand and the work register according to the state of the operand.
【請求項8】 与えられたソースプログラムを中間コー
ドに変換し、該中間コードから目的プログラムを生成す
る過程において、該中間コードにレジスタを割り付ける
方法であって、 オペランドがレジスタに乗るか否かによって、一時的に
使用するレジスタの割り付け数を変動させることを特徴
とするレジスタ割り付け処理方法。
8. A method of allocating a register to an intermediate code in the process of converting a given source program into an intermediate code and generating an object program from the intermediate code, the method comprising: , A register allocation processing method characterized by varying the allocation number of registers to be used temporarily.
【請求項9】 与えられたソースプログラムを中間コー
ドに変換し、該中間コードから目的プログラムを生成す
る装置において、 前記中間コードに対する選択割り付け要求を該中間コー
ドのレジスタ情報に設定する手段と、 前記オペランドの状態に応じて、該オペランドと前記作
業用レジスタのうちの一方にレジスタを割り付ける手段
とを備えることを特徴とするコンパイラ装置。
9. An apparatus for converting a given source program into an intermediate code and generating an object program from the intermediate code, means for setting a selective allocation request for the intermediate code in register information of the intermediate code, A compiler apparatus comprising: a means for allocating a register to one of the operand and the work register according to the state of the operand.
JP26555794A 1994-10-28 1994-10-28 Method and device for register allocation Withdrawn JPH08123692A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP26555794A JPH08123692A (en) 1994-10-28 1994-10-28 Method and device for register allocation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP26555794A JPH08123692A (en) 1994-10-28 1994-10-28 Method and device for register allocation

Publications (1)

Publication Number Publication Date
JPH08123692A true JPH08123692A (en) 1996-05-17

Family

ID=17418770

Family Applications (1)

Application Number Title Priority Date Filing Date
JP26555794A Withdrawn JPH08123692A (en) 1994-10-28 1994-10-28 Method and device for register allocation

Country Status (1)

Country Link
JP (1) JPH08123692A (en)

Similar Documents

Publication Publication Date Title
JP3945829B2 (en) Processing device for executing virtual machine instructions
JP2001290658A (en) Circuit and method for mapping
EP0889405A1 (en) Software debugging method
JP2003044273A (en) Data processor and data processing method
JP2551167B2 (en) Microcomputer
JPH08123692A (en) Method and device for register allocation
CN116107639A (en) Register renaming and instruction decoding method and device, processor and electronic equipment
JP3296027B2 (en) Compilation method when using additional registers of load store type processor
JPS63113634A (en) Relative address calculation system for program counter
JP2814683B2 (en) Instruction processing unit
JP2845694B2 (en) Data processing device
JP2927102B2 (en) Instruction string switching method and arithmetic processor using the same
JP3464019B2 (en) Register allocation method
JPH06324882A (en) Compiler device
JPH08221271A (en) Pipeline processor
JPH03263265A (en) Vector processor
JPH08272411A (en) Ladder instruction processor
JP3237591B2 (en) Compiling device, compiling method, and recording medium recording compiler
JP2001290653A (en) Resource-assigning device
JPS6149695B2 (en)
JPH09244918A (en) Function addition system to interpreter with debugger
JPS58149571A (en) Processing system of vector operation in information processing device
JPH0535499A (en) Data processing device and method
JPH02201541A (en) Compiling system
JPH08123693A (en) Method and device for register allocation

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20020115