JPH0962512A - Program transformation device and method having description language transformation function from low-class language to high-class language - Google Patents

Program transformation device and method having description language transformation function from low-class language to high-class language

Info

Publication number
JPH0962512A
JPH0962512A JP21475095A JP21475095A JPH0962512A JP H0962512 A JPH0962512 A JP H0962512A JP 21475095 A JP21475095 A JP 21475095A JP 21475095 A JP21475095 A JP 21475095A JP H0962512 A JPH0962512 A JP H0962512A
Authority
JP
Japan
Prior art keywords
procedure
register
program
level language
definition
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
JP21475095A
Other languages
Japanese (ja)
Inventor
Akitomo Yamada
晃智 山田
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.)
Toshiba Corp
Original Assignee
Toshiba 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 Toshiba Corp filed Critical Toshiba Corp
Priority to JP21475095A priority Critical patent/JPH0962512A/en
Publication of JPH0962512A publication Critical patent/JPH0962512A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PROBLEM TO BE SOLVED: To transform register preserving/recovering processing, which is contained in the respective procedure of low-class language program, into effective descriptions. SOLUTION: An assembly language program 11 is read into a description language transforming processor 20 and analyzed at a program analytic part 21, and a first type register to dispatch the program at the time of calling in each procedure and a second type register to reflect a master procedure with its value in the case of returning from each procedure are decided. when generating a high-class language program 12, a description language transforming part 22 expresses the respective respective registers in each procedure in local parameters for each procedure, describes the first type register in that procedure as the register to dispatch the program at the time of calling in that procedure and describes the second type register in that procedure as the register to reflect the master procedure with its value in the case of returning from that procedure in place of register preserving/recovering processing.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【発明の属する技術分野】本発明は、アセンブリ言語に
代表される低級言語で記述されたプログラム(低級言語
プログラム)から高級言語で記述されたプログラム(高
級言語プログラム)を変換・生成するのに好適な、低級
言語から高級言語への記述言語変換機能を有するプログ
ラム変換装置及び方法に関する。
TECHNICAL FIELD The present invention is suitable for converting and generating a program (high-level language program) written in a high-level language from a program written in a low-level language represented by an assembly language (low-level language program). The present invention relates to a program conversion device and method having a description language conversion function from a low level language to a high level language.

【0002】[0002]

【従来の技術】従来、アセンブリ言語に代表される低級
言語からC言語やFORTRANに代表される高級言語
へ記述言語を変換する場合、低級言語で記述されたプロ
グラム(低級言語プログラム)の各手続きに含まれてい
るレジスタ保存/回復処理については、当該プログラム
の記述に忠実に言語変換を行っていた。
2. Description of the Related Art Conventionally, when converting a description language from a low-level language typified by assembly language to a high-level language typified by C language or FORTRAN, each procedure of a program (low-level language program) written in a low-level language is Regarding the register saving / restoring processing included, language conversion was performed faithfully to the description of the program.

【0003】図8は、レジスタ保存/回復処理を含むア
センブリ言語プログラム81から高級言語(ここではC
言語)で記述されたプログラム(高級言語プログラム)
82への変換例を示す。
FIG. 8 shows an assembly language program 81 including a register saving / restoring process to a high-level language (here, C
Program written in (language) (high-level language program)
An example of conversion to 82 is shown.

【0004】図8の例では、アセンブリ言語プログラム
81に含まれているレジスタ保存/回復処理(SAVE
/RESTORE)の対象となっているレジスタがR2
〜R15の14個であり、この14個のレジスタR2〜
R15を対象とするレジスタ保存/回復処理がそのまま
高級言語(C言語)の記述に変換されている。
In the example of FIG. 8, the register save / restore processing (SAVE) included in the assembly language program 81 is performed.
/ RESTORE) target register is R2
To R15, and the 14 registers R2 to R15.
The register saving / restoring process for R15 is directly converted to the description in the high-level language (C language).

【0005】即ち、高級言語(C言語)プログラム82
において、グローバル変数定義文821により、上記1
5個の各レジスタを(メモリ上の領域を示す名前であ
る)各手続きから見えるグローバル変数R1〜R15
(このR1〜R15はアセンブリ言語プログラム中のR
1〜R15と意味が異なる)で表現し、代入文822に
より、このグローバル変数R1〜R15を手続き内部の
ローカルな変数r1〜r15で表現(ローカル変数r1
〜r15に代入)することで、アセンブリ言語プログラ
ム81中の15個のレジスタを対象とするレジスタ保存
処理811がC言語の記述に変換される。
That is, a high-level language (C language) program 82
In the above, according to the global variable definition statement 821, the above 1
Global variables R1 to R15 that can be seen from each procedure (which is a name indicating an area on the memory) of the five registers
(The R1 to R15 are R in the assembly language program.
1 to R15 have different meanings), and the assignment statement 822 expresses the global variables R1 to R15 as local variables r1 to r15 inside the procedure (local variable r1).
.. to r15), the register saving process 811 for the 15 registers in the assembly language program 81 is converted into the C language description.

【0006】また、代入文823により、ローカル変数
r1〜r15をグローバル変数R1〜R15で表現(グ
ローバル変数R1〜R15に代入)することで、アセン
ブリ言語プログラム81中の15個のレジスタを対象と
するレジスタ回復処理812がC言語の記述に変換され
る。
Further, by using the assignment statement 823, the local variables r1 to r15 are expressed by the global variables R1 to R15 (substitution to the global variables R1 to R15), thereby targeting 15 registers in the assembly language program 81. The register recovery process 812 is converted into a C language description.

【0007】[0007]

【発明が解決しようとする課題】上記したように従来
は、低級言語から高級言語へ記述言語を変換する場合、
低級言語プログラムの各手続きに含まれているレジスタ
保存/回復処理については、当該プログラムの記述に忠
実に言語変換を行うのが一般的であった。
As described above, conventionally, when converting a description language from a low level language to a high level language,
For register saving / restoring processing included in each procedure of a low-level language program, it is common to perform language conversion faithfully to the description of the program.

【0008】このため、変換・生成される高級言語プロ
グラムにおいても、手続き内で書き換えが行われないレ
ジスタまで保存/回復処理が行われることになり、性能
に影響するという問題があった。
For this reason, even in the high-level language program to be converted / generated, the register that is not rewritten in the procedure is also saved / restored, which has a problem of affecting the performance.

【0009】また、レジスタをグローバル変数で表現す
ることから、レジスタへのアクセスがメモリへのアクセ
スに変換され、性能が劣化するという問題もあった。本
発明は上記事情を考慮してなされたものでその目的は、
低級言語から高級言語への記述言語変換を行うことで高
級言語プログラムを生成する際に、低級言語プログラム
の各手続きに含まれているレジスタ保存/回復処理を無
駄のない記述に変換でき、当該レジスタ保存/回復処理
を高級言語で効率よく実行できるプログラム変換装置及
び方法を提供することにある。
Further, since the register is represented by a global variable, the access to the register is converted into the access to the memory, and there is a problem that the performance is deteriorated. The present invention has been made in consideration of the above circumstances, and its purpose is to
When a high-level language program is generated by converting a description language from a low-level language to a high-level language, the register save / restore processing included in each procedure of the low-level language program can be converted into a lean description, It is an object of the present invention to provide a program conversion device and method capable of efficiently executing save / restore processing in a high-level language.

【0010】[0010]

【課題を解決するための手段】本発明は、レジスタを、
各手続きで共通に見ることができるグローバル変数で表
さずに、手続き内部でのみ見ることができるローカル変
数で表すことで、そのレジスタを他の手続きからは見る
ことができないようにしたことを特徴とする。
The present invention provides a register,
The feature is that the register is not visible to other procedures by representing it as a local variable that can be seen only inside the procedure, not as a global variable that can be seen commonly in each procedure. And

【0011】こうすることで、レジスタへのアクセスが
メモリへのアクセスに変換される不具合が解消できる
他、ローカル変数で表されたレジスタは他の手続きから
は見ることができないため、レジスタ保存/回復処理を
行わなくても、他の手続きには何ら影響を及ぼさないで
済む。このため、手続き内で書き換えが行われないレジ
スタまでが保存/回復処理の対象となるようなこともな
くなる。
By doing this, the problem that the access to the register is converted into the access to the memory can be solved, and the register represented by the local variable cannot be seen from other procedures, so that the register saving / restoring is performed. Even if no processing is performed, it does not have any influence on other procedures. For this reason, even registers that are not rewritten in the procedure are not subject to the save / restore processing.

【0012】但し、レジスタをローカル変数で表した場
合、上記のように他の手続きからは見えないため、他の
手続きとの間で値を授受する必要のあるレジスタについ
ては、それを可能とする記述が必要となる。
However, when a register is represented by a local variable, it cannot be seen from other procedures as described above, and therefore it is possible for a register that needs to exchange a value with another procedure. A description is required.

【0013】そこで本発明は、低級言語プログラムを解
析して、各手続き毎に、その手続きで参照されるレジス
タ、及びその手続きから直接または間接に呼び出される
手続き(即ち子手続き以下の手続き)で参照されるレジ
スタであって、その手続きから直接または間接に呼び出
される以前にその手続きで書き換えられる定義レジスタ
には一致しないとレジスタを、各手続きの呼び出し時に
受け渡すべき(各手続きの呼び出し時に外部から受け渡
される)第1のタイプのレジスタとして決定すると共
に、その手続きで書き換えられる定義レジスタ、及びそ
の手続きから直接または間接に呼び出される手続きで書
き換えられる定義レジスタのうち、その手続きでの保存
/回復処理の対象外レジスタを、その手続きから戻る際
に親手続きに値を反映すべき第2のタイプのレジスタと
して決定し、低級言語プログラムを高級言語の記述に変
換して高級言語プログラムを生成する際には、各手続き
毎に、レジスタ保存/回復処理に代えて、上記決定した
対応する手続きでの第1のタイプのレジスタを、その手
続きの呼び出し時に受け渡すべきレジスタとして記述す
ると共に、前記決定した対応する手続きでの第2のタイ
プのレジスタを、その手続きから戻る際に親手続きに値
を反映すべきレジスタとして記述するようにしたことを
特徴とする。
Therefore, in the present invention, a low-level language program is analyzed, and for each procedure, a register referred to by the procedure and a procedure called directly or indirectly from the procedure (that is, a procedure following a child procedure) are referenced. Registers that are registered and that do not match the definition register that is rewritten by the procedure before it is directly or indirectly called by the procedure should be passed when the procedure is called (when the procedure is called from outside). Of the first type register (passed), and the definition register that is rewritten by the procedure and the definition register that is rewritten by the procedure that is called directly or indirectly from the procedure. When returning from a non-target register, the value is returned to the parent procedure when returning from the procedure. When determining as a second type of register to be processed and converting a low-level language program into a high-level language description to generate a high-level language program, instead of register save / restore processing for each procedure, the above determination is made. The register of the first type in the corresponding procedure described above is described as a register to be passed when the procedure is called, and the register of the second type in the determined corresponding procedure is returned when returning from the procedure. It is characterized in that it is described as a register whose value should be reflected in the parent procedure.

【0014】ここで、低級言語プログラムの各手続きに
含まれているレジスタ保存/回復処理を(レジスタ保存
/回復解析手段により)解析して、保存/回復の対象と
なるレジスタを認識しておくと共に、低級言語プログラ
ムの各手続き内のレジスタ定義/参照状況を(レジスタ
定義/参照解析手段により)解析し、更に低級言語プロ
グラムの手続き間の呼び出し関係を(手続き呼び出し関
係解析手段により)解析しておくならば、これら各(解
析手段の)解析結果を用いることで、上記第1のタイプ
のレジスタと第2のタイプのレジスタを効率的に決定す
ることが可能となる。
Here, the register saving / restoring processing included in each procedure of the low-level language program is analyzed (by the register saving / restoring analysis means) to recognize the register to be saved / restored. , The register definition / reference situation in each procedure of the low-level language program is analyzed (by the register definition / reference analysis means), and the call relationship between the procedures of the low-level language program is analyzed (by the procedure call relationship analysis means). Then, it becomes possible to efficiently determine the first type register and the second type register by using these analysis results (of the analysis means).

【0015】[0015]

【発明の実施の形態】以下、本発明の一実施形態につき
図面を参照して説明する。図1は本発明の一実施形態に
係るプログラム変換装置の全体構成を示すブロック図で
ある。
DESCRIPTION OF THE PREFERRED EMBODIMENTS One embodiment of the present invention will be described below with reference to the drawings. FIG. 1 is a block diagram showing the overall configuration of a program conversion device according to an embodiment of the present invention.

【0016】同図において、10は各種プログラム等を
格納するための外部記憶装置である。この外部記憶装置
10には、記述言語の変換の対象となる、低級言語、例
えばアセンブリ言語で記述されたプログラム(アセンブ
リ言語プログラム)11が格納されている。この外部記
憶装置10にはまた、アセンブリ言語プログラム11を
対象とする記述言語の変換、例えばアセンブリ言語から
高級言語であるC言語への記述言語変換を行うことで変
換・生成される高級言語(C言語)プログラム12も格
納されるようになっている。
In the figure, 10 is an external storage device for storing various programs and the like. The external storage device 10 stores a program (assembly language program) 11 described in a low-level language, for example, an assembly language, which is a target of the description language conversion. The external storage device 10 also converts a description language targeted for the assembly language program 11, for example, a description language conversion from the assembly language to the high-level C language to convert and generate a high-level language (C A language program 12 is also stored.

【0017】20は外部記憶装置10からアセンブリ言
語プログラム11を読み込んでアセンブリ言語から高級
言語(例えばC言語)への記述言語変換を行うことで高
級言語プログラム12を生成する記述言語変換処理装置
である。
Reference numeral 20 denotes a description language conversion processing device which reads the assembly language program 11 from the external storage device 10 and converts the assembly language into a high level language (for example, C language) to generate the high level language program 12. .

【0018】記述言語変換処理装置20は、計算機の中
心をなすCPU、及び記述言語変換処理のためのソフト
ウェア(プログラム)類を記憶しておくためのメモリ等
を用いて実現されるもので、プログラム解析部21及び
記述言語変換部22の各機能要素を備えている。
The description language conversion processing device 20 is realized by using a CPU, which is the center of a computer, and a memory for storing software (programs) for the description language conversion process. Each functional element of the analysis unit 21 and the description language conversion unit 22 is provided.

【0019】プログラム解析部21は、アセンブリ言語
プログラム11を解析して、各手続きの呼び出し時に外
部から受け渡されるレジスタ(第1のタイプのレジス
タ)、及び各手続きから戻る際に親手続きに値を反映す
べきレジスタ(第2のタイプのレジスタ)等を決定する
ためのものであり、レジスタ保存/回復解析部211、
レジスタ定義/参照解析部212、手続き呼び出し関係
解析部213及びレジスタ決定部214の各機能要素か
ら構成される。
The program analysis unit 21 analyzes the assembly language program 11 and assigns a value to a register (first type register) that is passed from the outside when each procedure is called, and a value to the parent procedure when returning from each procedure. The register saving / recovery analyzing unit 211 is for determining the register (the second type register) to be reflected.
The register definition / reference analysis unit 212, the procedure call relation analysis unit 213, and the register determination unit 214 are functionally configured.

【0020】レジスタ保存/回復解析部211は、記述
言語変換処理装置20に読み込まれたアセンブリ言語プ
ログラム11の各手続きに含まれているレジスタ保存/
回復処理を解析して、対象となるレジスタを認識する機
能を有する。
The register saving / restoring analysis unit 211 saves / registers registers included in each procedure of the assembly language program 11 read by the description language conversion processing device 20.
It has a function of analyzing a recovery process and recognizing a target register.

【0021】レジスタ定義/参照解析部212は、記述
言語変換処理装置20に読み込まれたアセンブリ言語プ
ログラム11の各手続き内のレジスタ定義/参照状況を
解析する機能を有する。
The register definition / reference analysis unit 212 has a function of analyzing the register definition / reference status in each procedure of the assembly language program 11 read by the description language conversion processing device 20.

【0022】手続き呼び出し関係解析部213は、アセ
ンブリ言語プログラム11の手続き間の呼び出し関係を
解析する機能を有する。レジスタ決定部214は、レジ
スタ保存/回復解析部211、レジスタ定義/参照解析
部212及び手続き呼び出し関係解析部213の解析結
果をもとに、上記第1のタイプのレジスタ(各手続きの
呼び出し時に外部から受け渡されるレジスタ)及び第2
のタイプのレジスタ(各手続きから戻る際に親手続きに
値を反映すべきレジスタ)を決定する他、手続き内部で
のみ使用するレジスタ(第3のタイプのレジスタ)を決
定する。
The procedure call relation analysis unit 213 has a function of analyzing the call relation between procedures of the assembly language program 11. The register determination unit 214, based on the analysis results of the register storage / recovery analysis unit 211, the register definition / reference analysis unit 212, and the procedure call relation analysis unit 213, registers of the first type (external when calling each procedure). From the register) and the second
Type registers (registers whose values should be reflected in the parent procedure when returning from each procedure) are determined, and also registers used only inside the procedure (third type registers) are determined.

【0023】記述言語変換部22は、レジスタ決定部2
14の決定結果及び記述言語変換処理装置20に読み込
まれたアセンブリ言語プログラム11をもとに、アセン
ブリ言語から高級言語(ここではC言語)への記述言語
変換を行う機能を有する。
The description language conversion unit 22 includes a register determination unit 2
Based on the determination result of 14 and the assembly language program 11 read by the description language conversion processing device 20, it has a function of performing a description language conversion from an assembly language to a high-level language (here, C language).

【0024】次に、図1の構成の動作を、アセンブリ言
語プログラム11が図2(a)に示すようになっている
場合を例に、図4乃至図7のフローチャートを参照して
説明する。なお、この図2(a)に示すアセンブリ言語
プログラム11は、[従来の技術]の欄で述べたアセン
ブリ言語プログラム81(図8参照)と同一内容であ
る。
Next, the operation of the configuration of FIG. 1 will be described with reference to the flow charts of FIGS. 4 to 7 by taking the case where the assembly language program 11 is as shown in FIG. 2A as an example. Note that the assembly language program 11 shown in FIG. 2A has the same contents as the assembly language program 81 (see FIG. 8) described in the "Prior Art" section.

【0025】まず記述言語変換処理装置20は、外部記
憶装置10に格納されているアセンブリ言語プログラム
11を読み込む(ステップS1)。すると、記述言語変
換処理装置20内のレジスタ保存/回復解析部211が
図示せぬ制御部により起動される。レジスタ保存/回復
解析部211は、外部記憶装置10から読み込まれたア
センブリ言語プログラム11の各手続きにおいてどのレ
ジスタ(レジスタ群)を保存し回復しているか、即ち各
手続き毎のレジスタ保存/回復処理の対象レジスタ(レ
ジスタ群)を認識する(ステップS2)。このレジスタ
保存/回復処理の認識は、各手続き毎にSAVE命令と
RESTORE命令を調べることで行われ、その認識結
果は図示せぬメモリに記憶される。
First, the description language conversion processing device 20 reads the assembly language program 11 stored in the external storage device 10 (step S1). Then, the register saving / restoring analysis unit 211 in the description language conversion processing device 20 is activated by a control unit (not shown). The register saving / restoring analysis unit 211 stores which register (register group) is saved and restored in each procedure of the assembly language program 11 read from the external storage device 10, that is, register saving / restoring processing of each procedure. The target register (register group) is recognized (step S2). The recognition of the register saving / restoring processing is performed by checking the SAVE instruction and the RESTORE instruction for each procedure, and the recognition result is stored in a memory (not shown).

【0026】図2(a)のアセンブリ言語プログラム1
1の例では、手続きPROC1においてレジスタR2〜
R15がレジスタ保存/回復処理の対象となることが認
識される。
Assembly language program 1 of FIG. 2 (a)
In the example of No. 1, the registers R2 to R2 in the procedure PROC1.
It is recognized that R15 is subject to register save / restore processing.

【0027】次にレジスタ定義/参照解析部212が起
動される。レジスタ定義/参照解析部212は、外部記
憶装置10から読み込まれたアセンブリ言語プログラム
11の各々の手続きで明示的に定義されている(書き換
えられている)レジスタと参照されているレジスタ及び
その位置(順序)を認識するためのレジスタ定義/参照
状況の解析処理を行う(ステップS3)。この解析処理
は、各手続き毎にレジスタ定義/参照を伴う命令(図2
(a)のアセンブリ言語プログラム11の例ではロード
(L)命令)を調べることで行われ、そのレジスタ定義
/参照状況解析結果はメモリに記憶される。
Next, the register definition / reference analysis unit 212 is activated. The register definition / reference analysis unit 212 includes a register explicitly defined (rewritten) by each procedure of the assembly language program 11 read from the external storage device 10, a register referred to, and a position thereof ( A register definition / reference situation analysis process for recognizing the (order) is performed (step S3). This analysis process is performed by an instruction (see FIG. 2) involving register definition / reference for each procedure.
In the example of the assembly language program 11 in (a), this is performed by checking the load (L) instruction, and the result of the register definition / reference situation analysis is stored in the memory.

【0028】図2(a)のアセンブリ言語プログラム1
1の例では、手続きPROC1においては、定義されて
いる(書き換えられている)レジスタ(定義レジスタ)
がレジスタR0,R10で、参照されているレジスタ
(参照レジスタ)がレジスタR3であることが認識さ
れ、手続きPROC2においては、定義レジスタがレジ
スタR1で、参照レジスタがレジスタR10であること
が認識される。
Assembly language program 1 of FIG. 2 (a)
In the example of No. 1, in the procedure PROC1, a defined (rewritten) register (definition register)
Is recognized by the registers R0 and R10, and the referenced register (reference register) is the register R3. In the procedure PROC2, it is recognized that the definition register is the register R1 and the reference register is the register R10. .

【0029】次に手続き呼び出し関係解析部213が起
動される。手続き呼び出し関係解析部213は、外部記
憶装置10から読み込まれたアセンブリ言語プログラム
11における手続き間の呼び出し関係を解析する(ステ
ップS4)。ここでは、呼び出される手続きの位置も認
識される。この手続き間の呼び出し関係の解析結果はメ
モリに記憶される。
Next, the procedure call relation analysis unit 213 is activated. The procedure call relation analysis unit 213 analyzes the call relation between procedures in the assembly language program 11 read from the external storage device 10 (step S4). The location of the called procedure is also recognized here. The analysis result of the call relationship between the procedures is stored in the memory.

【0030】図2(a)のアセンブリ言語プログラム1
1の例では、手続きPROC1から手続きPROC2が
呼び出されることが解析される。なお、上記したレジス
タ保存/回復解析部211、レジスタ定義/参照解析部
212及び手続き呼び出し関係解析部213の起動順序
は重要ではなく、どのような順序であっても構わない。
また、並列に動作するものであっても構わない。また、
これら各解析部211〜213での解析処理を効率よく
行うために、予めアセンブリ言語プログラム11の字句
を解析して当該プログラム11のアセンブリ言語上のデ
ータ構造を認識し、その結果をメモリに記憶しておき、
その結果を各解析部211〜213から参照できるよう
にするとよい。この字句解析結果は、記述言語変換部2
2からも参照できることから、各部が同様の処理を繰り
返す無駄が省ける。
Assembly language program 1 of FIG. 2 (a)
In the first example, it is analyzed that the procedure PROC1 is called from the procedure PROC1. The activation order of the register saving / restoring analysis unit 211, the register definition / reference analysis unit 212, and the procedure call relation analysis unit 213 described above is not important and any order may be used.
Further, it may operate in parallel. Also,
In order to efficiently perform the analysis processing in each of the analysis units 211 to 213, the lexical words of the assembly language program 11 are analyzed in advance, the data structure in the assembly language of the program 11 is recognized, and the result is stored in the memory. Aside
The analysis result may be referred to by each of the analysis units 211 to 213. This lexical analysis result is described in the description language conversion unit 2
Since it can be referred to from 2, the waste of repeating the same processing by each unit can be omitted.

【0031】さて、レジスタ保存/回復解析部211、
レジスタ定義/参照解析部212及び手続き呼び出し関
係解析部213の解析動作(ステップS2,S3,S
4)が終了すると、レジスタ決定部214が起動され
る。レジスタ決定部214は、メモリに記憶されている
上記各解析部211〜213の(ステップS2〜S4
の)解析結果をもとに、レジスタに着目したデータフロ
ー解析を行い、各手続きが呼び出されるときに外部から
受け取るべきレジスタ、及び各手続きから戻る際に親手
続きに値を反映すべきレジスタ等を決定するためのレジ
スタ決定処理を実行する(ステップS5)。なお、レジ
スタ決定部214での処理に手続き呼び出し関係解析部
213の解析結果を必要とする理由は、レジスタ定義/
参照解析部212では手続き自身のレジスタ定義/参照
は認識できるものの、実際には、その手続きの中から他
の手続き(子手続き)を呼び出す場合があり、そこで定
義/参照されるレジスタもあり得るためである。
Now, the register saving / restoring analysis unit 211,
Analysis operations of the register definition / reference analysis unit 212 and the procedure call relation analysis unit 213 (steps S2, S3, S
When 4) ends, the register determination unit 214 is activated. The register determination unit 214 includes the analysis units 211 to 213 stored in the memory (steps S2 to S4).
)) Based on the analysis result, perform data flow analysis focusing on registers, and register registers that should be received from the outside when each procedure is called, and registers that should reflect the value to the parent procedure when returning from each procedure. A register determining process for determining is executed (step S5). The reason why the analysis result of the procedure call relation analysis unit 213 is necessary for the processing in the register determination unit 214 is the register definition /
Although the reference analysis unit 212 can recognize the register definition / reference of the procedure itself, in reality, another procedure (child procedure) may be called from that procedure, and there may be registers defined / referenced there. Is.

【0032】このステップS5のレジスタ決定処理の詳
細を図5のフローチャートを参照して説明する。まずレ
ジスタ決定部214は、レジスタ定義/参照解析部21
2により認識された各手続きでの定義レジスタ及び参照
レジスタと、レジスタ保存/回復解析部211により認
識された各手続きでの保存/回復処理の対象レジスタと
をもとに、各手続きについて、保存/回復の対象となら
ない定義レジスタ(即ち、親手続きに値を反映すべき定
義レジスタ)のリスト(定義レジスタリスト)、保存/
回復の対象となる定義レジスタ(即ち、その手続きの内
部だけで用いられる定義レジスタ)のリスト(内部定義
レジスタリスト)、及び参照レジスタのリスト(参照レ
ジスタリスト)を生成する(ステップS11)。これら
各リストはメモリに記憶される。
Details of the register determination processing in step S5 will be described with reference to the flowchart of FIG. First, the register determining unit 214 is configured to register the register definition / reference analysis unit 21.
2 based on the definition register and reference register in each procedure recognized in 2 and the target register of the save / recovery process in each procedure recognized by the register save / recovery analysis unit 211. A list (definition register list) of definition registers that are not subject to recovery (that is, definition registers whose values should be reflected in the parent procedure), save /
A list of definition registers to be restored (that is, definition registers used only inside the procedure) (internal definition register list) and a list of reference registers (reference register list) are generated (step S11). Each of these lists is stored in memory.

【0033】次にレジスタ決定部214は、その時点に
おける各手続きでの定義レジスタリスに入っているレジ
スタを、その親手続きでの内部定義レジスタリストにも
あるレジスタを除いて、その親手続き内部でも見えるよ
うに、その親手続きでの定義レジスタリストに加える
(ステップS12)。
Next, the register deciding unit 214 excludes the registers in the definition register list in each procedure at that point in time even in the parent procedure except the registers in the internal definition register list in the parent procedure. As can be seen, it is added to the definition register list in the parent procedure (step S12).

【0034】次にレジスタ決定部214は、その時点に
おける各手続きでの参照レジスタリスに入っているレジ
スタを、その手続きが呼ばれる以前にその親手続きで定
義されているレジスタを除いて、その親手続き内部でも
見えるように、その親手続きでの参照レジスタリストに
加える(ステップS13)。なお、参照レジスタリスに
入っているレジスタが、対応する手続きが呼ばれる以前
にその親手続きで定義されているか否かは、レジスタ定
義/参照解析部212での各手続き毎のレジスタ定義/
参照状況解析結果に含まれるレジスタ位置と、子手続き
が呼び出される位置の関係から判断できる。
Next, the register determining unit 214 excludes the registers in the reference register list of each procedure at that point in time, except for the registers defined in the parent procedure before the procedure is called. It is added to the reference register list in the parent procedure so that it can be seen inside (step S13). Whether or not the register in the reference register list is defined by the parent procedure before the corresponding procedure is called is determined by the register definition / reference analysis unit 212.
It can be determined from the relationship between the register position included in the reference situation analysis result and the position where the child procedure is called.

【0035】レジスタ決定部214は、以上のステップ
S12,S13を、当該ステップS12,S13の実行
前後において全ての手続きでの定義レジスタリスト及び
参照レジスタリストに変化がなくなるまで繰り返す(ス
テップS14)。即ちレジスタ決定部214は、いずれ
かの手続きでの定義レジスタリストまたは参照レジスタ
リストの内容が、ステップS12,S13の前後で変化
する限りは、このステップS12,S13を繰り返す。
The register determining unit 214 repeats the above steps S12 and S13 until there is no change in the definition register list and the reference register list in all procedures before and after the execution of the steps S12 and S13 (step S14). That is, the register determination unit 214 repeats steps S12 and S13 as long as the contents of the definition register list or the reference register list in any procedure change before and after steps S12 and S13.

【0036】そしてレジスタ決定部214は、ステップ
S12,S13の実行前後において各手続きでの定義レ
ジスタリスト及び参照レジスタリストが全て変化しなく
なると、ステップS12,S13の繰り返しのループか
ら抜け、その時点における各手続きでの参照レジスタリ
ストを、その手続きの呼び出し時に受け渡すべきレジス
タのリストして決定すると共に、その時点における各手
続きでの定義レジスタリストを、その親手続きに値を反
映すべきレジスタのリストして決定する(ステップS1
5)。また、この時点における各手続きでの内部定義レ
ジスタリストは、さの手続きの内部だけで使用されるレ
ジスタのリストとして決定される。
Then, when the definition register list and the reference register list in each procedure do not change before and after the execution of steps S12 and S13, the register determination unit 214 exits the loop of repetition of steps S12 and S13, and at that time point. The reference register list in each procedure is determined by the list of registers that should be passed when the procedure is called, and the definition register list in each procedure at that time is the list of registers whose values are to be reflected in the parent procedure. And decide (step S1
5). Further, the internally defined register list in each procedure at this point is determined as a list of registers used only inside the procedure.

【0037】以上により、レジスタ決定部214による
ステップS5のレジスタ決定処理は終了となる。この結
果、図2(a)のアセンブリ言語プログラム11の例で
は、手続きPROC1の定義レジスタリストには、当該
手続きPROC1におけるレジスタ保存/回復の対象が
レジスタR2〜R15であることから、当該手続きPR
OC1中で定義されているレジスタR0,R10のうち
の保存/回復の対象とならないレジスタR0と、その子
手続きPROC2から(手続きPROC1での保存/回
復の対象とならないために)加えられる当該手続きPR
OC2で定義されているレジスタR1が入ることにな
る。一方、手続きPROC2の定義レジスタリストに
は、レジスタR1だけが入ることになる。このPROC
1,2の定義レジスタリストの内容を図3(a),
(b)に示す。
With the above, the register determination processing of step S5 by the register determination unit 214 is completed. As a result, in the example of the assembly language program 11 of FIG. 2A, since the register saving / restoring target in the procedure PROC1 is the registers R2 to R15 in the definition register list of the procedure PROC1, the procedure PR is concerned.
Of the registers R0 and R10 defined in OC1, the register R0 that is not the target of saving / restoring and its procedure PR that is added from its child procedure PROC2 (because it is not the target of saving / restoring in procedure PROC1)
The register R1 defined by OC2 will be entered. On the other hand, only the register R1 is included in the definition register list of the procedure PROC2. This PROC
The contents of the definition register lists 1 and 2 are shown in FIG.
(B).

【0038】次に、手続きPROC1の内部定義レジス
タリストには、当該手続きPROC1中で定義されてい
るレジスタR0,R10のうちの保存/回復の対象とな
るレジスタR10だけが入ることになる。一方、手続き
PROC2の内部定義レジスタリストには何も入らな
い。このPROC1,2の内部定義レジスタリストの内
容を図3(c),(d)に示す。
Next, only the register R10 to be saved / restored among the registers R0 and R10 defined in the procedure PROC1 is included in the internal definition register list of the procedure PROC1. On the other hand, nothing is entered in the internal definition register list of the procedure PROC2. The contents of the internally defined register list of PROC1 and PROC2 are shown in FIGS.

【0039】次に、手続きPROC1の参照レジスタリ
ストには、当該手続きPROC1中で参照されているレ
ジスタR3だけが入る。手続きPROC2中で参照され
ているレジスタR10は、その親手続きPROC1で、
それより先に定義されていることから、手続きPROC
1の参照レジスタリストには加えられない。一方、手続
きPROC2の参照レジスタリストには、レジスタR1
0だけが入る。このPROC1,2の参照レジスタリス
トの内容を図3(e),(f)に示す。
Next, only the register R3 referred to in the procedure PROC1 is entered in the reference register list of the procedure PROC1. The register R10 referenced in the procedure PROC2 is its parent procedure PROC1,
Since it is defined before that, the procedure PROC
It is not added to the reference register list of 1. On the other hand, in the reference register list of procedure PROC2, register R1
Only 0 enters. The contents of the reference register list of PROC1 and PROC2 are shown in FIGS.

【0040】レジスタ決定部214によるレジスタ決定
処理(ステップS5)が終了すると記述言語変換部22
が起動される。記述言語変換部22は、外部記憶装置1
0から読み込まれたアセンブリ言語プログラムとステッ
プS5でのレジスタ決定結果をもとに、アセンブリ言語
からC言語(高級言語)へ記述言語を変換する記述言語
変換処理を行う(ステップS6)。
When the register determination process (step S5) by the register determination unit 214 is completed, the description language conversion unit 22
Is started. The description language conversion unit 22 uses the external storage device 1.
Based on the assembly language program read from 0 and the register determination result in step S5, description language conversion processing for converting the description language from assembly language to C language (high-level language) is performed (step S6).

【0041】このステップS6の記述言語変換処理の詳
細を図6及び図7のフローチャートを参照して説明す
る。まず記述言語変換部22は、変換の対象となってい
るアセンブリ言語プログラム11(に対する字句解析の
結果認識されたデータ構造)の先頭から順に記述言語変
換対象部分(ラベルまたは命令)を検出する(ステップ
S21)。
Details of the description language conversion processing in step S6 will be described with reference to the flowcharts of FIGS. 6 and 7. First, the description language conversion unit 22 detects the description language conversion target portion (label or instruction) in order from the beginning of the assembly language program 11 (the data structure recognized as a result of the lexical analysis for the assembly language program 11) which is the conversion target (step). S21).

【0042】もし、記述言語変換対象部分が検出できた
ならば(ステップS22)、記述言語変換部22は、そ
の記述言語変換対象部分がラベル(図2の例であれば、
PROC1またはPROC2)であるか命令であるかを
判断する(ステップS23)。
If the description language conversion target portion can be detected (step S22), the description language conversion unit 22 determines that the description language conversion target portion is a label (in the example of FIG. 2,
It is determined whether it is PROC1 or PROC2) or an instruction (step S23).

【0043】記述言語変換部22は、検出した記述言語
変換対象部分がラベルの場合には、そのラベルを高級言
語(C言語)で記述される関数定義文に変換し、引数と
して、外部から与える情報(そのラベルに対応する手続
きでの参照レジスタリスト内の各レジスタを表すローカ
ル変数)と、親手続きに渡す情報の構造体のタイプ(名
前)及びアドレスとを設定する(ステップS26)。
When the detected description language conversion target portion is a label, the description language conversion unit 22 converts the label into a function definition statement described in a high-level language (C language) and gives it as an argument from the outside. Information (local variable representing each register in the reference register list in the procedure corresponding to the label), and the type (name) and address of the structure of information to be passed to the parent procedure are set (step S26).

【0044】続いて記述言語変換部22は、対応する手
続きの内部で使用するローカル変数の定義文を生成する
(ステップS27)。このローカル変数定義文では、レ
ジスタ決定部214により求められた定義レジスタリス
ト及び内部定義レジスタリスト内の各レジスタを表すロ
ーカル変数が定義される。
Subsequently, the description language conversion unit 22 generates a definition statement of a local variable used inside the corresponding procedure (step S27). In this local variable definition statement, a local variable representing each register in the definition register list and the internal definition register list obtained by the register determining unit 214 is defined.

【0045】但し、検出したラベルが最初のラベルでな
い場合には、即ち先頭の手続き以外の手続きの開始を検
出した場合には、言い換えれば手続きの区切りを検出し
た場合には、記述言語変換部22は、上記のステップS
26に先立って、先行する手続きからその親手続きに値
が反映できるように、親手続きに反映する値を構造体に
格納する代入文(先行する手続きの最後の文)を生成す
る処理を行う(ステップS25)。
However, when the detected label is not the first label, that is, when the start of a procedure other than the first procedure is detected, in other words, when a procedure break is detected, the description language conversion unit 22 Is the above step S
Prior to step 26, a process is performed to generate an assignment statement (the last statement of the preceding procedure) that stores the value to be reflected in the parent procedure in the structure so that the value can be reflected in the parent procedure from the preceding procedure ( Step S25).

【0046】以上の結果、図2(a)中のラベルPRO
C1が検出された場合であれば、図2(b)に示すよう
な高級言語(C言語)の関数定義文121及びローカル
変数定義文122が変換・生成される。
As a result of the above, the label PRO in FIG.
If C1 is detected, a function definition statement 121 and a local variable definition statement 122 in a high-level language (C language) as shown in FIG. 2B are converted / generated.

【0047】関数定義文121中では、引数として、図
3(e)に示すPROC1の参照レジスタリスト内のレ
ジスタR3を表す整数型(int)のローカル変数r3
と、親手続きに渡す情報の構造体のタイプ“struc
t ret1”及びアドレス“*ret”とが設定され
る。一方、ローカル変数定義文122中では、図3
(a)に示すPROC1の定義レジスタリスト及び図3
(c)に示すPROC1の内部定義レジスタリスト内の
各レジスタR0,R1,R10を表す整数型(int)
のローカル変数r0,r1,r10が定義される。
In the function definition statement 121, as an argument, an integer type (int) local variable r3 representing the register R3 in the reference register list of PROC1 shown in FIG. 3 (e).
And the type of the structure of information passed to the parent procedure, "struc
“t ret1” and the address “* ret” are set in the local variable definition statement 122.
Definition register list of PROC1 shown in (a) and FIG.
An integer type (int) representing each register R0, R1, R10 in the internally defined register list of PROC1 shown in (c).
Local variables r0, r1, r10 are defined.

【0048】同様に、図2(a)中のラベルPROC2
が検出された場合であれば、図2(b)に示すような高
級言語(C言語)の関数定義文123及びローカル変数
定義文124が変換・生成される。
Similarly, the label PROC2 in FIG.
2 is detected, the function definition statement 123 and the local variable definition statement 124 in the high-level language (C language) as shown in FIG. 2B are converted / generated.

【0049】関数定義文123中では、引数として、図
3(f)に示すPROC2の参照レジスタリスト内のレ
ジスタR10を表す整数型(int)のローカル変数r
10と、親手続きに渡す情報の構造体のタイプ“str
uct ret2”及びアドレス“*ret”とが設定
される。一方、ローカル変数定義文124中では、図3
(b)に示すPROC2の定義レジスタリスト内のレジ
スタR1を表す整数型(int)のローカル変数r1が
定義される。
In the function definition statement 123, as an argument, an integer type (int) local variable r representing the register R10 in the reference register list of PROC2 shown in FIG. 3 (f).
10 and the type of the structure of information passed to the parent procedure, "str
ct ret2 ”and the address“ * ret ”are set in the local variable definition statement 124 shown in FIG.
An integer type (int) local variable r1 representing the register R1 in the definition register list of PROC2 shown in (b) is defined.

【0050】また、関数定義文123及びローカル変数
定義文124の生成に先立ち、図2(b)に示すような
2つの代入文125が生成される。この代入文125で
は、図3(a)に示すPROC1の定義レジスタリスト
内のレジスタR1,R2を表すローカル変数r0,r1
を、親手続きに渡す構造体の“ret”で示される領域
中のr0,r1として代入することが示される。
Prior to the generation of the function definition statement 123 and the local variable definition statement 124, two assignment statements 125 as shown in FIG. 2B are generated. In this assignment statement 125, local variables r0 and r1 representing the registers R1 and R2 in the definition register list of PROC1 shown in FIG.
Is assigned as r0 and r1 in the area indicated by "ret" of the structure to be passed to the parent procedure.

【0051】記述言語変換部22は、ステップS26,
S27を実行するとステップS21に戻り、アセンブリ
言語プログラム11からの次の記述言語変換対象部分を
検出する処理を行う。
The description language conversion unit 22 executes the step S26,
When S27 is executed, the process returns to step S21, and the process for detecting the next description language conversion target part from the assembly language program 11 is performed.

【0052】次に、検出した記述言語変換対象部分がラ
ベルではなくて命令の場合には、記述言語変換部22
は、その命令がレジスタ保存/回復命令(SAVE/R
ESTORE命令)であるか、手続きの呼び出し命令
(CALL命令)であるか、或いはそれ以外の命令であ
るかを判断する(ステップS28,S29)。
Next, when the detected description language conversion target portion is not a label but an instruction, the description language conversion unit 22
Is the register save / restore instruction (SAVE / R
It is determined whether it is an ESTORE command), a procedure call command (CALL command), or another command (steps S28 and S29).

【0053】記述言語変換部22は、検出した記述言語
変換対象部分がレジスタ保存(SAVE)または回復
(RESTORE)命令である場合には、何もせずにス
テップS21に戻り、次の記述言語変換対象部分を検出
する処理を行う。
If the detected description language conversion target portion is a register save (SAVE) or restore (RESTORE) command, the description language conversion unit 22 returns to step S21 without doing anything and returns to the next description language conversion target. Perform the process of detecting the part.

【0054】また記述言語変換部22は、検出した記述
言語変換対象部分がレジスタ保存/回復命令(SAVE
/RESTORE命令)でも、手続きの呼び出し命令
(CALL命令)でもない命令の場合には、その命令を
そのまま高級言語(C言語)の記述に変換し(ステップ
S30)、ステップS21に戻る。
In the description language conversion unit 22, the detected description language conversion target portion is a register save / restore instruction (SAVE
If the command is neither a / RESTORE command) nor a procedure call command (CALL command), the command is converted into a high-level language (C language) description as it is (step S30), and the process returns to step S21.

【0055】これにより、図2(a)中のロード命令L
(R0,1)及びL(R10,R3)が検出された場合
であれば、図2(b)に示すような高級言語(C言語)
の代入文“r0=1”及び“r10=r3”に変換され
る。
As a result, the load instruction L in FIG.
If (R0,1) and L (R10, R3) are detected, a high-level language (C language) as shown in FIG. 2B.
Are converted into "r0 = 1" and "r10 = r3".

【0056】同様に、図2(a)中のロード命令L(R
1,R10)が検出された場合であれば、図2(b)に
示すような高級言語(C言語)の代入文“r1=r10
に変換される。
Similarly, the load instruction L (R) in FIG.
1, R10) is detected, a high-level language (C language) assignment statement “r1 = r10 as shown in FIG. 2B.
Is converted to

【0057】また記述言語変換部22は、検出した記述
言語変換対象部分が手続き呼び出し命令(CALL命
令)である場合には、その命令を高級言語(C言語)で
記述される関数呼び出し文に変換し、引数として、子手
続きの参照レジスタリスト内の各レジスタを表すローカ
ル変数と、子手続きから受け取る情報の構造体のアドレ
スとを設定する(ステップS31)。
When the detected description language conversion target portion is a procedure call instruction (CALL instruction), the description language conversion unit 22 converts the instruction into a function call statement described in a high-level language (C language). Then, a local variable representing each register in the reference register list of the child procedure and the address of the structure of information received from the child procedure are set as arguments (step S31).

【0058】続いて記述言語変換部22は、子手続きか
ら構造体を通して情報を受け取るための代入文を生成し
(ステップS32)、ステップS21に戻る。これによ
り、図2(a)中の手続きPROC1に含まれている手
続きPROC2を呼び出す手続き呼び出し命令(CAL
L命令)が検出された場合であれば、図2(b)に示す
ような高級言語(C言語)の関数呼び出し文126及び
代入文127が変換・生成される。
Subsequently, the description language conversion unit 22 generates an assignment statement for receiving information from the child procedure through the structure (step S32), and returns to step S21. This causes the procedure call instruction (CAL) to call the procedure PROC2 included in the procedure PROC1 in FIG.
If the L instruction) is detected, the function call statement 126 and the assignment statement 127 in the high-level language (C language) as shown in FIG. 2B are converted / generated.

【0059】関数呼び出し文126中では、引数とし
て、図3(e)に示すPROC2の参照レジスタリスト
内のレジスタR10を表す整数型(int)のローカル
変数r10と、子手続きから受け取る情報の構造体(タ
イプ“struct ret2”の構造体)のアドレス
“&ret2”とが設定される。一方、代入文127で
は、“ret2”で示される構造体のアドレスr1の内
容を手続きPROC1でのローカル変数r1とすること
が示される。
In the function call statement 126, as an argument, an integer type (int) local variable r10 representing the register R10 in the reference register list of the PROC2 shown in FIG. 3E and a structure of information received from the child procedure. The address "&ret2" of (structure of type "struct ret2") is set. On the other hand, the assignment statement 127 indicates that the content of the address r1 of the structure indicated by "ret2" is used as the local variable r1 in the procedure PROC1.

【0060】また、記述言語変換部22は、記述言語変
換対象部分が検出できなかったならば(ステップS2
2)、アセンブリ言語プログラム11の最後であるもの
として、現在処理中の手続きから親手続きに反映する値
を構造体に格納する代入文を生成し(ステップS3
3)、一連の記述言語変換処理(ステップS6)を終了
する。
Further, if the description language conversion unit 22 cannot detect the description language conversion target portion (step S2).
2) As an end of the assembly language program 11, an assignment statement for storing the value to be reflected in the parent procedure from the procedure currently being processed in the structure is generated (step S3).
3) The series of description language conversion processing (step S6) is ended.

【0061】このステップS33により、図2(a)の
アセンブリ言語プログラム11の例では、図2(b)に
示すような代入文128が生成される。この代入文12
8では、図3(b)に示すPROC2の定義レジスタリ
スト内のレジスタR1を表すローカル変数r1を、親手
続きに渡す構造体の“ret”で示される領域中のr1
として代入することが示される。
By this step S33, in the example of the assembly language program 11 of FIG. 2A, the assignment statement 128 as shown in FIG. 2B is generated. This assignment statement 12
8, the local variable r1 representing the register R1 in the definition register list of PROC2 shown in FIG. 3B is r1 in the area indicated by "ret" of the structure passed to the parent procedure.
It is shown to substitute as.

【0062】さて、記述言語変換部22は、上記一連の
記述言語変換処理(ステップS6)を終了すると、その
記述言語変換処理結果である図2(b)に示したような
高級言語プログラム12を外部記憶装置10に出力する
(ステップS7)。これにより、アセンブリ言語プログ
ラム11を解析して高級言語(C言語)の記述に変換
し、高級言語(C言語)プログラム12を生成する、記
述言語変換処理装置20での処理は終了となる。
When the description language conversion section 22 completes the series of description language conversion processing (step S6), the description language conversion processing result of the high-level language program 12 as shown in FIG. 2B is obtained. The data is output to the external storage device 10 (step S7). As a result, the processing in the description language conversion processing device 20 for analyzing the assembly language program 11 and converting it into a description in a high-level language (C language) and generating the high-level language (C language) program 12 is completed.

【0063】このように本実施形態においては、アセン
ブリ言語プログラム11を高級言語(C言語)の記述に
変換して高級言語(C言語)プログラム12を生成する
際には、当該プログラム11をプログラム解析部21に
て解析することで、各手続き(PROC1,PROC
2)毎に、その手続きの呼び出し時に受け渡すべきレジ
スタのリスト(参照レジスタリスト)、その手続きから
戻る際に親手続きに値を反映すべきレジスタのリスト
(定義レジスタリスト)、及びその手続き内部でのみ使
用するレジスタのリスト(内部定義レジスタリスト)を
求めてメモリに記憶しておき、そのメモリ上のリストを
もとに、記述言語変換部22において、各手続き毎に、
対応する各リスト内のレジスタをローカル変数で表すよ
うにしている。
As described above, in this embodiment, when the assembly language program 11 is converted into the description of the high-level language (C language) to generate the high-level language (C language) program 12, the program 11 is analyzed. By analyzing in the unit 21, each procedure (PROC1, PROC
For each 2), the list of registers that should be passed when the procedure is called (reference register list), the list of registers that should reflect the value to the parent procedure when returning from the procedure (definition register list), and inside the procedure A list of registers to be used only (internally defined register list) is obtained and stored in a memory, and based on the list in the memory, in the description language conversion unit 22, for each procedure,
The registers in each corresponding list are represented by local variables.

【0064】これにより、レジスタへのアクセスがメモ
リへのアクセスに変換されることがなくなり、性能劣化
を招かないで済む。しかも、ローカル変数で表されたレ
ジスタは他の手続きからは見ることができないため、レ
ジスタ保存/回復処理を行わなくても、他の手続きには
何ら影響を及ぼさないで済む。
As a result, the access to the register is not converted into the access to the memory, and the performance is not deteriorated. Moreover, since the register represented by the local variable cannot be seen from other procedures, it does not have any influence on other procedures without register saving / restoring processing.

【0065】また、本実施形態においては、各手続き毎
に、レジスタ保存/回復処理に代えて、対応する参照レ
ジスタレスト内のレジスタを、その手続きの呼び出し時
に受け渡すべきレジスタとして扱うと共に、対応する定
義レジスタ内のレジスタを、その手続きから戻る際に親
手続きに値を反映すべきレジスタとして扱って、記述言
語変換部22にて対応する記述を行うようにしているた
め、レジスタをローカル変数で表していながら、他の手
続きとの間で値を授受する必要のあるレジスタについて
は、その授受が可能となる。
Further, in the present embodiment, instead of register saving / restoring processing for each procedure, the register in the corresponding reference register rest is treated as a register to be passed at the time of calling of the procedure, and it corresponds. Since the register in the definition register is treated as a register whose value should be reflected in the parent procedure when returning from the procedure, and the corresponding description is made in the description language conversion unit 22, the register is represented by a local variable. However, for registers that need to exchange values with other procedures, they can be exchanged.

【0066】以上は、アセンブリ言語をC言語の記述に
変換する場合について説明したが、本発明は、FORT
RANなどC言語以外の高級言語に変換する場合にも応
用可能である。
The case where the assembly language is converted into the C language description has been described above.
It is also applicable when converting to a high-level language other than C language such as RAN.

【0067】[0067]

【発明の効果】以上詳述したように本発明によれば、低
級言語から高級言語への記述言語変換を行うことで高級
言語プログラムを生成する際に、レジスタを手続き内部
でのみ見ることができるローカル変数で表し、各手続き
毎に、レジスタ保存/回復処理に代えて、その手続きの
呼び出し時に必要となるレジスタの受け渡しと、その手
続きから戻る際に必要となる親手続きにレジスタ値を反
映させる操作とを記述するようにしたので、低級言語プ
ログラムの各手続きに含まれているレジスタ保存/回復
処理を無駄のない記述に変換でき、当該レジスタ保存/
回復処理を高級言語で効率よく実行できる。
As described in detail above, according to the present invention, when a high-level language program is generated by converting a description language from a low-level language to a high-level language, a register can be seen only inside a procedure. Expressed by local variables, instead of register save / restore processing for each procedure, operation to pass the register required when calling the procedure and reflect the register value to the parent procedure required when returning from the procedure Since, the register saving / restoring processing included in each procedure of the low-level language program can be converted into a description without waste,
The recovery process can be executed efficiently in a high-level language.

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

【図1】本発明の一実施形態に係るプログラム変換装置
の全体構成を示すブロック図。
FIG. 1 is a block diagram showing an overall configuration of a program conversion device according to an embodiment of the present invention.

【図2】同実施例におけるアセンブリ言語プログラム1
1の例と、そのアセンブリ言語プログラム11を対象に
アセンブリ言語から高級言語(C言語)への記述言語変
換を行うことで生成される高級言語プログラム12の例
を対比して示す図。
FIG. 2 is an assembly language program 1 in the same embodiment.
1 is a diagram showing the example 1 and a high-level language program 12 generated by performing a description language conversion from an assembly language to a high-level language (C language) for the assembly language program 11 as a target.

【図3】図1中のプログラム解析部21(内のレジスタ
決定部214)により決定される各手続き毎の定義レジ
スタリスト、内部定義レジスタリスト及び参照レジスタ
リストの内容例を、図2中のアセンブリ言語プログラム
11を対象とした場合について示す図。
3 shows an example of contents of a definition register list, an internal definition register list, and a reference register list for each procedure determined by a program analysis unit 21 (internal register determination unit 214) in FIG. The figure shown about the case where the language program 11 is made into object.

【図4】同実施例における全体の処理の流れを説明する
ためのフローチャート。
FIG. 4 is a flowchart for explaining the flow of overall processing according to the embodiment.

【図5】図4のフローチャート中のステップS5(レジ
スタ決定処理)の処理の流れを詳細に説明するためのフ
ローチャート。
5 is a flowchart for explaining in detail a processing flow of step S5 (register determination processing) in the flowchart of FIG.

【図6】図4のフローチャート中のステップS6(記述
言語変換処理)の処理の流れを詳細に説明するためのフ
ローチャートの一部を示す図。
FIG. 6 is a diagram showing a part of a flowchart for explaining in detail the processing flow of step S6 (description language conversion processing) in the flowchart of FIG. 4;

【図7】図4のフローチャート中のステップS6(記述
言語変換処理)の処理の流れを詳細に説明するためのフ
ローチャートの残りを示す図。
7 is a diagram showing the rest of the flowchart for explaining in detail the processing flow of step S6 (description language conversion processing) in the flowchart of FIG.

【図8】従来の記述言語変換処理によってアセンブリ言
語プログラム81から変換・生成される高級言語プログ
ラム82を、アセンブリ言語プログラム81と対比して
示す図。
FIG. 8 is a diagram showing a high-level language program 82 converted and generated from an assembly language program 81 by a conventional description language conversion process, in comparison with the assembly language program 81.

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

10…外部記憶装置、 11…アセンブリ言語プログラム(低級言語プログラ
ム)、 12…高級言語プログラム、 20…記述言語変換処理装置、 21…プログラム解析部、 22…記述言語変換部、 211…レジスタ保存/回復解析部、 212…レジスタ定義/参照解析部、 213…手続き呼び出し関係解析部、 214…レジスタ決定部。
10 ... External storage device, 11 ... Assembly language program (lower language program), 12 ... High-level language program, 20 ... Description language conversion processing device, 21 ... Program analysis unit, 22 ... Description language conversion unit, 211 ... Register save / restore Analysis unit, 212 ... Register definition / reference analysis unit, 213 ... Procedure call relation analysis unit, 214 ... Register determination unit.

Claims (3)

【特許請求の範囲】[Claims] 【請求項1】 低級言語で記述された低級言語プログラ
ムを高級言語の記述に変換して高級言語プログラムを生
成するプログラム変換装置において、 前記低級言語プログラムを解析して、各手続き毎に、そ
の手続きで参照されるレジスタ、及びその手続きから直
接または間接に呼び出される手続きで参照されるレジス
タであって、その手続きから直接または間接に呼び出さ
れる以前にその手続きで書き換えられる定義レジスタと
は異なるレジスタを、各手続きの呼び出し時に受け渡す
べき第1のタイプのレジスタとして決定すると共に、そ
の手続きで書き換えられる定義レジスタ、及びその手続
きから直接または間接に呼び出される手続きで書き換え
られる定義レジスタのうち、その手続きでの保存/回復
処理の対象外レジスタを、その手続きから戻る際に親手
続きに値を反映すべき第2のタイプのレジスタとして決
定する一方、その手続きで書き換えられる定義レジスタ
のうち、その手続きでの保存/回復処理の対象レジスタ
を、その手続き内部でのみ使用する第3のタイプのレジ
スタとして決定するプログラム解析手段と、 前記低級言語プログラム及び前記プログラム解析手段の
レジスタ決定結果をもとに前記低級言語プログラムを高
級言語の記述に変換して高級言語プログラムを生成する
記述言語変換手段であって、各手続き毎に前記プログラ
ム解析手段により決定された前記第1乃至第3のタイプ
の各レジスタをローカル変数で表し、レジスタ保存/回
復処理に代えて、前記各手続き毎に決定された第1のタ
イプのレジスタを、その手続きの呼び出し時に受け渡す
べきレジスタとして記述すると共に、前記各手続き毎に
決定された第2のタイプのレジスタを、その手続きから
戻る際に親手続きに値を反映すべきレジスタとして記述
する記述言語変換手段とを具備することを特徴とするプ
ログラム変換装置。
1. A program conversion device for converting a low-level language program described in a low-level language into a high-level language description to generate a high-level language program, analyzing the low-level language program, and for each procedure, its procedure. , And the registers that are referenced in the procedure that is called directly or indirectly from the procedure, and are different from the definition registers that are rewritten in the procedure before being called directly or indirectly from the procedure, It is determined as the first type of register that should be passed when each procedure is called, and the definition register that is rewritten by that procedure and the definition register that is rewritten by the procedure that is called directly or indirectly from that procedure Registers that are not subject to save / restore processing While determining from the register of the second type that the value should be reflected in the parent procedure when returning from the procedure, the register to be saved / restored in that procedure among the definition registers that are rewritten in that procedure Program analysis means for determining as a third type of register to be used only, and a high-level language program by converting the low-level language program into a high-level language description based on the register determination result of the low-level language program and the program analysis means Is a description language conversion means for generating each of the registers of the first to third types determined by the program analysis means for each procedure by a local variable, instead of the register saving / restoring processing, The register of the first type determined for each procedure should be passed when the procedure is called. And a description language conversion means for describing the second type of register determined for each procedure as a register whose value should be reflected in the parent procedure when returning from the procedure. Characteristic program conversion device.
【請求項2】 前記プログラム解析手段は、 前記低級言語プログラムの各手続きに含まれているレジ
スタ保存/回復処理を解析して、各手続き毎に保存/回
復の対象となるレジスタを認識するレジスタ保存/回復
解析手段と、 前記低級言語プログラムの各手続き内のレジスタ定義/
参照状況を解析するレジスタ定義/参照解析手段と、 前記低級言語プログラムの手続き間の呼び出し関係を解
析する手続き呼び出し関係解析手段と、 前記レジスタ保存/回復解析手段、前記レジスタ定義/
参照解析手段及び前記手続き呼び出し関係解析手段の解
析結果をもとに、各手続きの呼び出し時に受け渡すべき
前記第1のタイプのレジスタ、各手続きから戻る際に親
手続きに値を反映すべき、その手続きでの保存/回復対
象外となる前記第2のタイプのレジスタ、及び手続き内
部でのみ使用する、その手続きでの保存/回復対象とな
る前記第3のタイプのレジスタを決定するレジスタ決定
手段とを備えていることを特徴とする請求項1記載のプ
ログラム変換装置。
2. The program analysis means analyzes register saving / restoring processing included in each procedure of the low-level language program and recognizes a register to be saved / restored for each procedure. / Recovery analysis means and register definition in each procedure of the low-level language program /
A register definition / reference analysis means for analyzing a reference situation, a procedure call relationship analysis means for analyzing a call relationship between procedures of the low-level language program, the register save / recovery analysis means, the register definition /
Based on the analysis results of the reference analysis means and the procedure call relationship analysis means, the register of the first type to be passed when calling each procedure, and the value to be reflected in the parent procedure when returning from each procedure, Register deciding means for deciding the register of the second type which is not subject to save / restore in the procedure and the register of the third type which is subject to save / restore in the procedure and is used only in the procedure; The program conversion device according to claim 1, further comprising:
【請求項3】 低級言語で記述された低級言語プログラ
ムを高級言語の記述に変換して高級言語プログラムを生
成するプログラム変換方法において、 前記低級言語プログラムを解析して、各手続き毎に、そ
の手続きで参照されるレジスタ、及びその手続きから直
接または間接に呼び出される手続きで参照されるレジス
タであって、その手続きから直接または間接に呼び出さ
れる以前にその手続きで書き換えられる定義レジスタと
は異なるレジスタを、各手続きの呼び出し時に受け渡す
べき第1のタイプのレジスタとして決定すると共に、そ
の手続きで書き換えられる定義レジスタ、及びその手続
きから直接または間接に呼び出される手続きで書き換え
られる定義レジスタのうち、その手続きでの保存/回復
処理の対象外レジスタを、その手続きから戻る際に親手
続きに値を反映すべき第2のタイプのレジスタとして決
定する一方、その手続きで書き換えられる定義レジスタ
のうち、その手続きでの保存/回復処理の対象レジスタ
を、その手続き内部でのみ使用する第3のタイプのレジ
スタとして決定し、 前記低級言語プログラムを高級言語の記述に変換して高
級言語プログラムを生成する際には、各手続き毎に、前
記決定した対応する手続きでの第1乃至第3のタイプの
各レジスタをローカル変数で表し、レジスタ保存/回復
処理に代えて、前記決定した対応する手続きでの第1の
タイプのレジスタを、その手続きの呼び出し時に受け渡
すべきレジスタとして記述すると共に、前記決定した対
応する手続きでの第2のタイプのレジスタを、その手続
きから戻る際に親手続きに値を反映すべきレジスタとし
て記述することを特徴とするプログラム変換方法。
3. A program conversion method for converting a low-level language program written in a low-level language into a high-level language description to generate a high-level language program, wherein the low-level language program is analyzed, and the procedure is executed for each procedure. , And the registers that are referenced in the procedure that is called directly or indirectly from the procedure, and are different from the definition registers that are rewritten in the procedure before being called directly or indirectly from the procedure, It is determined as the first type of register that should be passed when each procedure is called, and the definition register that is rewritten by that procedure and the definition register that is rewritten by the procedure that is called directly or indirectly from that procedure Registers that are not subject to save / restore processing While determining from the register of the second type that the value should be reflected in the parent procedure when returning from the procedure, the register to be saved / restored in that procedure among the definition registers that are rewritten in that procedure It is determined as a third type of register to be used only, and when converting the low-level language program to a high-level language description to generate a high-level language program, for each procedure, Each of the first to third types of registers is represented by a local variable, and instead of the register saving / restoring process, the first type of register in the determined corresponding procedure is used as a register to be passed when the procedure is called. In addition to the description, the value of the second type register in the determined corresponding procedure is returned to the parent procedure when returning from the procedure. Program conversion method characterized by described as should do register.
JP21475095A 1995-08-23 1995-08-23 Program transformation device and method having description language transformation function from low-class language to high-class language Pending JPH0962512A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP21475095A JPH0962512A (en) 1995-08-23 1995-08-23 Program transformation device and method having description language transformation function from low-class language to high-class language

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP21475095A JPH0962512A (en) 1995-08-23 1995-08-23 Program transformation device and method having description language transformation function from low-class language to high-class language

Publications (1)

Publication Number Publication Date
JPH0962512A true JPH0962512A (en) 1997-03-07

Family

ID=16660961

Family Applications (1)

Application Number Title Priority Date Filing Date
JP21475095A Pending JPH0962512A (en) 1995-08-23 1995-08-23 Program transformation device and method having description language transformation function from low-class language to high-class language

Country Status (1)

Country Link
JP (1) JPH0962512A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6282705B1 (en) 1998-01-12 2001-08-28 Nec Corporation Compiler capable of reducing interrupt handling in optimization and its optimization method
JP2012038231A (en) * 2010-08-11 2012-02-23 Internatl Business Mach Corp <Ibm> Compile method for optimizing binary code, compiler system therefor, and computer program

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6282705B1 (en) 1998-01-12 2001-08-28 Nec Corporation Compiler capable of reducing interrupt handling in optimization and its optimization method
JP2012038231A (en) * 2010-08-11 2012-02-23 Internatl Business Mach Corp <Ibm> Compile method for optimizing binary code, compiler system therefor, and computer program

Similar Documents

Publication Publication Date Title
US6253371B1 (en) Method for supporting parallelization of source program
US8156471B2 (en) Multi-language execution method
US7415699B2 (en) Method and apparatus for controlling execution of a child process generated by a modified parent process
US6922827B2 (en) Iterative software development environment with prioritized build rules
JPH11259437A (en) Reducing system for unnecessary barrier instruction
JPH06314203A (en) Method and device for optimizing compiler
US20120030652A1 (en) Mechanism for Describing Values of Optimized Away Parameters in a Compiler-Generated Debug Output
JPH11242597A (en) Method for generation of flow graph of java byte code data
US7062753B1 (en) Method and apparatus for automated software unit testing
US20040168157A1 (en) System and method for creating a process invocation tree
JPH0962512A (en) Program transformation device and method having description language transformation function from low-class language to high-class language
JP3196675B2 (en) Language processing method
JP3039450B2 (en) Stack area switching method and method, and storage medium storing stack area switching program
JPH09179738A (en) Object-oriented language processing method and processor
JP3018783B2 (en) Compilation method
JP2001154850A (en) Compile method for computer program
JP3120434B2 (en) Program operation analysis method
JPH09258969A (en) Program developing device and method therefor
JPH0816431A (en) Debugging process system for user program
JP3604936B2 (en) Optimization method, optimization device, and recording medium
JP2590159B2 (en) Environment setting method for integration test
JP3130421B2 (en) Program analysis method and apparatus
JP3327662B2 (en) Program translation device and program translation method
JPH1195995A (en) Device and method for analyzing data flow, and recording medium recording computer program therefor
JPH04358232A (en) Function testing method for information processor