JPH06282444A - Compilation method - Google Patents
Compilation methodInfo
- Publication number
- JPH06282444A JPH06282444A JP6801593A JP6801593A JPH06282444A JP H06282444 A JPH06282444 A JP H06282444A JP 6801593 A JP6801593 A JP 6801593A JP 6801593 A JP6801593 A JP 6801593A JP H06282444 A JPH06282444 A JP H06282444A
- Authority
- JP
- Japan
- Prior art keywords
- computer
- compiler
- performance
- machine language
- machine languages
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 19
- 238000005259 measurement Methods 0.000 claims abstract description 12
- 238000012545 processing Methods 0.000 abstract description 13
- 238000013519 translation Methods 0.000 abstract description 4
- 238000009434 installation Methods 0.000 abstract 1
- 238000011900 installation process Methods 0.000 abstract 1
- 230000015654 memory Effects 0.000 description 11
- 238000012546 transfer Methods 0.000 description 8
- 238000013461 design Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 238000010348 incorporation Methods 0.000 description 2
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 238000007429 general method Methods 0.000 description 1
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
Description
【0001】[0001]
【産業上の利用分野】本発明は、パーソナルコンピュー
タ,ワークステーションおよび汎用計算機において高級
言語をコンパイルするコンパイル方法に関するものであ
る。BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a compiling method for compiling a high level language in a personal computer, a workstation and a general purpose computer.
【0002】[0002]
【従来の技術】COBOLやFORTRANなどの高級言語のコンパ
イラを作成するとき、対象とする計算機で同じ結果を得
るのに複数の機械語または機械語の並びがあった場合、
その計算機の機械語の性能を調べ、目的プログラムの実
行が最も速くなるような機械語または機械語の並びを選
択するのが普通に行われている。2. Description of the Related Art When creating a high-level language compiler such as COBOL or FORTRAN, if there are multiple machine languages or a sequence of machine languages to obtain the same result on the target computer,
It is common practice to examine the machine language performance of the computer and select the machine language or sequence of machine words that will result in the fastest execution of the target program.
【0003】例えば、4バイトのデータをメモリ間で転
送する命令を目的プログラム中に機械語で実現すると
き、対象とする計算機では次の2つの方法があるとす
る。For example, when an instruction to transfer 4-byte data between memories is realized in a machine language in a target program, a target computer has the following two methods.
【0004】1.メモリ間で直接転送する機械語(これ
をMV命令とする)を使用する。 2.レジスタにメモリのデータを格納する機械語(これ
をLD命令とする)を実行した後、レジスタからメモリ
にデータを格納する機械語(これをST命令とする)を
実行する。1. A machine language (this is called an MV instruction) that is directly transferred between memories is used. 2. After the machine language for storing the data in the memory in the register (this is the LD instruction) is executed, the machine language for storing the data in the memory from the register (this is the ST instruction) is executed.
【0005】コンパイラを作成するときは、上記の性能
をハードウェアの設計仕様から調べ、そのうち速い方を
目的プログラムに採用することが一般的な方法である。When creating a compiler, it is a general method to check the above performance from the hardware design specifications and adopt the faster one for the target program.
【0006】汎用計算機では、同一アーキテクチャの計
算機でも小型から超大型までを実現している。この全て
の計算機に共通なコンパイラを作成できれば、コンパイ
ラの開発効率を向上できる。In a general-purpose computer, a computer having the same architecture has realized a small size to an ultra-large size. If a compiler common to all computers can be created, the development efficiency of the compiler can be improved.
【0007】ところが、同一アーキテクチャで機械語の
仕様が同じ計算機であっても、その用途が異なったり、
CPUの設計の目指すところが異なると、上記の例で
は、ある型式の計算機ではMV命令の方が速くても、別
な型式の計算機ではLD命令とST命令の組み合わせの
方が速いというように、目的プログラムに採用すべき機
械語が型式によって異なることがありうる。However, even if computers having the same architecture and the same machine language specifications have different uses,
If the goal of CPU design is different, in the above example, even if the MV instruction is faster on one type of computer, the combination of LD and ST instructions is faster on another type of computer. The machine language to be adopted in the program may vary depending on the model.
【0008】この場合の方策として、従来はコンパイル
時に何らかの方法で稼働する計算機の型式を知り、その
種別に応じて性能のよい方の機械語を目的プログラムの
生成に採用するものがある。As a measure in this case, conventionally, there is a method of knowing a model of a computer which operates by some method at the time of compiling and adopting a machine language having a better performance in generating an object program according to the type.
【0009】[0009]
【発明が解決しようとする課題】しかし、計算機の型式
を知る方法がなかったり、あっても計算機メーカーが非
公開にしている場合には、上記のような方策をコンパイ
ラで実施できず、どちらか一方を固定的に採用せざるを
得ない。このため、コンパイラの作成時に特定の型式の
機械語の性能を考慮して目的プログラムを設計しても、
他の型式ではそれが必ずしも最適な結果をもたらすとは
限らないという問題があった。However, if there is no way to know the model of the computer, or if the computer manufacturer does not disclose it, the above measures cannot be implemented by the compiler. One must be fixedly adopted. Therefore, even if the target program is designed in consideration of the performance of a specific type of machine language when creating the compiler,
Other types have had the problem that they do not always give optimum results.
【0010】また、新しい型式の計算機が開発された場
合にも、機械語の性能が変われば、最適な結果にはなら
ないという問題があった。Further, even when a new type of computer is developed, if the performance of the machine language changes, the optimum result will not be obtained.
【0011】本発明の目的は、機械語の性能を事前に知
らなくても、その型式の計算機に最適な機械語から成る
目的プログラムを作成することができるコンパイル方法
を提供することにある。An object of the present invention is to provide a compiling method capable of creating a target program composed of a machine language most suitable for a computer of that type without knowing the performance of the machine language in advance.
【0012】[0012]
【課題を解決するための手段】本発明は、上記目的を達
成するために、コンパイラの組込時、または翻訳開始時
に、コンパイラ自身が当該形式の計算機の機械語性能を
測定し、前記測定結果に基づき、当該形式の計算機に最
適な機械語を選択するようにしたものである。SUMMARY OF THE INVENTION In order to achieve the above object, the present invention measures the machine language performance of a computer of the format at the time of embedding the compiler or at the start of translation, and Based on the above, the optimum machine language for the computer of the format is selected.
【0013】[0013]
【作用】上記手段によれば、コンパイラの翻訳開始前
に、実際にコンパイルを行う計算機の機械語の性能をコ
ンパイラ自身で測定しておき、目的プログラム生成時に
その結果を参照し、最も性能の良い機械語を選択する。According to the above means, the performance of the machine language of the computer that actually compiles is measured by the compiler itself before the translation of the compiler is started, and the result is referenced when the target program is generated, and the best performance is obtained. Select a machine language.
【0014】これにより、同一アーキテクチャの計算機
において、型式によって機械語の性能が異なり、その形
式を判別する手段がない場合でも、その型式の計算機に
最適な機械語を目的プログラムに採用可能となる。As a result, even in a computer having the same architecture, even if the performance of the machine language differs depending on the model and there is no means for discriminating the format, the machine language most suitable for the computer of the model can be adopted as the target program.
【0015】[0015]
【実施例】以下、本発明を図示する実施例に基づいて詳
細に説明する。DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS The present invention will be described in detail below with reference to illustrated embodiments.
【0016】なお、ここでは、説明を簡略化するため
に、以下のような条件を設けるものとする。In order to simplify the explanation, the following conditions are set here.
【0017】1.最適にしようとする高級言語の命令
を、4バイトのメモリ間の転送とする。 2.上記1.を実現するのに、次の2つの機械語がある
ものとする。1. A high-level language instruction to be optimized is transferred between 4-byte memories. 2. Above 1. To realize, there are the following two machine languages.
【0018】(1)MV命令によって、メモリ間の直接
転送を行う(以下、MV命令処理とする)。 (2)LD命令によって一旦レジスタに格納し、それを
ST命令によってメモリに格納する(以下、LD−ST
命令処理とする)。(1) Direct transfer between memories is performed by an MV instruction (hereinafter referred to as MV instruction processing). (2) Once stored in the register by the LD instruction and stored in the memory by the ST instruction (hereinafter, LD-ST
Command processing).
【0019】図1は、本発明を実現するためのコンパイ
ラの一実施例の構成を示す図であり、ユーザに提供する
コンパイラ101はコンパイラ本体105と、そのコン
パイラ本体105を計算機システムに組み込むための環
境を設定する環境設定処理102とから構成される。FIG. 1 is a diagram showing a configuration of an embodiment of a compiler for implementing the present invention. The compiler 101 provided to the user has a compiler main body 105 and a compiler main body 105 for incorporating the compiler main body 105 into a computer system. An environment setting process 102 for setting an environment.
【0020】環境設定処理102は、さらにコンパイラ
本体105を組み込むための組み込み処理103と、上
記2つのMV命令とLD−ST命令の機械語の処理スピ
ードを各々測定し、どちらが速いかを判断する性能測定
処理104とから成っている。The environment setting process 102 further measures an embedding process 103 for incorporating the compiler main body 105 and a machine language processing speed of the above two MV instructions and LD-ST instructions, and determines which is faster. It comprises a measurement process 104.
【0021】次に、コンパイラ101を組み込むときの
処理の流れを図2のフローチャートで説明する。Next, the flow of processing when the compiler 101 is incorporated will be described with reference to the flowchart of FIG.
【0022】ユーザは、初めにコンパイラ101を自分
の計算機システムに組み込むため環境設定を行う(ステ
ップ202)。The user first sets the environment for incorporating the compiler 101 into his computer system (step 202).
【0023】そして、組み込み時に性能測定処理104
を実行し、MV命令処理の性能測定(ステップ203)
と、LD−ST命令処理の性能を計測し(ステップ20
4)、どちらが速いかを格納用ディスク207に格納す
る(ステップ205)。Then, the performance measuring process 104 at the time of incorporation
To measure the performance of MV instruction processing (step 203)
And the performance of LD-ST instruction processing is measured (step 20
4) Then, which is faster is stored in the storage disk 207 (step 205).
【0024】上記性能測定処理104の性能の計測で
は、汎用計算機であれば、ハードウェア及びオペレーテ
ィングシステム等によるCPU時間を測定できる機能を
用い、コンパイルされる高級言語の転送命令を、MV命
令処理した機械語と、LD−ST命令処理した機械語と
でそれぞれ別々に所定の回数ループさせ、各々の時間を
計測する処理を行う。In the performance measurement of the performance measurement processing 104, a general-purpose computer uses a function capable of measuring the CPU time by the hardware and operating system, and the transfer instruction of the high-level language to be compiled is processed by the MV instruction. The machine language and the LD-ST instruction processed machine language are separately looped a predetermined number of times to measure each time.
【0025】以上のようにしてコンパイラ101の組込
が終了する。ユーザがコンパイラ101を起動してソー
スプログラムを目的プログラムに翻訳するときの動作
を、図3のフローチャートに示す。As described above, the incorporation of the compiler 101 is completed. The operation when the user starts the compiler 101 and translates the source program into the target program is shown in the flowchart of FIG.
【0026】まず、機械語の生成が開始されると(ステ
ップ301)、性能測定処理の結果が格納されているデ
ィスク207より機械語の性能測定結果を入力する(ス
テップ302)。First, when the generation of the machine language is started (step 301), the performance measurement result of the machine language is input from the disk 207 in which the result of the performance measurement processing is stored (step 302).
【0027】次に、コンパイルする命令が転送命令かど
うかをチェックし(ステップ303)、転送命令でなけ
れば、他の生成処理を行い(ステップ308)、転送命
令であれば、それがMV命令とLD−ST命令のどちら
の性能が良いか判断し(ステップ304)、LD−ST
命令の性能が良いと判断されたならば、LD−ST命令
を目的のプログラムの機械語として生成し(ステップ3
05)、逆にMV命令の性能が良いと判断されたなら
ば、MV命令を目的のプログラムの機械語として生成す
る(ステップ306)。Next, it is checked whether the instruction to be compiled is a transfer instruction (step 303). If it is not a transfer instruction, another generation process is performed (step 308). If it is a transfer instruction, it is determined to be an MV instruction. It is judged which performance of the LD-ST instruction is better (step 304), and LD-ST
If the performance of the instruction is judged to be good, the LD-ST instruction is generated as the machine language of the target program (step 3
On the contrary, if it is determined that the performance of the MV instruction is good, the MV instruction is generated as the machine language of the target program (step 306).
【0028】そして、全ての命令がコンパイルされると
処理を終了する(ステップ307)。When all the instructions have been compiled, the process ends (step 307).
【0029】なお、機械語の性能測定は、必ずしもコン
パイラの組込時で行う必要はなく、コンパイラの起動時
に実施してその結果を機械語の生成時に参照できるよう
にしてもよい。It is not always necessary to measure the performance of the machine language at the time of incorporating the compiler, but the performance may be measured at the time of starting the compiler so that the result can be referred to when the machine language is generated.
【0030】すなわち、メモリ間の転送であれば、格納
用ディスク207から性能測定結果を入力し、ステップ
304で目的プログラムの機械語としてMV命令とL
D,ST命令の組み合わせのどちらを採用するかを決定
する性能測定処理をコンパイラに組み込むことにより、
利用者が使用する計算機の型式がわからない場合でも、
その型式に最適な機械語を目的プログラムに採用するこ
とができる。That is, in the case of transfer between memories, the performance measurement result is input from the storage disk 207, and in step 304 the MV instruction and L are used as the machine language of the target program.
By incorporating in the compiler a performance measurement process that determines which combination of D and ST instructions is adopted,
Even if you do not know the model of the computer used by the user,
The optimum machine language for the model can be adopted in the target program.
【0031】また、本実施例ではメモリ間の転送命令に
ついて述べてきたが、本発明はこれに限定されるもので
はなく、例えば2進数の加減乗除と比較、つまり、レジ
スターメモリ間の演算と、一旦メモリの内容をレジスタ
に移した後のレジスタどうしの演算の2通りがある。ま
た、他の例としては、レジスタ内容のシフト、例えば代
数的シフトと、論理的なシフトなどが挙げられる。ま
た、パックデータなどの演算、いわゆるパックデータの
ままの演算と一旦2進数に変換した後の演算などが挙げ
られる。Although the transfer instruction between memories has been described in this embodiment, the present invention is not limited to this. For example, comparison with addition / subtraction / multiplication / division of binary numbers, that is, calculation between register memories, There are two types of operations between registers after the contents of the memory are once transferred to the registers. Another example is shift of register contents, such as algebraic shift and logical shift. Further, there are operations such as operations for packed data, so-called operations for so-called packed data and operations after once converted into binary numbers.
【0032】[0032]
【発明の効果】以上で説明したように本発明は、コンパ
イラの組み込み時、または翻訳開始時に、コンパイラ自
身が当該型式の計算機の機械語性能を測定し、その測定
結果に基づき当該型式の計算機に最適な機械語を選択す
るので、計算機の型式によって機械語の性能が変わる場
合で、型式を知る手段がないときでも、その型式の計算
機に最適な機械語で構成された目的プログラムを作成で
きるといった効果が得られる。As described above, according to the present invention, the compiler itself measures the machine language performance of the computer of the relevant model at the time of incorporating the compiler or at the start of translation, and the computer of the relevant model is determined based on the measurement result. Since the optimum machine language is selected, if the performance of the machine language changes depending on the model of the computer, even if there is no means to know the model, it is possible to create a target program composed of the optimum machine language for the computer of that model. The effect is obtained.
【図1】 本発明を適用したコンパイラの一実施例を示
す構成図である。FIG. 1 is a configuration diagram showing an embodiment of a compiler to which the present invention is applied.
【図2】 コンパイラ組み込み時の処理を示すフローチ
ャートである。FIG. 2 is a flowchart showing processing when a compiler is installed.
【図3】 コンパイラの目的プログラム生成処理を示す
フローチャートである。FIG. 3 is a flowchart showing a target program generation process of a compiler.
101…コンパイラ、102…環境設定処理、103…
コンパイラの組込処理、104…性能測定処理。101 ... Compiler, 102 ... Environment setting processing, 103 ...
Compiler built-in processing, 104 ... Performance measurement processing.
Claims (1)
アーキテクチャの計算機で共通して稼働するコンパイラ
によって原始プログラムを機械語に翻訳するコンパイル
方法であって、コンパイラの組み込み時、または翻訳開
始時に、前記コンパイラ自身が当該型式の計算機の機械
語性能を測定し、前記測定結果に基づき、前記当該型式
の計算機に最適な機械語を選択することを特徴とするコ
ンパイル方法。1. A compiling method for translating a source program into a machine language by a compiler that operates in common on computers of the same architecture that differ in machine language performance depending on the model, wherein the compiler is installed or started to be translated. A compiling method, characterized in that the compiler itself measures the machine language performance of a computer of the relevant type and selects the optimum machine language for the computer of the relevant type based on the measurement result.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP6801593A JPH06282444A (en) | 1993-03-26 | 1993-03-26 | Compilation method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP6801593A JPH06282444A (en) | 1993-03-26 | 1993-03-26 | Compilation method |
Publications (1)
Publication Number | Publication Date |
---|---|
JPH06282444A true JPH06282444A (en) | 1994-10-07 |
Family
ID=13361586
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP6801593A Pending JPH06282444A (en) | 1993-03-26 | 1993-03-26 | Compilation method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JPH06282444A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6021225A (en) * | 1996-10-03 | 2000-02-01 | Nec Corporation | Image processing apparatus |
-
1993
- 1993-03-26 JP JP6801593A patent/JPH06282444A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6021225A (en) * | 1996-10-03 | 2000-02-01 | Nec Corporation | Image processing apparatus |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6078744A (en) | Method and apparatus for improving compiler performance during subsequent compilations of a source program | |
US6973644B2 (en) | Program interpreter | |
JPH05257709A (en) | Parallelism discriminating method and parallelism supporting method using the same | |
US20100095286A1 (en) | Register reduction and liveness analysis techniques for program code | |
JP3546341B2 (en) | Data prefetch method and program generation method for multiple loops | |
JPH02217926A (en) | Compiler | |
WO1992015945A1 (en) | Symbol table for intermediate compiler language | |
US7877741B2 (en) | Method and corresponding apparatus for compiling high-level languages into specific processor architectures | |
US6301652B1 (en) | Instruction cache alignment mechanism for branch targets based on predicted execution frequencies | |
JP4026940B2 (en) | Program converter | |
US7624387B2 (en) | Compiler, program product, compilation device, communication terminal device, and compilation method | |
US20010044930A1 (en) | Loop optimization method and a compiler | |
JP3840149B2 (en) | Compiler, arithmetic processing system, and arithmetic processing method | |
JPH06282444A (en) | Compilation method | |
JP4626032B2 (en) | Program conversion apparatus, program conversion method, and recording medium | |
JPH10320212A (en) | Optimization method for cache | |
Leviathan et al. | Validating software pipelining optimizations | |
JPS62204374A (en) | Double operation optimization processing method | |
JP7026563B2 (en) | High-level synthesis method, high-level synthesis program, high-level synthesis device | |
JP3992122B2 (en) | Source program translation method, source program translation apparatus, and computer-readable program storage medium | |
CN120123041A (en) | Dynamic binary translation method and system for software pipeline code | |
JPH0573335A (en) | Automatic in-line development system for program | |
JPH1083311A (en) | Simulator | |
Alves et al. | A code generator for an application specific pipelined processor | |
JPH07192034A (en) | Interpreter type simulation method |