[go: up one dir, main page]

JP2000194569A - COMPILING DEVICE, COMPILING METHOD, COMPUTER-READABLE RECORDING MEDIUM STORED COMPILE PROGRAM, AND COMPUTER-READABLE RECORDING MEDIUM STORED OBJECT PROGRAM - Google Patents

COMPILING DEVICE, COMPILING METHOD, COMPUTER-READABLE RECORDING MEDIUM STORED COMPILE PROGRAM, AND COMPUTER-READABLE RECORDING MEDIUM STORED OBJECT PROGRAM

Info

Publication number
JP2000194569A
JP2000194569A JP10371613A JP37161398A JP2000194569A JP 2000194569 A JP2000194569 A JP 2000194569A JP 10371613 A JP10371613 A JP 10371613A JP 37161398 A JP37161398 A JP 37161398A JP 2000194569 A JP2000194569 A JP 2000194569A
Authority
JP
Japan
Prior art keywords
processing
state
program
start address
recording area
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
JP10371613A
Other languages
Japanese (ja)
Inventor
Kenji Tomizawa
研二 冨澤
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
Toshiba AVE Co Ltd
Original Assignee
Toshiba Corp
Toshiba AVE Co 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 Toshiba Corp, Toshiba AVE Co Ltd filed Critical Toshiba Corp
Priority to JP10371613A priority Critical patent/JP2000194569A/en
Publication of JP2000194569A publication Critical patent/JP2000194569A/en
Pending legal-status Critical Current

Links

Landscapes

  • Executing Machine-Instructions (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

(57)【要約】 【課題】 ループ処理を有する目的プログラムの容量を
減らし、その処理に要する時間を短縮することにある。 【解決手段】 原始プログラム又は原始言語を低級言語
に変換した中間テキスト内のループ処理部を抽出するル
ープ処理抽出手段124と、条件分岐命令内のループ回
数を制御する変数の記録領域を解析し、後記先頭アドレ
ス値を記録するアドレス記録領域を選定する記録領域解
析手段125と、状態処理の各々について先頭アドレス
値を計算し、1つの状態処理終了後、次に実行する状態
処理の先頭アドレス値を前記アドレス記録領域内に書き
込む先頭アドレス設定手段126と、条件分岐命令を、
アドレス記録領域内の先頭アドレス値を参照することに
より次に実行する状態処理の先頭アドレスにジャンプ
し、ジャンプ先の状態処理を行う処理を処理装置に実行
させるジャンプ命令に変換するジャンプ命令変換手段1
27とを有することを特徴とする。
(57) [Summary] [PROBLEMS] To reduce the capacity of a target program having loop processing and to reduce the time required for the processing. A loop processing extracting unit (124) for extracting a loop processing unit in an intermediate text obtained by converting a source program or a source language into a low-level language, and a recording area of a variable for controlling the number of loops in a conditional branch instruction are analyzed. A recording area analyzing means 125 for selecting an address recording area for recording a head address value to be described later; calculating a head address value for each state processing; A head address setting means 126 for writing in the address recording area, and a conditional branch instruction
Jump instruction conversion means 1 for jumping to the start address of the state processing to be executed next by referring to the start address value in the address recording area, and converting the processing for performing the state processing of the jump destination into a jump instruction to be executed by the processing device.
27.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明は、原始言語で記述さ
れた原始プログラムを処理装置が実行容易な目的プログ
ラムに変換するコンパイル装置、コンパイル方法、コン
パイルプログラムを格納したコンピュータ読み取り可能
な記録媒体および当該コンパイル方法により作成された
目的プログラムを格納したコンピュータ読み取り可能な
記録媒体に関し、特に、ループ処理に要する時間を短縮
し、目的プログラムの容量を削減する技術に係わる。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a compiling device for converting a source program described in a source language into a target program which can be easily executed by a processing device, a compiling method, a computer-readable recording medium storing a compiling program, and a computer-readable recording medium. The present invention relates to a computer-readable recording medium storing a target program created by a compiling method, and more particularly to a technique for reducing the time required for loop processing and reducing the capacity of the target program.

【0002】[0002]

【従来の技術】一般的に、コンピュータ等の処理装置に
所定の処理を実行させるための目的プログラムを開発す
る場合、開発者は、始めに原始言語を用いて原始プログ
ラムを作成した後、その原始プログラムをコンパイル装
置に導入することにより、原始言語を目的言語に変換し
(コンパイル処理)、所望の処理を実行させる目的プロ
グラムを生成する。これは、原始言語で書かれた原始プ
ログラムの状態では処理装置が原始プログラム内の命令
を解釈するために時間を要し、所定の処理の実行に要す
る時間が長くなるためである。これに対して、コンパイ
ル処理により生成される目的プログラムは、処理装置の
理解に適した言語で処理装置への各命令が記述されてい
るために、処理装置が与えられた命令を理解することが
容易となり、所定の処理の実行に要する時間を大幅に短
縮することが可能となる。尚、ここで言う「原始言語」
とは、C言語といった、開発者のプログラミング作業を
容易にする高級プログラム言語、「目的言語」とは、処
理装置が実際の処理を実行するために適した、いわゆる
機械向け言語のことを意味し、「目的プログラム」は、
1つ又は複数の目的プログラム(オブジェクト)に対し
てリンク手順を施すことにより、処理装置が実行可能な
実行プログラムに変換される。
2. Description of the Related Art Generally, when developing a target program for causing a processing device such as a computer to execute a predetermined process, a developer first creates a source program using a source language, and then prepares the source program. By introducing the program into the compiling device, the source language is converted into the target language (compile processing), and the target program for executing the desired processing is generated. This is because, in the state of the source program written in the source language, it takes time for the processing device to interpret the instructions in the source program, and the time required for executing the predetermined processing becomes longer. On the other hand, in the target program generated by the compiling process, since each instruction to the processing device is described in a language suitable for understanding the processing device, the processing device cannot understand the given instruction. As a result, the time required to execute the predetermined processing can be significantly reduced. The "primitive language" mentioned here
Means a high-level programming language, such as C language, which facilitates programming work for developers, and a "target language" means a so-called machine language suitable for a processing device to execute actual processing. , "Purpose Program"
By performing a link procedure on one or more target programs (objects), the program is converted into an executable program executable by the processing device.

【0003】次に、上記コンパイル処理方法について簡
単に説明する。
Next, the compile processing method will be briefly described.

【0004】典型的なコンパイル処理は、1)構文解
釈、2)コード変換の2つの段階により行われる。すな
わち、第1段階として、原始言語で記述された原始プロ
グラムの内容を低級言語に変換した中間テキストを生成
し(構文解釈ステップ)、第2段階として、第1段階で
生成された中間テキスト内の文字列を処理装置に適した
命令コードに置換し、必要に応じて、他の目的プログラ
ムとのアドレスのリンクを行うための制御コードを付加
する(コード変換ステップ)。ここで、「低級言語」と
は、処理装置に依存した言語であり、原始言語と目的言
語のいわば中間の位置に属し、一般的にアセンブリ言語
と呼ばれているものである。
[0004] A typical compiling process is performed in two stages: 1) parsing, 2) transcoding. That is, as a first step, an intermediate text is generated by converting the contents of a source program described in a source language into a lower-level language (syntax interpretation step). As a second step, the intermediate text in the intermediate text generated in the first step is generated. The character string is replaced with an instruction code suitable for the processing device, and a control code for linking an address with another target program is added as necessary (code conversion step). Here, the "low-level language" is a language depending on the processing device, belongs to a so-called intermediate position between the source language and the target language, and is generally called an assembly language.

【0005】[0005]

【発明が解決しようとする課題】以上述べてきたよう
に、処理装置に所定の処理を実行させるためのプログラ
ムを作成しようとする場合、原始言語で記述した原始プ
ログラムに対してコンパイル処理を施すことにより目的
プログラムを生成し、その目的プログラムを処理装置に
実行させることによって装置の処理速度の改善を図って
いる。ところが、最近、従来のコンパイル装置の状態で
は、ループ処理を有する原始プログラムをコンパイル処
理する際に、いくつかの技術的問題が生じることが明ら
かとなってきた。以下、この技術的問題をわかりやすく
説明するために、図12に示す処理を処理装置に実行さ
せる目的プログラムを生成することを考える。図12に
示すような、少なくとも1つ以上の共通処理部を持つ、
複数の処理を順次実行させるプログラムを記述する際、
ある変数を巡回させ(以下、巡回変数と略記)、処理X
を兼用し、例えば、巡回変数が0のときは処理A、1の
時は処理B、2の時は処理C、3の時は処理Dと選択し
て実行するようにできる。このように、複数ある状態処
理の共通部以外の所をある変数を巡回させ選択・実行す
ることで実現した処理をループ処理という。
As described above, when creating a program for causing a processing device to execute a predetermined process, it is necessary to compile a source program described in a source language. Thus, the processing speed of the device is improved by generating a target program and causing the processing device to execute the target program. However, recently, it has become clear that some technical problems occur when compiling a source program having loop processing in the state of the conventional compiling device. Hereinafter, in order to explain this technical problem in an easy-to-understand manner, generation of a target program that causes the processing device to execute the processing illustrated in FIG. 12 will be considered. Having at least one or more common processing units as shown in FIG.
When writing a program that executes multiple processes sequentially,
A certain variable is circulated (hereinafter abbreviated as a cyclic variable), and processing X
For example, when the cyclic variable is 0, the process A is selected, the process is B when the variable is 1, the process C is selected when the cyclic variable is 2, and the process D is selected when the cyclic variable is 3. In this manner, a process realized by circulating a variable and selecting and executing a portion other than a common part of a plurality of state processes is called a loop process.

【0006】図12に示す処理を処理装置に実行させる
目的プログラムを生成する際は、始めに、原始言語を用
いて原始プログラムを生成する。これを処理装置に実行
させるための原始プログラムの形態には幾つかのタイプ
があるが、通常、図13(a)、(b)のようなループ
処理となる。すなわち、共通の処理Xを原始プログラム
中の1個所にまとめ、0〜3の値の範囲で巡回しループ
回数を制御する巡回変数iとif〜else文(a)ま
たはswitch〜case文(b)により構成される
条件分岐命令55,56を各状態処理A,B,C,Dの
間に配置した構成となっている。このような構成によ
り、共通の処理Xを実行後、各条件分岐部においてルー
プ回数を制御する巡回変数の値を判別し、各状態処理
A,B,C,Dを順じ実行するようになる。
When generating a target program for causing the processing device to execute the processing shown in FIG. 12, a source program is first generated using a source language. There are several types of the source program for causing the processing device to execute this. Usually, a loop process as shown in FIGS. 13A and 13B is performed. That is, the common process X is collected in one place in the source program, and it is circulated in a range of values from 0 to 3 to control the number of loops and a if variable to if-else statement (a) or a switch to case statement (b). Are arranged between the state processings A, B, C and D. With this configuration, after executing the common process X, the value of the cyclic variable that controls the number of loops in each conditional branching unit is determined, and each of the state processes A, B, C, and D is sequentially executed. .

【0007】次に、図13(a)、(b)に示す原始プ
ログラムに対して、コンパイル処理の第1段階である構
文解釈処理を施し、図14(a)に示す中間テキストを
生成する。尚、構文解釈処理に関しては処理装置の仕様
に応じて幾つかの方式が存在するが、ここでは処理装置
としてMIPS R3000プロセッサを用い、それに
対応する方式(「mips RISCアーキテクチャ」
共立出版(株)版参照)を採用して構文解釈処理を行っ
た結果を示す。図からわかるように、構文解釈処理後、
原始プログラム中でループ処理部を構成するif〜el
se文、switch〜case文は共に低級言語「l
i」、「bne」で示される条件分岐命令57〜59
に、巡回変数iは巡回変数$2、$3にそれぞれ変換さ
れる。しかしながら、中間テキストの基本的な形態は原
始プログラムのそれと同じであり、やはり処理Xを共通
処理として1個所にまとめ、各状態処理の後に条件分岐
命令を設け、ループ回数を制御するための巡回変数$3
と巡回変数$3の値との比較に用いられる巡回変数$2
との値を比較しながら各状態処理A,B,C,Dに順に
移行していく構成となっている。
Next, the source program shown in FIGS. 13A and 13B is subjected to a syntax interpretation process, which is the first stage of the compile process, to generate an intermediate text shown in FIG. 14A. Note that there are several methods for the syntax interpretation processing according to the specifications of the processing device. Here, a MIPS R3000 processor is used as the processing device, and the corresponding method (“mips RISC architecture”) is used.
Here is the result of parsing using Kyoritsu Shuppan Co., Ltd.). As you can see, after the parsing process,
If-el constructing a loop processing unit in a source program
The “se” statement and the “switch to case” statement are both lower-level languages “l
i ", conditional branch instructions 57-59 indicated by" bne "
In addition, the cyclic variable i is converted into cyclic variables # 2 and # 3, respectively. However, the basic form of the intermediate text is the same as that of the source program. Processing X is also integrated in one place as common processing, a conditional branch instruction is provided after each state processing, and a cyclic variable for controlling the number of loops is provided. $ 3
Variable $ 2 used for comparison with the value of cyclic variable $ 3
Are sequentially shifted to each of the state processes A, B, C, and D while comparing the values of.

【0008】このように、従来までのコンパイル処理に
おいては、原始プログラム内で指定したループ処理の形
態が中間テキストおよび最終的に得られる目的プログラ
ムのそれにそのまま反映されるのである。
As described above, in the conventional compile processing, the form of loop processing specified in the source program is directly reflected in the intermediate text and the finally obtained target program.

【0009】次に、上記ループ処理部を有するプログラ
ムを処理装置が実行する際の処理装置の動作について説
明する。
Next, the operation of the processing apparatus when the processing apparatus executes the program having the loop processing section will be described.

【0010】上記ループ処理部を有するプログラムを処
理装置が実行する際、処理装置は、 1)始めに、ループ回数を制御する(次に行うべき状態
処理を規定する)巡回変数$3の値を0に設定した後、
共通の処理Xを実行し、 2)次に、条件分岐命令57において、比較処理に使用
する巡回変数$2の値を0に設定した後、巡回変数$
2、$3の値を比較し(この時、巡回変数$2、$3の
値はそれぞれ、0、0である)、 3)それぞれの値が等しいので、状態処理A($3=
0)を実行し、 4)巡回変数$3の値を1インクリメントした後、プロ
グラムの上部に戻り、再び共通の処理Xを実行し、 5)条件分岐命令57において、巡回変数$2の値を0
に設定した後、巡回変数$2、$3の値を比較し(この
時、巡回変数$2、$3の値はそれぞれ、0、1であ
る)、 6)それぞれの値が等しくないので、状態処理Aをジャ
ンプし、条件分岐命令58に行き(破線B)、 7)条件分岐命令58において、巡回変数$2の値を1
に設定した後、巡回変数$2、$3の値を比較し(この
時、巡回変数$2、$3の値はそれぞれ、1、1であ
る)、 8)それぞれの値が等しいので、状態処理B($3=
1)を実行し、 9)巡回変数$3の値を1インクリメントした後、プロ
グラムの上部に戻り、再び共通の処理Xを実行し、 10)条件分岐命令57において、巡回変数$2の値を
0に設定した後、巡回変数$2、$3の値を比較し(こ
の時、巡回変数$2、$3の値はそれぞれ、0、2であ
る)、 11)それぞれの値が等しくないので、状態処理Aをジ
ャンプし、条件分岐命令58に行き、 12)条件分岐命令58において、巡回変数$2の値を
1に設定した後、巡回変数$2、$3の値を比較し(こ
の時、巡回変数$2、$3の値はそれぞれ、1、2であ
る)、 13)それぞれの値が等しくないので、状態処理Bをジ
ャンプし、条件分岐命令59に行き(破線C)、 14)条件分岐命令59において、巡回変数$2の値を
2に設定した後、巡回変数$2、$3の値を比較し(こ
の時、巡回変数$2、$3の値はそれぞれ、2、2であ
る)、 15)それぞれの値が等しいので、状態処理C($3=
2)の内容を実行し、 16)巡回変数$3の値を1インクリメントした後、プ
ログラムの上部に戻り、再び共通の処理Xを実行し、 17)条件分岐命令57において、巡回変数$2の値を
0に設定した後、巡回変数$2、$3の値を比較し(こ
の時、巡回変数$2、$3の値はそれぞれ、0、3であ
る)、 18)それぞれの値が等しくないので、状態処理Aをジ
ャンプし、条件分岐命令58に行き、 19)条件分岐命令58において、巡回変数$2内の値
を1に設定した後、巡回変数$2、$3の値を比較し
(この時、巡回変数$2、$3の値はそれぞれ、1、3
である)、 20)それぞれの値が等しくないので、状態処理Bをジ
ャンプし、条件分岐命令59に行き(破線C)、 21)条件分岐命令59において、巡回変数$2の値を
2に設定した後、巡回変数$2、$3の値を比較し(こ
の時、巡回変数$2、$3の値はそれぞれ、2、3であ
る)、 22)それぞれの値が等しくないので、状態処理Cをジ
ャンプし(点線D)、処理Dの先頭に行き、処理Dを実
行する ように動作する。
When the processing device executes the program having the loop processing section, the processing device firstly controls the number of loops (defines a state process to be performed next) by changing the value of the cyclic variable # 3. After setting to 0,
2) Next, in the conditional branch instruction 57, after setting the value of the cyclic variable # 2 used for the comparison process to 0, the common variable X
2, and the values of $ 3 are compared (at this time, the values of the cyclic variables $ 2 and $ 3 are 0 and 0, respectively). 3) Since the respective values are equal, the state processing A ($ 3 =
0) is executed. 4) After incrementing the value of the cyclic variable # 3 by 1, the process returns to the top of the program and executes the common process X again. 5) In the conditional branch instruction 57, the value of the 0
, Then the values of the cyclic variables $ 2 and 比較 3 are compared (at this time, the values of the cyclic variables $ 2 and $ 3 are 0 and 1, respectively). 6) Since the values are not equal, The state process A is jumped to the conditional branch instruction 58 (broken line B). 7) In the conditional branch instruction 58, the value of the cyclic variable $ 2 is set to 1
, And the values of the cyclic variables # 2 and # 3 are compared (at this time, the values of the cyclic variables # 2 and # 3 are respectively 1 and 1). 8) Since the respective values are equal, the state Processing B ($ 3 =
9) After incrementing the value of the cyclic variable $ 3 by 1, return to the top of the program and execute the common processing X again. 10) In the conditional branch instruction 57, change the value of the After setting to 0, the values of the cyclic variables # 2 and # 3 are compared (at this time, the values of the cyclic variables # 2 and # 3 are 0 and 2, respectively). 11) Since the values are not equal, Jump to the state processing A, and go to the conditional branch instruction 58. 12) In the conditional branch instruction 58, after setting the value of the cyclic variable # 2 to 1, compare the values of the cyclic variables # 2 and # 3 (this At that time, the values of the cyclic variables # 2 and # 3 are 1 and 2, respectively). 13) Since the respective values are not equal, the state processing B is jumped to the conditional branch instruction 59 (dashed line C). ) In the conditional branch instruction 59, the value of the cyclic variable $ 2 was set to 2. , And the values of the cyclic variables # 2 and # 3 are compared (at this time, the values of the cyclic variables # 2 and # 3 are respectively 2 and 2). 15) Since the respective values are equal, the state processing C (# 3 =
16) After incrementing the value of the cyclic variable $ 3 by one, return to the top of the program and execute the common process X again. 17) In the conditional branch instruction 57, After setting the value to 0, the values of the cyclic variables # 2 and # 3 are compared (at this time, the values of the cyclic variables # 2 and # 3 are 0 and 3, respectively). 18) Each value is equal. Since there is not, jump the state processing A and go to the conditional branch instruction 58. 19) In the conditional branch instruction 58, set the value of the cyclic variable # 2 to 1 and then compare the values of the cyclic variables # 2 and $ 3 (At this time, the values of the cyclic variables # 2 and # 3 are 1, 3
20) Since the respective values are not equal, the state processing B is jumped to the conditional branch instruction 59 (broken line C). 21) In the conditional branch instruction 59, the value of the cyclic variable # 2 is set to 2 After that, the values of the cyclic variables # 2 and # 3 are compared (at this time, the values of the cyclic variables # 2 and # 3 are respectively 2 and 3). 22) Since the respective values are not equal, the state processing is performed. It jumps C (dotted line D), goes to the beginning of process D, and operates to execute process D.

【0011】つまり、このプログラムの構成において
は、共通の処理Xから各状態処理A,B,C,Dに到達
するまでに、複数の条件分岐命令をジャンプし、それぞ
れの条件分岐命令においてループ回数を制御する巡回変
数$3の値と比較変数$2の値とを逐次比較し、条件を
満たした状態処理を実行するのである。
In other words, in this program configuration, a plurality of conditional branch instructions are jumped from the common process X to each of the state processes A, B, C, and D, and the number of loops is executed in each conditional branch instruction. Is sequentially compared with the value of the cyclic variable # 3 for controlling the value of the comparison variable # 2, and a state process satisfying the condition is executed.

【0012】ここで、このような条件分岐命令を有する
プログラム全体の処理に要するジャンプの累積数を状態
処理数nを用いて数式化すると、n番目の状態処理nに
移行するまでに必要なジャンプ数(Jn)は、簡単な計
算により、Jn=(n+2)・(n−1)/2(回)と
求められる。すなわち、ループ処理を有するプログラム
を処理装置が実行する際のジャンプの累積数(Jn)は
状態処理数nの2乗に比例することになる。したがっ
て、プログラム内の状態処理数nが多ければ多いほど、
そのプログラムの実行に要するジャンプ数は飛躍的に増
加し、所定の機能を処理装置に実行させるために要する
時間は増え、さらにプログラム全体の条件分岐命令の数
に比例してプログラムサイズは大きくなるのである。
Here, when the cumulative number of jumps required for processing the entire program having such a conditional branch instruction is expressed by a mathematical expression using the number n of state processes, the jump required before shifting to the n-th state process n is obtained. The number (Jn) is obtained by a simple calculation as Jn = (n + 2) · (n−1) / 2 (times). That is, the cumulative number of jumps (Jn) when the processing device executes the program having the loop processing is proportional to the square of the number of state processing n. Therefore, the greater the number n of state processes in the program, the more
The number of jumps required to execute the program increases dramatically, the time required for the processor to execute a predetermined function increases, and the program size increases in proportion to the number of conditional branch instructions in the entire program. is there.

【0013】このように、従来までのループ処理に用い
る条件分岐命令は、2つの巡回変数値の比較を複数回行
うことにより、次の状態処理を探索・実行するので、全
体のループ処理時間は大きくなる。また、従来までのコ
ンパイル処理によりループ処理を伴う原始プログラムを
目的プログラムに変換すると、原始プログラム内の条件
分岐命令がそのまま目的プログラム内に引き継がれるの
で、プログラム処理速度の向上を図るためのコンパイル
処理にもかかわらず、ループ処理部の増加に伴い、生成
される目的プログラムの処理の高速化が難しくなり、さ
らに、条件分岐命令がそのまま引き継がれたプログラム
の容量は大きいので、処理装置に対して大きな負荷とな
ってしまうのである。
As described above, the conditional branch instruction used in the conventional loop processing searches and executes the next state processing by comparing two cyclic variable values a plurality of times, so that the entire loop processing time is reduced. growing. Also, if a source program with loop processing is converted to a target program by the conventional compilation process, the conditional branch instruction in the source program is inherited as it is in the target program. Nevertheless, with the increase in the number of loop processing units, it becomes difficult to speed up the processing of the generated target program, and the capacity of the program in which the conditional branch instruction is inherited as it is is large, so that a large load is imposed on the processing device. It will be.

【0014】本発明は、このような技術的問題に鑑みて
なされたものであり、その目的は、ループ処理を有する
原始プログラムを処理装置による実行に最適な目的プロ
グラムに変換するコンパイル装置を提供することにあ
る。
The present invention has been made in view of such technical problems, and has as its object to provide a compiling device for converting a source program having loop processing into a target program optimal for execution by a processing device. It is in.

【0015】また、本発明の他の目的は、ループ処理を
有する原始プログラムを処理装置による実行に最適な目
的プログラムに変換するコンパイル方法を提供すること
にある。
It is another object of the present invention to provide a compiling method for converting a source program having loop processing into a target program optimal for execution by a processing device.

【0016】さらに、本発明の他の目的は、ループ処理
を有する原始プログラムを処理装置による実行に最適な
目的プログラムに変換するコンパイルプログラムを格納
した記録媒体を提供することにある。
Still another object of the present invention is to provide a recording medium storing a compile program for converting a source program having loop processing into a target program optimal for execution by a processing device.

【0017】さらにまた、本発明の他の目的は、処理装
置による実行に最適な状態に変換されたループ処理を有
する目的プログラムを格納した記録媒体を提供すること
にある。
Still another object of the present invention is to provide a recording medium storing a target program having a loop process converted into a state optimal for execution by a processing device.

【0018】[0018]

【課題を解決するための手段】上記の問題を解決するた
めに、発明者は、原始プログラムを目的プログラムに変
換するためのコンパイル処理において、原始プログラム
又は中間テキスト中におけるループ処理部を抽出し、抽
出されたループ処理部内の条件分岐命令を、共通の処理
から次の状態処理の先頭アドレスに直接ジャンプし、ジ
ャンプ先の命令を行う処理を処理装置に実行させるジャ
ンプ手段に変換することにより、ループ処理に要する時
間を短縮し、さらには、目的プログラム全体の容量を小
さくすることが可能であるという考えに至った。
Means for Solving the Problems To solve the above problem, the inventor extracts a loop processing section in a source program or an intermediate text in a compiling process for converting a source program into a target program, By converting the extracted conditional branch instruction in the loop processing unit directly from the common processing to the start address of the next state processing, and converting it to jump means for causing the processing unit to execute the processing of performing the instruction at the jump destination, We have come to the idea that it is possible to shorten the time required for processing and further reduce the capacity of the entire target program.

【0019】このような考えから、本発明の第1の特徴
は、処理装置に所定の処理を実行させるための原始言語
で記述した原始プログラムを当該処理装置が処理容易な
目的プログラムに変換するコンパイル装置において、少
なくとも1つの共通処理と複数の状態処理およびこれら
の処理間に設けられた条件分岐命令から成るループ処理
部を抽出し、ループ処理の最適化を行う最適化手段を備
え、最適化手段は、原始プログラム又は原始言語を低級
言語に変換した中間テキスト内のループ処理部を抽出す
るループ処理抽出手段と、条件分岐命令内のループ回数
を制御する変数の記録領域を解析し、後記先頭アドレス
値を記録するアドレス記録領域を選定する記録領域解析
手段と、状態処理の各々について先頭アドレス値を計算
し、1つの状態処理終了後、次に実行する状態処理の先
頭アドレス値をアドレス記録領域内に書き込む先頭アド
レス設定手段と、条件分岐命令を、アドレス記録領域内
の先頭アドレス値を参照することにより次に実行する状
態処理の先頭アドレスにジャンプし、ジャンプ先の状態
処理を行う処理を処理装置に実行させるジャンプ命令に
変換するジャンプ命令変換手段を有するコンパイル装置
であることにある。
Based on the above idea, a first feature of the present invention is that a compiling program for converting a source program described in a source language for causing a processing device to execute a predetermined process into a target program which can be easily processed by the processing device. An optimizing means for extracting a loop processing unit comprising at least one common process and a plurality of state processes and a conditional branch instruction provided between these processes, and optimizing the loop process; Is a loop processing extraction means for extracting a loop processing unit in an intermediate text obtained by converting a source program or a source language into a lower-level language, and a recording area of a variable for controlling the number of loops in a conditional branch instruction is analyzed. A recording area analyzing means for selecting an address recording area for recording a value; After the end, the head address setting means for writing the head address value of the state processing to be executed next in the address recording area, and the state processing for executing the conditional branch instruction next by referring to the head address value in the address recording area Is a compiling device having a jump instruction conversion means for converting a process for performing a state process of a jump destination to a jump instruction for causing a processing device to execute the process for performing a state process of a jump destination.

【0020】これにより、共通の処理から各状態処理へ
のジャンプは状態処理の数に依存せず常に1回で済むの
で、ループ処理を有する目的プログラムの処理に要する
時間を短縮し、さらに、目的プログラムの容量を削減す
ることができる。
Thus, since the jump from the common processing to each state processing is always performed once irrespective of the number of state processing, the time required for processing the target program having the loop processing can be shortened. The capacity of the program can be reduced.

【0021】また、本発明の第2の特徴は、処理装置に
所定の処理を実行させるための原始言語で記述した原始
プログラムを当該処理装置が処理容易な目的プログラム
に変換するコンパイル方法において、少なくとも1つの
共通処理と複数の状態処理およびこれらの処理間に設け
られた条件分岐命令から成るループ処理部を抽出し、ル
ープ処理の最適化を行う最適化ステップを備え、最適化
ステップは、原始プログラム又は原始言語を低級言語に
変換した中間テキスト内のループ処理部を抽出するルー
プ処理抽出ステップと、条件分岐命令内のループ回数を
制御する変数の記録領域を解析し、後記先頭アドレス値
を記録する記録領域を選定するアドレス記録領域解析ス
テップと、状態処理の各々について先頭アドレス値を計
算し、1つの状態処理終了後、次に実行する状態処理の
先頭アドレス値を前記アドレス記録領域内に書き込む先
頭アドレス設定ステップと、条件分岐命令を、アドレス
記録領域内の先頭アドレス値を参照することにより次に
実行する状態処理の先頭アドレスにジャンプし、ジャン
プ先の状態処理を行う処理を処理装置に実行させるジャ
ンプ命令に変換するジャンプ命令変換ステップとを有す
るコンパイル方法であることにある。
A second feature of the present invention resides in a compiling method for converting a source program described in a source language for causing a processing device to execute a predetermined process into a target program which can be easily processed by the processing device. There is provided an optimization step of extracting a loop processing unit including one common process and a plurality of state processes and a conditional branch instruction provided between these processes, and optimizing the loop process. Alternatively, a loop processing extracting step of extracting a loop processing unit in an intermediate text obtained by converting a source language into a lower-level language, and analyzing a recording area of a variable for controlling the number of loops in a conditional branch instruction, and recording a start address value to be described later An address recording area analysis step of selecting a recording area and a start address value are calculated for each of the state processing, and one state is calculated. After the completion of the processing, the start address setting step of writing the start address value of the next state processing to be executed in the address recording area, and the conditional branch instruction are executed next by referring to the start address value in the address recording area. The present invention is a compile method including a jump instruction conversion step of jumping to a start address of a state process and converting a process of performing a state process of a jump destination into a jump instruction to be executed by a processing device.

【0022】これにより、共通の処理から各状態処理へ
のジャンプは状態処理の数に依存せず常に1回で済むの
で、ループ処理を有する目的プログラムの処理に要する
時間を短縮し、さらに、目的プログラムの容量を削減す
ることができる。
With this, the jump from the common process to each state process can be performed only once irrespective of the number of state processes, so that the time required for processing the target program having the loop process can be reduced, and The capacity of the program can be reduced.

【0023】さらに、本発明の第3の特徴は、処理装置
に所定の処理を実行させるための原始言語で記述した原
始プログラムを当該処理装置が処理容易な目的プログラ
ムに変換するコンパイルプログラムを格納したコンピュ
ータ読み取り可能な記録媒体において、少なくとも1つ
の共通処理と複数の状態処理およびこれらの処理間に設
けられた条件分岐命令から成るループ処理部を抽出し、
ループ処理の最適化を行う最適化処理を含み、最適化処
理は、原始プログラム又は原始言語を低級言語に変換し
た中間テキスト内のループ処理部を抽出するループ処理
抽出処理と、条件分岐命令内のループ回数を制御する変
数の記録領域を解析し、後記先頭アドレス値を記録する
アドレス記録領域を選定する記録領域解析処理と、状態
処理の各々について先頭アドレス値を計算し、1つの状
態処理終了後、次に実行する状態処理の先頭アドレス値
をアドレス記録領域内に書き込む先頭アドレス設定処理
と、条件分岐命令を、アドレス記録領域内の先頭アドレ
ス値を参照することにより次に実行する状態処理の先頭
アドレスにジャンプし、ジャンプ先の状態処理を行う処
理を処理装置に実行させるジャンプ命令に変換するジャ
ンプ命令変換処理とを含み、これらの処理をコンピュー
タに実行させるコンパイルプログラムを格納したコンピ
ュータ読み取り可能な記録媒体であることにある。
A third feature of the present invention resides in storing a compile program for converting a source program described in a source language for causing a processing device to execute a predetermined process into a target program which can be easily processed by the processing device. Extracting, on a computer-readable recording medium, a loop processing unit including at least one common process and a plurality of state processes and a conditional branch instruction provided between these processes;
The optimization processing includes optimization processing for optimizing loop processing. The optimization processing includes a loop processing extraction processing for extracting a loop processing unit in an intermediate text obtained by converting a source program or a source language into a lower-level language, and an optimization processing in a conditional branch instruction. Analyzing the recording area of the variable for controlling the number of loops, and calculating the head address value for each of the state processing and the recording area analysis processing for selecting the address recording area for recording the head address value to be described later. The start address setting processing for writing the start address value of the next state processing to be executed in the address recording area, and the start of the state processing for executing the conditional branch instruction by referring to the start address value in the address storage area Jump instruction conversion processing that jumps to an address and converts the processing that performs the state processing of the jump destination into a jump instruction that causes the processing unit to execute Hints, is that these processes a computer-readable recording medium storing a compiled program for causing a computer to execute.

【0024】これにより、共通の処理から各状態処理へ
のジャンプは状態処理の数に依存せず常に1回で済むの
で、ループ処理を有する目的プログラムの処理に要する
時間を短縮し、さらに、目的プログラムの容量を削減す
ることができる。
Thus, the jump from the common processing to each state processing can be performed only once irrespective of the number of state processing. Therefore, the time required for processing the target program having the loop processing can be shortened. The capacity of the program can be reduced.

【0025】さらにまた、本発明の第4の特徴は、前記
コンパイル方法により作成された目的プログラムを備え
ることを特徴とする目的プログラムを格納したコンピュ
ータ読み取り可能な記録媒体であることにある。
Further, a fourth feature of the present invention resides in a computer-readable recording medium storing a target program, characterized by including the target program created by the compiling method.

【0026】これにより、最適化されたループ処理を有
する目的プログラムを提供することができる。
Thus, it is possible to provide a target program having optimized loop processing.

【0027】ここで、「記録媒体」とは、例えば、半導
体メモリ、磁気ディスク、光ディスク、光磁気ディス
ク、磁気テープ、デジタルビデオディスク等、プログラ
ムを記録することができるコンピュータ読み取り可能な
媒体を意味する。
Here, the "recording medium" means a computer-readable medium on which a program can be recorded, such as a semiconductor memory, a magnetic disk, an optical disk, a magneto-optical disk, a magnetic tape, and a digital video disk. .

【0028】また、「アドレス記録領域」とは、レジス
タメモリ、スタックメモリ等の読み書き可能な記録媒体
を意味する。
The "address recording area" means a readable and writable recording medium such as a register memory and a stack memory.

【0029】さらに、ループ処理抽出は、中間テキスト
中で「bne $a,$b,Label1,...j Label2」と表記された部
分が複数存在する箇所を見つけるようにすると良い。
Further, in the loop process extraction, it is preferable to find a portion where a plurality of portions described as "bne $ a, $ b, Label1,... J Label2" exist in the intermediate text.

【0030】さらに又、ループ回数を制御するための巡
回変数の記録領域に対して記録領域解析ステップを実行
するようにする。
Further, a recording area analyzing step is executed for a recording area of a cyclic variable for controlling the number of loops.

【0031】[0031]

【発明の実施の形態】以下、本発明の実施形態を図1乃
至図11を用いて説明する。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS An embodiment of the present invention will be described below with reference to FIGS.

【0032】始めに、本発明の実施形態に係わるコンパ
イル装置の構成を図1により解説する。
First, the configuration of the compiling device according to the embodiment of the present invention will be described with reference to FIG.

【0033】本発明の実施形態に係わるコンパイル装置
100は、原始言語で記述された原始プログラムを入力
する原始プログラム入力部110、原始プログラムを目
的プログラムに変換するコンパイル処理部120、生成
された目的プログラムの他の目的プログラムとリンクさ
せるためのリンク付け処理部130リンク付け処理によ
り生成される実行プログラムを出力する実行プログラム
出力部131から構成され、コンパイル処理部120
は、構文解釈部121、中間テキスト生成部122、最
適化処理部123、コード変換部128、目的プログラ
ム出力部129を有し、さらに、最適化処理部123
は、少なくとも1つの共通処理と複数の状態処理および
これらの処理間に設けられた条件分岐命令により構成さ
れるループ処理を指定するプログラム部を抽出するルー
プ処理抽出部124、条件分岐命令内のループ回数を制
御する変数を記録する記録領域を解析し、後記先頭アド
レス値を記録するためのアドレス記録領域を選定する記
録領域解析部125、各状態処理の先頭アドレス値を計
算し、1つの状態処理終了後、次の状態処理の先頭アド
レス値をアドレス記録領域に書き込む先頭アドレス設定
部126、条件分岐命令を、アドレス記録領域を参照し
て各状態処理の先頭アドレス値にジャンプし、ジャンプ
先の命令を実行する処理を処理装置に実行させるジャン
プ命令に変換するためのジャンプ命令変換部127を備
えている。また、コンパイル装置100は、プログラム
言語や各処理部への命令を入力するための入力装置20
0、生成された目的プログラムやエラー表示等の情報を
出力するための出力装置300を備える。さらに、コン
パイル装置100は、ジャンプ命令変換部126やリン
ク付け処理部130が他の目的プログラムのアドレス値
等の情報を参照できるように、他の目的プログラムを格
納した記録装置400と接続されている。尚、ここでい
う「記録領域」とは、レジスタメモリ、スタックメモリ
等の読み書き可能な記録媒体を指す。
A compiling apparatus 100 according to an embodiment of the present invention includes a source program input unit 110 for inputting a source program described in a source language, a compile processing unit 120 for converting a source program into a target program, and a generated target program. A linking processing unit 130 for linking with another target program, and an execution program output unit 131 that outputs an execution program generated by the linking process.
Has a syntax interpreter 121, an intermediate text generator 122, an optimization processor 123, a code converter 128, and a target program output unit 129.
A loop processing extraction unit 124 for extracting a program part that specifies a loop processing composed of at least one common processing and a plurality of state processings and a conditional branch instruction provided between these processings; A recording area analyzing unit 125 analyzes a recording area for recording a variable for controlling the number of times, selects an address recording area for recording a later-described first address value, calculates a first address value of each state process, and performs one state process. After completion, the start address setting unit 126 that writes the start address value of the next state process to the address recording area, jumps the conditional branch instruction to the start address value of each state process with reference to the address record area, and executes the jump destination instruction And a jump instruction conversion unit 127 for converting the processing for executing the processing into a jump instruction to be executed by the processing device. Further, the compiling device 100 includes an input device 20 for inputting a program language and an instruction to each processing unit.
0, an output device 300 for outputting information such as the generated target program and error display. Further, the compiling device 100 is connected to a recording device 400 storing another target program so that the jump instruction conversion unit 126 and the linking processing unit 130 can refer to information such as the address value of another target program. . Here, the “recording area” refers to a readable and writable recording medium such as a register memory and a stack memory.

【0034】次に、本発明の実施形態に係わるコンパイ
ル方法を図2乃至図4を用いて説明する。
Next, a compiling method according to the embodiment of the present invention will be described with reference to FIGS.

【0035】本発明の実施形態に係わるコンパイル方法
により目的プログラムを作成する際は、図2に示すよう
に、原始言語により原始プログラム作成し(ステップS
100)、原始プログラムを目的プログラムに変換し
(ステップS200)、必要に応じて、目的プログラム
を既存の目的プログラムとリンク付けする(ステップS
300)ことより行われる。これらの一連の目的プログ
ラム作成プロセス中で、ループ処理部を有するプログラ
ムの最適化処理はステップS200におけるコンパイル
処理において行う。そこで、以下では図3に示すフロー
チャート図を用いて、このコンパイル処理に焦点を絞っ
て本発明の実施形態に係わるコンパイル方法の詳細につ
いて説明する。
When a target program is created by the compiling method according to the embodiment of the present invention, as shown in FIG. 2, a source program is created in a source language (step S).
100), convert the source program into a target program (step S200), and link the target program with an existing target program as necessary (step S200).
300). During the series of the target program creating process, the optimization process of the program having the loop processing unit is performed in the compiling process in step S200. The details of the compiling method according to the embodiment of the present invention will be described below with reference to the flowchart shown in FIG.

【0036】本発明の実施形態に係わるコンパイル方法
は、 1)(構文解釈、ステップS201)始めに、原始言語
で記述された原始プログラムを低級言語に変換し、 2)(第1中間テキスト生成、ステップS202)低級
言語に変換された原始プログラムを第1中間テキストと
して保存し、 3)(ループ処理抽出、ステップS203)第1中間テ
キスト内を検索し、第1中間テキスト内に少なくとも1
つの共通処理と複数の状態処理およびこれらの処理間に
設けられた条件分岐命令により構成されるループ処理を
指定するプログラム部分が存在するか否かを判別し、 ループ処理が存在する場合は → (ステップS20
5)へ ループ処理が存在しない場合は → (ステップS20
8)へ 4)(記録領域解析、ステップS205)条件分岐命令
内のループ回数を制御する巡回変数が記録される記録領
域が他の用途で使用されているか否かを判別し、 他の用途で使用されている場合は → (ステップS
207)へ 他の用途で使用されていない場合は → (ステップS
208)へ 5)(記録領域確保、ステップS207)他の用途で使
用されていない巡回変数の値を記録可能な記録領域を確
保し、 6)(先頭アドレス計算、ステップS208)ループ処
理を構成する複数の状態処理の各々について先頭アドレ
ス値を計算し、 7)(先頭アドレス書込み、ステップS209)計算さ
れた先頭アドレスの値を記録領域内に書き込み、 8)(ジャンプ命令変換、ステップS210)条件分岐
命令を、記録領域内のアドレス値を参照して記録領域内
に保存されたアドレス値にジャンプし、ジャンプ先の状
態処理を行う処理を処理装置に実行させるジャンプ命令
に変換し、 9)(第2中間テキスト生成、ステップS211)ステ
ップS203〜S210の処理を行った後の第1中間テ
キストを第2中間テキストとして保存し、 10)(コード変換、ステップS212)第2中間テキ
スト内に記述された文字列を処理装置に適した命令コー
ドに置換し、他の目的プログラムとのリンクを行うため
の制御コードを付加することにより行われる。
The compiling method according to the embodiment of the present invention is as follows: 1) (Syntax interpretation, step S201) First, a source program described in a source language is converted into a lower-level language, and 2) (first intermediate text generation, Step S202) Save the source program converted into the lower language as a first intermediate text. 3) (Loop process extraction, step S203) Search in the first intermediate text, and at least one
It is determined whether there is a program part that specifies a loop processing composed of one common processing, a plurality of state processings, and a conditional branch instruction provided between these processings. If a loop processing exists, → ( Step S20
Go to 5) If there is no loop processing → (Step S20)
Go to 8) 4) (Recording area analysis, step S205) It is determined whether or not the recording area where the cyclic variable for controlling the number of loops in the conditional branch instruction is recorded is used for another purpose. If used, → (Step S
Go to 207) If not used for other purposes → (Step S
To 208) 5) (securing a recording area, step S207) securing a recording area capable of recording a value of a cyclic variable that is not used for another purpose, and 6) configuring (start address calculation, step S208) loop processing 7) (Start address write, step S209) Write the calculated start address value in the recording area, 8) (jump instruction conversion, step S210) conditional branch The instruction is jumped to the address value stored in the recording area with reference to the address value in the recording area, and is converted into a jump instruction for causing the processing device to execute a process of performing a state process of a jump destination. (2) Intermediate text generation, step S211) The first intermediate text after performing the processing of steps S203 to S210 is defined as a second intermediate text. 10) (code conversion, step S212) Replace the character string described in the second intermediate text with an instruction code suitable for the processing device and add a control code for linking with another target program It is done by doing.

【0037】ここで、本発明の実施形態に係わるコンパ
イル方法においては、「ループ処理部の抽出」や「記録
領域解析」の処理は、第1中間テキストに対して実行し
ているが、原始プログラム内の記述と第1中間テキスト
内のそれとを比較することにより行っても良い。例え
ば、原始プログラム中における条件分岐命令for文、
while文、do文等は見つけることが比較的容易で
あるので、例えば、原始プログラム中でループ処理の有
無および位置の見当をつけ、第1中間テキスト内におけ
るループ処理部を抽出する、または原始プログラムに対
して上記の最適化処理を直接行うようにすれば、最適化
処理に要する時間を短縮することができる。
Here, in the compiling method according to the embodiment of the present invention, the processing of "extraction of loop processing unit" and "analysis of recording area" is performed on the first intermediate text. May be compared with the description in the first intermediate text. For example, a conditional branch instruction for statement in a source program,
Since a while sentence, a do sentence, etc. are relatively easy to find, for example, the presence / absence and position of loop processing in the source program is determined, and a loop processing unit in the first intermediate text is extracted, or the source program is extracted. In contrast, if the above-described optimization processing is performed directly, the time required for the optimization processing can be reduced.

【0038】また、第1中間テキスト内の「ループ処理
抽出方法」としては、中間テキスト中で「bne $a,$b,La
bel1,...j Label2」と表記された部分が複数存在する箇
所を見つけるようにする。そして、条件分岐命令内にお
いて使用される2つの巡回変数$a、$bの値の変化の
様子を調べることにより、どちらの巡回変数がループ回
数を制御するためのものであるか判断する。通常、条件
分岐命令内のli命令で指定された巡回変数は比較処理
に用いるものであるので、ループ回数を制御するための
巡回変数はli命令で指定されていないものであるとす
ることができる。その後、この巡回変数の記録領域に対
して記録領域解析ステップを実行するようにする。
As the "loop processing extraction method" in the first intermediate text, "bne $ a, $ b, La
bel1, ... j Label2 "should be found. Then, by examining how the values of the two cyclic variables #a and #b used in the conditional branch instruction change, it is determined which cyclic variable is for controlling the number of loops. Normally, the cyclic variable specified by the li instruction in the conditional branch instruction is used for comparison processing, so that the cyclic variable for controlling the number of loops can be assumed to be not specified by the li instruction. . Thereafter, a recording area analysis step is performed on the recording area of the cyclic variable.

【0039】さらに、ジャンプ命令変換ステップで用い
る「ジャンプ命令」とは、ジャンプ命令で指定された記
録領域内に保存されているアドレス値へジャンプし、引
き続きジャンプ先の命令を実行することを処理装置に促
す命令である。例えば、MIPS R3000プロセッ
サでは「j」や「jr」があり、「jr $3」と設定すると、
記録領域$3内に格納されているアドレス値にジャンプ
し、引き続きジャンプ先の命令を実行するようになる
($3は複数存在する記録領域の中の一つを指定する
(アドレス)値である)。尚、アドレス値を指定する
際、最適化するプログラムが図4に示すように他の目的
プログラムの一部であるような場合は、記録領域内に格
納するアドレス値は、他のプログラムのアドレス値を参
照した上で、相対的にではなく、絶対的に決めたものの
方が良い。
Further, the "jump instruction" used in the jump instruction conversion step is a processing device which jumps to an address value stored in a recording area designated by the jump instruction and subsequently executes the instruction at the jump destination. It is an instruction to urge. For example, in the MIPS R3000 processor, there are "j" and "jr", and if "jr $ 3" is set,
Jumps to the address value stored in the recording area # 3, and subsequently executes the instruction at the jump destination (# 3 is an (address) value designating one of a plurality of existing recording areas). ). When the address value is specified, if the program to be optimized is a part of another target program as shown in FIG. 4, the address value stored in the recording area is the address value of the other program. It is better to make an absolute decision rather than a relative decision.

【0040】このようなコンパイル方法により、共通の
処理から各状態処理へのジャンプは状態処理の数に依存
せず常に1回で済むので、状態処理の数が増えたとして
も、目的プログラムを実行する際の累積ジャンプ数(J
n)の急激な増加を抑制することができる。実際、本発
明に係わるコンパイル方法により得られる目的プログラ
ム内の累積ジャンプ数(Jn)を数式化すると、目的プ
ログラム内の状態処理数がnの時、共通処理から各状態
処理へのジャンプ数は全ての状態処理について1回であ
るから合計n回。各状態処理から共通処理へ戻るジャン
プ数は最後のn番目の状態処理を除き各々1回であるか
ら合計n−1回。よって、累積ジャンプ数(Jn)はこ
の2つの数値を合計することで求められ、2n−1回と
なり、従来までの累積ジャンプ数(Jn)と比較する
と、図5に示すように、大幅にその回数が減り、さら
に、プログラムの容量も2つの巡回変数を比較する条件
分岐命令を削除することができることから、従来のもの
より小さくすることができる。
According to such a compiling method, the jump from the common processing to each state processing can be performed only once irrespective of the number of state processing. Therefore, even if the number of state processing increases, the target program is executed. Number of jumps (J
The rapid increase of n) can be suppressed. Actually, when the cumulative jump number (Jn) in the target program obtained by the compiling method according to the present invention is expressed by a mathematical formula, when the number of state processes in the target program is n, the number of jumps from the common process to each state process is all Since the state processing is performed once, the total is n times. The number of jumps returning from each state process to the common process is one except for the last n-th state process, so that the total is n-1 times. Therefore, the cumulative jump number (Jn) is obtained by summing these two numerical values, which is 2n-1 times. When compared with the conventional cumulative jump number (Jn), as shown in FIG. Since the number of times can be reduced and the capacity of the program can be eliminated because the conditional branch instruction for comparing two cyclic variables can be deleted, it can be made smaller than the conventional one.

【0041】次に、本発明の実施形態に係わるコンパイ
ル方法の理解を深めるために、本発明の実施形態に係わ
るコンパイル方法を用いて作成された第2中間テキスト
の2、3の実験例を示す。尚、以下の実験例において
は、「記録領域」として、処理装置が備えるレジスタ$
3を用いている(注:$3は複数のレジスタメモリのそ
れぞれに割り当てられたアドレス値を示す)。
Next, in order to better understand the compiling method according to the embodiment of the present invention, a few experimental examples of the second intermediate text created using the compiling method according to the embodiment of the present invention will be described. . In the following experimental example, the “recording area” is a register provided in the processing device.
3 (Note: $ 3 indicates an address value assigned to each of the plurality of register memories).

【0042】図6は、実験例1として、図14(a)に
示す中間テキスト(第1中間テキスト)に対して本発明
の実施形態に係わるコンパイル方法を施し作成した第2
中間テキストを示す図である。
FIG. 6 shows, as Experimental Example 1, a second intermediate text (first intermediate text) shown in FIG. 14A created by applying the compiling method according to the embodiment of the present invention.
It is a figure showing an intermediate text.

【0043】本発明の実施形態に係わるコンパイル方法
は、 1)始めに、中間テキスト(第1中間テキスト)内を検
索し、ループ処理を規定するループ処理部が存在するか
否か判別する。この場合、中間テキスト(図14a))
は条件分岐命令57,58,59を有するので、ループ
処理部の最適化処理が実行される。
The compiling method according to the embodiment of the present invention is as follows: 1) First, the intermediate text (first intermediate text) is searched to determine whether or not there is a loop processing unit for defining the loop processing. In this case, the intermediate text (FIG. 14a)
Has conditional branch instructions 57, 58, 59, so that the optimization processing of the loop processing unit is executed.

【0044】2)次に、ループ回数を制御する巡回変数
の値を保存するレジスタ$3がループ処理に係わる以外
の用途で使用されているか否かを判別する。この中間テ
キストの場合、レジスタ$3はループ回数の制御のため
だけに使用されているものとして(使用されていない場
合については後述)、次の処理に移行する。
2) Next, it is determined whether or not the register # 3 for storing the value of the cyclic variable for controlling the number of loops is used for a purpose other than the one related to the loop processing. In the case of this intermediate text, it is assumed that the register # 3 is used only for controlling the number of loops (the case where it is not used will be described later), and the processing proceeds to the next processing.

【0045】3)続いて、中間テキストの先頭に、レジ
スタ$3に1番目の状態処理の先頭アドレスを書き込む
処理を処理装置に実行させる命令「li $3,(1番目の状
態処理の先頭アドレス)」500を配置する。この実験
例の場合、1番目に実行される状態処理Aの先頭アドレ
ス(0x100)をレジスタ$3内に書き込む。
3) Subsequently, at the beginning of the intermediate text, an instruction "li $ 3, (start address of the first state process) which causes the processing device to execute a process of writing the start address of the first state process in the register # 3 "500. In the case of this experimental example, the start address (0x100) of the state processing A to be executed first is written into the register # 3.

【0046】4)次に、共通処理Xの末尾に、レジスタ
$3で指定されるアドレス値にジャンプすることを促す
命令「jr $3」501を配置する。
4) Next, at the end of the common process X, an instruction "jr $ 3" 501 for prompting a jump to the address value specified by the register # 3 is arranged.

【0047】5)次に、各々の状態処理の末尾に、状態
処理実行後、レジスタ$3内のアドレス値を次の状態処
理の先頭アドレス値に設定する先頭アドレス計算命令5
03,504,505を配置する。この実験例において
は、状態処理Aが6ステップ(ここでステップとは命令
文の数を示す単位を意味し、1ステップは4バイトの大
きさを有する)(6ステップ×4バイト=24バイト)
有するので、次の状態処理Bの先頭アドレス値は状態処
理Aの先頭アドレスに状態処理Aの6ステップと命令5
02、503の2ステップ(8バイト)を足した8ステ
ップ(32バイト)となるので、状態処理Aの先頭アド
レス値に32バイトを加算し次の状態処理Bの先頭アド
レス値をもとめ、その値をレジスタ$3内の値とする先
頭アドレス設定命令「addi $3,$3,32」を状態処理Aの
後に配置する。同様に、状態処理B(30ステップ(1
20バイト))については、状態処理Bの後に状態処理
Bの先頭アドレス値に128バイトを加算しレジスタ$
3の値とする命令「addi $3,$3,128」504、状態処理
C(14ステップ(56バイト))については、状態処
理Cの後に状態処理Cの先頭アドレス値に64バイトを
加算しレジスタ$3の値とする命令「addi $3,$3,64」
505を配置する。尚、一般的にアドレスはバイト単位
で記述されているので、先頭アドレス計算ステップはバ
イト単位で行うものとする。
5) Next, at the end of each state process, after executing the state process, a start address calculation instruction 5 for setting the address value in register # 3 to the start address value of the next state process
03, 504 and 505 are arranged. In this experimental example, the state process A has six steps (here, step means a unit indicating the number of command statements, and one step has a size of 4 bytes) (6 steps × 4 bytes = 24 bytes)
Therefore, the start address value of the next state process B is 6 steps of the state process A and the instruction 5
Since there are 8 steps (32 bytes) obtained by adding 2 steps (8 bytes) of 02 and 503, 32 bytes are added to the start address value of the state processing A, and the start address value of the next state processing B is obtained. Is set after the state processing A, the start address setting instruction "addi $ 3, $ 3, 32", which sets the value in the register # 3. Similarly, state processing B (30 steps (1
20)), after the state processing B, 128 bytes are added to the start address value of the state processing B, and the register {
For the instruction “addi $ 3, $ 3,128” 504 having a value of 3 and the state processing C (14 steps (56 bytes)), 64 bytes are added to the start address value of the state processing C after the state processing C, and Instruction "addi $ 3, $ 3,64" as value
505 is arranged. Since the address is generally described in byte units, the start address calculation step is performed in byte units.

【0048】6)次に、各先頭アドレス設定命令50
3,504,505の直後に、先頭アドレス設定処理実
行後、共通処理Xの先頭アドレスにジャンプする処理を
処理装置に実行させる命令「j TOP」502を配置す
る。これにより、処理装置がこの命令を解釈すると、共
通処理Xの先頭アドレスにジャンプし、共通処理Xが実
行されることになる。
6) Next, each head address setting instruction 50
Immediately after 3, 504, and 505, after executing the start address setting processing, an instruction “j TOP” 502 that causes the processing device to execute processing for jumping to the start address of the common processing X is arranged. As a result, when the processing device interprets this instruction, it jumps to the start address of the common process X, and the common process X is executed.

【0049】上記の一連のステップにより、ループ処理
を備える第1中間テキストの最適化を行うことができ
る。ここで、コンパイル前のプログラム内に同様の独立
したループ処理部が複数存在する場合は、1回目の最適
化処理終了後得られる第2中間テキストを新たな第1の
中間テキストとして、未処理のループ処理部に対して最
適化処理を実行するようにすると良い。また、この実験
例においては、次の状態処理の先頭アドレス値は加算処
理により計算していたが、状態処理の先頭アドレス値を
もとめられる限りはどのような方法であっても良い。
By the above series of steps, the first intermediate text having the loop processing can be optimized. Here, if there are a plurality of similar independent loop processing units in the program before compilation, the second intermediate text obtained after the end of the first optimization process is set as a new first intermediate text and the unprocessed It is preferable to execute the optimization processing on the loop processing unit. Further, in this experimental example, the start address value of the next state processing is calculated by the addition processing, but any method may be used as long as the start address value of the state processing can be obtained.

【0050】次に、本発明の実施形態に係わるコンパイ
ル方法によって累積ジャンプ数を大幅に削減できること
を明らかにするために、この実験1により得られたプロ
グラムを処理装置が実行する際の処理装置の動作につい
て説明する。尚、ここでは、状態処理A,B,Cが有す
るバイト数をそれぞれ、24,120,56(バイト)
とした。
Next, in order to clarify that the number of accumulated jumps can be significantly reduced by the compiling method according to the embodiment of the present invention, the processing unit executes the program obtained in Experiment 1 when executing the program. The operation will be described. Here, the number of bytes of the state processes A, B, and C is 24, 120, and 56 (bytes), respectively.
And

【0051】図6に示す形態のプログラムを処理装置が
実行する際は、 1)始めに、命令500において、レジスタ$3内に最
初の状態処理Aの先頭アドレス値(0x100)を書き
込む。
When the processing device executes the program of the form shown in FIG. 6, 1) First, the first address value (0x100) of the first state process A is written into register # 3 in instruction 500.

【0052】2)続いて、1回目の共通の処理Xを実行
する。
2) Subsequently, the first common process X is executed.

【0053】3)次に、ジャンプ命令501において、
レジスタ$3で指定される状態処理Aの先頭アドレス値
(0x100)にジャンプする(実線A)。
3) Next, in the jump instruction 501,
Jump to the start address value (0x100) of state processing A specified by register # 3 (solid line A).

【0054】4)次に、状態処理Aを実行する。4) Next, state processing A is executed.

【0055】5)次に、先頭アドレス設定命令503に
おいて、レジスタ$3内のアドレス値に状態処理Aのバ
イト数24と命令502、503のバイト数8(2ステ
ップ×4バイト)を加算し、レジスタ$3内の値を次の
状態処理Bの先頭アドレス値(0x120)に設定す
る。
5) Next, in the start address setting instruction 503, the number of bytes 24 of the state processing A and the number of bytes 8 of the instructions 502 and 503 (2 steps × 4 bytes) are added to the address value in the register # 3. The value in register # 3 is set to the start address value (0x120) of the next state processing B.

【0056】6)次に、ジャンプ命令502により、共
通の処理Xの先頭アドレス値にジャンプする。
6) Next, a jump instruction 502 is used to jump to the start address value of the common process X.

【0057】7)続いて、2回目の共通の処理Xを実行
する。
7) Subsequently, the second common process X is executed.

【0058】8)次に、ジャンプ命令501において、
レジスタ$3内で指定される状態処理Bの先頭アドレス
値(0x120)にジャンプする(破線B)。
8) Next, in the jump instruction 501,
Jump to the start address value (0x120) of state processing B specified in register # 3 (broken line B).

【0059】9)続いて、状態処理Bを実行する。9) Subsequently, state processing B is executed.

【0060】10)次に、先頭アドレス設定命令504
において、レジスタ$3内のアドレス値に状態処理Bの
ビット数120と命令502、503のビット数8を加
算し、レジスタ$3内の値を次の状態処理Cの先頭アド
レス値(0x1A0)に設定する。
10) Next, a start address setting instruction 504
, The number of bits 120 of the state process B and the number of bits 8 of the instructions 502 and 503 are added to the address value in the register # 3, and the value in the register # 3 is set as the start address value (0x1A0) of the next state process C. Set.

【0061】11)続いて、ジャンプ命令502によ
り、共通の処理Xの先頭アドレス値にジャンプする。
11) Subsequently, a jump instruction 502 is used to jump to the start address value of the common process X.

【0062】12)続いて、3回目の共通の処理Xを実
行する。
12) Subsequently, the third common process X is executed.

【0063】13)次に、ジャンプ命令501におい
て、レジスタ$3内で指定される状態処理Cの先頭アド
レス値(0x1A0)にジャンプする(破線C)。
13) Next, in the jump instruction 501, jump to the start address value (0x1A0) of the state process C specified in the register # 3 (broken line C).

【0064】14)次に、状態処理Cを実行する。14) Next, state processing C is executed.

【0065】15)次に、先頭アドレス設定命令505
において、レジスタ$3内のアドレス値に状態処理Cの
ビット数56と命令503,502のビット数8を加算
し、レジスタ$3内の値を次の状態処理Dの先頭アドレ
ス値(0x1E0)に設定する。
15) Next, a start address setting instruction 505
In the above, the number of bits 56 of the state process C and the number of bits 8 of the instructions 503 and 502 are added to the address value in the register # 3, and the value in the register # 3 is changed to the start address value (0x1E0) of the next state process D. Set.

【0066】16)続いて、ジャンプ命令502によ
り、共通の処理Xの先頭アドレス値にジャンプする。
16) Subsequently, a jump instruction 502 is used to jump to the start address value of the common process X.

【0067】17)次に、4回目の共通の処理Xを実行
する。
17) Next, the fourth common process X is executed.

【0068】18)次に、ジャンプ命令501におい
て、レジスタ$3内で指定される状態処理Dの先頭アド
レス値(0x1E0)にジャンプする(破線D)。
18) Next, in the jump instruction 501, jump to the start address value (0x1E0) of the state processing D specified in the register # 3 (broken line D).

【0069】19)状態処理Dを実行する(ループ処理
終了)。
19) Execute state processing D (end of loop processing).

【0070】このように、本発明の実施形態に係わるコ
ンパイル方法により生成されたプログラムは、共通処理
Xから各々の状態処理A,B,C,Dに移行する際は、
従来のように複数の条件分岐命令において2つの巡回変
数の値を逐次比較することなく、前もって導出された次
の状態処理の先頭アドレス値を参照することにより次の
状態処理に直接ジャンプするので、より高速な処理が可
能となるのである。また、状態処理間に配置する命令の
数が従来の4つから2つに削減することができるので、
ループ処理を有する目的プログラムの容量を小さくする
こともできるのである。
As described above, when the program generated by the compiling method according to the embodiment of the present invention shifts from the common process X to each of the status processes A, B, C, and D,
Instead of successively comparing the values of two cyclic variables in a plurality of conditional branch instructions as in the related art, the program jumps directly to the next state processing by referring to the leading address value of the next state processing derived in advance. Higher-speed processing becomes possible. Also, since the number of instructions to be placed between state processes can be reduced from four to two,
It is also possible to reduce the capacity of the target program having the loop processing.

【0071】次に、実験例2として、レジスタ$3が、
共通処理や状態処理内等、他の用途で用いられる場合に
ついて図7(a)を用いて説明する。
Next, as an experimental example 2, the register # 3
The case where it is used for other purposes, such as in common processing or state processing, will be described with reference to FIG.

【0072】図6に示した実験例1においては、レジス
タ$3が他の用途で利用されていない場合について述べ
たが、レジスタ$3が他の用途で使用される場合は十分
に考えられる。このような場合は、基本的に、巡回変数
用として用いるレジスタを他の処理で使用されない空き
レジスタに設定することにより解決することができる。
例えば、処理装置としてMIPS R3000プロセッ
サを考えると、この処理装置は記録領域としてのレジス
タがアドレス$0〜$31の32個存在し、その大部分
は使用されていない。したがって、他の用途で使用され
ていないレジスタを見つけることは容易であり、図7
(a)に示す最適化終了後の中間テキストの場合は、記
録領域として、他の用途で使用されていないことが確認
されたレジスタ$16を選択している。ここで、図6に
示した中間テキストとの違いは、各々の状態処理の先頭
アドレスを書き込むレジスタ$3をレジスタ$16に設
定(「Jr $16」507)したことにある。
In the experimental example 1 shown in FIG. 6, the case where the register # 3 is not used for another purpose has been described. However, the case where the register # 3 is used for another purpose is sufficiently considered. Basically, such a case can be solved by setting a register used for a cyclic variable to an empty register not used in another process.
For example, when a MIPS R3000 processor is considered as a processing device, this processing device has 32 registers at addresses $ 0 to $ 31 as a recording area, and most of them are not used. Therefore, it is easy to find registers that are not used for other purposes.
In the case of the intermediate text after the end of optimization shown in (a), the register # 16 confirmed to be not used for another purpose is selected as a recording area. Here, the difference from the intermediate text shown in FIG. 6 is that the register # 3 for writing the start address of each state process is set in the register # 16 ("Jr $ 16" 507).

【0073】もし空きレジスタがない場合は、レジスタ
を他の用途と兼用しつつ、処理装置内のスタックメモリ
領域を先頭アドレスの記録領域として利用すると良い。
以下では、実験例3として、このような場合における本
発明の実施形態に係わるコンパイル方法について図7
(b)を用いて簡単に説明する。
If there is no empty register, it is preferable to use the stack memory area in the processing device as a recording area of the head address while using the register for other purposes.
Hereinafter, as an experimental example 3, a compiling method according to the embodiment of the present invention in such a case will be described with reference to FIG.
This will be briefly described with reference to FIG.

【0074】今、ループ処理において使用するレジスタ
$3が他の用途でも使用されている場合を想定しよう。
Assume now that register # 3 used in the loop processing is used for another purpose.

【0075】次に実行すべき状態処理の先頭アドレス値
を保存するレジスタが他の用途で利用されており、且
つ、空きレジスタが存在しない場合は、 1)始めに、レジスタ$3内の最新の情報をアドレスが
($sp+y)であるスタックメモリ領域内に退避させ
る命令「sw $3,y($sp)」508をプログラムの先頭に配
置する。
If the register for storing the start address value of the state processing to be executed next is used for another purpose and there is no empty register, 1) first, the latest in the register # 3 An instruction “sw $ 3, y ($ sp)” 508 for saving information in the stack memory area whose address is ($ sp + y) is arranged at the beginning of the program.

【0076】2)次に、レジスタ$3に1番目の状態処
理の先頭アドレスを書き込む処理を実行することを処理
装置に命ずる命令「li $3,(1番目の状態処理の先頭ア
ドレス)」を命令508の後に配置する。
2) Next, an instruction "li $ 3, (first address of the first state process)" instructing the processing device to execute a process of writing the first address of the first state process to the register # 3 is issued. Placed after 508.

【0077】3)次に、レジスタ$3内のアドレス値を
アドレスが($sp+x)であるスタックメモリ領域内
に退避させる命令「sw $3,x($sp)」510を命令509
の次に配置する。尚、2)、3)の処理においては、状
態処理の先頭アドレスをレジスタ$3を介してスタック
メモリ領域に書き込むという作業を行っているが、これ
は現時点で処理装置(MIPS R3000プロセッ
サ)に直接スタックメモリ領域に情報を書き込ませる処
理を実行させる手段が存在しないためである。したがっ
て、所望の情報を直接スタックメモリ内に書き込ませる
手段が利用可能となれば、2)、3)のステップを1つ
にまとめることが可能となる。
3) Next, an instruction “sw $ 3, x ($ sp)” 510 for saving the address value in the register $ 3 in the stack memory area whose address is ($ sp + x) is issued by the instruction 509.
Place after. In the processing of 2) and 3), the work of writing the start address of the state processing to the stack memory area via the register $ 3 is performed, but this is directly performed by the processing device (MIPS R3000 processor) at the present time. This is because there is no means for executing a process of writing information in the stack memory area. Therefore, if means for writing desired information directly into the stack memory becomes available, steps 2) and 3) can be combined into one.

【0078】4)続いて、アドレスが($sp+y)で
あるスタックメモリ領域の情報をレジスタ$3内に書き
込む処理を実行することを処理装置に命ずる命令「lw $
3,y($sp)」を命令510の次に配置する。
4) Subsequently, an instruction "lw $ which instructs the processing unit to execute a process of writing the information of the stack memory area having the address (@ sp + y) into the register $ 3
“3, y ($ sp)” is arranged after the instruction 510.

【0079】5)レジスタ$3内の値をアドレスが($
sp+y)であるスタックメモリ領域内に退避させる命
令「sw $3,y($sp)」512を共通処理Xの末尾に配置す
る。
5) The value in the register # 3 is changed to the address ($
The instruction “sw $ 3, y ($ sp)” 512 to be saved in the stack memory area (sp + y) is placed at the end of the common processing X.

【0080】6)アドレスが($sp+x)であるスタ
ックメモリ領域内の情報をレジスタ$3に書き込む処理
を実行することを処理装置に命ずる命令「lw $3,x($s
p)」513を命令512の次に配置する。
6) An instruction “lw $ 3, x ($ s) that instructs the processing unit to execute a process of writing information in the stack memory area having the address ($ sp + x) to the register $ 3
p) ”513 is arranged next to the instruction 512.

【0081】7)共通処理Xの末尾に、レジスタ$3に
保存されているアドレス値にジャンプすることを促す命
令「jr $3」501を配置する。
7) At the end of the common processing X, an instruction "jr $ 3" 501 for prompting a jump to the address value stored in the register # 3 is arranged.

【0082】8)各々の状態処理の末尾にレジスタ$3
に保存されているアドレス値を次の状態処理の先頭アド
レス値に設定する先頭アドレス設定命令「addi $3,$3,
(適当な値)」503,504,505を配置する。
8) Register $ 3 at the end of each state process
Address setting instruction "addi $ 3, $ 3,
(Appropriate value) "503, 504, 505 are arranged.

【0083】9)各先頭アドレス計算命令の直後に、共
通処理Xの先頭アドレスにジャンプする処理を実行する
ことを処理装置に命ずる命令「j TOP」502を配置す
る。これにより、処理装置がこの命令を解釈すると、共
通処理Xが実行されることになる。
9) Immediately after each head address calculation instruction, an instruction “j TOP” 502 for instructing the processing unit to execute a process for jumping to the head address of the common process X is arranged. Thus, when the processing device interprets this command, the common process X is executed.

【0084】このようにすることにより、空きレジスタ
が存在しない場合でも本発明の実施形態に係わるコンパ
イル方法を実行することができる。すなわち、空きレジ
スタがない場合には、各状態処理にジャンプする際に要
する先頭アドレス値および他の処理で利用されている情
報をスタックメモリ領域内の別々のアドレス位置に退避
させ、必要時にそれぞれの情報をスタックメモリ領域か
らレジスタ$3に読み出し、書込みを行うことにより、
本発明の実施形態に係わるコンパイル方法を実行するこ
とができる。また、コンパイル処理により、他の用途に
係わるレジスタ内の情報を消去してしまうことがなくな
る。
By doing so, the compiling method according to the embodiment of the present invention can be executed even when there is no empty register. In other words, when there is no empty register, the head address value required for jumping to each state process and information used in other processes are saved to different address positions in the stack memory area, and each of the information is saved when necessary. By reading and writing information from the stack memory area to register # 3,
The compiling method according to the embodiment of the present invention can be executed. In addition, the information in the register related to another use is not erased by the compiling process.

【0085】尚、以上の実験例は、各処理(X,A,
B,C,D)が1つのルーチン内に記述されている場合
のみを示したが、それぞれの処理がサブルーチン化され
他のプログラム内に記述されているような形態に対して
も、その処理の先頭アドレス値を絶対的に設定すること
により本発明の実施形態に係わるコンパイル方法を適用
できることは言うまでもない。また、状態数をA〜Dの
4つの場合で説明したが、5つ以上でも本発明の作用効
果を十分に得られることは勿論である。
In the above experimental example, each processing (X, A,
(B, C, D) are described only in one routine, but the processing of each processing is converted into a subroutine and described in another program. It goes without saying that the compile method according to the embodiment of the present invention can be applied by absolutely setting the start address value. Also, the case where the number of states is four (A to D) has been described, but it goes without saying that the function and effect of the present invention can be sufficiently obtained with five or more states.

【0086】また、処理装置によっては、ループ処理命
令やジャンプ命令等の命令を実行後、直ちにその直後の
命令を実行せずに、当該命令実行前に実行する他の命令
ブロックを格納した場所(遅延分岐スロット)を有する
ものがある。このような遅延分岐スロットを有する処理
装置においても、本発明の最適化を実行することが可能
であり、例えば、図14(b)に示す遅延分岐スロット
を有する中間テキストに対して、本発明の実施形態に係
わるコンパイル方法により図8に示す中間テキストのよ
うにプログラムサイズを最適化することができる。尚、
この際、遅延分岐スロット内に「何も実行しない」処理
を実行することを処理装置に命ずる命令nop514等
の適当な命令を配置するようにすると良い。
Also, depending on the processing device, after executing an instruction such as a loop processing instruction or a jump instruction, the instruction immediately after the instruction is not executed, but another instruction block to be executed before the execution of the instruction is stored. Delay slot). The processing device having such a delay branch slot can also perform the optimization of the present invention. For example, the present invention can be applied to an intermediate text having a delay branch slot shown in FIG. With the compiling method according to the embodiment, the program size can be optimized like the intermediate text shown in FIG. still,
At this time, an appropriate instruction such as an instruction nop 514 for instructing the processing unit to execute the “do nothing” processing in the delay branch slot may be arranged.

【0087】以上が、本発明の実施形態に係わるコンパ
イル方法を用いた基本的な実験結果であるが、本発明の
実施形態に係わるコンパイル方法は、例えば、図9に示
すようなMPEG2のPESパケット構造に関して、そ
の符号化ストリームを復号化するプログラム(ビデオ処
理プログラム)の最適化にも応用させることができる。
すなわち、一般的に、符号化ストリームの復号化は、図
10に示すように、入力ストリームを1バイト取得する
1バイト取得処理を共通処理として複数の状態処理を実
行する構成となっており、その復号化プログラムの基本
構造はループ処理となっている。したがって、本発明の
実施形態に係わるコンパイル方法を用いて復号化プログ
ラムを作成することにより、符号化ストリームの復号に
要する時間および復号化プログラムの容量を小さくする
ことができるのである。
The above is a basic experimental result using the compiling method according to the embodiment of the present invention. The compiling method according to the embodiment of the present invention is, for example, a PES packet of MPEG2 as shown in FIG. Regarding the structure, the present invention can be applied to optimization of a program (video processing program) for decoding the encoded stream.
That is, generally, as shown in FIG. 10, decoding of an encoded stream is configured to execute a plurality of state processes using a 1-byte acquisition process of acquiring an input stream of 1 byte as a common process. The basic structure of the decryption program is a loop process. Therefore, by creating the decoding program using the compiling method according to the embodiment of the present invention, the time required for decoding the encoded stream and the capacity of the decoding program can be reduced.

【0088】また、本発明の実施形態に係わるコンパイ
ル装置は、例えば、図11に示すような概観を有する。
つまり、本発明の実施形態に係わるコンパイル装置はコ
ンピュータ80内にコンパイル装置100の各要素を内
蔵することにより構成される。コンピュータ80は、フ
ロッピーディスクドライブ81および光ディスクドライ
ブ82を備えている。そして、フロッピーディスクドラ
イブ81に対してはフロッピーディスク83、光ディス
クドライブ82に対しては光ディスク84をそれぞれ挿
入し、所定の読み出し操作を行うことにより、これらの
記録媒体に格納されたコンパイルプログラムをコンピュ
ータ内にインストールすることができる。また、適当な
ドライブ装置をコンピュータ80に接続することによ
り、例えば、メモリ装置の役割を担うROM85や、磁
気テープ装置の役割を担うカートリッジ86を用いて、
プログラムのインストールや他の目的プログラムとのリ
ンク付けを実行することも可能である。
The compiling device according to the embodiment of the present invention has, for example, an appearance as shown in FIG.
That is, the compiling device according to the embodiment of the present invention is configured by incorporating each component of the compiling device 100 in the computer 80. The computer 80 includes a floppy disk drive 81 and an optical disk drive 82. Then, the floppy disk 83 is inserted into the floppy disk drive 81, and the optical disk 84 is inserted into the optical disk drive 82, and by performing a predetermined read operation, the compile programs stored in these recording media are loaded into the computer. Can be installed. Further, by connecting an appropriate drive device to the computer 80, for example, by using a ROM 85 serving as a memory device and a cartridge 86 serving as a magnetic tape device,
It is also possible to install programs and link with other target programs.

【0089】また、本発明の実施形態に係わるコンパイ
ル装置は、プログラム化しコンピュータ読み取り可能な
記録媒体内に格納しても良い。そして、原始プログラム
のコンパイルを実行する際は、この記録媒体をコンピュ
ータシステムに読み込ませ、コンピュータシステム内の
メモリ等の記録部にコンパイルプログラムを格納し、コ
ンパイルプログラムを処理装置に実行させることによ
り、本発明の実施形態に係わるコンパイル装置およびそ
の方法をコンピュータシステム上で実現することができ
る。尚、ここで、記録媒体とは、例えば、半導体メモ
リ、磁気ディスク、光ディスク、光磁気ディスク、磁気
テープ、デジタルビデオディスク等、プログラムを記録
することができるコンピュータ読み取り可能な媒体を意
味する。
Further, the compiling device according to the embodiment of the present invention may be programmed and stored in a computer-readable recording medium. When compiling the source program, the recording medium is read into a computer system, the compilation program is stored in a recording unit such as a memory in the computer system, and the processing program executes the compilation program. A compiling device and a compiling method according to an embodiment of the present invention can be realized on a computer system. Here, the recording medium means a computer-readable medium on which a program can be recorded, such as a semiconductor memory, a magnetic disk, an optical disk, a magneto-optical disk, a magnetic tape, and a digital video disk.

【0090】このように、本発明はここでは記載してい
ない様々な実施の形態を包含するということは十分に理
解すべきである。したがって、本発明はこの開示から妥
当な特許請求の範囲に係わる発明特定事項によってのみ
限定されるものでなければならない。
Thus, it should be understood that the present invention covers various embodiments not described herein. Therefore, the present invention must be limited only by the matters specifying the invention according to the claims that are reasonable from this disclosure.

【0091】[0091]

【発明の効果】以上述べてきたように、本発明のコンパ
イル装置によれば、処理装置にループ処理を実行させる
際の累積ジャンプ数を大幅に減らすことができるので、
ループ処理の実行に要する時間を短縮し、さらに、ルー
プ処理を有する目的プログラムの容量を小さくすること
ができる。
As described above, according to the compiling device of the present invention, the number of accumulated jumps when the processing device executes the loop processing can be greatly reduced.
The time required for executing the loop processing can be reduced, and the capacity of the target program having the loop processing can be reduced.

【0092】また、本発明のコンパイル方法によれば、
処理装置にループ処理を実行させる際の累積ジャンプ数
を大幅に減らすことができるので、ループ処理の実行に
要する時間を短縮し、さらに、ループ処理を有する目的
プログラムの容量を小さくすることができる。
According to the compiling method of the present invention,
Since the number of accumulated jumps when the processing device executes the loop processing can be greatly reduced, the time required for executing the loop processing can be reduced, and the capacity of the target program having the loop processing can be reduced.

【0093】さらに、本発明のコンパイルプログラムを
格納したコンピュータ読み取り可能な記録媒体によれ
ば、処理装置にループ処理を実行させる際の累積ジャン
プ数を大幅に減らすことができるので、ループ処理の実
行に要する時間を短縮し、さらに、ループ処理を有する
目的プログラムの容量を小さくすることができる。
Further, according to the computer-readable recording medium storing the compile program of the present invention, the number of accumulated jumps when the processing device executes the loop processing can be greatly reduced. The required time can be reduced, and the capacity of the target program having the loop processing can be reduced.

【0094】さらにまた、本発明の目的プログラムを格
納したコンピュータ読み取り可能な記録媒体によれば、
目的プログラムは最適化処理されているので、ループ処
理を高速に実行することができる。
Further, according to the computer-readable recording medium storing the object program of the present invention,
Since the target program has been optimized, loop processing can be executed at high speed.

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

【図1】本発明の実施形態に係わるコンパイル装置の構
成を示すブロック図である。
FIG. 1 is a block diagram illustrating a configuration of a compiling device according to an embodiment of the present invention.

【図2】本発明の実施形態に係わるコンパイル方法を示
すフローチャート図である。
FIG. 2 is a flowchart illustrating a compiling method according to the embodiment of the present invention.

【図3】本発明の実施形態に係わるコンパイル方法を示
すフローチャート図である。
FIG. 3 is a flowchart illustrating a compiling method according to the embodiment of the present invention.

【図4】最適化されたプログラムと他の目的プログラム
間のアドレス値のリンク付け方法を示す図である。
FIG. 4 is a diagram showing a method of linking an address value between an optimized program and another target program.

【図5】本発明のコンパイル方法により生成される目的
プログラムと従来までの目的プログラムの容量と累積ジ
ャンプ数を比較した図である。
FIG. 5 is a diagram comparing the capacity and the accumulated jump number of the target program generated by the compiling method of the present invention with those of the conventional target program.

【図6】本発明の実施形態に係わるコンパイル方法によ
り作成される中間テキストを示す図である。
FIG. 6 is a diagram showing an intermediate text created by a compiling method according to the embodiment of the present invention.

【図7】本発明の実施形態に係わるコンパイル方法によ
り作成される中間テキストを示す図である。
FIG. 7 is a diagram showing an intermediate text created by a compiling method according to the embodiment of the present invention.

【図8】本発明の実施形態に係わるコンパイル方法によ
り作成される中間テキストを示す図である。
FIG. 8 is a diagram showing an intermediate text created by a compiling method according to the embodiment of the present invention.

【図9】典型的なMPEG2のPESパケット構造を示
す図である。
FIG. 9 illustrates a typical MPEG2 PES packet structure.

【図10】典型的なビデオ処理の処理過程を説明するた
めの図である。
FIG. 10 is a diagram for explaining a typical video processing process;

【図11】本発明の実施形態に係わるコンパイル装置の
概観を示す図である。
FIG. 11 is a diagram showing an overview of a compiling device according to the embodiment of the present invention.

【図12】ループ処理を説明するための模式図である。FIG. 12 is a schematic diagram for explaining a loop process.

【図13】典型的なループ処理を有する原始プログラム
を示す図である。
FIG. 13 is a diagram showing a source program having typical loop processing.

【図14】典型的なループ処理を有する中間テキストを
示す図である。
FIG. 14 illustrates an intermediate text having a typical loop processing.

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

100...コンパイル装置 110...原始プログラム入
力部 120...コンパイル処理部 121...構文解釈
部 122...中間テキスト生成部 123...最適化処
理部 124...ループ処理抽出部 125...記録領域
解析部 126...先頭アドレス設定部 127...ジャ
ンプ命令変換部 128...コード変換部 129...目
的プログラム出力部 130...リンク付け処理部 1
31...実行プログラム出力部
REFERENCE SIGNS LIST 100 compile device 110 source program input unit 120 compile processing unit 121 syntactic interpretation unit 122 intermediate text generation unit 123 optimization processing unit 124 loop processing Extraction unit 125 ... Recording area analysis unit 126 ... Start address setting unit 127 ... Jump instruction conversion unit 128 ... Code conversion unit 129 ... Object program output unit 130 ... Link processing unit 1
31 ... Execution program output section

Claims (4)

【特許請求の範囲】[Claims] 【請求項1】 処理装置に所定の処理を実行させるため
の原始言語で記述した原始プログラムを当該処理装置が
処理容易な目的プログラムに変換するコンパイル装置に
おいて、 少なくとも1つの共通処理と複数の状態処理およびこれ
らの処理間に設けられた条件分岐命令から成るループ処
理部を抽出し、ループ処理の最適化を行う最適化手段を
備え、 前記最適化手段は、 原始プログラム又は原始言語を低級言語に変換した中間
テキスト内のループ処理部を抽出するループ処理抽出手
段と、 前記条件分岐命令内のループ回数を制御する変数の記録
領域を解析し、後記先頭アドレス値を記録するアドレス
記録領域を選定する記録領域解析手段と、 前記状態処理の各々について先頭アドレス値を計算し、
1つの状態処理終了後、次に実行する状態処理の先頭ア
ドレス値を前記アドレス記録領域内に書き込む先頭アド
レス設定手段と、 前記条件分岐命令を、前記アドレス記録領域内の先頭ア
ドレス値を参照することにより次に実行する状態処理の
先頭アドレスにジャンプし、ジャンプ先の状態処理を行
う処理を処理装置に実行させるジャンプ命令に変換する
ジャンプ命令変換手段とを有することを特徴とするコン
パイル装置。
1. A compiling device for converting a source program described in a source language for causing a processing device to execute a predetermined process into a target program which can be easily processed by the processing device, comprising: at least one common process and a plurality of state processes. And optimizing means for extracting a loop processing unit composed of conditional branch instructions provided between these processes and optimizing loop processing, wherein the optimizing means converts a source program or a source language into a lower-level language. Loop processing extraction means for extracting a loop processing unit in the intermediate text, and a recording area for analyzing a recording area of a variable for controlling the number of loops in the conditional branch instruction, and selecting an address recording area for recording a head address value to be described later. Area analyzing means, calculating a start address value for each of the state processes,
After completion of one state process, a start address setting means for writing a start address value of a state process to be executed next in the address recording area; and referring to the condition branch instruction with the start address value in the address recording area. A jump instruction converting means for jumping to the start address of the next state processing to be executed and converting the processing for performing the state processing of the jump destination into a jump instruction to be executed by the processing apparatus.
【請求項2】 処理装置に所定の処理を実行させるため
の原始言語で記述した原始プログラムを当該処理装置が
処理容易な目的プログラムに変換するコンパイル方法に
おいて、 少なくとも1つの共通処理と複数の状態処理およびこれ
らの処理間に設けられた条件分岐命令から成るループ処
理部を抽出し、ループ処理の最適化を行う最適化ステッ
プを備え、 前記最適化ステップは、 原始プログラム又は原始言語を低級言語に変換した中間
テキスト内のループ処理部を抽出するループ処理抽出ス
テップと、 前記条件分岐命令内のループ回数を制御する変数の記録
領域を解析し、後記先頭アドレス値を記録する記録領域
を選定するアドレス記録領域解析ステップと、 前記状態処理の各々について先頭アドレス値を計算し、
1つの状態処理終了後、次に実行する状態処理の先頭ア
ドレス値を前記アドレス記録領域内に書き込む先頭アド
レス設定ステップと、 前記条件分岐命令を、前記アドレス記録領域内の先頭ア
ドレス値を参照することにより次に実行する状態処理の
先頭アドレスにジャンプし、ジャンプ先の状態処理を行
う処理を処理装置に実行させるジャンプ命令に変換する
ジャンプ命令変換ステップとを有することを特徴とする
コンパイル方法。
2. A compiling method for converting a source program described in a source language for causing a processing device to execute a predetermined process into a target program which is easily processed by the processing device, comprising: at least one common process and a plurality of state processes. And optimizing loop processing by extracting a loop processing unit composed of conditional branch instructions provided between these processes, and optimizing the loop processing. The optimizing step converts a source program or a source language into a lower-level language. A loop processing extracting step of extracting a loop processing unit in the intermediate text, and an address recording for analyzing a recording area of a variable for controlling the number of loops in the conditional branch instruction and selecting a recording area for recording a leading address value to be described later. Calculating a start address value for each of the area analysis step and the state processing;
After completion of one state process, a start address setting step of writing a start address value of a state process to be executed next in the address recording area; and referring to the start address value in the address recording area for the conditional branch instruction. A jump instruction conversion step of jumping to a start address of a state processing to be executed next, and converting the processing for performing the state processing of the jump destination into a jump instruction to be executed by the processing device.
【請求項3】 処理装置に所定の処理を実行させるため
の原始言語で記述した原始プログラムを当該処理装置が
処理容易な目的プログラムに変換するコンパイルプログ
ラムを格納したコンピュータ読み取り可能な記録媒体に
おいて、 少なくとも1つの共通処理と複数の状態処理およびこれ
らの処理間に設けられた条件分岐命令から成るループ処
理部を抽出し、ループ処理の最適化を行う最適化処理を
含み、 前記最適化処理は、 原始プログラム又は原始言語を低級言語に変換した中間
テキスト内のループ処理部を抽出するループ処理抽出処
理と、 前記条件分岐命令内のループ回数を制御する変数の記録
領域を解析し、後記先頭アドレス値を記録するアドレス
記録領域を選定する記録領域解析処理と、 前記状態処理の各々について先頭アドレス値を計算し、
1つの状態処理終了後、次に実行する状態処理の先頭ア
ドレス値を前記アドレス記録領域内に書き込む先頭アド
レス設定処理と、 前記条件分岐命令を、前記アドレス記録領域内の先頭ア
ドレス値を参照することにより次に実行する状態処理の
先頭アドレスにジャンプし、ジャンプ先の状態処理を行
う処理を処理装置に実行させるジャンプ命令に変換する
ジャンプ命令変換処理とを含み、これらの処理をコンピ
ュータに実行させることを特徴とするコンパイルプログ
ラムを格納したコンピュータ読み取り可能な記録媒体。
3. A computer-readable recording medium storing a compile program for converting a source program described in a source language for causing a processing device to execute a predetermined process into a target program which can be easily processed by the processing device. An optimization process of extracting a loop processing unit including one common process and a plurality of state processes and a conditional branch instruction provided between these processes, and optimizing the loop process; A loop processing extraction process for extracting a loop processing unit in an intermediate text obtained by converting a program or a source language into a lower-level language; and analyzing a recording area of a variable for controlling the number of loops in the conditional branch instruction, and determining a start address value to be described later. A recording area analysis process for selecting an address recording region to be recorded, and a start address for each of the status processes The calculated,
After completion of one state process, a start address setting process of writing a start address value of a next state process to be executed in the address recording area, and referring to the start address value in the address recording area for the conditional branch instruction. Jump processing to jump to the start address of the state processing to be executed next, and to convert the processing for performing the state processing of the jump destination into a jump instruction to be executed by the processing device, and causing the computer to execute these processing. A computer-readable recording medium storing a compilation program characterized by the above-mentioned.
【請求項4】 請求項2に記載のコンパイル方法により
作成された目的プログラムを備えることを特徴とする目
的プログラムを格納したコンピュータ読み取り可能な記
録媒体。
4. A computer-readable recording medium storing a target program, comprising a target program created by the compiling method according to claim 2.
JP10371613A 1998-12-25 1998-12-25 COMPILING DEVICE, COMPILING METHOD, COMPUTER-READABLE RECORDING MEDIUM STORED COMPILE PROGRAM, AND COMPUTER-READABLE RECORDING MEDIUM STORED OBJECT PROGRAM Pending JP2000194569A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP10371613A JP2000194569A (en) 1998-12-25 1998-12-25 COMPILING DEVICE, COMPILING METHOD, COMPUTER-READABLE RECORDING MEDIUM STORED COMPILE PROGRAM, AND COMPUTER-READABLE RECORDING MEDIUM STORED OBJECT PROGRAM

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP10371613A JP2000194569A (en) 1998-12-25 1998-12-25 COMPILING DEVICE, COMPILING METHOD, COMPUTER-READABLE RECORDING MEDIUM STORED COMPILE PROGRAM, AND COMPUTER-READABLE RECORDING MEDIUM STORED OBJECT PROGRAM

Publications (1)

Publication Number Publication Date
JP2000194569A true JP2000194569A (en) 2000-07-14

Family

ID=18499009

Family Applications (1)

Application Number Title Priority Date Filing Date
JP10371613A Pending JP2000194569A (en) 1998-12-25 1998-12-25 COMPILING DEVICE, COMPILING METHOD, COMPUTER-READABLE RECORDING MEDIUM STORED COMPILE PROGRAM, AND COMPUTER-READABLE RECORDING MEDIUM STORED OBJECT PROGRAM

Country Status (1)

Country Link
JP (1) JP2000194569A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009233001A (en) * 2008-03-26 2009-10-15 Newgin Co Ltd Game machine
CN110362028A (en) * 2018-04-09 2019-10-22 发那科株式会社 Control device and editing device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009233001A (en) * 2008-03-26 2009-10-15 Newgin Co Ltd Game machine
CN110362028A (en) * 2018-04-09 2019-10-22 发那科株式会社 Control device and editing device

Similar Documents

Publication Publication Date Title
JP3327818B2 (en) Program conversion device and recording medium
US20070277162A1 (en) Compiler apparatus, compiler method, and compiler program
JP5148674B2 (en) Program parallelization apparatus and program
JPH02205929A (en) How to compile
JPH10228382A (en) Compiling system
US20100199269A1 (en) Program optimization device and program optimization method
JPH11212797A (en) Program conversion method, program converter and medium for storing program conversion program
JP2015194881A (en) Compiling device, compiler program, and compiling method
US6360355B1 (en) Hardware synthesis method, hardware synthesis device, and recording medium containing a hardware synthesis program recorded thereon
JP2015201119A (en) Compilation program, compilation method, and compilation apparatus
US20010039653A1 (en) Program conversion method, program conversion apparatus, storage medium for storing program conversion program and program conversion program
JP2000194569A (en) COMPILING DEVICE, COMPILING METHOD, COMPUTER-READABLE RECORDING MEDIUM STORED COMPILE PROGRAM, AND COMPUTER-READABLE RECORDING MEDIUM STORED OBJECT PROGRAM
JP2904099B2 (en) Compiling device and compiling method
US7120905B2 (en) System and method for transformation of assembly code for conditional execution
JP4719415B2 (en) Information processing system and code generation method
US5758164A (en) Method and system for processing language
JP2000194567A (en) COMPILING DEVICE, COMPILING METHOD, COMPUTER-READABLE RECORDING MEDIUM STORED COMPILE PROGRAM, AND COMPUTER-READABLE RECORDING MEDIUM STORED OBJECT PROGRAM
JP2002182926A (en) Compilation method and computer-readable recording medium
JP2006301989A (en) Method, apparatus and program for automatically generating a computer language program from a block diagram
JP5399601B2 (en) Implementation code development system and implementation code development program
JP2014099108A (en) Execution time calculating device, execution time calculating method, and program
JP7026563B2 (en) High-level synthesis method, high-level synthesis program, high-level synthesis device
JPH1196018A (en) COMPILING DEVICE AND METHOD, AND COMPUTER-READABLE RECORDING MEDIUM RECORDING COMPILING EXECUTION PROGRAM
JP4006887B2 (en) Compiler, processor and recording medium
JP2001043209A (en) Multiple nest loop program compile system

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20050926

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20080227

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20080520

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20080930