JP2570998B2 - Branch instruction processing device and branch instruction processing method - Google Patents

Branch instruction processing device and branch instruction processing method

Info

Publication number
JP2570998B2
JP2570998B2 JP5301376A JP30137693A JP2570998B2 JP 2570998 B2 JP2570998 B2 JP 2570998B2 JP 5301376 A JP5301376 A JP 5301376A JP 30137693 A JP30137693 A JP 30137693A JP 2570998 B2 JP2570998 B2 JP 2570998B2
Authority
JP
Japan
Prior art keywords
branch
branch information
bucket
information
branch instruction
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 - Lifetime
Application number
JP5301376A
Other languages
Japanese (ja)
Other versions
JPH07152580A (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.)
NEC Corp
Original Assignee
Nippon Electric 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 Nippon Electric Co Ltd filed Critical Nippon Electric Co Ltd
Priority to JP5301376A priority Critical patent/JP2570998B2/en
Publication of JPH07152580A publication Critical patent/JPH07152580A/en
Application granted granted Critical
Publication of JP2570998B2 publication Critical patent/JP2570998B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【産業上の利用分野】本発明は分岐命令処理装置および
分岐命令処理方法に関し、特にアセンブラにおける分岐
命令最適化のための分岐命令処理装置および分岐命令処
理方法に関する。
The present invention relates to a branch instruction processing apparatus and a branch instruction processing method, and more particularly to a branch instruction processing apparatus and a branch instruction processing method for optimizing a branch instruction in an assembler.

【0002】[0002]

【従来の技術】アセンブラ言語を用いるマイクロプロセ
ッサ用のプログラムでは、分岐命令とその分岐命令の参
照先のラベルとの距離により上記分岐命令のコード長が
異なるものがある。この種のプログラムでは、ユーザが
上記分岐命令をコーデングするときにコード長を適当に
選択して指定するか、上記分岐命令の分岐先位置対応の
最短コード長の分岐命令(以下最短分岐命令)に置換す
るためのユーザが記述した仮の分岐命令(以下仮分岐命
令)を、コンパイラやアセンブラ等の翻訳プログラムが
選択して上記置換を行う。これを分岐命令最適化と呼
ぶ。
2. Description of the Related Art In a microprocessor program using an assembler language, the code length of a branch instruction varies depending on the distance between the branch instruction and a label to which the branch instruction refers. In this type of program, when the user codes the above-mentioned branch instruction, the code length is appropriately selected and specified, or the branch instruction having the shortest code length corresponding to the branch destination position of the above-mentioned branch instruction (hereinafter the shortest branch instruction) A translation program such as a compiler or an assembler selects a tentative branch instruction (hereinafter, a tentative branch instruction) written by a user for replacement and performs the above replacement. This is called branch instruction optimization.

【0003】従来の分岐命令処理装置をブロックで示す
図7を参照すると、この従来の分岐命令処理装置は、入
力フアイルとなるソースファイル1と、アセンブラ処理
を行うアセンブラ2と、出力ファイルとなるオブジェク
トファイル3とを備える。
Referring to FIG. 7, which shows a block diagram of a conventional branch instruction processing device, this conventional branch instruction processing device includes a source file 1 serving as an input file, an assembler 2 performing assembler processing, and an object file serving as an output file. File 3.

【0004】アセンブラ2は、ソースファイル1を読込
むソースファイル入力部4と、読込んだソースファイル
1の構文解析を行いシンボルテーブル6を生成し中間情
報7を出力する構文解析部5と、分岐命令の最適化処理
を行う最適化処理部8と、中間情報の解析処理を行いオ
ブジェクトコードを生成する中間情報解析部9と、オブ
ジェクトコードをオブジェクトファイル3に出力するオ
ブジェクトファイル出力部10とを備える。
The assembler 2 includes a source file input unit 4 for reading the source file 1, a syntax analysis unit 5 for analyzing the syntax of the read source file 1, generating a symbol table 6 and outputting the intermediate information 7, and a branching unit. An optimization processing unit 8 that performs an instruction optimization process, an intermediate information analysis unit 9 that performs an analysis process of intermediate information to generate an object code, and an object file output unit 10 that outputs the object code to the object file 3 are provided. .

【0005】構文解析部5は、構文解析した内容が仮分
岐命令のとき分岐情報を分岐情報テーブル11に供給す
る分岐情報生成部51を備える。
The syntax analyzer 5 includes a branch information generator 51 for supplying branch information to the branch information table 11 when the content of the syntax analysis is a temporary branch instruction.

【0006】次に、図7を参照して、従来の分岐命令処
理装置の動作について説明すると、ソースファイル入力
部4はソースファイル1を順次読込み、構文解析部5に
供給する。構文解析部5は、読込内容を構文解析し、後
述するシンボルテーブル6を生成するとともに、解析内
容を中間情報7として出力する。また、構文解析内容が
仮分岐命令である場合には、分岐情報生成部51が分岐
情報を後述する分岐情報テーブル11に供給する。その
後、最適化処理部8は、上記仮分岐命令、シンボルテー
ブル6、中間情報7および分岐情報テーブル11の供給
を受け、シンボルテーブル6の仮のアドレスを最適化後
の正しいアドレスに補正することにより分岐命令最適化
処理を実行する。次に、中間情報解析部9は中間情報の
解析を行い、オブジェクトコードを生成し、オブジェク
トファイル出力部10を経由してオブジェクトファイル
3として出力する。
Next, the operation of the conventional branch instruction processing device will be described with reference to FIG. 7. The source file input unit 4 sequentially reads the source files 1 and supplies them to the syntax analysis unit 5. The syntax analysis section 5 analyzes the syntax of the read content, generates a symbol table 6 described later, and outputs the analysis content as intermediate information 7. If the content of the syntax analysis is a temporary branch instruction, the branch information generation unit 51 supplies the branch information to a branch information table 11 described later. After that, the optimization processing unit 8 receives the provisional branch instruction, the symbol table 6, the intermediate information 7, and the branch information table 11, and corrects the provisional address of the symbol table 6 to a correct address after optimization. Execute branch instruction optimization processing. Next, the intermediate information analysis unit 9 analyzes the intermediate information, generates an object code, and outputs the generated object code as the object file 3 via the object file output unit 10.

【0007】シンボルテーブル6と分岐情報テーブル1
1との関係を示す図8を参照すると、入力されたソース
ファイル1のソースコード中に、n個のシンボル定義と
k個の仮分岐命令とが記述されされたとき、構文解析部
5がシンボルテーブル6にシンボルエントリS1〜Sn
を生成し、一方、分岐情報生成部51が分岐情報テーブ
ル11に分岐情報エントリB1〜Bnを生成する。
Symbol table 6 and branch information table 1
Referring to FIG. 8 showing the relationship between the symbol analysis unit 1 and the input source file 1, when n symbol definitions and k provisional branch instructions are described in the source code of the input source file 1, the syntax analysis unit 5 Table 6 shows symbol entries S1 to Sn
On the other hand, the branch information generation unit 51 generates branch information entries B1 to Bn in the branch information table 11.

【0008】シンボルエントリS1〜Snの各々は分岐
情報フイールドAとアドレスフイールドBとを持つ。分
岐情報フイールドAは、最近生成された分岐情報エント
リ対応のポインタを格納するフイールドであり、アドレ
スフイールドBは、そのシンボルのアドレスを格納する
フイールドである。ただし、上記アドレスはそのシンボ
ル定義の前に仮分岐命令があると決定不能の場合がある
が、この場合には仮分岐命令が全部最短コード命令に置
換されると仮定したときのアドレスとする。
Each of the symbol entries S1 to Sn has a branch information field A and an address field B. The branch information field A is a field for storing a pointer corresponding to a recently generated branch information entry, and the address field B is a field for storing the address of the symbol. However, the above address may not be determined if there is a provisional branch instruction before the symbol definition. In this case, the address is assumed to be an address when it is assumed that all provisional branch instructions are replaced by the shortest code instructions.

【0009】分岐情報エントリB1〜Bnの各々は、そ
の分岐先のシンボルエントリ対応のポインタを格納する
分岐先フイールドAと、その仮分岐命令が記述されたア
ドレスを格納する分岐アドレスフイールドBと、その仮
分岐命令のアドレスがその分岐情報より前にある仮分岐
命令より増加するバイト長を格納するコード増加積フイ
ールドCと、その分岐情報より前にある仮分岐命令より
増加する可能性のあるバイト長を格納するコード増加可
能積フイールドDと、その分岐情報のコード長が決定し
ているか否かの情報を格納し、さらに決定済の場合には
そのコード長を格納するコード増加量フイールドEとの
5つのフイールドを持つ。
Each of the branch information entries B1 to Bn includes a branch destination field A for storing a pointer corresponding to the symbol entry of the branch destination, a branch address field B for storing an address in which the temporary branch instruction is described, and a A code increase product field C for storing a byte length at which the address of the temporary branch instruction is larger than that of the temporary branch instruction preceding the branch information, and a byte length that may be larger than the temporary branch instruction preceding the branch information. And a code increase amount field E that stores information on whether or not the code length of the branch information is determined. If the code length is determined, the code increase amount field E stores the code length. It has five fields.

【0010】最適化処理部8のフローチャートを示す図
9を参照してシンボルテーブル6と分岐情報テーブル1
1とを用いて行う最適化処理の動作についてさらに詳細
に説明すると、まず、ステップP1の初期化処理で、分
岐情報テーブル11の分岐情報位置の初期化やアドレス
増加量の初期化および決定分岐量の初期化を行う。ま
た、分岐情報エントリの操作を行う処理部では分岐情報
位置にある分岐情報エントリについて操作を行う。この
分岐情報位置,アドレス増加量,および決定分岐量の各
々の初期化により、上記分岐情報位置は分岐情報テーブ
ル11の先頭のエントリすなわち分岐情報エントリB1
を示し、アドレス増加量は0となり、決定分岐量は0バ
イトとなる。
Referring to FIG. 9 showing a flowchart of the optimization processing unit 8, a symbol table 6 and a branch information table 1 are shown.
More specifically, the operation of the optimization process performed by using No. 1 will be described. First, in the initialization process of step P1, initialization of the branch information position in the branch information table 11, initialization of the address increase amount, and the determined branch amount Is initialized. Further, the processing unit for operating the branch information entry operates on the branch information entry at the branch information position. By the initialization of the branch information position, the address increase amount, and the determined branch amount, the branch information position becomes the first entry of the branch information table 11, that is, the branch information entry B1.
, The address increment is 0, and the determined branch amount is 0 bytes.

【0011】ここで、説明の便宜上、以後は分岐情報位
置は分岐情報エントリBkを指示し、仮分岐先はj番目
のシンボルエントリSjとし、真の分岐先対応の分岐情
報エントリはi番目すなわち分岐情報エントリBiであ
るものとする。
Here, for convenience of explanation, the branch information position indicates the branch information entry Bk, the temporary branch destination is the j-th symbol entry Sj, and the branch information entry corresponding to the true branch destination is the i-th, that is, the branch information entry. It is assumed that the information entry is Bi.

【0012】ステップP2のアドレス増加処理では、ア
ドレスフイールドBkBのアドレスをアドレス増加量だ
け増加させる。次に、分岐情報判定処理(ステップP
3)では、コード増加量フイールドBkEの情報が未決
定で解決可能か否かを判定する。諾である場合は、ステ
ップP4に進み分岐情報解決処理を行う。否の場合に
は、ステップP5に進みコード増加処理を行う。上記判
定は次のように行う。分岐先アドレスフイールドBkA
により、分岐先のシンボルエントリSjのアドレスフイ
ールドSjBのアドレスAD1が上記分岐先アドレスと
なるがこれは仮のアドレスであるので、さらに分岐情報
フイールドSjAのポインタが指示する分岐情報エント
リBiを用いて補正する。分岐先フイールドBkAのア
ドレスAD2と分岐情報エントリBiのコード増加積フ
イールドBiCのコード増加積をCD1およびコード増
加可能積フイールドBiDのコード増加可能積をCD2
とすると次の判定処理が行われる。すなわち、AD2と
AD1+CD1+CD2との差が最短分岐命令に置換さ
れるときの分岐幅(置換分岐幅)以下の場合、この仮分
岐命令がコード長の短い方の分岐命令(短分岐命令)で
置換される。上記差が上記置換分岐幅を越える場合、こ
の仮分岐命令がコード長の長い方の分岐命令(長分岐命
令)で置換される。
In the address increasing process in step P2, the address of the address field BkB is increased by the address increasing amount. Next, branch information determination processing (step P
In 3), it is determined whether or not the information of the code increase field BkE is undecided and can be solved. If yes, the process proceeds to Step P4 to perform a branch information solving process. If not, the process proceeds to Step P5 to perform a code increase process. The above determination is performed as follows. Branch destination address field BkA
Thus, the address AD1 of the address field SjB of the symbol entry Sj of the branch destination becomes the above-mentioned branch destination address, but since this is a temporary address, it is further corrected using the branch information entry Bi indicated by the pointer of the branch information field SjA. I do. The address AD2 of the branch target field BkA and the code increase product of the code increase product field BiC of the branch information entry Bi are CD1 and the code increase product of the code increase possible product field BiD is CD2.
Then, the following determination processing is performed. That is, when the difference between AD2 and AD1 + CD1 + CD2 is equal to or less than the branch width (replacement branch width) at which the shortest branch instruction is replaced, the temporary branch instruction is replaced with a branch instruction having a shorter code length (short branch instruction). You. If the difference exceeds the replacement branch width, the provisional branch instruction is replaced with a branch instruction having a longer code length (long branch instruction).

【0013】分岐情報解決処理(ステップP4)は、ス
テップP3の上記判定位置に対応し短分岐命令に置換さ
れるなら、コード増加量フイールドBkEに0を格納
し、決定分岐量に1バイトを加算する。長分岐命令に置
換されるなら、コード増加量フイールドBkEに1を格
納し、アドレス増加量と決定分岐量とにそれぞれ1バイ
トを加算する。
The branch information solving process (step P4) stores 0 in the code increase amount field BkE and adds 1 byte to the determined branch amount if it is replaced with a short branch instruction corresponding to the above determination position in step P3. I do. If it is replaced by a long branch instruction, 1 is stored in the code increment field BkE, and one byte is added to each of the address increment and the determined branch parameter.

【0014】コード増加処理(ステップP5)は、コー
ド増加積フイールドBkCの増加積にアドレス増加量を
加え、コード増加可能積フイールドBkDの増加可能量
から決定分岐数を減算し、ステップP6の分岐情報位置
判定処理を行う。分岐情報位置判定処理(ステップP
6)は、分岐情報位置が最後か否かを判定し、否であれ
ばステップP7の分岐情報位置増加処理を行い、最後で
あればステップP8の終了判定処理に進む。
In the code increase process (step P5), the address increase amount is added to the increase product of the code increase product field BkC, the number of determined branches is subtracted from the increase amount of the code increase product field BkD, and the branch information in step P6 is obtained. Perform position determination processing. Branch information position determination processing (step P
In 6), it is determined whether or not the branch information position is the last. If not, the branch information position increasing process in step P7 is performed, and if it is the last, the process proceeds to the end determination process in step P8.

【0015】分岐情報位置増加処理(ステップP7)で
は、分岐情報位置が指示する分岐情報エントリBkをB
k+1に増加させ、次にアドレス増加処理(ステップP
2)に戻る。終了判定処理(ステップP8)では、全て
の分岐情報エントリB1〜Bkが決定済ならシンボルテ
ーブル変換処理(ステップP9)を行い、否であれば初
期化処理(ステップP1)に戻り残りの分についてステ
ップP1〜P9を再度実行する。
In the branch information position increasing process (step P7), the branch information entry Bk indicated by the branch information position is
k + 1, and then the address increase processing (step P
Return to 2). In the end determination process (step P8), if all the branch information entries B1 to Bk have been determined, the symbol table conversion process (step P9) is performed. If not, the process returns to the initialization process (step P1) and the remaining process is performed. P1 to P9 are executed again.

【0016】シンボルテーブル変換処理(ステップP
9)は、全てのシンボル情報エントリS1〜Snの仮ア
ドレスを補正して正しいアドレスにし最適化処理を完了
する。
Symbol table conversion processing (step P
In 9), the tentative addresses of all the symbol information entries S1 to Sn are corrected to correct addresses, and the optimization process is completed.

【0017】上記補正の方法を説明すると、補正対象の
シンボルエントリSiのアドレスフイールドSiBの格
納アドレスをAD1とし、分岐情報フイールドSiAの
指示する分岐情報エントリBiのコード増加積フイール
ドBiCのコード増加積をCD1とすると、アドレスフ
イールドSiBの値を新たなアドレス値AD1+CD1
に補正して再格納する。
The correction method will be described. The storage address of the address field SiB of the symbol entry Si to be corrected is assumed to be AD1, and the code increase product of the branch information entry Bi specified by the branch information field SiA is calculated. Assuming that CD1, the value of the address field SiB is a new address value AD1 + CD1.
And store it again.

【0018】上述のように、この最適化処理部部8の処
理では、ソースファイル1に記述された仮分岐命令の数
と同数の仮分岐情報である分岐情報エントリを分岐情報
テーブル11に生成するので、この分岐情報テーブル1
1を格納するメモりの容量は十分大きい必要がある。
As described above, in the processing of the optimizing processing section 8, the branch information table 11, which is the same number of temporary branch information as the number of temporary branch instructions described in the source file 1, is generated in the branch information table 11. Therefore, this branch information table 1
The memory capacity for storing 1 must be large enough.

【0019】[0019]

【発明が解決しようとする課題】上述した従来の分岐命
令処理装置および分岐命令処理方法は、最適化処理にお
いて、仮分岐命令の数と同数の仮分岐情報を生成するた
め大容量のメモリ領域を必要とするという欠点があっ
た。また、多数の仮分岐命令が記述されたときはメモリ
容量の不足に起因してエラーが発生したり、外部のテン
ポラリファイルを用いることによる実行時間の遅延の発
生という欠点があった。
The conventional branch instruction processing device and the conventional branch instruction processing method described above require a large-capacity memory area for generating the same number of temporary branch information as the number of temporary branch instructions in the optimization process. There was the disadvantage of needing. Further, when a large number of temporary branch instructions are described, there is a drawback that an error occurs due to a shortage of memory capacity, and an execution time is delayed by using an external temporary file.

【0020】[0020]

【課題を解決するための手段】本発明の分岐命令処理装
置および分岐命令処理方法は、分岐命令とその分岐命令
の参照先のラベルとの距離により前記分岐命令のコード
長が異なるマイクロプロセッサ用のアセンブラプログラ
ムを処理するため、アセンブラ言語で記述した前記ラベ
ルおよび前記分岐命令対応の仮分岐命令を含むソースフ
ァイルを読込むソースファイル入力手段と、読込んだ前
記ソースファイルの構文解析を行い前記ラベル対応のシ
ンボルエントリを格納するシンボルテーブルおよび前記
仮分岐命令対応の分岐情報エントリを格納する分岐情報
テーブルとを生成する構文解析手段と、前記仮分岐命令
を補正して生成した前記分岐命令のコード長を最短にす
る処理である最適化処理を行う最適化処理手段とを備え
る分岐命令処理装置において、前記構文解析手段が、前
記構文解析結果が前記仮分岐命令のとき予め定めた数の
前記分岐情報エントリの格納用の記憶領域であるバケッ
トを環状に配列した環状リスト構造の分岐情報テーブル
に前記分岐情報を供給する分岐情報生成手段と、前記分
岐情報テーブルの格納可能な前記分岐情報エントリの数
の上限値の到達に応答して前記最適化処理手段をアクセ
スして前記最適化処理を実行させ前記最適化処理済の前
記分岐情報エントリ対応の前記バケットを空に解放する
リスト上限判定処理手段とを備えて構成されている。
According to the present invention, there is provided a branch instruction processing apparatus and a branch instruction processing method for a microprocessor having a code length of a branch instruction which differs depending on a distance between the branch instruction and a label to which the branch instruction is referred. Source file input means for reading a source file including the label described in the assembler language and the provisional branch instruction corresponding to the branch instruction for processing the assembler program; and analyzing the read source file for syntax to read the source file. Syntactic analysis means for generating a symbol table for storing the symbol entry of the above and a branch information table for storing a branch information entry corresponding to the temporary branch instruction, and a code length of the branch instruction generated by correcting the temporary branch instruction. Optimization processing means for performing optimization processing, which is processing to minimize the processing time In the branch information table having a circular list structure in which buckets, which are storage areas for storing a predetermined number of the branch information entries, are circularly arranged when the syntax analysis result is the temporary branch instruction. Executing the optimization processing by accessing the optimization processing means in response to reaching an upper limit of the number of branch information entries that can be stored in the branch information table; List upper limit determining means for releasing the bucket corresponding to the optimized branch information entry to empty.

【0021】[0021]

【実施例】次に、本発明の第1の実施例を図7と共通の
構成要素には共通の参照数字/文字を付してブロックで
示す図1を参照すると、この図に示す本実施例の分岐命
令処理装置は、アセンブラ2の代りに、従来と同様のソ
ースファイル入力部4と、中間情報解析部9と、オブジ
ェクトファイル出力部10とに加えて、構文解析部5の
代りに構文解析結果が仮分岐命令のとき分岐情報を環状
リスト構造の分岐情報テーブル12に供給する分岐情報
生成部51Aとこの分岐情報テーブル12のリストの上
限を判定するリスト上限判定処理部52とを備え従来と
同様にシンボルテーブル6と中間情報7を出力する構文
解析部5Aと、最適化処理部8の代りに分岐情報テーブ
ル12を用いて分岐命令の最適化処理を行う最適化処理
部8Aとを備えるアセンブラ2Aを備える。
FIG. 1 is a block diagram showing a first embodiment of the present invention, in which constituent elements common to those in FIG. 7 are denoted by common reference numerals / characters, and FIG. The branch instruction processing device of the example includes, in place of the assembler 2, a source file input unit 4, an intermediate information analysis unit 9, and an object file output unit 10 similar to the conventional one, and a syntax analysis unit 5 instead of the syntax analysis unit 5. A conventional branch information generating unit 51A for supplying branch information to the branch information table 12 having a circular list structure when the analysis result is a temporary branch instruction; and a list upper limit determining unit 52 for determining the upper limit of the list of the branch information table 12. In the same manner as the above, a syntactic analysis unit 5A that outputs the symbol table 6 and the intermediate information 7 and an optimization processing unit 8A that performs a branch instruction optimization process using the branch information table 12 instead of the optimization processing unit 8 are provided. It comprises assembler 2A.

【0022】次に、図1を参照して本実施例の動作につ
いて説明すると、全体の処理の流れは上述した従来の技
術と同様であり、本発明に直接関連する構文解析部5A
と最適化処理部8Aおよび分岐情報テーブル12以外の
部分については説明が重複するので省略する。
Next, the operation of the present embodiment will be described with reference to FIG. 1. The overall processing flow is the same as that of the above-described conventional technique, and the syntax analyzer 5A directly related to the present invention.
The description of the other parts than the optimization processing unit 8A and the branch information table 12 will be omitted because they are duplicated.

【0023】まずソースファイル入力部4はソースファ
イル1を順次読込み、構文解析部5Aに供給する。構文
解析部5Aは、読込内容を構文解析し、シンボルテーブ
ル6を生成するとともに、解析内容を中間情報7として
出力する。また、構文解析内容が仮分岐命令である場合
には、分岐情報生成部51Aが分岐情報を後述する分岐
情報テーブル12に供給する。その後、最適化処理部8
Aは、上記仮分岐命令、シンボルテーブル6、中間情報
7および分岐情報テーブル12の供給を受け、シンボル
テーブル6の仮のアドレスを最適化後の正しいアドレス
に補正することにより分岐命令最適化処理を実行する。
次に、中間情報解析部9は中間情報の解析を行い、オブ
ジェクトコードを生成し、オブジェクトファイル出力部
10を経由してオブジェクトファイル3として出力す
る。
First, the source file input section 4 sequentially reads the source file 1 and supplies it to the syntax analysis section 5A. The syntax analysis unit 5A analyzes the syntax of the read content, generates the symbol table 6, and outputs the analysis content as the intermediate information 7. When the content of the syntax analysis is a temporary branch instruction, the branch information generation unit 51A supplies the branch information to a branch information table 12 described later. After that, the optimization processing unit 8
A receives the provisional branch instruction, the symbol table 6, the intermediate information 7, and the branch information table 12, and corrects the provisional address of the symbol table 6 to a correct address after optimization, thereby performing the branch instruction optimization processing. Run.
Next, the intermediate information analysis unit 9 analyzes the intermediate information, generates an object code, and outputs the generated object code as the object file 3 via the object file output unit 10.

【0024】本実施例のシンボルテーブル6と分岐情報
テーブル12との関係を示す図2を参照すると、分岐情
報テーブル12は分岐情報エントリの各々を格納する領
域であるN個のバケット121〜12Nを有する環状リ
スト構造で構成される。このバケット数Nは、分岐が許
容される最長分岐幅の2倍である。例えば、最長分岐幅
を128バイトとすると、バケット数Nは256とな
る。従来と同様に、ソースファイル1にn個のシンボル
定義とk個の仮分岐命令とが記述されたとき、分岐情報
テーブル12のバケット121〜12kの各々に分岐情
報エントリB1〜Bkが格納される。分岐情報エントリ
B1〜Bkの各々は、従来と同様に、分岐先フイールド
Aと、分岐アドレスフイールドBと、コード増加積フイ
ールドCと、コード増加可能積フイールドDと、コード
増加量フイールドEとの5つのフイールドを持つ。一
方、シンボルテーブル6には従来と同様の分岐情報フイ
ールドAとアドレスフイールドBとを持つn個のシンボ
ルエントリS1〜Snが格納される。
Referring to FIG. 2 showing the relationship between the symbol table 6 and the branch information table 12 according to the present embodiment, the branch information table 12 stores N buckets 121 to 12N which are areas for storing branch information entries. It has a cyclic wrist structure. This number of buckets N is twice the longest branch width that allows branching. For example, if the longest branch width is 128 bytes, the number of buckets N is 256. As described above, when n symbol definitions and k provisional branch instructions are described in the source file 1, the branch information entries B1 to Bk are stored in the buckets 121 to 12k of the branch information table 12, respectively. . Each of the branch information entries B1 to Bk has five fields of a branch destination field A, a branch address field B, a code increase product field C, a code increase possible product field D, and a code increase amount field E, as in the related art. With two fields. On the other hand, the symbol table 6 stores n symbol entries S1 to Sn having a branch information field A and an address field B as in the related art.

【0025】リスト上限判定処理部52は、分岐情報生
成部51Aが分岐情報エントリBを生成したときにその
分岐情報エントリBを分岐情報テーブル12に格納し、
分岐情報テーブル12が格納可能な分岐情報エントリB
の数の上限値すなわちNに達したならば、最適化処理部
8をアクセスして最適化処理を実行し、分岐情報テーブ
ル12の最適化処理済の分岐情報エントリ対応のバケッ
トを空として解放する。分岐情報テーブル12に対する
分岐情報エントリBの格納は、生成される分岐情報エン
トリを格納するバケットの位置を示すバケット格納位置
と分岐情報エントリの格納可能な最後のバケットの次の
バケット位置を示すバケット最後位置とを用いて行う。
上記バケット格納位置およびバケット最後位置の初期値
はいずれも分岐情報テーブル12の先頭のバケット12
1である。
When the branch information generation unit 51A generates the branch information entry B, the list upper limit determination processing unit 52 stores the branch information entry B in the branch information table 12,
Branch information entry B that can store the branch information table 12
Is reached, that is, N, the optimization processing unit 8 is accessed to execute the optimization processing, and the bucket corresponding to the optimized branch information entry in the branch information table 12 is released as empty. . The storage of the branch information entry B in the branch information table 12 includes a bucket storage position indicating the position of the bucket for storing the generated branch information entry and a bucket last indicating the next bucket position of the last bucket that can store the branch information entry. This is performed using the position.
The initial value of the bucket storage position and the initial value of the bucket last position are both the first bucket 12 of the branch information table 12.
It is one.

【0026】リスト上限判定処理部52の処理のアルゴ
リズムをフローチャートで示す図3を参照してリスト上
限判定処理の動作を説明すると、まず、ステップQ1の
バケット格納処理で、バケット格納位置が指示している
バケット(ここでは説明の便宜上12kとする)に分岐
情報エントリBkを格納する。分岐情報エントリBkの
格納が終了するとバケット格納位置をバケット12k+
1を指示するよう増加するバケット格納位置増加処理
(ステップQ2)を行う。次に、ステップQ3で、バケ
ット格納位置判定処理を行う。バケット格納位置とバケ
ット最後位置とが一致していれば、最適化処理部8で最
適化処理(ステップS100)を実行し、この最適化処
理の終了後、バケット最後位置を未解放の最後のバケッ
トに設定するバケット最後位置更新処理(ステップQ
4)を行い、リスト上限判定処理を終了する。一致して
いなければ、そのままリスト上限判定処理を終了する。
The operation of the list upper limit determination process will be described with reference to FIG. 3 which is a flowchart of the algorithm of the process of the list upper limit determination processing unit 52. First, in the bucket storage process of step Q1, the bucket storage position is instructed. The branch information entry Bk is stored in the bucket (here, 12k for convenience of explanation). When the storage of the branch information entry Bk is completed, the bucket storage position is changed to the bucket 12k +
1 is performed to increase the bucket storage position (step Q2). Next, in step Q3, bucket storage position determination processing is performed. If the bucket storage position and the bucket end position match, the optimization processing unit 8 executes optimization processing (step S100), and after this optimization processing ends, the bucket last position where the bucket last position has not been released is not released. Bucket last position update processing (step Q
4) is performed, and the list upper limit determination process ends. If they do not match, the list upper limit determination process is terminated.

【0027】本実施例の最適化処理部8Aにおける最適
化処理(ステップS100)のアルゴリズムをフローチ
ャートで示す図4を参照してさらに詳細に説明すると、
まず、従来と同様のステップS1の初期化処理で、分岐
情報テーブル12の分岐情報位置の初期化やアドレス増
加量の初期化および決定分岐量の初期化を行う。また、
分岐情報エントリの操作を行う処理部では分岐情報位置
にある分岐情報エントリについて操作を行う。この分岐
情報位置,アドレス増加量,および決定分岐量の各々の
初期化により、上記分岐情報位置は、始めて最適化処理
が行われる場合には分岐情報テーブル12の先頭のエン
トリすなわちバケット121に格納された分岐情報エン
トリB1を示し、2回目以降は、その前の回の最適化処
理の最後に設定した位置を示す。分岐情報最後位置はこ
の最適化処理の実行直前に生成した分岐情報エントリを
指示する。アドレス増加量は0バイトとなり、決定分岐
量は0バイトとなる。
The algorithm of the optimization processing (step S100) in the optimization processing unit 8A of this embodiment will be described in more detail with reference to FIG.
First, initialization of the branch information position in the branch information table 12, initialization of the address increase amount, and initialization of the determined branch amount are performed by the initialization processing in step S1 similar to the related art. Also,
The processing unit for operating the branch information entry operates on the branch information entry at the branch information position. By initializing the branch information position, the address increment, and the determined branch amount, the branch information position is stored in the first entry of the branch information table 12, ie, the bucket 121, when the optimization process is performed for the first time. The second and subsequent times indicate the position set at the end of the preceding optimization process. The branch information last position indicates the branch information entry generated immediately before the execution of the optimization processing. The address increment is 0 bytes, and the determined branch amount is 0 bytes.

【0028】ここで、従来と同様に説明の便宜上、以後
は分岐情報位置はバケット12kに格納した分岐情報エ
ントリBkを指示し、仮分岐先はj番目のシンボルエン
トリSjとし、また、真の分岐先対応の分岐情報エント
リはi番目すなわち分岐情報エントリBiであるものと
する。
Here, for convenience of explanation, the branch information position indicates the branch information entry Bk stored in the bucket 12k, the temporary branch destination is the j-th symbol entry Sj, and the true branch is performed. It is assumed that the corresponding branch information entry is the i-th branch information entry Bi.

【0029】従来のステップP2と同様のステップS2
のアドレス増加処理では、アドレスフイールドBkBの
アドレスをアドレス増加量だけ増加させる。次に、分岐
情報判定処理(ステップS3)では、コード増加量フイ
ールドBkEの情報が未決定で解決可能か否かを従来の
ステップP3と同様に判定する。すなわち、分岐先のア
ドレスフイールドSjBのアドレスAD1、分岐先フイ
ールドBkAのアドレスAD2とコード増加積フイール
ドBiCのコード増加積CD1およびコード増加可能積
フイールドBiDのコード増加可能積をCD2とする
と、AD2とAD1+CD1+CD2との差が置換分岐
幅以下の場合、この仮分岐命令が短分岐命令で、上記差
が上記置換分岐幅を越える場合、この仮分岐命令が長分
岐命令でそれぞれ置換する。諾である場合は、ステップ
S4に進み分岐情報解決処理を行う。否の場合には、ス
テップS5に進みコード増加処理を行う。
Step S2 similar to conventional step P2
In the address increase process, the address of the address field BkB is increased by the address increase amount. Next, in the branch information determination process (step S3), it is determined whether or not the information of the code increase field BkE is undecided and can be solved as in the conventional step P3. That is, assuming that the address AD1 of the branch destination address field SjB, the address AD2 of the branch destination field BkA and the code increase product CD1 of the code increase product field BiC, and the code increase possible product of the code increase possible product field BiD are CD2, AD2 and AD1 + CD1 + CD2. If the difference from the above is less than or equal to the replacement branch width, the temporary branch instruction is replaced by a short branch instruction, and if the difference exceeds the replacement branch width, the temporary branch instruction is replaced by a long branch instruction. If yes, the process proceeds to step S4 to perform a branch information solving process. If no, the process proceeds to step S5 to perform a code increase process.

【0030】分岐情報解決処理(ステップS4)は、ス
テップS3の上記判定位置に対応し短分岐命令に置換さ
れる場合はコード増加量フイールドBkEに0を格納
し、決定分岐量に1バイトを加算する。長分岐命令に置
換される場合はコード増加量フイールドBkEに1を格
納し、アドレス増加量と決定分岐量とにそれぞれ1バイ
トを加算する。
The branch information solving process (step S4) stores 0 in the code increase amount field BkE and adds 1 byte to the determined branch amount when it is replaced with a short branch instruction corresponding to the above-described determination position in step S3. I do. When replaced by a long branch instruction, 1 is stored in the code increase field BkE, and 1 byte is added to each of the address increase and the determined branch.

【0031】コード増加処理(ステップS5)は、コー
ド増加積フイールドBkCの増加積にアドレス増加量を
加え、コード増加可能積フイールドBkDの増加可能量
から決定分岐数を減算し、ステップS6の分岐情報位置
判定処理を行う。分岐情報位置判定処理(ステップS
6)は、分岐情報位置が分岐情報最後位置と一致するか
否かを判定し、否であればステップS7の分岐情報位置
増加処理を行い、一致すればステップS10の未解決判
定処理に進む。
In the code increase process (step S5), the address increase amount is added to the increase product of the code increase product field BkC, the number of determined branches is subtracted from the increase amount of the code increase product field BkD, and the branch information of step S6 is obtained. Perform position determination processing. Branch information position determination processing (step S
6) It is determined whether or not the branch information position matches the branch information end position. If not, the branch information position increasing process of step S7 is performed, and if the branch information position matches, the process proceeds to the unsolved determination process of step S10.

【0032】分岐情報位置増加処理(ステップS7)で
は、分岐情報位置が指示する分岐情報エントリBkの格
納バケット12kを次の分岐情報エントリBk+1の格
納バケット12k+1に変更し、次にアドレス増加処理
(ステップS2)に復帰する。未解決判定処理(ステッ
プS9)は、決定分岐量が0バイトの場合は、分岐情報
例外解決処理(ステップS13)に進み、否の場合は終
了判定処理(ステップS10)に進む。
In the branch information position increase processing (step S7), the storage bucket 12k of the branch information entry Bk indicated by the branch information position is changed to the storage bucket 12k + 1 of the next branch information entry Bk + 1, and then the address increase processing (step S7). Return to S2). The unsolved determination processing (step S9) proceeds to the branch information exception resolution processing (step S13) when the determined branch amount is 0 bytes, and proceeds to the end determination processing (step S10) otherwise.

【0033】分岐情報例外解決処理(ステップS13)
は、分岐情報最後位置の次のバケットからN/2番目の
バケットまでに格納されている全ての分岐情報エントリ
を長分岐命令として決定する。
Branch information exception solution processing (step S13)
Determines all branch information entries stored from the bucket next to the last position of branch information to the N / 2th bucket as long branch instructions.

【0034】終了判定処理(ステップS10)では、分
岐情報最後位置の次のバケットからN/2番目のバケッ
トまでに格納されている全ての分岐情報エントリが決定
済ならシンボルテーブル変換処理(ステップS11)を
行い、否であれば初期化処理(ステップS1)に戻り残
りの分についてステップS1〜S11を再度実行する。
In the end determination process (step S10), if all branch information entries stored from the next bucket at the last position of the branch information to the N / 2th bucket have been determined, a symbol table conversion process (step S11) If not, the process returns to the initialization process (step S1), and steps S1 to S11 are executed again for the remaining portion.

【0035】シンボルテーブル変換処理(ステップS1
1)は、従来のステップP9と同様の方法でに全てのシ
ンボル情報エントリS1〜Snの仮アドレスを補正して
正しいアドレスにし、ステップS12のバケット解放処
理を行って、この最適化処理を終了する。
Symbol table conversion processing (step S1)
In 1), the temporary addresses of all the symbol information entries S1 to Sn are corrected to correct addresses in the same manner as in the conventional step P9, and the bucket release processing in step S12 is performed, and this optimization processing is completed. .

【0036】バケット解放処理(ステップS12)は、
分岐情報最後位置の次のバケットからN/2番目のバケ
ットまでのメモリ領域を解放し、分岐情報先頭位置をこ
の解放後のバケットの先頭に設定し、この最適化処理を
終了する。
The bucket release processing (step S12)
The memory area from the bucket next to the last position of the branch information to the N / 2-th bucket is released, the leading position of the branch information is set at the beginning of the released bucket, and the optimization process ends.

【0037】ソースファイル1の一例を示す表1を併せ
参照して上述の最適化処理の動作をさらに具体的に説明
すると、この表に示すアセンブラソースには、各々50
0個ずつのラベル定義lab001〜lab500と、
仮分岐命令br lab001〜br lab500の
記述が示されている。ここで、説明の便宜上、ステップ
S3,S4の短分岐命令による許容最長分岐幅を128
バイトとし、したがって分岐情報テーブル12のバケッ
ト数Nを上記許容最長分岐幅の2倍の256とする。
The operation of the above-described optimization processing will be described more specifically with reference to Table 1 showing an example of the source file 1. The assembler source shown in this table has 50
0 label definitions lab001 to lab500,
The description of the provisional branch instructions br lab001 to br lab500 is shown. Here, for convenience of explanation, the allowable maximum branch width by the short branch instruction in steps S3 and S4 is set to 128.
Therefore, the number of buckets N in the branch information table 12 is set to 256, which is twice the allowable maximum branch width.

【0038】[0038]

【表1】 [Table 1]

【0039】表1の内容のソースファイル1の供給を1
行分ずつ順次受けると、構文解析部5Aは各行毎に構文
解析を行い対応するシンボルテーブル6と分岐情報テー
ブル12とを生成する。ある行の上記構文解析結果が仮
分岐命令であると、分岐情報生成部51Aが分岐情報エ
ントリを生成する。同時に、リスト上限判定部52が格
納対象のリストすなわちバケット数の上限を越えたか否
かの判定を行う。上述のように、バケット数Nは256
個であるので、256個目の分岐情報エントリの生成後
は上記上限値が超過する。リスト上限判定部52はこの
上限値超過に対応してこの仮分岐命令の最適化処理部8
による最適化処理を実行する。
The source file 1 having the contents shown in Table 1 is supplied as 1
When sequentially received for each line, the syntax analysis unit 5A performs a syntax analysis for each line and generates a corresponding symbol table 6 and a branch information table 12. If the syntax analysis result of a certain line is a temporary branch instruction, the branch information generation unit 51A generates a branch information entry. At the same time, the list upper limit determination unit 52 determines whether the list to be stored, that is, the upper limit of the number of buckets, has been exceeded. As described above, the number of buckets N is 256
Since the 256th branch information entry is generated, the above upper limit value is exceeded. The list upper limit judging section 52 responds to the excess of the upper limit value by optimizing the provisional branch instruction.
Perform optimization processing by.

【0040】最適化処理部8がアクセスされたとき、シ
ンボルテーブル6には256個のシンボルエントリが、
分岐情報テーブル12には256個の分岐情報エントリ
がそれぞれ格納されている。最適化処理の実行結果、分
岐情報テーブル12の先頭から128番目までの分岐情
報エントリ対応の仮分岐命令が決定され、対応する12
8個のバケットは空になる。
When the optimization processing unit 8 is accessed, the symbol table 6 has 256 symbol entries,
The branch information table 12 stores 256 branch information entries. As a result of the execution of the optimization processing, provisional branch instructions corresponding to the 128th branch information entry from the top of the branch information table 12 are determined, and the corresponding 12
Eight buckets are empty.

【0041】上記最適化処理の終了後は、構文解析部5
による構文解析を再開する。
After completion of the above-mentioned optimization processing, the syntax analysis unit 5
Resume parsing by.

【0042】さらに、128個の仮分岐命令対応の分岐
情報エントリを生成すると、再度、上限値256を超過
するので、リスト上限判定部52の判定により、この上
限値超過に対応してこの仮分岐命令の最適化処理部8に
よる最適化処理を実行する。
Further, when the branch information entries corresponding to the 128 temporary branch instructions are generated, the upper limit value 256 is exceeded again. The optimization processing by the instruction optimization processing unit 8 is performed.

【0043】この再度の最適化処理部8のアクセス時に
は、シンボルテーブル6には前回の256個に加えて1
28個すなわち384個のシンボルエントリが、分岐情
報テーブル12には256個の分岐情報エントリがそれ
ぞれ格納されている。最適化処理の実行結果、分岐情報
テーブル12の129番目から256番目までの分岐情
報エントリ対応の仮分岐命令が決定され、対応する12
8個のバケットは空になる。
When the optimization processing unit 8 accesses again, the symbol table 6 has 1
28 symbol data entries or 384 symbol entries are stored, and the branch information table 12 stores 256 branch information entries. As a result of the optimization processing, the tentative branch instructions corresponding to the 129th to 256th branch information entries in the branch information table 12 are determined, and the corresponding 12
Eight buckets are empty.

【0044】上記最適化処理の終了後は、構文解析部5
による構文解析を再開する。
After completion of the above-mentioned optimization processing, the syntax analysis unit 5
Resume parsing by.

【0045】このように、本実施例では、一定メモリ容
量の分岐情報テーブル12のメモリ容量が一定であって
も、このメモリ容量を越える多数の仮分岐命令を処理す
ることが可能である。
As described above, in this embodiment, even if the memory capacity of the branch information table 12 having a fixed memory capacity is constant, it is possible to process a large number of temporary branch instructions exceeding this memory capacity.

【0046】本発明の第2の実施例を示す図5を参照す
ると、この図に示す本実施例のアセンブラ2Bの最適化
処理部8Bは必要に応じて分岐情報テーブルのバケット
数を予め設定した数だけ増加しバケット最後位置を上記
増加数分だけシフトさせるバケット拡張処理部81を備
える。
Referring to FIG. 5 showing a second embodiment of the present invention, the optimization processing unit 8B of the assembler 2B of this embodiment shown in this figure presets the number of buckets in the branch information table as necessary. A bucket expansion processing unit 81 is provided, which increases the number by a number and shifts the bucket end position by the increase number.

【0047】本実施例の最適化処理部8Bのフローチャ
ートを示す図6を併せて参照して動作を説明すると、図
4の第1の実施例との相違点は、ステップS13の分岐
情報例外解決処理の代りに、ステップS14のバケット
拡張処理が付加されたことである。これにより、仮分岐
命令の分岐先がはるか前方、例えば60個分前方の場合
であるため、通常の最適化処理では仮分岐命令を決定で
きる分岐情報エントリが一つもなく未解決判定となるよ
うな場合に、例えば60個のバケットを追加するバケッ
ト拡張処理により解決可能とすることができる。
The operation will be described with reference to FIG. 6 showing a flowchart of the optimization processing unit 8B of this embodiment. The difference from the first embodiment shown in FIG. That is, instead of the processing, the bucket expansion processing of step S14 is added. In this case, since the branch destination of the temporary branch instruction is far ahead, for example, 60 branches ahead, there is no branch information entry that can determine the temporary branch instruction in the normal optimization processing, and the unresolved determination is made. In this case, the problem can be solved by, for example, bucket expansion processing for adding 60 buckets.

【0048】[0048]

【発明の効果】以上説明したように、本発明の分岐命令
処理装置および分岐命令処理方法は、構文解析手段が、
上記構文解析結果が仮分岐命令のとき一定数のバケット
を環状に配列した環状リスト構造の分岐情報テーブルに
上記分岐情報を供給する分岐情報生成手段と、上記分岐
情報テーブルの格納可能な分岐情報エントリの数の上限
値すなわち上記一定数の到達に応答して最適化処理を実
行させ最適化処理済の分岐情報エントリ対応の上記バケ
ットを空に解放するリスト上限判定処理手段とを備える
ため、分岐命令の数が増加しても所要メモリ領域は上記
一定数で済むので所要メモリ領域を節減できるという効
果がある。
As described above, according to the branch instruction processing apparatus and the branch instruction processing method of the present invention, the syntax analysis means includes:
Branch information generating means for supplying the branch information to a branch information table having a circular list structure in which a fixed number of buckets are circularly arranged when the result of the syntax analysis is a temporary branch instruction; and a storable branch information entry of the branch information table List upper limit determination processing means for executing an optimization process in response to the upper limit of the number of data items, that is, reaching the certain number, and releasing the bucket corresponding to the optimized branch information entry to empty. Even if the number increases, the required memory area can be kept at the above-mentioned fixed number, so that the required memory area can be saved.

【0049】また、メモリ容量の不足に起因するエラー
の発生や、外部のテンポラリファイルを用いることによ
る実行時間の遅延の発生が除去できるという効果があ
る。
Further, there is an effect that occurrence of an error due to lack of memory capacity and occurrence of a delay in execution time due to use of an external temporary file can be eliminated.

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

【図1】本発明の分岐命令処理装置の第1の実施例を示
すブロック図である。
FIG. 1 is a block diagram showing a first embodiment of a branch instruction processing device according to the present invention.

【図2】本実施例の分岐命令処理装置のシンボルテーブ
ルと分岐情報テーブルの構成を示す図である。
FIG. 2 is a diagram illustrating a configuration of a symbol table and a branch information table of the branch instruction processing device according to the embodiment.

【図3】本実施例の分岐命令処理装置のリスト上限判定
処理部の動作を示すフローチャートである。
FIG. 3 is a flowchart illustrating an operation of a list upper limit determination processing unit of the branch instruction processing device according to the present embodiment.

【図4】本実施例の分岐命令処理方法を示すフローチャ
ートである。
FIG. 4 is a flowchart illustrating a branch instruction processing method according to the embodiment.

【図5】本発明の分岐命令処理装置の第2の実施例を示
すブロック図である。
FIG. 5 is a block diagram showing a second embodiment of the branch instruction processing device of the present invention.

【図6】本実施例の分岐命令処理方法を示すフローチャ
ートである。
FIG. 6 is a flowchart illustrating a branch instruction processing method according to the present embodiment.

【図7】従来の分岐命令処理装置の一例を示すブロック
図である。
FIG. 7 is a block diagram showing an example of a conventional branch instruction processing device.

【図8】従来の分岐命令処理装置のシンボルテーブルと
分岐情報テーブルの構成を示す図である。
FIG. 8 is a diagram showing a configuration of a symbol table and a branch information table of a conventional branch instruction processing device.

【図9】従来の分岐命令処理方法を示すフローチャート
である。
FIG. 9 is a flowchart showing a conventional branch instruction processing method.

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

1 ソースファイル 2,2A,2B アセンブラ 3 オブジェクトファイル 4 ソースファイル入力部 5,5A 構文解析部 6 シンボルテーブル 7 中間情報 8,8A,8B 最適化処理部 9 中間情報解析処理部 10 オブジェクトファイル出力部 11,12 分岐情報テーブル 51 分岐情報生成部 52 リスト上限判定処理部 81 パケット拡張処理部 DESCRIPTION OF SYMBOLS 1 Source file 2, 2A, 2B assembler 3 Object file 4 Source file input part 5, 5A Syntax analysis part 6 Symbol table 7 Intermediate information 8, 8A, 8B Optimization processing part 9 Intermediate information analysis processing part 10 Object file output part 11 , 12 branch information table 51 branch information generator 52 list upper limit determination processor 81 packet extension processor

Claims (7)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 分岐命令とその分岐命令の参照先のラベ
ルとの距離により前記分岐命令のコード長が異なるマイ
クロプロセッサ用のアセンブラプログラムを処理するた
め、アセンブラ言語で記述した前記ラベルおよび前記分
岐命令対応の仮分岐命令を含むソースファイルを読込む
ソースファイル入力手段と、読込んだ前記ソースファイ
ルの構文解析を行い前記ラベル対応のシンボルエントリ
を格納するシンボルテーブルおよび前記仮分岐命令対応
の分岐情報エントリを格納する分岐情報テーブルとを生
成する構文解析手段と、前記仮分岐命令を補正して生成
した前記分岐命令のコード長を最短にする処理である最
適化処理を行う最適化処理手段とを備える分岐命令処理
装置において、 前記構文解析手段が、前記構文解析結果が前記仮分岐命
令のとき予め定めた数の前記分岐情報エントリの格納用
の記憶領域であるバケットを環状に配列した環状リスト
構造の分岐情報テーブルに前記分岐情報を供給する分岐
情報生成手段と、 前記分岐情報テーブルの格納可能な前記分岐情報エント
リの数の上限値の到達に応答して前記最適化処理手段を
アクセスして前記最適化処理を実行させ前記最適化処理
済の前記分岐情報エントリ対応の前記バケットを空に解
放するリスト上限判定処理手段とを備えることを特徴と
する分岐命令処理装置。
1. A label and a branch instruction described in an assembler language for processing an assembler program for a microprocessor in which a code length of the branch instruction varies depending on a distance between the branch instruction and a label referenced by the branch instruction. Source file input means for reading a source file including a corresponding provisional branch instruction, a symbol table for storing the symbol entry corresponding to the label by performing syntax analysis of the read source file, and a branch information entry corresponding to the provisional branch instruction And a optimizing processing means for performing an optimizing process which is a process of correcting the tentative branch instruction to minimize the code length of the generated branch instruction. In the branch instruction processing apparatus, the syntax analysis unit may be configured such that the syntax analysis result is the temporary branch instruction. Branch information generating means for supplying the branch information to a branch information table having a circular list structure in which buckets, which are storage areas for storing a predetermined number of the branch information entries, are circularly arranged; and storing the branch information table. In response to the arrival of the upper limit of the number of possible branch information entries, the optimization processing means is accessed to execute the optimization processing, and the bucket corresponding to the optimized branch information entry is emptied. A branch instruction processing device comprising: a list upper limit determination processing unit to be released.
【請求項2】 前記シンボルエントリが最近生成された
前記分岐情報エントリ対応のポインタを格納する分岐情
報フイールドとこのシンボルのアドレスを格納するアド
レスフイールドとを有し、 前記分岐情報エントリが前記仮分岐命令の分岐先の前記
シンボルエントリ対応のポインタを格納する分岐先フイ
ールドと、前記仮分岐命令が記述されたアドレスを格納
する分岐アドレスフイールドと、前記仮分岐命令のアド
レスが前記分岐情報より前にある第2の仮分岐命令より
増加するバイト長を格納するコード増加積フイールド
と、前記第2の仮分岐命令より増加する可能性のあるバ
イト長を格納するコード増加可能積フイールドと、前記
分岐情報のコード長が決定しているか否かの情報を格納
しさらに決定済の場合には前記コード長を格納するコー
ド増加量フイールドとを有することを特徴とする請求項
1記載の分岐命令処理装置。
2. The symbol entry has a branch information field storing a pointer corresponding to the branch information entry that has been recently generated, and an address field storing an address of the symbol, wherein the branch information entry is the temporary branch instruction. A branch destination field for storing a pointer corresponding to the symbol entry of the branch destination, a branch address field for storing an address where the temporary branch instruction is described, and a branch address field for storing the address of the temporary branch instruction before the branch information. A code increase product field for storing a byte length that is greater than the second provisional branch instruction, a code increase product field for storing a byte length that is likely to be greater than the second provisional branch instruction, and a code for the branch information Information on whether the length has been determined is stored. If the length has been determined, the code length is stored. Branch instruction processing apparatus according to claim 1, characterized in that it comprises a code increment field.
【請求項3】 前記最適化処理手段が、前記仮分岐命令
の分岐先が予め定めた第1の数の前記分岐命令を越えた
前方に分岐するため前記最適化処理が不可能となるとき
前記バケット数を予め定めた第2の数だけ増加させるバ
ケット拡張処理手段をさらに備えることを特徴とする請
求項1記載の分岐命令処理装置。
3. The optimization processing means according to claim 2, wherein said optimizing processing means is configured such that when said optimizing processing becomes impossible because a branch destination of said temporary branch instruction branches forward beyond a predetermined first number of said branch instructions. 2. The branch instruction processing device according to claim 1, further comprising a bucket extension processing unit that increases the number of buckets by a predetermined second number.
【請求項4】 分岐命令とその分岐命令の参照先のラベ
ルとの距離により前記分岐命令のコード長が異なるマイ
クロプロセッサ用のアセンブラプログラムを処理するた
め、アセンブラ言語で記述した前記ラベルおよび前記分
岐命令対応の仮分岐命令を含むソースファイルを読込
み、読込んだ前記ソースファイルの構文解析を行い前記
ラベル対応のシンボルエントリを格納するシンボルテー
ブルと前記仮分岐命令対応の分岐情報エントリを格納す
る分岐情報テーブルとを生成し、前記仮分岐命令を補正
して生成した前記分岐命令のコード長を最短にする処理
である最適化処理を行う分岐命令処理方法において、 前記分岐情報テーブルが予め定めた数の前記分岐情報エ
ントリの格納用の記憶領域であるバケットを環状に配列
した環状リスト構造を有し、前記分岐情報テーブルの格
納可能な前記分岐情報エントリの数の上限値の到達に応
答して前記最適化処理を実行させ前記最適化処理済の前
記分岐情報エントリ対応する前記バケットを空に解放す
るリスト上限判定処理を行なうことを特徴とする分岐命
令処理方法。
4. The label and the branch instruction described in an assembler language for processing an assembler program for a microprocessor in which a code length of the branch instruction varies depending on a distance between the branch instruction and a label referenced by the branch instruction. Reading a source file including a corresponding temporary branch instruction, parsing the read source file, and storing a symbol entry corresponding to the label and a branch information table storing a branch information entry corresponding to the temporary branch instruction And a branch instruction processing method for performing an optimization process that is a process of correcting the temporary branch instruction to minimize the code length of the generated branch instruction, wherein the branch information table has a predetermined number of the A circular list structure in which buckets, which are storage areas for storing branch information entries, are arranged in a ring. And executing the optimization process in response to the reaching of the upper limit of the number of the branch information entries that can be stored in the branch information table, and releasing the bucket corresponding to the optimized branch information entry to empty. A branch instruction processing method characterized by performing a list upper limit determination process.
【請求項5】 前記リスト上限判定処理が、生成された
前記分岐情報エントリを格納する前記バケットの位置を
示す情報であるバケット格納位置が指示する前記バケッ
トに前記分岐情報エントリを格納するバケット格納処理
ステップと、 前記バケット格納位置より予め定めた数だけ増加した第
2のバケット格納位置を指示するよう変更するバケット
格納位置増加処理ステップと、 前記バケット格納位置と前記分岐情報エントリの格納可
能な最後のバケットの次のバケット位置を示すバケット
最後位置との比較を行い、これら前記バケット格納位置
とバケット最後位置が一致していれば前記最適化処理を
実行し、一致していなければこのリスト上限判定処理を
終了するバケット格納位置判定ステップと、 前記最適化処理の終了後に前記バケット最後位置を未解
放の最後のバケットに設定するバケット最後位置更新処
理ステップとを含むことを特徴とする請求項4記載の分
岐命令処理方法。
5. A bucket storage process in which the list upper limit determination process stores the branch information entry in the bucket indicated by a bucket storage position which is information indicating a position of the bucket storing the generated branch information entry. A bucket storage position increase processing step of changing the bucket storage position to indicate a second bucket storage position that is increased by a predetermined number from the bucket storage position; and a last storeable storage of the bucket storage position and the branch information entry. A comparison is made with a bucket end position indicating the next bucket position of the bucket. If the bucket storage position and the bucket end position match, the optimization processing is executed. Ending the bucket storage position, and ending the optimization process. 5. The branch instruction processing method according to claim 4, further comprising: a bucket last position update processing step of setting a last position to a last bucket that has not been released.
【請求項6】 前記シンボルエントリが最近生成された
前記分岐情報エントリ対応のポインタを格納する分岐情
報フイールドとこのシンボルのアドレスを格納するアド
レスフイールドとを有し、 前記分岐情報エントリが前記仮分岐命令の分岐先の前記
シンボルエントリ対応のポインタを格納する分岐先フイ
ールドと、前記仮分岐命令が記述されたアドレスを格納
する分岐アドレスフイールドと、前記仮分岐命令のアド
レスが前記分岐情報より前にある第2の仮分岐命令より
増加するバイト長を格納するコード増加積フイールド
と、前記第2の仮分岐命令より増加する可能性のあるバ
イト長を格納するコード増加可能積フイールドと、前記
分岐情報のコード長が決定しているか否かの情報を格納
しさらに決定済の場合には前記コード長を格納するコー
ド増加量フイールドとを有し、 前記最適化処理が、前記分岐情報位置とアドレス増加量
の初期化および決定分岐量の各々を予め定めた初期値に
設定する初期化処理ステップと、 前記アドレスフイールドのアドレスをアドレス増加量だ
け増加させるアドレス増加処理ステップと、 前記コード増加量フイールドの情報が未決定で解決可能
か否かを判定し第1の判定結果を生成する分岐情報判定
処理ステップと、 前記第1の判定結果が未決定で解決可能ならば上記判定
に対応して前記分岐命令を決定する予め定めた補正処理
を実行する分岐情報解決処理ステップと、 前記第1の判定結果が未決定で解決可能でなければ予め
定めたコード増加処理を実行するコード増加処理ステッ
プと、 前記分岐情報位置が前記分岐情報最後位置と一致するか
否かを判定し第2の判定結果を生成する分岐情報位置判
定処理ステップと、 前記第2の判定結果が否の場合前記分岐情報位置が指示
する分岐情報エントリの格納バケットを次の分岐情報エ
ントリの格納バケットに変更する分岐情報位置増加処理
ステップと、 前記第2の判定結果が一致する場合は前記分岐情報位置
対応の決定分岐量が予め定めた値であるか否かを判定し
第3の判定結果を生成する未解決判定処理ステップと、 前記第3の判定結果が前記値であれば前記分岐情報最後
位置の次のバケットから予め定めた第2の数番目のバケ
ットまでに格納されている全ての分岐情報エントリを長
い方のコード長の長分岐命令として決定する分岐情報例
外解決処理ステップと、 前記分岐情報最後位置の次のバケットから前記第2の数
番目のバケットまでのメモリ領域を解放し分岐情報先頭
位置をこの解放後のバケットの先頭に設定するバケット
解放処理ステップとを含むことを特徴とする請求項4記
載の分岐命令処理方法。
6. A branch information field in which the symbol entry stores a pointer corresponding to the recently generated branch information entry, and an address field in which an address of the symbol is stored, wherein the branch information entry is the temporary branch instruction. A branch destination field for storing a pointer corresponding to the symbol entry of the branch destination, a branch address field for storing an address where the temporary branch instruction is described, and a branch address field for storing the address of the temporary branch instruction before the branch information. A code increase product field for storing a byte length that is greater than the second provisional branch instruction, a code increase product field for storing a byte length that is likely to be greater than the second provisional branch instruction, and a code for the branch information Information on whether the length has been determined is stored. If the length has been determined, the code length is stored. A code increment field, wherein the optimizing process initializes the branch information position and the address increment and sets each of the determined branch values to a predetermined initial value; and the address field Address increase processing step of increasing the address by the address increase amount; branch information determination processing step of determining whether or not the information of the code increase amount field is undecided and can be solved, and generating a first determination result; A branch information solution processing step of executing a predetermined correction process for determining the branch instruction in response to the above determination if the first determination result is undecided and can be resolved; A code increase processing step of executing a predetermined code increase processing if it cannot be solved; and whether the branch information position matches the branch information end position. Branch information position determination processing step of determining whether or not the branch information position is to be generated, and if the second determination result is negative, the branch information position indicated by the branch information position is stored in the next branch information entry And a branch information position increasing process step of changing to the storage bucket of the above. If the second determination result matches, it is determined whether or not the determined branch amount corresponding to the branch information position is a predetermined value. An unresolved determination processing step of generating a determination result, and if the third determination result is the value, the branch information is stored from a bucket next to the last position of the branch information to a second predetermined bucket. A branch information exception solution processing step of determining all branch information entries as long branch instructions having a longer code length; and the second number bucket from the bucket next to the last position of the branch information. 5. A branch instruction processing method according to claim 4, further comprising the step of: releasing a memory area up to the first packet and setting a branch information head position to a head of the bucket after the release.
【請求項7】 前記分岐情報例外解決処理ステップの代
りに前記分岐情報テーブルの前記バケット数を予め定め
た数だけ増加しバケット最後位置を前記増加数分だけシ
フトさせるバケット拡張処理ステップを含むことを特徴
とする請求項6記載の分岐命令処理方法。
7. A bucket extension processing step of increasing the number of buckets in the branch information table by a predetermined number and shifting the last position of the bucket by the increase number instead of the branch information exception solution processing step. 7. The branch instruction processing method according to claim 6, wherein:
JP5301376A 1993-12-01 1993-12-01 Branch instruction processing device and branch instruction processing method Expired - Lifetime JP2570998B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP5301376A JP2570998B2 (en) 1993-12-01 1993-12-01 Branch instruction processing device and branch instruction processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP5301376A JP2570998B2 (en) 1993-12-01 1993-12-01 Branch instruction processing device and branch instruction processing method

Publications (2)

Publication Number Publication Date
JPH07152580A JPH07152580A (en) 1995-06-16
JP2570998B2 true JP2570998B2 (en) 1997-01-16

Family

ID=17896134

Family Applications (1)

Application Number Title Priority Date Filing Date
JP5301376A Expired - Lifetime JP2570998B2 (en) 1993-12-01 1993-12-01 Branch instruction processing device and branch instruction processing method

Country Status (1)

Country Link
JP (1) JP2570998B2 (en)

Also Published As

Publication number Publication date
JPH07152580A (en) 1995-06-16

Similar Documents

Publication Publication Date Title
US5212794A (en) Method for optimizing computer code to provide more efficient execution on computers having cache memories
US5276882A (en) Subroutine return through branch history table
US4969091A (en) Apparatus for stack control employing mixed hardware registers and memory
US6624762B1 (en) Hardware-based, LZW data compression co-processor
US20080028381A1 (en) Optimizing source code for iterative execution
JPH08305577A (en) Optimizing device
JP2002033769A (en) Prefix-retrieving method using compressed retrieval table, and data structure
JP2001516920A (en) Digital signal processor with variable width instructions
JPH07200292A (en) Pipeline system processor
US6611956B1 (en) Instruction string optimization with estimation of basic block dependence relations where the first step is to remove self-dependent branching
US5459847A (en) Program counter mechanism having selector for selecting up-to-date instruction prefetch address based upon carry signal of adder which adds instruction size and LSB portion of address register
JPH09134287A (en) Microprocessor and its load address predicting method
JP2570998B2 (en) Branch instruction processing device and branch instruction processing method
US6928643B2 (en) Bi-endian libraries
JP2003122555A (en) System and method for split-stream dictionary program compression and just-in-time translation
US5740447A (en) Branch instruction optimizing process system in linkage editor
US20020104078A1 (en) Forming an executable program
JPH08227363A (en) Method for processing branch instruction
JPS60117335A (en) Information processor
JP3231619B2 (en) Assembling method
JP3036900B2 (en) Assembler processing unit
JPH056272A (en) Software designing device
KR20010022065A (en) A method and a processor adapted for the handling of conditional jumps
JP2797777B2 (en) Language processor
JP2559416B2 (en) Information processing device

Legal Events

Date Code Title Description
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 19960903