JP2000066897A - Device and method for generating object - Google Patents

Device and method for generating object

Info

Publication number
JP2000066897A
JP2000066897A JP10233145A JP23314598A JP2000066897A JP 2000066897 A JP2000066897 A JP 2000066897A JP 10233145 A JP10233145 A JP 10233145A JP 23314598 A JP23314598 A JP 23314598A JP 2000066897 A JP2000066897 A JP 2000066897A
Authority
JP
Japan
Prior art keywords
vertex
register
stack
interference graph
vertices
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.)
Abandoned
Application number
JP10233145A
Other languages
Japanese (ja)
Inventor
Yutaka Ota
裕 太田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Toshiba Corp
Original Assignee
Toshiba 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 Toshiba Corp filed Critical Toshiba Corp
Priority to JP10233145A priority Critical patent/JP2000066897A/en
Publication of JP2000066897A publication Critical patent/JP2000066897A/en
Abandoned legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide a device and a method for generating object with which a parameter can be efficiently allocated to a register in optimum manner by coloring. SOLUTION: When one register can be accessed as plural registers of small size, an interference graph and a stack for storing the apex of an interference graph based on this interference graph are generated and from this stack, the interference graph is reconstituted based on a coloring algorithm. Then, it is judged whether each apex can be piled on the stack or not while referring to information showing the correspondence of each apex and the usable register.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明は、オブジェクト生成
装置及びオブジェクト生成方法に関し、特に、カラーリ
ングによる変数のレジスタ割付を最適かつ効率的に行う
ことの可能なオブジェクト生成装置及びオブジェクト生
成方法に関するものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to an object generating apparatus and an object generating method, and more particularly to an object generating apparatus and an object generating method capable of optimally and efficiently allocating variables to registers by coloring. is there.

【0002】[0002]

【従来の技術】レジスタ割付の代表的なアルゴリズムと
してカラーリング(彩色法)がある。カラーリングの主
なアルゴリズムは、まずすべての変数に対して干渉グラ
フを作成する。次に干渉グラフから度数(その変数が干
渉しているすべての変数の数)がk未満の頂点(変数)
を順次取り除いていき、スタックに積む(スタックプッ
シュ)。ここで、kとはターゲット機械(即ち,マイク
ロプロセッサなど)の使用可能なレジスタ総数である。
すべての変数をスタックに積み、グラフが空になったな
らば、次にスタックから変数を順次取り出して(スタッ
クポップ)干渉グラフを再作成していく。このとき各頂
点(変数)には、他のすべての干渉する頂点(変数)と
は異なる色を塗るようにする。これは、その変数を、レ
ジスタを割り当てることである。すべての頂点をスタッ
クから取り出して、もとの干渉グラフが再現できたなら
ばレジスタ割り当ては完了する。
2. Description of the Related Art A typical algorithm for register allocation is coloring (coloring method). The main algorithm of coloring first creates an interference graph for all variables. Next, the vertices (variables) whose frequency (the number of all variables interfering with the variable) is less than k from the interference graph
Are sequentially removed, and are stacked (stack push). Here, k is the total number of available registers of the target machine (ie, microprocessor, etc.).
When all the variables are put on the stack and the graph becomes empty, the variables are sequentially fetched from the stack (stack pop) to re-create the interference graph. At this time, each vertex (variable) is painted in a different color from all other interfering vertices (variables). This is to assign that variable to a register. When all the vertices are removed from the stack and the original interference graph can be reproduced, the register assignment is completed.

【0003】ここで先ず問題となるのは、まず非決定的
な点がある点である。即ち、干渉グラフからどのような
順序で頂点を選ぶのか、また、スタックから取り出した
頂点にどのように色を塗るのか、といった点である。こ
れらについては、様々な規則を用いることにより、ある
程度望ましい色を塗る(レジスタを割り当てる)ことが
できるのだが、本発明とは直接関係しないので、ここで
は省略する。
The first problem here is that there is a non-deterministic point. That is, in what order the vertices are selected from the interference graph, and how to color the vertices extracted from the stack. For these, it is possible to paint a desired color (assign a register) to some extent by using various rules, but since they are not directly related to the present invention, they are omitted here.

【0004】次に問題となるのは、カラーリング途中で
アルゴリズムの続行が不可能になる場合である。実際の
ターゲット機械では、使用可能なレジスタ数kは有限で
あるため、干渉グラフのすべての頂点の度数がkより大
になった場合には、もはやカラーリングを続行できな
い。このような場合にはスピルアウト処理を行う。
[0004] The next problem is that the algorithm cannot be continued during coloring. In an actual target machine, since the number k of available registers is finite, if the frequency of all vertices of the interference graph becomes larger than k, coloring can no longer be continued. In such a case, a spill-out process is performed.

【0005】その次に問題となるのは、実際のレジスタ
割付では、kの値が確定しないことである。当然kの上
限はターゲット機械の総レジスタ数であるが、各変数に
対しては、コード生成上、さまざまな制約が課せられ、
各変数に対して割り当て可能なレジスタの数や種類はば
らばらとなる。このような場合には、各変数に対して、
使用可能なレジスタ数(最大度数)を設けることにより
処理を行う。
[0005] The second problem is that the value of k is not determined in actual register allocation. Naturally, the upper limit of k is the total number of registers of the target machine, but for each variable, various restrictions are imposed on code generation,
The number and types of registers that can be assigned to each variable vary. In such a case, for each variable,
Processing is performed by providing the number of registers (maximum frequency) that can be used.

【0006】カラーリングの詳細なアルゴリズムについ
ては、様々な文献があり、詳細はよく知られている。例
えば、コンパイラの本(Aho,Sethi,Ullman共著、原田
訳、「コンパイラ」サイエンス社、ISBN4-7819-0586-
2、または、佐々著、「プログラミング言語処理系」岩
波書店、ISBN4-00-010345-8)を参照されたい。
[0006] There are various literatures on the detailed algorithm of coloring, and the details are well known. For example, a book on compilers (co-authored by Aho, Sethi and Ullman, translated by Harada, Compiler Science, ISBN4-7819-0586-
2, or see Sasa, "Programming Language Processing System", Iwanami Shoten, ISBN4-00-010345-8).

【0007】スタックに積む処理の途中で、すべての頂
点の度数がkより大になった場合は、どの頂点を選ぶこ
ともできないため、処理を続行できない。このような場
合は、残ったグラフの中から1つの頂点を取り除く。こ
の頂点についてはレジスタに割り当てることを断念し、
メモリに割り当てることにする。これにより、干渉グラ
フに対して再び処理を続行できる。これがスピルアウト
である。この結果、再び頂点を選ぶことができなくなっ
たときには、随時スピルアウトを行うことにより、処理
を続けることができる。
If the frequency of all vertices becomes larger than k during the process of stacking, no vertex can be selected, and the process cannot be continued. In such a case, one vertex is removed from the remaining graph. Abandon assigning this vertex to a register,
I will allocate it to memory. Thereby, the processing can be continued on the interference graph again. This is spill-out. As a result, when the vertex cannot be selected again, the processing can be continued by performing spill-out as needed.

【0008】ここでも、残った干渉グラフの中からどの
変数を選ぶか、という点が非決定的であるが、これも本
発明とは直接関係しないので省略する。
[0008] Again, it is indeterminate which variable to select from the remaining interference graphs, but this is also not directly related to the present invention and will not be described.

【0009】また、スピルアウトによりメモリ割付され
た変数に対するコードが不正となる場合があり、完全な
コード生成ができない場合が生じるという問題点があ
る。
Further, there is a problem that a code for a variable allocated to a memory may be incorrect due to spill-out, and that complete code generation may not be possible.

【0010】このような場合、レジスタ割付を行った
後、不正なコードに対する補正のコード(スピルコー
ド)を挿入し、再びレジスタ割付を行うなどして対処す
る必要がある。
In such a case, it is necessary to cope with the problem by, after register allocation, inserting a correction code (spill code) for an illegal code and performing register allocation again.

【0011】通常のコンパイラでは、レジスタの使い方
の制約、各コードに対してのコード生成上の制約が生じ
るため、各変数に対して割り当て可能なレジスタ数はば
らばらとなる。したがって、干渉グラフから各頂点を取
り出す場合に、kとその頂点の度数との比較では、現実
的ではない。
In a normal compiler, there are restrictions on how to use registers and restrictions on code generation for each code, so that the number of registers that can be allocated to each variable varies. Therefore, when extracting each vertex from the interference graph, it is not realistic to compare k with the frequency of the vertex.

【0012】しかしながら、各頂点に対して、その頂点
が割り当て可能なレジスタ数を最大度数としてあらかじ
め設定しておき、干渉グラフから頂点を取り除いていく
段階で、その度数が最大度数未満の頂点を選ぶことによ
り処理を続けることが出来る。これは、再びその頂点を
スタックから取り出し干渉グラフに加えていく時に、必
ず空いたレジスタを見つけることができるためである。
However, for each vertex, the number of registers to which the vertex can be allocated is preset as the maximum frequency, and at the stage of removing the vertex from the interference graph, a vertex whose frequency is less than the maximum frequency is selected. Thus, the processing can be continued. This is because an empty register can always be found when the vertex is taken out of the stack again and added to the interference graph.

【0013】以上のアルゴリズムは、RICSプロセッ
サのように1つの変数に1つのレジスタを割り当てるこ
とを前提としている。しかしながらターゲット機械によ
っては、CISCプロセッサのように、1つのレジスタ
を小さいサイズのレジスタとしてアクセスできるという
特徴を持つものがある。即ち、1つのレジスタを小さい
サイズの複数のレジスタとしてアクセスできる場合があ
る。
The above algorithm is based on the assumption that one register is assigned to one variable as in the RICS processor. However, some target machines have a feature that one register can be accessed as a small-sized register, such as a CISC processor. That is, there is a case where one register can be accessed as a plurality of registers having a small size.

【0014】このような場合、小さいサイズの変数に割
り当て可能なレジスタの総数(最大度数)は、見かけ上
増加する。しかしながら、その変数(頂点)と干渉する
変数のサイズは一般にはばらばらであり、それよりも大
きなサイズの変数との干渉による度数は、見かけ上増加
する。
In such a case, the total number of registers (maximum frequency) that can be allocated to a variable having a small size apparently increases. However, the size of a variable that interferes with the variable (vertex) is generally disjoint, and the frequency of interference with a variable of a larger size apparently increases.

【0015】ひとつの方法として、従来の度数と最大度
数を利用し、最大度数はその頂点のサイズで数えられた
割り当て可能なレジスタ総数とし、度数はその頂点と干
渉する変数のサイズをその頂点のサイズで割った値の総
数として代用する方法が挙げられる。
As one method, the conventional frequency and the maximum frequency are used, and the maximum frequency is the total number of registers that can be allocated counted by the size of the vertex, and the frequency is the size of a variable that interferes with the vertex. An alternative is to use the total number of values divided by the size.

【0016】しかしながら、その頂点に割り当て可能な
レジスタは、その頂点をオペランドに持つ命令の種類に
よって制限がある。この制限の為に、従来の度数と最大
度数を利用する方法は、この方法は完全ではない。途中
で割り当て不可能となったり、必要以上のスピルアウト
が起こる恐れがある。
However, registers that can be assigned to the vertex are limited by the type of instruction having the vertex as an operand. Due to this limitation, the conventional method using frequency and maximum frequency is not perfect. There is a risk of being unassignable or spilling out more than necessary.

【0017】[0017]

【発明が解決しようとする課題】以下、上記従来の方法
に伴う問題点を生成オブジェクト効率とコンパイル時間
の2点から説明する。先ず、生成オブジェクト効率であ
る。従来の方法では、スタックに積めるかどうかの判断
が不完全であるため、スタックを作成していく段階で不
必要なスピルアウトを生じたり、スタックが空にできた
にもかかわらず干渉グラフを再現できないといった問題
を生じる。
The problems associated with the above-mentioned conventional method will be described below in terms of the efficiency of a generated object and the compile time. The first is the efficiency of the generated object. In the conventional method, the decision whether to stack the stack is incomplete, so unnecessary spill-out may occur at the stage of creating the stack, or the interference graph is reproduced even though the stack can be emptied The problem of being unable to do so occurs.

【0018】不必要なスピルアウトを発生した場合は、
メモリアクセスが増えたりスピルコードが挿入されるた
めコード効率は悪化する。また、スタックから頂点を取
り出して干渉グラフを再現していく途中でカラーリング
できなくなった場合は、さらにスピルアウトを行うか、
最初からカラーリングをやり直すといった方法で回避す
る必要が生じる。スピルアウトが増えれば当然コード効
率は悪化する。
When unnecessary spill-out occurs,
Code efficiency deteriorates due to increased memory access and insertion of spill codes. Also, if it becomes impossible to color while extracting the vertices from the stack and reproducing the interference graph, further spill out,
There is a need to avoid this by re-coloring from the beginning. As spillout increases, code efficiency naturally declines.

【0019】次にコンパイル時間という点での問題点を
説明する。従来の方法では上記のように、スピルアウト
が必要以上に行われた場合に、生成オブジェクトコード
の効率が悪化する。同時に、コンパイル処理においても
スピルコードを挿入するなどの追加処理が必要なため、
コンパイル速度も低下する。
Next, a problem in terms of compile time will be described. In the conventional method, as described above, when the spill-out is performed more than necessary, the efficiency of the generated object code deteriorates. At the same time, additional processing such as inserting spill code is required in the compilation process,
Compilation speed is also reduced.

【0020】一般にコンパイラの処理におけるレジスタ
割付に費やす時間は大きいため、スピルアウトによりさ
らにコンパイル速度が低下すれば、使い勝手を大きく損
なうことになる。
In general, since the time spent for register allocation in the processing of the compiler is large, if the compile speed is further reduced by spill-out, usability will be greatly impaired.

【0021】従って、本発明の目的は、カラーリングに
よる変数のレジスタ割付を最適かつ効率的に行うことの
可能なオブジェクト生成装置及び方法を提供することで
ある。
It is therefore an object of the present invention to provide an object generating apparatus and method capable of optimally and efficiently allocating variables to registers by coloring.

【0022】本発明の他の目的は、コードサイズや実行
時間を短縮するオブジェクト(機械命令)を高速に生成
することが可能なオブジェクト生成装置及び方法を提供
することである。
Another object of the present invention is to provide an object generating apparatus and method capable of generating objects (machine instructions) for reducing code size and execution time at high speed.

【0023】[0023]

【課題を解決するための手段】本発明によれば、1つの
レジスタを小さいサイズの複数のレジスタとしてアクセ
スできる場合に、カラーリングアルゴリズムにおいて、
スタックに積む頂点を選択する条件として、割り当て可
能なレジスタマップを使用する。これにより、1つのレ
ジスタに1つの変数を割り当てる場合と同様の生成オブ
ジェクト効率を実現する。
According to the present invention, when one register can be accessed as a plurality of registers of a small size, a coloring algorithm is used.
An assignable register map is used as a condition for selecting a vertex to be stacked. This achieves the same generation object efficiency as in the case where one variable is assigned to one register.

【0024】従来のカラーリングにおいて、ある頂点を
干渉グラフから取り除くときに度数が最大度数未満かど
うかという比較は、あとから干渉グラフを再作成すると
きに必ず空きがあることを保証するためである。
In the conventional coloring, the comparison of whether or not the frequency is less than the maximum frequency when a certain vertex is removed from the interference graph is to ensure that there is always a space when the interference graph is recreated later. .

【0025】このアルゴリズムを1つのレジスタを小さ
いサイズの複数のレジスタとしてアクセスできる場合に
あてはめる場合、かならず空きがあることを保証するた
めには、その頂点に対して干渉しているすべての頂点の
サイズと、その頂点が使用可能なレジスタマップを用い
て考えることができる。
If this algorithm is applied when one register can be accessed as a plurality of registers of a small size, in order to guarantee that there is always room, the size of all vertices interfering with that vertex is Can be considered using a register map whose vertices can be used.

【0026】その頂点を後でスタックから取り出して干
渉グラフに加えていく段階で空きを確保するために、そ
の時点で干渉するすべての頂点により使用可能なレジス
タマップをふさがれた最悪の場合を考慮すればよい。
Consider the worst case where all the interfering vertices at that point in time fill the available register map in order to make room in the later step of removing that vertex from the stack and adding it to the interference graph. do it.

【0027】現在の干渉グラフが後からどのような順序
で再作成されるかは不明であるため、その時点での干渉
する頂点によりもっとも速くレジスタマップが塗られて
いく場合を考慮する。
Since it is not clear in what order the current interference graph will be recreated later, consider the case where the register map is painted on the interfering vertices at that point in time.

【0028】この結果、使用可能レジスタマップに空き
が残った場合、その頂点を選択することができる。
As a result, when a vacancy remains in the available register map, the vertex can be selected.

【0029】即ち、本発明(請求項1)は、1つのレジ
スタを小さいサイズの複数のレジスタとしてアクセスで
きるようなターゲット機械のためのオブジェクト生成装
置であって、高級言語のソースコードに含まれる自動変
数及び引数の集合と、前記高級言語を機械命令に翻訳す
る際に一時的に使用する一時変数とから、干渉グラフを
生成する手段と、この干渉グラフに基づいて干渉グラフ
の頂点を格納するスタックを生成する手段と、前記スタ
ックからカラーリングアルゴリズムに基づいて前記干渉
グラフを再構成する手段と、夫々の頂点とその使用可能
レジスタとの対応を示す情報を生成する手段とからな
り、夫々の頂点がスタックに積めるかどうかの判断をそ
の頂点の使用可能レジスタの情報を参照することにより
行うことを特徴とするオブジェクト生成装置を提供す
る。
That is, the present invention (claim 1) is an object generating apparatus for a target machine in which one register can be accessed as a plurality of registers having a small size. Means for generating an interference graph from a set of variables and arguments, and temporary variables used temporarily when translating the high-level language into machine instructions, and a stack for storing vertices of the interference graph based on the interference graph Means for reconstructing the interference graph from the stack based on a coloring algorithm, and means for generating information indicating the correspondence between each vertex and its available register, Is determined by referring to information in an available register of the vertex. To provide an object generating device.

【0030】従って、そのような構成によって、本発明
によるオブジェクト生成装置では、ある頂点がスタック
に積めるかどうかの判断を高速かつ効率的に行うことが
出来る。
Therefore, with such a configuration, the object generation apparatus according to the present invention can quickly and efficiently determine whether or not a certain vertex can be stacked.

【0031】本発明(請求項2)は、レジスタ割付処理
でのカラーリングアルゴリズムにて、ある頂点がスタッ
クに積めるかどうかの判断を、干渉する頂点の度数と使
用可能なレジスタマップを用いて行う請求項1のオブジ
ェクト生成装置を提供する。
According to the present invention (claim 2), in the coloring algorithm in the register allocation processing, whether or not a certain vertex can be stacked on the stack is determined using the frequency of the interfering vertex and an available register map. An object generation device according to claim 1 is provided.

【0032】従って、そのような構成によって、本発明
によるオブジェクト生成装置では、ある頂点がスタック
に積めるかどうかの判断を、干渉する頂点の度数と使用
可能なレジスタマップを用いて行う請求項5のオブジェ
クト生成方法を提供する。
Therefore, with such a configuration, the object generating apparatus according to the present invention determines whether or not a certain vertex can be stacked on the stack by using the frequency of the interfering vertex and an available register map. Provide an object generation method.

【0033】本発明(請求項3)は、上記請求項2にお
いて、レジスタ割付処理でのカラーリングアルゴリズム
にて、ある頂点がスタックに積めるかどうかの判断を行
う為の前記度数は、使用可能なレジスタの構成を分類
し、夫々の干渉する頂点がどの分類に属するかという情
報を含んでいることを特徴とする提供する。
According to the present invention (claim 3), in the above-mentioned claim 2, the frequency for determining whether or not a certain vertex can be stacked on the stack can be used in the coloring algorithm in the register allocation processing. The structure of the register is classified, and the information includes information on which classification each of the vertices to interfere belongs to is provided.

【0034】従って、そのような構成によって、本発明
によるオブジェクト生成装置では、レジスタ割付処理に
対象とするプロセッサのレジスタの構成を反映すること
ができる。
Therefore, with such a configuration, the object generation device according to the present invention can reflect the configuration of the register of the processor targeted for the register allocation processing.

【0035】本発明(請求項4)は、レジスタ割付処理
でのカラーリングアルゴリズムにて、ある頂点がスタッ
クに積めるかどうかの判断を、干渉する他の頂点の使用
可能レジスタマップと、その頂点の使用可能レジスタマ
ップを用いて行う請求項2のオブジェクト生成装置を提
供する。
According to the present invention (claim 4), in the coloring algorithm in the register allocation processing, the determination as to whether a certain vertex can be stacked on the stack is made by using a register map of an available vertex that interferes with another vertex and a register map of that vertex. An object generating apparatus according to claim 2, wherein the object generating apparatus performs the processing using an available register map.

【0036】従って、そのような構成によって、本発明
によるオブジェクト生成装置では、ある頂点がスタック
に積めるかどうかの判断をより効果的に行うことが出来
る。
Therefore, with such a configuration, the object generating apparatus according to the present invention can more effectively determine whether or not a certain vertex can be stacked.

【0037】本発明(請求項5)は、1つのレジスタを
小さいサイズの複数のレジスタとしてアクセスできるよ
うなターゲット機械のためのオブジェクト生成方法であ
って、高級言語のソースコードに含まれる自動変数及び
引数の集合と、前記高級言語を機械命令に翻訳する際に
一時的に使用する一時変数とから、干渉グラフを生成す
る段階と、この干渉グラフに基づいて干渉グラフの頂点
を格納するスタックを生成する段階と、前記スタックか
らカラーリングアルゴリズムに基づいて前記干渉グラフ
を再構成する段階と、夫々の頂点とその使用可能レジス
タとの対応を示す情報を生成する段階とからなり、夫々
の頂点がスタックに積めるかどうかの判断をその頂点の
使用可能レジスタの情報を参照することにより行うこと
を特徴とするオブジェクト生成方法を提供する。
The present invention (claim 5) is a method for generating an object for a target machine in which one register can be accessed as a plurality of registers of a small size. Generating an interference graph from a set of arguments and temporary variables used temporarily when translating the high-level language into machine instructions, and generating a stack for storing vertices of the interference graph based on the interference graph And reconstructing the interference graph from the stack based on a coloring algorithm, and generating information indicating the correspondence between each vertex and its available register. The object is determined by referring to information in an available register of the vertex. To provide a-object generation method.

【0038】従って、そのような構成によって、本発明
によるオブジェクト生成方法では、ある頂点がスタック
に積めるかどうかの判断を高速かつ効率的に行うことが
出来る。
Therefore, with such a configuration, in the object generation method according to the present invention, it is possible to quickly and efficiently determine whether or not a certain vertex can be stacked.

【0039】本発明(請求項6)は、レジスタ割付処理
でのカラーリングアルゴリズムにて、ある頂点がスタッ
クに積めるかどうかの判断を、干渉する頂点の度数と使
用可能なレジスタマップを用いて行う請求項5のオブジ
ェクト生成方法を提供する。
According to the present invention (claim 6), in the coloring algorithm in the register allocation processing, whether or not a certain vertex can be stacked on the stack is determined using the frequency of the interfering vertex and an available register map. An object generation method according to claim 5 is provided.

【0040】従って、そのような構成によって、本発明
によるオブジェクト生成方法では、干渉する頂点の度数
を考慮することによって、ある頂点がスタックに積める
かどうかの判断をより効果的に行うことが出来る。
Therefore, with such a configuration, in the object generation method according to the present invention, it is possible to more effectively determine whether or not a certain vertex can be stacked on the stack by considering the frequency of the interfering vertex.

【0041】本発明(請求項7)は、上記請求項6にお
いて、レジスタ割付処理でのカラーリングアルゴリズム
にて、ある頂点がスタックに積めるかどうかの判断を行
う為の前記度数は、使用可能なレジスタの構成を分類
し、夫々の干渉する頂点がどの分類に属するかという情
報を含んでいることを特徴とする提供する。
According to the present invention (claim 7), in the above-mentioned claim 6, the frequency used for determining whether or not a certain vertex can be stacked on the stack in the coloring algorithm in the register allocation processing can be used. The structure of the register is classified, and the information includes information on which classification each of the vertices to interfere belongs to is provided.

【0042】従って、そのような構成によって、本発明
によるオブジェクト生成方法では、レジスタ割付処理に
対象とするプロセッサのレジスタの構成を反映すること
ができる。
Therefore, with such a configuration, the object generation method according to the present invention can reflect the configuration of the register of the processor targeted for the register allocation processing.

【0043】本発明(請求項8)は、レジスタ割付処理
でのカラーリングアルゴリズムにて、ある頂点がスタッ
クに積めるかどうかの判断を、干渉する他の頂点の使用
可能レジスタマップと、その頂点の使用可能レジスタマ
ップを用いて行う請求項6のオブジェクト生成方法を提
供する。
According to the present invention (claim 8), the coloring algorithm in the register allocation processing determines whether or not a certain vertex can be stacked on the stack by using a usable register map of another interfering vertex and a register map of that vertex. An object generation method according to claim 6, wherein the method is performed using an available register map.

【0044】従って、そのような構成によって、本発明
によるオブジェクト生成方法では、ある頂点がスタック
に積めるかどうかの判断をより効果的に行うことが出来
る。
Therefore, with such a configuration, in the object generation method according to the present invention, it is possible to more effectively determine whether or not a certain vertex can be stacked.

【0045】[0045]

【発明の実施の形態】以下、本発明の第1の実施形態に
よるオブジェクト生成装置を図を参照して説明する。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Hereinafter, an object generating apparatus according to a first embodiment of the present invention will be described with reference to the drawings.

【0046】本発明に係るオブジェクト生成装置のハー
ドウエア構成を図1に示す。即ち,以下で説明する各処
理を行うためのMPUを含むコンピュータ1、ハードデ
ィスク装置などの内部記憶手段(図不示)、マウス5や
キーボード6などの入力手段、モニタ7やプリンタ9な
どの出力手段、及びCDーROM11やフレキシブルデ
ィスク13等の外部記憶媒体及びその駆動ドライブ15
からなっている。これらは通常の汎用コンピュータシス
テムを用いてもよい。なお、前記MPUは、以下に説明
する各処理等を行う演算部と、前記処理の命令を記憶す
る主記憶部とを具備する。
FIG. 1 shows a hardware configuration of the object generating apparatus according to the present invention. That is, a computer 1 including an MPU for performing each processing described below, an internal storage unit (not shown) such as a hard disk device, an input unit such as a mouse 5 and a keyboard 6, and an output unit such as a monitor 7 and a printer 9. , And an external storage medium such as a CD-ROM 11 and a flexible disk 13 and a drive 15 for the external storage medium
Consists of These may use a general-purpose computer system. The MPU includes an operation unit that performs each process described below, and a main storage unit that stores instructions for the process.

【0047】コンパイラの処理の流れを元にした構成を
図2に示す。コンパイラは、高級言語で記述されたソー
スプログラムを入力とし、オブジェクトコードを生成す
るソフトウェアプログラムである。C言語などのソース
プログラムは、パーサ(字句解析、構文解析)をへて、
中間コードに変換される。その中間コードは最適化を経
て、レジスタ割り付けを行うことによって機械語のコー
ドに変換され、再度最適化を経てオブジェクトコードと
して出力される。図2は、ソースプログラムを中間コー
ドに変換して、コード生成を行うコンパイラの構成であ
るが、コード生成を行うコンパイラもある。ここで、中
間コードからレジスタ割り付けを行う部分に本発明の特
徴がある。その処理は、図3に要約されている。以下、
順を追ってその内容を説明する。
FIG. 2 shows a configuration based on the processing flow of the compiler. The compiler is a software program that receives a source program described in a high-level language and generates an object code. Source programs such as C language go through a parser (lexical analysis, syntax analysis),
Converted to intermediate code. The intermediate code is converted into a machine language code by allocating registers after optimization, and is output as an object code through optimization again. FIG. 2 shows a configuration of a compiler that generates a code by converting a source program into an intermediate code, but there is also a compiler that generates a code. Here, there is a feature of the present invention in a portion that performs register allocation from the intermediate code. The process is summarized in FIG. Less than,
The contents will be explained step by step.

【0048】本発明の特徴は、スタック作成部に関する
ものである。図3の干渉グラフが作成されるまでを以下
に簡単に説明する。ここでコンパイラとしてTLCS‐900
をターゲットとしたコンパイラを例に取る。図5にTLCS
‐900のレジスタ構成を示す。本発明ではスタックポイ
ンタは直接関係ないので省略してある。
A feature of the present invention relates to a stack creating section. Until the interference graph of FIG. 3 is created, a brief description will be given below. Here TLCS-900 as a compiler
Take the example of a compiler targeting. Figure 5 shows the TLCS
The register configuration of -900 is shown. In the present invention, the stack pointer is omitted because it is not directly related.

【0049】一般に、コンパイラは図6のようなC言語
プログラムを図7のような中間コードに変換し処理す
る。図7では中間コードそのものは最適化されていない
が、本発明は中間コードの最適化とは関係ないので説明
上問題はない。
Generally, a compiler converts a C language program as shown in FIG. 6 into an intermediate code as shown in FIG. 7 and processes it. Although the intermediate code itself is not optimized in FIG. 7, there is no problem in the explanation because the present invention is not related to the optimization of the intermediate code.

【0050】図7の中間コードをもとに各変数(自動変
数I、引数P、一時変数T)に対して、生存区間が重な
っているかどうかを調べたものが図8であり、これを干
渉グラフと呼ぶ。図8の各変数に対して括弧中の数値は
その変数に割り当てられるべきレジスタのサイズ(1、
2、4バイト)である。図9は、各変数に対して割り当
て可能なレジスタの集合であり、以下割付可能レジスタ
マップと呼ぶ。
FIG. 8 shows whether each of the variables (the automatic variable I, the argument P, and the temporary variable T) overlaps in the live range based on the intermediate code shown in FIG. Call it a graph. For each variable in FIG. 8, the number in parentheses is the size of the register to be assigned to that variable (1,
2, 4 bytes). FIG. 9 is a set of registers that can be assigned to each variable, and is hereinafter referred to as an allocatable register map.

【0051】尚、ここで、自動変数Iとは、高級言語の
ソースコードに元々含まれる変数であり、一時変数Tと
は、コンパイラがコンパイルの際に一時的に生成する変
数である。勿論、自動変数Iとは、狭い意味での変数に
限らず、一般的なメモリのデータ領域の場所(オブジェ
クト)を示すものであることは言うまでもない。例え
ば、C++言語のクラスのインスタンスといったものも
変数と考える。
Here, the automatic variable I is a variable originally included in the source code of the high-level language, and the temporary variable T is a variable temporarily generated by the compiler when compiling. Needless to say, the automatic variable I is not limited to a variable in a narrow sense, but indicates a location (object) of a data area of a general memory. For example, an instance of a C ++ language class instance is also considered as a variable.

【0052】次に、本発明の実装方法について説明す
る。現在の干渉グラフをGとする。ある頂点xに対し
て、その頂点をスタックに積むことができるかどうかの
判断を以下のように行う。ここで、頂点xに対して干渉
するすべての頂点の集合をAとする。すべての頂点につ
いてサイズが既知であるものとし、また、すべての頂点
に対して使用可能なレジスタマップが既知であるものと
する。つまり、前処理として、それらを求めておく。
Next, a mounting method of the present invention will be described. Let G be the current interference graph. For a certain vertex x, it is determined whether or not the vertex can be stacked on the stack as follows. Here, a set of all vertices that interfere with the vertex x is assumed to be A. Assume that the size is known for all vertices, and that the register map available for all vertices is known. That is, they are obtained as preprocessing.

【0053】xに対する使用可能レジスタマップmap
を、すべてのAの要素に対し、相当するサイズのレジス
タマップで塗っていく。この塗り方をもっとも高速に塗
りつぶすために、AをさらにサイズごとにA1、A
2、...、Anのようにグループ分けする。ただし、
A1から順にサイズが大きくなるものとする。従って、
TLCS‐900では、A1、A2、A3、A4の4つのグル
ープ毎に処理を行う(ただしTLCS−900では、仕
様上3バイトの変数の集合ABは存在しない)。
Usable register map for x
For all the elements of A with a register map of an equivalent size. In order to fill this method at the highest speed, A is further divided into A1 and A for each size.
2,. . . , An. However,
It is assumed that the size increases in order from A1. Therefore,
In the TLCS-900, processing is performed for each of four groups A1, A2, A3, and A4 (however, in the TLCS-900, there is no 3-byte variable set AB in specifications).

【0054】まず、最もサイズの大きいAnの各要素
(頂点)に対し、相当するサイズのレジスタマップで、
mapを塗っていく。もっとも高速にmapを塗るため
に、mapの空きをふさぐ割合が大きいように塗ってい
く。つまり、最悪の状況を考える。
First, for each element (vertex) of An having the largest size, a register map of a corresponding size is used.
I will apply the map. In order to apply the map at the highest speed, the application is performed in such a manner that the percentage of the space in the map is large. That is, consider the worst situation.

【0055】Anのすべての要素について終了したら、
順次An−1、...、A2、A1の各要素についてm
apを塗っていく。途中でmapに空きがなくなった時
点で、xはもはやスタックに積むことはできないと判断
し、終了する。すべての要素(頂点)について塗り終わ
った時点で、mapに空きがあれば、その頂点xをスタ
ックに積むことが出来ることになる。
When all elements of An have been completed,
In order, An-1,. . . , A2, and m for each element of A1
I will apply the ap. When there is no more space in the map on the way, it is determined that x can no longer be stacked on the stack, and the process ends. At the time when all elements (vertices) have been painted, if there is a space in the map, the vertex x can be stacked on the stack.

【0056】以下、本発明の第2の実施形態によるオブ
ジェクト生成装置を図を参照して説明する。上記(1)
のアルゴリズムにおいて、割り当て可能なレジスタマッ
プを、それを特微づける何種類かの最大度数で表現する
ことにより、(1)のアルゴリズムを高速に動作させる
ことが可能になる。これにより、1つのレジスタに1つ
の変数を割り当てる場合と同様の高遠なコンパイル速度
を実現する。
Hereinafter, an object generating apparatus according to a second embodiment of the present invention will be described with reference to the drawings. The above (1)
In the algorithm of (1), the register map that can be allocated is expressed by several kinds of maximum frequencies that characterize the register map, so that the algorithm (1) can be operated at high speed. As a result, a high-level compilation speed similar to the case where one variable is assigned to one register is realized.

【0057】レジスタマップは一般的にビットマップで
表現されるが、ビットマップを塗ったりビットマップの
空きを検索するには時間がかかる。従来の最大度数と度
数の比較のような単純な算術演算を使用すれば非常に高
速な処理が可能となるため、レジスタマップの情報を表
現する何種類かの最大度数を導入し、この最大度数と度
数の値からある頂点をスタックに積めるかどうかの判断
を判断関数fにより決定する。これにより高速な処理が
可能となる。
Although the register map is generally represented by a bitmap, it takes time to paint the bitmap or search for a free bitmap. Because very fast processing is possible using simple arithmetic operations such as the conventional maximum frequency and frequency comparison, several types of maximum frequencies that represent register map information are introduced. Then, whether or not a certain vertex can be stacked on the stack is determined by the determination function f from the value of the frequency. This enables high-speed processing.

【0058】次に、本実施形態の実装方法について説明
する。ある頂点xに干渉する頂点の集合Aがあり、その
集合Aの情報はサイズごとの要素数、即ち集合A1、A
2、A3、...、Anの要素数であり、度数d1、d
2、...、dnとして表現できる。この度数の値は、
スタックを作成するために干渉グラフから頂点を取り除
く時点で、適切に更新されていくものとする。
Next, a mounting method according to the present embodiment will be described. There is a set A of vertices that interfere with a certain vertex x, and the information of the set A is the number of elements for each size, that is, sets A1, A
2, A3,. . . , An, the number of elements, and the frequencies d1, d
2,. . . , Dn. The value of this frequency is
It should be updated appropriately when vertices are removed from the interference graph to create a stack.

【0059】また、頂点xの使用可能レジスタマップm
apを何種類かの最大度数(m1、m2、....mi)で表
現する。このとき、サイズjの頂点xがスタックに積める
かどうかの判断を、算術的関数fj(d1,d2,...,dn,m1,m
2,...,mi)の値により判断する。以下に説明するよう
に、TLCS‐900の場合、N=4であり(ただし、d3は
使用しない)最大でi=5となる。
The usable register map m of the vertex x
ap is represented by several types of maximum frequencies (m1, m2,... mi). At this time, whether the vertex x having the size j can be stacked on the stack is determined by an arithmetic function fj (d1, d2, ..., dn, m1, m
2, ..., mi). As described below, in the case of TLCS-900, N = 4 (however, d3 is not used), and i = 5 at the maximum.

【0060】最大度数の数え方、関数fの決定方法につ
いては、ターゲット機械のレジスタ構成に依存する。そ
れぞれ非決定的ではあるが、TLCS‐900の場合について
は、以下のように定式化できる。
The method of counting the maximum frequency and the method of determining the function f depend on the register configuration of the target machine. Each is non-deterministic, but for TLCS-900, it can be formulated as follows:

【0061】TLCS―900の場合には、サイズが1、2、
4バイトの3種類がある。これらに対する添字を、それ
ぞれ1、2、4で表す。まず、サイズj(j=1,2,4)の
頂点xについての度数を、d1,d2,d4とする。次に頂点
のサイズごとの最大度数を以下のように設定する。
In the case of TLCS-900, the size is 1, 2,
There are three types of 4 bytes. Subscripts for these are denoted by 1, 2, and 4, respectively. First, the frequencies of the vertex x of the size j (j = 1, 2, 4) are d1, d2, and d4. Next, the maximum frequency for each vertex size is set as follows.

【0062】j=4の場合の使用可能レジスタマップ
は、XWA(またはXBCなど)が使用できるかできないかだ
けであり、空きがあるか、空きがないかだけで表現でき
る。従って、最大度数は、m1(=msingle)の1種類で表
現できる。
The usable register map in the case of j = 4 indicates whether XWA (or XBC or the like) can be used or not, and can be expressed only by whether there is a free space or no free space. Therefore, the maximum frequency can be represented by one type of m1 (= msingle).

【0063】j=2の場合の使用可能レジスタマップ
は、WAとQWA(またはBCとQBCなど)の両方が使用できる場
合、それと、QWAが使用できないが、WAが使用できる場
合などの2種類が考えられる。前者のようなパターン
を、m2(=mdouble)とし、後者のようなバターンをm1(=ms
ingle)として表現する。
The usable register map when j = 2 has two types, such as a case where both WA and QWA (or BC and QBC) can be used, and a case where QWA cannot be used but WA can be used. Conceivable. The pattern like the former is m2 (= mdouble), and the pattern like the latter is m1 (= ms
ingle).

【0064】j=1の場合の使用可能レジスタマップ
は、QW,QA,W,A(またはQB,QC,B,Cなど)の4つが使
用できる場合、QA,W,Aの3つが使用できるがQWのみが
使用できないような場合、QW,Wの2つが使用できてQ
A,Aが使用できないような場合、W,Aの2つが使用でき
てQW,QAが使用できないような場合、Aだけが使用でき
る場合、の合計5つのパターンが考えられる。それぞれ
のパターンについての最大度数を m5(=mquad),m4(=mtriple),m3(=mseparate),m2(=mdou
ble),m1(=msingle) として表現する。
When j = 1, the available register map can use three QA, W, A when four QW, QA, W, A (or QB, QC, B, C, etc.) can be used. If only QW cannot be used, QW and W can be used and Q
When A and A cannot be used, W and A can be used but QW and QA cannot be used, and when only A can be used, a total of five patterns can be considered. The maximum frequency for each pattern is m5 (= mquad), m4 (= mtriple), m3 (= mseparate), m2 (= mdou
ble) and m1 (= msingle).

【0065】以上で述べたレジスタマップと最大度数に
関連する、single(シングル)、double(ダブル)、separa
te(セパレート)、triple(トリプル)、quad(クワツド)の
概念図を図16に示す。
The single, double, and separa related to the register map and the maximum frequency described above.
FIG. 16 is a conceptual diagram of te (separate), triple (triple), and quad (quad).

【0066】以上の設定方法により、図8、7の干渉す
る頂点と使用可能レジスタマップの情報を度数と最大度
数に置き換えたものを図10に示す。
FIG. 10 shows the information obtained by replacing the information of the interfering vertices and the usable register map shown in FIGS. 8 and 7 with the frequency and the maximum frequency by the above setting method.

【0067】次に判断関数fについて定式化する。サイ
ズj(j=1,2,4)の頂点xに干渉する他の頂点を考えた場
合、そのサイズよりも小さいサイズの頂点はすべて頂点
xの使用可能レジスタマップのサイズjの空きを1つず
つ埋めていくことができるために、同じ度数として考え
ることが出来ることを考慮して、関数fを定式化する。
Next, the decision function f is formulated. When considering other vertices that interfere with vertex x of size j (j = 1, 2, 4), all vertices of a size smaller than that size have one free space of size j in the available register map of vertex x. The function f is formalized in consideration that it can be considered as the same frequency because it is possible to fill in each time.

【0068】j=4の場合、サイズに関係なくすべての
頂点は等しくj=4のサイズで使用可能レジスタマップ
を塗ることが出来る。したがって、f4(d1,d2,d4,msi
ngle)の値は、d1+d2+d4<msingleならば真、そうでない
ならば偽である。
When j = 4, all the vertices are equal regardless of the size, and the available register map can be painted with the size of j = 4. Therefore, f4 (d1, d2, d4, msi
The value of ngle) is true if d1 + d2 + d4 <msingle, false otherwise.

【0069】j=2の場合、レジスタマップを早く塗る
ためにj=4サイズの干渉する頂点から塗る。このと
き、ダブルの空きがある箇所から塗るべきである。j=
4サイ_ズの頂点をすべて塗り終わった後で、ダブルが
残った場合はそれらはシングル2つの空きと置き換えら
れる。j=1のサイズの頂点はj=2のサイズの頂点と
して干渉すると考えることができる。以上を定式化する
と、f2(d1,d2,d4,mdouble,msingle)の値は、d4<mdo
ubleのとき、d1+d2<msingle+(mdouble-d4)*2 ならば
真、そうでないならば偽である。d4>=mdoubleのとき、d
1+d2+d4<msingle+mdoubleならば真、そうでないならば
偽である。
In the case of j = 2, in order to paint the register map quickly, paint is performed from the interference vertex of j = 4 size. At this time, you should paint from the place where there is a double space. j =
After filling all the vertices of 4 sizes, if doubles remain, they are replaced with two single vacancies. Vertices of size j = 1 can be considered to interfere as vertices of size j = 2. Formulating the above, the value of f2 (d1, d2, d4, mdouble, msingle) is d4 <mdo
For uble, true if d1 + d2 <msingle + (mdouble-d4) * 2, false otherwise. When d4> = mdouble, d
True if 1 + d2 + d4 <msingle + mdouble, false otherwise.

【0070】j=1の場合、もっとも小さいサイズであ
るため、3種類のサイズそれぞれの干渉する頂点につい
て考慮する必要がある。まず、もっとも大きなサイズj
=4の干渉する頂点について塗っていく。このとき、ク
ワツド、トリプル、セパレート、ダブル、シングルの優
先順位で空きを塗りつぶす。セパレートとダブル以外に
ついては、この順で空きのマップが包含関係を持つてい
るため、優先順位の正しさは直感的にわかるが、セパレ
ートの優先順位がダブルよりも高い理由は以下のように
なる。サイズj=4の頂点に対してはどちらも同じ割合
でレジスタマップを塗るために優劣はない。サイズj=
2の頂点に対してセパレートとダブルどちらを残すべき
かという問題に帰着するが、サイズj=2の頂点に対し
て早く塗れるのはダブルであり、ダブルは後に残してお
くべきである。したがってサイズj=4については、セ
パレートから先に塗らなければならない。サイズj=4
の頂点で塗っていく途中でまったく空きがなくなった場
合は偽である。ここまでは、数式としては定義できない
ので、図11に処理フローとして定義する。j=4につ
いての処理が終わった後は、干渉する頂点のサイズはj
=1、2だけであり、上述の関数f2に帰着できる。
When j = 1, the size is the smallest, and it is necessary to consider the interfering vertices of the three sizes. First, the largest size j
= 4 interfering vertices. At this time, the space is filled in the order of priority of quad, triple, separate, double, and single. Except for separate and double, empty maps have an inclusive relationship in this order, so the correctness of priority can be intuitively understood, but the reason for the priority of separate is higher than double is as follows . For both vertices of size j = 4, there is no difference in painting the register map at the same ratio. Size j =
This results in the problem of whether to leave a separate or double for the vertex of No. 2, but the vertex of size j = 2 can be painted quickly as a double, and the double should be left behind. Therefore, for the size j = 4, the paint must be applied first from the separate. Size j = 4
It is false if there is no free space during painting at the top. Up to this point, since it cannot be defined as a mathematical expression, it is defined as a processing flow in FIG. After the processing for j = 4, the size of the interfering vertex is j
= 1 and 2 and can be reduced to the function f2 described above.

【0071】f1(d1,d2,d4,mquad,mtriple,msepara
te,mdouble,msingle)の値は、上記の処理を行った後
は、d4==0であり、mquad,mtriple,mseparate,mdoubl
e,msingleは更新されているものとする。この段階で偽
が確定していない場合、関数の値は、f2(0,d1,d2,mquad*
2+mtriple+mdouble,mtriple+mseparate*2+msingle)の値
と一致する。この判断関数を用いて図10からスタック
を作成し、グラフ再現部によりレジスタ割付を行った結
果と会わせて図12に示す。
F1 (d1, d2, d4, mquad, mtriple, msepara
The values of te, mdouble, msingle) are d4 == 0 after performing the above processing, and mquad, mtriple, mseparate, mdoubl
It is assumed that e and msingle have been updated. If false is not determined at this stage, the function value is f2 (0, d1, d2, mquad *
2 + mtriple + mdouble, mtriple + mseparate * 2 + msingle). A stack is created from FIG. 10 using this judgment function, and the result is shown in FIG. 12 in association with the result of register allocation by the graph reproduction unit.

【0072】以下、本発明の第3の実施形態によるオブ
ジェクト生成装置を図を参照して説明する。第2の実施
形態の方法でスタックを高速に作成している途中にスピ
ルアウトの必要が生じた場合、別の方法で頂点をスタッ
クに積むことができるかの判新を行い、スピルアウトを
可能な限り回避するのが望ましい。
Hereinafter, an object generating apparatus according to a third embodiment of the present invention will be described with reference to the drawings. If it is necessary to spill out while the stack is being created at high speed by the method of the second embodiment, it is possible to spill out by determining whether vertices can be stacked on the stack by another method. It is desirable to avoid as much as possible.

【0073】第2の実施形態による判断処理はレジスタ
割付処理における主要処理であり、処理時間は割り当て
変数の総数の2乗以上で効いてくる。従って高速性が要
求されるが、比較的まれに発生するスピルアウトについ
ては、できるだけスピルアウトを回避するために、スタ
ックに積めるかどうかの再判断を行う。本実施形態によ
り、回避可能なスピルアウトを回避し、生成オブジェク
ト効率の向上を実現する。本発明が適用されるのは、第
2の実施形態とは異なり、比較的まれに動作する場合で
あり、低速でも間題にならないことを前提とする。
The judgment processing according to the second embodiment is the main processing in the register allocation processing, and the processing time is effective when the total number of allocated variables is equal to or larger than the square. Therefore, although high speed is required, spill-out which occurs relatively rarely is re-determined as to whether or not the spill-out can be stacked on the stack in order to avoid spill-out as much as possible. According to the present embodiment, avoidable spillout is avoided, and the efficiency of generated objects is improved. Unlike the second embodiment, the present invention is applied to a case where the operation is performed relatively rarely, and it is assumed that no problem occurs even at a low speed.

【0074】以下、本実施形態の実装方法について説明
する。ここでは、判断関数fと同様、あらたな判断関数
gを定式化する。
Hereinafter, a mounting method of the present embodiment will be described. Here, similarly to the judgment function f, a new judgment function g is formulated.

【0075】ある頂点xの使用可能レジスタマップma
pを、他の全ての干渉する頂点の使用可能レジスタマッ
プで塗りつぶしていく。すべての干渉する頂点について
塗り終わった後、使用可能レジスタマップmapに頂点
xのサイズでの空きがあれば関数gは真を返す。即ち、
頂点xはスタックに積める。
Usable register map ma of a certain vertex x
Fill p with the available register map of all other interfering vertices. After painting all the interfering vertices, if there is a space in the usable register map map at the size of the vertex x, the function g returns true. That is,
Vertex x is placed on the stack.

【0076】残った空きは干渉するどの頂点でも使用可
能ではないため、後から干渉グラフを再現したときに必
ずその空きだけは塗られずに残つていることが保証され
る。判断関数gについての処理フローを図15に示す。
Since the remaining space is not available at any of the interfering vertices, it is guaranteed that only the space will remain unpainted when the interference graph is reproduced later. FIG. 15 shows a processing flow for the judgment function g.

【0077】例として図13に示すような干渉グラフと
使用可能レジスタマップが与えられている場合を想定す
る。この場合に判断関数fを使用しても、どの頂点もス
タックに積むことが出来ず、スピルアウトを起こさざる
をえない。しかしながら本発明の判断関数gを用いる
と、図14に示すように頂点I0を最初にスタックに積
むことが出来る。
As an example, it is assumed that an interference graph and an available register map as shown in FIG. 13 are given. In this case, even if the judgment function f is used, no vertices can be stacked on the stack, and spill-out must be caused. However, when the judgment function g of the present invention is used, the vertex I0 can be first stacked on the stack as shown in FIG.

【0078】この結果、スピルアウトを発生せずに図1
4に示すようなレジスタ割付を行うことができる。以
上、説明した本発明の処理は、図4の処理フローのよう
にまとめられる。これは、図3のように要約することが
できる。
As a result, without causing spill-out, FIG.
4 can be performed. The processing of the present invention described above is summarized as a processing flow of FIG. This can be summarized as in FIG.

【0079】即ち、本発明によるスタック作成部は、ス
テップ401で、度数を計算する。ステップ403で、
最大度数を計算する。ステップ405で、最初の候補x
を取り出す。ステップ407で、候補xがスタックに積
めるかを判断関数fを使って判断する。積める場合は、
ステップ409で、スタックにPushして、干渉グラフを
更新する。ステップ411で、干渉グラフが空かどうか
を判断し、空でなければ、ステップ405に戻る。空な
ら、干渉グラフを再構成する。
That is, the stack creation unit according to the present invention calculates the frequency in step 401. In step 403,
Calculate the maximum frequency. In step 405, the first candidate x
Take out. In step 407, it is determined using the determination function f whether the candidate x can be stacked on the stack. If you can
At step 409, the stack is pushed to update the interference graph. In step 411, it is determined whether or not the interference graph is empty. If not, the process returns to step 405. If empty, reconstruct the interference graph.

【0080】又、ステップ407で、候補xがスタック
に積めない場合には、ステップ413で、更に候補が残
っているかを判断する。残っていれば、ステップ405
に戻る。残っていなければ、ステップ415で、再び最
初の候補xに戻って、今度は候補xがスタックに積める
かをステップ417で判断関数gを使って判断する。積
める場合は、ステップ409で、スタックにPushして、
干渉グラフを更新する。
If it is determined in step 407 that the candidate x cannot be stacked on the stack, it is determined in step 413 whether any more candidates remain. If left, step 405
Return to If not, in step 415, the process returns to the first candidate x, and it is determined in step 417 whether the candidate x can be stacked on the stack using the determination function g. If you can stack it, push it to the stack at step 409,
Update the interference graph.

【0081】ステップ417で、候補xがスタックに積
めない場合には、ステップ419で、更に候補が残って
いるかを判断する。残っていれば、ステップ415に戻
る。残っていなければ、スピルアウトの処理に移行す
る。
If it is determined in step 417 that the candidate x cannot be stacked on the stack, it is determined in step 419 whether any more candidates remain. If there are, the process returns to step 415. If not, the process proceeds to spill-out processing.

【0082】[0082]

【発明の効果】以上説明したように、この発明によれ
ば、高級言語を機械命令に翻訳するオブジェクト生成装
置において、1つのレジスタを小さいサイズの複数のレ
ジスタとしてアクセスできるようなターゲット機械のた
めのレジスタ割付をカラーリングあるアルゴリズムにて
行う場合に、効率的なレジスタ割付を行うことにより生
成したコードのコードサイズ、実行時間などのオブジェ
クト効率を向上できる。
As described above, according to the present invention, in an object generating apparatus for translating a high-level language into machine instructions, a target machine which can access one register as a plurality of registers having a small size is provided. When register allocation is performed using an algorithm with coloring, object efficiency such as code size and execution time of generated code can be improved by performing efficient register allocation.

【0083】また、カラーリングアルゴリズムにおける
スタックプツシュにおいて、選択する頂点を選ぶ判断を
高速に行うことにより、高速なレジスタ割付を行うこと
ができる。
In addition, in the stack push in the coloring algorithm, a high-speed register allocation can be performed by performing a high-speed determination of selecting a vertex to be selected.

【0084】本発明の効果を図17に示す。ベンチマー
クプログラムStanford(C言語)を用いて、従来の方法
と本発明の方法とによるレジスタ割付をそれぞれ行つた
場合の生成オブジェクトの性能と、コンパイル時間を示
す。図17の結果から以上で述べた本発明の効果を認め
ることができる。
FIG. 17 shows the effect of the present invention. The performance of a generated object and the compile time when register allocation is performed by the conventional method and the method of the present invention using the benchmark program Stanford (C language) are shown. The effects of the present invention described above can be recognized from the results of FIG.

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

【図1】本発明に係るオブジェクト生成装置の構成図を
示す図である。
FIG. 1 is a diagram showing a configuration diagram of an object generation device according to the present invention.

【図2】本発明が適用されるコンパイラの処理フローを
示す。
FIG. 2 shows a processing flow of a compiler to which the present invention is applied.

【図3】本発明によって、中間コードからレジスタ割り
付けを行うまでの処理を示す。
FIG. 3 shows a process from the intermediate code to register allocation according to the present invention.

【図4】本発明の処理フローを示す。FIG. 4 shows a processing flow of the present invention.

【図5】TLCS‐900のレジスタ構成を示す。FIG. 5 shows a register configuration of the TLCS-900.

【図6】簡単なC言語プログラムの例を示す。FIG. 6 shows an example of a simple C language program.

【図7】図6のプログラムを言語非依存の中間コードで
表現した例を示す。
FIG. 7 shows an example in which the program of FIG. 6 is represented by a language-independent intermediate code.

【図8】図7の中間コード上の各変数に対してカラーリ
ングでレジスタを割り付けを行った場合に作成すべき干
渉グラフ
8 is an interference graph to be created when registers are assigned by coloring to each variable on the intermediate code in FIG. 7;

【図9】図8の干渉グラフの各頂点に対しての使用可能
レジスタマップを示す。
FIG. 9 shows an available register map for each vertex of the interference graph of FIG.

【図10】図8、7の情報を本発明に必要な情報に置き
換えた情報を示す。
FIG. 10 shows information obtained by replacing the information in FIGS. 8 and 7 with information necessary for the present invention.

【図11】本発明の判断関数f式を示す。FIG. 11 shows a decision function f equation of the present invention.

【図12】本発明の判断関数f式を用いて、図10の情
報からスタックを作成した例とスタックをもとにグラフ
を再現した例(レジスタ割付の結果)を示す。
12 shows an example in which a stack is created from the information in FIG. 10 using the decision function f formula of the present invention and an example in which a graph is reproduced based on the stack (result of register allocation).

【図13】本発明の判断関数gが動作する例を示す。FIG. 13 shows an example in which the judgment function g of the present invention operates.

【図14】図13の例に対して判断関数gを試した結果
とスタックからグラフを再現した例を示す。
14 shows an example in which a graph is reproduced from a result obtained by testing the judgment function g with respect to the example in FIG. 13 and a stack.

【図15】本発明の判断関数gについての処理フローで
ある。
FIG. 15 is a processing flow for a judgment function g of the present invention.

【図16】本発明による使用可能なレジスタの構成を示
す度数の種類の例としてのシングル、ダブル、セパレー
ト、トリプル、クワッドの概念図である。
FIG. 16 is a conceptual diagram of single, double, separate, triple, and quad as examples of frequency types showing the configuration of a register that can be used according to the present invention.

【図17】Stanfordベンチマークによる本発明の評価結
果を示す。
FIG. 17 shows evaluation results of the present invention based on the Stanford benchmark.

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

1 コンピュータ 5 マウス 6 キーボード 7 モニタ 9 プリンタ 13 フレキシブルディスク 15 駆動ドライブ 1 Computer 5 Mouse 6 Keyboard 7 Monitor 9 Printer 13 Flexible Disk 15 Drive Drive

Claims (2)

【特許請求の範囲】[Claims] 【請求項1】 1つのレジスタを小さいサイズの複数の
レジスタとしてアクセスできるようなターゲット機械の
ためのオブジェクト生成装置であって、高級言語のソー
スコードに含まれる自動変数及び引数の集合と、前記高
級言語を機械命令に翻訳する際に一時的に使用する一時
変数とから、干渉グラフを生成する手段と、この干渉グ
ラフに基づいて干渉グラフの頂点を格納するスタックを
生成する手段と、前記スタックからカラーリングアルゴ
リズムに基づいて前記干渉グラフを再構成する手段と、
夫々の頂点とその使用可能レジスタとの対応を示す情報
を生成する手段とからなり、夫々の頂点がスタックに積
めるかどうかの判断をその頂点の使用可能レジスタの情
報を参照することにより行うことを特徴とするオブジェ
クト生成装置。
1. An object generating apparatus for a target machine which can access one register as a plurality of registers of a small size, comprising: a set of automatic variables and arguments included in a high-level language source code; Means for generating an interference graph from temporary variables used temporarily when translating the language into machine instructions; means for generating a stack for storing vertices of the interference graph based on the interference graph; and Means for reconstructing the interference graph based on a coloring algorithm,
Means for generating information indicating the correspondence between each vertex and its available register, and determining whether each vertex can be stacked on the stack by referring to the information of the available register of that vertex. An object generation device that is a feature.
【請求項2】 1つのレジスタを小さいサイズの複数の
レジスタとしてアクセスできるようなターゲット機械の
ためのオブジェクト生成方法であって、高級言語のソー
スコードに含まれる自動変数及び引数の集合と、前記高
級言語を機械命令に翻訳する際に一時的に使用する一時
変数とから、干渉グラフを生成する段階と、この干渉グ
ラフに基づいて干渉グラフの頂点を格納するスタックを
生成する段階と、前記スタックからカラーリングアルゴ
リズムに基づいて前記干渉グラフを再構成する段階と、
夫々の頂点とその使用可能レジスタとの対応を示す情報
を生成する段階とからなり、夫々の頂点がスタックに積
めるかどうかの判断をその頂点の使用可能レジスタの情
報を参照することにより行うことを特徴とするオブジェ
クト生成方法。
2. A method for generating an object for a target machine in which one register can be accessed as a plurality of registers having a small size, comprising: a set of automatic variables and arguments included in a high-level language source code; From a temporary variable used temporarily when translating the language into machine instructions, generating an interference graph, generating a stack for storing vertices of the interference graph based on the interference graph, Reconstructing the interference graph based on a coloring algorithm;
Generating information indicating the correspondence between each vertex and its available register, and determining whether each vertex can be stacked on the stack by referring to the information of the available register of that vertex. An object generation method that is a feature.
JP10233145A 1998-08-19 1998-08-19 Device and method for generating object Abandoned JP2000066897A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP10233145A JP2000066897A (en) 1998-08-19 1998-08-19 Device and method for generating object

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP10233145A JP2000066897A (en) 1998-08-19 1998-08-19 Device and method for generating object

Publications (1)

Publication Number Publication Date
JP2000066897A true JP2000066897A (en) 2000-03-03

Family

ID=16950437

Family Applications (1)

Application Number Title Priority Date Filing Date
JP10233145A Abandoned JP2000066897A (en) 1998-08-19 1998-08-19 Device and method for generating object

Country Status (1)

Country Link
JP (1) JP2000066897A (en)

Similar Documents

Publication Publication Date Title
JP3110040B2 (en) Method and apparatus for compiling a computer program with register allocation between procedures
US8806463B1 (en) Feedback-directed inter-procedural optimization
US8266603B2 (en) Technique for allocating register to variable for compiling
US7103881B2 (en) Virtual machine to provide compiled code to processing elements embodied on a processor device
US8104026B2 (en) Compiler register allocation and compilation
US6832369B1 (en) Object oriented method and apparatus for class variable initialization
US6408433B1 (en) Method and apparatus for building calling convention prolog and epilog code using a register allocator
JP2500079B2 (en) Program optimization method and compiler system
US20080104365A1 (en) Configurable processor design apparatus and design method, library optimization method, processor, and fabrication method for semiconductor device including processor
EP0650121B1 (en) Resource assignment apparatus
US6434743B1 (en) Method and apparatus for allocating stack slots
EP0702293B1 (en) Compiler with improved live range interference investigation
JP4041248B2 (en) COMPILER DEVICE, COMPUTER-READABLE RECORDING MEDIUM CONTAINING COMPILING PROGRAM, AND COMPILING METHOD
JP2011118909A (en) Memory access instruction vectorization
EP0947922B1 (en) Compiler
EP0825531B1 (en) A language processing unit and a language processing method to translate a source program and generate an object module file
US20050071846A1 (en) Passing parameters by implicit reference
US20010044930A1 (en) Loop optimization method and a compiler
US6421824B1 (en) Method and apparatus for producing a sparse interference graph
US6139200A (en) Register resource allocation feedback
Ottoni et al. Optimal live range merge for address register allocation in embedded programs
JP2000066897A (en) Device and method for generating object
Johansson et al. Linear scan register allocation in a high-performance erlang compiler
JP3264901B2 (en) Compiling device and compiling method
JPH02236638A (en) Register allocation managing system

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20041130

A762 Written abandonment of application

Free format text: JAPANESE INTERMEDIATE CODE: A762

Effective date: 20050126