JP2000132405A - In-line expansion processing device and method - Google Patents

In-line expansion processing device and method

Info

Publication number
JP2000132405A
JP2000132405A JP10301846A JP30184698A JP2000132405A JP 2000132405 A JP2000132405 A JP 2000132405A JP 10301846 A JP10301846 A JP 10301846A JP 30184698 A JP30184698 A JP 30184698A JP 2000132405 A JP2000132405 A JP 2000132405A
Authority
JP
Japan
Prior art keywords
function
library
object code
code
inline expansion
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
JP10301846A
Other languages
Japanese (ja)
Inventor
Yukihiro Kaneko
行洋 金子
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 IC Microcomputer Systems Co Ltd
Original Assignee
NEC IC Microcomputer Systems 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 NEC IC Microcomputer Systems Co Ltd filed Critical NEC IC Microcomputer Systems Co Ltd
Priority to JP10301846A priority Critical patent/JP2000132405A/en
Publication of JP2000132405A publication Critical patent/JP2000132405A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PROBLEM TO BE SOLVED: To increase the in-line expansion processing speed of a library function by reading the object code of a function out of a library and outputting the object code in place of a function call code to perform the in-line expansion. SOLUTION: A source program is read by a program input means 21, decomposed into tokens by a token analysis means 31 and undergoes the parsing by a parsing means 32 to be decomposed into expressions. Then an object code generation means 41 generates the codes corresponding to every expression, and these object codes are outputted to a file by a result file output means 51. At the same time, the call expression of a library function is detected by a library function call detection means 33. Then the object code of the library function is read out of a library by a library function object code extraction means 23 and directly outputted to a file.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明は、インライン展開処
理方法及び装置に関し、特に、ソースプログラムを入力
しオブジェクトコードを生成するコンパイラにおけるイ
ンライン展開処理方法及び装置に関する。
The present invention relates to an inline expansion processing method and apparatus, and more particularly, to an inline expansion processing method and apparatus in a compiler that inputs a source program and generates object code.

【0002】[0002]

【従来の技術】コンパイラの最適化手法の1つとしてイ
ンライン展開処理方式が知られている。このインライン
展開処理方式はコンパイラが生成するオブジェクトの実
行速度の向上を図る最適化手法であり、呼び出す関数の
中身(コード)を、呼び出し場所に展開するものであ
る。従来より、インライン展開の対象となる関数がC言
語で記述されたソースを入力することを前提としたイン
ライン展開処理方式が各種検討されている。
2. Description of the Related Art An inline expansion processing method is known as one of the optimization methods of a compiler. This inline expansion processing method is an optimization method for improving the execution speed of an object generated by a compiler, and expands the contents (code) of a function to be called to a calling place. 2. Description of the Related Art Conventionally, various studies have been made on an inline expansion processing method on the premise that a function to be subjected to inline expansion inputs a source described in C language.

【0003】ソフトウェア規模の増大化に伴い、汎用的
な関数をライブラリとして登録する場合が増大し、上述
したC言語のソースを伴わないライブラリ関数のインラ
イン展開処理の要求が増大している。
[0003] With the increase in software scale, the number of cases where general-purpose functions are registered as libraries has increased, and the demand for inline expansion processing of library functions without the above-mentioned C language source has increased.

【0004】異なるコンパイル単位に存在する関数のイ
ンライン展開を可能とする関数のインライン展開装置と
して、例えば特開平10−31591号公報には、図1
1に示すように、関数呼び出し発見手段(S12)は複
数のオブジェクトプログラム中に関数呼び出しが存在す
るか判定し、存在する場合、関数呼び出し情報テーブル
を作成し、関数定義発見手段(S13)は、関数呼び出
し情報テーブルに格納されている関数呼び出しの関数定
義を検索し、関数定義テーブル(T2)を作成し、該当
関数のサイズ及び関数のオブジェクトをコピーし、プロ
ローグ・エピローグ除去手段(S14)は、関数定義テ
ーブルT2に格納されている関数のオブジェクトに対し
て、インライン展開により不要となるプロローグ及びエ
ピローグの除去を行い、関数インライン展開手段(S1
5)は、関数定義テーブルに格納されている関数につい
て関数呼び出しテーブルを参照し、関数呼び出し箇所に
関数定義テーブルに格納されているオブジェクトを埋め
込み、関数呼び出し命令を削除し、参照アドレス変更手
段(S16)は、関数インライン手段で呼び出している
関数に、インライン関数を跨ぐジャンプ命令が存在する
場合、インライン展開により、ジャンプ命令とジャンプ
先の相対アドレスが変化するため、ジャンプ命令とジャ
ンプ先アドレスを計算して修正する。このインライン展
開装置は、コンパイラにより生成されたオブジェクトに
対して、リンカで関数のインライン展開処理を行ってお
り、概念的にはライブラリ関数もインライン展開可能で
ある。
Japanese Patent Application Laid-Open No. H10-31591 discloses a function inline expansion apparatus which enables inline expansion of functions existing in different compilation units.
As shown in FIG. 1, the function call finding means (S12) determines whether a function call exists in a plurality of object programs, and if so, creates a function call information table, and the function definition finding means (S13) The function definition of the function call stored in the function call information table is searched, a function definition table (T2) is created, the size of the corresponding function and the object of the function are copied, and the prologue / epilogue removal means (S14) The function object stored in the function definition table T2 is subjected to removal of unnecessary prologues and epilogues by inline expansion, and the function inline expansion means (S1
5) refers to the function call table for the function stored in the function definition table, embeds the object stored in the function definition table at the function call location, deletes the function call instruction, and changes the reference address changing means (S16). ) Calculates the jump instruction and the jump destination address if the function called by the function inline means includes a jump instruction that straddles the inline function, because the relative address between the jump instruction and the jump destination changes due to inline expansion. To correct. This inline expansion apparatus performs inline expansion processing of a function by a linker for an object generated by a compiler, and can conceptually also perform inline expansion of a library function.

【0005】[0005]

【発明が解決しようとする課題】しかし、上記したイン
ライン展開処理装置では、リンク時にインライン展開す
る場合の前後の命令アドレスの変更をどのように解決す
るかについて全く開示されていない。そして、リンカ
が、ライブラリ関数のインライン展開(コードの埋め込
み)を行う場合、全命令および全シンボルのアドレスを
コード埋め込み後に変更しなければならないため、リン
ク処理時間は、例えば、インライン展開を行わない場合
の従約2倍となり、現実的とはいえない。
However, the above-described inline expansion processing device does not disclose how to solve the change of instruction addresses before and after inline expansion at the time of linking. When the linker performs inline expansion (embedding code) of a library function, the address of all instructions and all symbols must be changed after embedding the code. This is not realistic.

【0006】また、図10に示すように、コンパイラ
(翻訳プログラム)自身が、ライブラリ関数の機能を具
備し、ライブラリ関数のインライン展開を可能にしてい
るものもある。すなわち、図10を参照すると、ソース
入力手段(S8)と、ライブラリ関数呼び出し発見手段
(S9)と、ライブラリ関数インライン展開手段(S1
0)と、コード生成手段(S11)と、ライブラリ関数
機能格納テーブル(T1)と、を備えている。
Further, as shown in FIG. 10, there is a compiler (translation program) itself having a function of a library function and enabling inline expansion of the library function. That is, referring to FIG. 10, source input means (S8), library function call finding means (S9), and library function inline expansion means (S1)
0), code generation means (S11), and a library function storage table (T1).

【0007】しかし、ライブラリ関数の機能をコンパイ
ラ自身が具備しているため、ライブラリ関数の機能が変
わったときに、コンパイラ本体も同様に変更しなければ
ならないことになる。
However, since the function of the library function is provided in the compiler itself, when the function of the library function changes, the compiler itself must also be changed.

【0008】さらに、コンパイラ(翻訳プログラム)の
利用者が作成したライブラリ関数については、事前にコ
ンパイラ本体がその機能を持つことはできないため、イ
ンライン展開することができない。このように、図10
に示した方式も、ライブラリ関数のインライン展開処理
方式としては十分といえない。
Further, a library function created by a user of a compiler (translation program) cannot be expanded inline because the compiler itself cannot have the function in advance. Thus, FIG.
Is not sufficient as an inline expansion processing method for library functions.

【0009】したがって、本発明は、上記問題点に鑑み
なされたものであって、その目的は、コンパイラにおい
て、すべてのライブラリ関数のインライン展開可能と
し、ライブラリ関数のインライン展開処理を高速化する
インライン展開処理装置及び方法を提供することにあ
る。
SUMMARY OF THE INVENTION Therefore, the present invention has been made in view of the above problems, and has as its object to enable inline expansion of all library functions in a compiler and to speed up inline expansion processing of library functions. It is to provide a processing device and a method.

【0010】[0010]

【課題を解決するための手段】前記目的を達成する本発
明は、ソースプログラムを入力しオブジェクトコードを
生成するコンパイラにおいてインライン展開を行う方法
であって、入力したソースプログラムの構文が関数呼び
出しである場合、該関数名がライブラリに登録されたも
のであるか判定し、前記ライブラリに登録されている場
合、該関数のオブジェクトコードを前記ライブラリから
読み出して、オブジェクトコードとして出力することで
インライン展開する。
According to the present invention, there is provided a method for performing inline expansion in a compiler for inputting a source program and generating object code, wherein the syntax of the input source program is a function call. In this case, it is determined whether or not the function name is registered in a library. If the function name is registered in the library, the object code of the function is read from the library and output as an object code to perform inline expansion.

【0011】[0011]

【発明の実施の形態】本発明の実施の形態について説明
する。図1は、本発明の一実施の形態のコンパイラ装置
の構成を示す図である。図1を参照すると、本発明の一
実施の形態において、コマンド入力手段(22)によっ
て、ライブラリ関数のインライン展開が要求されると、
ライブラリ関数呼出し検出手段(33)は、構文解析手
段(32)によって認識された呼出し関数名がライブラ
リ関数名であるか否かを判定する。
Embodiments of the present invention will be described. FIG. 1 is a diagram illustrating a configuration of a compiler device according to an embodiment of the present invention. Referring to FIG. 1, in one embodiment of the present invention, when the command input means (22) requests inline expansion of a library function,
The library function call detection means (33) determines whether or not the call function name recognized by the syntax analysis means (32) is a library function name.

【0012】ライブラリ関数の呼出しが検出されると、
ライブラリ関数オブジェクトコード抽出手段(23)
は、ライブラリ内のシンボル一覧から該当関数のオブジ
ェクトコード格納位置をサーチし、該検索された情報に
従って、該当関数のオブジェクトコードを読み込む。
When a call to a library function is detected,
Library function object code extraction means (23)
Searches the object code storage position of the function from the list of symbols in the library, and reads the object code of the function according to the searched information.

【0013】結果ファイル出力手段(51)は、該当関
数のコードを結果ファイルに直接出力する。このように
して、ライブラリ関数のインライン展開処理を可能にす
る。
The result file output means (51) directly outputs the code of the corresponding function to a result file. Thus, the inline expansion processing of the library function is enabled.

【0014】本発明は、その好ましい実施の形態におい
て、ソースプログラムを構文解析してなる構文が関数呼
び出しであるか否か判定する手段(33)と、該構文が
関数呼び出しである場合、関数名一覧と該関数のオブジ
ェクトコードとを含むライブラリを入力し、該関数名が
ライブラリに登録されているか否か調べ、該関数呼び出
しの関数名がライブラリに登録されている場合、ライブ
ラリ内から該関数のオブジェクトコード格納位置をサー
チし、該検索された情報に従って該関数のオブジェクト
コードを読み込む手段(23)と、読み込んだオブジェ
クトコードをファイルに出力する手段(51)とを備
え、上記各手段はコンピュータ上で実行されるプログラ
ムによりその機能を実現することができる。この場合、
該プログラムを記録媒体に記録しておき、コンピュータ
で該プログラムを記憶媒体から読み出し主メモリにロー
ドして実行することで本発明を実施することができる。
またライブラリはコンパイラと独立して設けられてお
り、ライブラリにおける関数の追加、変更等は自在とさ
れる。
According to a preferred embodiment of the present invention, a means (33) for judging whether or not a syntax obtained by parsing a source program is a function call, and a function name when the syntax is a function call. A library including a list and the object code of the function is input, and it is checked whether the function name is registered in the library. If the function name of the function call is registered in the library, the library Means (23) for searching the object code storage location and reading the object code of the function according to the searched information; and means (51) for outputting the read object code to a file. The function can be realized by the program executed by the program. in this case,
The present invention can be implemented by recording the program on a recording medium, reading the program from the storage medium to a main memory by a computer, and executing the program.
The library is provided independently of the compiler, and functions such as additions and changes in the library can be freely performed.

【0015】本発明においては、全命令および全シンボ
ルのアドレスが確定していない状態のオブジェクトコー
ドを生成するコンパイラにおいて、インライン展開処理
を行っているためインライン展開処理を高速化してい
る。これに対して、図11に示した従来のインライン展
開処理装置のように、インライン展開処理をリンカで行
おうとした場合、既に確定している全命令および全シン
ボルのアドレスを変更しなければならず、このために要
する処理時間は、上記したように、インライン展開処理
を行わないときに比べ、約2倍の処理時間が必要にな
る。
In the present invention, the inline expansion processing is performed in a compiler that generates an object code in a state where addresses of all instructions and all symbols are not determined, so that the speed of the inline expansion processing is increased. On the other hand, when the inline expansion processing is to be performed by the linker as in the conventional inline expansion processing apparatus shown in FIG. 11, the addresses of all instructions and all symbols that have already been determined must be changed. As described above, the processing time required for this is about twice as long as when the inline expansion processing is not performed.

【0016】[0016]

【実施例】本発明の実施例について図面を参照して説明
する。図1は、本発明の一実施例の構成を示す図であ
る。図1を参照すると、本発明一実施例は、全体の処理
を行う制御処理手段1と、入力手段2と、ソース解析手
段3と、変換手段4と、出力手段5とを備えて構成され
ている。
Embodiments of the present invention will be described with reference to the drawings. FIG. 1 is a diagram showing the configuration of one embodiment of the present invention. Referring to FIG. 1, one embodiment of the present invention includes a control processing unit 1 for performing the entire processing, an input unit 2, a source analysis unit 3, a conversion unit 4, and an output unit 5. I have.

【0017】入力手段2は、翻訳対象のソースプログラ
ムを入力するプログラム入力手段21と、インライン展
開処理等の指示を受け付けるコマンド入力手段22と、
ライブラリから目的関数のオブジェクトコードを読み込
むライブラリ関数オブジェクトコード抽出手段23とを
備えている。
The input means 2 includes: a program input means 21 for inputting a source program to be translated; a command input means 22 for receiving an instruction such as an inline expansion process;
Library function object code extracting means 23 for reading the object code of the objective function from the library.

【0018】ソース解析手段3は、入力ソースを数字、
演算式、変数等のトークンに分解する字句解析手段31
と、分解されたトークンを構文解析し、構文木等の式と
して構築する構文解析手段32と、式(構文)の中にラ
イブラリ関数の呼出しがあるか否かを判定するライブラ
リ関数呼出し発見手段33とを備えている。
The source analysis means 3 converts the input source into a number,
Lexical analysis means 31 for decomposing into tokens such as arithmetic expressions and variables
And a parsing means 32 for parsing the decomposed token and constructing it as an expression such as a syntax tree, and a library function call finding means 33 for judging whether a library function is called in the expression (syntax). And

【0019】変換手段4は、各式に対して目的コードを
生成するオブジェクトコード生成手段41を備えてい
る。
The conversion means 4 includes an object code generation means 41 for generating a target code for each expression.

【0020】出力手段5は、変換したコードをファイル
に出力する結果ファイル出力手段51と、エラー等のメ
ッセージを画面に表示する結果表示手段52とを備えて
いる。
The output means 5 includes a result file output means 51 for outputting the converted code to a file, and a result display means 52 for displaying a message such as an error on a screen.

【0021】ソースプログラムがプログラム入力手段2
1によって読み込まれ、字句解析手段31によってトー
クンに分解され、構文解析手段32によって構文解析さ
れて式に分解され、オブジェクトコード生成手段41に
よって各式に対応したコードが生成され、結果ファイル
出力手段51によって生成されたオブジェクトコードが
ファイルに出力されることで、ソースプログラムの翻訳
処理は完了する。
The source program is a program input means 2
1 and decomposed into tokens by the lexical analysis means 31, parsed by the syntax analysis means 32 and decomposed into expressions, a code corresponding to each expression is generated by the object code generation means 41, and a result file output means 51 The translation of the source program is completed by outputting the object code generated by the file to a file.

【0022】その際、ライブラリ関数呼出し発見手段3
3によって、ライブラリ関数の呼出し式を検出し、ライ
ブラリ関数オブジェクトコード抽出手段23によってラ
イブラリ関数のオブジェクトコードをライブラリから読
み込み、そのオブジェクトコードを直接ファイルに出力
することにより、ライブラリ関数のインライン展開を実
現する。
At this time, library function call finding means 3
3, the call expression of the library function is detected, the object code of the library function is read from the library by the library function object code extracting means 23, and the object code is directly output to a file, thereby implementing the inline expansion of the library function. .

【0023】図2は、本発明の一実施例の動作の説明す
るための流れ図である。図1及び図2を参照して、本実
施例の全体の動作について詳細に説明する。
FIG. 2 is a flowchart for explaining the operation of one embodiment of the present invention. With reference to FIGS. 1 and 2, the overall operation of the present embodiment will be described in detail.

【0024】まずステップS1において、読み込んだ構
文(式)が、関数呼出しであるか否かをチェックする。
関数呼出しでないときには、以下のステップS2〜S5
の処理は行なわれない。
First, in step S1, it is checked whether the read syntax (expression) is a function call.
If it is not a function call, the following steps S2 to S5
Is not performed.

【0025】読み込んだ構文が関数呼出しのときには、
その関数名がライブラリ関数であるか否かをチェックす
るため、ステップS2において、ライブラリF1内に、
対象とする関数が登録されているか否かチェックする。
When the read syntax is a function call,
To check whether the function name is a library function, in step S2,
Check whether the target function is registered.

【0026】図3は、本発明の一実施例におけるライブ
ラリ構成の一例を示す図である。図3を参照すると、ラ
イブラリは、関数のオブジェクトコードが格納されてい
るオブジェクトコード領域301と、関数名と関数の格
納場所とが格納されているシンボル一覧領域302とか
ら構成されている。シンボル一覧領域302には、関数
ごとに、関数名、関数コード先頭アドレス、関数コード
サイズが格納されている。
FIG. 3 is a diagram showing an example of a library configuration in one embodiment of the present invention. Referring to FIG. 3, the library includes an object code area 301 in which object codes of functions are stored, and a symbol list area 302 in which function names and storage locations of functions are stored. The symbol list area 302 stores a function name, a function code start address, and a function code size for each function.

【0027】図2のステップS2において、図3のライ
ブラリ内のシンボル一覧領域302から、対象関数名を
検索する。
In step S2 of FIG. 2, a target function name is searched from the symbol list area 302 in the library of FIG.

【0028】次にステップS3の判定処理で、対象関数
がライブラリ関数ではないとわかったとき、すなわち、
図3のシンボル一覧領域302に対象関数名が見つから
なかったときには、ここでの処理は終了する。
Next, when it is determined in the determination processing in step S3 that the target function is not a library function,
When the target function name is not found in the symbol list area 302 of FIG. 3, the processing here ends.

【0029】ステップS3の判定処理で、対象関数がラ
イブラリ関数として検索されたとき、すなわち、対象関
数がライブラリ関数とわかったときには、ステップS4
において、図3のシンボル一覧領域302から、対象関
数の関数コード先頭アドレスとオブジェクトサイズを読
み込み、それぞれ変数adrとsizeに設定する。
If the target function is found as a library function in the determination processing in step S3, that is, if the target function is found to be a library function, step S4
In step (3), the function code start address and the object size of the target function are read from the symbol list area 302 in FIG. 3, and are set in variables adr and size, respectively.

【0030】次にステップS5において、図3のオブジ
ェクトコード領域301のアドレスadrからsize
分のコードを読み込む。この読み込み時、先頭の関数名
シンボルと、最後のret命令(復帰命令)は読み飛ば
す。このようにして、ライブラリ関数オブジェクトコー
ドの読み込みは終了する。
Next, in step S5, the size from the address adr of the object code area 301 in FIG.
Read the minute code. During this reading, the first function name symbol and the last ret instruction (return instruction) are skipped. Thus, the reading of the library function object code ends.

【0031】次に、具体例を用いて本実施例の動作を説
明する。図4及び図5は、本発明の一実施例を具体的に
例示する図であり、ソースプログラム及びライブラリ構
成の具体例をそれぞれ示している。
Next, the operation of this embodiment will be described using a specific example. FIGS. 4 and 5 are diagrams specifically illustrating an embodiment of the present invention, and show specific examples of a source program and a library configuration, respectively.

【0032】例えば、図4に示すソースプログラム(C
言語によるソース)を翻訳(コンパイル)時に、ライブ
ラリ関数インライン展開指示が行われている場合につい
て説明する。このとき、図5に示すライブラリ構造を持
つライブラリを入力するものとする。
For example, the source program (C shown in FIG. 4)
A case in which a library function inline expansion instruction is given when translating (compiling) a language source will be described. At this time, a library having the library structure shown in FIG. 5 is input.

【0033】図1のプログラム入力手段21は、図4の
ソースプログラムを入力し、図1の字句解析手段31
と、構文解析手段32により、ソースプログラムを構文
(式)に分解する。構文解析まで終了すると、図1のラ
イブラリ関数呼出し発見手段33と、ライブラリ関数オ
ブジェクトコード抽出手段23によって、構文(式)ご
とに、ライブラリ関数のインライン展開処理を行う。以
下具体的な処理について説明する。
The program input means 21 of FIG. 1 inputs the source program of FIG.
Then, the syntax analysis unit 32 decomposes the source program into a syntax (expression). When the syntax analysis is completed, the library function call finding means 33 and the library function object code extracting means 23 of FIG. 1 perform inline expansion processing of the library function for each syntax (expression). Hereinafter, specific processing will be described.

【0034】図2において、はじめにステップS1で
は、読み込んだ構文、この場合、図4の構文401(ma
in())は関数呼出しではないので、ここでの処理は終了
する。つづく構文402、構文403も同様に、関数呼
出しではないので、処理は終了する。
In FIG. 2, first, in step S1, the read syntax, in this case, the syntax 401 (ma
Since in ()) is not a function call, the processing here ends. Similarly, the subsequent syntaxes 402 and 403 are not function calls, so the process ends.

【0035】次の構文404を読み込んだとき、関数呼
び出しであるため、図2のステップS1での判定が真と
なり、ステップS2に移る。ステップS2とステップS
3では、図5に示すライブラリに、関数absが登録さ
れているか否か調べ、関数名absはライブラリに登録
されているので、図2のステップS4に移り、このステ
ップS4では、図5に示すシンボル一覧領域502か
ら、関数absの関数コード先頭アドレスとオブジェク
トサイズを読み込み、それぞれ変数adrとsizeに
設定する。この場合、変数adrとsizeには0と6
がそれぞれ設定される。
When the next syntax 404 is read, since it is a function call, the determination in step S1 of FIG. 2 is true, and the process proceeds to step S2. Step S2 and Step S
In 3, it is checked whether or not the function abs is registered in the library shown in FIG. 5. Since the function name abs is registered in the library, the process proceeds to step S 4 in FIG. 2. The function code start address and the object size of the function abs are read from the symbol list area 502, and are set in variables adr and size, respectively. In this case, the variables adr and size are 0 and 6
Are set respectively.

【0036】次に、図2のステップS5では、図5に示
すオブジェクトコード領域501のアドレスadrから
size分のコードを読み込む。この場合、アドレス0
から6ワード分のオブジェクトコードが読み込まれる。
ただし、この読み込み時には、先頭の関数名シンボル
と、最後のret命令は読み飛ばすため、実際には、図
5における、コード504からコード507までの4ワ
ードが読み込まれる。
Next, in step S5 of FIG. 2, a code corresponding to size is read from the address adr of the object code area 501 shown in FIG. In this case, address 0
The object code for 6 words is read from.
However, at the time of this reading, since the first function name symbol and the last ret instruction are skipped, actually four words from code 504 to code 507 in FIG. 5 are read.

【0037】読み込んだオブジェクトコードを、図1の
オブジェクトコード生成手段41が、各構文に対するオ
ブジェクトコードを生成する際に、関数呼出しコードの
代わりに用いる。図6に、このようにして出力されるオ
ブジェクトコードの例をニューモニックで示す。
When the object code generating means 41 of FIG. 1 generates an object code for each syntax, the read object code is used instead of the function call code. FIG. 6 shows an example of the object code output in this way by mnemonics.

【0038】次に、本発明の第2の実施例について説明
する。本発明の第2の実施例の基本構成は図1に示した
構成と同様である。
Next, a second embodiment of the present invention will be described. The basic configuration of the second embodiment of the present invention is the same as the configuration shown in FIG.

【0039】図7は、本発明の第2の実施例の動作を説
明するための流れ図である。図8は、本発明の第2の実
施例におけるライブラリの構成を説明するための図であ
る。図7及び図8を参照すると、本実施例は、入力する
ライブラリ構造のシンボル一覧情報802が、図3に示
した前記実施例における関数コードのサイズの代わり
に、図8に示すように、関数コードの終了アドレスとさ
れ、ライブラリ読み込みにおいて、関数コードサイズを
用して関数オブジェクトコードを読み込むという図2の
ステップS4とステップS5の代わりに、図7に示すよ
うに、関数コード終了アドレスを用いて関数オブジェク
トコードを読み込む点が、前記実施例と相違している。
なお、図7において、図2と同一の処理ステップには同
一の参照符号が付されている。
FIG. 7 is a flow chart for explaining the operation of the second embodiment of the present invention. FIG. 8 is a diagram for explaining the configuration of the library according to the second embodiment of the present invention. Referring to FIG. 7 and FIG. 8, in the present embodiment, the symbol list information 802 of the library structure to be input is replaced with the function code as shown in FIG. 8 instead of the size of the function code in the embodiment shown in FIG. As shown in FIG. 7, instead of steps S4 and S5 in FIG. 2 in which the function object code is read using the function code size in reading the library, the function code end address is used. The difference from the above embodiment is that the function object code is read.
In FIG. 7, the same processing steps as those in FIG. 2 are denoted by the same reference numerals.

【0040】次に、本発明の第2の実施例の動作につい
て具体例に即して説明する。例えば、図4に示すソース
プログラム翻訳時に、ライブラリ関数インライン展開指
示が行われている場合について説明する。このとき、図
9に示すライブラリ構造を持つライブラリを入力するも
のとする。
Next, the operation of the second embodiment of the present invention will be described with reference to a specific example. For example, a case will be described in which a library function inline expansion instruction is issued at the time of translating the source program shown in FIG. At this time, a library having the library structure shown in FIG. 9 is input.

【0041】プログラム入力手段21(図1参照)は、
図4のソースプログラムを入力し、字句解析手段31
と、構文解析手段32により、ソースプログラムを構文
(式)に分解する。構文解析まで終了すると、図1のラ
イブラリ関数呼出し発見手段33と、ライブラリ関数オ
ブジェクトコード抽出手段23によって、構文(式)ご
とに、ライブラリ関数のインライン展開処理を行う。以
降、具体的な処理について説明する。図7において、は
じめにステップS1は、読み込んだ構文、この場合、図
4の構文401は関数呼出しではないので、ここでの処
理は終了する。構文402、構文403も同様に、関数
呼出しではないので、処理は終了する。
The program input means 21 (see FIG. 1)
The source program of FIG.
Then, the syntax analysis unit 32 decomposes the source program into a syntax (expression). When the syntax analysis is completed, the library function call finding means 33 and the library function object code extracting means 23 of FIG. 1 perform inline expansion processing of the library function for each syntax (expression). Hereinafter, specific processing will be described. In FIG. 7, first, step S1 is the read syntax, in this case, the syntax 401 in FIG. 4 is not a function call, and thus the processing here ends. Similarly, since the syntax 402 and the syntax 403 are not function calls, the process ends.

【0042】図4の構文404を読み込んだとき、図7
のステップS1での判定が真となり、ステップS2に移
る。ステップS2とステップS3は、図9に示したライ
ブラリに、関数absが登録されているかどうかを調べ
る。この場合、関数名absは登録されているので、図
7のステップS6に移る。ステップS6では、図9のシ
ンボル一覧領域902から、関数absの関数コード先
頭アドレスと関数コード終了アドレスを読み込み、それ
ぞれ変数adr_sとadr_eに設定する。この場
合、変数adr_sとadr_eには0と5がそれぞれ
設定される。
When the syntax 404 of FIG. 4 is read, FIG.
Is true in step S1, and the process proceeds to step S2. Steps S2 and S3 check whether the function abs is registered in the library shown in FIG. In this case, since the function name abs has been registered, the process proceeds to step S6 in FIG. In step S6, the function code start address and the function code end address of the function abs are read from the symbol list area 902 in FIG. 9 and set in variables adr_s and adr_e, respectively. In this case, 0 and 5 are set to the variables adr_s and adr_e, respectively.

【0043】次に、図7のステップS7では、図9に示
すのオブジェクトコード領域901のアドレスadr_
sからアドレスadr_eまでのコードを読み込む。こ
の場合、アドレス0からアドレス5までの6ワード分の
オブジェクトコードが読み込まれる。ただし、この読み
込み時には、先頭の関数名シンボルと、最後のret命
令は読み飛ばすため、実際には、図9のコード904か
らコード907までの4ワードが読み込まれる。
Next, in step S7 of FIG. 7, the address adr_of the object code area 901 shown in FIG.
The code from s to address adr_e is read. In this case, six words of object code from address 0 to address 5 are read. However, at the time of this reading, since the first function name symbol and the last ret instruction are skipped, four words from code 904 to code 907 in FIG. 9 are actually read.

【0044】読み込んだオブジェクトコードを、図1の
オブジェクトコード生成手段41が、各構文に対するオ
ブジェクトコードを生成する際に、関数呼出しコードの
代わりに用いる。図6に、このようにして出力されるオ
ブジェクトコードの例を示す。本発明の第2の実施例に
おいても、前記実施例として図5に示したライブラリ構
造を入力したときと同等の効果を奏することが判る。
The read object code is used in place of the function call code when the object code generation means 41 of FIG. 1 generates an object code for each syntax. FIG. 6 shows an example of the object code output in this manner. Also in the second embodiment of the present invention, it can be seen that the same effect as when the library structure shown in FIG. 5 is input as the above embodiment is obtained.

【0045】[0045]

【発明の効果】以上説明したように、本発明によれば下
記記載の効果を奏する。
As described above, according to the present invention, the following effects can be obtained.

【0046】本発明の第1の効果は、すべてのライブラ
リ関数のインライン展開ができる、ということである。
The first effect of the present invention is that all library functions can be expanded inline.

【0047】その理由は、本発明においては、コンパイ
ラがライブラリを入力し、ライブラリの中からインライ
ン展開の対象となるオブジェクトコードを抽出するライ
ブラリ関数オブジェクトコード抽出手段を備える構成と
したためである。
The reason is that, in the present invention, the compiler is provided with a library function object code extracting means for inputting a library and extracting an object code to be subjected to inline expansion from the library.

【0048】本発明の第2の効果は、上記ライブラリ関
数のインライン展開処理を高速化し、インライン展開処
理なしの処理時間と同等の処理時間で実現できる、とい
うことである。
A second effect of the present invention is that the inline expansion processing of the library function can be speeded up and realized in a processing time equivalent to the processing time without the inline expansion processing.

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

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

【図2】本発明の一実施例の動作を説明するための流れ
図である。
FIG. 2 is a flowchart for explaining the operation of one embodiment of the present invention.

【図3】本発明の一実施例におけるライブラリ構成の一
例を示す図である。
FIG. 3 is a diagram illustrating an example of a library configuration according to an embodiment of the present invention.

【図4】本発明の一実施例を具体的に説明するための図
であり、ソースプログラムの一例を示す図である。
FIG. 4 is a diagram specifically illustrating an embodiment of the present invention, and is a diagram illustrating an example of a source program.

【図5】本発明の一実施例を具体的に説明するための図
であり、ライブラリの具体例を示す図である。
FIG. 5 is a diagram specifically illustrating an embodiment of the present invention, and is a diagram illustrating a specific example of a library.

【図6】本発明の一実施例を具体的に説明するための図
であり、出力オブジェクトコードの一例を示す図であ
る。
FIG. 6 is a diagram specifically illustrating one embodiment of the present invention, and is a diagram illustrating an example of an output object code.

【図7】本発明の第2の実施例の動作を説明するための
流れ図である。
FIG. 7 is a flowchart for explaining the operation of the second exemplary embodiment of the present invention.

【図8】本発明の第2の実施例におけるライブラリ構成
の一例を示す図である。
FIG. 8 is a diagram illustrating an example of a library configuration according to a second embodiment of the present invention.

【図9】本発明の第2の実施例を説明するための図であ
り、ライブラリ構成の具体例を示す図である。
FIG. 9 is a diagram for explaining a second embodiment of the present invention, and is a diagram showing a specific example of a library configuration.

【図10】従来のインライン展開処理方式の構成の一例
を示す図である。
FIG. 10 is a diagram showing an example of a configuration of a conventional inline expansion processing method.

【図11】従来のインライン展開処理方式の構成の別の
例を示す図である。
FIG. 11 is a diagram showing another example of the configuration of the conventional inline expansion processing method.

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

1 制御処理手段 2 入力手段 3 ソース解析手段 4 変換手段4 5 出力手段5 21 プログラム入力手段 22 コマンド入力手段 23 ライブラリ関数オブジェクトコード抽出手段 31 字句解析手段 32 構文解析手段 33 ライブラリ関数呼出し発見手段 41 オブジェクトコード生成手段 51 結果ファイル出力手段 52 結果表示手段 301、501、801、901 オブジェクトコード
領域 302、502、802、902 シンボル一覧 F1、F2 ライブラリ
DESCRIPTION OF SYMBOLS 1 Control processing means 2 Input means 3 Source analysis means 4 Conversion means 4 5 Output means 5 21 Program input means 22 Command input means 23 Library function object code extraction means 31 Lexical analysis means 32 Syntax analysis means 33 Library function call finding means 41 Object Code generation means 51 Result file output means 52 Result display means 301, 501, 801, 901 Object code area 302, 502, 802, 902 Symbol list F1, F2 Library

─────────────────────────────────────────────────────
────────────────────────────────────────────────── ───

【手続補正書】[Procedure amendment]

【提出日】平成11年9月27日(1999.9.2
7)
[Submission date] September 27, 1999 (September 9, 1999
7)

【手続補正1】[Procedure amendment 1]

【補正対象書類名】明細書[Document name to be amended] Statement

【補正対象項目名】請求項1[Correction target item name] Claim 1

【補正方法】変更[Correction method] Change

【補正内容】[Correction contents]

【手続補正2】[Procedure amendment 2]

【補正対象書類名】明細書[Document name to be amended] Statement

【補正対象項目名】請求項3[Correction target item name] Claim 3

【補正方法】変更[Correction method] Change

【補正内容】[Correction contents]

【手続補正3】[Procedure amendment 3]

【補正対象書類名】明細書[Document name to be amended] Statement

【補正対象項目名】請求項4[Correction target item name] Claim 4

【補正方法】変更[Correction method] Change

【補正内容】[Correction contents]

【手続補正4】[Procedure amendment 4]

【補正対象書類名】明細書[Document name to be amended] Statement

【補正対象項目名】請求項5[Correction target item name] Claim 5

【補正方法】変更[Correction method] Change

【補正内容】[Correction contents]

【手続補正5】[Procedure amendment 5]

【補正対象書類名】明細書[Document name to be amended] Statement

【補正対象項目名】請求項6[Correction target item name] Claim 6

【補正方法】変更[Correction method] Change

【補正内容】[Correction contents]

【手続補正6】[Procedure amendment 6]

【補正対象書類名】明細書[Document name to be amended] Statement

【補正対象項目名】請求項7[Correction target item name] Claim 7

【補正方法】変更[Correction method] Change

【補正内容】[Correction contents]

【手続補正7】[Procedure amendment 7]

【補正対象書類名】明細書[Document name to be amended] Statement

【補正対象項目名】請求項8[Correction target item name] Claim 8

【補正方法】変更[Correction method] Change

【補正内容】[Correction contents]

【手続補正8】[Procedure amendment 8]

【補正対象書類名】明細書[Document name to be amended] Statement

【補正対象項目名】請求項9[Correction target item name] Claim 9

【補正方法】変更[Correction method] Change

【補正内容】[Correction contents]

【手続補正9】[Procedure amendment 9]

【補正対象書類名】明細書[Document name to be amended] Statement

【補正対象項目名】0010[Correction target item name] 0010

【補正方法】変更[Correction method] Change

【補正内容】[Correction contents]

【0010】[0010]

【課題を解決するための手段】前記目的を達成する本発
明は、ソースプログラムを入力しオブジェクトコードを
生成するコンパイラにおいてインライン展開を行う方法
であって、関数名一覧と該関数のオブジェクトコードと
を含むライブラリを前記コンパイラ外部に用意してお
き、入力した前記ソースプログラムの構文が関数呼び出
しである場合、該関数名が前記ライブラリに登録された
ものであるか否か判定し、前記ライブラリに登録されて
いる場合、該関数のオブジェクトコードを前記ライブラ
リから読み出し該オブジェクトコードを前記関数呼び
出しのコードの代わりに出力することでインライン展開
する。
SUMMARY OF THE INVENTION The present invention for achieving the above object is a method for performing inline expansion in a compiler for inputting a source program and generating object code.
Prepare a library including
Can, if the syntax of the source program input is a function call, it is determined whether or not the number people the function is registered in the library, when registered in the library, the object code of the function number read from the library, calls the function the object code
Inline expansion by outputting in place of the output code .

Claims (9)

【特許請求の範囲】[Claims] 【請求項1】ソースプログラムを入力しオブジェクトコ
ードを生成するコンパイラにおいてインライン展開を行
う方法であって、 入力した前記ソースプログラムの構文が関数呼び出しで
ある場合、該関数名がライブラリに登録されたものであ
るか否か判定し、前記ライブラリに登録されている場
合、該関数のオブジェクトコードを前記ライブラリから
読み出し、該オブジェクトコードを前記関数呼び出しの
コードの代わりに出力する、ことを特徴とするインライ
ン展開処理方法。
1. A method for performing inline expansion in a compiler that inputs a source program and generates an object code, wherein, when the syntax of the input source program is a function call, the function name is registered in a library. Judge whether or not the function code is registered in the library, read the object code of the function from the library, and output the object code instead of the code of the function call; Processing method.
【請求項2】インライン展開処理が指示された時に、前
記ライブラリを入力することを特徴とする請求項1記載
のインライン展開処理方法。
2. The inline expansion processing method according to claim 1, wherein the library is input when an inline expansion processing is instructed.
【請求項3】ソースプログラムを構文解析してなる構文
が関数呼び出しであるか否か判定する手段と、 前記構文が関数呼び出しである場合、関数名一覧と該関
数のオブジェクトコードとを含むライブラリを検索し、
前記関数名が前記ライブラリに登録されているか否か調
べ、前記関数呼び出しの関数名が前記ライブラリに登録
されている場合、前記ライブラリから該関数のオブジェ
クトコードの格納位置を取得し、該位置情報に従って該
関数のオブジェクトコードを読み込む手段と、 前記読み込んだオブジェクトコードを前記関数呼び出し
のコードの代わりに出力する手段と、 を備えたことを特徴とするインライン展開装置。
3. A means for determining whether or not a syntax obtained by parsing a source program is a function call. If the syntax is a function call, a library including a function name list and an object code of the function is provided. Search and
Check whether the function name is registered in the library, and if the function name of the function call is registered in the library, obtain the storage location of the object code of the function from the library, and according to the location information An inline expansion device comprising: a unit for reading the object code of the function; and a unit for outputting the read object code instead of the function call code.
【請求項4】前記入力手段からインライン展開処理が指
示された場合、前記ライブラリを入力することを特徴と
する請求項3記載のインライン展開処理装置。
4. The inline expansion processing apparatus according to claim 3, wherein the library is input when an inline expansion processing is instructed from the input unit.
【請求項5】前記ライブラリが、シンボル一覧として、
関数名一覧の他、関数名毎に、該関数の先頭アドレス及
びサイズ情報を含む、ことを特徴とする請求項3記載の
インライン展開装置。
5. The library as a symbol list,
4. The inline expansion apparatus according to claim 3, wherein, in addition to the function name list, a start address and size information of the function are included for each function name.
【請求項6】前記ライブラリが、シンボル一覧として、
関数名一覧の他、関数名毎に、該関数の先頭アドレス及
び終了アドレス情報を含む、ことを特徴とする請求項3
記載のインライン展開装置。
6. The library as a symbol list,
4. The method according to claim 3, wherein each function name includes information on a start address and an end address of the function in addition to the function name list.
The inline expansion device as described.
【請求項7】前記ライブラリが、前記コンパイラの外部
に設けられており、更新自在である、ことを特徴とする
請求項3記載のインライン展開装置。
7. The inline expansion device according to claim 3, wherein the library is provided outside the compiler and is updatable.
【請求項8】前記ライブラリから関数のオブジェクトを
読み込む際に、先頭の関数名シンボルラベル、及び最後
の復帰命令を読み飛ばす、ことを特徴とする請求項3記
載のインライン展開装置。
8. The inline expansion apparatus according to claim 3, wherein when reading the function object from the library, the first function name symbol label and the last return instruction are skipped.
【請求項9】(a)ソースプログラムを構文解析してな
る構文が関数呼び出しであるか否か判定する処理と、 (b)前記構文が関数呼び出しである場合、関数名一覧
と該関数のオブジェクトコードとを含むライブラリか
ら、前記関数名一覧を検索し、前記関数名が前記ライブ
ラリに登録されているか否かを調べ、前記関数呼び出し
の関数名が前記ライブラリに登録されている場合、前記
ライブラリ内から該関数のオブジェクトコード格納位置
をサーチし、該検索された情報に従って該関数のオブジ
ェクトコードを読み込む処理と、 (c)前記読み込んだオブジェクトコードを前記関数呼
び出しコードの代わりに、ファイルに出力する処理と、 の上記(a)〜(c)の各処理をコンピュータ上で実行
させるためのプログラムを記録した記録媒体。
9. A process for determining whether or not a syntax obtained by parsing a source program is a function call. (B) When the syntax is a function call, a list of function names and an object of the function. From the library including the code, the function name list is searched to determine whether the function name is registered in the library.If the function name of the function call is registered in the library, Searching for the object code storage location of the function from, and reading the object code of the function according to the searched information; and (c) outputting the read object code to a file instead of the function call code. And a recording medium storing a program for causing a computer to execute each of the above-described processes (a) to (c). .
JP10301846A 1998-10-23 1998-10-23 In-line expansion processing device and method Pending JP2000132405A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP10301846A JP2000132405A (en) 1998-10-23 1998-10-23 In-line expansion processing device and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP10301846A JP2000132405A (en) 1998-10-23 1998-10-23 In-line expansion processing device and method

Publications (1)

Publication Number Publication Date
JP2000132405A true JP2000132405A (en) 2000-05-12

Family

ID=17901873

Family Applications (1)

Application Number Title Priority Date Filing Date
JP10301846A Pending JP2000132405A (en) 1998-10-23 1998-10-23 In-line expansion processing device and method

Country Status (1)

Country Link
JP (1) JP2000132405A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009294992A (en) * 2008-06-06 2009-12-17 Akuseru:Kk Image processing system and image processing method
JP2020087452A (en) * 2018-11-16 2020-06-04 富士通株式会社 Method for generating computer-readable code, computer readable medium, and system

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009294992A (en) * 2008-06-06 2009-12-17 Akuseru:Kk Image processing system and image processing method
JP4669948B2 (en) * 2008-06-06 2011-04-13 株式会社アクセル Image processing system and image processing method
JP2020087452A (en) * 2018-11-16 2020-06-04 富士通株式会社 Method for generating computer-readable code, computer readable medium, and system
JP7302440B2 (en) 2018-11-16 2023-07-04 富士通株式会社 Method, computer readable medium, and system for generating computer readable code

Similar Documents

Publication Publication Date Title
JP2666847B2 (en) Heterogeneous language communication method
JP3612294B2 (en) Debugging method and debugging device
US20020019973A1 (en) Compiler and method for compiling easily adaptable to processor specifications
JPH08314728A (en) Method and apparatus for conversion of source program into object program
JPH07105012A (en) Compiling processing system for language processing program
JPH0769832B2 (en) Method and apparatus for expressing effects and dependencies of programming operations
JPH11249875A (en) Method for supporting programming and device therefor
US20040010780A1 (en) Method and apparatus for approximate generation of source code cross-reference information
JPH0736680A (en) Parallelized program development aid device
JP2000132405A (en) In-line expansion processing device and method
CN114791811A (en) Assembler implementation method based on metafunction template
KR900006667B1 (en) Program assembling system
KR20080045545A (en) Method of pre-processing conditional region
JP7059757B2 (en) API processing method, terminal, API processing program
GB2420638A (en) Method of substituting code fragments in Internal Representation
CN114489653A (en) Compiler-based data processing method, compiler-based data processing device and readable storage medium
JP3461185B2 (en) Method and apparatus for registering source code line number to load module
JPH1185536A (en) Device and method for automatically correcting error of source program
JP2001005655A (en) Device and method for aiding development of application generator
JP2006202134A (en) Profile information collection method and device
JP2607975B2 (en) Debug method
JP2000207226A (en) Code optimizing device, language processor, and code optimization method
JP2002073347A (en) Exception handling method and compiler
JPH11327887A (en) Compiler system with automatic parts converting function and recording medium
JP2004246924A (en) Application generator development support device and application generator development support method

Legal Events

Date Code Title Description
A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20010612