JPH01136240A - Register allocation processing system in compiler - Google Patents

Register allocation processing system in compiler

Info

Publication number
JPH01136240A
JPH01136240A JP62295877A JP29587787A JPH01136240A JP H01136240 A JPH01136240 A JP H01136240A JP 62295877 A JP62295877 A JP 62295877A JP 29587787 A JP29587787 A JP 29587787A JP H01136240 A JPH01136240 A JP H01136240A
Authority
JP
Japan
Prior art keywords
registers
global
local
register
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.)
Pending
Application number
JP62295877A
Other languages
Japanese (ja)
Inventor
Masakazu Hayashi
正和 林
Makoto Nakanishi
誠 中西
Yoshihiro Naito
良浩 内藤
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 JP62295877A priority Critical patent/JPH01136240A/en
Publication of JPH01136240A publication Critical patent/JPH01136240A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/441Register allocation; Assignment of physical memory space to logical memory space

Abstract

PURPOSE:To perform the optimization of an object by varying the number of global registers and that of local registers corresponding to a program. CONSTITUTION:The numbers of the global and the local registers are decided tentatively in advance, and they are registered in a register managing table 8. Next, the register managing table 8 is operated based on the result of prediction in a local prediction part 4. Afterwards, the compilation allocation processing of the local register to perform an actual arithmetic processing is performed. And a global count part 5 recognizes the number of the global registers used actually, and the register managing table 8 is operated based on the above result. Hereafter, the compilation allocation processing to perform the actual arithmetic processing is performed by a local allocation part 7, and its result is registered in the register managing table 8.

Description

【発明の詳細な説明】 〔目 次〕 概要 産業上の利用分野 従来の技術 発明が解決しようとする問題点 問題点を解決するための手段 作用 実施例 発明の効果 〔概 要〕 コンパイラにおけるレジスタ割付は処理方式に関し。[Detailed description of the invention] 〔table of contents〕 overview Industrial applications Conventional technology The problem that the invention aims to solve Means to solve problems action Example Effect of the invention 〔overview〕 Register allocation in the compiler is related to the processing method.

コンパイル処理の際にプログラムの内容に応じて、汎用
レジスタをローカル用またはグローバル用として割付け
ることを目的とし。
The purpose is to allocate general-purpose registers for local or global use depending on the program content during compilation processing.

複数のレジスタからなるレジスタ群と、前記レジスタに
ついて、グローバルレジスタとして使用するための割付
は処理を行うグローバル割付は部と、前記レジスタにつ
いて、ローカルレジスタとして使用するための割付は処
理を行うローカル割付は部と、レジスタ管理テーブルと
を有するコンパイラにおいて。
A register group consisting of multiple registers, a global allocation section that processes the allocation of the registers for use as global registers, and a local allocation section that processes the allocation of the registers for use as local registers. In a compiler having a register management table and a register management table.

コンパイル処理のために前記コンパイラに入力されたプ
ログラムについて、その必要とするローカルレジスタの
数を予測するローカル予測部と。
a local prediction unit that predicts the number of local registers required for a program input to the compiler for compilation processing;

コンパイル処理において前記グローバルレジスタとして
使用するように割付は処理されたレジスタの数をカウン
トするグローバルカウント部とを備え、コンパイル処理
の際に前記プログラムに応じて前記グローバルおよびロ
ーカルレジスタとして使用されるべきレジスタの数を可
変とするように構成する。
The allocation includes a global count unit that counts the number of processed registers to be used as the global registers in the compilation process, and the registers to be used as the global and local registers according to the program during the compilation process. The configuration is configured so that the number of is variable.

〔産業上の利用分野〕[Industrial application field]

本発明はコンパイラに関し、更に詳しくは、コンパイラ
におけるレジスタ割付は処理方式に関する。
The present invention relates to a compiler, and more particularly, register allocation in a compiler relates to a processing method.

汎用コンピュータの如きデータ処理装置においては、多
数の汎用レジスタを設け、これを用いて演算処理を行っ
ている。
In a data processing device such as a general-purpose computer, a large number of general-purpose registers are provided and used to perform arithmetic processing.

そこで、ソースプログラムをコンパイル(翻訳)処理し
てオブジェクトモジュールを得る際に。
Therefore, when compiling (translating) a source program to obtain an object module.

各汎用レジスタについてその具体的な用途等を指定した
く割付けした)オブジェクトモジュールを得る必要があ
る。
It is necessary to obtain an object module (allocated to specify the specific use etc. of each general-purpose register).

〔従来の技術〕[Conventional technology]

演算用の汎用レジスタにはレジスタ番号が付され1例え
ば、0番から5番まではローカル用のレジスタ(ローカ
ルレジスタ)、6番から10番まではグローバル用のレ
ジスタ(グローバルレジスタ)というように割付けられ
(仮の割付け)、その用途が予め定められていた。換言
すれば、ローカルレジスタの個数とグローバルレジスタ
の個数は、固定されていた。
General-purpose registers for calculations are assigned register numbers.1 For example, numbers 0 to 5 are assigned as local registers, numbers 6 to 10 are assigned as global registers, and so on. (temporary allocation), and its use was determined in advance. In other words, the number of local registers and the number of global registers were fixed.

ローカルレジスタは、プログラムのブロック。Local registers are blocks of the program.

即ち、命令が一旦実行開始されると他から割込まれるこ
とのない連続した処理の単位を処理するために用いるも
のであり、一方、グローバルレジスタは、複数のブロッ
クからなる例えばループ等を処理するために用いるもの
である。
In other words, once an instruction starts executing, it is used to process a continuous unit of processing that cannot be interrupted by anything else.On the other hand, global registers are used to process, for example, a loop consisting of multiple blocks. It is used for this purpose.

このように、予めその用途が割付けられた汎用レジスタ
について、この用途の割付けの範囲内において、実際の
演算処理を行うための割付け(コンパイル処理における
レジスタ割付け;以下、単にコンパイル割付けという)
が再度行なわれる。
In this way, for general-purpose registers that have been assigned their usage in advance, they are assigned to perform actual arithmetic processing within the scope of the assignment for this usage (register assignment in compilation processing; hereinafter simply referred to as compilation assignment).
will be performed again.

即ち、ソースプログラムをコンパイル処理してオブジェ
クトモジュールを得る際に、どの命令の処理においてど
の汎用レジスタをどう使うかが、レジスタ番号を指定し
て具体的に定められ(割付けられ)、オブジェクトとさ
れる。
In other words, when a source program is compiled to obtain an object module, the register numbers are specified (assigned) to specify (allocate) which general-purpose registers are to be used in which instruction processing, and the module is made into an object. .

〔発明が解決しようとする問題点〕[Problem that the invention seeks to solve]

第3図は従来技術の問題点を説明するためのプログラム
の一例である。
FIG. 3 is an example of a program for explaining the problems of the prior art.

第3図(A)に示すプログラム41は、整数型の乗算、
除算、剰余および文字関係の演算を含み、ローカルレジ
スタを多く必要とし、グローバルレジスタをあまり多く
必要としない例である。
The program 41 shown in FIG. 3(A) includes integer type multiplication,
This example includes division, remainder, and character-related operations, and requires many local registers, but not many global registers.

特に、  rcHl(1:A(1)+B(J))  −
cH2(J:C(J)−八(1)) Jは、最も多くの
ローカルレジスタを必要とする処理である。即ち、配列
中に文字型データを含んでいるため、どのような順で処
理を行っても9種々の命令中最多の6個のローカルレジ
スタが必要となる。
In particular, rcHl(1:A(1)+B(J)) −
cH2(J:C(J)-8(1)) J is the process that requires the most local registers. That is, since character type data is included in the array, no matter what order the processing is performed, six local registers, the most among nine different instructions, are required.

このようなプログラム41においては、 (他にグロー
バルレジスタを必要とする記述がなければ)グローバル
レジスタが余ることになる。しかし。
In such a program 41, there will be a surplus of global registers (if there is no other description that requires global registers). but.

コンパイル処理における汎用レジスタの割付けは。General-purpose register allocation during compilation processing.

固定された用途(仮の割付け)の範囲内でのものである
ため、余ったグローバルレジスタをローカルレジスタと
して使用することはできない、このため1割付は可能な
一時名を実際に割付けることができないので、この−時
名を生成名に退避させるための5TORE命令が生じて
しまい、最適化された処理(オブジェクト生成)を行う
ことができない。
Since it is within the range of fixed usage (temporary allocation), surplus global registers cannot be used as local registers. Therefore, it is not possible to actually allocate a temporary name, which is possible with 1 allocation. Therefore, a 5TORE instruction is generated to save this -time name to the generation name, making it impossible to perform optimized processing (object generation).

第3図(B)に示すプログラム42は、グローバルレジ
スタへ割付けることが望ましい制御変数、ループ回数、
ループ内の配列の基底および誘導変数等を含み、グロー
バルレジスタを多く必要とし。
The program 42 shown in FIG. 3(B) includes control variables that are preferably allocated to global registers, loop counts,
It requires many global registers, including the base and induction variables of the array within the loop.

ローカルレジスタはあまり多く必要としない例である。This is an example of not requiring too many local registers.

例えば、データx、y、zおよびQは浮動小数点型デー
タであるのでフローティング(浮動小数点)レジスタを
その処理のために用い、汎用レジスタは用いない(割付
けの対象外である)、一方。
For example, data x, y, z, and Q are floating point type data, so floating (floating point) registers are used for processing them, and general purpose registers are not used (not subject to allocation).

ループ内での配列X、YおよびZの基底、ループ回数1
.変数Q等をグローバルレジスタに割付けることにより
、プログラムの実行速度を向上させることができる。
Bases of arrays X, Y, and Z in loop, loop count 1
.. By allocating variables such as Q to global registers, the execution speed of the program can be improved.

このようなプログラム42においては、 (他にローカ
ルレジスタを必要とする記述がなければ)ローカルレジ
スタが余るが、コンパイル処理において、余ったローカ
ルレジスタをグローバルレジスタとして用いることは許
されない、このため、プログラムの実行速度の向上が可
能であるにも拘らず、そのためのコンパイル処理を行う
ことができなかった。
In such a program 42, local registers are left over (unless there is any other description that requires local registers), but during compilation processing, the leftover local registers are not allowed to be used as global registers. Although it is possible to improve the execution speed of , it has not been possible to perform the compilation process for this purpose.

以上述べたように、従来技術においては、汎用レジスタ
の用途、即ち、ローカルレジスタとグローバルレジスタ
の個数が予め固定されており、プログラムの内容に応じ
て汎用レジスタの仮の割付けを変更することができない
。このため、レジスタの使用効率が悪く、オブジェクト
モジュールの最適化ができず、実行速度を向上させるこ
とができなかった。
As described above, in the conventional technology, the purpose of general-purpose registers, that is, the number of local registers and global registers, is fixed in advance, and the temporary allocation of general-purpose registers cannot be changed depending on the contents of the program. . As a result, register usage efficiency was poor, object modules could not be optimized, and execution speed could not be improved.

本発明は、コンパイル処理の際にプログラムの内容に応
じて、汎用レジスタをローカル用またはグローバル用と
して割付けることが可能なコンパイラにおけるレジスタ
割付は処理方式を提供することを目的とする。
An object of the present invention is to provide a register allocation processing method in a compiler that can allocate general-purpose registers as local or global registers depending on the contents of a program during compilation processing.

〔問題点を解決するための手段〕 第1図は本発明の原理構成図であり1本発明によるデー
タ処理装置を示している。
[Means for Solving the Problems] FIG. 1 is a diagram showing the basic structure of the present invention, and shows a data processing device according to the present invention.

第1図において、1はコンパイラ、2は割付は処理部、
3は制御部、4はローカルレジスタ数を予測するローカ
ル予測部、5は実際に使用したグローバルレジスタ数を
カウントするグローバルカウント部、6はグローバルレ
ジスタの割付けを行うグローバル割付は部、7はローカ
ルレジスタの割付けを行うローカル割付は部、8はレジ
スタ管理テーブル、9は0番からn番までのレジスタ番
号が付された(n + 1)個の汎用レジスタからなる
レジスタ群、 10は中間テキストの如きプログラム。
In Figure 1, 1 is the compiler, 2 is the processing section, and
3 is a control unit, 4 is a local prediction unit that predicts the number of local registers, 5 is a global count unit that counts the number of global registers actually used, 6 is a global allocation unit that allocates global registers, and 7 is a local register. 8 is a register management table, 9 is a register group consisting of (n + 1) general-purpose registers numbered from 0 to n, and 10 is an intermediate text etc. program.

11はオブジェクトモジュールである。11 is an object module.

コンパイラ1は、入力されたソースプログラムを構文解
析することによって中間テキストlOを生成し、さらに
、中間テキスト10に対応したオブジェクトモジュール
11を作成するため、汎用レジスタ群9についての必要
な割付は処理を行う、このために1割付は処理部2は、
中間テキス目0(即ち、中間テキスト10を構成する中
間言票)を走査し、コンパイル処理において、まず、グ
ローバルレジスタの割付は処理を行い1次に、ローカル
レジスタの割付は処理を行う。
The compiler 1 generates the intermediate text IO by parsing the input source program, and further creates the object module 11 corresponding to the intermediate text 10, so the necessary allocation of the general-purpose register group 9 is not processed. To do this, the processing unit 2 performs 1 allocation.
Intermediate text number 0 (that is, the intermediate text constituting the intermediate text 10) is scanned, and in the compiling process, global register allocation is first processed, and then local register allocation is processed.

グローバル割付は部6およびローカル割付は部7は、各
々、コンパイル処理におけるグローバルレジスタの割付
は処理およびローカルレジスタの割付は処理を、制御部
3の制御の下で行う。
The global allocation unit 6 and the local allocation unit 7 respectively perform global register allocation processing and local register allocation processing in the compiling process under the control of the control unit 3.

ローカル予測部4は、前記中間言票の走査、特にグロー
バルレジスタの割付は処理のためにループ内の中間言票
までを走査することを利用して。
The local prediction unit 4 utilizes the fact that the intermediate statements are scanned, and in particular, the global register allocation is performed by scanning up to the intermediate statements within the loop for processing.

そのループ内で必要なローカルレジスタの数を予測する
。ローカル予測部4 (制御部3)は、予測結果に基づ
いて、レジスタ管理テーブル8を操作し、仮に定められ
ていたグローバルレジスタ (として用いるように仮に
その用途が割付けられていたレジスタ)の数を増す。
Predict the number of local registers needed within that loop. The local prediction unit 4 (control unit 3) operates the register management table 8 based on the prediction result, and calculates the number of temporarily determined global registers (registers whose use has been temporarily assigned to be used as). Increase.

グローバルカウント部5は、グローバルレジスタのコン
パイル割付は処理の結果、いくつのグローバルレジスタ
が実際に使用されたかを、レジスタ管理テーブル8を参
照して知り、ローカルレジスタとして使用できるグロー
バルレジスタの数を知る。グローバルカウント部5 (
制御部3)は。
The global count unit 5 refers to the register management table 8 to know how many global registers are actually used as a result of the global register compile allocation process, and learns the number of global registers that can be used as local registers. Global count section 5 (
The control unit 3).

参照結果に基づいて、レジスタ管理テーブル8を操作し
、ローカルレジスタ(とじて用いるようにその用途が割
付けられるレジスタ)の数を増す。
Based on the reference result, the register management table 8 is operated to increase the number of local registers (registers whose purpose is assigned for use as a lock).

レジスタ管理テーブル8には、レジスタ群9の個々のレ
ジスタについて、予め定められたその用途(グローバル
用かローカル用か)の割付け(仮の割付け)、および、
実際の演算処理を行うための割付け(コンパイル処理に
おける割付け)が登録される。
The register management table 8 includes predetermined assignments (temporary assignments) of each register in the register group 9 to its use (global or local), and
Allocations for performing actual arithmetic processing (allocations in compilation processing) are registered.

〔作 用〕[For production]

コンパイル処理におけるレジスタ割付は処理に先立って
、レジスタ群9のレジスタの個数を考慮して、予めグロ
ーバル用およびローカル用のレジスタの個数が、仮に定
められ(用途が仮に割付けられ)、レジスタ管理テーブ
ル8に登録される。
For register allocation in the compilation process, prior to processing, the number of global and local registers is provisionally determined (the usage is provisionally allocated) in consideration of the number of registers in the register group 9, and the register management table 8 is will be registered.

ローカル予測部4における予測の結果、中間テキスト1
0の内容に応じた必要とされるであろうローカルレジス
タの数が仮に割付けられたローカルレジスタの数より少
ない場合、ローカルレジスタ数を減らしグローバルレジ
スタ数を増すように。
As a result of prediction in local prediction unit 4, intermediate text 1
If the number of local registers that would be required according to the contents of 0 is less than the number of allocated local registers, the number of local registers will be reduced and the number of global registers will be increased.

レジスタ管理テーブル8が操作される。Register management table 8 is manipulated.

この後、前記操作により変更された範囲において、グロ
ーバル割付は部6によって、実際の演算処理を行うため
のグローバルレジスタのコンパイル割付は処理が行なわ
れ、その結果がレジスタ管理テーブル8に登録される。
Thereafter, within the range changed by the above operation, the global allocation unit 6 performs compile allocation of global registers for performing actual arithmetic processing, and the results are registered in the register management table 8.

必要とされるグローバルレジスタの数が仮に割付けられ
たグローバルレジスタの数より多い場合でも、予めグロ
ーバルレジスタ数が増加されているので、必要な処理が
できる。
Even if the number of required global registers is greater than the number of allocated global registers, the necessary processing can be performed because the number of global registers has been increased in advance.

グローバルカウント部5は、レジスタ管理テーブル8を
参照して中間テキスト10の内容に応じて実際に使用さ
れたグローバルレジスタの数を知る。
The global count unit 5 refers to the register management table 8 and learns the number of global registers actually used according to the contents of the intermediate text 10.

これに基づいて、実際に使用したグローバルレジスタの
数が先に割付けられたグローバルレジスタの数より少な
い場合、グローバルレジスタ数を減らしローカルレジス
タ数を増すように、レジスタ管理テーブル8が操作され
る。
Based on this, if the number of global registers actually used is less than the number of previously allocated global registers, the register management table 8 is operated to decrease the number of global registers and increase the number of local registers.

この後、前記操作により変更された範囲内で。After this, within the range modified by said operation.

ローカル割付は部7によって、実際の演算処理を行うた
めのローカルレジスタのコンパイル割付は処理が行なわ
れ、その結果がレジスタ管理テーブル8に登録される。
The local allocation section 7 performs compilation allocation of local registers for performing actual arithmetic processing, and the results are registered in the register management table 8.

このように、経験的に得た必要とされるであろうグロー
バルおよびローカルレジスタ数を仮に割付け、これをプ
ログラム(中間テキスト10)の内容に応じて変更する
ことができる。従って、コンパイル処理において、最適
化されたレジスタ割付は処理を行うことができ、プログ
ラムの実行速度を向上することができる。
In this way, the number of global and local registers that will be required based on experience can be provisionally allocated, and this can be changed depending on the content of the program (intermediate text 10). Therefore, in the compilation process, optimized register allocation can be performed, and the execution speed of the program can be improved.

なお、汎用レジスタであっても、スタックポインタ、フ
レームポインタ、手続き呼出し時の入口アドレス用また
は戻りアドレス用の如く、その用途が決まっているもの
はレジスタ群9から除かれるものである。
Note that, even among general-purpose registers, those whose use is determined, such as a stack pointer, a frame pointer, an entry address when a procedure is called, or a return address, are excluded from the register group 9.

〔実施例〕〔Example〕

第2図は本発明のコンパイラにおけるレジスタ割付は処
理フローを示している。
FIG. 2 shows a processing flow for register allocation in the compiler of the present invention.

本実施例においては、第1図に示すコンパイラにおいて
、第3図に示すプログラムについてコンパイル処理を行
う場合のレジスタ割付は処理について、説明する。
In this embodiment, the register allocation process will be explained when the compiler shown in FIG. 1 compiles the program shown in FIG. 3.

本実施例のローカル予測部4は、その予測手段として、
ループの回帰計算を除いて、1ループ内において浮動小
数点演算以外の演算が現れるか否かを調べる手段を持つ
The local prediction unit 4 of this embodiment has the following as its prediction means:
Except for loop regression calculations, there is a means for checking whether operations other than floating point operations occur within one loop.

ローカル予測部4におけるローカルレジスタ数の判断基
準(予測手段)を前記の如(設定する理由は、浮動小数
点演算は全てフローティングレジスタを使用するので汎
用レジスタの割付けの対象外であること、第3図図示の
如きFORTRANのプログラムにおいてループ内の演
算の多くは行列演算などの浮動小数点演算が多いことに
よる。なお。
The criterion (prediction means) for determining the number of local registers in the local prediction unit 4 is set as described above (the reason is that all floating point operations use floating registers and are therefore not subject to general-purpose register allocation. This is because in the FORTRAN program shown in the figure, many of the operations within the loop are floating point operations such as matrix operations.

このような予測手段はコンパイラ(または割付は処理の
ためのプログラム)について1局所的かつ少量の修正を
行うことによって、実現することができる。
Such a prediction means can be realized by making one local and small modification to the compiler (or the program for processing the layout).

また0本実施例の汎用レジスタ群9は、0番から10番
までの11個からなるもの(n = 10)とされ。
The general-purpose register group 9 of this embodiment is made up of 11 registers numbered 0 to 10 (n = 10).

経験的に、仮の用途の割付けとして、0番から5番まで
の6個がローカルレジスタとされ、6番から10番まで
の5個がグローバルレジスタとされる。
Empirically, as a temporary allocation of uses, six registers numbered 0 to 5 are set as local registers, and five registers numbered 6 to 10 are set as global registers.

この汎用レジスタ群9は9本発明に従って、プログラム
の内容に応じて、全てのレジスタをローカルレジスタと
して使用する(割付ける)ことができ、また、4番から
10番までの7個のレジスタをグローバルレジスタとし
て使用する(割付ける)ことができるものとされる、グ
ローバルレジスタ数を7個とするのは、経験的に、どの
ようなプログラムであっても、4個のローカルレジスタ
を確保した方が望ましいと考えられるからである。
According to the present invention, all registers in the general-purpose register group 9 can be used (allocated) as local registers depending on the contents of the program, and seven registers from No. 4 to No. 10 can be used as global registers. The reason for setting the number of global registers that can be used (assigned) as registers to 7 is because, empirically, it is better to reserve 4 local registers for any program. This is because it is considered desirable.

即ち、ローカルレジスタ数を減らしすぎると、逆に、−
時名を生成名に退避させる5TORE命令が出てしまい
、オブジェクトが却って悪いものとなる可能性があるた
めである。
In other words, if the number of local registers is reduced too much, -
This is because a 5TORE command that saves the time name to the generated name will be issued, and the object may become worse.

なお、グローバルレジスタは10番から順に、ローカル
レジスタは0番から順に、各々使用される。
Note that global registers are used in order from number 10, and local registers are used in order from number 0.

ta)  ローカルレジスタが余る場合第3図(B)の
如きプログラムについてレジスタコンパイル割付は処理
は第2図に示す如くにされる。
ta) When local registers are left over, the register compile allocation process for the program shown in FIG. 3(B) is performed as shown in FIG.

■ ソースプログラムがコンパイラ1に入力され。■ The source program is input to compiler 1.

これに対応した中間テキスト10が生成されると。When intermediate text 10 corresponding to this is generated.

割付は処理部2は中間テキスト10から1つの00ルー
プを取出す。
As for the layout, the processing unit 2 extracts one 00 loop from the intermediate text 10.

■ 割付は処理部2は、取出したOOループについて、
これが最も内側(最内)のループか否かを判断する。
■ As for the allocation, the processing unit 2
Determine whether this is the innermost (innermost) loop.

■ 最内ループである場合9割付は処理部2は中間テキ
スト10を構成する中間言票を走査する。
(2) In the case of the innermost loop, the processing unit 2 scans the intermediate statements constituting the intermediate text 10 in the case of 9 allocation.

■ ローカル予測部4は、処理■における走査の結果を
利用して、当該ループ内において実行される演算が浮動
小数点演算のみか否かを判断する。
(2) The local prediction unit 4 uses the result of scanning in process (2) to determine whether or not the calculations executed in the loop are only floating point calculations.

■ 浮動小数点演算のみの場合、ローカル予測部4 (
制御部3)は、当該ループ内において必要とされるであ
ろうローカルレジスタ数が少ない(仮に割付けた数より
少ない)と判断する。そして。
■ In the case of only floating point operations, the local prediction unit 4 (
The control unit 3) determines that the number of local registers that will be required within the loop is small (less than the number that was provisionally allocated). and.

ローカル予測部4 (制御部3)は、レジスタ管理テー
ブル8を操作することによって、4番から7番までの7
個をグローバルレジスタとして割付けし直す(2個増加
させる)。
The local prediction unit 4 (control unit 3) operates the register management table 8 to predict the numbers 4 to 7.
reallocate (increase by 2) as global registers.

浮動小数点演算のみでない場合、ローカル予測部4 (
制御部3)は、処理■を省略する。
If it is not only floating point operations, the local prediction unit 4 (
The control unit 3) omits the process (2).

■ グローバル割付は部6が、オブジェクトモジュール
11を生成するために、演算処理に必要なグローバルレ
ジスタのコンパイル割付は処理を行う。
(2) The global allocation unit 6 performs compilation allocation of global registers necessary for arithmetic processing in order to generate the object module 11.

この割付けは、グローバルレジスタ数を知っている制御
部3 (ローカル予測部4)の制御の下でレジスタ管理
テーブル8を参照し、前記グローバルレジスタ数の範囲
内で行なわれる。
This allocation is performed within the range of the number of global registers by referring to the register management table 8 under the control of the control section 3 (local prediction section 4) which knows the number of global registers.

例えば、この処理■において第3図(B)の如きプログ
ラムについてのグローバルレジスタの割付は処理を行う
場合、処理■においてグローバルレジスタが2個増して
いるので、制御変数、誘導変数、ループ回数の他に、ル
ープ内の配列X、Y。
For example, when processing global register allocation for a program such as that shown in FIG. Then, the arrays X, Y in the loop.

Zの基底についてまでも、その処理のために、グローバ
ルレジスタを割付けることができる。これにより、ルー
プ内のオブジェクトが良好なものとなり、また、オブジ
ェクトサイズを小さくでき。
Even for the basis of Z, global registers can be allocated for processing. This makes the objects in the loop nicer and also reduces the object size.

全体としてプログラムの実行速度を向上できる。Overall program execution speed can be improved.

■ グローバルカウント部5 (制御部3)は、実際に
処理■においてグローバルレジスタとして使用した数を
、レジスタ管理テーブル8を参照して知る。そして9例
えば、5番以降のレジスタしか使用していない場合は、
4番のレジスタについての仮の割付けを、グローバルレ
ジスタからローカルレジスタへ変更するように、レジス
タ管理テーブル8を操作する。
(2) The global count unit 5 (control unit 3) refers to the register management table 8 and learns the number actually used as a global register in the process (2). 9For example, if only registers from number 5 onwards are used,
The register management table 8 is operated so as to change the temporary allocation of register No. 4 from a global register to a local register.

■ 処理■の後9割付は処理部2は当該ループ内の1つ
のブロックを取出す。
(2) After processing (2), the processing unit 2 takes out one block in the loop for 9 allocation.

■ ローカル割付は部7が、オブジェクトモジュール1
1を生成するために、演算処理に必要なローカルレジス
タのコンパイル割付は処理を行う、この割付けは、ロー
カルレジスタ数を知っている制御部3 (ローカル割付
は部7)の制御の下で、レジスタ管理テーブル8を参照
して行なわれる。
■ Local allocation is part 7, object module 1
1, compile allocation of local registers necessary for arithmetic processing is performed. This allocation is performed under the control of control unit 3 (local allocation unit 7), which knows the number of local registers. This is done with reference to the management table 8.

第3図(B)の如きプログラムについてのローカルレジ
スタの割付は処理を行う場合、処理■においてローカル
レジスタ数が2個減少しているが。
When processing the allocation of local registers for a program such as that shown in FIG. 3(B), the number of local registers is reduced by two in process (2).

データx、y、zおよびQは浮動小数点型であるから汎
用レジスタの割付けの対象外であり、4個のローカルレ
ジスタの範囲内でコンパイル割付けを行うことができ何
ら支障を生じない。
Since the data x, y, z, and Q are of floating point type, they are not subject to general-purpose register allocation, and compile allocation can be performed within the range of four local registers without causing any problems.

[相] ループ内の各ブロックについて、これを取出し
てローカルレジスタのコンパイル割付けを行う処理(処
理■および■)がくり返される。
[Phase] For each block in the loop, the process of extracting it and compiling and allocating the local register (processes ① and ②) is repeated.

■ プログラムの各ループについて、処理■ないし0が
くり返される。
■ For each loop of the program, processing ■ or 0 is repeated.

(bl  グローバルレジスタが余る場合第3図(A)
の如きプログラムについてのレジスタコンパイル割付は
処理を行う場合、その処理は次のようにされる。
(bl If there are excess global registers, Figure 3 (A)
When performing register compilation allocation processing for a program such as the following, the processing is performed as follows.

ループ内が浮動小数点演算のみではないので。Because the inside of the loop is not only floating point operations.

処理■は省略される。Processing ■ is omitted.

従って、処理■においては、グローバルレジスタの数を
最大5個として、この範囲内でコンパイル割付は処理が
行なわれる。
Therefore, in process (2), the number of global registers is set to five at most, and the compile allocation process is performed within this range.

第3図(A)の如きプログラムにあっては(他にグロー
バルレジスタを必要とする記述がなければ)、処理■に
おいてグローバルレジスタを使用しないので、処理■に
おいてレジスタ群9の全てのレジスタをローカルレジス
タとして使用できるように、レジ長夕管理テーブル8が
操作される。
In a program like the one shown in Figure 3 (A) (unless there is any other description that requires global registers), global registers are not used in process (2), so all registers in register group 9 are localized in process (2). The cash register management table 8 is operated so that it can be used as a register.

tc+  前記の場合以外の場合 前記中)の場合と同様に、グローバルレジスタ数を最大
5個までとして処理■を行い、その結果に応じて、処理
■においてローカルレジスタ数の変更(増加)が行なわ
れる。
tc+ Cases other than the above As in the case (middle) above, process (2) is performed with the number of global registers up to 5, and according to the result, the number of local registers is changed (increased) in process (2). .

以上本発明を実施例により説明したが1本発明はその主
旨に従い種々の変形が可能である。
Although the present invention has been described above with reference to embodiments, the present invention can be modified in various ways according to its gist.

例えば、ローカル予測部4における予測手段として、処
理■における中間8票の走査の際に、ローカルレジスタ
のコンパイル割付は処理のアルゴリズムを適用して(ロ
ーカル割付は部7において擬似的にローカルレジスタの
コンパイル割付けを行って)、必要なローカルレジスタ
数を厳密に求めるような手段を用いてもよい。
For example, as a prediction means in the local prediction unit 4, when scanning the intermediate 8 votes in process Alternatively, the number of necessary local registers may be precisely determined by performing allocation).

また、ループ内にローカルレジスタを多く使用する8票
(文字演算、整数の乗算、除算、剰余)が現れなければ
、1つの中間8票が必要とするローカルレジスタ数は少
ない(オペランドにつき1個程度)と考えられるので、
必要なローカルレジスタ数は少ないと考えられる。従っ
て、予測手段として、前記判断に基づいて、ローカルレ
ジスタ数を予測するようにしてもよい。
Also, if there are no 8 votes that use many local registers (character operations, integer multiplication, division, remainder) in the loop, the number of local registers required for one intermediate 8 vote is small (about 1 for each operand). ), so
It is believed that the number of local registers required is small. Therefore, the prediction means may predict the number of local registers based on the above judgment.

(発明の効果〕 以上説明したように1本発明によれば、コンパイラにお
けるレジスタ割付は処理において、グローバルレジスタ
数とローカルレジスタ数を固定することなくプログラム
に応じて変動できるようにすることにより、汎用レジス
タの使用効率を向上させ、オブジェクトの最適化を図り
、プログラムの実行速度を向上させることができる。
(Effects of the Invention) As explained above, according to the present invention, the register allocation in the compiler is made general-purpose by allowing the number of global registers and the number of local registers to be changed according to the program during processing without being fixed. It is possible to improve register usage efficiency, optimize objects, and improve program execution speed.

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

第1図は本発明の原理構成図。 第2図はレジスタ割付は処理フロー図。 第3図は従来技術の問題点説明図。 図中、1はコンパイラ、2は割付は処理部、3は制御部
、4はローカル予測部、5はグローバルカウント部、6
はグローバル割付は部、7はローカル割付は部、8はレ
ジスタ管理テーブル、9はレジスタ群、 10は中間テ
キスト、11はオブジェクトモジュール。
FIG. 1 is a diagram showing the principle configuration of the present invention. FIG. 2 is a processing flow diagram for register allocation. FIG. 3 is a diagram illustrating problems in the prior art. In the figure, 1 is the compiler, 2 is the allocation processing section, 3 is the control section, 4 is the local prediction section, 5 is the global count section, 6
is a global allocation section, 7 is a local allocation section, 8 is a register management table, 9 is a register group, 10 is an intermediate text, and 11 is an object module.

Claims (1)

【特許請求の範囲】 グローバルレジスタとして使用されるべき複数のレジス
タとローカルレジスタとして使用されるべき複数のレジ
スタとからなるレジスタ群(9)と、前記レジスタにつ
いて、前記グローバルレジスタとして使用するための割
付け処理を行うグローバル割付け部(6)と、 前記レジスタについて、前記ローカルレジスタとして使
用するための割付け処理を行うローカル割付け部(7)
と、 前記レジスタの各々についての前記割付け処理の結果が
登録されるレジスタ管理テーブル(8)とを有するコン
パイラにおいて、 コンパイル処理のために前記コンパイラに入力されたプ
ログラム(10)について、その必要とするローカルレ
ジスタの数を予測するローカル予測部(4)と、 コンパイル処理において前記グローバルレジスタとして
使用するように割付け処理されたレジスタの数を、前記
レジスタ管理テーブル(8)を参照してカウントするグ
ローバルカウント部(5)とを備え。 前記グローバルレジスタの割付け処理に先立って前記予
測を行いその結果に基づいてグローバルレジスタとして
使用されるべきレジスタの数を増すと共に、前記グロー
バルレジスタの割付け処理後に前記カウントの結果に基
づいてローカルレジスタとして使用されるべきレジスタ
の数を増すことによって、コンパイル処理の際に前記プ
ログラム(10)に応じて前記グローバルおよびローカ
ルレジスタとして使用されるべきレジスタの数を可変と
した ことを特徴とするコンパイラにおけるレジスタ割付け処
理方式。
[Claims] A register group (9) consisting of a plurality of registers to be used as global registers and a plurality of registers to be used as local registers, and allocation of the registers for use as the global registers. a global allocation unit (6) that performs processing; and a local allocation unit (7) that performs allocation processing for using the register as the local register.
and a register management table (8) in which the results of the allocation processing for each of the registers are registered, with respect to the program (10) input to the compiler for compilation processing, the necessary a local prediction unit (4) that predicts the number of local registers; and a global count that counts the number of registers allocated to be used as the global registers in the compilation process with reference to the register management table (8). Part (5). Performing the prediction prior to the global register allocation process, increasing the number of registers to be used as global registers based on the result, and using the registers as local registers based on the count result after the global register allocation process. Register allocation in a compiler, characterized in that the number of registers to be used as the global and local registers is made variable according to the program (10) during compilation processing by increasing the number of registers to be used as the global and local registers. Processing method.
JP62295877A 1987-11-24 1987-11-24 Register allocation processing system in compiler Pending JPH01136240A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP62295877A JPH01136240A (en) 1987-11-24 1987-11-24 Register allocation processing system in compiler

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP62295877A JPH01136240A (en) 1987-11-24 1987-11-24 Register allocation processing system in compiler

Publications (1)

Publication Number Publication Date
JPH01136240A true JPH01136240A (en) 1989-05-29

Family

ID=17826334

Family Applications (1)

Application Number Title Priority Date Filing Date
JP62295877A Pending JPH01136240A (en) 1987-11-24 1987-11-24 Register allocation processing system in compiler

Country Status (1)

Country Link
JP (1) JPH01136240A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH03269638A (en) * 1990-03-19 1991-12-02 Fujitsu Ltd Control processing system for allocation of register

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6158046A (en) * 1984-08-29 1986-03-25 Fujitsu Ltd Register assigning system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6158046A (en) * 1984-08-29 1986-03-25 Fujitsu Ltd Register assigning system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH03269638A (en) * 1990-03-19 1991-12-02 Fujitsu Ltd Control processing system for allocation of register

Similar Documents

Publication Publication Date Title
CN101268444B (en) For the data transaction of Stream Media Application on multiprocessor
JP2738692B2 (en) Parallel compilation method
Gross et al. Compilation for a high-performance systolic array
CN101923492B (en) Method for executing dynamic allocation command on embedded heterogeneous multi-core
Lee et al. A vertically layered allocation scheme for data flow systems
CN102750131A (en) Graphics processing unit (GPU) oriented bitonic merge sort method
WO2004074962A2 (en) Allocation of processes to processors in a processor array
US6038397A (en) System for allocating the memory area of second data which value need not be preserved to another data of some of the processes
Aida et al. Compiling concurrent rewriting onto the rewrite rule machine
JPH01136240A (en) Register allocation processing system in compiler
CN112579089B (en) Heterogeneous many-core data reuse method
Moon et al. Generalized multiway branch unit for VLIW microprocessors
JPH05324430A (en) Data processor
JPS62219130A (en) Optimizing system for program
Berthold et al. Comparing and optimising parallel Haskell implementations for multicore machines
KR100912114B1 (en) A Memory Assignment Method for X-Y Data Transfer
JPH0628324A (en) Parallel computer and compiler
Yamana et al. A macrotask-level unlimited speculative execution on multiprocessors
CN1365047A (en) Sub pipeline and pipeline executed in a superlong instruction character
Kvas et al. Evaluation of static program allocation schemes for macro data-flow computer
JPH02171831A (en) Data access system for compiler
CN117910026A (en) Acceleration method of fully homomorphic encryption neural network based on coarse-granularity reconfigurable hardware
JP3625878B2 (en) Stack area allocation method by the compiler
Luque et al. Heuristic algorithms for register allocation
DeLeone et al. Optimal Resource Allocation and Binding of Non-Pipelined Designs