JP5598375B2 - Allocation method for allocating code included in program to memory area and memory system for executing the method - Google Patents

Allocation method for allocating code included in program to memory area and memory system for executing the method Download PDF

Info

Publication number
JP5598375B2
JP5598375B2 JP2011036487A JP2011036487A JP5598375B2 JP 5598375 B2 JP5598375 B2 JP 5598375B2 JP 2011036487 A JP2011036487 A JP 2011036487A JP 2011036487 A JP2011036487 A JP 2011036487A JP 5598375 B2 JP5598375 B2 JP 5598375B2
Authority
JP
Japan
Prior art keywords
function
call
memory
recursive
memory bank
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.)
Expired - Fee Related
Application number
JP2011036487A
Other languages
Japanese (ja)
Other versions
JP2012174069A (en
Inventor
俊樹 小原
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.)
Fujitsu Ltd
Original Assignee
Fujitsu 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 Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2011036487A priority Critical patent/JP5598375B2/en
Publication of JP2012174069A publication Critical patent/JP2012174069A/en
Application granted granted Critical
Publication of JP5598375B2 publication Critical patent/JP5598375B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Memory System (AREA)
  • Devices For Executing Special Programs (AREA)

Description

プログラムコードに含まれるコードをメモリ領域に割り当てる方法及びその方法を実行するメモリシステムに関する。   The present invention relates to a method for assigning a code included in a program code to a memory area and a memory system for executing the method.

CPUとメモリからなるシステムにおいて、CPUに供給されるソースプログラムの内容に応じて、メモリの消費電力を削減するように、CPUがメモリの動作を制御する方法が提案されている(特許文献1−2参照)。特に、CPUとメモリからなるシステムを半導体1チップに搭載するSOC(System On Chip)において、上記に記載した、消費電力を削減するメモリの動作制御方法が注目されようとしている。   In a system comprising a CPU and a memory, a method has been proposed in which the CPU controls the operation of the memory so as to reduce the power consumption of the memory in accordance with the contents of the source program supplied to the CPU (Patent Document 1). 2). In particular, in an SOC (System On Chip) in which a system including a CPU and a memory is mounted on a single semiconductor chip, the above-described memory operation control method for reducing power consumption is drawing attention.

特許文献1によれば、ソースプログラム中のループを単位とする各フェーズ及び各フェーズで参照する参照データを抽出することにより、ソースプログラムを分割するフェーズ分割処理を行い、各フェーズにおいて、参照データを記憶するのに必要なメモリ領域をCPUのキャッシュメモリとCPU外のオンチップメモリとに最適に配分することにより電力の削減を図る方法が記載されている。   According to Patent Document 1, each phase in units of a loop in a source program and reference data to be referred to in each phase are extracted to perform phase division processing for dividing the source program. There is described a method for reducing power by optimally allocating a memory area necessary for storage to a cache memory of a CPU and an on-chip memory outside the CPU.

特許文献1から2の文献によれば、メモリが電力制御状態へ遷移する、又は電力制御状態から復帰する時間が、CPUに供給されるクロック周期に比較して長い場合に、性能が低下しないように、命令コードを記憶するメモリ領域の電力制御状態を最適に制御して消費電力の削減を図る方法が記載されている。   According to the documents of Patent Documents 1 and 2, when the time for the memory to transition to or return from the power control state is longer than the clock period supplied to the CPU, the performance does not deteriorate. Describes a method for reducing the power consumption by optimally controlling the power control state of the memory area in which the instruction code is stored.

しかし、ソースプログラムの構造によっては、電力制御状態にすることができる、命令コードを記憶するメモリ領域が制限され、電力制御状態の制御によっては、消費電力の削減効果が減少する場合があった。   However, depending on the structure of the source program, the memory area that stores the instruction code that can be in the power control state is limited, and depending on the control of the power control state, the effect of reducing power consumption may be reduced.

特開2008−102733号公報JP 2008-102733 A 特開2010−257437号公報JP 2010-257437 A

記憶領域の電力状態の制御により消費電力削減をさせ得る、プログラムコードの記憶領域への割り当て状態を実現する方法及びその方法を実行するメモリシステムを提供することを目的とする。   It is an object of the present invention to provide a method for realizing an allocation state of program codes to a storage area, which can reduce power consumption by controlling the power state of the storage area, and a memory system for executing the method.

上記を解決するため、本発明の一側面によれば、プロセッサに読み込まれたプログラム中の関数間の呼び出し関係を、プロセッサが抽出する工程と、関数間の呼出し関係に基づく、関数の呼び出し連鎖に沿って、呼出し関係を追跡していき、一度呼出された関数が再度呼出された場合に、一度目の呼出しから2度目の呼出しまでの間に経由した関数群を再帰呼出し部とする再帰呼出し抽出工程と、再帰呼出し部を表すプログラムに含まれるコードを、供給される電圧状態を独立して切替可能なメモリバンクに、プロセッサが、割り当てるコード割当工程と、を備えることを特徴とするプログラムに含まれるコードをメモリ領域に割り当てる割当方法を提供する。   In order to solve the above, according to one aspect of the present invention, a call relationship between functions in a program read by a processor is extracted into a function call chain based on a process in which the processor extracts and a call relationship between functions. The call relationship is traced, and when a function that has been called once is called again, recursive call extraction is performed with the function group passed between the first call and the second call as the recursive call part. A code allocation step in which a processor assigns a code included in a program representing a process and a recursive calling unit to a memory bank in which a supplied voltage state can be switched independently; A method for allocating assigned codes to memory areas is provided.

本発明によれば、プログラムに含まれるコードを記憶領域に割り当てる方法であって、その方法により実現された、記憶領域におけるコードの割当状態に応じて、記憶領域を構成するデバイスの電力状態を制御した場合、消費電力削減を実現させ得る方法及びその方法を実行するメモリシステムを提供することができる。
According to the present invention, a method for allocating a code included in a program to a storage area, and controlling a power state of a device constituting the storage area according to a code allocation state in the storage area realized by the method. In this case, it is possible to provide a method capable of realizing power consumption reduction and a memory system that executes the method.

図1は、実施例1のメモリシステム50を示す図である。FIG. 1 is a diagram illustrating a memory system 50 according to the first embodiment. 図2はソースプログラムの例及びソースプログラムの命令コードに対するメモリ領域の割り当ての例を示す図である。FIG. 2 is a diagram showing an example of a source program and an example of allocation of memory areas to instruction codes of the source program. 図3は、プログラムに含まれるコードに記憶領域を割り当てる割当方法を示す。FIG. 3 shows an allocation method for allocating storage areas to codes included in a program. 図4は呼出関係抽出ステップ工程S31に関する、フローチャート、静的コールグラフ、及び、呼出し関係抽出後の出力データ表を図示する。FIG. 4 shows a flowchart, a static call graph, and an output data table after the call relationship is extracted regarding the call relationship extraction step S31. 図5は再帰呼出抽出工程S32Aを説明するメインフローチャート及びサブルーチンS321を説明するサブルーチンフローチャートを示す。FIG. 5 shows a main flowchart for explaining the recursive call extraction step S32A and a subroutine flowchart for explaining the subroutine S321. 図6はサブルーチンS322及びサブルーチンS322と再帰縮退工程S33との関係を示すフローチャートである。FIG. 6 is a flowchart showing the relationship between the subroutine S322 and the subroutine S322 and the recursive degeneration step S33. 図7は再帰呼出抽出工程S32Aにおける、再帰読出部の検出について説明する図である。FIG. 7 is a diagram for explaining the detection of the recursive reading unit in the recursive call extraction step S32A. 図8は、再帰縮退工程S33を説明するための図である。FIG. 8 is a diagram for explaining the recursive degeneration step S33. 図9は、再帰縮退工程S33における具体的な処理動作の例を示す。FIG. 9 shows an example of a specific processing operation in the recursive degeneration step S33. 図10はメモリ割当工程S34を説明するフローチャートである。FIG. 10 is a flowchart for explaining the memory allocation step S34. 図11は関数に関するプログラムソースコードの割当状況を示す図である。FIG. 11 is a diagram showing an assignment state of program source codes related to functions. 図12は、実施例1の変形例であるメモリシステム110及びそのメモリシステム110において生成される電源制御入り実行プログラムの生成方法に対するフローチャートを示す。FIG. 12 is a flowchart for a memory system 110 that is a modification of the first embodiment and a method for generating an execution program with power supply control generated in the memory system 110. 図13は、実施例2に係わる、プログラムに含まれるコードに記憶領域を割り当てる割当方法を説明する図である。FIG. 13 is a diagram illustrating an allocation method for allocating storage areas to codes included in a program according to the second embodiment. 図14は呼出関係抽出工程S35に関する、フローチャート、静的コールグラフ、及び、呼出抽出後の出力データ表を図示する。FIG. 14 shows a flowchart, a static call graph, and an output data table after the call extraction related to the call relationship extraction step S35. 図15は再帰縮退工程S36を説明するための図である。FIG. 15 is a diagram for explaining the recursive degeneration step S36. 図16は、再帰縮退工程S36における具体的な処理動作の例を示す。FIG. 16 shows an example of a specific processing operation in the recursive degeneration step S36. 図17は、実施例のメモリ割当工程S37を説明するフローチャートである。FIG. 17 is a flowchart illustrating the memory allocation step S37 according to the embodiment. 図18Aは実施例3に係わるメモリ割当工程S4005を示す。FIG. 18A shows a memory allocation step S4005 according to the third embodiment. 図18Bは実施例3に係わるメモリ領域割り当てルーチンS400507を示す。FIG. 18B shows a memory area allocation routine S400507 according to the third embodiment. 図19Aは、第3実施例に係わるメモリ割当工程S4005により関数を各メモリバンクに割り当てる具体例を示す。FIG. 19A shows a specific example in which a function is allocated to each memory bank in the memory allocation step S4005 according to the third embodiment. 図19Bは第3実施例に係わるメモリ割当工程S4005により関数を各メモリバンクに割り当てる具体例を示す。FIG. 19B shows a specific example in which a function is allocated to each memory bank in the memory allocation step S4005 according to the third embodiment. 図19Cは、第3実施例に係わるメモリ割当工程S4005により関数を各メモリバンクに割り当てる具体例を示す。FIG. 19C shows a specific example in which a function is allocated to each memory bank in the memory allocation step S4005 according to the third embodiment. 図19Dは電力制御有りメモリ割当工程S4005を行った結果を示す。FIG. 19D shows the result of performing memory allocation step S4005 with power control. 図20は実施例3に示したプログラムを実施した場合に、消費電力の削減効果が減少する例を示す。FIG. 20 shows an example in which the power consumption reduction effect decreases when the program shown in the third embodiment is executed. 図21Aは、実施例4に係わるメモリ割当工程S4105を示す。FIG. 21A shows a memory allocation step S4105 according to the fourth embodiment. 図21Bは、関数群F_Maxをメモリバンクに割り当てるルーチンS410524を説明する図である。FIG. 21B is a diagram for explaining a routine S410524 for assigning a function group F_Max to a memory bank. 図22は、実施例4に係わるメモリ割当工程S4105により関数を各メモリバンクに割り当てる具体例を示す。FIG. 22 shows a specific example in which a function is allocated to each memory bank in the memory allocation step S4105 according to the fourth embodiment.

本発明は、以下に説明する実施例に対し、当業者が想到可能な、設計上の変更が加えられたもの、及び、実施例に現れた構成要素の組み換えが行われたものも含む。また、本発明は、その構成要素が同一の作用効果を及ぼす他の構成要素へ置き換えられたもの等も含み、以下の実施例に限定されない。   The present invention includes the embodiments described below that have been modified by the design that can be conceived by those skilled in the art, and those in which the components shown in the embodiments have been recombined. Further, the present invention includes those in which the constituent elements are replaced with other constituent elements having the same operational effects, and are not limited to the following embodiments.

図1は、実施例1のメモリシステム50を示す図である。メモリシステム50はメモリユニット10、プロセッサ20、制御レジスタ群30、バス40、電源線45、電源制御装置46を含む。(特願2009−9065、特願2009−266575、特願2010−9269参照)
プロセッサ20はメモリコントローラを内蔵し、メモリユニット10に含まれるメモリバンク11、12、13、14、15へのデータ又は命令コードの書込又は読出をコントロールする。さらに、メモリバンク11、12、13、14、15の電源制御を行うための電源制御信号を制御レジスタ群30に出力する。
制御レジスタ群30は、CPUからの電源制御信号に応じて、メモリバンク11、12、13、14、15の電源制御状態を記憶するレジスタ群である。そこで、例えば、制御レジスタ群30は、8個のレジスタからなり、“00000101”とデジットが設定されると、メモリバンク11とメモリバンク13の電源がオンする。
FIG. 1 is a diagram illustrating a memory system 50 according to the first embodiment. The memory system 50 includes a memory unit 10, a processor 20, a control register group 30, a bus 40, a power supply line 45, and a power supply control device 46. (See Japanese Patent Application Nos. 2009-9065, 2009-266575, and 2010-9269)
The processor 20 includes a memory controller, and controls writing or reading of data or instruction codes to or from the memory banks 11, 12, 13, 14, 15 included in the memory unit 10. Further, a power control signal for performing power control of the memory banks 11, 12, 13, 14, 15 is output to the control register group 30.
The control register group 30 is a register group that stores the power control states of the memory banks 11, 12, 13, 14, and 15 in accordance with a power control signal from the CPU. Therefore, for example, the control register group 30 is composed of eight registers. When “00000101” is set as a digit, the power to the memory bank 11 and the memory bank 13 is turned on.

電源制御装置46は、電源線45と各メモリバンク11、12、13、14、15間に配置され、各メモリバンク11、12、13、14、15の電源状態を、制御レジスタ群30からの信号に応じて制御する。なお、電源状態とは、電源線45から各メモリバンク11、12、13、14、15への接続を切断している電源切断状態、電源線45からの電源を、電圧を低下させて各メモリバンク11、12、13、14、15へ供給する省電力供給状態、電源線45からの電源を電圧を保持しながら各メモリバンク11、12、13、14、15へ供給する通常電力供給状態を含む。   The power supply control device 46 is disposed between the power supply line 45 and each of the memory banks 11, 12, 13, 14, 15. The power supply state of each of the memory banks 11, 12, 13, 14, 15 is changed from the control register group 30. Control according to the signal. The power supply state is a power-off state in which the connection from the power supply line 45 to each of the memory banks 11, 12, 13, 14, and 15 is cut off, and the power supply from the power supply line 45 is reduced in voltage to each memory. A power saving supply state for supplying to the banks 11, 12, 13, 14, 15 and a normal power supply state for supplying the power from the power supply line 45 to each of the memory banks 11, 12, 13, 14, 15 while maintaining the voltage. Including.

メモリユニット10は命令コード用メモリ16とデータ用メモリ17を含む。命令コード用メモリ16は、メモリバンク11、12、13、14を含む。また、データ用メモリ17は複数のメモリバンク15を含む。各メモリバンク11、12、13、14、15の電源状態は電源制御装置46によって制御されることはいうまでもない。
なお、電源切断状態においては、各メモリバンク11、12、13、14、15は、データの保持もできないし、読出及び書込もできない。省電力供給状態においては、各メモリバンク11、12、13、14、15は、データ保持はできるが、読出及び書込を正常に行えない。通常電力供給状態においては、各メモリバンク11、12、13、14、15は、データ保持もできるし、読出及び書込を正常に行える。なお、メモリバンク11はメモリユニット10において、0x0000番地から0x0fff番地までの領域を占める。メモリバンク12はメモリユニット10において、0x1000番地から0x1fff番地までの領域を占める。メモリバンク13はメモリユニット10において、0x2000番地から0x2fff番地までの領域を占める。メモリバンク14はメモリユニット10において、0x3000番地から0x3fff番地までの領域を占める。メモリバンク15はデータ用メモリ17において、0x4000番地以降のメモリ領域を占める。
The memory unit 10 includes an instruction code memory 16 and a data memory 17. The instruction code memory 16 includes memory banks 11, 12, 13, and 14. The data memory 17 includes a plurality of memory banks 15. It goes without saying that the power supply state of each memory bank 11, 12, 13, 14, 15 is controlled by the power supply control device 46.
In the power-off state, the memory banks 11, 12, 13, 14, and 15 cannot hold data, and cannot read and write. In the power saving supply state, each of the memory banks 11, 12, 13, 14, and 15 can hold data, but cannot read and write normally. In the normal power supply state, each of the memory banks 11, 12, 13, 14, and 15 can hold data and can normally perform reading and writing. The memory bank 11 occupies an area from the address 0x0000 to the address 0x0fff in the memory unit 10. The memory bank 12 occupies an area from the address 0x1000 to the address 0x1fff in the memory unit 10. The memory bank 13 occupies an area from the address 0x2000 to the address 0x2fff in the memory unit 10. The memory bank 14 occupies an area from the address 0x3000 to the address 0x3fff in the memory unit 10. The memory bank 15 occupies the memory area after the address 0x4000 in the data memory 17.

従って、読出及び書込動作が発生しないときに、各メモリバンク11、12、13、14、15を省電力供給状態とすることができる。そうすると、少数のメモリバンクに読出及び書込を集中させるほど、メモリシステム50全体の電力を大きく削減することができる。   Therefore, each memory bank 11, 12, 13, 14, 15 can be brought into a power saving supply state when no read and write operations occur. Then, the power of the entire memory system 50 can be greatly reduced as reading and writing are concentrated in a small number of memory banks.

図2はソースプログラムの例及びソースプログラムの命令コードに対するメモリ領域の割り当ての例を示す図である。図2によれば、メモリバンク11にメインプログラムが割り当てられ、メモリバンク12に関数func_A1を特定するプログラムが割り当てられ、メモリバンク13に関数func_A2を特定するプログラムが割り当てられている。
メインプログラムにおける、「メモリバンク12 Sleep解除コード片」は、メモリバンク12を、省電力供給状態から通常電力供給状態へ移行させる命令コード片である。次いで、「call Func_A1」はメモリバンクに割り当てられているFunc_A1という関数を呼び出す命令コードである。次いで、「メモリバンク12 Sleepコード片」は、メモリバンク12を、通常電力供給状態から省電力供給状態へ移行させる命令コード片」である。
FIG. 2 is a diagram showing an example of a source program and an example of allocation of memory areas to instruction codes of the source program. According to FIG. 2, the main program is assigned to the memory bank 11, the program specifying the function func_A1 is assigned to the memory bank 12, and the program specifying the function func_A2 is assigned to the memory bank 13.
The “memory bank 12 sleep cancellation code fragment” in the main program is an instruction code fragment that shifts the memory bank 12 from the power saving supply state to the normal power supply state. Next, “call Func_A1” is an instruction code for calling a function called Func_A1 assigned to the memory bank. Next, the “memory bank 12 Sleep code fragment” is an instruction code fragment that shifts the memory bank 12 from the normal power supply state to the power saving supply state.

メインプログラムにおける、「メモリバンク13 Sleep解除コード片」は、メモリバンク13を、省電力供給状態から通常電力供給状態へ移行させる命令コード片である。次いで、「call Func_A2」はメモリバンクに割り当てられているFunc_A2という関数を呼び出す命令コードである。次いで、「メモリバンク13 Sleepコード片」は、メモリバンク13を、通常電力供給状態から省電力供給状態へ移行させる命令コード片」である。
このように、メインプログラム中に関数を呼び出す命令コードがあると、関数を表す命令コードが割り当てられているメモリバンクは省電力供給状態から通常電力供給状態へ移行され、関数結果をメインプログラムに引き渡すと、そのメモリバンクは通常電力供給状態から省電力供給状態へ戻される。
The “memory bank 13 sleep cancellation code fragment” in the main program is an instruction code fragment that shifts the memory bank 13 from the power saving supply state to the normal power supply state. Next, “call Func_A2” is an instruction code for calling a function called Func_A2 assigned to the memory bank. Next, the “memory bank 13 Sleep code piece” is an instruction code piece for shifting the memory bank 13 from the normal power supply state to the power saving supply state.
As described above, when there is an instruction code for calling a function in the main program, the memory bank to which the instruction code representing the function is assigned is shifted from the power saving supply state to the normal power supply state, and the function result is transferred to the main program. Then, the memory bank is returned from the normal power supply state to the power saving supply state.

図3は、プログラムに含まれるコードに記憶領域を割り当てる割当方法を示す。なお、その割当方法を実行することによって、記憶領域の電力状態の制御により消費電力を削減させ得る、記憶領域の割り当て状態を実現することができる。
コードを記憶領域に割り当てる割当方法は、図1のプロセッサ20によって実行され、呼出し関係抽出工程S31、再帰呼出抽出工程S32A、再帰呼出処理済み静的コールグラフ作成工程S32B、再帰縮退工程S33、及び、メモリ割当工程S34を含む。
呼出し関係抽出工程S31はプログラム62のソースコード、アセンブリまたはオブジェクトを走査し、静的コールグラフを作成するステップである。静的コールグラフとは、ソースコード、アセンブリコード、またはオブジェクトコード上において、親関数又は関数間の呼出し関係を表現するものである。従って、静的コールグラフを作成するに先立ち、プロセッサ20は、読み込まれたプログラム中の「関数間の呼び出し関係」を抽出することとなる。静的コールグラフについて、図4を用いてさらに説明する。
FIG. 3 shows an allocation method for allocating storage areas to codes included in a program. By executing the allocation method, it is possible to realize a storage area allocation state that can reduce power consumption by controlling the power state of the storage area.
The allocation method for allocating codes to storage areas is executed by the processor 20 of FIG. 1 and includes a call relation extraction step S31, a recursive call extraction step S32A, a recursive call processed static call graph creation step S32B, a recursive degeneration step S33, and A memory allocation step S34 is included.
The call relationship extraction step S31 is a step of scanning the source code, assembly or object of the program 62 and creating a static call graph. A static call graph expresses a call relationship between a parent function or functions on source code, assembly code, or object code. Therefore, prior to creating the static call graph, the processor 20 extracts the “call relationship between functions” in the read program. The static call graph will be further described with reference to FIG.

再帰呼出抽出工程S32Aは呼出し関係抽出工程S31の呼出し関係に基づいて、親関数又は関数間の再帰呼出し部を抽出するステップである。再帰呼出し部を抽出した場合、再帰呼出し部の縮退を行うため再帰縮退工程S33に進む。一方、再帰縮退工程S33から戻ってきたときに、さらに再帰呼出し部を抽出しないときには、再帰読出処理済み静的コールグラフ作成工程S32Bに進む。
ここで、再帰呼出しとは、呼出しに応じた関数又はその関数からさらに呼び出しを受けた関数を含む、呼び出し連鎖中の関数が、呼出し関係の元となった関数を呼び出すことをいう。
また、再帰呼出し部を抽出するとは、「関数間の呼出し関係」に基づく、関数の呼び出し連鎖に沿って、前記呼出し関係を追跡していき、一度呼出された関数が再度呼出された場合に、一度目の呼出しから2度目の呼出しまでの間に経由した関数群を再帰呼出し部とするとすることである。再帰呼出し部の抽出について、図5、6、7を用いてさらに説明する。
再帰呼出処理済み静的コールグラフ作成工程S32B:再帰呼出抽出工程S32A及び再帰縮退工程S33を繰り返し行い、すべてのソースコードに対して、再帰呼出部の抽出と、再帰呼出部に対する再帰縮退が終了した時に、再帰呼出処理済み静的コールグラフ作成工程S32Bにおいて、すべてのソースコードに対する、再帰呼出処理済み静的コールグラフ63、再帰呼出済み関数サイズ情報64、関数縮退情報65が、作成される。
The recursive call extraction step S32A is a step of extracting a parent function or a recursive call portion between functions based on the call relationship of the call relationship extraction step S31. When the recursive call part is extracted, the process proceeds to the recursive degeneration step S33 in order to degenerate the recursive call part. On the other hand, when returning from the recursive degeneration step S33, if no recursive call part is extracted, the process proceeds to the recursive read processed static call graph creation step S32B.
Here, the recursive call means that a function in a call chain including a function corresponding to the call or a function further called from the function calls a function that is a source of the call relation.
Further, extracting the recursive call part means that the call relationship is traced along the function call chain based on the “call relationship between functions”, and when a function that has been called once is called again, A function group passed between the first call and the second call is assumed to be a recursive call unit. The extraction of the recursive call part will be further described with reference to FIGS.
Recursive call processed static call graph creation step S32B: The recursive call extraction step S32A and the recursive degeneration step S33 are repeated, and the extraction of the recursive call portion and the recursive degeneration for the recursive call portion are completed for all source codes. Sometimes, in the recursive call processed static call graph creation step S32B, recursive call processed static call graph 63, recursive call completed function size information 64, and function degeneration information 65 are created for all source codes.

再帰縮退工程S33は再帰呼出抽出工程S32Aにおいて、再帰呼出し部を抽出した場合、再帰呼出し部をまとめる再帰縮退を行う。再帰縮退を行った結果、ひとまとまりとなった再帰呼出し部は一つの関数と見立てられる。一つと見立てられた関数の記憶サイズは、関数サイズ情報61から得られる、元の関数サイズに応じて、計算によって求められる。再帰縮退について、図8、図9、図10を用いてさらに、説明する。
再帰読出処理済み静的コールグラフ作成工程S32Bはすべての再帰読出部の検出と、その再帰縮退が終了した場合、与えられたソースコード全体について、再帰読出処理済み後の静的コールグラフ、再帰呼出し処理済み後の関数サイズ情報、関数縮退情報を作成する。
In the recursive degeneration step S33, when a recursive call portion is extracted in the recursive call extraction step S32A, a recursive degeneracy for recursive call portions is performed. As a result of the recursive reduction, the recursive call part that is grouped is regarded as one function. The storage size of the function regarded as one is obtained by calculation according to the original function size obtained from the function size information 61. The recursive degeneration will be further described with reference to FIG. 8, FIG. 9, and FIG.
In the recursive read processed static call graph creation step S32B, when all the recursive read units are detected and the recursive degeneration is completed, the static call graph and recursive call after the recursive read processing are applied to the entire given source code. Create function size information and function degeneration information after processing.

メモリ割当工程S34は一つと見立てられた関数を表すプログラム中のコードについて、一体としてメモリ領域の同一のメモリバンクに割り振る工程である。すなわち、一つと見立てられた関数は、同一メモリバンクに格納される。ここで、一つと見立てられた関数が割り振られたメモリバンクは、図1に示すメモリバンク11、12、13、14、15のように、電力供給状態が切替可能な、メモリバンクである。   The memory allocation step S34 is a step of allocating codes in a program representing a function assumed to be one to the same memory bank in the memory area. That is, a function that is regarded as one is stored in the same memory bank. Here, a memory bank to which a function assumed to be one is allocated is a memory bank whose power supply state can be switched, such as memory banks 11, 12, 13, 14, and 15 shown in FIG.

図4は呼出関係抽出ステップ工程S31に関する、フローチャート、静的コールグラフ、及び、呼出し関係抽出後の出力データ表を図示する。
図4の静的コールグラフは、例として与えられた、ソースコード上での関数の呼出し関係を表現している。すなわち、図4の静的コールグラフにおいては、メイン関数f_MAINから子関数f_A2を経由して子関数f_B2を呼び出す経路と、メイン関数f_MAINから子関数f_A3を経由して子関数f_B2を呼び出す経路と、メイン関数f_MAINから子関数f_A3を経由して子関数f_B3を呼び出す経路と、子関数f_B2から子関数f_B3を呼び出す経路と、子関数f_B2から子関数f_A3を呼び出す経路と、が記載されている。
図4の呼出し関係抽出工程S31の出力データ表は、図4の静的コールグラフに対応する出力データ表である。図4の出力データ表の第1列は呼出し元の関数が記載され、第2列は呼出し先の関数が記載されている。図4の出力データ表によれば、メイン関数f_MAINは子関数f_A2と、子関数f_A3を呼び出す。子関数f_A2及び子関数f_A3は子関数f_B2を呼び出す。子関数f_A3及び子関数f_B2は子関数f_B3を呼び出す。子関数f_B2は子関数f_A3を呼び出す。
FIG. 4 shows a flowchart, a static call graph, and an output data table after the call relationship is extracted regarding the call relationship extraction step S31.
The static call graph of FIG. 4 represents a function calling relationship on the source code given as an example. That is, in the static call graph of FIG. 4, a path for calling the child function f_B2 from the main function f_MAIN via the child function f_A2, a path for calling the child function f_B2 from the main function f_MAIN via the child function f_A3, A path for calling the child function f_B3 from the main function f_MAIN via the child function f_A3, a path for calling the child function f_B3 from the child function f_B2, and a path for calling the child function f_A3 from the child function f_B2 are described.
The output data table in the call relationship extraction step S31 in FIG. 4 is an output data table corresponding to the static call graph in FIG. The first column of the output data table in FIG. 4 describes the call source function, and the second column describes the call destination function. According to the output data table of FIG. 4, the main function f_MAIN calls the child function f_A2 and the child function f_A3. The child function f_A2 and the child function f_A3 call the child function f_B2. The child function f_A3 and the child function f_B2 call the child function f_B3. The child function f_B2 calls the child function f_A3.

図4のフローチャートによれば、呼出関係抽出工程S31は、関数開始記述抽出工程S311と、関数呼出し記述検出および出力データ表への追加工程S312を行うステップとを含む。
関数開始記述抽出工程S311は与えられたソースコードより関数の開始となる記述を抽出し、呼出し元の関数名を得る工程である。関数呼出し記述検出および出力表への追加工程S312は、与えられたソースコード中の関数呼出し記述を検出し、呼出し元関数と呼出し先関数を表形式で追加して行く工程である。例えば、図4の出力データ表に示すデータの作成が行われる。
According to the flowchart of FIG. 4, the call relationship extraction step S31 includes a function start description extraction step S311 and a step of performing a function call description detection and addition step S312 to the output data table.
The function start description extraction step S311 is a step of extracting a description at the start of the function from the given source code and obtaining the function name of the call source. The function call description detection and output table addition step S312 is a step of detecting a function call description in a given source code and adding the call source function and the call destination function in a table format. For example, the data shown in the output data table of FIG. 4 is created.

図5は再帰呼出抽出工程S32Aを説明するメインフローチャート及びサブルーチンS321を説明するサブルーチンフローチャートを示す。再帰呼出抽出工程S32Aを説明するメインフローチャートは初期化工程S3201、サブルーチン実行工程S3202、フラッグ判定工程S3203を含む。
初期化工程S3201:再帰呼出抽出工程S32Aにおいて使用する変数visitedをすべてfalseに設定する。また、データPATHを空にする。さらに、変数flagをfalseに設定する。
サブルーチン実行工程S3202:サブルーチンS321中の対象関数を示す変数fにメイン関数f_MAINを設定して、サブルーチンS321を実行する工程である。
フラッグ判定工程S3203:変数flagの真偽をチェックし、真であるときには初期化工程S3201に戻る。また、偽であるときには、再帰呼出抽出S32Aを終了する。ここで、変数flagが真であるときには、サブルーチンS321を行ったことにより再帰呼出部が見つかったことを意味する。また、再帰縮退工程S33を行うことによって、ここで見つけた再帰呼出部は一つの関数と見立てられたことを意味する。
FIG. 5 shows a main flowchart for explaining the recursive call extraction step S32A and a subroutine flowchart for explaining the subroutine S321. The main flowchart for explaining the recursive call extraction step S32A includes an initialization step S3201, a subroutine execution step S3202, and a flag determination step S3203.
Initialization step S3201: All variables visited used in the recursive call extraction step S32A are set to false. Also, the data PATH is emptied. Further, the variable flag is set to false.
Subroutine execution step S3202: This is a step of setting the main function f_MAIN to the variable f indicating the target function in the subroutine S321 and executing the subroutine S321.
Flag determination step S3203: Checks whether the variable flag is true or false. If true, the process returns to the initialization step S3201. If it is false, the recursive call extraction S32A is terminated. Here, when the variable flag is true, it means that the recursive calling unit is found by performing the subroutine S321. In addition, it means that the recursive call unit found here is regarded as one function by performing the recursive degeneration step S33.

サブルーチンS321を説明するサブルーチンフローチャートは、PATH追加工程S32101、サブルーチン実行工程S32102、PATH削除工程S32103を含む。
PATH追加工程S32101はメイン関数から呼び出されるすべての子関数について、メイン関数に引き続いてPATHの変数に設定する工程である。なお、親関数から呼び出される子関数が複数あった場合、関数の呼出し連鎖からなるPATHが複数存在することになる。
そこで、サブルーチン実行工程S32102に進み、そのPATHそれぞれにおいて、サブルーチンS322を行うことにより再帰呼出部を検出し、その再帰呼出部を一つと見立てる関数とする。その後、PATH削除工程S32103に進む。
PATH削除工程S32103はPATHの変数から末尾の関数を削除する工程である。PATH削除工程S32103が終了した後、メインフローチャートへ戻る。
The subroutine flowchart for explaining the subroutine S321 includes a PATH addition step S32101, a subroutine execution step S32102, and a PATH deletion step S32103.
The PATH addition step S32101 is a step of setting all the child functions called from the main function as PATH variables following the main function. When there are a plurality of child functions called from the parent function, there are a plurality of PATHs composed of function call chains.
Therefore, the process proceeds to the subroutine execution step S32102, and in each of the PATHs, the subroutine S322 is performed to detect the recursive calling unit, and the recursive calling unit is regarded as one function. Thereafter, the process proceeds to the PATH deletion step S32103.
The PATH deletion step S32103 is a step of deleting the last function from the PATH variable. After the PATH deletion step S32103 is completed, the process returns to the main flowchart.

図6はサブルーチンS322及びサブルーチンS322と再帰縮退工程S33との関係を示すフローチャートである。サブルーチンS322のフローチャートは、変数flagの真偽をチェックする工程S32201、PATHに加えた関数に対して、呼出しが行われたか否かを示す変数visitedの真偽をチェックする工程S32202、変数visited設定工程S32203、サブルーチン実行工程S32204、変数visited設定工程S32205、再帰呼出部設定工程S32206、再帰縮退工程S33を行う工程32207、変数flag設定工程S32208を含む。   FIG. 6 is a flowchart showing the relationship between the subroutine S322 and the subroutine S322 and the recursive degeneration step S33. The flowchart of the subroutine S322 includes a step S3221 for checking whether a variable flag is true or false, a step S32202 for checking whether a function added to the PATH has been called or not, and a variable verified setting step. S32203, subroutine execution step S32204, variable visited setting step S32205, recursive call part setting step S32206, recursive degeneration step S33, step 32207, and variable flag setting step S32208 are included.

変数flagの真偽をチェックする工程S32201:変数flagが真のときにはサブルーチンS322の終了ステージに進む。変数flagが偽のときには呼出しが行われたか否かを示す変数visitedの真偽をチェックする工程S32202へ進む。
変数visitedの真偽をチェックする工程S32202:変数visitedが真のときには再帰呼出部設定工程S32206へ進む。変数visitedが偽のときには変数visited設定工程S32203へ進む。
変数visited設定工程S32203:呼出しが行われた関数の変数visitedを真に設定する。
サブルーチン実行工程S32204:呼出しが行われた関数をサブルーチンS321中の対象関数を示す変数fに設定し、サブルーチンS321を行う。
変数visited設定工程S32205:呼出しを行った関数に対する変数visitedを偽とする工程である。
Step S3221 for checking whether the variable flag is true or not: When the variable flag is true, the process proceeds to the end stage of the subroutine S322. When the variable flag is false, the process proceeds to step S32202 for checking the truth of the variable visited indicating whether or not the call has been made.
Step S32202 of checking whether the variable visited is true or not: When the variable visited is true, the process proceeds to the recursive call unit setting step S32206. When the variable visited is false, the process proceeds to a variable visited setting step S32203.
Variable visited setting step S32203: The variable visited of the called function is set to true.
Subroutine execution step S32204: The called function is set to the variable f indicating the target function in the subroutine S321, and the subroutine S321 is executed.
Variable visited setting step S32205: This is a step in which the variable visited for the called function is set to false.

再帰呼出部設定工程S32206:サブルーチンS322を実行する際に、PATHの変数に追加されていた関数の内、変数visitedが真となった関数とそれ以降の関数を再帰呼出部とする工程である。
再帰縮退工程S33を行う工程32207:再帰呼出部設定工程S32206において再帰呼出部とされた関数連鎖について再帰縮退工程S33を行う工程である。
変数flag設定工程S32208:呼出しが行われた関数の変数visitedを真とする工程である。
Recursive call section setting step S32206: This is a process in which a function in which the variable “visited” is true and a function thereafter are used as a recursive call section among the functions added to the PATH variable when executing the subroutine S322.
Step 32207 for performing the recursive degeneration step S33: This is a step for performing the recursive degeneration step S33 for the function chain that has been made a recursive call unit in the recursive call unit setting step S32206.
Variable flag setting step S32208: This is a step of setting the variable visited of the called function to be true.

図7は再帰呼出抽出工程S32Aにおける、再帰読出部の検出について説明する図である。図7によれば、再帰読出部を検出するため、ステージ1から5までがある。
ステージ1:ステージ1は図5、図6に示すフローチャートにおけるサブルーチン実行工程S32102の1度目の開始時点を表すステージである。この状態に至るまでに、初期化工程S3201、サブルーチン実行工程S3202およびPATH追加工程S32101を実行している。PATH追加工程S32101にて、PATHの末尾に追加する関数は、サブルーチン実行工程S3202にて関数fに設定した、親関数f_MAINであるため、PATHの関数は、親関数f_MAINのみで構成されている。
ここからまず、関数f_MAINの呼出し先の関数であるf_A2およびf_A3について、サブルーチンS322を開始する。以下では、先に関数f_A2について、サブルーチンS322を開始した場合を示す。
ここで、関数f_A2に対する変数flagと変数visitedは偽である。初期化工程S3201を行ったときから、今回の呼出しが、最初の子関数f_A2の呼び出し、及び、訪問となるからである。そうすると、変数flagの真偽をチェックする工程S32201と、変数visitedの真偽をチェックする工程S32202を経て、変数visited設定工程S32203を行う。その結果、子関数f_A2の変数visitedは真に設定された後、サブルーチン実行工程S32204へ進む。
サブルーチン実行工程S32204は、関数fを子関数f_A2と設定した状態で、サブルーチンS321の実行を開始する。そして、PATH追加工程S32101にて、サブルーチン実行工程S32204により関数fに設定した、子関数f_A2をPATHの末尾に追加する。その結果、PATHの関数は、親関数f_MAINと、子関数f_A2とから構成される。なお、この子関数f_A2はステージ1にて処理対象とした関数である。
ステージ2:ステージ2は図5、図6に示すフローチャートにおけるサブルーチン実行工程S32102の2度目の開始時点を表すステージである。この状態から、関数f_A2の呼び出し先関数f_B2について、サブルーチンS322を開始する。
ここで、関数f_B2に対する変数flagと変数visitedは偽である。初期化工程S3201を行ったときから、今回の呼出しが、最初の子関数f_B2の呼び出し、及び、訪問となるからである。そうすると、変数flagの真偽をチェックする工程S32201と、変数visitedの真偽をチェックする工程S32202を経て、変数visited設定工程S32203を行う。その結果、子関数f_B2の変数visitedは真に設定された後、サブルーチン実行工程S32204へ進む。
サブルーチン実行工程S32204により、関数fを子関数f_B2と設定した状態で、さらにサブルーチンS321の実行を開始する。
PATH追加工程S3210では、サブルーチン実行工程S32204により関数fに設定した、子関数f_B2をPATHの末尾に追加し、PATHは親関数f_MAIN、親関数f_MAINから呼び出された子関数f_A2、子関数f_A2から呼び出された子関数f_B2となる。
FIG. 7 is a diagram for explaining the detection of the recursive reading unit in the recursive call extraction step S32A. According to FIG. 7, there are stages 1 to 5 for detecting the recursive readout section.
Stage 1: Stage 1 is a stage representing the first start time of the subroutine execution step S32102 in the flowcharts shown in FIGS. Until this state is reached, the initialization step S3201, the subroutine execution step S3202, and the PATH addition step S32101 are executed. In the PATH addition step S32101, the function added to the end of the PATH is the parent function f_MAIN set to the function f in the subroutine execution step S3202, and therefore, the PATH function is composed of only the parent function f_MAIN.
From here, first, the subroutine S322 is started for the functions f_A2 and f_A3 that are the call destinations of the function f_MAIN. Hereinafter, a case where the subroutine S322 is started for the function f_A2 will be described.
Here, the variable flag and the variable visited for the function f_A2 are false. This is because, since the initialization step S3201 is performed, the current call is a call to the first child function f_A2 and a visit. Then, a variable visited setting step S32203 is performed via a step S32201 for checking the authenticity of the variable flag and a step S3222 for checking the trueness of the variable visited. As a result, after the variable visited of the child function f_A2 is set to true, the process proceeds to the subroutine execution step S32204.
Subroutine execution step S32204 starts execution of subroutine S321 with function f set as child function f_A2. In the PATH addition step S32101, the child function f_A2 set in the function f in the subroutine execution step S32204 is added to the end of the PATH. As a result, the PATH function is composed of a parent function f_MAIN and a child function f_A2. Note that this child function f_A2 is a function to be processed in stage 1.
Stage 2: Stage 2 is a stage representing the second start time of the subroutine execution step S32102 in the flowcharts shown in FIGS. From this state, the subroutine S322 is started for the callee function f_B2 of the function f_A2.
Here, the variable flag and the variable visited for the function f_B2 are false. This is because, since the initialization step S3201 is performed, the current call is a call to the first child function f_B2 and a visit. Then, a variable visited setting step S32203 is performed via a step S32201 for checking the authenticity of the variable flag and a step S3222 for checking the trueness of the variable visited. As a result, after the variable visited of the child function f_B2 is set to true, the process proceeds to the subroutine execution step S32204.
In subroutine execution step S32204, execution of subroutine S321 is further started with function f set as child function f_B2.
In the PATH addition step S3210, the child function f_B2 set in the function f by the subroutine execution step S32204 is added to the end of the PATH, and the PATH is called from the parent function f_MAIN, the child function f_A2 called from the parent function f_MAIN, and the child function f_A2. Child function f_B2.

ステージ3:ステージ3は図5、図6の示すフローチャートにおけるサブルーチン実行工程S32102の3度目の開始時点を表すステージである。ここから、子関数f_B2の呼び出し先関数である子関数f_A3と子関数f_B3について、サブルーチンS322を開始する。ここでは、先に子関数f_A3について、サブルーチンS322を開始した場合を示している。
ここで、関数f_A3に対する変数flagと変数visitedは偽である。初期化工程S3201を行ったときから、今回の呼出しが、最初の子関数f_A3の呼び出し、及び、訪問となるからである。そうすると、変数flagの真偽をチェックする工程S32201と、変数visitedの真偽をチェックする工程S32202を経て、変数visited設定工程S32203を行う。その結果、子関数f_A3の変数visitedは真に設定された後、サブルーチン実行工程S32204へ進む。
サブルーチン実行工程S32204により、関数fを子関数f_A3と設定した状態で、さらにサブルーチンS321の実行を開始する。
PATH追加工程S3210では、サブルーチン実行工程S32204により関数fに設定した、子関数f_A3をPATHの末尾に追加する。すなわち、PATHは、親関数f_MAIN、親関数f_MAINから呼び出された子関数f_A2、子関数f_A2から呼び出された子関数f_B2、子関数f_B2から呼び出された子関数f_A3である。
ステージ4:ステージ4は図5、図6の示すフローチャートにおけるサブルーチン実行工程S32102の4度目の開始時点を表すステージである。この状態から、関数f_A3の呼び出し先関数である子関数f_B2と子関数f_B3について、サブルーチンS322を開始する。ここでは、先に子関数f_B2について、サブルーチンS322を開始する場合を示す。
Stage 3: Stage 3 is a stage representing the third start time of the subroutine execution step S32102 in the flowcharts shown in FIGS. From here, the subroutine S322 is started for the child function f_A3 and the child function f_B3, which are the call destination functions of the child function f_B2. Here, the case where the subroutine S322 is started for the child function f_A3 is shown.
Here, the variable flag and the variable visited for the function f_A3 are false. This is because, since the initialization step S3201 is performed, the current call is a call to the first child function f_A3 and a visit. Then, a variable visited setting step S32203 is performed via a step S32201 for checking the authenticity of the variable flag and a step S3222 for checking the trueness of the variable visited. As a result, after the variable visited of the child function f_A3 is set to true, the process proceeds to the subroutine execution step S32204.
In the subroutine execution step S32204, the execution of the subroutine S321 is further started with the function f set as the child function f_A3.
In the PATH addition step S3210, the child function f_A3 set in the function f in the subroutine execution step S32204 is added to the end of the PATH. That is, PATH is a parent function f_MAIN, a child function f_A2 called from the parent function f_MAIN, a child function f_B2 called from the child function f_A2, and a child function f_A3 called from the child function f_B2.
Stage 4: Stage 4 is a stage representing the fourth start time of the subroutine execution step S32102 in the flowcharts shown in FIGS. From this state, the subroutine S322 is started for the child function f_B2 and the child function f_B3 that are the call destination functions of the function f_A3. Here, the case where the subroutine S322 is started for the child function f_B2 first is shown.

ステージ5:ステージ5は図5、図6の示すフローチャートにおける呼出しが行われたか否かを示す変数visitedの真偽をチェックする工程S32202のステージ4直後の開始時点を表すステージである。ここで、子関数f_B2に対する変数visitedは真であり、変数flagは偽である。ステージ5の前ステージで、子関数f_B2に対して変数visited設定工程S32203を行い、子関数f_B2の変数visitedを真に設定したからである。その結果、再帰呼出部設定工程S32206へ進み、子関数f_B2と子関数f_A3とを再帰呼出部として抽出し、CYCLE=(f_B2,f_A3)を得る。次いで、再帰縮退工程S33を行うステップ32207へ進み、CYCLE=(f_B2,f_A3)を引数に、再帰縮退工程S33を行うことにより、子関数f_B2と子関数f_A3とを一つの関数と見立てた静的コールグラフを得る。
次いで、変数flag設定工程S32208に進み、変数flagを真に設定する。そして、子関数f_A3の呼び出し先としての子関数f_B2についてのサブルーチンS322を終了する。すると、ステージ4のサブルーチンS322を開始したところに戻ってくる。
続いて、子関数f_A3の呼び出し先関数としての子関数f_B3について、サブルーチンS322を開始するが、先ほど変数flag設定工程S32208にて変数flagを真と設定したため、変数flagの真偽をチェックする工程S32201にて、サブルーチンS322を終了する。以降、初期化工程S3201を再び実行し、変数flagを偽に戻さない限り、サブルーチンS322を新たに実行する場合は、何もしないサブルーチンとなる。続いて、PATH削除工程S32103に進む。
Stage 5: Stage 5 is a stage that represents the start time immediately after stage 4 of step S32202 for checking the truth of the variable visited indicating whether or not the call in the flowcharts shown in FIGS. Here, the variable visited for the child function f_B2 is true, and the variable flag is false. This is because the variable visited setting step S32203 is performed on the child function f_B2 in the previous stage of the stage 5, and the variable visited of the child function f_B2 is set to true. As a result, the process proceeds to the recursive call unit setting step S32206, where the child function f_B2 and the child function f_A3 are extracted as recursive call units, and CYCLE = (f_B2, f_A3) is obtained. Next, the process proceeds to step 32207 where the recursive reduction process S33 is performed, and the recursive reduction process S33 is performed with CYCLE = (f_B2, f_A3) as an argument, so that the child function f_B2 and the child function f_A3 are regarded as one function. Get the call graph.
Next, the process proceeds to a variable flag setting step S32208, and the variable flag is set to true. Then, the subroutine S322 for the child function f_B2 as a call destination of the child function f_A3 is ended. Then, it returns to the place where the subroutine S322 of stage 4 is started.
Subsequently, the subroutine S322 is started for the child function f_B3 as a call destination function of the child function f_A3. Since the variable flag is set to true in the variable flag setting step S32208, the process checks the truth of the variable flag S32201. Then, the subroutine S322 is terminated. Thereafter, unless the initialization step S3201 is executed again and the variable flag is returned to false, the subroutine S322 is newly executed as a subroutine that does nothing. Subsequently, the process proceeds to the PATH deletion step S32103.

PATH削除工程S32103では、これまでのPATHは、親関数f_MAIN、親関数f_MAINから呼び出された子関数f_A2、子関数f_A2から呼び出された子関数f_B2、子関数f_B2から呼び出された子関数f_A3であるところ、PATHの末尾の子関数f_A3を削除して、PATHを親関数f_MAIN、親関数f_MAINから呼び出された子関数f_A2、子関数f_A2から呼び出された子関数f_B2とする。
そして、ステージ4におけるサブルーチンS321を終了すると、変数visited設定工程S32205により、子関数f_A3に関する変数visitedは偽に戻され、サブルーチンS322は終了する。すると、ステージ3においてサブルーチンS322を開始したサブルーチン実行工程S32102に戻ってくる。
サブルーチン実行工程S32102では子関数f_A3から呼び出される、もうひとつの子関数f_B2についても、サブルーチンS322を新たに実行するが、変数flagを真であるため、何もせず終了する。
続いて、PATH削除工程S32103にて、これまでのPATHは、親関数f_MAIN、親関数f_MAINから呼び出された子関数f_A2、子関数f_A2から呼び出された子関数f_B2であるところ、PATHの末尾の子関数f_B2を削除して、PATHを親関数f_MAIN、親関数f_MAINから呼び出された子関数f_A2とし、ステージ3におけるサブルーチンS321を終了する。
そして、ステージ3におけるサブルーチンS321を終了すると、変数visited設定工程S32205により、子関数f_B2に関する変数visitedは偽に戻され、サブルーチンS322は終了する。すると、ステージ2においてサブルーチンS322を開始したサブルーチン実行工程S32102に戻ってくる。
サブルーチン実行工程S32102では、子関数f_B2以外に子関数f_A2から呼び出される子関数が存在しないため、PATH削除工程S32103に進む。PATH削除工程S32103では、これまでのPATHは、親関数f_MAIN、親関数f_MAINから呼び出された子関数f_A2であるところ、PATHの末尾の子関数f_A2を削除して、PATHを親関数f_MAINとし、ステージ2におけるサブルーチンS321を終了する。
そして、ステージ2におけるサブルーチンS321を終了すると、変数visited設定工程S32205により、子関数f_A2に関する変数visitedは偽に戻され、サブルーチンS322は終了し、ステージ2においてサブルーチンS322を開始したサブルーチン実行工程S32102に戻ってくる。
サブルーチン実行工程S32102では子関数f_MAINから呼び出される、もうひとつの子関数f_A3についても、サブルーチンS322を新たに実行するが、変数flagを真であるため、何もせず終了する。そして、PATH削除工程S32103では、これまでのPATHは、親関数f_MAINであるところ、PATHの末尾の子関数f_MAINを削除して、PATHを空とし、ステージ1におけるサブルーチンS321を終了する。そして、ステージ1におけるサブルーチンS321を終了すると、フラッグ判定工程S3203に進む。
フラッグ判定工程S3203では、変数flag設定工程S32208にて変数flagが真に設定されているため、初期化工程S3201に戻る。
以降、ほかの再帰呼出部を検出するために、再帰縮退工程S33を行うステップ32207にて得た静的コールグラフに対して、再びサブルーチン実行工程S3202以降を実行する。しかし、このコールグラフには再帰呼出部は存在しないため、すべての子関数について、呼出しが行われたか否かを示す変数visitedの真偽をチェックする工程S32202において、すべて変数visited設定工程S32203側へ進み、再帰読出部を検出するための再帰呼出工程S32Aが終了する。
In the PATH deletion step S32103, the PATH so far is the parent function f_MAIN, the child function f_A2 called from the parent function f_MAIN, the child function f_B2 called from the child function f_A2, and the child function f_A3 called from the child function f_B2. However, the child function f_A3 at the end of the PATH is deleted, and the PATH becomes a parent function f_MAIN, a child function f_A2 called from the parent function f_MAIN, and a child function f_B2 called from the child function f_A2.
Then, when the subroutine S321 in the stage 4 is finished, the variable visited setting step S32205 returns the variable visited regarding the child function f_A3 to false, and the subroutine S322 is finished. Then, it returns to the subroutine execution process S32102 which started the subroutine S322 in the stage 3.
In the subroutine execution step S32102, the subroutine S322 is newly executed with respect to another child function f_B2 called from the child function f_A3. However, since the variable flag is true, the subroutine ends without doing anything.
Subsequently, in the PATH deletion step S32103, the PATH so far is the parent function f_MAIN, the child function f_A2 called from the parent function f_MAIN, and the child function f_B2 called from the child function f_A2. The function f_B2 is deleted and the PATH is changed to a parent function f_MAIN and a child function f_A2 called from the parent function f_MAIN, and the subroutine S321 in the stage 3 is ended.
When the subroutine S321 in the stage 3 is finished, the variable visited for the child function f_B2 is returned to false by the variable visited setting step S32205, and the subroutine S322 is finished. Then, it returns to the subroutine execution process S32102 which started the subroutine S322 in the stage 2.
In the subroutine execution step S32102, since there is no child function called from the child function f_A2 other than the child function f_B2, the process proceeds to the PATH deletion step S32103. In the PATH deletion step S32103, the previous PATH is the parent function f_MAIN and the child function f_A2 called from the parent function f_MAIN. The child function f_A2 at the end of the PATH is deleted, and the PATH becomes the parent function f_MAIN. The subroutine S321 in 2 is finished.
When the subroutine S321 in stage 2 ends, the variable visited setting step S32205 returns the variable visited regarding the child function f_A2 to false, the subroutine S322 ends, and the subroutine returns to the subroutine execution step S32102 that started the subroutine S322 in stage 2. Come.
In the subroutine execution step S32102, the subroutine S322 is newly executed for another child function f_A3 called from the child function f_MAIN. However, since the variable flag is true, the subroutine ends without doing anything. In the PATH deletion step S32103, the previous PATH is the parent function f_MAIN, the child function f_MAIN at the end of the PATH is deleted, the PATH is emptied, and the subroutine S321 in the stage 1 is ended. Then, when the subroutine S321 in the stage 1 is finished, the process proceeds to the flag determination step S3203.
In the flag determination step S3203, since the variable flag is set to true in the variable flag setting step S32208, the process returns to the initialization step S3201.
Thereafter, in order to detect other recursive calling units, the subroutine execution step S3202 and subsequent steps are executed again on the static call graph obtained in step 32207 in which the recursive degeneration step S33 is performed. However, since there is no recursive calling part in this call graph, all of the child functions are checked in the variable verified setting step S32203 for checking whether the variable visited indicating whether or not the call has been made. Then, the recursive calling step S32A for detecting the recursive reading unit is completed.

図8は、再帰縮退工程S33を説明するための図である。再帰縮退工程S33は、呼出し関係抽出工程S31からの出力と、再帰呼出部設定工程S32206からの出力と、関数サイズ情報3304を受けて、工程S3301、工程S3302、工程S3303を実行するルーチンである。その結果、再帰縮退工程S33は、再帰呼出し処理済み静的コールグラフ3305、関数縮退情報3306、再帰呼出し処理済関数サイズ情報3307を出力する。   FIG. 8 is a diagram for explaining the recursive degeneration step S33. The recursive degeneration step S33 is a routine that receives the output from the call relationship extraction step S31, the output from the recursive call unit setting step S32206, and the function size information 3304, and executes steps S3301, S3302, and S3303. As a result, the recursive degeneration step S33 outputs a recursive call processed static call graph 3305, function degenerate information 3306, and recursive call processed function size information 3307.

呼出し関係抽出S31からの出力及び再帰呼出部設定工程S32206からの出力については、図4、図6に対する説明文において説明済みである。
関数サイズ情報3304は、親関数(f_MAIN)及び子関数(f_A2、f_A3等)を定義するソースコードのデータサイズである。
The output from the call relationship extraction S31 and the output from the recursive call unit setting step S32206 have been described in the explanatory texts for FIGS.
The function size information 3304 is the data size of the source code that defines the parent function (f_MAIN) and the child functions (f_A2, f_A3, etc.).

工程S3301は、呼出し関数抽出工程S31からの出力としての静的コールグラフにおいて、検出した再帰呼出しに関係している各関数を同一の関数名に置き換える置換動作を行う。このときの置き換えルールを関数縮退情報3306として記憶する。なお、置き換えルールは、上記置換動作で使用した同一の関数名の情報を含む。そして、工程S3301の終了後、上記の関数縮退情報3306は、工程S3302、工程S3303のために出力される。工程S3301の置き換え処理について、図9において具体例を示す。
工程S3302は、関数縮退情報3306を用いて、関数呼出し関係(エントリ)の削除及び統合を行う工程である。すなわち、工程S3301の置換動作の結果、呼出し元の関数と呼出し先の関数が同一となった関数呼出し関係(エントリ)が生じた場合は、その関数呼出し関係は静的コールグラフより削除される。また、呼出し元の関数と呼出し先の関数が複数の関数呼出し関係(エントリ)において同一となり、重複する関数呼出し関係が生じたときは、静的コールグラフにおいて、複数の関数呼出し関係(エントリ)は一つに統合される。その結果、再帰呼出しに関連する関数は、静的コールグラフ上において、一つと見立てた関数として記述される。そして、工程S3302が終了すると、関数呼出し関係(エントリ)の削除及び統合が行われた後の静的コールグラフを再帰呼出し処理済み静的コールグラフ3305が出力される。関数呼出し関係(エントリ)の削除及び統合についても、図9において具体例を示す。
工程S3303は、関数縮退情報3306を用いて、再帰呼出し処理済み関数サイズ情報を作成する工程である。すなわち、関数サイズ情報3304に基づいて、一つと見立てた関数の関数サイズを見積もる。そして、工程S3303において、関数サイズ情報3304に一つと見立てた関数の関数サイズを追加して再帰呼出し処理済み関数サイズ情報3307を作成する。工程S3303の処理について、図9において具体例を示す。
Step S3301 performs a replacement operation for replacing each function related to the detected recursive call with the same function name in the static call graph as the output from the call function extracting step S31. The replacement rule at this time is stored as function degeneration information 3306. The replacement rule includes information on the same function name used in the replacement operation. And after completion | finish of process S3301, said function degeneracy information 3306 is output for process S3302 and process S3303. A specific example of the replacement process in step S3301 is shown in FIG.
Step S3302 is a step of deleting and integrating function call relationships (entries) using the function degeneration information 3306. That is, as a result of the replacement operation in step S3301, if a function call relationship (entry) in which the call source function and the call destination function are the same is generated, the function call relationship is deleted from the static call graph. In addition, when the call source function and the call destination function are the same in a plurality of function call relationships (entries) and a duplicate function call relationship occurs, a plurality of function call relationships (entries) are expressed in the static call graph. Integrated into one. As a result, the function related to the recursive call is described as a function regarded as one on the static call graph. When step S3302 ends, a static call graph 3305 that has been subjected to recursive call processing is output from the static call graph after the function call relationship (entry) is deleted and integrated. A specific example of the deletion and integration of the function call relationship (entry) is also shown in FIG.
Step S3303 is a step of creating recursive call processed function size information using the function degeneration information 3306. That is, based on the function size information 3304, the function size of the function assumed to be one is estimated. In step S3303, the function size information 3307 is created by adding the function size of the function that is assumed to be one to the function size information 3304. A specific example of the process in step S3303 is shown in FIG.

図9は、再帰縮退工程S33における具体的な処理動作の例を示す。図9は、呼出し関係出力S31の出力、再帰呼出部設定工程S32206の出力、工程S3301の出力、関数サイズ情報3304、及び、再帰縮退工程S33の出力を図示する。
呼出し関係出力工程S31の出力において、親関数(f_MAIN)は子関数f_A2、子関数f_A3を呼び出す関係にあり、子関数f_A2は子関数f_B2を呼び出す関係にあり、子関数f_A3は子関数f_B2、子関数f_B3を呼び出す関係にあり、子関数f_B2は子関数f_A3、子関数f_B3を呼び出す関係にあることが記載されている。
再帰呼出部設定工程S32203の出力において、子関数f_B2と子関数f_A3は再帰呼出の関係にあることが記載されている。そこで、工程S3301においては、呼出し関係出力工程S31の出力に対して、子関数f_B2と子関数f_A3とを一つと見立てた関数f_B2*f_A3に、子関数f_A2及び子関数f_B2が置き換えられる。そして、関数縮退情報3306として、一つと見立てた関数f_B2*f_A3は{f_B2,f_A3}である旨が記憶される。
FIG. 9 shows an example of a specific processing operation in the recursive degeneration step S33. FIG. 9 illustrates the output of the call-related output S31, the output of the recursive call unit setting step S32206, the output of the step S3301, the function size information 3304, and the output of the recursive degeneration step S33.
In the output of the call relationship output step S31, the parent function (f_MAIN) has a relationship of calling the child function f_A2 and the child function f_A3, the child function f_A2 has a relationship of calling the child function f_B2, and the child function f_A3 has the relationship of calling the child function f_B2, child It is described that the function f_B3 is called and the child function f_B2 is called to call the child function f_A3 and the child function f_B3.
The output of the recursive call unit setting step S32203 describes that the child function f_B2 and the child function f_A3 are in a recursive call relationship. Therefore, in step S3301, the child function f_A2 and the child function f_B2 are replaced with a function f_B2 * f_A3 in which the child function f_B2 and the child function f_A3 are regarded as one with respect to the output of the call relation output step S31. Then, the function degeneration information 3306 stores that the function f_B2 * f_A3 regarded as one is {f_B2, f_A3}.

再帰縮退工程S33の出力は、工程S3302の出力と、工程S3301の出力の一部と、工程S3303の出力を含む。ここで、工程S3301の出力の一部は、関数縮退情報3306である。
工程S3302において、工程S3301の出力の内、関数の呼出し関係について、一つと見立てた関数f_B2*f_A3から一つと見立てた関数f_B2*f_A3を呼び出す関係が複数あるため、それらの内一つを残して削除する。また、工程S3302において、一つと見立てた関数f_B2*f_A3から子関数f_B3を呼び出す関数も複数あるため、一つに統合する。その結果、再帰呼出し処理済み静的コールグラフ3305が形成される。
工程S3303において、関数サイズ情報3304に基づいて、再帰呼出し処理済み静的コールグラフ3305中に存在する、親関数、子関数、一つと見立てた関数f_B2*f_A3を表しデータのデータサイズを見積もる。その結果、再帰呼出し処理済み関数サイズ情報3307が形成される。
The output of the recursive degeneration step S33 includes the output of the step S3302, a part of the output of the step S3301, and the output of the step S3303. Here, part of the output of step S3301 is function degeneration information 3306.
In step S3302, there are a plurality of relations for calling the function f_B2 * f_A3 assumed to be one from the function f_B2 * f_A3 assumed to be one of the outputs of the step S3301, so that one of them is left. delete. In step S3302, since there are a plurality of functions that call the child function f_B3 from the function f_B2 * f_A3 that is regarded as one, they are integrated into one. As a result, a recursive call processed static call graph 3305 is formed.
In step S3303, based on the function size information 3304, the parent function, the child function, and the function f_B2 * f_A3 regarded as one existing in the recursive call processed static call graph 3305 are estimated. As a result, recursive call processed function size information 3307 is formed.

図10はメモリ割当工程34を説明するフローチャートである。メモリ割当工程34は親関数配置工程S3401、合計コードサイズ計算工程S3402、電力制御を伴うメモリへの割当工程S3403、アドレス計算工程S3404を含む。
なお、メモリ割当工程34を実行するには、再帰縮退工程S33から出力された、bと表示した再帰処理済み静的コールグラフ、cと表示した再帰処理済み関数サイズ情報、dと表示した関数縮退情報を含む情報3407を使用する。また、メモリ割当工程34を実行するには、aと表示したメモリ構造情報3408を使用する。さらに、メモリ割当工程34を実行するには、eと表示した静的コールグラフ、fと表示した関数サイズ情報を含む情報3409を使用する。なお、情報3407及び情報3409はソースコード、オブジェクト、又は、アセンブリ3411から得られる情報である。
親関数選択工程S3401において、親関数に関するコードに対し、メモリ領域を割り当てる。メモリ領域を割り当てるにあたり、aと表示したメモリ構造情報、bと表示した再帰処理済み静的コールグラフ、cと表示した再帰処理済み関数サイズ情報を使用する。
合計コードサイズの計算工程S3402において、メモリ領域の確保のため、すべての関数に対してコードサイズを計算する。コードサイズを計算するにあたり、cと表示した再帰呼出済み関数サイズ情報を使用する。さらに、一つの関数と見立てた関数に対するコードサイズを把握する。コードサイズの把握にあたり、cと表示した再帰呼出済み関数サイズ情報を使用する。
電力制御を伴うメモリへの割当工程S3403において、一つの関数と見立てた関数のコードサイズと、aと表示したメモリ構造情報から、一つの関数と見立てた関数が、単一のメモリバンクに割り当てられるように、メモリ領域を一つの関数と見立てた関数について割り当てる。メモリ領域を一つの関数と見立てた関数について割り当てる際に、aと表示したメモリ構造情報と、合計コードサイズの計算工程S3402の結果を使用する。
アドレス計算工程S3404において、すべての関数についてメモリ領域に割当るととこに、メモリ領域と、そのメモリ領域に割り当てた関数についてメモリマップ情報を作成する。なお、メモリ領域に関数を割り当てる際に、図10中のeで示す静的グラフ、fで示す関数サイズ情報を使用する。eで示す静的グラフ、fで示す関数サイズ情報は、呼び出し関係抽出工程S31で求めたものを使用することが望ましい。
FIG. 10 is a flowchart for explaining the memory allocation step 34. The memory allocation step 34 includes a parent function placement step S3401, a total code size calculation step S3402, a memory allocation step S3403 with power control, and an address calculation step S3404.
In order to execute the memory allocation process 34, the recursive static call graph displayed as b output from the recursive degeneration process S33, the recursive function size information displayed as c, and the function degeneration displayed as d. Information 3407 including information is used. Further, in order to execute the memory allocation step 34, the memory structure information 3408 labeled a is used. Further, in order to execute the memory allocation step 34, information 3409 including a static call graph labeled e and function size information labeled f is used. Information 3407 and information 3409 are information obtained from the source code, the object, or the assembly 3411.
In the parent function selection step S3401, a memory area is allocated to the code related to the parent function. In allocating the memory area, the memory structure information indicated as a, the recursive static call graph indicated as b, and the recursive function size information indicated as c are used.
In the total code size calculation step S3402, code sizes are calculated for all functions in order to secure a memory area. In calculating the code size, the recursively called function size information indicated as c is used. Furthermore, it grasps the code size for a function that is regarded as one function. In recognizing the code size, the recursively called function size information indicated as c is used.
In the allocation step S3403 to the memory with power control, a function regarded as one function is allocated to a single memory bank from the code size of the function regarded as one function and the memory structure information indicated as a. As described above, a function that assumes a memory area as one function is allocated. When allocating a memory area for a function that is regarded as one function, the memory structure information indicated as a and the result of the total code size calculation step S3402 are used.
In the address calculation step S3404, all the functions are assigned to the memory area, and memory map information is created for the memory area and the function assigned to the memory area. Note that when assigning a function to a memory area, a static graph indicated by e in FIG. 10 and function size information indicated by f are used. The static graph indicated by e and the function size information indicated by f are preferably those obtained in the call relationship extraction step S31.

図11は関数に関するプログラムソースコードの割当状況を示す図である。図11によって、メモリバンク11aからメモリバンク16aまで、メモリバンク11bからメモリバンク16bについて、関数に関するプログラムソースコードの割当状況が示される。
図11の上段は、プログラムソースコードに対して、本実施例に係わる記憶領域の割当方法を適用しない場合の割当状況である。なお、図11の上段中において、例示部分と表示した点線領域は、図4で説明した静的コールグラフに表した関数の呼出状況に対応している。
FIG. 11 is a diagram showing an assignment state of program source codes related to functions. FIG. 11 shows the allocation status of the program source code related to the function from the memory bank 11a to the memory bank 16a and from the memory bank 11b to the memory bank 16b.
The upper part of FIG. 11 shows an allocation situation when the storage area allocation method according to the present embodiment is not applied to the program source code. In the upper part of FIG. 11, the dotted line area displayed as an example portion corresponds to the function call status shown in the static call graph described in FIG. 4.

本実施例1に係わる記憶領域の割当方法を適用しない場合には、以下の順番で割当を行う。
プログラムソースコード中において、親関数から直接呼出しがかかる第1階層の関数を、アドレス順にメモリバンクに配置する。ついで、第1階層の関数からさらに呼出しがかかる第2階層の関数を第1階層の関数と同一のメモリバンクに配置できるときには配置する。ただし、再帰呼出しについては考慮されない。
従って、点線図形で囲った例示部分において、第1階層の子関数f_A2と、子関数f_A2から呼び出される第2階層の子関数f_B2はメモリバンク13aに割り当てられている。また、第1階層の子関数f_A3と、子関数f_A3から呼び出される第2階層の子関数f_B3はメモリバンク14aに割り当てられている。
When the storage area allocation method according to the first embodiment is not applied, the allocation is performed in the following order.
In the program source code, the first layer function that is directly called from the parent function is arranged in the memory bank in order of address. Next, the second layer function that is further called from the first layer function is disposed when it can be disposed in the same memory bank as the first layer function. However, recursive calls are not considered.
Therefore, in the example part surrounded by the dotted line figure, the child function f_A2 of the first hierarchy and the child function f_B2 of the second hierarchy called from the child function f_A2 are allocated to the memory bank 13a. The child function f_A3 in the first hierarchy and the child function f_B3 in the second hierarchy called from the child function f_A3 are allocated to the memory bank 14a.

なお、子関数f_A1、子関数f_C1はメモリバンク12aに割り当てられている。子関数f_B1、子関数f_D1はメモリバンク13aに割り当てられている。子関数f_A4、子関数f_B4はメモリバンク15aに割り当てられている。子関数f_A5、子関数f_B5、子関数f_C2はメモリバンク16aに割り当てられている。親関数f_MAINはメモリバンク11aに割り当てられている。   The child function f_A1 and the child function f_C1 are allocated to the memory bank 12a. The child function f_B1 and the child function f_D1 are assigned to the memory bank 13a. The child function f_A4 and the child function f_B4 are assigned to the memory bank 15a. The child function f_A5, child function f_B5, and child function f_C2 are allocated to the memory bank 16a. The parent function f_MAIN is assigned to the memory bank 11a.

一方、図11の下段は、プログラムソースコードに対して、本実施例1に係わる記憶領域の割当方法を行った場合の割当状況である。
本実施例1に係わる記憶領域の割当方法を適用する場合には、以下のように割当が行われる。
On the other hand, the lower part of FIG. 11 shows an allocation state when the storage area allocation method according to the first embodiment is performed on the program source code.
When the storage area allocation method according to the first embodiment is applied, the allocation is performed as follows.

図11上段の例示部分に対応する、下段の点線図形で囲った例示部分において、第1階層の子関数f_A2はメモリバンク13bに割り当てられる。また、一つに見立てられた関数f_B2*f_A3は、第1階層の子関数としてメモリバンク14bに割り当てられる。ここで、図11上段では、子関数f_B3は単独の子関数であったが、本実施例1に係わる記憶領域の割当方法を適用することにより、子関数f_B3は一つと見立てられた子関数f_B3*f_B4*f_B5*f_C2の構成要素となった。その結果、図11下段の第2階層の子関数f_B3*f_B4*f_B5*f_C2の一部として、子関数f_B3はメモリバンク15bに配置されている。   In the example part surrounded by the lower dotted line figure corresponding to the example part in the upper part of FIG. 11, the child function f_A2 in the first hierarchy is assigned to the memory bank 13b. Also, the function f_B2 * f_A3 that is regarded as one is assigned to the memory bank 14b as a child function of the first hierarchy. Here, in the upper part of FIG. 11, the child function f_B3 is a single child function, but by applying the storage area allocation method according to the first embodiment, the child function f_B3 is regarded as one child function f_B3. * F_B4 * f_B5 * f_C2 became a constituent element. As a result, the child function f_B3 is arranged in the memory bank 15b as a part of the child function f_B3 * f_B4 * f_B5 * f_C2 in the second hierarchy in the lower part of FIG.

なお、子関数f_A1、子関数f_C1はメモリバンク12bに割り当てられている。子関数f_B1、子関数f_D1はメモリバンク13bに割り当てられている。子関数f_A4はメモリバンク15bに割り当てられている。子関数f_A5はメモリバンク16bに割り当てられている。親関数f_MAINはメモリバンク11bに割り当てられている。   The child function f_A1 and the child function f_C1 are allocated to the memory bank 12b. The child function f_B1 and the child function f_D1 are assigned to the memory bank 13b. The child function f_A4 is assigned to the memory bank 15b. The child function f_A5 is assigned to the memory bank 16b. The parent function f_MAIN is assigned to the memory bank 11b.

図11の上段に示す、子関数f_A3と子関数f_B2とは、再帰呼出関係にあるが、子関数f_A3と子関数f_B2とは異なるメモリバンクに配置されている。そうすると、CPUは、メモリバンク13aとメモリバンク14aは、同時に通常電力供給状態とすることになる。メモリバンク13a又はメモリバンク14aの内の一方が、省電力供給状態であり、他方が通常電力供給状態であるとすると、相互に再帰呼出を行えないからである。
一方、図11の下段に示す、子関数f_A3と子関数f_B2とは、一つと見立てられた子関数f_B2*f_A3として、同一のメモリバンク14bに配置されている。従って、一つと見立てられた子関数f_B2*f_A3に関する呼出動作を行うにはメモリバンク14bのみを通常供給状態とすればよく、メモリバンク13bは省電力供給状態のまま維持することができる。
従って、実施例1のメモリシステム50において、実施例1のプログラムに含まれるコードに記憶領域を割り当てる割当方法を実施し、メモリシステム50に含まれるCPUによって、関数の呼出状態に応じて、メモリバンクの電源状態を制御すれば、通常電力供給状態とするメモリバンク数を減少させることができる。その結果、実施例1のプログラムに含まれるコードに記憶領域を割り当てる割当方法を実施によって、メモリシステム50の消費電力を削減することができる。
The child function f_A3 and the child function f_B2 shown in the upper part of FIG. 11 have a recursive call relationship, but the child function f_A3 and the child function f_B2 are arranged in different memory banks. Then, the CPU sets the memory bank 13a and the memory bank 14a to the normal power supply state at the same time. This is because if one of the memory bank 13a or the memory bank 14a is in a power saving supply state and the other is in a normal power supply state, recursive calls cannot be made to each other.
On the other hand, the child function f_A3 and the child function f_B2 shown in the lower part of FIG. 11 are arranged in the same memory bank 14b as the child function f_B2 * f_A3 regarded as one. Accordingly, in order to perform the calling operation related to the child function f_B2 * f_A3 regarded as one, only the memory bank 14b needs to be in the normal supply state, and the memory bank 13b can be maintained in the power saving supply state.
Therefore, in the memory system 50 according to the first embodiment, an allocation method for allocating a storage area to the code included in the program according to the first embodiment is performed. The CPU included in the memory system 50 performs the memory bank according to the function call state. If the power supply state is controlled, the number of memory banks in the normal power supply state can be reduced. As a result, the power consumption of the memory system 50 can be reduced by implementing the allocation method for allocating the storage area to the code included in the program of the first embodiment.

なお、上記の説明において、各メモリバンクの電源状態のコントロールを、CPUがメモリバンクに割り当てた関数に関するソースプログラムコードの割当状態に応じて、行うこととした。しかし、図12に示す方法によって、CPUがソースプログラムから、電源制御入り実行プログラムを生成し、電源制御入り実行プログラムによる制御によって、CPUがメモリバンクの電源状態をコントロールすることとしても、メモリシステムの消費電力を削減することができる。   In the above description, the power supply state of each memory bank is controlled according to the assignment state of the source program code related to the function assigned to the memory bank by the CPU. However, even if the CPU generates an execution program with power supply control from the source program by the method shown in FIG. 12 and the CPU controls the power state of the memory bank by the control by the execution program with power supply control, Power consumption can be reduced.

図12は、実施例1の変形例であるメモリシステム120及びそのメモリシステム120において生成される電源制御入り実行プログラムの生成方法に対するフローチャートを示す。図12の左半分は電源制御入り実行プログラムの生成方法を説明するためのフローチャートであり、右半分は実施例1の変形例であるメモリシステム120を示す。
図12のフローチャートにより示す実行プログラムの生成方法は、コンパイル工程S1、制御位置算出工程S2、メモリマップ決定工程S3、制御パラメータ決定・制御コード挿入工程S4、アセンブル・リンク工程S5を含む。
コンパイル工程S1において、ソースプログラムは、CPU110内のプロセッサに読み込まれ、アセンブリコード又はオブジェクトに変換される。
制御位置算出工程S2において、CPU110内のプロセッサはメモリバンクのオンオフを制御するアセンブリコード又はオブジェクトを検出する。
メモリマップ(レイアウト)決定工程S3において、呼出し関係抽出工程S31からメモリ割当工程S34までを行いメモリマップを決定し、メモリマップ情報を出力する。
ここで、メモリマップとは、再帰呼出し部を表すアセンブリコード又はオブジェクトと、アセンブリコード又はオブジェクトを格納した場所を示すメモリバンクのアドレスとの対応を示すマップである。また、メモリマップ情報は、メモリマップをコードで表したデータから構成されている。
制御パラメータ決定・制御コード挿入工程S4において、メモリマップ情報に基づいてメモリバンクのオンオフを制御するアセンブリコード又はオブジェクトの位置を修正する。
アセンブル・リンク工程S5において、メモリバンクのオンオフを制御するアセンブリコード又はオブジェクトの位置が修正されたプログラムを、電力制御入り実行プログラムとしてプログラム記憶領域に記憶する。
FIG. 12 is a flowchart illustrating a memory system 120 that is a modification of the first embodiment and a method for generating an execution program with power supply control generated in the memory system 120. The left half of FIG. 12 is a flowchart for explaining a method for generating an execution program with power supply control, and the right half shows a memory system 120 which is a modification of the first embodiment.
The execution program generation method shown in the flowchart of FIG. 12 includes a compilation step S1, a control position calculation step S2, a memory map determination step S3, a control parameter determination / control code insertion step S4, and an assemble / link step S5.
In the compiling step S1, the source program is read into a processor in the CPU 110 and converted into assembly code or an object.
In the control position calculation step S2, the processor in the CPU 110 detects an assembly code or an object that controls on / off of the memory bank.
In the memory map (layout) determination step S3, the call relationship extraction step S31 to the memory allocation step S34 are performed to determine the memory map and output the memory map information.
Here, the memory map is a map indicating the correspondence between the assembly code or object representing the recursive calling unit and the address of the memory bank indicating the location where the assembly code or object is stored. The memory map information is composed of data representing the memory map with codes.
In the control parameter determination / control code insertion step S4, the position of the assembly code or object for controlling on / off of the memory bank is corrected based on the memory map information.
In the assemble and link step S5, the assembly code for controlling on / off of the memory bank or a program in which the position of the object is corrected is stored in the program storage area as an execution program with power control.

図12の右半分の図はメモリシステム120を示す。メモリシステム120は、CPU110、制御レジスタ群30、電源線45、電源制御装置46、メモリユニット10、及び、バス40を含む。
図1の説明において、制御レジスタ群30、電源線45、電源制御装置46、メモリユニット10、バス40の説明をしたため、説明を省略する。
CPU110は、プロセッサと、メモリコントローラと、ソースプログラム格納領域と、電源制御入り実行プログラム格納領域を含む。図1の説明において、メモリコントローラについては説明済みなため、説明を省略する。ソースプログラム格納領域は、外部から与えられたソースプログラムを記憶する領域である。電源制御入り実行プログラム格納領域は、CPU110自身が、ソースプログラムから生成した電源制御入り実行プログラムを格納する領域である。
以上より、メモリシステム120は、図1に示したメモリシステム50と比較し、CPU内に、ソースプログラムから生成した電源制御入り実行プログラムを保持することになり、メモリユニット10の制御を容易に行うことができる。
The right half of FIG. 12 shows the memory system 120. The memory system 120 includes a CPU 110, a control register group 30, a power supply line 45, a power supply control device 46, a memory unit 10, and a bus 40.
In the description of FIG. 1, the control register group 30, the power supply line 45, the power supply control device 46, the memory unit 10, and the bus 40 have been described.
The CPU 110 includes a processor, a memory controller, a source program storage area, and an execution program storage area with power control. In the description of FIG. 1, since the memory controller has already been described, description thereof is omitted. The source program storage area is an area for storing a source program given from the outside. The execution program storage area with power control is an area in which the CPU 110 itself stores the execution program with power control generated from the source program.
As described above, the memory system 120 holds the execution program with power supply control generated from the source program in the CPU as compared with the memory system 50 shown in FIG. 1, and easily controls the memory unit 10. be able to.

図13は、実施例2に係わる、プログラムに含まれるコードに記憶領域を割り当てる割当方法を説明する図である。
実施例2に係わる、プログラムに含まれるコードに記憶領域を割り当てる割当方法は、呼出関係抽出工程S35、再帰呼出抽出工程S32A、再帰読出処理済み静的コールグラフ作成工程S32B、再帰呼出縮退工程S36、及び、メモリ割当工程S37を含む。
再帰呼出抽出工程S32A及び再帰読出処理済み静的コールグラフ作成工程S32Bは、図3に示す同様な符号を付したステップと同様なものであり、その説明を省略する。
呼出関係抽出工程S35において、プログラムのソースコード、アセンブリまたはオブジェクトを走査し、出現する関数それぞれに対し、関数呼出回数をカウントする。次いで、カウントに応じて関数呼出しに重みを付加し、重み情報付きの静的コールグラフを作成する。再帰呼出抽出工程S32について、図14を用いてさらに説明を加える。
再帰縮退工程S36において、再帰呼出抽出工程S32Aにおいて再帰呼出部を検出した場合、再帰呼出部をまとめる再帰縮退を行う。すなわち、再帰呼出部に関連する関数を、重み付け情報を有する一つと見立てられた関数とする。なお、再帰縮退工程S36において、関数サイズ情報81が使用される。なお、再帰縮退工程S36について、図15、図16を用いてさらに説明を加える。
メモリ割当工程S37において、重み付けされた一つと見立てられた関数について、一体としてメモリ領域を割り振る。すなわち、一つと見立てられた関数は、同一メモリバンクに格納される。なお、一つと見立てられた関数は、ソースコード、アセンブリ、又はオブジェクト82から得られるコードから抽出されるものである。
FIG. 13 is a diagram illustrating an allocation method for allocating storage areas to codes included in a program according to the second embodiment.
The allocation method for allocating a storage area to a code included in a program according to the second embodiment includes a call relation extraction step S35, a recursive call extraction step S32A, a recursive read processed static call graph creation step S32B, a recursive call degeneration step S36, And memory allocation process S37 is included.
The recursive call extraction step S32A and the recursive read processed static call graph creation step S32B are the same as the steps denoted by the same reference numerals as shown in FIG.
In the call relationship extraction step S35, the program source code, assembly, or object is scanned, and the number of function calls is counted for each function that appears. Next, a weight is added to the function call according to the count, and a static call graph with weight information is created. The recursive call extraction step S32 will be further described with reference to FIG.
In the recursive degeneration process S36, when a recursive call part is detected in the recursive call extraction process S32A, a recursive degeneracy that combines the recursive call parts is performed. That is, a function related to the recursive call unit is assumed to be a function having weighting information. Note that the function size information 81 is used in the recursive degeneration step S36. The recursive degeneration step S36 will be further described with reference to FIGS.
In the memory allocation step S37, a memory area is allocated as a unit with respect to the function regarded as one weighted. That is, a function that is regarded as one is stored in the same memory bank. The function regarded as one is extracted from the code obtained from the source code, the assembly, or the object 82.

図14は呼出関係抽出工程S35に関する、フローチャート、静的コールグラフ、及び、呼出抽出後の出力データ表を図示する。
図14の重み情報付き静的コールグラフは、図4の静的コールグラフと、例として上げられている関数及びその呼出関係において同様である。ただし、関数の呼出関係において呼出回数に応じた重み付けがされている点で異なる。
図14の呼出関係抽出工程S35の出力データ表は、図14の重み情報付き静的コールグラフに対応する出力データ表である。図4の出力データ表に記載されている項目に加えて、第3列に関数の呼出関係に対する重みの数値が記載されている点で異なる。
図14のフローチャートによれば、呼出関係抽出工程S35は、関数別呼出回数カウント工程S351、重み付け工程S352、重み情報付き静的コールグラフの作成工程S353、静的コールグラフに関するデータ作成工程S354を含む。
FIG. 14 shows a flowchart, a static call graph, and an output data table after the call extraction related to the call relationship extraction step S35.
The static call graph with weight information shown in FIG. 14 is the same as the static call graph shown in FIG. However, the difference is that weighting is performed according to the number of calls in the function call relationship.
The output data table of the call relationship extraction step S35 in FIG. 14 is an output data table corresponding to the static call graph with weight information in FIG. In addition to the items described in the output data table of FIG. 4, the third column is different in that numerical values of weights for function calling relationships are described in the third column.
According to the flowchart of FIG. 14, the call relation extraction step S35 includes a function-specific call count counting step S351, a weighting step S352, a static call graph with weight information creation step S353, and a data creation step S354 related to the static call graph. .

関数別呼出回数カウント工程S351は、アセンブリ及びオブジェクトと、関数の呼出履歴を受けて、呼出元の関数から呼出先の関数への呼出回数をカウントする工程である。
重み付け工程S352は、関数別呼出回数カウント工程S351における呼出回数に基づいて、呼出元となる関数と、呼出先となる関数との呼出関係について重み付けを付与するステップである。
ここで、プログラムソースコード、アセンブリまたはオブジェクトにおける呼出し関係に基づいて、親関数f_MAINが行う子関数の呼出しの回数を、ソースコード呼出し回数とする。また、プログラムを実行する際に、親関数f_MAINの関数形式に基づいて、すなわち、引数等に基づいて、親関数f_MAINが行う子関数の呼出しの回数を、関数依存呼出し回数とする。ソースコード呼出し回数は、プログラムソースコード、アセンブリまたはオブジェクトにより、一義的にきまるため、静的な呼出し回数といえる。一方、関数依存呼出し回数は、入力された引数等によりその回数が増減するため、動的な呼出し回数といえる。
そこで、関数依存呼出し回数を、ソースコード呼出し回数に対する重み付けとし、ソースコード呼出し回数を、関数依存呼出し回数とする。
ここで、関数依存呼出し回数をX(=A11+A12+・・・+A1m+A21+A22+・・・+A2m)、ソースコード呼出し回数をY(=Y1+Y2)とする。ここで、プログラムコード中における、親関数f_MAINからの子関数f_A1のソースコード呼出し回数はY1であり、さらに、ソースコード中の各呼出しについて、親関数の関数形式に依存した子関数の関数依存呼出し回数は、A11、A12、・・・A1m(mは正の整数)である。また、プログラムコード中における、親関数f_MAINに対応する子関数f_A2のソースコード呼出し回数はY2であり、さらに、ソースコード中に各呼出しについて、親関数の関数形式に依存した子関数の関数依存呼出し回数はA21、A22、・・・A2m(mは正の整数)である。そうすると、重みは以下のように表される。
重みP(f_MAIN,f_A1)=(Y1×X+A11×Y+A12×Y+・・・+A1m×Y)
重みP(f_MAIN,f_A2)=(Y2×X+A21×Y+A22×Y+・・・+A2m×Y)
例えば、親関数f_MAINに対応するプログラムコード中に子関数f_A1を3回、子関数f_A2を2回呼び出しているとするならば、親関数f_MAINから子関数f_A2への重みが3とされ、親関数f_MAINから数f_A2への重みが2とされる。また、親関数f_MAINから子関数f_A1へ10回、子関数f_A2へ20回の呼出し履歴と、親関数f_MAINから子関数f_A2へ10回、親関数f_MAINから子関数f_A3へ40回の呼出しがあったとする。
重みP(f_MAIN,f_A1)=(3×80+5×10+5×10)=340
重みP(f_MAIN,f_A2)=(2×80+5×20+5×40)=460
となる。
重み情報付き静的コールグラフの作成工程S353は、重み情報を付加された静的コールグラフを作成し、その静的コールグラフに関するデータを作成する工程である。
The function-specific call count step S351 is a process of counting the number of calls from a call source function to a call destination function in response to an assembly, an object, and a function call history.
The weighting step S352 is a step of assigning a weight to the calling relationship between the function serving as the call source and the function serving as the call destination based on the number of calls in the function-specific call count counting step S351.
Here, the number of child function calls performed by the parent function f_MAIN based on the calling relationship in the program source code, assembly, or object is defined as the number of source code calls. Further, when the program is executed, the number of calls of the child function performed by the parent function f_MAIN based on the function format of the parent function f_MAIN, that is, based on the argument or the like, is set as the number of function-dependent calls. Since the source code call count is uniquely determined by the program source code, assembly, or object, it can be said to be a static call count. On the other hand, the number of function-dependent calls can be said to be a dynamic number of calls because the number of calls increases or decreases depending on an input argument or the like.
Therefore, the function-dependent call count is set as a weight for the source code call count, and the source code call count is set as the function-dependent call count.
Here, it is assumed that the number of function-dependent calls is X (= A11 + A12 +... + A1m + A21 + A22 +... + A2m) and the number of source code calls is Y (= Y1 + Y2). Here, in the program code, the number of calls to the source code of the child function f_A1 from the parent function f_MAIN is Y1, and for each call in the source code, the function-dependent call of the child function depending on the function form of the parent function The number of times is A11, A12,... A1m (m is a positive integer). The number of calls to the source code of the child function f_A2 corresponding to the parent function f_MAIN in the program code is Y2. Further, for each call in the source code, the function-dependent call of the child function depending on the function form of the parent function. The number of times is A21, A22,... A2m (m is a positive integer). Then, the weight is expressed as follows.
Weight P (f_MAIN, f_A1) = (Y1 × X + A11 × Y + A12 × Y +... + A1m × Y)
Weight P (f_MAIN, f_A2) = (Y2 × X + A21 × Y + A22 × Y +... + A2m × Y)
For example, if the child function f_A1 is called three times and the child function f_A2 is called twice in the program code corresponding to the parent function f_MAIN, the weight from the parent function f_MAIN to the child function f_A2 is set to 3, and the parent function The weight from f_MAIN to the number f_A2 is 2. Also, there are 10 calls from the parent function f_MAIN to the child function f_A1, 20 calls to the child function f_A2, 10 calls from the parent function f_MAIN to the child function f_A2, and 40 calls from the parent function f_MAIN to the child function f_A3. To do.
Weight P (f_MAIN, f_A1) = (3 × 80 + 5 × 10 + 5 × 10) = 340
Weight P (f_MAIN, f_A2) = (2 × 80 + 5 × 20 + 5 × 40) = 460
It becomes.
The static call graph with weight information creation step S353 is a step of creating a static call graph to which weight information is added and creating data related to the static call graph.

図15は再帰縮退工程S36を説明するための図である。再帰縮退工程S36は、呼出し関係抽出工程S35からの出力と、再帰呼出設定工程S32206からの出力と、関数サイズ情報3604を受けて、工程S3601、工程S3602、工程S3603を実行するルーチンである。その結果、再帰縮退工程S36は、再帰呼出処理済み静的コールグラフ3605、関数縮退情報3606、再帰呼出処理済関数サイズ情報3607を出力する。   FIG. 15 is a diagram for explaining the recursive degeneration step S36. The recursive degeneration step S36 is a routine that receives the output from the call relationship extraction step S35, the output from the recursive call setting step S32206, and the function size information 3604, and executes step S3601, step S3602, and step S3603. As a result, the recursive degeneration step S36 outputs a recursive call processed static call graph 3605, function degeneration information 3606, and recursive call processed function size information 3607.

工程S3601は、呼出関数抽出S31からの出力としての静的コールグラフにおいて、検出した再帰呼出しに関係している各関数を同一の関数名に置き換える置換動作を行う。このときの置き換えルールを関数縮退情報3606として記憶する。なお、置き換えルールは、上記置換動作で使用した同一の関数名の情報を含む。そして、工程S3301の終了後、上記の関数縮退情報3606は、工程S3602、工程S3603のために出力される。ステップS3601の置き換え処理について、図16において具体例を示す。
工程S3602は、関数縮退情報3606を用いて、関数呼出関係の削除及び統合を行うステップである。すなわち、工程S3301の置換動作の結果、呼出元の関数と呼出先の関数が同一となった関数呼出し関係が生じた場合は、その関数呼出関数は静的コールグラフより削除される。また、呼出元の関数と呼出先の関数が複数の関数呼出関係において同一となり、重複する関数呼出し関係が生じたときは、静的コールグラフにおいて、複数の関数呼出し関係を一つに統合される。その結果、再帰呼出しに関連する関数は、静的コールグラフ上において、一つと見立てた関数として記述される。そして、工程S3602が終了すると、関数呼出し関係の削除及び統合が行われた後の静的コールグラフを再帰呼出し処理済静的コールグラフ3605が出力される。関数呼出し関係の削除及び統合についても、図16において具体例を示す。
工程S3603は、関数縮退情報3606を用いて、再帰呼出処理済み関数サイズ情報を作成する工程である。すなわち、関数サイズ情報3604の基づいて、一つと見立てた関数の関数サイズを見積もる。また、一つと見立てた関数の重みは、再帰呼出しに関連する関数の重みを加算したものである。そして、工程S3603はにおいて、関数サイズ情報3604に一つと見立てた関数の関数サイズを追加して再帰呼出処理済み関数サイズ情報3607を作成する。工程S3603の処理について、図16において具体例を示す。
Step S3601 performs a replacement operation for replacing each function related to the detected recursive call with the same function name in the static call graph as an output from the call function extraction S31. The replacement rule at this time is stored as function degeneration information 3606. The replacement rule includes information on the same function name used in the replacement operation. And after completion | finish of process S3301, said function degeneracy information 3606 is output for process S3602 and process S3603. A specific example of the replacement processing in step S3601 is shown in FIG.
Step S3602 is a step of deleting and integrating function call relationships using the function degeneration information 3606. In other words, as a result of the replacement operation in step S3301, if a function call relationship in which the call source function is the same as the call destination function is generated, the function call function is deleted from the static call graph. In addition, when the call source function and the call destination function are the same in a plurality of function call relationships and an overlapping function call relationship occurs, the plurality of function call relationships are integrated into one in the static call graph. . As a result, the function related to the recursive call is described as a function regarded as one on the static call graph. When step S3602 ends, a static call graph 3605 that has been subjected to recursive call processing is output from the static call graph after the function call relationship is deleted and integrated. A specific example of the deletion and integration of the function call relationship is also shown in FIG.
Step S3603 is a step of creating recursive call processed function size information using the function degeneration information 3606. That is, based on the function size information 3604, the function size of the function assumed to be one is estimated. Moreover, the weight of the function regarded as one is the sum of the weight of the function related to the recursive call. In step S3603, the function size information 3607 is created by adding the function size of the function that is regarded as one to the function size information 3604. A specific example of the process of step S3603 is shown in FIG.

図16は、再帰縮退工程S36における具体的な処理動作の例を示す。図16は、呼出関係出力工程S35の出力、再帰呼出設定工程S32206の出力、工程S3601の出力、関数サイズ情報3304、及び、再帰縮退工程S36の出力を図示する。
呼出関係抽出工程S35の出力は、呼出関係出力工程S31の出力に加え、呼出し関係の重み付けを表示する欄を含む。呼出し関係の重みを表示する欄において、親関数f_MAINから子関数f_A2への呼出し関係に対する重みは150、親関数f_MAINから子関数f_A3への呼出し関係に対する重みは450、親関係f_A2から子関係f_B2の呼出し関係の重みは200、親関数f_A2から子関数f_A3への呼出し関係に対する重みは100、親関数f_A3から子関数f_B3への呼出し関係に対する重みは330、親関数f_B2から子関数f_A3への呼出し関係に対する重みは300、親関数f_B2から子関数f_B3への呼出し関係に対する重みは50である。なお、図16のS35中の重みの例は、図14に示した例とは異なる例である。
FIG. 16 shows an example of a specific processing operation in the recursive degeneration step S36. FIG. 16 illustrates the output of the call relation output step S35, the output of the recursive call setting step S32206, the output of the step S3601, the function size information 3304, and the output of the recursive degeneration step S36.
The output of the call relationship extraction step S35 includes a column for displaying the weight of the call relationship in addition to the output of the call relationship output step S31. In the column for displaying the weight of the call relationship, the weight for the call relationship from the parent function f_MAIN to the child function f_A2 is 150, the weight for the call relationship from the parent function f_MAIN to the child function f_A3 is 450, and the parent relationship f_A2 to the child relationship f_B2 The weight of the calling relationship is 200, the weight for the calling relationship from the parent function f_A2 to the child function f_A3 is 100, the weight for the calling relationship from the parent function f_A3 to the child function f_B3 is 330, and the calling relationship from the parent function f_B2 to the child function f_A3 Is 300, and the weight for the calling relationship from the parent function f_B2 to the child function f_B3 is 50. Note that the example of the weight in S35 of FIG. 16 is an example different from the example shown in FIG.

再帰縮退工程S36の出力は、工程S3602と、工程S3601の出力の一部と、工程S3603の出力を含む。ここで、工程S3601の出力の一部は、関数縮退情報3606である。
工程S3602において、工程S3601の出力の内、関数の呼出し関係について、一つの見立てた関数f_B2*f_A3について、工程S3302と同様に、削除と統合を行う。ただし、一つの見立てた関数f_B2*f_A3について、重み付けが付加される点では、工程S3602は工程S3302とは異なる。その結果、再帰呼出し処理済静的コールグラフ3605が形成される。
工程S3603において、親関数、子関数、一つと見立てた関数f_B2*f_A3のコードサイズを見積もる。その結果、再帰呼出し処理済関数のサイズ情報3607が形成される。
The output of the recursive reduction process S36 includes the process S3602, a part of the output of the process S3601, and the output of the process S3603. Here, part of the output of step S 3601 is function degeneration information 3606.
In step S3602, the function f_B2 * f_A3 ascertained with respect to the function calling relationship in the output of step S3601 is deleted and integrated in the same manner as in step S3302. However, step S3602 is different from step S3302 in that a weight is added to one assumed function f_B2 * f_A3. As a result, a recursive call processed static call graph 3605 is formed.
In step S3603, the code size of the parent function, the child function, and the function f_B2 * f_A3 regarded as one is estimated. As a result, recursive call processed function size information 3607 is formed.

図17は、実施例のメモリ割当工程S37を説明するフローチャートである。メモリ割当工程S37は親関数選択工程S3701、電力制御無しメモリ割当工程S3702、合計コードサイズ計算工程S3703、呼出頻度算出工程S3704、電力制御を伴うメモリへの割当工程S3705、アドレス計算工程S3706を含む。
なお、メモリ割当工程S37を実行するには、再帰縮退工程S36から出力された、bと表示した再帰処理済み静的コールグラフ、cと表示した再帰処理済み関数サイズ情報、dと表示した関数縮退情報を含む情報3707を使用する。また、メモリ割当工程37を実行するには、aと表示したメモリ構造情報3708を使用する。さらに、メモリ割当工程S37を実行するには、eと表示した静的コールグラフ、fと表示した関数サイズ情報を含む情報3709を使用する。なお、情報3707及び情報3709はソースコード、オブジェクト、又は、アセンブリ3711から得られる情報である。
親関数選択工程S3701において、メイン関数を除くすべての関数について、呼出し頻度が最も高い呼出し元関数を、その関数の親関数として選択する。親関数の選択にあたり、bと表示した再帰処理済み静的コールグラフ、ソースコード、オブジェクト、又は、アセンブリ3711を使用する。この工程により、メイン関数を頂点とした親子関係の階層が特定される。
電力制御無しメモリ割当工程S3702において、親関数選択工程S3701にて特定したメイン関数を頂点とした親子関係の階層にて、メイン関数から一定の呼出し階層内の関数を選択し(この詳細は特許文献5にて開示)、選択した関数を電力制御を行わないメモリバンクに割り当てる。メモリバンクに選択した関数を割り当てるために、aと表示したメモリ構造情報3708、cと表示した再帰呼出処理済み関数サイズ情報を使用する。
FIG. 17 is a flowchart illustrating the memory allocation step S37 according to the embodiment. The memory allocation step S37 includes a parent function selection step S3701, a memory allocation step S3702 without power control, a total code size calculation step S3703, a call frequency calculation step S3704, a memory allocation step S3705 with power control, and an address calculation step S3706.
In order to execute the memory allocation step S37, the recursive static call graph displayed as b output from the recursive reduction step S36, the recursive function size information indicated as c, and the function reduction indicated as d. Information 3707 including information is used. In order to execute the memory allocation step 37, the memory structure information 3708 labeled a is used. Further, in order to execute the memory allocation step S37, information 3709 including the static call graph indicated as e and the function size information indicated as f is used. Information 3707 and information 3709 are information obtained from the source code, object, or assembly 3711.
In the parent function selection step S3701, the call source function having the highest call frequency is selected as the parent function of the function for all functions except the main function. In selecting a parent function, a recursive static call graph, source code, object, or assembly 3711 labeled b is used. By this process, the hierarchy of the parent-child relationship with the main function as the vertex is specified.
In the memory allocation process S3702 without power control, a function in a certain call hierarchy is selected from the main function in the parent-child relation hierarchy with the main function specified in the parent function selection process S3701 as a vertex (for details, see Patent Literature 5), the selected function is assigned to a memory bank for which power control is not performed. In order to assign the selected function to the memory bank, the memory structure information 3708 indicated by a and the recursive call processed function size information indicated by c are used.

合計コードサイズ計算工程S3703において、電力制御を行わないメモリバンクに割り当てた関数の、親子関係の階層における直下の階層に属する各関数につき、各関数を代表関数とする関数群を作成し、その関数群の合計コードサイズを、その関数群を構成するコードサイズの合計により、計算する。この結果は、合計コードサイズテーブルとして保存される。なお、各関数を代表関数とする関数群は、代表関数および親子関係の階層における代表関数の子孫関数(呼出し先関数、呼出し先関数の呼出し先関数、呼出し先関数の呼出し先関数の呼出し先関数・・・すべてを指す)により構成される。合計コードサイズを計算するにあたり、cと表示した再帰処理済み関数サイズ情報を使用する。また、電力制御無しメモリ割当工程S3702で用いた、呼出し階層数の情報を合計コードサイズ計算工程S3703でも用いる。   In the total code size calculation step S3703, for each function belonging to the layer immediately below the parent-child relationship layer of the function assigned to the memory bank for which power control is not performed, a function group having each function as a representative function is created. The total code size of the group is calculated by the sum of the code sizes constituting the function group. This result is stored as a total code size table. A function group having each function as a representative function is a representative function descendant function (call destination function, call destination function call destination function, call destination function call destination function). ... indicates all). In calculating the total code size, the recursively processed function size information indicated as c is used. Further, the information on the number of call layers used in the memory allocation process without power control S3702 is also used in the total code size calculation process S3703.

呼出し頻度算出工程S3704において、bと表示した再帰呼出処理済み静的コールグラフを用いて、合計コードサイズ計算工程S3703において構成した関数群の間の呼出し頻度を算出する。この結果は関数群間の呼出頻度表として保存される。
電力制御を伴うメモリへの割当工程S3405において、電力制御無しメモリに割り当てられた関数以外の関数について、メモリ領域を割当てる。メモリ領域を関数に割り当てるにあたり、aと表示したメモリ構造情報、合計コードサイズ計算工程S3703にて計算した合計コードサイズテーブル、および、呼出し頻度算出工程S3704にて算出した関数群間の呼出頻度表を使用する。合計コードサイズ計算工程S3703にて構成した関数群ごとに割り当てることにより、呼出し元の関数から一番呼出し頻度が高い呼出し先の関数を、呼出し元の関数と同一のメモリバンクに、また、呼出し頻度算出工程S3704の結果を用いることで二番目以降に呼出し頻度が関数についてもできるだけ呼出し元の関数と同一のメモリバンクに、割り当てることができる。
アドレス計算工程S3706において、電力制御無しメモリ割当工程S3702および電力制御を伴うメモリへの割当工程S3705において割り当てた各関数のうち再帰縮退工程S36によって一つにまとめられた関数は元の関数に復元し、その後、各関数について開始アドレスを算出し、メモリマップ情報を作成する。開始アドレスを算出とメモリマップ情報作成にあたり、aと表示したメモリ構造情報、dと表示した関数縮退情報、eと表示した静的コールグラフ、fと表示した関数サイズ情報を使用する。また、電力制御無しメモリ割当工程S3702における割り当て結果、および電力制御を伴うメモリへの割当工程S3705における割り当て結果を用いる。
In the call frequency calculation step S3704, the call frequency between the function groups configured in the total code size calculation step S3703 is calculated using the recursive call processed static call graph indicated as b. This result is stored as a call frequency table between function groups.
In step S3405 for allocating memory with power control, a memory area is allocated for a function other than the function allocated to the memory without power control. In allocating a memory area to a function, memory structure information indicated as a, a total code size table calculated in the total code size calculation step S3703, and a call frequency table between function groups calculated in the call frequency calculation step S3704 use. By assigning each function group configured in the total code size calculation step S3703, the call destination function having the highest call frequency from the call source function is placed in the same memory bank as the call source function, and the call frequency By using the result of the calculation step S3704, the call frequency for the second and subsequent functions can be assigned to the same memory bank as the call source function as much as possible.
In the address calculation step S3706, among the functions assigned in the memory allocation step S3702 without power control and the memory allocation step S3705 with power control, the functions combined by the recursive degeneration step S36 are restored to the original functions. Thereafter, a start address is calculated for each function, and memory map information is created. In calculating the start address and creating the memory map information, the memory structure information indicated by a, the function degeneration information indicated by d, the static call graph indicated by e, and the function size information indicated by f are used. Also, the allocation result in the memory allocation step S3702 without power control and the allocation result in the allocation step S3705 to the memory with power control are used.

以上より、実施例1のメモリシステム50において、実施例2のプログラムに含まれるコードに記憶領域を割り当てる割当方法を実施し、メモリシステム50に含まれるCPUによって、関数の呼出し状態に応じて、メモリバンクの電源状態を制御すれば、通常電力供給状態とするメモリバンク数を減少させることができる。ここで、実施例2のプログラムに含まれるコードに記憶領域を割り当てる割当方法を実施すると、呼出し元の子関数に対して、呼出し頻度の高い、呼出し先の子関数を選択して、同一バンクに割り当てることができる。そうすると、実施例1の割当方法により、子関数をメモリ領域に割り当てる場合に比較し、実施例2の割当方法により、子関数をメモリ領域に割り当てる方が、より通常電力供給状態とするメモリバンク数を減少させることができる。
呼出し元の子関数について、呼出し先の子関数が複数ある場合、呼出し頻度の低い子関数を同一バンクに割り当てる一方で、呼出し頻度の高い子関数を他のメモリバンクに割り当てる場合、複数のメモリバンクを通常電力供給状態とする頻度が高くなるからである。
As described above, in the memory system 50 according to the first embodiment, the allocation method for allocating the storage area to the code included in the program according to the second embodiment is performed, and the CPU included in the memory system 50 performs By controlling the power supply state of the bank, the number of memory banks in the normal power supply state can be reduced. Here, when the allocation method for allocating the storage area to the code included in the program of the second embodiment is performed, a call destination child function having a high call frequency is selected for the call source child function, and the call destination child function is selected in the same bank. Can be assigned. Then, compared to the case where the child function is assigned to the memory area by the assignment method of the first embodiment, the number of memory banks in which the child function is assigned to the memory area by the assignment method of the second embodiment is more normally supplied. Can be reduced.
If there are multiple callee child functions for the caller child function, assign a child function with a low call frequency to the same bank, while assign a child function with a high call frequency to another memory bank. This is because the frequency of setting to the normal power supply state increases.

実施例2において、呼び出し頻度の高い、呼出し先の子関数を同一のメモリバンクに割り当てようとするが、割り当て先のメモリバンクの記憶容量が小さく、呼出し先の子関数すべてを同一のメモリバンクに割り当てられない場合が想定される。その場合に、メモリシステム50において、以下に示す実施例3のプログラムを実行すると、同一のメモリバンクに割当られなかった関数は所定のメモリバンクに割り当てられる。ここで、実施例3のメモリ割当工程は、実施例2のメモリ割当工程S37中の電力制御有りメモリ割当部S3705に代えて、以下に示す電力制御有りメモリ割当部S4005を含む工程である。
図18A、及び18Bは実施例3に係わる電力制御有りメモリ割当部S4005を示す。
実施例3のメモリ割当工程は、親関数選択工程S3701、電力制御無しメモリ割当工程S3702、合計コードサイズ計算工程S3703、呼出頻度算出工程S3704、電力制御を伴うメモリへの割当工程S4005、アドレス計算工程S3706を含む。このうち、親関数選択工程S3701、電力制御無しメモリ割当工程S3702、合計コードサイズ計算工程S3703、呼出し頻度算出工程S3704、アドレス計算工程S3406は実施例2と同一である。実施例3の電力制御を伴うメモリへの割当工程S4005の実行は、スタート以下、次の工程を実行することとなる。
まず、残りメモリサイズ変数初期化工程S400501を行う。残りメモリ領域サイズ変数初期化工程S400501は残りメモリ領域サイズを記憶する変数m_restの値を初期化する工程である。すなわち、電力制御無しメモリ割当工程S3702において割り当てた電力制御を行わないメモリバンクMに対しては、m_rest(m_rest[M])の値を0、それ以外のメモリバンクMに対するm_restの値(m_rest[M])をメモリバンクMの容量と初期化する。
次いで、合計コードサイズ最大の関数群を選択する工程S400502を行う。合計コードサイズ最大の関数群を選択する工程S400502は、合計コードサイズテーブルを走査し、現時点でメモリバンクへ割り当てていない関数群のうちコードサイズ最大の関数群を選び最大関数群F_Maxとして設定する。なお、実施例3および後述の実施例4において、「関数群」とは合計コードサイズ計算工程S3703において構成した関数群のことを意味している。
次いで、最大関数群を配置判断する工程S400503を行う。最大関数群を配置判断する工程S400503は最大関数群F_Maxが配置できるメモリバンクを検出できるかを判断する工程である。最大関数群F_Maxが配置できるメモリバンクを検出できた場合には、残りメモリサイズ変数を更新する工程S400504へ進む。一方、最大関数群F_Maxが配置できるメモリバンクを検出できなかった場合には、最大関数群F_Max配置ルーチン(メモリバンク認識工程S400513から残りメモリバンク更新工程S400516を含む)に進む。
In the second embodiment, an attempt is made to assign a call destination child function having a high call frequency to the same memory bank, but the memory capacity of the assignment destination memory bank is small, and all the call destination child functions are assigned to the same memory bank. It is assumed that it cannot be assigned. In this case, when the program of the third embodiment shown below is executed in the memory system 50, functions that are not assigned to the same memory bank are assigned to a predetermined memory bank. Here, the memory allocation process of the third embodiment is a process including a memory allocation unit with power control S4005 shown below instead of the memory allocation unit with power control S3705 in the memory allocation process S37 of the second example.
18A and 18B show the power allocation memory allocation unit S4005 according to the third embodiment.
The memory allocation process of the third embodiment includes a parent function selection process S3701, a memory allocation process without power control S3702, a total code size calculation process S3703, a call frequency calculation process S3704, a memory allocation process S4005 with power control, and an address calculation process. Including S3706. Among these, the parent function selection step S3701, the memory allocation step without power control S3702, the total code size calculation step S3703, the call frequency calculation step S3704, and the address calculation step S3406 are the same as those in the second embodiment. Execution of the memory allocation step S4005 with power control according to the third embodiment executes the following steps after the start.
First, the remaining memory size variable initialization step S400501 is performed. The remaining memory area size variable initialization step S400501 is a process of initializing the value of the variable m_rest that stores the remaining memory area size. That is, for the memory bank M that is not subjected to the power control allocated in the power allocation without memory control step S3702, the value of m_rest (m_rest [M]) is 0, and the value of m_rest for the other memory banks M (m_rest [ M]) is initialized with the capacity of the memory bank M.
Next, step S400502 for selecting a function group having the maximum total code size is performed. In step S400502 of selecting the function group having the maximum total code size, the total code size table is scanned, and the function group having the maximum code size is selected from the function groups not currently allocated to the memory bank and set as the maximum function group F_Max. In the third embodiment and the fourth embodiment which will be described later, the “function group” means a function group configured in the total code size calculation step S3703.
Next, step S400503 for determining the arrangement of the maximum function group is performed. Step S400503 for determining the placement of the maximum function group is a step for determining whether a memory bank in which the maximum function group F_Max can be placed can be detected. If a memory bank in which the maximum function group F_Max can be arranged is detected, the process proceeds to step S400504 for updating the remaining memory size variable. On the other hand, if the memory bank in which the maximum function group F_Max can be placed cannot be detected, the process proceeds to the maximum function group F_Max placement routine (including the remaining memory bank update step S400516 from the memory bank recognition step S4000051).

残りメモリサイズ変数を更新する工程S400504は、コードサイズ最大の関数群F_Maxのコード量(s(F_Max))を、最大関数群を配置判断する工程S400503にて検出したメモリバンクの残りメモリ領域サイズ(m_rest[M])から差し引いて、最大関数群F_Max配置後のメモリバンクの残りメモリ領域サイズ(m_rest[M])を更新する工程である。
次いで、呼び出し頻度認識により集合Γを生成する工程S400505を行う。呼び出し頻度認識工程により集合Γを生成するS400505は最大関数群F_Maxから呼び出し関係にあり、かつ、メモリバンクへ未割り当ての関数群Fからなる集合Γを生成する工程である。なお、最大関数群F_Maxから呼び出し関係にあることの判定は、最大関数群F_Maxからの呼び出し頻度Q(F_Max,F)が0より真に大きいことにより行う。呼び出し頻度Q(F_Max,F)は関数群F_Maxに含まれる関数φ及び関数群Fに含まれる関数ψの組合せについて、重みP(φ,ψ)と重みP(ψ,φ)の合算値を、すべての組合せについて計算し、計算した合算値すべてについて和をとって得られるものである。ただし、関数群F_Maxに含まれる関数は割り当て済みであり、呼び出し頻度Q(F_Max,F_Max)は上記のとおりに計算しても集合Γから除外されるので、呼び出し頻度Q(F_Max,F_Max)の値は0とする。すなわち、呼び出し頻度Q(F_Max,F)は以下の式で表される。
(数1)
Q(F_Max,F)=0 F=F_Maxのとき
Σ(P(φ,ψ)+P(ψ,φ)) F≠F_Maxのとき
φ∈F_Max
ψ∈F
ここで、φは関数群F_Maxに含まれる関数を示す。ψは関数群Fに含まれる関数を示す。
次いで、集合Γが空集合か否かを判断する工程S400506を行う。集合Γが空集合であるときは、メモリ割当が終了したかを判断する工程S400512に進む。一方、集合Γが空集合でないときは、メモリ領域割り当てルーチンS400507へ進む。メモリ領域割り当てルーチンS400507は最大関数群F_Max以外の関数であって、集合Γに属する関数についてメモリ領域を割り当てるルーチンであり、図18Bを用いて説明する。
In step S400504 for updating the remaining memory size variable, the code amount (s (F_Max)) of the function group F_Max having the maximum code size is set to the remaining memory area size (in the memory bank detected in step S400503 for determining the placement of the maximum function group). This is a step of subtracting from m_rest [M]) and updating the remaining memory area size (m_rest [M]) of the memory bank after the maximum function group F_Max is arranged.
Next, step S400505 for generating a set Γ by call frequency recognition is performed. S400505 for generating the set Γ by the call frequency recognition step is a step for generating the set Γ including the function group F that is in a calling relationship from the maximum function group F_Max and is not assigned to the memory bank. Note that the determination of the call relationship from the maximum function group F_Max is made when the call frequency Q (F_Max, F) from the maximum function group F_Max is truly greater than zero. The call frequency Q (F_Max, F) is the sum of the weight P (φ, ψ) and the weight P (ψ, φ) for the combination of the function φ included in the function group F_Max and the function ψ included in the function group F. It is obtained by calculating all combinations and summing all calculated sums. However, since the functions included in the function group F_Max have already been assigned, and the call frequency Q (F_Max, F_Max) is excluded from the set Γ even if calculated as described above, the value of the call frequency Q (F_Max, F_Max) Is 0. That is, the call frequency Q (F_Max, F) is expressed by the following equation.
(Equation 1)
When Q (F_Max, F) = 0 F = F_Max
Σ (P (φ, φ) + P (φ, φ)) When F ≠ F_Max
φ∈F_Max
ψ∈F
Here, φ indicates a function included in the function group F_Max. ψ indicates a function included in the function group F.
Next, step S400506 is performed to determine whether the set Γ is an empty set. If the set Γ is an empty set, the process advances to step S400212 to determine whether the memory allocation has been completed. On the other hand, when the set Γ is not an empty set, the process proceeds to a memory area allocation routine S400507. The memory area allocation routine S400507 is a function other than the maximum function group F_Max, and is a routine for allocating memory areas for functions belonging to the set Γ, and will be described with reference to FIG. 18B.

メモリバンク認識工程S400513は残りのメモリ領域が存在するメモリバンクを認識し、残りメモリ領域サイズが大きい順にM1、M2、・・・、Mn(nは正の整数)と名付ける工程である。なお、残りメモリ領域サイズが同一値であるメモリバンクが存在する場合は、同一値であるメモリバンク同士、同一値であるメモリバンクの次に残りメモリ領域サイズが多いメモリバンク、および、同一値であるメモリバンクの次に残りメモリ領域サイズが少ないメモリバンクが、可能な限りアドレスが連続するように名付けると、後述する理由により望ましい結果となる。
次いで、最大関数を割り当て可能なメモリバンクを認識する工程S400514を行う。最大関数を割り当て可能なメモリバンクを認識する工程S400514では、残りのメモリ領域を大きい順に加えていき、加算された残りのメモリ領域が最大関数群F_Maxのコードサイズ以上となるときが何番目のメモリバンクにあたるかを検出する。すなわち、m_rest[M1]+m_rest[M2]+・・・+m_rest[Mm]≧s(F_Max)(mはn以下の正の整数)となるmを検出することとなる。ここで、s(F_Max)は最大関数群F_Maxのコードサイズを表す。
The memory bank recognition step S400313 is a step of recognizing a memory bank in which the remaining memory area exists and naming it as M1, M2,..., Mn (n is a positive integer) in descending order of the remaining memory area size. If there are memory banks with the same value of the remaining memory area size, the memory banks with the same value, the memory bank with the remaining memory area size next to the memory bank with the same value, and the same value If a memory bank having the smallest remaining memory area size next to a certain memory bank is named so that addresses are continuous as much as possible, a desirable result is obtained for the reason described later.
Next, step S400514 of recognizing a memory bank to which the maximum function can be assigned is performed. In the step S400514 of recognizing the memory bank to which the maximum function can be allocated, the remaining memory areas are added in descending order, and the added memory area is larger than the code size of the maximum function group F_Max. Detect whether it hits a bank. That is, m that satisfies m_rest [M1] + m_rest [M2] +... + M_rest [Mm] ≧ s (F_Max) (m is a positive integer equal to or less than n) is detected. Here, s (F_Max) represents the code size of the maximum function group F_Max.

次いで、メモリ領域割当工程S400515を行う。メモリ領域割当工程S400515はM1からMmまでの複数のメモリバンクに、最大関数群F_Maxを割り当てる工程である。なお、メモリバンクM1からMmまで、アドレスが連続しているとより望ましい結果となる。例えば、後に図19Dに示すように、アドレスが連続しているメモリバンク400521とメモリバンク400522が、最大関数群F_Maxを割り当てるメモリ領域として選択されることと望ましい結果となる。アドレスが連続するメモリバンクを選択すれば、メモリバンク間を移動するための分岐命令を省くことができ、プロセッサの消費電力を削減できるからである。
次いで、残りメモリ領域サイズ更新工程S400516を行う。残りメモリ領域サイズ更新工程S400516は、次の操作をする工程である。まず、m_rest[Mi]=0 (i=1、・・・、m−1)とした後、m_rest[Mm]=(m_rest[M1]+m_rest[M2]+・・・+m_rest[Mn])−s(F_Max)とする。ここで、s(F_Max)は最大関数群F_Maxのコード量を表す。すなわち、1からm−1番目までのメモリバンクの残りメモリ領域サイズを0にするとともに、最大関数群F_Maxの内、1からm−1番目までのメモリバンクに配置しきれなかった部分のサイズを、m番目のメモリバンクの元のメモリ領域サイズから、差し引き、m番目のメモリバンクの残りメモリ領域サイズを求める。
残りのメモリ領域の更新工程S400516が終了すると、呼び出し頻度認識工程S400505へ進む。
Next, a memory area allocation step S400515 is performed. The memory area allocation step S400515 is a step of allocating the maximum function group F_Max to a plurality of memory banks from M1 to Mm. A more desirable result is obtained when the addresses are continuous from the memory banks M1 to Mm. For example, as shown in FIG. 19D later, the memory bank 400521 and the memory bank 400522 having consecutive addresses are selected as the memory area to which the maximum function group F_Max is assigned, which is a desirable result. This is because if a memory bank having consecutive addresses is selected, a branch instruction for moving between memory banks can be omitted, and the power consumption of the processor can be reduced.
Next, a remaining memory area size update step S400516 is performed. The remaining memory area size update step S400516 is a step for performing the following operation. First, after setting m_rest [Mi] = 0 (i = 1,..., M−1), m_rest [Mm] = (m_rest [M1] + m_rest [M2] +... + M_rest [Mn]) − s (F_Max). Here, s (F_Max) represents the code amount of the maximum function group F_Max. That is, the remaining memory area size of the 1st to (m-1) th memory banks is set to 0, and the size of the portion of the maximum function group F_Max that cannot be arranged in the 1st to (m-1) th memory banks is set. , Subtract from the original memory area size of the mth memory bank to obtain the remaining memory area size of the mth memory bank.
When the remaining memory area update step S400516 is completed, the process proceeds to a call frequency recognition step S400505.

メモリ割当が終了したかを判断する工程S400512は、合計コードサイズテーブル中の関数群のすべてについて、メモリ領域を割り当てたかを判断する工程である。すなわち、最大関数群F_Maxに含まれる関数及び最大関数群F_Maxと呼び出し関係にある関数群に含まれる関数をメモリ領域に割当てた後、さらに合計コードサイズテーブル中に、メモリ領域に割り当てられていない他の関数群が存在するか否かを判断する工程である。ここで、合計コードサイズテーブル中に他の関数群が存在し、その関数群について、メモリ領域の割当が終了していないと判断する場合、合計メモリサイズ最大の関数群を選択する工程S400502に進む。一方、メモリ領域の割り当てが終了していると判断する場合、実施例3のメモリ割当工程を終了する。   Step S40052 for determining whether the memory allocation has been completed is a step for determining whether a memory area has been allocated for all the functions in the total code size table. That is, after a function included in the maximum function group F_Max and a function included in the function group having a calling relationship with the maximum function group F_Max are allocated to the memory area, the total code size table is not allocated to the memory area. This is a step of determining whether or not there is a function group. Here, when it is determined that another function group exists in the total code size table and the allocation of the memory area is not completed for the function group, the process proceeds to step S400502 for selecting the function group having the maximum total memory size. . On the other hand, if it is determined that the memory area allocation has been completed, the memory allocation process of the third embodiment is terminated.

図18Bは、メモリ領域割り当てルーチンS400507について説明するフローチャートである。
メモリ領域割当ルーチンS400507は、呼出し頻度最大の関数群F_Relを選択する工程S400508と、残りメモリ領域サイズ(m_rest[M])の判断工程S400509と、関数をメモリ領域の残りに割り当てる工程S400510と、集合Γ更新工程S400511とを含む。
FIG. 18B is a flowchart for describing the memory area allocation routine S400507.
The memory area allocation routine S400507 includes a process S400508 for selecting a function group F_Rel having the maximum call frequency, a determination process S400509 for a remaining memory area size (m_rest [M]), a process S400510 for allocating a function to the remaining memory area, Γ update step S40011.

呼出し頻度最大の関数群F_Relを選択する工程S400508は、集合Γに含まれる関数群Fの内、最大関数群F_Maxとの呼出し頻度最大の関数を選び関数群F_Relとして設定する工程である。但し、同一呼出し頻度の関数が複数存在する場合は、呼出し回数最大関数群F_Relの候補となる関数群の内、コードサイズが最大となる関数を選択する。
残りメモリ領域サイズ判断工程S400509は、メモリバンクMの残りメモリ領域サイズ(m_rest[M])が呼出し頻度最大の関数群F_Relのコード量以上であるかを判断する工程である。ただし、前記メモリバンクMは、最大関数群を配置判断する工程S400503にて割り当てたメモリバンク、あるいはメモリ領域割当工程S400515におけるメモリバンクMmを指している。どちらを指すかは最大関数群を配置判断する工程S400503の判断結果に依存する。残りメモリ領域サイズ(m_rest[M])が関数群F_Relのコード量(s(F_Rel))以上である場合には、関数群F_Relを残りメモリ領域に割り当てる工程S400510に進み、残りメモリ領域サイズ(m_rest[M])が関数群F_Relのコード量(s(F_Rel))より真に小さい場合には、集合Γ更新工程S400511へ進む。
In step S400508, the function group F_Rel having the maximum calling frequency is selected, and the function having the maximum calling frequency with the maximum function group F_Max is selected from the function group F included in the set Γ and set as the function group F_Rel. However, when there are a plurality of functions having the same call frequency, the function having the maximum code size is selected from the function groups that are candidates for the function group F_Rel having the maximum number of calls.
The remaining memory area size determining step S400509 is a step of determining whether the remaining memory area size (m_rest [M]) of the memory bank M is equal to or larger than the code amount of the function group F_Rel having the maximum calling frequency. However, the memory bank M indicates the memory bank assigned in step S400503 for determining the placement of the maximum function group, or the memory bank Mm in the memory area assignment step S400515. Which is pointed depends on the determination result in step S400503 for determining the placement of the maximum function group. If the remaining memory area size (m_rest [M]) is greater than or equal to the code amount (s (F_Rel)) of the function group F_Rel, the process proceeds to step S400510 for assigning the function group F_Rel to the remaining memory area, and the remaining memory area size (m_rest) If [M]) is truly smaller than the code amount (s (F_Rel)) of the function group F_Rel, the process proceeds to the set Γ update step S40011.

集合Γ更新工程S400511は、最大関数群F_Maxから呼び出し関係にある関数群の集合Γから、関数群F_Relを取り除いて、集合Γを更新する工程である。この工程は、残りメモリ領域サイズ判断工程S400509の結果によらず行われる。なお、メモリバンクMの残りメモリ領域サイズ(m_rest[M])より呼出し頻度最大関数群F_Relが大きい場合には、その関数群については、メモリ領域への割当が行われないが、メモリ割当が終了したかを判断する工程S400512を経由して、メモリバンク認識工程S400513から残りメモリ領域サイズ更新工程S400516によってメモリ領域への割当が行われる。   The set Γ update step S40011 is a step of updating the set Γ by removing the function group F_Rel from the function group set Γ having a calling relationship from the maximum function group F_Max. This process is performed regardless of the result of the remaining memory area size determination process S400509. When the maximum call frequency function group F_Rel is larger than the remaining memory area size (m_rest [M]) of the memory bank M, the function group is not allocated to the memory area, but the memory allocation is completed. Through the step S40052 for determining whether or not the memory area is allocated, the memory area is allocated from the memory bank recognition process S4000051 to the remaining memory area size update process S400516.

以上より、関数群F_Maxから呼び出し関係にある関数群Fの集合Γが空でない場合、メモリ領域割り当てルーチンS400507にエントリし、集合Γを更新する工程S400511を終了すると、フローチャートの集合Γが空集合か否かを判断する工程S400506に進む。   As described above, when the set Γ of the function group F having the calling relationship from the function group F_Max is not empty, the process enters the memory area allocation routine S400507 and ends the process S40011 for updating the set Γ. The process proceeds to step S400506 for determining whether or not.

図19は、第3実施例に係わるメモリ割当工程S4005により関数を各メモリバンクに割り当てる具体例を示す。
図19Aから図19Cは、第3実施例に係わるメモリ割当工程S4005を開始するにあたり、合計コードサイズ計算工程S3703、呼出し頻度計算工程S3704を行った結果をそれぞれ示す。
図19Aにおいて、呼出し元の関数を親関数として列挙し、それらに対する呼び出し先の関数と、呼出し回数に基づいた重み付けを列挙した左表を示す。また、一つの呼び出し先の関数に対し、呼出し元の関数が2以上ある場合に、重み付けに基づいて呼出し元の関数を一つに選択した状態の親関数と、その呼出し先の関数を列挙した右表を示す。左表と、右表を比較してみると、関数B4は、親関数A2、A3双方の呼出し先の関数となっているが、重み付けに従って、親関数A2が関数B4の親関数として選択したことがわかる。
図19Bにおいて、関数群名F_A1、F_A2、F_A3及び関数群それぞれの代表関数A1*B1*C1*D1、代表関数A2、代表関数A3が記載された表が示されている。関数A1*B1*C1*D1は再帰呼び出し関係にあるため、一つの関数と見なされた関数である。なお、図19Bに示す表には、さらに、代表関数から子孫関係にある関数(代表関数からの呼び出し先の関数及びそれらからさらに呼び出される関数)と、代表関数とその子孫関数の合計コードサイズとが、記載されている。
図19Cは呼出し頻度算出工程S3704により計算された関数群間の呼出し頻度を示す表である。呼出し頻度は2つの異なる関数群については、片方の関数群に属する関数が呼び出し元となり、もう一方の関数群に属する関数が呼び出し先となる呼出しが発生する頻度を表す。そこで、関数群F_A1、F_A2、F_A3から呼出し関係にある関数群F_A1、F_A2、F_A3に対する呼出し頻度を表した結果が、図19Cに示されている。関数群F_A1に属する関数が呼出し元あるいは呼出し先となる呼出しの、それぞれ呼出し先、呼出し元は、メイン関数または関数群F_A1に属する関数であるため、関数群F_A1と関数群F_A1、F_A2、F_A3との呼出し頻度は0である。一方、関数群F_A2に属する関数が呼出し元あるいは呼出し先となる呼出しにおいては、関数A3(関数群F_A3に属する)が関数B4(関数群A2に属する)を頻度20で呼び出しており、それ以外については呼出し先または呼出し元は、メイン関数または関数群F_A2に属する関数であるため、関数群F_A2と関数群F_A1、F_A2との呼出し頻度は0であるが、関数群F_A3との呼出し頻度は20である。同様に、関数群F_A3と関数群F_A1、F_A3に属する関数を呼出し頻度は0であるが、関数群F_A2との呼出し頻度は20である。
図19Dは電力制御有りメモリ割当工程S4005を行った結果を示す。図19Dにおいて、メイン関数400517、関数A1を含む一つとみなされた関数(関数A1*B1*C1*D1)を代表関数とする関数群(F_A1)400518、関数A2を代表関数とする関数群(F_A2)400519、関数A3を代表関数とする関数群(F_A3)400520、メモリバンク400521、メモリバンク400522、メモリバンク400523、及び、メモリバンク400524を示す。
FIG. 19 shows a specific example in which a function is allocated to each memory bank in the memory allocation step S4005 according to the third embodiment.
19A to 19C show the results of performing the total code size calculation step S3703 and the call frequency calculation step S3704 in starting the memory allocation step S4005 according to the third embodiment.
FIG. 19A shows a left table in which caller functions are listed as parent functions, and callee functions for these functions and weights based on the number of calls are listed. In addition, when there are two or more call source functions for one call destination function, the parent function in a state where the call source function is selected as one based on the weighting and the call destination functions are listed. The right table is shown. Comparing the left table and the right table, the function B4 is a call destination function of both the parent functions A2 and A3. According to the weighting, the parent function A2 is selected as the parent function of the function B4. I understand.
FIG. 19B shows a table in which the function group names F_A1, F_A2, and F_A3 and the representative functions A1 * B1 * C1 * D1, the representative function A2, and the representative function A3 of the function groups are described. The function A1 * B1 * C1 * D1 is a function that is regarded as one function because of the recursive call relationship. The table shown in FIG. 19B further includes a function that has a descendant relationship from the representative function (a function that is called from the representative function and a function that is further called from the function), and a total code size of the representative function and its descendant functions. Is described.
FIG. 19C is a table showing the call frequency between function groups calculated in the call frequency calculation step S3704. For two different function groups, the call frequency represents the frequency with which a function belonging to one function group becomes a caller and a call belonging to a function belonging to the other function group occurs. Accordingly, FIG. 19C shows the result of expressing the calling frequency for the function groups F_A1, F_A2, and F_A3 having a calling relationship from the function groups F_A1, F_A2, and F_A3. Since the call destination and call source of the call to which the function belonging to the function group F_A1 is the call source or call destination are the main function or the function belonging to the function group F_A1, respectively, the function group F_A1 and the function groups F_A1, F_A2, and F_A3 The call frequency of is 0. On the other hand, in a call in which a function belonging to the function group F_A2 is a call source or a call destination, the function A3 (belonging to the function group F_A3) calls the function B4 (belonging to the function group A2) with the frequency 20; Since the call destination or call source is a main function or a function belonging to the function group F_A2, the call frequency of the function group F_A2 and the function groups F_A1 and F_A2 is 0, but the call frequency of the function group F_A3 is 20. is there. Similarly, the frequency of calling the function group F_A3 and the functions belonging to the function groups F_A1 and F_A3 is 0, but the frequency of calling the function group F_A2 is 20.
FIG. 19D shows the result of performing memory allocation step S4005 with power control. In FIG. 19D, a function group (F_A1) 400518 having a main function 400517 and a function (function A1 * B1 * C1 * D1) regarded as one including the function A1 and a function group (F_A2) having the function A2 as a representative function. ) 400519, a function group (F_A3) 400520 having a function A3 as a representative function, a memory bank 40000521, a memory bank 40000522, a memory bank 4000052, and a memory bank 4000052.

メモリバンク400521、400522、400523の容量は4KBであり、電力制御ありのメモリバンクである。また、メモリバンク400521、400522、400523のメモリ領域は、アクセスするためのアドレスが連続している。
メイン関数400517は、関数A1、関数A2、関数A3を呼び出す関数である。また、関数の出入りで電力を制御する方式では電力削減効果が減少するため、メイン関数400517は、電力制御無しのメモリバンク400524へ割り当てられている。以下、図19Dに示す電力制御有りメモリ割当工程S4005を行った結果が得られるまで、図18A、Bのフローチャートにそって各工程の具体例を示す。
まず、残りメモリサイズ変数初期化工程S400501を行う。メモリサイズ変数初期化の対象は、メモリバンク400521、400522、400523、400524であり、初期化の結果それぞれのメモリバンクの残りメモリ領域サイズm_rest[M]は、4KB、4KB、4KB、0KBとなる。すでに、メモリバンク400524にはメイン関数400517が配置され、電力制御なしのメモリバンクとして使用することが決定してているため、メモリバンク400524の残りメモリ領域サイズは0である。
関数A1を含む一つとみなされた関数(関数A1*B1*C1*D1)を代表関数とする関数群F_A1(400518)は、関数A1*B1*C1*D1、関数C2を含む。関数群F_A1(400518)の合計コードサイズは5KBである。
関数A2を代表関数とする関数群F_A2(400519)は、関数A2、関数B2、関数B3、関数B4を含む。関数群F_A2(400519)の合計コードサイズは4KBである。
関数A3を代表関数とする関数群F_A3(400520)は、関数A3、関数B5、関数B6を含む。関数群F_A3(400520)は3KBである。
The capacity of the memory banks 400521, 400522, and 400523 is 4 KB, which is a memory bank with power control. In addition, the memory areas of the memory banks 400521, 40000522, and 400523 have consecutive addresses for access.
The main function 400517 is a function that calls the function A1, the function A2, and the function A3. Further, since the power reduction effect is reduced in the method of controlling the power by entering and exiting the function, the main function 400517 is assigned to the memory bank 4000052 without power control. Hereinafter, specific examples of each process will be described with reference to the flowcharts of FIGS. 18A and 18B until the result of performing the memory allocation process with power control S4005 illustrated in FIG. 19D is obtained.
First, the remaining memory size variable initialization step S400501 is performed. The target of the memory size variable initialization is the memory banks 400521, 40000522, 40000523, and 400524. As a result of the initialization, the remaining memory area size m_rest [M] of each memory bank is 4KB, 4KB, 4KB, and 0KB. Since the main function 400517 is already arranged in the memory bank 4000052 and it has been decided to use it as a memory bank without power control, the remaining memory area size of the memory bank 4000052 is 0.
A function group F_A1 (400518) having a function (function A1 * B1 * C1 * D1) regarded as one including the function A1 as a representative function includes a function A1 * B1 * C1 * D1 and a function C2. The total code size of the function group F_A1 (400518) is 5 KB.
A function group F_A2 (400519) having the function A2 as a representative function includes a function A2, a function B2, a function B3, and a function B4. The total code size of the function group F_A2 (400519) is 4 KB.
A function group F_A3 (400520) having the function A3 as a representative function includes a function A3, a function B5, and a function B6. The function group F_A3 (400520) is 3 KB.

次いで、合計コードサイズ最大の関数群を選択する工程S400502を行う。その結果、関数群F_A1(400518)が関数群F_Maxとして選択される。
次いで、最大関数群を配置判断する工程S400503を行う。その結果、関数群F_A1(400518)は5KBであるため、どのメモリバンクにも配置できないと判断される。 次いで、メモリバンク認識工程S400513を行う。その結果、各メモリバンクの残り容量、残りメモリ領域サイズm_rest[M]は4KB、4KB、4KB、0KBであると認識するとともに、メモリバンク400521、400522、400523、400524の順に並べ、M1、M2、M3、M4と名付ける。
次いで、最大関数を割当可能なメモリバンクを認識する工程S400514を行う。その結果、M1の残りメモリサイズm_rest[M1]、M2の残りメモリ領域サイズm_rest[M2]を加算すると8KBとなり、関数群F_A1(400518)の容量s(F_Max)以上となるため、最小のmは2である。
次いで、メモリ領域割当工程S400515を行う。その結果、関数群F_A1(400518)の内、4KB分は、メモリバンク400521に割り当てられ、残りの1KB分はメモリバンク400522に割り当てられる。
次いで、残りメモリ領域サイズ更新工程S400516を行う。メモリバンク400521、400522、400523、400524の残りのメモリ容量は0KB、3KB、4KB、0KBと更新される。
次いで、呼び出し頻度認識により集合Γを生成する工程S400505を行う。その結果、関数群F_Maxから呼び出し頻度が0以上の関数群Fの集合Γは、図19Cより空となる。
次いで、集合Γが空集合か否かを判断する工程S400506を行う。その結果、集合Γは空であるから、メモリ割当が終了したかを判断する工程S400512に進む。その結果、関数群F_A2(400519)、関数群F_A3(400520)の割当が未了なため、最大コードサイズの関数群を選択する工程S400502に進む。
次いで、最大コードサイズの関数群を選択する工程S400502を行う。その結果、関数群F_A2(400519)が関数群F_Maxとして選択される。
次いで、最大コードサイズの関数群を配置判断する工程S400503を行う。その結果、関数群F_A2(400519)の合計コードサイズと、メモリバンク400523のメモリ領域は4KBと同一であり、関数群F_A2(400519)はメモリバンク400523からはみ出すことなく割り当てられる。そこで、残りメモリサイズ変数を更新する工程S400504へ進む。
次いで、残りメモリサイズ変数を更新する工程S400504を行う。その結果、メモリバンク400521、400522、400523、400524の残りメモリ領域サイズ(m_rest[M])は、0KB、3KB、0KB、0KBと更新される。
次いで、呼び出し頻度認識により集合Γを生成する工程S400505を行う。関数群F_A2(400519)をF_Maxとした場合、現時点で最大関数群F_Maxから呼び出し頻度が0でない関数群Fあって、メモリバンク領域に割り当てられていない関数群Fとして関数群F_A3が存在するため、関数群F_A3を含む集合Γを生成する。
次いで、集合Γが空集合か否かを判断する工程S400506を行う。呼び出し頻度が0でない関数が集合Γに存在するので、メモリ領域割当ルーチンS400507へ進む。
次いで、メモリ領域割当ルーチンS400507中の呼出し頻度最大の関数F_Relを選択する工程S400508を行う。その結果、関数群F_A3を関数群F_Relと設定する。
次いで、残りメモリ領域サイズ判断工程S400509を行う。メモリバンク400523の残りメモリ領域サイズ3KBが関数群F_Relの合計コードサイズ3KB以上であるので、残りメモリ領域に割り当てる工程S400510に進む。
次いで、集合Γ更新工程S400511を行う。集合Γから、関数群F_Fel、すなわち、関数群F_A3を除く。
次いで、メモリ領域割当ルーチンS400507を抜けて、集合Γが空集合か否かを判断する工程S400506を行う。その結果、集合Γは空であるため、メモリ割当が終了したかを判断する工程S400512に進む。その結果、関数群関数群F_A3(400520)がメモリバンクに割当られていないため、最大コードサイズの関数群を選択する工程S400502に進む。
次いで、最大コードサイズの関数群を選択する工程S400502を行う。その結果、関数群F_A3(400520)が関数群F_Maxとして選択される。
次いで、最大コードサイズの関数群を配置判断する工程S400503を行う。その結果、関数群F_A3(400520)の合計コードサイズは3KB、メモリバンク400522の残りメモリ領域は3KBなので、関数群F_A3(400520)はメモリバンク400523からはみ出すことなく割り当てられる。そこで、残りメモリサイズ変数を更新する工程S400504へ進む。
次いで、残りメモリサイズ変数を更新する工程S400504を行う。その結果、メモリバンク400521、400522、400523、400524の残りメモリ領域サイズ(m_rest[M])は、0KB、0KB、0KB、0KBと更新される。
次いで、呼び出し頻度認識により集合Γを生成する工程S400505を行う。関数群F_A3(400520)をF_Maxとした場合、現時点で関数群F_Maxからの呼び出し頻度が0でない関数群Fであって、メモリバンク領域に割り当てられていない関数群Fはないので、集合Γは空に設定される。
次いで、集合Γが空集合か否かを判断する工程S400506を行う。集合Γは空であるため、メモリ割当が終了したかを判断する工程S400512に進む。
次いで、メモリ割当が終了したかを判断する工程S400512を行う。メモリ領域に割り当てられていない関数群が、合計コードサイズテーブル中に存在しないため、実施例3のメモリ割当工程S4005を終了する。
Next, step S400502 for selecting a function group having the maximum total code size is performed. As a result, the function group F_A1 (400518) is selected as the function group F_Max.
Next, step S400503 for determining the arrangement of the maximum function group is performed. As a result, since the function group F_A1 (400518) is 5 KB, it is determined that it cannot be placed in any memory bank. Next, the memory bank recognition step S400313 is performed. As a result, the remaining capacity of each memory bank and the remaining memory area size m_rest [M] are recognized as 4 KB, 4 KB, 4 KB, and 0 KB, and are arranged in the order of the memory banks 40051, 40052, 4000052, and 4000052, and M1, M2, Name them M3 and M4.
Next, step S400514 of recognizing a memory bank to which the maximum function can be assigned is performed. As a result, when the remaining memory size m_rest [M1] of M1 and the remaining memory area size m_rest [M2] of M2 are added, the result becomes 8 KB, which is equal to or larger than the capacity s (F_Max) of the function group F_A1 (400518). 2.
Next, a memory area allocation step S400515 is performed. As a result, of the function group F_A1 (400518), 4 KB is allocated to the memory bank 40000521, and the remaining 1 KB is allocated to the memory bank 400522.
Next, a remaining memory area size update step S400516 is performed. The remaining memory capacities of the memory banks 400521, 400522, 40000523, and 400524 are updated to 0 KB, 3 KB, 4 KB, and 0 KB.
Next, step S400505 for generating a set Γ by call frequency recognition is performed. As a result, the set Γ of the function group F whose call frequency is 0 or more from the function group F_Max becomes empty from FIG. 19C.
Next, step S400506 is performed to determine whether the set Γ is an empty set. As a result, since the set Γ is empty, the process proceeds to step S400212 where it is determined whether the memory allocation is completed. As a result, since the allocation of the function group F_A2 (400519) and the function group F_A3 (400520) has not been completed, the process proceeds to step S400502 for selecting the function group having the maximum code size.
Next, step S400502 for selecting a function group having the maximum code size is performed. As a result, the function group F_A2 (400519) is selected as the function group F_Max.
Next, step S400503 for determining the arrangement of the function group having the maximum code size is performed. As a result, the total code size of the function group F_A2 (400519) and the memory area of the memory bank 4000052 are the same as 4 KB, and the function group F_A2 (400519) is allocated without protruding from the memory bank 4000052. Therefore, the process proceeds to step S400504 for updating the remaining memory size variable.
Next, step S400504 for updating the remaining memory size variable is performed. As a result, the remaining memory area size (m_rest [M]) of the memory banks 400521, 40000522, 40000523, and 40000524 is updated to 0 KB, 3 KB, 0 KB, and 0 KB.
Next, step S400505 for generating a set Γ by call frequency recognition is performed. When the function group F_A2 (400519) is set to F_Max, the function group F_A3 exists as the function group F that is not assigned to the memory bank area because the function group F is not currently called from the maximum function group F_Max. A set Γ including the function group F_A3 is generated.
Next, step S400506 is performed to determine whether the set Γ is an empty set. Since a function whose call frequency is not 0 exists in the set Γ, the process proceeds to the memory area allocation routine S400507.
Next, step S400508 for selecting the function F_Rel having the maximum calling frequency in the memory area allocation routine S400507 is performed. As a result, the function group F_A3 is set as the function group F_Rel.
Next, a remaining memory area size determination step S400509 is performed. Since the remaining memory area size 3KB of the memory bank 4000052 is equal to or larger than the total code size 3KB of the function group F_Rel, the process proceeds to step S400510 for assigning to the remaining memory area.
Next, the set Γ update step S40011 is performed. The function group F_Fel, that is, the function group F_A3 is excluded from the set Γ.
Next, the process exits the memory area allocation routine S400507 and performs step S400506 for determining whether the set Γ is an empty set. As a result, since the set Γ is empty, the process proceeds to step S400212 where it is determined whether the memory allocation is completed. As a result, since the function group function group F_A3 (400520) is not allocated to the memory bank, the process proceeds to step S400502 for selecting the function group having the maximum code size.
Next, step S400502 for selecting a function group having the maximum code size is performed. As a result, the function group F_A3 (400520) is selected as the function group F_Max.
Next, step S400503 for determining the arrangement of the function group having the maximum code size is performed. As a result, since the total code size of the function group F_A3 (400520) is 3 KB and the remaining memory area of the memory bank 40000522 is 3 KB, the function group F_A3 (400520) is allocated without protruding from the memory bank 400523. Therefore, the process proceeds to step S400504 for updating the remaining memory size variable.
Next, step S400504 for updating the remaining memory size variable is performed. As a result, the remaining memory area size (m_rest [M]) of the memory banks 400521, 40000522, 40000523, and 40000524 is updated to 0 KB, 0 KB, 0 KB, and 0 KB.
Next, step S400505 for generating a set Γ by call frequency recognition is performed. When the function group F_A3 (400520) is F_Max, since there is no function group F that is currently not called by the function group F_Max and is not assigned to the memory bank area, the set Γ is empty. Set to
Next, step S400506 is performed to determine whether the set Γ is an empty set. Since the set Γ is empty, the process advances to step S40052 for determining whether the memory allocation is completed.
Next, step S40052 for determining whether the memory allocation is completed is performed. Since the function group not allocated to the memory area does not exist in the total code size table, the memory allocation process S4005 of the third embodiment is finished.

以上より、メモリシステム50において、実施例3のプログラムに含まれるコードに記憶領域を割り当てる割当方法を実施した場合、関数A1*B1*C1*D1を代表関数とする関数群F_A1(400518)はメモリバンク400521のメモリ領域より大きいため、メモリバンク400521とメモリバンク400522の2つのメモリバンクに集中して割り当てられる。また、関数A2を代表関数とする関数群F_A2の合計コードサイズ量は、メモリバンク400523のメモリ領域より小さいため、その関数群F_A2に含まれる関数は、一つのメモリバンク400523に集中して配置される。さらに、関数A3を代表関数とする関数群F_A3の合計コードサイズ量は、メモリバンク400522の残りのメモリ領域より小さいため、その関数群F_A3に含まれる関数は、メモリバンク400523に集中して配置される。
そこで、メモリシステム50に含まれるCPUによって、関数の呼出し状態に応じて、メモリバンクの電源状態を制御すれば、通常電力供給状態とするメモリバンク数を減少させることができる。
As described above, in the memory system 50, when the allocation method for allocating the storage area to the code included in the program of the third embodiment is performed, the function group F_A1 (400518) having the function A1 * B1 * C1 * D1 as a representative function is stored in the memory. Since it is larger than the memory area of the bank 400521, the allocation is concentrated on two memory banks, the memory bank 400521 and the memory bank 400522. In addition, since the total code size amount of the function group F_A2 having the function A2 as a representative function is smaller than the memory area of the memory bank 4000052, the functions included in the function group F_A2 are concentrated in one memory bank 4000052. The Further, since the total code size amount of the function group F_A3 having the function A3 as a representative function is smaller than the remaining memory area of the memory bank 4000052, the functions included in the function group F_A3 are concentrated on the memory bank 4000052. The
Therefore, if the CPU included in the memory system 50 controls the power supply state of the memory bank in accordance with the function call state, the number of memory banks in the normal power supply state can be reduced.

実施例3で示したプログラムは、最大関数群をメモリバンクに割り当てた後、新たなメモリバンクを使用しない範囲で、呼出し関係のある関数群(最大関数群との呼出し頻度が0より真に大きい関数群)を割り当てる方式に基づくものである。この方式は、複数のメモリバンクに割り当てられる関数群を削減できるという利点があるものの、この方式によりいくつかの関数群を割り当てた結果、各メモリバンクとも残りメモリ領域サイズは少量となり、残りの関数群が多数のメモリバンクに割り当てられるという状況が発生しうる。この状況となり、かつその関数群が少数の関数で構成されており(そのため、該当関数群の各関数に割り当てられるメモリバンク数も多くなる)、それらの関数の実行時間がほかの関数に比べて長い場合には、消費電力の削減効果が減少する場合もあり得る。
図20は実施例3に示したプログラムを実施した場合に、消費電力の削減効果が減少する例を示す。
メモリ割当工程S4005を実行するにあたり、合計コードサイズ計算工程S3703、呼出し頻度計算工程S3704において、図19Aから図19Cに示すような結果が得られているとする。ただし、図19Bに示す関数群F_A1の合計コードサイズは2.5KB、関数群F_A2の合計コードサイズは7KB、関数群F_A3の合計コードサイズは3KBであるとする。また、図19Dに示されている実施例3のメモリシステム50の構成要素に加えて、メモリシステム50の構成要素として、メモリ容量1KBのメモリバンク400525が追加されている。さらに、図20に係わるメモリシステム50においては、メモリバンク400525にはメイン関数400517が配置されており、メモリバンク400524はメモリバンク400523とアドレスが連続したメモリ領域を有している。
メイン関数400517、関数群F_A1(400518)、関数群F_A2(400519)、関数群F_A3(400520)、メモリバンク400521、メモリバンク400522、及び、メモリバンク400523については、図19Dと同様なものであるので、説明を省略する。
図20に係わるメモリシステム50において、実施例3にメモリ割り当て工程S4005を行うと、まず、最大関数群として関数群F_A2(400519)が設定され、メモリバンク400521、400522に割り当てられる。このとき、メモリバンク400521、400522の残りメモリ領域サイズ(m_rest[M])はそれぞれ、0KB、1KBとなる。最大関数群F_Max(=関数群F_A2)から呼び出し頻度が0でない関数群であって、メモリバンク領域に割り当てられていない関数群として、関数群F_A3(400520)が存在するが、メモリバンク400522の残りメモリ領域サイズ(m_rest[M])は1KBであり、関数群F_A3(400520)の合計コードサイズ(3KB)より小さいため、関数群F_A3はこの時点ではメモリバンクに割り当てられない。
続いて、最大関数群として関数群F_A3(400520)が設定され、メモリバンク400523に割り当てられる。このときのメモリバンク400523の残りメモリ領域サイズ(m_rest[M])は1KBとなる。最大関数群F_Max(=関数群F_A3)から呼び出し頻度が0でない関数群であって、メモリバンク領域に割り当てられていない関数群は存在しないため、再び最大関数群の選択を実行する。
続いて、最大関数群として関数群F_A1(400518)が設定されるが、この時点でのメモリバンク400521、400522、400523、400524の残りメモリ領域サイズ(m_rest[M])はそれぞれ、0KB、1KB、1KB、1KBである。したがって、関数群F_A1(400518)は、メモリバンク400522、400523、400524にわたって配置されることとなる。
ここでもし、関数群F_A1(400518)の関数を実行している間、メモリバンク400522、400523、400524が通常電力供給状態となってしまうと、通常電力供給状態のメモリバンクが多くなるため、関数群F_A1(400518)の関数実行中の消費電力は高くなる。さらに、関数群F_A1(400518)の全プログラム中における実行時間の比率が高いと、プログラム全体の消費電力も高くなる。
このように、実施例1のメモリシステム50において、以下に示す実施例4のプログラムを実行して、メモリバンクに空きが発生しないように割り当てることが考えられる。
実施例4において示すメモリ割当工程S4105を、実施例2のメモリ割当工程S37中の電力制御有りメモリ割当部S3705に代えて、実行することにより、
実施例3のプログラムの場合、多数のメモリバンクに割り当てられ、かつその多数のメモリバンクに割り当てられた関数群の実行時間が長くなる場合に、消費電力を削減することができる。
図21Aは、実施例4に係わるメモリ割当工程S4105を示す。実施例4のメモリ割当工程S4105の実行は、スタート以下、次の工程を行うことにより実行される。
まず、残りメモリ領域サイズ変数初期化工程S410521を行う。残りメモリ領域サイズ変数初期化工程S410521は残りメモリ領域サイズを記憶する変数m_restの値を初期化する工程である。すなわち、電力制御を行わないメモリバンクMに対しては、m_rest(m_rest[M])の値を0、それ以外のメモリバンクMに対するm_restの値(m_rest[M])をメモリバンクMの容量と初期化する。
次いで、合計コードサイズ最大の関数群を選択する工程S410522を行う。合計コードサイズ最大の関数群を選択する工程S410522は、合計コードサイズテーブルを走査し、合計コードサイズ最大の関数群を選び、最大関数群F_Maxとして設定する。
次いで、メモリバンク認識工程S410523を行う。メモリバンク認識工程S410523は残りメモリ領域サイズが大きい順にM1、M2、・・・、Mn(nは正の整数)と名付ける工程である。なお、残りメモリ領域サイズが同一値であるメモリバンクが存在する場合は、同一値であるメモリバンク同士、同一値であるメモリバンクの次に残りメモリ領域サイズが多いメモリバンク、および、同一値であるメモリバンクの次に残りメモリ領域サイズが少ないメモリバンクが、可能な限りアドレスが連続するように名付けると、より望ましい結果となる。
次いで、最大関数群F_Maxをメモリバンクに割り当てるルーチンS410524を行う。なお、最大関数群F_Maxをメモリバンクに割り当てるルーチンS410524は、図21を用いて別途説明する。
In the program shown in the third embodiment, after a maximum function group is assigned to a memory bank, a function group (call frequency with the maximum function group is truly greater than 0) within a range in which a new memory bank is not used. This is based on a method for assigning a function group. Although this method has the advantage that the function groups assigned to multiple memory banks can be reduced, as a result of assigning several function groups by this method, the remaining memory area size is small for each memory bank, and the remaining functions A situation can occur where a group is assigned to multiple memory banks. This is the situation, and the function group is composed of a small number of functions (therefore, the number of memory banks allocated to each function in the corresponding function group also increases), and the execution time of these functions is compared to other functions. If it is long, the effect of reducing power consumption may be reduced.
FIG. 20 shows an example in which the power consumption reduction effect decreases when the program shown in the third embodiment is executed.
In executing the memory allocation step S4005, it is assumed that the results shown in FIGS. 19A to 19C are obtained in the total code size calculation step S3703 and the call frequency calculation step S3704. However, the total code size of the function group F_A1 illustrated in FIG. 19B is 2.5 KB, the total code size of the function group F_A2 is 7 KB, and the total code size of the function group F_A3 is 3 KB. In addition to the components of the memory system 50 according to the third embodiment illustrated in FIG. 19D, a memory bank 4000052 having a memory capacity of 1 KB is added as a component of the memory system 50. Furthermore, in the memory system 50 according to FIG. 20, a main function 400517 is arranged in the memory bank 40055, and the memory bank 4000052 has a memory area in which addresses are continuous with the memory bank 4000052.
The main function 400517, the function group F_A1 (400518), the function group F_A2 (400519), the function group F_A3 (400520), the memory bank 40000521, the memory bank 40000522, and the memory bank 4000052 are the same as those in FIG. 19D. The description is omitted.
In the memory system 50 according to FIG. 20, when the memory allocation step S4005 is performed in the third embodiment, first, the function group F_A2 (400519) is set as the maximum function group and is allocated to the memory banks 40051 and 4000052. At this time, the remaining memory area sizes (m_rest [M]) of the memory banks 400521 and 400522 are 0 KB and 1 KB, respectively. A function group F_A3 (400520) exists as a function group that is not called from the maximum function group F_Max (= function group F_A2) and is not assigned to the memory bank area. Since the memory area size (m_rest [M]) is 1 KB and is smaller than the total code size (3 KB) of the function group F_A3 (400520), the function group F_A3 is not assigned to the memory bank at this time.
Subsequently, a function group F_A3 (400520) is set as the maximum function group and is assigned to the memory bank 4000052. At this time, the remaining memory area size (m_rest [M]) of the memory bank 400533 is 1 KB. Since there is no function group that is not called from the maximum function group F_Max (= function group F_A3) and is not assigned to the memory bank area, the selection of the maximum function group is executed again.
Subsequently, the function group F_A1 (400518) is set as the maximum function group. At this time, the remaining memory area sizes (m_rest [M]) of the memory banks 400521, 40000522, 40000523, and 40000524 are 0 KB, 1 KB, respectively. 1 KB and 1 KB. Therefore, the function group F_A1 (400518) is arranged over the memory banks 400522, 40000523, and 400524.
Here, if the memory banks 400522, 40000523, and 400524 are in the normal power supply state while the function of the function group F_A1 (400518) is being executed, the number of memory banks in the normal power supply state increases. The power consumption during the function execution of the group F_A1 (400518) becomes high. Furthermore, if the ratio of the execution time in all the programs of the function group F_A1 (400518) is high, the power consumption of the entire program also increases.
As described above, in the memory system 50 according to the first embodiment, it is conceivable to execute the following program according to the fourth embodiment and allocate the memory bank so that no space is generated.
By executing the memory allocation step S4105 shown in the fourth embodiment instead of the memory allocation unit with power control S3705 in the memory allocation step S37 of the second embodiment,
In the case of the program of the third embodiment, the power consumption can be reduced when the execution time of a function group assigned to a large number of memory banks and assigned to the large number of memory banks becomes long.
FIG. 21A shows a memory allocation step S4105 according to the fourth embodiment. The execution of the memory allocation step S4105 of the fourth embodiment is executed by performing the following steps after the start.
First, the remaining memory area size variable initialization step S410521 is performed. The remaining memory area size variable initialization step S410521 is a process for initializing the value of the variable m_rest that stores the remaining memory area size. That is, for the memory bank M that is not subjected to power control, the value of m_rest (m_rest [M]) is 0, and the value of m_rest (m_rest [M]) for the other memory banks M is the capacity of the memory bank M. initialize.
Next, step S410522 for selecting a function group having the maximum total code size is performed. In step S410522 for selecting the function group having the maximum total code size, the total code size table is scanned, the function group having the maximum total code size is selected, and set as the maximum function group F_Max.
Next, a memory bank recognition step S410523 is performed. The memory bank recognition step S410523 is a step of naming M1, M2,..., Mn (n is a positive integer) in descending order of the remaining memory area size. If there are memory banks with the same value of the remaining memory area size, the memory banks with the same value, the memory bank with the remaining memory area size next to the memory bank with the same value, and the same value If a memory bank having the remaining memory area size next to a certain memory bank is named so that addresses are continuous as much as possible, a more desirable result is obtained.
Next, a routine S410524 for assigning the maximum function group F_Max to the memory bank is performed. The routine S410524 for assigning the maximum function group F_Max to the memory bank will be separately described with reference to FIG.

次いで、呼び出し頻度認識により集合Γを生成する工程S410525を行う。呼び出し頻度認識により集合Γを生成する工程S410525は最大関数群F_Maxから呼び出し関係にあり、かつ、メモリバンクへ未割り当ての関数群Fを集合Γとする工程である。なお、最大関数群F_Maxから呼び出し関係にあることの判定は、最大関数群F_Maxからの呼び出し頻度Q(F_Max,F)が0より真に大きいことにより行う。
次いで、集合Γが空集合か否かを判断する工程S400526を行う。集合Γが空であるときは、メモリ割当が終了したかを判断する工程S410527に進む。一方、集合Γが空でないときは、呼出し頻度最大の関数群F_Relを選択する工程S410528へ進む。
次いで、呼出し頻度最大の関数群F_Relを選択する工程S410528を行う。呼出し頻度最大の関数群F_Relを選択する工程S410528は、集合Γに含まれる関数の内、最大関数群F_Maxとの呼出し頻度最大の関数群を選び関数群F_Relとして設定する工程である。但し、同一呼出し頻度の関数群が複数存在する場合は、呼出し回数最大関数群F_Relの候補となる関数群の内、コードサイズが最大となる関数群を選択する。
次いで、関数群F_Relについてメモリバンクに割り当てるルーチンS410529を行う。なお、関数群F_Relをメモリバンクに割り当てるルーチンS410529は、図21Bを用いて別途説明する。
Next, step S410525 for generating the set Γ by calling frequency recognition is performed. The step S410525 for generating the set Γ by calling frequency recognition is a step for setting the function group F that is in a calling relationship from the maximum function group F_Max and is not assigned to the memory bank to the set Γ. Note that the determination of the call relationship from the maximum function group F_Max is made when the call frequency Q (F_Max, F) from the maximum function group F_Max is truly greater than zero.
Next, step S40056 for determining whether or not the set Γ is an empty set is performed. When the set Γ is empty, the process proceeds to step S410527 for determining whether the memory allocation is completed. On the other hand, when the set Γ is not empty, the process proceeds to step S410528 for selecting the function group F_Rel having the maximum calling frequency.
Next, step S410528 for selecting the function group F_Rel having the maximum calling frequency is performed. The step S410528 of selecting the function group F_Rel with the maximum calling frequency is a process of selecting the function group with the maximum calling frequency with the maximum function group F_Max from the functions included in the set Γ and setting it as the function group F_Rel. However, when there are a plurality of function groups having the same call frequency, the function group having the maximum code size is selected from the function groups that are candidates for the function group F_Rel having the maximum number of calls.
Next, a routine S410529 for assigning the function group F_Rel to the memory bank is performed. Note that the routine S410529 for assigning the function group F_Rel to the memory bank will be separately described with reference to FIG. 21B.

次いで、集合Γ更新工程S410530を行う。集合Γ更新工程S410530は、最大関数群F_Maxから呼び出し関係にある関数群の集合Γから、関数群F_Relを除いて、集合Γを更新する工程である。
次いで、集合Γが空集合か否かを判断する工程S410526に戻る。集合Γが空になるまで、呼出し頻度最大の関数群F_Relを選択する工程S410528から集合Γ更新工程S410530までの工程を繰り返す。次いで、集合Γが空になると、メモリ割当が終了したかを判断する工程S410527へ進む。
Next, a set Γ update step S410530 is performed. The set Γ update step S410530 is a step of updating the set Γ by removing the function group F_Rel from the function group set Γ having a calling relationship from the maximum function group F_Max.
Next, the process returns to step S410526 for determining whether the set Γ is an empty set. Until the set Γ becomes empty, the processes from the step S410528 for selecting the function group F_Rel having the maximum calling frequency to the set Γ update step S410530 are repeated. Next, when the set Γ is empty, the process proceeds to step S410527 for determining whether the memory allocation is completed.

メモリ割当が終了したかを判断する工程S410527は、最大関数群F_Maxに含まれる関数及び最大関数群F_Maxと呼び出し関係にある関数群に含まれる関数をメモリ領域に割り当てた後、さらに合計コードサイズテーブル中にメモリ領域に割り当てられていない他の関数群が存在するか否かを判断する工程である。ここで、合計コードサイズテーブル中にさらに関数群が存在し、その関数群について、メモリ領域の割当が終了していないと判断する場合は、合計コードサイズ最大の関数群を選択する工程S410522を行う。
一方、合計コードサイズテーブル中に関数が存在しない場合は、実施例4に係わるメモリ割当工程S4105を終了する。
In step S410527 for determining whether the memory allocation has been completed, a function included in the maximum function group F_Max and a function included in the function group having a calling relationship with the maximum function group F_Max are allocated to the memory area, and then the total code size table This is a step of determining whether or not there is another function group not allocated to the memory area. Here, when it is determined that there are further function groups in the total code size table and the allocation of the memory area is not completed for the function groups, step S410522 for selecting the function group having the maximum total code size is performed. .
On the other hand, if there is no function in the total code size table, the memory allocation step S4105 according to the fourth embodiment is terminated.

図21Bは、最大関数群F_Maxをメモリバンクに割り当てるルーチンS410524を説明する図である。最大関数群F_Maxをメモリバンクに割り当てるルーチンS410524は以下の工程を含む。
まず、関数群すべてを割り当て可能であるメモリバンクを認識する工程S410524aを行う。関数群すべてを割り当て可能であるメモリバンクを認識する工程S410524aは、メモリバンク認識工程S410523により認識された、アドレスが連続するM1、M2、・・・、Mnについて、1番目からm番目(mはn≧mとなる正の整数)までのメモリ領域を加算した結果得られるメモリ領域が、最大関数群F_Maxのコードサイズ以上となる最小のmを検出する工程である。
次いで、メモリ領域割当工程S410524bを行う。メモリ領域割当工程S410524bはM1からMmまでのメモリバンクに、最大関数群F_Maxを割り当てる工程である。
次いで、残りメモリ領域サイズ更新工程S410524cを行う。残りメモリ領域サイズ更新工程S410524cは、m_rest[Mi]=0 (i=1、・・・、m−1)とするとともに、m_rest[Mm]=(m_rest[M1]+m_rest[M2]+・・・+m_rest[Mm])−s(F_Max)とする工程である。
なお、上記の最大関数群F_Maxをメモリバンクに割り当てるルーチンS410524は、最大関数群F_Maxについて処理をするルーチンであったが、関数群F_Relをメモリバンクに割り当てるルーチンS410529は、最大関数群F_Maxのかわりに、関数群F_Relについて、関数群F_Maxをメモリバンクに割り当てるルーチンS410524と同様の工程を行うルーチンである。
FIG. 21B is a diagram for explaining a routine S410524 for assigning the maximum function group F_Max to the memory bank. The routine S410524 for assigning the maximum function group F_Max to the memory bank includes the following steps.
First, step S410524a for recognizing a memory bank to which all function groups can be assigned is performed. In step S410524a for recognizing a memory bank to which all the function groups can be assigned, M1, M2,..., Mn having consecutive addresses recognized in the memory bank recognition step S410523 are first to mth (m is This is a step of detecting the minimum m in which the memory area obtained as a result of adding the memory areas up to (positive integer satisfying n ≧ m) is not less than the code size of the maximum function group F_Max.
Next, a memory area allocation step S410524b is performed. The memory area allocating step S410524b is a step of allocating the maximum function group F_Max to the memory banks M1 to Mm.
Next, a remaining memory area size update step S410524c is performed. The remaining memory area size update step S410524c sets m_rest [Mi] = 0 (i = 1,..., M−1) and m_rest [Mm] = (m_rest [M1] + m_rest [M2] +. + M_rest [Mm]) − s (F_Max).
The routine S410524 for assigning the maximum function group F_Max to the memory bank is a routine for processing the maximum function group F_Max. However, the routine S410529 for assigning the function group F_Rel to the memory bank is used instead of the maximum function group F_Max. , The function group F_Rel is a routine for performing the same process as the routine S410524 for assigning the function group F_Max to the memory bank.

図22は、実施例4に係わるメモリ割当工程S4105により関数を各メモリバンクに割り当てる具体例を示す。
メモリ割当工程S4105を実行するにあたり、合計コードサイズ計算工程S3703、呼出し頻度計算工程S3704において、図19Aから図19Cに示すような結果が得られているとする。ただし、図19Bに示す関数群F_A1の合計コードサイズは2.5KB、関数群F_A2の合計コードサイズは7KB、関数群F_A3の合計コードサイズは3KBであるとする。また、図19Dに示されている実施例3のメモリシステム50の構成要素に加えて、メモリシステム50の構成要素として、メモリ容量1KBのメモリバンク400525が追加されている。さらに、実施例4に係わるメモリシステム50においては、メモリバンク400525にはメイン関数400517が配置されており、メモリバンク400524はメモリバンク400523とアドレスが連続したメモリ領域を有している。
メイン関数400517、関数群F_A1(400518)、関数群F_A2(400519)、関数群F_A3(400520)、メモリバンク400521、メモリバンク400522、及び、メモリバンク400523については、図19Dと同様なものであるので、説明を省略する。
上記のメモリシステム50において、実施例4に係わるメモリ割当工程S4105を行うと、合計コードサイズ最大の関数群を選択する工程S410522の実行により、まず、関数群F_A2が合計コードサイズ最大の関数群F_Maxとして選択される。
次いで、最大関数群F_Maxをメモリバンクに割り当てるルーチンS410524が実行されると、メモリバンク400521、400522のメモリ容量を加算した結果、最大関数群F_Maxのコードサイズを超えることが検出される(関数群すべてを割当可能であるメモリバンクを認識する工程S410524a)。次いで、メモリバンク400521、400522、400523、400524の残りメモリ領域サイズが更新される(残りのメモリ領域の更新工程S410524c)。
次いで、呼び出し頻度認識工程S410525を行う。その結果、未だメモリバンクへの割当が行われておらず、関数群F_Max(現時点で関数群F_A2)から呼び出し頻度が0でない、関数群F_A3(400520)を含む集合Γが設定される。
次いで、集合Γが空集合か否かを判断する工程S400526を行う。集合Γは空でないので、呼出し頻度最大の関数群F_Relを選択する工程S410528を実行し、関数群F_A3を関数群F_Relとし、メモリバンクに割り当てるルーチンS410529を行う。その結果、関数群F_A3はメモリバンク400523に割当られる。
次いで、再び、集合Γが空集合か否かを判断する工程S400526を行う。集合Γは空なので、関数群はすべて割当済かを判断する工程S410527を実行する。メモリバンクに割り当てられていない関数群F_A1(400518)が存在するので、合計コードサイズ最大の関数群を選択する工程S410522に進む。
次いで、合計コードサイズ最大の関数群を選択する工程S410522を行い関数群F_A1(400518)を関数群F_Maxとして選択する。
次いで、メモリバンク認識工程S410523、関数群F_Maxをメモリバンクに割り当てるルーチンS410524を行い、メモリバンク400523、400524に現時点での関数群F_Maxである関数群F_A1(400518)が割り当てられる。
次いで、呼び出し頻度認識工程S410525を行う。合計コードサイズ最大の関数群F_Maxを関数群F_A1とする場合、図19Cより、集合Γは空となる。
次いで、再び、集合Fが空集合か否かを判断する工程S400526を行う。集合Fは空なので、関数群はすべて割当済かを判断する工程S410527を実行する。すべての関数群はメモリバンクに割当られていると判断されるので、実施例4のメモリ割当工程S4105は終了する。
FIG. 22 shows a specific example in which a function is allocated to each memory bank in the memory allocation step S4105 according to the fourth embodiment.
In executing the memory allocation step S4105, it is assumed that the results shown in FIGS. 19A to 19C are obtained in the total code size calculation step S3703 and the call frequency calculation step S3704. However, the total code size of the function group F_A1 illustrated in FIG. 19B is 2.5 KB, the total code size of the function group F_A2 is 7 KB, and the total code size of the function group F_A3 is 3 KB. In addition to the components of the memory system 50 according to the third embodiment illustrated in FIG. 19D, a memory bank 4000052 having a memory capacity of 1 KB is added as a component of the memory system 50. Further, in the memory system 50 according to the fourth embodiment, the main function 400517 is disposed in the memory bank 40055, and the memory bank 4000052 has a memory area in which addresses are continuous with the memory bank 4000052.
The main function 400517, the function group F_A1 (400518), the function group F_A2 (400519), the function group F_A3 (400520), the memory bank 40000521, the memory bank 40000522, and the memory bank 4000052 are the same as those in FIG. 19D. The description is omitted.
When the memory allocation step S4105 according to the fourth embodiment is performed in the memory system 50 described above, first, the function group F_A2 is the function group F_Max having the maximum total code size by executing the step S410522 that selects the function group having the maximum total code size. Selected as.
Next, when the routine S410524 for allocating the maximum function group F_Max to the memory bank is executed, it is detected that the code size of the maximum function group F_Max is exceeded as a result of adding the memory capacities of the memory banks 400521 and 400522 (all function groups Step S410524a) for recognizing a memory bank to which can be assigned. Next, the remaining memory area size of the memory banks 40000521, 40000522, 40000523, and 40000524 is updated (remaining memory area updating step S410524c).
Next, a call frequency recognition step S410525 is performed. As a result, a set Γ including the function group F_A3 (400520) that is not yet assigned to the memory bank and whose calling frequency is not 0 from the function group F_Max (currently the function group F_A2) is set.
Next, step S40056 for determining whether or not the set Γ is an empty set is performed. Since the set Γ is not empty, step S410528 is executed to select the function group F_Rel with the highest call frequency, and the routine S410529 is performed, with the function group F_A3 as the function group F_Rel and assigned to the memory bank. As a result, the function group F_A3 is assigned to the memory bank 4000052.
Next, step S40056 for determining whether the set Γ is an empty set is performed again. Since the set Γ is empty, step S410527 for determining whether all the function groups have been assigned is executed. Since there is a function group F_A1 (400518) not assigned to the memory bank, the process proceeds to step S410522 for selecting a function group having the maximum total code size.
Next, step S410522 for selecting the function group having the maximum total code size is performed, and the function group F_A1 (400518) is selected as the function group F_Max.
Next, a memory bank recognition step S410523 and a routine S410524 for assigning a function group F_Max to a memory bank are performed, and a function group F_A1 (400518) which is the current function group F_Max is assigned to the memory banks 40000523 and 40000524.
Next, a call frequency recognition step S410525 is performed. When the function group F_Max having the maximum total code size is the function group F_A1, the set Γ is empty from FIG. 19C.
Next, step S40056 for determining whether the set F is an empty set is performed again. Since the set F is empty, step S410527 for determining whether all the function groups have been assigned is executed. Since it is determined that all the function groups are allocated to the memory bank, the memory allocation step S4105 of the fourth embodiment ends.

以上より、メモリシステム50において、実施例4のプログラムに含まれるコードに記憶領域を割り当てる割当方法を実施した場合、以下のような動作が行われる。まず、最大関数群(未だメモリバンクへの割当が行われていない関数群のうち合計コードサイズ量が最大であるもの)と、その最大関数から呼び出し関係にある未だメモリバンクへの割当が行われていない関数群の合計コードサイズ量より、メモリ領域が大きくなる複数のメモリバンクを検出する。その後、順次、最大関数群と、その最大関数群から呼び出し関係にある未だメモリバンクへの割当が行われていない関数群が、上記で検出した複数のメモリバンクに配置される。
そうすると、メモリシステム50に含まれるCPUによって、最大関数及びその最大関数から呼出される関係にある関数について処理が行われる場合、通常電力供給状態とするメモリバンクを容易に特定することができる。その結果、余分なメモリバンクを通常電力状態とすることがなくなるため、通常電力供給状態とするメモリバンク数を減少させることができる。従って、メモリバンクが消費する電力を削減することができる。
また、アドレスが連続していないメモリ領域に配置されていると、通常電力供給状態と、そうでない状態とを切り替える場合に、CPUは、数回の命令を必要とする。しかし、最大関数及びその最大関数から呼出される関係にある関数が、アドレスが連続しているメモリ領域に配置されている場合は、通常電力供給状態と、そうでない状態とを切り替える場合に、CPUは、一括して1回の命令で行える。従って、アドレスが連続している場合は、CPUの負荷を軽減でき、CPUの消費電力を削減することができる。
As described above, in the memory system 50, when the allocation method for allocating the storage area to the code included in the program of the fourth embodiment is performed, the following operation is performed. First, the maximum function group (the function group that has not been allocated to the memory bank yet has the largest total code size) and the allocation from the maximum function to the memory bank that is still in the calling relationship are performed. A plurality of memory banks having a memory area larger than the total code size amount of the function group not yet detected are detected. Thereafter, the maximum function group and the function group that has not yet been assigned to the memory bank in the calling relation from the maximum function group are sequentially arranged in the plurality of memory banks detected above.
Then, when the CPU included in the memory system 50 processes the maximum function and the function called from the maximum function, it is possible to easily specify the memory bank to be in the normal power supply state. As a result, the extra memory banks are not brought into the normal power state, and the number of memory banks in the normal power supply state can be reduced. Therefore, the power consumed by the memory bank can be reduced.
In addition, if the addresses are arranged in non-contiguous memory areas, the CPU needs several instructions when switching between the normal power supply state and the state where the addresses are not. However, when the maximum function and the function called from the maximum function are arranged in the memory area where the addresses are continuous, the CPU is used when switching between the normal power supply state and the state where it is not. Can be performed in one batch. Therefore, when the addresses are continuous, the load on the CPU can be reduced, and the power consumption of the CPU can be reduced.

以下に本発明の特徴を付記する。
(付記1)
プロセッサに読み込まれたプログラム中の関数間の呼び出し関係を、プロセッサが抽出する工程と、
前記関数間の呼出し関係に基づく、関数の呼び出し連鎖に沿って、前記呼出し関係を追跡していき、一度呼出された関数が再度呼出された場合に、一度目の呼出しから2度目の呼出しまでの間に経由した関数群を再帰呼出し部とする再帰呼出し抽出工程と、
前記再帰呼出し部を表す前記プログラムに含まれるコードを、供給される電圧状態を独立して切替可能なメモリバンクに、前記プロセッサが、割り当てるコード割当工程と、
を備えることを特徴とするプログラムに含まれるコードをメモリ領域に割り当てる割当方法。
(付記2)
前記コード割当工程において、前記プロセッサは、前記再帰呼出し部を表す前記プログラムに含まれるコードを、一体として、一つの前記メモリバンクに割り当てることを特徴とする、プログラムに含まれるコードをメモリ領域に割り当てる付記1記載の割当方法。
(付記3)
前記コード割当工程において、前記プロセッサは、前記再帰呼出し部を表す前記プログラムに含まれるコードを、一体として、アドレスが連続する2以上の前記メモリバンクに割り当てることを特徴とする、プログラムに含まれるコードをメモリ領域に割り当てる付記1記載の割当方法。
(付記4)
関数を表すコードを含むプログラムを読込むことによって、動作可能なプロセッサと、
前記プロセッサからの制御によって、供給される電圧状態を独立して切替可能なメモリバンクと、を備え、
前記プロセッサは
前記プロセッサに読み込まれた前記プログラム中の関数間の呼び出し関係を抽出する機能と、
前記関数間の呼出し関係に基づく、関数の呼び出し連鎖に沿って、前記呼出し関係を追跡していき、一度呼出された関数が再度呼出された場合に、一度目の呼出しから2度目の呼出しまでの間に経由した関数群を再帰呼出し部とする機能と、
前記再帰呼出し部を表す前記プログラムに含まれるコードを、供給される電圧状態を独立して切替可能なメモリバンクに、前記プロセッサが、割り当てる機能と、を有することを特徴とするメモリシステム。
(付記5)
前記メモリバンクの電圧状態を、前記プロセッサからの命令を受けて、設定する制御レジスタと、
前記制御レジスタからの信号を受けて、前記メモリバンクの電圧状態を制御する電源制御回路と、をさらに備えることを特徴とする付記4記載のメモリシステム。
(付記6)
プロセッサとメモリバンクを備えるメモリシステムにおいて、
ソースプログラムを前記プロセッサに読み込みこませ、前記ソースプログラムをアセンブリコード又はオブジェクトに変換するコンパイル工程と、
メモリバンクのオンオフを制御するアセンブリコード又はオブジェクトを前記プロセッサが検出する制御位置算出工程と(制御位置算出工程S2)、
前記プロセッサに読み込まれたプログラム中の関数間の呼び出し関係を、プロセッサが抽出する工程と、
前記関数間の呼出し関係に基づく、関数の呼び出し連鎖に沿って、前記呼出し関係を追跡していき、一度呼出された関数が再度呼出された場合に、一度目の呼出しから2度目の呼出しまでの間に経由した関数群を再帰呼出し部とする再帰呼出し抽出工程と、
前記プロセッサが、前記プログラムに含まれる、前記再帰呼出し部を表すアセンブリコード又はオブジェクトを、供給される電圧状態を独立して切替可能な前記メモリバンクに割り当て、前記再帰呼出し部を表すアセンブリコード又はオブジェクトを格納した場所を示す前記メモリバンクのアドレスをメモリマップ情報として出力するコード割当工程と、
前記メモリマップ情報に基づいて前記メモリバンクのオンオフを制御するアセンブリコード又はオブジェクトの位置を修正する工程と、を備えることを特徴とする電源制御入り実行プログラムの生成方法。
The features of the present invention are described below.
(Appendix 1)
A process in which the processor extracts a calling relationship between functions in a program read by the processor;
The call relationship is traced along the function call chain based on the call relationship between the functions, and when the function that has been called once is called again, the call from the first call to the second call is performed. A recursive call extraction step in which a group of functions passed in between is a recursive call part;
A code allocating step for the processor to allocate a code included in the program representing the recursive calling unit to a memory bank capable of independently switching a supplied voltage state;
An allocation method for allocating a code included in a program to a memory area.
(Appendix 2)
In the code allocation step, the processor allocates a code included in the program representing the recursive calling unit as a unit to one of the memory banks, and allocates a code included in the program to a memory area The allocation method according to attachment 1.
(Appendix 3)
In the code allocation step, the processor allocates a code included in the program representing the recursive calling unit as a unit to two or more memory banks having consecutive addresses, and the code included in the program 2. The allocation method according to appendix 1, wherein the allocation is performed in the memory area.
(Appendix 4)
A processor capable of operating by reading a program containing code representing a function;
A memory bank capable of independently switching the voltage state supplied by the control from the processor,
The processor has a function of extracting a call relationship between functions in the program read by the processor;
The call relationship is traced along the function call chain based on the call relationship between the functions, and when the function that has been called once is called again, the call from the first call to the second call is performed. The function group between them as a recursive call part,
A memory system comprising: a function for the processor to allocate a code included in the program representing the recursive calling unit to a memory bank in which a supplied voltage state can be switched independently.
(Appendix 5)
A control register for setting the voltage state of the memory bank in response to an instruction from the processor;
The memory system according to claim 4, further comprising: a power supply control circuit that receives a signal from the control register and controls a voltage state of the memory bank.
(Appendix 6)
In a memory system comprising a processor and a memory bank,
A compiling step of loading a source program into the processor and converting the source program into assembly code or objects;
A control position calculation step in which the processor detects an assembly code or object for controlling on / off of the memory bank (control position calculation step S2);
A process in which a processor extracts a calling relationship between functions in a program read by the processor;
The call relationship is traced along the function call chain based on the call relationship between the functions, and when the function that has been called once is called again, the call from the first call to the second call is performed. A recursive call extraction step in which a group of functions passed in between is a recursive call part;
Assembly code or object representing the recursive call unit, the assembly code or object representing the recursive call unit included in the program assigned to the memory bank that can be switched independently of the supplied voltage state. Code allocation step of outputting the address of the memory bank indicating the location of storing as memory map information;
And a step of correcting an assembly code or object position for controlling on / off of the memory bank based on the memory map information.

本発明によれば、プログラムコードに含まれるコードを記憶領域に割り当てる方法であって、記憶領域の電力状態の制御により消費電力削減させ得る、記憶領域の割り当て状態を実現する方法及びその方法を実行するメモリシステムを提供することができる。   According to the present invention, a method for allocating a code included in a program code to a storage area, realizing a storage area allocation state capable of reducing power consumption by controlling the power state of the storage area, and executing the method A memory system can be provided.

10 メモリユニット
11、12、13、14、15 メモリバンク
20 プロセッサ
30 制御レジスタ群
40 バス
45 電源線
46 電源制御装置
50 メモリシステム
61 関数サイズ情報
62 プログラム
63 再帰呼出し処理済み静的コールグラフ
64 再帰呼出し処理済関数サイズ情報
65 関数縮退情報
66 メモリマップ情報
S31 呼出関係抽出
S32A 再帰呼出抽出
S32B 再帰処理済み静的コールグラフ作成
S33 再帰呼出縮退
S34 メモリ割当
10 memory units 11, 12, 13, 14, 15 memory bank 20 processor 30 control register group 40 bus 45 power supply line 46 power supply control device 50 memory system 61 function size information 62 program 63 recursive call processed static call graph 64 recursive call Processed function size information 65 Function degeneration information 66 Memory map information S31 Call relation extraction S32A Recursive call extraction S32B Recursive processed static call graph creation S33 Recursive call degeneration S34 Memory allocation

Claims (5)

プロセッサに読み込まれたプログラム中の関数間の呼び出し関係を、プロセッサが抽出する工程と、
前記関数間の呼出し関係に基づく、関数の呼び出し連鎖に沿って、前記呼出し関係を追跡していき、一度呼出された関数が再度呼出された場合に、一度目の呼出しから2度目の呼出しまでの間に経由した関数群を再帰呼出し部とする再帰呼出し抽出工程と、
前記再帰呼出し部を表す前記プログラムに含まれるコードを、供給される電圧状態を独立して切替可能なメモリバンクに、前記プロセッサが、割り当てるコード割当工程と、
を備えることを特徴とするプログラムに含まれるコードをメモリ領域に割り当てる割当方法。
A process in which the processor extracts a calling relationship between functions in a program read by the processor;
The call relationship is traced along the function call chain based on the call relationship between the functions, and when the function that has been called once is called again, the call from the first call to the second call is performed. A recursive call extraction step in which a group of functions passed in between is a recursive call part;
A code allocating step for the processor to allocate a code included in the program representing the recursive calling unit to a memory bank capable of independently switching a supplied voltage state;
An allocation method for allocating a code included in a program to a memory area.
前記コード割当工程において、前記プロセッサは、前記再帰呼出し部を表す前記プログラムに含まれるコードを、一体として、一つの前記メモリバンクに割り当てることを特徴とする、プログラムに含まれるコードをメモリ領域に割り当てる請求項1記載の割当方法。   In the code allocation step, the processor allocates a code included in the program representing the recursive calling unit as a unit to one of the memory banks, and allocates a code included in the program to a memory area The allocation method according to claim 1. 前記コード割当工程において、前記プロセッサは、前記再帰呼出し部を表す前記プログラムに含まれるコードを、一体として、アドレスが連続する2以上の前記メモリバンクに割り当てることを特徴とする、プログラムに含まれるコードをメモリ領域に割り当てる請求項1記載の割当方法。   In the code allocation step, the processor allocates a code included in the program representing the recursive calling unit as a unit to two or more memory banks having consecutive addresses, and the code included in the program The allocation method according to claim 1, wherein the allocation to the memory area is performed. 関数を表すコードを含むプログラムを読込むことによって、動作可能なプロセッサと、
前記プロセッサからの制御によって、供給される電圧状態を独立して切替可能なメモリバンクと、を備え、
前記プロセッサは
前記プロセッサに読み込まれた前記プログラム中の関数間の呼び出し関係を抽出する機能と、
前記関数間の呼出し関係に基づく、関数の呼び出し連鎖に沿って、前記呼出し関係を追跡していき、一度呼出された関数が再度呼出された場合に、一度目の呼出しから2度目の呼出しまでの間に経由した関数群を再帰呼出し部とする機能と、
前記再帰呼出し部を表す前記プログラムに含まれるコードを、供給される電圧状態を独立して切替可能なメモリバンクに、前記プロセッサが、割り当てる機能と、を有することを特徴とするメモリシステム。
A processor capable of operating by reading a program containing code representing a function;
A memory bank capable of independently switching the voltage state supplied by the control from the processor,
The processor has a function of extracting a call relationship between functions in the program read by the processor;
The call relationship is traced along the function call chain based on the call relationship between the functions, and when the function that has been called once is called again, the call from the first call to the second call is performed. The function group between them as a recursive call part,
A memory system comprising: a function for the processor to allocate a code included in the program representing the recursive calling unit to a memory bank in which a supplied voltage state can be switched independently.
前記メモリバンクの電圧状態を、前記プロセッサからの命令を受けて、設定する制御レジスタと、
前記制御レジスタからの信号を受けて、前記メモリバンクの電圧状態を制御する電源制御回路と、をさらに備えることを特徴とする請求項4記載のメモリシステム。

A control register for setting the voltage state of the memory bank in response to an instruction from the processor;
5. The memory system according to claim 4, further comprising: a power supply control circuit that receives a signal from the control register and controls a voltage state of the memory bank.

JP2011036487A 2011-02-22 2011-02-22 Allocation method for allocating code included in program to memory area and memory system for executing the method Expired - Fee Related JP5598375B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2011036487A JP5598375B2 (en) 2011-02-22 2011-02-22 Allocation method for allocating code included in program to memory area and memory system for executing the method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2011036487A JP5598375B2 (en) 2011-02-22 2011-02-22 Allocation method for allocating code included in program to memory area and memory system for executing the method

Publications (2)

Publication Number Publication Date
JP2012174069A JP2012174069A (en) 2012-09-10
JP5598375B2 true JP5598375B2 (en) 2014-10-01

Family

ID=46976915

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2011036487A Expired - Fee Related JP5598375B2 (en) 2011-02-22 2011-02-22 Allocation method for allocating code included in program to memory area and memory system for executing the method

Country Status (1)

Country Link
JP (1) JP5598375B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103984538B (en) 2014-03-27 2017-04-26 华为技术有限公司 Application scenario identification method, power consumption management method, devices and terminal equipment
WO2021079408A1 (en) * 2019-10-21 2021-04-29 三菱電機株式会社 Software analysis device

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2564653B2 (en) * 1989-08-20 1996-12-18 株式会社ピーエフユー Function rearrangement method
JP2002026803A (en) * 2000-07-12 2002-01-25 Fujitsu Ltd Portable radio terminal device
JP3877518B2 (en) * 2000-12-13 2007-02-07 松下電器産業株式会社 Processor power control device
WO2008090665A1 (en) * 2007-01-25 2008-07-31 Nec Corporation Program parallelizing method and device
JP5551868B2 (en) * 2008-12-17 2014-07-16 富士通株式会社 Executable file creation device
JP5202472B2 (en) * 2009-03-30 2013-06-05 富士通株式会社 Instruction placement program, instruction placement apparatus, and instruction placement method

Also Published As

Publication number Publication date
JP2012174069A (en) 2012-09-10

Similar Documents

Publication Publication Date Title
KR101360512B1 (en) Register allocation with simd architecture using write masks
US9292284B2 (en) Parallel arithmetic device, data processing system with parallel arithmetic device, and data processing program
JP2007293383A (en) Program development support device and method for operating same device
CN110781016B (en) Data processing method, device, equipment and medium
US20230084523A1 (en) Data Processing Method and Device, and Storage Medium
JP5598375B2 (en) Allocation method for allocating code included in program to memory area and memory system for executing the method
JP4865016B2 (en) Processor
CN116010299B (en) Data processing method, device, equipment and readable storage medium
TW201901483A (en) Circuit for performing absolute value of two input values and summing operation
CN115981870A (en) Data processing method and device, storage medium and electronic equipment
CN104133668A (en) Apparatus and method for translating multithread program code
US8484446B2 (en) Microprocessor saving data stored in register and register saving method
JP5671050B2 (en) Dynamic management of random access memory
Haaß et al. Automatic custom instruction identification in memory streaming algorithms
JP5278538B2 (en) Compilation system, compilation method, and compilation program
JPH05101141A (en) High-level composition device
JP4870956B2 (en) Embedded program generation method, embedded program development system, and information table section
JP2020027591A (en) High-level synthesis multiprocessor system and the like
US20070011440A1 (en) Processor and processing method
JP2009020695A (en) Information processing apparatus and system
JP4898365B2 (en) Embedded program development apparatus and program automatic generation method
US20130166887A1 (en) Data processing apparatus and data processing method
JP2007004475A (en) Processor and method for executing program
CN118210736A (en) Cache line alignment method, device, equipment and storage medium
JP2017111662A (en) Electronic controller

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20131106

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20140611

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20140715

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20140728

R150 Certificate of patent or registration of utility model

Ref document number: 5598375

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

LAPS Cancellation because of no payment of annual fees