JPH07141328A - Compiling device - Google Patents

Compiling device

Info

Publication number
JPH07141328A
JPH07141328A JP28712493A JP28712493A JPH07141328A JP H07141328 A JPH07141328 A JP H07141328A JP 28712493 A JP28712493 A JP 28712493A JP 28712493 A JP28712493 A JP 28712493A JP H07141328 A JPH07141328 A JP H07141328A
Authority
JP
Japan
Prior art keywords
loop
value
control variable
conditional
setting part
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
JP28712493A
Other languages
Japanese (ja)
Inventor
Kazuhiro Tomita
和宏 富田
Kenichi Yamamoto
賢一 山本
Hirotoshi 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.)
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 JP28712493A priority Critical patent/JPH07141328A/en
Publication of JPH07141328A publication Critical patent/JPH07141328A/en
Pending legal-status Critical Current

Links

Landscapes

  • Complex Calculations (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

PURPOSE:To provide a compiling device which can vectorize a loop part consisting of a conditional loop instruction sentence of a form where the repetitive execution frequency is not specified in regard to the compiling processing of a computer program. CONSTITUTION:This compiling device includes a translation processing part 3 which generates an object program 4 based on the analyzing result of an analysis processing part 2. The part 2 is provided with a control variable deciding part 30 which decides a loop control variable among those variables of a conditional expression of a conditional loop instruction sentence, an updated value setting part 31 which decides the updated value of the control variable, an initial value setting part 32 which calculates the initial value of the control variable, a final value setting part 33 which decides the final value of the control variable out of the conditional expression of the conditional loop instruction sentence, an executing frequency setting part 34 which decides the loop executing frequency based on the initial value, the final value and the updated value of the control variable, and a loop reconstructing part 35 which reconstructs such a loop that is repetitively executed by the decided frequency.

Description

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

【0001】[0001]

【産業上の利用分野】本発明は計算機の原始プログラム
を、ベクトル命令を実行するベクトル実行部分とスカラ
命令を実行するスカラ実行部分とからなる目的プログラ
ムに翻訳する処理において、繰り返し実行回数が明示さ
れない形式の条件ループ命令文によるループ部分につい
て、ベクトル化を可能にするようにしたコンパイル装置
に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention does not explicitly indicate the number of repetitions in the process of translating a source program of a computer into a target program consisting of a vector execution part for executing vector instructions and a scalar execution part for executing scalar instructions. The present invention relates to a compiling device that enables vectorization of a loop part by a conditional loop statement of a format.

【0002】[0002]

【従来の技術と発明が解決しようとする課題】当業者の
常識的技術として知られているように、ベクトル処理装
置は、ベクトルレジスタにあるデータについて演算を実
行して、演算結果をベクトルレジスタに格納する等の処
理を行うベクトル命令を、高度のパイプライン方式の演
算制御によって高速に実行するものである。
2. Description of the Related Art As known to those skilled in the art as a common sense technique, a vector processing device executes an operation on data in a vector register and stores the operation result in a vector register. A vector instruction that performs processing such as storing is executed at high speed by arithmetic control of an advanced pipeline system.

【0003】コンパイラが或るプログラミング言語で記
述された原始プログラムを、所要の計算機で実行できる
目的プログラムに翻訳する場合に、原始プログラムを解
析して、前記のようなベクトル処理装置によって効率よ
く実行される処理の部分を識別し、ベクトル命令を実行
する目的プログラムに翻訳してベクトル実行部分とす
る、いわゆるベクトル化の処理を行うことはよく知られ
ている。
When a compiler translates a source program written in a certain programming language into a target program that can be executed by a required computer, the source program is analyzed and efficiently executed by the vector processing device as described above. It is well known to perform a so-called vectorization process in which a part of a process to be performed is identified and translated into an object program that executes a vector instruction to be a vector execution part.

【0004】なお、その場合にベクトル化が不適当と識
別され、通常のいわゆるスカラ命令を実行する計算機で
実行するようにする部分を、スカラ実行部分という。ベ
クトル化の主要な対象は、原始プログラムにおいて、配
列データに対する繰り返し処理として記述された部分で
あるが、原始プログラムにおける繰り返し処理の典型的
な記述には、公知のFORTRAN プログラミング言語等のDO
命令文による、いわゆるDOループの記述がある。
In this case, a portion where vectorization is identified as inappropriate and the so-called scalar instruction is executed by a computer is called a scalar execution portion. The main target of vectorization is the part described as the iterative process for the sequence data in the source program, but the typical description of the iterative process in the source program is DO in the well-known FORTRAN programming language.
There is a so-called DO loop description with a statement.

【0005】ここで、ベクトル実行部分については、前
記のように必要なベクトルデータをベクトルレジスタに
予めロードしてベクトル演算を実行しなければ、ベクト
ル処理装置の高速性能を得ることができない等の理由か
ら、ベクトル化の対象となるプログラム部分は、前記繰
り返し処理で処理対象の配列データのベクトル長を決定
する繰り返し実行回数(以下において回転数という)
が、繰り返し処理の最初の実行に入る前に確定している
必要がある。
Regarding the vector execution part, the reason why the high speed performance of the vector processing device cannot be obtained unless the necessary vector data is loaded into the vector register in advance and the vector operation is executed as described above. Therefore, the program part to be vectorized is the number of times of repeated execution (hereinafter referred to as the number of rotations) that determines the vector length of the array data to be processed in the above-mentioned iterative processing.
Must be confirmed before the first execution of the iterative process.

【0006】前記DO命令文の場合には、公知のように図
4(a)の例の「DO 15 I=1,10,3」のような記述によっ
て、「ラベル15までのプログラムを繰り返し実行し、制
御変数Iの初期値を1とし、繰り返し実行1回ごとに制
御変数Iに増分値3を加えて、制御変数Iの値が終値10
を越えたら実行を終わる」ことを示す。
In the case of the above-mentioned DO command statement, as is well known, by the description such as "DO 15 I = 1,10,3" in the example of FIG. 4A, "the program up to label 15 is repeatedly executed. Then, the initial value of the control variable I is set to 1, and the increment value 3 is added to the control variable I for each repeated execution so that the value of the control variable I becomes the final value 10
If it exceeds, the execution ends. "

【0007】従って、この場合の回転数は、 回転数=(終値−初期値+増分値)/増分値=(10−1
+3)/3=4 として確定できる。
Therefore, the rotation speed in this case is as follows: rotation speed = (final price−initial value + incremental value) / incremental value = (10-1
It can be confirmed as +3) / 3 = 4.

【0008】なお、初期値、終値、増分値は何れも変数
であってもよく、何れか一つでも変数で指定されれば、
ベクトル化処理時に回転数の値を算出することはできな
いが、プログラムの内容が正しく記述されていれば、DO
命令文の実行までには、それらの変数の値が確定してい
なければならないから、実行時には繰り返しの最初の実
行を開始するまでに回転数を確定できる。
The initial value, the final value, and the increment value may be variables, and if any one of them is specified by a variable,
The value of the rotation speed cannot be calculated during vectorization processing, but if the contents of the program are described correctly, DO
Since the values of these variables must be determined by the time the command statement is executed, the number of rotations can be determined by the execution before the first execution of the iteration is started.

【0009】そこで、コンパイル装置の解析処理部は図
4(a)のようなDOループを、(b)に処理の流れ図として示
すように展開する。図で「回転数設定」は制御変数に初
期値を与え、又回転数を示す変数I'に、回転数を設定す
る部分であり、回転数は前記のようにコンパイル時に確
定する定数か、又は実行時に算出するための計算式とな
る。
Therefore, the analysis processing unit of the compiling device develops a DO loop as shown in FIG. 4A as shown in FIG. 4B as a processing flow chart. In the figure, "rotation speed setting" is a part that gives an initial value to a control variable and sets the rotation speed in a variable I'representing the rotation speed. The rotation speed is a constant determined at compile time as described above, or It is a calculation formula for calculation at the time of execution.

【0010】又、図4(b) の「判定部I」は、回転数が
0以下の場合に実行をパスする判定を行う部分、「ルー
プ内計算」は(a)のループ内計算部分の内容、「判定部
II」は、ループ内計算を1回実行するごとに、変数I'の
値を1減じ、その結果I'が0になるまで、ループ内計算
を反復する制御を行う部分である。なお、ループ内で変
数Iの参照がある特定の場合には、流れ図のループ内計
算の後にIの更新 (この例ではI=I+3)を加える必要があ
る。
Further, the "decision section I" in FIG. 4 (b) is a section for making a decision to pass the execution when the rotation speed is 0 or less, and the "in-loop calculation" is for the in-loop calculation section in (a). Contents, "Judgment part
"II" is a part for performing a control for repeating the in-loop calculation until the value of the variable I'is decremented by 1 every time the in-loop calculation is executed and I'becomes 0 as a result. Note that in certain cases where there is a reference to the variable I in the loop, it is necessary to add the update of I (I = I + 3 in this example) after the in-loop calculation of the flow chart.

【0011】コンパイル装置の翻訳処理部は、このルー
プ内計算部分がベクトル化に適当な内容か識別し、ベク
トル化する場合には、回転数を処理ベクトル長とするベ
クトル化を行って、目的プログラムのベクトル実行部分
を生成する。
The translation processing unit of the compiling apparatus identifies whether the calculation portion in the loop is suitable for vectorization, and when vectorizing, the translation processing unit performs vectorization with the rotation speed as the processing vector length, and the target program. Generates the vector execution part of.

【0012】ところが、DO命令文のように、回転数を確
定する要素を明示するタイプではなく、任意に指定する
式の論理値が真である期間をループの繰り返し実行を続
ける期間として指定するタイプの命令文(条件ループ命
令文とする)がある。
However, unlike the DO statement, which does not explicitly indicate the element that determines the number of revolutions, it specifies the period during which the logical value of the arbitrarily specified expression is true as the period during which the loop is repeatedly executed. There is a statement (which is a conditional loop statement).

【0013】C言語のwhile 命令文は、前記のような条
件ループ命令文の典型的な例であって、図5(a)の例の
ように記述され、命令語while に続く括弧内の式の論理
値を、毎実行ごとに評価して、それが真であれば、その
後の中括弧内に記述されたプログラムを実行することを
繰り返し、式の値が偽になれば実行を終わることを指定
する。
The C language while command statement is a typical example of the conditional loop command statement as described above, and is described as in the example of FIG. 5A, and the expression in parentheses following the command word while. The logical value of is evaluated for each execution, and if it is true, the program described in curly braces is repeated, and if the value of the expression is false, execution is terminated. specify.

【0014】従って解析処理部は、図5(a)の例のプロ
グラムを解析して、(b)に示す処理の流れ図のように展
開するので、この例のプログラムは、命令語while に続
く括弧内の式「i<10」と、ループ内にあり計算の直後に
実行される「i++」(公知のように、C言語においてi++
はポスト・インクリメントであって、iを参照後、i=i+
1を実行することを示す) とによって、前記FORTRAN のD
O命令文で「DO ... i=0,9,1」と指定したのと同様にな
り、回転数は(9-0+1)/1=10となる。
Therefore, the analysis processing unit analyzes the program of the example of FIG. 5 (a) and develops it as shown in the flow chart of the process of FIG. 5 (b). The expression "i <10" in the above and "i ++" in the loop and executed immediately after the calculation (as is well known, in the C language, i ++
Is a post-increment, i = i +
1 to indicate that the FORTRAN D
This is the same as specifying "DO ... i = 0,9,1" in the O command statement, and the rotation speed is (9-0 + 1) / 1 = 10.

【0015】次に、以下の説明において使用する用語を
定義する。A式とは、命令語whileに続く括弧内の式
(前記例の「i<10」)をいう。B式とは、A式中に記述さ
れ前記DO命令文の制御変数に相当する役割を持つ或る変
数をループ実行中で更新する式 (前記例の「i++」)をい
う。
Next, terms used in the following description will be defined. Expression A is the expression in parentheses following the command word while
("I <10" in the above example). The expression B is an expression (“i ++” in the above example) for updating a certain variable described in the expression A and having a role corresponding to the control variable of the DO command statement during loop execution.

【0016】但し、一般にwhile命令文の文法上から、
B式がwhile命令文中に必ず有ることは要求されていな
い。又、B式のような更新があっても、その更新の増減
分値がループ回転中に一定値であるように指定されると
も限らない。
However, in general, from the syntax of the while statement,
Expression B is not required to be included in the while statement. Further, even if there is an update like the expression B, the increment / decrement value of the update is not always specified to be a constant value during the loop rotation.

【0017】即ち、while 命令文は本来の仕様として、
DO命令文のように回転数を確定する要素を明示するタイ
プではないので、従来C言語等のコンパイラでは前記の
ベクトル化を可能とする要件から、while 命令文のよう
な仕様の命令文のループについてはベクトル化対象とし
ていない。
That is, the while statement has the original specifications:
Unlike the DO statement, which is not a type that explicitly defines the number of rotations, the conventional C language or other compiler allows the vectorization described above. Is not subject to vectorization.

【0018】本発明は、前記のように繰り返し実行回数
が明示されない形式の条件ループ命令文によるループに
ついて、ベクトル化を可能にするようにしたコンパイル
装置を目的とする。
It is an object of the present invention to provide a compiling device capable of vectorizing a loop based on a conditional loop instruction statement in which the number of times of repeated execution is not specified as described above.

【0019】[0019]

【課題を解決するための手段】図1は、本発明の構成を
示すブロック図である。図はコンパイル装置の構成であ
って、任意の条件式の論理値が真である間、ループを繰
り返し実行する条件ループ命令文を含む原始プログラム
1を解析する解析処理部2と、解析処理部2の解析結果
に基づいて目的プログラム4を生成するとともに、実行
回数の定まったループに関してはベクトル化処理を行う
翻訳処理部3とからなるコンパイル装置である。
FIG. 1 is a block diagram showing the configuration of the present invention. The figure shows the configuration of the compiling device, and an analysis processing unit 2 for analyzing a source program 1 including a conditional loop statement for repeatedly executing a loop while a logical value of an arbitrary conditional expression is true, and an analysis processing unit 2 The compiling device includes the translation processing unit 3 that generates the object program 4 on the basis of the analysis result and performs vectorization processing for a loop whose execution count is fixed.

【0020】上記解析処理部2が、条件ループ命令文の
条件式を構成する変数の中から、ループの制御変数を決
定する制御変数決定部30と、繰り返し実行される命令の
中から、上記制御変数決定部30で決定された制御変数の
更新値を求める更新値設定部31と、制御変数の初期値を
求める初期値設定部32と、条件ループ命令文の条件式の
中から制御変数の終値求める終値設定部33と、初期値設
定部32で求めた初期値と、終値設定部33で求めた終値
と、更新値設定部31で求めた更新値とから、ループの実
行回数を決定する実行回数設定部34と、実行回数設定部
34により決定された実行回数だけループを繰り返すよう
ループを再構成するループ再構成部35とを持つ。
The analysis processing unit 2 selects the control variable from the control variable determining unit 30 that determines the control variable of the loop from the variables that form the conditional expression of the conditional loop statement and the control that is repeatedly executed from the instructions. The update value setting unit 31 for obtaining the update value of the control variable determined by the variable determination unit 30, the initial value setting unit 32 for obtaining the initial value of the control variable, and the final value of the control variable from the conditional expressions of the conditional loop statement. Execute to determine the number of loop executions from the final value setting unit 33 to be obtained, the initial value obtained by the initial value setting unit 32, the final price obtained by the final price setting unit 33, and the update value obtained by the update value setting unit 31 Number of times setting unit 34 and execution number setting unit
And a loop reconfiguration unit 35 that reconfigures the loop so that the loop is repeated the number of times of execution determined by 34.

【0021】[0021]

【作用】本発明のコンパイル装置により、前記while 命
令文等の条件ループ命令文について、繰り返し実行プロ
グラムの回転数を実行開始前に確定できるか否かを識別
し、確定可能な場合には、前記DO命令文の場合と同様の
展開を行うので、展開したプログラムについて従来と同
様のベクトル化処理を行うことにより、条件ループ命令
文の原始プログラムからベクトル化した目的プログラム
を生成することが可能になる。
With the compiling device of the present invention, it is discriminated whether or not the number of rotations of the repetitive execution program can be fixed before the start of execution of the conditional loop command statement such as the while command statement. Since the same expansion as in the case of the DO statement is performed, it is possible to generate the vectorized target program from the source program of the conditional loop statement by performing the same vectorization processing as before on the expanded program. .

【0022】[0022]

【実施例】C言語で記述された原始プログラムを翻訳す
るコンパイル装置を例として説明する。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS A compile device for translating a source program written in C language will be described as an example.

【0023】ここで、以下の説明において使用する用語
について説明しておく。変数に対する「値の定義」と
は、当業者が通常使用しているとおり、変数に値を設定
したり、変数の持つ値を更新したりする操作をいうもの
である。
Here, terms used in the following description will be explained. The "value definition" for a variable means an operation of setting a value to the variable or updating the value of the variable, as is commonly used by those skilled in the art.

【0024】又、変数についての「回帰的演算」とは、
当業者が通常使用しているとおり、その変数の持つ値に
ついて或る演算をし、その演算結果をその変数の新たな
値とする操作をいうものである。
"Regressive calculation" for variables means
As is commonly used by those skilled in the art, it means an operation of performing a certain operation on the value of the variable and setting the operation result as a new value of the variable.

【0025】回帰的演算の単純且つ典型的な例は、「i=
i+1 」等である。装置の説明に戻り、図1の解析処理部
2はwhile 命令文を解析して、while 命令文及びそれか
ら指定される繰り返し実行プログラムの記述が文法的に
正しい場合に、それらを例えば前記図5(b)に示すよう
に展開して制御変数決定部30、更新値設定部31、初期値
設定部32、終値設定部33、実行回数設定部34及びループ
再構成部35によって処理する。
A simple and typical example of a recursive operation is "i =
i + 1 "and so on. Returning to the description of the apparatus, the analysis processing unit 2 in FIG. 1 analyzes the while statement and, if the description of the while statement and the repeated execution program specified from it is grammatically correct, those are described, for example, in FIG. It is expanded as shown in b) and processed by the control variable determination unit 30, the update value setting unit 31, the initial value setting unit 32, the final value setting unit 33, the execution count setting unit 34, and the loop reconfiguration unit 35.

【0026】そこで制御変数決定部30は、while 命令文
のA式を解析して制御変数の候補を1個選択し、次に繰
り返し実行プログラム内で、その候補変数について1個
所のみで値の定義があり、その値の定義が繰り返し実行
ごとに必ず実行され、その値の定義が回帰的な加算又は
減算であるか調べ、以上の値の定義条件 (以下にB式の
条件という)が満足されれば、その候補変数を制御変数
とする。
Therefore, the control variable determination unit 30 analyzes the expression A of the while statement and selects one control variable candidate, and then defines the value of the candidate variable only once in the repeated execution program. The value definition is always executed each time it is executed, and it is checked whether the value definition is recursive addition or subtraction, and the above value definition conditions (hereinafter referred to as the condition of formula B) are satisfied. If so, the candidate variable is set as a control variable.

【0027】なお、C言語においてはA式に値の定義が
含まれている場合がある。即ち例えばA式を「++i<10」
のように記述することができ、これは公知のように繰り
返し実行期間の条件「i<10」の論理値を評価するごと
に、評価の前に「i=i+1 」の値の定義を行うことを表す
ので、このような記述の場合には、この値の定義部分を
含めてB式の条件を調べる必要がある。
In the C language, the definition of the value may be included in the A expression. That is, for example, the expression A is "++ i <10"
As is well known, each time the logical value of the condition "i <10" of the repeated execution period is evaluated, the value of "i = i + 1" is defined before the evaluation. In the case of such a description, it is necessary to check the condition of the expression B including the definition part of this value.

【0028】以上の制御変数を決定する処理を、必要な
らA式中の候補変数を順次取り替えて行い、制御変数が
決まらないか、複数個ある場合には、このwhile 命令文
のループはベクトル化不可とし、この解析を中止する。
The above-mentioned processing for determining the control variables is performed by sequentially replacing the candidate variables in the expression A if necessary. If there are a plurality of control variables or if there are a plurality of control variables, the loop of this while statement is vectorized. No, and this analysis is stopped.

【0029】1個の制御変数を決定できた場合には、次
に更新値設定部31が、制御変数決定部30の決定した制御
変数に対する、前記の回帰的加算又は減算の加減算値を
更新値として求める。なお、以下において、この値を増
分値という。
When one control variable can be determined, the update value setting unit 31 then updates the control variable determined by the control variable determination unit 30 with the addition / subtraction value of the recursive addition or subtraction described above. Ask as. In addition, below, this value is called an increment value.

【0030】次に初期値設定部32がA式で最初にその制
御変数が持つ値を初期値とする。又、終値設定部33がA
式を解析して制御変数に対してA式の論理値を与える要
素となる変数又は値を終値とする。
Next, the initial value setting unit 32 first sets the value of the control variable in the expression A as the initial value. Also, the closing price setting unit 33
A variable or a value that is an element that analyzes the expression and gives the logical value of the expression A to the control variable is set as the final value.

【0031】制御変数の初期値及び変数で表されている
増分値、終値については、必要ならば解析処理部2の解
析結果を調べて、例えば制御変数とした変数が、この処
理対象のループに入る直前に持っている値を求めること
により初期値を得る。又、直ちに値が定まるときはその
値を取得し、実行時まで値が定まらなければ変数のまま
とする。
Regarding the initial value of the control variable and the increment value and the final value represented by the variable, if necessary, the analysis result of the analysis processing unit 2 is checked, and the variable used as the control variable is set in the loop to be processed. The initial value is obtained by finding the value that the user has immediately before entering. If the value is immediately set, the value is acquired, and if the value is not set until execution, the variable remains as it is.

【0032】なお、前記のような形でA式にB式を含む
場合には、図2(a)に示すように、プレインクリメン
ト、プレデクリメント等と、ポストインクリメント、ポ
ストデクリメントがあり、それらに応じて初期値の値を
異ならせる。
When the expression A includes the expression B as described above, there are pre-increment, pre-decrement, etc., and post-increment, post-decrement as shown in FIG. 2 (a). The initial value is changed accordingly.

【0033】又、A式が「i」のように、終値を陽に表
示しない形の場合は、言語の仕様に従って、省略されて
いる終値が決まる。即ちiの論理値は、iが非0であれ
ば真(=1)、0であれば偽(=0)であるので、A式
の場合に「i」は「i≠0」と同一となり、終値を0と
する。
In the case where the expression A has a form such that the closing price is not displayed explicitly, as in the case of "i", the omitted closing price is determined according to the language specifications. That is, since the logical value of i is true (= 1) when i is non-zero and false (= 0) when i is 0, “i” is the same as “i ≠ 0” in the case of expression A. , And the closing price is 0.

【0034】増分値については、値が決まらない場合に
は、後述のような増分値の正負に基づく各種のチェック
ができないので、増分値については現に値が定まらなけ
れば、このループはベクトル化対象外と判断して、この
解析を中止する。
For the increment value, if the value is not determined, various checks based on the positive / negative of the increment value, which will be described later, cannot be performed. This analysis is judged to be outside, and this analysis is stopped.

【0035】なお、利用者が指定するオプションを設け
て、それが指定された場合には、増分値の値が実行時ま
で定まらない場合であっても、正しい正負符号を持つも
のとして処理するようにしてもよい。
An option designated by the user is provided, and when the option is designated, even if the value of the increment value is not determined until the time of execution, it is processed as having a correct sign. You may

【0036】又、終値設定部33及び更新値設定部31は、
以上の終値及び増分値について、繰り返し実行プログラ
ムの中で、値の定義が有るか否か検査し、このプログラ
ム中で値の定義がある場合には、回転数を実行前に確定
することが不可能か、単純にはできないので、このルー
プはベクトル化不可とし、この解析を中止する。
Further, the final price setting unit 33 and the update value setting unit 31 are
For the above closing value and increment value, it is checked whether or not there is a value definition in the repetitive execution program, and if there is a value definition in this program, it is not possible to confirm the rotation speed before execution. Since it is possible or simply not possible, this loop is not vectorizable, and this analysis is stopped.

【0037】以上で初期値、増分値及び終値が決まる
と、実行回数設定部34は、それらを使用して繰り返し実
行プログラムのループの回転数を回転数を表す変数に設
定するプログラム(前記の図4(b)の「回転数設定」の
ステップに相当する部分)を生成する。
When the initial value, the increment value, and the final value are determined as described above, the execution number setting unit 34 uses them to set the number of rotations of the loop of the repeatedly executed program to the variable representing the number of rotations (see the above-mentioned figure). 4 (b), which corresponds to the step of "rotation number setting") is generated.

【0038】回転数の計算式は、A式の条件式、B式の
加減算の別、及び増分値の正負によって図3(a)のよう
に区分できる。なお、条件式が「≠(等しくない)」の
場合は、増分値が±1以外の場合には、制御変数の値が
終値を飛び越して更新される可能性を考慮しなければな
らないので、処理の簡単化のために本実施例では、条件
式が≠の場合には増分値に「±1」のみを許し、その他
の増分値の場合には、この解析を中止する。
The formula for calculating the number of revolutions can be classified as shown in FIG. 3 (a) depending on the conditional expression of the expression A, the addition / subtraction of the expression B, and whether the increment value is positive or negative. If the conditional expression is “≠ (not equal)”, and if the increment value is other than ± 1, it is necessary to consider the possibility that the value of the control variable will be updated by jumping over the final value. In order to simplify the above, in the present embodiment, when the conditional expression is ≠, only "± 1" is allowed as the increment value, and in the case of other increment values, this analysis is stopped.

【0039】又、条件式に大小判定(<、>)が含まれ
る場合には、図3(b)に示す条件の組合せにより、ルー
プの状態を識別し、永久に回転するループとなる可能性
のある「誤りループ」の場合は、このループはベクトル
化不可として、この解析を中止する。なお、前記の増分
値のオプションが指定された場合には、この判定を省略
して、正しいループであるとみなす。
Further, when the conditional expression includes the magnitude judgment (<,>), the state of the loop can be identified by the combination of the conditions shown in FIG. 3 (b), and the loop may be a permanently rotating loop. In the case of an "erroneous loop", the loop is regarded as non-vectorizable and the analysis is stopped. When the option of the increment value is specified, this judgment is omitted and the loop is considered to be correct.

【0040】なお明らかなように、図3(b)の条件で誤
りループの場合にも、ループの中に何等かの条件でルー
プを飛び出すようにしたプログラムが含まれていたり、
外部から強制的に実行を中止する等を想定して記述され
ている場合があるので、一般的にこのプログラムを誤り
とすることはできない。
As is clear, even in the case of an erroneous loop under the condition of FIG. 3 (b), there is a program included in the loop that causes the loop to jump out under some condition,
In some cases, this program cannot be made an error because it is written assuming that the execution will be forcibly stopped from the outside.

【0041】以上により、ベクトル化可能である場合
に、初期値、増分値、終値の3値がすべて確定している
場合には、それらから図3(a)に従って回転数を算出
し、その値を定数として回転数の変数に代入する文を生
成する。
As described above, when vectorization is possible, if all three values of the initial value, the increment value, and the final value are fixed, the rotational speed is calculated from them and the value is calculated according to FIG. 3 (a). Generate a statement that assigns to the variable of rotation speed as a constant.

【0042】又、前記3値の何れかが実行時まで値の定
まらない変数である場合には、図3(a)に従って回転数
を算出する計算式を生成して、その計算式の演算結果を
回転数の変数に代入するように構成した文を生成する。
If any of the three values is a variable whose value is not determined until execution, a calculation formula for calculating the rotation speed is generated according to FIG. 3A, and the calculation result of the calculation formula is generated. Generate a statement configured to assign to the variable for the number of revolutions.

【0043】ループ再構成部35は、このように生成した
何れかの形の文を回転数設定のステップとして、繰り返
し実行プログラムの部分に前置することにより、while
命令文のループを前記DO命令文の場合と同様の構成に展
開したプログラムに変換して、翻訳処理部3に渡すべ
き、解析処理部2の解析結果とする。図5(c)は、(a)の
プログラムを以上の処理により変換した例を示す図であ
る。
The loop reconstructing unit 35 prepends a statement of any of the forms thus generated in the portion of the repetitive execution program as a step of setting the rotation number, so that while
The loop of the imperative sentence is converted into a program expanded into the same configuration as the case of the DO imperative sentence, and the analysis result of the analysis processing unit 2 to be passed to the translation processing unit 3 is set. FIG. 5C is a diagram showing an example in which the program of FIG. 5A is converted by the above processing.

【0044】翻訳処理部3は、その展開されたプログラ
ムについて、DO命令文の場合と同様の通常のベクトル化
処理により、ループ計算部分の処理内容がベクトルデー
タを処理するプログラムで、ベクトル化に適する内容か
を検査し、ベクトル化に適する場合には、展開プログラ
ムで示される回転数に基づくベクトル長のデータを処理
するベクトル実行部分の目的プログラムを生成する。
The translation processing unit 3 is a program in which the processing content of the loop calculation portion processes vector data by the normal vectorization processing similar to the case of the DO statement for the expanded program, and is suitable for vectorization. If it is suitable for vectorization, the target program of the vector execution part for processing the data of the vector length based on the rotation number indicated by the expansion program is generated.

【0045】図6は本発明の制御変数決定部30、更新値
設定部31、初期値設定部32、終値設定部33、実行回数設
定部34及びループ再構成部35による、while 命令文ルー
プの解析及び展開の処理の流れの一例を示す図であり、
先ず処理ステップ10でwhile命令文のA式を解析して、
制御変数の候補とする変数を決める。
FIG. 6 shows a while statement loop by the control variable determination unit 30, the update value setting unit 31, the initial value setting unit 32, the final value setting unit 33, the execution number setting unit 34 and the loop reconstructing unit 35 of the present invention. It is a figure showing an example of the flow of processing of analysis and expansion,
First, in processing step 10, the A expression of the while statement is analyzed,
Decide the variable to be a control variable candidate.

【0046】処理ステップ11で、各候補変数それぞれに
ついて、当該変数を更新する文、即ちB式の候補を、繰
り返し実行プログラムの中から検索し、処理ステップ12
でそれらのふるい分けを行い、更新が1回のみで、それ
が回帰的値の定義であるB式の候補を残す。
In processing step 11, for each candidate variable, a sentence for updating the variable, that is, a candidate of the expression B, is searched from the repeated execution program, and processing step 12
, And sift them, and the update is performed only once, and the candidates of the formula B, which is the definition of the recursive value, are left.

【0047】処理ステップ13で識別して、残ったB式候
補が1個のみであれば、それをB式として以下の処理を
続け、B式候補が無いか又は複数個であればこの処理を
中止する。
If there is only one B-expression candidate identified in the processing step 13, the following processing is continued by setting it as the B-expression. If there are no B-expression candidates or there are a plurality of B-expression candidates, this processing is executed. Abort.

【0048】なお、処理を中止した場合は、例えば解析
処理部2に通知し、解析処理部2はそのwhile 命令文ル
ープについては、その他の部分と同様に、ベクトル化対
象外として解析処理部2から受け取った情報をそのまま
翻訳処理部3へ渡すものとし、以下で処理を中止した場
合も同様とする。
When the processing is stopped, the analysis processing unit 2 is notified, for example, and the analysis processing unit 2 excludes the while statement loop from the vectorization target as in the other portions. It is assumed that the information received from the computer is passed to the translation processing unit 3 as it is, and the same applies when the processing is stopped below.

【0049】B式が決まると、処理ステップ14でその式
から増分値を決定し、処理ステップ15で増分値の値が現
に定まるか識別し (このために要すれば解析処理部2に
問い合わせて、値の定まる場合にその値を取得する) 、
値が実行時まで定まらない場合は処理を中止する(本例
では前記の増分値オプションは無いものとする)。
When the formula B is determined, the increment value is determined from the formula in the processing step 14, and it is discriminated whether or not the value of the increment value is actually determined in the processing step 15 (for this purpose, the analysis processing unit 2 is inquired). , If the value is fixed, get that value),
If the value is not determined until the time of execution, the processing is stopped (in this example, the increment value option is not provided).

【0050】次に、処理ステップ16でA式を解析し、必
要な場合はこのループの前までのプログラムについての
解析処理部2の解析結果を参照して、変数の値を求める
ことにより、初期値、終値を取り出す。なお、初期値の
決定には図2を参照し、その規則に従う。
Next, in the processing step 16, the expression A is analyzed, and if necessary, the value of the variable is obtained by referring to the analysis result of the analysis processing section 2 for the program up to this loop, thereby obtaining the initial value. Get the value and closing price. Note that FIG. 2 is referred to in determining the initial value, and the rule is followed.

【0051】処理ステップ17で、終値、増分値とした変
数について、繰り返し実行プログラム内の値の定義があ
るか検索し、その結果値の定義があることを処理ステッ
プ18で識別した場合は、前記のとおり回転数を確定でき
ないので処理を中止する。
In processing step 17, it is searched for the definition of the value in the repetitive execution program for the variable used as the final value and the increment value, and if it is identified in processing step 18 that the definition of the result value exists, Since the number of rotations cannot be confirmed as shown in, the processing is stopped.

【0052】前記の値の定義が無い場合は処理ステップ
19で図3(b) のテーブルに従って、ループの正しさを判
定し、又条件式が≠の場合には増分値が±1以外か識別
し、何れかを満足しなければ処理を中止する。処理可能
の場合は、処理ステップ20で図3(a) のテーブルから回
転数計算式を決定して、プログラムの変換をする。
If there is no definition of the above value, processing step
In step 19, the correctness of the loop is judged according to the table of FIG. 3 (b), and if the conditional expression is ≠, it is discriminated whether the increment value is other than ± 1, and if either of the conditions is not satisfied, the processing is stopped. If the processing is possible, the rotational speed calculation formula is determined from the table of FIG. 3A in processing step 20 and the program is converted.

【0053】プログラムの変換は、先ず処理ステップ21
で解析処理部2から受け取っている展開プログラム(図
5(b)参照)の判定部Iをループ外のループの前に移
す。処理ステップ22で回転数計算式に従って回転数の値
を決定し回転数の変数i'に設定するプログラムを生成し
て回転数設定ステップとして判定部Iの更に前に挿入す
る。
The conversion of the program is performed by first processing step 21.
Then, the determination unit I of the expansion program (see FIG. 5B) received from the analysis processing unit 2 is moved to the loop outside the loop. In processing step 22, a program for determining the value of the number of revolutions according to the formula for calculating the number of revolutions and setting it in the variable i'of the number of revolutions is generated and inserted as a number of revolutions setting step before the determination unit I.

【0054】次に処理ステップ23で判定部Iの繰り返し
実行プログラムをパスする判定条件を、変数i'の値が0
以下で分岐するように変更する。処理ステップ24で、元
の無条件分岐のステップを、判定部IIのステップに変
え、判定部IIでは回転数の変数i'を1減じて、結果が0
でなければループ内計算の先頭に分岐するようにする。
Next, in processing step 23, the judgment condition for passing the repetitive execution program of the judgment unit I is set so that the value of the variable i'is 0.
Change to branch below. In the processing step 24, the original unconditional branch step is changed to the step of the judging section II, and the judging section II subtracts 1 from the variable i ′ of the rotation speed, and the result is 0.
If not, branch to the beginning of the calculation in the loop.

【0055】以上の変換により、図5の(a)のwhile 命
令文のループの、展開プログラム(b)が、(c)のように変
換され、DOループの場合の展開(図4(b))と同じ構成
になるので、翻訳処理部3はこの展開プログラムについ
て、従来のDOループの場合と同様の処理でベクトル化処
理を行うことができる。
By the above conversion, the expansion program (b) of the while statement loop of FIG. 5A is converted as shown in FIG. 5C, and the expansion in the case of the DO loop (FIG. 4B) ), The translation processing unit 3 can perform vectorization processing on this expansion program by the same processing as in the case of the conventional DO loop.

【0056】[0056]

【発明の効果】以上の説明から明らかなように本発明に
よれば、ベクトル化処理を行うコンパイル装置におい
て、従来ベクトル化の対象外とされた、繰り返し実行回
数が明示されない形式の条件ループ命令文によるループ
部分についても、ベクトル化が可能になるという著しい
工業的効果がある。
As is apparent from the above description, according to the present invention, in the compiling device for performing the vectorization processing, the conditional loop instruction statement of the format which is not included in the conventional vectorization and in which the number of times of repeated execution is not explicitly stated is provided. There is also a remarkable industrial effect that vectorization is also possible for the loop part due to.

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

【図1】 本発明の構成を示すブロック図FIG. 1 is a block diagram showing the configuration of the present invention.

【図2】 A式に制御変数の値の定義がある場合の初期
値を説明する図
FIG. 2 is a diagram illustrating an initial value when a value of a control variable is defined in expression A.

【図3】 回転数計算式等を説明する図FIG. 3 is a diagram illustrating a rotational speed calculation formula and the like.

【図4】 DOループの例を説明する図FIG. 4 is a diagram illustrating an example of a DO loop.

【図5】 while ループの例を説明する図FIG. 5 is a diagram illustrating an example of a while loop.

【図6】 本発明の処理の流れ図FIG. 6 is a flow chart of processing of the present invention.

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

1 原始プログラム 2 解析処理部 3 翻訳処理部 4 目的プログラム 10〜24 処理ステップ 30 制御変数決定部 31 更新値設定部 32 初期値設定部 33 終値設定部 34 実行回数設定部 35 ループ再構成部 1 source program 2 analysis processing unit 3 translation processing unit 4 target program 10 to 24 processing steps 30 control variable determination unit 31 update value setting unit 32 initial value setting unit 33 final value setting unit 34 execution count setting unit 35 loop reconfiguration unit

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】 任意の条件式の論理値が真である間、ル
ープを繰り返し実行する条件ループ命令文を含む原始プ
ログラム(1)を解析する解析処理部(2)と、 該解析処理部の解析結果に基づいて目的プログラムを生
成するとともに、実行回数の定まったループに関しては
ベクトル化処理を行う翻訳処理部(3)とからなるコンパ
イル装置であって、 上記解析処理部(2)が、 条件ループ命令文の条件式を構成する変数の中から、ル
ープの制御変数を決定する制御変数決定部(30)と、 繰り返し実行される命令の中から、上記制御変数決定部
(30)で決定された制御変数の更新値を求める更新値設定
部(31)と、 制御変数の初期値を求める初期値設定部(32)と、 条件ループ命令文の条件式の中から制御変数の終値求め
る終値設定部(33)と、 初期値設定部(32)で求めた初期値と、終値設定部(33)で
求めた終値と、更新値設定部(31)で求めた更新値とか
ら、ループの実行回数を決定する実行回数設定部(34)
と、 実行回数設定部(34)により決定された実行回数だけルー
プを繰り返すようループを再構成するループ再構成部(3
5)とを持つことを特徴とするコンパイル装置。
1. An analysis processing unit (2) for analyzing a source program (1) including a conditional loop statement for repeatedly executing a loop while a logical value of an arbitrary conditional expression is true; A compiling device comprising a translation processing unit (3) for generating a target program based on an analysis result and performing vectorization processing for a loop whose execution count is fixed, wherein the analysis processing unit (2) The control variable determination unit (30) that determines the control variable of the loop from the variables that make up the conditional expression of the loop statement, and the control variable determination unit that is selected from the commands that are repeatedly executed.
An update value setting part (31) that obtains the update value of the control variable determined in (30), an initial value setting part (32) that obtains the initial value of the control variable, and control from the conditional expression of the conditional loop statement. The closing price setting part (33) to find the closing price of the variable, the initial value found in the initial value setting part (32), the closing price found in the closing price setting part (33), and the updated value found in the updated value setting part (31) From, the execution count setting unit that determines the execution count of the loop (34)
And a loop reconfiguration unit (3) that reconfigures the loop so that the loop is repeated for the number of executions determined by the execution count setting unit (34).
5) A compiling device characterized by having and.
JP28712493A 1993-11-17 1993-11-17 Compiling device Pending JPH07141328A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP28712493A JPH07141328A (en) 1993-11-17 1993-11-17 Compiling device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP28712493A JPH07141328A (en) 1993-11-17 1993-11-17 Compiling device

Publications (1)

Publication Number Publication Date
JPH07141328A true JPH07141328A (en) 1995-06-02

Family

ID=17713389

Family Applications (1)

Application Number Title Priority Date Filing Date
JP28712493A Pending JPH07141328A (en) 1993-11-17 1993-11-17 Compiling device

Country Status (1)

Country Link
JP (1) JPH07141328A (en)

Similar Documents

Publication Publication Date Title
EP0214751B1 (en) A method for vectorizing and compiling object code
US6473897B1 (en) Method and apparatus for generating multiple processor-specific code segments in a single executable
US5317743A (en) System for compiling iterated loops based on the possibility of parallel execution
US5361357A (en) Method and apparatus for optimizing computer file compilation
US4821181A (en) Method for converting a source program of high level language statement into an object program for a vector processor
US6049668A (en) Method and apparatus for supporting multiple processor-specific code segments in a single executable
US10860300B2 (en) Direct function call substitution using preprocessor
US5280617A (en) Automatic program code generation in a compiler system for an instantiation of a generic program structure and based on formal parameters and characteristics of actual parameters
JPH05257709A (en) Parallelism discriminating method and parallelism supporting method using the same
JPH0814817B2 (en) Automatic vectorization method
EP0884678A2 (en) Loader conditionally replacing a code sequence with a functionally-alike code sequence in an executable program intended for execution in different run-time environments
JPH06103463B2 (en) Code generation method
JPH04215132A (en) Compiler optimizing method
JP3539613B2 (en) Array summary analysis method for loops containing loop jump statements
JPH07141328A (en) Compiling device
JP2002073346A (en) Compiler, storage medium, program conversion device, program conversion method and microcomputer
JPH07271631A (en) Debugger
JP2621555B2 (en) Vectorization processing method
JPS62169272A (en) Unrolling processing system for vector arithmetic string loop
JP3594106B2 (en) Automatic programming device, automatic programming method and recording medium
LaMeres Program Flow Instructions
JP2956591B2 (en) Method and apparatus for parallelizing a loop having a conditional jump out of the loop
JPH02236638A (en) Register allocation managing system
JPH11195011A (en) Language translation processor, language translation processing method and record medium recording language translation processing program
JP3311774B2 (en) Compiler unit

Legal Events

Date Code Title Description
A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20020226