JPH0239241A - Compiler - Google Patents

Compiler

Info

Publication number
JPH0239241A
JPH0239241A JP19036788A JP19036788A JPH0239241A JP H0239241 A JPH0239241 A JP H0239241A JP 19036788 A JP19036788 A JP 19036788A JP 19036788 A JP19036788 A JP 19036788A JP H0239241 A JPH0239241 A JP H0239241A
Authority
JP
Japan
Prior art keywords
complex number
number type
type
mixed
type 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
JP19036788A
Other languages
Japanese (ja)
Inventor
Midori Fujimaki
藤巻 緑
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NEC Corp
Original Assignee
NEC Corp
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 Corp filed Critical NEC Corp
Priority to JP19036788A priority Critical patent/JPH0239241A/en
Publication of JPH0239241A publication Critical patent/JPH0239241A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To shorten the executing time of a compiler by deciding and detecting a replaceable operator to an arithmetical formula including a mixed operation of the complex number type data and another type data and changing the operation order of the arithmetical formula. CONSTITUTION:A mixed operation detecting means 3 analyzes a source program 1 and decides whether an arithmetical formula includes or not a mixed operation of a complex number type data and another type data. An operation order change detecting means 4 decides whether an operation of a type other than the complex number type that can be calculated is included or not before a complex number type operation against said detected mixed operation. An operation order change processing means 5 changes an internal table of a compiler so that the detected operation of a type other than the complex number type one is carried out before the complex number type operation. Then a code generating means 6 produces an object program based on the changed internal table of the compiler.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明は、コンパイラで行われる算術混合演算の最適化
手段に関する。
DETAILED DESCRIPTION OF THE INVENTION [Field of Industrial Application] The present invention relates to means for optimizing mixed arithmetic operations performed by a compiler.

〔概要〕〔overview〕

本発明は、複素数型データと非複素数型データとが混在
する算術式を含むソースプログラムをオブジェクトプロ
グラムに翻訳する手段において、可換律が成立する範囲
内で演算順序を変更することにより、 非複素数型データの複素数型データへの型変換の回数を
減らし、プログラムの実行時間の短縮が図れるようにし
たものである。
The present invention provides means for translating a source program containing an arithmetic expression containing a mixture of complex number data and non-complex number data into an object program, by changing the order of operations within the range where the commutativity law holds. This reduces the number of times type data is converted to complex number data, thereby reducing program execution time.

〔従来の技術〕[Conventional technology]

従来のコンパイラでは、算術混合演算を含む算術式に対
し複素数型演算より先に演算可能な複素数型以外の型の
演算が含まれている場合でもソースプログラムに記述さ
れている算術式に忠実に従ってコンパイラの内部テーブ
ルを生成し、その内部テーブルに基づきオブジェクトプ
ログラムを生成していた。
Conventional compilers faithfully follow the arithmetic expressions written in the source program, even if the arithmetic expressions include arithmetic mixed operations and include operations of types other than complex number types that can be operated on before complex number type operations. An internal table was generated, and an object program was generated based on the internal table.

表 例えば表に示すFORTRANソースプログラムの場合
に実数型データと複素数型データの混合演算を含む算術
式C1=C2:*R1*R2に対して第2図に示す木構
造の内部テーブルが生成され、第4図に示すオブジェク
トプログラムが生成されていた。
For example, in the case of the FORTRAN source program shown in the table, the tree-structured internal table shown in FIG. The object program shown in FIG. 4 has been generated.

第4図に示すオブジェクトプログラムの演算順序を以下
に示す。実数型データR1を複素数型データR1’ に
型変換を行う(ステップ511)。複素数型データR1
’ と複素数型データC2の複素数型乗算演算を行い作
業域Tに格納する(ステップ512)。実数型データR
2を複素数型データR2’に型変換を行う(ステップ5
13)。作業域Tと複素数型データR2’の複素数型乗
算演算を行い、作業域Tに格納する(ステップ514)
。作業域Tを複素数型データC1に格納する(ステップ
515)。
The calculation order of the object program shown in FIG. 4 is shown below. The real number type data R1 is converted into complex number type data R1' (step 511). Complex number type data R1
' and complex number type data C2 is performed and stored in the work area T (step 512). Real number data R
2 to complex number type data R2' (step 5
13). A complex type multiplication operation is performed on the work area T and complex type data R2', and the result is stored in the work area T (step 514).
. The work area T is stored in the complex number type data C1 (step 515).

〔発明が解決しようとする問題点〕[Problem that the invention seeks to solve]

このような従来のコンパイラでは、複素数型データと複
素数型以外の型のデータの混合演算が含まれる算術式に
対し、可換な演算子であっても演算順序の変更は行わな
いで演算子が出現した順序に演算を行うオブジェクトプ
ログラムを生成していた。
With such conventional compilers, for arithmetic expressions that include mixed operations on complex number data and data of non-complex number types, operators are processed without changing the order of operations even if the operators are commutative. An object program was generated that performed operations in the order in which they appeared.

したがって、複素数型データと複素数型以外の型のデー
タの混合演算を行うごとに複素数型以外の型のデータを
複素数型に型変換を行うオブジェクトプログラムが必要
になる欠点がある。また、実部と虚部とがある複素数型
の演算数は実数型の演算数よりも多く、このような混合
演算が多くなる程演算数が増加する欠点がある。
Therefore, there is a drawback that an object program is required to convert data of a type other than complex number type to complex number type each time a mixed operation of complex number type data and data of a type other than complex number type is performed. In addition, the number of operations for complex number types having a real part and imaginary part is greater than the number of operations for real numbers, and there is a drawback that the number of operations increases as the number of such mixed operations increases.

本発明はこのような欠点を除去するもので、型変換およ
び演算数の少ないオブジェクトプログラムを生成できる
コンパイラを提供することを目的とする。
The present invention aims to eliminate these drawbacks, and aims to provide a compiler that can generate object programs with fewer type conversions and fewer operations.

〔問題点を解決するための手段〕[Means for solving problems]

本発明は、算術式を含むソースプログラムが与えられ、
所定の演算順序でこの算術式を演算する実行単位からな
る処理プログラムを含むオブジェクトプログラムを生成
するコード生成手段を備えたコンパイラにおいて、算術
式中に複素数の実部および虚部を含む複素数型データと
複素数の実部または虚部の一方である非曳素数型データ
との混合演算を含むか否かを検出する混合演算検出手段
と、この混合演算検出手段で混合演算が検出されたとき
に、この混合演算中に複素数型データの演算に先行して
実行した演算に対し可換律が成立する非複素数型データ
の演算を含むか否かを検出する演算順序変更検出手段と
、この演算順序変更検出手段が検出した可換律の成立す
る演算順序に変更された演算順序を上記コード生成手段
に与える演算順序変更処理手段とを備えたことを特徴と
する。
The present invention provides a source program including an arithmetic expression,
In a compiler equipped with a code generation means for generating an object program including a processing program consisting of an execution unit that operates on this arithmetic expression in a predetermined order of operations, a compiler that generates an object program that includes a processing program consisting of an execution unit that operates on this arithmetic expression in a predetermined order of operations is used to generate complex number type data that includes real and imaginary parts of a complex number in an arithmetic expression. mixed operation detection means for detecting whether or not a mixed operation with non-prime type data that is either the real part or the imaginary part of a complex number is included; and when the mixed operation detection means detects a mixed operation, An operation order change detection means for detecting whether or not an operation on non-complex number type data for which a commutative law holds with respect to an operation executed prior to an operation on complex number type data during a mixed operation is included, and this operation order change detection means. The present invention is characterized by comprising an operation order change processing means for providing the code generation means with an operation order changed to an operation order in which the commutativity law detected by the means is satisfied.

〔作用〕[Effect]

ソースプログラムを解析して算術式中に複素数型データ
と複素数型以外の型のデータとの混合演算が含まれてい
るか否かを判定し、検出する。複素数型データと複素数
型以外の型のデータとの混合演算が検出された場合に、
その混合演算中に複素数型演算より先に演算可能な複素
数型以外の型の演算が含まれているか否か判定し、検出
する。
A source program is analyzed to determine and detect whether an arithmetic expression contains a mixed operation of complex number type data and data of a type other than complex number type. If a mixed operation between complex number data and data of a type other than complex number type is detected,
It is determined and detected whether or not the mixed operation includes an operation of a type other than the complex number type that can be performed before the complex number type operation.

該当する複素数型以外の型の演算が検出された場合に、
それらの演算が複素数型演算より先に行われるようにコ
ンパイラの内部テーブルの変更を行う。変更された内諾
テーブルをもとにオブジェクドブログラムを生成する。
If an operation of a type other than the corresponding complex number type is detected,
Modify the compiler's internal table so that these operations are performed before complex type operations. Generate an object program based on the changed implicit table.

〔実施例〕〔Example〕

以下、本発明の一実施例を図面に基づき説明する。 Hereinafter, one embodiment of the present invention will be described based on the drawings.

第1図はこの実施例の構成を示すブロック構成図である
。この実施例であるコンパイラ2は、第1図に示すよう
に、ソースプログラム1を解析して算術式中に複素数型
データと複素数型以外の型のデータとの混合演算が含ま
れているか否かの判定および検出を行う混合演算検出手
段3と、混合演算検出手段3で検出された複素数型デー
タと複素数型以外の型のデータとの混合演算を対象に複
素数型演算より先に演算可能な複素数型以外の型の演算
が含まれているか否かの判定および検出を行う演算順序
変更検出手段4と、演算順序変更検出手段4て検出され
た複素数型以外の型の演算が複素数型演算より先に行わ
れるようにコンパイラの内部テーブルの変更を行う演算
順序変更処理手段5と、演算順序変更処理手段5で変更
されたコンパイラの内部テーブルに基づきオブジェクト
プログラム7を生成するコード生成手段6とを備える。
FIG. 1 is a block diagram showing the configuration of this embodiment. As shown in FIG. 1, the compiler 2 in this embodiment analyzes the source program 1 to determine whether an arithmetic expression contains a mixed operation of complex number type data and data of a type other than complex number type. A mixed operation detection means 3 that determines and detects a complex number that can be operated before a complex number type operation for a mixed operation of complex number type data detected by the mixed operation detection means 3 and data of a type other than the complex number type. An operation order change detection means 4 that determines and detects whether an operation of a type other than the type is included; computation order change processing means 5 for changing the internal table of the compiler so that the operation order change processing means 5 changes the compiler internal table; and code generation means 6 for generating the object program 7 based on the compiler internal table changed by the operation order change processing means 5. .

すなわち、この実施例は、所定の演算順序で算術式を演
算する実行単位からなる処理プログラムを含むオブジェ
クトプログラムを生成するコード生成手段6と、算術式
中に複素数の実部および虚部を含む複素数型データと複
素数の実部または虚部の一方である非複素数型データと
の混合演算を含むか否かを検出する混合演算検出手段3
と、この混合演算検出手段3で混合演算が検出されたと
きに、この混合演算中に複素数型データの演算に先行し
て実行した演算に対し可換律が成立する非複素数型デー
タの演算を含むか否かを検出する演算順序変更検出手段
4と、この演算順序変更検出手段4が検出した可換律の
成立する演算順序に変更された演算順序をコード生成手
段6に与える演算順序変更処理手段5とを備える。
That is, this embodiment includes a code generation means 6 that generates an object program including a processing program consisting of an execution unit that operates an arithmetic expression in a predetermined order of operations, and a complex number that includes a real part and an imaginary part of a complex number in the arithmetic expression. Mixed operation detection means 3 for detecting whether a mixed operation of type data and non-complex type data that is either the real part or the imaginary part of a complex number is included.
When a mixed operation is detected by this mixed operation detection means 3, an operation on non-complex number type data is performed for which commutativity law holds for the operation executed prior to the operation on complex number type data during this mixed operation. an operation order change detection means 4 for detecting whether or not the operation order change detection means 4 includes an operation order change detection means 4, and an operation order change processing that provides the operation order changed to the operation order that satisfies the commutative law detected by the operation order change detection means 4 to the code generation means 6; means 5.

次に、この実施例の算術混合演算の最適化処理動作を説
明する。表に示すFORTRANソースプログラムがソ
ースプログラム1として読み込まれると、混合演算検出
手段3は表中の算術式ClC2*R1*R2に対して生
成された第2図に示す木構造の内部テーブルに基づき複
素数型データと複素数型以外の型のデータとの混合演算
になっている乗算演算を検出する。次に、演算順序変更
検出手段4は混合演算検出手段3で検出された乗算演算
を対象に複素数型演算より先に演算可能な複素数型以外
の演算が含まれているか否か判定し、第2図に示す木構
造の内部テーブルに基づき実数型データR1およびR2
の乗算演算を検出する。次に、演算順序変更処理手段5
は演算順序変更検出手段4で検出された複素数型演算よ
り先に演算可能な実数型データR1およびR2の乗算演
算を対象に第2図で示した木構造の内部テーブルを第3
図に示す木構造の内部テーブルに変更する。
Next, the optimization processing operation of arithmetic mixed operations in this embodiment will be explained. When the FORTRAN source program shown in the table is read as the source program 1, the mixed operation detection means 3 detects the complex number based on the tree-structured internal table shown in FIG. 2 generated for the arithmetic expression ClC2*R1*R2 in the table. Detects a multiplication operation that is a mixed operation of type data and data of a type other than complex number type. Next, the operation order change detection means 4 determines whether or not the multiplication operation detected by the mixed operation detection means 3 includes an operation other than the complex number type that can be performed before the complex number type operation. Real number type data R1 and R2 based on the tree-structured internal table shown in the figure.
Detects multiplication operations. Next, the operation order change processing means 5
is the tree-structured internal table shown in FIG.
Change to the tree-structured internal table shown in the figure.

最後に、コード生成手段6は演算順序変更処理手段5で
変更されたコンパイラの内部テーブルに基づき第5図に
示すオブジェクトプログラム7を生成する。
Finally, the code generation means 6 generates the object program 7 shown in FIG. 5 based on the internal table of the compiler changed by the operation order change processing means 5.

第5図に示すオブジェクトプログラムの演算順序を以下
に示す。実数型データR1と実数型データR2の実数型
乗算演算を行い、作業域Tに格納する(ステップ521
)。実数型乗算演算結果のデータの作業域Tを複素数型
データの作業域T′に型変換を行う(ステップ522)
。作業域T′と複素数型データC2の複素数型乗算演算
を行い作業域T′に格納する(ステップ523)。作業
域T′を複素数型データC1に格納する(ステップ52
4)。
The calculation order of the object program shown in FIG. 5 is shown below. A real number type multiplication operation is performed on the real number type data R1 and the real number type data R2, and the result is stored in the work area T (step 521
). Type conversion is performed from the work area T of the data of the real number type multiplication operation result to the work area T' of the complex number type data (step 522).
. A complex type multiplication operation is performed on the work area T' and the complex type data C2, and the result is stored in the work area T' (step 523). The work area T' is stored in the complex number type data C1 (step 52
4).

このように、コンパイラ2は複素数型以外の型のデータ
から複素数型データへの型変換および複素数型演算の回
数が減ったオブジェクトプログラム7を生成する。
In this way, the compiler 2 generates the object program 7 in which the number of type conversions from data of a type other than complex number type to complex number data and the number of complex number type operations are reduced.

〔発明の効果〕〔Effect of the invention〕

本発明は、以上説明したように、複素数型データと複素
数型以外の型のデータの混合演算が含まれる算術式に対
して可換な演算子の判定および検出を行い、算術式の演
算順序を変更するので、演算数を減少することが可能に
なり、実行時間を短縮できる効果がある。
As explained above, the present invention determines and detects commutative operators for arithmetic expressions that include mixed operations of complex number data and non-complex number data, and determines the order of operations in the arithmetic expression. Since the number of operations is changed, the number of operations can be reduced, which has the effect of shortening the execution time.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図は本発明実施例の構成を示すプロ7り構成図。 第2図および第3図はコンパイラの内部テーブルの木構
造図。 第4図および第5図はオブジェクトプログラムの内容を
示す図。 1・・・ソースプログラム、2・・・コンパイラ、3・
・・混合演算検出手段、4・・・演算順序変更検出手段
、5・・・演算順序変更処理手段、6・・・コード生成
手段、7・・・オブジェクトプログラム。
FIG. 1 is a block diagram showing the configuration of an embodiment of the present invention. Figures 2 and 3 are tree structure diagrams of the compiler's internal tables. FIG. 4 and FIG. 5 are diagrams showing the contents of the object program. 1... Source program, 2... Compiler, 3.
. . . Mixed operation detection means, 4. Operation order change detection means, 5. Operation order change processing means, 6. Code generation means, 7. Object program.

Claims (1)

【特許請求の範囲】 1、算術式を含むソースプログラムが与えられ、所定の
演算順序でこの算術式を演算する実行単位からなる処理
プログラムを含むオブジェクトプログラムを生成するコ
ード生成手段を備えたコンパイラにおいて、 算術式中に複素数の実部および虚部を含む複素数型デー
タと複素数の実部または虚部の一方である非複素数型デ
ータとの混合演算を含むか否かを検出する混合演算検出
手段と、 この混合演算検出手段で混合演算が検出されたときに、
この混合演算中に複素数型データの演算に先行して実行
した演算に対し可換律が成立する非複素数型データの演
算を含むか否かを検出する演算順序変更検出手段と、 この演算順序変更検出手段が検出した可換律の成立する
演算順序に変更された演算順序を上記コード生成手段に
与える演算順序変更処理手段とを備えたことを特徴とす
るコンパイラ。
[Scope of Claims] 1. In a compiler provided with a source program including an arithmetic expression, and provided with code generation means for generating an object program including a processing program consisting of execution units that operate on the arithmetic expression in a predetermined order of operations. , a mixed operation detection means for detecting whether an arithmetic expression includes a mixed operation of complex number type data including the real part and imaginary part of a complex number and non-complex number type data which is either the real part or the imaginary part of the complex number; , When a mixed operation is detected by this mixed operation detection means,
an operation order change detection means for detecting whether or not the mixed operation includes an operation on non-complex number type data for which a commutative law holds for the operation executed prior to the operation on complex number type data; and this operation order change. 1. A compiler comprising: operation order change processing means for providing the code generation means with an operation order changed to an operation order in which the commutative law detected by the detection means holds.
JP19036788A 1988-07-28 1988-07-28 Compiler Pending JPH0239241A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP19036788A JPH0239241A (en) 1988-07-28 1988-07-28 Compiler

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP19036788A JPH0239241A (en) 1988-07-28 1988-07-28 Compiler

Publications (1)

Publication Number Publication Date
JPH0239241A true JPH0239241A (en) 1990-02-08

Family

ID=16257003

Family Applications (1)

Application Number Title Priority Date Filing Date
JP19036788A Pending JPH0239241A (en) 1988-07-28 1988-07-28 Compiler

Country Status (1)

Country Link
JP (1) JPH0239241A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009134748A (en) * 2006-02-03 2009-06-18 Maeda Corp Information processor, information processing method, program, data structure, and medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009134748A (en) * 2006-02-03 2009-06-18 Maeda Corp Information processor, information processing method, program, data structure, and medium
JP2012248219A (en) * 2006-02-03 2012-12-13 Maeda Corp Information processor, information processing method, program, and data structure

Similar Documents

Publication Publication Date Title
JPS6325733A (en) Compiler processing system
Knuth Invited papers: History of writing compilers
JPH0239241A (en) Compiler
Krohn A parallel approach to code generation for Fortran like compilers
JPS5922140A (en) Interactive compiling system
JPS62274433A (en) Partial compiling system for relational data base control system
JPH0379741B2 (en)
JPH0223429A (en) Optimization processing method for square root reciprocal number
JPS6155738A (en) Determining system of operation mode
JPS63280335A (en) Language processing system
JPS63318605A (en) Nc part program generating device
JPH01128136A (en) Compiling process system
JPH0250730A (en) Language converting system based upon common machine word
JPH0496145A (en) Method and device for measuring test data inclusion rate of software
JPH0269832A (en) System for processing definition operator in expression processing
Diwan Stack tracing in a statically typed language
Clark et al. Improving the reversible programming language r and its supporting tools
JPH01304539A (en) Production system for function level simulator
JPS56157549A (en) Access address check processing system for storage device
JPH04316130A (en) Program preparing system
JPH036672A (en) Graphic editing device
JPS6441934A (en) Method for processing stack of prolog machine
JPH0251739A (en) Loop structure compiling system
JPH03127224A (en) External name changing system
JPH01296347A (en) Error message outputting system for compiler