[go: up one dir, main page]

JPH06161748A - Subroutine return prediction mechanism - Google Patents

Subroutine return prediction mechanism

Info

Publication number
JPH06161748A
JPH06161748A JP2403242A JP40324290A JPH06161748A JP H06161748 A JPH06161748 A JP H06161748A JP 2403242 A JP2403242 A JP 2403242A JP 40324290 A JP40324290 A JP 40324290A JP H06161748 A JPH06161748 A JP H06161748A
Authority
JP
Japan
Prior art keywords
instruction
subroutine
pipeline
buffer
ring
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2403242A
Other languages
Japanese (ja)
Inventor
Jr Simon C Steely
シー スティーリー ジュニア シモン
David J Sager
ジェイ サージャー ディヴィッド
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.)
Digital Equipment Corp
Original Assignee
Digital Equipment Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Digital Equipment Corp filed Critical Digital Equipment Corp
Publication of JPH06161748A publication Critical patent/JPH06161748A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • G06F9/4484Executing subprograms
    • G06F9/4486Formation of subprogram jump address
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/3005Arrangements for executing specific machine instructions to perform operations for flow control
    • G06F9/30054Unconditional branch instructions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/32Address formation of the next instruction, e.g. by incrementing the instruction counter
    • G06F9/322Address formation of the next instruction, e.g. by incrementing the instruction counter for non-sequential address
    • G06F9/323Address formation of the next instruction, e.g. by incrementing the instruction counter for non-sequential address for indirect branch instructions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3802Instruction prefetching
    • G06F9/3804Instruction prefetching for branches, e.g. hedging, branch folding
    • G06F9/3806Instruction prefetching for branches, e.g. hedging, branch folding using address prediction, e.g. return stack, branch history buffer

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Advance Control (AREA)
  • Executing Machine-Instructions (AREA)

Abstract

(57)【要約】 【目的】 パイプライン式コンピュータにおいてスタッ
クを使用するときに複雑な手順を必要とせずパイプライ
ン内のバブルを除去すると共に復帰アドレスを与える機
構を提供する。 【構成】 コンピュータパイプラインにおいてサブルー
チン復帰命令の入力に応答して予想されるサブルーチン
復帰アドレスを発生する機構であり、リングポインタカ
ウンタと、これに接続されたリングバッファとを有して
いる。リングポインタカウンタのリングポインタは、サ
ブルーチン呼び出し命令又は復帰命令のいずれかがパイ
プラインに入るときに変更される。リングバッファのバ
ッファ位置は、サブルーチン呼び出し命令がパイプライ
ンに入るときリングポインタで指示されたバッファ位置
に入力の値が記憶されるようになっている。リングバッ
ファは、サブルーチン復帰命令がコンピュータパイプラ
インに入るときにリングポインタで指示されたバッファ
位置からの値を与え、この値が予想されるサブルーチン
復帰アドレスとなる。
(57) [Summary] [Object] To provide a mechanism for removing a bubble in a pipeline and giving a return address without using a complicated procedure when using a stack in a pipeline type computer. A mechanism for generating an expected subroutine return address in response to an input of a subroutine return instruction in a computer pipeline, which has a ring pointer counter and a ring buffer connected thereto. The ring pointer of the ring pointer counter is changed when either a subroutine call instruction or a return instruction enters the pipeline. The buffer position of the ring buffer is such that the value of the input is stored in the buffer position designated by the ring pointer when the subroutine call instruction enters the pipeline. The ring buffer gives a value from the buffer position pointed to by the ring pointer when the subroutine return instruction enters the computer pipeline, and this value becomes the expected subroutine return address.

Description

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

【0001】[0001]

【産業上の利用分野】本発明は、パイプライン式コンピ
ュータにおいて制御の流れを変更する技術に係り、より
詳細には、高度にパイプライン構造となったコンピュー
タにおいてサブルーチンに関連した命令を処理すること
に係る。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a technique for changing a control flow in a pipeline type computer, and more particularly to processing instructions related to a subroutine in a computer having a highly pipelined structure. Pertain to.

【0002】[0002]

【従来の技術】コンピュータにおいて命令をパイプライ
ン構成にする考え方は良く知られている。単一命令の処
理は、フェッチ、デコード及び実行といった多数の異な
った段階で行なわれる。パイプライン式コンピュータに
おいては、種々の段階の各々が種々の命令に同時に作用
する。例えば、パイプラインの長さが3つの段階のみで
ある場合には、パイプラインを通過した第1の命令が第
3の段階によって実行されている間に、パイプラインに
入る第2の命令が第2の段階によって実行され、一方、
パイプラインに入る第3の命令は第1の段階によって実
行される。パイプライン構成は、単一の命令が完全に処
理されるのを待ってから第2命令の処理を開始する場合
に比して、非常に効率的な命令処理方法である。コンピ
ュータプログラムの通常の流れにおいては、どの命令が
次にパイプラインに入るかが容易に分かる。ほとんどの
場合に、順番で次の命令がパイプラインに入り、従っ
て、例えば、命令101は命令100の後にパイプライ
ンに入る。
2. Description of the Related Art The concept of making instructions pipelined in a computer is well known. The processing of a single instruction occurs in many different stages, such as fetching, decoding and executing. In pipelined computers, each of the various stages operates on various instructions simultaneously. For example, if the length of the pipeline is only three stages, then while the first instruction that has passed through the pipeline is being executed by the third stage, the second instruction that enters the pipeline is Performed in two stages, while
The third instruction entering the pipeline is executed by the first stage. The pipeline configuration is a very efficient instruction processing method as compared with the case where the processing of the second instruction is started after waiting for the single instruction to be completely processed. In the normal flow of a computer program, it is easy to see which instruction goes into the pipeline next. In most cases, the next instruction in sequence enters the pipeline, so, for example, instruction 101 enters the pipeline after instruction 100.

【0003】この通常の制御の流れに対する1つの例外
はサブルーチンとして知られている。サブルーチンと
は、或るプログラム又は別々のプログラム内の別々の点
において同じタスクを実行するために呼び出すことので
きるプログラム又は一連の命令である。例えば、命令1
00は、命令200で実行を開始するサブルーチンを呼
び出す。サブルーチンは命令200ないし202を実行
し、次いで、命令102において主たる流れに戻る。更
に、命令200ないし202より成る同じサブルーチン
が主たる流れの多数の種々の位置から呼び出されそして
主たる流れの種々の位置へ戻る。
One exception to this normal flow of control is known as a subroutine. A subroutine is a program or set of instructions that can be called to perform the same task at different points within a program or different programs. For example, instruction 1
00 calls a subroutine that begins execution at instruction 200. The subroutine executes instructions 200-202 and then returns to the main flow at instruction 102. In addition, the same subroutine of instructions 200-202 is called from a number of different locations in the main stream and returns to various locations in the main stream.

【0004】これらのサブルーチンは、著しいパイプラ
イン構造のコンピュータ(パイプラインに多数の段を有
するもの)について問題を課する。サブルーチンを呼び
出す命令は、どれがパイプラインに入る次の命令である
か(即ち、呼び出されたサブルーチンにおける第1の命
令であるか)を判断するに充分な情報を含んでいるが、
サブルーチンにおける復帰命令はこのような情報を含ま
ない。実際に、復帰命令は、この復帰命令から復帰アド
レスが分かる前にパイプラインの全ての段を通過しなけ
ればならない。復帰命令がパイプラインを通過してから
別の命令に入るまでコンピュータが待期された場合に
は、復帰命令の後に全く命令のないバブルが生じ、コン
ピュータの性能を低下させる。
These subroutines pose a problem for computers of significant pipeline structure (those with multiple stages in the pipeline). The instruction that calls the subroutine contains enough information to determine which is the next instruction to enter the pipeline (ie, the first instruction in the called subroutine),
The return instruction in the subroutine does not include such information. In fact, the return instruction must go through all stages of the pipeline before the return address is known from the return instruction. If the computer is delayed until the return instruction passes through the pipeline until it enters another instruction, a bubble with no instruction occurs after the return instruction, degrading the performance of the computer.

【0005】これらのバブルを回避するために、スタッ
クとして知られている機構が使用されていた。基本的
に、スタックはサブルーチンが呼び出されたときに復帰
アドレスを記憶するものであり、サブルーチンが完了し
て制御が復帰命令によって主たる流れに復帰されたとき
には、この復帰アドレスがスタック内で探索されそして
パイプラインに送られる。従って、パイプラインは、適
当な命令をパイプラインに入れることにより制御を主た
る流れに復帰させることができる。復帰アドレスのスタ
ックを保持しそしてサブルーチンから戻るときにこれら
の復帰アドレスを用いて次の命令を探索することによ
り、パイプライン内のバブルが除去される。
To avoid these bubbles, a mechanism known as the stack was used. Basically, the stack stores the return address when the subroutine is called, and when the subroutine is completed and control is returned to the main flow by the return instruction, this return address is searched in the stack and Sent to the pipeline. Therefore, the pipeline can return control to the main flow by putting the appropriate instructions into the pipeline. Bubbles in the pipeline are eliminated by holding a stack of return addresses and using these return addresses to search for the next instruction when returning from the subroutine.

【0006】[0006]

【発明が解決しようとする課題】スタック機構に伴なう
問題は、スタックのサイズに限度があると共に、多数の
サブルーチンが呼び出されたときにスタックのオーバー
ラン及びアンダーランを取り扱う手順が複雑であること
である。換言すれば、スタックが12の位置を含んでい
る場合に、スタックオーバーランに対する複雑な手順に
頼ることなく一度に呼び出すことのできるサブルーチン
は12個であるに過ぎない。
The problem with the stack mechanism is that the size of the stack is limited and the procedure for handling stack overruns and underruns when multiple subroutines are called is complicated. That is. In other words, if the stack contains 12 locations, only 12 subroutines can be called at a time without resorting to the complicated procedure for stack overruns.

【0007】そこで、復帰アドレスを与えると共に、パ
イプライン内のバブルを排除し、然もスタックを用いる
ときに必要な複雑な手順を必要としない機構が要望され
ている。
Therefore, there is a demand for a mechanism that gives a return address, eliminates bubbles in the pipeline, and does not require the complicated procedure required when using the stack.

【0008】[0008]

【課題を解決するための手段】このそして別の要望は、
サブルーチン復帰アドレスを予想するようにスタック機
構の特性を模擬するリングバッファを提供する本発明に
よって満足される。このリングバッファは、サブルーチ
ンが呼び出されるたびに(即ち、パイプラインに入るた
びに)予想される復帰アドレスをそのリングバッファ位
置の1つに記憶する。サブルーチン復帰命令がパイプラ
インに入ると、予想される復帰アドレスがリングバッフ
ァからパイプラインに送られ、主たる流れからの適当な
命令がパイプラインに入ることができる。このように、
パイプラインのバブルが除去される。
[Means for Solving the Problems] This and another request are
It is satisfied by the present invention to provide a ring buffer that mimics the characteristics of the stack mechanism to predict the subroutine return address. This ring buffer stores the expected return address each time the subroutine is called (ie, each time it enters the pipeline) in one of its ring buffer locations. When a subroutine return instruction enters the pipeline, the expected return address is sent from the ring buffer to the pipeline so that the appropriate instructions from the main stream can enter the pipeline. in this way,
Bubbles in the pipeline are removed.

【0009】本発明に用いられるリングバッファはサイ
ズが限定されたものであり、例えば、8個の異なった復
帰アドレスを記憶するための8つの位置を有している。
8個より多いサブルーチンが復帰なしに呼び出された場
合には、リングバッファ形態で、最も早く記憶された復
帰アドレスが、そのリングバッファに記憶されているよ
り最近の復帰アドレスでオーバーライトされる。最終的
に、オーバーライトされた復帰アドレスに関連したサブ
ルーチンがパイプラインを通る処理を完了し、そして制
御の流れが主たる流れに変更されたときには、リングバ
ッファ内の予想される復帰アドレスが間違ったものとな
る。復帰命令の実際の復帰アドレスは、復帰命令がパイ
プラインを完全に通過したときにパイプラインの端で分
かる。この実際の復帰アドレスは、この時にリングバッ
ファ内の予想される復帰アドレスと比較される。予想さ
れる復帰アドレスが間違っていることがこの比較によっ
て示されると、パイプラインがフラッシュされ、実際の
復帰アドレスを用いてその命令から再開される。
The ring buffer used in the present invention is of limited size and has, for example, eight positions for storing eight different return addresses.
If more than eight subroutines are called without a return, the earliest stored return address in ring buffer form is overwritten with the more recent return address stored in that ring buffer. Eventually, the expected return address in the ring buffer is incorrect when the subroutine associated with the overwritten return address completes processing through the pipeline, and control flow is changed to main flow. Becomes The actual return address of the return instruction is known at the end of the pipeline when the return instruction has completely traversed the pipeline. This actual return address is then compared to the expected return address in the ring buffer. If this comparison indicates that the expected return address is incorrect, the pipeline is flushed and the instruction is restarted with the actual return address.

【0010】充分な働きをするプログラムの場合、復帰
アドレスは90%の時間にわたって正しく予想される。
For well-functioning programs, the return address is correctly predicted over 90% of the time.

【0011】[0011]

【実施例】図1はコンピュータプログラムの制御の流れ
を示すブロック図である。命令100−107は、命令
の主たる流れ10を作り上げる命令である。命令200
−202の第2の流れがサブルーチン12を構成する。
図1の例においては、サブルーチン12が2つの命令1
01及び104の1つから呼び出される。サブルーチン
12が例えば命令101から呼び出されると、コンピュ
ータは命令200、201を実行し、命令202で主た
る流れ10に復帰する。主たる流れ10の実行は命令1
02において再開される。然し乍ら、サブルーチン12
が命令104から呼び出された場合には、サブルーチン
12は命令の流れを命令105において主たる流れ10
に戻さねばならない。
1 is a block diagram showing the control flow of a computer program. Instructions 100-107 are instructions that make up the main flow of instructions 10. Command 200
The second stream at -202 constitutes subroutine 12.
In the example of FIG. 1, the subroutine 12 has two instructions 1
Called from one of 01 and 104. When the subroutine 12 is called from, for example, the instruction 101, the computer executes the instructions 200 and 201, and the instruction 202 returns to the main flow 10. Execution of main flow 10 is instruction 1
It will be resumed at 02. However, subroutine 12
, Is called from instruction 104, subroutine 12 directs the instruction flow to the main flow 10 at instruction 105.
Must be returned to.

【0012】上記流れの説明から明らかなように、主た
る流れ10は2つの場所の1つにおいてサブルーチン1
2から復帰することができる。もっと大規模なプログラ
ムにおいては、主たる流れへの復帰をいかなる数の場所
でも行なうことができる。パイプライン式コンピュータ
において命令を実行する場合には、パイプラインの次々
の段で多数の動作が実行される。コンピュータのパイプ
ライン構成は公知であり、パイプラインの個別の段で個
別の命令に対して同時に動作することが含まれる。例え
ば、パイプラインに5つの段がある場合、これら5つの
段の各々において異なった命令が同時に実行され、各段
において個々の命令に対して別々の動作が行なわれる。
命令をパイプライン構成にすることは、各命令が完了し
てから次の命令の処理を開始するのを待機する場合より
も非常に効率的に命令を処理する方法である。
As is apparent from the above description of the flow, the main flow 10 is the subroutine 1 in one of two places.
You can return from 2. In larger programs, the return to the main flow can occur at any number of locations. When executing instructions in a pipelined computer, many operations are performed in successive stages of the pipeline. Computer pipeline configurations are well known and involve operating simultaneously on separate instructions in separate stages of the pipeline. For example, if there are five stages in the pipeline, different instructions are executed concurrently in each of these five stages, with each stage performing different operations on individual instructions.
Pipelining instructions is a way to process instructions much more efficiently than waiting for each instruction to complete before starting to process the next instruction.

【0013】本発明により構成されたパイプラインが図
2に示されており、参照番号20で示されている。パイ
プライン20はプログラムカウンタバッファ21を有し
ており、これはプログラムカウント即ち“PC”を命令
キャッシュ22にバッファする。命令キャッシュ22に
はいつでも多数の命令が記憶される。命令キャッシュ2
2がプログラムカウンタバッファ21からPCを受け取
ると、コード化された命令が命令フェッチデコーダ24
に送られる。その名称の示す通り、デコーダ24は、プ
ログラムカウンタバッファ21によって指示された命令
キャッシュ22からの命令をデコードする。パイプライ
ン技術によれば、デコーダ24はパイプラインの第1命
令をデコードし、その間に第2の命令が命令キャッシュ
22内で探索される。
A pipeline constructed in accordance with the present invention is shown in FIG. 2 and is designated by the reference numeral 20. The pipeline 20 has a program counter buffer 21, which buffers the program count or "PC" in the instruction cache 22. A large number of instructions are stored in the instruction cache 22 at any time. Instruction cache 2
When 2 receives the PC from the program counter buffer 21, the coded instruction is transferred to the instruction fetch decoder 24.
Sent to. As the name implies, the decoder 24 decodes the instruction from the instruction cache 22 designated by the program counter buffer 21. According to the pipeline technique, the decoder 24 decodes the first instruction of the pipeline while the second instruction is searched in the instruction cache 22.

【0014】デコードされた命令はデコーダ24から命
令バッファ26に送られ、該バッファ26はデコードさ
れた命令を単にバッファするだけのものである。命令バ
ッファ26の後には、スケジューリング形式のファンク
ションを実行する発行論理回路28がある。パイプライ
ン内の他の段は参照番号30で示されているが、これは
いかなる数の段であってもよい。パイプライン20の最
終段は、命令を実行する実行段32である。第2図のパ
イプライン20には6個の段があるので、6個までの命
令を同時に処理することができる。
Decoded instructions are sent from decoder 24 to instruction buffer 26, which merely buffers the decoded instructions. Following the instruction buffer 26 is an issue logic circuit 28 which performs a scheduling type function. The other stages in the pipeline are shown at reference numeral 30, but this could be any number of stages. The final stage of the pipeline 20 is the execution stage 32, which executes instructions. Since pipeline 20 of FIG. 2 has six stages, up to six instructions can be processed simultaneously.

【0015】通常は、命令キャッシュ22から1つの命
令、例えば命令100が呼び出された後に、次の命令が
キャッシュ22から呼び出され、順番で次の命令、例え
ば命令101となる。命令101のような呼び出し命令
の場合には、デコードされた命令それ自体が、実行され
るべき次の命令のためのPCを与える。この場合、呼び
出し命令の後に実行されるべき次の命令は、サブルーチ
ンの第1命令、例えば命令200となる。このように、
順番で次の命令(PC+1)か又はデコードされた呼び
出し命令により指示された命令かのいずれかを用いるこ
とにより、パイプライン20にはいっぱいの命令が保持
される。パイプライン内の1つ以上の段にバブルがある
(命令がない)場合にはパイプライン20が効率的に使
用されない。このようなバブルは、以下に述べるよう
に、命令202のようなサブルーチン復帰命令で潜在的
に生じることがある。
Usually, after one instruction, for example, the instruction 100, is called from the instruction cache 22, the next instruction is called from the cache 22 and becomes the next instruction, for example, the instruction 101 in order. In the case of a calling instruction, such as instruction 101, the decoded instruction itself provides the PC for the next instruction to be executed. In this case, the next instruction to be executed after the calling instruction is the first instruction of the subroutine, for example instruction 200. in this way,
A full instruction is held in pipeline 20 by using either the next instruction in turn (PC + 1) or the instruction pointed to by the decoded call instruction. Pipeline 20 is not used efficiently if there are bubbles (no instructions) in one or more stages in the pipeline. Such bubbles can potentially occur on subroutine return instructions, such as instruction 202, as described below.

【0016】サブルーチン復帰命令でパイプライン20
にバブルが生じる理由は、サブルーチン復帰命令が実行
段32において実行されてしまうまで、主たる流れに復
帰する実際の場所(実際の復帰アドレス)が分からない
からである。更に別の手段がとられない場合には、次の
命令のアドレスが分からないので段22−30がサブル
ーチン復帰命令の後方で空になる。先に述べたように、
このバブルはパイプライン20の使用効率が低いことを
表わしている。
Pipeline 20 by a subroutine return instruction
The reason why the bubble occurs is that the actual location (actual return address) of returning to the main flow is unknown until the subroutine return instruction is executed in the execution stage 32. If no further measures are taken, the address of the next instruction is not known and stages 22-30 are empty after the subroutine return instruction. As mentioned earlier,
This bubble indicates that the usage efficiency of the pipeline 20 is low.

【0017】パイプライン20のバブルを防ぐために
は、パイプライン20の復帰命令の後に処理すべき次の
命令が何であるかを予想する機構がなければならない。
或るコンピュータアーキテクチャでは、サブルーチンが
呼び出されるたびに各々の復帰アドレスを記憶するスタ
ックを使用することができる。このスタックは後入れ先
出し方式でこれらの復帰アドレスを記憶し、これによ
り、パイプラインにおいて次の復帰命令がデコードされ
るときには、スタックに記憶された最後の復帰アドレス
がスタックから発生される最初の復帰アドレスとなる。
然し乍ら、或るコンピュータアーキテクチャでは、スタ
ックを使用することができない。
In order to prevent bubbles in the pipeline 20, there must be a mechanism for predicting what the next instruction to process after the pipeline 20 return instruction.
Some computer architectures can use a stack that stores each return address each time the subroutine is called. This stack stores these return addresses in a last in, first out manner so that when the next return instruction is decoded in the pipeline, the last return address stored in the stack is the first return generated from the stack. It becomes an address.
However, in some computer architectures the stack cannot be used.

【0018】本発明は、スタック装置を実際に使用する
ことなくスタックの基本的な機能を果たすものである。
(本発明はスタックのないアーキテクチャに有用である
が、スタックを使用するアーキテクチャにも有用であ
る。)むしろ、図2に示すように、リングバッファ34
が使用される。このリングバッファ34は、比較的少数
の予想される復帰アドレスを保持する。以下で詳細に説
明するように、リングバッファ34に保たれた予想され
る復帰アドレスは、命令フェッチデコーダ24が復帰ア
ドレスをデコードしたときに命令キャッシュ22から次
の命令をフェッチするのに使用される。次いで、パイプ
ライン20は、それ自体にバブルを形成することなく次
の命令に基づいて動作し続ける。予想される復帰アドレ
スが最終的に間違っていると分った場合には、命令シー
ケンスが中止され、正しい命令シーケンスを用いて実行
が続けられる。
The present invention performs the basic functions of the stack without actually using the stack device.
(The present invention is useful for architectures without stacks, but also for architectures that use stacks.) Rather, as shown in FIG.
Is used. This ring buffer 34 holds a relatively small number of expected return addresses. The expected return address held in the ring buffer 34 is used to fetch the next instruction from the instruction cache 22 when the instruction fetch decoder 24 decodes the return address, as described in detail below. . The pipeline 20 then continues to operate based on the next instruction without forming a bubble on itself. If the expected return address is finally found to be incorrect, the instruction sequence is aborted and execution continues with the correct instruction sequence.

【0019】リングバッファ34は、例えば、深さ8の
バッファであり、各位置に予想される復帰アドレスが記
憶される。上記で述べたように、命令キャッシュ22は
プログラムカウンタバッファ21からプログラムカウン
ト(PC)を受け取って命令を探索する。このPCは加
算器38にも送られ、該加算器はPCに値1を加える。
この値PC+1はリングバッファ34及びマルチプレク
サ36に送られる。サブルーチン又は分岐を伴わない通
常の命令シーケンス中には、1つの命令の後に順次に別
の命令が続き、PC=PC+1となる。最初の命令に対
するプログラムカウントがPCである場合には、次の命
令に対するプログラムカウントがPC+1となり、そし
て第3の命令がPC+2となる。他の実施例において
は、増分値が1とは異なり、例えば、命令300に続く
命令のアドレスが304であり、そしてその次が308
となる。この場合、PCの値は4だけ変化し、従ってP
C=PC+4となる。
The ring buffer 34 is, for example, a buffer having a depth of 8 and stores an expected return address at each position. As described above, the instruction cache 22 receives the program count (PC) from the program counter buffer 21 and searches for an instruction. This PC is also sent to adder 38, which adds the value 1 to PC.
This value PC + 1 is sent to the ring buffer 34 and the multiplexer 36. During a normal instruction sequence without a subroutine or branch, one instruction is followed by another instruction in sequence, PC = PC + 1. If the program count for the first instruction is PC, then the program count for the next instruction will be PC + 1 and the third instruction will be PC + 2. In another embodiment, the increment value is different than 1, eg, the address of the instruction following instruction 300 is 304 and then 308.
Becomes In this case, the value of PC changes by 4, so P
C = PC + 4.

【0020】又、マルチプレクサ36は命令フェッチデ
コーダ24から入力を受け取る。一方の入力は呼び出し
命令内に含まれた呼び出されたサブルーチンアドレス
(CSA)であり、上記呼び出し命令は命令キャッシュ
22から受け取られてデコーダ24でデコードされたも
のである。上記呼び出されたサブルーチンアドレスは、
デコードされた命令が呼び出し命令であるときに命令キ
ャッシュ22に対するPCとしてマルチプレクサ36か
ら選択される。命令フェッチデコーダ24においてデコ
ードされた命令が復帰命令であり、呼び出し命令でない
場合には、RPカウンタ40を経てリングバッファ34
に信号が送られる。RPカウンタ40は、リングバッフ
ァ34をインデックスするリングポインタ(RP)を含
んでいる。リングバッファ34は、RPによって指示さ
れた予想される復帰アドレス(PRA)をマルチプレク
サ36に送る。命令フェッチデコーダ24からの信号の
制御のもとで、マルチプレクサ36は命令キャッシュ2
2に対するPCとしてPRAを選択する。リングバッフ
ァ34の動作については以下に説明する。
The multiplexer 36 also receives inputs from the instruction fetch decoder 24. One input is the called subroutine address (CSA) contained in the calling instruction, which is received from the instruction cache 22 and decoded by the decoder 24. The subroutine address called above is
It is selected from the multiplexer 36 as the PC for the instruction cache 22 when the decoded instruction is a call instruction. When the instruction decoded by the instruction fetch decoder 24 is a return instruction and not a call instruction, the ring buffer 34 is passed through the RP counter 40.
Is sent to. The RP counter 40 includes a ring pointer (RP) that indexes the ring buffer 34. Ring buffer 34 sends to multiplexer 36 the expected return address (PRA) pointed to by RP. Under the control of the signal from the instruction fetch decoder 24, the multiplexer 36 operates in the instruction cache 2
Select PRA as the PC for 2. The operation of the ring buffer 34 will be described below.

【0021】以上、PCを選択するためのマルチプレク
サ36の3つの入力について説明した。これらのうちの
最初のものはPC+1であり、これは、命令フェッチデ
コーダ24によってデコードされた命令が呼び出し命令
でも復帰命令でもないときにマルチプレクサによって選
択される。マルチプレクサ36への第2入力は、デコー
ドされた入力に含まれた呼び出されたサブルーチンアド
レス(CSA)であり、これは命令フェッチデコーダ2
4によりマルチプレクサ36へ送られたものである。C
SAは、デコーダ24が呼び出し命令をデコードしたと
きに使用される。以上に述べたマルチプレクサ36への
第3入力は、復帰命令がデコーダ24によってデコード
されたときにリングバッファ34によってマルチプレク
サ36に送られた予想される復帰アドレス(PRA)で
ある。リングバッファ34の動作は以下に述べる。
The three inputs of the multiplexer 36 for selecting the PC have been described above. The first of these is PC + 1, which is selected by the multiplexer when the instruction decoded by instruction fetch decoder 24 is neither a call nor a return instruction. The second input to the multiplexer 36 is the called subroutine address (CSA) contained in the decoded input, which is the instruction fetch decoder 2
4 sent to the multiplexer 36. C
The SA is used when the decoder 24 decodes the calling instruction. The third input to multiplexer 36, described above, is the expected return address (PRA) sent by ring buffer 34 to multiplexer 36 when the return instruction was decoded by decoder 24. The operation of the ring buffer 34 will be described below.

【0022】前記したように、リングバッファ34は、
予想される復帰アドレスを記憶する限定された数のバッ
ファ位置を備えている。リングバッファ34のバッファ
位置は、RPカウンタ40に保持されたリングポインタ
(RP)によってインデックスされる。RPカウンタの
動作は簡単である。デコードされた命令が呼び出し命令
であることを示すデコーダ24からの信号をRPカウン
タ40が受け取ると、RPカウンタ40は1だけ増加さ
れ、次に高いバッファ位置を指す。式で表わすと、サブ
ルーチン呼び出しの際に、RP=RP+1となる。デコ
ーダ24によってデコードされた命令が復帰命令である
ときには、RPが1だけ減少される。これは、サブルー
チン復帰命令に対しRP=RP−1という式を与える。
As described above, the ring buffer 34 is
It has a limited number of buffer locations to store expected return addresses. The buffer position of the ring buffer 34 is indexed by the ring pointer (RP) held in the RP counter 40. The operation of the RP counter is simple. When the RP counter 40 receives a signal from the decoder 24 indicating that the decoded instruction is a call instruction, the RP counter 40 is incremented by 1 and points to the next higher buffer position. Expressed as an expression, RP = RP + 1 when the subroutine is called. When the instruction decoded by the decoder 24 is a return instruction, RP is decreased by 1. This gives the equation RP = RP-1 for the subroutine return instruction.

【0023】サブルーチン呼び出し命令をデコードする
際にRPによって指示されたリングバッファ34内の位
置に入れられる値は、RPによって指示されたリングバ
ッファ34の位置に呼び出し命令のアドレスがロードさ
れた後のPCの次のアドレス値である。この値PC+1
はPRAとなる。PRAは、サブルーチン復帰命令がデ
コーダ24によってデコードされたときにリングバッフ
ァ34によってマルチプレクサ36に送られる。RPに
よって指示された位置にPC+1をロードしたりそこか
らPRAを復帰したりすることは、デコーダ24により
発生されたリングバッファ制御信号に基づいて行なわれ
る。
The value put in the position in the ring buffer 34 designated by the RP when decoding the subroutine calling instruction is the PC after the address of the calling instruction is loaded in the position of the ring buffer 34 designated by the RP. Is the next address value of. This value PC + 1
Becomes PRA. The PRA is sent by the ring buffer 34 to the multiplexer 36 when the subroutine return instruction is decoded by the decoder 24. Loading PC + 1 into the location indicated by RP and returning PRA from it is done based on the ring buffer control signal generated by decoder 24.

【0024】リングバッファ34の動作例を以下に述べ
る。パイプライン20に入る最初の命令は命令100で
ある。これは、PC=100を用いて命令キャッシュ2
2内で探索される。命令はデコーダ24においてデコー
ドされ、これはサブルーチン呼び出しでも復帰でもない
ので、デコーダ24からの制御信号は、PC+1となる
べき次のPCを選択する。この場合、PC+1の値は1
01であり、従って命令101が命令キャッシュ22か
らデコーダ24へ送られる。
An operation example of the ring buffer 34 will be described below. The first instruction to enter pipeline 20 is instruction 100. This is instruction cache 2 using PC = 100
2 is searched. The instruction is decoded in the decoder 24, which is neither a subroutine call nor a return, so the control signal from the decoder 24 selects the next PC to be PC + 1. In this case, the value of PC + 1 is 1.
01, so instruction 101 is sent from instruction cache 22 to decoder 24.

【0025】命令101はサブルーチン呼び出し(図1
参照)であり、デコーダ24はRPカウンタ40に信号
を送る。RPカウンタ40のRPは、例えばRP=3か
らRP=4へ増加され、リングバッファ34内の新たな
バッファ位置RP(4)を指す。PC+1の値、この場
合は101+1=102は、リングバッファ34におい
てリングバッファ位置RP(4)に記憶される。
Instruction 101 is a subroutine call (see FIG.
(See reference), and the decoder 24 sends a signal to the RP counter 40. The RP of the RP counter 40 is increased from RP = 3 to RP = 4, for example, and points to a new buffer position RP (4) in the ring buffer 34. The value of PC + 1, in this case 101 + 1 = 102, is stored in ring buffer 34 at ring buffer location RP (4).

【0026】デコーダ24は、呼び出し命令101をデ
コードする際に、制御信号をマルチプレクサ36に送る
と共に、呼び出されたサブルーチンアドレス(CSA)
を次のPCとして送る。CSAは、デコードされたサブ
ルーチン呼び出し命令101に含まれているので、デコ
ーダ24によりマルチプレクサ36に送ることができ
る。
When the decoder 24 decodes the call instruction 101, it sends a control signal to the multiplexer 36 and also calls the called subroutine address (CSA).
As the next PC. Since the CSA is included in the decoded subroutine call instruction 101, it can be sent to the multiplexer 36 by the decoder 24.

【0027】サブルーチン12は、命令200が命令キ
ャッシュ22から探索されてデコードされるように実行
される。命令200は呼び出し命令でも復帰命令でもな
いので、命令201が命令キャッシュ22からフェッチ
される(PC=PC+1=201)。同様に、パイプラ
インにおいて命令201の後に命令202が続く。然し
乍ら、命令202はサブルーチン復帰命令である。
Subroutine 12 is executed such that instruction 200 is retrieved from instruction cache 22 and decoded. Since the instruction 200 is neither a call instruction nor a return instruction, the instruction 201 is fetched from the instruction cache 22 (PC = PC + 1 = 201). Similarly, instruction 201 is followed by instruction 202 in the pipeline. However, the instruction 202 is a subroutine return instruction.

【0028】サブルーチン復帰命令202がデコーダ2
4によってデコードされるときには、潜在的に次の命令
は命令102又は105のいずれかとなる。(図1参
照)リングバッファ34を用いると、正しい復帰アドレ
スを通常与えることができる。復帰命令をデコードする
際には、デコーダ24がRPカウンタ40に信号を送
る。RPカウンタ40に含まれたRPによって指示され
たPRAはマルチプレクサ36に送られる。この例にお
いて、RP(4)に記憶された命令102に関連したP
RAはマルチプレクサ36に送られる。デコーダ24は
マルチプレクサ36に制御信号を送ってこのマルチプレ
クサがPRAを次のPCとして選択するようにする。従
って、送られたPRAを使用し、命令102が命令キャ
ッシュ22から送られ、デコーダ24によってデコード
される。又、RPカウンタ40内のRPは減少され、新
たにRP(3)を指す。
The subroutine return instruction 202 is the decoder 2
When decoded by 4, the potentially next instruction is either instruction 102 or 105. Using the ring buffer 34 (see FIG. 1), the correct return address can usually be provided. When decoding the return instruction, the decoder 24 sends a signal to the RP counter 40. The PRA designated by the RP included in the RP counter 40 is sent to the multiplexer 36. In this example, P associated with instruction 102 stored in RP (4)
RA is sent to multiplexer 36. Decoder 24 sends a control signal to multiplexer 36 to cause it to select PRA as the next PC. Therefore, using the PRA sent, the instruction 102 is sent from the instruction cache 22 and decoded by the decoder 24. Also, the RP in the RP counter 40 is decremented and newly points to RP (3).

【0029】以上、PRAが正しいときのパイプライン
20の動作について説明した。然し乍ら、或る状態にお
いては、PRAが正しくない。例えば、これは、サブル
ーチンが呼び出し命令の直後の命令ではなくて主たる流
れ10の別の位置への復帰を生じさせる場合に起こるこ
とがある。PRAが間違っていることは、復帰命令が完
全にパイプライン20を通過して実行されてしまうまで
分からない。復帰命令に対する実際の復帰アドレスが分
かるのはその時点である。その間に、復帰命令に続く多
数の命令が入力され、パイプライン20の種々の段に入
れられる。パイプライン20は、実際の復帰アドレスが
予想される復帰アドレスとは異なっており、修正手段を
とることを確認しなければならない。
The operation of the pipeline 20 when the PRA is correct has been described above. However, in some situations the PRA is incorrect. For example, this may occur if the subroutine causes a return of the main stream 10 to another location rather than the instruction immediately following the calling instruction. The PRA is wrong until the return instruction is completely executed through the pipeline 20. It is at that point that the actual return address for the return instruction is known. In the meantime, a number of instructions following the return instruction are input and placed in various stages of pipeline 20. It must be ensured that the pipeline 20 takes corrective measures as the actual return address is different from the expected return address.

【0030】実際の復帰アドレス(ARA)はパイプラ
インの端から比較ユニット42へ送られる。比較ユニッ
ト42はARAを受け取るのと同時に、PRAも受け取
る。PRAは一連の遅延ラッチ44を経て比較ユニット
42へ送られる。PRA及びARAが比較される。比較
が不一致である場合には、不一致比較信号がデコーダ2
4及び発行論理回路28に送られる。この不一致比較信
号により、復帰命令の後にパイプライン20に入った全
ての命令がパイプライン20からフラッシングされる。
マルチプレクサ36はARAをその第4入力に受け取
り、従って命令キャッシュ22へ送られるPCは不一致
比較が確認された後にこのARAになる。次いで、実際
の復帰アドレス(ARA)にある命令で始まる新たな一
連の命令がパイプライン20によって処理される。
The actual return address (ARA) is sent to the compare unit 42 from the end of the pipeline. At the same time the comparison unit 42 receives the ARA, it also receives the PRA. The PRA is sent to the comparison unit 42 via a series of delay latches 44. PRA and ARA are compared. If the comparisons do not match, the mismatch comparison signal is the decoder 2
4 and issue logic 28. By this mismatch comparison signal, all the instructions that have entered the pipeline 20 after the return instruction are flushed from the pipeline 20.
Multiplexer 36 receives the ARA on its fourth input, so the PC sent to instruction cache 22 becomes this ARA after a mismatch comparison is confirmed. The pipeline 20 then processes a new series of instructions beginning with the instruction at the actual return address (ARA).

【0031】リングバッファ34は限定された数のバッ
ファ位置しか有していない。これにより、予想違いの復
帰アドレスがリングバッファ34によって与えられるこ
とがある。例えば、リングバッファ34が8個の位置R
P(0)−RP(7)を有していると仮定する。8個の
サブルーチンが呼び出され、復帰がなされない場合に
は、リングバッファ34がいっぱいになる。9番目のサ
ブルーチン呼び出しが行なわれると、第1のリングバッ
ファ位置RP(0)が標準リングバッファ方式でオーバ
ーライトされる。その前にRP(0)にあったPRA
は、この位置に新たなPRAがオーバーライトされるこ
とにより本質的に失なわれる。従って、9個のサブルー
チン復帰が発生された場合には、呼び出された最初のサ
ブルーチンに対する正しいサブルーチン復帰アドレスが
RP(0)にもはや見つからない。そうではなくて、R
P(0)に記憶されたPRAの新たな値がPRAとして
発生される。このPRAが間違っていることは、PRA
とARAとの比較によって最終的に決定される。この比
較不一致が確認された際に前記の適当な修正手段がとら
れる。
Ring buffer 34 has only a limited number of buffer positions. As a result, a wrong return address may be given by the ring buffer 34. For example, the ring buffer 34 has eight positions R
Suppose we have P (0) -RP (7). If eight subroutines are called and no return is made, the ring buffer 34 will be full. When the ninth subroutine call is made, the first ring buffer position RP (0) is overwritten by the standard ring buffer method. PRA that was in RP (0) before that
Is essentially lost by overwriting a new PRA in this position. Thus, if nine subroutine returns have occurred, the correct subroutine return address for the first subroutine called is no longer found in RP (0). R, not
The new value of PRA stored in P (0) is generated as PRA. What is wrong with this PRA is
And ARA are finally determined. When this comparison mismatch is confirmed, the appropriate corrective measures described above are taken.

【0032】パイプライン式コンピュータによるプログ
ラムの実行中に、パイプラインがその全ての段において
全ての命令を中止しなければならない事象が生じること
がある。これはパイプラインを“フラッシングする”と
も称する。このときパイプライン20において実行され
ている全ての作業は排除される。これらの排除された命
令を“シャドー(Shadow)"と称する。典型的に、パイプ
ラインの前端は或るエラー処理アドレスにおいて命令の
実行を開始する。
During the execution of a program by a pipelined computer, an event may occur in which the pipeline must abort all instructions in all its stages. This is also referred to as "flushing" the pipeline. At this time, all the work being executed in the pipeline 20 is eliminated. These excluded instructions are called "Shadow". Typically, the front end of the pipeline begins executing instructions at some error handling address.

【0033】説明上、パイプラインをフラッシュする事
象を“トラップ”と称する。これらのトラップの例は、
予想違い分岐、仮想メモリページ欠陥、リソースビジ
ー、及びハードウエアのパリティエラーである。サブル
ーチン復帰予想機構の性能向上を計るために、リングバ
ッファ34は、トラップを生じた命令がパイプライン2
0のリングバッファ段を通過したときに該バッファがあ
ったポイントに対してバックアップされる必要がある。
トラップが生じないことが分かるまでリングバッファ3
4に対して生じる各々の変化のコピーを保持するので
は、あまりに経費のかゝるやり方である。
For purposes of explanation, the event of flushing the pipeline is called a "trap". Examples of these traps are
Mispredicted branches, virtual memory page defects, resource busy, and hardware parity errors. In order to improve the performance of the subroutine return prediction mechanism, the ring buffer 34 stores the instruction causing the trap in the pipeline 2
It needs to be backed up to the point where the buffer was when it passed through the 0 ring buffer stage.
Ring buffer 3 until no trap is found
Keeping a copy of each change that occurs for 4 is an overly costly way.

【0034】図3の実施例では、CRPカウンタ45に
保持される別のリングポインタ、“確認リングポイン
タ”即ちCRPを設けることにより、この問題が解消さ
れる。CRPはRPと同様に変化し、即ちサブルーチン
呼び出し命令が見られたときに増加されそしてサブルー
チン復帰命令が見られたときに減少される。その相違
は、CRPカウンタ45がパイプライン20の最終段に
到達する命令を監視することである。最終段にある命令
に基づいてCRPに変更が加えられる。トラップが生じ
ると、RPカウンタ40のRPはCRPカウンタ45の
CRPの値にセットされる。
In the embodiment of FIG. 3, this problem is solved by providing another ring pointer, the "confirmation ring pointer" or CRP, held in the CRP counter 45. CRP changes similarly to RP, ie it is increased when a subroutine call instruction is seen and decreased when a subroutine return instruction is seen. The difference is that the CRP counter 45 monitors the instructions that reach the final stage of the pipeline 20. Changes are made to the CRP based on the instructions in the last stage. When the trap occurs, the RP of the RP counter 40 is set to the CRP value of the CRP counter 45.

【0035】これは、トラップの後に新たな命令が実行
され始めたときにRPに正しい同期を保持させる。リン
グバッファ34の入力を書き込んだトラップのシャドー
に或るサブルーチン呼び出し命令が生じることがあり、
サブルーチン復帰命令のその後の予想が間違ったものと
なる。然し乍ら、RPは同期しており、RPが間違った
入力を通過するや否や、リングバッファ34は再び良好
な状態となる。
This causes the RP to maintain the correct synchronization when a new instruction begins executing after the trap. A certain subroutine call instruction may occur in the shadow of the trap in which the input of the ring buffer 34 is written,
Subsequent expectations of the subroutine return instruction will be incorrect. However, RP is in sync and as soon as RP passes the wrong input, ring buffer 34 is in good condition again.

【0036】本発明は以上に述べた実施例に限定される
ものではなく、色々なサイズのリングバッファをもつ色
々なサイズのパイプラインに適用できる。
The present invention is not limited to the above-described embodiments, but can be applied to pipelines of various sizes having ring buffers of various sizes.

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

【図1】主たる流れ及びサブルーチンを有するプログラ
ムのブロック図である。
FIG. 1 is a block diagram of a program having a main flow and a subroutine.

【図2】本発明の実施例を用いたパイプラインのブロッ
ク図である。
FIG. 2 is a block diagram of a pipeline using an embodiment of the present invention.

【図3】本発明の別の実施例を用いたパイプラインのブ
ロック図である。
FIG. 3 is a block diagram of a pipeline using another embodiment of the present invention.

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

10……命令の主たる流れ、 12……サブルーチン、 100〜107,200〜202……命令、 20……パイプライン、 21……プログラムカウンタバッファ、 22……命令キャッシュ、 24……命令フェッチデコーダ、 26……命令バッファ、 28……発行論理回路、 32……実行段、 34……リングバッファ、 36……マルチプレクサ、 40……RPカウンタ。 10 ... Main flow of instruction, 12 ... Subroutine, 100-107, 200-202 ... Instruction, 20 ... Pipeline, 21 ... Program counter buffer, 22 ... Instruction cache, 24 ... Instruction fetch decoder, 26 ... Instruction buffer, 28 ... Issuing logic circuit, 32 ... Execution stage, 34 ... Ring buffer, 36 ... Multiplexer, 40 ... RP counter.

Claims (7)

【特許請求の範囲】[Claims] 【請求項1】 コンピュータパイプライン内でサブルー
チン復帰命令の入力に応答して予想されるサブルーチン
復帰アドレスを発生する構成体において、 サブルーチン呼び出し命令がコンピュータパイプライン
に入るときに増加されそしてサブルーチン復帰命令がコ
ンピュータパイプラインに入るときに減少されるリング
ポインタを含んだリングポインタカウンタと、 上記リングポインタカウンタに接続され、バッファ位置
と、入力及び出力とを有しているリングバッファとを具
備し、該リングバッファは、サブルーチン呼び出し命令
がコンピュータパイプラインに入るときに上記入力にあ
る値を上記リングポインタで指示されたバッファ位置へ
記憶すると共に、サブルーチン復帰命令がコンピュータ
パイプラインに入るときに上記リングポインタで指示さ
れたバッファ位置から上記出力の値を与え、該出力の値
は上記予想されるサブルーチン復帰アドレスであること
を特徴とする構成体。
1. A structure for generating an expected subroutine return address in response to an input of a subroutine return instruction in a computer pipeline, wherein a subroutine call instruction is incremented as it enters the computer pipeline and the subroutine return instruction is A ring pointer counter containing a ring pointer that is decremented upon entering the computer pipeline; and a ring buffer connected to the ring pointer counter and having a buffer location and an input and an output. The buffer stores the value at the input when the subroutine call instruction enters the computer pipeline into the buffer location pointed to by the ring pointer, and when the subroutine return instruction enters the computer pipeline. Gives the value of the output from the indicated buffer position pointer, the value of the output is structure, which is a subroutine return address to be expected above.
【請求項2】 上記リングバッファに接続されて、復帰
命令の処理に応答してコンピュータパイプラインにより
発生された実際の復帰アドレスをその復帰命令に対する
予想される復帰アドレスと比較する比較ユニットを更に
具備し、該ユニットは実際の復帰アドレスが予想される
復帰アドレスと同じでないときに比較不一致信号を与え
る出力を有していることを特徴とする請求項1記載の構
成体。
2. A comparison unit connected to the ring buffer for comparing the actual return address generated by the computer pipeline in response to processing the return instruction with the expected return address for the return instruction. 2. The structure of claim 1, wherein the unit has an output that provides a compare mismatch signal when the actual return address is not the same as the expected return address.
【請求項3】 コード化された命令を記憶する命令キャ
ッシュであって、コード化された命令をインデックスす
るプログラムカウントを受け取る入力と、上記インデッ
クスされたコード化命令が与えられる出力とを有してい
る命令キャッシュと、 上記命令キャッシュの出力に入力が接続されていて、コ
ード化された命令をデコードする命令フェッチデコーダ
であって、上記コード化された命令がサブルーチン呼び
出し命令であるときのサブルーチン呼び出しアドレス
と、マルチプレクサ制御信号と、リングポインタカウン
タ制御信号と、デコードされた命令とを出力として有し
ている命令フェッチデコーダとを具備し、この命令フェ
ッチデコーダには実行段が接続されていて、デコードさ
れた命令を実行し、上記命令キャッシュの入力にはプロ
グラムカウンタが接続され、該カウンタは命令キャッシ
ュの入力にプログラムカウントを与える出力と、入力と
を有し、更に、複数の入力と、上記命令フェッチデコー
ダのマルチプレクサ制御信号出力に接続された制御入力
と、プログラムカウンタの入力に接続された出力とを有
するマルチプレクサが設けられており、更に加算器はそ
の入力が上記プログラムカウンタの出力に接続されそし
て加算器の出力はプログラムカウントに1を加えたもの
に等しい値が与えられる上記マルチプレクサ入力の1つ
に接続され、更に、リングポインタカウンタが設けられ
ており、その入力はリングポインタカウンタ制御信号を
受け取るように上記命令フェッチデコーダに接続され、
該リングポインタカウンタにはリングポインタカウンタ
制御信号に応答してバッファ位置を指すリングポインタ
が含まれており、このリングポインタは上記命令フェッ
チデコーダがサブルーチン呼び出し命令をデコードする
ときには増加されそして命令フェッチデコーダがサブル
ーチン復帰命令をデコードするときには減少され、更
に、上記加算器の出力に接続された入力と、複数のバッ
ファ位置と、上記マルチプレクサ入力の1つに接続され
た出力とを有するリングバッファが設けられており、こ
のリングバッファはサブルーチン呼び出し命令がデコー
ドされたときには上記リングポインタによって指示され
たバッファ位置に上記値を記憶すると共に、サブルーチ
ン復帰命令がデコードされたときには上記リングポイン
タにより指示されたバッファ位置から上記値をリングバ
ッファ出力に与え、このリングバッファ出力の値は予想
されるサブルーチン復帰アドレスであることを特徴とす
るコンピュータパイプライン。
3. An instruction cache storing coded instructions having an input for receiving a program count indexing the coded instructions and an output provided with the indexed coded instructions. And an instruction fetch decoder that has an input connected to the output of the instruction cache and decodes a coded instruction, and the coded instruction is a subroutine call address when the coded instruction is a subroutine call instruction. And a multiplexer control signal, a ring pointer counter control signal, and an instruction fetch decoder having as output the decoded instruction. The instruction fetch decoder is connected to an execution stage and is decoded. Instructions are executed and input to the above instruction cache A gram counter is connected, the counter having an output for providing a program count to the input of the instruction cache and an input, and further having a plurality of inputs and a control input connected to the multiplexer control signal output of the instruction fetch decoder. , A multiplexer having an output connected to the input of the program counter, the adder having its input connected to the output of the program counter and the output of the adder being the program count plus one. Connected to one of the multiplexer inputs provided with an equal value, and further provided with a ring pointer counter, the input of which is connected to the instruction fetch decoder to receive a ring pointer counter control signal,
The ring pointer counter includes a ring pointer pointing to a buffer position in response to a ring pointer counter control signal, the ring pointer being incremented when the instruction fetch decoder decodes a subroutine call instruction and the instruction fetch decoder A ring buffer is provided which is reduced when decoding a subroutine return instruction and which further has an input connected to the output of the adder, a plurality of buffer locations and an output connected to one of the multiplexer inputs. This ring buffer stores the above value in the buffer position designated by the ring pointer when the subroutine call instruction is decoded, and is designated by the ring pointer when the subroutine return instruction is decoded. Supplied from Ffa position the value in the ring buffer output, a computer pipeline, wherein the value of the ring buffer output is a subroutine return address to be expected.
【請求項4】 上記リングバッファに接続された比較ユ
ニットであって、復帰命令の処理に応答してコンピュー
タパイプラインにより発生された実際の復帰アドレスを
その復帰アドレスのための予想される復帰アドレスと比
較する比較ユニットを更に備え、該ユニットの出力には
実際の復帰アドレスが予想される復帰アドレスと同じで
ないときに比較不一致信号が与えられることを特徴とす
る請求項3に記載のパイプライン。
4. A comparison unit connected to the ring buffer, wherein the actual return address generated by the computer pipeline in response to processing the return instruction is the expected return address for that return address. 4. The pipeline according to claim 3, further comprising a comparing unit for comparing, the output of the unit being provided with a compare mismatch signal when the actual return address is not the same as the expected return address.
【請求項5】 上記比較不一致信号が上記予想される復
帰アドレスと実際の復帰アドレスとの不一致を示すとき
に実際の復帰アドレスで指示された命令で始まる正しい
一連の命令を処理する手段を更に備えたことを特徴とす
る請求項4に記載のパイプライン。
5. Further comprising means for processing the correct sequence of instructions starting with the instruction pointed to by the actual return address when the comparison mismatch signal indicates a mismatch between the expected return address and the actual return address. The pipeline according to claim 4, characterized in that
【請求項6】 実行段及びリングポインタカウンタに接
続された確認リングポインタカウンタを更に備え、該カ
ウンタに含まれた確認リングポインタは実行段がサブル
ーチン呼び出し命令を受けたときに増加されそして実行
段がサブルーチン復帰命令を受けたときに減少され、更
に、トラップが生じたときにリングポインタに取って代
わるようにリングポインタカウンタに確認リングポイン
タが与えられることを特徴とする請求項3に記載のパイ
プライン。
6. A confirmation ring pointer counter connected to the execution stage and the ring pointer counter, wherein the confirmation ring pointer contained in the counter is incremented when the execution stage receives a subroutine call instruction and the execution stage is 4. The pipeline of claim 3, wherein the ring pointer counter is provided with a confirmation ring pointer which is decremented upon receipt of a subroutine return instruction and which further replaces the ring pointer when a trap occurs. .
【請求項7】 パイプライン式コンピュータにおいてサ
ブルーチン復帰アドレスを予想する方法であって、 呼び出し命令に応答しその呼び出し命令のアドレスに1
を加えたものに等しい値をリングバッファの複数のバッ
ファ位置の1つに記憶し、 最も最近記憶された値を含むバッファ位置を指示し、 最も最近記憶された値に対する上記指示を復帰命令に応
答して出力として与え、この出力は予想されるサブルー
チン復帰アドレスであり、 その次に最近記憶された値を含むバッファ位置を指示す
ることを特徴とする方法。
7. A method for predicting a subroutine return address in a pipeline computer, comprising: 1 in response to a call instruction, at the address of the call instruction.
Store a value equal to the sum of the values in one of a plurality of buffer positions in the ring buffer, indicate the buffer position containing the most recently stored value, and respond the return instruction with the above instruction for the most recently stored value. And the output is an expected subroutine return address, and then indicates the buffer location containing the most recently stored value.
JP2403242A 1989-12-18 1990-12-18 Subroutine return prediction mechanism Pending JPH06161748A (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
US07/451,943 US5179673A (en) 1989-12-18 1989-12-18 Subroutine return prediction mechanism using ring buffer and comparing predicated address with actual address to validate or flush the pipeline
US451943 1989-12-18

Publications (1)

Publication Number Publication Date
JPH06161748A true JPH06161748A (en) 1994-06-10

Family

ID=23794364

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2403242A Pending JPH06161748A (en) 1989-12-18 1990-12-18 Subroutine return prediction mechanism

Country Status (6)

Country Link
US (1) US5179673A (en)
EP (1) EP0433709B1 (en)
JP (1) JPH06161748A (en)
KR (1) KR940009378B1 (en)
CA (1) CA2032320A1 (en)
DE (1) DE69033339T2 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7757071B2 (en) 2004-07-29 2010-07-13 Fujitsu Limited Branch predicting apparatus and branch predicting method
JP2015535634A (en) * 2012-11-28 2015-12-14 クアルコム,インコーポレイテッド Establishing branch target instruction cache (BTIC) entries for subroutine returns to reduce execution pipeline bubbles, and associated systems, methods, and computer-readable media

Families Citing this family (27)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5193205A (en) * 1988-03-01 1993-03-09 Mitsubishi Denki Kabushiki Kaisha Pipeline processor, with return address stack storing only pre-return processed address for judging validity and correction of unprocessed address
US5493687A (en) * 1991-07-08 1996-02-20 Seiko Epson Corporation RISC microprocessor architecture implementing multiple typed register sets
US5539911A (en) * 1991-07-08 1996-07-23 Seiko Epson Corporation High-performance, superscalar-based computer system with out-of-order instruction execution
JP2773471B2 (en) * 1991-07-24 1998-07-09 日本電気株式会社 Information processing device
WO1993020505A2 (en) * 1992-03-31 1993-10-14 Seiko Epson Corporation Superscalar risc instruction scheduling
KR950701437A (en) * 1992-05-01 1995-03-23 요시오 야마자끼 System and Method for Instruction Retrieval in Superscalar Microprocessor
DE69330889T2 (en) 1992-12-31 2002-03-28 Seiko Epson Corp., Tokio/Tokyo System and method for changing register names
US5628021A (en) * 1992-12-31 1997-05-06 Seiko Epson Corporation System and method for assigning tags to control instruction processing in a superscalar processor
US5604877A (en) * 1994-01-04 1997-02-18 Intel Corporation Method and apparatus for resolving return from subroutine instructions in a computer processor
US5758142A (en) * 1994-05-31 1998-05-26 Digital Equipment Corporation Trainable apparatus for predicting instruction outcomes in pipelined processors
US5896528A (en) * 1995-03-03 1999-04-20 Fujitsu Limited Superscalar processor with multiple register windows and speculative return address generation
US5968169A (en) * 1995-06-07 1999-10-19 Advanced Micro Devices, Inc. Superscalar microprocessor stack structure for judging validity of predicted subroutine return addresses
US5854921A (en) * 1995-08-31 1998-12-29 Advanced Micro Devices, Inc. Stride-based data address prediction structure
US5881278A (en) * 1995-10-30 1999-03-09 Advanced Micro Devices, Inc. Return address prediction system which adjusts the contents of return stack storage to enable continued prediction after a mispredicted branch
US5864707A (en) * 1995-12-11 1999-01-26 Advanced Micro Devices, Inc. Superscalar microprocessor configured to predict return addresses from a return stack storage
US6088793A (en) * 1996-12-30 2000-07-11 Intel Corporation Method and apparatus for branch execution on a multiple-instruction-set-architecture microprocessor
US5958039A (en) * 1997-10-28 1999-09-28 Microchip Technology Incorporated Master-slave latches and post increment/decrement operations
US6044456A (en) * 1998-01-05 2000-03-28 Intel Corporation Electronic system and method for maintaining synchronization of multiple front-end pipelines
US20050149694A1 (en) * 1998-12-08 2005-07-07 Mukesh Patel Java hardware accelerator using microcode engine
US6304962B1 (en) 1999-06-02 2001-10-16 International Business Machines Corporation Method and apparatus for prefetching superblocks in a computer processing system
US6289444B1 (en) 1999-06-02 2001-09-11 International Business Machines Corporation Method and apparatus for subroutine call-return prediction
EP1197847A3 (en) * 2000-10-10 2003-05-21 Nazomi Communications Inc. Java hardware accelerator using microcode engine
US20020080388A1 (en) * 2000-12-27 2002-06-27 Sharp Laboratories Of America, Inc. Dynamic method for determining performance of network connected printing devices in a tandem configuration
US20040049666A1 (en) * 2002-09-11 2004-03-11 Annavaram Murali M. Method and apparatus for variable pop hardware return address stack
US7975132B2 (en) * 2009-03-04 2011-07-05 Via Technologies, Inc. Apparatus and method for fast correct resolution of call and return instructions using multiple call/return stacks in the presence of speculative conditional instruction execution in a pipelined microprocessor
US9411590B2 (en) * 2013-03-15 2016-08-09 Qualcomm Incorporated Method to improve speed of executing return branch instructions in a processor
US20240036864A1 (en) * 2022-08-01 2024-02-01 Qualcomm Incorporated Apparatus employing wrap tracking for addressing data overflow

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS62285140A (en) * 1986-06-04 1987-12-11 Hitachi Ltd Information processor
JPH01222332A (en) * 1988-03-01 1989-09-05 Mitsubishi Electric Corp Data processor having pipe line processing mechanism

Family Cites Families (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US3794980A (en) * 1971-04-21 1974-02-26 Cogar Corp Apparatus and method for controlling sequential execution of instructions and nesting of subroutines in a data processor
US4649472A (en) * 1981-02-04 1987-03-10 Burroughs Corporation Multi-phase subroutine control circuitry
US4399507A (en) * 1981-06-30 1983-08-16 Ibm Corporation Instruction address stack in the data memory of an instruction-pipelined processor
US4594659A (en) * 1982-10-13 1986-06-10 Honeywell Information Systems Inc. Method and apparatus for prefetching instructions for a central execution pipeline unit
US4586127A (en) * 1982-11-03 1986-04-29 Burroughs Corp. Multiple control stores for a pipelined microcontroller
US4611278A (en) * 1983-04-01 1986-09-09 Honeywell Information Systems Inc. Wraparound buffer for repetitive decimal numeric operations
JPS6054049A (en) * 1983-09-02 1985-03-28 Hitachi Ltd Subroutine link control system of data processing device
US5008807A (en) * 1984-07-05 1991-04-16 Texas Instruments Incorporated Data processing apparatus with abbreviated jump field
JPS62152043A (en) * 1985-12-26 1987-07-07 Nec Corp Control system for instruction code access
US4773041A (en) * 1986-06-02 1988-09-20 Unisys Corporation System for executing a sequence of operation codes with some codes being executed out of order in a pipeline parallel processor
US4814978A (en) * 1986-07-15 1989-03-21 Dataflow Computer Corporation Dataflow processing element, multiprocessor, and processes
JPH06100967B2 (en) * 1987-06-10 1994-12-12 三菱電機株式会社 Data processing device having pipeline processing mechanism and processing method
US4890221A (en) * 1988-04-01 1989-12-26 Digital Equipment Corporation Apparatus and method for reconstructing a microstack
US5040137A (en) * 1989-12-13 1991-08-13 Audio Animation Random access FIR filtering

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS62285140A (en) * 1986-06-04 1987-12-11 Hitachi Ltd Information processor
JPH01222332A (en) * 1988-03-01 1989-09-05 Mitsubishi Electric Corp Data processor having pipe line processing mechanism

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7757071B2 (en) 2004-07-29 2010-07-13 Fujitsu Limited Branch predicting apparatus and branch predicting method
JP2015535634A (en) * 2012-11-28 2015-12-14 クアルコム,インコーポレイテッド Establishing branch target instruction cache (BTIC) entries for subroutine returns to reduce execution pipeline bubbles, and associated systems, methods, and computer-readable media

Also Published As

Publication number Publication date
US5179673A (en) 1993-01-12
EP0433709B1 (en) 1999-11-03
DE69033339T2 (en) 2000-08-03
KR940009378B1 (en) 1994-10-07
EP0433709A2 (en) 1991-06-26
KR910012914A (en) 1991-08-08
EP0433709A3 (en) 1993-05-12
CA2032320A1 (en) 1991-06-19
DE69033339D1 (en) 1999-12-09

Similar Documents

Publication Publication Date Title
JPH06161748A (en) Subroutine return prediction mechanism
US6898699B2 (en) Return address stack including speculative return address buffer with back pointers
EP0365188B1 (en) Central processor condition code method and apparatus
KR930004214B1 (en) Data processing system
US5872985A (en) Switching multi-context processor and method overcoming pipeline vacancies
JP3014773B2 (en) Processor architecture
EP0241946B1 (en) Information processing system
JP2937485B2 (en) Method and apparatus for detecting and executing traps in a superscalar processor
EP0344450A2 (en) Apparatus and method for implementing precise interrupts on pipelined processor with multiple functional units
EP0463628A2 (en) One cycle register mapping
EP0644482A1 (en) Dispatch of instructions to multiple execution units
US5280615A (en) Out of order job processing method and apparatus
EP0180725A2 (en) Instruction prefetch operation for branch instructions
JP2004127319A (en) Backup device
JPH02227731A (en) Data processing system
JP2560988B2 (en) Information processing apparatus and processing method
JP2898105B2 (en) Method of minimizing interruption of hardware pipeline processing by using software scheduling technique during compilation
JPH096611A (en) Method and system for buffering of data in data-processing system
US7080239B2 (en) Loop control circuit and loop control method
US5146570A (en) System executing branch-with-execute instruction resulting in next successive instruction being execute while specified target instruction is prefetched for following execution
JP3602801B2 (en) Memory data access structure and method
JPH11345121A (en) Instruction fetch device and method for program control unit
JPH07219766A (en) Arithmetic processor
TWI864776B (en) Method and system for predicting branch
JPH02151930A (en) Storage buffer managing system