JPH04141737A - Register re-assignment system - Google Patents

Register re-assignment system

Info

Publication number
JPH04141737A
JPH04141737A JP26573790A JP26573790A JPH04141737A JP H04141737 A JPH04141737 A JP H04141737A JP 26573790 A JP26573790 A JP 26573790A JP 26573790 A JP26573790 A JP 26573790A JP H04141737 A JPH04141737 A JP H04141737A
Authority
JP
Japan
Prior art keywords
instruction
register
instructions
block
memory
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
JP26573790A
Other languages
Japanese (ja)
Inventor
Kuniko Yamamoto
山本 久仁子
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NEC Corp
Original Assignee
NEC Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NEC Corp filed Critical NEC Corp
Priority to JP26573790A priority Critical patent/JPH04141737A/en
Publication of JPH04141737A publication Critical patent/JPH04141737A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To reduce object size by studying the dependence of included commands on a register as well as the state of equivalence relationships between a memory and the register with respect to a command block which is a maximum unit of the linear migration of control, executing re-assigning the register and deleting unnecessary commands. CONSTITUTION:The system consists of a command input means 1, a command block dividing means 2, a means 3 analizing register flow between blocks, an equivalence relationships analizing means 4, a register re-assignment means 5, a command output means 6, a command development memory 7, block tables 8, equivalence relationships table 9 and a command storage medium 10. With respect to a command block which is a maximum unit of the linear migration of control, the dependence of included commands on the register as well as the state of the equivalence relationships between the memory and the register are studied, the re-assignment of the register is executed and unnecessary load commands are deleted. Thus, the object size can be reduced.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明はレジスタ再割付は方式に関し、特にメモリ・レ
ジスタ間のロード/ストア命令をもち、間接分岐命令を
もたないアーキテクチャ上におけるレジスタ再割付は方
式に関する。
[Detailed Description of the Invention] [Field of Industrial Application] The present invention relates to a method for register reallocation, particularly register reallocation on architectures that have load/store instructions between memory and registers but do not have indirect branch instructions. is related to the method.

〔従来の技術〕[Conventional technology]

従来、レジスタの割付けは、コンパイラ内部の中間テキ
スト、またはコード生成後のテキストに対して行われて
おり、(レジスタ割付けも含めて)機械語命令の生成完
了後に、再度レジスタの割付けが行われることはなかっ
た。
Traditionally, register allocation has been done to intermediate text inside the compiler or to text after code generation, and register allocation has to be done again after machine language instruction generation (including register allocation) has been completed. There was no.

〔発明が解決しようとする課題〕[Problem to be solved by the invention]

上述したコンパイラ内部の中間テキスト、またはコード
生成後のテキストに対して行う従来のレジスタ割付は方
式では、必すしも同値関係(命令実行中のある時点て、
メモリの内容とレジスタの内容とが同じ値である関係)
を考慮したレノスタ割付けが行われているとはかぎらず
、同値関係を有効利用しない不要なロード命令が生成さ
れる場合があり、オブジェクトサイズの増大や実行スピ
ードの低下を招くという問題点があった。
Conventional register allocation methods for intermediate text inside the compiler or text after code generation described above do not necessarily involve equivalence relationships (at some point during instruction execution,
A relationship in which the contents of memory and the contents of a register are the same value)
Renostar allocation is not always carried out in consideration of this, and unnecessary load instructions that do not effectively utilize equivalence relationships may be generated, leading to problems such as an increase in object size and a decrease in execution speed. .

また、コンパイラの構成に依存する中間テキスト、また
はフード生成後のテキストに対してレジスタを割付けて
いたため、コンパイラごとにフッバイラ特有のレジスタ
割付は処理を用意しなければならないという問題点があ
った。
Furthermore, since registers were allocated to intermediate text depending on the compiler configuration or text after food generation, there was a problem in that each compiler had to prepare a process for register allocation specific to Hubbaira.

本発明の目的は、オブジェクトサイズを縮小することが
でき、実行速度も向上できるとともに、コンパイラごと
にコンパイラ特有のレジスタ割付は処理を用意する必要
がないレジスタ再割付は方式を提供することにある。
An object of the present invention is to provide a register reallocation method that can reduce object size, improve execution speed, and eliminate the need for compiler-specific register allocation processing for each compiler.

〔課題を解決するための手段〕[Means to solve the problem]

第1の発明のレジスタ再割付は方式は、メモリとレジス
タとの間のロード/ストア命令をもち、間接分岐命令を
もたないアーキテクチャ上のレジスタ再割付は方式にお
いて、 (A)命令を格納した媒体から命令の並びを入力してメ
モリ上に展開する命令入力手段、(B)入力した前記命
令を解析して、分岐命令の直後と分岐先ラベル位置で命
令の並びを分割して命令ブロックを作成し、同時に分割
した前記命令ブロック間の制御の流れを求める命令ブロ
ック分割手段、 (C)前記分割した命令ブロンク間のレジスタの定義書
参照の依存関係を調査し、前記命令ブロックの入口/出
口で生きているレジスタを求めるプロ、り間レジスタフ
ロー解析手段、(D)前記分割した命令ブロック内の命
令について、命令実行中のある時点て前記メモリの内容
と前記レジスタの内容とが同じ値の関係をボす同値関係
の状態を解析する同値関係解析手段、 (E)前記同値関係の付いた前記メモリからの不要なロ
ード命令があれば、矛盾がないように前記レジスタの再
割付けを行って不要なロード命令を削除するレジスタ再
割付は手段、(F)分割したすべての前記命令ブロック
に関して同値関係解析及びレジスタ再割付けを行った後
、命令を格納してあった前記媒体にレジスタ再割付は済
命令の並びを出力する命令出力手段、 を有して構成されている。
The register reallocation method of the first invention is an architectural register reallocation method that has load/store instructions between memory and registers and does not have indirect branch instructions. (B) An instruction input means for inputting a sequence of instructions from a medium and expanding it onto a memory; (B) analyzing the inputted instructions and dividing the sequence of instructions immediately after a branch instruction and at a branch destination label position to create an instruction block; (C) An instruction block dividing means for determining the flow of control between the instruction blocks created and divided at the same time; (D) For an instruction in the divided instruction block, the contents of the memory and the contents of the register have the same value at a certain point during instruction execution. (E) an equivalence relationship analysis means for analyzing the state of an equivalence relationship that violates the relationship; Register reallocation is a means to delete unnecessary load instructions. (F) After performing equivalence relationship analysis and register reallocation for all the divided instruction blocks, register reallocation is carried out on the medium where the instructions were stored. The apparatus includes an instruction output means for outputting a list of completed instructions.

また、第2の発明のレジスタ再割付は方式は、メモリと
レジスタとの間のロード/ストア命令をもち、間接分岐
命令をもたないアーキテクチャ上のレジスタ再割付は方
式において、 (A)命令を格納した媒体から命令の並びを入力してメ
モリ上に展開するステ・ツブ、 (B)入力した前記命令を解析して、分岐命令の直後と
分岐先ラベル位置で命令の並びを分割して命令ブロック
を作成し、同時に分割した前記命令ブロック間の制御の
流れを求めるステップ) (C)前記分割した命令ブロック間のレジスタの定義・
参照の依存関係を訳査し、前記命令ブロックの入口/出
口で生きているレジスタを求めるステップ、 (D)前記分割した命令ブロック内の命令ζこつ(1て
、命令実行中のある時点て前記メモリの内容と前記レジ
スタの内容とが同じ値の関係を示す同値関係の状態を解
析するステ・ツブ、(E)前記同値関係の付いた前記メ
モリからの不要なロード命令があれば、矛盾かな0よう
番こ前記レジスタの再割付けを行って不要なロード命令
を削除するステ・ツブ、 (F)分割したすべての前記命令ブロック(こ関して同
値関係解析及びレジスタ再割付けを行った後、命令を格
納してあった前記媒体(こレジスタ再割付は済命令の並
びを出力するステ・ツブ、 を実行するように構成されている。
In addition, the register reallocation method of the second invention has load/store instructions between memory and registers, and the register reallocation method based on the architecture does not have indirect branch instructions. (B) Analyzes the input instructions and divides the instruction sequence immediately after the branch instruction and at the branch destination label position to generate instructions. (C) Definition of registers between the divided instruction blocks (C) Definition of registers between the divided instruction blocks
interpreting reference dependencies and finding live registers at the entry/exit of the instruction block; (D) instructions in the divided instruction block (1. A step to analyze the state of an equivalence relationship in which the contents of the memory and the contents of the register have the same value; (E) If there is an unnecessary load instruction from the memory with the equivalence relationship, it is determined whether there is a contradiction. (F) All divided instruction blocks (after performing equivalence relationship analysis and register reallocation) The program is configured to execute a step that outputs a sequence of instructions that have been stored on the medium (this register reallocation has been completed).

〔実施例〕〔Example〕

次に、本発明の実施例について図面を参照して説明する
Next, embodiments of the present invention will be described with reference to the drawings.

第1図は本発明の一実施例のブロック図である。FIG. 1 is a block diagram of one embodiment of the present invention.

第1図に示すレジスタ再割付は方式は、命令を格納した
媒体から命令の並びを入力してメモリ上に展開する命令
入力手段1、入力した命令を解析して、分岐命令の直後
と分岐先ラベル位置で命令の並びを分割して命令ブロッ
クを作成し、同時に分割した前記命令ブロック間の制御
の流れを求める命令ブロック分割手段2、分割した命令
ブロック間のレジスタの定義φ参照の依存関係を調査し
、命令ブロックの入口/出口で生きているレジスタを求
めるブロック間レジスタフロー解析手段3、分割した命
令ブロック内の命令について、命令実行中のある時点で
メモリの内容とレジスタの内容とが同じ値の関係を示す
同値関係の状態を解析する同値関係解析手段4、同値関
係の付いたメモリからの不要なロード命令があれば、矛
盾がないようにレジスタの再割付けを行って不要なロー
ド命令を削除するレジスタ再割付は手段5、分割したす
べての命令ブロックに関して同値関係解析及びレジスタ
再割付けを行った後、命令を格納してあった媒体にレジ
スタ再割付は済命令の並びを出力する命令出力手段6、
命令展開メモリ7、ブロックテーブル群8、同値関係表
9、命令格納媒体(ファイルまたはメモリ)10から構
成されている。
The register reallocation shown in Figure 1 consists of an instruction input means 1 that inputs a sequence of instructions from a medium storing instructions and expands them on memory, and an instruction input means 1 that analyzes the input instructions and stores them immediately after the branch instruction and at the branch destination. An instruction block dividing means 2 which creates instruction blocks by dividing a sequence of instructions at label positions and simultaneously determines the flow of control between the divided instruction blocks; Inter-block register flow analysis means 3 to investigate and find registers that are alive at the entrance/exit of an instruction block.For instructions in divided instruction blocks, the contents of memory and the contents of registers are the same at a certain point during instruction execution. Equivalence relationship analysis means 4 that analyzes the state of equivalence relationships that indicate value relationships.If there is an unnecessary load instruction from memory with an equivalence relationship, registers are reallocated to avoid conflicts and the unnecessary load instructions are removed. Means 5 is an instruction to perform equivalence relation analysis and register reallocation for all divided instruction blocks, and then output a sequence of register reallocated instructions to the medium where the instructions were stored. output means 6,
It is composed of an instruction expansion memory 7, a block table group 8, an equivalence relationship table 9, and an instruction storage medium (file or memory) 10.

なお、第1図の各ブロック間の処理の流れは、太線の矢
印で示され、データの流れは細線の矢印で示されている
Note that the flow of processing between each block in FIG. 1 is shown by thick line arrows, and the flow of data is shown by thin line arrows.

次に、動作を説明する。Next, the operation will be explained.

まず、命令入力手段1により、命令を格納した任意の媒
体(ファイルまたはメモリ)′10から命令の並びを入
力する。入力は一命令ずつ行い、命令展開メモリ7上に
展開した後、−命令ごとに、命令ブロック分割手段2に
より、命令を解析しながら、制御上入口が一つで出口が
一つ、かつ途中に出口以外の分岐がないような単位(以
降「命令ブロック」または単に「ブロック」と呼ぶ)に
命令の並びを分割していく。
First, the command input means 1 inputs a sequence of commands from any medium (file or memory) '10 storing commands. Input is performed one instruction at a time, and after expansion on the instruction expansion memory 7, the instruction is analyzed by the instruction block dividing means 2 for each instruction. The sequence of instructions is divided into units (hereinafter referred to as "instruction blocks" or simply "blocks") that have no branches other than exits.

命令ブロック分割手段2の処理の流れは第2図に示す通
りである。分割された命令プロ、ツクは、第4図に示す
ようなブロックテーブルが命令展開メモリ7中のブロッ
クの先頭命令をポイントすることにより表現される。
The processing flow of the instruction block dividing means 2 is as shown in FIG. The divided instruction programs are expressed by pointing the block table shown in FIG. 4 to the first instruction of the block in the instruction expansion memory 7.

命令ブロック分割手段2は、命令コードを解析しくステ
ップ11)、対象命令が分岐命令か否かを判断しくステ
ップ12)、分岐命令のときのみブロック分割処理を行
う。すなわち、対象命令が分岐命令ならば、まず、分岐
命令の次の命令を指しているブロックテーブルを検索し
くステップ13)、すでにあれば何もしない。もし、分
岐命令の次の命令を指しているブロックテーブルがなけ
れば、ブロックテーブルを一つ作成しくステップ14)
、分岐命令の次の命令を、次ブロックの最初の命令とし
て命令へのポインタ(または命令展開メモリ7上の展開
命令内相対オフセット、以降の命令へのポインタも同様
)を設定し、プロ、ツクテーブルが命令のアドレス順に
チェ一二ングされるように、前後のブロックテーブルと
チエ一二ングする(ステップ15)。そして、さらに分
岐命令が条件分岐命令か否かを判断しくステップ16)
、条件分岐命令の場合は、ブロックテーブルを新しく作
成しなかった場合も含めて、現ブロックテーブルとの間
を、制御順先行ブロックポインタ及び制御順後続ブロッ
クポインタで互いにチェーニングする(ステップ17)
。また、分岐命令の分岐相対オフセットから、下方向分
岐か否かを判断しくステップ18)、下方向分岐ならば
無条件にブロックテーブルを作成しくステップ20)、
上方向分岐ならば分岐先命令をポイントするブロックテ
ーブルがあるか否かを判断しくステップ19)、ブロッ
クテーブルがないときのみ、ブロックテーブルを作成し
て(ステップ20)、前記と同様に命令のアドレス順に
前後のブロックテーブルとチェーニングしくステップ2
1)、さらにブロックテーブルを新しく作成しなかった
場合も含ぬて、前記と同様に制御順に現ブロックテーブ
ルとチェーニングする(ステップ22)。これで、分岐
命令の直後、及び分岐先ラベル位置でブロックが分割さ
れたことになり、命令入力手段1と命令ブロック分割手
段2とを繰り返し、全命令について前記の処理を行うと
、ブロックテーブル単位の制御フローができあがる。
The instruction block division means 2 analyzes the instruction code (step 11), determines whether the target instruction is a branch instruction (step 12), and performs block division processing only when the instruction is a branch instruction. That is, if the target instruction is a branch instruction, first the block table pointing to the next instruction of the branch instruction is searched (step 13), and if it already exists, nothing is done. If there is no block table pointing to the next instruction after the branch instruction, create one (step 14).
, sets the instruction next to the branch instruction as the first instruction of the next block (or the relative offset within the expanded instruction on the instruction expansion memory 7, and the same goes for the pointer to subsequent instructions), and The table is checked with the preceding and succeeding block tables so that the table is checked in the order of the addresses of the instructions (step 15). Then, it is further determined whether the branch instruction is a conditional branch instruction or not (step 16).
, In the case of a conditional branch instruction, even if a new block table is not created, the current block table is chained with the control order preceding block pointer and the control order succeeding block pointer (step 17).
. Also, from the branch relative offset of the branch instruction, it is determined whether it is a downward branch or not (Step 18), and if it is a downward branch, a block table is unconditionally created (Step 20).
If it is an upward branch, it is determined whether there is a block table that points to the branch destination instruction (step 19), and only if there is no block table, a block table is created (step 20), and the address of the instruction is determined in the same way as above. Step 2 Chaining with the front and rear block tables in order
1), chaining is performed with the current block table in the same control order as described above, even if no new block table is created (step 22). Now, the block is divided immediately after the branch instruction and at the branch destination label position.If the instruction input means 1 and the instruction block division means 2 are repeated and the above processing is performed for all instructions, the block table will be divided. A control flow is created.

このブロックテーブルの集りをブロックテーブル群8と
呼ぶ。
This collection of block tables is called a block table group 8.

次に、ブロック間レジスタフロー解析手段3によって、
ブロック間のレジスタの依存関係(ブロック間にまたが
ってその値が引き継がれるか否かの関係、レジスタ上の
値が引き継がれている間は、そのレジスタは「生きてい
る」という)を調へ、ブロックの入口で生きているレジ
スタ、及びブロックの出口で生きているレジスタを求め
る。
Next, by the inter-block register flow analysis means 3,
Determine the dependencies of registers between blocks (the relationship of whether or not the value is inherited across blocks; while the value on the register is inherited, the register is said to be "alive"), Find the registers that are alive at the entrance of the block and the registers that are alive at the exit of the block.

ブロックごとに、含まれる命令列を各レジスタに着目し
て解析し、ブロック内で最初に現われたレジスタアクセ
ス命令がレジスタ参照命令ならば、そのレジスタはブロ
ックの入口で生きていることになる。ブロックテーブル
を、ブロックテーブル起点ポインタからアドレス順チェ
ーンにしたがってたどり、上記のように全ブロックに関
してその入口で生きているレジスタを洗い出し、各ブロ
ックテーブルに設定する。次に、ブロックテーブルを制
御フローの逆順にたどり、ブロックの出口で生きている
レジスタを求め、各ブロックテーブルに設定する。ブロ
ックの出口で生きているレジスタとは、制御移行上の直
後のブロックの出口で生きていて、そのブロックで定義
されていないレジスタと、制御移行上の直後のブロック
の入口で生きているレジスタとの和集合である。
For each block, the included instruction string is analyzed focusing on each register, and if the first register access instruction that appears in the block is a register reference instruction, that register is alive at the entrance of the block. The block table is traced from the block table starting point pointer according to the address order chain, and as described above, registers that are active at the entrance of all blocks are identified and set in each block table. Next, the block table is traversed in reverse order of control flow to determine which registers are alive at the exit of the block and set in each block table. Registers that are alive at the exit of a block are registers that are alive at the exit of the block that immediately follows on a control transition and are not defined in that block, and registers that are alive at the entrance of the block that immediately follows on a control transition. is the union of

ブロックの入口/出口で生きているレジスタの情報が得
られたならば、次に同値関係解析手段4によって、メモ
リとレジスタとの間の同値関係を解析する(ここでいう
同値関係とは、前述したように命令実行中のある時点て
、メモリの内容とレジスタの内容とが同じ値である関係
のことであり、一般にメモリからレジスタへのロード命
令、及びレジスタからメモリへのストア命令によって付
けられる)。
Once the information on the registers alive at the entrance/exit of the block is obtained, the equivalence relationship analysis means 4 analyzes the equivalence relationship between the memory and the register (the equivalence relationship here refers to the It is a relationship in which the contents of memory and the contents of a register have the same value at a certain point during instruction execution, as shown above, and is generally created by load instructions from memory to registers and store instructions from registers to memory. ).

同値関係解析手段4の処理の流れは第3図に示す通りで
ある。同値関係解析手段4は、第5図に示すような同値
関係表9を使用して、プロ・νり内の命令について、−
命令ずつ命令コードによって以下のような処理をしてい
く。
The processing flow of the equivalence relation analysis means 4 is as shown in FIG. The equivalence relation analysis means 4 uses an equivalence relation table 9 as shown in FIG.
The following processing is performed for each instruction using the instruction code.

まず、ロード命令か否かを判断しくステップ31)、ロ
ード命令の場合は、次にロード先のメモリに対して同値
関係(すなわち、同一アドレス・同一長のメモリに対し
て同値関係表9がすでに設定しである場合)が付いてい
るか否か判断しくステップ32)、同値関係が付いてい
る場合、後述のようにレジスタの再割付けを試みる(ス
テップ33)。
First, it is determined whether it is a load instruction or not (step 31). If it is a load instruction, then the equivalence relation table 9 has already been established for the memory at the load destination (that is, the memory of the same address and the same length has an equivalence relation table 9). If it is set, it is determined whether or not it is attached (step 32), and if an equivalence relation is attached, an attempt is made to reallocate the register as described below (step 33).

ロード先のメモリに対して同値関係が付イテイない場合
(すなわち、同一アドレス・同一長のメモリに対して同
値関係表9がない場合)、新たに同値関係表9にロード
先のメモリのアドレスと長さ(命令によって決まる)、
及びロード先のレジスタを設定する(ステップ37)。
If the equivalence relationship does not exist for the memory to which the load is to be loaded (that is, if there is no equivalence relationship table 9 for the memory with the same address and the same length), a new equivalence relationship table 9 will be created with the address of the memory to which the load is to be performed. length (determined by instruction),
and sets the load destination register (step 37).

ステップ31において、ロード命令でない場合、さらに
ストア命令か否かを判断しくステップ34)、ストア命
令の場合は、対象メモリの何れかと同値関係の付いたレ
ジスタがあるか否かを判断し、(ステップ35)、スト
ア先のメモリに対して、一部でも同値関係が伺いている
場合(すなわち、アドレスと長さで示されるメモリのと
こか一部に対してでも、同値関係表9がすてに設定しで
ある場合)、同値関係表9からその情報を削除しくステ
ップ36)、新たに同値関係表9にストア先のメモリの
アドレスと長さ(命令によって決る)、及びストア元の
レジスタを設定する(ステップ37)。
In step 31, if it is not a load instruction, it is further determined whether or not it is a store instruction (step 34); if it is a store instruction, it is determined whether there is a register with an equivalency relationship with any of the target memories (step 34); 35) If there is an equivalence relation even for a part of the storage destination memory (that is, even for a part of the memory indicated by the address and length, the equivalence relation table 9 is If it is set), delete that information from the equivalence relation table 9 (Step 36), and newly set the store destination memory address and length (determined by the instruction) in the equivalence relation table 9, and the store source register. (Step 37).

また、ストア先のメモリに対して、一部でも同値関係が
付いていない場合(すなわち、アドレスと長さで示され
るメモリのどこか一部に対しても、同値関係表9がない
場合)、新たに同値関係表9にストア先の命令のアドレ
スと長さ(命令によって決る)、及びストア元のレジス
タを設定する(ステップ37)。
In addition, if there is no equivalence relation even in part of the storage destination memory (that is, if there is no equivalence relation table 9 for any part of the memory indicated by the address and length), The address and length of the store destination instruction (determined by the instruction) and the store source register are newly set in the equivalence relation table 9 (step 37).

さらに、ステップ31及びステップ34で、ロード命令
でもストア命令でもない場合は、何もしないで終了する
Furthermore, if it is neither a load instruction nor a store instruction in steps 31 and 34, the process ends without doing anything.

上記のような解析処理でレジスタの再割付は可能になっ
た場合(同値関係が付いているメモリに対するロード命
令が生成されている場合)のみ、レジスタ再割付は手段
5によって同値関係を引き継いで、不要なロード命令を
削除するようにレジスタの再割付けを行う。
Only when it becomes possible to reallocate registers through the above analysis process (when a load instruction is generated for a memory with an equivalence relationship), register reallocation is performed by inheriting the equivalence relationship by means 5. Reallocate registers to remove unnecessary load instructions.

ここで、同値関係を設定した命令を81同値関係の付い
た対象メモリをM1対象レジスタをRz削除しようとす
るMからのロード命令をり、Lのロード先レジスタをR
2、ブロックの先頭からしの直前命令までの区間をα、
Lの直後の命令からブロックの最後までの区間をβ、α
区間内のAレジスタの最後の定義命令以降の区間をγ(
A)、β区間内のAレジスタ参照命令以前の区間の内、
Aレジスタ定義命令を含まない最大区間をδ(A)とす
る(第6図参照)。
Here, the instruction that set the equivalence relationship is 81, the target memory with the equivalence relationship is M1, the load instruction from M that attempts to delete the target register is Rz, and the load destination register of L is Rz.
2. Let α be the interval from the beginning of the block to the immediately preceding instruction.
The interval from the instruction immediately after L to the end of the block is β, α
The interval after the last definition instruction of the A register in the interval is expressed as γ(
A), in the interval before the A register reference instruction in the β interval,
Let δ(A) be the maximum interval that does not include the A register definition instruction (see FIG. 6).

たたし、α区間内にAレジスタ定義命令がなければ、 γ(A)=α+ε とし、β区間内にAレジスタ定義命令がなく、Aレジス
タがブロックの出口で生きていれば、δ(A)=β十ε とし、β区間内にAレジスタ定義命令があれば、最初の
A定義命令まで、なければブロックの最後までの区間内
にAレジスタ参照命令がないとき、δ(A)=0 とする。
However, if there is no A register definition instruction within the α interval, γ(A) = α + ε, and if there is no A register definition instruction within the β interval and the A register is alive at the exit of the block, δ(A ) = β + ε, and if there is an A register definition instruction within the β interval, then up to the first A definition instruction, and if there is no A register reference instruction within the interval up to the end of the block, then δ(A) = 0. shall be.

まず、L以降のR2レジスタを、同値関係の付いたレジ
スタR1に置き換えることにより、Lの削除を行う。以
下の条件をすへて満たした場合、δ(R2)区間内のR
2レジスタ参照命令のレジスタをR1に変更して、Lを
削除する。
First, L is deleted by replacing the R2 registers after L with registers R1 having an equivalence relationship. If the following conditions are all satisfied, R in the δ(R2) interval
Change the register of the 2-register reference instruction to R1 and delete L.

(1)Lで定義されたR2レジスタの寿命はブロック内
で終わる。
(1) The life of the R2 register defined by L ends within the block.

[δ(R2)≦β] (2)Lで定義されたR2レジスタが生きている間、R
+ レジスタの定義命令がない。
[δ(R2)≦β] (2) While the R2 register defined by L is alive, R
+ There is no register definition instruction.

[δ(R2)  R,レジスタ定義命令]R2レジスタ
→R1レジスタ置換が不可能たった場合、Lの前後の同
値関係の付いたレジスタR1を、レジスタR2に置き換
えることにより、Lの削除を行う。
[δ(R2) R, register definition instruction] If it is impossible to replace the R2 register → R1 register, L is deleted by replacing register R1 with an equivalency relationship before and after L with register R2.

以下の条件をすべて満たした場合、γ(Ro)+6(R
8)区間内のR1レジスタ定義/参照命令のレジスタを
R2に変更して、Lを削除する。
If all of the following conditions are met, γ(Ro)+6(R
8) Change the register of the R1 register definition/reference instruction in the interval to R2 and delete L.

(1) Sで同値関係を設定したR1レジスタの寿命は
、ブロック内で始まり、ブロック内で終わる。
(1) The life of the R1 register with an equivalence relationship set in S begins and ends within the block.

[γ (R1)≦α  &  δ (R,)≦β](2
)Sで同値関係を設定したR、レジスタが生きている間
でかつ、して定義したR2レジスタが生きている間以外
で、R2レジスタの定義/参照命令がない。
[γ (R1)≦α & δ (R,)≦β] (2
) There is no definition/reference instruction for the R2 register except while the equivalence relationship is set in S and the register R is alive and the R2 register defined by is alive.

[γ(R1)十δ(R,)−δ(R2)R2レジスタ定
義/参照命令コ R1レジスタ→R2レジスタ置換も不可能たった場合、
レジスタの再割付けは行わない。
[γ (R1) + δ (R,) - δ (R2) R2 register definition/reference instruction R1 register → R2 register replacement is also impossible,
No register reallocation is performed.

ブロックテーブルをブロックテーブル起点ポインタから
アドレス順チェーンにしたがってたどり、全ブロックに
関して同値関係解析手段4とレジスタ再割付は手段5と
によって最適化を行ったならば、命令出力手段6によっ
て、命令を格納してあった命令格納媒体10にレジスタ
再割付は済命令の並びを出力する。
After tracing the block table from the block table starting point pointer in accordance with the address order chain and optimizing all blocks by the equivalence relation analysis means 4 and the register reallocation means 5, the instruction output means 6 stores the instructions. A list of instructions whose registers have been reallocated is output to the instruction storage medium 10 that has been previously allocated.

このように、線形に制御移行する最大の単位である命令
ブロックに対して、含まれる命令のレジスタに関する依
存関係、及びメモリ番レジスタ間の同値関係状態を調査
して、レジスタの再割付けを行い不要なロード命令を削
除することにより、オブジェクトサイズを縮小すること
ができ、実行速度も向上できる。
In this way, for an instruction block, which is the largest unit of linear control transfer, we investigate the register dependencies of included instructions and the equivalence relationship between memory number registers, and reallocate registers to eliminate unnecessary registers. By removing unnecessary load instructions, the object size can be reduced and execution speed can be improved.

また、機械語命令に対して行うことにより、コンパイラ
ごとにコンパイラ特有のレジスタ割付は処理を用意する
必要がなくなり、さらに、コンパイラが出力したオブジ
ェクトに対しても適用可能である。
Furthermore, by performing this on machine language instructions, there is no need to prepare compiler-specific register allocation processing for each compiler, and it can also be applied to objects output by the compiler.

〔発明の効果〕〔Effect of the invention〕

以上説明したように、本発明は、線形に制御移行する最
大の単位である命令ブロックに対して、含まれる命令の
レジスタに関する依存関係及びメモリ・レジスタ間の同
値関係状態を調査して、レジスタの再割付けを行い不要
なロード命令を削除することにより、オブジェクトサイ
ズを縮小することができ、実行速度も向上できるという
効果を有する。
As explained above, the present invention investigates the register dependencies of included instructions and the equivalence relationship between memory and registers for an instruction block, which is the largest unit in which control is transferred linearly. By reallocating and deleting unnecessary load instructions, the object size can be reduced and the execution speed can be improved.

また、機械語命令に対して行うことにより、コンパイラ
ごとにフンバイラ特有のレジスタ割付は処理を用意する
必要がなくなるという効果を有する。
Moreover, by performing this on machine language instructions, there is an effect that there is no need to prepare a register allocation process specific to Funvira for each compiler.

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

第1図は本発明の一実施例のブロック図、第2図は第1
図に示す命令ブロック分割手段の処理の流れを示す流れ
図、第3図は第1図に示す同値関係解析手段の処理の流
れを示す流れ図、第4図は第1図に示すブロックテーブ
ル群の詳細を示す図、第5図は第1図に示す同値関係表
の詳細を示す図、第6図は第1図に示すレジスタ再割付
は手段の処理中におけるブロック内の命令の関連イメー
ジを示す図である。 1・・・・・・命令入力手段、2・・・・・・命令ブロ
ック分割手段、3・・・・・・ブロック間レジスタフロ
ー解析手段、4・・・・・・同値関係解析手段、5・・
・・・・レジスタ再割付は手段、6・・・・・・命令出
力手段、7・・・由命令展開メモ1ハ8・・・・・・ブ
ロックテーブル群、9・・・・・・同値関係表、10・
・・・・・命令格納媒体。 代理人 弁理士  内 原  晋 第 図 第 図
FIG. 1 is a block diagram of one embodiment of the present invention, and FIG. 2 is a block diagram of an embodiment of the present invention.
FIG. 3 is a flowchart showing the processing flow of the instruction block dividing means shown in FIG. 1, FIG. 4 is a flowchart showing the processing flow of the equivalence relation analysis means shown in FIG. , FIG. 5 is a diagram showing details of the equivalence relation table shown in FIG. 1, and FIG. 6 is a diagram showing a related image of instructions in the block during processing of the register reallocation shown in FIG. 1. It is. DESCRIPTION OF SYMBOLS 1... Instruction input means, 2... Instruction block division means, 3... Inter-block register flow analysis means, 4... Equivalence relation analysis means, 5・・・
...Register reallocation is a means, 6...Instruction output means, 7...Year instruction expansion memo 1c8...Block table group, 9...Equivalent Relationship table, 10.
...Instruction storage medium. Agent: Susumu Uchihara, Patent Attorney

Claims (1)

【特許請求の範囲】 1、メモリとレジスタとの間のロード/ストア命令をも
ち、間接分岐命令をもたないアーキテクチャ上のレジス
タ再割付け方式において、 (A)命令を格納した媒体から命令の並びを入力してメ
モリ上に展開する命令入力手段、(B)入力した前記命
令を解析して、分岐命令の直後と分岐先ラベル位置で命
令の並びを分割して命令ブロックを作成し、同時に分割
した前記命令ブロック間の制御の流れを求める命令ブロ
ック分割手段、 (C)前記分割した命令ブロック間のレジスタの定義・
参照の依存関係を調査し、前記命令ブロックの入口/出
口で生きているレジスタを求めるブロック間レジスタフ
ロー解析手段、 (D)前記分割した命令ブロック内の命令について、命
令実行中のある時点で前記メモリの内容と前記レジスタ
の内容とが同じ値の関係を示す同値関係の状態を解析す
る同値関係解析手段、 (E)前記同値関係の付いた前記メモリからの不要なロ
ード命令があれば、矛盾がないように前記レジスタの再
割付けを行って不要なロード命令を削除するレジスタ再
割付け手段、 (F)分割したすべての前記命令ブロックに関して同値
関係解析及びレジスタ再割付けを行った後、命令を格納
してあった前記媒体にレジスタ再割付け済命令の並びを
出力する命令出力手段、 を有することを特徴とするレジスタ再割付け方式。 2、メモリとレジスタとの間のロード/ストア命令をも
ち、間接分岐命令をもたないアーキテクチャ上のレジス
タ再割付け方式において、 (A)命令を格納した媒体から命令の並びを入力してメ
モリ上に展開するステップ、 (B)入力した前記命令を解析して、分岐命令の直後と
分岐先ラベル位置で命令の並びを分割して命令ブロック
を作成し、同時に分割した前記命令ブロック間の制御の
流れを求めるステップ、 (C)前記分割した命令ブロック間のレジスタの定義・
参照の依存関係を調査し、前記命令ブロックの入口/出
口で生きているレジスタを求めるステップ、 (D)前記分割した命令ブロック内の命令について、命
令実行中のある時点で前記メモリの内容と前記レジスタ
の内容とが同じ値の関係を示す同値関係の状態を解析す
るステップ、 (E)前記同値関係の付いた前記メモリからの不要なロ
ード命令があれば、矛盾がないように前記レジスタの再
割付けを行って不要なロード命令を削除するステップ、 (F)分割したすべての前記命令ブロックに関して同値
関係解析及びレジスタ再割付けを行った後、命令を格納
してあった前記媒体にレジスタ再割付け済命令の並びを
出力するステップ、 を実行することを特徴とするレジスタ再割付け方式。
[Scope of Claims] 1. In an architectural register reallocation method that has load/store instructions between memory and registers but does not have indirect branch instructions, (A) A sequence of instructions from a medium storing instructions; (B) Analyzes the inputted instruction, creates an instruction block by dividing the instruction sequence immediately after the branch instruction and at the branch destination label position, and divides the instruction block at the same time. (C) definition of registers between the divided instruction blocks;
inter-block register flow analysis means for investigating reference dependencies and finding live registers at the entry/exit of the instruction block; (D) for the instructions in the divided instruction block, the an equivalence relationship analysis means for analyzing the state of an equivalence relationship in which the content of the memory and the content of the register have the same value; (E) if there is an unnecessary load instruction from the memory with the equivalence relationship; (F) register reallocation means for reallocating the registers and deleting unnecessary load instructions so as to avoid unnecessary load instructions; A register reallocation method comprising: instruction output means for outputting a sequence of register reallocated instructions to the medium where the registers have been reallocated. 2. In an architectural register reallocation method that has load/store instructions between memory and registers but does not have indirect branch instructions, (A) A sequence of instructions is input from the medium storing the instructions and transferred to memory. (B) Analyzing the inputted instructions, dividing the sequence of instructions immediately after the branch instruction and at the branch destination label position to create instruction blocks, and simultaneously developing control between the divided instruction blocks. (C) Defining registers between the divided instruction blocks.
(D) examining reference dependencies and determining live registers at the entry/exit of the instruction block; (E) If there is an unnecessary load instruction from the memory with the equivalence relationship, rewriting the register to avoid conflicts; performing allocation and deleting unnecessary load instructions; (F) After performing equivalence relationship analysis and register reallocation for all the divided instruction blocks, register reallocation has been completed on the medium in which the instructions were stored; A register reallocation method characterized by executing the steps of outputting a sequence of instructions.
JP26573790A 1990-10-03 1990-10-03 Register re-assignment system Pending JPH04141737A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP26573790A JPH04141737A (en) 1990-10-03 1990-10-03 Register re-assignment system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP26573790A JPH04141737A (en) 1990-10-03 1990-10-03 Register re-assignment system

Publications (1)

Publication Number Publication Date
JPH04141737A true JPH04141737A (en) 1992-05-15

Family

ID=17421295

Family Applications (1)

Application Number Title Priority Date Filing Date
JP26573790A Pending JPH04141737A (en) 1990-10-03 1990-10-03 Register re-assignment system

Country Status (1)

Country Link
JP (1) JPH04141737A (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6325374A (en) * 1986-02-11 1988-02-02 Nippon Denso Co Ltd Ignition device for internal combustion engine
JPS6429936A (en) * 1987-07-27 1989-01-31 Mitsubishi Electric Corp Register re-mapping system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6325374A (en) * 1986-02-11 1988-02-02 Nippon Denso Co Ltd Ignition device for internal combustion engine
JPS6429936A (en) * 1987-07-27 1989-01-31 Mitsubishi Electric Corp Register re-mapping system

Similar Documents

Publication Publication Date Title
JP3417984B2 (en) Compile method to reduce cache contention
US8434074B2 (en) Register allocation with SIMD architecture using write masks
US7401329B2 (en) Compiling computer programs to exploit parallelism without exceeding available processing resources
JP3299611B2 (en) Resource allocation device
KR0138468B1 (en) Microcomputer
JPS6149242A (en) Optimization compiler
US7386843B2 (en) Method and system for register allocation
EP0795821B1 (en) Optimization method using global analysis to remove redundant transfer instructions
JP2008500654A (en) Banking for register banks with partitions
JPH0522936B2 (en)
US20010052120A1 (en) Critical path optimization - unload hard extended scalar block
JP3318051B2 (en) Translation processing method
JP2002527816A (en) Program optimization apparatus and method
JPH04141737A (en) Register re-assignment system
US10475151B2 (en) Graphics engine resource management and allocation system
JP3638171B2 (en) Resource allocation device
WO2021005130A1 (en) A streaming compiler for automatic adjoint differentiation
JP2019185486A (en) Code conversion device, code conversion method, and code conversion program
JPH0421031A (en) Register reallocating system
JPH03127229A (en) Register reallocating device
JP7338778B2 (en) Program, instruction generation method and instruction generation device
KR100912114B1 (en) A Memory Assignment Method for X-Y Data Transfer
JP2522372B2 (en) Data driven computer
JPH04252336A (en) Program optimization processor
JPH07105015A (en) Compiling system