JPH0635712A - Automatic in-line expansion processing system for procedure in fortran program - Google Patents

Automatic in-line expansion processing system for procedure in fortran program

Info

Publication number
JPH0635712A
JPH0635712A JP19350792A JP19350792A JPH0635712A JP H0635712 A JPH0635712 A JP H0635712A JP 19350792 A JP19350792 A JP 19350792A JP 19350792 A JP19350792 A JP 19350792A JP H0635712 A JPH0635712 A JP H0635712A
Authority
JP
Japan
Prior art keywords
statement
function
sentence
name
statement function
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.)
Withdrawn
Application number
JP19350792A
Other languages
Japanese (ja)
Inventor
Kenji Sato
研二 佐藤
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 Solution Innovators Ltd
Original Assignee
NEC Solution Innovators 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 NEC Solution Innovators Ltd filed Critical NEC Solution Innovators Ltd
Priority to JP19350792A priority Critical patent/JPH0635712A/en
Publication of JPH0635712A publication Critical patent/JPH0635712A/en
Withdrawn legal-status Critical Current

Links

Abstract

PURPOSE:To attain the in-line expansion of many procedures by using an outside function quoted in a sentential function definition sentence as the object of the in-line expansion. CONSTITUTION:A sentential function processing part 12 equipped with a sentential function expansion processing control means 121 which controls the processing of expanding a sentential function to a sentential function quoting part, sentential function definition sentence analyzing means 122 which prepares information for expanding the sentential function to the sentential function quoting part, sentential function quoting part analyzing means 123, and sentential function expanding means 124 which operates the processing of expanding the sentential function to the sentential function quoting part based on the prepared information, is added to an in-line expansion processing part 11 being the function of an FORTRAN compiler. Thus, the sentential function definition sentence can be expanded to a source program as the execution sentence, and the outside function quoted in the sentential function definition sentence can be used as the object of the in-line expansion of the procedure.

Description

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

【0001】[0001]

【産業上の利用分野】本発明はFORTRANコンパイ
ラのプリプロセッサとしてソースレベルのインライン展
開を行なうFORTRANプログラムにおける手続きの
自動インライン展開処理方式に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to an automatic inline expansion processing system for procedures in a FORTRAN program which performs source level inline expansion as a preprocessor of a FORTRAN compiler.

【0002】[0002]

【従来の技術】従来、FORTRANコンパイラが保有
する手続きの自動インライン展開処理においては、ソー
スレベルでの実行文中の手続きのみが手続きのインライ
ン展開の対象であるため、文関数定義文は対象となら
ず、従って文関数定義文で引用している外部関数は手続
きのインライン展開の対象にはなっていない。そのた
め、外部関数についてインライン展開されたソースプロ
グラムが生成されないようになっている。
2. Description of the Related Art Conventionally, in the automatic inline expansion processing of a procedure held by the FORTRAN compiler, only the procedure in the execution statement at the source level is the target of the inline expansion of the procedure, so the statement function definition statement is not the object. , Therefore, the external function quoted in the statement function definition statement is not the target of inline expansion of the procedure. Therefore, the inline expanded source program is not generated for external functions.

【0003】[0003]

【発明が解決しようとする課題】上述した従来のFOR
TRANプログラムにおける手続きの自動インライン展
開処理方式は、文関数内で引用している外部関数が手続
きのインライン展開の対象にならず、コンパイラでの最
適化が個々の手続きに対してしか行なわれないという欠
点がある。
DISCLOSURE OF THE INVENTION The above-mentioned conventional FOR
According to the automatic inline expansion processing method for procedures in TRAN programs, the external function quoted in the statement function is not subject to inline expansion of the procedure, and optimization by the compiler is performed only for individual procedures. There are drawbacks.

【0004】本発明の目的は、上述の欠点を改善し、文
関数定義文で引用している外部関数をインライン展開の
対象とし、より多くの手続きのインライン展開を可能と
するFORTRANプログラムにおける手続きの自動イ
ンライン展開処理方式を提供することにある。
An object of the present invention is to improve the above-mentioned drawbacks, to target an external function quoted in a statement function definition statement for inline expansion, and to enable inline expansion of more procedures. It is to provide an automatic inline expansion processing method.

【0005】[0005]

【課題を解決するための手段】本発明のFORTRAN
プログラムにおける手続きの自動インライン展開処理方
式は、FORTRANコンパイラにプリプロセッサとし
てソースレベルのインライン展開を行う自動インライン
展開処理部と展開されたソースプログラムを入力として
翻訳を行う翻訳処理部とを備え、前記自動インライン展
開処理部にソースプログラム内の文関数を事前に展開す
るための文関数処理部と文関数が展開されたソースプロ
グラムを入力として手続きのインライン展開を行う手続
きインライン展開処理部とを備え、前記文関数処理部に
プログラム中で使用している名標および各々の型を名標
情報として作成し、文関数の展開処理を制御する文関数
展開処理制御手段と、文関数定義文を解析し、文関数
名、その仮引数および文関数の型などの文関数定義文情
報を作成する文関数定義文解析手段と、文関数引用部分
を解析し、引用している文関数ごとに文関数名とその実
引数などの文関数引用情報を作成する文関数引用部解析
手段と、文関数の引用があるごとに文関数引用情報と文
関数定義文情報を基に実引数および仮引数の名標および
文関数の型の整合性をとりながら、文関数を引用してい
る文の直後に文関数名と同じ型をもつ生成変数へ文関数
の式の評価結果を代入する代入文を挿入し、文関数引用
部分をその生成変数に置換した文を新たに生成し、もと
の文関数を引用している文を注釈文に置換するための処
理を行う文関数展開手段とを有し、文関数をソースレベ
ルで事前にインライン展開し、そのソースプログラムを
入力することで文関数内で引用している外部関数も手続
きのインライン展開の対象として扱うことにより構成さ
れる。
FORTRAN of the present invention
An automatic inline expansion processing method of a procedure in a program includes a FORTRAN compiler including an automatic inline expansion processing unit for performing source level inline expansion as a preprocessor and a translation processing unit for performing translation using the expanded source program as an input. The expansion processing unit is provided with a statement function processing unit for expanding the statement function in the source program in advance and a procedure inline expansion processing unit for performing inline expansion of the procedure by using the source program with the expanded statement function as input. The name function and each type used in the program in the function processing part are created as name information, and the statement function expansion processing control means for controlling the expansion processing of the statement function and the statement function definition statement are analyzed to A statement function that creates statement function definition statement information such as the function name, its formal parameters, and the statement function type There is a sentence function quoting part analysis means that analyzes the sentence function quotation part and the sentence function quotation information such as the sentence function name and its actual argument by analyzing the sentence function quotation part and the quotation of the sentence function. For each of the statement function reference information and the statement function definition statement information, the name of the actual function and the dummy argument and the type of the statement function are matched, and the statement function name is added immediately after the statement that cites the statement function. Insert an assignment statement that substitutes the evaluation result of a statement function expression into a created variable of the same type, create a new statement with the statement function reference part replaced with the created variable, and quote the original statement function. It has a statement function expansion unit that performs processing for replacing existing statements with comment statements, and the statement functions are quoted in the statement function by inline expansion in advance at the source level and inputting the source program. External functions are also treated as targets for inline expansion of procedures Constituted by the.

【0006】[0006]

【実施例】次に、本発明について図面を参照して説明す
る。
DESCRIPTION OF THE PREFERRED EMBODIMENTS Next, the present invention will be described with reference to the drawings.

【0007】図1は本発明の一実施例の構成図で、図
2,図3は図1の実施例の処理に用いられる各種のテー
ブルの構成図で、また図4はFORTRANプログラム
でもつ型情報の対応表を示す図である。図1の実施例は
コンパイラ制御部10にインライン展開処理部11と翻
訳処理部14とを有し、インライン展開処理部11は文
関数処理部12と手続きのインライン展開処理部13と
を有し、文関数処理部12は文関数展開処理制御部12
1,文関数定義文解析手段122,文関数引用部解析手
段123,および文関数展開手段124を有して構成さ
れる。
FIG. 1 is a block diagram of an embodiment of the present invention, FIGS. 2 and 3 are block diagrams of various tables used in the processing of the embodiment of FIG. 1, and FIG. 4 is a model of a FORTRAN program. It is a figure which shows the correspondence table of information. In the embodiment of FIG. 1, the compiler control unit 10 has an inline expansion processing unit 11 and a translation processing unit 14, and the inline expansion processing unit 11 has a statement function processing unit 12 and a procedure inline expansion processing unit 13. The statement function processing unit 12 is a statement function expansion processing control unit 12
1, statement function definition statement analysis means 122, statement function reference part analysis means 123, and statement function expansion means 124.

【0008】文関数処理部12は文関数定義文内で引用
している外部関数をインライン展開の対象とさせるため
に、インライン展開処理部11から呼び出され、文関数
定義文を文関数の引用部分へ実行文としてソース展開す
る。即ち、文関数展開処理制御手段121は入力された
ソースプログラムを解析していき、プログラム中に現れ
た関数名、共通ブロック名および変数名などの名標と名
標の型などとの名標情報を図2(a)に示す名標テーブ
ル21の2番目の要素欄から名標フィールド211、型
フィールド212に順次登録していく。型フィールド2
12に登録する値は図4の型対応表から求める。解析が
終了したら名標テーブル21に登録した名標の個数を名
標テーブル21の1番目の要素欄の名標フィールド21
1に登録する。次に文関数展開処理手段121は、文関
数定義文を解析するために文関数定義文解析手段122
を呼出す。
The statement function processing unit 12 is called from the inline expansion processing unit 11 in order to make the external function quoted in the statement function definition statement an object of inline expansion, and the statement function definition statement is the statement function reference section. The source is expanded as an executable statement. That is, the statement function expansion processing control means 121 analyzes the input source program, and the name information such as the name of the function name, common block name, variable name, etc. appearing in the program and the type of the name tag. Are sequentially registered in the name field 211 and the type field 212 from the second element column of the name table 21 shown in FIG. Type field 2
The value registered in 12 is obtained from the type correspondence table of FIG. When the analysis is completed, the number of the registered names in the name table 21 is changed to the name field 21 in the first element column of the name table 21.
Register to 1. Next, the statement function expansion processing means 121 analyzes the statement function definition statement by the statement function definition analysis means 122.
Call.

【0009】文関数定義文解析手段122は文関数定義
文を順次解析していく。そして文関数定義文に対して図
2(b)に示す文関数定義文テーブル22を作成し、文
関数名とその型などの情報とをそれぞれ文関数定義文テ
ーブル22の文関数名フィールド221と型フィールド
222とに登録する。また、文関数定義文に仮引数があ
る場合は図2(c)に示す文関数定義文引数テーブル2
3を作成する。そして仮引数名に2桁の通し番号を付加
した最大文字数を越えず、かつ名標テーブル21に登録
した名標と一致していない名標を作りだし、その名標を
引数の順番に文関数定義文引数テーブル23の名標フィ
ールド231に、もとの仮引数の型を型フィールド23
2に登録していく。またこの作りだした名標を図3
(d)に示す型宣言テーブル7の型に対応する名標フィ
ールド272に登録する。登録が終了したら文関数定義
文引数テーブル23のアドレスを文関数定義文テーブル
22の引数チェーンフィールド225にセットし、引数
の個数を引数個数フィールド224にセットする。解析
が終了したら文関数定義文テーブル22の生成変数フィ
ールド223に生成変数を登録するために、文関数定義
文テーブル22の文関数名フィールド221に登録した
文関数名に、2桁の通し番号を付加した最大文字数を越
えず、かつ名標テーブル21に登録している名前と一致
していない名標を作りだし、文関数定義テーブル22の
生成変数フィールド223に登録する。またこの作りだ
した名標を型宣言テーブル27の型に対応する名標フィ
ールド272に登録する。以上の処理を文関数定義文を
検出する度に繰返す。文関数定義文全てに対して処理を
終了したら文関数展開処理制御手段121に制御を戻
す。
The statement function definition statement analysis means 122 sequentially analyzes the statement function definition statements. Then, the statement function definition statement table 22 shown in FIG. 2B is created for the statement function definition statement, and the statement function name and information such as its type are respectively stored in the statement function name field 221 of the statement function definition statement table 22. Register with the type field 222. If the statement function definition statement has a dummy argument, the statement function definition statement argument table 2 shown in FIG.
Create 3. Then, a name that does not exceed the maximum number of characters obtained by adding a 2-digit serial number to the dummy argument name and that does not match the name registered in the name table 21 is created. In the name field 231 of the argument table 23, the original dummy argument type is set to the type field 23.
Register in 2. In addition, the nameplate that was created is shown in Figure 3.
It is registered in the name tag field 272 corresponding to the type of the type declaration table 7 shown in (d). When the registration is completed, the address of the statement function definition statement argument table 23 is set in the argument chain field 225 of the statement function definition statement table 22, and the number of arguments is set in the argument number field 224. When the analysis is completed, a two-digit serial number is added to the statement function name registered in the statement function name field 221 of the statement function definition statement table 22 in order to register the created variable in the creation variable field 223 of the statement function definition statement table 22. A name tag which does not exceed the maximum number of characters and does not match the name registered in the name table 21 is created and registered in the generated variable field 223 of the statement function definition table 22. The created name tag is registered in the name tag field 272 corresponding to the type of the type declaration table 27. The above processing is repeated every time a statement function definition statement is detected. When the processing is completed for all the statement function definition statements, the control is returned to the statement function expansion processing control means 121.

【0010】文関数展開処理制御手段121は次に文関
数引用部解析手段123を呼出す。文関数引用部解析手
段123は文関数の引用部を検索していく。文関数の引
用を検出すると文関数を引用している文の行番号を図3
(a)に示す文関数引用文テーブル24の行番号フィー
ルド241に登録し、引用している実行文のイメージを
引用文フィールド243に登録する。次に文関数情報を
登録するため、図3(b)に示す文関数引用テーブル2
5を作成し、この文関数引用テーブル25のアドレスを
文関数引用文テーブル24の文関数引用チェーンフィー
ルド242に登録する。そして、文関数名を文関数引用
文テーブル25の文関数名フィールド251に登録して
いく。文関数に引数がある場合は図3(c)に示す文関
数引用引数テーブル26を作成する。そして引数の順番
に引数の名標を文関数引用引数テーブル26の名標フィ
ールド261に登録していく。登録が終了したら文関数
引用引数テーブル26のアドレスと登録した引数の個数
とをそれぞれ文関数引用テーブル25の引数チェーンフ
ィールド253と引数個数フィールド252とに登録す
る。文関数の引用が二つ以上ある場合は、さらに文関数
引用テーブル25を作成し、この文関数引用テーブル2
5のアドレスを文関数引用テーブル25のNEXTチェ
ーンフィールド254に登録する。文関数引用部解析手
段123が終了したら文関数展開処理制御手段121に
制御を戻す。文関数展開処理制御手段121は次に、文
関数の展開処理を行うために文関数展開手段124を呼
出す。
The statement function expansion processing control means 121 next calls the statement function reference part analysis means 123. The sentence function quotation portion analysis unit 123 searches for the quotation portion of the sentence function. When the citation of a statement function is detected, the line number of the statement that cites the statement function is shown in Fig. 3.
The line number field 241 of the sentence function reference sentence table 24 shown in (a) is registered, and the image of the quoted execution sentence is registered in the reference sentence field 243. Next, in order to register the sentence function information, the sentence function reference table 2 shown in FIG.
5 is created and the address of the sentence function reference table 25 is registered in the sentence function reference chain field 242 of the statement function reference sentence table 24. Then, the sentence function name is registered in the sentence function name field 251 of the sentence function reference sentence table 25. If the statement function has arguments, the statement function reference argument table 26 shown in FIG. 3C is created. Then, the names of the arguments are registered in the name field 261 of the sentence function reference argument table 26 in the order of the arguments. When the registration is completed, the address of the statement function reference argument table 26 and the number of registered arguments are registered in the argument chain field 253 and the argument number field 252 of the statement function reference table 25, respectively. When there are two or more statement function references, a statement function reference table 25 is further created, and this statement function reference table 2 is created.
The address 5 is registered in the NEXT chain field 254 of the sentence function reference table 25. When the statement function quoting part analysis means 123 is completed, control is returned to the statement function expansion processing control means 121. The statement function expansion processing control means 121 next calls the statement function expansion means 124 to perform the expansion processing of the statement function.

【0011】文関数展開手段124は文関数を展開した
文を、動的に確保した生成文領域に登録しておき、文関
数を引用している文の直後に登録しておいた生成文を一
括して挿入する処理を行う。挿入が終了したら文関数を
引用している文を注釈化する。この処理を行う際には行
番号の整合性をとるため文関数引用文テーブル24の行
番号フィールド241をキーに下から(行番号の降順)
行っていく。処理としては文関数定義文テーブル22と
文関数引用文テーブル24と文関数引用テーブル25と
を付き合わせ、対応する文関数定義文引数テーブル23
と文関数引用引数テーブル26とを使用し、文関数定義
文内での仮引数から作りだした名標へ文関数引用時の実
引数を代入する代入文の作成を行う。この文を生成文領
域に登録する。次に文関数定義文の文関数名への代入を
文関数定義文テーブル22の生成変数フィールド223
に登録した生成変数へ代入する代入文を作成する。この
文も生成文領域に登録する。次に文関数引用部を上記で
代入した生成変数で置換えた代入文を作成する。この文
の作成には文関数引用文テーブル24の文関数引用イメ
ージフィールド243に対応する文関数引用テーブル2
5の文関数名フィールド251と文関数定義文テーブル
22の文関数名フィールド221と生成変数フィールド
223とを使用して、文関数を検出すると文関数を生成
変数で置換え、それ以外は順次生成文領域に登録してい
く。これを文関数引用イメージフィールド243に登録
されている文の最後まで繰返す。この処理が終了した
ら、生成文領域に登録している生成文をこの文関数引用
文の後に順次挿入していく。このようにして文関数の引
用している文を、文関数を展開した生成変数への代入文
とその代入した生成変数を引用する文とに変換を行う。
変換が終了したら文関数引用文を注釈に換える。文関数
引用文テーブル24に登録されている要素全ての変換処
理が終了したら、次に以上の処理により生成した名標に
ついての型と名標情報とを持つ型宣言テーブル27をも
とに型宣言文を作成し、ソースプログラム中の最後の型
宣言文の後に挿入する。これにより文関数の展開処理が
終了し、文関数展開処理制御手段121に制御を戻す。
The statement function expanding means 124 registers the statement in which the statement function is expanded in a dynamically prepared generated statement area, and the created statement registered immediately after the statement in which the statement function is cited is registered. Perform the process to insert all at once. When the insertion is complete, annotate the statement that references the statement function. When performing this process, in order to maintain consistency of the line numbers, the line number field 241 of the sentence function reference sentence table 24 is used as a key from the bottom (line number descending order).
I will go. As the processing, the statement function definition statement table 22, the statement function reference statement table 24, and the statement function reference table 25 are associated with each other, and the corresponding statement function definition statement argument table 23.
And the statement function quotation argument table 26 are used to create an assignment statement for substituting the actual argument at the time of the statement function reference into the name tag created from the dummy argument in the statement function definition statement. This sentence is registered in the generated sentence area. Next, the assignment of the statement function definition statement to the statement function name is performed by the generation variable field 223 of the statement function definition statement table 22.
Create an assignment statement to assign to the generated variable registered in. This sentence is also registered in the generated sentence area. Next, an assignment statement is created by replacing the statement function reference part with the generated variable assigned above. To create this sentence, the sentence function reference table 2 corresponding to the sentence function reference image field 243 of the statement function reference table 24.
When the statement function is detected by using the statement function name field 251 of 5 and the statement function name field 221 and the created variable field 223 of the statement function definition statement table 22, the created statement function is replaced with the created variable, and the others are sequentially created statements. Register in the area. This is repeated until the end of the sentence registered in the sentence function reference image field 243. When this processing is completed, the generated sentences registered in the generated sentence area are sequentially inserted after this sentence function reference sentence. In this way, the statement quoted by the statement function is converted into an assignment statement for the generated variable in which the statement function is expanded and a statement for quoting the assigned generated variable.
When the conversion is complete, replace the sentence function quote with a comment. When the conversion processing of all the elements registered in the statement function reference sentence table 24 is completed, the type declaration is made based on the type declaration table 27 having the type and the name tag information about the name tag generated by the above processing. Create a statement and insert it after the last type declaration statement in your source program. As a result, the sentence function expansion processing ends, and control is returned to the statement function expansion processing control means 121.

【0012】文関数展開処理制御手段121は文関数を
実行文にソース展開したソースプログラムを入力された
ソースプログラム情報として手続きのインライン展開処
理部13に制御を戻す。これにより最初に入力した際の
ソースプログラム中に文関数内で引用している外部関数
がある場合は、文関数が実行文としてソース展開されて
いるため、この外部関数は手続きのインライン展開対象
として扱われることになる。
The statement function expansion processing control means 121 returns the control to the inline expansion processing section 13 of the procedure as the source program information of the source program obtained by source expansion of the statement function into the execution statement. As a result, if there is an external function referenced in the statement function in the source program when it is first input, this external function is subject to inline expansion of the procedure because the statement function is source-expanded as an executable statement. Will be treated.

【0013】次に、このように構成された本実施例の動
作について、図5に示すソースプログラムを処理する場
合を例にして説明する。図5に示すようなソースプログ
ラムが入力されると、インライン展開処理部11は文関
数を展開させるため文関数展開処理部12を呼出す。文
関数展開処理部12は文関数の展開処理を制御するため
文関数展開処理制御手段121を呼び出す。
Next, the operation of the present embodiment thus constructed will be described by taking the case of processing the source program shown in FIG. 5 as an example. When a source program as shown in FIG. 5 is input, the inline expansion processing section 11 calls the statement function expansion processing section 12 to expand the statement function. The statement function expansion processing unit 12 calls the statement function expansion processing control means 121 to control the expansion processing of the statement function.

【0014】文関数展開処理制御手段121は入力され
たソースプログラムを解析していき、プログラム中で現
れた関数名、共通ブロック名および変数名などの名標お
よびその名標の型などの情報を名標テーブル21の2番
目の要素欄から名標フィールド211に名標を、型フィ
ールド212には図4の型対応表から名標の対応する型
の値を抽出して順次登録する。解析が終了したら名標テ
ーブル21に登録した名標の個数(本例の場合30個と
する)を名標テーブル21の1番目の要素欄に登録す
る。次に文関数定義文を解析するために文関数定義文解
析手段122を呼出す。
The statement function expansion processing control means 121 analyzes the input source program and obtains information such as function names, common block names, variable names and other names appearing in the program and the type of the names. The name tag is extracted from the second element column of the name table 21 into the name field 211, and the type value corresponding to the name is extracted from the type correspondence table of FIG. When the analysis is completed, the number of names (30 in this example) registered in the name table 21 is registered in the first element column of the name table 21. Next, the statement function definition statement analysis means 122 is called to analyze the statement function definition statement.

【0015】文関数定義文解析手段122は引用対象の
文関数定義文に対し、文関数定義文テーブル22の文関
数名フィールド221に文関数名SFUNを、その文関
数の型に応じた値を名標テーブル21を検索し、値2を
型フィールド222に登録する。また文関数定義文に仮
引数X,Yがあるため文関数定義文引数テーブル23を
作成する。最初に名標Xに通し番号01を付加した名標
を作成し、この名標と一致する名標があるか否かを名標
テーブル21を検索していく。一致する名標がないので
この名標01を文関数定義引数テーブル23の名標フィ
ールド231に登録する。仮引数Xの型を名標X01は
引き継ぐので仮引数Xの型の値を名標テーブル21から
取り出し、型フィールド232に登録する。またこの名
標X01の型の値が2であるので型宣言テーブル27の
型フィールドの値が2に対応する名標フィールド272
にX01を登録する。仮引数Yについても同様な処理を
行う。そしてこの文関数定義引数テーブル23のアドレ
スを文関数定義文テーブル22の引数チェーンフィール
ド225にセットし、引数の個数である2を引数個数フ
ィールド224にセットする。解析が終了したら文関数
定義テーブル22の生成変数フィールド223に生成変
数を登録するために文関数定義テーブル22の文関数名
フィールド221に登録した文関数名に通し番号01を
付加した名標SFUN01を作りだし、その名標が名標
テーブル21に登録してる名前と一致していないかを検
索する。同一の名前がないのでSFUN01を、文関数
定義文テーブル22の生成変数フィールド223に登録
する。また型宣言テーブル27の型フィールド271の
値が2に対応する名標フィールド272に追加登録す
る。生成変数の登録が終了したので文関数展開処理制御
手段121に制御を戻す。文関数展開処理制御手段12
1は次に文関数引用部解析手段123を呼出す。
The statement function definition statement analysis unit 122 sets the statement function name SFUN in the statement function name field 221 of the statement function definition statement table 22 for the statement function definition statement to be quoted, and sets a value corresponding to the type of the statement function. The name table 21 is searched, and the value 2 is registered in the type field 222. Since the statement function definition statement has dummy arguments X and Y, the statement function definition statement argument table 23 is created. First, a name mark in which the serial number 01 is added to the name mark X is created, and the name mark table 21 is searched for whether there is a name mark matching this name mark. Since there is no matching name tag, this name tag 01 is registered in the name tag field 231 of the statement function definition argument table 23. Since the name X01 takes over the type of the dummy argument X, the value of the type of the dummy argument X is fetched from the name table 21 and registered in the type field 232. Since the value of the type of the name tag X01 is 2, the name field 272 corresponding to the value of the type field of the type declaration table 27 is 2.
Register X01 in. Similar processing is performed for the dummy argument Y. Then, the address of the statement function definition argument table 23 is set in the argument chain field 225 of the statement function definition statement table 22, and 2 which is the number of arguments is set in the argument number field 224. When the analysis is completed, a name label SFUN01 is created by adding the serial number 01 to the statement function name registered in the statement function name field 221 of the statement function definition table 22 in order to register the created variable in the created variable field 223 of the statement function definition table 22. Then, it is searched whether or not the name tag matches the name registered in the name tag table 21. Since there is no same name, SFUN01 is registered in the generated variable field 223 of the statement function definition statement table 22. Further, the value of the type field 271 of the type declaration table 27 is additionally registered in the name tag field 272 corresponding to 2. Since the registration of the generated variable is completed, the control is returned to the statement function expansion processing control means 121. Statement function expansion processing control means 12
1 then calls the sentence function reference part analysis means 123.

【0016】文関数引用部解析手段123は文関数の引
用部を検索していく。行番号200で文関数SFUNの
引用を検出し、文関数引用文テーブル24の文関数を引
用している文の行番号200を行番号フィールド241
に、文関数引用テーブル25の文関数名フィールド25
1に文関数名SFUNを登録する。また文関数SFUN
の引用時の引数としてAとBとの二つを使用しているの
で、その引数の個数2を文関数引用テーブル25の引数
個数フィールド252に登録する。つぎに引数に関する
情報を作成するため引数の個数分の文関数引用引数テー
ブル26を作成し、引数の順番にA,Bを名標フィール
ド261に登録する。そして文関数引用引数テーブル2
6のアドレスを文関数引用テーブル25の引数チェーン
フィールド253に登録する。この文関数引用テーブル
25のNEXTチェーンフィールドは初期値としてNU
LLアドレスにしている。文関数の引用側の処理が終了
したので文関数展開処理制御手段121に制御を戻す。
文関数展開処理制御手段121は次に文関数展開手段1
24を呼び出す。
The sentence function quotation portion analysis means 123 searches for the quotation portion of the sentence function. The line number 200 detects the citation of the sentence function SFUN, and the line number 200 of the sentence that cites the sentence function in the sentence function reference sentence table 24 is displayed in the line number field 241.
In the sentence function name table 25 of the sentence function reference table 25.
The statement function name SFUN is registered in 1. Also, the statement function SFUN
Since the two arguments A and B are used when quoting, the number of arguments 2 is registered in the argument number field 252 of the statement function reference table 25. Next, in order to create information about the arguments, the statement function reference arguments table 26 for the number of arguments is created, and A and B are registered in the name field 261 in the order of the arguments. And sentence function reference argument table 2
The address No. 6 is registered in the argument chain field 253 of the sentence function reference table 25. The NEXT chain field of this sentence function reference table 25 is NU as an initial value.
LL address is used. Since the processing on the quote side of the statement function is completed, control is returned to the statement function expansion processing control means 121.
The statement function expansion processing control means 121 then proceeds to the statement function expansion means 1
Call 24.

【0017】文関数展開手段124は文関数定義テーブ
ル22と文関数定義引数テーブル23と文関数引用文テ
ーブル24と文関数引用テーブル25と文関数引用引数
テーブル26と付き合わせ、文関数定義文内での仮引数
へ文関数引用時の実引数を代入する代入文の作成を行
う。
The statement function expansion means 124 matches the statement function definition table 22, the statement function definition argument table 23, the statement function reference statement table 24, the statement function reference table 25, and the statement function reference argument table 26, and within the statement function definition statement. Create an assignment statement that substitutes the actual argument when the statement function is quoted to the formal argument in.

【0018】文関数展開手段124は文関数引用テーブ
ル25の文関数名フィールド251のSFUNと一致す
る名前を文関数定義テーブル22と文関数名フィールド
221から検索していく。一致する名前SFUNが検出
されると、仮引数の名標へ実引数の名標を代入する代入
文に変更するため、引数の対応を調査する。名標X01
に対応する名標はAであり、名標Y01に対応する名標
はBとなっている。従って、 X01=A Y01=B のような代入文を作成し生成文領域に登録する。次に、 SFUN01=UFUN1(Y01)*10*UFUN2(X01) のように文関数定義文から生成変数への代入文を仮引数
の引用部分を仮引数から作りだした名標で置き換えて生
成した文を生成文領域に追加登録する。次に、 XYZ=SFUN01*10 のように生成変数で文関数引用部を置換えた文を作成し
生成文領域に追加登録する。ソースプログラム変更用の
実行文の作成が終了したので、従来の文関数引用部の実
行文を注釈化して、その次の行との間に生成文領域に登
録した文を挿入する。生成文領域からの文の挿入が終了
したので生成領域は初期化する。次に作成した生成変数
の型宣言文を型宣言テーブル27を使用して作成するた
め型宣言テーブル27を作成する。型フィールド271
の値2はINTEGERであり、これに対応する名標フ
ィールド272の内容はX01、SFUN01である。
また型フィールド271の値6はREALであり、これ
に対応する名標フィールド272の内容はY01である
ので、 INTEGER SFUN01,X01 REAL Y01 のような型宣言文を作成する。これを生成文領域に登録
する。この型宣言文を最後の型宣文の後ろに挿入するた
めソースプログラムを解析し、行番号20が最後の型宣
言文であるので行番号20の後ろに生成文領域に登録し
ている宣言文を挿入する。これで図6に示すようなソー
スプログラムを作成する。変換が全て終了すると文関数
展開処理制御手段121に制御を戻す。
The statement function expansion means 124 searches the statement function definition table 22 and the statement function name field 221 for a name that matches the SFUN of the statement function name field 251 of the statement function reference table 25. When the matching name SFUN is detected, the correspondence of the arguments is checked in order to change to the assignment statement for substituting the name of the actual argument for the name of the dummy argument. Name tag X01
The name tag corresponding to is A, and the name tag corresponding to name Y01 is B. Therefore, an assignment statement such as X01 = A Y01 = B is created and registered in the generated statement area. Next, a statement generated by replacing the quotation part of the dummy argument with the name tag created from the dummy argument for the assignment statement from the statement function definition statement to the generated variable, such as SFUN01 = UFUN1 (Y01) * 10 * UFUN2 (X01). Is additionally registered in the generated sentence area. Next, a sentence in which the sentence function reference part is replaced with a generated variable is created as in XYZ = SFUN01 * 10 and additionally registered in the generated sentence area. Since the creation of the execution statement for changing the source program is completed, the execution statement of the conventional statement function quotation part is annotated, and the statement registered in the generated statement area is inserted between it and the next line. Since the insertion of the sentence from the generated sentence area is completed, the generated area is initialized. Next, the type declaration table 27 is created in order to create the type declaration statement of the created variable using the type declaration table 27. Type field 271
2 is INTEGER, and the corresponding contents of the name tag field 272 are X01 and SFUN01.
Since the value 6 of the type field 271 is REAL and the content of the name tag field 272 corresponding thereto is Y01, a type declaration statement such as INTERGER SFUN01, X01 REAL Y01 is created. This is registered in the generated sentence area. The source program is analyzed to insert this type declaration statement after the last type declaration statement. Since line number 20 is the last type declaration statement, the declaration statement registered in the generated statement area after line number 20 Insert. This creates a source program as shown in FIG. When all the conversions are completed, the control is returned to the statement function expansion processing control means 121.

【0019】文関数展開処理制御手段121はこのソー
スプログラムをあたかも最初に入力したソースプログラ
ムであるかのようにしてインライン展開処理に制御を戻
す。このソースプログラムに入力することで、インライ
ン展開処理部11は最終的に図7に示すようなソースプ
ログラムを作成する。
The statement function expansion processing control means 121 returns control to the inline expansion processing as if the source program was the first input source program. By inputting to this source program, the inline expansion processing unit 11 finally creates a source program as shown in FIG.

【0020】[0020]

【発明の効果】以上説明したように本発明は、FORT
RANコンパイラのインライン展開処理に文関数を文関
数引用部へ展開するための情報を作成する文関数定義文
解析手段と文関数引用部解析手段と、作成された情報を
もとに文関数を文関数引用部へ展開する文関数展開手段
とを有する文関数処理部を設けて、文関数定義文を実行
文としてソースプログラムに展開させ、文関数定義文内
で引用している外部関数を手続きのインライン展開の対
象としたことにより、より多くの手続きのインライン展
開を可能とし、コンパイラの最適化の対象が広範囲に対
して行なわれるという効果がある。
As described above, the present invention is a FORT.
A statement function definition statement analyzing means and statement function quote part analyzing means for creating information for expanding a statement function into a statement function reference part in the inline expansion processing of the RAN compiler, and a statement function statement based on the created information. A statement function processing unit having a statement function expanding unit that expands to the function reference section is provided to expand the statement function definition statement into the source program as an execution statement, and the external function quoted in the statement function definition statement The target of inline expansion has the effect that more procedures can be expanded inline and the compiler is optimized for a wide range.

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

【図1】本発明の一実施例の構成図である。FIG. 1 is a configuration diagram of an embodiment of the present invention.

【図2】図1の実施例で使用する各種のテーブルの一部
および内容例を示す図である。
FIG. 2 is a diagram showing a part and an example of contents of various tables used in the embodiment of FIG.

【図3】図1の実施例で使用する各種のテーブルの図2
の他のテーブルおよび内容例を示す図である。
3 is a diagram of various tables used in the embodiment of FIG.
It is a figure which shows the other table and the example of content.

【図4】FORTRANプログラムでもつ型情報の対応
表を示す図である。
FIG. 4 is a diagram showing a correspondence table of type information held by a FORTRAN program.

【図5】図1の実施例の処理を説明するためのソースプ
ログラムの例を示す図である。
FIG. 5 is a diagram showing an example of a source program for explaining the processing of the embodiment of FIG.

【図6】図5のソースプログラムを図1の実施例の処理
によってインライン展開が可能の形式に変更したソース
プログラムを示す図である。
6 is a diagram showing a source program obtained by changing the source program of FIG. 5 into a format in which inline expansion is possible by the processing of the embodiment of FIG.

【図7】図5のソースプログラムを図1の実施例の処理
によって作成された最終的なインライン展開後のソース
プログラムを示す図である。
7 is a diagram showing a source program after the final in-line expansion of the source program of FIG. 5 created by the processing of the embodiment of FIG.

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

10 コンパイラ制御部 11 インライン展開処理部 12 文関数処理部 13 手続きのインライン展開処理部 14 翻訳処理部 121 文関数展開処理制御手段 122 文関数定義文解析手段 123 文関数引用部解析手段 124 文関数展開手段 Reference numeral 10 compiler control unit 11 inline expansion processing unit 12 statement function processing unit 13 procedure inline expansion processing unit 14 translation processing unit 121 statement function expansion processing control unit 122 statement function definition statement analysis unit 123 statement function reference analysis unit 124 statement function expansion means

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】 FORTRANコンパイラにプリプロセ
ッサとしてソースレベルのインライン展開を行う自動イ
ンライン展開処理部と展開されたソースプログラムを入
力として翻訳を行う翻訳処理部とを備え、前記自動イン
ライン展開処理部にソースプログラム内の文関数を事前
に展開するための文関数処理部と文関数が展開されたソ
ースプログラムを入力として手続きのインライン展開を
行う手続きインライン展開処理部とを備え、前記文関数
処理部にプログラム中で使用している名標および各々の
型を名標情報として作成し、文関数の展開処理を制御す
る文関数展開処理制御手段と、文関数定義文を解析し、
文関数名、その仮引数および文関数の型などの文関数定
義文情報を作成する文関数定義文解析手段と、文関数引
用部分を解析し、引用している文関数ごとに文関数名と
その実引数などの文関数引用情報を作成する文関数引用
部解析手段と、文関数の引用があるごとに文関数引用情
報と文関数定義文情報を基に実引数および仮引数の名標
および文関数の型の整合性をとりながら、文関数を引用
している文の直後に文関数名と同じ型をもつ生成変数へ
文関数の式の評価結果を代入する代入文を挿入し、文関
数引用部分をその生成変数に置換した文を新たに生成
し、もとの文関数を引用している文を注釈文に置換する
ための処理を行う文関数展開手段とを有し、文関数をソ
ースレベルで事前にインライン展開し、そのソースプロ
グラムを入力することで文関数内で引用している外部関
数も手続きのインライン展開の対象として扱うことを特
徴とするFORTRANプログラムにおける手続きの自
動インライン展開処理方式。
1. A FORTRAN compiler includes, as a preprocessor, an automatic inline expansion processing unit for performing source-level inline expansion and a translation processing unit for performing translation using the expanded source program as an input, and the automatic inline expansion processing unit is provided with the source program. A statement function processing unit for expanding the statement function in the sentence in advance and a procedure inline expansion processing unit for performing inline expansion of a procedure using the source program in which the statement function is expanded as an input, and the statement function processing unit Create the name tag and each type used in the name tag information, and analyze the statement function expansion processing control means for controlling the expansion processing of the statement function and the statement function definition statement,
A statement function definition statement analysis unit that creates statement function definition statement information such as statement function names, their formal parameters, and statement function types, and a statement function name for each statement function that is analyzed by analyzing the statement function reference part. The statement function reference part analysis means for creating the statement function reference information such as the actual argument, and the name and statement of the actual argument and the dummy argument based on the statement function reference information and the statement function definition statement information every time the statement function is referenced. Insert the assignment statement that assigns the evaluation result of the statement function expression to the generated variable that has the same type as the statement function name immediately after the statement that references the statement function while maintaining the consistency of the function type. A sentence function expanding unit that performs a process for newly generating a sentence in which a quoted portion is replaced with the generated variable and replacing a sentence that is quoting the original sentence function with a comment sentence is provided. You can inline in advance at the source level and enter the source program. Automatic inlining process scheme in procedure in FORTRAN program characterized by handled as an object of inlining external functions also procedures are cited in the text function.
JP19350792A 1992-07-21 1992-07-21 Automatic in-line expansion processing system for procedure in fortran program Withdrawn JPH0635712A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP19350792A JPH0635712A (en) 1992-07-21 1992-07-21 Automatic in-line expansion processing system for procedure in fortran program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP19350792A JPH0635712A (en) 1992-07-21 1992-07-21 Automatic in-line expansion processing system for procedure in fortran program

Publications (1)

Publication Number Publication Date
JPH0635712A true JPH0635712A (en) 1994-02-10

Family

ID=16309209

Family Applications (1)

Application Number Title Priority Date Filing Date
JP19350792A Withdrawn JPH0635712A (en) 1992-07-21 1992-07-21 Automatic in-line expansion processing system for procedure in fortran program

Country Status (1)

Country Link
JP (1) JPH0635712A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE19757602B4 (en) * 1997-01-14 2005-07-14 Pentax Corp. Scanning device with optical cascade scanning system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE19757602B4 (en) * 1997-01-14 2005-07-14 Pentax Corp. Scanning device with optical cascade scanning system

Similar Documents

Publication Publication Date Title
US5287444A (en) Message processing system
JPH0630066B2 (en) Table type language translation method
JPH0635712A (en) Automatic in-line expansion processing system for procedure in fortran program
JPH08194611A (en) Device for analyzing rang of influence caused by program correction
JPH0424767A (en) Machine translation system
JPH07160490A (en) Coding assistance device
JP3003459B2 (en) Program creation support device
JPH0833895B2 (en) Sentence generation processing method in machine translation system
JPH0752391B2 (en) Translation method of source program including multiple database descriptions
JP4399154B2 (en) Translation apparatus and translation program
JP3419483B2 (en) Natural language processing apparatus and method
JPH07182346A (en) Machine translation system
JPH06214777A (en) Method and device for developiig program
JPH0695890A (en) Name replacement system in compiler
JPH02178844A (en) Translation list output control system
JPH06242958A (en) Compilation system
KR950015127A (en) CHILL Separate Compilation Method
JP2000132405A (en) In-line expansion processing device and method
JPH06187370A (en) Document read assisting device
JPH04149640A (en) Precompiler
JPS63262726A (en) Translation processing system for designated program
JPH09198246A (en) Method for analyzing function calling status
JP2002032231A (en) Character code converting method
JPH0546373A (en) Flow chart generation processor
Räihä et al. Töölönkatu 11, SF-00100 Helsinki 10, Finland

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 19991005