JPH04256132A - Optimization system for substitute sentence of high level program language - Google Patents

Optimization system for substitute sentence of high level program language

Info

Publication number
JPH04256132A
JPH04256132A JP1723891A JP1723891A JPH04256132A JP H04256132 A JPH04256132 A JP H04256132A JP 1723891 A JP1723891 A JP 1723891A JP 1723891 A JP1723891 A JP 1723891A JP H04256132 A JPH04256132 A JP H04256132A
Authority
JP
Japan
Prior art keywords
variable
assignment
variable allocation
assignment statement
storage area
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
JP1723891A
Other languages
Japanese (ja)
Inventor
Tomoyuki Yui
朋之 湯井
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 JP1723891A priority Critical patent/JPH04256132A/en
Publication of JPH04256132A publication Critical patent/JPH04256132A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PURPOSE:To improve the executing performance of a program. CONSTITUTION:A variable allocation address setting means 3 sets a variable allocation address, i.e., an allocation address of a declared variable in a variable allocation address store area 6 in a name table 5. A variable allocation length setting means 4 sets the variable allocation length in a variable allocation length store area 8 in the table 5. A substitute sentence token saving means 12 saves a substitute sentence token into a substitute sentence token saving area 25. Then a block substitute intermediate language text generating means 13 substitute plural substitute sentences for the single one and sets the variable allocation address and the variable allocation length in en intermediate language operand text 14.

Description

【発明の詳細な説明】[Detailed description of the invention]

【0001】0001

【産業上の利用分野】本発明は高級プログラム言語の代
入文最適化方式に関し、特に高級プログラム言語コンパ
イラがコンパイル時に、定数を変数に代入する代入文が
複数個連続して存在するプログラムにおいて、複数個連
続した代入文を1つの代入文に置換する高級プログラム
言語の代入文最適化方式に関する。
[Field of Industrial Application] The present invention relates to an optimization method for assignment statements in high-level programming languages, and in particular, the present invention relates to an optimization method for assignment statements in high-level programming languages. The present invention relates to an assignment statement optimization method for high-level programming languages that replaces consecutive assignment statements with one assignment statement.

【0002】0002

【従来の技術】従来、高級プログラム言語において、定
数を変数に代入する代入文が複数個連続して存在する場
合は、複数の代入用命令が出力されていた。
2. Description of the Related Art Conventionally, in high-level programming languages, when a plurality of assignment statements for assigning a constant to a variable exist in succession, a plurality of assignment instructions are output.

【0003】0003

【発明が解決しようとする課題】上述した従来の高級プ
ログラム言語においては、定数を変数に代入する代入文
が複数個連続して存在する場合の最適化は行われていな
いので、複数の代入文を1つの代入文に置換できる場合
も、複数の代入用命令が出力されるために実行性能が低
下するという欠点を有していた。
[Problem to be Solved by the Invention] In the conventional high-level programming languages mentioned above, optimization is not performed when there are multiple consecutive assignment statements that assign a constant to a variable. Even when it is possible to replace ``with'' a single assignment statement, there is a drawback that execution performance deteriorates because multiple assignment instructions are output.

【0004】本発明の目的は、プログラムの実行性能を
向上することができる高級プログラム言語の代入文最適
化方式を提供することにある。
An object of the present invention is to provide an assignment statement optimization method for a high-level programming language that can improve program execution performance.

【0005】[0005]

【課題を解決するための手段】本発明の高級プログラム
言語の代入文最適化方式は、高級プログラム言語のソー
スプログラム中に、定数を変数に代入する代入文が複数
個連続して存在する場合に、コンパイラがそのプログラ
ムをコンパイルするとき、複数の代入文を1つの代入文
で置換し、プログラムの実行性能を向上させる高級プロ
グラム言語の代入文最適化方式であって、(A)コンパ
イラの宣言データ処理部内の名前テーブル作成部によっ
て作成される名前テーブル内に変数割り付けアドレス格
納域と、変数割り付け長格納域とを有し、さらに中間語
テキスト生成部によって生成される中間語オペランドテ
キスト内に変数割り付けアドレス格納域と変数割り付け
長格納域とを有し、中間語テキスト生成部が入力する代
入文トークンを保持する代入文トークン退避域を有して
おり、宣言データトークンを入力し、前記名前テーブル
内の変数割り付けアドレス格納域に宣言された変数の割
り付けアドレスである変数割り付けアドレスを設定する
変数割り付けアドレス設定手段、(B)前記名前テーブ
ル内の変数割り付け長格納域に宣言された変数の割り付
け長である変数割り付け長を設定する変数割り付け長設
定手段、 (C)実行文トークンを入力し、代入文を処理する代入
文処理部内にあって代入文トークンを前記代入文トーク
ン退避域へ退避する代入文トークン退避手段、(D)前
記名前テーブルと代入文トークン退避域とを参照し、複
数の代入文を1つのの代入文に置換し、前記中間語オペ
ランドテキスト内の変数割り付けアドレス格納域へ変数
割り付けアドレスを設定し、前記中間語オペランドテキ
スト内の変数割り付け長格納域へ変数割り付け長を設定
するブロック代入中間語テキスト生成手段、を備えて構
成されている。
[Means for Solving the Problems] The optimization method for assignment statements in a high-level programming language of the present invention is applicable to cases where a plurality of assignment statements that assign a constant to a variable exist consecutively in a source program of a high-level programming language. , is an assignment statement optimization method for high-level programming languages that improves program execution performance by replacing multiple assignment statements with a single assignment statement when a compiler compiles the program, wherein: (A) compiler declaration data; The name table created by the name table creation section in the processing section has a variable allocation address storage area and a variable allocation length storage area, and furthermore, the variable allocation address storage area and the variable allocation length storage area are included in the intermediate language operand text generated by the intermediate language text generation section. It has an address storage area and a variable allocation length storage area, and has an assignment statement token save area that holds assignment statement tokens input by the intermediate language text generation section. (B) variable allocation address setting means for setting a variable allocation address that is the allocation address of the variable declared in the variable allocation address storage area in the name table; Variable allocation length setting means for setting a certain variable allocation length; (C) an assignment statement that inputs an executable statement token and saves the assignment statement token to the assignment statement token save area in an assignment statement processing section that processes the assignment statement; token saving means, (D) referring to the name table and the assignment statement token saving area, replacing multiple assignment statements with one assignment statement, and assigning a variable to the variable assignment address storage area in the intermediate language operand text; The apparatus further comprises block assignment intermediate language text generation means for setting an address and setting a variable allocation length in a variable allocation length storage area in the intermediate language operand text.

【0006】[0006]

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

【0007】図1は本発明の高級プログラム言語の代入
文最適化方式の一実施例を示す構成図である。
FIG. 1 is a block diagram showing an embodiment of an assignment statement optimization method for a high-level programming language according to the present invention.

【0008】本実施例の高級プログラム言語の代入文最
適化方式は、図1に示すように、コンパイラの一部であ
る宣言データ処理部1、中間語テキスト生成部10、オ
ブジェクト生成部19、宣言文に対するトークンである
宣言データトークン20、実行文に対するトークンであ
る実行文トークン21、ソースプログラム中の各変数の
宣言ごとに作成される名前テーブル5、中間語テキスト
生成部10により生成される中間語オペランドテキスト
14、代入文の実行文トークンが退避する代入文トーク
ン退避域25、中間語テキストを格納する中間語テキス
トファイル22、オブジェクトを格納するオブジェクト
ファイル24から構成されている。
As shown in FIG. 1, the assignment statement optimization method for the high-level programming language of this embodiment consists of a declaration data processing section 1, an intermediate text generation section 10, an object generation section 19, and a declaration data processing section 1, which are part of the compiler. A declaration data token 20 which is a token for a statement, an executable statement token 21 which is a token for an executable statement, a name table 5 created for each declaration of each variable in the source program, and an intermediate language generated by the intermediate language text generation unit 10. It consists of an operand text 14, an assignment statement token save area 25 where executable statement tokens of assignment statements are saved, an intermediate language text file 22 where intermediate language text is stored, and an object file 24 where objects are stored.

【0009】さらに、宣言データ処理部1は、名前テー
ブル作成部2を有し、名前テーブル作成部2は、変数割
り付けアドレス設定手段3と変数割り付け長設定手段4
とを含んで構成されている。
Furthermore, the declaration data processing section 1 has a name table creation section 2, and the name table creation section 2 has variable allocation address setting means 3 and variable allocation length setting means 4.
It is composed of:

【0010】また、名前テーブル5は、変数割り付けア
ドレス格納域6と変数割り付け長格納域8とを含んで構
成されている。
The name table 5 also includes a variable allocation address storage area 6 and a variable allocation length storage area 8.

【0011】また、中間語テキスト生成部10は、代入
文処理部11を含み、代入文処理部11は、代入文トー
クン退避手段12とブロッ代入中間語テキスト生成手段
13とを含んで構成されている。
Further, the intermediate language text generation section 10 includes an assignment statement processing section 11, and the assignment statement processing section 11 includes an assignment statement token saving means 12 and a block assignment intermediate language text generation means 13. There is.

【0012】また、中間語オペランドテキスト14は、
変数割り付けアドレス格納域15と変数割り付け長格納
域17とを含んで構成されている。
[0012] Furthermore, the intermediate language operand text 14 is
It is configured to include a variable allocation address storage area 15 and a variable allocation length storage area 17.

【0013】次に、動作を説明する。Next, the operation will be explained.

【0014】図1において、コンパイラが起動されると
、宣言データ処理部1、中間語テキスト生成部10、オ
ブジェクト生成部19が順次起動される。
In FIG. 1, when the compiler is activated, the declaration data processing unit 1, intermediate language text generation unit 10, and object generation unit 19 are activated in sequence.

【0015】宣言データ処理部1が起動されると、名前
テーブル作成部2が起動され、さらに名前テーブル作成
部2から変数割り付けアドレス設定手段3、変数割り付
け長設定手段4が順次起動される。
When the declaration data processing section 1 is activated, the name table creation section 2 is activated, and further, the variable allocation address setting means 3 and the variable allocation length setting means 4 are activated in sequence from the name table creation section 2.

【0016】名前テーブル作成部2は、宣言された変数
の情報を有する宣言データトークン20を入力し、入力
された変数情報から、図2に示すように名前テーブル5
を作成する。そして、変数割り付けアドレス設定手段3
は、変数の宣言された順に、その割り付けアドレス7を
決定し、名前テーブル5内の変数割り付けアドレス格納
域6へ設定する。また、変数割り付け長設定手段4は、
宣言された変数の長さ情報を宣言データトークン20よ
り得て変数割り付け長9とし、これを変数割り付け長格
納域8へ設定する。
The name table creation unit 2 inputs a declaration data token 20 having information on declared variables, and creates a name table 5 from the input variable information as shown in FIG.
Create. Then, variable allocation address setting means 3
determines the allocation addresses 7 of the variables in the order in which they are declared, and sets them in the variable allocation address storage area 6 in the name table 5. Further, the variable allocation length setting means 4
The length information of the declared variable is obtained from the declaration data token 20 and set as the variable allocation length 9, which is set in the variable allocation length storage area 8.

【0017】また、中間語テキスト生成部10が起動さ
れると、代入文処理部11が起動され、さらに代入文処
理部11から代入文トークン退避手段12、ブロッ代入
中間語テキスト生成手段13が順次起動される。
Furthermore, when the intermediate language text generation section 10 is activated, the assignment statement processing section 11 is activated, and further, the assignment statement token saving means 12 and the block assignment intermediate language text generation means 13 are sequentially executed from the assignment statement processing section 11. will be activated.

【0018】代入文トークン退避手段12は、実行文ト
ークン21を入力し、入力された実行文が代入文である
間、代入文トークンを代入文トークン退避域25へ退避
させる。ブロッ代入中間語テキスト生成手段13は、代
入文トークン退避域25に退避させられている代入文ト
ークンを順次参照し、参照したときに、代入される変数
に対する名前テーブル5内の変数割り付けアドレス7と
変数割り付け長9とを得て、代入文トークン退避域25
に退避されている代入文トークンの代入される変数がメ
モリ上で連続しているか否かの判定を行う。メモリ上で
連続しているか否かの判定は、式(n番目の代入文の代
入される変数の割り付けアドレス+n番目の代入文の代
入される変数の割り付け長)と(n+1番目の代入文の
代入される変数の割り付けアドレス)が等しいときに、
メモリ上で連続しているものとする。
The assignment statement token saving means 12 receives an executable statement token 21 and saves the assignment statement token to an assignment statement token save area 25 while the input executable statement is an assignment statement. The block assignment intermediate language text generation means 13 sequentially refers to the assignment statement tokens saved in the assignment statement token save area 25, and when referenced, the variable assignment address 7 in the name table 5 for the variable to be assigned. Obtain variable allocation length 9 and save assignment statement token area 25
It is determined whether the variables to which the assignment statement tokens saved in are assigned are consecutive in memory. To determine whether they are consecutive in memory, use the expression (allocation address of the variable to be assigned in the n-th assignment statement + allocation length of the variable to be assigned in the n-th assignment statement) and (n+allocation length of the variable to be assigned in the n-th assignment statement). When the assigned variables (allocated addresses) are equal,
Assume that they are contiguous in memory.

【0019】代入文トークン退避域25に退避されてい
る代入文トークンの代入される変数がメモリ上で連続し
ており、かつ代入するデータがすべて定数のときに、代
入文トークン退避域25に退避されている代入文トーク
ンすべてを1つの代入文トークンで置換する。その1つ
の代入文トークンの代入される変数に対して、中間語オ
ペランドテキスト14が生成される。
When the variables to which the assignment statement tokens saved in the assignment statement token save area 25 are assigned are continuous in memory and all the data to be assigned are constants, the assignment statement tokens saved in the assignment statement token save area 25 are saved to the assignment statement token save area 25. Replace all assigned assignment statement tokens with one assignment statement token. Intermediate operand text 14 is generated for the variable to be assigned to that one assignment statement token.

【0020】中間語オペランドテキスト14内の変数割
り付けアドレス格納域15、及び変数割り付け長格納域
17には、それぞれ、代入文トークン退避域25の最初
の代入文の代入される変数の変数割り付けアドレス16
と、代入文トークン退避域25内のすべての代入される
変数の割り付け長を加算したものを変数割り付け長18
として設定する。縮退された代入文の代入するデータは
、長さが代入される変数の変数割り付け長18と同じで
ある。そして、定数テキストとして中間語テキストファ
イル22へ出力する。
The variable allocation address storage area 15 and the variable allocation length storage area 17 in the intermediate language operand text 14 each contain the variable allocation address 16 of the variable to be assigned in the first assignment statement in the assignment statement token save area 25.
The variable allocation length 18 is the sum of the allocation lengths of all assigned variables in the assignment statement token save area 25.
Set as . The length of the data assigned by the reduced assignment statement is the same as the variable allocation length 18 of the variable to which it is assigned. Then, it is output to the intermediate language text file 22 as constant text.

【0021】オブジェクト生成部19は、中間語テキス
トを入力し、オブジェクトファイル24へオブジェクト
を出力する。
The object generating section 19 inputs the intermediate language text and outputs the object to the object file 24.

【0022】このように、コンパイラがコンパイル時に
、定数を変数に代入する代入文が複数個連続していると
きに、複数の代入文を1つの代入文に置換できるか否か
を判定し、置換可能であれば、複数の代入文を1つの代
入文に置換することにより、プログラムの実行性能を向
上することができる。
[0022] In this way, when compiling, the compiler determines whether or not multiple assignment statements can be replaced with one assignment statement when there are multiple assignment statements that assign constants to variables, and performs the replacement. If possible, program execution performance can be improved by replacing multiple assignment statements with one assignment statement.

【0023】[0023]

【発明の効果】以上説明したように、本発明の高級プロ
グラム言語の代入文最適化方式は、コンパイラがコンパ
イル時に、定数を変数に代入する代入文が複数個連続し
ているときに、複数の代入文を1つの代入文に置換でき
るか否かを判定し、置換可能であれば、複数の代入文を
1つの代入文に置換することにより、プログラムの実行
性能を向上することができるという効果を有している。
[Effects of the Invention] As explained above, the method for optimizing assignment statements in a high-level programming language of the present invention allows the compiler to perform multiple assignment statements that assign a constant to a variable when there are multiple consecutive assignment statements during compilation. The effect is that program execution performance can be improved by determining whether an assignment statement can be replaced with one assignment statement, and if so, replacing multiple assignment statements with one assignment statement. have.

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

【図1】本発明の高級プログラム言語の代入文最適化方
式の一実施例を示すブロック図である。
FIG. 1 is a block diagram showing an embodiment of an assignment statement optimization method for a high-level programming language of the present invention.

【図2】本実施例の高級プログラム言語の代入文最適化
方式における名前テーブルの詳細を示す図である。
FIG. 2 is a diagram showing details of a name table in the assignment statement optimization method of the high-level programming language of this embodiment.

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

1    宣言データ処理部 2    名前テーブル作成部 3    変数割り付けアドレス設定手段4    変
数割り付け長設定手段 5    名前テーブル 6    変数割り付けアドレス格納域7    変数
割り付けアドレス 8    変数割り付け長格納域 9    変数割り付け長 10    中間語テキスト生成部 11    代入文処理部 12    代入文トークン退避手段 13    ブロッ代入中間語テキスト生成手段14 
   中間語オペランドテキスト15    変数割り
付けアドレス格納域16    変数割り付けアドレス 17    変数割り付け長格納域 18    変数割り付け長 19    オブジェクト生成部 20    宣言データトークン 21    実行文トークン 22    中間語テキストファイル 24    オブジェクトファイル 25    代入文トークン退避域
1 Declaration data processing section 2 Name table creation section 3 Variable allocation address setting means 4 Variable allocation length setting means 5 Name table 6 Variable allocation address storage area 7 Variable allocation address 8 Variable allocation length storage area 9 Variable allocation length 10 Intermediate text generation Part 11 Assignment statement processing unit 12 Assignment statement token saving means 13 Block assignment intermediate language text generation means 14
Intermediate language operand text 15 Variable allocation address storage area 16 Variable allocation address 17 Variable allocation length storage area 18 Variable allocation length 19 Object generation unit 20 Declaration data token 21 Executable statement token 22 Intermediate language text file 24 Object file 25 Assignment statement token save area

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】  高級プログラム言語のソースプログラ
ム中に、定数を変数に代入する代入文が複数個連続して
存在する場合に、コンパイラがそのプログラムをコンパ
イルするとき、複数の代入文を1つの代入文で置換し、
プログラムの実行性能を向上させる高級プログラム言語
の代入文最適化方式であって、 (A)コンパイラの宣言データ処理部内の名前テーブル
作成部によって作成される名前テーブル内に変数割り付
けアドレス格納域と、変数割り付け長格納域とを有し、
さらに中間語テキスト生成部によって生成される中間語
オペランドテキスト内に変数割り付けアドレス格納域と
変数割り付け長格納域とを有し、中間語テキスト生成部
が入力する代入文トークンを保持する代入文トークン退
避域を有しており、宣言データトークンを入力し、前記
名前テーブル内の変数割り付けアドレス格納域に宣言さ
れた変数の割り付けアドレスである変数割り付けアドレ
スを設定する変数割り付けアドレス設定手段、(B)前
記名前テーブル内の変数割り付け長格納域に宣言された
変数の割り付け長である変数割り付け長を設定する変数
割り付け長設定手段、 (C)実行文トークンを入力し、代入文を処理する代入
文処理部内にあって代入文トークンを前記代入文トーク
ン退避域へ退避する代入文トークン退避手段、(D)前
記名前テーブルと代入文トークン退避域とを参照し、複
数の代入文を1つのの代入文に置換し、前記中間語オペ
ランドテキスト内の変数割り付けアドレス格納域へ変数
割り付けアドレスを設定し、前記中間語オペランドテキ
スト内の変数割り付け長格納域へ変数割り付け長を設定
するブロック代入中間語テキスト生成手段、を備えるこ
とを特徴とする高級プログラム言語の代入文最適化方式
[Claim 1] When a source program of a high-level programming language contains multiple consecutive assignment statements that assign a constant to a variable, when the compiler compiles the program, the multiple assignment statements are combined into one assignment. replace with the sentence,
This is an assignment statement optimization method for high-level programming languages that improves program execution performance, and includes: (A) variable allocation address storage area and variable It has an allocated length storage area,
Furthermore, the intermediate language operand text generated by the intermediate language text generation unit has a variable allocation address storage area and a variable allocation length storage area, and an assignment statement token save area that holds the assignment statement token input by the intermediate language text generation unit. (B) variable allocation address setting means for inputting a declaration data token and setting a variable allocation address that is an allocation address of the declared variable in the variable allocation address storage area in the name table; Variable allocation length setting means for setting the variable allocation length that is the allocation length of the variable declared in the variable allocation length storage area in the name table; (C) Inside the assignment statement processing unit that inputs the executable statement token and processes the assignment statement. (D) an assignment statement token saving means for saving assignment statement tokens to the assignment statement token save area; block substitution intermediate language text generation means for replacing, setting a variable allocation address in a variable allocation address storage area in the intermediate language operand text, and setting a variable allocation length in a variable allocation length storage area in the intermediate language operand text; An assignment statement optimization method for a high-level programming language characterized by the following.
JP1723891A 1991-02-08 1991-02-08 Optimization system for substitute sentence of high level program language Pending JPH04256132A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP1723891A JPH04256132A (en) 1991-02-08 1991-02-08 Optimization system for substitute sentence of high level program language

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP1723891A JPH04256132A (en) 1991-02-08 1991-02-08 Optimization system for substitute sentence of high level program language

Publications (1)

Publication Number Publication Date
JPH04256132A true JPH04256132A (en) 1992-09-10

Family

ID=11938369

Family Applications (1)

Application Number Title Priority Date Filing Date
JP1723891A Pending JPH04256132A (en) 1991-02-08 1991-02-08 Optimization system for substitute sentence of high level program language

Country Status (1)

Country Link
JP (1) JPH04256132A (en)

Similar Documents

Publication Publication Date Title
CA2010056C (en) Method for improving the efficiency of arithmetic code generation in an optimizing compiler using machine independent update instruction generation
US5606697A (en) Compiler system for language processing program
JP2001147819A (en) Optimizing device and recording medium
JP5118745B2 (en) Vectorization of memory access instructions
JP2004234126A (en) Compiler and compiling method
US5450588A (en) Reducing pipeline delays in compilers by code hoisting
JP3539613B2 (en) Array summary analysis method for loops containing loop jump statements
JPH04256132A (en) Optimization system for substitute sentence of high level program language
JPH11345127A (en) Compiler
JPH03135630A (en) Instruction scheduling system
JP5208589B2 (en) Compiling device, compiler, and compiling method
JP2809073B2 (en) Array memory allocation method
JP2585793B2 (en) Compiler system
JPH0689187A (en) Inline expansion optimizing method
JP3921722B2 (en) Compiler processing device
JP2003005982A (en) Method and device for rearranging call instruction and program
JPH04107638A (en) Literal constant allocation system
JPH02171831A (en) Data access system for compiler
JP2020086734A (en) compiler
JPH05197565A (en) Constant area allocation processing method
JPH05241851A (en) Constant optimal allocation system
JPH0754511B2 (en) Vectorization processing method
JPH1091456A (en) Method and system for processing input/output repetition of program, and storage medium for storing input/output repetition processing program of program
JPH05119982A (en) Compiler
Tirelo et al. Optimization Techniques for Abstract State Machines-Based Programs