JP2500515B2 - CASE structure processing method that allows range specification - Google Patents

CASE structure processing method that allows range specification

Info

Publication number
JP2500515B2
JP2500515B2 JP4352410A JP35241092A JP2500515B2 JP 2500515 B2 JP2500515 B2 JP 2500515B2 JP 4352410 A JP4352410 A JP 4352410A JP 35241092 A JP35241092 A JP 35241092A JP 2500515 B2 JP2500515 B2 JP 2500515B2
Authority
JP
Japan
Prior art keywords
branch
case
processing
range
value
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.)
Expired - Fee Related
Application number
JP4352410A
Other languages
Japanese (ja)
Other versions
JPH06180651A (en
Inventor
洋 船木
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NEC Corp
Original Assignee
Nippon Electric 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 Nippon Electric Co Ltd filed Critical Nippon Electric Co Ltd
Priority to JP4352410A priority Critical patent/JP2500515B2/en
Publication of JPH06180651A publication Critical patent/JPH06180651A/en
Application granted granted Critical
Publication of JP2500515B2 publication Critical patent/JP2500515B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Description

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

【0001】[0001]

【産業上の利用分野】本発明は、範囲指定が可能なCA
SE構造の仕様をサポートする言語で記述された原始プ
ログラムのコンパイラを有する計算機システムでのCA
SE構造の処理方式に係わり、特にCASE文が現れる
たびに、CASE文で指定された値をSELECT C
ASEブロックごとに記憶しておいて、すでに記憶して
ある値と比較することにより、値の範囲に対してそのブ
ロックが実行されないときの最適な分岐先を決定する、
範囲指定が可能なCASE構造の処理方式に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention is a CA whose range can be specified.
CA in a computer system having a compiler of a source program written in a language that supports the specification of SE structure
This is related to the processing method of the SE structure, and especially when the CASE statement appears, the value specified in the CASE statement is changed to SELECT C
Each ASE block is stored and compared with a previously stored value to determine the optimal branch destination when that block is not executed for a range of values,
The present invention relates to a CASE structure processing method capable of specifying a range.

【0002】[0002]

【従来の技術】範囲指定が可能なCASE構造の仕様を
サポートする言語で記述された原始プログラムをコンパ
イルするコンパイラを備えた計算機システムにおいて、
従来CASE文で指定された処理への分岐先を定める値
を、昇順または降順に並べることにより余分な判定及び
分岐命令を減らす、およびCASE文の範囲指定と範囲
指定の間に分岐テーブルによる分岐を生成するという技
術はあった(特開平3−4332号公報(A) FOR
TRANにおけるCASE構造処理方式)。
2. Description of the Related Art In a computer system equipped with a compiler that compiles a source program written in a language that supports the specification of a CASE structure capable of specifying a range,
By arranging the values that determine the branch destination for the process specified by the conventional CASE statement in ascending or descending order, unnecessary judgment and branch instructions are reduced, and branching by the branch table is performed between the range specification of the CASE statement. There was a technique of generating (for example, Japanese Patent Laid-Open No. 3-4332 (A) FOR
CASE structure processing method in TRAN).

【0003】[0003]

【発明が解決しようとする課題】前述の従来技術では、
範囲指定が可能なCASE構造を処理する際、余分な判
定及び分岐命令を減らす、およびCASE文の範囲指定
と範囲指定の間に分岐テーブルによる分岐を生成するた
めに、CASE文で指定された処理への分岐先を定める
値を、昇順または降順に並べていた。
In the above-mentioned prior art,
The processing specified in the CASE statement in order to reduce extra judgment and branch instructions when processing a range-capable CASE structure, and to generate a branch by a branch table between the range specification of the CASE statement. The values that determine the branch destinations for are arranged in ascending or descending order.

【0004】しかし、この方法では最も実行される可能
性の高いCASEブロックを利用者が意識して最初の方
に記述しても、利用者の意図が反映されず、かえって実
行速度が遅くなるという欠点があった。
However, in this method, even if the user consciously describes the CASE block that is most likely to be executed in the first part, the intention of the user is not reflected and the execution speed is rather slowed down. There was a flaw.

【0005】[0005]

【課題を解決するための手段】本発明の範囲指定が可能
なCASE構造の処理方式は、範囲指定が可能なCAS
E構造の使用をサポートする言語で記述された原始プロ
グラムのコンパイラを有する計算機システムにおけるC
ASE構造の処理方式において、CASE文が現れるた
びに、該CASE文で指定された値をSELECT C
ASEブロックごとに記憶しておいて、すでに記憶して
ある値と大小関係を比較することにより、前記ブロック
が実行されないときの最適な分岐先を決定する次期判定
分岐処理決定部と、前記CASE構造にかかる式を評価
した結果に対して判定し、真ならば対応するCASEブ
ロックへ、偽ならば前記次期判定分岐処理決定部で得た
最適な分岐先へ分岐する中間コードを生成し、各CAS
E文に該当する処理ブロックへ分岐するテキストを順次
出力する判定分岐処理生成部と、を有するCASE構造
処理部から構成されることを特徴とする。
The processing method of the CASE structure capable of specifying a range according to the present invention is a CAS specifying a range.
C in a computer system having a compiler for a source program written in a language that supports the use of E structures
In the processing method of the ASE structure, each time a CASE statement appears, the value specified by the CASE statement is changed to SELECT C
An ASE block is stored for each ASE block and the magnitude relationship is compared with the already stored value to determine the optimum branch destination when the block is not executed. Is determined for the result of evaluation of the expression, if it is true, an intermediate code for branching to the corresponding CASE block is generated, and if false, an intermediate code is generated for branching to the optimum branch destination obtained by the next-stage determination branch processing determination unit.
The text that branches to the processing block corresponding to the E sentence is sequentially
And a CASE structure processing section having a decision branch processing generation section for outputting .

【0006】[0006]

【作用】本発明により、利用者の記述したブロックの順
序を変更することなしに、余分な判定及び分岐命令を減
らす、およびCASE文の範囲指定と範囲指定の間に分
岐テーブルによる分岐を生成することができるようにな
る。
According to the present invention, unnecessary judgment and branch instructions are reduced without changing the order of blocks described by the user, and branches are generated by a branch table between the range specification of the CASE statement. Will be able to.

【0007】[0007]

【実施例】〔第1の実施例〕以下、本発明のFortr
anコンパイラにおける一実施例を図面に基づき詳細に
説明する。
EXAMPLES [First Example] The following is the Fortr of the present invention.
An embodiment of an compiler will be described in detail with reference to the drawings.

【0008】図2は、本発明が適用されたコンパイラ全
体の構造を示す図である。図2の構文解析部22がFo
rtranプログラムである原始プログラム21を入力
して、構文を解析し中間コード13に変換する。意味解
析部23がCASE構造処理部1などを用いて、各文の
意味を解析し、オブジェクト・コードに近い形式の中間
コード14に変換する。これを最適化処理部24が最適
化を行い、コード生成部25がオブジェクト・コード2
7を生成する。
FIG. 2 is a diagram showing the structure of the entire compiler to which the present invention is applied. The syntax analysis unit 22 of FIG.
The source program 21, which is an rtran program, is input, the syntax is analyzed, and the intermediate code 13 is converted. The semantic analysis unit 23 analyzes the meaning of each sentence using the CASE structure processing unit 1 or the like, and converts it into the intermediate code 14 in a format close to the object code. This is optimized by the optimization processing unit 24, and the code generation unit 25 executes the object code 2
7 is generated.

【0009】本発明はCASE構造処理部1に係わり、
オブジェクト・コード27の実行効率を上げるものであ
る。CASE構造処理部1のうち、本発明に係わる部分
について動作を説明する。
The present invention relates to the CASE structure processing unit 1,
This is to improve the execution efficiency of the object code 27. The operation of the portion related to the present invention in the CASE structure processing unit 1 will be described.

【0010】図1は、本発明の一実施例である範囲指定
が可能なCASE構造の処理方式の構成図である。図1
において、CASE構造処理部1はCASE構造に関す
る文の処理を行う手段であり、次期判定分岐処理決定部
11はCASE文が現れるたびに、CASE文で指定さ
れたCASE値をSELECT CASEブロックごと
に記憶しておいて、すでに記憶してある値と比較するこ
とにより、CASE値の範囲に対してそのブロックが実
行されないときの最適な分岐先を決定する手段であり、
判定分岐処理生成部12は次期判定分岐処理決定部11
で得た情報をもとCASE構造に係る式を評価した結果
に対して、判定し、分岐する中間コードを生成する手段
であり、分岐テーブル生成判定部121は上記次期判定
分岐処理決定部11で得た情報を元に分岐テーブルによ
る分岐を用いた方がオブジェクトプログラムが早く実行
できる一群の判定を決定する手段であり、テーブル分岐
中間コード生成部122は上記分岐テーブル生成判定部
121で決定した一群の判定に対し、テーブル分岐によ
る分岐の中間コードを出力する手段であり、中間コード
13、14は原始プログラム21からオブジェクト コ
ード27へ変換される途中の中間コードに対応するもの
である。
FIG. 1 is a block diagram of a CASE structure processing method capable of specifying a range, which is an embodiment of the present invention. FIG.
In the above, the CASE structure processing unit 1 is a means for processing a sentence related to the CASE structure, and the next decision branch processing decision unit 11 stores the CASE value specified in the CASE sentence for each SELECT CASE block every time the CASE sentence appears. Then, it is a means for determining the optimum branch destination when the block is not executed for the range of CASE value by comparing with the value already stored,
The decision branch process generation unit 12 is the next decision branch process determination unit 11
The branch table generation judging unit 121 is a means for judging the result of evaluating the expression related to the CASE structure on the basis of the information obtained in 1. and generating a branching intermediate code. Using the branch by the branch table based on the obtained information is a means for determining the group of determinations that the object program can execute earlier, and the table branch intermediate code generation unit 122 determines the group by the branch table generation determination unit 121. In response to the above determination, it is a means for outputting the intermediate code of the branch by the table branch, and the intermediate codes 13 and 14 correspond to the intermediate code which is being converted from the source program 21 to the object code 27.

【0011】本実施例では、範囲指定が可能なCASE
構造の仕様をサポートする言語として、新しいFort
ran言語を例にあげている。
In this embodiment, CASE capable of specifying a range
New Fort as a language that supports the specification of structure
The ran language is taken as an example.

【0012】新しいFortran言語では次の構文規
則からなる範囲指定が可能なCASE構造の仕様を追加
している。 SELECT CASE構造 select-case 文 [case文 block]… end-select文 select-case 文 [case構造名:]SELECT CASE(case式) case文 CASE case選択子 [case構造名] block 実行文の集まり end-select文 END SELECT[case構造名] case選択子 DEFAULT または (case値の範囲の並び) case値の範囲 case値 または case値: または :case値 または case値:case値 FortranにおけるCASE構造の規則は、CAS
E値の範囲指定ができること、一つのブロックに対し複
数のCASE値やCASE値の範囲が指定できること、
実行されるブロックが二つ以上あるようなCASE値や
CASE値の範囲を指定することができないこと、c言
語のbreak文のように明示的にブロックから出るこ
とを指定しなくても、一つのブロックしか実行されない
ことに特徴がある。
In the new Fortran language, the specification of the CASE structure capable of specifying the range consisting of the following syntax rules is added. SELECT CASE structure select-case statement [case statement block] ... end-select statement select-case statement [case structure name:] SELECT CASE (case expression) case statement CASE case selector [case structure name] block Collection of execution statements end -select statement END SELECT [case structure name] case selector DEFAULT or (list of case value range) case value range case value or case value: or: case value or case value: case value The FORSE rules for CASE structure are , CAS
E value range can be specified, multiple CASE values and CASE value range can be specified for one block,
Even if it is not possible to specify a CASE value or a range of CASE values such that there are two or more blocks to be executed, or if you do not explicitly specify to exit from the block like the break statement in c language, The feature is that only blocks are executed.

【0013】次のプログラム片はCASE構造の例であ
る。
The following program fragment is an example of the CASE structure.

【0014】 SELECT CASE (I+ J) ! CASE(10:20) ! PRINT *,'10-20' ! CASE DEFAULT ! PRINT *,'DEFAULT' ! CASE(30) ! PRINT *,'30' ! END SELECT ! このプログラム片は(I+J)の値が10以上20以下
ならば「10−20」を印字し、END SELECT
文の次の実行文に制御を移し、(I+J)の値が30に
等しければ、「30」を印字し、END SELECT
文の次の実行文に制御を移し、そのいずれでもなけれ
ば、「DEFAULT」を印字し、ENDSELECT
文の次の実行文に制御を移すように動作する。
SELECT CASE (I + J)! CASE (10:20)! PRINT *, '10-20'! CASE DEFAULT! PRINT *, 'DEFAULT'! CASE (30)! PRINT *, '30'! END SELECT! This program fragment prints "10-20" if the value of (I + J) is 10 or more and 20 or less, and END SELECT
If the value of (I + J) is equal to 30, control is transferred to the next execution statement of the statement, "30" is printed, and END SELECT
The control is transferred to the next execution statement of the statement, and if none of them, "DEFULT" is printed and ENDSELECT
Operates to transfer control to the next executable statement in the statement.

【0015】次に本発明の図1の示す実施例のうちCA
SE構造処理部1の動作について、図3、図4、図5を
用いて説明する。
Next, of the embodiments shown in FIG. 1 of the present invention, CA
The operation of the SE structure processing unit 1 will be described with reference to FIGS. 3, 4, and 5.

【0016】図3は本発明の一実施例を説明するための
Fortranの原始プログラムである。
FIG. 3 shows a Fortran original program for explaining an embodiment of the present invention.

【0017】図4は従来技術によって図3のプログラム
から生成された中間コードの例である。
FIG. 4 shows an example of intermediate code generated from the program of FIG. 3 according to the prior art.

【0018】図3のような原始プログラムは標準的な構
文/意味解析の理論に基づくと図4のような中間コード
に変換される。すなわち、CASE文の情報を記録して
おいて、END SELECT文が現れたところで、各
々のCASEの値に対応する判定分岐を行う中間コード
を出力することになる。
A source program as shown in FIG. 3 is converted into an intermediate code as shown in FIG. 4 based on the standard syntax / semantic analysis theory. That is, the information of the CASE statement is recorded, and when the END SELECT statement appears, an intermediate code for performing a decision branch corresponding to each CASE value is output.

【0019】図3の3−1(以降単に3−1と書く)の
文のCASE値の範囲による判定分岐は、図4の4−1
と4−2(以降4−1、4−2と書く)のような2つの
中間コードに分解される。4−1はCASE値の範囲の
下限より小さければそのブロックを実行しないので、次
の判定の中間コードへ分岐するというものである。この
ような判定分岐を以降、下限判定分岐と呼ぶ。4−2は
CASE値の範囲の上限より小さければ、4−2に制御
が渡るということは下限よりも大きいか等しいという条
件は満たしていることになるので、このブロックを実行
する分岐先へ分岐する。このような判定分岐を以降、上
限判定分岐と呼ぶ。
The decision branch according to the range of CASE value of the sentence 3-1 (hereinafter simply referred to as 3-1) in FIG. 3 is 4-1 in FIG.
And 4-2 (hereinafter referred to as 4-1 and 4-2) are decomposed into two intermediate codes. If 4-1 is smaller than the lower limit of the range of CASE value, the block is not executed, so that the process branches to the intermediate code of the next judgment. Hereinafter, such a determination branch will be referred to as a lower limit determination branch. If 4-2 is smaller than the upper limit of the range of CASE values, it means that the condition that control is passed to 4-2 is greater than or equal to the lower limit, so branch to the branch destination for executing this block. To do. Hereinafter, such a determination branch will be referred to as an upper limit determination branch.

【0020】4−1が真の場合、つまり係るCASE式
が20より小さい場合、その分岐先である4−3は、判
定条件が60に等しいことなので、決して真になること
はなく、このような、判定はむだになる。この場合、4
−4、4−5の判定も無駄で、次に真になる可能性があ
るのは、4−6ということになる。
When 4-1 is true, that is, when the CASE expression is smaller than 20, the branching destination 4-3 is never true because the judgment condition is equal to 60. The decision is useless. In this case, 4
The judgments of -4 and 4-5 are also useless, and there is a possibility of becoming true next, that is, 4-6.

【0021】4−5の場合も同様に、4−5が偽の場
合、つまり係るCASE式が50より大きいとき、その
分岐先である4−6は決して真になることはないので、
この判定を行うことは無駄である。
Similarly, in the case of 4-5, when 4-5 is false, that is, when the CASE expression is larger than 50, the branch destination 4-6 is never true.
It is useless to make this determination.

【0022】CASE値の判定分岐をソートしてしまえ
ば、この無駄な判定は減らすことができるが、利用者の
意図した順序で判定を行わないと実行される可能性の高
い判定を後の方で行う可能性がありよくない。
If the judgment branches of the CASE value are sorted, this useless judgment can be reduced, but if the judgment is not performed in the order intended by the user, the judgment that is likely to be executed will be performed later. Not good to do in.

【0023】次期判定分岐処理決定部11は、利用者の
指定した順序を変えないまま、無駄な判定を避けるよう
に記録してあるCASE文の情報に無駄な分岐をとばす
ようCASE値の大小関係の情報を付加する処理を行
う。
The next-judgment branching processing decision unit 11 skips the unnecessary branching in the information of the CASE statement recorded so as to avoid the unnecessary judgment without changing the order specified by the user, and the magnitude relationship of the CASE values. The process of adding the information of is performed.

【0024】以下、図5、図6、図7を用いて次期判定
分岐処理決定部11の処理を説明する。
The process of the next decision branch process decision unit 11 will be described below with reference to FIGS. 5, 6 and 7.

【0025】図5は図3の原始プログラムを例に、標準
的な構文解析の理論と従来技術と本発明によるCASE
文の情報の差異を説明する図である。
FIG. 5 shows the case of the standard parsing theory, the conventional technique and the CASE according to the present invention, using the source program of FIG. 3 as an example.
It is a figure explaining the difference of the information of a sentence.

【0026】図5において、ラベルとはこの判定に対し
て作るラベルである。内容とはどのような判定を行うか
を記録したものである。分岐先とはこの判定が真の時に
どのブロックを実行するかを意味する。出力順序とは原
始プログラムに記述されている順序と異なる順序で判定
を行うとき、その順序を記録するもので、この例では、
昇順に並び替えられている。
In FIG. 5, a label is a label created for this determination. The content is a record of what kind of determination is made. The branch destination means which block is executed when this judgment is true. The output order is to record the order when the judgment is made in the order different from the order described in the source program. In this example,
They are sorted in ascending order.

【0027】本発明によるCASE情報の記録による
と、記録されるCASE文の情報のうち範囲指定に対
し、左の枝と右の枝を付加している。左の枝はこの判定
より後に現れる、範囲指定の下限より小さいCASE値
を持つ判定を意味する。すなわち、下限判定によって判
定に対応するブロックが実行されないことが決定したと
きの次に行う判定である。右の枝はこの判定より後に現
れる、範囲指定の上限より大きなCASE値を持つ判定
を意味する。すなわち、上限判定によって判定に対応す
るブロックが実行されないことが決定したときの次に行
う判定である。
According to the recording of the CASE information according to the present invention, the left branch and the right branch are added to the range designation of the recorded CASE sentence information. The left branch means a judgment that appears after this judgment and has a CASE value smaller than the lower limit of the range specification. That is, it is the determination to be performed next when the lower limit determination determines that the block corresponding to the determination is not executed. The right branch means a judgment that appears after this judgment and has a CASE value larger than the upper limit of the range specification. That is, it is the next determination made when the upper limit determination determines that the block corresponding to the determination is not executed.

【0028】記録されるCASE文の情報のうち範囲指
定以外の判定に対し、右の枝だけ付加している。これは
この判定によって判定に対応するブロックが実行されな
いことが決定したときの次に行う判定である。
Of the recorded CASE sentence information, only the right branch is added to the judgment other than the range designation. This is the next determination made when it is determined by this determination that the block corresponding to the determination is not executed.

【0029】新しく記録されるCASE方法は必ず、ど
こかのCASE情報の枝になる。このようにすると原始
プログラムに書かれた判定の順序を変更することはな
い。
The newly recorded CASE method is always a branch of CASE information somewhere. In this way, the order of judgments written in the source program is not changed.

【0030】ここで×は、右枝または左枝が存在しない
ことを意味し、−はここでは用いない(参照されない)
ことを意味する。
Here, x means that there is no right or left branch, and-is not used here (not referenced).
Means that.

【0031】標準的な構文解析の理論に基づくCASE
情報の記録によると、例えば、15という値(どのブロ
ックも実行されない)を判定すると、全ての判定を行わ
なければいけない。
CASE based on standard parsing theory
According to the recorded information, for example, if a value of 15 (no block is executed) is determined, all determinations must be made.

【0032】一般的に最も実行される確率の高い判定を
最初に持ってくると実行効率はよくなるが、従来の技術
によると、例えば図5の例では、このSELECT C
ASEブロックが実行されるときはほとんどの場合2
0:30のブロックが実行されるとしても必ず、10の
判定を行ってしまう。
Generally, the efficiency of execution is improved by bringing the judgment with the highest probability of execution first, but according to the conventional technique, for example, in the example of FIG.
2 most of the time when ASE blocks are executed
Even if the block of 0:30 is executed, the judgment of 10 is always made.

【0033】図6は図5のような本発明によるCASE
情報を記録するための次期判定分岐処理決定部11の処
理を説明するブロック図である。CASE構造解析部1
は、CASE文が現れるたびに次期判定分岐処理決定部
11を呼び出し、CASE文の情報を記録する。
FIG. 6 shows a CASE according to the present invention as shown in FIG.
It is a block diagram explaining the process of the next determination branch process determination part 11 for recording information. CASE structural analysis unit 1
Every time the CASE statement appears, it calls the next decision branching process determining section 11 and records the information of the CASE statement.

【0034】図6をみると、61は初期設定として入力
したCASE文の情報を現判定とし、処理中のSELE
CT CASE情報の最初のCASE文の情報を対象判
定するステップ、62は対象判定が範囲指定であるかど
うかを調べ対象判定ならばステップ63へ、対象判定で
なければステップ65へ実行を移すステップ、63は現
判定の値が対象判定の値より小さいかどうかを調べ、小
さければステップ64へ、大きければステップ65へ実
行を移すステップ、64は対象判定に既に左の枝が存在
するかを調べ、存在すればステップ641へ、しなけれ
ばステップ642へ実行を移すステップ、641は対象
判定の左の枝を対象判定とし、ステップ62へ実行を移
すステップ、642は現判定を対象判定の左の枝とし処
理を終えるステップ、65は対象判定に既に右の枝が存
在するかを調べ、存在すればステップ651へ、しなけ
ればステップ652へ実行を移すステップ、651は対
象判定の右の枝を対象判定とし、ステップ62へ実行を
移すステップ、652は現判定を対象判定の右の枝とし
処理を終えるステップである。
Referring to FIG. 6, reference numeral 61 designates the information of the CASE sentence input as the initial setting as the current determination, and the SELE being processed.
The step of determining the information of the first CASE statement of the CT CASE information as a target, 62 is a step of checking whether the target determination is a range designation and moving to step 63 if the target determination is determined, and step 65 to step 65 if not determined. 63 is a step of checking whether or not the value of the current judgment is smaller than the value of the target judgment, and if it is smaller, the step is moved to step 64, and if it is larger, the step is moved to step 65. 64 is checked whether the left branch already exists in the target judgment, If it exists, the step moves to step 641; otherwise, the step moves to step 642; 641 sets the left branch of the target judgment as the target judgment, and moves the execution to step 62; 642 shows the current judgment the left branch of the target judgment. Then, the step 65 ends the processing, and the step 65 checks whether or not the right branch already exists in the target determination. If it exists, the step goes to the step 651, and if not, the step 652. Step 651 is the step of shifting the execution to step 651, the right branch of the target determination is the target determination, step 562 is the step of shifting the execution to the step 62, and the current determination is the right branch of the target determination to end the processing.

【0035】図7は図5のCASE情報に対応する本発
明を適用したときに得るCASE情報の状態にさらにC
ASE値15の判定のCASE情報を付加したときの図
である。
FIG. 7 shows the state of CASE information obtained by applying the present invention corresponding to the CASE information of FIG.
It is a figure when CASE information of the determination of ASE value 15 is added.

【0036】図6、図7を用いて次期判定分岐処理決定
部11の処理を具体的に説明する。
The process of the next decision branch process decision unit 11 will be concretely described with reference to FIGS. 6 and 7.

【0037】図6によると、CASE情報の記録が図5
の状態にあるときは、さらにCASE (15)という
CASE文を読み込むと次のような動作でCASE情報
L15を記録する。
According to FIG. 6, the recording of the CASE information is shown in FIG.
When the CASE statement of CASE (15) is further read in the state of, the CASE information L15 is recorded by the following operation.

【0038】まず、現判定L15は値15、対象判定L
20は値20:30となる(ステップ61)。対象判定
が範囲指定なので(ステップ62)、現判定と対象判定
で値を比較すると、現判定が小さいので対象判定の左の
枝を調べる(ステップ63)。左の枝が存在するので
(ステップ64)、対象判定を左の枝のL10にして、
処理を繰り返す(ステップ641)。次に対象判定は範
囲指定ではないので(ステップ62)、右の枝を調べ
る。右の枝は存在しないので(ステップ65)、現判定
を対象判定の枝に設定して処理を終える(ステップ65
2)。
First, the current judgment L15 is the value 15, the target judgment L15.
20 becomes the value 20:30 (step 61). Since the target determination is the range designation (step 62), when the values of the current determination and the target determination are compared, the current determination is small, so the left branch of the target determination is checked (step 63). Since the left branch exists (step 64), the target determination is set to L10 of the left branch,
The process is repeated (step 641). Next, since the target determination is not the range designation (step 62), the right branch is examined. Since the right branch does not exist (step 65), the current judgment is set as the target judgment branch and the processing ends (step 65).
2).

【0039】この処理の結果、図7のようなCASE情
報を得る。
As a result of this processing, CASE information as shown in FIG. 7 is obtained.

【0040】次に、図7、図8を用いて判定分岐中間コ
ード生成部12の処理を説明する。
Next, the processing of the decision branch intermediate code generator 12 will be described with reference to FIGS. 7 and 8.

【0041】図8は図3の原始プログラムに対して本発
明を適用したときに得る中間コードである。
FIG. 8 is an intermediate code obtained when the present invention is applied to the source program of FIG.

【0042】判定分岐処理生成部12はCASE文の現
れた順序で判定を行う中間コードを生成する。このとき
上記次期判定分岐処理決定部11で記録された、CAS
E値の大小関係から、次の判定への分岐を決定し、中間
コードを生成する。
The decision branching process generator 12 generates an intermediate code for making a decision in the order in which the CASE statement appears. At this time, the CAS recorded in the next determination branching process determination unit 11 is
A branch to the next determination is determined based on the magnitude relationship of the E value, and an intermediate code is generated.

【0043】つまり、記録してある順にCASEの情報
を取り出し、判定分岐の中間コードと、そのCASE情
報の枝の判定に対しラベルを生成し、ブロックが実行さ
れないときそこに分岐する中間コードを生成する。CA
SE情報に枝が記録されていない場合、ブロックが実行
されないときはDEFAULTがあればDEFALUT
ブロック、なければSELECT CASEブロックを
抜ける無条件分岐の中間コードを生成する。
That is, the CASE information is taken out in the recorded order, the intermediate code of the decision branch and the label for the decision of the branch of the CASE information are generated, and the intermediate code branching to the branch is generated when the block is not executed. To do. CA
If a branch is not recorded in the SE information, and if the block is not executed, DEFALUT is present if DEFULT exists.
Generates intermediate code for an unconditional branch that exits a block, or a SELECT CASE block if none.

【0044】図7の例でいうとラベルL20の情報は範
囲指定なので、20より小さいときは左の枝のラベルL
10へ分岐する中間コードを生成し、次に30以下のと
きにBLK20へ分岐、それ以外の場合には右の枝のL
60に分岐する中間コードを生成する。次にラベルL6
0の情報は範囲指定でないので、60に等しければBL
K60へ分岐、それ以外の場合には右の枝のL60に分
岐する中間コードを生成する。同様の処理を繰り返す
と、図8の中間コードを得る。図4と図8を比べると、
4−1と4−4の分岐先が冗長な判定を行わない最適な
分岐先に変更されている。
In the example of FIG. 7, since the information of the label L20 is the range designation, when it is smaller than 20, the label L of the left branch is displayed.
Generates an intermediate code that branches to 10, then branches to BLK 20 when the number is 30 or less, and L in the right branch otherwise.
An intermediate code that branches to 60 is generated. Then label L6
Since the information of 0 is not the range designation, if it is equal to 60, BL
An intermediate code that branches to K60, and branches to L60 on the right branch otherwise is generated. By repeating the same process, the intermediate code of FIG. 8 is obtained. Comparing FIG. 4 and FIG.
The branch destinations of 4-1 and 4-4 are changed to optimal branch destinations that do not make a redundant determination.

【0045】ここでこの判定の順序を利用者が原始プロ
グラム上でソートして記述すると、従来技術と同じ効果
を得ることができる。従って利用者はプログラムすると
きどのブロックが実行される確率が高いか分からない場
合は、原始プログラム上でCASE値を並び変え、実行
される確率が高いブロックが分かっている場合は確率の
高いブロックから順に記述すれば良い。
If the user sorts and describes the order of this determination on the source program, the same effect as the conventional technique can be obtained. Therefore, when the user does not know which block has a high probability of being executed when programming, the CASE values are rearranged in the source program, and when the block with a high probability of being executed is known, the block with the highest probability is selected. It should be described in order.

【0046】〔第2の実施例〕最後に第2の実施例につ
いて、図9、図10の例を基に分岐テーブル生成判定部
121とテーブル分岐中間コード生成部122の動作を
説明する。
[Second Embodiment] Finally, with respect to the second embodiment, the operations of the branch table generation determination unit 121 and the table branch intermediate code generation unit 122 will be described based on the examples of FIGS. 9 and 10.

【0047】図9は第2の実施例を説明するFortr
anの原始プログラムである。
FIG. 9 is a Fortr for explaining the second embodiment.
It is an original program.

【0048】図10は次期判定分岐処理決定部11によ
って図9のFortranの原始プログラムから得たC
ASE情報の図である。ただし、図10中の‘*’の記
号は分岐テーブル生成判定部121によって記録される
テーブル分岐を行うことを示す印であり、‘!’は同じ
くこのCASE情報が処理済みであることを示す印であ
る。
FIG. 10 shows C obtained from the Fortran original program of FIG. 9 by the next decision branch process decision unit 11.
It is a figure of ASE information. However, the symbol “*” in FIG. 10 is a mark that indicates that the table branch is performed, which is recorded by the branch table generation determination unit 121, and the symbol “!”. Similarly, "is a mark indicating that this CASE information has been processed.

【0049】分岐テーブル生成判定部121は、上記次
期判定分岐処理決定部11で作られたCASE値の大小
関係を表す木構造から、各々の枝について左の枝のさら
に右の枝または右の枝のさらに左の枝になっているよう
な枝を調べる。すなわち、ある範囲指定とある範囲指定
の間の値の持つ判定の一群を検出し、その枝の下にある
一群の判定に対して分岐テーブルによる分岐が高速かど
うかを判断する。分岐テーブルによる分岐が高速である
と判断したら、枝にテーブル分岐を行うという印を記録
しておく。
The branch table generation determining unit 121 determines, from the tree structure representing the magnitude relationship of the CASE values created by the next determination branching processing determining unit 11, the left branch of each branch, or the right branch or the right branch. Examine the branch that is the leftmost branch of. That is, a group of judgments having a value between a certain range specification and a certain range specification is detected, and it is judged whether or not the branch by the branch table is faster than the group of judgments under the branch. When it is determined that the branch by the branch table is fast, the mark that the table is branched is recorded in the branch.

【0050】判断の基準は分岐テーブルに必要なメモリ
の量と分岐テーブルによる判定命令の減る量である。
The criteria for the judgment are the amount of memory required for the branch table and the amount of decrease of the judgment instruction by the branch table.

【0051】例えば図10を見ると、番号101に示す
部分が範囲指定と範囲指定に囲まれている部分であるこ
とが分かる。この部分に対して分岐テーブルによる分岐
はテーブルの大きさがアドレス10個分で、判定命令は
範囲指定に対しては2つ必要なので5個となり、これ
は、分岐テーブルによる分岐の命令を持つ計算機システ
ムにおいてはほとんどの場合高速になる。そこでCAS
E値31の枝にテーブル分岐の印を記録する。
For example, referring to FIG. 10, it can be seen that the portion indicated by the numeral 101 is the portion surrounded by the range designation and the range designation. For this part, the branch by the branch table has a table size of 10 addresses, and two judgment instructions are required for the range specification, so there are five, which is a computer having a branch table branch instruction. In most cases it will be faster in the system. Then CAS
Record the table branch mark on the branch with E value 31.

【0052】テーブル分岐中間コード生成部122は、
判定中間コードを出力する際、テーブル分岐を行う印が
あれば、そこから枝をたどることによってテーブル分岐
による分岐の中間コードを出力し、対象となる一群の判
定すべてに処理済みの印を記録する。
The table branch intermediate code generator 122
When outputting the judgment intermediate code, if there is a mark for branching the table, the branch is traced from there to output the intermediate code of the branch by the table branch, and the processed mark is recorded for all of the target group of judgments. .

【0053】例えば図10をみると、最初にCASE値
31の枝に印がついているのが分かる。そこで31より
下にある枝に対するテーブルによる分岐の中間コードを
出力する。サーチする際には20:30と40:50の
情報を記録しておいて、31から39までの分岐テーブ
ルを作成する。また枝をたどり31、36、33:3
5、32の分岐先を分岐テーブルに設定しながら、各々
の枝に処理済みの印を記録する。判定を行う中間コード
を出力する際には、この出力済みの印が記録されていな
いことを確認しなくてはいけない。
For example, referring to FIG. 10, it can be seen that the branch with the CASE value 31 is first marked. Therefore, the intermediate code of the branch by the table for the branches below 31 is output. When searching, information of 20:30 and 40:50 is recorded, and a branch table from 31 to 39 is created. Also follow the branches 31, 36, 33: 3
While setting the branch destinations of 5 and 32 in the branch table, the processed mark is recorded in each branch. When outputting the intermediate code for judgment, it is necessary to confirm that this output mark is not recorded.

【0054】図11は、本発明によって図9の原始プロ
グラムが変換された中間コードの例である。
FIG. 11 is an example of intermediate code obtained by converting the source program of FIG. 9 according to the present invention.

【0055】ここで11−1は(R)の後ろのラベルの
うち、R番目のラベルに分岐することを意味するテーブ
ル分岐の中間コードである。
Here, 11-1 is an intermediate code of the table branch which means to branch to the Rth label among the labels after (R).

【0056】図11をみると、判定の順序を変えずに、
分岐テーブルによる分岐の中間コードを出力することが
可能になり、31、32、33:35、36の判定の代
わりに分岐テーブルによる分岐の中間コード一つになり
高速化がはかれたことが分かる。
Looking at FIG. 11, without changing the order of determination,
It becomes possible to output the intermediate code of the branch by the branch table, and it can be seen that there is one intermediate code of the branch by the branch table instead of the judgment of 31, 32, 33: 35, 36, and the speedup is achieved. .

【0057】[0057]

【発明の効果】以上説明したように、本発明によれば、
範囲指定が可能なCASE構文の実現に当たって、判定
する命令の出力順序を変えずに、効率的な命令の出力が
可能になり、高速分岐によりオブジェクトの実行速度を
高めることが可能になる。
As described above, according to the present invention,
When the CASE syntax capable of specifying a range is realized, efficient instruction output can be performed without changing the output order of the instructions to be determined, and high-speed branching can increase the object execution speed.

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

【図1】本発明の一実施例を示す構成図。FIG. 1 is a configuration diagram showing an embodiment of the present invention.

【図2】本発明が適用されたコンパイラ全体の構造を示
す図。
FIG. 2 is a diagram showing a structure of an entire compiler to which the present invention is applied.

【図3】本発明の一実施例を説明するためのFortr
anの原始プログラム。
FIG. 3 is a Fortr for explaining an embodiment of the present invention.
An primitive program.

【図4】従来技術によって図3のプログラムから生成さ
れた中間コードの例。
4 is an example of intermediate code generated from the program of FIG. 3 according to the prior art.

【図5】図3の原始プログラムを例に、標準的な構文解
析の理論と従来技術と本発明によるCASE文の情報の
差異を説明する図。
FIG. 5 is a diagram for explaining the difference between the standard syntax analysis theory and the information of the CASE statement according to the present invention and the present invention, using the source program of FIG. 3 as an example.

【図6】次期判定分岐処理決定部11の処理を説明する
図。
FIG. 6 is a diagram illustrating a process of a next decision branch process decision unit 11;

【図7】図5のCASE情報に対応する本発明を適用し
たときに得るCASE情報の図。
FIG. 7 is a diagram of CASE information obtained when the present invention corresponding to the CASE information of FIG. 5 is applied.

【図8】図3の原始プログラムに対して本発明を適用し
たときに得る中間コード。
8 is an intermediate code obtained when the present invention is applied to the source program of FIG.

【図9】第2の実施例を説明するFortranの原始
プログラム。
FIG. 9 is a Fortran original program for explaining a second embodiment.

【図10】次期判定処理決定部11によって図9のFo
rtranの原始プログラムから得たCASE情報の
図。
FIG. 10: Fo of FIG. 9 by the next determination process determination unit 11
Figure of CASE information obtained from the rtran source program.

【図11】本発明によって図9の原始プログラムが変換
された中間コード。
11 is an intermediate code obtained by converting the source program of FIG. 9 according to the present invention.

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

図1において 1 CASE情報処理部 11 次期判定分岐処理決定部 12 判定分岐処理生成部 121 分岐テーブル生成判定部 122 テーブル分岐中間コード生成部 13 中間コード 14 中間コード 図2において 1 CASE構造処理部 13 中間コード 14 中間コード 21 ソース プログラム 22 構文解析部 23 意味解析部 24 最適化処理部 25 コード生成部 26 中間コード 27 オブジェクト コード In FIG. 1, 1 CASE information processing unit 11 next decision branch process determination unit 12 decision branch process generation unit 121 branch table generation determination unit 122 table branch intermediate code generation unit 13 intermediate code 14 intermediate code In FIG. 2, 1 CASE structure processing unit 13 intermediate Code 14 Intermediate code 21 Source program 22 Syntax analysis unit 23 Semantic analysis unit 24 Optimization processing unit 25 Code generation unit 26 Intermediate code 27 Object code

Claims (2)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 範囲指定が可能なCASE構造の使用を
サポートする言語で記述された原始プログラムのコンパ
イラを有する計算機システムにおけるCASE構造の処
理方式において、 CASE文が現れるたびに、該CASE文で指定された
値をSELECT CASEブロックごとに記憶してお
いて、すでに記憶してある値と大小関係を比較すること
により、前記ブロックが実行されないときの最適な分岐
先を決定する次期判定分岐処理決定部と、 前記CASE構造にかかる式を評価した結果に対して判
定し、真ならば対応するCASEブロックへ、偽ならば
前記次期判定分岐処理決定部で得た最適な分岐先へ分岐
する中間コードを生成し、各CASE文に該当する処理
ブロックへ分岐するテキストを順次出力する判定分岐処
理生成部と、 を有するCASE構造処理部から構成されることを特徴
とする範囲指定が可能なCASE構造の処理方式。
1. In a CASE structure processing method in a computer system having a compiler for a source program written in a language that supports the use of a range-specifiable CASE structure, a CASE statement is specified each time the CASE statement appears. The determined value for each SELECT CASE block, and compares the value stored with the stored value to determine the optimum branch destination when the block is not executed. Then, if the result of evaluating the expression related to the CASE structure is determined, if it is true, the intermediate code that branches to the corresponding CASE block, and if false, branches to the optimum branch destination obtained by the next decision branch processing decision unit is selected. Generate and process corresponding to each CASE sentence
A processing method of a CASE structure capable of specifying a range, which comprises a CASE structure processing unit having a judgment branching processing generation unit that sequentially outputs a text branched to a block .
【請求項2】 前記判定分岐処理生成部が、前記CAS
E文で指定された範囲指定と後に現れた範囲指定との間
の値を持つ前記の範囲指定以降に現れる全ての判定に対
し、分岐テーブルを用いる処理と、分岐テーブルを用い
ない処理とでどちらが高速な処理が可能であるか判断す
る分岐テーブル生成判定部と、 前記分岐テーブル生成判定部で分岐テーブルを用いた方
が高速な処理が可能であると判断されたCASE文で指
定された範囲指定と、次に現れた範囲指定との間の値を
持つ前記範囲指定以降に現れる全ての判定に対し、分岐
テーブルによる分岐を行う中間コードを生成するテーブ
ル分岐中間コード生成部と、を有することを特徴とする
請求項1記載の範囲指定が可能なCASE構造の処理方
式。
2. The decision branch process generation unit is configured to execute the CAS.
Which of the processing using the branch table and the processing not using the branch table for all the judgments that occur after the range specification having a value between the range specification specified by the E statement and the range specification that appears later is performed. A branch table generation determination unit that determines whether high-speed processing is possible, and a range specification specified by a CASE statement that determines that the branch table generation determination unit can use the branch table for higher-speed processing. And a table branch intermediate code generation unit that generates an intermediate code for branching by a branch table for all judgments that occur after the range specification having a value between the range specification that appears next. The CASE structure processing method capable of specifying a range according to claim 1.
JP4352410A 1992-12-11 1992-12-11 CASE structure processing method that allows range specification Expired - Fee Related JP2500515B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP4352410A JP2500515B2 (en) 1992-12-11 1992-12-11 CASE structure processing method that allows range specification

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP4352410A JP2500515B2 (en) 1992-12-11 1992-12-11 CASE structure processing method that allows range specification

Publications (2)

Publication Number Publication Date
JPH06180651A JPH06180651A (en) 1994-06-28
JP2500515B2 true JP2500515B2 (en) 1996-05-29

Family

ID=18423887

Family Applications (1)

Application Number Title Priority Date Filing Date
JP4352410A Expired - Fee Related JP2500515B2 (en) 1992-12-11 1992-12-11 CASE structure processing method that allows range specification

Country Status (1)

Country Link
JP (1) JP2500515B2 (en)

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS5960640A (en) * 1982-09-30 1984-04-06 Fujitsu Ltd Method for processing compiler
JP2585793B2 (en) * 1989-06-01 1997-02-26 富士通株式会社 Compiler system

Also Published As

Publication number Publication date
JPH06180651A (en) 1994-06-28

Similar Documents

Publication Publication Date Title
US6243864B1 (en) Compiler for optimizing memory instruction sequences by marking instructions not having multiple memory address paths
US6574644B2 (en) Automatic capturing of hyperlink specifications for multimedia documents
US7069501B2 (en) Structured document processing system and structured document processing method
US5606697A (en) Compiler system for language processing program
US20090249307A1 (en) Program analysis apparatus, program analysis method, and program storage medium
US20080320031A1 (en) Method and device for analyzing an expression to evaluate
JPH05127961A (en) Multi-stage document-format converting method and data processing system therefor
JP2008059279A (en) Technique for optimizing character string output processing
JPH06103463B2 (en) Code generation method
JPH07219758A (en) Specification generation method
US20030159128A1 (en) Generating instructions for drawing a flowchart
US5822592A (en) Method and system for determining source code location
RU2115159C1 (en) Method and device for checking use of record fields during compilation
JP2500515B2 (en) CASE structure processing method that allows range specification
JP2003177924A (en) Device and method for program conversion, and program realizing program conversion device
EP1121641A1 (en) Apparatus and method for program optimizing
JPH11272503A (en) Device for automatically generating test data of program
JPH08328904A (en) Program development supporting device
JPH10214265A (en) Device for processing structured document
JP3637606B2 (en) Data processing device
JP3417960B2 (en) Sentence correction support method and device
WO1997007452A1 (en) Programmable compiler
Cosgrove et al. LFP User's Manual (Lincoln FORTRAN Preprocessor): Version 02.01 for MODCOMP Systems
CN116755700A (en) Data collection method, device and medium
JPH0793144A (en) Program analyzer

Legal Events

Date Code Title Description
LAPS Cancellation because of no payment of annual fees