JP2001034482A - Compile device, program optimizing device, compile processing method and recording medium - Google Patents

Compile device, program optimizing device, compile processing method and recording medium

Info

Publication number
JP2001034482A
JP2001034482A JP11202315A JP20231599A JP2001034482A JP 2001034482 A JP2001034482 A JP 2001034482A JP 11202315 A JP11202315 A JP 11202315A JP 20231599 A JP20231599 A JP 20231599A JP 2001034482 A JP2001034482 A JP 2001034482A
Authority
JP
Japan
Prior art keywords
program
source program
generating
optimized
internal data
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
JP11202315A
Other languages
Japanese (ja)
Inventor
Hiroki Machida
弘樹 町田
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 Microcomputer Technologies Ltd
Original Assignee
NEC Microcomputer Technologies 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 Microcomputer Technologies Ltd filed Critical NEC Microcomputer Technologies Ltd
Priority to JP11202315A priority Critical patent/JP2001034482A/en
Publication of JP2001034482A publication Critical patent/JP2001034482A/en
Pending legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To provide a technique generalizing optimization processing in compile processing. SOLUTION: This compile device is provided with a pre-processing type program optimizing device 6 for generating an optimized primitive program 7 described in high standard language by generating and optimizing inside date in a binary tree format from a primitive program 1, a semantic analysis device 51 for generating a data structure by applying the semantic analysis to the optimized primitive program, and a code generating device 52 for generating an object program by generating a code from the data structure.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明は、コンパイル装置に
おけるプログラム最適化技術に関する。
[0001] 1. Field of the Invention [0002] The present invention relates to a program optimization technique in a compiling device.

【0002】[0002]

【従来の技術】高水準言語で記述された原始プログラム
をコンピュータに実行させるにあたっては、その原始プ
ログラムをコンパイルして機械語やアセンブラ言語で記
述された目的プログラムを生成する言語処理が行われ
る。
2. Description of the Related Art When a computer executes a source program described in a high-level language, language processing for compiling the source program and generating a target program described in a machine language or an assembler language is performed.

【0003】さらに、近年のコンパイル装置において
は、単に原始プログラムを目的プログラムに変換するだ
けでなく、目的プログラムの実行速度を上げるためや、
目的プログラムの占有する記憶領域を小さくするための
最適化処理が、コンパイルの際に行われることが多い。
Further, in recent compiling apparatuses, not only a source program is simply converted into a target program, but also the speed of executing the target program is increased.
Optimization processing for reducing the storage area occupied by the target program is often performed at the time of compilation.

【0004】最適化処理を伴うコンパイル処理において
は、先ず、原始プログラムの字句解析処理及び構文解析
処理を順次に行った後に、最適化処理行っている。そし
て、最適処理されたデータからコード生成を行って、目
的プログラムを生成する。
[0004] In the compiling process involving the optimization process, first, the lexical analysis process and the syntax analysis process of the source program are sequentially performed, and then the optimization process is performed. Then, the target program is generated by performing code generation from the data that has been optimally processed.

【0005】ここで、図5を参照して、最適化処理を行
う従来のコンパイル装置の一例について簡単に説明す
る。図5に示すように、従来例のコンパイル装置3は、
構文意味解析装置31、最適化装置32及びコード生成
装置33により構成されている。そして、このコンパイ
ル装置3は、電子計算機4の制御により、原始プログラ
ム1をアセンブラプログラム2にコンパイルする。
Here, an example of a conventional compiling device for performing an optimization process will be briefly described with reference to FIG. As shown in FIG. 5, the compiling device 3 of the conventional example includes:
It comprises a syntactic and semantic analyzer 31, an optimizer 32, and a code generator 33. The compiling device 3 compiles the source program 1 into an assembler program 2 under the control of the computer 4.

【0006】このコンパイル処理にあたっては、先ず、
構文意味解析装置31により、原始プログラム1の字句
解析処理及び構文解析処理を順次に行い、内部データを
生成する。次に、最適化装置32により、この内部デー
タを最適化し、最適化内部データを生成する。さらに、
コード生成装置33により、最適化内部データからアセ
ンブラ言語の命令を作り出し、アセンブラプログラム2
を生成する。
In the compiling process, first,
The lexical analysis process and the lexical analysis process of the source program 1 are sequentially performed by the syntactic and semantic analysis device 31 to generate internal data. Next, the optimization device 32 optimizes the internal data to generate optimized internal data. further,
The code generator 33 generates an assembler language instruction from the optimized internal data, and executes the assembler program 2
Generate

【0007】[0007]

【発明が解決しようとする課題】しかしながら、従来の
コンパイル装置においては、最適化などのコンパイル処
理の中間的なフェーズが、通常、そのフェーズの入力の
内部データ形式を基本に内部設計されている。この内部
データ形式はコンパイル装置ごとに細かな表現形式が異
なっている。このため、従来は、コンパイル装置ごとに
専用の最適化装置をそれぞれ設計する必要があり、さら
に、コンパイル装置の設計が変更された場合には、最適
化装置を新規に設計し直さなければならなかった。
However, in a conventional compiling apparatus, an intermediate phase of a compiling process such as optimization is usually internally designed based on an internal data format of an input of the phase. This internal data format differs in a detailed expression format for each compiling device. For this reason, conventionally, it is necessary to design a dedicated optimization device for each compiling device, and when the design of the compiling device is changed, it is necessary to newly design the optimization device. Was.

【0008】特に、組み込み分野においては、利用者ご
とに個別の小型中央演算処理装置が開発されている。こ
のため、その小型中央演算処理装置用のクロスコンパイ
ル装置も個別に開発される。その結果、コンパイル装置
別の専用最適化装置の設計に多大な労力と時間とが費や
されていた。
Particularly, in the field of embedding, a small central processing unit has been developed for each user. For this reason, a cross compiling device for the small central processing unit is also separately developed. As a result, a great deal of effort and time has been spent designing a dedicated optimization device for each compiling device.

【0009】本発明は、上記の問題を解決すべくなされ
たものであり、コンパイル処理において、最適化処理を
汎用化することができる技術の提供を目的とする。
SUMMARY OF THE INVENTION The present invention has been made to solve the above-described problem, and has as its object to provide a technique capable of generalizing an optimization process in a compiling process.

【0010】なお、特許公報第2636665号には、
プリプロセッサ方式による最適化コンパイラを有する情
報処理装置において、最適化されたプログラムの実行情
報を採取するにあたり、オリジナルのソースプログラム
の最適化が阻害されないように被測定ソースプログラム
を最適化する技術が開示されている。しかし、この公報
開示の技術においても、オリジナルのソースプログラム
自体の最適化処理を汎用化することに関しては何ら考慮
されていなかった。
[0010] In addition, in Japanese Patent Publication No. 2636665,
In an information processing apparatus having an optimizing compiler based on a preprocessor system, a technique for optimizing a source program under measurement so as to prevent the optimization of an original source program from being taken out in collecting execution information of the optimized program has been disclosed. ing. However, even in the technology disclosed in this publication, no consideration has been given to generalizing the optimization processing of the original source program itself.

【0011】[0011]

【課題を解決するための手段】この目的の達成を図るた
め、本発明の請求項1に係るコンパイル装置によれば、
原始プログラムを最適化し、高水準言語で記述された最
適化原始プログラムを生成するプログラム最適化装置
と、最適化原始プログラムの意味解析を行い、データ構
造を生成する意味解析装置と、このデータ構造からコー
ド生成して目的プログラムを生成するコード生成装置と
を備えた構成としてある。
In order to achieve this object, according to the compiling apparatus of the first aspect of the present invention,
A program optimization device that optimizes a source program and generates an optimized source program written in a high-level language, a semantic analysis device that performs a semantic analysis of the optimized source program and generates a data structure, and And a code generation device for generating a code to generate a target program.

【0012】このように、本発明によれば、コンパイル
処理の意味解析処理の前の段階で、原始プログラムの最
適化処理を行って、高水準のプログラム言語で記述され
た最適化原始プログラムを生成する。高水準のプログラ
ム言語は、JIS規格で統一されている。その結果、最
適化原始プログラムもJIS規格で統一されたものとな
る。このため、最適化原始プログラムは、任意のコンパ
イル装置でコンパイル処理を行うことができる。したが
って、本発明によれば、コンパイラ装置によらず、プロ
グラム最適化処理装置の汎用性を向上させることができ
る。
As described above, according to the present invention, at the stage before the semantic analysis processing of the compilation processing, the optimization processing of the source program is performed to generate the optimized source program described in a high-level programming language. I do. High-level programming languages are unified by the JIS standard. As a result, the optimization source program is also unified by the JIS standard. Therefore, the optimizing source program can be compiled by an arbitrary compiling device. Therefore, according to the present invention, the versatility of the program optimization processing device can be improved regardless of the compiler device.

【0013】また、請求項2記載の発明によれば、プロ
グラム最適化装置は、原始プログラムを二分木形式の内
部データに変換する手段と、この内部データを最適化す
る手段と、最適化された内部データから最適化原始プロ
グラムを生成する手段とを有する構成としてある。
According to a second aspect of the present invention, there is provided a program optimizing device, comprising: means for converting a source program into internal data in a binary tree format; means for optimizing the internal data; Means for generating an optimized source program from internal data.

【0014】二分木形式のデータ構造は、プログラムの
記述形態をそのままデータ化している。このため、二分
木形式の内部データは、原始プログラムの情報をプログ
ラム言語レベルで余さず保持することができる。その結
果、二分木形式の内部データを生成して最適化を行え
ば、原始プログラムの全ての情報を最適化に利用するこ
とができる。
In the binary tree data structure, the description form of the program is directly converted into data. For this reason, the internal data in the binary tree format can hold all the information of the source program at the programming language level. As a result, if the internal data in the binary tree format is generated and optimized, all information of the source program can be used for optimization.

【0015】これにより、二分木形式の内部データ構造
を生成してこれを最適化すれば、内部データ生成による
情報の欠落がないため最適化が抑制されるおそれがな
く、さらに、高水準言語の最適化原始プログラムを確実
に生成することができる。
By generating a binary tree internal data structure and optimizing it, there is no risk of information being lost due to the generation of the internal data, and there is no danger of suppressing the optimization. An optimized source program can be reliably generated.

【0016】また、本発明の請求項3記載のプログラム
最適化装置によれば、コンパイルに先立ち、原始プログ
ラムを二分木形式の内部データに変換する手段と、この
内部データを最適化する手段と、最適化された内部デー
タから高水準言語で記述された最適化原始プログラムを
生成する手段とを有する構成としてある。
According to a third aspect of the present invention, there is provided a program optimizing apparatus for converting a source program into binary tree format internal data prior to compiling, optimizing the internal data, Means for generating an optimized source program described in a high-level language from the optimized internal data.

【0017】このように、本発明のプログラム最適化装
置によれば、コンパイルに先立ち最適化を行って最適化
原始プログラムを生成するので、コンパイラ装置によら
ず、汎用性を有する。また、二分木形式の内部データを
生成し、これを最適化するので、高水準言語で最適化原
始プログラムを確実に生成することができる。
As described above, according to the program optimizing apparatus of the present invention, optimization is performed prior to compiling to generate an optimized source program, so that the program optimizing apparatus has versatility regardless of the compiler apparatus. Further, since the internal data in the binary tree format is generated and optimized, it is possible to reliably generate the optimized source program in a high-level language.

【0018】また、請求項4記載の発明によれば、原始
プログラムを単語ごとに分割する字句解析部と、単語の
各々を個別のデータとして情報化する高級言語パーズ部
と、情報化されたデータから二分木形式の内部データを
生成する内部データ生成部と、生成された内部データを
最適化して最適化内部データを生成する最適化処理部
と、最適化内部データをリスト構造に並び替えて、一列
のデータ構造を生成する内部データパーズ部と、データ
構造を逐次変換して、最適化原始プログラムを生成する
プログラム生成部とを備える構成としてある。
According to the fourth aspect of the present invention, a lexical analyzer for dividing a source program into words, a high-level language parse unit for converting each word into individual data, and From an internal data generating unit that generates internal data in a binary tree format, an optimization processing unit that generates optimized internal data by optimizing the generated internal data, and rearranging the optimized internal data into a list structure. The configuration includes an internal data parse unit that generates a single-row data structure, and a program generation unit that sequentially converts the data structure and generates an optimized source program.

【0019】また、本発明の請求項5記載のコンパイル
方法によれば、原始プログラムをコンパイルして目的プ
ログラムを生成するにあたり、原始プログラムを最適化
して高水準言語で記述された最適化原始プログラムを生
成し、この最適化原始プログラムの意味解析を行ってデ
ータ構造を生成し、このデータ構造からコード生成して
目的プログラムを生成する方法としてある。
Further, according to the compiling method of the present invention, when compiling the source program and generating the target program, the source program is optimized and the optimized source program described in a high-level language is used. In this method, a data structure is generated by performing a semantic analysis of the optimized source program, and a code is generated from the data structure to generate a target program.

【0020】このように、本発明のコンパイル方法によ
れば、コンパイルに先立ち最適化を行って最適化原始プ
ログラムを生成するので、コンパイラ装置によらず、プ
ログラム最適化処理に汎用性を与えることができる。
As described above, according to the compiling method of the present invention, an optimized source program is generated by performing optimization before compiling, so that versatility can be given to the program optimizing process regardless of the compiler device. it can.

【0021】また、本発明の請求項6記載の記録媒体に
よれば、原始プログラムをコンパイルして目的プログラ
ムを生成するにあたり、原始プログラムを最適化して高
水準言語で記述された最適化原始プログラムを生成する
処理と、この最適化原始プログラムの意味解析を行って
データ構造を生成する処理と、このデータ構造からコー
ド生成して目的プログラムを生成する処理とをコンピュ
ータに実行させるコンパイル制御プログラムを記録して
ある。
According to the recording medium of the present invention, when compiling the source program and generating the target program, the source program is optimized and the optimized source program described in a high-level language is used. A compilation control program for causing a computer to execute a process of generating, a process of generating a data structure by performing a semantic analysis of the optimized source program, and a process of generating a code from the data structure and generating a target program is recorded. It is.

【0022】本発明の記録媒体に記録されたプログラム
をコンピュータに読み込ませて実行させることにより、
コンパイル装置によらず、最適化処理を実行することが
可能となる。
By causing a computer to read and execute the program recorded on the recording medium of the present invention,
The optimization process can be executed regardless of the compiling device.

【0023】[0023]

【発明の実施の形態】以下、本発明の実施の形態につい
て、図面を参照して説明する。なお、以下の各実施形態
におけるコンパイル処理は、プログラムに制御されたコ
ンピュータ(電子計算機)により実行される。このプロ
グラムは、例えば、記録媒体により提供される。記録媒
体としては、例えば、磁気ディスク、半導体メモリ、そ
の他の任意の、コンピュータで読み取り可能なものを使
用することができる。また、記録媒体に記録されたプロ
グラムは、通信回線を介してもコンピュータに読込ませ
ることもできる。
Embodiments of the present invention will be described below with reference to the drawings. Note that the compiling process in each of the following embodiments is executed by a computer (electronic computer) controlled by a program. This program is provided, for example, by a recording medium. As the recording medium, for example, a magnetic disk, a semiconductor memory, or any other computer-readable medium can be used. Also, the program recorded on the recording medium can be read by a computer via a communication line.

【0024】まず、図1を参照して、実施形態のコンパ
イル装置の概要について説明する。図1に示すように、
このコンパイル装置1は、電子計算機4により制御され
ている。そして、このコンパイル装置1は、原始プログ
ラム1を最適化し、高水準言語で記述された最適化原始
プログラムを7生成するプログラム最適化装置6と、こ
の最適化原始プログラム7をコンパイルしてアセンブラ
プログラム2を生成する基本コンパイル装置50とを備
えている。
First, an outline of the compiling device of the embodiment will be described with reference to FIG. As shown in FIG.
The compiling device 1 is controlled by a computer 4. The compiling device 1 optimizes the source program 1 to generate an optimized source program 7 described in a high-level language, and a program optimizing device 6 that compiles the optimized source program 7 to generate an assembler program 2 And a basic compiling device 50 that generates

【0025】この基本コンパイル装置50は、最適化原
始プログラム7の意味解析を行い、データ構造を生成す
る構文意味解析装置51と、このデータ構造からコード
生成してアセンブラプログラム2を生成するコード生成
装置52により構成されている。なお、この構文意味解
析装置51及びコード生成装置52の構成及び機能は、
図5に示した従来の構文意味解析装置31及びコード生
成装置33の構成及び機能と同様である。
The basic compiling device 50 performs a semantic analysis of the optimizing source program 7 to generate a data structure, and a code generating device that generates a code from the data structure to generate the assembler program 2. 52. The configuration and functions of the syntactic and semantic analysis device 51 and the code generation device 52 are as follows.
It has the same configuration and function as the conventional syntactic and semantic analysis device 31 and code generation device 33 shown in FIG.

【0026】したがって、このプログラム最適化装置6
は、コンパイル処理の意味解析処理の前の段階で、原始
プログラム1の最適化処理を行って、最適化原始プログ
ラム7を生成する、前処理型のプログラム最適化装置6
である。
Therefore, the program optimizing device 6
Is a preprocessing-type program optimizing device 6 that performs optimization processing of the source program 1 to generate an optimization source program 7 at a stage before the semantic analysis processing of the compilation processing.
It is.

【0027】次に、図2を参照して、プログラム最適化
装置6の構成について説明する。図2は、特にプログラ
ム最適化装置6の内部構成を説明するための、コンパイ
ル装置の機能ブロック図である。図2に示すように、こ
のプログラム最適化装置6は、原始プログラムを二分木
形式の内部データに変換する手段としての字句解析装置
51、高級言語パーズ装置62及び内部データ生成装置
63と、この内部データを最適化する手段としての最適
化処理装置64と、最適化された内部データから最適化
原始プログラムを生成する手段としての内部データパー
ズ装置65及びプログラム生成装置66とにより構成さ
れている。
Next, the configuration of the program optimizing device 6 will be described with reference to FIG. FIG. 2 is a functional block diagram of the compiling device, particularly for explaining the internal configuration of the program optimizing device 6. As shown in FIG. 2, the program optimizing device 6 includes a lexical analyzer 51, a high-level language parsing device 62, and an internal data generator 63 as means for converting a source program into binary tree format internal data. It comprises an optimization processing device 64 as a means for optimizing data, and an internal data parse device 65 and a program generation device 66 as a means for generating an optimized source program from the optimized internal data.

【0028】そして、プログラム最適化装置6により原
始プログラム1を最適化して、最適化原始プログラム2
を生成するにあたり、先ず、字句解析装置61は、入力
された原始プログラム1を記述する高水準言語(高級言
語)の仕様に従い、その原始プログラム1の個々の文字
を認識し、原始プログラム1を単語ごとに分割する。
Then, the source program 1 is optimized by the program optimizing device 6 and the optimized source program 2 is optimized.
First, the lexical analyzer 61 recognizes each character of the source program 1 according to the specification of the input high-level language (high-level language) describing the source program 1, and converts the source program 1 into a word. Divide each.

【0029】続いて、高級言語パーズ装置62は、字句
解析装置61により分割された各単語の並びを判断し
て、その並びの順序を言語仕様の構文と比較する。そし
て、比較の結果、単語の順序と構文とが合致した場合に
は、各単語を個別のデータとして情報化する。なお、比
較の結果、合致しなかった場合には、入力に誤りが有る
旨を出力して、処理を終了する。
Subsequently, the high-level language parsing device 62 determines the arrangement of the words divided by the lexical analyzer 61, and compares the arrangement order with the syntax of the language specification. Then, as a result of the comparison, if the word order and the syntax match, each word is turned into information as individual data. If the results of the comparison do not match, a message indicating that there is an error in the input is output, and the process is terminated.

【0030】次に、内部データ生成装置63は、高級言
語パーズ装置62により情報化されたデータから、二分
木形式の内部データを生成する。
Next, the internal data generator 63 generates internal data in the form of a binary tree from the data computerized by the high-level language parsing device 62.

【0031】ここで、図3を参照して、二分木形式につ
いて説明する。まず、図3の(A)に、原始プログラム
の一部分を示す。そして、図3の(B)に、図3の
(A)に示した原始プログラムを情報化して従来型の内
部形式で表したデータ構造を示す。
Here, the binary tree format will be described with reference to FIG. First, FIG. 3A shows a part of a source program. FIG. 3B shows a data structure in which the source program shown in FIG. 3A is converted into information and represented in a conventional internal format.

【0032】従来のコンパイル装置3の最適化装置32
においては、最適化にあたりデータを情報化する際に、
この従来型の内部形式でデータ構造を記述していた。こ
の従来型の内部形式は、電子計算機が理解できる機械語
を汎用的にしたものであり、電子計算機に処理を行わせ
る順番に命令が並べてある。
The optimizing device 32 of the conventional compiling device 3
In, when the information is converted to information for optimization,
The data structure was described in this conventional internal format. This conventional internal format is a general-purpose machine language that can be understood by a computer, in which instructions are arranged in the order in which the computer performs processing.

【0033】ところで、従来型の内部形式でデータを情
報化した場合、電子計算機によるプログラムの最終的な
動作としては正しく動作するが、データとしては、元の
原始プログラムのレベルよりも電子計算機レベルに近く
なっている。このため、従来型の内部形式で表されたデ
ータは、元の原始プログラムの情報に比べて、情報が欠
落している。
By the way, when data is converted into information in a conventional internal format, the program operates correctly as the final operation of the program by the computer, but the data is at a computer level rather than the level of the original source program. It's getting closer. For this reason, the data represented in the conventional internal format lacks information as compared with the information of the original source program.

【0034】このため、従来型の内部形式のデータを最
適化した場合、情報の欠落により、最適化処理の後に、
高水準言語で記述された最適化原始プログラムを生成す
ることが困難となる場合がある。
For this reason, when the data of the conventional internal format is optimized, due to the lack of information, after the optimization process,
It may be difficult to generate an optimized source program described in a high-level language.

【0035】そこで、本実施形態では、内部データを二
分木方式で表している。ここで、図3の(B)に、図3
の(A)に示した原始プログラムを情報化して二分木形
式で表したデータ構造を示す。二分木形式のデータ構造
は、データ構造そのものが高水準言語の記述に沿ったも
のとなっている。このため、二分木形式によればプログ
ラムの記述形態をそのままデータ化することができる。
その結果、二分木形式の内部データには、原始プログラ
ムの情報をプログラム言語レベルで余さず保持させるこ
とができる。
Therefore, in the present embodiment, the internal data is represented by a binary tree method. Here, FIG.
3A shows a data structure in which the source program shown in FIG. In a binary tree data structure, the data structure itself conforms to the description of a high-level language. Therefore, according to the binary tree format, the description form of the program can be directly converted into data.
As a result, the binary tree format internal data can hold information on the source program at the programming language level.

【0036】これにより、二分木形式の内部データ構造
を生成してこれを最適化すれば、内部データ生成による
情報の欠落がないため最適化が抑制されるおそれがな
く、さらに、高水準言語の最適化原始プログラムを確実
に生成することができる。
Thus, if an internal data structure of the binary tree format is generated and optimized, there is no loss of information due to the generation of the internal data, so there is no danger that the optimization will be suppressed. An optimized source program can be reliably generated.

【0037】次に、図4を参照して、二分木形式のデー
タ構造について詳細に説明する。例えば、「A=B」と
いうプログラムは、字句解析装置61において、
「A」、「=」及び「B」の三つの単語に分解される。
Next, the data structure of the binary tree format will be described in detail with reference to FIG. For example, in the lexical analyzer 61, the program “A = B”
It is broken down into three words, "A", "=", and "B".

【0038】また、プログラム言語は、(1)末端デー
タ(メモリや値)と、(2)式や文の記号を表すデータ
と大きく分けることができる。上記の単語「A」及び
「B」は、(1)端末データに該当する。一方、上記の
単語「=」は、式を表すデータに該当する。
The programming language can be broadly divided into (1) terminal data (memory and values) and (2) data representing expressions and symbols of sentences. The words “A” and “B” correspond to (1) terminal data. On the other hand, the word “=” corresponds to data representing an expression.

【0039】これらの各単語は、上述したように、高級
言語パーズ装置62で単語の並びがプログラムの文法に
合っているか否かを確認後、内部データ生成装置63で
二分木形式の内部データが生成される。
As described above, each of these words is checked by the high-level language parsing device 62 to determine whether or not the arrangement of words matches the grammar of the program. Generated.

【0040】ここで、図4の(A)に、「A=B」とい
うプログラムを二分木形式で表した様子を示す。そし
て、実際の電子計算機の内部では、図4の(A)に示し
た二分木形式を、図4の(B)に示すデータ構造として
メモリ上に格納する。
Here, FIG. 4A shows a state where the program "A = B" is represented in a binary tree format. Then, inside the actual computer, the binary tree format shown in FIG. 4A is stored in the memory as a data structure shown in FIG. 4B.

【0041】なお、図4の(B)データ構造中の、「A
の実行アドレス」とは、入力されたプログラムを実行す
るときのAのアドレスを表し、「Aの保持アドレス」と
は、最適化装置内のAのデータを保持している領域のア
ドレスを表している。また、Bのアドレスについても、
Aと同様である。
Note that "A" in the data structure of FIG.
The “execution address” indicates the address of A when the input program is executed, and the “holding address of A” indicates the address of the area holding the data of A in the optimization device. I have. Also, for the address of B,
Same as A.

【0042】次に、このようにして生成された二分木形
式の内部データは、最適化処理装置64へ渡される。最
適化処理装置64は、内部データ生成装置63により生
成された内部データを最適化手段640により最適化
し、最適化内部データを生成する。なお、最適化手段6
40による最適化にあたっては、従来周知の任意好適な
手段を用いることができる。
Next, the internal data in the binary tree format generated in this way is passed to the optimization processing device 64. The optimization processing device 64 optimizes the internal data generated by the internal data generation device 63 by the optimization means 640, and generates optimized internal data. The optimization means 6
In the optimization by 40, any well-known means conventionally known can be used.

【0043】続いて、内部データパーズ装置65は、先
ず、最適化処理装置64により生成された最適化内部デ
ータそれぞれの構造を、内部データ構文と比較し認識す
る。なお、内部データは、既に情報化されているため、
字句解析の必要はない。また、高級パーズ装置62にお
いても構文を比較済みであるので、ここでは、内部デー
タの構造は、必ず内部データ構文と合致する。さらに、
内部データパーズ装置65は、内部データをリスト構造
に並び替え、一列のデータ構造を生成する。
Subsequently, the internal data parse device 65 first recognizes the structure of each of the optimized internal data generated by the optimization processing device 64 by comparing it with the internal data syntax. Since the internal data has already been turned into information,
There is no need for lexical analysis. In addition, since the syntax is already compared in the high-level parse device 62, the structure of the internal data always matches the internal data syntax here. further,
The internal data parse device 65 rearranges the internal data into a list structure and generates a one-row data structure.

【0044】最後に、プログラム生成装置66は、デー
タ構造を逐次変換して、最適化原始プログラムを生成す
る。ここで、原始プログラムと、それを最適化した最適
化原始プログラムの一例を示す。先ず、下記の表1に、
原始プログラムの一部分の一例を示す。
Finally, the program generating device 66 sequentially converts the data structure to generate an optimized source program. Here, an example of a source program and an optimized source program obtained by optimizing the source program will be described. First, in Table 1 below,
An example of a part of a source program is shown.

【0045】[0045]

【表1】 [Table 1]

【0046】上記の表1のプログラムにおいては、1行
目において、「i」に「10」を代入しているにもかか
わらず、二行目において、「i」の値が「10」である
か判断し、「10」である場合にのみ「j」に「5」を
代入している。この2行目の判断は、実質上意味を持た
ない。そこで、この表1のプログラムを最適化すると、
一般に、下記の表2に示すプログラムが得られる。
In the program shown in Table 1, "10" is substituted for "i" in the first line, but the value of "i" is "10" in the second line. Then, "5" is substituted for "j" only when it is "10". The determination in the second line has substantially no meaning. Therefore, when the program in Table 1 is optimized,
Generally, the programs shown in Table 2 below are obtained.

【0047】[0047]

【表2】 i = 10; j = 5; func ( j );[Table 2] i = 10; j = 5; func (j);

【0048】ところで、もし、「i」がこの後のプログ
ラムで利用されない場合には、「i= 10;」を削除して、
下記の表3に示すように、さらに最適化を図ることがで
きる。
By the way, if "i" is not used in the subsequent program, delete "i = 10;"
As shown in Table 3 below, further optimization can be achieved.

【0049】[0049]

【表3】 j = 5; func ( j );[Table 3] j = 5; func (j);

【0050】さらに、もし、「j」もこの後のプログラ
ムで利用されない場合には、下記の表4に示すように、
一層の最適化を図ることができる。
Further, if "j" is not used in the subsequent program, as shown in Table 4 below,
Further optimization can be achieved.

【0051】[0051]

【表4】 func ( 5 );[Table 4] func (5);

【0052】このようにして、上記の表1の原始プログ
ラムを入力すると、上記の表2〜表4のいずれかに示
す、高水準言語で記述された最適化原始プログラムが生
成される。
As described above, when the source program shown in Table 1 is input, an optimized source program described in any of Tables 2 to 4 described in a high-level language is generated.

【0053】高水準のプログラム言語は、JIS規格で
統一されている。その結果、最適化原始プログラムもJ
IS規格で統一されたものとなる。したがって、コンパ
イルに先立ち最適化を行って最適化原始プログラムを生
成し、この最適化原始プログラムを基本コンパイラ装置
50によりコンパイルするようにすれば、任意のコンパ
イル装置でコンパイル処理を行うことができる。その結
果、プログラム最適化処理装置の汎用性を向上させるこ
とができる。
The high-level programming language is standardized by the JIS standard. As a result, the optimization source program is also J
It is unified by IS standard. Therefore, if optimization is performed prior to compilation to generate an optimized source program, and this optimized source program is compiled by the basic compiler device 50, the compilation process can be performed by any compilation device. As a result, the versatility of the program optimization processing device can be improved.

【0054】上述した実施の形態においては、本発明を
特定の条件で構成した例について説明したが、本発明
は、種々の変更を行うことができる。例えば、上述した
実施の形態においては、目的プログラムとしてアセンブ
ラプログラムを生成する例について説明したが、本発明
では、目的プログラムはこれに限定されない。例えば、
目的プログラムとして機械語を生成してもよい。また、
本発明では、原始プログラムの言語も高水準言語ならば
限定されない。
In the above-described embodiment, an example in which the present invention is configured under specific conditions has been described. However, the present invention can be variously modified. For example, in the above-described embodiment, an example has been described in which an assembler program is generated as a target program. However, the present invention is not limited to this. For example,
A machine language may be generated as a target program. Also,
In the present invention, the language of the source program is not limited as long as it is a high-level language.

【0055】[0055]

【発明の効果】以上、詳細に説明したように、本発明に
よれば、コンパイル処理の意味解析処理の前の段階で、
原始プログラムの最適化処理を行って、高水準のプログ
ラム言語で記述された最適化原始プログラムを生成す
る。高水準のプログラム言語は、JIS規格で統一され
ている。その結果、最適化原始プログラムもJIS規格
で統一されたものとなる。このため、最適化原始プログ
ラムは、任意のコンパイル装置でコンパイル処理を行う
ことができる。したがって、本発明によれば、プログラ
ム最適化処理に汎用性を与えることができる。
As described in detail above, according to the present invention, at the stage before the semantic analysis processing of the compile processing,
Optimize the source program to generate an optimized source program written in a high-level programming language. High-level programming languages are unified by the JIS standard. As a result, the optimization source program is also unified by the JIS standard. Therefore, the optimizing source program can be compiled by an arbitrary compiling device. Therefore, according to the present invention, versatility can be given to the program optimizing process.

【0056】また、二分木形式の内部データを生成し、
これを最適化すれば、原始プログラムの全ての情報を最
適化に利用することができるので、高水準言語で記述さ
れた最適化原始プログラムを確実に生成することができ
る。
Further, internal data in a binary tree format is generated,
By optimizing this, all the information of the source program can be used for optimization, so that an optimized source program described in a high-level language can be reliably generated.

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

【図1】本発明の実施形態のコンパイル装置の構成の概
要を説明するための機能ブロック図である。
FIG. 1 is a functional block diagram illustrating an outline of a configuration of a compiling device according to an embodiment of the present invention.

【図2】実施形態のコンパイル装置を構成するプログラ
ム最適化装置の構成を説明するための機能ブロック図で
ある。
FIG. 2 is a functional block diagram for explaining a configuration of a program optimizing device constituting the compiling device of the embodiment.

【図3】(A)は、原始プログラムの一例であり、
(B)は、従来形式の内部データの一例であり、(C)
は、二分木形式の内部データの一例である。
FIG. 3A is an example of a source program;
(B) is an example of internal data in a conventional format, and (C)
Is an example of internal data in a binary tree format.

【図4】(A)は二分木形式の一例であり、(B)は
(A)に示す二分木形式の内部データのデータ構造の一
例を示す図である。
4A is a diagram illustrating an example of a binary tree format, and FIG. 4B is a diagram illustrating an example of a data structure of internal data in the binary tree format illustrated in FIG.

【図5】従来のコンパイル装置の構成を説明するための
機能ブロック図である。
FIG. 5 is a functional block diagram for explaining a configuration of a conventional compiling device.

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

1 原始プログラム 2 アセンブラプログラム 3 コンパイル装置 4 電子計算機 5 コンパイル装置 6 プログラム最適化装置 7 最適化原始プログラム 31 構文意味解析装置 32 最適化装置 33 コード生成装置 50 基本コンパイル装置 51 構文意意味解析装置 52 コード生成装置 61 字句解析装置 62 高級言語パーズ装置 63 内部データ生成装置 64 最適化処理装置 65 内部データパーズ装置 66 プログラム生成装置 640 最適化手段 Reference Signs List 1 source program 2 assembler program 3 compiling device 4 computer 5 compiling device 6 program optimizing device 7 optimizing source program 31 syntactic and semantic analyzing device 32 optimizing device 33 code generating device 50 basic compiling device 51 syntactic and semantic analyzing device 52 code Generation device 61 Lexical analysis device 62 High-level language parse device 63 Internal data generation device 64 Optimization processing device 65 Internal data parse device 66 Program generation device 640 Optimization means

Claims (6)

【特許請求の範囲】[Claims] 【請求項1】 原始プログラムを最適化し、高水準言語
で記述された最適化原始プログラムを生成するプログラ
ム最適化装置と、 前記最適化原始プログラムの意味解析を行い、データ構
造を生成する意味解析装置と、 このデータ構造からコード生成して目的プログラムを生
成するコード生成装置とを備えたことを特徴とするコン
パイル装置。
1. A program optimization device for optimizing a source program and generating an optimized source program described in a high-level language, and a semantic analysis device for performing a semantic analysis of the optimized source program and generating a data structure. And a code generator for generating a target program by generating a code from the data structure.
【請求項2】 前記プログラム最適化装置は、前記原始
プログラムを二分木形式の内部データに変換する手段
と、 この内部データを最適化する手段と、 最適化された内部データから最適化原始プログラムを生
成する手段とを有することを特徴とする請求項1記載の
コンパイル装置。
2. The program optimizing device includes: means for converting the source program into internal data in a binary tree format; means for optimizing the internal data; and optimizing the source program from the optimized internal data. 2. The compiling device according to claim 1, further comprising: means for generating.
【請求項3】 コンパイルに先立ち、原始プログラムを
二分木形式の内部データに変換する手段と、 この内部データを最適化する手段と、 最適化された内部データから高水準言語で記述された最
適化原始プログラムを生成する手段とを有することを特
徴とするプログラム最適化装置。
3. A means for converting a source program into internal data in a binary tree format prior to compilation, a means for optimizing the internal data, and an optimization described in a high-level language from the optimized internal data Means for generating a source program.
【請求項4】 前記原始プログラムを単語ごとに分割す
る字句解析部と、 前記単語の各々を個別のデータとして情報化する高級言
語パーズ部と、 情報化された前記データから二分木形式の内部データを
生成する内部データ生成部と、 生成された内部データを最適化して最適化内部データを
生成する最適化処理部と、 前記最適化内部データをリスト構造に並び替えて、一列
のデータ構造を生成する内部データパーズ部と、 前記データ構造を逐次変換して、最適化原始プログラム
を生成するプログラム生成部とを備えることを特徴とす
る請求項3記載のプログラム最適化装置。
4. A lexical analyzer for dividing the source program into words, a high-level language parse unit for converting each of the words into individual data, and internal data in a binary tree format based on the converted data. An internal data generation unit for generating the internal data; an optimization processing unit for generating the optimized internal data by optimizing the generated internal data; and rearranging the optimized internal data into a list structure to generate a one-row data structure. 4. The program optimizing device according to claim 3, further comprising: an internal data parse unit that performs a sequential conversion of the data structure to generate an optimized source program.
【請求項5】 原始プログラムをコンパイルして目的プ
ログラムを生成するにあたり、 前記原始プログラムを最適化して高水準言語で記述され
た最適化原始プログラムを生成し、 この最適化原始プログラムの意味解析を行ってデータ構
造を生成し、 このデータ構造からコード生成して目的プログラムを生
成することを特徴とするコンパイル方法。
5. When compiling a source program and generating a target program, the source program is optimized to generate an optimized source program described in a high-level language, and a semantic analysis of the optimized source program is performed. And generating a target program by generating a code from the data structure.
【請求項6】 原始プログラムをコンパイルして目的プ
ログラムを生成するにあたり、 前記原始プログラムを最適化して高水準言語で記述され
た最適化原始プログラムを生成する処理と、 この最適化原始プログラムの意味解析を行ってデータ構
造を生成する処理と、 このデータ構造からコード生成して目的プログラムを生
成する処理とをコンピュータに実行させるコンパイル制
御プログラムを記録したコンピュータ読取可能な記録媒
体。
6. Compiling a source program to generate a target program, optimizing the source program to generate an optimized source program described in a high-level language, and analyzing the semantics of the optimized source program. And a computer-readable recording medium storing a compile control program for causing a computer to execute a process of generating a data structure by performing the above process and a process of generating a target program by generating a code from the data structure.
JP11202315A 1999-07-15 1999-07-15 Compile device, program optimizing device, compile processing method and recording medium Pending JP2001034482A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP11202315A JP2001034482A (en) 1999-07-15 1999-07-15 Compile device, program optimizing device, compile processing method and recording medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP11202315A JP2001034482A (en) 1999-07-15 1999-07-15 Compile device, program optimizing device, compile processing method and recording medium

Publications (1)

Publication Number Publication Date
JP2001034482A true JP2001034482A (en) 2001-02-09

Family

ID=16455520

Family Applications (1)

Application Number Title Priority Date Filing Date
JP11202315A Pending JP2001034482A (en) 1999-07-15 1999-07-15 Compile device, program optimizing device, compile processing method and recording medium

Country Status (1)

Country Link
JP (1) JP2001034482A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9280328B2 (en) 2013-04-17 2016-03-08 International Business Machines Corporation Method for optimizing binary code in language having access to binary coded decimal variable, and computer and computer program

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9280328B2 (en) 2013-04-17 2016-03-08 International Business Machines Corporation Method for optimizing binary code in language having access to binary coded decimal variable, and computer and computer program
US9858054B2 (en) 2013-04-17 2018-01-02 International Business Machines Corporation Method for optimizing binary code in language having access to binary coded decimal variable, and computer and computer program

Similar Documents

Publication Publication Date Title
US5606697A (en) Compiler system for language processing program
US7784039B2 (en) Compiler, compilation method, and compilation program
US7823139B2 (en) Method and system for translating programming languages
US20070226720A1 (en) System and Method for Efficiently Passing Information Between Compiler and Post-Compile-Time Software
US7917899B2 (en) Program development apparatus, method for developing a program, and a computer program product for executing an application for a program development apparatus
CN117075909B (en) Compiling method, electronic device and medium for realizing parallel programming
KR20080045545A (en) Method of pre-processing conditional region
JP2001034482A (en) Compile device, program optimizing device, compile processing method and recording medium
CN113031952A (en) Method and device for determining execution code of deep learning model and storage medium
CN116560667B (en) Splitting scheduling system and method based on precompiled delay execution
CN117008919A (en) Analysis method and device of simulation model file, electronic equipment and storage medium
JP2000242504A (en) Compiler device
JPH07121379A (en) Plural languages mixing compiler
JP3003459B2 (en) Program creation support device
JP2009515243A (en) Method for generating a simulation program executable on a host computer
JP3323147B2 (en) Compiling device, compiling method, and recording medium recording compiler program
JP3141945B2 (en) Compiling device
CN113900657A (en) Method for reading data rule, electronic device and storage medium
JPH11195011A (en) Language translation processor, language translation processing method and record medium recording language translation processing program
CN116560761A (en) Global function information acquisition method and device, electronic equipment and storage medium
JP2001125793A (en) Compiler system, compile method and recording medium
JP3226172B2 (en) Inline expansion system
JP3018783B2 (en) Compilation method
JPH0561687A (en) Processing system for compiler
JPH08161179A (en) Method for executing one sentence

Legal Events

Date Code Title Description
A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20040217