JP4327533B2 - Arithmetic processing program, arithmetic processing method, and arithmetic processing apparatus - Google Patents

Arithmetic processing program, arithmetic processing method, and arithmetic processing apparatus Download PDF

Info

Publication number
JP4327533B2
JP4327533B2 JP2003299311A JP2003299311A JP4327533B2 JP 4327533 B2 JP4327533 B2 JP 4327533B2 JP 2003299311 A JP2003299311 A JP 2003299311A JP 2003299311 A JP2003299311 A JP 2003299311A JP 4327533 B2 JP4327533 B2 JP 4327533B2
Authority
JP
Japan
Prior art keywords
polynomial
digits
hardware instruction
operations
arithmetic processing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
JP2003299311A
Other languages
Japanese (ja)
Other versions
JP2005071056A (en
Inventor
剛司 山本
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2003299311A priority Critical patent/JP4327533B2/en
Publication of JP2005071056A publication Critical patent/JP2005071056A/en
Application granted granted Critical
Publication of JP4327533B2 publication Critical patent/JP4327533B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Devices For Executing Special Programs (AREA)

Description

本発明は、ソースプログラムに含まれる多項演算を翻訳する演算処理プログラム、演算処理方法、および演算処理装置に関するものである。   The present invention relates to an arithmetic processing program, an arithmetic processing method, and an arithmetic processing device for translating a polynomial operation included in a source program.

従来、コンパイラでソースプログラム中に記述された多項演算をハードウェア命令を用いて実行させる場合、多項演算で記述されている演算子の優先順に従って左から右方向に順次ハードウェア命令を用いて演算を行う命令列に展開していた。   Conventionally, when executing a multinomial operation described in a source program using a hardware instruction using a compiler, the operation is performed sequentially from left to right according to the priority order of the operators described in the multinomial operation. It was expanded to the instruction sequence to do.

例えば多項演算として、図4の(a)に示す
16バイト2進=8バイト2進*2バイト2進*4バイト2進*2バイト2進
があった場合、32ビット(4バイト)のCPUでは、1度に32ビット(4バイト)同士の演算(乗算)ができ、これを越えるときは分割する必要があるため、図4の(a)中の(1)から(3)に示す乗算について、図4の(b)の(1)から(3)のようなハードウェア命令にそれぞれ展開して演算するようにしていた。
For example, when there is a 16-byte binary = 8-byte binary * 2-byte binary * 4-byte binary * 2-byte binary shown in FIG. 4A as a polynomial operation, a 32-bit (4 bytes) CPU In this case, the calculation (multiplication) between 32 bits (4 bytes) can be performed at once, and if it exceeds this, it is necessary to divide, so the multiplications shown in (1) to (3) in FIG. 4 are expanded into hardware instructions as shown in (1) to (3) of FIG.

このため、
図4の(b)の(1)で、2回の乗算が必要
図4の(b)の(2)で、3回の乗算が必要
図4の(b)の(3)で、4回の乗算が必要
となり、合計9回の乗算(ハードウェア命令による乗算)が必要となっていた。
For this reason,
4 (b) (1) requires two multiplications FIG. 4 (b) (2) requires three multiplications FIG. 4 (b) (3) four times In other words, a total of 9 multiplications (multiplication by hardware instructions) are necessary.

従来は、上述した図4の(a)に示すように、多項演算を左から順に右の方向にハードウェア命令に展開したので、展開されるハードウェア命令の数が多くなってしまい、迅速に実行し得ないという問題があった。   Conventionally, as shown in (a) of FIG. 4 above, since the polynomial operation is expanded into hardware instructions in order from the left to the right, the number of hardware instructions to be expanded increases, so that There was a problem that it could not be executed.

本発明は、これらの問題を解決するため、演算ソート手段8がソースプログラムに含まれる多項演算中の演算を桁数の小さい順にソートし、分割手段9が小さい順にソートした後の多項演算の先頭から順に演算するハードウェア命令を生成する際に、実行させる装置のハードウェア命令の桁数を超えたときは超えない範囲に分割し、オブジェクト生成手段11が多項演算の先頭から順に演算するハードウェア命令を生成、あるいは分割されたときは分割後の演算についてそれぞれハードウェア命令を生成するようにしている。   In the present invention, in order to solve these problems, the operation sorting means 8 sorts the operations in the polynomial operation included in the source program in ascending order of the number of digits, and the dividing means 9 sorts the head of the polynomial operation after sorting in ascending order. When generating hardware instructions that are operated in order, the hardware instructions are divided into ranges that do not exceed when the number of digits of hardware instructions of the device to be executed is exceeded, and the object generation means 11 calculates hardware in order from the beginning of the multinomial operation When an instruction is generated or divided, a hardware instruction is generated for each operation after division.

また、組み合わせ選択手段10がソースプログラムに含まれる多項演算中の演算のうち、演算結果の桁数が最も小さくなる組み合わせの2つの演算を選択する、あるいは選択した2つの演算の演算結果の桁数と、残りの演算とのうち、演算結果の桁数が最も小さくなる組み合わせの2つの演算を選択し、分割手段9が選択された演算の組について、演算するハードウェア命令を生成する際に、実行させる装置のハードウェア命令の桁数を超えたときは超えない範囲に分割し、オブジェクト生成手段11が多項演算の先頭から順に演算するハードウェア命令を生成、あるいは分割されたときは分割後の演算についてそれぞれハードウェア命令を生成するようにしている。   Also, the combination selection means 10 selects two operations of the combination having the smallest number of digits of the operation result among the operations in the polynomial operation included in the source program, or the number of digits of the operation result of the two selected operations. And, when selecting two operations of the combination having the smallest number of digits of the operation result among the remaining operations and generating the hardware instruction to perform the operation for the selected operation set, the dividing unit 9 When the number of digits of the hardware instruction of the device to be executed is exceeded, it is divided into a range that does not exceed, and when the object generation means 11 generates or divides the hardware instruction for calculating in order from the beginning of the multinomial operation, A hardware instruction is generated for each operation.

従って、コンパイル時に多項演算をハードウェア命令に展開する際に、多項演算の桁数の少ない順にソートした後にハードウェア命令に展開したり、中間結果も含めて演算結果が最小となる組み合わせから順にハードウェア命令に展開したりすることにより、多項演算を実行するハードウェア命令数を最小限にし、または処理時間がかかる命令の展開を抑制し、実行速度の向上を図ることが可能となる。   Therefore, when expanding a multinomial operation to a hardware instruction at compile time, it is sorted into the hardware instruction after sorting in ascending order of the number of digits of the multinomial operation, or from the combination that minimizes the operation result including intermediate results. By expanding to hardware instructions, it is possible to minimize the number of hardware instructions that execute a multinomial operation, or to suppress the expansion of instructions that require processing time, thereby improving the execution speed.

本願発明は、コンパイル時に多項演算を実行するためのハードウェア命令数を最小限に展開しているため、ソースプログラム中に出現する多項演算の実行速度の向上を図ることが可能となる。   In the present invention, since the number of hardware instructions for executing a polynomial operation at the time of compilation is expanded to a minimum, the execution speed of the polynomial operation appearing in the source program can be improved.

本発明は、コンパイル時に多項演算をハードウェア命令に展開する際に、多項演算の桁数の少ない順にソートした後にハードウェア命令に展開したり、中間結果も含めて演算の演算結果が最小となる組み合わせから順にハードウェア命令に展開したりすることにより、多項演算を実行するハードウェア命令数を最小限にし、または処理時間がかかる命令の展開を抑制し、実行速度の向上を図ることを実現した。   In the present invention, when a multinomial operation is expanded into a hardware instruction at the time of compilation, the operation is sorted into the hardware instruction after the number of digits of the multinomial operation is reduced, or the operation result of the operation including the intermediate result is minimized. By expanding the hardware instructions in order from the combination, the number of hardware instructions that execute multinomial operations is minimized, or the expansion of instructions that require processing time is suppressed, and the execution speed is improved. .

図1は、本発明のシステム構成図を示す。   FIG. 1 shows a system configuration diagram of the present invention.

図1において、コンパイラ1は、プログラムをコンピュータが実行することによって、ソースプログラム2をコンパイル(翻訳)して実行可能形式のオブジェクトプログラム3を生成するものであって、ここでは、字句解析手段2、構文解析手段3、意味解析手段4、最適化手段5、およびオブジェクト生成手段11などから構成されるものである。   In FIG. 1, a compiler 1 is a computer that executes a program to compile (translate) a source program 2 to generate an executable object program 3. Here, a lexical analysis unit 2, It comprises a syntax analysis means 3, a semantic analysis means 4, an optimization means 5, an object generation means 11, and the like.

字句解析手段2は、コンパイル対象のソースプログラム2を読み込んで当該ソースプログラム2の字句を解析するものであって、公知の手段である。   The lexical analysis means 2 is a known means for reading the source program 2 to be compiled and analyzing the lexical of the source program 2.

構文解析手段3は、字句解析手段2によってソースプログラム2の字句解析した結果をもとに、当該ソースプログラム2の構文(構造)を解析するものであって、公知の手段である。   The syntax analysis means 3 is a known means for analyzing the syntax (structure) of the source program 2 based on the result of the lexical analysis of the source program 2 by the lexical analysis means 2.

意味解析手段4は、構文解析手段3によって解析されたソースプログラム2の意味を解析するものであって、公知の手段である。   The semantic analysis means 4 analyzes the meaning of the source program 2 analyzed by the syntax analysis means 3, and is a known means.

最適化手段5は、意味解析手段4によって解析された結果をもとに、最適化(実行形式のオブジェクトプログラムが高速に実行したり、レジスタの有効利用を図ったりなどの最適化)を行うものであって、ここでは、分岐最適化手段6、演算最適化手段7などから構成されるものである。   The optimization means 5 performs optimization (optimization such as execution of an object program in an executable format or effective use of registers) based on the result analyzed by the semantic analysis means 4 In this example, the branch optimization unit 6 and the operation optimization unit 7 are included.

分岐最適化手段6は、ソースプログラム2の分岐を最適化するものであって、公知の手段である。   The branch optimization means 6 optimizes the branch of the source program 2 and is a known means.

演算最適化手段7は、本願発明に係わるものであって、多項演算をコンパイルするときにハードウェア命令数を最小限にする最適化を図るものであり、演算ソート手段8、分割手段9、および組合せ選択手段10などから構成されるものである(図2、図3を用いて後述する)。   The operation optimizing means 7 relates to the present invention and is intended to optimize the number of hardware instructions when compiling a multinomial operation. The operation optimizing means 8, the dividing means 9, The combination selection means 10 and the like (which will be described later with reference to FIGS. 2 and 3).

演算ソート手段8は、多項演算の桁数が小さい順にソートするものである(図2を用いて後述する)。   The arithmetic sorting means 8 sorts the multiple arithmetic operations in ascending order of digits (described later with reference to FIG. 2).

分割手段9は、多項演算をハードウェア命令に展開するときに、当該ハードウェアで演算する桁数を超えるときに分割(例えば上位4バイトと、下位4バイトに分割)するものである(図2、図3を用いて後述する)。   The dividing means 9 divides a multinomial operation into hardware instructions when it exceeds the number of digits to be calculated by the hardware (for example, divided into upper 4 bytes and lower 4 bytes) (FIG. 2). And will be described later with reference to FIG.

組合せ選択手段10は、多項演算の桁数が小さい組合せを選択するものである(図3を用いて後述する)。   The combination selection means 10 selects a combination with a small number of digits in the polynomial operation (described later with reference to FIG. 3).

オブジェクト生成手段11は、ソースプログラムの実行可能形式のオブジェクトプログラム3を生成するものである。   The object generation means 11 generates an object program 3 in an executable format of the source program.

ソースプログラム2は、コンパイル(翻訳)対象のソースプログラムである。   The source program 2 is a source program to be compiled (translated).

オブジェクトプログラム3は、コンパイルした後の実行可能形式のプログラムである。   The object program 3 is an executable program after being compiled.

次に、図2の(b)のフローチャートの順番に従い、多項演算の桁数が小さい順にソートして順次ハードウェア命令に展開し、ハードウェア命令数を最小限にするときの手順を詳細に説明する。   Next, in accordance with the order of the flowchart of FIG. 2B, the procedure for sorting the hardware operations in ascending order of the number of digits and expanding them into hardware instructions in order and minimizing the number of hardware instructions will be described in detail. To do.

図2は、本発明の説明図(その1)を示す。   FIG. 2 is an explanatory diagram (part 1) of the present invention.

図2の(a)は、多項演算の例を示す。ここでは、図示の下記の多項演算
・16バイト2進=8バイト2進*2バイト2進*4バイト2進*2バイト2進
= a * b * c * d
とする(aは8バイト2進で表現される任意の数値を表すとする、以下同様)。
FIG. 2A shows an example of a polynomial operation. Here, the following polynomial operation shown: 16 bytes binary = 8 bytes binary * 2 bytes binary * 4 bytes binary * 2 bytes binary
= A * b * c * d
(A represents an arbitrary numerical value expressed in 8-byte binary, and so on).

図2の(b)は、フローチャートを示す。これは、図2の(a)の多項演算を、ここでは、CPUが4バイト(32ビット)の演算命令で実行するときの展開などの様子を示す。   FIG. 2B shows a flowchart. This shows a situation such as expansion when the CPU executes the polynomial operation of FIG. 2A with a 4-byte (32-bit) operation instruction.

図2の(b)において、S1で、演算式を取り込む。これは、図2の(a)の多項演算(乗算の多項演算)の式を取り込む、ここでは、右側に記載したように、
a*b*c*d
と取り込む。
In FIG. 2B, an arithmetic expression is fetched in S1. This takes in the expression of the polynomial operation (multiplicative operation of multiplication) in FIG. 2A, where, as described on the right side,
a * b * c * d
And capture.

S2で、ビット数の少ない順に並び替える。これは、S1で取り込んだ図2の(a)の多項演算のa*b*c*dを、ビット数の少ない順に並び変え、右側に記載したように、
b*d*c*a
とする。
In S2, rearrangement is performed in ascending order of the number of bits. This is because the a * b * c * d of the polynomial operation of FIG. 2A taken in S1 is rearranged in ascending order of the number of bits, and as described on the right side,
b * d * c * a
And

S3で、先頭の1データを取り込む。これは、S2で並び替えた後の多項演算の先頭の1データ、1回目はbを取り込む。   In S3, the first data is fetched. This is the first one data of the polynomial operation after the rearrangement in S2, and b is taken in the first time.

S4で、分割要か判別する。これは、S3で取り込んだデータについて、CPUが実行できる演算命令の4バイトよりも大きくて分割要か判別する。1回目のときは、S3でbを取り込み当該bが2バイト2進で4バイトよりも小さく分割不要でNOとなり、S6に進む。一方、YESの場合には、S5で上位下位に分割してCPUが実行できる演算命令の4バイトよりも小さくしてS6に進む(尚、上位下位に分割してもなおも4バイトを超えるときは更に3分割、4分割などして4バイトを超えないようにし、S6に進む)。   In S4, it is determined whether division is necessary. This determines whether the data fetched in S3 is larger than 4 bytes of the arithmetic instruction that can be executed by the CPU and needs to be divided. At the first time, b is fetched in S3, and b is smaller than 4 bytes in 2 bytes binary and no division is required, and the process proceeds to S6. On the other hand, in the case of YES, the process advances to S6 after being divided into upper and lower parts in S5 and smaller than 4 bytes of the arithmetic instruction that can be executed by the CPU (in addition, when the upper and lower parts are still exceeded 4 bytes) Is further divided into 3 or 4 so as not to exceed 4 bytes, and the process proceeds to S6).

S6で、次のデータを取り込む。ここでは、2番目のd(2バイト2進)を取り込む。   In S6, the next data is fetched. Here, the second d (2-byte binary) is taken in.

S7で、分割要か判別する。これは、乗算する側についてもS4(被乗数の側)と同様に、CPUが実行できる演算命令の4バイトよりも大きくて分割要か判別する。YESの場合には、S8で上位下位(更に、4バイトよりも大きいときは3分割、4分割などする)に分割し、S9に進む。NOの場合には、S9に進む。   In S7, it is determined whether division is necessary. This is also determined on the multiplication side, as in S4 (multiplicand side), if it is larger than 4 bytes of the arithmetic instruction that can be executed by the CPU and needs to be divided. In the case of YES, in S8, it is divided into higher order and lower order (further, if it is larger than 4 bytes, it is divided into 3 divisions, 4 divisions, etc.), and the process proceeds to S9. If NO, the process proceeds to S9.

S9で、演算を処理する展開を行う。これは、S3からS5で被乗数について4バイト以下とし、S7、S8で乗数について4バイト以下としたので、被除数と乗数を演算処理できるように展開を行う(例えば後述する図2の(c)の「2バイト2進*2バイト2進」などのようにハードウェア命令で演算実行できるように展開する)。   In S9, development for processing the calculation is performed. This is because the multiplicand is set to 4 bytes or less in S3 to S5, and the multiplier is set to 4 bytes or less in S7 and S8, so that the dividend and the multiplier can be calculated (for example, as shown in FIG. It is expanded so that it can be executed by a hardware instruction such as “2-byte binary * 2-byte binary”).

S10で、終わりか判別する。YESの場合には、S12に進む。NOの場合には、S11で結果を先頭にし、S3以降を繰り返し、2回目、3回目の処理などを行う。   In S10, it is determined whether or not the end. If YES, the process proceeds to S12. In the case of NO, the result is placed at the top in S11, and S3 and subsequent steps are repeated, and the second and third processes are performed.

S12で、演算を行う展開を行う。これは、S9でハードウェア命令で演算を行える桁数以下の演算(演算式)に展開したので、当該演算(演算式)をハードウェア命令を使用した形に展開する。   In S12, the expansion for performing the calculation is performed. Since this is expanded to an operation (arithmetic expression) of the number of digits or less that can be performed by a hardware instruction in S9, the arithmetic (arithmetic expression) is expanded into a form using a hardware instruction.

以上の手順によって、ここでは、図2の(a)の多項演算a*b*c*dについて、S2でb*d*c*aに桁数の小さい順に並び変え、先頭から順に、図示の1回目(分割なし)、2回目(分割なし)、3回目(中間結果を3つに分割)の処理を行い、後述する図2の(c)に示す1回目、2回目、3回目のように展開でき、合計6回のハードウェア命令の実行(乗算の実行)で済み、既述した従来の合計9回から3回少なくでき、高速実行できるオブジェクトプログラムを生成可能となる。   By the above procedure, here, the polynomial operation a * b * c * d in FIG. 2A is rearranged to b * d * c * a in ascending order of the number of digits in S2, and the order shown in FIG. The first (no division), second (no division), and third (intermediate results are divided into three) processes are performed, and the first, second, and third shown in FIG. It is possible to develop an object program that can be executed at high speed, and can be executed three times from the total of nine times of the conventional method described above.

図2の(c)は、図2の(a)の多項演算について、図2の(b)のフローチャートに従い処理した結果を模式的に示す。   FIG. 2 (c) schematically shows the result of processing the polynomial operation of FIG. 2 (a) according to the flowchart of FIG. 2 (b).

・1回目:図2の(b)の1回目に対応し、b*d(ここで、b=2バイト2進、d=2バイト2進)は、4バイト以下であるので、そのまま演算し、中間結果4バイトとなる様子を示す。   ・ First time: Corresponding to the first time in FIG. 2 (b), b * d (where b = 2 bytes binary, d = 2 bytes binary) is 4 bytes or less, so the calculation is performed as it is. The intermediate result is 4 bytes.

・2回目:図2の(b)の2回目に対応し、中間結果4バイト*c(ここで、c=4バイト2進)は、4バイト以下であるので、そのまま演算し、中間結果8バイトとなる様子を示す。   Second time: Corresponding to the second time in FIG. 2B, the intermediate result 4 bytes * c (where c = 4 bytes binary) is 4 bytes or less, so the calculation is performed as it is, and the intermediate result 8 It shows how it becomes a byte.

・3回目:図2の(b)の3回目に対応し、中間結果8バイト*a(ここで、a=8バイト2進)は、4バイト以上であるので、図示のように分割してそれぞれ演算し、中間結果16バイトとなる様子を示す。ここでは、上位4バイトと下位4バイトにそれぞれ分割して組み合わせて合計4回の図示のような演算に展開する。   -Third time: Corresponding to the third time of FIG. 2 (b), the intermediate result 8 bytes * a (where a = 8 bytes binary) is 4 bytes or more. Each of the operations is shown as an intermediate result of 16 bytes. Here, the upper 4 bytes and the lower 4 bytes are divided and combined, and expanded into a total of four operations as shown in the figure.

図2の(d)は、図2の(c)の乗算は合計6回でよいという様子を示す。これは、既述した図4の従来の合計9回に比べて6回となり、3回乗算が少なくなっている。   FIG. 2 (d) shows that the multiplication of FIG. 2 (c) may be six times in total. This is 6 times compared to the conventional 9 times in FIG. 4 described above, and the multiplication of 3 times is reduced.

図3は、本発明の説明図(その2)を示す。   FIG. 3 is an explanatory diagram (part 2) of the present invention.

図3の(a)は、多項演算の例を示す。ここでは、図示の下記の多項演算
・8バイト2進=2バイト2進*2バイト2進*2バイト2進*2バイト2進
= a * b * c * d
とする(aは2バイト2進で表現される任意の数値を表すとする、以下同様)。
FIG. 3A shows an example of a polynomial operation. Here, the following polynomial operation shown below: 8-byte binary = 2-byte binary * 2-byte binary * 2-byte binary * 2-byte binary
= A * b * c * d
(A represents an arbitrary numerical value expressed in 2-byte binary, and so on).

図3の(b)は、フローチャートを示す。これは、図3の(a)の多項演算を、ここでは、CPUが4バイト(32ビット)の演算命令で実行するときの展開などの様子を示す。   FIG. 3B shows a flowchart. This shows a situation such as expansion when the CPU executes the multinomial operation of FIG. 3A with a 4-byte (32-bit) operation instruction.

図3の(b)において、S21で、演算式を取り込む。これは、図3の(a)の多項演算(乗算の多項演算)の式を取り込む、ここでは、
a*b*c*d
と取り込む。
In FIG. 3B, an arithmetic expression is fetched in S21. This takes in the expression of the polynomial operation (multiplicative operation of multiplication) in FIG.
a * b * c * d
And capture.

S22で、ビット数の少ない順に並び替える。これは、S21で取り込んだ図3の(a)の多項演算のa*b*c*dを、ビット数の少ない順に並び変える。ここでは、ビット数が全て同じであるので、a*b*c*dのままとする。   In S22, rearrangement is performed in ascending order of the number of bits. This rearranges the a * b * c * d of the polynomial operation of FIG. 3A taken in S21 in ascending order of the number of bits. Here, since all the numbers of bits are the same, a * b * c * d remains as it is.

S23で、1個目と2個目を演算する。これは、1個目(先頭)のaと、2個目のbとを演算(a*b)する。尚、被乗数、乗数(ここでは、a,b)の桁数が4バイトを超えるときは、既述した図2の(b)のS3〜S5、あるいはS6〜S8のように超えないように分割し、これら分割したものの演算を行う。   In S23, the first and second are calculated. This calculates (a * b) the first (first) a and the second b. When the number of digits of the multiplicand or multiplier (here, a, b) exceeds 4 bytes, it is divided so as not to exceed S3 to S5 or S6 to S8 in FIG. Then, the operation of these divided parts is performed.

S24で、演算結果と残りのビットの組合せで最小の演算結果のビット数となるものを見つける。これは、1回目はS23で演算した演算結果、2回目以降は前回の演算結果と、残りの演算とを含めて2つの組合せて演算結果のビット数(桁数)が最小となる組合せを見つける。   In S24, the combination of the operation result and the remaining bits that finds the minimum number of operation result bits is found. This is to find the combination that minimizes the number of bits (number of digits) of the operation result by combining the two results including the previous operation result and the remaining operation after the first operation result calculated in S23. .

S25で、分割する。これは、S24で見つけた2つの演算(演算と他の演算、あるいは前回の中間結果と演算)について、4バイト(CPUが実行できるハードウェア命令のサイズである4バイト)を超えるときに超えないように分割する(既述した図2のS3からS8と同様に分割する)。   In S25, the image is divided. This does not exceed when the two operations (operation and other operations or the previous intermediate result and operation) found in S24 exceed 4 bytes (4 bytes which is the size of the hardware instruction that can be executed by the CPU). (Similar to S3 to S8 in FIG. 2 described above).

S26で、演算を処理する展開を行う。これは、S24で選択した2つ(あるいはS25で分割した後の2つ)の被除数と乗数を演算処理できるように展開を行う(例えば後述する図3の(d)の「2バイト2進*2バイト2進」などのようにハードウェア命令で演算実行できるように展開する)。   In S26, the expansion for processing the calculation is performed. This is expanded so that the two dividends and multipliers selected in S24 (or two after division in S25) can be processed (for example, “2-byte binary * in FIG. 3D described later). It is expanded so that it can be executed by hardware instructions such as “2-byte binary”).

S27で、終わりか判別する。YESの場合には、S28に進む。NOの場合には、S24以降を繰り返す。   In S27, it is determined whether or not the end. If YES, the process proceeds to S28. In the case of NO, S24 and subsequent steps are repeated.

S28で、演算を行う展開を行う。これは、S26でハードウェア命令で演算を行える桁数以下の演算(演算式)に展開したので、当該演算(演算式)をハードウェア命令を使用した形に展開する。   In S28, the expansion for performing the calculation is performed. Since this is expanded to an operation (arithmetic expression) of the number of digits or less that can be performed by a hardware instruction in S26, the operation (arithmetic expression) is expanded into a form using a hardware instruction.

以上の手順によって、ここでは、図3の(a)の多項演算a*b*c*dについて、S22でa*b*c*dの桁数の小さい順に並び変え、1回目は1個目と2個目の演算を行い、以降、前回の演算結果と、残りの演算とのうちの最小の演算結果となる組合せを選択して演算(4バイトを越えるときは分割した後に演算)することを繰り返すことにより、例えば図3の(a)の例では、後述する図3の(c)に示すように、
・1回目:a*b
・2回目:c*d
・3回目:1回目の演算結果e*2回目の演算結果f
というように合計3回の演算(乗算)で実行させるオブジェクトプログラム3を生成することが可能となる。
Through the above procedure, here, the polynomial operation a * b * c * d in FIG. 3A is rearranged in ascending order of the number of digits of a * b * c * d in S22, and the first is the first one. And then the second operation, and then select the combination of the previous operation result and the remaining operation that gives the minimum operation result (if it exceeds 4 bytes, perform the operation after dividing). By repeating the above, for example, in the example of FIG. 3A, as shown in FIG.
・ First time: a * b
・ Second time: c * d
・ 3rd: First calculation result e * Second calculation result f
Thus, it is possible to generate the object program 3 to be executed by a total of three operations (multiplication).

図3の(c)は、図3の(a)の多項演算について、図3の(b)のフローチャートに従い処理した結果を模式的に示す。   FIG. 3C schematically shows the result of processing the polynomial operation of FIG. 3A according to the flowchart of FIG.

・1回目:図3の(a)のa*b(ここで、a,b=2バイト2進)を選択し、これらは4バイト以下であるので、そのまま演算し、中間結果eが4バイトとなる様子を示す。   -First time: a * b (a, b = 2 bytes binary) in FIG. 3A is selected. Since these are 4 bytes or less, the calculation is performed as it is, and the intermediate result e is 4 bytes. It shows how it becomes.

・2回目:図3の(a)のc*d(ここで、c,d=2バイト2進)を選択し、これらは4バイト以下であるので、そのまま演算し、中間結果fが4バイトとなる様子を示す。   Second time: Select c * d (where c, d = 2 bytes binary) in (a) of FIG. 3. Since these are 4 bytes or less, the calculation is performed as it is, and the intermediate result f is 4 bytes. It shows how it becomes.

・3回目:図3の(a)の1回目のa*bの演算結果eと、2回目のc*dの演算結果fとを選択し、これらは4バイト以下であるので、そのまま演算し、中間結果8バイトとなる様子を示す。   -Third time: The first a * b calculation result e and the second c * d calculation result f in FIG. 3A are selected. Since these are four bytes or less, the calculation is performed as it is. The intermediate result is 8 bytes.

図3の(d)は、図3の(c)の演算をハードウェア命令を使用して展開できる状態にした様子を示す。   FIG. 3D shows a state in which the operation of FIG. 3C can be expanded using hardware instructions.

・1回目:図3の(c)の1回目に対応し、a*bに展開した様子を示す。   First time: Corresponding to the first time in (c) of FIG.

・2回目:図3の(c)の2回目に対応し、c*dに展開した様子を示す。   Second time: Corresponding to the second time in (c) of FIG.

・3回目:図3の(C)の3回目に対応し、1回目の演算結果eと、2回目の演算結果fとを演算するように展開した様子を示す。   Third time: Corresponding to the third time in (C) of FIG. 3, a state where the first calculation result e and the second calculation result f are calculated is shown.

図3の(e)は、乗算は合計3回でよい様子を示す。これは、図3の(c),(d)で説明したように、図3の(a)の多項演算は図3の(b)のフローチャートに従えば、合計3回の演算(乗算)という少ない演算回数で実行することが可能となる。   FIG. 3 (e) shows that the multiplication may be three times in total. As described in FIGS. 3C and 3D, the polynomial operation of FIG. 3A is called a total of 3 operations (multiplication) according to the flowchart of FIG. 3B. It can be executed with a small number of operations.

本発明は、ソースプログラムに含まれる多項演算を翻訳する演算処理プログラムにおいて、コンパイル時に多項演算をハードウェア命令に展開する際に、多項演算の桁数の少ない順にソートした後にハードウェア命令に展開したり、中間結果も含めて他の演算の演算結果が最小となる組み合わせから順にハードウェア命令に展開し、多項演算を実行するハードウェア命令数を最小限にして実行速度の向上を図ることが可能となる。   In an arithmetic processing program for translating a polynomial operation included in a source program, when expanding a polynomial operation into a hardware instruction at the time of compilation, the polynomial operation is sorted into a hardware instruction after being sorted in ascending order of digits. In addition, it is possible to expand the hardware instructions in order starting from the combination that minimizes the operation result of other operations including intermediate results, thereby minimizing the number of hardware instructions that execute multinomial operations and improving the execution speed. It becomes.

本発明のシステム構成図である。It is a system configuration diagram of the present invention. 本発明の説明図(その1)である。It is explanatory drawing (the 1) of this invention. 本発明の説明図(その2)である。It is explanatory drawing (the 2) of this invention. 従来技術の説明図である。It is explanatory drawing of a prior art.

符号の説明Explanation of symbols

1:コンパイラ
2:字句解析手段
3:構文解析手段
4:意味解析手段
5:最適化手段
6:分岐最適化手段
7:演算最適化手段
8:演算ソート手段
9:分割手段
10:組合せ選択手段
11:オブジェクト生成手段
2:ソースプログラム
3:オブジェクトプログラム
1: compiler 2: lexical analysis means 3: syntax analysis means 4: semantic analysis means 5: optimization means 6: branch optimization means 7: calculation optimization means 8: calculation sort means 9: division means 10: combination selection means 11 : Object generation means 2: Source program 3: Object program

Claims (5)

ソースプログラムに含まれる多項演算をコンピュータに翻訳させるための演算処理プログラムにおいて、
前記コンピュータに、
ソースプログラムに含まれる多項演算中の多項乗算を桁数の小さい順にソートするステップと、
前記ソートされた多項乗算の先頭から順に演算するハードウェア命令を生成し、該演算が実行される装置のハードウェア命令が演算可能な桁数を超えるときには、超えない範囲の複数の演算に分割してからハードウェア命令を生成するステップと
実行させるための演算処理プログラム。
In an arithmetic processing program for causing a computer to translate a polynomial operation included in a source program,
In the computer,
Sorting the polynomial multiplications in the polynomial operations included in the source program in ascending order of the number of digits;
Generate a hardware instruction that operates in order from the top of the sorted polynomial multiplication , and if the hardware instruction of the device that executes the operation exceeds the number of digits that can be calculated, it is divided into a plurality of operations in a range not exceeding Generating hardware instructions after
Arithmetic processing program for causing a run.
ソースプログラムに含まれる多項演算をコンピュータに翻訳させるための演算処理プログラムにおいて、
前記コンピュータに、
ソースプログラムに含まれる多項演算中の多項乗算から、演算結果の桁数が最も小さくなる組み合わせの2つの演算を選択する選択ステップと、
前記組み合わせの2つを選択した時に、該選択した2つを演算するハードウェア命令を生成し、該演算が実行される装置のハードウェア命令が演算可能な桁数を超えるときには、超えない範囲の複数の演算に分割してからハードウェア命令を生成する生成ステップと、
前記多項演算の全ての項が選択されるまで前記選択ステップと前記生成ステップを順に繰り返すステップと
実行させるための演算処理プログラム。
In an arithmetic processing program for causing a computer to translate a polynomial operation included in a source program,
In the computer,
A selection step for selecting two operations of a combination in which the number of digits of the operation result is the smallest from the multiplicative multiplication in the polynomial operation included in the source program;
When two of the combinations are selected, a hardware instruction that calculates the selected two is generated, and when the hardware instruction of the device on which the calculation is performed exceeds the number of digits that can be calculated, A generation step of generating a hardware instruction after dividing into a plurality of operations;
Repeating the selection step and the generation step in order until all terms of the polynomial operation are selected;
Arithmetic processing program for causing a run.
ソースプログラムに含まれる多項演算を翻訳する演算処理方法において、
コンピュータが、
ソースプログラムに含まれる多項演算中の多項乗算を桁数の小さい順にソートするステップと、
前記ソートされた多項乗算の先頭から順に演算するハードウェア命令を生成し、該演算が実行される装置のハードウェア命令が演算可能な桁数を超えるときには、超えない範囲の複数の演算に分割してからハードウェア命令を生成するステップと
を実行することを特徴とする演算処理方法。
In an arithmetic processing method for translating a multinomial operation included in a source program,
Computer
Sorting the polynomial multiplications in the polynomial operations included in the source program in ascending order of the number of digits;
Generate a hardware instruction that operates in order from the top of the sorted polynomial multiplication , and if the hardware instruction of the device that executes the operation exceeds the number of digits that can be calculated, it is divided into a plurality of operations in a range not exceeding And a step of generating a hardware instruction after that.
ソースプログラムに含まれる多項演算を翻訳する演算処理方法において、
コンピュータが、
ソースプログラムに含まれる多項演算中の多項乗算から、演算結果の桁数が最も小さくなる組み合わせの2つの演算を選択する選択ステップと、
前記組み合わせの2つを選択した時に、該選択した2つを演算するハードウェア命令を生成し、該演算が実行される装置のハードウェア命令が演算可能な桁数を超えるときには、超えない範囲の複数の演算に分割してからハードウェア命令を生成する生成ステップと、
前記多項演算の全ての項が選択されるまで前記選択ステップと前記生成ステップを順に繰り返すステップと
を実行することを特徴とする演算処理方法。
In an arithmetic processing method for translating a polynomial operation included in a source program,
Computer
A selection step for selecting two operations of a combination in which the number of digits of the operation result is the smallest from the multiplicative multiplication in the polynomial operation included in the source program;
When two of the combinations are selected, a hardware instruction that calculates the selected two is generated, and when the hardware instruction of the device on which the calculation is performed exceeds the number of digits that can be calculated, A generation step for generating a hardware instruction after dividing into a plurality of operations;
An operation processing method , comprising: repeating the selection step and the generation step in order until all terms of the polynomial operation are selected .
ソースプログラムに含まれる多項演算を翻訳する演算処理装置において、
ソースプログラムに含まれる多項演算中の多項乗算を桁数の小さい順にソートする手段と、
前記ソートされた多項乗算の先頭から順に演算するハードウェア命令を生成し、該演算が実行される装置のハードウェア命令が演算可能な桁数を超えるときには、超えない範囲の複数の演算に分割してからハードウェア命令を生成する手段と
を備えたことを特徴とする演算処理装置。
In an arithmetic processing device that translates a polynomial operation included in a source program,
Means for sorting the polynomial multiplications in the polynomial operations included in the source program in ascending order of the number of digits;
Generate a hardware instruction that operates in order from the top of the sorted polynomial multiplication , and if the hardware instruction of the device that executes the operation exceeds the number of digits that can be calculated, it is divided into a plurality of operations in a range not exceeding And a means for generating a hardware instruction after that.
JP2003299311A 2003-08-22 2003-08-22 Arithmetic processing program, arithmetic processing method, and arithmetic processing apparatus Expired - Fee Related JP4327533B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003299311A JP4327533B2 (en) 2003-08-22 2003-08-22 Arithmetic processing program, arithmetic processing method, and arithmetic processing apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003299311A JP4327533B2 (en) 2003-08-22 2003-08-22 Arithmetic processing program, arithmetic processing method, and arithmetic processing apparatus

Publications (2)

Publication Number Publication Date
JP2005071056A JP2005071056A (en) 2005-03-17
JP4327533B2 true JP4327533B2 (en) 2009-09-09

Family

ID=34404568

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003299311A Expired - Fee Related JP4327533B2 (en) 2003-08-22 2003-08-22 Arithmetic processing program, arithmetic processing method, and arithmetic processing apparatus

Country Status (1)

Country Link
JP (1) JP4327533B2 (en)

Also Published As

Publication number Publication date
JP2005071056A (en) 2005-03-17

Similar Documents

Publication Publication Date Title
JP3280449B2 (en) Compiling device
JPH10228382A (en) Compiling system
JP2008510230A (en) Method for recognizing acyclic instruction patterns
Kalali et al. Near-precise parameter approximation for multiple multiplications on a single dsp block
JPS6314378B2 (en)
JP4327533B2 (en) Arithmetic processing program, arithmetic processing method, and arithmetic processing apparatus
JP5267243B2 (en) Behavior description conversion apparatus, behavior description conversion method, and program
CN106598839A (en) Program static analysis method oriented to object code
JP3727039B2 (en) Multiplication method in compiler
JPH0764766A (en) Maximum and minimum value calculating method for parallel computer
JP2002041496A (en) Method performed by computer, calculating apparatus and computer program product
JP3233245B2 (en) Language processing method
US5437035A (en) Method and apparatus for compiling a program incending a do-statement
JP2003067195A (en) Optimization compile method and optimization compile device
JP7263994B2 (en) Information processing method and optimization program
JP6897213B2 (en) Code generator, code generator and code generator
JP2748582B2 (en) Compile processing unit
JP2956591B2 (en) Method and apparatus for parallelizing a loop having a conditional jump out of the loop
JPH09160784A (en) Paralleled compiling system
JP2722493B2 (en) Register allocation processing method
JPS63155264A (en) Language tuning processing system for vector computer
JP3327634B2 (en) Program conversion device and program conversion method
JP2019128760A (en) Compiler program, compiling method, and information processing device for compiling
JPS62169272A (en) Unrolling processing system for vector arithmetic string loop
JPH06274351A (en) Optimizing system for compiler

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20051209

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20080430

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20081209

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20090204

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20090407

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20090512

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

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20090609

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20090611

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

Free format text: PAYMENT UNTIL: 20120619

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

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

Free format text: PAYMENT UNTIL: 20120619

Year of fee payment: 3

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

Free format text: PAYMENT UNTIL: 20130619

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20130619

Year of fee payment: 4

LAPS Cancellation because of no payment of annual fees