JP3915019B2 - VLIW processor, program generation device, and recording medium - Google Patents

VLIW processor, program generation device, and recording medium Download PDF

Info

Publication number
JP3915019B2
JP3915019B2 JP16787598A JP16787598A JP3915019B2 JP 3915019 B2 JP3915019 B2 JP 3915019B2 JP 16787598 A JP16787598 A JP 16787598A JP 16787598 A JP16787598 A JP 16787598A JP 3915019 B2 JP3915019 B2 JP 3915019B2
Authority
JP
Japan
Prior art keywords
instruction
unit
word
instructions
add
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
JP16787598A
Other languages
Japanese (ja)
Other versions
JP2000003279A5 (en
JP2000003279A (en
Inventor
信哉 宮地
信生 檜垣
哲也 田中
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Panasonic Corp
Panasonic Holdings Corp
Original Assignee
Panasonic Corp
Matsushita Electric Industrial Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Panasonic Corp, Matsushita Electric Industrial Co Ltd filed Critical Panasonic Corp
Priority to JP16787598A priority Critical patent/JP3915019B2/en
Publication of JP2000003279A publication Critical patent/JP2000003279A/en
Publication of JP2000003279A5 publication Critical patent/JP2000003279A5/ja
Application granted granted Critical
Publication of JP3915019B2 publication Critical patent/JP3915019B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Advance Control (AREA)

Description

【0001】
【発明の属する技術分野】
本発明は、命令供給が十分に行えない環境で使用されても供給されたものから事項する事により、性能劣化を抑制するVLIWプロセッサ、プログラム生成装置および記録媒体に関するものである。
【0002】
【従来の技術】
近年のマイクロプロセッサ応用製品の高機能化および高速化に伴い、高い処理能力を持つマイクロプロセッサ(以下、単に「プロセッサ」という。)が望まれている。このため、最近では、1サイクルに複数の命令を同時に実行することが行われている。
【0003】
命令レベルの並列処理を実現する方法として、ダイナミックスケジューリングによるものとスタティックスケジューリングによるものがある。
【0004】
ダイナミックスケジューリングによるものの代表例としてスーパースカラ方式がある。この方式では、実行時に命令コードを解読後、ハードウェアにて動的に命令間の依存関係を解析して並列実行可能か否かを判定し、適切な組み合わせの命令を並列実行する。スタティックスケジューリングによるものの代表例としてVLIW(Very Long Instruction Word)方式がある。この方式は、実行コード生成時にコンパイラ等により静的に命令間の依存関係を解析し、命令コードの移動を行って実行効率の良い命令ストリームを生成する。一般のVLIW方式では、同時実行可能な複数の命令(ここでは「単位命令」と呼ぶ。)を一つの固定長命令供給単位(ここでは「一語」と呼ぶ。)に記述する。この方式を採ると、ハードウェアで命令間の依存解析を行う必要が無いため、ハードウェアを単純化できるというメリットがある。
【0005】
以下、従来技術におけるVLIWプロセッサの動作を図13を用いて説明する。
【0006】
図13は、従来技術におけるVLIWプロセッサの構成図であり、10はデータ、命令等が格納されているメモリ、20はメモリ10から命令等を取り出す命令供給発行部、30は命令供給発行部20で取り出された命令を解読し解読結果を命令実行部へ与える命令解読部である。命令供給発行部20は、メモリ10からの命令等の取り出しを制御する命令フェッチ制御部21とメモリ10から取り出した命令等を格納する命令レジスタ22からなる。また、命令解読部30は、命令の発行を制御する命令発行制御部31とデコーダ32と解読結果を格納するレジスタ33からなる。このプロセッサは、32ビットの単位命令4つから構成される一語を同時に実行することが可能なVLIWプロセッサで、128ビット単位で命令フェッチされる。
【0007】
まず、命令供給発行部20内の命令フェッチ制御部21は、PC2(プログラムカウンタ)、クロック1に基づいて実行する命令のアドレスをアドレスバス11からメモリ10に与える。これにより、メモリ10は指定されたアドレスに対応する命令を128ビットのデータバスによって、命令レジスタ22内の4つの命令レジスタに32ビットずつ命令を供給する。命令レジスタ22は、クロック1に基づいてメモリ10から供給されたデータを格納する。これとともに、命令フェッチが完了したことを意味する命令フェッチフラグ23を”1”とする。このとき、4つの命令レジスタ22には、常に命令が格納される。なお、命令フェッチを開始したとき(ジャンプ命令や割り込みが生じた場合等)、誤った命令の解読を防止するため命令フェッチフラグ23は”0”とされ、キャンセル信号34によりデコーダからNOP(No Operation)が出力される。
【0008】
次に、命令解読部30におけるデコーダ32は、命令フェッチフラグ23により命令レジスタ22に命令が格納されたという情報を得て、命令を解読した結果を出力する。そして、レジスタ33はクロック1によって解読した結果を格納する。
【0009】
最後に、レジスタ33に格納された解読結果は、命令実行部に供給され(図示せず)、命令が実行されることとなる。
【0010】
【発明が解決しようとする課題】
しかしながら、上記従来のVLIWプロセッサでは、命令フェッチを一語長よりも小さい単位で行った場合や命令を可変長とした場合、命令レジスタに命令が供給されるタイミングに差異が生じるため性能が劣化してしまうことがあった。
【0011】
すなわち、従来のVLIWプロセッサは一語長と命令フェッチ単位とが一致しているが、VLIWを組み込みマイコンに適応するとコストの理由から命令フェッチ幅が一語の幅よりも小さくせざるを得ない場合がある。
【0012】
また、たとえ最大語長と命令フェッチ単位とが一致していても可変長命令の場合、2回の命令フェッチによって初めて1つの命令を取り込むことができる場合もある。
【0013】
以下、具体的に図面を用いて説明する。
(1)命令フェッチを一語長よりも小さい単位で行った場合
図14はプログラム例であり、図15は同プログラムを実行した場合のパイプラインの流れを説明したものである。
【0014】
図14では、(10000000)16番地に、メモリから読み込んだ結果をr0レジスタに格納させる命令”mov (mem)、r0”が、(10000004)16番地にはr1レジスタの値を1つ増加させる命令”add #1、r1、r1”が、以下同様に(1000001F)16番地まで命令が配置されている。
【0015】
この場合、図15に示すように、タイミングt1で(10000000)16番地の32ビット長の2つの命令が、タイミングt2で(10000008)16番地の32ビット長の2つの命令が命令フェッチされ、タイミングt3で4つの命令が同時にデコード、t4で実行される。しかし、(10000000)16番地の命令”mov (mem)、r0”は、MEMステージでメモリを読み込んだ結果をレジスタr0に書き込むものであるのに対して、後続する命令である(1000000C)16番地の命令”add #1、r0、r0”はレジスタr0の内容を使用するものであるためWBステージでレジスタの書込を行うまで内容を参照出来ない。このため、レジスタ干渉が発生し、(1000000C)16番地の命令”add #1、r0、r0”はタイミングt6で実行できず、タイミングt7で実行されることになる。
【0016】
結果として、命令供給不足とレジスタ干渉の為に、すべての命令を実行するまでに9サイクル必要となる。
(2)命令を可変長とした場合
図16はプログラム例であり、図17は同プログラムを実行した場合のパイプラインの流れを説明したものである。
【0017】
図16では、(10000000)16番地に、メモリから読み込んだ結果をr0レジスタに格納させる命令”mov (mem)、r0”が、(10000004)16番地にはレジスタr1の値を1つ増加させる命令”add #1、r1、r1”が、以下、同様に(1000001F)16番地まで命令が配置されている。なお、本命令中で、”add #12345678、r3、r3”命令は64ビット単位命令であり、他は32ビット単位命令である。
【0018】
この場合、図17に示すように、(1000000C)16番地の命令は64ビット長の命令であるため、タイミングt1、t2の2回の命令フェッチによって初めて4つの命令が揃い、タイミングt3で4つの命令が同時にデコードされ、t4で実行される。しかし、(10000000)16番地の命令”mov (mem)、r0”は、MEMステージでメモリを読み込んだ結果を書き込んだものであるのに対して、後続する(10000010)16番地の命令”add #1、r0、r0”はレジスタr0の内容を使用するものであるため、WBステージでレジスタの書込を行うまで、内容を参照出来ない。このため、レジスタ干渉が発生し、(10000010)16番地の命令”add #1、r0、r0”はタイミングt6で実行できず、タイミングt7で実行されることになる。
【0019】
結果として、命令供給不足とレジスタ干渉の為に、すべての命令を実行するまでに9サイクル必要となる。
【0020】
このように、上記従来のVLIWプロセッサは、なるべくハードウェアを簡略化することにより高速化を図るものであるため、並列処理できる全ての命令が揃った段階でこれらの命令を同時に実行するものであり、この前提が成り立たない場合には十分な性能を発揮できないという問題点があった。
【0021】
本願発明は、上記従来の課題を解決するもので、命令フェッチを一語長よりも小さい単位で行った場合や命令を可変長とした場合であっても十分な性能を発揮することができるプロセッサを提供するものである。
【0022】
【課題を解決するための手段】
本願発明は、並列実行できる全ての命令が命令フェッチされなくても、命令フェッチされた命令から先に実行することを特徴とするVLIWプロセッサである。
【0023】
【発明の実施の形態】
以下、本発明について、図面を用いて詳細に説明する。
【0024】
(第1の実施の形態)
本実施の形態は、一語長よりも小さい単位で命令フェッチをした場合でも、効率よく命令を実行可能とするプロセッサ等に関するものである。すなわち、4つの命令を同時に実行できるVLIWプロセッサであっても、2つの命令が揃った段階で、デコード、実行を開始することにより、極力レジスタ干渉によるパイプラインインタロックを軽減するものである。また、先行的に実行した命令がI/Oに関する命令である場合、より早くデータを得ることができる。
(1)プロセッサ
図1は本発明の第1の実施の形態におけるプロセッサのブロック図である。図13に示した従来のVLIWプロセッサと比較すると、(a)データバス112が一語長よりも小さい64ビットである点、(b)4つの命令レジスタのうち左側の2つの命令レジスタに命令が格納されたか、右側の2つの命令レジスタに命令が格納されたかを示す位置情報124を持つ点、(c)NOPを出力させるためのキャンセル信号134、135がある点で異なる。
【0025】
このプロセッサは、位置情報124により命令レジスタ122のどこに命令が格納されたかを認識し、この情報を元にキャンセル信号134、135を生成しNOPを出力することにより、命令レジスタ122に命令が格納されたものから順に解読・実行することを実現している。
【0026】
まず、命令供給発行部120内の命令フェッチ制御部121は、PC102、クロック101に基づいて実行する命令のアドレスをアドレスバス111からメモリ110に与える。これにより、メモリ110は64ビットのデータバス112を介して、命令レジスタ122内の左側の2つの命令レジスタに32ビットずつ命令を供給する。命令レジスタ122は、クロック101に基づいてメモリ110から供給されたデータを格納する。これとともに、命令フェッチが完了したことを表すため命令フェッチフラグ123を”1”、さらに命令レジスタ122内の左側の2つに命令が格納されたことを表すため位置情報124を”0”とする。このとき、4つの命令レジスタ122のうち、左側の2つめの命令レジスタには命令が格納されているが、右側の2つの命令レジスタには命令が格納されていないことになる。なお、従来と同様に命令フェッチが完了していない場合、命令フェッチフラグ123は”0”であり、このためキャンセル信号134、135は”0”となり、NOP信号生成器137はNOPを出力する。
【0027】
次に、命令解読部130におけるデコーダ132は、命令フェッチフラグ123により命令レジスタ122に命令が格納されたという情報を得て、命令を解読した結果を出力する。このとき、位置情報124が”0”であり命令レジスタ122のうち左側の2つの命令レジスタにしか命令が格納されていないことを表しているので、キャンセル信号生成器131はキャンセル信号134を”1”に、キャンセル信号135を”0”にする。これにより、デコーダ132におけるNOP生成器137のうち左側の2つからは命令レジスタ122に格納された命令の解読結果が出力され、右側の2つからはNOPが出力される。そして、レジスタ133はクロック101によって解読した結果を格納する。なお、NOP生成器137は、命令解読器136の出力とキャンセル信号との論理積を演算するAND回路である。すなわち、キャンセル信号134、135が”0”となっているときは、解読器136の出力に関わらず、NOPを意味する”0”を出力する。
【0028】
最後に、レジスタ133に格納された解読結果は、命令実行部に供給され(図示せず)、命令が実行されることとなる。
【0029】
なお、次の命令フェッチの際には、フェッチされた命令等は命令レジスタ122の右側の2つに格納され、位置情報124もこれに対応して更新され、そしてキャンセル信号134は”0”、キャンセル信号135は”1”となる。
【0030】
次に、図14に示すプログラムを実行した場合のパイプラインの流れについて、図2を用いて説明する。
【0031】
本プロセッサのパイプラインは、命令供給発行部120によって命令フェッチを行うステージ(IFステージ)、命令解読部130によって命令フェッチした命令を解読するステージ(DECステージ)、解読した命令を演算器を使って実行する実行ステージ(以下EXステージ)、解読した命令がメモリアクセス命令であった場合にメモリアクセスを行うメモリステージ(MEMステージ)、演算やメモリアクセス結果をレジスタに反映させる書込ステージ(以下WBステージ)の5段パイプラインとなっている。さらに、レジスタ間演算の様なEXステージで演算した実行結果を書き込んだレジスタの値は、WBステージでレジスタで実際の書込を行わなくともEXステージ、或いはMEMステージから後続する命令のEXステージへバイパスする事によって、直後に配置した命令でも参照可能である。
【0032】
図14では、(10000000)16番地に、メモリから読み込んだ結果をr0レジスタに格納させる命令”mov (mem)、r0”が、(10000004)16番地にはr1レジスタの値を1つ増加させる命令”add #1、r1、r1”が、以下、同様に(1000001F)16番地まで命令が配置されている。
【0033】
この場合、図2に示すように、タイミングt1で(10000000)16番地の32ビット長の2つの命令が命令フェッチされ、タイミングt2で2つの命令が同時にデコード、t3で実行される。そして、タイミングt6ではWBステージを終え、レジスタr0の内容は使用できる状態になっている。
【0034】
一方、タイミングt4で(10000018)16番地の命令”add #1、r0、r0”の命令フェッチが行われ、タイミングt6でEXステージに入る。このとき、レジスタr0は使用できる状態になっているため、レジスタ干渉によるパイプラインインタロックは生じない。結果として、すべての命令を実行するまでに8サイクル必要となる。
【0035】
図16に示すパイプラインの流れと図2に示すパイプラインの流れとを比較すると、(10000018)16番地の命令”add #1、r0、r0”がEXステージに入るのはタイミングt6で同一である。しかし、(10000000)16番地の命令”mov (mem)、r0”がWBステージを完了するのが、図16ではタイミングt6であるのに対し、図2ではタイミングt5である点で異なる。これは、図15では64ビットの命令フェッチが2回行われ、128ビットの命令フェッチが完了した段階でデコード、実行されているのに対し、図2では64ビットの命令フェッチが行われると次の64ビットの命令フェッチを待たずにデコード、実行を行っているからである。このため、図16ではすべての命令を実行するまでに9サイクル必要であるのに対し、図2では8サイクルで実行が完了している。
【0036】
なお、本実施の形態では、命令の一語長が128ビットであるのに対して、データバスが64ビットである場合を例としているがこれに限られるものではない。例えば、命令の一語長は64ビットでも256ビットでも良く、データバスは32ビット、16ビット等2のべき乗であれば足りる。すなわち、命令の一語長よりもデータバスの幅が小さく、一回の命令フェッチで命令の一語長をフェッチできないケースであれば足りる。この場合、命令の一語長を何回の命令フェッチでフェッチできるかによって、位置情報124、キャンセル信号134、135の数が変わる。本実施の形態では、2回の命令フェッチによって命令の一語長をフェッチしているので、位置情報124は1ビット(1ビットで2つの情報を表すことができる)で、キャンセル信号は2種類設けている。また、4つの命令を同時に実行するVLIWを前提としているがこれに限られない。
【0037】
また、本実施の形態では、メモリ110のみが接続されている場合について説明したが、さらに128ビットで命令フェッチされるメモリが接続されている場合であっても良い。例えば、内蔵メモリは速度重視で128ビットで命令フェッチされるものとし、外部メモリはコストの関係で64ビットで命令フェッチされるものとし、データバス112を介して同列にメモリを接続しメモリ領域によっていずれのメモリを使用するかを切り換えてもよい。この場合、128ビットで命令フェッチされるメモリから読み出された場合はもちろんのこと、64ビット単位で命令フェッチされるメモリから読み出された場合も性能の劣化をなるべく起こさないようにできる。
(2)プログラム生成装置
以上、第1の実施の形態のプロセッサについて述べたが、従来のVLIWプロセッサ用のプログラム生成装置を本第1の実施の形態のプロセッサに適応しようとすると、例えば、一語中に、命令”add #1、r0、r0”が4つ連続した命令を実行する場合、命令供給が十分で一語中の命令を同時に実行した場合にはr0レジスタの値が”1”増加するのに対して、命令供給が不十分で一語中の命令を1単位命令毎に逐次実行した場合にはr0レジスタの値が”4”増加し、命令供給の状態によって実行結果が異なってしまうという問題点が発生する。
【0038】
(第1のプログラム生成装置の構成)
図6は本発明の第1の実施の形態における第1のプログラム生成装置のブロック図である。
【0039】
300は命令列を格納しているメモリ、320は一語内の単位命令を同時実行した場合と一語内の単位命令を逐次実行した場合で実行結果が異なる命令列を抽出する回避対象コード検出手段、330は問題となる命令列を回避する命令列を生成する逐次実行保証コード生成手段、340は逐次実行保証コード生成手段が生成したプログラムを格納する命令列格納手段である。
【0040】
以上の様に構成された本発明の第1の実施の形態の第1のプログラム生成装置について、以下、その動作を説明する。
【0041】
回避対象コード検出手段320はソースコード格納手段300に格納された命令列を入力すると、その命令列中で、一語内の単位命令を同時実行した場合と、一語内の単位命令を逐次実行した場合で実行結果が異なる命令列を回避対象命令列として抽出する。実行結果が異なる命令列とは、具体的には、一語中の任意の単位命令が出力する結果を後続する単位命令が参照する場合の出力命令と参照命令の組み合わせであり、例えば、一語中に含まれる命令”add r0、r1、r1”と後続する命令”add r1、r2、r3”の組み合わせである。
【0042】
図7は回避対象コード検出手段が回避対象命令列を生成するアルゴリズムを示したものである。
【0043】
ステップ401はソースプログラムから1語を読み出すステップ、ステップ402は読み込んだ1語を先頭側から1命令単位ずつ読み出すステップ、ステップ403はステップ402で読み込んだ1命令単位中の出力レジスタ情報を登録するステップ、ステップ404は後続する命令単位を先頭側から1命令単位ずつ読み出すステップ、ステップ405はステップ404で読み込んだ1命令単位中の参照レジスタを登録するステップ、ステップ406はステップ402で登録した出力レジスタとステップ405で登録した参照レジスタが一致しているかどうかを判断するステップ、ステップ407はステップ405で一致していた場合に後続する命令単位を登録するステップ、ステップ408は後続する命令単位があるかを判断し存在する場合にはステップ404以降を実行する判断ステップ、ステップ409は登録された出力命令と参照命令の組み合わせが存在する場合には回避対象コードとして出力するステップ、ステップ410は後続する命令単位があるかを判断し存在する場合にはステップ402以降を実行する判断ステップ、ステップ411は後続する1語があるかを判断し存在する場合にはステップ401以降を実行する判断ステップである。
【0044】
逐次実行保証コード生成手段330は、回避対象コード検出手段320の出力する回避対象命令列の情報を用いて、ソースコード格納手段300に格納された命令列を、同時実行した場合と逐次実行した場合で動作が同一になる命令列への変換を行う。具体的には、命令列中で使用されていないレジスタを検索し、問題となる命令列中の問題となるレジスタを出力する命令の出力レジスタを使用されていないレジスタで置き換えると共に、後続する語で問題となるレジスタを参照する命令の参照レジスタを置き換えたレジスタに置き換える。例えば、一語中に命令”add r0、r1、r1”と後続する命令”add r1、r2、r3”が存在し、後続する語に命令”add #1、r1、r1”が存在する場合(以降、”add r0、r1、r1 & add r1、r2、r3 ; add #1、r1、r1”と記述する。ここで”&”は同一語に含まれ、逐次実行の場合には左から右へ実行する事を、”;”は、後続する語との境界であることを示す)は、命令列中で使用していないレジスタをr4とすると、問題となる命令列中の問題となるレジスタr1を出力する命令”add r0、r1、r1”の出力レジスタを使用されていないレジスタで置き換え”add r0、r1、r4”にすると共に、後続する語で問題となるレジスタを参照する命令”add#1、r1、r1”の参照レジスタを置き換えたレジスタに置き換え”add#1、r4、r1”にする。変換された命令列は命令列格納手段340に出力される。
【0045】
使用されていないレジスタの検索は、検索を全く行わずに問題となる命令語の前後にスタックへの退避復帰処理を装入することによってレジスタを確保することも可能であるし、最適化コンパイラのレジスタ割付けの要素技術を流用することによって基本ブロック内部や基本ブロックを越えた検索を行い、使用されていないレジスタが存在しない場合には問題となる命令語の前後にスタックへの退避復帰処理を装入することによってレジスタを確保するという方法も可能である。
【0046】
(命令列生成装置の動作)
次に具体的な命令を解読実行した場合の本命令列生成装置の動作について説明する。
【0047】
図8(a)は、ソースコード格納手段300に格納された従来のVLIWプロセッサ用のプログラム生成装置が生成した命令列である。
【0048】
まず、(10000000)16番地から始まる一語の処理を行う。
回避対象コード検出手段320はソースコード格納手段300に格納された(10000000)16番地から始まる命令列一語分”add #1、r0、r0& add #1、r1、r1 & add #1、r2、r2 & add#1、r3、r3”を入力し、その命令列中で、一語を同時実行した場合と一語内の単位命令を逐次実行した場合で実行結果が異なる命令列がないかを検査する。この命令列中には問題となる命令列は存在しないので、回避対象コード検出手段320は問題となる命令列を出力しない。
【0049】
逐次実行保証コード生成手段330は、回避対象コード検出手段320が回避対象命令列を出力しないので、ソースコード格納手段300に格納された(10000000)16番地から始まる命令列一語分をそのまま命令列格納手段340へ出力する。
【0050】
次に、後続する(10000010)16番地から始まる一語の処理を行う。
回避対象コード検出手段320はソースコード格納手段300に格納された(10000010)16番地から始まる命令列一語分”add r0、r1、r0& sub r0、r1、r1 & add #1、r2、r2 & add#1、r3、r3”を入力し、その命令列中で、一語を同時実行した場合と一語内の単位命令を逐次実行した場合で実行結果が異なる命令列がないかを検査する。この命令列中には、”add r0、r1、r0 & sub r0、r1、r1”が該当する命令となる。
【0051】
逐次実行保証コード生成手段330は、回避対象コード検出手段320の出力する回避対象命令列”add r0、r1、r0 & sub r0、r1、r1”の情報を用いて、ソースコード格納手段300に格納された命令列を、同時実行した場合と逐次実行した場合で動作が同一になる命令列への変換を行う。後続する命令列を参照し、使用していないレジスタとしてr4レジスタを使い、回避対象命令列中の命令”add r0、r1、r0”を命令”add r0、r1、r4”に変換すると共に、後続するr0を参照する命令を検索し、命令”add #1、r0、r0を命令add #1、r4、r0”に変換した後、命令列格納手段340に出力する。
【0052】
同様にして、(10000020)16番地から始まる命令列一語を処理する事によって、”add r1、r2、r1 & sub r1、r2、r2 ; add #1、r1、r1”を ”add r1、r2、r5 & sub r1、r2、r2 ; add #1、r5、r1”に変換する。
【0053】
また、(10000030)16番地から始まる命令列一語を処理し、回避対象コードが存在するが使用していないレジスタが存在しない場合には、たとえばr6レジスタをスタックへの退避命令”push r6”により確保し、スタックからの復帰命令”pop r6”により復元する事により、”add r2、r3、r2 & sub r2、r3、r3”を”push r6;add r2、r3、r6 & sub r2、r3、r3;mov r6、r2 & pop r6”に変換する。
【0054】
以上の処理によって、回避対象コード検出手段320は、図8(b)の様に、斜線部分の命令列を検出し、逐次実行保証コード生成手段330は、図8(c)の様に、回避対象コード検出手段320の出力する斜線部分の命令列の出力レジスタを変更すると共に、後続する語に含まれる、濃い斜線部分の出力レジスタを参照する参照レジスタを変更した命令列や追加したスタックへのアクセス命令やNOP命令の命令列を命令列格納手段340へ出力する。
【0055】
(第2のプログラム生成装置の構成)
図9は本発明の第1の実施の形態における第2のプログラム生成装置のブロック図である。
【0056】
300は命令列を格納しているメモリシステム、
310はプロセッサの命令フェッチ境界を検出する命令フェッチ境界検出手段、320は一語内の単位命令を同時実行した場合と一語内の単位命令を命令フェッチ境界を単位に逐次実行した場合で実行結果が異なる命令列を抽出する回避対象コード検出手段、330は問題となる命令列を回避する命令列を生成する逐次実行保証コード生成手段、340は逐次実行保証コード生成手段が生成したプログラムを格納する命令列格納手段である。
【0057】
以上の様に構成された本発明の第1の実施の形態における第2のプログラム生成装置について、以下、その動作を説明する。
【0058】
命令フェッチ境界検出手段310はソースコード格納手段300に格納された命令列を入力すると、その命令列中で、プロセッサの命令フェッチの境界がどこに存在するかを検出する。本実施の形態ではプロセッサの命令フェッチ幅は64ビットであるので、プロセッサの命令フェッチ境界は、(10000000)16、(10000008)16、(10000010)16番地という様なアドレスの下位が0または8の番地となる。
【0059】
回避対象コード検出手段320はソースコード格納手段300に格納された命令列、および、命令フェッチ境界検出手段310から出力される命令フェッチ境界情報を入力すると、その命令列中で、一語内の単位命令を同時実行した場合と一語内の単位命令を命令フェッチ境界を単位に逐次実行した場合で実行結果が異なる命令列を抽出する。実行結果が異なる命令列とは、具体的には、一語中の任意の単位命令が出力する結果を後続する単位命令が参照する場合の出力命令と参照命令の組み合わせのうち、命令フェッチ境界を跨いでいるものであり、例えば、一語中に含まれる命令”add r0、r1、r1”と後続する命令”addr1、r2、r3”の組み合わせで、命令フェッチ境界を跨いでいるものである。
【0060】
逐次実行保証コード生成手段330は、回避対象コード検出手段320の出力する回避対象命令列の情報を用いて、ソースコード格納手段300に格納された命令列を、同時実行した場合と逐次実行した場合で動作が同一になる命令列への変換を行う。具体的には、命令列中で使用されていないレジスタを検索し、問題となる命令列中の問題となるレジスタを出力する命令の出力レジスタを使用されていないレジスタで置き換えると共に、後続する語で問題となるレジスタを参照する命令の参照レジスタを置き換えたレジスタに置き換える。例えば、一語中に命令”add r0、r1、r1”と後続する命令”add r1、r2、r3”が存在し、後続する語に命令”add #1、r1、r1”が存在する場合(以降、”add r0、r1、r1 & add r1、r2、r3 ; add #1、r1、r1”と記述する。ここで”&”は同一語に含まれ、逐次実行の場合には左から右へ実行する事を、”;”は、次の語との境界であることを示す)は、命令列中で使用していないレジスタをr4とすると、問題となる命令列中の問題となるレジスタr1を出力する命令”add r0、r1、r1”の出力レジスタを使用されていないレジスタで置き換え”add r0、r1、r4”にすると共に、後続する語で問題となるレジスタを参照する命令”add #1、r1、r1”の参照レジスタを置き換えたレジスタに置き換え”add #1、r4、r1”にする。変換された命令列は命令列格納手段340に出力される。
【0061】
(命令列生成装置の動作)
次に具体的な命令を解読実行した場合の本命令列生成装置の動作について説明する。
【0062】
図10(a)は、ソースコード格納手段300に格納された従来のVLIWプロセッサ用のプログラム生成装置が生成した命令列である。
【0063】
まず、(10000000)16番地から始まる一語の処理を行う。
命令境界検出手段310はソースコード格納手段300に格納された(10000000)16番地から始まる命令列一語分中の命令境界である、(10000008)16番地を検出する。
【0064】
回避対象コード検出手段320はソースコード格納手段300に格納された(10000000)16番地から始まる命令列一語分”add #1、r0、r0& add #1、r1、r1 & add #1、r2、r2 & add#1、r3、r3”を入力し、その命令列中で、一語を同時実行した場合と、一語内の命令境界検出手段310の出力する命令フェッチ境界を単位として単位命令を逐次実行した場合で実行結果が異なる命令列がないかを検査する。つまり、命令列一語分”add #1、r0、r0 & add #1、r1、r1 & add #1、r2、r2 & add #1、r3、r3”を同時実行した場合と、”add #1、r0、r0 & add #1、r1、r1”の2つの単位命令と ”add #1、r2、r2 & add #1、r3、r3”の2つの単位命令を逐次実行した場合に実行結果が異なる事はないかを検査する。この命令列中には問題となる命令列は存在しないので、回避対象コード検出手段320は問題となる命令列を出力しない。
【0065】
逐次実行保証コード生成手段は330は、回避対象コード検出手段320が回避対象命令列を出力しないので、ソースコード格納手段300に格納された(10000000)16番地から始まる命令列一語分をそのまま命令列格納手段340へ出力する。
【0066】
次に、後続する(10000010)16番地から始まる一語の処理を行う。
命令境界検出手段310はソースコード格納手段300に格納された(10000010)16番地から始まる命令列一語分中の命令境界である、(10000018)16番地を検出する。
【0067】
回避対象コード検出手段320はソースコード格納手段300に格納された(10000010)16番地から始まる命令列一語分”add r0、r1、r0& sub r0、r1、r1 & add #1、r2、r2 & add#1、r3、r3”を入力し、その命令列中で、一語を同時実行した場合と、一語内の命令境界検出手段310の出力する命令フェッチ境界を単位として単位命令を逐次実行した場合で実行結果が異なる命令列がないかを検査する。つまり、命令列一語分”add r0、r1、r0 & sub r0、r1、r1 & add #1、r2、r2 & add #1、r3、r3”を同時実行した場合と、”add r0、r1、r0 & sub r0、r1、r1”の2つの単位命令と”add #1、r2、r2 & add #1、r3、r3”の2つの単位命令を逐次実行した場合に実行結果が異なる事はないかを検査する。この命令列中にも問題となる命令列は存在しないので、回避対象コード検出手段320は問題となる命令列を出力しない。
【0068】
逐次実行保証コード生成手段330は、回避対象コード検出手段320が回避対象命令列を出力しないので、ソースコード格納手段300に格納された(10000010)16番地から始まる命令列一語分をそのまま命令列格納手段340へ出力する。
【0069】
次に、後続する(10000020)16番地から始まる一語の処理を行う。
命令境界検出手段310はソースコード格納手段300に格納された(10000020)16番地から始まる命令列一語分中の命令境界である、(10000028)16番地を検出する。
【0070】
回避対象コード検出手段320はソースコード格納手段300に格納された(10000020)16番地から始まる命令列一語分”add #1、r0、r0& add r1、r2、r1 & sub r1、r2、r2 & add#1、r3、r3”を入力し、その命令列中で、一語を同時実行した場合と、一語内の命令境界検出手段210の出力する命令フェッチ境界を単位として単位命令を逐次実行した場合で実行結果が異なる命令列がないかを検査する。つまり、命令列一語分”add #1、r0、r0 & add r1、r2、r1 & sub r1、r2、r2 & add #1、r3、r3”を同時実行した場合と、”add #1、r0、r0 & add r1、r2、r1”の2つの単位命令と”sub r1、r2、r2 & add #1、r3、r3”の2つの単位命令を逐次実行した場合に実行結果が異なる事はないかを検査する。この場合、”add r1、r2、r1 & sub r1、r2、r2”命令が該当する命令となる。
【0071】
逐次実行保証コード生成手段330は、回避対象コード検出手段320の出力する回避対象命令列”add r1、r2、r1 & sub r1、r2、r2”の情報を用いて、ソースコード格納手段300に格納された命令列を、同時実行した場合と逐次実行した場合で動作が同一になる命令列への変換を行う。後続する命令列を参照し、使用していないレジスタとしてr4レジスタを使い、回避対象命令列中の命令”add r1、r2、r1”を命令”add r1、r2、r5”に変換すると共に、後続するr1を参照する命令を検索し、命令”add #1、r1、r1”を命令”add #1、r5、r1”に変換した後、命令列格納手段340に出力する。
【0072】
以降、(10000030)16番地から始まる命令列一語は問題が無いのでそのまま命令列格納手段340に出力する。
【0073】
以上の処理によって、命令フェッチ境界検出手段310は図10(a)の太線で示す命令フェッチ境界情報を出力し、回避対象コード検出手段320は、図10(a)の様に、斜線部分の命令列を検出し、逐次実行保証コード生成手段330は、図10(b)の様に、回避対象コード検出手段320の出力する斜線部分の命令列の出力レジスタを変更すると共に、後続する語に含まれる、出力レジスタを参照する濃い斜線部分の命令列の参照レジスタを変更し、命令列を命令列格納手段340へ出力する。
【0074】
なお、本実施の形態では、命令フェッチ幅64ビット、128ビット固定長、最大同時実行4命令のVLIWプロセッサを想定しているが、これらの値は特に限定しない。例えば、命令の一語長は64ビットでも256ビットでも良く、データバスの幅は16ビットでも32ビットでも良く、すなわち、命令の一語長よりもデータバスの幅が小さいケースが存在すれば足りる。
【0075】
また、逐次実行保証コード生成手段は、命令列中で使用されていないレジスタを検索し、問題となる命令列中の問題となるレジスタを出力する命令の出力レジスタを使用されていないレジスタで置き換えると共に、後続する語で問題となるレジスタを参照する命令の参照レジスタを置き換えたレジスタに置き換えるアルゴリズムで説明を行ったが、あらかじめ問題となるレジスタを使用されていないレジスタに転送し、問題となるレジスタを参照する命令の参照レジスタを置き換えたレジスタに置き換えるアルゴリズムを行っても構わない。具体的には、実施例では、”add r0,r1,r0 & sub r0,r1,r1 ; add #1,r0,r0”の命令列を”mov r0、r4 ; add r0,r1,r0 & add r4,r1,r1 ; add #1,r0,r0”としてもよい。
【0076】
また、回避対象コード検出手段が出力する命令列は、出力命令と参照命令の組み合わせであるので、2命令とは限らない。参照命令が複数ある場合には3命令以上の組み合わせになる場合も存在する。
【0077】
また、命令列格納手段は、フロッピーディスクやテープやハードディスクやメモリなどの記録媒体でも構わないし、コンパイラやアセンブラオプティマイザ等の最適化プログラムへの入力ファイルであっても構わない。最適化プログラムで処理を繰り返すことにより出力ファイルの更なる最適化を図ることが可能となる。
【0078】
また、命令フェッチ境界検出手段の認識する命令フェッチ幅は、固定である必要はなく、例えば、それぞれのメモリ領域毎に異なる値を設定しても構わない。その場合には、命令フェッチ境界検出手段は、アドレス情報で命令フェッチ幅を判断する。
【0079】
また、命令フェッチ幅情報は、プログラム生成装置に組み込んでも構わないし、外部から情報を与えても構わない。具体的には、コンパイラやアセンブラやリンカに、定数として組み込んだ形で指定しても構わないし、引き数や環境ファイルの形で指定しても構わない。また、指定する命令フェッチ幅は一定でも構わないし、空間毎に個別に与えても構わない。
【0080】
(第2の実施の形態)
本実施の形態は、可変長命令についても効率よく命令を実行できるプロセッサ等に関するものである。
(1)プロセッサ
図3は本発明第2の実施の形態におけるVLIWプロセッサのブロック図である。このプロセッサは、32ビットと64ビットの2通りの単位命令を持ち、最大4つの単位命令から構成される可変長の一語を同時に実行可能なVLIWプロセッサである。
【0081】
基本的な構造は図1のVLIWプロセッサと同じであるが、可変長命令を扱うために、(a)命令供給発行部220において、メモリ110から128バイト単位で命令フェッチした命令を命令バッファ225を用いて命令バッファ中に32ビットを1単位とし最大8個のレジスタに格納している点、(b)32ビット命令または64ビット命令を切り換えるためにセレクタ229を有している点で異なる。
【0082】
このVLIWプロセッサは同時に実行できる4つの命令が2回の命令フェッチによって初めて供給されるものであっても、4つの命令の命令フェッチを待たずにデコード、実行するものである。なお、同時に実行できる最大の命令数は4つであるが、命令中に埋め込まれた同時実行できる命令の境界情報により、4以下の同時実行できる命令の数を指定できるが、この機構については図面を省略している。
【0083】
以上の様に構成された本発明の第2の実施の形態のプロセッサについて、以下、その動作を説明する。
(命令供給部220)
まず、命令供給発行部220内の命令フェッチ制御部221は、PC202、クロック201に基づいて実行する命令のアドレスをアドレスバス211からメモリ210に与える。これにより、メモリ210は命令を128ビットのデータバス212を介して、命令レジスタ222内の4つの命令レジスタに32ビットづつ命令を供給する。命令レジスタ222は、クロック201に基づいてメモリ210から供給されたデータを格納する。これとともに、4つの命令レジスタに命令を格納したことを表すため、格納フラグ223を(00001111)2とする。なお、命令バッファ225は128バイトで命令フェッチされた命令を一旦格納しておくことにより、命令レジスタ222に最大256ビットの命令を格納するためのものである。
(命令解読部230)
次に、命令解読部230におけるデコーダ232のうち第1命令解読器は一番左端のセレクタ229の出力をデコードする。デコードの際には、命令が32ビット命令である64ビット命令かを認識し命令長情報241とデコード結果242とを出力する。具体的には、図4に示すように32ビットを1単位する先頭に32ビット命令か64ビット命令かを示すフォーマット情報が割り当てられているので、この情報をそのまま命令長情報241として出力する。なお、セレクタ229はそれぞれ、命令が32ビット命令であるか64ビット命令であるかに関係なく常に64ビットのデータを出力する。
【0084】
デコーダ232のうち第1命令発行器は、格納フラグ223の値(00001111)2を用いて命令が供給されているか否かを判断する。具体的には、命令が32ビット命令であった場合には、使用フラグ更新部240が(00000000)2を命令長情報241に基づいて左から”1”を入れつつ右に1ビットシフトし(10000000)2を得る。そして、これと格納フラグ223の値(00001111)2とについてそれぞれのビット単位で論理積を演算し、(00000000)2となった場合(すべてのビットが”0”)には命令が供給されていると判断し”1”をキャンセル信号234として出力する。なお、64ビット命令の場合、使用フラグ更新部240は左から”1”を入れつつ右に2ビットシフトし((11000000)2を得て、格納フラグ223の値(00001111)2ついてそれぞれのビットの論理積を演算し、(00000000)2を得て命令が供給されていると判断し”1”をキャンセル信号234として出力する。なお、使用フラグ更新部240は、キャンセル信号234が”0”すなわち命令供給不足であった場合、シフトはしない。
【0085】
一番左端の格納フラグシフタ239は、命令長情報241に基づいて、右から”1”を入れつつ格納フラグ223を左シフトする。具体的には、第1命令解読部で32ビット命令を解読した場合は格納フラグ223(00001111)2を1ビット左にシフトして(00011111)2を得てこれを第2命令発行器に渡す。64ビット命令であった場合は、2ビット左にシフトして(00111111)2を得てこれを第2命令発行器に渡す。例えば、格納フラグ223が(00001111)2であるにも関わらず、第1、2命令解読部でそれぞれ64ビット命令が解読された場合、第3命令発行器は格納フラグシフタ239から(11111111)2を受け取り、命令供給不足と判断する。これとともに、第2命令解読器に対応したセレクタ239で選択すべき命令レジスタ222を切り換える。なお、第1〜第4命令解読器で使用したビット数は使用フラグ更新部240で計算され、使用フラグ224として格納される。
【0086】
そして、NOP生成器237はデコード結果を出力する。NOP生成器237は図1のNOP生成器137と同じで、解読器236の出力とキャンセル信号234との論理積を演算するAND回路である。すなわち、キャンセル信号234が”0”となっているときは、解読器236の出力に関わらず、NOPを意味する”0”を出力する。
【0087】
次に、図16のプログラムを実行した場合のパイプラインの流れについて、図5を用いて説明する。
【0088】
図16では、(10000000)16番地に、メモリから読み込んだ結果をr0レジスタに格納させる命令”mov (mem)、r0”が、(10000004)16番地にはレジスタr1の値を1つ増加させる命令”add #1、r1、r1”が、以下、同様に(1000001F)16番地まで命令が配置されている。なお、本命令中で、”add #12345678、r3、r3”命令は64ビット単位命令であり、他は32ビット単位命令である。
【0089】
この場合、図5に示すように、(10000010)16番地の命令は64ビット長の命令であるため、タイミングt1、t2の2回の命令フェッチによって初めて4つの命令が揃うが、このプロセッサでは図5に示すように2回目の命令フェッチをまたずに(10000000)16番地の命令”mov (mem)、r0”を含む3つの命令をデコード、実行する。そして、タイミングt6でレジスタr0が使用できる状態になる。
【0090】
一方、タイミングt3で(10000029)16番地の命令”add #1、r0、r0”の命令フェッチが行われ、タイミングt5でEXステージに入るが、レジスタr0が使用できる状態にまだなっていないためレジスタ干渉によるパイプラインインタロックが発生する。そして、タイミングt6でレジスタr0は使用できる状態になっているため、”add #1、r0、r0”が実行される。結果として、すべての命令を実行するまでに8サイクル必要となる。
【0091】
図17に示すパイプラインの流れと図5に示すパイプラインの流れとを比較すると、(10000020)16番地の命令”add #1、r0、r0”がEXステージに入るのはタイミングt5で同一である。しかし、(10000000)16番地の命令”mov (mem)、r0”がWBステージを完了するのが、図17ではタイミングt7であるのに対し、図5ではタイミングt6である点で異なる。これは、図17では並列実行する4つの命令全てがそろった段階でデコード、実行されているのに対し、図5では2回目の命令フェッチを待たず(4つ目の命令が命令フェッチされるのを待たずに)にデコード、実行を行っているからである。このため、図17ではすべての命令を実行するまでに9サイクル必要(タイミングt5、t6でパイプラインインタロックが発生)であるのに対し、図5では8サイクルで実行が完了(タイミングt5でのみパイプラインインタロックが発生)している。
【0092】
なお、タイミングt2で、(10000010)16番地の命令”add #12345678、r3、r3”命令がフェッチされると同時に、(10000020)16番地までの命令もフェッチされるが、”add #12345678、r3、r3”命令が同時に実行できる命令の境界であるため、この命令のみをタイミングt3で実行する。
【0093】
また、本実施の形態では、4つの命令を同時に実行できるハードウェアを持つVLIWプロセッサに対し、常に4つの命令を供給することを前提としているが、同じハードウェアに対して、同時実行できる命令の境界を示す技術を用いて4つ未満の命令を供給するものとしても良い。この場合であっても、同時実行できる命令の数に満たない場合であっても、1回の命令フェッチごとにデコード、実行を行う。
(プログラム生成装置)
(第1のプログラム生成装置の構成)
図6は本発明の第2の実施の形態における第1のプログラム生成装置のブロック図である。
【0094】
基本的な構造は第1の実施の形態の第1のプログラム生成装置と同じであるが、単位命令や一語のビット幅が可変であることに起因して、回避対象コード検出手段320、および、逐次実行保証コード生成手段330が、単位命令中の並列実行境界情報301、および、フォーマット情報302を認識する点が異なる。
【0095】
(命令列生成装置の動作)
以上の様に構成された本発明の第2の実施の形態の第1のプログラム生成装置について、以下、具体的な命令を解読実行した場合の動作を説明する。
【0096】
図11(a)は、ソースコード格納手段300に格納された従来のVLIWプロセッサ用のプログラム生成装置が生成した命令列である。
【0097】
まず、(10000000)16番地から始まる一語の処理を行う。
回避対象コード検出手段320はソースコード格納手段300に格納された(10000000)16番地から始まる命令列一語分”add #1、r0、r0& add #1、r1、r1 & add #1、r2、r2 & add#12345678、r3、r3”を入力し、その命令列中で、一語を同時実行した場合と一語内の単位命令を逐次実行した場合で実行結果が異なる命令列がないかを検査する。この命令列中には問題となる命令列は存在しないので、回避対象コード検出手段320は問題となる命令列を出力しない。
【0098】
逐次実行保証コード生成手段330は、回避対象コード検出手段320が回避対象命令列を出力しないので、ソースコード格納手段300に格納された(10000000)16番地から始まる命令列一語分をそのまま命令列格納手段340へ出力する。
【0099】
次に、後続する(10000014)16番地から始まる一語の処理を行う。
回避対象コード検出手段320はソースコード格納手段300に格納された(10000014)16番地から始まる命令列一語分”add r0、r1、r0& sub #12345678、r0、r1 & add #1、r2、r2 & add #1、r3、r3”を入力し、その命令列中で一語を同時実行した場合と一語内の単位命令を逐次実行した場合で実行結果が異なる命令列がないかを検査する。この命令列中には、”add r0、r1、r0 & sub#12345678、r0、r1”が該当する命令となる。
【0100】
逐次実行保証コード生成手段330は、回避対象コード検出手段320の出力する回避対象命令列”add r0、r1、r0 & sub #12345678、r0、r1”の情報を用いて、ソースコード格納手段300に格納された命令列を、同時実行した場合と逐次実行した場合で動作が同一になる命令列への変換を行う。後続する命令列を参照し、使用していないレジスタとしてr4レジスタを使い、回避対象命令列中の命令”add r0、r1、r0”を命令”add r0、r1、r4”に変換すると共に、後続するr0を参照する命令を検索し、命令”add #1、r0、r0”を命令”add #1、r4、r0”に変換した後、命令列格納手段340に出力する。
【0101】
以降、(10000028)16番地から始まる命令列一語を処理する事によって、”add r1、r2、r1 & sub #12345678、r1、r2 ; add #1、r1、r1 を add r1、r2、r5 & sub #12345678、r1、r2 ; add #1、r5、r1”に、(1000003c)16番地から始まる命令列一語を処理することによって、”add r2、r3、r2 & sub #12345678、r2、r3”を”add r2、r3、r6 & sub #12345678、r2、r3”に変換する。
【0102】
以上の処理によって、回避対象コード検出手段320は、図11(b)の様に、網かけ部分の命令列を検出し、逐次実行保証コード生成手段330は、図11(c)の様に、回避対象コード検出手段320の出力する網かけ部分の命令列の出力レジスタを変更すると共に、後続する語に含まれる、出力レジスタを参照する濃い網かけ部分の命令列の参照レジスタを変更し、命令列を命令列格納手段340へ出力する。
【0103】
(第2のプログラム生成装置の構成)
図9は本発明の第2の実施の形態における第2のプログラム生成装置のブロック図である。
【0104】
基本的な構造は第1の実施の形態の第2のプログラム生成装置と同じであるが、単位命令や一語のビット幅が可変であることに起因して、回避対象コード検出手段320、および、逐次実行保証コード生成手段330が、フォーマット情報302を認識する点、及び、回避対象コード検出手段320において、命令フェッチ境界が単位命令中にあった場合には、命令フェッチ境界が該当する単位命令の先頭に存在すると見なして評価する点、及び、命令フェッチ境界検出手段の検出する命令フェッチ幅が目的とするプロセッサの命令フェッチ幅である128ビットとなっている点が異なる。
【0105】
(命令列生成装置の動作)
次に具体的な命令を解読実行した場合の本命令列生成装置の動作について説明する。
【0106】
図12(a)は、ソースコード格納手段300に格納された従来のVLIWプロセッサ用のプログラム生成装置が生成した命令列である。
【0107】
まず、(10000000)16番地から始まる一語の処理を行う。
命令境界検出手段310はソースコード格納手段300に格納された(10000000)16番地から始まる命令列一語分中の命令境界である、(10000010)16番地を検出する。
【0108】
回避対象コード検出手段320はソースコード格納手段300に格納された(10000000)16番地から始まる命令列一語分”add #1、r0、r0& add #1、r1、r1 & add #1、r2、r2 & add#12345678、r3、r3”を入力し、その命令列中で、一語を同時実行した場合と一語内の命令境界検出手段310の出力する命令フェッチ境界を単位として単位命令を逐次実行した場合で実行結果が異なる命令列がないかを検査する。この命令列中には問題となる命令列は存在しないので、回避対象コード検出手段320は問題となる命令列を出力しない。
【0109】
逐次実行保証コード生成手段330は、回避対象コード検出手段320が回避対象命令列を出力しないので、ソースコード格納手段300に格納された(10000000)16番地から始まる命令列一語分をそのまま命令列格納手段340へ出力する。
【0110】
次に、後続する(10000014)16番地から始まる一語の処理を行う。
命令境界検出手段310はソースコード格納手段300に格納された(10000014)16番地から始まる命令列一語分中の命令境界である、(10000020)16番地を検出する。
【0111】
回避対象コード検出手段320はソースコード格納手段300に格納された(10000014)16番地から始まる命令列一語分”add r0、r1、r0& sub #12345678、r0、r1 & add #1、r2、r2 & add #1、r3、r3”を入力し、その命令列中で、一語を同時実行した場合と、一語内の命令境界検出手段310の出力する命令フェッチ境界を単位として単位命令を逐次実行した場合で実行結果が異なる命令列がないかを検査する。つまり、命令列一語分”add r0、r1、r0 & sub #12345678、r0、r1 & add #1、r2、r2 & add #1、r3、r3”を同時実行した場合と、”add r0、r1、r0 & sub #12345678、r0、r1”の2つの単位命令と”add #1、r2、r2 & add #1、r3、r3”の2つの単位命令を逐次実行した場合に実行結果が異なる事はないかを検査する。この命令列中にも問題となる命令列は存在しないので、回避対象コード検出手段320は問題となる命令列を出力しない。
【0112】
逐次実行保証コード生成手段330は、回避対象コード検出手段320が回避対象命令列を出力しないので、ソースコード格納手段300に格納された(10000014)16番地から始まる命令列一語分をそのまま命令列格納手段340へ出力する。
【0113】
次に、後続する(10000028)16番地から始まる一語の処理を行う。
命令境界検出手段310はソースコード格納手段300に格納された(10000028)16番地から始まる命令列一語分中の命令境界である、(10000030)16番地を検出する。
【0114】
回避対象コード検出手段320はソースコード格納手段300に格納された(10000028)16番地から始まる命令列一語分”add #1、r0、r0& add r1、r2、r1 & sub #12345678、r1、r2 & add #1、r3、r3”を入力し、その命令列中で、一語を同時実行した場合と、一語内の命令境界検出手段310の出力する命令フェッチ境界を単位として単位命令を逐次実行した場合で実行結果が異なる命令列がないかを検査する。つまり、命令列一語分”add #1、r0、r0 & add r1、r2、r1 & sub #12345678、r1、r2 & add #1、r3、r3”を同時実行した場合と、”add #1、r0、r0 & add r1、r2、r1”の2つの単位命令と”sub #12345678、r1、r2 & add #1、r3、r3”の2つの単位命令を逐次実行した場合に実行結果が異なる事はないかを検査する。この場合、”add r1、r2、r1 & sub #12345678、r1、r2”命令が該当する命令となる。
【0115】
逐次実行保証コード生成手段330は、回避対象コード検出手段320の出力する回避対象命令列”add r1、r2、r1 & sub #12345678、r1、r2”の情報を用いて、ソースコード格納手段300に格納された命令列を、同時実行した場合と逐次実行した場合で動作が同一になる命令列への変換を行う。後続する命令列を参照し、使用していないレジスタとしてr4レジスタを使い、回避対象命令列中の命令”add r1、r2、r1”を命令”add r1、r2、r5”に変換すると共に、後続するr1を参照する命令を検索し、命令”add #1、r1、r1”を命令”add #1、r5、r1”に変換した後、命令列格納手段340に出力する。
【0116】
以降、(10000030)16番地から始まる命令列一語は問題が無いのでそのまま命令列格納手段340に出力する。
【0117】
以上の処理によって、命令フェッチ境界検出手段310は図12(a)の太線で示す命令フェッチ境界情報を出力し、回避対象コード検出手段320は、図12(a)の様に、網かけ部分の命令列を検出し、逐次実行保証コード生成手段330は、図12(b)の様に、回避対象コード検出手段320の出力する網かけ部分の命令列の出力レジスタを変更すると共に、後続する語に含まれる、出力レジスタを参照する濃い網かけ部分の命令列の参照レジスタを変更し、命令列を命令列格納手段340へ出力する。
【0118】
なお、本実施の形態では、命令フェッチ幅128ビット、32ビットと64ビットの可変長、最大同時実行4命令のVLIWプロセッサを想定しているが、これらの値は特に限定しない。
【0119】
また、逐次実行保証コード生成手段は、命令列中で使用されていないレジスタを検索し、問題となる命令列中の問題となるレジスタを出力する命令の出力レジスタを使用されていないレジスタで置き換えると共に、後続する語で問題となるレジスタを参照する命令の参照レジスタを置き換えたレジスタに置き換えるアルゴリズムで説明を行ったが、第1の実施例における第2のプログラム生成装置と同じく、あらかじめ問題となるレジスタを使用されていないレジスタに転送し、問題となるレジスタを参照する命令の参照レジスタを置き換えたレジスタに置き換えるアルゴリズムを行っても構わない。
【0120】
また、回避対象コード検出手段が出力する命令列は、出力命令と参照命令の組み合わせであるので、2命令とは限らない。参照命令が複数ある場合には3命令以上の組み合わせになる場合も存在する。
【0121】
また、命令列格納手段は、フロッピーディスクやテープやハードディスクやメモリなどの記録媒体でも構わないし、コンパイラやアセンブラオプティマイザ等の最適化プログラムへの入力ファイルであっても構わない。最適化プログラムで処理を繰り返すことにより出力ファイルの更なる最適化を図ることが可能となる。
【0122】
また、命令フェッチ境界検出手段の認識する命令フェッチ幅は、固定である必要はなく、例えば、それぞれのメモリ領域毎に異なる値を設定しても構わない。その場合には、命令フェッチ境界検出手段は、アドレス情報で命令フェッチ幅を判断する。
【0123】
また、命令フェッチ幅情報は、プログラム生成装置に組み込んでも構わないし、外部から情報を与えても構わない。具体的には、コンパイラやアセンブラやリンカに、定数として組み込んだ形で指定しても構わないし、引き数や環境ファイルの形で指定しても構わない。また、指定する命令フェッチ幅は一定でも構わないし、空間毎に個別に与えても構わない。
【0124】
【発明の効果】
以上のように、本願発明によれば、命令供給が十分に行えない環境で使用されても供給されたものから実行する事により、性能劣化を抑制することができる。
【図面の簡単な説明】
【図1】本発明の第1の実施の形態におけるプロセッサのブロック構成図
【図2】本発明の第1の実施の形態における第1のプログラム例及びパイプライン図
【図3】本発明の第1、第2の実施の形態における第2のプログラム例及びパイプライン図
【図4】本発明の第1、第2の実施の形態における第1のプログラム生成装置のブロック図
【図5】本発明の第1、第2の実施の形態における第1のプログラム生成装置におけるプログラム図
【図6】本発明の第1、第2の実施の形態における第1のプログラム生成装置のブロック図
【図7】本発明の第1の実施の形態における第1のプログラム生成装置における回避対象コード検出手段の検出アルゴリズムを示す図
【図8】本発明の第1の実施の形態における第1のプログラム生成装置のプログラム図
【図9】本発明の第1、第2の実施の形態における第2のプログラム生成装置のブロック図
【図10】本発明の第1の実施の形態における第2のプログラム生成装置のプログラム図
【図11】本発明の第2の実施の形態における第1のプログラム生成装置のプログラム図
【図12】本発明の第2の実施の形態における第2のプログラム生成装置のプログラム図
【図13】第1の従来例におけるプロセッサのブロック構成図
【図14】第1のプログラム例を示す図
【図15】従来例における第1のプログラム例のパイプライン図
【図16】第2のプログラム例を示す図
【図17】従来例における第2のプログラム例のパイプライン図
【符号の説明】
101、201 クロック
102、202 PC
110、210 メモリ
111、211 アドレスバス
112、212 データバス
120、220 命令供給発行部
121、221 命令フェッチ制御部
122、222 命令レジスタ
123 命令フェッチフラグ
124 位置情報
130、230 命令解読部
131 キャンセル信号生成部
132、232 デコーダ
133、233 レジスタ
134、135、234 キャンセル信号
136、236 解読器
137、237 NOP信号生成器
223 格納フラグ
224 使用フラグ
[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a VLIW processor, a program generation device, and a recording medium that suppress performance deterioration by making matters from what is supplied even when used in an environment where instruction supply cannot be sufficiently performed.
[0002]
[Prior art]
2. Description of the Related Art Along with high functionality and high speed of recent microprocessor application products, a microprocessor with high processing capability (hereinafter simply referred to as “processor”) is desired. For this reason, recently, a plurality of instructions are simultaneously executed in one cycle.
[0003]
There are two methods for realizing instruction level parallel processing: dynamic scheduling and static scheduling.
[0004]
A superscalar method is a typical example of the dynamic scheduling. In this method, after decoding an instruction code at the time of execution, the dependency relationship between instructions is dynamically analyzed by hardware to determine whether or not parallel execution is possible, and an appropriate combination of instructions is executed in parallel. A typical example of the static scheduling is a VLIW (Very Long Instruction Word) system. In this method, a dependency relationship between instructions is statically analyzed by a compiler or the like when an execution code is generated, and an instruction stream with high execution efficiency is generated by moving the instruction code. In the general VLIW system, a plurality of instructions (here called “unit instructions”) that can be executed simultaneously are described in one fixed-length instruction supply unit (here called “one word”). Adopting this method has the advantage that the hardware can be simplified because it is not necessary to perform dependency analysis between instructions in hardware.
[0005]
Hereinafter, the operation of the VLIW processor in the prior art will be described with reference to FIG.
[0006]
FIG. 13 is a configuration diagram of a VLIW processor according to the prior art. 10 is a memory storing data, instructions, etc., 20 is an instruction supply issuing unit for retrieving instructions from the memory 10, and 30 is an instruction supply issuing unit 20. This is an instruction decoding unit that decodes the fetched instruction and gives the decoding result to the instruction execution unit. The instruction supply / issuance unit 20 includes an instruction fetch control unit 21 that controls fetching of instructions and the like from the memory 10 and an instruction register 22 that stores instructions and the like fetched from the memory 10. The instruction decoding unit 30 includes an instruction issuance control unit 31 that controls the issuance of instructions, a decoder 32, and a register 33 that stores a decoding result. This processor is a VLIW processor capable of simultaneously executing one word composed of four 32-bit unit instructions, and fetches instructions in units of 128 bits.
[0007]
First, the instruction fetch control unit 21 in the instruction supply / issuance unit 20 gives the address of an instruction to be executed based on the PC 2 (program counter) and clock 1 from the address bus 11 to the memory 10. As a result, the memory 10 supplies an instruction corresponding to the designated address to the four instruction registers in the instruction register 22 by 32 bits via the 128-bit data bus. The instruction register 22 stores data supplied from the memory 10 based on the clock 1. At the same time, an instruction fetch flag 23 which means that instruction fetch is completed is set to “1”. At this time, instructions are always stored in the four instruction registers 22. When instruction fetch is started (when a jump instruction or an interrupt occurs), the instruction fetch flag 23 is set to “0” in order to prevent an erroneous instruction from being decoded, and a NOP (No Operation) is issued from the decoder by a cancel signal 34. ) Is output.
[0008]
Next, the decoder 32 in the instruction decoding unit 30 obtains information that the instruction is stored in the instruction register 22 by the instruction fetch flag 23 and outputs the result of decoding the instruction. The register 33 stores the result decoded by the clock 1.
[0009]
Finally, the decoding result stored in the register 33 is supplied to the instruction execution unit (not shown), and the instruction is executed.
[0010]
[Problems to be solved by the invention]
However, in the above-described conventional VLIW processor, when instruction fetch is performed in units smaller than one word length or when the instruction is variable length, the timing at which the instruction is supplied to the instruction register is different, so the performance deteriorates. There was a case.
[0011]
In other words, the conventional VLIW processor has the same word length and instruction fetch unit, but if the VLIW is applied to an embedded microcomputer, the instruction fetch width must be smaller than the width of one word for cost reasons. There is.
[0012]
Even if the maximum word length matches the instruction fetch unit, in the case of a variable-length instruction, it may be possible to fetch one instruction for the first time by two instruction fetches.
[0013]
Hereinafter, it demonstrates concretely using drawing.
(1) When instruction fetch is performed in units smaller than one word length
FIG. 14 shows an example of a program, and FIG. 15 explains the flow of the pipeline when the program is executed.
[0014]
In FIG. 14, (10000000) 16 At the address, the instruction “mov (mem), r0” for storing the result read from the memory in the r0 register is (10000004). 16 At the address, an instruction “add # 1, r1, r1” for incrementing the value of the r1 register by one is similarly applied (1000001F). 16 Instructions are arranged up to the address.
[0015]
In this case, as shown in FIG. 15, at timing t1 (10000000) 16 Two instructions with a 32-bit length at the address are at timing t2 (10000008) 16 Two instructions having a 32-bit length at the address are fetched. At timing t3, four instructions are simultaneously decoded and executed at t4. But (10000000) 16 The address instruction “mov (mem), r0” is a subsequent instruction (1000000C) while the result of reading the memory in the MEM stage is written to the register r0. 16 Since the address instruction “add # 1, r0, r0” uses the contents of the register r0, the contents cannot be referred to until the register is written in the WB stage. For this reason, register interference occurs (1000000C) 16 The address instruction “add # 1, r0, r0” cannot be executed at timing t6, but is executed at timing t7.
[0016]
As a result, nine cycles are required to execute all instructions due to insufficient supply of instructions and register interference.
(2) When the instruction is variable length
FIG. 16 shows an example of a program, and FIG. 17 explains the flow of a pipeline when the program is executed.
[0017]
In FIG. 16, (10000000) 16 At the address, the instruction “mov (mem), r0” for storing the result read from the memory in the r0 register is (10000004). 16 At the address, an instruction “add # 1, r1, r1” for incrementing the value of the register r1 by 1 is similarly given below (1000001F). 16 Instructions are arranged up to the address. In this instruction, the “add # 12345678, r3, r3” instruction is a 64-bit unit instruction, and the others are 32-bit unit instructions.
[0018]
In this case, as shown in FIG. 16 Since the address instruction is a 64-bit instruction, four instructions are prepared for the first time by two instruction fetches at timings t1 and t2, and the four instructions are simultaneously decoded at timing t3 and executed at t4. But (10000000) 16 The address instruction “mov (mem), r0” is the result of reading the memory in the MEM stage and writing the result (10000010). 16 Since the address instruction “add # 1, r0, r0” uses the contents of the register r0, the contents cannot be referred to until the register is written in the WB stage. This causes register interference and (10000010) 16 The address instruction “add # 1, r0, r0” cannot be executed at timing t6, but is executed at timing t7.
[0019]
As a result, nine cycles are required to execute all instructions due to insufficient supply of instructions and register interference.
[0020]
As described above, the conventional VLIW processor is intended to increase the speed by simplifying the hardware as much as possible. Therefore, when all the instructions that can be processed in parallel are prepared, these instructions are executed simultaneously. When this assumption is not satisfied, there is a problem that sufficient performance cannot be exhibited.
[0021]
The present invention solves the above-described conventional problems, and a processor capable of exhibiting sufficient performance even when instruction fetch is performed in units smaller than one word length or even when the instruction is variable length. Is to provide.
[0022]
[Means for Solving the Problems]
The present invention is a VLIW processor that executes an instruction fetched instruction first, even if not all instructions that can be executed in parallel are fetched.
[0023]
DETAILED DESCRIPTION OF THE INVENTION
Hereinafter, the present invention will be described in detail with reference to the drawings.
[0024]
(First embodiment)
The present embodiment relates to a processor or the like that can efficiently execute an instruction even when an instruction is fetched in a unit smaller than one word length. That is, even in a VLIW processor that can execute four instructions at the same time, the pipeline interlock due to register interference is reduced as much as possible by starting decoding and execution when the two instructions are ready. In addition, when the previously executed instruction is an instruction related to I / O, data can be obtained earlier.
(1) Processor
FIG. 1 is a block diagram of a processor according to the first embodiment of the present invention. Compared with the conventional VLIW processor shown in FIG. 13, (a) the data bus 112 is 64 bits smaller than one word length, and (b) instructions are stored in the left two instruction registers among the four instruction registers. It differs in that it has position information 124 indicating whether it has been stored or the instruction has been stored in the two instruction registers on the right side, and (c) there are cancel signals 134 and 135 for outputting NOP.
[0025]
The processor recognizes where the instruction is stored in the instruction register 122 based on the position information 124, generates a cancel signal 134, 135 based on this information, and outputs a NOP, whereby the instruction is stored in the instruction register 122. It is possible to decode and execute in order from the first.
[0026]
First, the instruction fetch control unit 121 in the instruction supply issue unit 120 gives the address of an instruction to be executed based on the PC 102 and the clock 101 from the address bus 111 to the memory 110. As a result, the memory 110 supplies a 32-bit instruction to the two left instruction registers in the instruction register 122 via the 64-bit data bus 112. The instruction register 122 stores data supplied from the memory 110 based on the clock 101. At the same time, the instruction fetch flag 123 is set to “1” to indicate that the instruction fetch is completed, and the position information 124 is set to “0” to indicate that the instruction is stored in the left two in the instruction register 122. . At this time, among the four instruction registers 122, the instruction is stored in the second instruction register on the left side, but no instruction is stored in the two instruction registers on the right side. When instruction fetch is not completed as in the conventional case, the instruction fetch flag 123 is “0”, so that the cancel signals 134 and 135 are “0”, and the NOP signal generator 137 outputs NOP.
[0027]
Next, the decoder 132 in the instruction decoding unit 130 obtains information that the instruction is stored in the instruction register 122 by the instruction fetch flag 123 and outputs the result of decoding the instruction. At this time, since the position information 124 is “0”, indicating that the instruction is stored only in the left two instruction registers of the instruction register 122, the cancel signal generator 131 sets the cancel signal 134 to “1”. The cancel signal 135 is set to “0”. As a result, the decoding result of the instruction stored in the instruction register 122 is output from the left two of the NOP generators 137 in the decoder 132, and the NOP is output from the right two. The register 133 stores the result decoded by the clock 101. The NOP generator 137 is an AND circuit that calculates the logical product of the output of the instruction decoder 136 and the cancel signal. That is, when the cancel signals 134 and 135 are “0”, “0” indicating NOP is output regardless of the output of the decoder 136.
[0028]
Finally, the decoding result stored in the register 133 is supplied to the instruction execution unit (not shown), and the instruction is executed.
[0029]
At the time of the next instruction fetch, the fetched instruction and the like are stored in the two on the right side of the instruction register 122, the position information 124 is also updated accordingly, and the cancel signal 134 is “0”. The cancel signal 135 is “1”.
[0030]
Next, the flow of the pipeline when the program shown in FIG. 14 is executed will be described with reference to FIG.
[0031]
The pipeline of this processor includes a stage for fetching an instruction by the instruction supply issuing unit 120 (IF stage), a stage for decoding the instruction fetched by the instruction decoding unit 130 (DEC stage), and using the arithmetic unit for the decoded instruction. An execution stage (hereinafter referred to as EX stage) to be executed, a memory stage (MEM stage) that performs memory access when the decoded instruction is a memory access instruction, and a write stage (hereinafter referred to as WB stage) that reflects an operation or memory access result in a register ) 5-stage pipeline. Furthermore, the value of the register in which the execution result calculated in the EX stage such as the operation between registers is written can be transferred to the EX stage or the EX stage of the subsequent instruction from the MEM stage without actually writing the register in the WB stage. By bypassing, it is possible to refer to the instruction placed immediately after.
[0032]
In FIG. 14, (10000000) 16 At the address, the instruction “mov (mem), r0” for storing the result read from the memory in the r0 register is (10000004). 16 At the address, an instruction “add # 1, r1, r1” for incrementing the value of the r1 register by 1 is similarly given below (1000001F). 16 Instructions are arranged up to the address.
[0033]
In this case, as shown in FIG. 2, at timing t1 (10000000) 16 Two instructions having a 32-bit length at the address are fetched. At timing t2, the two instructions are simultaneously decoded and executed at t3. At the timing t6, the WB stage is finished and the contents of the register r0 are ready for use.
[0034]
On the other hand, at timing t4 (10000018) 16 The instruction fetch of the address instruction “add # 1, r0, r0” is performed, and the EX stage is entered at timing t6. At this time, since the register r0 is in a usable state, pipeline interlock due to register interference does not occur. As a result, 8 cycles are required to execute all instructions.
[0035]
When the pipeline flow shown in FIG. 16 and the pipeline flow shown in FIG. 2 are compared, (10000018) 16 The address instruction “add # 1, r0, r0” enters the EX stage at the same time t6. But (10000000) 16 The address instruction “mov (mem), r0” completes the WB stage at timing t6 in FIG. 16, but differs at timing t5 in FIG. In FIG. 15, the 64-bit instruction fetch is performed twice and is decoded and executed when the 128-bit instruction fetch is completed, whereas in FIG. 2, when the 64-bit instruction fetch is performed, This is because the decoding and execution are performed without waiting for the 64-bit instruction fetch. For this reason, in FIG. 16, nine cycles are required to execute all the instructions, whereas in FIG. 2, the execution is completed in eight cycles.
[0036]
In the present embodiment, the word length of the instruction is 128 bits while the data bus is 64 bits. However, the present invention is not limited to this. For example, the instruction word length may be 64 bits or 256 bits, and the data bus may be a power of 2, such as 32 bits or 16 bits. That is, it is sufficient if the width of the data bus is smaller than the word length of the instruction and the word length of the instruction cannot be fetched by one instruction fetch. In this case, the number of the position information 124 and the cancel signals 134 and 135 varies depending on how many instruction fetches the word length of the instruction can be fetched. In this embodiment, since the word length of an instruction is fetched by two instruction fetches, the position information 124 is 1 bit (two bits can represent two pieces of information), and there are two types of cancel signals. Provided. Further, although it is assumed that VLIW executes four instructions simultaneously, the present invention is not limited to this.
[0037]
In the present embodiment, the case where only the memory 110 is connected has been described. However, a case where a memory for fetching instructions with 128 bits may be connected. For example, the built-in memory is assumed to be fetched with 128 bits for speed, and the external memory is assumed to be fetched with 64 bits because of cost. Which memory is used may be switched. In this case, it is possible to prevent performance degradation as much as possible not only when reading from a memory fetched by 128 bits but also when reading from a memory fetched by 64 bits.
(2) Program generation device
The processor according to the first embodiment has been described above. When the conventional program generation apparatus for a VLIW processor is applied to the processor according to the first embodiment, for example, the instruction “add” is included in one word. When four consecutive instructions # 1, r0, and r0 ”are executed, the instruction supply is sufficient and if the instructions in one word are executed simultaneously, the value of the r0 register increases by“ 1 ”. When the instruction supply is insufficient and instructions in a word are executed sequentially for each unit instruction, the value of the r0 register increases by “4”, and the execution result varies depending on the instruction supply state. To do.
[0038]
(Configuration of first program generation device)
FIG. 6 is a block diagram of the first program generation device according to the first embodiment of the present invention.
[0039]
300 is a memory storing an instruction sequence, 320 is an avoidance target code detection that extracts an instruction sequence having different execution results when a unit instruction within one word is executed simultaneously and when a unit instruction within one word is executed sequentially Means 330 is a sequential execution guarantee code generating means for generating an instruction string that avoids a problematic instruction string, and 340 is an instruction string storage means for storing a program generated by the sequential execution guarantee code generating means.
[0040]
The operation of the first program generating apparatus according to the first embodiment of the present invention configured as described above will be described below.
[0041]
When the instruction sequence stored in the source code storage unit 300 is input to the avoidance target code detection unit 320, a unit instruction in one word is simultaneously executed in the instruction sequence, and a unit instruction in one word is sequentially executed. In this case, instruction sequences having different execution results are extracted as avoidance target instruction sequences. An instruction sequence having different execution results is specifically a combination of an output instruction and a reference instruction when a subsequent unit instruction refers to a result output by an arbitrary unit instruction in one word. This is a combination of the instruction “add r0, r1, r1” and the subsequent instruction “add r1, r2, r3” included therein.
[0042]
FIG. 7 shows an algorithm in which the avoidance target code detection means generates an avoidance target instruction sequence.
[0043]
Step 401 is a step of reading one word from the source program, Step 402 is a step of reading one word read from the head one by one instruction unit, and Step 403 is a step of registering output register information in one instruction unit read in Step 402 Step 404 is a step of reading subsequent instruction units one by one from the head side, Step 405 is a step of registering a reference register in one instruction unit read in Step 404, and Step 406 is an output register registered in Step 402. A step for determining whether or not the reference registers registered in step 405 match, a step 407 for registering a subsequent instruction unit if they match in step 405, and a step 408 for determining whether there is a subsequent instruction unit Judgment and presence Is a determination step for executing step 404 and subsequent steps, step 409 is a step of outputting as a code to be avoided when a combination of a registered output instruction and a reference instruction exists, and step 410 is a determination of whether there is a subsequent instruction unit. If it exists, a determination step for executing step 402 and subsequent steps. Step 411 is a determination step for determining whether or not there is a subsequent word and executing step 401 and subsequent steps.
[0044]
The sequential execution guarantee code generating means 330 uses the information of the avoidance target instruction sequence output from the avoidance target code detection means 320, and the instruction sequence stored in the source code storage means 300 is executed simultaneously with the case where it is executed simultaneously. To convert the instruction sequence to the same operation. Specifically, it searches for unused registers in the instruction sequence, replaces the output register of the instruction that outputs the problematic register in the problematic instruction sequence with an unused register, and uses the following word Replace the reference register of the instruction that refers to the register in question with the replaced register. For example, the instruction “add r0, r1, r1” and the following instruction “add r1, r2, r3” exist in one word, and the instruction “add # 1, r1, r1” exists in the following word ( Hereafter, “add r0, r1, r1 & add r1, r2, r3; add # 1, r1, r1” is described, where “&” is included in the same word, and in the case of sequential execution, from left to right ";" Indicates that this is a boundary with the following word). If the register not used in the instruction sequence is r4, the problematic register in the problematic instruction sequence Replace the output register of the instruction “add r0, r1, r1” that outputs r1 with an unused register “add r0, r1, r4”, and also refer to the register in question in the subsequent word “add” # 1, r1, r1 " Replaced by replacing the reference registers Register "add # 1, r4, r1" to. The converted instruction sequence is output to the instruction sequence storage means 340.
[0045]
It is possible to search for unused registers by allocating a save / restore process to the stack before and after the instruction word in question without performing any search. By diverting the element technology of register allocation, a search inside the basic block or beyond the basic block is performed, and if there is no unused register, the save / restore processing to the stack is implemented before and after the problematic instruction word. It is also possible to secure a register by inserting the register.
[0046]
(Operation of instruction sequence generator)
Next, the operation of this instruction sequence generation apparatus when a specific instruction is decoded and executed will be described.
[0047]
FIG. 8A shows an instruction sequence generated by a conventional program generation apparatus for a VLIW processor stored in the source code storage unit 300.
[0048]
First, (10000000) 16 Process one word starting from the address.
The avoidance target code detection means 320 is stored in the source code storage means 300 (10000000) 16 Input "add # 1, r0, r0 & add # 1, r1, r1 & add # 1, r2, r2 & add # 1, r3, r3" for one instruction string starting from the address. It is checked whether there is an instruction sequence having different execution results when one word is executed simultaneously and when unit instructions within one word are executed sequentially. Since there is no problematic instruction sequence in this instruction sequence, the avoidance target code detecting unit 320 does not output the problematic instruction sequence.
[0049]
The sequential execution guarantee code generation means 330 is stored in the source code storage means 300 because the avoidance target code detection means 320 does not output the avoidance target instruction sequence (10000000). 16 The instruction sequence starting from the address is output to the instruction sequence storage means 340 as it is.
[0050]
Next follows (10000010) 16 Process one word starting from the address.
The avoidance target code detection means 320 is stored in the source code storage means 300 (10000010). 16 Input "add r0, r1, r0 & sub r0, r1, r1 & add # 1, r2, r2 & add # 1, r3, r3" for one instruction string starting from the address. It is checked whether there is an instruction sequence with different execution results between the case where the instruction is executed simultaneously and the case where the unit instructions within one word are executed sequentially. In this instruction sequence, “add r0, r1, r0 & sub r0, r1, r1” is a corresponding instruction.
[0051]
The sequential execution guarantee code generation means 330 stores the avoidance target instruction sequence “add r0, r1, r0 & sub r0, r1, r1” output from the avoidance target code detection means 320 in the source code storage means 300. The executed instruction sequence is converted into an instruction sequence whose operation is the same between the simultaneous execution and the sequential execution. Refer to the subsequent instruction sequence, use the r4 register as an unused register, convert the instruction “add r0, r1, r0” in the avoidance target instruction sequence to the instruction “add r0, r1, r4” and follow The instruction referring to r0 is retrieved, and the instruction “add # 1, r0, r0” is converted into the instruction add # 1, r4, r0, and then output to the instruction string storage means 340.
[0052]
Similarly, (10000020) 16 By processing one word of the instruction sequence starting from the address, “add r1, r2, r1 & sub r1, r2, r2; add # 1, r1, r1” is added to “add r1, r2, r5 & sub r1, r2, r2; converted into add # 1, r5, r1 ″.
[0053]
Also, (10000030) 16 If a single instruction sequence starting from the address is processed and there is a register that is not used but there is an avoidance target code, for example, the r6 register is secured by a save instruction “push r6” to the stack, By restoring by the return instruction “pop r6”, “add r2, r3, r2 & sub r2, r3, r3” is changed to “push r6; add r2, r3, r6 & sub r2, r3, r3; mov r6, r2 & Pop r6 ".
[0054]
Through the above processing, the avoidance target code detection unit 320 detects the instruction sequence in the shaded portion as shown in FIG. 8B, and the sequential execution guarantee code generation unit 330 avoids the operation as shown in FIG. 8C. The output register of the instruction sequence in the hatched portion output from the target code detection unit 320 is changed, and the instruction register in which the reference register that refers to the output register in the dark hatched portion included in the subsequent word is changed or added to the stack An instruction sequence of an access instruction or NOP instruction is output to the instruction sequence storage means 340.
[0055]
(Configuration of second program generation device)
FIG. 9 is a block diagram of the second program generation device according to the first embodiment of the present invention.
[0056]
300 is a memory system storing an instruction sequence;
310 is an instruction fetch boundary detecting means for detecting an instruction fetch boundary of the processor, 320 is an execution result when unit instructions in one word are simultaneously executed and when unit instructions in one word are sequentially executed in units of instruction fetch boundaries The avoidance target code detecting means for extracting instruction sequences with different numbers, 330 is a sequential execution guarantee code generating means for generating an instruction sequence for avoiding a problematic instruction sequence, and 340 stores a program generated by the sequential execution guarantee code generating means. Instruction sequence storage means.
[0057]
The operation of the second program generation device according to the first embodiment of the present invention configured as described above will be described below.
[0058]
When the instruction fetch boundary detection unit 310 inputs the instruction sequence stored in the source code storage unit 300, the instruction fetch boundary detection unit 310 detects where the instruction fetch boundary of the processor exists in the instruction sequence. In this embodiment, since the instruction fetch width of the processor is 64 bits, the instruction fetch boundary of the processor is (10000000) 16 , (10000008) 16 , (10000010) 16 The lower address of an address such as an address is an address of 0 or 8.
[0059]
When the avoidance target code detection unit 320 inputs the instruction sequence stored in the source code storage unit 300 and the instruction fetch boundary information output from the instruction fetch boundary detection unit 310, the unit within one word in the instruction sequence Instruction sequences having different execution results are extracted when the instructions are executed simultaneously and when the unit instructions in one word are sequentially executed in units of instruction fetch boundaries. An instruction sequence with different execution results specifically refers to an instruction fetch boundary in the combination of an output instruction and a reference instruction when a subsequent unit instruction refers to a result output by an arbitrary unit instruction in one word. For example, a combination of an instruction “add r0, r1, r1” and a subsequent instruction “addr1, r2, r3” included in one word straddles an instruction fetch boundary.
[0060]
The sequential execution guarantee code generating means 330 uses the information of the avoidance target instruction sequence output from the avoidance target code detection means 320, and the instruction sequence stored in the source code storage means 300 is executed simultaneously with the case where it is executed simultaneously. To convert the instruction sequence to the same operation. Specifically, it searches for unused registers in the instruction sequence, replaces the output register of the instruction that outputs the problematic register in the problematic instruction sequence with an unused register, and uses the following word Replace the reference register of the instruction that refers to the register in question with the replaced register. For example, the instruction “add r0, r1, r1” and the following instruction “add r1, r2, r3” exist in one word, and the instruction “add # 1, r1, r1” exists in the following word ( Hereafter, “add r0, r1, r1 & add r1, r2, r3; add # 1, r1, r1” is described, where “&” is included in the same word, and in the case of sequential execution, from left to right ";" Indicates that this is a boundary with the next word). If a register that is not used in the instruction sequence is r4, the problematic register in the problematic instruction sequence Replace the output register of the instruction “add r0, r1, r1” that outputs r1 with an unused register “add r0, r1, r4”, and also refer to the register in question in the subsequent word “add” # 1, r1, r1 " The reference register is replaced with the replaced register to “add # 1, r4, r1”. The converted instruction sequence is output to the instruction sequence storage means 340.
[0061]
(Operation of instruction sequence generator)
Next, the operation of this instruction sequence generation apparatus when a specific instruction is decoded and executed will be described.
[0062]
FIG. 10A shows an instruction sequence generated by a conventional program generation apparatus for a VLIW processor stored in the source code storage unit 300.
[0063]
First, (10000000) 16 Process one word starting from the address.
Instruction boundary detection means 310 is stored in source code storage means 300 (10000000) 16 It is an instruction boundary in one word of an instruction sequence starting from an address (10000008) 16 The address is detected.
[0064]
The avoidance target code detection means 320 is stored in the source code storage means 300 (10000000) 16 Input "add # 1, r0, r0 & add # 1, r1, r1 & add # 1, r2, r2 & add # 1, r3, r3" for one instruction string starting from the address. It is checked whether there is an instruction sequence having different execution results when one word is executed simultaneously and when a unit instruction is executed sequentially with the instruction fetch boundary output from the instruction boundary detection means 310 in one word as a unit. That is, when “add # 1, r0, r0 & add # 1, r1, r1 & add # 1, r2, r2 & add # 1, r3, r3” is executed simultaneously for one instruction string, “add # 1, Execution result when two unit instructions "1, r0, r0 & add # 1, r1, r1" and two unit instructions "add # 1, r2, r2 & add # 1, r3, r3" are executed sequentially Inspect for any differences. Since there is no problematic instruction sequence in this instruction sequence, the avoidance target code detecting unit 320 does not output the problematic instruction sequence.
[0065]
The sequential execution guarantee code generation means 330 is stored in the source code storage means 300 because the avoidance target code detection means 320 does not output the avoidance target instruction sequence (10000000). 16 The instruction sequence starting from the address is output to the instruction sequence storage means 340 as it is.
[0066]
Next follows (10000010) 16 Process one word starting from the address.
The instruction boundary detection unit 310 is stored in the source code storage unit 300 (10000010). 16 It is an instruction boundary in one word of an instruction sequence starting from an address (10000018) 16 The address is detected.
[0067]
The avoidance target code detection means 320 is stored in the source code storage means 300 (10000010). 16 Input "add r0, r1, r0 & sub r0, r1, r1 & add # 1, r2, r2 & add # 1, r3, r3" for one instruction string starting from the address. Are simultaneously executed, and when a unit instruction is sequentially executed in units of instruction fetch boundaries output from the instruction boundary detection unit 310 in one word, it is checked whether there is an instruction sequence having different execution results. That is, "add r0, r1, r0 & sub r0, r1, r1 & add # 1, r2, r2 & add # 1, r3, r3" for one instruction string is executed simultaneously with "add r0, r1". , R0 & sub r0, r1, r1 ”and two unit instructions“ add # 1, r2, r2 & add # 1, r3, r3 ”are executed differently. Inspect for any. Since there is no problematic instruction sequence in this instruction sequence, the avoidance target code detecting unit 320 does not output the problematic instruction sequence.
[0068]
The sequential execution guarantee code generation means 330 is stored in the source code storage means 300 because the avoidance target code detection means 320 does not output the avoidance target instruction sequence (10000010). 16 The instruction sequence starting from the address is output to the instruction sequence storage means 340 as it is.
[0069]
Then follow (10000020) 16 Process one word starting from the address.
The instruction boundary detection unit 310 is stored in the source code storage unit 300 (10000020). 16 It is an instruction boundary in one word of an instruction sequence starting from an address (10000028) 16 The address is detected.
[0070]
The avoidance target code detection means 320 is stored in the source code storage means 300 (10000020). 16 Input "add # 1, r0, r0 & add r1, r2, r1 & sub r1, r2, r2 & add # 1, r3, r3" for one instruction string starting from the address. Are simultaneously executed and whether or not unit instructions are sequentially executed in units of instruction fetch boundaries output from the instruction boundary detection unit 210 in one word, it is checked whether there is an instruction sequence having different execution results. That is, when “add # 1, r0, r0 & add r1, r2, r1 & sub r1, r2, r2 & add # 1, r3, r3” are executed simultaneously for one instruction string, “add # 1, When two unit instructions “r0, r0 & add r1, r2, r1” and two unit instructions “sub r1, r2, r2 & add # 1, r3, r3” are sequentially executed, the execution results are different. Inspect for any. In this case, the instruction “add r1, r2, r1 & sub r1, r2, r2” is a corresponding instruction.
[0071]
The sequential execution guarantee code generation means 330 stores the avoidance target instruction sequence “add r1, r2, r1 & sub r1, r2, r2” output from the avoidance target code detection means 320 in the source code storage means 300. The executed instruction sequence is converted into an instruction sequence whose operation is the same between the simultaneous execution and the sequential execution. The subsequent instruction sequence is referenced, the r4 register is used as an unused register, the instruction “add r1, r2, r1” in the avoidance target instruction sequence is converted to the instruction “add r1, r2, r5”, and the subsequent The instruction referring to r1 is retrieved, and the instruction “add # 1, r1, r1” is converted into the instruction “add # 1, r5, r1”, and then output to the instruction string storage means 340.
[0072]
Since then, (10000030) 16 Since there is no problem with one instruction sequence word starting from the address, it is output to the instruction sequence storage means 340 as it is.
[0073]
Through the above processing, the instruction fetch boundary detection unit 310 outputs the instruction fetch boundary information indicated by the bold line in FIG. 10A, and the avoidance target code detection unit 320 outputs the instruction in the shaded portion as shown in FIG. As shown in FIG. 10B, the sequential execution guarantee code generation unit 330 changes the output register of the instruction sequence in the shaded portion output from the avoidance target code detection unit 320 and includes it in the subsequent word. The reference register of the instruction sequence in the dark shaded portion that refers to the output register is changed, and the instruction sequence is output to the instruction sequence storage means 340.
[0074]
In this embodiment, a VLIW processor with an instruction fetch width of 64 bits, a fixed length of 128 bits, and a maximum of four simultaneous execution instructions is assumed, but these values are not particularly limited. For example, the word length of an instruction may be 64 bits or 256 bits, and the width of the data bus may be 16 bits or 32 bits. That is, it is sufficient if there is a case where the width of the data bus is smaller than the word length of the instruction. .
[0075]
Further, the sequential execution guarantee code generation means searches for an unused register in the instruction sequence, and replaces the output register of the instruction that outputs the problematic register in the problematic instruction sequence with an unused register. In the following word, the algorithm that replaces the reference register of the instruction that refers to the register in question with the replaced register was explained. However, the register in question is transferred to an unused register in advance, and the register in question is An algorithm for replacing the reference register of the instruction to be referenced with a replaced register may be used. Specifically, in the embodiment, the instruction sequence of “add r0, r1, r0 & sub r0, r1, r1; add # 1, r0, r0” is changed to “mov r0, r4; add r0, r1, r0 & add”. r4, r1, r1; add # 1, r0, r0 ".
[0076]
The instruction sequence output by the avoidance target code detection means is a combination of an output instruction and a reference instruction, and thus is not limited to two instructions. When there are a plurality of reference instructions, there may be a combination of three or more instructions.
[0077]
The instruction sequence storage means may be a recording medium such as a floppy disk, a tape, a hard disk, or a memory, or may be an input file to an optimization program such as a compiler or an assembler optimizer. It is possible to further optimize the output file by repeating the process using the optimization program.
[0078]
Further, the instruction fetch width recognized by the instruction fetch boundary detection means does not need to be fixed, and for example, a different value may be set for each memory area. In that case, the instruction fetch boundary detecting means determines the instruction fetch width from the address information.
[0079]
Further, the instruction fetch width information may be incorporated in the program generation apparatus or information may be given from the outside. Specifically, it may be specified as a constant incorporated in a compiler, assembler or linker, or may be specified in the form of an argument or an environment file. Also, the instruction fetch width to be specified may be constant or may be given individually for each space.
[0080]
(Second Embodiment)
The present embodiment relates to a processor or the like that can execute instructions efficiently even for variable-length instructions.
(1) Processor
FIG. 3 is a block diagram of the VLIW processor according to the second embodiment of the present invention. This processor is a VLIW processor that has two unit instructions of 32 bits and 64 bits and can simultaneously execute a variable-length word composed of a maximum of four unit instructions.
[0081]
The basic structure is the same as that of the VLIW processor of FIG. 1, but in order to handle variable-length instructions, (a) the instruction supply / issuance unit 220 uses the instruction buffer 225 to fetch instructions fetched from the memory 110 in units of 128 bytes. The difference is that the instruction buffer stores 32 bits as a unit in a maximum of 8 registers, and (b) a selector 229 is provided for switching between a 32-bit instruction and a 64-bit instruction.
[0082]
This VLIW processor decodes and executes without waiting for the instruction fetch of four instructions even if four instructions that can be executed simultaneously are supplied for the first time by two instruction fetches. The maximum number of instructions that can be executed simultaneously is four, but the boundary information of instructions that can be executed simultaneously embedded in the instruction can specify the number of instructions that can be executed simultaneously of 4 or less. Is omitted.
[0083]
The operation of the processor according to the second embodiment of the present invention configured as described above will be described below.
(Instruction supply unit 220)
First, the instruction fetch control unit 221 in the instruction supply issue unit 220 gives the address of an instruction to be executed based on the PC 202 and the clock 201 from the address bus 211 to the memory 210. As a result, the memory 210 supplies instructions to the four instruction registers in the instruction register 222 via the 128-bit data bus 212 in 32-bit units. The instruction register 222 stores data supplied from the memory 210 based on the clock 201. At the same time, the storage flag 223 is set to (000011111) to indicate that the instruction is stored in the four instruction registers. 2 And The instruction buffer 225 is used to store an instruction having a maximum of 256 bits in the instruction register 222 by temporarily storing an instruction fetched with 128 bytes.
(Instruction decoding unit 230)
Next, the first instruction decoder of the decoder 232 in the instruction decoding unit 230 decodes the output of the leftmost selector 229. At the time of decoding, it recognizes whether the instruction is a 64-bit instruction which is a 32-bit instruction, and outputs instruction length information 241 and a decoding result 242. Specifically, as shown in FIG. 4, format information indicating whether the instruction is a 32-bit instruction or a 64-bit instruction is assigned to the head of 32 bits as one unit, and this information is output as instruction length information 241 as it is. Each selector 229 always outputs 64-bit data regardless of whether the instruction is a 32-bit instruction or a 64-bit instruction.
[0084]
The first instruction issuer of the decoder 232 has the value of the storage flag 223 (00001111). 2 Is used to determine whether an instruction is supplied. Specifically, when the instruction is a 32-bit instruction, the use flag update unit 240 (00000000) 2 Is shifted by 1 bit to the right with “1” from the left based on the instruction length information 241 (10000000) 2 Get. And this and the value of the storage flag 223 (00001111) 2 AND for each bit unit and (00000000) 2 If it becomes (all bits are “0”), it is determined that an instruction is supplied, and “1” is output as the cancel signal 234. In the case of a 64-bit instruction, the use flag update unit 240 shifts 2 bits to the right while inserting “1” from the left ((11000000) 2 And the value of the storage flag 223 (00001111) 2 About the logical product of each bit, (00000000) 2 It is determined that the command is supplied, and “1” is output as the cancel signal 234. Note that the use flag updating unit 240 does not shift when the cancel signal 234 is “0”, that is, the instruction supply is insufficient.
[0085]
The leftmost storage flag shifter 239 shifts the storage flag 223 to the left while putting “1” from the right based on the instruction length information 241. Specifically, when a 32-bit instruction is decoded by the first instruction decoding unit, the storage flag 223 (00001111) 2 Is shifted 1 bit to the left (00011111) 2 And pass this to the second instruction issuer. If it is a 64-bit instruction, shift it 2 bits to the left (00111111) 2 And pass this to the second instruction issuer. For example, the storage flag 223 is (00001111) 2 However, when the 64-bit instruction is decoded by the first and second instruction decoding units, the third instruction issuer starts from the storage flag shifter 239 (11111111). 2 It is determined that the supply of instructions is insufficient. At the same time, the instruction register 222 to be selected is switched by the selector 239 corresponding to the second instruction decoder. The number of bits used by the first to fourth instruction decoders is calculated by the use flag update unit 240 and stored as the use flag 224.
[0086]
Then, the NOP generator 237 outputs the decoding result. The NOP generator 237 is the same as the NOP generator 137 of FIG. 1 and is an AND circuit that calculates the logical product of the output of the decoder 236 and the cancel signal 234. That is, when the cancel signal 234 is “0”, “0” meaning NOP is output regardless of the output of the decoder 236.
[0087]
Next, the flow of the pipeline when the program of FIG. 16 is executed will be described with reference to FIG.
[0088]
In FIG. 16, (10000000) 16 At the address, the instruction “mov (mem), r0” for storing the result read from the memory in the r0 register is (10000004). 16 At the address, an instruction “add # 1, r1, r1” for incrementing the value of the register r1 by 1 is similarly given below (1000001F). 16 Instructions are arranged up to the address. In this instruction, the “add # 12345678, r3, r3” instruction is a 64-bit unit instruction, and the others are 32-bit unit instructions.
[0089]
In this case, as shown in FIG. 16 Since the instruction at the address is a 64-bit length instruction, four instructions are prepared for the first time by two instruction fetches at timings t1 and t2. However, in this processor, the second instruction fetch is not performed as shown in FIG. (10000000) 16 Decode and execute the three instructions including the address instruction “mov (mem), r0”. At a timing t6, the register r0 can be used.
[0090]
On the other hand, at timing t3 (10000029) 16 The instruction fetch of the address instruction “add # 1, r0, r0” is performed, and the EX stage is entered at timing t5. However, since the register r0 is not yet ready for use, a pipeline interlock occurs due to register interference. . Since the register r0 is ready for use at timing t6, “add # 1, r0, r0” is executed. As a result, 8 cycles are required to execute all instructions.
[0091]
When the pipeline flow shown in FIG. 17 is compared with the pipeline flow shown in FIG. 5, (10000020) 16 The address instruction “add # 1, r0, r0” enters the EX stage at the same time t5. But (10000000) 16 The instruction at the address “mov (mem), r0” completes the WB stage at timing t7 in FIG. 17, but differs at timing t6 in FIG. In FIG. 17, this is decoded and executed when all four instructions to be executed in parallel are prepared, whereas in FIG. 5, the second instruction fetch is not waited (the fourth instruction is fetched). This is because the data is decoded and executed (without waiting for this). For this reason, in FIG. 17, 9 cycles are required to execute all instructions (pipeline interlock occurs at timings t5 and t6), whereas in FIG. 5, execution is completed in 8 cycles (only at timing t5). A pipeline interlock has occurred.
[0092]
At time t2, (10000010) 16 At the same time that the instruction “add # 12345678, r3, r3” is fetched at the address (10000020) 16 The instruction up to the address is also fetched, but since the “add # 12345678, r3, r3” instruction is an instruction boundary that can be executed simultaneously, only this instruction is executed at timing t3.
[0093]
In this embodiment, it is assumed that four instructions are always supplied to a VLIW processor having hardware capable of executing four instructions simultaneously. However, instructions that can be executed simultaneously on the same hardware are assumed. It is also possible to supply less than four instructions using a technique that indicates boundaries. Even in this case, even if the number of instructions that can be executed simultaneously is not reached, decoding and execution are performed for each instruction fetch.
(Program generation device)
(Configuration of first program generation device)
FIG. 6 is a block diagram of the first program generation device according to the second embodiment of the present invention.
[0094]
Although the basic structure is the same as that of the first program generation device of the first embodiment, the avoidance target code detection means 320, and the unit instruction and the bit width of one word are variable, and The sequential execution guarantee code generating means 330 is different in that it recognizes the parallel execution boundary information 301 and the format information 302 in the unit instruction.
[0095]
(Operation of instruction sequence generator)
With respect to the first program generation apparatus according to the second embodiment of the present invention configured as described above, the operation when a specific instruction is decoded and executed will be described below.
[0096]
FIG. 11A shows an instruction sequence generated by a conventional program generation apparatus for a VLIW processor stored in the source code storage unit 300.
[0097]
First, (10000000) 16 Process one word starting from the address.
The avoidance target code detection means 320 is stored in the source code storage means 300 (10000000) 16 Input "add # 1, r0, r0 & add # 1, r1, r1 & add # 1, r2, r2 & add # 12345678, r3, r3" for one word of the instruction string starting from the address. It is checked whether there is an instruction sequence having different execution results when one word is executed simultaneously and when unit instructions within one word are executed sequentially. Since there is no problematic instruction sequence in this instruction sequence, the avoidance target code detecting unit 320 does not output the problematic instruction sequence.
[0098]
The sequential execution guarantee code generation means 330 is stored in the source code storage means 300 because the avoidance target code detection means 320 does not output the avoidance target instruction sequence (10000000). 16 The instruction sequence starting from the address is output to the instruction sequence storage means 340 as it is.
[0099]
Then follow (10000014) 16 Process one word starting from the address.
The avoidance target code detection means 320 is stored in the source code storage means 300 (10000014). 16 Input "add r0, r1, r0 & sub # 12345678, r0, r1 & add # 1, r2, r2 & add # 1, r3, r3" for one word in the instruction string starting from the address. It is checked whether there is an instruction sequence with different execution results between the case where the instruction is executed simultaneously and the case where the unit instructions within one word are executed sequentially. In this instruction sequence, “add r0, r1, r0 & sub # 12345678, r0, r1” is a corresponding instruction.
[0100]
The sequential execution guarantee code generation means 330 uses the information of the avoidance target instruction sequence “add r0, r1, r0 & sub # 12345678, r0, r1” output from the avoidance target code detection means 320 to store in the source code storage means 300. The stored instruction sequence is converted into an instruction sequence whose operation is the same between the simultaneous execution and the sequential execution. Refer to the subsequent instruction sequence, use the r4 register as an unused register, convert the instruction “add r0, r1, r0” in the avoidance target instruction sequence to the instruction “add r0, r1, r4” and follow The instruction referring to r0 is retrieved, and the instruction “add # 1, r0, r0” is converted into the instruction “add # 1, r4, r0”, and then output to the instruction string storage means 340.
[0101]
Since then, (10000028) 16 By processing one word of the instruction sequence starting from the address, “add r1, r2, r1 & sub # 12345678, r1, r2; add # 1, r1, r1 to add r1, r2, r5 & sub # 12345678, r1, r2; add # 1, r5, r1 ″ to (1000003c) 16 By processing one word of the instruction sequence starting from the address, “add r2, r3, r2 & sub # 12345678, r2, r3” is converted to “add r2, r3, r6 & sub # 12345678, r2, r3”.
[0102]
By the above processing, the avoidance target code detection unit 320 detects the instruction sequence in the shaded portion as shown in FIG. 11B, and the sequential execution guarantee code generation unit 330 performs the operation as shown in FIG. The output register of the shaded portion instruction sequence output from the avoidance target code detection means 320 is changed, and the reference register of the dark shaded portion instruction sequence included in the subsequent word and referring to the output register is changed. The sequence is output to the instruction sequence storage means 340.
[0103]
(Configuration of second program generation device)
FIG. 9 is a block diagram of a second program generation device according to the second embodiment of the present invention.
[0104]
Although the basic structure is the same as that of the second program generation device of the first embodiment, the avoidance target code detection means 320 and the unit instruction and the bit width of one word are variable, and When the sequential execution guarantee code generating means 330 recognizes the format information 302 and the avoidance target code detecting means 320 has an instruction fetch boundary in a unit instruction, the unit instruction to which the instruction fetch boundary corresponds The difference is that the instruction fetch width detected by the instruction fetch boundary detection means is 128 bits, which is the instruction fetch width of the target processor.
[0105]
(Operation of instruction sequence generator)
Next, the operation of this instruction sequence generation apparatus when a specific instruction is decoded and executed will be described.
[0106]
FIG. 12A shows an instruction sequence generated by a conventional program generation apparatus for a VLIW processor stored in the source code storage unit 300.
[0107]
First, (10000000) 16 Process one word starting from the address.
Instruction boundary detection means 310 is stored in source code storage means 300 (10000000) 16 This is an instruction boundary in one word of the instruction sequence starting from the address. (10000010) 16 The address is detected.
[0108]
The avoidance target code detection means 320 is stored in the source code storage means 300 (10000000) 16 Input "add # 1, r0, r0 & add # 1, r1, r1 & add # 1, r2, r2 & add # 12345678, r3, r3" for one word of the instruction string starting from the address. It is checked whether there is an instruction sequence with different execution results when one word is executed simultaneously and when a unit instruction is executed sequentially with the instruction fetch boundary output from the instruction boundary detection unit 310 within one word as a unit. Since there is no problematic instruction sequence in this instruction sequence, the avoidance target code detecting unit 320 does not output the problematic instruction sequence.
[0109]
The sequential execution guarantee code generation means 330 is stored in the source code storage means 300 because the avoidance target code detection means 320 does not output the avoidance target instruction sequence (10000000). 16 The instruction sequence starting from the address is output to the instruction sequence storage means 340 as it is.
[0110]
Then follow (10000014) 16 Process one word starting from the address.
The instruction boundary detection unit 310 is stored in the source code storage unit 300 (10000014). 16 It is an instruction boundary in one word of an instruction sequence starting from an address (10000020) 16 The address is detected.
[0111]
The avoidance target code detection means 320 is stored in the source code storage means 300 (10000014). 16 "Add r0, r1, r0 & sub # 12345678, r0, r1 & add # 1, r2, r2 & add # 1, r3, r3" is input for one word of the instruction string starting from the address. It is checked whether there is an instruction sequence with different execution results when the words are executed simultaneously and when the unit instructions are executed sequentially with the instruction fetch boundary output from the instruction boundary detection means 310 in one word as a unit. That is, when “add r0, r1, r0 & sub # 12345678, r0, r1 & add # 1, r2, r2 & add # 1, r3, r3” are executed simultaneously for one instruction string, “add r0, Execution results differ when two unit instructions “r1, r0 & sub # 12345678, r0, r1” and two unit instructions “add # 1, r2, r2 & add # 1, r3, r3” are executed sequentially. Inspect for anything. Since there is no problematic instruction sequence in this instruction sequence, the avoidance target code detecting unit 320 does not output the problematic instruction sequence.
[0112]
The sequential execution guarantee code generation means 330 is stored in the source code storage means 300 because the avoidance target code detection means 320 does not output the avoidance target instruction sequence (10000014). 16 The instruction sequence starting from the address is output to the instruction sequence storage means 340 as it is.
[0113]
Then follow (10000028) 16 Process one word starting from the address.
The instruction boundary detection means 310 is stored in the source code storage means 300 (10000028) 16 This is an instruction boundary in one word of the instruction sequence starting from the address, (10000030) 16 The address is detected.
[0114]
The avoidance target code detection unit 320 is stored in the source code storage unit 300 (10000028). 16 “Add # 1, r0, r0 & add r1, r2, r1 & sub # 12345678, r1, r2 & add # 1, r3, r3” are input for one word in the instruction string starting from the address. It is checked whether there is an instruction sequence with different execution results when the words are executed simultaneously and when the unit instructions are executed sequentially with the instruction fetch boundary output from the instruction boundary detection means 310 in one word as a unit. That is, when “add # 1, r0, r0 & add r1, r2, r1 & sub # 12345678, r1, r2 & add # 1, r3, r3” are executed simultaneously for one instruction string, “add # 1 , R0, r0 & add r1, r2, r1 ”and two unit instructions“ sub # 12345678, r1, r2 & add # 1, r3, r3 ”are executed differently Inspect for anything. In this case, the instruction “add r1, r2, r1 & sub # 12345678, r1, r2” is a corresponding instruction.
[0115]
The sequential execution guarantee code generation means 330 uses the information of the avoidance target instruction sequence “add r1, r2, r1 & sub # 12345678, r1, r2” output from the avoidance target code detection means 320 to the source code storage means 300. The stored instruction sequence is converted into an instruction sequence whose operation is the same between the simultaneous execution and the sequential execution. The subsequent instruction sequence is referenced, the r4 register is used as an unused register, the instruction “add r1, r2, r1” in the avoidance target instruction sequence is converted to the instruction “add r1, r2, r5”, and the subsequent The instruction referring to r1 is retrieved, and the instruction “add # 1, r1, r1” is converted into the instruction “add # 1, r5, r1”, and then output to the instruction string storage means 340.
[0116]
Since then, (10000030) 16 Since there is no problem with one instruction sequence word starting from the address, it is output to the instruction sequence storage means 340 as it is.
[0117]
Through the above processing, the instruction fetch boundary detection unit 310 outputs the instruction fetch boundary information indicated by the bold line in FIG. 12A, and the avoidance target code detection unit 320 detects the shaded portion as shown in FIG. As shown in FIG. 12B, the sequential execution guarantee code generating means 330 detects the instruction sequence and changes the output register of the shaded instruction sequence output from the avoidance target code detecting means 320 as shown in FIG. , The reference register of the instruction sequence in the dark shaded portion that refers to the output register is changed, and the instruction sequence is output to the instruction sequence storage means 340.
[0118]
In this embodiment, an instruction fetch width of 128 bits, a variable length of 32 bits and 64 bits, and a VLIW processor with a maximum of four simultaneous execution instructions are assumed, but these values are not particularly limited.
[0119]
Further, the sequential execution guarantee code generation means searches for an unused register in the instruction sequence, and replaces the output register of the instruction that outputs the problematic register in the problematic instruction sequence with an unused register. The algorithm for replacing the reference register of the instruction that refers to the register in question in the following word with the replaced register has been described, but in the same way as the second program generation device in the first embodiment, the register in question in advance May be transferred to a register that is not used, and an algorithm that replaces the reference register of the instruction that refers to the register in question with the replaced register may be performed.
[0120]
The instruction sequence output by the avoidance target code detection means is a combination of an output instruction and a reference instruction, and thus is not limited to two instructions. When there are a plurality of reference instructions, there may be a combination of three or more instructions.
[0121]
The instruction sequence storage means may be a recording medium such as a floppy disk, a tape, a hard disk, or a memory, or may be an input file to an optimization program such as a compiler or an assembler optimizer. It is possible to further optimize the output file by repeating the process using the optimization program.
[0122]
Further, the instruction fetch width recognized by the instruction fetch boundary detection means does not need to be fixed, and for example, a different value may be set for each memory area. In that case, the instruction fetch boundary detecting means determines the instruction fetch width from the address information.
[0123]
Further, the instruction fetch width information may be incorporated in the program generation apparatus or information may be given from the outside. Specifically, it may be specified as a constant incorporated in a compiler, assembler or linker, or may be specified in the form of an argument or an environment file. Also, the instruction fetch width to be specified may be constant or may be given individually for each space.
[0124]
【The invention's effect】
As described above, according to the present invention, even if it is used in an environment where instruction supply cannot be sufficiently performed, Execution By doing so, performance degradation can be suppressed.
[Brief description of the drawings]
FIG. 1 is a block configuration diagram of a processor according to a first embodiment of the present invention.
FIG. 2 is a first program example and pipeline diagram according to the first embodiment of the present invention;
FIG. 3 is a second program example and pipeline diagram in the first and second embodiments of the present invention;
FIG. 4 is a block diagram of a first program generation device in the first and second embodiments of the present invention.
FIG. 5 is a program diagram in the first program generation device in the first and second embodiments of the present invention;
FIG. 6 is a block diagram of a first program generation device in the first and second embodiments of the present invention.
FIG. 7 is a diagram showing a detection algorithm of an avoidance target code detection unit in the first program generation device according to the first embodiment of the present invention;
FIG. 8 is a program diagram of the first program generation device in the first embodiment of the present invention;
FIG. 9 is a block diagram of a second program generation device in the first and second embodiments of the present invention.
FIG. 10 is a program diagram of the second program generation device in the first embodiment of the present invention;
FIG. 11 is a program diagram of the first program generation device in the second embodiment of the present invention;
FIG. 12 is a program diagram of a second program generation device according to the second embodiment of the present invention;
FIG. 13 is a block diagram of a processor in the first conventional example.
FIG. 14 is a diagram showing a first program example
FIG. 15 is a pipeline diagram of a first program example in a conventional example.
FIG. 16 is a diagram showing a second program example
FIG. 17 is a pipeline diagram of a second program example in the conventional example.
[Explanation of symbols]
101, 201 clock
102, 202 PC
110, 210 memory
111, 211 Address bus
112, 212 Data bus
120, 220 Instruction supply issuer
121, 221 Instruction fetch control unit
122, 222 Instruction register
123 Instruction fetch flag
124 Location information
130, 230 Instruction decoding part
131 Cancel signal generator
132, 232 decoder
133, 233 registers
134, 135, 234 Cancel signal
136, 236 decoder
137, 237 NOP signal generator
223 storage flag
224 use flag

Claims (2)

固定長又は可変長の複数の命令を並列に実行できるVLIWプロセッサにおいて、並列に実行できる命令の総ビット数よりも小さい単位で命令フェッチを行い命令レジスタに格納する命令供給発行部と、
いずれの命令解読器に命令が供給されているかを判断する命令発行器と、
前記命令発行器に基づいて、命令が格納されていない命令レジスタに対応する解読結果としてNOPを出力し、命令が格納されている命令レジスタに対応する解読結果はそのまま出力するNOP生成部とを有し、
並列に実行できる前記複数の命令が、命令フェッチされた命令と命令フェッチされていない命令とを含むとき、前記命令フェッチされた命令のみを実行することを特徴とするVLIWプロセッサの実行するプログラムを生成するプログラム生成装置であって、
一語が複数の単位命令からなるVLIWプロセッサのソースコードを格納するソースコード格納手段と、
前記ソースコード格納手段に格納された前記ソースコード中で一語内の単位命令を同時実行した場合と一語内の単位命令を逐次実行した場合で実行結果が異なる問題コードを検出する回避対象コード検出手段と、
前記回避対象コード検出手段により検出された問題コードを一語内の単位命令を同時実行した場合と一語内の単位命令を逐次実行した場合で実行結果が異ならないコードに置き換える逐次実行保証コード生成手段と、
前記逐次実行保証コード生成手段が生成した生成コードを格納する生成コード格納手段とを備えることを特徴とするプログラム生成装置。
In a VLIW processor that can execute a plurality of fixed-length or variable-length instructions in parallel, an instruction supply issuing unit that fetches instructions in units smaller than the total number of bits of instructions that can be executed in parallel and stores them in an instruction register;
An instruction issuer for determining which instruction decoder is supplied with an instruction;
Based on the instruction issuer, there is provided a NOP generation unit that outputs a NOP as a decoding result corresponding to an instruction register in which no instruction is stored and outputs a decoding result corresponding to the instruction register in which the instruction is stored as it is. And
When the plurality of instructions that can be executed in parallel include an instruction fetched instruction and an instruction not fetched instruction, only the instruction fetched instruction is executed, and a program to be executed by the VLIW processor is generated A program generation device for
Source code storage means for storing the source code of the VLIW processor in which one word is composed of a plurality of unit instructions;
Avoidance target code for detecting problem codes having different execution results when unit instructions in one word are simultaneously executed in the source code stored in the source code storage means and when unit instructions in one word are sequentially executed. Detection means;
Sequential execution guarantee code generation that replaces the problem code detected by the avoidance target code detection means with a code that does not differ in execution result when a unit instruction in one word is executed simultaneously and when a unit instruction in one word is executed sequentially Means,
A program generation apparatus comprising: generated code storage means for storing the generated code generated by the sequential execution guarantee code generating means.
前記ソースコード格納手段に格納されたソースコード中の命令フェッチ境界を検出し命令フェッチ境界情報を出力する命令フェッチ境界検出手段とを備え、
前記回避対象コード検出手段は前記ソースコード格納手段に格納された前記ソースコードの中で一語内の単位命令を同時実行した場合と一語内の単位命令を命令フェッチ境界を単位に逐次実行した場合で実行結果が異なる問題コードを検出し、
逐次実行保証コード生成手段は一語内の単位命令を同時実行した場合と一語内の単位命令を命令フェッチ境界を単位に逐次実行した場合で実行結果が異ならないコードに置き換えることを特徴とする請求項記載のプログラム生成装置。
Instruction fetch boundary detection means for detecting an instruction fetch boundary in the source code stored in the source code storage means and outputting instruction fetch boundary information;
The avoidance target code detecting means sequentially executes unit instructions in one word in the source code stored in the source code storage means and sequentially executes unit instructions in one word in units of instruction fetch boundaries. Detect problem codes with different execution results
Sequential execution guarantee code generating means is characterized in that a unit instruction in one word is replaced with a code that does not differ in execution result when a unit instruction in one word is sequentially executed in units of instruction fetch boundaries. The program generation device according to claim 1 .
JP16787598A 1998-06-16 1998-06-16 VLIW processor, program generation device, and recording medium Expired - Fee Related JP3915019B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP16787598A JP3915019B2 (en) 1998-06-16 1998-06-16 VLIW processor, program generation device, and recording medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP16787598A JP3915019B2 (en) 1998-06-16 1998-06-16 VLIW processor, program generation device, and recording medium

Publications (3)

Publication Number Publication Date
JP2000003279A JP2000003279A (en) 2000-01-07
JP2000003279A5 JP2000003279A5 (en) 2005-10-20
JP3915019B2 true JP3915019B2 (en) 2007-05-16

Family

ID=15857704

Family Applications (1)

Application Number Title Priority Date Filing Date
JP16787598A Expired - Fee Related JP3915019B2 (en) 1998-06-16 1998-06-16 VLIW processor, program generation device, and recording medium

Country Status (1)

Country Link
JP (1) JP3915019B2 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6312561B1 (en) * 2000-01-21 2001-11-06 E. I. Du Pont De Nemours And Company Flame barrier compositions and their use
WO2002101562A1 (en) * 2001-06-12 2002-12-19 Tops Systems Corporation Multiprocessor system and signal processor
JP3564445B2 (en) 2001-09-20 2004-09-08 松下電器産業株式会社 Processor, compiling device and compiling method

Also Published As

Publication number Publication date
JP2000003279A (en) 2000-01-07

Similar Documents

Publication Publication Date Title
KR100900364B1 (en) Instruction execution device, instruction execution method, and computer readable memory media
US8161266B2 (en) Replicating opcode to other lanes and modifying argument register to others in vector portion for parallel operation
EP2951681B1 (en) Solution to divergent branches in a simd core using hardware pointers
US6889318B1 (en) Instruction fusion for digital signal processor
US8612728B2 (en) Reducing data hazards in pipelined processors to provide high processor utilization
EP2951682B1 (en) Hardware and software solutions to divergent branches in a parallel pipeline
JP2010532063A (en) Method and system for extending conditional instructions to unconditional instructions and selection instructions
WO2002008893A1 (en) A microprocessor having an instruction format containing explicit timing information
JP3449186B2 (en) Data processing device having pipeline bypass function
KR101183270B1 (en) Method and data processor with reduced stalling due to operand dependencies
CN108319559B (en) Data processing apparatus and method for controlling vector memory access
US6324639B1 (en) Instruction converting apparatus using parallel execution code
JP4841861B2 (en) Arithmetic processing device and execution method of data transfer processing
JP2006522398A (en) Using bypass in pipelined instruction processors
WO2006122941A2 (en) Controlling out of order execution pipelines using skew parameters
US7454598B2 (en) Controlling out of order execution pipelines issue tagging
KR100983135B1 (en) Processor and method for grouping and executing dependency instructions of packets
JP3915019B2 (en) VLIW processor, program generation device, and recording medium
JP2009508180A (en) Efficient subprogram return in microprocessors.
JP3182591B2 (en) Microprocessor
US6886091B1 (en) Replacing VLIW operation with equivalent operation requiring fewer issue slots
US20070220235A1 (en) Instruction subgraph identification for a configurable accelerator
JPH11242599A (en) Computer program
JP2004508607A (en) Apparatus and method for reducing register write traffic in a processor having an exception routine
GB2515020A (en) Operand generation in at least one processing pipeline

Legal Events

Date Code Title Description
A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20050616

A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20050616

RD01 Notification of change of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7421

Effective date: 20050621

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20060414

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20060418

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20060619

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20060711

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20060911

A911 Transfer of reconsideration by examiner before appeal (zenchi)

Free format text: JAPANESE INTERMEDIATE CODE: A911

Effective date: 20060915

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20061003

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20061204

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20070122

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20100216

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20110216

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120216

Year of fee payment: 5

LAPS Cancellation because of no payment of annual fees