JPH02170235A - Register saving/restoring system for call of subroutine - Google Patents

Register saving/restoring system for call of subroutine

Info

Publication number
JPH02170235A
JPH02170235A JP32496888A JP32496888A JPH02170235A JP H02170235 A JPH02170235 A JP H02170235A JP 32496888 A JP32496888 A JP 32496888A JP 32496888 A JP32496888 A JP 32496888A JP H02170235 A JPH02170235 A JP H02170235A
Authority
JP
Japan
Prior art keywords
subroutine
program
information
register
saving
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
JP32496888A
Other languages
Japanese (ja)
Inventor
Hisashi Uchida
久 内田
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 JP32496888A priority Critical patent/JPH02170235A/en
Publication of JPH02170235A publication Critical patent/JPH02170235A/en
Pending legal-status Critical Current

Links

Landscapes

  • Executing Machine-Instructions (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

PURPOSE:To improve the program executing efficiency by outputting an object program which includes the saving/restoring processes of the information on a register used in a subroutine. CONSTITUTION:An object program information output means 2 inputs a source program 1 including a subroutine and extracts a register used in the subroutine of the program 1 to output the object program information 3 including the information on the extracted register and an intermediate language 4. Then a translation code generating means 5 inputs the information 3 and the language 4 and outputs an object program 6 including the saving/restoring processes of the information on the register used in the subroutine based on the information 3 and the language 4. Thus it is possible to omit the undesired register saving/restoring processes when a subroutine is called out of a main program. Then the program executing efficiency is improved.

Description

【発明の詳細な説明】 (産業上の利用分野) 本発明は、原始プログラムを翻訳して目的プログラムを
出力する翻訳処理において、メインプログラムがサブル
ーチンを呼び出した際のレジスタの情報の退避/復旧方
式に関する。
Detailed Description of the Invention (Field of Industrial Application) The present invention provides a method for saving/recovering information in registers when a main program calls a subroutine in a translation process that translates a source program and outputs a target program. Regarding.

(従来の技術) −aにプログラムはメインプログラムと複数のサブルー
チンから構成されておりメインプログラムで使用するレ
ジスタと各サブルーチンで使用するレジスタが重複する
可能性があるので、メインプログラムが各サブルーチン
を呼び出すときは、全てのレジスタの内容を所定の場所
に退避し、サブルーチンの処理が終了してメイン・プロ
グラムに戻るときに所定の場所に退避した内容を各レジ
スタに復旧する必要がある。この各レジスタの内容の退
避および復旧処理プログラムは、従来、原始プログラム
から目的プログラムを生成する翻訳処理で作成している
。そして、各サブルーチンを独立に翻訳する場合は、各
サブルーチンで使用される全てのレジスタの退避および
回復処理は呼び出し側であるメインプログラムが行うか
、呼び出された側であるサブルーチンが行うかのいずれ
かの方式であった。
(Prior art) -a.A program consists of a main program and multiple subroutines, and the registers used in the main program and the registers used in each subroutine may overlap, so the main program calls each subroutine. In this case, it is necessary to save the contents of all registers to a predetermined location, and when the subroutine processing ends and return to the main program, the contents saved to the predetermined location must be restored to each register. Conventionally, the program for saving and restoring the contents of each register is created by a translation process that generates a target program from a source program. When each subroutine is translated independently, all registers used in each subroutine are saved and restored either by the calling main program or by the called subroutine. It was the method of

例えば、第3図に示すように、メインプログラム10と
このメインプログラム10のブロック12で呼び出され
るサブルーチン20とから構成されるプログラムを、メ
インプログラム10側でレジスタの内容を退避/復旧す
る方式でサブルーチンを別に翻訳すると、サブルーチン
20ではブロック21でレジスタ2しか使用していない
にもかかわらず、メインプログラム10のブロック11
の各5TORE命令(数字はレジスタを示す)でレジス
タ1、レジスタ2およびレジスタ3の内容を退避し、サ
ブルーチン10の処理が終了した後、ブロック13の各
LOAD命令(数字はレジスタを示す)でレジスタ1,
2.3の内容を復旧している。なお、レジスタはレジス
タ1,2.3の3個があるものとした。
For example, as shown in FIG. 3, a program consisting of a main program 10 and a subroutine 20 called by block 12 of this main program 10 is created using a subroutine that saves/restores register contents on the main program 10 side. Translated separately, even though subroutine 20 uses only register 2 in block 21, block 11 of main program 10
The contents of registers 1, 2, and 3 are saved with each of the 5 TORE instructions (numbers indicate registers), and after the processing of subroutine 10 is completed, the contents of registers are saved with each LOAD instruction (numbers indicate registers) of block 13. 1,
The contents of 2.3 have been restored. It is assumed that there are three registers, registers 1, 2, and 3.

(発明が解決しようとする課題) 上述したように、従来の方式では、メインプログラム、
サブルーチン両者とも相手側で使用されているレジスタ
を知ることができない、従ってメインプログラム側また
はサブルーチンの側いずれでレジスタの内容の退避およ
び復旧を行う方式でも、退避および復旧を必要としない
レジスタまでも退避および復旧の処理を行っているので
、プログラムの実行効率が悪くなっていた。このように
従来の方式には解決すべき課題があった。
(Problem to be solved by the invention) As mentioned above, in the conventional method, the main program,
Neither subroutine can know which registers are being used on the other side. Therefore, regardless of the method of saving and restoring register contents on either the main program side or the subroutine side, even registers that do not need to be saved and restored are saved. and recovery processing, resulting in poor program execution efficiency. As described above, the conventional methods had problems that needed to be solved.

本発明は、このような事情に鑑みてなされたものであり
、その目的は、サブルーチンを呼び゛出しな際の不用な
レジスタの3A避および復旧処理をなくすことによりプ
ログラムの実行効率を高めることができるサブルーチン
呼び出し時のレジスタ内容の退避/復旧方式を提供する
ことにある。
The present invention has been made in view of these circumstances, and its purpose is to improve program execution efficiency by eliminating unnecessary register 3A avoidance and restoration processing when calling a subroutine. The object of the present invention is to provide a method for saving and restoring register contents when calling a subroutine.

(課題を解決するための手段) 本発明のサブルーチン呼び出し時のレジスタ内容の退避
/復旧方式は上記目的を達成するために、サブルーチン
を含みえる原始プログラムを入力して目的プログラムを
生成するコンパイル処理において、 前記サブルーチンを含んだ原始プログラムを入力し前記
原始プログラム内のサブルーチンで使用されているレジ
スタを抽出して該レジスタに関する情報を含んだ目的プ
ログラム情報および中間言語を出力する目的プログラム
情報出力手段と、前記目的プログラム情報および前記中
間言語を入力して前記目的プログラム情報および前記中
間言語に基づいて、前記サブルーチンで使用されている
レジスタの情報の退避および回復処理を含んだ目的プロ
グラムを出力する翻訳コード生成手段とを有する。
(Means for Solving the Problems) In order to achieve the above object, the method of saving/restoring register contents when calling a subroutine of the present invention is implemented in a compile process that inputs a source program that can include a subroutine and generates a target program. , target program information output means for inputting a source program including the subroutine, extracting registers used in the subroutines in the source program, and outputting target program information and intermediate language including information regarding the registers; Translation code generation for inputting the target program information and the intermediate language and outputting a target program including saving and restoring processing of register information used in the subroutine based on the target program information and the intermediate language. means.

(作用) 本発明のサブルーチン呼び出し時のレジスタ内容の退避
/復旧方式においては、目的プログラム情報出力手段が
、サブルーチンを含んだ原始プログラムを入力し原始プ
ログラム内のサブルーチンで使用されているレジスタを
抽出してこのレジスタに関する情報を含んだ目的プログ
ラム情報および中間言語を出力すると、翻訳コード生成
手段が、目的プログラム情報および前記中間言語を入力
して目的プログラム情報および中間言語に基づいて、サ
ブルーチンで使用されているレジスタの情報の退避およ
び回復処理を含んだ目的プログラムを出力する。
(Operation) In the method for saving/restoring register contents when calling a subroutine of the present invention, the target program information output means inputs a source program including a subroutine and extracts the registers used by the subroutine in the source program. After outputting the target program information and the intermediate language including the information regarding the lever register, the translation code generating means inputs the target program information and the intermediate language and converts the code to be used in the subroutine based on the target program information and the intermediate language. Outputs the target program that includes the process of saving and restoring the information in the register.

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

第1図は本発明の実権例の構成図である。同図において
、1はメインプログラムおよびサブルーチンを含んだ原
始プログラム、2は目的プログラム情報出力手段、3は
各サブルーチンで使用するレジスタ情報を含んだ目的プ
ログラム情報、4は中間言語、5は翻訳/コード生成手
段、6は目的プログラムである。
FIG. 1 is a block diagram of a practical example of the present invention. In the figure, 1 is a source program including a main program and subroutines, 2 is a target program information output means, 3 is target program information including register information used in each subroutine, 4 is an intermediate language, and 5 is a translation/code The generating means 6 is a target program.

第2図は本発明の実施例により生成された目的プログラ
ムの一例である。
FIG. 2 is an example of a target program generated according to an embodiment of the present invention.

ここで、レジスタはレジスタ1,2.3の3個があるも
のとする。なお同図において第3図と同一符号は同一部
分を示す。
Here, it is assumed that there are three registers, registers 1, 2, and 3. In this figure, the same reference numerals as in FIG. 3 indicate the same parts.

第1図の実施例において、原始プログラムから目的プロ
グラムを作成する場合は、先ず、目的プログラム情報出
力手段2は、メインプログラムおよびサブルーチンを含
んだ原始プログラム1を入力し、各サブルーチンで使用
されているレジスタを抽出してこのレジスタに関する情
報を含んだ目的プログラム情報と、仮想的な翻訳処理(
翻訳/コード生成手段5へ入力するための前処理)をし
て得た中間言語4とを出する6次に、翻訳/コード生成
手段5は、この目的プログラム情報3および中間言語4
を入力してこれらの情報に基づいて翻訳すると共に計算
機で実行可能なコードを生成することにより、メインプ
ログラムでサブルーチンが呼び出される際に、サブルー
チンで使用されるレジスタについてだけ退避および復旧
処理を含んだ目的プログラム6を出力する。
In the embodiment shown in FIG. 1, when creating a target program from a source program, first, the target program information output means 2 inputs a source program 1 including a main program and subroutines, and inputs a source program 1 including a main program and subroutines. Registers are extracted and target program information containing information about these registers and virtual translation processing (
Next, the translation/code generation means 5 outputs the intermediate language 4 obtained by performing the preprocessing (preprocessing for input to the translation/code generation means 5) and the intermediate language 4.
By inputting and translating based on this information and generating code that can be executed by a computer, when a subroutine is called in the main program, it includes saving and restoring processing only for the registers used in the subroutine. Output the target program 6.

このように処理して得られた目的プログラムの一例を第
2図に示す、同図においてサブルーチン20においては
レジスタ2しか使用していないので、メインプログラム
10のブロック14でレジスタ2の内容を所定の領域(
WORKl )に退避し、サブルーチン10の処理が終
了した後、ブロック15でWORKIに退避してあった
内容をレジスタ2に復旧する命令が生成されている。
An example of the target program obtained by processing in this way is shown in FIG. region(
After the processing of subroutine 10 is completed, an instruction to restore the contents saved to WORKI to register 2 is generated in block 15.

(発明の効果) 以上に説明したように、本発明によれば、メインプログ
ラムからサブルーチンを呼び出す際の不用なレジスタの
退11/復旧処理をなくすことができるので、プログラ
ムの実行効率を高めることができる。
(Effects of the Invention) As described above, according to the present invention, it is possible to eliminate unnecessary register write-down/restoration processing when calling a subroutine from the main program, thereby improving program execution efficiency. can.

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

第1図は本発明の実施例の構成図、第2図は第1図の実
施例により生成された目的プログラムの一例を示す図、
第3図は従来例の説明図である。 1・・・原始プログラム、2・・・目的プログラム情報
出力手段、3・・・目的プログラム情報、4・・・中間
言語、5・・・翻訳/コード生成手段、6・・・目的プ
ログラム、10・・・メインプログラム、20・・・サ
ブルーチン。
FIG. 1 is a block diagram of an embodiment of the present invention, FIG. 2 is a diagram showing an example of a target program generated by the embodiment of FIG. 1,
FIG. 3 is an explanatory diagram of a conventional example. DESCRIPTION OF SYMBOLS 1... Source program, 2... Target program information output means, 3... Target program information, 4... Intermediate language, 5... Translation/code generation means, 6... Target program, 10 ...Main program, 20...Subroutine.

Claims (1)

【特許請求の範囲】 サブルーチンを含みえる原始プログラムを入力して目的
プログラムを生成するコンパイル処理において、 前記サブルーチンを含んだ原始プログラムを入力し前記
原始プログラム内のサブルーチンで使用されているレジ
スタを抽出して該レジスタに関する情報を含んだ目的プ
ログラム情報および中間言語を出力する目的プログラム
情報出力手段と、前記目的プログラム情報および前記中
間言語を入力して前記目的プログラム情報および前記中
間言語に基づいて、前記サブルーチンで使用されている
レジスタの情報の退避および回復処理を含んだ目的プロ
グラムを出力する翻訳コード生成手段と を有するサブルーチン呼び出し時のレジスタの退避/復
旧方式。
[Claims] In a compilation process that generates a target program by inputting a source program that can include subroutines, the source program that includes the subroutines is input and registers used by the subroutines in the source program are extracted. a target program information output means for outputting target program information and an intermediate language including information regarding the register; A method for saving/restoring registers when calling a subroutine, the method having a translation code generating means for outputting a target program including saving and restoring processing of register information used in a subroutine.
JP32496888A 1988-12-23 1988-12-23 Register saving/restoring system for call of subroutine Pending JPH02170235A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP32496888A JPH02170235A (en) 1988-12-23 1988-12-23 Register saving/restoring system for call of subroutine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP32496888A JPH02170235A (en) 1988-12-23 1988-12-23 Register saving/restoring system for call of subroutine

Publications (1)

Publication Number Publication Date
JPH02170235A true JPH02170235A (en) 1990-07-02

Family

ID=18171639

Family Applications (1)

Application Number Title Priority Date Filing Date
JP32496888A Pending JPH02170235A (en) 1988-12-23 1988-12-23 Register saving/restoring system for call of subroutine

Country Status (1)

Country Link
JP (1) JPH02170235A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06242962A (en) * 1993-01-15 1994-09-02 Internatl Business Mach Corp <Ibm> Optimized method and equipment for specifying visual border of compiled cord
CN112445484A (en) * 2019-08-27 2021-03-05 龙芯中科技术股份有限公司 Register processing method and device, electronic equipment and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06242962A (en) * 1993-01-15 1994-09-02 Internatl Business Mach Corp <Ibm> Optimized method and equipment for specifying visual border of compiled cord
CN112445484A (en) * 2019-08-27 2021-03-05 龙芯中科技术股份有限公司 Register processing method and device, electronic equipment and storage medium
CN112445484B (en) * 2019-08-27 2023-11-24 龙芯中科技术股份有限公司 Register processing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
TW356540B (en) Method for operating a computer program on a computer readable media for execution by a vector processor and by a dual multiprocessor including a vector processor and a RISC processor
JPH02170235A (en) Register saving/restoring system for call of subroutine
JPS61245239A (en) Logical circuit system
JP2590288B2 (en) Program conversion device
JPH03240837A (en) Debug information generating device
KR0169909B1 (en) Method for designing assembly code generator for target processor
KR100255801B1 (en) Method of debugging a specified processor in electric switching system
JPH0210429A (en) Program structure processing system
JPH0358136A (en) Compiler operation system in machine different in character code system
JPH0250730A (en) Language converting system based upon common machine word
JPH0358232A (en) Preprocessor calling system
JP3293652B2 (en) Simulation program generation method
JPH03167638A (en) Logical simulation system
JPH04343140A (en) Parallelized processing system
JPH11272473A (en) Code optimizing system for program language processor
JPH03144830A (en) Parallel processing system
JPH04153741A (en) Adverse debugging execution system for debugged program
JPH01136239A (en) Program translation processing system
JPS62267830A (en) Arithmetic control system for vector processing built-in function in programming language
JPH02205930A (en) Interface check processing method
JPH0357022A (en) Arithmetic processing system
JPS6143347A (en) Simulation method of vector instruction
JPS62271024A (en) Optimization processing system
JPH04340647A (en) Method for supporting auxiliary function by coprocessor
JPH01100633A (en) Purpose program generating system