JPS6057437A - Compiler device - Google Patents

Compiler device

Info

Publication number
JPS6057437A
JPS6057437A JP16554083A JP16554083A JPS6057437A JP S6057437 A JPS6057437 A JP S6057437A JP 16554083 A JP16554083 A JP 16554083A JP 16554083 A JP16554083 A JP 16554083A JP S6057437 A JPS6057437 A JP S6057437A
Authority
JP
Japan
Prior art keywords
block
variable
assignment
register
flow graph
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
JP16554083A
Other languages
Japanese (ja)
Inventor
Naosuke Haruna
春名 修介
Akimi Kamikawa
昭海 上川
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.)
Panasonic Holdings Corp
Original Assignee
Matsushita Electric Industrial Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Matsushita Electric Industrial Co Ltd filed Critical Matsushita Electric Industrial Co Ltd
Priority to JP16554083A priority Critical patent/JPS6057437A/en
Publication of JPS6057437A publication Critical patent/JPS6057437A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To delete a redundant store instruction covering plural blocks and to produce a machine word program having a small quantity of memory occupation, by putting substitution equations to the same variable with superposition into 2 immediately subsequent blocks. CONSTITUTION:A common substitution equation deciding part 24 detects a block A containing plural immediately subsequent blocks in a flow graph memory 23 and checks the equations in these subsequent blocks. When the variable at the left side of a substitution equation detects the same equation, the position information in the flow graphs of two equations is transferred to a register substitution equation producing part 25. The part 25 changes the variable at the left side of the substitution equation into a register which is common to two equations. Then a deciding part 26 for immediately preceding block to be controlled decides an immediately preceding block which is controlled by the block A on the basis of the flow graph. A variable substitution equation producing part 27 adds an equation which substitutes the contents of the register decided by the part 25 to the variable common to two equations at the head of a block in the flow graph. Then all blocks in the memory 23 are processed.

Description

【発明の詳細な説明】 産業上の利用分野 本発明は高級言語ソースプログラムを機械語プログラム
に変換するとき、フローグラフを用いたフロー解析を行
なうコンパイラ装置に関するものである。
DETAILED DESCRIPTION OF THE INVENTION Field of Industrial Application The present invention relates to a compiler device that performs flow analysis using a flow graph when converting a high-level language source program into a machine language program.

従来例の構成とその問題点 近年、マイクロコンピュータのソフトウェア開発には従
来のアセンブラ言語に代り人間がより理解しやすい高級
言語が用いられている。そのために、メモリ効率のよい
機械語に翻訳するコンパイラが必要不可欠となっている
。従来のコンパイラでは一式単位の機械語への翻訳を行
なっていた。
Conventional configurations and their problems In recent years, high-level languages that are easier for humans to understand have been used in the development of microcomputer software in place of the conventional assembler language. For this reason, a compiler that translates into memory-efficient machine language is essential. Conventional compilers translated a set of data into machine language.

この方式では多くのロード/ストア命令が生成され効率
の悪い翻訳結果となっていた。従来よりこの欠点を改良
するために、ブロック単位で機械語への翻訳が行なわれ
ている。この場合でも、ブロック間に及ぶ冗長なロード
/ストア命令を除くことは困難であった。またデータの
流れの分析を行なうフロー解析により行なわれる最適化
処理は(1)共通式の除去 (2)ループ不変式の移動 (3)ループ制御変数の最適化 等があるが、これらは多くの割算処理を必要とするため
実行速度及びプログラムの大きさを考慮すると容易に実
現出来るものではない。
This method generates many load/store instructions, resulting in inefficient translation results. Conventionally, in order to improve this drawback, translation into machine language has been performed on a block-by-block basis. Even in this case, it is difficult to eliminate redundant load/store instructions that extend between blocks. In addition, optimization processing performed by flow analysis that analyzes the flow of data includes (1) removal of common expressions, (2) movement of loop-invariant expressions, and (3) optimization of loop control variables. Since it requires division processing, it is not easy to implement considering execution speed and program size.

発明の目的 本発明は上記従来からの欠点を解消するもので一比較的
簡単な処理で、ブロック間に及ぶ冗長なストア命令を削
除し−メモリ占有量の少ない機械語プログラムを生成す
るコンパイラ装置を提供することを目的とする。
OBJECTS OF THE INVENTION The present invention solves the above-mentioned conventional drawbacks by providing a compiler device that eliminates redundant store instructions extending between blocks through relatively simple processing and generates a machine language program that occupies less memory. The purpose is to provide.

発明の構成 本発明は中間コードから作られたフローグラフを記憶す
る70−グラフメモリと、フローグラフメモリ中の第1
のブロックの直後続ブロックの各々に含まれる同一変数
に対する代入式を検出する共通代入式決定部と、共通代
入式決定部により検出された代入式について変数の代り
に同一レジスタに対する代入式を生成するレジスタ代入
式生成部と一第1のブロックによシ直先行支配される第
2のブロックを検出する被嵌先行支配プロクク決定部と
、第2のブロックの先頭に前記レジスタの内容を前記変
数に代入する式を生成する変数代入式生成部とを備えた
コンパイラ装置であり、この装置によればブ0ツク間に
存在する重複した代入式を削除することが出来、メモリ
占有量の少ない機械語プログラムを得ることが出来る。
Structure of the Invention The present invention provides a 70-graph memory for storing a flow graph created from intermediate code, and a first 70-graph memory in the flow graph memory.
a common assignment expression determination unit that detects assignment expressions for the same variable included in each of the immediately following blocks of the block; and a common assignment expression determination unit that generates an assignment expression for the same register instead of the variable for the assignment expression detected by the common assignment expression determination unit. a register assignment expression generation unit; a to-be-fitted predecessor control block determination unit that detects a second block that is immediately dominated by the first block; This is a compiler device that is equipped with a variable assignment expression generator that generates expressions to be assigned. This device can eliminate duplicate assignment expressions that exist between blocks, and is a machine language that occupies less memory. You can get the program.

実施例の説明 第1図に示すものは直後続ブロック中に同−変峨に対す
る代入式を含む高級言語プログラムの例である。式1及
び式2が同一変数yに対する代入式である。第2図は第
1図のプログラムのフローグラフによる表現を示す04
及び6がブロック3の直後続ブロックであυ、6がブロ
ック3により直先行支配されるブロックである。第3図
はブロック4及びブロック5の中の各式を計算機の内部
レジスタを考慮した形式で表現したものである07はレ
ジスタ名を示し、8及び9がブロック4及びブロック6
間で重複している同一変数に対する代入式である。第4
図は式8及び式9をブロック4及びブロック6の共通な
直後続ブロック6(これはプo、り3によシ直先行支配
されるブロックである。)に移動した図である。ブロッ
ク4からは弐8がそしてブロック6からは式9が削除さ
れ。
DESCRIPTION OF THE EMBODIMENTS FIG. 1 shows an example of a high-level language program that includes an assignment expression for the same variation in the immediately succeeding block. Equations 1 and 2 are assignment expressions for the same variable y. Figure 2 shows a flow graph representation of the program in Figure 104
and 6 are the immediately succeeding blocks of block 3 υ, and 6 is the block immediately preceded and dominated by block 3. Figure 3 represents each formula in block 4 and block 5 in a format that takes into account the internal registers of the computer. 07 indicates the register name, and 8 and 9 represent block 4 and block 6.
This is an assignment expression for the same variable that is duplicated between. Fourth
The figure is a diagram in which Equations 8 and 9 are moved to the common immediately succeeding block 6 of blocks 4 and 6 (this is a block that is immediately preceded and dominated by PU o and RI 3). 28 is deleted from block 4 and formula 9 is deleted from block 6.

ブロック6中に共通な代入式1oが追加されている。こ
れによりブロック6及びブロック6に重複して存在して
いた同一変数に対する代入式は1式に1とめられ、メモ
リ占有量の少ない機械語プログラムを得ることが出来る
。以上が本発明の概略説明である。次にこれらの処理を
行なうハードウェアについて説明する。第6図は本発明
を実現するハードウェア構成である。20は変換された
中間コード、21は中間コード2oを読み取る中間コー
ド読み取り部、22は中間コード読み取シ部21により
読み取られた中間コード20を第2図に示すようムフロ
ーグラフに構成するフローグラフ作成部、23はプログ
ラム全体に渡るフローグラフを記憶するフローグラフメ
モリ、24はある1つのブロックの直後続ブロック内の
同一変数には共通代入式決定部24の制御によりブロッ
ク中の変数に対する代入式をレジスタに対する代入式に
変更するレジスタ代入式生成部、26はレジスタ代入式
生成部26により決定されたレジスタの値を変数に代入
する式を追加するブロックを決定する被嵌先行支配ンロ
ック決定部、27は被嵌先行支配ブロック決定部26に
より決定されたブロックの先頭に前述のレジスタの値を
液収に代入する式を追加する変数代入式生成部、28は
フローグラフを基に実際の計算機のための機械語を生成
するコード生成部であシ、29はコード生成部2Bによ
り生成された機械語である。
A common assignment expression 1o is added to block 6. As a result, the assignment formulas for the same variables that were duplicated in blocks 6 and 6 are reduced to one formula, making it possible to obtain a machine language program that occupies less memory. The above is a general description of the present invention. Next, the hardware that performs these processes will be explained. FIG. 6 shows a hardware configuration for realizing the present invention. 20 is a converted intermediate code, 21 is an intermediate code reader that reads the intermediate code 2o, and 22 is a flow graph that configures the intermediate code 20 read by the intermediate code reader 21 into a flow graph as shown in FIG. A creation unit 23 is a flow graph memory that stores a flow graph spanning the entire program, and 24 is an assignment formula for the same variable in a block immediately following a certain block under the control of a common assignment formula determination unit 24. 26 is a register assignment expression generation unit that changes the expression into an assignment expression for a register; 26 is a pre-control lock determination unit that determines a block to which an expression for assigning the value of the register determined by the register assignment expression generation unit 26 to a variable is added; 27 is a variable substitution formula generation unit that adds a formula for substituting the above-mentioned register value to liquid yield at the beginning of the block determined by the inserted preceding dominant block determination unit 26; 29 is the machine language generated by the code generator 2B.

共通代入式決定部24はフローグラフメモリ23中のブ
ロックの中で複数の直後続ブロックを持つブロック(A
)を検出すると、その直後続ブロックの各々の中の式を
調べ一代入演算子に一)の左辺の変数が同じ式を検出し
たとき、この2つの式のフローグラフ中の位置の情報が
レジスタ代入式生成部26へ渡される。レジスタ代入式
生成算子の左辺の変数を2つ式に共通なレジスタに変更
する。そして被嵌先行支配ブロック決定部では前述のブ
ロック(A)が直先行支配するブロックをフローグラフ
に基づいて決定する。そして変数代入式生成部2γで、
被嵌先行支配ブロック決定部26により決定されたフロ
ーグラフ中のブロックの先頭にレジスタ代入式生成部2
5で決定されたレジスタの内容を前述の2つ式に共通な
変数に代入する式を追加する。そして上記の処理をフロ
ーグラフメモリ23中のすべてのブロックについて行な
う。以上により本発明によれば、各ブロック内の重複し
た変数への代入式を削除することが出来る。
The common assignment formula determination unit 24 selects a block (A
) is detected, the expressions in each of the immediately succeeding blocks are examined, and when an expression is detected in which the variable on the left side of (1) is the same as the assignment operator, information on the positions of these two expressions in the flow graph is stored in the register. It is passed to the assignment expression generation unit 26. Change the variable on the left side of the register assignment expression generation operator to a register common to the two expressions. Then, the fitted preceding dominant block determination unit determines the block to be immediately preceded and controlled by the aforementioned block (A) based on the flow graph. Then, in the variable assignment expression generation unit 2γ,
The register assignment formula generation unit 2 is placed at the beginning of the block in the flow graph determined by the inserted preceding dominant block determination unit 26.
Add an expression that assigns the contents of the register determined in step 5 to a variable common to the above two expressions. The above processing is then performed for all blocks in the flow graph memory 23. As described above, according to the present invention, duplicate assignment expressions for variables in each block can be deleted.

なお−この実施列の説明の例は第2図に示すように2つ
の直径線ブロックを持つ場合について説明したが、これ
は2つ以上でも同様である。また第6図に示すように、
直径線ブロックの1部に同一変数に対する代入式が含ま
れている場合でも。
Although the example of this embodiment has been explained with reference to the case where there are two diameter wire blocks as shown in FIG. 2, the same applies to the case where there are two or more diameter wire blocks. Also, as shown in Figure 6,
Even if part of the diameter line block contains assignment expressions for the same variable.

11に示す位置に新らたなブロックを作成し、その中に
レジスタの内容を変数に代入する式を生成すればよい。
All you have to do is create a new block at the location shown in 11 and generate an expression in it to assign the contents of the register to a variable.

発明の効果 本発明の最適化方式によれば、2つ以上の直径線ブロッ
ク内に同一変数に対する代入式が重複して存在するとき
、各ブロック内の冗長な変数への代入式を削除出来るた
め、メモリ効率の良い機械語プログラムを得ることが出
来る。
Effects of the Invention According to the optimization method of the present invention, when assignment formulas for the same variable exist redundantly in two or more diameter line blocks, redundant assignment formulas for variables in each block can be deleted. , it is possible to obtain a machine language program with good memory efficiency.

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

第1図は直径線ブロック中に同一変数に対する代入式を
含む高級言語プログラムの例を示すプログラム図、第2
図は第1図のプログラムをフローグラフによって表現し
たプログラム図、第3図は第2図のフローグラフをレジ
スタを考慮した形式で表現したプログラム図、第4図は
本発明により冗長な代入式を削除したフローグラフを示
すプログラム図、第6図は本発明の一実施例におけるコ
ンパイラ装置のブロック図、第6図は直径線ブロックを
3つ以上持つプログラムのフローグラフの例を示すプロ
グラム図−第7図は第6図のフローグラフに対して本発
明を適用したときの結果のフローグラフを示すプログラ
ム図である。 23・・・・・・フローグラフメモリ、24・・・・・
・共通代入式決定部、26・・・・・・レジスタ代入式
生成部、26・・・・・・被嵌先行支配ブロック決定部
、27・・・・・・変数代入式生成部。 代理人の氏名 弁理士 中 尾 敏 男 ほか1名第1
図 第2図 第3図 第4図 第5図 第6図 第7図
Figure 1 is a program diagram showing an example of a high-level language program that includes assignment expressions for the same variable in the diameter line block.
Figure 3 is a program diagram that expresses the program in Figure 1 using a flow graph, Figure 3 is a program diagram that expresses the flow graph in Figure 2 in a format that takes registers into consideration, and Figure 4 shows that the present invention eliminates redundant assignment expressions. FIG. 6 is a block diagram of a compiler device in an embodiment of the present invention. FIG. 6 is a program diagram showing an example of a flow graph of a program having three or more diameter line blocks. FIG. 7 is a program diagram showing a flow graph resulting from applying the present invention to the flow graph of FIG. 23...Flow graph memory, 24...
- Common assignment formula determination unit, 26...Register assignment formula generation unit, 26...Inserted preceding dominant block determination unit, 27...Variable assignment formula generation unit. Name of agent: Patent attorney Toshio Nakao and 1 other person No. 1
Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7

Claims (1)

【特許請求の範囲】 フローグラフを記憶するフローグラフメモリと。 このフローグラフメモリ中の第1のブロックの直後続ブ
ロックの各々に含まれる同一変数に対する代入式を検出
する共通代入式決定部と、この共通代入式決定部により
検出された代入式について変数の代りに同一レジスタに
対する代入式を生成するレジスタ代入式生成部と、前記
第1のブロックにより直先行支配される第2のブロック
を検出する被直先支配ブロック決定部と、前記被嵌先行
支配ブロック決定部が検出した第2のブロックの先頭に
前記レジスタの内容を前記変数に代入する式を生成する
変数代入式生成部とを有し、前記第1のブロックの直後
続ブロックの各々に含まれる同一変数に対する重複した
代入式を削除することを特徴としたコンパイラ装置。
[Claims] A flow graph memory that stores a flow graph. a common assignment expression determination unit that detects assignment expressions for the same variable included in each of the blocks immediately following the first block in this flow graph memory; and a variable substitution for the assignment expression detected by the common assignment expression determination unit. a register assignment expression generation unit that generates an assignment expression for the same register, an immediately preceding dominant block determining unit that detects a second block that is immediately preceding dominated by the first block, and an immediately preceding controlling block determining unit that detects a second block immediately preceding controlled by the first block; a variable assignment expression generation section that generates an expression for assigning the contents of the register to the variable at the beginning of the second block detected by the first block; A compiler device characterized by eliminating duplicate assignment expressions for variables.
JP16554083A 1983-09-08 1983-09-08 Compiler device Pending JPS6057437A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP16554083A JPS6057437A (en) 1983-09-08 1983-09-08 Compiler device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP16554083A JPS6057437A (en) 1983-09-08 1983-09-08 Compiler device

Publications (1)

Publication Number Publication Date
JPS6057437A true JPS6057437A (en) 1985-04-03

Family

ID=15814323

Family Applications (1)

Application Number Title Priority Date Filing Date
JP16554083A Pending JPS6057437A (en) 1983-09-08 1983-09-08 Compiler device

Country Status (1)

Country Link
JP (1) JPS6057437A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS62169233A (en) * 1986-01-22 1987-07-25 Fujitsu Ltd Optimizing processing system for compiler

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS62169233A (en) * 1986-01-22 1987-07-25 Fujitsu Ltd Optimizing processing system for compiler

Similar Documents

Publication Publication Date Title
JPH0827774B2 (en) How to perform modifiable functions on the server
JP2539385B2 (en) Information processing device
JP4257553B2 (en) Motion controller program creation and execution method
JPS5958505A (en) Numerical controller
JPS6057437A (en) Compiler device
JPH01118931A (en) Program conversion system
JPH09223023A (en) Compile system and compiler
JPH01195505A (en) Numerical controller
JPH05113882A (en) Out-fitted man-machine interface realizing system by intermediate file
JP2003076547A (en) System and method for automatically generating control software
JPS63318605A (en) Nc part program generating device
JPS6365530A (en) Code optimizing system
JPS60200341A (en) Virtual head addressing system of character data
JPH0619721A (en) Machine language translation optimizing system
JPH04322327A (en) Subroutine sharing method
JPH0358232A (en) Preprocessor calling system
JPS63133230A (en) Compiling system for source program
JPH0296244A (en) Program execution system
JPH05233241A (en) Program forming device
JPH05289867A (en) Multibranch branching control system
JPH0769830B2 (en) Program translation device with expansion control function
JPH06348505A (en) Compiling method
JPH0239242A (en) Temporary work area allocation system for electronic computer system
JPS6330906A (en) Nc device
JPH052487A (en) Language processing system