JP3758991B2 - Method for adjusting the number of execution steps of a target program, adjusting device therefor, and recording medium storing the program - Google Patents

Method for adjusting the number of execution steps of a target program, adjusting device therefor, and recording medium storing the program Download PDF

Info

Publication number
JP3758991B2
JP3758991B2 JP2001126084A JP2001126084A JP3758991B2 JP 3758991 B2 JP3758991 B2 JP 3758991B2 JP 2001126084 A JP2001126084 A JP 2001126084A JP 2001126084 A JP2001126084 A JP 2001126084A JP 3758991 B2 JP3758991 B2 JP 3758991B2
Authority
JP
Japan
Prior art keywords
step number
execution
adjustment
program
steps
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
JP2001126084A
Other languages
Japanese (ja)
Other versions
JP2002323981A (en
Inventor
佳典 羽坂
Original Assignee
Necマイクロシステム株式会社
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Necマイクロシステム株式会社 filed Critical Necマイクロシステム株式会社
Priority to JP2001126084A priority Critical patent/JP3758991B2/en
Publication of JP2002323981A publication Critical patent/JP2002323981A/en
Application granted granted Critical
Publication of JP3758991B2 publication Critical patent/JP3758991B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Description

【0001】
【発明の属する技術分野】
本発明はプログラムの実行ステップ数を調整する方法とその調整装置およびプログラムを記憶した記録媒体に関し、特に目的プログラムの実行ステップ数調整方法とその調整装置および目的プログラムやその実行プログラムを記憶した記録媒体に関する。
【0002】
【従来の技術】
一般に、プログラムの性能を向上させる意味で、コンパイラの最適化を行うことおよびプログラムの実行速度を知ることは、プログラム開発における重要な要素の一つである。
【0003】
このコンパイラは、限られた時間および記録媒体にプログラムを収めるために、プログラムを高速動作させるとともに、プログラムのサイズを小さくすることが理想とされており、通常この為のソースプログラムの変換をコンパイラの最適化と呼んでいる。また、プログラムの実行速度を予測あるいは計測し、その結果によりソースプログラムを修正するか、あるいは実行速度の結果に基づきコンパイラを最適化し直すことが行われている。
【0004】
しかし、このソースプログラムの修正あるいはコンパイラの最適化を行うと、プログラムの実行速度が変化したとき、プログラムの動作に不具合が生じる場合がある。
【0005】
例えば、第一の不具合の例は、プログラムによって動作するCPUに接続された外部回路の動作速度が遅く、そのためにプログラム上に時間待ち処理を挿入した場合に発生する。
【0006】
また、第二の不具合の例は、外部入力を正確に計測したり、あるいは外部出力を正確に行う必要があり、そのためにプログラム上に待ち合せ処理を挿入した場合に発生する。
【0007】
これらの不具合は、タイマ回路を使用して正確に時間計測を行っていたときには発生しないが、時間待ち処理機構や待ち合わせ処理機構がプログラムの命令コード実行ステップ数に依存する形式になっていたときには発生する。本来ならば、タイマ回路を使用して正確に時間計測を行うべきであるが、幾つかの要因によって、プログラムの命令コード実行ステップ数に依存する場合がある。
【0008】
その第一の要因は、ソースプログラムの流用の問題である。例えば、ソースプログラムをCPUに依存するアセンブラ命令や、タイマ回路によって実現したとき、そのソースプログラムのアルゴリズムを修正することになる。しかし、このアルゴリズムの修正を直接行うと、修正が面倒であり、信頼性も乏しくなるため、アルゴリズムの修正に比べて、より信頼性の高い命令コード実行ステップ数の修正に依存してしまうからである。
【0009】
第二の要因は、組み込みシステムなどにおける価格の問題である。一般的に、タイマ回路などをシステムに組み込んだ場合、その分価格が上昇してしまう。近年、CPU性能は向上したものの、それに合わせてプログラムも複雑な機能を組み込むことが要求されており、十分な性能を持ったCPUを使用できないことが多い。
【0010】
要するに、これらの要因により、前述した2つの不具合は無くならない問題であると言える。
【0011】
かかる2つの不具合を抑制させる為に、規模の小さいシステムでは、目的プログラム中の必要な点にトラップ命令を埋め込み、ターゲットシステム上で実際にプログラムを動作させた上で調整を行っている。しかし、プログラムの規模が大きく、調整箇所が多い場合は再コンパイルなどの作業後、何度も調整を繰り返す必要があり時間がかかった。
【0012】
また、例えば特開平11−039155号公報(文献1)や特開平11−296416号公報(文献2)にも開示されているように、静的にソースプログラムを解析し、実行ステップを出力する方法もある。この方法は、コンパイラの最適化によって、実行ステップが変化するため、何度も調整を繰り返す必要がある。しかも、かかる方法は時間がかかり、ターゲットシステム上で行う動的な計測を利用した調整、およびソース解析による静的な調整では、ソースプログラムを何度も修正することが必要であり、ソースプログラムの流用を著しく妨げていた。
【0013】
さらに、動的に計測する方法として、例えば特開平6−282444号公報(文献3)に記載されたコンパイル方法もある。このコンパイル方法は、予め準備された機械語を選択するか、命令数のみを計測するものであり、上述した2つの不具合を発生させないためには不十分である。
【0014】
図16は従来の実行ステップ数調整方法の一例を示すシステム構成図である。図16に示すように、従来の実行ステップ数調整にあたっては、ソースプログラム50よりオブジェクト52を作成するオブジェクト生成部1aと、オブジェクト結合部2aと、実行ステップ数の計測を行う実行部3aとを有している。このオブジェクト生成部1aは、オブジェクト生成手段12と、コード解析ステップ数計測手段13と、アセンブラソース生成手段15とを備え、ソースプログラム50より命令実行ステップ数情報51に基づいてオブジェクト52およびステップ数計測結果61を出力するとともに、アセンブラソース生成手段15よりアセンブラソース60を出力する。またオブジェクト結合部2aは、オブジェクト52をメモリ割付情報55に基づいて結合するオブジェクト結合手段21を備え、実行形式56を出力する。さらに、実行部3aは、実行ステップ数計測手段31を備え、ターゲットシステム34との間の情報授受を行うとともに、外部モデル33および実行形式56により実行ステップ数計測結果59を出力する。
【0015】
このソースプログラム50はC言語,アセンブリ言語などで記述された原始プログラムであり、オブジェクト52はかかる原始プログラムをコンパイラ,アセンブラによって命令コードに変換したオブジェクトコード群である。ここで、命令実行ステップ数情報51は、命令コードと,この命令コードの実行ステップ数とによって構成されている。このオブジェクト52はメモリ割付情報55を元にし、オブジェクト結合手段21によって実行形式56として出力されるが、この実行形式56は実行部3aにおいて実行できるオブジェクトコード群である。一方、ターゲットシステム34は、実行部3aが例えばエミュレータであったときには、メモリや外部装置などのハードウェアであり、また外部モデル33は、実行部3aが例えばシミュレータであったときには、メモリや外部装置などをソフトウェアにより、シミュレーションするための構成と動作を定義されているファイルである。
【0016】
このように、従来の実行ステップ数の調整(文献1)においては、ソースプログラム50を解析し、ステップ数計測結果61をアセンブラソース60に付加して出力することにより、ソースプログラム50の実行ステップ数を予測しようとしている。すなわち、この従来例においては、アセンブラソース60に付加された実行ステップ数によって、ソースプログラム50の修正と、オブジェクト52の生成とを繰返えすことにより、実行ステップ数を調整する必要がある。
【0017】
また、上述したシステムにおいて、文献2に記載したような技術を用いても、文献2では、ソースプログラム50を解析し、ステップ数計測結果61に基づいて、ループ毎のステップ数を求め、ソースプログラム50の実行ステップ数を予測するものであるため、ループ毎の命令数を計測するだけであり、実行ステップ数を求めることはできない。
【0018】
同様に、上述したシステムにおいて、文献3のようなシステムを用いても、文献3では、オブジェクト生成部1aおよびオブジェクト結合部2aの組込み時、またはソースプログラム50を翻訳してオブジェクト52を生成するとき、実行部3aによって命令実行ステップ数情報51を最適なものに更新することはできても、予め準備された命令を選択するだけであるので、実行ステップ数を求めることはできない。
【0019】
したがって、上述した従来例においては、計測技術が不十分であることに加えて、複数の外部装置を接続するシステムの通信部分が、前述したプログラムの命令コード実行ステップ数に依存する構成になっている場合には、すべての機器接続の組合せにおいて、前述したような計測を行い、ソースプログラムの修正を行うことは、プログラムの開発の後段階での評価を長くするという問題がある。さらに、プログラムの開発途中において、CPUに接続するROM,RAM,I/Oなどの外部回路および前述した外部装置は、タイミングが変化することから、結果を簡単に反映することが必要である。
【0020】
以上のことから、アルゴリズムを変更しないで、しかもソースプログラムを修正せずに、上述した2つの不具合の対策を施すこと、再コンパイルなどによる調整時間を短くすること、さらには開発途中における外部回路または外部装置のタイミング調整を簡単に行えることが重要である。
【0021】
図17は従来の他の例を説明するためのコンパイル装置を用いたシステム構成図である。図17に示すように、このシステムは、例えば特開2000−194566号公報(文献4)に記載されているように、オブジェクト生成部にコンパイル装置1bを用いたものであり、ソースプログラム50からオブジェクト52を生成するにあたり、分岐履歴情報ファイル67を使用している。特に、コンパイル装置1bは分岐履歴情報採取コード生成手段63と、分岐パターン解析手段64と、ループ並列化手段65と、ループ最適化手段66とを備え、分岐情報を貯えるためのコードを埋め込み、実行結果を元に最適なオブジェクトプロゲラムを生成することにより、並列化処理における各ループの負荷分散を均等化し、プログラムの性能を向上させるものである。
【0022】
しかし、このコンパイル装置を用いたシステムは、オブジェクトから履歴情報ファイルを作成するため、コンパイル装置1bで再コンパイルを必要とし、実行環境が無いと最適化を行えないという問題がある。しかも、この例は、分岐に関する最適化のみであり、外部回路(ROM,RAM,I/Oなど)や外部装置のタイミング調整を行えないという問題がある。
【0023】
図18は従来のまた別の例を説明するための目的プログラムの最適化を行うCPUとメモリ等の接続構成図である。図18に示すように、この構成例は、例えば特開平7−64799号公報(文献5)に記載されているように、コンパイラで生成した目的プログラムを計算機に試行させ、その試行結果で目的プログラムを最適化させるものである。
【0024】
すなわち、コンパイラが最適化処理中の目的プログラムを第1のCPU75に対応した第1のメモリ76に格納し、そのプログラムの試行の実行をOSに要求する。この要求により、OSは試行モードを設定し、第2のCPU73の試行モード切換スイッチ72を切換えるとともに、目的プログラム試行に際して実行する命令毎に計算機内部の動的状態を格納する実行状況テーブルを第2のCPU73に接続された第2のメモリ77に設定し且つトレース先頭指定レジスタ71を設定する。また、パイプライン制御機構74は、命令の実行毎に実行状況テーブルに計算機の動的状態を自動的に記録する。かかる試行後、その実行状況テーブルの記録内容をコンパイラに渡すと、コンパイラはその記録内容により目的プログラムの未最適化部分の最適化を行う。要するに、この従来例は、第1のCPU75で実行された結果を、第2のCPU73により実行状況テーブルとしての第2のメモリ77の指定位置から保存し、その結果をコンパイラに知らせるものである。
【0025】
しかし、この例においては、コンパイラ最適化処理中に、第1のCPU75で試行の実行をし、その後第2のCPU73が記録する実行状況テーブルを読み出して、再度コンパイラによる最適化を実行するため、コンパイル時間が長くなるという問題がある。また、この例においては、コンパイル時に、特別なハードウェアを必要とするという問題がある。例えば、パイプライン制御機構74から出力される情報を記録するためには、第2のCPU73の性能が、少なくとも第1のCPU75よりも上でないと、記録することはできない。その理由は、プログラムによって第2のメモリ77に保存するための命令が1命令では実行できないからである。このために、かかる従来例においては、外部回路などのタイミング調整を行うことができないことになる。
【0026】
【発明が解決しようとする課題】
上述した図16のシステムにおいては、計測技術が不十分であり、複数の外部装置を接続するシステムの通信部分が、前述したプログラムの命令コード実行ステップ数に依存する構成になっている場合には、すべての機器接続の組合せにおいて計測を行い、ソースプログラムの修正を行わねばならず、プログラム開発の時間を長くするという欠点がある。さらに、プログラムの開発途中において、外部回路などはタイミングが変化することから、結果を簡単に反映することが困難であるという欠点がある。
【0027】
このため、アルゴリズムを変更せずに且つソースプログラムも修正せずに、上述した不具合の対策を施すこと、再コンパイルなどによる調整時間を短くすること、さらには開発途中における外部回路等のタイミング調整を簡単に行うことが困難であるという欠点もある。
【0028】
また、上述した図17および図18のシステムにおいては、プログラムの最適化が目的である。つまり、これらが意図しているのは、プログラムを高速に動作させたり、あるいはプログラムのサイズを小さくすることであり、時間待ちおよび待ち合せを命令コードの挿入によって行っているとき、分岐ルートごとの実行ステップ数を合わせるようなことは、実現できないという欠点がある。
【0029】
本発明の目的は、上述したソースプログラム上に時間待ち処理や待ち合わせ処理を挿入したとき、正確な時間待ちや待ち合わせを実現し、再コンパイルなどによる調整時間を短くするとともに、プログラム開発における外部回路などのタイミング調整を簡単に行うことのできる目的プログラムの実行ステップ数調整方法とその調整装置およびプログラムを記憶した記録媒体を提供することにある。
【0030】
【課題を解決するための手段】
本発明の目的プログラムの実行ステップ数調整方法は、ソースプログラムからターゲットシステム上で実行される目的プログラムを生成する装置における実行ステップ調整方法であって、前記ソースプログラムより命令コードに変換して生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析を行い、その結果によりステップ数調整オブジェクトを生成する第1の手順と、前記生成されたオブジェクトのメモリ割付情報を参照し該メモリ割付情報に基づき前記ステップ数調整オブジェクトを修正する第2の手順と、前記生成されたオブジェクトと前記ステップ数調整オブジェクトを結合し、前記目的プログラムとしての実行形式を生成する第3の手順とを含んで構成される。
【0031】
また、本発明における前記第1の手順は、前記ソースプログラムおよび命令実行ステップ数情報を参照して、前記ステップ数調整オブジェクトと個別ステップ数調整情報とを作成し、前記第2の手順は、前記メモリ割付情報を参照して、前記個別ステップ数調整情報と前記ステップ数調整オブジェクトを修正し、第3の手順は、前記生成されたオブジェクトおよび前記ステップ数調整オブジェクトを結合して前記実行形式および結合ステップ数調整情報を作成するように形成される。
【0032】
本発明の目的プログラムの実行ステップ数調整方法は、ソースプログラムからターゲットシステム上で実行される目的プログラムを生成する装置における実行ステップ調整方法であって、前記ソースプログラムより命令コードに変換して生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析を行い、その結果によりステップ数調整オブジェクトを生成する第1の手順と、前記生成されたオブジェクトのメモリ割付情報を参照し該メモリ割付情報に基づき前記ステップ数調整オブジェクトを修正する第2の手順と、前記生成されたオブジェクトと前記ステップ数調整オブジェクトを結合し、前記目的プログラムとしての実行形式を生成する第3の手順と、前記第3の手順により生成された前記実行形式を前記ステップ数調整情報によって動的解析を行い、その結果により実行ステップ数計測結果を出力する第4の手順と、前記実行ステップ数計測結果を用いて前記ステップ数調整オブジェクトを修正する第5の手順とを含み、前記第5の手順により前記ステップ数調整オブジェクトが修正されたとき、前記第3の手順に戻って前記目的プログラムとしての実行形式を再生成するように形成される。
【0033】
また、本発明における前記第1の手順は、前記第1の手順は、前記ソースプログラムおよび命令実行ステップ数情報を参照して、前記ステップ数調整オブジェクトと個別ステップ数調整情報とを作成し、前記第2の手順は、前記メモリ割付情報を参照して、前記個別ステップ数調整情報と前記ステップ数調整オブジェクトを修正し、第3の手順は、前記生成されたオブジェクトおよび前記ステップ数調整オブジェクトを結合して前記実行形式および結合ステップ数調整情報を作成し、前記第4の手順は、前記結合ステップ数調整情報を用いて、分岐ルートに対する実行ステップ数の計測および不要ステップの削除を行った後に、前記実行ステップ数計測結果を作成し、前記第5の手順は、前記実行ステップ数計測結果を参照し、前記個別ステップ数調整情報と前記ステップ数調整オブジェクトを修正するように形成される。
【0034】
本発明の目的プログラムの実行ステップ数調整方法は、ソースプログラムからターゲットシステム上で実行される目的プログラムを生成する装置における実行ステップ調整方法であって、前記ソースプログラムより命令コードに変換して生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析および前記生成されたオブジェクトのメモリ割付情報の参照を行い、それらの結果によりステップ数調整オブジェクトを生成する第1の手順と、前記生成されたオブジェクトと前記ステップ数調整オブジェクトを結合し、前記目的プログラムとしての実行形式を生成する第2の手順と、前記第2の手順により生成された前記実行形式をステップ数調整情報によって動的解析を行い、その結果により実行ステップ数計測結果を出力する第3の手順と、前記実行ステップ数計測結果により前記ステップ数調整オブジェクトを修正する第4の手順とを含み、前記第4の手順によって前記ステップ数調整オブジェクトが修正されたとき、前記第2の手順に戻って前記目的プログラムを再生成するように構成される。
【0035】
本発明の目的プログラムの実行ステップ数調整装置は、ソースプログラムより命令コードに変換して生成されたオブジェクトを出力し、前記生成されたオブジェクトをメモリ割付情報に基づいて結合することにより、目的プログラムとしての実行形式を作成し、それによって実行ステップ数を計測する目的プログラムの実行ステップ数調整装置において、命令実行ステップ数情報を参照して前記生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析を行うコード解析ステップ数計測手段と,前記コード解析ステップ数計測手段によって得られた静的解析の結果を用い、個別ステップ数調整情報およびステップ数調整オブジェクトを作成するコード解析ステップ数調整手段とを備えるオブジェクト生成部と、前記生成されたオブジェクト,前記ステップ数調整オブジェクト,前記個別ステップ数調整情報を結合し、前記目的プログラムとしての実行形式と結合ステップ数調整情報を出力するオブジェクト結合手段と,前記生成されたオブジェクトのメモリ割付情報を参照し該メモリ割付情報に基づき前記ステップ数調整オブジェクトおよび前記個別ステップ数調整情報を修正するメモリ割付ステップ数調整手段とを備えるオブジェクト結合部とを有して構成される。
【0036】
また、本発明の目的プログラムの実行ステップ数調整装置は、前記オブジェクト結合部で作成された前記実行形式を実行するとともに、前記結合ステップ数調整情報によって分岐ルートごとの実行ステップ数を計測する実行ステップ数計測手段と,前記実行ステップ数計測手段の計測結果から不要ステップを削除し、実行ステップ数計測結果を出力する不要ステップ削除手段とを備える目的プログラムの実行部と、前記実行ステップ数計測結果より分岐ルートごとの実行ステップ数を取出し、調整を行って、前記ステップ数調整オブジェクトと前記個別ステップ数調整情報を修正する実行ステップ数調整手段を備える実行ステップ数更新部とを有し、前記オブジェクト結合手段により、前記実行形式と前記結合ステップ数調整情報を再結合するように形成される。
【0037】
本発明の目的プログラムの実行ステップ数調整装置は、ソースプログラムより命令コードに変換して生成されたオブジェクトを出力し、前記生成されたオブジェクトをメモリ割付情報に基づいて結合することにより、目的プログラムとしての実行形式を作成し、それによって実行ステップ数を計測する目的プログラムの実行ステップ数調整装置において、
命令実行ステップ数情報を参照して前記生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析を行うコード解析ステップ数計測手段と,前記コード解析ステップ数計測手段によって得られた静的解析の結果を用い、個別ステップ数調整情報およびステップ数調整オブジェクトを作成するコード解析ステップ数調整手段と,前記生成されたオブジェクトのメモリ割付情報を参照し該メモリ割付情報に基づき前記ステップ数調整オブジェクトおよび前記個別ステップ数調整情報を修正するメモリ割付ステップ数調整手段とを備えるオブジェクト生成部と、前記生成されたオブジェクト,前記ステップ数調整オブジェクト,前記個別ステップ数調整情報を結合し、前記目的プログラムとしての実行形式と結合ステップ数調整情報を出力するオブジェクト結合手段を備えるオブジェクト結合部とを有して構成される。
【0038】
また、本発明の目的プログラムの実行ステップ数調整装置は、前記オブジェクト結合部で作成された前記実行形式を実行するとともに、前記結合ステップ数調整情報によって分岐ルートごとの実行ステップ数を計測する実行ステップ数計測手段と,前記実行ステップ数計測手段の計測結果から不要ステップを削除し、実行ステップ数計測結果を出力する不要ステップ削除手段とを備える目的プログラムの実行部と、前記実行ステップ数計測結果より分岐ルートごとの実行ステップ数を取出し、調整を行って、前記ステップ数調整オブジェクトと前記個別ステップ数調整情報を修正する実行ステップ数調整手段を備える実行ステップ数更新部とを有し、前記オブジェクト結合手段により、前記実行形式と前記結合ステップ数調整情報を再結合するようぬ形成される。
【0039】
本発明のプログラムを記憶した記録媒体は、ソースプログラムより命令コードに変換して生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析を行い、その結果によりステップ数調整オブジェクトを生成する第1の手順と、前記生成されたオブジェクトのメモリ割付情報を参照し該メモリ割付情報に基づき前記ステップ数調整オブジェクトを修正する第2の手順と、前記生成されたオブジェクトと前記ステップ数調整オブジェクトを結合し、目的プログラムとしての実行形式を生成する第3の手順とを処理として、目的プログラムの生成装置に実行させるプログラムを記録して構成される。
【0040】
本発明のプログラムを記憶した記録媒体は、ソースプログラムより命令コードに変換して生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析を行い、その結果によりステップ数調整オブジェクトを生成する第1の手順と、前記生成されたオブジェクトのメモリ割付情報を参照し該メモリ割付情報に基づき前記ステップ数調整オブジェクトを修正する第2の手順と、前記生成されたオブジェクトと前記ステップ数調整オブジェクトを結合し、目的プログラムとしての実行形式を生成する第3の手順と、前記第3の手順により生成された前記実行形式を前記ステップ数調整情報によって動的解析を行い、その結果により実行ステップ数計測結果を出力する第4の手順と、前記実行ステップ数計測結果を用いて前記ステップ数調整オブジェクトを修正する第5の手順とを処理として、目的プログラムの実行装置に実行されるプログラムを記録して構成される。
【0041】
本発明のプログラムを記憶した記録媒体は、ソースプログラムより命令コードに変換して生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析および前記生成されたオブジェクトのメモリ割付情報の参照を行い、それらの結果によりステップ数調整オブジェクトを生成する第1の手順と、前記生成されたオブジェクトと前記ステップ数調整オブジェクトを結合し、目的プログラムとしての実行形式を生成する第2の手順と、前記第2の手順により生成された前記実行形式をステップ数調整情報によって動的解析を行い、その結果により実行ステップ数計測結果を出力する第3の手順と、前記実行ステップ数計測結果により前記ステップ数調整オブジェクトを修正する第4の手順とを処理として、目的プログラムの生成装置または前記目的プログラムの実行装置に実行させるプログラムを記録して構成される。
【0042】
また、本発明のプログラムを記憶した記録媒体は、前記目的プログラムの実行ステップ数調整によって作成されたいずれかのプログラムを記録して形成される。
【0043】
【発明の実施の形態】
本発明の実施の形態は、ソースプログラムに記述された時間待ちおよび待ち合せを命令コード挿入によって行っているとき、プログラムの分岐ルートごとに異なる実行ステップ数を同一ステップ数にすることにより、タイマ回路などの特殊なハードウェアを用いずに正確に行うものである。
【0044】
具体的には、まずコンパイラ,アセンブラにより静的解析を行い、その結果によってステップ数調整オブジェクトを出力する。ついで、リンカによってメモリ配置による静的解析を行い、その結果でステップ数調整オブジェクトを修正する。さらに、エミュレータ,シミュレータにより動的解析を行い、その結果によりステップ数調整オブジェクトを修正する。しかる後、再度リンクすることによって、プログラムの分岐ルートごとの実行ステップ数を同一ステップ数にする。以上の操作により、実行ステップ数を段階的に調整する。
【0045】
以下、本発明の実施の形態を図面を参照して説明する。
【0046】
図1は本発明の一実施の形態を説明するための実行ステップ数調整装置のシステム構成図である。なお、前述した図16のシステム構成における回路やファイルの機能と同様の要素については、同一の番号を付与している。図1に示すように、本実施の形態は、目的プログラムの実行ステップ数調整を行うにあたり、ソースプログラム50および命令実行ステップ数情報51よりオブジェクト52,個別ステップ数調整情報53およびステップ数調整オブジェクト54を作成するオブジェクト生成部1と、このオブジェクト52やメモリ割付情報55などにより複数のオブジェクトを結合し、実行形式(目的プログラム)56および結合ステップ数調整情報57を作成するオブジェクト結合部2と、外部モデル33やターゲットシステム34を入力するとともに、実行形式56や結合ステップ数調整情報57に基づいてプログラムを試行実行し、実行ステップ数計測結果58を出力する実行部3と、この実行ステップ数計測結果58を用いて実行ステップ数の調整を行い、前述した個別ステップ数調整情報53およびステップ数調整オブジェクト54を更新する実行ステップ数更新部4とを有している。
【0047】
ここで、ソースプログラム50は、C言語,アセンブリ言語など記述された原始プログラムであり、命令実行ステップ数情報51は、命令コードと、この命令コードの実行ステップ数とによって構成されている。オブジェクト52は、原始プログラムをコンパイラ,アセンブラによって命令コードに変換したオブジェクトコード群である。このオブジェクト52は、メモリ割付情報55を元にし、オブジェクト結合部2によりて実行形式56として出力される。この実行形式56は、実行部3において実行できるオブジェクトコード群である。
【0048】
一方、ターゲットシステム34は、実行部3をエミュレータとしたときに、メモリや外部装置などのハードウェアであり、また外部モデル33は、実行部3をシミュレータで形成した場合、メモリや外部装置などを、ソフトウェアによりシミュレーションするための構成と動作を定義したファイルである。なお、ターゲットシステム34とシミュレータ、および外部モデル33とエミュレータの組合わせでは、使用されない。
【0049】
さらに、実行部3における実行ステップ数とは、命令コードをCPUによって実行した場合に必要なクロック数であり、後述する合計ステップ数,差分ステップ数,加算ステップ数は、それぞれ複数個の実行クロック数を合計、差分、加算した値である。さらに、調整ステップ数は、分岐ルートごとの実行ステップ数を同一ステップにするために調整する値を意味する。
【0050】
以下の説明では、コンパイラ、アセンブラ、リンカなどによって、ソースプログラム50、オブジェクト52、実行形式56の命令コードを実行せずに、分岐ルートを解析することを静的解析と呼び、命令コードを実行せずに、実行ステップ数、合計ステップ数、差分ステップ数、加算ステップ数を計測することを静的計測と呼び、この静的計測によって、ステップ数を調整することを静的調整と呼ぶ。同様に、エミュレータやシミュレータなどによって、実行形式56の命令コードを実行し、その実行した結果により分岐ルートを解析することを動的解析と呼び、実行した結果によって、実行ステップ数、合計ステップ数、差分ステップ数、加算ステップ数を計測することを動的計測と呼び、この動的計測によって、ステップ数を調整することを動的調整と呼ぶ。
【0051】
また、個別ステップ数調整情報53は、ソースプログラム50ごとに生成し、ソースプログラム50を識別するためのソースファイル情報と、ステップ数範囲行とステップ数範囲レーベルとステップ数解析調整データとステップ数調整オブジェクト開始レーベル名を含むステップ数調整範囲情報と、によって構成される。メモリ割付情報55は、メモリ割付の種類を識別できるセグメント名と、このセグメント名ごとのメモリ割付アドレス範囲と、このメモリ割付アドレス範囲をアクセスしたときに余分にかかる加算ステップ数とによって構成されている。結合ステップ数調整情報57は、個別ステップ数調整情報53を結合したものである。
【0052】
このことを具体的に説明すると、ソースプログラム50は、通常複数個(n個)存在し、これらn個のソースプログラム50をコンパイルすると、n個のオブジェクト52が生成される。このとき、n個のソースプログラム50に、例えばステップ数調整範囲を1個所指定すると、n個の個別ステップ数調整情報53と、n個×(分岐ルート数)のステップ数調整オブジェクト54が生成される。このため、n個のオブジェクト52と、n個×(分岐ルート数)のステップ数調整オブジェクト54とは、1つに結合して実行形式56を得る。同様に、n個の個別ステップ数調整情報53を1つに結合して結合ステップ数調整情報57を得るようにしている。
【0053】
かかるオブジェクト生成部1は、ソースプログラム50におけるステップ数の調整範囲を判定するステップ数調整範囲判定手段11と、この判定手段11の判定結果により実際のオブジェクトを生成するオブジェクト生成手段12と、このオブジェクト生成結果によりコード解析するステップ数を計測するコード解析ステップ数計測手段13と、ステップ数の計測結果によりコード解析するステップ数を調整するコード解析ステップ数調整手段14とを備えている。このオブジェクト生成部1は、コンパイラまたはアセンブラであり、ソースプログラム50と、命令実行ステップ数情報51によって、オブジェクト52と、個別ステップ数調整情報53と、ステップ数調整オブジェクト54を出力する。このオブジェクト生成部1におけるステップ数調整範囲判定手段11は、ソースプログラム50の計測範囲を識別し、個別ステップ数調整情報53とステップ数調整オブジェクト54の初期情報を出力する。また、コード解析ステップ数計測手段13は、オブジェクト生成手段12で生成したオブジェクト52の計測範囲に対して分岐ルートを解析し、命令実行ステップ数情報51を使った分岐ルートごとの命令コード実行ステップ数の合計と、各分岐ルートについてメモリ割付ごとのアクセス回数とを計測する。その結果、コード解析ステップ数調整手段14は、分岐ルートごとの命令ステップ数から調整ステップ数を求め、個別ステップ数調整情報53を更新し、ステップ数調整オブジェクト54を呼び出す命令コードをオブジェクト52に対して挿入した後、個別ステップ数調整情報53で更新された調整ステップ数に相当する命令コードをステップ数調整オブジェクト54として出力する。
【0054】
また、オブジェクト生成部2は、リンカおよびアーカイバで構成され、オブジェクト結合手段21と、個別ステップ数調整情報結合手段22と、メモリ割付ステップ数調整手段23とを備えており、メモリ割付情報55を元にして、オブジェクト52を結合して実行形式56を出力するとともに、ステップ数調整オブジェクト54を結合して結合ステップ数調整情報57を出力する。すなわち、オブジェクト結合手段21によって、オブジェクト52を結合し、必要であればアーカイバまたはライブラリアンで作成されたライブラリも結合して実行形式56を出力する。個別ステップ数調整情報結合手段22はメモリ割付情報55を元にして、個別ステップ数調整情報53を結合し、結合ステップ数調整情報57を出力する。このとき、結合ステップ数調整情報57内のアドレスは、実行形式56を作成することによって得られた絶対アドレスに変換する。ついで、メモリ割付ステップ数調整手段23は、個別ステップ数調整情報結合手段22の出力により、分岐ルートごとのメモリ割付によるアクセス回数から調整ステップ数を求め、それを個別ステップ数調整情報53に挿入し且つ調整ステップ数に相当する命令をステップ数調整オブジェクト54に挿入するとともに、その調整ステップ数に相当する命令を実行形式56に結合する。
【0055】
次に、実行部3は、シミュレータまたはエミュレータで構成され、実行ステップ数計測手段31と、不要ステップ数削除手段32とを備えている。この実行部3は、外部モデル33またはターゲットシステム34を使用し、実行形式56に対しエミュレーションまたはシミュレーションを行い、結合ステップ数調整情報57によって分岐ルートごとの計測範囲を得ることにより、実行ステップ数計測結果58を出力する。特に、実行ステップ数計測手段31は、結合ステップ数調整情報57における分岐ルートの分岐開始アドレスと分岐終了アドレスを取出し、シミュレータまたはエミュレータに対して、分岐ルートの計測開始アドレスと計測終了アドレスとして命令コード実行ステップ数を計測する。また、不要ステップ削除手段32は、割り込み処理やDMA転送などの分岐ルート以外の命令が実行された場合、実行ステップ数計測手段31に対して再計測を要求するか、あるいは計測開始アドレスから計測終了アドレスまでの命令コード実行ステップ数より割り込み処理とDMA転送などの分岐ルート以外の実行ステップ数を減算することによって、実行ステップ数計測結果58を出力する。
【0056】
さらに、実行ステップ数更新部4は、実行ステップ数調整手段41を備え、実行ステップ数計測結果58に基づいて実行ステップ数の計算を行い、その結果によって個別ステップ数調整情報53とステップ数調整オブジェクト54とを更新する。要するに、実行ステップ数調整手段41によって、コード解析による分岐ルートごとの実行ステップ数にメモリ割付による加算ステップ数を加えた値と、実行ステップ数計測結果58の実行ステップ数との差分ステップ数を求め、それを調整ステップ数として個別ステップ数調整情報53に挿入するとともに、差分ステップ数に相当する命令コードをステップ数調整オブジェクト54に挿入する。
【0057】
上述した実行部3において、初めて実行形式56をエミュレーションまたはシミュレーションを行った場合、オブジェクト生成部1のコード解析による調整ステップ数と、オブジェクト結合部2におけるメモリ割付による加算ステップ数とによって、ソースプログラム50に記述された調整範囲の分岐ルートを捜し、その分岐ルートごとの実行ステップ数を大まかに調整する。
【0058】
その後、オブジェクト結合部2におけるメモリ割付情報55の加算ステップ数が変更されたとき、メモリ割付ステップ数調整手段23によりその加算ステップ数の変更が反映されたステップ数調整オブジェクト54を作成し、その変更結果で実行形式56を生成することにより、ソースプログラム50に記述された調整範囲の分岐ルートごとの実行ステップ数も同時に調整される。
【0059】
再度、実行部3において、実行ステップ数計測結果58が出力された後、実行ステップ数更新部4において、個別ステップ数調整情報53を更新する。この個別ステップ数調整情報53が更新されたとき、再度オブジェクト結合部2は、調整範囲の分岐ルートごとの実行ステップ数の精度が向上した実行形式56を出力するので、再度実行部3が実行ステップ数の計測を実行したときは、分岐ルート毎の実行ステップ数に差異が無くなる。
【0060】
なお、上述したオブジェクト生成部1、オブジェクト結合部2、実行部3、実行ステップ数更新部4は、記憶媒体(図示せず)に記録されても良い。ここで、記憶媒体とは、プログラムを記録したコンピュータ読み取り可能な記録媒体のことであり、具体的には、光ディスク、磁気ディスク、半導体メモリなどが用いられる。要するに、この記憶媒体には、コンピュータが読み取り可能な形式で保存され、コンピュータが実行可能な形式に変換された媒体であればよい。これにより、記憶媒体に保存されたプログラムをコンピュータが直接実行するか、あるいは記憶媒体から別の高速な半導体メモリなどへ出力した後、コンピュータが実行することができる。
【0061】
図2は図1に示すシステムの動作を説明するフロー図である。図2に示すように、このシステム全体の動作フローにおいて、図1のブロック図との関係で説明すると、ステップS1〜S3はオブジェクト生成部1のステップ数調整範囲判定手段11によって実現し、ステップS4はオブジェクト生成手段12によって実現し、ステップS5〜S7はコード解析ステップ数計測手段13とコード解析ステップ数調整手段14によって実現している。また、ステップS8はオブジェクト結合部2におけるオブジェクト結合手段21と個別ステップ数調整情報結合手段22によって実現し、ステップS9〜S11はメモリ割付ステップ数調整手段23によって実現し、ステップS12はオブジェクト結合手段21によって実現する。さらに、ステップS13〜S15は実行部3の実行ステップ数計測手段31と不要ステップ数削除手段32および実行ステップ数更新部4の実行ステップ数調整手段41とによって実現し、ステップS16はオブジェクト結合手段21によって実現する。
【0062】
まず、ソースプログラム50のステップ数調整範囲は、ステップS1〜S3によって検索され、ステップ数調整範囲の開始行と終了行に、それぞれ開始レーベルと終了レーベルを挿入する。すなわち、ステップS1でステップ数調整開始位置を検出したか否かの判定を行い、検出した場合には、ステップS2の処理を行う。このとき、ステップ調整情報が存在するときはそのままとするが、存在しないときはステップ調整情報を作成する。ついで、ステップS3で、ステップ数調整範囲レーベルをソースプログラムに挿入してステップ調整情報を書込む。この書込みが完了すると、ステップS1に戻って再度ステップ調整開始位置の検出判定を行う。
【0063】
一方、このステップS1でステップ調整開始位置を検出しないと、ステップS4のオブジェクト生成を行う。このオブジェクト生成ステップでは、開始レーベルと終了レーベルを挿入したソースプログラム50よりオブジェクト52を生成する。このソースプログラム50の記述例としては、例えば後述する図10のC言語におけるpragma疑似命令を用いる。
【0064】
次に、ステップS5により、開始レーベルと終了レーベルを元にオブジェクト52に含まれるステップ数調整範囲の分岐ルートを解析し、命令実行ステップ数情報51を使った分岐ルートごとの命令コード実行ステップ数の合計と、各分岐ルートにおけるメモリ割付ごとのアクセス回数とを計測する。その結果、分岐ルートごとの命令ステップ数から調整ステップ数を求め、個別ステップ数調整情報53を更新する。
【0065】
この分岐ルートの解析,調整が完了すると、ステップS5で解析および調整の結果より、ステップ数調整オブジェクトを作成する。すなわち、ステップ数調整オブジェクト54を呼び出す命令コードをオブジェクト52に対して挿入し、個別ステップ数調整情報53で更新された調整ステップ数に相当する命令コードをステップ数調整オブジェクト54に挿入する。ついで、ステップS7で調整範囲が未だ残っているかの判定を行う。残っている場合、つまりステップ数調整範囲がオブジェクト52に存在する間、ステップS5,ステップS6を継続する。
【0066】
次に、ステップS8によって、オブジェクト52を結合するとともに、ステップ数調整情報を結合し、実行形式56および結合ステップ数調整情報57を生成する。
【0067】
次に、ステップS9により、メモリ割付情報55の加算ステップ数を元にして、個別ステップ数調整情報53に含まれるメモリ割付ごとのアクセス回数から分岐ルートごとのメモリ割付による調整ステップ数を求め、個別ステップ数調整情報53を更新する。ついで、ステップS10により、個別ステップ数調整情報53で更新された調整ステップ数に相当する命令コードをステップ数調整オブジェクト54に挿入する。このステップ数調整オブジェクト54への挿入が完了すると、ステップ11において、調整範囲が未だ残っているか否かの判定を行う。ステップ数調整範囲が実行形式56に存在する間、ステップS9,ステップS10を繰返し継続する。
【0068】
次に、このステップ数調整範囲が無くなると、ステップS12によって、実行形式56に調整済みのステップ調整オブジェクト54を結合する。ついで、ステップS13により、結合ステップ数調整情報57における分岐ルートの分岐開始アドレスと分岐終了アドレスを取出し、分岐ルートの計測開始アドレスと計測終了アドレスとして命令コード実行ステップ数を計測した後、割り込み処理やDMA転送などの分岐ルート以外の実行ステップ数を減算して調整した結果を実行ステップ数計測結果58として出力する。
【0069】
次に、ステップS14により、上述の調整結果に基づいて、コード解析による分岐ルートごとの実行ステップ数にメモリ割付による加算ステップ数を加えた値と、実行ステップ数計測結果58の実行ステップ数との差分ステップ数を求める。このステップS14では、求めた差分ステップ数を調整ステップ数として個別ステップ数調整情報53に挿入し、差分ステップ数に相当する命令コードをステップ数調整オブジェクト54に挿入する。さらに、ステップ15で調整範囲が未だ残っているか否かの判定を行う。この結果、ステップ数調整範囲が実行形式56に存在する間、ステップS13、ステップS14は繰返し継続する。要するに、実行ステップ数のフィードバックがかけられる。
【0070】
最後に、ステップS16により、ステップS14によって調整されたステップ数調整オブジェクト54を再度結合し、実行形式56を作成する。このオブジェクト54の再結合が完了すると、一連の処理が終了する。
【0071】
図3は図1における個別ステップ数調整情報の構成図である。図3に示すように、この個別ステップ数調整情報53は、ファイル情報100と、複数の(個別)ステップ数調整範囲情報101とから構成され、そのステップ数調整範囲情報101は、ステップ数の調整範囲を行で規定したステップ数調整範囲行102とステップ数調整範囲レーベル103と複数のステップ数解析調整データ104とを含んで形成される。なお、このファイル情報100は、個別ステップ数調整情報53の元になるソースプログラム50およびオブジェクト52のファイル名、作成日付などによって構成され、ソースプログラム50とオブジェクト52と個別ステップ数調整情報53との関係および更新日時、更新理由(例えば、ソースプログラム50の変更、メモリ割付による更新、実行ステップ数による更新)などを備えている。したがって、前述した図1のコード解析ステップ数調整手段14と、メモリ割付ステップ数調整手段23と、実行ステップ数調整手段41とにおいて、何時更新されたか、さらには更新する必要があるか否かを知ることができる。
【0072】
また、複数のステップ数解析調整データ104は、それぞれステップ数調整オブジェクト開始レーベル名105を持って形成される。この個別ステップ数調整情報53は、前述したように、図2におけるステップS2によって生成し、ステップS6とステップS10によって更新し、ステップS8によってオブジェクト結合と同時に、個別ステップ数調整情報も結合される。
【0073】
なお、前述した結合ステップ数調整情報57もこの個別ステップ数調整情報53と同様に、ファイル情報と複数のステップ数調整範囲情報とで構成される。
、結合ステップ数調整情報57の構成例である。
【0074】
図4は図3におけるステップ数調整解析調整データの構成図である。図4に示すように、ステップ数調整情報53におけるステップ数解析調整データ104は、解析開始アドレス,コード解析合計ステップ数,メモリ割付個別アクセス数,コード解析調整ステップ数,メモリ割付調整ステップ数,実行時計測ステップ数,実行時調整ステップ数,複数(分岐先1〜n)のステップ数解析調整データへのポインタを含んでおり、分岐先毎のポインタが複数個あるときのステップ数解析調整データ例を調整データ(1〜3)106,107,108で表わしている。例えば、分岐先1に複数のポインタがあるときのステップ数解析調整データ106は、解析開始アドレス,コード解析合計ステップ数,メモリ割付個別アクセス数,コード解析調整ステップ数,メモリ割付調整ステップ数,実行時計測ステップ数,実行時調整ステップ数,分岐先1−1乃至分岐先1−nのステップ数解析調整データへのポインタとから形成される。要するに、実行ステップ数調整範囲1個に対して分岐先がn個あったときには、n個のポインタによりn個の調整データを管理する。つまり、データ106において、n個の分岐先のうち、さらにm個の分岐先があったとき、m個のポインタによってm個の調整データを管理する方法を説明している。
【0075】
すなわち、前述した図2のステップS5において、分岐ルートを解析した結果に基づき、ステップ数解析調整データをポインタによって接続している。
【0076】
図5は図1におけるステップ数調整オブジェクトの構成図である。図5に示すように、ステップ数調整オブジェクト54は、ステップ数調整オブジェクト開始レーベル名〔Entry〕106,コード解析調整ステップ数に相当する命令コード〔nop〕107,メモリ割付調整ステップ数に相当する命令コード〔nop〕108,実行時調整ステップ数に相当する命令コード〔nop〕109,ステップ数調整オブジェクトからの復帰コード〔jmp(jp)〕110から構成される。このステップ数調整オブジェクト54は、調整ステップ数に相当する命令コードとして、NOP(ノン・オペレーション)命令を挿入した例である。
【0077】
すなわち、前述した図2のフローにおいては、ステップS6によって生成し、ステップS10によって更新し、ステップS12によって結合している。このステップ数調整オブジェクト54は、ステップ数調整オブジェクト情報に対応して生成し、オブジェクト52からステップ数調整オブジェクト54を呼び出すステップ数調整オブジェクト開始レーベル名106と、コード解析調整ステップ数に相当する命令コード107と、メモリ割付調整ステップ数に相当する命令コード108と、実行時調整ステップ数に相当する命令コード109と、ステップ数調整オブジェクト54から復帰する命令コード110とによって構成される。
【0078】
次に、図2における個々の動作フロー(図6〜図8)と前述した図3〜図5を参照し、本実施の形態の調整動作について説明する。
【0079】
図6は図2における分岐ステップ数解析および調整のフロー図である。図6に示すように、この分岐ステップ数解析および調整フローは、前述した図2のステップS5の詳細なフローである。このステップS5で呼び出される分岐ステップ数解析および調整は、まずステップS20により、解析開始アドレスを記憶させ、解析中アドレスを個別ステップ調整情報53に追加する。このアドレスの記憶が完了すると、ステップS21により分岐命令を検索する。
【0080】
この検索判定の結果、分岐命令がある場合は、ステップ23で解析調整処理を再帰呼出し、このときの分岐先アドレスを解析開始アドレスとする。
【0081】
一方、ステップS21で分岐命令がない場合は、ステップS22において、コード解析によって選られた合計ステップ数(コード解析合計ステップ数)とメモリ割付ごとのアクセス回数(メモリ割付個別アクセス数)を測定し、その測定結果を個別ステップ調整情報53に追加し、処理を終了する。
【0082】
ついで、ステップS24において、再帰呼出しからの復帰後、ステップS24により、再帰呼出しからの復帰後、前述した図4のステップ数解析調整データ104における分岐先1〜nへのポインタを設定する。このポインタの設定が完了すると、ステップS25において、全ての分岐を処理したか否かの判定を行う。これらステップS24,ステップS25は、分岐命令がある間、すなわち未処理がある間、ステップS23へ戻り、繰返し継続される。
【0083】
さらに、全ての分岐について処理済みになると、ステップS26において、分岐先へのポインタ(図4のステップ数解析調整データ104における分岐先1〜n)が指し示すステップ数解析調整データ106,107,108にあるコード解析合計ステップ数の差分ステップ数を求め、コード解析調整ステップ数を挿入し、処理を終了する。
【0084】
図7は図2におけるメモリ割付ステップ数調整フロー図である。図7に示すように、メモリ割付ステップ数調整フローは、前述した図2のステップS9の詳細なフローである。このステップS9で呼び出されるメモリ割付ステップ数調整は、まずステップS30により分岐命令を検索する。なお、この分岐命令の検索およびつぎの図8で説明する分岐命令の検索は、図2のコード解析によって得られたステップ数解析データのポインタ接続を追い掛けることを意味する。
【0085】
このステップS30で分岐命令がある場合は、ステップS31のメモリ割付ステップ数調整を行った後、ステップS32で全ての分岐について処理したか否かの判定をする。ここで、未処理の分岐があった場合には、ステップS31に戻ってステップ数調整の再帰呼出しを行う。しかし、前述したステップS30の分岐命令検索の結果、分岐命令が残っていないときは、メモリ割付ステップ数調整の処理を終了させる。
【0086】
最後に、ステップS33により、再帰呼出しからの復帰後、分岐先へのポインタ(図4のステップ数解析調整データ104の分岐先1〜nのポインタ)が指し示すコード解析によって得られたメモリ割付個別アクセス数とメモリ割付情報55の加算ステップ数から図4のステップ数解析調整データ1,2,3(106〜108)におけるメモリ割付調整ステップ数を挿入(加算)して終了する。
【0087】
図8は図2における実行ステップ数調整フロー図である。図8に示すように、この実行ステップ数調整フローは、前述した図2のステップS13の詳細なフローである。このステップS13で呼び出される実行ステップ数調整は、まずステップS40により分岐命令を検索する。ここで、分岐命令がある場合は、ステップS41の実行ステップ数調整を行い、続いてステップS43で全ての分岐について処理したか否かの判定を行う。この判定の結果、未処理の分岐が残っていると処理を繰返し継続する。
【0088】
一方、ステップS40で分岐命令がない場合は、分岐開始アドレスを計測開始アドレスとし、エミュレータまたはシミュレータを実行した結果から実行時計測ステップ数(図4の106〜108)を挿入して終了する。
【0089】
しかし、ステップS41によって、再帰呼出しから復帰後、すべての分岐に対して、実行時計測ステップ数を得られたら、ステップS44において、分岐先へのポインタ(図4の106〜108)が指し示す実行時計測ステップ数の差分ステップ数を求め、実行時調整ステップ数を挿入(加算)して処理を終了する。
【0090】
図9は図1におけるメモリ割付情報の一例を示す構成図である。図9に示すように、このメモリ割付情報55は、変数と領域と加算ステップ数からなる。例えば、変数MEM1は低速RAMの領域であり、加算するステップ数は1としている。この加算ステップ数を1,0,3などと規定することにより、異った領域の長さ(時間)の調整を行っている。
【0091】
図10は図1におけるソースプログラムの一例を示す構成図である。図10に示すように、このソースプログラム50は、#pragma adjust start(ステップ数調整範囲の開始位置)と#pragma adjust end(ステップ数調整範囲の終了位置)を指定した例である。この例におけるステップ数調整範囲内のソースプログラム50は、「if(MEM2==0){MEM1=0;}」において、前述した図9の高速RAMを参照して値が0であれば、低速RAMに0を書き込み、また「else if(MEM2==1){MEM3=0;}」において高速RAMを参照して値が1であれば、I/Oポートに0を書き込み、さらに「else{MEM2=0;}」において高速RAMを参照して値が0または11でなければ、高速RAMに0を書き込むことを表わしている。
【0092】
このように、かかる調整範囲に指定されたコマンドが、上述の意味を表わすことにより、ソースプログラム50は、オブジェクト生成部1によりオブジェクト52に形成される。
【0093】
図11は図1におけるオブジェクトの一例を示す構成図である。図11に示すように、このオブジェクト52は、前述した図10のステップ数調整範囲内のソースプログラム50より変換されたものである。
【0094】
すなわち、図11において、「if(MEM2==0)」が、「CMP MEM2,0」、「BNZ LABEL 1」となり、「{MEM1=0;}」が、「MOVE MEM1,0」、「BR LABEL 1 END」となり、「else if(MEM2==1)」が、「CMP MEM2,1」、「BNZLABEL 1 2」となり、「{MEM3=0;}」が、「MOVE MEM3,0」、「BR LABEL 1 END」となり、「else{MEM2=0;}」が、「MOVE MEM2,0」とそれぞれ変換される。なお、記号A〜Eは、図12で説明するブロックを表わしている。
【0095】
図12は図11に示すオブジェクトのフロー図である。図12に示すように、このフローは、オブジェクト52を分解したとき、ブロックA,Cが比較命令と分岐判定を行うブロック、ブロックB,D,Eがメモリに数値を代入するブロックである。
【0096】
しかるに、前述した図10のソースプログラム50の調整範囲(スタートとエンドを除く範囲)が指定されているとき、図11のようなオブジェクト52が生成される。したがって、分岐ルートを解析する場合、まず分岐しない側を先に解析し、次に分岐する側を解析する。その結果、図12のフローに示すように、ブロックA→B→C→D→Eの順番で解析を行う。
【0097】
図13(a)〜(c)はそれぞれ図12における分岐ルートの解析フロー図である。図13(a)に示すように、この解析フローは、ブロックA,Bからなるルートである。同様に、図13(b),(c)に示すように、これらの解析フローは、ブロックA,C,DからなるルートおよびブロックA,C,Eからなるルートである。要するに、図12の解析フローは、図13のような3つの分岐ルートになる。
【0098】
かかる解析フローにおいて、ブロックAは全ルートで実行されるため、調整ステップを挿入しない。また、ブロックBは、ブロックCとDの合計ステップ数と、CとEの合計ステップ数と同じ長さのステップになるように、調整ステップを挿入する。また、ブロックCは、分岐ルート2(A→C→D)と分岐ルート3(A→C→E)で実行されるため、調整ステップを挿入しない。さらに、ブロックDおよびEは、同一ステップになるように、どちらかに、調整ステップを挿入する。
【0099】
要するに、図13は、図12のフローを分岐ルートごとに組合わせを説明したものであり、(a)〜(c)の3つのルートが存在するので、そのルートごとのトータル時間を同じにするため、コード解析による調整ステップと、メモリ割付による調整ステップと、実行時による調整ステップとを挿入した例を示している。すなわち、処理ステップ1つについて1ステップだけの処理時間がかかる場合、すべてのルートの処理時間は一致しないといけないため、図13における比較,分岐命令,調整ステップなどのステップ数(箱の数)は、各ルートごとに一致させる必要がある。これら分岐ルートごとの箱の数は、前述した図1におけるコード解析ステップ数調整手段14によって同じになるように調整される。
【0100】
つぎに、箱の数だけでは分らない時間の調整、例えばMEM1とMEM2とMEM3の実行ステップの違いによる調整は、メモリ割付ステップ数調整手段23により行う。すなわち、前述した図9の例に示すように、加算ステップの関係が、MEM3〉MEM1〉MEM1であった場合、[MEM3の加算ステップ数−MEM2の加算ステップ数]を図13(c)の分岐ルートに挿入し、[MEM3の加算ステップ数−MEM1の加算ステップ数]を図13(a)の分岐ルートに挿入することにより、箱の数だけでは分からない部分の調整を行う。
【0101】
さらに、実行部3において、図13(b),(c)のブロックD,Eを実行ブロックDの方が遅いステップ数であった場合、そのステップ数の差を図13(b)に挿入することにより、箱の数だけでは分からず、メモリ割付でも分からなかった調整を実行ステップ数調整手段41で行う。
【0102】
図14(a)〜(c)はそれぞれ図13におけるオブジェクトをステップ数調整オブジェクトに置き換えた解析フロー図である。。図14(a)〜(c)に示すように、これらの解析フローは、図13(a)〜(c)におけるブロックA〜EをブロックA′〜E′に置換えるとともに、ステップ数を合わせるための新たなブロックF,G,Hを追加して記載したものである。
【0103】
要するに、本実施の形態においては、前述した図6の分岐ステップ数解析および調整フローにおいて、分岐ルートを再帰呼出しによって検索し、枝から順番に合計ステップが決定する。したがって、図12のフローの場合、ブロックE→D→C→B→Aの順番で決定する。
【0104】
すなわち、ブロックDが決定したとき、ブロックEとDの調整ステップ数をブロックEまたはDに挿入し、ブロックEまたはDの最大ステップ数をブロックCの合計ステップ数とする。
【0105】
また、ブロックBが決定したとき、ブロックCとBの調整ステップ数をブロックCまたはBに挿入し、ブロックCまたはDの最大ステップ数をブロックAの合計ステップ数とする。
【0106】
しかるに、図13および図14において、ブロックEとHの両方にコード解析調整ステップが挿入されているが、図13のブロックB,ブロックDおよび図14のブロックB′,ブロックD′における「LABEL 1 ENDにジャンプ」と同様に、分岐命令を挿入した場合を想定している。
【0107】
最終的に、図13のブロックBにおける「コード解析調整ステップ」(一番下),ブロックDにおける「コード解析調整ステップ」,ブロックEにおける「コード解析調整ステップ」および図14におけるブロックFにおける「コード解析調整ステップ」(一番下),ブロックGにおける「コード解析調整ステップ」,ブロックHにおける「コード解析調整ステップ」の差分ステップ数から片方のステップを削除することができる。
【0108】
なお、図13(a)のブロックBにおける「コード解析調整ステップ」(上の3つ),ブロックEにおける「分岐する(偽)場合のステップ」および図14におけるブロックFにおける「コード解析調整ステップ」(上の3つ),ブロックE′に「分岐する(偽)場合のステップ」は、個別ステップ数調整情報53に入れたとき合計ステップ数として挿入される。
【0109】
このように、図14(a)〜(c)に示すとおり、分岐ルートの最後に調整ステップをまとめたブロックF,G,Hがステップ数調整オブジェクトになる。
【0110】
上述した点をさらに図12〜図14を用い、各調整フローを参照して、より具対的に説明する。
【0111】
図12に示すブロックA、B、C、D、Eは、前述した図6の分岐ステップ数解析および調整フローにより、以下のように分岐ルートを再帰呼び出しによって検索し、枝から順番に合計ステップを決定する。ここで、枝とは、ブロックAに対してブロックBとCであり、ブロックCに対してブロックDとEである。まず、ブロックDとEの解析後にブロックCの解析が終了し、ブロックBとCの解析後にブロックAの解析が終了する。
【0112】
▲1▼ブロックAの解析からブロックCの解析呼び出し
ブロックAから他分岐命令を検索(図6のステップS21)し、「BNZ LABEL 1」(図11)を発見すると、分岐先である「LABEL1」を現在の解析位置として、1回目の再帰呼び出しを行う(ステップS23)。
【0113】
▲2▼ブロックCの解析からブロックEの解析呼び出し
ブロックCから他分岐命令を検索(ステップS21)し、「BNZ LABEL 1 2」を発見すると、分岐先である「BNZ LABEL 1 2」を現在の解析位置として、2回目の再帰呼び出しを行う(ステップS23)。ついで、ブロックEから他分岐命令を検索(ステップS21)すると、他分岐命令が無いため、「MOVE MEM2,0」のステップ数をブロックEにおけるコード解析合計ステップ数とする(ステップS22)。
【0114】
▲3▼ブロックCの解析からブロックDの解析呼び出し
2回目の再帰呼び出しから復帰し、分岐しない場合の「MOVE MEM3,0」を現在の解析位置として、3回目の再帰呼び出しを行う(ステップS25)。ついで、ブロックDから他分岐命令を検索する(ステップS21)と、他分岐命令が無いため、「MOVE MEM3,0」と「BR LABEL 1 END」の合計ステップ数をブロックDにおけるコード解析合計ステップ数とする(ステップ22)。
【0115】
▲4▼ブロックEとブロックDの解析結果からブロックCの結果を保存
3回目の再帰呼び出しから復帰し、ブロックEとDのコード解析合計ステップ数の合計ステップが長い方のステップ数と、ブロックCにおける「CMP MEM2,1」と「BNZ LABEL 1 2」とのステップ数を加算したステップ数をブロックCにおけるコード解析合計ステップ数とする(ステップS26)。また、ブロックEとDのコード解析合計ステップ数との差分を調整ステップ数とする。
【0116】
▲5▼ブロックAの解析からブロックBの解析呼び出し
1回目の再帰呼び出しから復帰し、分岐しない場合の「MOVE MEM1,0」を現在の解析位置として、4回目の再帰呼び出しを行う(ステップ25)。ついで、ブロックBから多分岐命令を検索(ステップS21)すると、多分岐が無いため、「MOVE MEM1,0」と「BR LABEL 1 END」の合計ステップ数をブロックBにおけるコード解析合計ステップ数とする(ステップS22)。
【0117】
▲6▼ブロックCとブロックBの解析結果からブロックAの結果を保存
4回目の再帰呼び出しから復帰し、ブロックCとBのコード解析合計ステップ数の合計ステップが長い方のステップ数と、ブロックAにおける「CMP MEM2,0」と「BNZ LABEL 1」とのステップ数を加算したステップ数をブロックAにおけるコード解析合計ステップ数とする(ステップS26)。また、ブロックCとBのコード解析合計ステップ数との差分を調整ステップ数とする。
【0118】
以上の解析によって、多分岐を2回検出したことから、図13(a)、(b)、(c)のように、3つの分岐ルートがあったことになる。この解析した結果は、前述した図4のステップ数解析調整データ104として記憶させる。
【0119】
さらに、図13に示すように、ブロックEとDの調整ステップ数は、ブロックDにコード解析調整ステップ数D−1を挿入し、ブロックCとBの調整ステップ数は、ブロックBにコード解析調整ステップ数B−1、B−2、B−3、B−4として挿入した調整オブジェクトを生成する(図2のステップS6)。
【0120】
次に、図7のメモリ割付ステップ数調整フローによリ、図4のステップ数解析調整データを用い、以下のように解析する。
【0121】
▲1▼図12に示すブロックAの解析からブロックCの解析呼び出し
ブロックCの1回目の再帰呼び出しを行う(ステップS31)。
【0122】
▲2▼ブロックCの解析からブロックEの解析呼び出し
ブロックEの2回目の再帰呼び出しを行う(ステップS31)。このブロックEには多分岐がないので、ブロックEからメモリ割付個別アクセス数を記憶した後、2回目の再帰呼び出しから復帰する。
【0123】
▲3▼ブロックCの解析からブロックDの解析呼び出し
ブロックCには、もう一つの分岐先が残っていることから、再度ステップS31により、ブロックDの3回目の再帰呼び出しを行う(ステップS32)。ブロックDには多分岐がないので、ブロックDのメモリ割付個別アクセス数を記憶した後、3回目の再帰呼び出しから復帰する。
【0124】
▲4▼ブロックEとブロックDの解析結果からブロックCの結果を保存する
ブロックEとブロックDのメモリ割付個別アクセス数の差分を求め、ブロックEとブロックDのそれぞれのメモリ割付調整ステップ数を更新する(ステップS33)。メモリ割付個別アクセス数の大きい側のステップ数は、ブロックCのメモリ割付個別アクセス数として記憶する。
【0125】
▲5▼ブロックAの解析からブロックBの解析呼び出し
1回目の再帰呼び出しから復帰し、ステップS32によりもう一つの分岐先が残っていることから、再度ステップS31によって、ブロックBの4回目の再帰呼び出しを行う。ブロックBには多分岐がないので、ブロックBのメモリ割付個別アクセス数を記憶した後、4回目の再帰呼び出しから復帰する。
【0126】
▲6▼ブロックCとブロックBの解析結果からブロックAの結果を保存する
ステップS33によりブロックCとブロックBのメモリ割付個別アクセス数の差分を求め、ブロックCとブロックBのメモリ割付調整ステップ数を更新する。メモリ割付個別アクセス数の大きい側のステップ数は、ブロックAのメモリ割付個別アクセス数として記憶する。
【0127】
以上の解析により、解析した結果は、図4のステップ数解析調整データを更新することによって実現する。
【0128】
さらに、図13に示すように、ブロックEとDの調整ステップ数は、ブロックEにメモリ割付調整ステップ数E−1として挿入し、ブロックCとBの調整ステップ数は、ブロックBにメモリ割付調整ステップ数B−5として挿入した調整オブジェクトを生成する(図2のステップS10)。
【0129】
次に、図8によって、図4のステップ数解析調整データを使って、以下のように解析する。
【0130】
▲1▼ブロックAの解析からブロックCの解析呼び出し
ブロックCの1回目の再帰呼び出しを行う(ステップS41)。
【0131】
▲2▼ブロックCの解析からブロックEの解析呼び出し
ブロックEの2回目の再帰呼び出しを行う(ステップS41)。ブロックEには多分岐がないので、実行時計測ステップ数を計測し、2回目の再帰呼び出しから復帰する(ステップS42)。
【0132】
▲3▼ブロックCの解析からブロックDの解析呼び出し
もう一つの分岐先が残っていること(ステップS43)から、再度ステップS41により、ブロックDの3回目の再帰呼び出しを行う。ブロックDには多分岐がないので、実行時計測ステップ数を計測し(ステップ42)、3回目の再帰呼び出しから復帰する。
【0133】
▲4▼ブロックEとブロックDの解析結果からブロックCの結果を保存する
ブロックEとブロックDの実行時計測ステップ数の差分を求め(ステップS44)、ブロックEとブロックDのそれぞれの実行時調整ステップ数を更新する。実行時計測ステップ数の大きい側のステップ数は、ブロックCの実行時計測ステップ数として記憶する。
【0134】
▲5▼ブロックAの解析からブロックBの解析呼び出し
1回目の再帰呼び出しから復帰し、ステップS43によりもう一つの分岐先が残っていることから、再度ブロックBの4回目の再帰呼び出しを行う(ステップ41)。ブロックBには多分岐がないので、実行時計測ステップ数を計測し(ステップ42)、4回目の再帰呼び出しから復帰する。
【0135】
▲6▼ブロックCとブロックBの解析結果からブロックAの結果を保存する
ブロックCとブロックBの実行時計測ステップ数の差分を求め(ステップS44)、ブロックCとブロックBの実行時調整ステップ数を更新する。実行時計測ステップ数の大きい側のステップ数は、ブロックAの実行時計測ステップ数として記憶する。
【0136】
以上の解析によって、解析した結果は、図4のステップ数解析調整データを更新することによって実現する。
【0137】
さらに、図13に示すように、ブロックEとDの調整ステップ数は、ブロックDに実行時調整ステップ数D−2として挿入し(図2のステップS14)、ブロックCとBの調整ステップ数は、ブロックBに実行時調整ステップ数B−6として挿入した調整オブジェクトを生成する。
【0138】
最終的には、調整ステップB−1〜B−6を図14のブロックFとして、調整ステップD−1,D−2を図14のブロックGとして、調整ステップE−1を図14のブロックHとして、分岐ルートごとに調整オブジェクトを生成したことになる。
【0139】
以上、本発明の一実施の形態について説明したが、本発明はこれに限ることなく、以下のような変形も可能である。
【0140】
前述した一実施の形態では、図1におけるオブジェクト生成部1は命令ステップ数情報51を参照したが、このオブジェクト生成部1が命令ステップ数情報51の他に、オブジェクト結合部2で参照していたメモリ割付情報55を参照するようにしてもよい。その場合を図15を参照して説明する。
【0141】
図15は本発明の他の実施の形態を説明するための実行ステップ数調整装置のシステム構成図である。図15に示すように、命令実行ステップ数情報51とメモリ割付情報55を結合するとともに、オブジェクト結合部2に設けていたメモリ割付ステップ数調整手段23をオブジェクト生成部1の内部に設けることで実現することができる。これによって、前述の図7で行っていたメモリ割付ステップ数調整を、図6のステップS22における個別メモリアクセス数を求めたときに、メモリ割付情報55を参照して、図7のステップS33における差分の計算および調整ステップ数の計算を行うことができる。これによって、図2におけるステップS9〜S12を削除することができる。
【0142】
また、前述したように、ソースプログラム50は複数存在するために、オブジェクト52と個別ステップ数調整情報53とステップ数調整オブジェクト54とは、複数存在する。例えば、n個のソースプログラム50があると、n個のオブジェクト52と、[n個×調整範囲数]の個別ステップ数調整情報53と、[n個×調整範囲数×分岐ルート数]のステップ数調整オブジェクト54を生成しているが、記憶装置に記憶する際はまとめることが考えられる。例えば、[n個×調整範囲数]の個別ステップ数調整情報53は、一つにまとめて、n個の個別ステップ数調整情報53とすることができる。また、[n個×調整範囲数×分岐ルート数]のステップ数調整オブジェクト54は、一つにまとめて、n個のステップ数調整オブジェクト54とすることができる。ただし、この場合であっても記憶装置への記憶のさせ方が異なるだけであり、それぞれ、[調整範囲数]および[調整範囲数×分岐ルート数]の情報を持つため、同等になることは明白である。
【0143】
以上は図15に示す他の実施形態の構成およびその主要部の動作であり、他は図1と同様である。
【0144】
また、図1におけるステップ数調整オブジェクト54は、ソースプログラムとしても実現することができる。すなわち、ソースプログラムが単純であり、コンパイルまたはアセンブルに時間がかからないからである。しかも、このステップ数調整オブジェクト54は、アーカイバまたはライブラリアンを使用して、ライブラリ化して実現することも可能である。その場合、コード解析ステップ数調整手段14とメモリ割付ステップ数調整手段23と実行ステップ数調整手段41とに、ライブラリアンを更新する機能を付属させるか、調整ステップ数を可変したくないとき、意図的にライブラリアンとすることが可能である。
【0145】
また、図1における実行部3および実行ステップ数変更部4は一体化することも可能である。その場合は、実行ステップ数調整手段41を実行部3に含ませることにより、実行ステップ数計測結果58を省くこともできる。
【0146】
さらに、前述した図10のソースプログラム50中のpragma調整スタート,調整終了のようなC言語におけるpragma疑似命令において、ステップ数の最大ステップ数または最小ステップ数を制限するオプションを加え、個別ステップ数調整情報53や結合ステップ数調整情報57に、前記最大ステップ数または最小ステップ数を挿入することにより、コード解析ステップ数調整手段14,メモリ割付ステップ数調整手段23,実行ステップ数調整手段41のそれぞれで挿入される調整ステップ数を制限することも可能である。
【0147】
例えば、ステップ数調整範囲内にfor文,while文などのループ文があり、且つその終了条件に変数が使用されていた場合には、ステップ調整を毎回更新することが有得るため、図10のソースプログラム50中のpragma調整スタート,調整終了のようなC言語におけるpragma疑似命令において、for文,while文などの終了条件に変数が使用されていたとき、平均ステップ数を求めるオプションを加え、個別ステップ数調整情報53、結合ステップ数調整情報57に平均ステップ数を挿入することにより、コード解析ステップ数調整手段14、メモリ割付ステップ数調整手段23、実行ステップ数調整手段41に挿入される調整ステップ数の乱れを抑制することが可能である。また、これらfor文,while文などの終了条件に変数が使用されている箇所に、調整ステップ数を固定ステップ数にしたり、最大ステップ数または最小ステップ数を制限できる特殊コメントなどを挿入することにより、調整ステップ数を制限することができる。その理由は、ある範囲だけ特定ステップ数に固定することは、一部分だけ調整を無効化することにもなり、また調整ステップ数を入れすぎると、全体の処理時間が長くなりすぎるという問題があるためである。
【0148】
一方、前述した図10のpragma調整スタート,調整終了のように、C言語におけるpragma疑似命令を使用せず、個別ステップ数調整情報53の行番号などにより、まったくソースプログラム50を修正せずにステップ数調整範囲判定手段11を簡略化することも可能である。つまり、ソースプログラム50の調整したい範囲を直接個別ステップ数調整情報53に入れることにより、#pragma疑似命令を使用しない方法では、行番号から開始レーベルと終了レーベルを生成することになる。例えば、ソースプログラム50のファイル名が「abcd」というファイル名であるとし、調整開始行が11行目、調整終了行が20行目であったとすると、前記ファイル名「abcd」と行番号を組合わせて、abcd11を開始レーベル、abcd20を終了レーベルとする方法が考えられる。
【0149】
上述した実施の形態の変形例は、これらに限定されることなく、特許請求範囲に記載した範囲内で各種の変形が可能であることは、言うまでもない。
【0150】
【発明の効果】
以上説明したように、本発明の目的プログラムの実行ステップ数調整方法およびその調整装置は、プログラムで動作させるCPUに接続された外部回路の動作速度が遅く、ソースプログラム上に時間待ち処理を挿入するときでも、正確な時間待ちを得ることが出来るという効果がある。また、本発明は、外部入力を正確に計測したり、あるいは外部出力を正確に行う必要があり、ソースプログラム上に待ち合せ処理を挿入したときでも、正確な待ち合せを実現できるという効果がある。
【0151】
その理由は、ソースプログラムの分岐ルートごとのステップ数を同一ステップにすることにより、分岐ルートごとに存在した命令ステップ数の違いによる待ち時間の誤差を無くし、外部回路,外部装置の実際の動作に応じた待ち合せ時間を反映することができるからである。
【0152】
すなわち、コンパイラまたはアセンブラにおいて、分岐ルートを解析し、分岐ルートごとに命令コードの実行ステップ数を計測して分岐ルートごとに同一ステップ数になるように大まかに調整し、エミュレータまたはシミュレータにおいて分岐ルートごとに命令コードをエミュレーションまたはシミュレーションした実行ステップ数を計測することにより、命令コードの実行ステップ数との差分ステップ数によって分岐ルートごとに同一ステップ数になるように細かく調整できるからである。
【0153】
また、本発明は、目的オブジェクトとステップ数調整オブジェクトとを別々に出力するため、ステップ調整にあたっては、ステップ数調整オブジェクトを調整した後に再結合するだけで良いので、時間待ちおよび待ち合せを調整するための再コンパイルなどによる調整期間を短くできるという効果がある。
【0154】
さらに、本発明は、エミュレータまたはシミュレータによって、実行ステップ数の計測結果を元にした細かな調整を行うので、ターゲットシステムの外部回路または外部装置をバージョンアップするとき、ステップ数調整オブジェクトを調整した後に再結合するだけで済み、開発途中における外部回路または外部装置のタイミング調整を簡単に行うことができるという効果がある。
【図面の簡単な説明】
【図1】本発明の一実施の形態を説明するための実行ステップ数調整装置のシステム構成図である。
【図2】図1に示すシステムの動作を説明するフロー図である。
【図3】図1における個別ステップ数調整情報の構成図である。
【図4】図3におけるステップ数解析調整データの構成図である。
【図5】図1におけるステップ数調整オブジェクトの構成図である。
【図6】図2における分岐ステップ数解析および調整のフロー図である。
【図7】図2におけるメモリ割付ステップ数調整フロー図である。
【図8】図2における実行ステップ数調整フロー図である。
【図9】図1におけるメモリ割付情報の一例を示す構成図である。
【図10】図1におけるソースプログラムの一例を示す構成図である。
【図11】図1におけるオブジェクトの一例を示す構成図である。
【図12】図11に示すオブジェクトのフロー図である。
【図13】図12における分岐ルートの解析フロー図である。
【図14】図13におけるオブジェクトをステップ数調整オブジェクトに置き換えた解析フロー図である。
【図15】本発明の他の実施の形態を説明するための実行ステップ数調整装置のシステム構成図である。
【図16】従来の実行ステップ数調整方法の一例を示すシステム構成図である。
【図17】従来の他の例を説明するためのコンパイル装置を用いたシステム構成図である。
【図18】従来のまた別の例を説明するための目的プログラムの最適化を行うCPUとメモリ等の接続構成図である。
【符号の説明】
1 オブジェクト生成部
2 オブジェクト結合部
3 実行部
4 実行ステップ数更新部
11 ステップ数調整範囲判定手段
12 オブジェクト生成手段
13 コード解析ステップ数計測手段
14 コード解析ステップ数調整手段
21 オブジェクト結合手段
22 個別ステップ数調整情報結合手段
23 メモリ割付ステップ数調整手段
31 実行ステップ数計測手段
32 不要ステップ削除手段
33 外部モデル
34 ターゲットシステム
41 実行ステップ数調整手段
50 ソースプログラム
51 命令実行ステップ数情報
52 オブジェクト
53 個別ステップ数調整情報
54 ステップ数調整オブジェクト
55 メモリ割付情報
56 実行形式
57 結合ステップ数調整情報
58 実行ステップ数計測結果
[0001]
BACKGROUND OF THE INVENTION
TECHNICAL FIELD The present invention relates to a method for adjusting the number of execution steps of a program, an adjustment device for the method, and a recording medium storing the program, and more particularly, an adjustment method for the number of execution steps of the target program, the adjustment device, the purpose program, About.
[0002]
[Prior art]
In general, in order to improve the performance of a program, optimization of a compiler and knowing the execution speed of the program are one of important factors in program development.
[0003]
It is ideal for this compiler to operate the program at a high speed and reduce the size of the program so that the program can be stored in a recording medium for a limited time. Usually, the conversion of the source program for this purpose is performed by the compiler. This is called optimization. Further, the execution speed of the program is predicted or measured, and the source program is corrected based on the result, or the compiler is re-optimized based on the execution speed result.
[0004]
However, if the source program is modified or the compiler is optimized, there may be a problem in the operation of the program when the execution speed of the program changes.
[0005]
For example, the first defect example occurs when an operation speed of an external circuit connected to a CPU that operates according to a program is slow, and therefore a time waiting process is inserted into the program.
[0006]
In addition, the second problem example occurs when an external input needs to be accurately measured or an external output needs to be accurately performed, and a waiting process is inserted into the program for that purpose.
[0007]
These problems do not occur when time is accurately measured using a timer circuit, but they occur when the time wait processing mechanism or the wait processing mechanism is in a format that depends on the number of instruction code execution steps in the program. To do. Originally, the time should be accurately measured using a timer circuit, but depending on several factors, it may depend on the number of instruction code execution steps of the program.
[0008]
The first factor is a problem of diversion of the source program. For example, when the source program is realized by an assembler instruction depending on the CPU or a timer circuit, the algorithm of the source program is corrected. However, if this algorithm is modified directly, the modification becomes cumbersome and the reliability becomes poor. Therefore, it depends on the more reliable modification of the number of instruction code execution steps compared to the modification of the algorithm. is there.
[0009]
The second factor is the price problem in embedded systems. Generally, when a timer circuit or the like is incorporated in a system, the price increases accordingly. In recent years, although the CPU performance has improved, it is required that the program incorporates a complicated function in accordance with the CPU performance, and a CPU having sufficient performance cannot be used in many cases.
[0010]
In short, it can be said that the above-mentioned two problems are not lost due to these factors.
[0011]
In order to suppress these two problems, in a small-scale system, a trap instruction is embedded at a necessary point in the target program, and adjustment is performed after the program is actually operated on the target system. However, when the scale of the program is large and there are many adjustment points, it was necessary to repeat the adjustment many times after the recompilation and other operations, which took time.
[0012]
Further, as disclosed in, for example, Japanese Patent Application Laid-Open No. 11-039155 (Reference 1) and Japanese Patent Application Laid-Open No. 11-296416 (Reference 2), a method of statically analyzing a source program and outputting an execution step There is also. In this method, the execution step changes depending on the optimization of the compiler, and therefore it is necessary to repeat the adjustment many times. In addition, this method takes time, and adjustment using dynamic measurement performed on the target system and static adjustment by source analysis require that the source program be modified many times. Diversion was significantly hindered.
[0013]
Furthermore, as a method for dynamic measurement, there is also a compiling method described in, for example, Japanese Patent Laid-Open No. 6-282444 (Document 3). This compiling method selects a machine language prepared in advance or measures only the number of instructions, and is insufficient for preventing the above-described two problems.
[0014]
FIG. 16 is a system configuration diagram showing an example of a conventional method for adjusting the number of execution steps. As shown in FIG. 16, the conventional adjustment of the number of execution steps includes an object generation unit 1a that creates an object 52 from a source program 50, an object combination unit 2a, and an execution unit 3a that measures the number of execution steps. is doing. The object generation unit 1 a includes an object generation unit 12, a code analysis step number measurement unit 13, and an assembler source generation unit 15. The object generation unit 1 a measures the object 52 and the step number based on the instruction execution step number information 51 from the source program 50. The result 61 is output and the assembler source 60 is output from the assembler source generation means 15. The object combining unit 2 a includes an object combining unit 21 that combines the objects 52 based on the memory allocation information 55, and outputs an execution format 56. Furthermore, the execution unit 3 a includes an execution step number measuring unit 31, exchanges information with the target system 34, and outputs an execution step number measurement result 59 using the external model 33 and the execution format 56.
[0015]
The source program 50 is a source program written in C language, assembly language or the like, and the object 52 is an object code group obtained by converting the source program into an instruction code by a compiler or assembler. Here, the instruction execution step number information 51 includes an instruction code and the number of execution steps of the instruction code. The object 52 is output as an execution format 56 by the object combining means 21 based on the memory allocation information 55. The execution format 56 is an object code group that can be executed by the execution unit 3a. On the other hand, the target system 34 is hardware such as a memory or an external device when the execution unit 3a is an emulator, for example, and the external model 33 is a memory or external device when the execution unit 3a is a simulator, for example. This is a file that defines the configuration and operation for simulating the software.
[0016]
As described above, in the conventional adjustment of the number of execution steps (Reference 1), the source program 50 is analyzed, and the step number measurement result 61 is added to the assembler source 60 and output. Is trying to predict. That is, in this conventional example, it is necessary to adjust the number of execution steps by repeating the modification of the source program 50 and the generation of the object 52 according to the number of execution steps added to the assembler source 60.
[0017]
In the above-described system, even if the technique described in Document 2 is used, Document 2 analyzes the source program 50 and obtains the number of steps for each loop based on the step number measurement result 61. Since 50 execution steps are predicted, only the number of instructions per loop is measured, and the number of execution steps cannot be obtained.
[0018]
Similarly, in the system described above, even if a system such as Document 3 is used, in Document 3, when the object generation unit 1a and the object combination unit 2a are incorporated, or when the object 52 is generated by translating the source program 50 Even though the execution unit 3a can update the instruction execution step number information 51 to an optimum one, it can only determine the instruction prepared in advance, and thus cannot determine the execution step number.
[0019]
Therefore, in the above-described conventional example, in addition to insufficient measurement technology, the communication part of the system connecting a plurality of external devices is configured to depend on the number of instruction code execution steps of the program described above. In such a case, the measurement as described above and the correction of the source program are performed in all combinations of device connections, and there is a problem that the evaluation at a later stage of program development becomes longer. Further, during the development of the program, the external circuits such as ROM, RAM, and I / O connected to the CPU and the aforementioned external device need to reflect the results easily because the timing changes.
[0020]
From the above, the countermeasures for the above-mentioned two problems are taken without changing the algorithm and the source program is not corrected, the adjustment time by recompilation is shortened, and further, an external circuit in the middle of development or It is important to be able to easily adjust the timing of external devices.
[0021]
FIG. 17 is a system configuration diagram using a compiling device for explaining another conventional example. As shown in FIG. 17, this system uses a compiling device 1b in an object generation unit as described in, for example, Japanese Patent Laid-Open No. 2000-194466 (Document 4). In generating 52, the branch history information file 67 is used. In particular, the compiling device 1b includes a branch history information collection code generation means 63, a branch pattern analysis means 64, a loop parallelization means 65, and a loop optimization means 66, and embeds and executes a code for storing branch information. By generating an optimal object program based on the result, the load distribution of each loop in the parallel processing is equalized and the performance of the program is improved.
[0022]
However, since a system using this compiling device creates a history information file from an object, recompilation is required by the compiling device 1b, and there is a problem that optimization cannot be performed without an execution environment. Moreover, this example is only optimization related to branching, and there is a problem that timing adjustment of external circuits (ROM, RAM, I / O, etc.) and external devices cannot be performed.
[0023]
FIG. 18 is a connection configuration diagram of a CPU and a memory for optimizing a target program for explaining another conventional example. As shown in FIG. 18, in this configuration example, as described in, for example, Japanese Patent Application Laid-Open No. 7-64799 (Document 5), a target program generated by a compiler is tried by a computer, and the result of the trial is used as the target program. Is to optimize.
[0024]
In other words, the compiler stores the target program being optimized in the first memory 76 corresponding to the first CPU 75, and requests the OS to execute the trial of the program. In response to this request, the OS sets the trial mode, switches the trial mode changeover switch 72 of the second CPU 73, and stores the second execution status table for storing the dynamic state inside the computer for each instruction executed when the target program is tried. Are set in the second memory 77 connected to the CPU 73 and the trace head designation register 71 is set. The pipeline control mechanism 74 automatically records the dynamic state of the computer in the execution status table every time an instruction is executed. After such a trial, when the recorded contents of the execution status table are passed to the compiler, the compiler optimizes the unoptimized portion of the target program based on the recorded contents. In short, in this conventional example, the result executed by the first CPU 75 is stored by the second CPU 73 from the designated position in the second memory 77 as the execution status table, and the result is notified to the compiler.
[0025]
However, in this example, during the compiler optimization process, the first CPU 75 performs a trial run, and then reads the execution status table recorded by the second CPU 73 and executes the optimization by the compiler again. There is a problem that the compilation time becomes long. Further, in this example, there is a problem that special hardware is required at the time of compilation. For example, in order to record the information output from the pipeline control mechanism 74, the information cannot be recorded unless the performance of the second CPU 73 is at least higher than that of the first CPU 75. The reason is that an instruction for saving in the second memory 77 by the program cannot be executed by one instruction. For this reason, in such a conventional example, timing adjustment of an external circuit or the like cannot be performed.
[0026]
[Problems to be solved by the invention]
In the system of FIG. 16 described above, when the measurement technique is insufficient and the communication portion of the system connecting a plurality of external devices is configured to depend on the number of instruction code execution steps of the program described above. Measures are required for all combinations of device connections, and the source program must be corrected, which has the disadvantage of increasing the program development time. Furthermore, since the timing of external circuits and the like changes during program development, it is difficult to easily reflect the results.
[0027]
Therefore, without changing the algorithm and correcting the source program, take measures against the above-mentioned problems, shorten the adjustment time due to recompilation, and adjust the timing of external circuits during development. There is also the disadvantage that it is difficult to do easily.
[0028]
In addition, in the system shown in FIGS. 17 and 18, the purpose is to optimize the program. In other words, they are intended to run the program at high speed or to reduce the size of the program. When waiting for time and waiting by inserting instruction codes, execution is performed for each branch route. Matching the number of steps has the disadvantage that it cannot be realized.
[0029]
The purpose of the present invention is to realize accurate time waiting and waiting when inserting time waiting processing and waiting processing on the above-mentioned source program, shorten adjustment time by recompilation, etc., and external circuit in program development, etc. It is an object of the present invention to provide a method for adjusting the number of execution steps of a target program that can easily perform the timing adjustment, an adjustment device for the same, and a recording medium storing the program.
[0030]
[Means for Solving the Problems]
The method for adjusting the number of execution steps of the object program of the present invention is as follows: An execution step adjustment method in an apparatus for generating a target program to be executed on a target system from a source program, The source program Object generated by converting to instruction code Static analysis of the number of instruction steps for each branch structure and branch route, and the result of step number adjustment object Generation The first procedure to generate the Based on the memory allocation information with reference to the memory allocation information of the selected object A second procedure for modifying the step number adjustment object; The generated Combining the object and the step number adjustment object, Said And a third procedure for generating an execution format as a target program.
[0031]
In the first procedure according to the present invention, the step number adjustment object refers to the source program and the instruction execution step number information. And individual step number adjustment information And the second step is Said With reference to the memory allocation information, the individual step number adjustment information and the step number adjustment object are modified. Generated An object and the step number adjustment object are combined to create the execution format and the combined step number adjustment information.
[0032]
The method for adjusting the number of execution steps of the object program of the present invention is as follows: An execution step adjustment method in an apparatus for generating a target program to be executed on a target system from a source program, The source program Object generated by converting to instruction code Static analysis of the number of instruction steps for each branch structure and branch route, and the result of step number adjustment object Generation A first procedure to Based on the memory allocation information by referring to the memory allocation information of the generated object A second procedure for modifying the step number adjustment object; The generated Combining the object and the step number adjustment object, Said A third procedure for generating an execution format as a target program, and the execution format generated by the third procedure are dynamically analyzed based on the step number adjustment information, and an execution step count measurement result is output based on the result. And a fifth procedure for correcting the step number adjustment object using the execution step number measurement result, and when the step number adjustment object is corrected by the fifth procedure, Returning to the third procedure, the execution format as the target program is regenerated.
[0033]
In the first procedure according to the present invention, the first procedure refers to the step number adjustment object by referring to the source program and the instruction execution step number information. And individual step number adjustment information Create and said second step is Said With reference to the memory allocation information, the individual step number adjustment information and the step number adjustment object are modified. Generated An object and the step number adjustment object are combined to create the execution format and the combined step number adjustment information, and the fourth procedure uses the combined step number adjustment information to measure the number of execution steps for the branch route and After the unnecessary step is deleted, the execution step number measurement result is created, and the fifth procedure refers to the execution step number measurement result and corrects the individual step number adjustment information and the step number adjustment object. To be formed.
[0034]
The method for adjusting the number of execution steps of the object program of the present invention is as follows: An execution step adjustment method in an apparatus for generating a target program to be executed on a target system from a source program, The source program Object generated by converting to instruction code Static analysis of the branch structure and the number of instruction steps per branch route Reference to memory allocation information of the generated object Step number adjustment object according to the result Generation A first procedure to: The generated Combining the object and the step number adjustment object, Said A second procedure for generating an execution format as a target program and the execution format generated by the second procedure are dynamically analyzed based on step number adjustment information, and an execution step count measurement result is output based on the result. A third procedure and a fourth procedure for correcting the step number adjustment object based on the execution step number measurement result, and when the step number adjustment object is corrected by the fourth procedure, the second procedure Returning to the procedure, the object program is configured to be regenerated.
[0035]
The object program execution step number adjustment device of the present invention converts an instruction code from a source program. Generated Output the object Generated By combining the objects based on the memory allocation information, an execution format as the target program is created, and the execution step number adjusting device of the target program that measures the number of execution steps thereby refers to the instruction execution step number information. Above Generated Code analysis step number measurement means for performing static analysis of the branch structure of an object and the number of instruction steps for each branch route, and individual step number adjustment information using the result of the static analysis obtained by the code analysis step number measurement means And an object generation unit comprising a code analysis step number adjustment unit for creating a step number adjustment object, Generated An object combining means for combining an object, the step number adjustment object, and the individual step number adjustment information, and outputting an execution format as the target program and combined step number adjustment information; Based on the memory allocation information by referring to the memory allocation information of the generated object An object combination unit comprising: the step number adjustment object; and a memory allocation step number adjustment unit that modifies the individual step number adjustment information. , It is comprised.
[0036]
An execution step number adjusting apparatus for an object program according to the present invention executes the execution format created by the object combining unit, and measures the number of execution steps for each branch route by the combined step number adjustment information. An execution unit of a target program comprising a number measuring unit, an unnecessary step deleting unit for deleting an unnecessary step from the measurement result of the execution step number measuring unit, and outputting an execution step number measurement result, and the execution step number measurement result An execution step number update unit including an execution step number adjustment unit that takes out and adjusts the number of execution steps for each branch route and adjusts the step number adjustment object and the individual step number adjustment information; Means to recombine the execution format and the combined step number adjustment information. It is formed so as.
[0037]
The object program execution step number adjustment device of the present invention converts an instruction code from a source program. Generated Output the object Generated In an object program execution step number adjustment device that creates an execution format as a target program by combining objects based on memory allocation information and thereby measures the number of execution steps.
Referring to the instruction execution step number information Generated Code analysis step number measurement means for performing static analysis of the branch structure of an object and the number of instruction steps for each branch route, and individual step number adjustment information using the result of the static analysis obtained by the code analysis step number measurement means And a code analysis step number adjusting means for creating a step number adjusting object, Based on the memory allocation information by referring to the memory allocation information of the generated object An object generation unit comprising: the step number adjustment object; and memory allocation step number adjustment means for correcting the individual step number adjustment information; Generated An object combining unit including an object, the step number adjustment object, and the individual step number adjustment information, and an object combining unit that outputs an execution format as the target program and outputs the combined step number adjustment information. .
[0038]
An execution step number adjusting apparatus for an object program according to the present invention executes the execution format created by the object combining unit, and measures the number of execution steps for each branch route by the combined step number adjustment information. An execution unit of a target program comprising a number measuring unit, an unnecessary step deleting unit for deleting an unnecessary step from the measurement result of the execution step number measuring unit, and outputting an execution step number measurement result, and the execution step number measurement result An execution step number update unit including an execution step number adjustment unit that takes out and adjusts the number of execution steps for each branch route and adjusts the step number adjustment object and the individual step number adjustment information; Means to recombine the execution format and the combined step number adjustment information. Yo bran is formed.
[0039]
The recording medium storing the program of the present invention is a source program. Object generated by converting to instruction code Static analysis of the number of instruction steps for each branch structure and branch route, and the result of step number adjustment object Generation The first procedure to generate the Based on the memory allocation information with reference to the memory allocation information of the selected object A second procedure for modifying the step number adjustment object; The generated A program to be executed by the target program generation device is recorded by processing the third procedure for combining the object and the step number adjustment object and generating the execution format as the target program.
[0040]
The recording medium storing the program of the present invention is a source program. Object generated by converting to instruction code Static analysis of the number of instruction steps for each branch structure and branch route, and the result of step number adjustment object Generation A first procedure to Based on the memory allocation information by referring to the memory allocation information of the generated object A second procedure for correcting the step number adjustment object; Generated A third procedure for generating an execution format as a target program by combining an object and the step count adjustment object, and dynamically analyzing the execution format generated by the third procedure using the step count adjustment information Then, the fourth procedure for outputting the execution step number measurement result based on the result and the fifth procedure for correcting the step number adjustment object using the execution step number measurement result are processed into the target program execution device. The program to be executed is recorded and configured.
[0041]
The recording medium storing the program of the present invention is a source program. Object generated by converting to instruction code Static analysis of the branch structure and the number of instruction steps per branch route Reference to memory allocation information of the generated object Step number adjustment object according to the result Generation A first procedure to Generated A second procedure for combining an object and the step number adjustment object to generate an execution format as a target program, and dynamically analyzing the execution format generated by the second procedure using step number adjustment information; A target program generation apparatus or the target program is processed using a third procedure for outputting the execution step number measurement result based on the result and a fourth procedure for correcting the step number adjustment object based on the execution step number measurement result. The program to be executed by the execution device is recorded and configured.
[0042]
A recording medium storing the program of the present invention is formed by recording any program created by adjusting the number of execution steps of the target program.
[0043]
DETAILED DESCRIPTION OF THE INVENTION
In the embodiment of the present invention, when the time waiting and waiting described in the source program are performed by inserting an instruction code, the number of execution steps different for each branch route of the program is set to the same number of steps. This is done accurately without using special hardware.
[0044]
Specifically, first, static analysis is performed by a compiler and an assembler, and a step number adjustment object is output according to the result. Next, the linker performs a static analysis based on memory allocation, and corrects the step number adjustment object based on the result. Further, dynamic analysis is performed by an emulator and a simulator, and the step number adjustment object is corrected based on the result. Thereafter, by linking again, the number of execution steps for each branch route of the program is set to the same number of steps. Through the above operation, the number of execution steps is adjusted stepwise.
[0045]
Hereinafter, embodiments of the present invention will be described with reference to the drawings.
[0046]
FIG. 1 is a system configuration diagram of an execution step number adjusting device for explaining an embodiment of the present invention. Note that the same numbers are assigned to the same elements as the circuit and file functions in the system configuration of FIG. 16 described above. As shown in FIG. 1, in the present embodiment, when adjusting the number of execution steps of the target program, the object 52, the individual step number adjustment information 53, and the step number adjustment object 54 are obtained from the source program 50 and the instruction execution step number information 51. An object generation unit 1 that generates a combination of a plurality of objects by using the object 52 and memory allocation information 55, and an object combination unit 2 that generates an execution format (target program) 56 and combined step number adjustment information 57; The execution unit 3 that inputs the model 33 and the target system 34, trially executes the program based on the execution format 56 and the combined step number adjustment information 57, and outputs the execution step number measurement result 58, and the execution step number measurement result 58 to adjust the number of execution steps Performed, and a number of execution steps updating unit 4 updates the individual steps speed adjusting information 53 and the number of steps adjustment object 54 previously described.
[0047]
Here, the source program 50 is a primitive program written in C language, assembly language, or the like, and the instruction execution step number information 51 is composed of an instruction code and the number of execution steps of this instruction code. An object 52 is an object code group obtained by converting a source program into an instruction code by a compiler or assembler. The object 52 is output as an execution format 56 by the object combining unit 2 based on the memory allocation information 55. This execution format 56 is a group of object codes that can be executed by the execution unit 3.
[0048]
On the other hand, the target system 34 is hardware such as a memory or an external device when the execution unit 3 is an emulator, and the external model 33 is a memory or external device when the execution unit 3 is formed by a simulator. A file that defines the configuration and operation for simulation by software. It is not used in the combination of the target system 34 and simulator, and the external model 33 and emulator.
[0049]
Furthermore, the number of execution steps in the execution unit 3 is the number of clocks required when the instruction code is executed by the CPU. Is the sum, difference, and added value. Furthermore, the number of adjustment steps means a value adjusted to make the number of execution steps for each branch route the same.
[0050]
In the following description, analyzing a branch route without executing the instruction code of the source program 50, the object 52, and the execution format 56 by a compiler, assembler, linker, or the like is called static analysis, and the instruction code is executed. Instead, measuring the number of execution steps, the total number of steps, the number of difference steps, and the number of addition steps is called static measurement, and adjusting the number of steps by this static measurement is called static adjustment. Similarly, executing the instruction code in the execution format 56 by an emulator or a simulator and analyzing the branch route based on the execution result is called dynamic analysis. Depending on the execution result, the number of execution steps, the total number of steps, Measuring the number of difference steps and the number of addition steps is called dynamic measurement, and adjusting the number of steps by this dynamic measurement is called dynamic adjustment.
[0051]
The individual step number adjustment information 53 is generated for each source program 50, and includes source file information for identifying the source program 50, a step number range line, a step number range label, step number analysis adjustment data, and a step number adjustment. And step number adjustment range information including the object start label name. The memory allocation information 55 includes a segment name that can identify the type of memory allocation, a memory allocation address range for each segment name, and the number of additional steps that are extra when the memory allocation address range is accessed. . The combined step number adjustment information 57 is obtained by combining the individual step number adjustment information 53.
[0052]
More specifically, there are usually a plurality (n) of source programs 50. When these n source programs 50 are compiled, n objects 52 are generated. At this time, for example, when one step number adjustment range is designated in n source programs 50, n individual step number adjustment information 53 and n × (number of branch routes) step number adjustment objects 54 are generated. The For this reason, n objects 52 and n × (number of branch routes) step number adjustment objects 54 are combined into one to obtain an execution format 56. Similarly, n individual step number adjustment information 53 is combined into one to obtain combined step number adjustment information 57.
[0053]
The object generation unit 1 includes a step number adjustment range determination unit 11 that determines an adjustment range of the number of steps in the source program 50, an object generation unit 12 that generates an actual object based on the determination result of the determination unit 11, and the object A code analysis step number measuring unit 13 for measuring the number of steps for code analysis based on the generation result, and a code analysis step number adjusting unit 14 for adjusting the number of steps for code analysis based on the step number measurement result are provided. The object generation unit 1 is a compiler or assembler, and outputs an object 52, individual step number adjustment information 53, and a step number adjustment object 54 based on the source program 50 and the instruction execution step number information 51. The step number adjustment range determination unit 11 in the object generation unit 1 identifies the measurement range of the source program 50 and outputs initial information of the individual step number adjustment information 53 and the step number adjustment object 54. Further, the code analysis step number measuring unit 13 analyzes the branch route with respect to the measurement range of the object 52 generated by the object generating unit 12 and uses the instruction execution step number information 51 to determine the number of instruction code execution steps for each branch route. And the number of accesses for each memory allocation for each branch route. As a result, the code analysis step number adjusting means 14 obtains the adjustment step number from the instruction step number for each branch route, updates the individual step number adjustment information 53, and sends an instruction code for calling the step number adjustment object 54 to the object 52. Then, the instruction code corresponding to the adjustment step number updated by the individual step number adjustment information 53 is output as the step number adjustment object 54.
[0054]
The object generation unit 2 includes a linker and an archiver, and includes an object combining unit 21, an individual step number adjustment information combining unit 22, and a memory allocation step number adjustment unit 23. Then, the object 52 is combined to output the execution format 56, and the step number adjustment object 54 is combined to output combined step number adjustment information 57. In other words, the object combining means 21 combines the objects 52 and, if necessary, the library created by the archiver or the librarian, and outputs the execution format 56. The individual step number adjustment information combining unit 22 combines the individual step number adjustment information 53 based on the memory allocation information 55 and outputs combined step number adjustment information 57. At this time, the address in the combined step number adjustment information 57 is converted into an absolute address obtained by creating the execution format 56. Next, the memory allocation step number adjustment unit 23 obtains the adjustment step number from the number of accesses by the memory allocation for each branch route by the output of the individual step number adjustment information combination unit 22 and inserts it into the individual step number adjustment information 53. An instruction corresponding to the number of adjustment steps is inserted into the step number adjustment object 54, and an instruction corresponding to the number of adjustment steps is coupled to the execution format 56.
[0055]
Next, the execution unit 3 includes a simulator or an emulator, and includes an execution step number measuring unit 31 and an unnecessary step number deleting unit 32. The execution unit 3 uses the external model 33 or the target system 34, performs emulation or simulation for the execution format 56, and obtains a measurement range for each branch route by the combined step number adjustment information 57, thereby measuring the number of execution steps. The result 58 is output. In particular, the execution step number measuring means 31 takes out the branch start address and branch end address of the branch route in the combined step number adjustment information 57, and sends the instruction code as the measurement start address and measurement end address of the branch route to the simulator or emulator. Measure the number of execution steps. Further, when an instruction other than the branch route such as interrupt processing or DMA transfer is executed, the unnecessary step deleting unit 32 requests the execution step number measuring unit 31 to perform remeasurement or ends the measurement from the measurement start address. An execution step count measurement result 58 is output by subtracting the number of execution steps other than the branch route such as interrupt processing and DMA transfer from the number of instruction code execution steps up to the address.
[0056]
Further, the execution step number update unit 4 includes an execution step number adjustment unit 41, calculates the number of execution steps based on the execution step number measurement result 58, and according to the result, the individual step number adjustment information 53 and the step number adjustment object. And 54 are updated. In short, the execution step number adjusting means 41 obtains the number of difference steps between the value obtained by adding the number of execution steps by memory allocation to the number of execution steps for each branch route by code analysis and the number of execution steps of the execution step number measurement result 58. Then, it is inserted into the individual step number adjustment information 53 as an adjustment step number, and an instruction code corresponding to the difference step number is inserted into the step number adjustment object 54.
[0057]
When the execution unit 3 performs emulation or simulation for the first time in the execution unit 3 described above, the source program 50 depends on the number of adjustment steps by code analysis of the object generation unit 1 and the number of addition steps by memory allocation in the object combination unit 2. The branch route within the adjustment range described in the above is searched, and the number of execution steps for each branch route is roughly adjusted.
[0058]
Thereafter, when the addition step number of the memory allocation information 55 in the object combination unit 2 is changed, the memory allocation step number adjustment unit 23 creates the step number adjustment object 54 in which the change of the addition step number is reflected, and the change By generating the execution format 56 as a result, the number of execution steps for each branch route in the adjustment range described in the source program 50 is also adjusted at the same time.
[0059]
After the execution step number measurement result 58 is output again in the execution unit 3, the execution step number update unit 4 updates the individual step number adjustment information 53. When the individual step number adjustment information 53 is updated, the object combining unit 2 again outputs the execution format 56 in which the accuracy of the number of execution steps for each branch route in the adjustment range is increased. When the number measurement is executed, there is no difference in the number of execution steps for each branch route.
[0060]
The object generation unit 1, the object combination unit 2, the execution unit 3, and the execution step number update unit 4 described above may be recorded on a storage medium (not shown). Here, the storage medium is a computer-readable recording medium in which a program is recorded. Specifically, an optical disk, a magnetic disk, a semiconductor memory, or the like is used. In short, the storage medium may be any medium that is stored in a computer-readable format and converted into a computer-executable format. Accordingly, the computer can directly execute the program stored in the storage medium, or can output the program from the storage medium to another high-speed semiconductor memory or the like, and then execute the program.
[0061]
FIG. 2 is a flowchart for explaining the operation of the system shown in FIG. As shown in FIG. 2, in the operation flow of the entire system, when described in relation to the block diagram of FIG. 1, steps S <b> 1 to S <b> 3 are realized by the step number adjustment range determination unit 11 of the object generation unit 1 and step S <b> 4. Is realized by the object generating means 12, and steps S5 to S7 are realized by the code analysis step number measuring means 13 and the code analysis step number adjusting means 14. Further, step S8 is realized by the object combining means 21 and the individual step number adjustment information combining means 22 in the object combining section 2, steps S9 to S11 are realized by the memory allocation step number adjusting means 23, and step S12 is the object combining means 21. Realized by. Further, steps S13 to S15 are realized by the execution step number measuring unit 31 of the execution unit 3, the unnecessary step number deleting unit 32, and the execution step number adjusting unit 41 of the execution step number updating unit 4, and step S16 is the object combining unit 21. Realized by.
[0062]
First, the step number adjustment range of the source program 50 is searched by steps S1 to S3, and a start label and an end label are inserted in the start line and end line of the step number adjustment range, respectively. That is, it is determined whether or not the step number adjustment start position is detected in step S1, and if it is detected, the process of step S2 is performed. At this time, if step adjustment information exists, it is left as it is, but if it does not exist, step adjustment information is created. In step S3, a step number adjustment range label is inserted into the source program to write step adjustment information. When this writing is completed, the process returns to step S1 and the step adjustment start position is detected again.
[0063]
On the other hand, if the step adjustment start position is not detected in step S1, the object generation in step S4 is performed. In this object generation step, an object 52 is generated from the source program 50 in which the start label and the end label are inserted. As a description example of the source program 50, for example, a pragma pseudo instruction in the C language shown in FIG.
[0064]
Next, in step S5, the branch route in the step number adjustment range included in the object 52 is analyzed based on the start label and the end label, and the instruction code execution step number for each branch route using the instruction execution step number information 51 is calculated. The total and the number of accesses for each memory allocation in each branch route are measured. As a result, the number of adjustment steps is obtained from the number of instruction steps for each branch route, and the individual step number adjustment information 53 is updated.
[0065]
When the analysis and adjustment of this branch route is completed, a step number adjustment object is created from the result of analysis and adjustment in step S5. That is, an instruction code for calling the step number adjustment object 54 is inserted into the object 52, and an instruction code corresponding to the adjustment step number updated with the individual step number adjustment information 53 is inserted into the step number adjustment object 54. Next, in step S7, it is determined whether the adjustment range still remains. If it remains, that is, while the step number adjustment range exists in the object 52, step S5 and step S6 are continued.
[0066]
Next, in step S8, the object 52 is combined and the step number adjustment information is combined to generate the execution format 56 and the combined step number adjustment information 57.
[0067]
Next, in step S9, the number of adjustment steps by memory allocation for each branch route is obtained from the number of accesses for each memory allocation included in the individual step number adjustment information 53, based on the number of steps added in the memory allocation information 55. The step number adjustment information 53 is updated. Next, in step S 10, an instruction code corresponding to the adjustment step number updated by the individual step number adjustment information 53 is inserted into the step number adjustment object 54. When the insertion into the step number adjustment object 54 is completed, in step 11, it is determined whether or not the adjustment range still remains. While the step number adjustment range exists in the execution format 56, step S9 and step S10 are repeated.
[0068]
Next, when the step number adjustment range disappears, the adjusted step adjustment object 54 is combined with the execution format 56 in step S12. Next, in step S13, the branch start address and branch end address of the branch route in the combined step number adjustment information 57 are extracted, and the instruction code execution step number is measured as the measurement start address and measurement end address of the branch route. The result obtained by subtracting the number of execution steps other than the branch route such as DMA transfer is output as the execution step count measurement result 58.
[0069]
Next, in step S14, based on the above adjustment result, a value obtained by adding the number of execution steps by memory allocation to the number of execution steps for each branch route by code analysis, and the number of execution steps of the execution step number measurement result 58 Find the number of difference steps. In step S 14, the obtained difference step number is inserted as the adjustment step number into the individual step number adjustment information 53, and an instruction code corresponding to the difference step number is inserted into the step number adjustment object 54. Further, in step 15, it is determined whether or not the adjustment range still remains. As a result, while the step number adjustment range exists in the execution format 56, step S13 and step S14 continue repeatedly. In short, feedback of the number of execution steps is applied.
[0070]
Finally, in step S16, the step number adjustment object 54 adjusted in step S14 is combined again to create an execution format 56. When the recombination of the objects 54 is completed, a series of processing ends.
[0071]
FIG. 3 is a block diagram of the individual step number adjustment information in FIG. As shown in FIG. 3, the individual step number adjustment information 53 is composed of file information 100 and a plurality of (individual) step number adjustment range information 101. The step number adjustment range information 101 is an adjustment of the step number. A step number adjustment range row 102 in which the range is defined by a row, a step number adjustment range label 103, and a plurality of step number analysis adjustment data 104 are formed. The file information 100 includes the source program 50 and the file names of the objects 52 that are the basis for the individual step number adjustment information 53, the creation date, and the like, and includes the source program 50, the object 52, and the individual step number adjustment information 53. The relationship and the update date / time, the reason for the update (for example, the change of the source program 50, the update by the memory allocation, the update by the number of execution steps) are provided. Therefore, when the code analysis step number adjusting unit 14, the memory allocation step number adjusting unit 23, and the execution step number adjusting unit 41 of FIG. I can know.
[0072]
The plurality of step number analysis adjustment data 104 is formed with a step number adjustment object start label name 105, respectively. As described above, the individual step number adjustment information 53 is generated in step S2 in FIG. 2 and updated in steps S6 and S10. In step S8, the individual step number adjustment information is combined with the object combination.
[0073]
Note that the combined step number adjustment information 57 described above is also composed of file information and a plurality of step number adjustment range information, like the individual step number adjustment information 53.
This is a configuration example of the combined step number adjustment information 57.
[0074]
FIG. 4 is a configuration diagram of the step number adjustment analysis adjustment data in FIG. As shown in FIG. 4, the step number analysis adjustment data 104 in the step number adjustment information 53 includes an analysis start address, a code analysis total step number, a memory allocation individual access number, a code analysis adjustment step number, a memory allocation adjustment step number, and an execution. Example of step number analysis adjustment data when there are multiple pointers for each branch destination, including the number of time measurement steps, the number of execution adjustment steps, and pointers to multiple (branch destinations 1 to n) step number analysis adjustment data Is represented by adjustment data (1-3) 106, 107, 108. For example, the step number analysis adjustment data 106 when there are a plurality of pointers at the branch destination 1 is the analysis start address, the total number of code analysis steps, the number of individual memory allocation accesses, the number of code analysis adjustment steps, the number of memory allocation adjustment steps, the execution It is formed from the number of time measurement steps, the number of adjustment steps at the time of execution, and pointers to step number analysis adjustment data of branch destinations 1-1 to 1-n. In short, when there are n branch destinations for one execution step number adjustment range, n adjustment data are managed by n pointers. That is, a method of managing m adjustment data by m pointers when there are m further branch destinations among the n branch destinations in data 106 is described.
[0075]
That is, in step S5 of FIG. 2 described above, the step number analysis adjustment data is connected by the pointer based on the result of analyzing the branch route.
[0076]
FIG. 5 is a block diagram of the step number adjustment object in FIG. As shown in FIG. 5, the step number adjustment object 54 includes a step number adjustment object start label name [Entry] 106, an instruction code [nop] 107 corresponding to the code analysis adjustment step number, and an instruction corresponding to the memory allocation adjustment step number. A code [nop] 108, an instruction code [nop] 109 corresponding to the number of adjustment steps at the time of execution, and a return code [jmp (jp)] 110 from the step number adjustment object. This step number adjustment object 54 is an example in which a NOP (non-operation) instruction is inserted as an instruction code corresponding to the adjustment step number.
[0077]
That is, in the flow of FIG. 2 mentioned above, it produces | generates by step S6, is updated by step S10, and is couple | bonded by step S12. The step number adjustment object 54 is generated corresponding to the step number adjustment object information, and the step number adjustment object start label name 106 for calling the step number adjustment object 54 from the object 52 and the instruction code corresponding to the code analysis adjustment step number. 107, an instruction code 108 corresponding to the number of memory allocation adjustment steps, an instruction code 109 corresponding to the number of adjustment steps at the time of execution, and an instruction code 110 returned from the step number adjustment object 54.
[0078]
Next, the adjustment operation of the present embodiment will be described with reference to the individual operation flows (FIGS. 6 to 8) in FIG. 2 and FIGS. 3 to 5 described above.
[0079]
FIG. 6 is a flowchart of branch step number analysis and adjustment in FIG. As shown in FIG. 6, this branch step number analysis and adjustment flow is a detailed flow of step S5 of FIG. In the branch step number analysis and adjustment called in step S 5, first, in step S 20, the analysis start address is stored and the in-analysis address is added to the individual step adjustment information 53. When this address storage is completed, a branch instruction is retrieved in step S21.
[0080]
If there is a branch instruction as a result of this search determination, the analysis adjustment process is recursively called in step 23, and the branch destination address at this time is set as the analysis start address.
[0081]
On the other hand, if there is no branch instruction in step S21, in step S22, the total number of steps selected by code analysis (code analysis total number of steps) and the number of accesses for each memory allocation (memory allocation individual access number) are measured. The measurement result is added to the individual step adjustment information 53, and the process ends.
[0082]
In step S24, after returning from the recursive call, in step S24, after returning from the recursive call, pointers to the branch destinations 1 to n in the step number analysis adjustment data 104 of FIG. 4 are set. When the setting of the pointer is completed, it is determined in step S25 whether all branches have been processed. These steps S24 and S25 return to step S23 and continue repeatedly while there is a branch instruction, that is, while there is an unprocessed instruction.
[0083]
Further, when all the branches have been processed, in step S26, the step number analysis adjustment data 106, 107, 108 indicated by the branch destination pointers (branch destinations 1 to n in the step number analysis adjustment data 104 in FIG. 4) are indicated. The difference step number of a certain code analysis total step number is obtained, the code analysis adjustment step number is inserted, and the process ends.
[0084]
FIG. 7 is a flowchart for adjusting the number of memory allocation steps in FIG. As shown in FIG. 7, the memory allocation step number adjustment flow is a detailed flow of step S9 in FIG. In the memory allocation step number adjustment called in step S9, first, a branch instruction is searched in step S30. The search for the branch instruction and the search for the branch instruction described in FIG. 8 mean that the pointer connection of the step number analysis data obtained by the code analysis of FIG. 2 is followed.
[0085]
If there is a branch instruction in step S30, after adjusting the number of memory allocation steps in step S31, it is determined whether or not all branches have been processed in step S32. Here, if there is an unprocessed branch, the process returns to step S31 to perform a recursive call for adjusting the number of steps. However, if no branch instruction remains as a result of the branch instruction search in step S30 described above, the memory allocation step number adjustment process is terminated.
[0086]
Finally, after returning from the recursive call in step S33, the memory allocation individual access obtained by the code analysis indicated by the pointer to the branch destination (the branch destination pointers 1 to n of the step number analysis adjustment data 104 in FIG. 4) The number of memory allocation adjustment steps in the step number analysis adjustment data 1, 2, 3 (106 to 108) in FIG.
[0087]
FIG. 8 is a flowchart for adjusting the number of execution steps in FIG. As shown in FIG. 8, this execution step number adjustment flow is a detailed flow of step S13 of FIG. In adjusting the number of execution steps called in step S13, first, a branch instruction is searched in step S40. If there is a branch instruction, the number of execution steps in step S41 is adjusted, and then in step S43, it is determined whether all branches have been processed. If an unprocessed branch remains as a result of this determination, the processing is repeated repeatedly.
[0088]
On the other hand, if there is no branch instruction in step S40, the branch start address is set as the measurement start address, and the number of execution measurement steps (106 to 108 in FIG. 4) is inserted from the result of execution of the emulator or simulator, and the process ends.
[0089]
However, when the number of execution time steps is obtained for all branches after returning from the recursive call in step S41, the execution time indicated by the branch destination pointers (106 to 108 in FIG. 4) in step S44. The difference step number of the measurement step number is obtained, the adjustment step number at the time of execution is inserted (added), and the process is terminated.
[0090]
FIG. 9 is a block diagram showing an example of the memory allocation information in FIG. As shown in FIG. 9, the memory allocation information 55 includes variables, areas, and the number of addition steps. For example, the variable MEM1 is a low-speed RAM area, and the number of steps to be added is 1. By defining the number of addition steps as 1, 0, 3, etc., the length (time) of different areas is adjusted.
[0091]
FIG. 10 is a block diagram showing an example of the source program in FIG. As shown in FIG. 10, the source program 50 is an example in which #pragma adjust start (start position of the step number adjustment range) and #pragma adjust end (end position of the step number adjustment range) are specified. In this example, the source program 50 within the step number adjustment range is “if (MEM2 == 0) {MEM1 = 0;}”. If the value is 0 with reference to the high-speed RAM of FIG. Write 0 to the RAM, and if “else if (MEM2 == 1) {MEM3 = 0;}” refers to the high-speed RAM and the value is 1, then 0 is written to the I / O port and “else { In MEM2 = 0;} ”, if the value is not 0 or 11 with reference to the high-speed RAM, this means that 0 is written to the high-speed RAM.
[0092]
As described above, when the command specified in the adjustment range represents the above-described meaning, the source program 50 is formed in the object 52 by the object generation unit 1.
[0093]
FIG. 11 is a block diagram showing an example of the object in FIG. As shown in FIG. 11, this object 52 has been converted by the source program 50 within the step number adjustment range of FIG. 10 described above.
[0094]
That is, in FIG. 11, “if (MEM2 == 0)” becomes “CMP MEM2,0” and “BNZ LABEL 1”, and “{MEM1 = 0;}” becomes “MOVE MEM1,0”, “BR”. LABEL 1 END ”,“ else if (MEM2 == 1) ”becomes“ CMP MEM2, 1 ”,“ BNZLABEL 1 2 ”,“ {MEM3 = 0;} ”becomes“ MOVE MEM3, 0 ”,“ “BR LABEL 1 END”, and “else {MEM2 = 0;}” is converted to “MOVE MEM2, 0”, respectively. Symbols A to E represent blocks described in FIG.
[0095]
FIG. 12 is a flowchart of the object shown in FIG. As shown in FIG. 12, when the object 52 is disassembled, this flow is a block in which blocks A and C perform a comparison instruction and branch determination, and blocks B, D, and E substitute blocks for numerical values.
[0096]
However, when the adjustment range (excluding the start and end) of the source program 50 shown in FIG. 10 is specified, an object 52 as shown in FIG. 11 is generated. Therefore, when analyzing a branch route, the side that does not branch first is analyzed first, and the side that branches next is analyzed. As a result, as shown in the flow of FIG. 12, the analysis is performed in the order of blocks A → B → C → D → E.
[0097]
FIGS. 13A to 13C are analysis flow diagrams of the branch route in FIG. As shown in FIG. 13A, this analysis flow is a route including blocks A and B. Similarly, as shown in FIGS. 13B and 13C, these analysis flows are a route composed of blocks A, C, and D and a route composed of blocks A, C, and E. In short, the analysis flow of FIG. 12 has three branch routes as shown in FIG.
[0098]
In this analysis flow, block A is executed in all routes, so no adjustment step is inserted. In addition, the adjustment step is inserted so that the block B has the same number of steps as the total number of steps of the blocks C and D and the total number of steps of the C and E. Since block C is executed by branch route 2 (A → C → D) and branch route 3 (A → C → E), no adjustment step is inserted. Further, an adjustment step is inserted in either of the blocks D and E so that they are the same step.
[0099]
In short, FIG. 13 illustrates the combination of the flow of FIG. 12 for each branch route, and since there are three routes (a) to (c), the total time for each route is made the same. Therefore, an example is shown in which an adjustment step by code analysis, an adjustment step by memory allocation, and an adjustment step at the time of execution are inserted. That is, when processing time of only one step is required for one processing step, the processing times of all routes must match, so the number of steps (number of boxes) such as comparison, branch instruction, adjustment step in FIG. Need to match for each route. The number of boxes for each branch route is adjusted to be the same by the code analysis step number adjusting means 14 in FIG.
[0100]
Next, adjustment of time that cannot be understood only by the number of boxes, for example, adjustment based on the difference in execution steps of MEM1, MEM2, and MEM3 is performed by the memory allocation step number adjusting means 23. That is, as shown in the example of FIG. 9 described above, when the relationship of the addition steps is MEM3>MEM1> MEM1, [the number of addition steps of MEM3−the number of addition steps of MEM2] is branched as shown in FIG. By inserting into the route and inserting [the number of addition steps of MEM3−the number of addition steps of MEM1] into the branch route of FIG. 13A, the portion that is not known only by the number of boxes is adjusted.
[0101]
Furthermore, in the execution unit 3, when the blocks D and E in FIGS. 13B and 13C have a slower number of steps in the execution block D, the difference in the number of steps is inserted into FIG. 13B. As a result, the execution step number adjusting means 41 performs adjustments that are not known only by the number of boxes but not by memory allocation.
[0102]
FIGS. 14A to 14C are analysis flow diagrams in which the object in FIG. 13 is replaced with a step number adjustment object. . As shown in FIGS. 14A to 14C, these analysis flows replace blocks A to E in FIGS. 13A to 13C with blocks A ′ to E ′ and adjust the number of steps. For this reason, new blocks F, G, and H are additionally described.
[0103]
In short, in the present embodiment, the branch route is searched by recursive call in the branch step number analysis and adjustment flow of FIG. 6 described above, and the total steps are determined in order from the branch. Accordingly, in the case of the flow of FIG. 12, the determination is made in the order of blocks E → D → C → B → A.
[0104]
That is, when the block D is determined, the number of adjustment steps of the blocks E and D is inserted into the block E or D, and the maximum number of steps of the block E or D is set as the total number of steps of the block C.
[0105]
When block B is determined, the number of adjustment steps for blocks C and B is inserted into block C or B, and the maximum number of steps for block C or D is taken as the total number of steps for block A.
[0106]
However, in FIG. 13 and FIG. 14, the code analysis adjustment step is inserted in both the blocks E and H, but “LABEL 1” in the blocks B and D in FIG. 13 and the blocks B ′ and D ′ in FIG. Similar to “jump to END”, it is assumed that a branch instruction is inserted.
[0107]
Finally, “code analysis adjustment step” (bottom) in block B in FIG. 13, “code analysis adjustment step” in block D, “code analysis adjustment step” in block E, and “code analysis adjustment step” in block F in FIG. One step can be deleted from the difference step number of “analysis adjustment step” (bottom), “code analysis adjustment step” in block G, and “code analysis adjustment step” in block H.
[0108]
It should be noted that “code analysis adjustment step” in block B in FIG. 13A (the above three), “step in case of branching (false)” in block E, and “code analysis adjustment step” in block F in FIG. (The above three) “Steps in the case of branching (false)” in the block E ′ are inserted as the total number of steps when the individual step number adjustment information 53 is entered.
[0109]
Thus, as shown in FIGS. 14A to 14C, the blocks F, G, and H in which the adjustment steps are collected at the end of the branch route become the step number adjustment objects.
[0110]
The above-described points will be described more specifically with reference to each adjustment flow with reference to FIGS.
[0111]
The blocks A, B, C, D, and E shown in FIG. 12 search the branch route by recursive call as follows by the branch step number analysis and adjustment flow of FIG. decide. Here, the branches are the blocks B and C with respect to the block A, and the blocks D and E with respect to the block C. First, the analysis of the block C is completed after the analysis of the blocks D and E, and the analysis of the block A is completed after the analysis of the blocks B and C.
[0112]
(1) Call analysis of block C from analysis of block A
When another branch instruction is searched from block A (step S21 in FIG. 6) and “BNZ LABEL 1” (FIG. 11) is found, the first recursive call is made with “LABEL1” being the branch destination as the current analysis position. This is performed (step S23).
[0113]
(2) Block E analysis call from block C analysis
When another branch instruction is searched from the block C (step S21) and “BNZ LABEL 1 2” is found, a second recursive call is performed with the branch destination “BNZ LABEL 1 2” as the current analysis position (step S21). S23). Next, when another branch instruction is searched from block E (step S21), since there is no other branch instruction, the number of steps of “MOVE MEM2, 0” is set as the total number of code analysis steps in block E (step S22).
[0114]
(3) Call analysis of block D from analysis of block C
Returning from the second recursive call, the third recursive call is performed with “MOVE MEM 3, 0” in the case of not branching as the current analysis position (step S25). Next, when another branch instruction is searched from block D (step S21), since there is no other branch instruction, the total number of steps of “MOVE MEM 3, 0” and “BR LABEL 1 END” is calculated as the total number of code analysis steps in block D. (Step 22).
[0115]
(4) Save the result of block C from the analysis results of block E and block D
Returning from the third recursive call, the number of steps in which the total number of code analysis total steps of blocks E and D is longer, and the number of steps of “CMP MEM2, 1” and “BNZ LABEL 1 2” in block C Is the total number of code analysis steps in block C (step S26). Further, the difference between the code analysis total step number of blocks E and D is set as the adjustment step number.
[0116]
(5) Call analysis of block B from analysis of block A
Returning from the first recursive call, the fourth recursive call is performed with “MOVE MEM1, 0” in the case of not branching as the current analysis position (step 25). Next, when a multi-branch instruction is searched from block B (step S21), since there is no multi-branch, the total number of steps of “MOVE MEM1,0” and “BR LABEL 1 END” is set as the total number of code analysis steps in block B. (Step S22).
[0117]
(6) Save the results of block A from the analysis results of blocks C and B
Returning from the fourth recursive call, the number of steps of the longer total code analysis steps of blocks C and B, and the number of steps of “CMP MEM2,0” and “BNZ LABEL 1” in block A The added number of steps is set as the total number of code analysis steps in block A (step S26). Further, the difference between the code analysis total step number of blocks C and B is set as the adjustment step number.
[0118]
As a result of detecting the multi-branch twice by the above analysis, there are three branch routes as shown in FIGS. 13A, 13B, and 13C. The analysis result is stored as the step number analysis adjustment data 104 in FIG.
[0119]
Furthermore, as shown in FIG. 13, the number of adjustment steps for blocks E and D is inserted in block D by code analysis adjustment step number D-1, and the number of adjustment steps in blocks C and B is adjusted by code analysis adjustment in block B. The adjustment objects inserted as step numbers B-1, B-2, B-3, and B-4 are generated (step S6 in FIG. 2).
[0120]
Next, according to the memory allocation step number adjustment flow of FIG. 7, the following analysis is performed using the step number analysis adjustment data of FIG.
[0121]
(1) Call analysis of block C from analysis of block A shown in FIG.
The first recursive call of block C is performed (step S31).
[0122]
(2) Block E analysis call from block C analysis
A second recursive call of block E is performed (step S31). Since there is no multi-branch in the block E, the memory allocation individual access number is stored from the block E, and then the process returns from the second recursive call.
[0123]
(3) Call analysis of block D from analysis of block C
Since another branch destination remains in block C, the third recursive call of block D is performed again in step S31 (step S32). Since there is no multi-branch in the block D, the memory allocation individual access number of the block D is stored, and then the process returns from the third recursive call.
[0124]
(4) Save the result of block C from the analysis results of block E and block D
The difference in the number of memory allocation individual accesses between block E and block D is obtained, and the number of memory allocation adjustment steps for each of block E and block D is updated (step S33). The number of steps on the larger memory allocation individual access count is stored as the memory allocation individual access count of block C.
[0125]
(5) Call analysis of block B from analysis of block A
Since returning from the first recursive call and another branch destination remains in step S32, the fourth recursive call of block B is performed again in step S31. Since there is no multi-branch in block B, the memory allocation individual access number of block B is stored, and then the process returns from the fourth recursive call.
[0126]
(6) Save the result of block A from the analysis results of block C and block B
In step S33, the difference in the number of memory allocation individual accesses between block C and block B is obtained, and the number of memory allocation adjustment steps between block C and block B is updated. The number of steps on the larger memory allocation individual access count is stored as the memory allocation individual access count of block A.
[0127]
With the above analysis, the analysis result is realized by updating the step number analysis adjustment data in FIG.
[0128]
Further, as shown in FIG. 13, the number of adjustment steps for blocks E and D is inserted into block E as memory allocation adjustment step number E-1, and the number of adjustment steps for blocks C and B is adjusted to memory allocation adjustment for block B. The adjustment object inserted as the step number B-5 is generated (step S10 in FIG. 2).
[0129]
Next, according to FIG. 8, the analysis is performed as follows using the step number analysis adjustment data of FIG.
[0130]
(1) Call analysis of block C from analysis of block A
The first recursive call of block C is performed (step S41).
[0131]
(2) Block E analysis call from block C analysis
A second recursive call of block E is performed (step S41). Since there is no multi-branch in the block E, the number of measurement steps at the time of execution is measured, and the process returns from the second recursive call (step S42).
[0132]
(3) Call analysis of block D from analysis of block C
Since another branch destination remains (step S43), the third recursive call of block D is performed again in step S41. Since there is no multi-branch in block D, the number of execution time measurement steps is measured (step 42), and the process returns from the third recursive call.
[0133]
(4) Save the result of block C from the analysis results of block E and block D
A difference between the number of measurement steps at the time of execution of the block E and the block D is obtained (step S44), and the number of adjustment steps at the time of execution of the block E and the block D is updated. The number of steps on the side with the larger number of measurement steps at the time of execution is stored as the number of measurement steps at the time of execution of block C.
[0134]
(5) Call analysis of block B from analysis of block A
Returning from the first recursive call and another branch destination remains in step S43, the fourth recursive call of block B is performed again (step 41). Since there is no multi-branch in block B, the number of execution time measurement steps is measured (step 42), and the process returns from the fourth recursive call.
[0135]
(6) Save the result of block A from the analysis results of block C and block B
The difference between the number of measurement steps at the time of execution of block C and block B is obtained (step S44), and the number of adjustment steps at the time of execution of block C and block B is updated. The number of steps with the larger number of execution time measurement steps is stored as the number of execution time measurement steps of block A.
[0136]
The analysis result by the above analysis is realized by updating the step number analysis adjustment data in FIG.
[0137]
Furthermore, as shown in FIG. 13, the number of adjustment steps for blocks E and D is inserted into block D as the number of adjustment steps for execution D-2 (step S14 in FIG. 2), and the number of adjustment steps for blocks C and B is Then, the adjustment object inserted into the block B as the number of adjustment steps B-6 at the time of execution is generated.
[0138]
Finally, adjustment steps B-1 to B-6 are set as block F in FIG. 14, adjustment steps D-1 and D-2 are set as block G in FIG. 14, and adjustment step E-1 is set as block H in FIG. As a result, an adjustment object is generated for each branch route.
[0139]
Although one embodiment of the present invention has been described above, the present invention is not limited to this, and the following modifications are possible.
[0140]
In the above-described embodiment, the object generation unit 1 in FIG. 1 refers to the instruction step number information 51, but the object generation unit 1 refers to the instruction combination number 2 in addition to the instruction step number information 51. The memory allocation information 55 may be referred to. Such a case will be described with reference to FIG.
[0141]
FIG. 15 is a system configuration diagram of an execution step number adjusting device for explaining another embodiment of the present invention. As shown in FIG. 15, the instruction execution step number information 51 and the memory allocation information 55 are combined, and the memory allocation step number adjustment means 23 provided in the object combination unit 2 is provided in the object generation unit 1. can do. As a result, when the memory allocation step number adjustment performed in FIG. 7 described above is performed and the individual memory access number in step S22 in FIG. 6 is obtained, the difference in step S33 in FIG. And the number of adjustment steps can be calculated. Thereby, steps S9 to S12 in FIG. 2 can be deleted.
[0142]
As described above, since there are a plurality of source programs 50, there are a plurality of objects 52, individual step number adjustment information 53, and step number adjustment objects 54. For example, if there are n source programs 50, n objects 52, [n × number of adjustment ranges] individual step number adjustment information 53, and [n × number of adjustment ranges × number of branch routes] steps. Although the number adjustment object 54 is generated, it can be considered that the number adjustment object 54 is collected when stored in the storage device. For example, the individual step number adjustment information 53 of [n × number of adjustment ranges] can be combined into one individual step number adjustment information 53. Further, the step number adjustment objects 54 of [n × number of adjustment ranges × number of branch routes] can be combined into one step number adjustment object 54. However, even in this case, only the way of storing in the storage device is different, and since the information of [number of adjustment ranges] and [number of adjustment ranges × number of branch routes] is respectively obtained, they are equivalent. It is obvious.
[0143]
The above is the configuration of the other embodiment shown in FIG.
[0144]
The step number adjustment object 54 in FIG. 1 can also be realized as a source program. That is, the source program is simple and does not take time to compile or assemble. Moreover, the step number adjusting object 54 can be realized as a library by using an archiver or a librarian. In this case, when the code analysis step number adjusting unit 14, the memory allocation step number adjusting unit 23, and the execution step number adjusting unit 41 are provided with a function for updating the librarian or when the adjustment step number is not desired to be variable, A librarian.
[0145]
Further, the execution unit 3 and the execution step number changing unit 4 in FIG. 1 can be integrated. In that case, the execution step number measurement result 58 can be omitted by including the execution step number adjusting means 41 in the execution unit 3.
[0146]
Furthermore, in the Pragma pseudo instruction in C language such as the start and end of adjustment of the program in the source program 50 of FIG. 10 described above, an option for limiting the maximum number of steps or the minimum number of steps is added to adjust the number of individual steps. By inserting the maximum step number or the minimum step number into the information 53 or the combined step number adjustment information 57, the code analysis step number adjustment unit 14, the memory allocation step number adjustment unit 23, and the execution step number adjustment unit 41 respectively. It is also possible to limit the number of adjustment steps inserted.
[0147]
For example, if there is a loop statement such as a for statement or a while statement in the step number adjustment range and a variable is used for the end condition, the step adjustment may be updated every time. In the Pragma pseudo instruction in C language, such as pragma adjustment start and adjustment end in the source program 50, when a variable is used in the end condition such as a for statement and a while statement, an option for obtaining the average number of steps is added. Adjustment steps inserted into the code analysis step number adjustment means 14, the memory allocation step number adjustment means 23, and the execution step number adjustment means 41 by inserting the average step number into the step number adjustment information 53 and the combined step number adjustment information 57. It is possible to suppress the number disturbance. In addition, by making the number of adjustment steps a fixed number of steps or inserting a special comment that can limit the maximum number of steps or the minimum number of steps in places where variables are used in the end condition such as for statement and while statement The number of adjustment steps can be limited. The reason is that fixing a certain range to a certain number of steps also invalidates the adjustment for a part, and if too many adjustment steps are included, the overall processing time becomes too long. It is.
[0148]
On the other hand, unlike the above-described pragma adjustment start and adjustment end in FIG. 10, the step without using the Pragma pseudo instruction in C language and correcting the source program 50 at all by the line number of the individual step number adjustment information 53 or the like. It is also possible to simplify the number adjustment range determination means 11. In other words, by putting the range to be adjusted of the source program 50 directly into the individual step number adjustment information 53, the start label and the end label are generated from the line number in the method not using the #pragma pseudo instruction. For example, if the file name of the source program 50 is the file name “abcd”, the adjustment start line is the 11th line, and the adjustment end line is the 20th line, the file name “abcd” and the line number are combined. In addition, a method in which abcd11 is a start label and abcd20 is an end label can be considered.
[0149]
Needless to say, the modifications of the embodiment described above are not limited to these, and various modifications can be made within the scope of the claims.
[0150]
【The invention's effect】
As described above, according to the object program execution step number adjusting method and the adjusting apparatus of the present invention, the operation speed of the external circuit connected to the CPU operated by the program is slow, and the time waiting process is inserted into the source program. Even at times, there is an effect that an accurate waiting time can be obtained. In addition, the present invention needs to accurately measure an external input or accurately perform an external output, and has an effect that an accurate waiting can be realized even when a waiting process is inserted into a source program.
[0151]
The reason is that by making the number of steps for each branch route of the source program the same step, the waiting time error due to the difference in the number of instruction steps that existed for each branch route is eliminated, and the actual operation of the external circuit and external device is eliminated. This is because the corresponding waiting time can be reflected.
[0152]
In other words, the compiler or assembler analyzes the branch route, measures the number of instruction code execution steps for each branch route, and roughly adjusts to the same number of steps for each branch route. This is because, by measuring the number of execution steps in which the instruction code is emulated or simulated, the number of steps different from the number of execution steps of the instruction code can be finely adjusted so that the same number of steps is obtained for each branch route.
[0153]
In addition, since the present invention outputs the target object and the step number adjustment object separately, it is only necessary to recombine after adjusting the step number adjustment object in order to adjust the time waiting and waiting. This has the effect of shortening the adjustment period due to recompilation.
[0154]
Furthermore, since the present invention performs fine adjustment based on the measurement result of the number of execution steps by an emulator or simulator, when upgrading the external circuit or external device of the target system, after adjusting the step number adjustment object It is only necessary to recombine, and there is an effect that timing adjustment of an external circuit or an external device during development can be easily performed.
[Brief description of the drawings]
FIG. 1 is a system configuration diagram of an execution step number adjusting device for explaining an embodiment of the present invention;
FIG. 2 is a flowchart for explaining the operation of the system shown in FIG. 1;
FIG. 3 is a configuration diagram of individual step number adjustment information in FIG. 1;
4 is a configuration diagram of step number analysis adjustment data in FIG. 3; FIG.
FIG. 5 is a configuration diagram of a step number adjustment object in FIG. 1;
6 is a flowchart of branch step number analysis and adjustment in FIG. 2; FIG.
7 is a flowchart for adjusting the number of memory allocation steps in FIG. 2; FIG.
FIG. 8 is a flowchart for adjusting the number of execution steps in FIG. 2;
9 is a block diagram showing an example of memory allocation information in FIG. 1. FIG.
10 is a block diagram showing an example of a source program in FIG. 1. FIG.
11 is a block diagram showing an example of the object in FIG.
12 is a flowchart of the object shown in FIG.
13 is an analysis flow diagram of the branch route in FIG. 12. FIG.
FIG. 14 is an analysis flowchart in which the object in FIG. 13 is replaced with a step number adjustment object.
FIG. 15 is a system configuration diagram of an execution step number adjusting device for explaining another embodiment of the present invention;
FIG. 16 is a system configuration diagram showing an example of a conventional method for adjusting the number of execution steps.
FIG. 17 is a system configuration diagram using a compiling device for explaining another conventional example.
FIG. 18 is a connection configuration diagram of a CPU and a memory for optimizing a target program for explaining another conventional example.
[Explanation of symbols]
1 Object generator
2 Object connection part
3 execution part
4 execution step number update part
11 Step number adjustment range determination means
12 Object generation means
13 Code analysis step number measuring means
14 Code analysis step number adjustment means
21 Object combination means
22 Individual step number adjustment information combining means
23 Memory allocation step number adjustment means
31 execution step number measuring means
32 Unnecessary step deletion means
33 External model
34 Target system
41 execution step number adjusting means
50 source programs
51 Instruction execution step number information
52 objects
53 Individual step number adjustment information
54 Step number adjustment object
55 Memory allocation information
56 Execution format
57 Combined step number adjustment information
58 Number of steps executed

Claims (13)

ソースプログラムからターゲットシステム上で実行される目的プログラムを生成する装置における実行ステップ調整方法であって、
前記ソースプログラムより命令コードに変換して生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析を行い、その結果によりステップ数調整オブジェクトを生成する第1の手順と、
前記生成されたオブジェクトのメモリ割付情報を参照し該メモリ割付情報に基づき前記ステップ数調整オブジェクトを修正する第2の手順と、
前記生成されたオブジェクトと前記ステップ数調整オブジェクトを結合し、前記目的プログラムとしての実行形式を生成する第3の手順とを含むことを特徴とする目的プログラムの実行ステップ数調整方法。
An execution step adjustment method in an apparatus for generating a target program to be executed on a target system from a source program,
A first procedure for performing a static analysis of the branch structure of an object generated by converting the source program into an instruction code and the number of instruction steps for each branch route, and generating a step number adjustment object based on the result;
A second procedure of referring to the memory allocation information of the generated object and correcting the step number adjustment object based on the memory allocation information ;
Combining the step number adjustment object and the generated object, the third step and execution step number adjustment method of the object program, characterized in that it comprises a for generating executable as the object program.
前記第1の手順は、前記ソースプログラムおよび命令実行ステップ数情報を参照して、前記ステップ数調整オブジェクトと個別ステップ数調整情報とを作成し、前記第2の手順は、前記メモリ割付情報を参照して、前記個別ステップ数調整情報と前記ステップ数調整オブジェクトを修正し、第3の手順は、前記生成されたオブジェクトおよび前記ステップ数調整オブジェクトを結合して前記実行形式および結合ステップ数調整情報を作成する請求項1記載の目的プログラム実行ステップ調整方法。The first procedure, referring to the source program and instruction execution step number information, create a step speed adjusting object and the individual number of steps adjustment information, the second procedure, see the memory allocation information Then, the individual step number adjustment information and the step number adjustment object are modified, and the third procedure combines the generated object and the step number adjustment object to obtain the execution format and the combined step number adjustment information. 2. The object program execution step adjustment method according to claim 1, wherein the object program execution step adjustment method is created. ソースプログラムからターゲットシステム上で実行される目的プログラムを生成する装置における実行ステップ調整方法であって、
前記ソースプログラムより命令コードに変換して生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析を行い、その結果によりステップ数調整オブジェクトを生成する第1の手順と、
前記生成されたオブジェクトのメモリ割付情報を参照し該メモリ割付情報に基づき前記ステップ数調整オブジェクトを修正する第2の手順と、
前記生成されたオブジェクトと前記ステップ数調整オブジェクトを結合し、前記目的プログラムとしての実行形式を生成する第3の手順と、
前記第3の手順により生成された前記実行形式を前記ステップ数調整情報によって動的解析を行い、その結果により実行ステップ数計測結果を出力する第4の手順と、
前記実行ステップ数計測結果を用いて前記ステップ数調整オブジェクトを修正する第5の手順とを含み、
前記第5の手順により前記ステップ数調整オブジェクトが修正されたとき、前記第3の手順に戻って前記目的プログラムとしての実行形式を再生成することを特徴とする目的プログラムの実行ステップ数調整方法。
An execution step adjustment method in an apparatus for generating a target program to be executed on a target system from a source program,
A first procedure for performing a static analysis of the branch structure of an object generated by converting the source program into an instruction code and the number of instruction steps for each branch route, and generating a step number adjustment object based on the result;
A second procedure of referring to the memory allocation information of the generated object and correcting the step number adjustment object based on the memory allocation information ;
Combining the step number adjustment object and the generated object, a third procedure of generating the executable as the object program,
A fourth procedure for performing dynamic analysis on the execution format generated by the third procedure based on the step number adjustment information and outputting an execution step number measurement result based on the result;
And a fifth procedure for correcting the step number adjustment object using the execution step number measurement result,
When the step number adjustment object is corrected by the fifth procedure, the method returns to the third procedure and regenerates the execution format as the target program.
前記第1の手順は、前記ソースプログラムおよび命令実行ステップ数情報を参照して、前記ステップ数調整オブジェクトと個別ステップ数調整情報とを作成し、前記第2の手順は、前記メモリ割付情報を参照して、前記個別ステップ数調整情報と前記ステップ数調整オブジェクトを修正し、第3の手順は、前記生成されたオブジェクトおよび前記ステップ数調整オブジェクトを結合して前記実行形式および結合ステップ数調整情報を作成し、前記第4の手順は、前記結合ステップ数調整情報を用いて、分岐ルートに対する実行ステップ数の計測および不要ステップの削除を行った後に、前記実行ステップ数計測結果を作成し、前記第5の手順は、前記実行ステップ数計測結果を参照し、前記個別ステップ数調整情報と前記ステップ数調整オブジェクトを修正する請求項3記載の目的プログラムの実行ステップ数調整方法。The first procedure, referring to the source program and instruction execution step number information, create a step speed adjusting object and the individual number of steps adjustment information, the second procedure, see the memory allocation information Then, the individual step number adjustment information and the step number adjustment object are modified, and the third procedure combines the generated object and the step number adjustment object to obtain the execution format and the combined step number adjustment information. The fourth procedure creates the execution step number measurement result after measuring the number of execution steps and deleting unnecessary steps for the branch route using the combined step number adjustment information. Step 5 refers to the execution step number measurement result, and determines the individual step number adjustment information and the step number adjustment object. 3. the number of execution steps adjustment method of the object program according to fix-object. ソースプログラムからターゲットシステム上で実行される目的プログラムを生成する装置における実行ステップ調整方法であって、
前記ソースプログラムより命令コードに変換して生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析および前記生成されたオブジェクトのメモリ割付情報の参照を行い、それらの結果によりステップ数調整オブジェクトを生成する第1の手順と、
前記生成されたオブジェクトと前記ステップ数調整オブジェクトを結合し、前記目的プログラムとしての実行形式を生成する第2の手順と、
前記第2の手順により生成された前記実行形式をステップ数調整情報によって動的解析を行い、その結果により実行ステップ数計測結果を出力する第3の手順と、
前記実行ステップ数計測結果により前記ステップ数調整オブジェクトを修正する第4の手順とを含み、
前記第4の手順によって前記ステップ数調整オブジェクトが修正されたとき、前記第2の手順に戻って前記目的プログラムを再生成することを特徴とする目的プログラムの実行ステップ数調整方法。
An execution step adjustment method in an apparatus for generating a target program to be executed on a target system from a source program,
Performs static analysis of the branch structure of the object generated by converting the instruction code from the source program and the number of instruction steps for each branch route, and references the memory allocation information of the generated object, and the number of steps based on the result. A first procedure for generating an adjustment object;
Combining the step number adjustment object and the generated object, a second step of generating an executable as the object program,
A third procedure for performing dynamic analysis on the execution format generated by the second procedure using step number adjustment information, and outputting a result of measuring the number of execution steps based on the result;
A fourth procedure for correcting the step number adjustment object based on the execution step number measurement result,
When the step number adjustment object is modified by the fourth procedure, the target program execution step number adjustment method is returned to the second procedure and the target program is regenerated.
ソースプログラムより命令コードに変換して生成されたオブジェクトを出力し、前記生成されたオブジェクトをメモリ割付情報に基づいて結合することにより、目的プログラムとしての実行形式を作成し、それによって実行ステップ数を計測する目的プログラムの実行ステップ数調整装置において、
命令実行ステップ数情報を参照して前記生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析を行うコード解析ステップ数計測手段と,前記コード解析ステップ数計測手段によって得られた静的解析の結果を用い、個別ステップ数調整情報およびステップ数調整オブジェクトを作成するコード解析ステップ数調整手段とを備えるオブジェクト生成部と、
前記生成されたオブジェクト,前記ステップ数調整オブジェクト,前記個別ステップ数調整情報を結合し、前記目的プログラムとしての実行形式と結合ステップ数調整情報を出力するオブジェクト結合手段と,前記生成されたオブジェクトのメモリ割付情報を参照し該メモリ割付情報に基づき前記ステップ数調整オブジェクトおよび前記個別ステップ数調整情報を修正するメモリ割付ステップ数調整手段とを備えるオブジェクト結合部と
を有することを特徴とする目的プログラムの実行ステップ数調整装置。
An object generated by converting into an instruction code from the source program is output, and the generated object is combined based on the memory allocation information to create an execution format as a target program, thereby reducing the number of execution steps. In the device for adjusting the number of execution steps of the target program to be measured,
Code analysis step number measuring means for performing static analysis of the branch structure of the generated object and the number of instruction steps for each branch route with reference to the instruction execution step number information, and obtained by the code analysis step number measuring means An object generation unit comprising code analysis step number adjustment means for creating individual step number adjustment information and a step number adjustment object using the result of static analysis;
Object combining means for combining the generated object, the step number adjustment object, and the individual step number adjustment information, and outputting the execution format as the target program and the combined step number adjustment information, and the memory of the generated object An object combining unit comprising : memory allocation step number adjustment means for referring to the allocation information and correcting the step number adjustment object and the individual step number adjustment information based on the memory allocation information ;
An apparatus for adjusting the number of execution steps of an object program, comprising:
前記目的プログラムの実行ステップ数調整装置は、前記オブジェクト結合部で作成された前記実行形式を実行するとともに、前記結合ステップ数調整情報によって分岐ルートごとの実行ステップ数を計測する実行ステップ数計測手段と,前記実行ステップ数計測手段の計測結果から不要ステップを削除し、実行ステップ数計測結果を出力する不要ステップ削除手段とを備える目的プログラムの実行部と、前記実行ステップ数計測結果より分岐ルートごとの実行ステップ数を取出し、調整を行って、前記ステップ数調整オブジェクトと前記個別ステップ数調整情報を修正する実行ステップ数調整手段を備える実行ステップ数更新部とを有し、前記オブジェクト結合手段により、前記実行形式と前記結合ステップ数調整情報を再結合する請求項6記載の目的プログラムの実行ステップ数調整装置。  The execution step number adjusting device for the target program executes the execution format created by the object combining unit, and executes an execution step number measuring unit that measures the number of execution steps for each branch route by the combined step number adjustment information. , An unnecessary step deletion unit that deletes unnecessary steps from the measurement result of the execution step number measurement unit, and outputs an execution step number measurement result; An execution step number update unit including an execution step number adjustment unit that takes out and adjusts the number of execution steps, and adjusts the step number adjustment object and the individual step number adjustment information. The execution format and the combination step number adjustment information are recombined. Number of execution steps adjuster object program placement. ソースプログラムより命令コードに変換して生成されたオブジェクトを出力し、前記生成されたオブジェクトをメモリ割付情報に基づいて結合することにより、目的プログラムとしての実行形式を作成し、それによって実行ステップ数を計測する目的プログラムの実行ステップ数調整装置において、
命令実行ステップ数情報を参照して前記生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析を行うコード解析ステップ数計測手段と,前記コード解析ステップ数計測手段によって得られた静的解析の結果を用い、個別ステップ数調整情報およびステップ数調整オブジェクトを作成するコード解析ステップ数調整手段と,前記生成されたオブジェクトのメモリ割付情報を参照し該メモリ割付情報に基づき前記ステップ数調整オブジェクトおよび前記個別ステップ数調整情報を修正するメモリ割付ステップ数調整手段とを備えるオブジェクト生成部と、前記生成されたオブジェクト,前記ステップ数調整オブジェクト,前記個別ステップ数調整情報を結合し、前記目的プログラムとしての実行形式と結合ステップ数調整情報を出力するオブジェクト結合手段を備えるオブジェクト結合部とを有することを特徴とする目的プログラムの実行ステップ数調整装置。
An object generated by converting into an instruction code from the source program is output, and the generated object is combined based on the memory allocation information to create an execution format as a target program, thereby reducing the number of execution steps. In the device for adjusting the number of execution steps of the target program to be measured,
Code analysis step number measuring means for performing static analysis of the branch structure of the generated object and the number of instruction steps for each branch route with reference to the instruction execution step number information, and obtained by the code analysis step number measuring means Code analysis step number adjustment means for creating individual step number adjustment information and step number adjustment object using the result of static analysis, and referring to the memory allocation information of the generated object, the number of steps based on the memory allocation information An object generation unit comprising an adjustment object and a memory allocation step number adjustment unit for correcting the individual step number adjustment information; and the generated object, the step number adjustment object, and the individual step number adjustment information, Execution form and combination step as a program Number of execution steps adjuster object program characterized by having an object binding part provided with object combining means for outputting the number adjustment information.
前記目的プログラムの実行ステップ数調整装置は、前記オブジェクト結合部で作成された前記実行形式を実行するとともに、前記結合ステップ数調整情報によって分岐ルートごとの実行ステップ数を計測する実行ステップ数計測手段と,前記実行ステップ数計測手段の計測結果から不要ステップを削除し、実行ステップ数計測結果を出力する不要ステップ削除手段とを備える目的プログラムの実行部と、前記実行ステップ数計測結果より分岐ルートごとの実行ステップ数を取出し、調整を行って、前記ステップ数調整オブジェクトと前記個別ステップ数調整情報を修正する実行ステップ数調整手段を備える実行ステップ数更新部とを有し、前記オブジェクト結合手段により、前記実行形式と前記結合ステップ数調整情報を再結合する請求項8記載の目的プログラムの実行ステップ数調整装置。  The execution step number adjusting device for the target program executes the execution format created by the object combining unit, and executes an execution step number measuring unit that measures the number of execution steps for each branch route by the combined step number adjustment information. , An unnecessary step deletion unit that deletes unnecessary steps from the measurement result of the execution step number measurement unit, and outputs an execution step number measurement result; An execution step number update unit including an execution step number adjustment unit that takes out and adjusts the number of execution steps, and adjusts the step number adjustment object and the individual step number adjustment information. The execution form and the combination step number adjustment information are recombined. Number of execution steps adjuster object program placement. ソースプログラムより命令コードに変換して生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析を行い、その結果によりステップ数調整オブジェクトを生成する第1の手順と、
前記生成されたオブジェクトのメモリ割付情報を参照し該メモリ割付情報に基づき前記ステップ数調整オブジェクトを修正する第2の手順と、
前記生成されたオブジェクトと前記ステップ数調整オブジェクトを結合し、目的プログラムとしての実行形式を生成する第3の手順とを処理として、目的プログラムの生成装置に実行させるプログラムを記録したことを特徴とするプログラムを記憶した記録媒体。
A first procedure for statically analyzing the branch structure of the object generated by converting the instruction code from the source program and the number of instruction steps for each branch route, and generating a step number adjustment object based on the result;
A second procedure of referring to the memory allocation information of the generated object and correcting the step number adjustment object based on the memory allocation information ;
A program to be executed by a target program generation device is recorded by combining the generated object and the step number adjustment object as a process and a third procedure for generating an execution format as a target program. A recording medium that stores a program.
ソースプログラムより命令コードに変換して生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析を行い、その結果によりステップ数調整オブジェクトを生成する第1の手順と、
前記生成されたオブジェクトのメモリ割付情報を参照し該メモリ割付情報に基づき前記ステップ数調整オブジェクトを修正する第2の手順と、
前記生成されたオブジェクトと前記ステップ数調整オブジェクトを結合し、目的プログラムとしての実行形式を生成する第3の手順と、
前記第3の手順により生成された前記実行形式を前記ステップ数調整情報によって動的解析を行い、その結果により実行ステップ数計測結果を出力する第4の手順と、
前記実行ステップ数計測結果を用いて前記ステップ数調整オブジェクトを修正する第5の手順とを処理として、目的プログラムの実行装置に実行されるプログラムを記録したことを特徴とするプログラムを記憶した記憶媒体。
A first procedure for statically analyzing the branch structure of the object generated by converting the instruction code from the source program and the number of instruction steps for each branch route, and generating a step number adjustment object based on the result;
A second procedure of referring to the memory allocation information of the generated object and correcting the step number adjustment object based on the memory allocation information ;
A third procedure for combining the generated object and the step number adjustment object to generate an execution format as a target program;
A fourth procedure for performing dynamic analysis on the execution format generated by the third procedure based on the step number adjustment information and outputting an execution step number measurement result based on the result;
A storage medium storing a program, in which a program to be executed by an execution device of a target program is recorded by processing the fifth procedure for correcting the step number adjustment object using the execution step number measurement result .
ソースプログラムより命令コードに変換して生成されたオブジェクトの分岐構造および分岐ルートごとの命令ステップ数の静的解析および前記生成されたオブジェクトのメモリ割付情報の参照を行い、それらの結果によりステップ数調整オブジェクトを生成する第1の手順と、
前記生成されたオブジェクトと前記ステップ数調整オブジェクトを結合し、目的プログラムとしての実行形式を生成する第2の手順と、
前記第2の手順により生成された前記実行形式をステップ数調整情報によって動的解析を行い、その結果により実行ステップ数計測結果を出力する第3の手順と、
前記実行ステップ数計測結果により前記ステップ数調整オブジェクトを修正する第4の手順とを処理として、目的プログラムの生成装置または前記目的プログラムの実行装置に実行させるプログラムを記録したことを特徴とするプログラムを記憶した記録媒体。
Static analysis of the branch structure of the object generated by converting the instruction code from the source program and the number of instruction steps for each branch route, and reference to the memory allocation information of the generated object, and adjustment of the number of steps based on the result A first procedure for creating an object;
A second procedure for combining the generated object and the step number adjustment object to generate an execution format as a target program;
A third procedure for performing dynamic analysis on the execution format generated by the second procedure using step number adjustment information, and outputting a result of measuring the number of execution steps based on the result;
A program in which a program to be executed by an object program generation device or an object program execution device is recorded by processing the fourth procedure for correcting the step number adjustment object based on the execution step number measurement result. Recorded recording medium.
前記目的プログラムの実行ステップ数調整によって作成されたプログラムを記録した請求項10乃至請求項12のいずれかに記載のプログラムを記憶した記録媒体。The recording medium which memorize | stored the program in any one of Claim 10 thru | or 12 which recorded the program produced by the execution step number adjustment of the said objective program.
JP2001126084A 2001-04-24 2001-04-24 Method for adjusting the number of execution steps of a target program, adjusting device therefor, and recording medium storing the program Expired - Fee Related JP3758991B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2001126084A JP3758991B2 (en) 2001-04-24 2001-04-24 Method for adjusting the number of execution steps of a target program, adjusting device therefor, and recording medium storing the program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2001126084A JP3758991B2 (en) 2001-04-24 2001-04-24 Method for adjusting the number of execution steps of a target program, adjusting device therefor, and recording medium storing the program

Publications (2)

Publication Number Publication Date
JP2002323981A JP2002323981A (en) 2002-11-08
JP3758991B2 true JP3758991B2 (en) 2006-03-22

Family

ID=18975180

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2001126084A Expired - Fee Related JP3758991B2 (en) 2001-04-24 2001-04-24 Method for adjusting the number of execution steps of a target program, adjusting device therefor, and recording medium storing the program

Country Status (1)

Country Link
JP (1) JP3758991B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009076002A (en) 2007-09-25 2009-04-09 Nec Electronics Corp Method for adjusting control timing, compile program, compile apparatus, and information processor
JP5353587B2 (en) * 2009-09-11 2013-11-27 株式会社リコー Embedded program development apparatus and embedded program development method

Also Published As

Publication number Publication date
JP2002323981A (en) 2002-11-08

Similar Documents

Publication Publication Date Title
JP3664473B2 (en) Program optimization method and compiler using the same
JP4042604B2 (en) Program parallelization apparatus, program parallelization method, and program parallelization program
KR101418969B1 (en) Processor and methods of compiling
US7337301B2 (en) Designing configurable processor with hardware extension for instruction extension to replace searched slow block of instructions
JP3602857B2 (en) Multi-model compatible information processing system and method
JP5717015B2 (en) Architecture optimizer
US6588009B1 (en) Method and apparatus for compiling source code using symbolic execution
US20070011664A1 (en) Device and method for generating an instruction set simulator
US20120185820A1 (en) Tool generator
US20100199269A1 (en) Program optimization device and program optimization method
US7702499B1 (en) Systems and methods for performing software performance estimations
US20070271080A1 (en) Model generation method for software/hardware collaboration design
JP2001166946A (en) Method and device for compiling source code by flattening hierarchy
JP5504960B2 (en) Simulation apparatus and simulation method
JP3758991B2 (en) Method for adjusting the number of execution steps of a target program, adjusting device therefor, and recording medium storing the program
CN110210046B (en) Application program and special instruction set processor integrated agility design method
US5960171A (en) Dynamic signal loop resolution in a compiled cycle based circuit simulator
La Rosa et al. A software development tool chain for a reconfigurable processor
Sarkar et al. LightningSim: Fast and accurate trace-based simulation for High-Level Synthesis
JP5979965B2 (en) Circuit design support apparatus, circuit design support method, and program
JPH10320212A (en) Cache optimizing method
US6968523B2 (en) Design method of logic circuit using data flow graph
Matoussi et al. Loop aware ir-level annotation framework for performance estimation in native simulation
Fischer et al. BUILDABONG: A framework for architecture/compiler co-exploration for ASIPs
JPH02176938A (en) Machine language instruction optimizing system

Legal Events

Date Code Title Description
A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20050801

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20050809

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20050930

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: 20051129

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20051227

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313113

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

LAPS Cancellation because of no payment of annual fees