JP6409639B2 - Compiler program, system, method, and apparatus - Google Patents

Compiler program, system, method, and apparatus Download PDF

Info

Publication number
JP6409639B2
JP6409639B2 JP2015058504A JP2015058504A JP6409639B2 JP 6409639 B2 JP6409639 B2 JP 6409639B2 JP 2015058504 A JP2015058504 A JP 2015058504A JP 2015058504 A JP2015058504 A JP 2015058504A JP 6409639 B2 JP6409639 B2 JP 6409639B2
Authority
JP
Japan
Prior art keywords
optimization
mark
program
unit
compiler
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.)
Active
Application number
JP2015058504A
Other languages
Japanese (ja)
Other versions
JP2016177652A (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 JP2015058504A priority Critical patent/JP6409639B2/en
Publication of JP2016177652A publication Critical patent/JP2016177652A/en
Application granted granted Critical
Publication of JP6409639B2 publication Critical patent/JP6409639B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Devices For Executing Special Programs (AREA)

Description

開示する技術は、コンパイラプログラム、コンパイラシステム、コンパイラ方法、及びコンパイラ装置に関する。   The disclosed technology relates to a compiler program, a compiler system, a compiler method, and a compiler apparatus.

従来、高級言語で記述された原始プログラム(ソースプログラム)を、機械語プログラム(目的プログラム)に翻訳するためのコンパイラに、目的プログラムの実行時の効率を高めるための最適化機能を持たせる技術が存在する。   Conventionally, a compiler that translates a source program (source program) written in a high-level language into a machine language program (target program) has a technology to provide an optimization function to increase the efficiency at the time of execution of the target program. Exists.

例えば、コンパイラにおける命令式を木構造に変換し、当該木構造を構成する項を優先順位の高い方から順にサーチして中間結果の項に当該中間結果の演算精度を保障する最低のビットを設定する。そして、最低のビット数を設定された木構造を構成する項を優先順位の低い方から順にサーチして中間結果のうち、代入元の演算精度が代入先の演算精度を超えている場合のみ代入元の演算精度を代入先の演算精度に置き換えることを用いて式解析を行う方法がある。   For example, convert the instruction expression in the compiler to a tree structure, search the terms that make up the tree structure in descending order of priority, and set the lowest bit that guarantees the accuracy of the intermediate result in the intermediate result term To do. Then, search for the terms that make up the tree structure with the lowest number of bits set, starting from the lowest priority, and assign only if the calculation accuracy of the assignment source exceeds the calculation accuracy of the assignment destination. There is a method of performing expression analysis by replacing the original calculation accuracy with the calculation accuracy of the assignment destination.

また、まず、除算以外の最適化の前に、中間形式での命令の種類毎の割合を調べ、除算が性能のボトルネックとなるかどうか判断する。そして、除算が性能のボトルネックとなる場合は、依存関係のない複数の除算を、除数の積の逆数を計算し、除算の商を逆数と被逆数と被除数に対応する除数以外の全ての除数の積として求める方法がある。   First, prior to optimization other than division, the ratio of each type of instruction in the intermediate format is examined to determine whether division is a performance bottleneck. If division is a bottleneck for performance, calculate the reciprocal of the product of the divisors for multiple divisions that do not depend on each other, and use the quotient for all the divisors other than the divisor corresponding to the reciprocal, reciprocal, and dividend There is a method to find it as the product of

また、数値計算プログラムを中間言語に変換し、精度落ちを生じる箇所を検出して当該部分を精度落ちの防止を行ったものに変換する方法がある。   Further, there is a method of converting a numerical calculation program into an intermediate language, detecting a portion where a loss of accuracy is detected, and converting the portion into one in which a loss of accuracy has been prevented.

特開昭63−173132号公報JP 63-173132 A 特開2000−181722号公報JP 2000-181722 A 特開平4−112229号公報Japanese Patent Laid-Open No. 4-112229

1つの側面では、開示する技術は、入力値の精度に敏感な演算の精度を落とさずにプログラムの他の部分の演算を高速化する。   In one aspect, the disclosed technology speeds up operations in other parts of the program without reducing the accuracy of operations that are sensitive to the accuracy of the input values.

一つの態様として、開示の技術は、コンパイルの対象となる第1プログラムに含まれる複数の演算の各々を表す複数の構造体と、前記複数の演算間のデータの入出力の関係を表すデータ依存関係とを取得する。また、前記取得された構造体の各々について、前記取得された前記構造体によって表わされる前記演算が、入力値の精度に応じて出力結果が特定の影響を受ける演算である場合に前記構造体に印を付加する。また、前記取得されたデータ依存関係に基づいて、前記印が付加された前記構造体によって表わされる演算に対して特定のデータ依存関係を有する演算を表す構造体に他の印を付加する。また、前記印が付加されていない構造体のうち、最適化の対象となる構造体に対して前記最適化を実施する。なお、最適化は、前記第1プログラムに対して前記コンパイルを施すことによって取得予定の第2プログラムの実行が特定の条件下で異なる結果を生成する演算の内容に置き換える最適化であるものとする。   As one aspect, the disclosed technique is a data dependency that represents a plurality of structures representing each of a plurality of operations included in the first program to be compiled, and a data input / output relationship between the plurality of operations. Get relationships and. In addition, for each of the acquired structures, the operation represented by the acquired structure is an operation whose output result has a specific influence depending on the accuracy of the input value. Add a mark. Further, another mark is added to the structure representing an operation having a specific data dependency with respect to the operation represented by the structure to which the mark is added based on the acquired data dependency. In addition, the optimization is performed on the structure to be optimized among the structures to which the mark is not added. The optimization is an optimization in which the execution of the second program scheduled to be acquired by performing the compilation on the first program is replaced with the content of an operation that generates a different result under a specific condition. .

一つの側面として、入力値の精度に敏感な演算の精度を落とさずにプログラムの他の部分の演算を高速化する、という効果を有する。   As one aspect, it has the effect of speeding up operations in other parts of the program without degrading the accuracy of operations sensitive to the accuracy of input values.

コンパイラの処理の流れの例を示した図である。It is the figure which showed the example of the flow of a process of a compiler. 構文木の例を示した図である。It is the figure which showed the example of a syntax tree. 浮動小数点除算に対するテンプレート例を示す図である。It is a figure which shows the example template with respect to floating point division. テンプレートの組み合わせによる命令作成の例を示す図である。It is a figure which shows the example of the command preparation by the combination of a template. 浮動小数点の整数への型変換のテンプレートを示す図である。It is a figure which shows the template of the type conversion to the integer of a floating point. 複数のノードを含む単一のテンプレートによる命令作成の例を示す図である。It is a figure which shows the example of the instruction preparation by the single template containing a some node. テンプレートでは対応できない例を示す図である。It is a figure which shows the example which cannot respond with a template. load/store命令を介したデータ依存の可能性がある場合の例を示す図である。It is a figure which shows an example in case there exists a possibility of data dependence via a load / store instruction. 従来のデータ構造体の例を示す図である。It is a figure which shows the example of the conventional data structure. 本実施形態において用いるデータ構造体の例を示す図である。It is a figure which shows the example of the data structure used in this embodiment. ノードに印を付加した例を示す図である。It is a figure which shows the example which added the mark to the node. 第1の実施形態に係るコンパイラ装置を含むシステム構成を示す概略図である。1 is a schematic diagram showing a system configuration including a compiler apparatus according to a first embodiment. 第1の実施形態に係るコンパイラ装置の機能ブロック図である。It is a functional block diagram of the compiler apparatus which concerns on 1st Embodiment. 記録表の例を示す図である。It is a figure which shows the example of a recording table. 第1の実施形態に係るコンパイラ装置として機能するコンピュータの概略構成を示すブロック図である。1 is a block diagram illustrating a schematic configuration of a computer that functions as a compiler apparatus according to a first embodiment. FIG. 第1の実施形態に係るコンパイル処理の一例を示すフローチャートである。It is a flowchart which shows an example of the compilation process which concerns on 1st Embodiment. 第1の実施形態に係る最適化処理の一例を示すフローチャートである。It is a flowchart which shows an example of the optimization process which concerns on 1st Embodiment. 第1の実施形態に係る構文木の探索と印の付加処理の一例を示すフローチャートである。It is a flowchart which shows an example of the search of a syntax tree and the addition process of a mark concerning 1st Embodiment. 第1の実施形態に係る構文木の探索処理の一例を示すフローチャートである。It is a flowchart which shows an example of the search process of the syntax tree which concerns on 1st Embodiment. 第1の実施形態に係る構文木の再探索処理の一例を示すフローチャートである。It is a flowchart which shows an example of the re-search process of the syntax tree which concerns on 1st Embodiment. 第1の実施形態に係る命令・選択生成処理の一例を示すフローチャートである。It is a flowchart which shows an example of the command and selection production | generation process which concerns on 1st Embodiment. ソースプログラムの一例を示す図である。It is a figure which shows an example of a source program. 構文木の例を示す図である。It is a figure which shows the example of a syntax tree. 構文木の例を示す図である。It is a figure which shows the example of a syntax tree. 根ノードの選択の例を示す図である。It is a figure which shows the example of selection of a root node. 入力値の精度に敏感な演算に対応するノードに印を付加する例を示す図である。It is a figure which shows the example which adds a mark to the node corresponding to the calculation sensitive to the precision of an input value. 親ノードに印が付加されている場合のノードに印を付加する例を示す図である。It is a figure which shows the example which adds a mark to a node in case the mark is added to the parent node. 構文木の葉まで印が伝播した例を示す図である。It is a figure which shows the example which the mark propagated to the leaf of the syntax tree. ノードに印がついている構文木の命令生成の例を示す図である。It is a figure which shows the example of the instruction | indication production | generation of the syntax tree in which the node is marked. 根ノードを選択の例を示す図である。It is a figure which shows the example of selection of a root node. 探索の例を示す図である。It is a figure which shows the example of a search. 探索の例を示す図である。It is a figure which shows the example of a search. 探索の例を示す図である。It is a figure which shows the example of a search. ノードに印が付加されていない構文木について命令生成を行った例を示す図である。It is a figure which shows the example which performed the instruction | indication about the syntax tree where the mark is not added to the node. ソースプログラムの例を示す図である。It is a figure which shows the example of a source program. load命令及びstore命令を含む構文木の例を示す図である。It is a figure which shows the example of the syntax tree containing the load command and the store command. 構文木の再探索前の状態を表す例を示す図である。It is a figure which shows the example showing the state before re-searching of a syntax tree. store命令とload命令の指し示すアドレスが一致する可能性がある場合におけるノードに印を付加する例を示す図である。It is a figure which shows the example which adds a mark to a node in case there exists a possibility that the address which a store instruction and a load instruction point is in agreement. 再探索の結果の例を示す図である。It is a figure which shows the example of the result of a re-search. store命令及びload命令を含む構文木の命令生成の例を示す図である。It is a figure which shows the example of the instruction | indication production | generation of a syntax tree containing a store instruction and a load instruction. 最適化記録表の例を示す図である。It is a figure which shows the example of an optimization recording table. 第2の実施形態に係るコンパイラ装置の機能ブロック図である。It is a functional block diagram of the compiler apparatus which concerns on 2nd Embodiment. 第2の実施形態に係るコンパイラ装置として機能するコンピュータの概略構成を示すブロック図である。It is a block diagram which shows schematic structure of the computer which functions as a compiler apparatus which concerns on 2nd Embodiment. 第2の実施形態に係るコンパイル処理の一例を示すフローチャートである。It is a flowchart which shows an example of the compilation process which concerns on 2nd Embodiment. 第2の実施形態に係る引数解析処理の一例を示すフローチャートである。It is a flowchart which shows an example of the argument analysis process which concerns on 2nd Embodiment. 第2の実施形態に係る最適化処理の一例を示すフローチャートである。It is a flowchart which shows an example of the optimization process which concerns on 2nd Embodiment. 指定処理記録表の一例を示す図である。It is a figure which shows an example of a designation | designated process recording table. 第3の実施形態に係るコンパイラ装置の機能ブロック図である。It is a functional block diagram of the compiler apparatus which concerns on 3rd Embodiment. 第3の実施形態に係るコンパイラ装置として機能するコンピュータの概略構成を示すブロック図である。It is a block diagram which shows schematic structure of the computer which functions as a compiler apparatus which concerns on 3rd Embodiment. 第3の実施形態に係るコンパイル処理の一例を示すフローチャートであるIt is a flowchart which shows an example of the compilation process which concerns on 3rd Embodiment. 第3の実施形態に係る引数解析処理の一例を示すフローチャートである。It is a flowchart which shows an example of the argument analysis process which concerns on 3rd Embodiment. 第3の実施形態に係る最適化処理の一例を示すフローチャートである。It is a flowchart which shows an example of the optimization process which concerns on 3rd Embodiment. 第3の実施形態に係る構文木の探索と印の付加処理の一例を示すフローチャートである。14 is a flowchart illustrating an example of syntax tree search and mark addition processing according to the third embodiment. 第3の実施形態に係る構文木の探索処理の一例を示すフローチャートである。It is a flowchart which shows an example of the search process of the syntax tree which concerns on 3rd Embodiment.

以下、開示する技術に係る実施形態について説明する。   Hereinafter, embodiments according to the disclosed technology will be described.

まず、実施形態の詳細を説明する前に、後述する各実施形態により提供されるシステムにおいて前提となるコンパイラと最適化について説明する。   First, before explaining the details of the embodiment, a compiler and optimization which are prerequisites in a system provided by each embodiment described later will be explained.

コンパイラとは、図1に示すように、高級プログラム言語で記載された原始プログラム(以後、ソースプログラムとする。)を、機械語プログラム(以後、目的プログラムとする。)に翻訳するためのプログラムである。   As shown in FIG. 1, a compiler is a program for translating a source program (hereinafter referred to as a source program) written in a high-level program language into a machine language program (hereinafter referred to as a target program). is there.

コンパイラの動作は、一般的に、引数解析処理、字句・構文解析処理、最適化処理、命令選択・生成処理、及び機械語出力処理となる。   The operations of the compiler are generally argument analysis processing, lexical / syntax analysis processing, optimization processing, instruction selection / generation processing, and machine language output processing.

ここで、引数解析処理は、コンパイラの起動時に渡されたファイル名指定、オプションを解析し、コンパイラの動作を決定する。   Here, the argument analysis processing analyzes the file name specification and options passed when the compiler is started, and determines the operation of the compiler.

また、字句・構文解析処理は、ソースプログラムを読み取り、ソースプログラムに記述されている処理をコンパイラ内で用いられる中間言語に変換する。   In the lexical / syntactic analysis process, the source program is read, and the process described in the source program is converted into an intermediate language used in the compiler.

ここで、現在多くのコンパイラでは、ソースプログラムを直接目的プログラムに変換するのではなく、ソースプログラムを一旦コンパイラ内部で中間的な表現に変換し、さらに、その中間的な表現を目的プログラムに変換するという方法がとられている。この中間的な表現のことを中間言語という。   Here, in many compilers, instead of directly converting the source program into the target program, the source program is once converted into an intermediate representation inside the compiler, and then the intermediate representation is converted into the target program. The method is taken. This intermediate expression is called an intermediate language.

中間言語を用いることの利点は、ソースプログラムが持つ制御構造やデータ構造・命令間の依存関係などを計算機が扱いやすい形式で表現することにある。中間言語には、何種類もの形式が存在し、1つのコンパイラが複数の形式を用いることも可能であるが、後述する各実施形態においては、中間言語として構文木形式を用いる。なお、中間言語として3番地文形式、4番地文形式等、他の表現方法を用いてもよい。   The advantage of using an intermediate language is that the control structure, data structure, and dependency between instructions of the source program are expressed in a format that is easy for a computer to handle. There are various types of intermediate languages, and a single compiler can use a plurality of formats. In each embodiment described later, a syntax tree format is used as an intermediate language. In addition, you may use other expression methods, such as 3 address sentence format and 4 address sentence format, as an intermediate language.

また、構文木は、ソースプログラムに含まれるデータ、演算などを表すノードと、ノード間の依存関係を表すアークとを含む。単純な演算「c= a / b 」を表すソースプログラムを構文木に変換した一例を図2に示す。ここで、入力のないノードを「葉」、出力のないノードを「根」と呼ぶ。あるノードAとノードBとがアークでつながっており、ノードBがノードAの出力を入力とする場合、ノードBをノードAの「親」と呼び、ノードAをノードBの「子」と呼ぶ。このノード間の親子関係が、ノード間の依存関係の一例である。なお、構文木以外の他の形式の中間言語にも、データ、演算などを表す構成要素間の親子関係、又は、上流と下流との関係を表す依存関係が含まれる。そのため、他の形式の中間言語を用いても、後述するコンパイラにおける処理を、構文木を用いた場合と同様に処理をすることができる。   The syntax tree includes nodes representing data, operations, etc. included in the source program, and arcs representing dependency relationships between the nodes. An example in which a source program representing a simple operation “c = a / b” is converted into a syntax tree is shown in FIG. Here, a node without input is called “leaf”, and a node without output is called “root”. When a node A and a node B are connected by an arc and the node B receives the output of the node A, the node B is called a “parent” of the node A and the node A is called a “child” of the node B. . This parent-child relationship between nodes is an example of a dependency relationship between nodes. Note that intermediate languages other than syntax trees also include parent-child relationships between components representing data, operations, etc., or dependency relationships representing upstream and downstream relationships. For this reason, even if an intermediate language of another format is used, the processing in the compiler described later can be performed in the same manner as when a syntax tree is used.

また、最適化処理は、目的プログラムの実行時の効率を高めるための中間言語を変換する処理である。一般的なコンパイラは、多くの最適化機能を有し、最適化機能は、例えば以下の3種類に分類することができる。具体的には、制御解析・データ解析と、通常の最適化と、積極的な最適化とである。なお、3種類の最適化の実施順は、順不同であり、また、必要に応じて1つの最適化を複数回繰り返すことがある。   The optimization process is a process of converting an intermediate language for improving the efficiency at the time of executing the target program. A general compiler has many optimization functions, and the optimization functions can be classified into the following three types, for example. Specifically, control analysis / data analysis, normal optimization, and aggressive optimization. Note that the order of execution of the three types of optimization is out of order, and one optimization may be repeated a plurality of times as necessary.

ここで、制御解析・データ解析とは、プログラムの制御の流れ及びデータの解析であるが、この解析自体は最適化ではなく、制御解析・データ解析によって、最適化の実施に必要な情報が提供される。制御解析・データ解析には、複数のポインタ変数が指すメモリアドレスが同じものかどうかの解析も含まれる。   Here, the control analysis / data analysis is a program control flow and data analysis, but this analysis itself is not an optimization, and the control analysis / data analysis provides information necessary for the implementation of the optimization. Is done. The control analysis / data analysis includes analysis of whether or not the memory addresses pointed to by a plurality of pointer variables are the same.

また、通常の最適化は、ソースプログラムから得られた中間言語をその意味するところを変えないよう、より効率の良い中間言語に変換する処理である。なお、通常の最適化は、必ず実施する処理ではない。通常の最適化の実施の可否は通常の最適化を実施するオプションが指定されたか否かによって決まる。   The normal optimization is a process of converting the intermediate language obtained from the source program into a more efficient intermediate language so as not to change the meaning of the intermediate language. Note that normal optimization is not necessarily performed. Whether or not normal optimization can be performed depends on whether or not an option for performing normal optimization is specified.

また、積極的な最適化は、最適化の一種であり、詳細は後述する。積極的な最適化の実施の可否は積極的な最適化を実施するオプションが指定されたか否かによって決まる。なお、積極的な最適化は、第1プログラムに対してコンパイルを施すことによって取得予定の第2プログラムの実行が特定の条件下で異なる結果を生成する演算の内容に置き換える最適化の一例である。   Active optimization is a kind of optimization, and details will be described later. Whether or not to perform aggressive optimization depends on whether or not an option for aggressive optimization is specified. Note that aggressive optimization is an example of optimization in which the execution of the second program to be acquired is compiled with the contents of an operation that generates different results under a specific condition by compiling the first program. .

また、命令選択・生成処理は、中間言語を、対応する目的プログラムの機械語命令に変換する処理である。機械語命令への変換には、テンプレートと呼ばれる、単独あるいは複数の中間言語命令を目的プログラムの機械語命令と紐付けるためのルールを用いる。   The instruction selection / generation process is a process for converting the intermediate language into a machine language instruction of the corresponding target program. For conversion to machine language instructions, a rule called a template for associating one or more intermediate language instructions with machine language instructions of the target program is used.

なお、命令選択は最適化と独立した処理ではない。命令選択の方法を複数個用意し、最適化レベル(最適化をまったく実施しない場合、通常の最適化のみを実施する場合、積極的な最適化も実施する場合)に応じて、そのうちの1つを選択させることができる。もちろん、最適化を実施するかしないかに関わらず、同じ命令を選択しても良い。   Note that instruction selection is not a process independent of optimization. Prepare multiple instruction selection methods, and select one of them depending on the optimization level (when optimization is not performed at all, only normal optimization is performed, or aggressive optimization is also performed). Can be selected. Of course, the same instruction may be selected regardless of whether or not optimization is performed.

また、機械語出力処理は、目的プログラムを出力する処理である。   The machine language output process is a process for outputting a target program.

コンパイラの重要な機能の1つに上述した最適化がある。近年のコンパイラでは、最適化の一種である「積極的な最適化」を備えているものが多い。積極的な最適化とは、ソースプログラムを解析しただけでは得ることができない特定の条件を仮定することにより達成することができる、通常の最適化より効率の良い最適化である。また、積極的な最適化は、目的プログラムでの演算の実行が特定の条件下で異なる結果を生成する演算の内容に置き換える最適化処理ともいえる。この点について、詳細に説明する。   One of the important functions of the compiler is the optimization described above. In recent years, many compilers have “aggressive optimization” which is a kind of optimization. Aggressive optimization is optimization that is more efficient than normal optimization that can be achieved by assuming specific conditions that cannot be obtained simply by analyzing a source program. In addition, active optimization can be said to be optimization processing in which execution of an operation in the target program is replaced with the content of an operation that generates a different result under a specific condition. This point will be described in detail.

科学技術の分野で用いられるプログラムでは、数値を浮動小数点で表現して演算することが一般的である。浮動小数点数の演算については、IEEE754と呼ばれる標準規格がある。当該標準規格は、データの形式(基本形式、交換形式)、演算の種類、誤差の丸めの規則、又は例外処理の事柄に対して定められている。   In a program used in the field of science and technology, a numerical value is generally expressed by a floating point and operated. There is a standard called IEEE754 for the calculation of floating point numbers. The standard is defined for the data format (basic format, exchange format), operation type, error rounding rules, or exception handling matters.

例えば、上記のようなIEEE754に準拠した浮動小数点演算に対する積極的な最適化として、IEEE754への準拠度合いを緩めることによる大幅な高速化を可能とする最適化がある。   For example, as an aggressive optimization for floating point arithmetic conforming to the above-mentioned IEEE754, there is an optimization that enables a significant speedup by loosening the degree of conformance to IEEE754.

次に、上記の浮動小数点演算に対する積極的な最適化について2つの例について考えてみる。   Next, consider two examples of aggressive optimization for the above floating point operations.

1つめの積極的な最適化の例を、「変数xと定数1.0との乗算をxそのものと置き換えることで乗算を省略する」とする。この場合、演算の対象が特定の値以外の場合、当該積極的な最適化を実施した場合と実施しない場合とでは同じ結果を返すが、特定の値では、結果が異なることがある。例えば、xがIEEE754で正規化して表現できる範囲を超えた値であれば、乗算の実行結果は、元のxの値と異なることがあるが、最適化を適用した結果として乗算が省略されれば、式の値としてxがそのまま使われる。   The first example of aggressive optimization is “omitting multiplication by replacing variable x with constant 1.0 by x itself”. In this case, when the calculation target is other than a specific value, the same result is returned depending on whether or not the aggressive optimization is performed, but the result may be different depending on the specific value. For example, if x is a value that exceeds the range that can be expressed by normalizing with IEEE754, the execution result of the multiplication may be different from the original value of x, but the multiplication is omitted as a result of applying the optimization. For example, x is used as the value of the expression.

2つめの積極的な最適化の例を、「浮動小数点除算y/xを、yを直接xで除算するのではなく、xの逆数とyとの乗算に置き換えることで、計算時間の短縮やスループットの向上を図る」とする。これは、ハードウェアの設計によっては、除算命令1個より逆数演算と乗算との組み合わせの方が計算時間やスループットが短縮されることがありうるという理由に基づくものである。当該例は、逆数を求める演算を支援するハードウェアを備えた計算機において実行されるものとする。逆数を求める演算のハードウェア的な支援については、従来技術を用いる。図3に例を示す。   A second example of aggressive optimization is: “Floating-point division y / x is not directly divided by x, but replaced by multiplication of the reciprocal of x and y to reduce computation time. "Improve throughput". This is based on the reason that, depending on the hardware design, the combination of the reciprocal operation and the multiplication may reduce the calculation time and the throughput than one division instruction. This example is assumed to be executed in a computer equipped with hardware that supports an operation for obtaining an inverse number. The conventional technology is used for hardware support of the calculation for obtaining the reciprocal. An example is shown in FIG.

図3の例においては、最適化を行わない場合、または通常の最適化を実施する場合には、図3に示す構文木を変形せずに、そのまま対応するテンプレート「fdiv %a,%b,%c」を用いて目的プログラムを生成する。一方、積極的な最適化を実施する場合には、図3に示す構文木を、まず、bのノードをbの逆数を求める構造に変形し、当該bの逆数を求めた結果とaの積によりcを算出する構造になるように構文木を変形する。そして、変形した構文木に対応するテンプレート「reciprocal %b,%t及びfmul %t,%a,%c」を用いて目的プログラムを生成する。   In the example of FIG. 3, when optimization is not performed or when normal optimization is performed, the corresponding template “fdiv% a,% b, Generate target program using "% c". On the other hand, when aggressive optimization is performed, the syntax tree shown in FIG. 3 is first transformed into a structure for obtaining the reciprocal of b by transforming the node of b into the structure of obtaining the reciprocal of b and the product of a. The syntax tree is transformed to have a structure for calculating c. Then, a target program is generated using the templates “reciprocal% b,% t and fmul% t,% a,% c” corresponding to the modified syntax tree.

この場合、除算命令を直接用いて除算を求めた場合と、除数の逆数を求めてから、被除数と除数の逆数との乗算で求めた場合とでは、理論上は同じ結果となる。しかし、与えられたデータの値によっては、計算値をIEEE754が定めた形式に正規化したときの誤差により、異なる結果となる場合がある。   In this case, theoretically, the same result is obtained when the division is obtained by directly using the division instruction and when the reciprocal of the divisor is obtained and then obtained by multiplying the dividend and the reciprocal of the divisor. However, depending on the value of the given data, different results may be obtained due to an error when the calculated value is normalized to the format defined by IEEE754.

上記2つの例のように、演算対象が特定の値でないと仮定すれば、最適化を実施した場合と、実施しない場合とで結果は変わらないが、演算対象が特定の値以外の値かどうかはソースプログラムを解析しただけではわからない。そのため、上記2つの最適化は、積極的な最適化といえる。   As in the above two examples, assuming that the operation target is not a specific value, the result does not change between when optimization is performed and when it is not performed, but whether the operation target is a value other than a specific value. Does not know just by analyzing the source program. Therefore, the above two optimizations can be said to be aggressive optimizations.

積極的な最適化で生じる誤差の影響は、殆どの場合には無視しても差し支えない。しかし、入力値の精度に敏感な演算(入力値の精度に応じて出力結果が影響を受ける演算)の入力値として、積極的な最適化が実施された結果が使われた場合、プログラムの実行結果に想定外の影響を及ぼすことがある。そのため、入力値の精度に敏感な演算に対する入力値を出力する演算に対して、積極的な最適化を抑止する必要がある。   In most cases, the effects of errors resulting from aggressive optimization can be ignored. However, if the result of aggressive optimization is used as the input value for an operation that is sensitive to the accuracy of the input value (the operation that affects the output result depending on the accuracy of the input value), the program is executed. Results may be affected unexpectedly. For this reason, it is necessary to suppress aggressive optimization for an operation that outputs an input value for an operation that is sensitive to the accuracy of the input value.

ここで、入力値の精度に敏感な演算の例を示す。1つ目の例として、「浮動小数点数の整数への変換」について説明する。   Here, an example of calculation sensitive to the accuracy of the input value is shown. As a first example, “conversion of floating point number to integer” will be described.

浮動小数点数を、小数点以下を切り捨てて整数に変換する場合、例えば、元のデータの値が、「1.0000000000000000」であるとすると結果の値が1となるが、元の値が、「0.9999999999999999」であるとすると結果の値が0となる。   When converting a floating-point number to an integer by rounding down the decimal point, for example, if the value of the original data is “1.0000000000000000”, the result value is 1, but the original value is “0.9999999999999999” If there is, the result value is zero.

次に、2つ目の例として「浮動小数点数同士の比較による分岐」について説明する。   Next, “branch by comparison between floating point numbers” will be described as a second example.

2つの浮動小数点数の大小、又は一致/不一致の比較によって、その後の実行する命令を変える比較分岐命令の場合について考える。この場合、例えば、2つの値が「1.0」と「1.0000000000000001」であった場合と「1.0」と「0.9999999999999999」であった場合では、大小の比較結果が逆になるので、その後のプログラムの挙動がまったく異なることがあり得る。   Consider the case of a comparison branch instruction that changes the instruction to be executed later by comparing two floating-point numbers, or a match / mismatch comparison. In this case, for example, when the two values are “1.0” and “1.0000000000000001”, and when they are “1.0” and “0.9999999999999999”, the comparison result of magnitude is reversed, so the behavior of the program after that is It can be quite different.

上述の通り、積極的な最適化は、その性質上、入力値の精度に敏感な演算と組み合わせて用いることが困難な場合がある。これに対し、積極的な最適化の抑止方法として、下記(1)、(2)、及び(3)のような3つの抑止方法が考えられる。   As described above, aggressive optimization may be difficult to use in combination with operations sensitive to the accuracy of input values due to its nature. On the other hand, the following three suppression methods such as (1), (2), and (3) are conceivable as positive optimization suppression methods.

(1)積極的な最適化のファイル単位での完全な抑止
(2)ユーザによるソースプログラムの修正
(3)コンパイラによる自動判別を用いた一部の積極的な最適化の抑止
(1) Complete suppression of aggressive optimization in file units (2) Modification of source program by user (3) Partial suppression of aggressive optimization using automatic discrimination by compiler

上記(1)の方法は、プログラムを最適化するかどうか、また、どの程度まで最適化するかのレベルを、コンパイラを起動するときにユーザが与えるオプションで指定する方法である。この指定を行うことにより、積極的な最適化の実施を完全に抑止することができる。   The method (1) is a method of specifying whether to optimize a program and to what extent the program is optimized by an option given by the user when starting the compiler. By performing this designation, it is possible to completely prevent aggressive optimization.

上記(2)の方法は、ユーザがソースプログラム上に最適化に関するプラグマ指定を挿入する方法である。ここで、プラグマ指定とは、プログラムの翻訳方法をソースプログラムの行単位やブロックなどを単位として制御する方法である。プラグマ指定をソースプログラムの精度に敏感な演算への入力を生成している演算が記載された箇所に対して記述することで積極的な最適化を抑止したい部分を指定し、積極的な最適化を抑止することができる。   The method (2) is a method in which the user inserts a pragma specification related to optimization on the source program. Here, pragma designation is a method of controlling the program translation method in units of lines or blocks of the source program. Specify the part where you want to suppress aggressive optimization by writing the pragma specification to the place where the operation generating the input to the operation sensitive to the accuracy of the source program is described, and aggressive optimization Can be suppressed.

上記(3)の方法は、コンパイラの命令選択処理において、1つの中間言語のノードではなく、複数の中間言語のノードの連鎖に対して、目的プログラムの命令の並びを対応させる方法である。当該方法を用いることにより、積極的な最適化の結果を入力値の精度に敏感な演算が用いる場合に、2つの連鎖した中間言語のノードを含めた目的プログラムの生成を指定することができる。   The method (3) is a method in which the instruction sequence of the target program is associated with a chain of a plurality of intermediate language nodes instead of one intermediate language node in the compiler instruction selection process. By using this method, when an operation that is sensitive to the accuracy of the input value is used as the result of aggressive optimization, it is possible to specify generation of a target program including two intermediate language nodes.

次に、上記(3)の方法について例を挙げて詳細に説明する。   Next, the method (3) will be described in detail with an example.

例として、図4に示す「数式 ii=(int64_t)(aa/xx);」のような浮動小数点除算の結果を整数へと型変換する処理を表す中間言語から目的プログラムを得る場合を考える。この場合、単独の浮動小数点除算を表すテンプレートと、単独の型変換を表すテンプレートとの組み合わせで実現することができる。   As an example, let us consider a case where an object program is obtained from an intermediate language representing a process of converting a floating-point division result into an integer such as “Formula ii = (int64_t) (aa / xx);” shown in FIG. In this case, it can be realized by a combination of a template representing a single floating-point division and a template representing a single type conversion.

まず、浮動小数点除算の目的プログラムへの変換が積極的な最適化を実施する場合と、積極的な最適化を行わない場合との2通り考えられるとする。この場合、図3に示すように、最適化レベル別に、2つのテンプレートを用意する。1つは、積極的な最適化を実施した構文木に適用して目的プログラムへ変換するためのテンプレートであり、もう1つは、積極的な最適化を実施していない構文木に適用して目的プログラムへ変換するためのテンプレートである。また、型変換に関しては、図5のように、最適化レベルによらず1通りだけ用意することにする。当該例において、「数式 ii=(int64_t)(aa/xx);」の中間言語に対して、図4に示すように、図3に示す積極的な最適化を実施する場合、または実施しない場合のテンプレートと、図5に示すテンプレートとを組み合わせて適用することができる。   First, suppose that there are two ways to convert the floating-point division into the target program: a case where aggressive optimization is performed and a case where aggressive optimization is not performed. In this case, as shown in FIG. 3, two templates are prepared for each optimization level. One is a template that is applied to a syntax tree that has been aggressively optimized and converted into a target program, and the other is a template that is applied to a syntax tree that has not been aggressively optimized. This is a template for conversion to the target program. As for type conversion, only one type is prepared regardless of the optimization level as shown in FIG. In this example, when the aggressive optimization shown in FIG. 3 is performed or not performed as shown in FIG. 4 for the intermediate language of “Formula ii = (int64_t) (aa / xx);” These templates and the template shown in FIG. 5 can be applied in combination.

なお、図4に示す構文木は、積極的な最適化を実施していない構文木の例を示しているが、積極的な最適化を実施する場合には、積極的な最適化により変換された構文木に対して、積極的な最適化を実施する場合のテンプレートが適用される。   The syntax tree shown in FIG. 4 shows an example of a syntax tree that has not been aggressively optimized. However, when aggressive optimization is performed, the syntax tree is converted by aggressive optimization. A template for aggressive optimization is applied to the syntax tree.

この方法の場合、最適化レベルを積極的な最適化を実施すると指定すると、誤差を生じる可能性のある逆数との乗算による除算演算の結果を浮動小数点数の整数への変換の入力として用いるため、プログラムの実行結果に想定外の影響を及ぼす可能性がある。   In this method, if the optimization level is specified as aggressive optimization, the result of the division operation by multiplication with the reciprocal that may cause an error is used as the input to convert the floating-point number to an integer. There is a possibility of unexpected influence on the execution result of the program.

当該問題に対して、上記(3)の方法は、除算とその結果を利用する型変換命令との各々に対する2つのテンプレートを組み合わせて、積極的な最適化を実施する場合のテンプレートを用意する。また、当該テンプレートとは別に、図6のように、除算とその結果を利用する型変換命令との両方を含むパターンの構文木に対して、全ての最適化レベルで構文木に適用して目的プログラムへ変換するためのテンプレートを用意する。   In response to the problem, the method (3) above prepares a template for performing aggressive optimization by combining two templates for each of the division and the type conversion instruction using the result. In addition to the template, as shown in FIG. 6, a pattern syntax tree including both division and a type conversion instruction using the result is applied to the syntax tree at all optimization levels. Prepare a template to convert to a program.

ここで、目的プログラムの生成において複数の最適化レベル毎のテンプレートが適応できる場合(複数の最適化レベルが実施できる場合)について考える。この場合、テンプレートの優先順位を定めておくことで、最適化レベルが決定されるようにする。例えば、図3、及び図5のテンプレートよりも、図6のテンプレートが優先して選ばれるように設定しておく。このようにすることにより、型変換命令が後続する除算命令に対し、最適化を実施しない、又は通常の最適化が実施され、図6のテンプレートを適用する。よって、積極的な最適化の実施を抑止することができる。   Here, consider a case where a template for each of a plurality of optimization levels can be applied in the generation of the target program (a case where a plurality of optimization levels can be implemented). In this case, the optimization level is determined by determining the priority order of the templates. For example, it is set so that the template in FIG. 6 is selected with priority over the templates in FIGS. In this way, optimization is not performed on the division instruction followed by the type conversion instruction, or normal optimization is performed, and the template of FIG. 6 is applied. Therefore, aggressive optimization can be suppressed.

しかし、上記(1)〜(3)の方法に対しては、各々下記のような課題がある。   However, each of the methods (1) to (3) has the following problems.

上記(1)の方法に対しては、最適化レベルの指定がソースプログラムを記述したファイル単位で行われることになる。そのため、当該ファイルに記述されたソースプログラム中に1箇所でも入力値の精度に敏感な演算がある場合、当該ファイルに指定する最適化レベルを当該演算に合わせて落とす必要がある。このような方法であると、同じファイルに存在する残りの演算に対し、積極的な最適化が実施できないため、プログラム全体の効率化を妨げることから、性能に対する悪影響が大きい。   In the method (1), the optimization level is specified in units of files describing the source program. For this reason, if there is an operation sensitive to the accuracy of the input value even in one place in the source program described in the file, it is necessary to drop the optimization level specified in the file according to the operation. With such a method, since the active optimization cannot be performed on the remaining operations existing in the same file, the efficiency of the entire program is hindered, so that the performance is adversely affected.

上記(2)の方法に対しては、正しくプラグマを挿入するためには、目的プログラムを実行させるハードウェアに対して、ユーザが詳細な知識を持つ必要がある。そのため、全てのユーザが利用可能な方法であるとはいえない。また、ユーザにソースプログラムを修正させることの負担が大きいといえる。また、ソースプログラムに挿入されたプラグマは、他のハードウェアの目的プログラムに翻訳する用途に使えるとは限らないため、ユーザはプログラムを実行させるハードウェア毎にプラグマを変更する必要がある。また、大規模なプログラムでは、全ての積極的な最適化を抑止したい場所に適切にプラグマを挿入するのは非常に大きな工数がかかる可能性がある。   In the method (2), in order to correctly insert the pragma, the user needs to have detailed knowledge of the hardware that executes the target program. Therefore, it cannot be said that this method is available to all users. Moreover, it can be said that the burden of having the user modify the source program is large. Further, since the pragma inserted into the source program is not always usable for the purpose of translating into the target program of other hardware, the user needs to change the pragma for each piece of hardware that executes the program. Also, in a large-scale program, it may take a very large amount of man-hours to properly insert pragmas where it is desired to prevent all aggressive optimization.

上記(3)の方法に対しては、2つの観点から課題がある。1つめの課題(a)として、コンパイラは、問題となりそうな演算の組み合わせに対し、事前にテンプレートを用意しなければならない。しかし、実際のプログラムでは、事前にテンプレートを用意できない場合がありうるということである。   The method (3) has problems from two viewpoints. As a first problem (a), the compiler must prepare a template in advance for a combination of operations that may cause a problem. However, in an actual program, a template may not be prepared in advance.

例えば、上記(3)の方法について説明した際に用いた例「ii=(int64_t)(aa/xx);」を少し変更した「ii=(int64_t)(aa/xx-yy);」というソースプログラムを考える。当該ソースプログラムの構文木は、図7のようになり、図6に示す構文木とは異なる。そのため、図6に示す、積極的な最適化を実施しない場合のテンプレートを適用することができず、積極的な最適化を抑止することができない。図7のパターンの構文木に対応するただ1つのテンプレートをコンパイラに追加したとしても、このような例は無数にあるため、ユーザは自分の翻訳しようとするプログラムで積極的な最適化が適切に抑止されることを確証できない。   For example, the source “ii = (int64_t) (aa / xx-yy);”, which is a slightly modified version of the example “ii = (int64_t) (aa / xx);” that was used when explaining the method (3) above Think about the program. The syntax tree of the source program is as shown in FIG. 7, and is different from the syntax tree shown in FIG. For this reason, the template shown in FIG. 6 when the aggressive optimization is not performed cannot be applied, and the aggressive optimization cannot be suppressed. Even if only one template corresponding to the syntax tree of the pattern in FIG. 7 is added to the compiler, there are countless examples of this, so users can make appropriate optimizations actively in the program they are translating. It cannot be confirmed that it will be deterred.

2つ目の課題(b)は、複数の構文木がデータのメモリ転送命令を介してデータ依存関係を結ぶ可能性がある場合に対応できないということである。例えば、図8に示すように、プログラムのある部分で得られた値をstore命令でメモリに格納し、別の部分でload命令を使用してメモリから取り出して演算に用いることを考える。図8では、プログラムのある部分では浮動小数点除算が実行され、別の部分では型変換命令が実行される例を示している。   The second problem (b) is that it cannot cope with a case where there is a possibility that a plurality of syntax trees form a data dependency through a data memory transfer instruction. For example, as shown in FIG. 8, it is assumed that a value obtained in a part of a program is stored in a memory by a store instruction and is extracted from the memory by using a load instruction in another part and used for an operation. FIG. 8 shows an example in which floating-point division is executed in one part of the program and a type conversion instruction is executed in another part.

この場合、浮動小数点除算と型変換命令とは異なる構文木に存在するので、上記(3)の方法の様に、浮動小数点除算と型変換との両方を含むパターンの構文木に対して、ただ1つの積極的な最適化を実施しないテンプレートを用意する方法は適用できない。そのため、ユーザがプログラム中にstore命令、又はload命令を用いるような処理がないことを確認する必要がある。   In this case, since the floating-point division and type conversion instructions exist in different syntax trees, as in the method (3) above, it is only necessary for the syntax tree of a pattern including both floating-point division and type conversion. One method of preparing a template that does not perform aggressive optimization is not applicable. Therefore, it is necessary for the user to confirm that there is no processing using the store instruction or the load instruction in the program.

よって、上記(3)の方法では、特に、「積極的な最適化」の対象となる演算と、「入力値の精度に敏感な演算」との構文木上での距離が遠い場合、積極的な最適化を実施することにより、問題が起きる可能性が高まる。また、メモリを介して間接的に繋がっている場合も、積極的な最適化を実施することにより、問題が起きる可能性が高まる。   Therefore, in the above method (3), especially when the distance between the operation to be “proactively optimized” and the “operation sensitive to the accuracy of the input value” on the syntax tree is long, By carrying out the optimization, the possibility of problems increases. In addition, even when the connection is indirectly made through a memory, the possibility of a problem increases by performing aggressive optimization.

これは、距離が遠い場合、又はメモリを介している場合は、「入力値の精度に敏感な演算」から遡って影響が波及する範囲に、「積極的な最適化」の対象となる演算が含まれるかどうかをユーザが判断することが難しくなることによるものである。   This means that if the distance is long, or if it is via a memory, the calculation subject to “active optimization” will be in the range where the influence is retroactive to “the calculation sensitive to the accuracy of the input value”. This is because it becomes difficult for the user to determine whether or not it is included.

上述の通り、上記(1)〜(3)の積極的な最適化の抑止方法については問題がある。そのため、後述する各実施形態に係るコンパイラにおいては、上記課題(a)及び(b)を解決して、積極的な最適化の適切な実施、又は抑止を実現する。なお、課題(a)及び(b)が解決できれば、上記(1)及び(2)の方法を用いる必要性は著しく減少すると考えられるため、上記(1)及び(2)の課題はほぼ問題にならない。   As described above, there is a problem with the positive optimization suppression methods (1) to (3). Therefore, the compiler according to each embodiment to be described later solves the problems (a) and (b) and realizes appropriate implementation or suppression of aggressive optimization. If the problems (a) and (b) can be solved, the need to use the methods (1) and (2) will be significantly reduced. Therefore, the problems (1) and (2) are almost problematic. Don't be.

以下、実施形態の概要として、上記の課題(a)及び(b)の解決方法について説明する。   Hereinafter, as a summary of the embodiment, a solution to the problems (a) and (b) will be described.

まず、課題(a)の解決方法について説明する。課題(a)に対しては、構文木上で、入力値の精度に敏感な演算を始点として、既存のデータ依存解析を行い、その入力値の精度に敏感な演算の入力値を生成した演算を特定して印を付加する。   First, a solution for the problem (a) will be described. For task (a), an operation that generates an input value for an operation sensitive to the accuracy of the input value by performing an existing data dependency analysis starting from the operation sensitive to the accuracy of the input value on the syntax tree Is added and a mark is added.

さらに、当該印を付けた演算に再帰的に既存のデータ依存解析を適用することで、同じ構文木の中の、入力値の精度に敏感な演算に影響を与える全ての演算に、その距離に関係なく印の伝播を可能とすることで、特定作業を完了する。   Furthermore, by applying the existing data dependence analysis recursively to the operations marked with this mark, all the operations in the same syntax tree that affect operations sensitive to the accuracy of the input value The specific work is completed by enabling the propagation of the mark regardless.

そして、印を付けられた演算、即ち、入力値の精度に敏感な演算に対する入力値にかかわる演算を積極的な最適化の対象外とすることで、課題(a)を解決する。   Then, the marked operation, that is, the operation related to the input value for the operation sensitive to the accuracy of the input value is excluded from the object of active optimization, thereby solving the problem (a).

なお、課題(a)を解決するために、実施形態に係るコンパイラ内部のデータ構造を変更する。例えば、図9に示す従来のノードのデータ依存関係の情報を含むノードを表す構造体に、当該ノードが入力値の精度に敏感な演算に連絡することを表明する印を付加し、図10に示すような構造体に変更する。例えば、ノードを表す構造体に、図10に示すように真偽値を表す「error_sensitive」というメンバを追加し、当該メンバの値が真で有るときに、当該ノードが入力値の精度に敏感な演算に連絡することを表明するものとすることができる。なお、「error_sensitive」というメンバが真である場合には、図11に示すように、従来のノード表記に印を付加し、積極的な最適化を実施しない対象として表明する。   In order to solve the problem (a), the data structure inside the compiler according to the embodiment is changed. For example, a mark representing that the node is in contact with an operation sensitive to the accuracy of the input value is added to the structure representing the node including the data dependency information of the conventional node shown in FIG. Change to the structure shown. For example, when a member “error_sensitive” representing a true / false value is added to a structure representing a node as shown in FIG. 10 and the value of the member is true, the node is sensitive to the accuracy of the input value. It can be stated that the operation is contacted. When the member “error_sensitive” is true, as shown in FIG. 11, a mark is added to the conventional node notation, and it is asserted that no aggressive optimization is performed.

次に、課題(b)の解決方法について説明する。課題(b)に対しては、既存の、メモリとのデータ転送命令同士の間のアドレス解析を行うことで、入力値の精度に敏感な演算が含まれる構文木以外の構文木にまで、印の伝播する範囲を拡大させる。このようにすることにより、複数の構文木にまたがった特定作業が可能となる。   Next, a method for solving the problem (b) will be described. For the problem (b), by performing address analysis between the existing data transfer instructions with the memory, the syntax tree other than the syntax tree including the operation sensitive to the accuracy of the input value can be displayed. Increase the propagation range of By doing so, it is possible to perform specific work across a plurality of syntax trees.

そして、複数の構文木にまたがって印をつけられた演算も入力値の精度に敏感な演算の入力値に関わる演算であるとの判断が可能となるので、それらに対し積極的な最適化の対象外とすることで、課題(b)を解決する。   And it is possible to determine that operations marked across multiple syntax trees are operations related to the input value of operations that are sensitive to the accuracy of the input value. By excluding it, the problem (b) is solved.

以下、図面を参照して、各実施形態について詳細に説明する。なお、各実施形態において用いられる、「入力値の精度に敏感な演算」は予め定義されているものとする。また、各実施形態において、上述した前提となるコンパイラと最適化についての説明、及び実施形態の概要と共通する内容については、詳細な説明を省略する。   Hereinafter, each embodiment will be described in detail with reference to the drawings. It is assumed that the “operation sensitive to the accuracy of the input value” used in each embodiment is defined in advance. Further, in each embodiment, a detailed description of the description of the premise compiler and optimization described above, and contents common to the outline of the embodiment is omitted.

図12は、第1の実施形態のコンパイラシステム5の一例である。図12に示すように、コンパイラシステム5は、コンパイラ装置1と、利用者用の利用者端末3と、外部ディスク40とを有する。また、外部ディスク40は、ソースプログラム記憶部42、及び目的プログラム記憶部46を有する。第1の実施形態に係るコンパイラ装置1は、インターネット等のネットワーク2を介して、利用者端末3、及び外部ディスク40と相互に通信可能に接続される。なお、図12における利用者端末3は、1つの場合について図示したが、利用者端末3の数は図示の例に限定されず、コンパイラシステム5は任意の数の利用者端末3を有することができる。また、利用者端末3は、例えば、パーソナルコンピュータ等の情報処理装置であり、コンパイルを行う者により利用されるものとする。   FIG. 12 is an example of the compiler system 5 of the first embodiment. As shown in FIG. 12, the compiler system 5 includes a compiler device 1, a user terminal 3 for users, and an external disk 40. The external disk 40 has a source program storage unit 42 and a target program storage unit 46. The compiler apparatus 1 according to the first embodiment is connected to a user terminal 3 and an external disk 40 through a network 2 such as the Internet so that they can communicate with each other. 12 illustrates one case of the user terminal 3, but the number of user terminals 3 is not limited to the illustrated example, and the compiler system 5 may include an arbitrary number of user terminals 3. it can. The user terminal 3 is an information processing apparatus such as a personal computer, and is used by a person who performs compilation.

ソースプログラム記憶部42には、ソースプログラムの各々が記憶されている。 Each source program is stored in the source program storage unit 42.

目的プログラム記憶部46は、目的プログラムの各々が記憶される。   The target program storage unit 46 stores each of the target programs.

図13に、第1の実施形態に係るコンパイラ装置1の機能ブロック図を示す。図13に示すように、コンパイラ装置1は、引数解析部22、字句構文解析部24、最適化部26、命令生成部28、目的プログラム出力部30、テンプレート記憶部32、記録表記憶部44を含むコンパイラ20を有する。   FIG. 13 shows a functional block diagram of the compiler apparatus 1 according to the first embodiment. As shown in FIG. 13, the compiler apparatus 1 includes an argument analysis unit 22, a lexical syntax analysis unit 24, an optimization unit 26, an instruction generation unit 28, a target program output unit 30, a template storage unit 32, and a recording table storage unit 44. A compiler 20 is included.

コンパイラ20は、利用者端末3から受信した入力情報(コマンド)に基づいて、起動され、ネットワーク2を介してソースプログラム記憶部42から対象となるソースプログラムを取得する。また、コンパイラ20は、取得したソースプログラムを目的プログラムに変換し、ネットワーク2を介して目的プログラム記憶部46に記憶する。   The compiler 20 is activated based on the input information (command) received from the user terminal 3 and acquires the target source program from the source program storage unit 42 via the network 2. The compiler 20 converts the acquired source program into a target program and stores it in the target program storage unit 46 via the network 2.

引数解析部22は、利用者端末3から受信した入力情報に基づいて、コンパイラの動作を決定する。具体的には、引数解析部22は、利用者端末3から受信した、コンパイラの起動時に渡されたソースプログラムを格納したファイル、又は目的プログラムを格納すべきファイルのファイル名などのファイル名指定により、対象となるファイルを決定する。また、引数解析部22は、利用者端末3から受信した、コンパイラの起動時に渡された、どのような最適化を実施するかを指定するオプションを解析し、実施する最適化を決定する。また、引数解析部22は、利用者端末3から受信した、出力する目的プログラムの形式を指定するオプションを解析し、出力する目的プログラムの形式を決定する。なお、決定される最適化は、後述する字句構文解析部24において生成される構文木の全てが対象となる。   The argument analysis unit 22 determines the operation of the compiler based on the input information received from the user terminal 3. Specifically, the argument analysis unit 22 receives a file name specification such as a file stored from the user terminal 3 that stores the source program passed when the compiler is started or a file that stores the target program. Determine the target file. Further, the argument analysis unit 22 analyzes the option that is received from the user terminal 3 and is passed when the compiler is started and specifies what kind of optimization is performed, and determines the optimization to be performed. The argument analyzing unit 22 analyzes the option received from the user terminal 3 and specifying the format of the target program to be output, and determines the format of the target program to be output. Note that the optimization to be determined covers all the syntax trees generated in the lexical syntax analysis unit 24 described later.

字句構文解析部24は、引数解析部22において決定した、対象となるソースプログラムを格納したファイル名に基づいて、対象となるソースプログラムに記述された処理をコンパイラ内で用いられる中間言語である構文木形式に変換する。字句構文解析部24により、特定の演算単位の構文木の各々が生成される。字句構文解析部24により、複数の演算間のデータの入出力の関係を表すデータ依存関係を取得することができる。   The lexical syntax analysis unit 24 is a syntax that is an intermediate language used in the compiler for processing described in the target source program based on the file name storing the target source program determined by the argument analysis unit 22. Convert to tree format. The lexical syntax analysis unit 24 generates each syntax tree of a specific operation unit. The lexical syntax analysis unit 24 can acquire a data dependency representing a data input / output relationship between a plurality of operations.

具体的には、字句構文解析部24は、まず、引数解析部22において決定した、対象となるソースプログラムを格納したファイル名に基づいて、ソースプログラム記憶部42から、対象となるソースプログラムを取得する。次に、字句構文解析部24は、取得したソースプログラムに記述された処理について、字句解析を行う。次に、字句構文解析部24は、字句解析結果に基づいて、構文解析を行い、特定の演算単位の構文木の各々を生成する。   Specifically, the lexical syntax analysis unit 24 first acquires the target source program from the source program storage unit 42 based on the file name that stores the target source program determined by the argument analysis unit 22. To do. Next, the lexical syntax analysis unit 24 performs lexical analysis on the processing described in the acquired source program. Next, the lexical syntax analysis unit 24 performs syntax analysis based on the lexical analysis result, and generates each syntax tree of a specific operation unit.

最適化部26は、字句構文解析部24において生成した構文木の各々について、引数解析部22において決定した最適化に関するコンパイラの動作に基づいて、最適化を実施する。具体的には、まず、最適化部26は、制御解析・データ解析を行い、通常の最適化、又は積極的な最適化の実施に必要な情報を取得する。第1の実施形態においては、最適化部26は、従来技術を用いて、全ての構文木に含まれるstore命令の各々とload命令の各々との指すアドレスが一致するか否かの判定結果を取得する。   The optimization unit 26 performs optimization on each syntax tree generated by the lexical syntax analysis unit 24 based on the compiler operation related to optimization determined by the argument analysis unit 22. Specifically, first, the optimization unit 26 performs control analysis and data analysis, and acquires information necessary for performing normal optimization or aggressive optimization. In the first embodiment, the optimization unit 26 uses a conventional technique to determine whether or not the addresses indicated by the store instructions and the load instructions included in all the syntax trees match. get.

ここで、アドレスが一致するか否かの判定結果は、一致する、一致しない、及び不明の3種類に分類されるものであるが、第1の実施形態においては、一致する、及び不明の場合に一致すると判定するものとする。   Here, the determination result of whether or not the addresses match is classified into three types of matching, non-matching, and unknown, but in the first embodiment, when matching and unknown It shall be determined that they match.

次に、最適化部26は、構文木の各々について、当該構文木のノードを探索し、当該構文木に含まれるノードのうち、入力値の精度に敏感な演算の入力値に関わる演算に関わるノードに対して印を付加する。   Next, the optimization unit 26 searches each syntax tree for a node of the syntax tree, and relates to an operation related to an input value of an operation sensitive to the accuracy of the input value among the nodes included in the syntax tree. Add a mark to the node.

具体的には、まず、最適化部26は、構文木の各々のうち、処理対象となる構文木の根ノードを処理対象となるノードとして決定する。次に、最適化部26は、当該ノードが、「入力値の精度に敏感な演算を表すノード」、及び「親ノードに印が付加されている」という2つの条件のうち少なくとも1つを満たしているか判定する。次に、最適化部26は、条件を満たしていると判定した場合、当該ノードに印を付加する。例えば、ノードが、図10に示すようなデータ構造体で表される場合、当該ノードのデータ構造体の「error_sensitive」の値を1(true)に変更することで、当該ノードに印を付加することができる。また、最適化部26は、当該ノードがload命令か否かを判定する。最適化部26は、当該ノードがload命令である場合には、当該load命令の指すアドレスを、図14に示すような記録表記憶部44に記憶されている記録表に記憶する。   Specifically, first, the optimization unit 26 determines the root node of the syntax tree to be processed among the syntax trees as the node to be processed. Next, the optimization unit 26 satisfies at least one of the two conditions that the node is “a node representing an operation sensitive to the accuracy of the input value” and “a parent node is marked”. Judgment is made. Next, when the optimization unit 26 determines that the condition is satisfied, the optimization unit 26 adds a mark to the node. For example, when a node is represented by a data structure as shown in FIG. 10, a mark is added to the node by changing the value of “error_sensitive” of the data structure of the node to 1 (true). be able to. The optimization unit 26 determines whether the node is a load instruction. If the node is a load instruction, the optimization unit 26 stores the address indicated by the load instruction in a recording table stored in the recording table storage unit 44 as illustrated in FIG.

次に、最適化部26は、当該ノードに未処理の子ノードが存在する場合には、当該子ノードを処理対象のノードとして選択し、同様の処理を再帰的に繰り返す。次に、最適化部26は、全ての子ノードについて処理を終了したら処理対象のノードを当該ノードの親ノードに変更し、未処理の子ノードが存在するか判定する。次に、最適化部26は、未処理の子ノードが存在する場合には、再帰的に上記処理を繰り返す。一方、未処理の子ノードが存在しない場合には、当該処理対象のノードの親ノードを処理対象のノードとする処理を繰り返す。最適化部26は、上記処理を繰り返すことにより、構文木の各々について、当該構文木に含まれるノードの各々について印を付加する処理を行う。   Next, when an unprocessed child node exists in the node, the optimization unit 26 selects the child node as a processing target node, and repeats the same processing recursively. Next, when the process is completed for all the child nodes, the optimization unit 26 changes the node to be processed to the parent node of the node, and determines whether there is an unprocessed child node. Next, when there is an unprocessed child node, the optimization unit 26 recursively repeats the above processing. On the other hand, when there is no unprocessed child node, the process of setting the parent node of the processing target node as the processing target node is repeated. The optimization unit 26 performs processing for adding a mark to each of the nodes included in the syntax tree by repeating the above processing.

次に、最適化部26は、構文木の各々について、当該構文木のノードを再探索し、当該構文木に含まれるノードのうち、別の構文木に含まれる入力値の精度に敏感な演算の入力値に関わる演算に関わるノードに対して印を付加する。   Next, for each syntax tree, the optimization unit 26 re-searches the node of the syntax tree, and among the nodes included in the syntax tree, an operation sensitive to the accuracy of the input value included in another syntax tree. A mark is added to a node related to an operation related to the input value of.

具体的には、まず、最適化部26は、構文木の各々のうち、処理対象となる構文木の根ノードを処理対象となるノードとして決定する。次に、最適化部26は、当該ノードが「store命令を表すノードであり、かつ、store命令の指すアドレスが記録表記憶部44に記憶されている記録表に記憶されている」、及び「親ノードに印が付加されている」のうち少なくとも一方の条件を満たすか判定する。次に、最適化部26は、条件を満たしていると判定した場合、当該ノードに印を付加する。   Specifically, first, the optimization unit 26 determines the root node of the syntax tree to be processed among the syntax trees as the node to be processed. Next, the optimization unit 26 indicates that the node is “a node representing a store instruction and the address indicated by the store instruction is stored in the recording table stored in the recording table storage unit 44”, and “ It is determined whether at least one of the conditions “a mark is added to the parent node” is satisfied. Next, when the optimization unit 26 determines that the condition is satisfied, the optimization unit 26 adds a mark to the node.

次に、最適化部26は、当該ノードに未処理の子ノードが存在する場合には、当該子ノードを処理対象のノードとして選択し、同様の処理を再帰的に繰り返す。次に、最適化部26は、全ての子ノードについて処理を終了したら処理対象のノードを当該ノードの親ノードに変更し、未処理の子ノードが存在するか判定する。次に、最適化部26は、未処理の子ノードが存在する場合には、再帰的に上記処理を繰り返す。一方、未処理の子ノードが存在しない場合には、当該処理対象のノードの親ノードを処理対象のノードとする処理を繰り返す。最適化部26は、上記処理を繰り返すことにより、構文木の各々について、当該構文木に含まれるノードの各々について印を付加する処理を行う。   Next, when an unprocessed child node exists in the node, the optimization unit 26 selects the child node as a processing target node, and repeats the same processing recursively. Next, when the process is completed for all the child nodes, the optimization unit 26 changes the node to be processed to the parent node of the node, and determines whether there is an unprocessed child node. Next, when there is an unprocessed child node, the optimization unit 26 recursively repeats the above processing. On the other hand, when there is no unprocessed child node, the process of setting the parent node of the processing target node as the processing target node is repeated. The optimization unit 26 performs processing for adding a mark to each of the nodes included in the syntax tree by repeating the above processing.

次に、最適化部26は、引数解析部22において決定した最適化に関するコンパイラの動作に基づいて、構文木の各々について、最適化を実施する。具体的には、最適化部26は、引数解析部22において最適化を実施するオプションが指定されていないと判定した場合には、全ての構文木について通常の最適化、及び積極的な最適化を行わない。また、最適化部26は、引数解析部22において最適化を実施するオプションが指定され、かつ、積極的な最適化のオプションが指定されていないと判定した場合、全ての構文木に対して通常の最適化を実施する。また、最適化部26は、引数解析部22において最適化を実施するオプションが指定され、かつ、積極的な最適化のオプションが指定されていると判定した場合には、構文木の各々について、通常の最適化、又は積極的な最適化を実施する。   Next, the optimization unit 26 performs optimization on each syntax tree based on the compiler operation related to optimization determined by the argument analysis unit 22. Specifically, when the argument analyzing unit 22 determines that the option for performing optimization is not specified, the optimization unit 26 performs normal optimization and aggressive optimization for all the syntax trees. Do not do. If the optimization unit 26 determines that the option for performing optimization is specified in the argument analysis unit 22 and that the option for aggressive optimization is not specified, the optimization unit 26 normally performs processing for all syntax trees. Perform optimization. When the optimization unit 26 determines that the option for performing optimization is specified in the argument analysis unit 22 and the option for aggressive optimization is specified, for each of the syntax trees, Perform normal optimization or aggressive optimization.

ここで、最適化を実施するオプションが指定され、かつ、積極的な最適化のオプションが指定されている場合における、通常の最適化を実施するか、積極的な最適化を実施するかの判断について説明する。最適化部26は、処理対象となる構文木に含まれるノードに印が付加されているか否かにより判断する。最適化部26は、処理対象となる構文木に含まれるノードに印が付加されている場合には、当該構文木に対して通常の最適化を実施する。一方、最適化部26は、処理対処となる構文木に含まれるノードに印が付加されていない場合には、当該構文木に対して積極的な最適化を実施する。最適化部26は、最適化を行わない、通常の最適化を行った、積極的な最適化を行ったという最適化処理の結果(最適化レベル)も含めて、処理済の構文木の各々を命令生成部28に出力する。なお、処理済の構文木とは、最適化又は積極的な最適化を実施した場合には、最適化済み又は積極的な最適化済み構文木であり、最適化を実施していない場合には、字句構文解析部24で生成されたままの状態の構文木である。   Here, when the option for performing optimization is specified and the option for aggressive optimization is specified, it is determined whether to perform normal optimization or aggressive optimization. Will be described. The optimization unit 26 determines whether or not a mark is added to a node included in the syntax tree to be processed. When a mark is added to a node included in the syntax tree to be processed, the optimization unit 26 performs normal optimization on the syntax tree. On the other hand, when the mark is not added to the node included in the syntax tree to be processed, the optimization unit 26 performs positive optimization on the syntax tree. The optimization unit 26 performs each of the processed syntax trees including the result of optimization processing (optimization level) in which normal optimization is performed, optimization is not performed, and optimization is performed. Is output to the instruction generator 28. The processed syntax tree is an optimized or aggressively optimized syntax tree when optimization or aggressive optimization is performed, and when optimization is not performed. This is a syntax tree as it is generated by the lexical syntax analysis unit 24.

命令生成部28は、最適化部26における処理済みの構文木の各々を、テンプレート記憶部32に記憶されているテンプレートの各々に基づいて、目的プログラムに変換する。また、命令生成部28は、当該目的プログラムを、目的プログラム出力部30に出力する。   The instruction generation unit 28 converts each processed syntax tree in the optimization unit 26 into a target program based on each template stored in the template storage unit 32. The instruction generation unit 28 outputs the target program to the target program output unit 30.

具体的には、まず、命令生成部28は、処理対象となる構文木を選択する。次に、命令生成部28は、テンプレート記憶部32に記憶されているテンプレートから、処理対象となる構文木に対応するテンプレートを選択する。   Specifically, first, the instruction generation unit 28 selects a syntax tree to be processed. Next, the instruction generation unit 28 selects a template corresponding to the syntax tree to be processed from the templates stored in the template storage unit 32.

ここで、テンプレート記憶部32には、構文木の各パターンに対応したテンプレートの各々が、最適化レベル毎に分類されて記憶されている。具体的には、構文木の各パターンに対応したテンプレートの各々が、最適化を実施しない場合のテンプレート群、通常の最適化を実施した場合のテンプレート群、及び積極的な最適化を実施した場合のテンプレート群に分類されて記憶されている。   Here, each template corresponding to each pattern of the syntax tree is stored in the template storage unit 32 classified for each optimization level. Specifically, each template corresponding to each pattern of the syntax tree is a template group when optimization is not performed, a template group when normal optimization is performed, and when aggressive optimization is performed The template groups are classified and stored.

そこで、命令生成部28は、処理対象となる構文木に対して最適化が行われなかった場合には、テンプレート記憶部32に記憶されている、最適化を実施しない場合のテンプレート群から、当該構文木に対応するテンプレートを選択する。また、命令生成部28は、処理対象となる構文木に対して通常の最適化が行われた場合には、テンプレート記憶部32に記憶されている通常の最適化を実施した場合のテンプレート群から、当該構文木に対応するテンプレートを選択する。また、命令生成部28は、処理対象の構文木に対して積極的な最適化が行われた場合には、テンプレート記憶部32に記憶されている、積極的な最適化を実施した場合のテンプレート群から、当該構文木に対応するテンプレートを選択する。   Therefore, the instruction generation unit 28, when the optimization is not performed on the syntax tree to be processed, from the template group stored in the template storage unit 32 when the optimization is not performed. Select the template that corresponds to the syntax tree. In addition, when normal optimization is performed on the syntax tree to be processed, the instruction generation unit 28 uses the template group when the normal optimization stored in the template storage unit 32 is performed. , A template corresponding to the syntax tree is selected. Further, the instruction generation unit 28 stores the template stored in the template storage unit 32 when the optimization is performed positively when the processing target syntax tree is positively optimized. A template corresponding to the syntax tree is selected from the group.

次に、命令生成部28は、処理対象となる構文木と、選択したテンプレートとに基づいて、当該構文木を目的プログラムに変換する。   Next, the instruction generation unit 28 converts the syntax tree into a target program based on the syntax tree to be processed and the selected template.

目的プログラム出力部30は、命令生成部28において変換された目的プログラムの各々をまとめ、1つの目的プログラムとして、ネットワーク2を介して、外部ディスク40に記憶されている目的プログラム記憶部46に記憶する。   The target program output unit 30 collects each of the target programs converted by the instruction generation unit 28 and stores it as a single target program in the target program storage unit 46 stored in the external disk 40 via the network 2. .

記録表記憶部44には、図14に示すような、印が付加されたload命令のノードを示す情報とアドレスとの組み合わせを記憶する記録表が記憶されている。   The recording table storage unit 44 stores a recording table for storing a combination of information indicating the node of the load instruction with a mark and an address, as shown in FIG.

コンパイラ装置1は、例えば図15に示すコンピュータ200で実現することができる。コンピュータ200はCPU202、一時記憶領域としてのメモリ204、及び不揮発性の記憶装置206を備える。また、コンピュータ200は、入出力装置208が接続される入出力インターフェース(I/F)210を備える。また、コンピュータ200は、記録媒体212に対するデータの読み込み及び書き込みを制御するread/write(R/W)部214、及びインターネット等のネットワーク2に接続されるネットワークI/F216を備える。CPU202、メモリ204、記憶装置206、入出力I/F210、R/W部214、及びネットワークI/F216は、バス218を介して互いに接続される。   The compiler apparatus 1 can be realized by a computer 200 shown in FIG. 15, for example. The computer 200 includes a CPU 202, a memory 204 as a temporary storage area, and a nonvolatile storage device 206. The computer 200 also includes an input / output interface (I / F) 210 to which an input / output device 208 is connected. The computer 200 also includes a read / write (R / W) unit 214 that controls reading and writing of data with respect to the recording medium 212 and a network I / F 216 connected to the network 2 such as the Internet. The CPU 202, the memory 204, the storage device 206, the input / output I / F 210, the R / W unit 214, and the network I / F 216 are connected to each other via a bus 218.

記憶装置206はHDD(Hard Disk Drive)、SSD(solid state drive)、フラッシュメモリ等によって実現できる。記憶媒体としての記憶装置206には、コンピュータ200をコンパイラ装置1として機能させるためのコンパイラプログラム300が記憶される。また、記憶装置206は、テンプレートの各々が記憶されるテンプレート記憶領域350を有する。また、記録表が記録される記録表記憶領域354を有する。   The storage device 206 can be realized by a hard disk drive (HDD), a solid state drive (SSD), a flash memory, or the like. A storage device 206 as a storage medium stores a compiler program 300 for causing the computer 200 to function as the compiler device 1. In addition, the storage device 206 has a template storage area 350 in which each template is stored. In addition, it has a recording table storage area 354 in which a recording table is recorded.

CPU202は、コンパイラプログラム300を記憶装置206から読みだしてメモリ204に展開する。また、CPU202は、コンパイラプログラム300が有するプロセスを順次実行する。また、CPU202は、テンプレート記憶領域350に記憶されたテンプレートの各々を読み出し、メモリ204に展開する。また、CPU202は、記録表記憶領域354に記憶された記録表を読み出し、メモリ204に展開する。   The CPU 202 reads the compiler program 300 from the storage device 206 and expands it in the memory 204. Further, the CPU 202 sequentially executes processes included in the compiler program 300. In addition, the CPU 202 reads each template stored in the template storage area 350 and develops it in the memory 204. Further, the CPU 202 reads the recording table stored in the recording table storage area 354 and develops it in the memory 204.

コンパイラプログラム300は、引数解析プロセス302と、字句構文解析プロセス304と、最適化プロセス306と、命令生成プロセス308と、目的プログラム出力プロセス310とを有する。   The compiler program 300 includes an argument analysis process 302, a lexical syntax analysis process 304, an optimization process 306, an instruction generation process 308, and an object program output process 310.

CPU202は、引数解析プロセス302を実行することで、図13に示す引数解析部22として動作する。また、CPU202は、字句構文解析プロセス304を実行することで、図13に示す字句構文解析部24として動作する。また、CPU202は、最適化プロセス306を実行することで、図13に示す最適化部26として動作する。また、CPU202は、命令生成プロセス308を実行することで、図13に示す命令生成部28として動作する。また、CPU202は、目的プログラム出力プロセス310を実行することで、図13に示す目的プログラム出力部30として動作する。   The CPU 202 operates as the argument analysis unit 22 illustrated in FIG. 13 by executing the argument analysis process 302. The CPU 202 operates as the lexical syntax analysis unit 24 shown in FIG. 13 by executing the lexical syntax analysis process 304. Further, the CPU 202 operates as the optimization unit 26 illustrated in FIG. 13 by executing the optimization process 306. Further, the CPU 202 operates as the instruction generation unit 28 illustrated in FIG. 13 by executing the instruction generation process 308. Further, the CPU 202 operates as the target program output unit 30 shown in FIG. 13 by executing the target program output process 310.

これにより、コンパイラプログラム300を実行したコンピュータ200が、コンパイラ装置1として機能することになる。   As a result, the computer 200 that has executed the compiler program 300 functions as the compiler apparatus 1.

なお、コンパイラ装置1は、例えば半導体集積回路、より詳しくはASIC(Application Specific Integrated Circuit)等で実現することも可能である。   The compiler apparatus 1 can be realized by, for example, a semiconductor integrated circuit, more specifically, an ASIC (Application Specific Integrated Circuit) or the like.

次に、第1の実施形態に係るコンパイラ装置1の作用について説明する。まず、利用者端末3から受信された入力情報をコンパイラ装置1が受け付けると、コンパイラ装置1において、図16に示すコンパイル処理が実行される。なお、コンパイラ装置1により実行されるコンパイル処理は、開示する技術のコンパイラ方法の一例である。   Next, the operation of the compiler apparatus 1 according to the first embodiment will be described. First, when the compiler apparatus 1 receives input information received from the user terminal 3, the compiler apparatus 1 executes a compilation process shown in FIG. The compiling process executed by the compiler apparatus 1 is an example of a compiler method of the disclosed technology.

図16は、コンパイル処理の一例を示すフローチャートである。図16に示すコンパイル処理のフローチャートにおいて、まず、ステップS100で、引数解析部22は、入力情報に含まれるファイル名指定、オプション等を解析する。   FIG. 16 is a flowchart illustrating an example of compilation processing. In the flowchart of the compilation process shown in FIG. 16, first, in step S100, the argument analysis unit 22 analyzes a file name designation, options, and the like included in the input information.

次に、ステップS102で、引数解析部22は、テンプレート記憶部32から、テンプレートの各々を取得する。   Next, in step S <b> 102, the argument analysis unit 22 acquires each template from the template storage unit 32.

次に、ステップS104で、引数解析部22は、ネットワーク2を介してソースプログラム記憶部42から、ステップS100において取得した、処理対象となるソースプログラムのファイルを取得する。   Next, in step S <b> 104, the argument analysis unit 22 acquires the source program file to be processed acquired in step S <b> 100 from the source program storage unit 42 via the network 2.

次に、ステップS106で、字句構文解析部24は、ステップS104において取得したソースプログラムについて、字句解析、及び構文解析を行い、中間言語である構文木の各々を取得する。   Next, in step S106, the lexical syntax analysis unit 24 performs lexical analysis and syntax analysis on the source program acquired in step S104, and acquires each syntax tree that is an intermediate language.

次に、ステップS108で、最適化部26は、ステップS104において取得した構文木の各々について、ステップS100において取得したオプション解析の結果に基づいて、最適化を実施する。   Next, in step S108, the optimization unit 26 performs optimization on each syntax tree acquired in step S104 based on the result of the option analysis acquired in step S100.

次に、ステップS110で、命令生成部28は、ステップS108において取得した構文木の各々と、ステップS102において取得したテンプレートの各々とに基づいて、構文木の各々を、目的プログラムの命令に変換する。   Next, in step S110, the instruction generation unit 28 converts each of the syntax trees into an instruction of the target program based on each of the syntax trees acquired in step S108 and each of the templates acquired in step S102. .

次に、ステップS112で、目的プログラム出力部30は、ステップS110において取得した目的プログラムの命令をまとめ、一つの目的プログラムとする。また、目的プログラム出力部30は、まとめた目的プログラムをネットワーク2を介して、目的プログラム記憶部46に記憶する。そして、目的プログラム出力部30は、コンパイル処理を終了する。   Next, in step S112, the target program output unit 30 combines the instructions of the target program acquired in step S110 into one target program. The target program output unit 30 stores the collected target programs in the target program storage unit 46 via the network 2. Then, the target program output unit 30 ends the compilation process.

上述のステップS108の最適化の処理について、図17において詳細に説明する。図17は、ステップS108の最適化処理の一例を示すフローチャートである。図17に示す最適化処理のフローチャートにおいて、まず、ステップS200で、最適化部26は、ステップS106において取得した構文木の各々について、制御解析、及びデータ解析を行い、最適化の実施に必要な情報を取得する。最適化部26は、構文木の各々に含まれるstore命令とload命令とのアドレスの対応関係を取得する。   The optimization process in step S108 described above will be described in detail with reference to FIG. FIG. 17 is a flowchart illustrating an example of the optimization process in step S108. In the flowchart of the optimization process shown in FIG. 17, first, in step S200, the optimization unit 26 performs control analysis and data analysis for each of the syntax trees acquired in step S106, and is necessary for performing the optimization. Get information. The optimization unit 26 acquires the correspondence between the addresses of the store instruction and the load instruction included in each of the syntax trees.

次に、ステップS202で、最適化部26は、ステップS106において取得した構文木の各々について、構文木の探索を行い、入力値の精度に敏感な演算の入力値に関わる演算に関わるノードに対して印を付加する。   Next, in step S202, the optimization unit 26 searches the syntax tree for each of the syntax trees acquired in step S106, and performs processing on the nodes related to the calculation related to the input value of the calculation sensitive to the accuracy of the input value. Add a mark.

次に、ステップS204で、最適化部26は、ステップS100において取得したオプション解析の結果に基づいて、最適化を実施するオプションが指定されているか否かを判定する。最適化部26が、オプションが指定されていると判定した場合には、最適化処理は、ステップS206へ移行する。一方、最適化部26が、オプションが指定されていないと判定した場合には、全ての構文木について最適化を行わないと判定し、最適化処理は終了する。   Next, in step S204, the optimization unit 26 determines whether an option for performing optimization is designated based on the result of the option analysis acquired in step S100. If the optimization unit 26 determines that the option is specified, the optimization process proceeds to step S206. On the other hand, if the optimization unit 26 determines that no option is specified, it determines that optimization is not performed for all the syntax trees, and the optimization process ends.

次に、ステップS206で、最適化部26は、処理対象となる構文木を決定する。   Next, in step S206, the optimization unit 26 determines a syntax tree to be processed.

次に、ステップS210で、最適化部26は、ステップS100において取得したオプション解析の結果に基づいて、積極的な最適化を実施するオプションが指定されているか否かを判定する。最適化部26が、積極的な最適化のオプションが指定されていると判定した場合には、最適化処理は、ステップS212へ移行する。一方、最適化部26が、積極的な最適化のオプションが指定されていないと判定した場合には、最適化処理は、ステップS216へ移行する。   Next, in step S210, the optimization unit 26 determines whether an option for performing aggressive optimization is specified based on the result of the option analysis acquired in step S100. If the optimization unit 26 determines that an aggressive optimization option is designated, the optimization process proceeds to step S212. On the other hand, when the optimization unit 26 determines that the option for aggressive optimization is not designated, the optimization process proceeds to step S216.

次に、ステップS212で、最適化部26は、処理対象となる構文木に含まれるノードに印が付加されているノードが含まれているか否かを判定する。最適化部26が、処理対象となる構文木に含まれるノードに印が付加されているノードが含まれていると判定した場合には、最適化処理は、ステップS216へ移行する。一方、最適化部26は、処理対象となる構文木に含まれるノードに印が付加されているノードが含まれていないと判定した場合には、最適化処理は、ステップS214へ移行する。   Next, in step S212, the optimization unit 26 determines whether or not a node to which a mark is added is included in a node included in the syntax tree to be processed. If the optimization unit 26 determines that the node included in the syntax tree to be processed includes a node with a mark, the optimization process proceeds to step S216. On the other hand, if the optimization unit 26 determines that the node included in the syntax tree to be processed does not include a node with a mark, the optimization process proceeds to step S214.

次に、ステップS214で、最適化部26は、処理対象となる構文木に対して、積極的な最適化を実施する。   Next, in step S214, the optimization unit 26 performs active optimization on the syntax tree to be processed.

ステップS216で、最適化部26は、処理対象となる構文木に対して、通常の最適化を実施する。   In step S216, the optimization unit 26 performs normal optimization on the syntax tree to be processed.

次に、ステップS220で、最適化部26は全ての構文木について、ステップS206〜ステップS214、又はステップS216までの処理を終了したか否かを判定する。最適化部26が、全ての構文木についてステップS206〜ステップS216までの処理を終了したと判定した場合には、最適化処理は終了する。一方、最適化部26が、全ての構文木についてSS206〜ステップS216までの処理を終了していないと判定した場合には、最適化処理は、ステップS206へ移行する。   Next, in step S220, the optimization unit 26 determines whether or not the processing from step S206 to step S214 or step S216 has been completed for all the syntax trees. If the optimization unit 26 determines that the processing from step S206 to step S216 has been completed for all the syntax trees, the optimization processing ends. On the other hand, if the optimization unit 26 determines that the processing from SS 206 to step S 216 has not been completed for all the syntax trees, the optimization processing proceeds to step S 206.

上述のステップS202の構文木の探索と印の付加処理について、図18において詳細に説明する。図18は、ステップS202の構文木の探索と印の付加処理の一例を示すフローチャートである。図18に示す構文木の探索と印の付加処理のフローチャートにおいて、まず、ステップS300で、最適化部26は、処理対象となる構文木を決定する。   The syntax tree search and mark addition processing in step S202 will be described in detail with reference to FIG. FIG. 18 is a flowchart illustrating an example of syntax tree search and mark addition processing in step S202. In the flowchart of the syntax tree search and mark addition process shown in FIG. 18, first, in step S300, the optimization unit 26 determines a syntax tree to be processed.

次に、ステップS302で、最適化部26は、処理対象となる構文木について探索を行い、対象となるノードに印を付加する。   Next, in step S302, the optimization unit 26 searches for a syntax tree to be processed and adds a mark to the target node.

次に、ステップS304で、最適化部26は、全ての構文木についてステップS302の処理を終了したか否かを判定する。最適化部26が、全ての構文木についてステップS302の処理を終了したと判定した場合には、ステップS306へ移行する。一方、最適化部26が、全ての構文木についてステップS302の処理を終了していないと判定した場合には、ステップS300へ移行する。   Next, in step S304, the optimization unit 26 determines whether or not the processing in step S302 has been completed for all the syntax trees. If the optimization unit 26 determines that the process of step S302 has been completed for all the syntax trees, the process proceeds to step S306. On the other hand, when the optimization unit 26 determines that the process of step S302 has not been completed for all the syntax trees, the process proceeds to step S300.

次に、ステップS306で、最適化部26は、処理対象となる構文木を決定する。   Next, in step S306, the optimization unit 26 determines a syntax tree to be processed.

次に、ステップS308で、最適化部26は、処理対象となる構文木を再探索し、対象となるノードに印を付加する。   Next, in step S308, the optimization unit 26 re-searches the syntax tree to be processed and adds a mark to the target node.

次に、ステップS310で、最適化部26は、全ての構文木についてステップS308の処理を終了したか否かを判定する。最適化部26が、全ての構文木についてステップS308の処理を終了したと判定した場合には、構文木の探索と印付け処理は終了する。一方、最適化部26が、全ての構文木についてステップS308の処理を終了していないと判定した場合には、構文木の探索と印付け処理は、ステップS306へ移行する。   Next, in step S310, the optimization unit 26 determines whether or not the processing in step S308 has been completed for all the syntax trees. If the optimization unit 26 determines that the process of step S308 has been completed for all syntax trees, the syntax tree search and marking process ends. On the other hand, if the optimization unit 26 determines that the process of step S308 has not been completed for all syntax trees, the syntax tree search and marking process proceeds to step S306.

上述のステップS302の構文木の探索処理について、図19において詳細に説明する。図19は、ステップS302の構文木の探索処理の一例を示すフローチャートである。図19に示す構文木の探索処理のフローチャートにおいて、まず、ステップS400で、最適化部26は、処理対象となる構文木の根ノードを処理対象となるノードとして選択する。   The syntax tree search process in step S302 will be described in detail with reference to FIG. FIG. 19 is a flowchart illustrating an example of syntax tree search processing in step S302. In the flowchart of the syntax tree search process shown in FIG. 19, first, in step S400, the optimization unit 26 selects the root node of the syntax tree to be processed as the node to be processed.

次に、ステップS402で、最適化部26は、当該ノードが、予め定められた入力値の精度に敏感な演算を表すか否かを判定する。最適化部26が、当該ノードが、予め定められた入力値の精度に敏感な演算を表すと判定した場合には、構文木の探索処理は、ステップS406へ移行する。一方、最適化部26が、当該ノードが、予め定められた入力値の精度に敏感な演算を表さないと判定した場合には、構文木の探索処理は、ステップS404へ移行する。   Next, in step S402, the optimization unit 26 determines whether or not the node represents an operation sensitive to the accuracy of a predetermined input value. When the optimization unit 26 determines that the node represents an operation sensitive to the accuracy of a predetermined input value, the syntax tree search process proceeds to step S406. On the other hand, if the optimization unit 26 determines that the node does not represent an operation sensitive to the accuracy of a predetermined input value, the syntax tree search process proceeds to step S404.

次に、ステップS404で、最適化部26は、当該ノードの親ノードに印が付加されているか否かを判定する。最適化部26が、当該ノードの親ノードに印が付加されていると判定した場合には、構文木の探索処理は、ステップS406へ移行する。一方、最適化部26が、当該ノードの親ノードに印が付加されていないと判定した場合には、構文木の探索処理は、ステップS412へ移行する。   Next, in step S404, the optimization unit 26 determines whether or not a mark is added to the parent node of the node. When the optimization unit 26 determines that the mark is added to the parent node of the node, the syntax tree search process proceeds to step S406. On the other hand, when the optimization unit 26 determines that the mark is not added to the parent node of the node, the syntax tree search processing moves to step S412.

次に、ステップS406で、最適化部26は、当該ノードに印を付加する。   Next, in step S406, the optimization unit 26 adds a mark to the node.

次に、ステップS408で、最適化部26は、当該ノードがload命令を表すか否かを判定する。最適化部26が、当該ノードがload命令を表すと判定した場合には、構文木の探索処理は、ステップS410へ移行する。一方、最適化部26が、当該ノードがload命令を表さないと判定した場合には、構文木の探索処理は、ステップS412へ移行する。   Next, in step S408, the optimization unit 26 determines whether the node represents a load instruction. If the optimization unit 26 determines that the node represents a load instruction, the syntax tree search process proceeds to step S410. On the other hand, if the optimization unit 26 determines that the node does not represent a load instruction, the syntax tree search process moves to step S412.

次に、ステップS410で、最適化部26は、ステップS200において取得した、当該ノードのload命令の指すアドレスを記録表記憶部44に記憶されている記録表に記憶する。   Next, in step S410, the optimization unit 26 stores the address indicated by the load instruction of the node acquired in step S200 in the recording table stored in the recording table storage unit 44.

次に、ステップS412で、最適化部26は、当該ノードの全ての子ノードについて、ステップS402〜S410の処理を終了したか否かを判定する。最適化部26が、当該ノードの全ての子ノードについてステップS402の処理を終了していないと判定した場合には、構文木の探索処理は、ステップS414へ移行する。一方、最適化部26が、当該ノードの全ての子ノードについてステップS402の処理を終了したと判定した場合には、構文木の探索処理は、ステップS416へ移行する。   Next, in step S412, the optimization unit 26 determines whether or not the processing in steps S402 to S410 has been completed for all child nodes of the node. If the optimization unit 26 determines that the process in step S402 has not been completed for all child nodes of the node, the syntax tree search process proceeds to step S414. On the other hand, if the optimization unit 26 determines that the process of step S402 has been completed for all child nodes of the node, the syntax tree search process proceeds to step S416.

次に、ステップS414で、最適化部26は、当該ノードの子ノードから、処理対象となるノードを選択し、ステップS402へ移行する。   Next, in step S414, the optimization unit 26 selects a node to be processed from child nodes of the node, and proceeds to step S402.

ステップS416で、最適化部26は、当該ノードが根ノードであるか否かを判定する。最適化部26が、当該ノードが根ノードであると判定した場合には、構文木の探索処理を終了する。一方、最適化部26が、当該ノードが根ノードでないと判定した場合には、構文木の探索処理は、ステップS418へ移行する。   In step S416, the optimization unit 26 determines whether the node is a root node. When the optimization unit 26 determines that the node is the root node, the syntax tree search process ends. On the other hand, if the optimization unit 26 determines that the node is not a root node, the syntax tree search process moves to step S418.

次に、ステップS418で、最適化部26が、当該ノードの親ノードを処理対象となるノードとして決定し、構文木の探索処理は、ステップS412へ移行する。   Next, in step S418, the optimization unit 26 determines the parent node of the node as a node to be processed, and the syntax tree search processing moves to step S412.

上述のステップS308の構文木の再探索処理について、図20において詳細に説明する。図20は、ステップS308の構文木の再探索処理の一例を示すフローチャートである。図20に示す構文木の再探索処理のフローチャートにおいて、まず、ステップS500で、最適化部26は、処理対象となる構文木の根ノードを処理対象となるノードとして選択する。   The syntax tree re-search process in step S308 will be described in detail with reference to FIG. FIG. 20 is a flowchart illustrating an example of syntax tree re-search processing in step S308. In the flowchart of the syntax tree re-search process shown in FIG. 20, first, in step S500, the optimization unit 26 selects the root node of the syntax tree to be processed as the node to be processed.

次に、ステップS502で、最適化部26は、当該ノードが、store命令を表すノードか否かを判定する。最適化部26が、当該ノードが、store命令を表すノードであると判定した場合には、構文木の再探索処理は、ステップS504へ移行する。一方、最適化部26が、当該ノードが、store命令を表すノードでないと判定した場合には、構文木の再探索処理は、ステップS506へ移行する。   Next, in step S502, the optimization unit 26 determines whether the node is a node representing a store instruction. When the optimization unit 26 determines that the node is a node representing a store instruction, the syntax tree re-search process proceeds to step S504. On the other hand, when the optimization unit 26 determines that the node is not a node representing a store instruction, the syntax tree re-search process proceeds to step S506.

次に、ステップS504で、最適化部26は、ステップS200において取得した解析結果と、記録表記憶部44に記憶されている記録表とに基づいて、当該ノードが表すstore命令が指し示すアドレスと一致する可能性があるload命令が存在するか否か判定する。最適化部26が、当該ノードが表すstore命令が指し示すアドレスと一致する可能性があるload命令が存在すると判定した場合には、構文木の再探索処理は、ステップS508へ移行する。一方、最適化部26が、当該ノードが表すstore命令が指し示すアドレスと一致する可能性があるload命令が存在しないと判定した場合には、ステップS506へ移行する。   Next, in step S504, the optimization unit 26 matches the address indicated by the store instruction represented by the node based on the analysis result acquired in step S200 and the recording table stored in the recording table storage unit 44. It is determined whether or not there is a load instruction that may occur. If the optimization unit 26 determines that there is a load instruction that may match the address indicated by the store instruction represented by the node, the syntax tree re-searching process proceeds to step S508. On the other hand, if the optimization unit 26 determines that there is no load instruction that may match the address indicated by the store instruction represented by the node, the process proceeds to step S506.

次に、ステップS506で、最適化部26は、当該ノードの親ノードに印が付加されているか否かを判定する。最適化部26が、当該ノードの親ノードに印が付加されていると判定した場合には、構文木の再探索処理は、ステップS508へ移行する。一方、最適化部26が、当該ノードの親ノードに印が付加されていないと判定した場合には、構文木の再探索処理は、ステップS514へ移行する。   Next, in step S506, the optimization unit 26 determines whether or not a mark is added to the parent node of the node. If the optimization unit 26 determines that a mark is added to the parent node of the node, the syntax tree re-search process proceeds to step S508. On the other hand, when the optimization unit 26 determines that the mark is not added to the parent node of the node, the syntax tree re-search process moves to step S514.

次に、ステップS508で、最適化部26は、当該ノードに印を付加する。   Next, in step S508, the optimization unit 26 adds a mark to the node.

次に、ステップS514で、最適化部26は、当該ノードの全ての子ノードについて、ステップS502の処理を終了したか否かを判定する。最適化部26が、当該ノードの全ての子ノードについてステップS502の処理を終了していないと判定した場合には、構文木の再探索処理は、ステップS516へ移行する。一方、最適化部26が、当該ノードの全ての子ノードについてステップS502の処理を終了したと判定した場合には、構文木の探索処理は、ステップS518へ移行する。   Next, in step S514, the optimization unit 26 determines whether or not the processing in step S502 has been completed for all child nodes of the node. When the optimization unit 26 determines that the process of step S502 has not been completed for all child nodes of the node, the syntax tree re-search process proceeds to step S516. On the other hand, when the optimization unit 26 determines that the process of step S502 has been completed for all child nodes of the node, the syntax tree search process proceeds to step S518.

次に、ステップS516で、最適化部26は、当該ノードの子ノードから、処理対象となるノードを選択し、構文木の再探索処理は、ステップS502へ移行する。   Next, in step S516, the optimization unit 26 selects a node to be processed from child nodes of the node, and the syntax tree re-search process proceeds to step S502.

ステップS518で、最適化部26は、当該ノードが根ノードであるか否かを判定する。最適化部26が、当該ノードが根ノードであると判定した場合には、構文木の再探索処理を終了する。一方、最適化部26が、当該ノードが根ノードでないと判定した場合には、構文木の再探索処理は、ステップS520へ移行する。   In step S518, the optimization unit 26 determines whether the node is a root node. If the optimization unit 26 determines that the node is a root node, the syntax tree re-search process is terminated. On the other hand, when the optimization unit 26 determines that the node is not a root node, the syntax tree re-search process proceeds to step S520.

次に、ステップS520で、最適化部26が、当該ノードの親ノードを処理対象となるノードとして決定し、構文木の再探索処理は、ステップS514へ移行する。   Next, in step S520, the optimization unit 26 determines the parent node of the node as a node to be processed, and the syntax tree re-search process proceeds to step S514.

上述のステップS110の命令選択・生成処理について、図21において詳細に説明する。図21は、ステップS110の命令選択・生成処理の一例を示すフローチャートである。図21に示す命令選択・生成処理のフローチャートにおいて、まず、ステップS600で、命令生成部28は、処理対象となる構文木を決定する。   The instruction selection / generation process in step S110 will be described in detail with reference to FIG. FIG. 21 is a flowchart illustrating an example of the instruction selection / generation process in step S110. In the instruction selection / generation process flowchart shown in FIG. 21, first, in step S600, the instruction generation unit 28 determines a syntax tree to be processed.

次に、ステップS604で、命令生成部28は、ステップS108において決定した処理対象となる構文木の最適化処理の結果に基づいて、当該構文木について最適化が実施されたか否かを判定する。命令生成部28が、当該構文木について最適化が実施されたと判定する場合には、命令選択・生成処理は、ステップS608へ移行する。一方、命令生成部28が、当該構文木について最適化が実施されていないと判定した場合には、ステップS606へ移行する。   Next, in step S604, the instruction generation unit 28 determines whether or not optimization has been performed on the syntax tree based on the result of the optimization process of the syntax tree to be processed determined in step S108. When the instruction generation unit 28 determines that the optimization has been performed on the syntax tree, the instruction selection / generation process proceeds to step S608. On the other hand, if the instruction generation unit 28 determines that the optimization is not performed on the syntax tree, the process proceeds to step S606.

次に、ステップS606で、命令生成部28は、ステップS102において取得したテンプレートのうち、最適化を実施しない場合のテンプレート群から、当該構文木に対応するテンプレートを選択する。そして、命令生成部28は、選択したテンプレートに基づいて、処理対象となる構文木を目的プログラムに変換する。   Next, in step S606, the instruction generation unit 28 selects a template corresponding to the syntax tree from the template group when optimization is not performed, from the templates acquired in step S102. Then, the instruction generation unit 28 converts the syntax tree to be processed into a target program based on the selected template.

次に、ステップS608で、命令生成部28は、ステップS108において取得した処理対象となる構文木の最適化処理の結果に基づいて、当該構文木について積極的な最適化が実施されたか否かを判定する。命令生成部28が、当該構文木について積極的な最適化が実施されたと判定する場合には、命令選択・生成処理は、ステップS614へ移行する。一方、命令生成部28が、当該構文木について通常の最適化が実施されたと判定する場合には、命令選択・生成処理は、ステップS612へ移行する。   Next, in step S608, the instruction generation unit 28 determines whether or not positive optimization has been performed on the syntax tree based on the result of the optimization process of the syntax tree to be processed acquired in step S108. judge. If the instruction generation unit 28 determines that aggressive optimization has been performed on the syntax tree, the instruction selection / generation process proceeds to step S614. On the other hand, when the instruction generation unit 28 determines that normal optimization has been performed on the syntax tree, the instruction selection / generation process proceeds to step S612.

ステップS612で、命令生成部28は、ステップS102において取得したテンプレートのうち、通常の最適化を実施した場合のテンプレート群から、当該構文木に対応するテンプレートを選択する。そして、命令生成部28は、選択したテンプレートに基づいて、処理対象となる構文木を目的プログラムに変換する。   In step S612, the instruction generation unit 28 selects, from the templates acquired in step S102, a template corresponding to the syntax tree from the template group when normal optimization is performed. Then, the instruction generation unit 28 converts the syntax tree to be processed into a target program based on the selected template.

ステップS614で、命令生成部28は、ステップS102において取得したテンプレートのうち、積極的な最適化を実施した場合のテンプレート群から、当該構文木に対応するテンプレートを選択する。そして、命令生成部28は、選択したテンプレートに基づいて、処理対象となる構文木を目的プログラムに変換する。   In step S614, the instruction generation unit 28 selects a template corresponding to the syntax tree from the templates obtained when aggressive optimization is performed among the templates acquired in step S102. Then, the instruction generation unit 28 converts the syntax tree to be processed into a target program based on the selected template.

次に、ステップS618で、命令生成部28は全ての構文木について、ステップS604の処理を終了したか否かを判定する。命令生成部28が、全ての構文木についてステップS604の処理を終了したと判定した場合には、命令・選択生成処理は終了する。一方、命令生成部28が、全ての構文木についてS604の処理を終了していないと判定した場合には、命令・選択生成処理は、ステップS600へ移行する。   Next, in step S618, the instruction generation unit 28 determines whether or not the processing in step S604 has been completed for all the syntax trees. If the instruction generation unit 28 determines that the process of step S604 has been completed for all the syntax trees, the instruction / selection generation process ends. On the other hand, if the instruction generation unit 28 determines that the process of S604 has not been completed for all the syntax trees, the instruction / selection generation process proceeds to step S600.

次に、プログラムの例1及び例2を挙げて簡単に、第1の実施形態に係る構文木の探索、及び構文木の再探索について説明する。   Next, the search of the syntax tree and the re-search of the syntax tree according to the first embodiment will be briefly described with reference to Example 1 and Example 2 of the program.

まず、第1の例として、図22に示すソースプログラムについて考える。字句構文解析部24の処理により、当該ソースプログラムから生成される構文木は、図23と、図24となる。ここで、図23の構文木について、構文木の探索処理について考える。まず、最適化部26は、図25に示すように、図23の構文木の根ノードから子ノードへと再帰的に探索を開始する。このとき、最適化部26は、図26に示すように、探索の結果、入力値の精度に敏感な演算となるノードについて印を付加する。また、最適化部26は、図27、及び図28に示すように、探索の結果、親ノードに印がついている場合、探索対象となるノードに印を付加する。そして、最適化部26において、当該構文木に印が付加されているノードが含まれる場合には、積極的な最適化の実施を抑制する。図29に当該構文木について、命令生成部28の処理を行った結果を示す。   First, consider the source program shown in FIG. 22 as a first example. The syntax tree generated from the source program by the processing of the lexical syntax analysis unit 24 is shown in FIG. 23 and FIG. Here, regarding the syntax tree of FIG. 23, a syntax tree search process will be considered. First, as shown in FIG. 25, the optimization unit 26 starts a search recursively from the root node of the syntax tree of FIG. 23 to the child node. At this time, as shown in FIG. 26, the optimization unit 26 adds a mark to a node that is an operation sensitive to the accuracy of the input value as a result of the search. In addition, as illustrated in FIGS. 27 and 28, the optimization unit 26 adds a mark to a search target node when the parent node is marked as a result of the search. When the optimization unit 26 includes a node with a mark in the syntax tree, aggressive optimization is suppressed. FIG. 29 shows the result of processing of the instruction generation unit 28 for the syntax tree.

一方、図24の構文木について、構文木の探索処理について考える。まず、最適化部26は、図30に示すように、図24の構文木の根ノードから子ノードへと再帰的に探索を開始する。このとき、最適化部26は、図31〜図33に示すように、探索の結果、入力値の精度に敏感な演算となるノード、又は親ノードに印が付加されているノードが存在しないため、全てのノードに印を付加しない。そのため、積極的な最適化を実施するオプションが指定されている場合には、当該構文木に、積極的な最適化の実施を抑止することを示す印が付加されているノードが含まれないため、最適化部26が、当該構文木に対して積極的な最適化の実施をする。図34に当該構文木について、命令生成部28の処理を行った結果を示す。   On the other hand, a syntax tree search process will be considered for the syntax tree of FIG. First, as shown in FIG. 30, the optimization unit 26 recursively starts searching from the root node of the syntax tree of FIG. 24 to the child node. At this time, as shown in FIGS. 31 to 33, the optimization unit 26 does not include a node that is an operation sensitive to the accuracy of the input value or a node to which a mark is added to the parent node, as a result of the search. , Do not mark all nodes. Therefore, if the option to perform aggressive optimization is specified, the syntax tree does not include a node with a mark indicating that aggressive optimization is prohibited. The optimization unit 26 actively performs optimization on the syntax tree. FIG. 34 shows the result of processing of the instruction generation unit 28 for the syntax tree.

このように、図23の構文木については、構文木の根に近いノードに入力値の精度に敏感な演算があることが明らかとなったので、浮動小数点除算の命令生成において、積極的な最適化が抑止される。同様に、図24の構文木は構文木の中に入力値の精度に敏感な演算がないことが明らかなので、積極的な最適化が実施される。   As described above, with regard to the syntax tree of FIG. 23, it has been clarified that there is an operation sensitive to the accuracy of the input value at a node close to the root of the syntax tree. Deterred. Similarly, since it is clear that there is no operation sensitive to the accuracy of input values in the syntax tree of FIG. 24, aggressive optimization is performed.

次に、第2の例として、図35に示すソースプログラムについて考える。字句構文解析部24の処理により、当該ソースプログラムから生成される構文木は、図36左と、図36右となる。ここで、図36右、及び左の構文木について、構文木の再探索処理について考える。まず、再探索を行う段階で、図36の右、及び左の構文木の状態は、図37の右、及び左に示す構文木の状態になっており、記録表記憶部44に記憶されている記録表に図14の内容が記憶されている。この場合、図37の左の構文木の根ノードがstore命令を表すノードであるため、最適化部26は、当該ノードのstore命令が指すアドレスと記録表に記憶されているload命令のアドレスとが、一致する可能性があるか解析する。そして、一致する可能性があれば、当該ノードに印をつけ、再探索の処理を継続する。図38に一致する可能性がある場合の例を示す。また、最適化部26の再探索の処理の終了状態を図39に示す。そして、図40に当該構文木について、命令生成部28の処理を行った結果を示す。   Next, consider the source program shown in FIG. 35 as a second example. The syntax tree generated from the source program by the processing of the lexical syntax analysis unit 24 is the left side of FIG. 36 and the right side of FIG. Here, a syntax tree re-search process is considered for the right and left syntax trees in FIG. First, at the stage of re-searching, the states of the right and left syntax trees in FIG. 36 are the states of the syntax trees shown in right and left in FIG. 37 and are stored in the recording table storage unit 44. 14 is stored in the recording table. In this case, since the root node of the left syntax tree in FIG. 37 is a node representing the store instruction, the optimization unit 26 determines that the address indicated by the store instruction of the node and the address of the load instruction stored in the recording table are Analyze for possible matches. If there is a possibility of a match, the node is marked and the re-search process is continued. FIG. 38 shows an example when there is a possibility of matching. FIG. 39 shows the end state of the re-search process of the optimization unit 26. FIG. 40 shows the result of processing of the instruction generation unit 28 for the syntax tree.

このように、図39左のstore命令を表すノードを根に持つ構文木の浮動小数点命令には、「入力値の精度に敏感な演算に連絡する」ことを表明する印が付加されているため、積極的な最適化が抑止される。   As described above, since the floating-point instruction in the syntax tree having the node representing the store instruction on the left in FIG. 39 has a mark indicating that “the operation sensitive to the accuracy of the input value is communicated” is added. , Aggressive optimization is deterred.

以上説明したように、第1の実施形態によれば、入力値の精度に敏感な演算の精度を落とさずに、プログラムの他の部分の演算を高速化することができる。   As described above, according to the first embodiment, it is possible to speed up operations in other parts of the program without degrading the accuracy of operations sensitive to the accuracy of input values.

なお、第1の実施形態のコンパイラ装置における、印を付加する処理、及び印が付加されているノードを含む構文木に対して積極的な最適化の実施を抑止する処理以外の処理については、コンパイラの構成により処理内容を変更してもよい。   In the compiler apparatus according to the first embodiment, the processing other than the processing for adding a mark and the processing for suppressing the active optimization of the syntax tree including the node to which the mark is added. The processing content may be changed depending on the configuration of the compiler.

次に、第2の実施形態について説明する。なお、第1の実施形態と同様の構成及び作用となる部分については、同一符号を付して説明を省略する。   Next, a second embodiment will be described. In addition, about the part which becomes the structure and effect | action similar to 1st Embodiment, the same code | symbol is attached | subjected and description is abbreviate | omitted.

第2の実施形態では、特定の種類の積極的な最適化をコンパイラ起動時に渡すオプションで指定し、当該特定の種類の積極的な最適化を抑止の対象から外す点が第1の実施形態と異なっている。なお、第2の実施形態においては、コンパイラの起動時オプションとして、抑止の対象から外す積極的な最適化の種類を指定するオプションを新設する。また、予めオプションに指定する、積極的な最適化の種類に対応する文字列を定義しておく。また、図41に示すように積極的な最適化において実施される処理の種類と、当該処理の種類に対応する文字列と、抑止対象外か否かの情報とを格納した最適化記録表を設ける。ここで、最適化記録表の「最適化機能」の欄の情報が実施される処理の種類を表し、「オプション文字列」の欄の情報が対応する文字列を表し、「抑止対象外」の欄の情報が抑止対象外か否かの情報を表す。なお、最適化記録表の「抑止対象外」の初期値は、「No」であるとする。また、第2の実施形態においては、1つの構文木において対象となる積極的な最適化の種類は1つであるものとする。   The second embodiment is different from the first embodiment in that a specific type of aggressive optimization is specified by an option to be passed at the time of starting the compiler, and the particular type of aggressive optimization is excluded from suppression. Is different. Note that, in the second embodiment, an option for specifying the type of aggressive optimization to be excluded from the suppression target is newly provided as a compiler startup option. In addition, a character string corresponding to the type of aggressive optimization designated as an option in advance is defined. In addition, as shown in FIG. 41, an optimization record table storing the types of processing performed in the aggressive optimization, the character strings corresponding to the types of the processing, and information on whether or not the suppression is performed is provided. Provide. Here, the information in the “optimization function” column of the optimization record table indicates the type of processing to be performed, the information in the “option character string” column indicates the corresponding character string, and “unsuppressed” Indicates whether the column information is not subject to suppression. Note that the initial value of “not subject to inhibition” in the optimization record table is “No”. In the second embodiment, it is assumed that there is only one type of aggressive optimization targeted in one syntax tree.

図12は、第2の実施形態のコンパイラシステム405の一例である。図12に示すように、コンパイラシステム405は、コンパイラ装置401と、利用者端末3と、外部ディスク40とを有する。第2の実施形態に係るコンパイラ装置401は、インターネット等のネットワーク2を介して、利用者用の利用者端末3、及び外部ディスク40と相互に通信可能に接続される。   FIG. 12 is an example of the compiler system 405 of the second embodiment. As shown in FIG. 12, the compiler system 405 includes a compiler device 401, a user terminal 3, and an external disk 40. The compiler device 401 according to the second embodiment is connected to the user terminal 3 for users and the external disk 40 through the network 2 such as the Internet so as to be able to communicate with each other.

図42に、第2の実施形態に係るコンパイラ装置401の機能ブロック図を示す。図42に示すように、コンパイラ装置401は、引数解析部422、字句構文解析部24、最適化部426、命令生成部28、目的プログラム出力部30を含むコンパイラ420を有する。また、コンパイラ420は、テンプレート記憶部32、記録表記憶部44、及び最適化記録表記憶部448を有する。   FIG. 42 shows a functional block diagram of the compiler apparatus 401 according to the second embodiment. As shown in FIG. 42, the compiler device 401 includes a compiler 420 including an argument analysis unit 422, a lexical syntax analysis unit 24, an optimization unit 426, an instruction generation unit 28, and a target program output unit 30. The compiler 420 includes a template storage unit 32, a recording table storage unit 44, and an optimized recording table storage unit 448.

コンパイラ420は、利用者端末3から受信した、入力情報(コマンド)に基づいて、起動され、ネットワーク2を介して、ソースプログラム記憶部42から対象となるソースプログラムを取得する。また、コンパイラ420は、取得したソースプログラムを目的プログラムに変換し、ネットワーク2を介して、目的プログラム記憶部46に記憶する。   The compiler 420 is activated based on input information (command) received from the user terminal 3 and acquires a target source program from the source program storage unit 42 via the network 2. Further, the compiler 420 converts the acquired source program into a target program and stores it in the target program storage unit 46 via the network 2.

引数解析部422は、利用者端末3から受信した入力情報に基づいて、コンパイラの動作を決定する。引数解析部422は、取得したコンパイラの起動オプションとして、抑止の対象外とする積極的な最適化の種類に対応する文字列があるか否かを判定する。引数解析部422は、当該文字列があると判定した場合には、最適化記録表記憶部448に記憶されている、図41に示す最適化記録表の当該文字列に対応する「抑止対象外」の欄を「Yes」に設定する。なお、引数解析部422の他の処理は、第1の実施形態の引数解析部22と同様のため、説明は省略する。   The argument analysis unit 422 determines the operation of the compiler based on the input information received from the user terminal 3. The argument analysis unit 422 determines whether or not there is a character string corresponding to the aggressive optimization type that is not subject to suppression, as the acquired compiler startup option. If the argument analysis unit 422 determines that the character string exists, the argument analysis unit 422 stores “not subject to inhibition” corresponding to the character string in the optimization recording table illustrated in FIG. 41 and stored in the optimization recording table storage unit 448. "" Is set to "Yes". Since the other processing of the argument analysis unit 422 is the same as that of the argument analysis unit 22 of the first embodiment, the description thereof is omitted.

最適化部426は、字句構文解析部24において取得した構文木の各々について、引数解析部422において取得した最適化に関するコンパイラの動作に基づいて、最適化を実施する。最適化部426は、字句構文解析部24において取得した構文木の各々について、制御解析、及びデータ解析を行う。また、最適化部426は、構文木の各々について、構文木の探索と印の付加処理を行う。   The optimization unit 426 performs optimization for each syntax tree acquired by the lexical syntax analysis unit 24 based on the compiler operation related to optimization acquired by the argument analysis unit 422. The optimization unit 426 performs control analysis and data analysis for each syntax tree acquired by the lexical syntax analysis unit 24. Further, the optimization unit 426 performs syntax tree search and mark addition processing for each syntax tree.

次に、最適化部426は、引数解析部422において取得した最適化に関するコンパイラの動作に基づいて、最適化を実施するオプションが指定されていないと判定した場合には、全ての構文木について通常の最適化、及び積極的な最適化を行わない。   Next, when the optimization unit 426 determines that the option for performing the optimization is not specified based on the operation of the compiler related to the optimization acquired by the argument analysis unit 422, the optimization unit 426 normally performs processing for all the syntax trees. Do not perform optimization or aggressive optimization.

また、最適化部426は、引数解析部422において最適化を実施するオプションが指定され、かつ、積極的な最適化のオプションが指定されていないと判定した場合、全ての構文木に対して、通常の最適化を実施する。   Further, when the optimization unit 426 determines that the option for performing optimization is specified in the argument analysis unit 422 and the option for aggressive optimization is not specified, for all syntax trees, Perform normal optimization.

また、最適化部426は、引数解析部422において最適化を実施するオプションが指定され、かつ、積極的な最適化のオプションが指定されていると判定した場合には、構文木の各々に対して、通常の最適化、又は積極的な最適化を実施する。   Further, the optimization unit 426 determines that an option for performing optimization is specified in the argument analysis unit 422, and determines that an aggressive optimization option is specified, for each syntax tree. Normal optimization or aggressive optimization.

ここで、最適化を実施するオプションが指定され、かつ、積極的な最適化のオプションが指定されている場合における、通常の最適化を実施するか、積極的な最適化を実施するかの判断について説明する。まず、最適化部426は、処理対象の構文木に含まれるノードの各々に基づいて、対象となる積極的な最適化の種類を取得する。次に、最適化部426は、取得した積極的な最適化の種類が最適化記録表記憶部448に記憶されている最適化記録表にあるか否かを判定する。ここで、最適化部426は、最適化記録表に、取得した積極的な最適化の種類がある場合には、最適化記録表の当該積極的な最適化に対応する「抑止対象外」の欄が「YES」であるか否か判定する。最適化部426が、「YES」であると判定した場合には、処理対象となる構文木に積極的な最適化を実施する。   Here, when the option for performing optimization is specified and the option for aggressive optimization is specified, it is determined whether to perform normal optimization or aggressive optimization. Will be described. First, the optimization unit 426 obtains a target aggressive optimization type based on each of the nodes included in the processing target syntax tree. Next, the optimization unit 426 determines whether or not the acquired positive optimization type is in the optimization record table stored in the optimization record table storage unit 448. Here, when the optimization record table includes the type of aggressive optimization acquired, the optimization unit 426 selects “not subject to inhibition” corresponding to the aggressive optimization in the optimization record table. It is determined whether or not the column is “YES”. If the optimization unit 426 determines that the answer is “YES”, it performs aggressive optimization on the syntax tree to be processed.

一方、最適化部426は、最適化記録表に取得した積極的な最適化の種類がない、又は対象の積極的な最適化に対応する「抑止対象外」の欄が「No」である場合には、当該構文木に含まれるノードに印が付加されているか否かにより判断する。   On the other hand, the optimization unit 426 does not have the type of aggressive optimization acquired in the optimization record table, or the column “Non-suppressed” corresponding to the target aggressive optimization is “No”. Is determined based on whether or not a mark is added to a node included in the syntax tree.

最適化部426は、処理対象となる構文木に含まれるノードに印が付加されている場合には、当該構文木に対して通常の最適化を実施する。一方、最適化部426は、処理対処となる構文木に含まれるノードに印が付加されているノードが存在しない場合には、当該構文木に対して積極的な最適化を実施する。   When a mark is added to a node included in the syntax tree to be processed, the optimization unit 426 performs normal optimization on the syntax tree. On the other hand, when there is no node with a mark added to a node included in the syntax tree to be processed, the optimization unit 426 performs aggressive optimization on the syntax tree.

最適化記録表記憶部448には、図41に示すような最適化記録表が記憶されている。   The optimization record table storage unit 448 stores an optimization record table as shown in FIG.

コンパイラ装置401は、例えば図43に示すコンピュータ500で実現することができる。コンピュータ500はCPU502、一時記憶領域としてのメモリ504、及び不揮発性の記憶装置506を備える。また、コンピュータ500は、入出力装置208が接続される入出力I/F210を備える。また、コンピュータ500は、記録媒体212に対するデータの読み込み及び書き込みを制御するR/W部214、及びインターネット等のネットワーク2に接続されるネットワークI/F216を備える。CPU502、メモリ504、記憶装置506、入出力I/F210、R/W部214、及びネットワークI/F216は、バス218を介して互いに接続される。   The compiler apparatus 401 can be realized by a computer 500 shown in FIG. 43, for example. The computer 500 includes a CPU 502, a memory 504 as a temporary storage area, and a nonvolatile storage device 506. The computer 500 also includes an input / output I / F 210 to which the input / output device 208 is connected. The computer 500 also includes an R / W unit 214 that controls reading and writing of data with respect to the recording medium 212 and a network I / F 216 connected to the network 2 such as the Internet. The CPU 502, memory 504, storage device 506, input / output I / F 210, R / W unit 214, and network I / F 216 are connected to each other via a bus 218.

記憶装置506はHDD、SSD、フラッシュメモリ等によって実現できる。記憶媒体としての記憶装置506には、コンピュータ500をコンパイラ装置501として機能させるためのコンパイラプログラム600が記憶される。また、記憶装置506は、テンプレートの各々が記憶されるテンプレート記憶領域350を有する。また、記憶装置506は、記録表が記録される記録表記憶領域354と、最適化記録表が記録される最適化記録表記憶領域558とを有する。   The storage device 506 can be realized by an HDD, an SSD, a flash memory, or the like. A storage device 506 serving as a storage medium stores a compiler program 600 for causing the computer 500 to function as the compiler device 501. The storage device 506 includes a template storage area 350 in which each template is stored. Further, the storage device 506 has a recording table storage area 354 in which a recording table is recorded, and an optimized recording table storage area 558 in which an optimized recording table is recorded.

CPU502は、コンパイラプログラム600を記憶装置506から読みだしてメモリ504に展開する。また、CPU502は、コンパイラプログラム600が有するプロセスを順次実行する。また、CPU502は、最適化記録表記憶領域658に記憶された最適化記録表を読み出し、メモリ504に展開する。他の記憶領域に記憶された各種データも、第1実施形態と同様に、メモリ504に展開する。   The CPU 502 reads the compiler program 600 from the storage device 506 and expands it in the memory 504. The CPU 502 sequentially executes processes included in the compiler program 600. In addition, the CPU 502 reads the optimization record table stored in the optimization record table storage area 658 and develops it in the memory 504. Various data stored in other storage areas are also expanded in the memory 504 as in the first embodiment.

コンパイラプログラム600は、引数解析プロセス602と、字句構文解析プロセス304と、最適化プロセス606と、命令生成プロセス308と、目的プログラム出力プロセス310とを有する。   The compiler program 600 includes an argument analysis process 602, a lexical syntax analysis process 304, an optimization process 606, an instruction generation process 308, and an object program output process 310.

CPU502は、引数解析プロセス602を実行することで、図42に示す引数解析部422として動作する。また、CPU502は、最適化プロセス606を実行することで、図42に示す最適化部426として動作する。他のプロセスについては、第1実施形態におけるコンパイラプログラム300のプロセスと同様である。   The CPU 502 operates as the argument analysis unit 422 illustrated in FIG. 42 by executing the argument analysis process 602. Further, the CPU 502 operates as the optimization unit 426 illustrated in FIG. 42 by executing the optimization process 606. Other processes are the same as those of the compiler program 300 in the first embodiment.

なお、コンパイラ装置501は、例えば半導体集積回路、より詳しくはASIC等で実現することも可能である。   The compiler device 501 can be realized by, for example, a semiconductor integrated circuit, more specifically, an ASIC or the like.

次に、第2の実施形態に係るコンパイラ装置501の作用について説明する。まず、利用者端末3から受信された入力情報をコンパイラ装置501が受け付けると、コンパイラ装置501において、図44に示すコンパイル処理が実行される。なお、コンパイラ装置501により実行されるコンパイル処理は、開示する技術のコンパイラ方法の一例である   Next, the operation of the compiler apparatus 501 according to the second embodiment will be described. First, when the compiler apparatus 501 receives input information received from the user terminal 3, the compiler apparatus 501 executes a compilation process shown in FIG. Note that the compilation processing executed by the compiler apparatus 501 is an example of a compiler method of the disclosed technology.

図44は、コンパイル処理の一例を示すフローチャートである。図44に示すコンパイル処理のフローチャートにおいて、まず、ステップS700で、引数解析部422は、最適化記録表記憶部448から最適化記録表を取得する。   FIG. 44 is a flowchart illustrating an example of compilation processing. 44, first, in step S700, the argument analysis unit 422 acquires an optimization record table from the optimization record table storage unit 448.

次に、ステップS702で、引数解析部422は、引数解析を行う。   Next, in step S702, the argument analysis unit 422 performs argument analysis.

ステップS106の次のステップS704で、最適化部426は、ステップS104において取得した構文木の各々について、ステップS702において取得したオプション解析の結果に基づいて、最適化を実施する。   In step S704 subsequent to step S106, the optimization unit 426 performs optimization on each syntax tree acquired in step S104 based on the result of the option analysis acquired in step S702.

上述のステップS702の引数解析の処理について、図45において詳細に説明する。なお、図45において、図示は省略するが、第1の実施形態のステップS100において実施された引数解析処理も、当該引数解析処理において行われるものとする。図45は、ステップS702の引数解析処理の一例を示すフローチャートである。図45に示す引数解析処理のフローチャートにおいて、まず、ステップS800で、引数解析部422は、入力情報において、抑止の対象から外す積極的な最適化を指定するオプションが指定されているか否かを判定する。引数解析部422が、抑止の対象から外す積極的な最適化を指定するオプションが指定されていると判定した場合には、引数解析処理は、ステップS802へ移行する。一方、引数解析部422が、抑止の対象から外す積極的な最適化を指定するオプションが指定されていないと判定した場合には、引数解析処理を終了する。   The argument analysis process in step S702 will be described in detail with reference to FIG. In FIG. 45, although not shown, the argument analysis process performed in step S100 of the first embodiment is also performed in the argument analysis process. FIG. 45 is a flowchart illustrating an example of the argument analysis process in step S702. In the argument analysis processing flowchart shown in FIG. 45, first, in step S800, the argument analysis unit 422 determines whether or not an option for specifying aggressive optimization to be excluded from the suppression target is specified in the input information. To do. If the argument analysis unit 422 determines that an option that specifies aggressive optimization to be excluded from the suppression target is specified, the argument analysis processing proceeds to step S802. On the other hand, when the argument analysis unit 422 determines that the option for specifying the positive optimization to be excluded from the suppression target is not specified, the argument analysis process ends.

次に、ステップS802で、引数解析部422は、ステップS800において取得した抑止の対象から外す積極的な最適化を指定するオプションの文字列を切り出す。   Next, in step S802, the argument analysis unit 422 cuts out an optional character string that specifies aggressive optimization to be removed from the suppression target acquired in step S800.

次に、ステップS806で、引数解析部422は、ステップS700において取得した最適化記録表の「オプション文字列」の欄が、ステップS802において取得した文字列となる、「抑止対象外」の欄を「YES」に変更する。   Next, in step S806, the argument analysis unit 422 sets the “non-suppression target” field in which the “option character string” field of the optimization record table acquired in step S700 is the character string acquired in step S802. Change to "YES".

上述のステップS704の最適化処理について、図46において詳細に説明する。図46は、ステップS704の最適化処理の一例を示すフローチャートである。図46に示す最適化処理のフローチャートにおいて、ステップS210で肯定判定されると、最適化処理はステップS900へ移行する。ステップS900で、最適化部426は、処理対象となる構文木に含まれるノードの各々に基づいて、対象となる積極的な最適化の種類を取得する。   The optimization process in step S704 described above will be described in detail with reference to FIG. FIG. 46 is a flowchart illustrating an example of the optimization process in step S704. In the optimization process flowchart shown in FIG. 46, if an affirmative determination is made in step S210, the optimization process proceeds to step S900. In step S900, the optimization unit 426 acquires a target aggressive optimization type based on each node included in the processing target syntax tree.

ステップS902で、最適化部426は、ステップS900において取得した積極的な最適化の種類と、ステップS700において取得した最適化記録表に基づいて、処理対象となる積極的な最適化が抑止対象外か否かを判定する。最適化部426が、処理対象となる積極的な最適化が抑止対象外であると判定した場合には、最適化処理は、ステップS214へ移行する。一方、最適化部426が、処理対象となる積極的な最適化が抑止対象であると判定した場合には、ステップS212へ移行する。   In step S902, the optimization unit 426 determines that the active optimization to be processed is not to be inhibited based on the type of aggressive optimization acquired in step S900 and the optimization record table acquired in step S700. It is determined whether or not. If the optimization unit 426 determines that the aggressive optimization to be processed is not the suppression target, the optimization process proceeds to step S214. On the other hand, when the optimizing unit 426 determines that the active optimization to be processed is a suppression target, the process proceeds to step S212.

ステップS900で、最適化部426は、ステップS900において取得した積極的な最適化と、ステップS700において取得した最適化記録表に基づいて、処理対象となる積極的な最適化が抑止対象外か否かを判定する。最適化部426が、処理対象となる積極的な最適化が抑止対象外であると判定した場合には、最適化処理は、ステップS214へ移行する。一方、最適化部426が、処理対象となる積極的な最適化が抑止対象であると判定した場合には、ステップS212へ移行する。   In step S900, the optimization unit 426 determines whether the active optimization to be processed is out of the suppression target based on the active optimization acquired in step S900 and the optimization record table acquired in step S700. Determine whether. If the optimization unit 426 determines that the aggressive optimization to be processed is not the suppression target, the optimization process proceeds to step S214. On the other hand, when the optimizing unit 426 determines that the active optimization to be processed is a suppression target, the process proceeds to step S212.

以上説明したように、第2の実施形態によれば、入力値の精度に敏感な演算の精度を落とさずに、プログラムの他の部分の演算を高速化することができる。   As described above, according to the second embodiment, it is possible to speed up operations in other parts of the program without degrading the accuracy of operations sensitive to the accuracy of input values.

また、積極的な最適化の抑止の対象外とするオプションを指定可能とすることで、より高速化を実現することができる。例えば、当該コンパイラの行うことの出来る積極的な最適化のうちいくつかを適用しても、その最適化の対象となった処理が生成したデータが入力値の精度に敏感な演算に影響しないと判断できる場合である。   Further, by making it possible to specify options that are not subject to aggressive optimization suppression, higher speed can be realized. For example, even if some of the aggressive optimizations that the compiler can perform are applied, the data generated by the process targeted for the optimization will not affect operations sensitive to the accuracy of the input values. This is a case where it can be determined.

次に、第3の実施形態について説明する。なお、第1の実施形態と同様の構成及び作用となる部分については、同一符号を付して説明を省略する。   Next, a third embodiment will be described. In addition, about the part which becomes the structure and effect | action similar to 1st Embodiment, the same code | symbol is attached | subjected and description is abbreviate | omitted.

第3の実施形態では、特定の種類の入力値の精度に敏感な演算をコンパイラ起動時に渡すオプションで指定し、当該演算の入力データを生成する全ての種類の積極的な最適化を抑止の対象から外す点が第1の実施形態と異なっている。なお、第3の実施形態においては、コンパイラの起動時オプションとして、抑止の対象から外す、入力値の精度に敏感な演算の種類を指定するオプションを新設する。また、予めオプションに指定する、入力値の精度に敏感な演算の種類に対応する文字列を定義しておく。また、図47に示すように演算の種類と、当該演算の種類に対応する文字列と、抑止対象外か否かの情報とを格納した指定処理記録表を設ける。ここで、指定処理記録表の「演算種」の欄の情報が実施される演算の種類を表し、「オプション文字列」の欄の情報が対応する文字列を表し、「抑止対象外」の欄の情報が抑止対象外か否かの情報を表す。なお、指定処理記録表の「抑止対象外」の初期値は、「No」であるとする。   In the third embodiment, an operation that is sensitive to the accuracy of a specific type of input value is specified by an option that is passed when the compiler is started, and all types of aggressive optimization that generates input data of the operation are to be suppressed. This is different from the first embodiment in that it is removed from the first embodiment. In the third embodiment, an option for specifying the type of operation sensitive to the accuracy of the input value, which is excluded from the suppression target, is newly provided as a compiler startup option. In addition, a character string corresponding to the type of calculation sensitive to the accuracy of the input value, which is designated as an option in advance, is defined. Further, as shown in FIG. 47, there is provided a designation process record table storing the type of calculation, a character string corresponding to the type of calculation, and information on whether or not the object is a suppression target. Here, the information in the “Calculation type” column of the specified processing record table indicates the type of calculation to be performed, the information in the “Option character string” column indicates the corresponding character string, and the “Not subject to suppression” column This information indicates whether or not the information is not subject to suppression. It is assumed that the initial value of “not subject to inhibition” in the designation processing record table is “No”.

図12は、第3の実施形態のコンパイラシステム705の一例である。図12に示すようにコンパイラシステム705は、コンパイラ装置701と、利用者端末3と、外部ディスク40とを有する。第3の実施形態に係るコンパイラ装置701は、インターネット等のネットワーク2を介して、利用者用の利用者端末3、及び外部ディスク40と相互に通信可能に接続される。   FIG. 12 is an example of the compiler system 705 according to the third embodiment. As shown in FIG. 12, the compiler system 705 includes a compiler device 701, a user terminal 3, and an external disk 40. A compiler apparatus 701 according to the third embodiment is connected to a user terminal 3 for users and an external disk 40 via a network 2 such as the Internet so as to be able to communicate with each other.

図48に、第3の実施形態に係るコンパイラ装置701の機能ブロック図を示す。図48に示すように、コンパイラ装置701は、引数解析部722、字句構文解析部24、最適化部726、命令生成部28、目的プログラム出力部30、及びテンプレート記憶部32を含むコンパイラ720を有する。また、コンパイラ720は、記録表記憶部44、及び指定処理記録表記憶部748を有する。   FIG. 48 shows a functional block diagram of a compiler apparatus 701 according to the third embodiment. As shown in FIG. 48, the compiler apparatus 701 includes a compiler 720 including an argument analysis unit 722, a lexical syntax analysis unit 24, an optimization unit 726, an instruction generation unit 28, a target program output unit 30, and a template storage unit 32. . Further, the compiler 720 includes a recording table storage unit 44 and a designation processing recording table storage unit 748.

コンパイラ720は、利用者端末3から受信した、入力情報(コマンド)に基づいて、起動され、ネットワーク2を介して、ソースプログラム記憶部42から対象となるソースプログラムを取得する。また、コンパイラ720は、取得したソースプログラムを目的プログラムに変換し、ネットワーク2を介して、目的プログラム記憶部46に記憶する。   The compiler 720 is activated based on input information (command) received from the user terminal 3, and acquires a target source program from the source program storage unit 42 via the network 2. Further, the compiler 720 converts the acquired source program into a target program and stores it in the target program storage unit 46 via the network 2.

引数解析部722は、利用者端末3から受信した入力情報に基づいて、コンパイラの動作を決定する。引数解析部722は、取得したコンパイラの起動オプションとして、抑止の対象外とする入力値の精度に敏感な演算に対応する文字列があるか否かを判定する。引数解析部722は、当該文字列があると判定した場合には、指定処理記録表記憶部748に記憶されている、図47に示す指定処理記録表の当該文字列に対応する「抑止対象外」の欄を「Yes」に設定する。なお、引数解析部722の他の処理は、第1の実施形態の引数解析部22と同様のため、説明は省略する。   The argument analysis unit 722 determines the operation of the compiler based on the input information received from the user terminal 3. The argument analysis unit 722 determines whether there is a character string corresponding to an operation sensitive to the accuracy of an input value that is not subject to suppression, as the acquired compiler startup option. If the argument analysis unit 722 determines that the character string exists, the argument analysis unit 722 stores “not subject to inhibition” corresponding to the character string in the designation process record table illustrated in FIG. 47 stored in the designation process record table storage unit 748. "" Is set to "Yes". Since the other processing of the argument analysis unit 722 is the same as that of the argument analysis unit 22 of the first embodiment, description thereof is omitted.

最適化部726は、字句構文解析部24において取得した構文木の各々について、引数解析部722において取得した最適化に関するコンパイラの動作に基づいて、最適化を実施する。最適化部726は、字句構文解析部24において取得した構文木の各々について、制御解析、及びデータ解析を行う。   The optimization unit 726 performs optimization for each syntax tree acquired by the lexical syntax analysis unit 24 based on the compiler operation related to optimization acquired by the argument analysis unit 722. The optimization unit 726 performs control analysis and data analysis for each syntax tree acquired by the lexical syntax analysis unit 24.

次に、最適化部726は、構文木の各々について、当該構文木のノードを探索し、当該構文木に含まれるノードのうち、入力値の精度に敏感な演算の入力値に関わる演算に関わるノードに対して印付けを行う。   Next, the optimization unit 726 searches each syntax tree for a node of the syntax tree, and relates to an operation related to an input value that is sensitive to the accuracy of the input value among the nodes included in the syntax tree. Mark the node.

具体的には、まず、最適化部726は、構文木の各々のうち、処理対象となる構文木の根ノードを処理対象となるノードとして決定する。次に、最適化部726は、当該ノードが、「入力値の精度に敏感な演算を表すノード」かつ、「当該演算が抑止の対象外でない」、及び「親ノードに印がついている」という2つの条件のうち少なくとも1つを満たしているか判定する。ここで、「当該演算が抑止の対象外でない」か否かの判定には、指定処理記録表記憶部748に記憶されている指定処理記録表に、対象となる演算に対応する演算種があり、かつ、当該「抑止対象外」の欄が「Nо」となっているかにより判定する。最適化部726が、演算種があり、かつ、当該「抑止対象外」の欄が「No」となっていると判定した場合には、「当該演算が抑止の対象外でない」と判定する。一方、最適化部726が、演算種があり、かつ、当該「抑止対象外」の欄が「YES」となっていると判定した場合には、「当該演算が抑止の対象外」と判定する。   Specifically, first, the optimization unit 726 determines the root node of the syntax tree to be processed among the syntax trees as the node to be processed. Next, the optimization unit 726 says that the node is “a node representing an operation sensitive to the accuracy of the input value”, “the operation is not subject to inhibition”, and “the parent node is marked”. It is determined whether at least one of the two conditions is satisfied. Here, in determining whether or not “the operation is not subject to inhibition”, there is an operation type corresponding to the target operation in the specified process record table stored in the specified process record table storage unit 748. In addition, the determination is made based on whether the “non-suppression subject” column is “Nо”. If the optimization unit 726 determines that there is an operation type and that the “not subject to inhibition” column is “No”, it determines that “the operation is not subject to inhibition”. On the other hand, when the optimization unit 726 determines that there is an operation type and the “not subject to inhibition” field is “YES”, the optimization unit 726 judges that “the operation is not subject to inhibition”. .

次に、最適化部726は、条件を満たしていると判定した場合、当該ノードに印を付加する。次に、最適化部726は、当該ノードがload命令か否かを判定する。最適化部726は、当該ノードがload命令である場合には、当該load命令の指すアドレスを記録表記憶部44に記憶されている記録表に記憶する。最適化部726は、第1の実施形態の最適化部26と同様に、処理対象のノードに未処理の子ノードが存在しなくなるまで、同様の処理を再帰的に繰り返すことにより、構文木の各々について、当該構文木に含まれるノードの各々について印を付加する処理を行う。   Next, when the optimization unit 726 determines that the condition is satisfied, the optimization unit 726 adds a mark to the node. Next, the optimization unit 726 determines whether the node is a load instruction. When the node is a load instruction, the optimization unit 726 stores the address indicated by the load instruction in the recording table stored in the recording table storage unit 44. Similar to the optimization unit 26 of the first embodiment, the optimization unit 726 recursively repeats the same processing until there are no unprocessed child nodes in the processing target node, thereby generating a syntax tree. For each, a process of adding a mark to each of the nodes included in the syntax tree is performed.

次に、最適化部726は、構文木の各々について、当該構文木を再探索し、当該構文木に含まれるノードのうち、別の構文木の入力値の精度に敏感な演算の入力値に関わる演算に関わるノードに対して印を付加する。   Next, the optimization unit 726 re-searches the syntax tree for each syntax tree, and sets the input value of an operation sensitive to the accuracy of the input value of another syntax tree among the nodes included in the syntax tree. A mark is added to a node related to an operation involved.

指定処理記録表記憶部748には、図47に示すような指定処理記録表が記憶されている。   The designation process record table storage unit 748 stores a designation process record table as shown in FIG.

コンパイラ装置701は、例えば図49に示すコンピュータ800で実現することができる。コンピュータ800はCPU802、一時記憶領域としてのメモリ804、及び不揮発性の記憶装置806を備える。また、コンピュータ800は、入出力装置208が接続される入出力I/F210を備える。また、コンピュータ800は、記録媒体212に対するデータの読み込み及び書き込みを制御するR/W部214、及びインターネット等のネットワーク2に接続されるネットワークI/F216を備える。CPU802、メモリ804、記憶装置806、入出力I/F210、R/W部214、及びネットワークI/F216は、バス218を介して互いに接続される。   The compiler apparatus 701 can be realized by a computer 800 shown in FIG. 49, for example. The computer 800 includes a CPU 802, a memory 804 as a temporary storage area, and a nonvolatile storage device 806. The computer 800 also includes an input / output I / F 210 to which the input / output device 208 is connected. The computer 800 also includes an R / W unit 214 that controls reading and writing of data with respect to the recording medium 212 and a network I / F 216 connected to the network 2 such as the Internet. The CPU 802, the memory 804, the storage device 806, the input / output I / F 210, the R / W unit 214, and the network I / F 216 are connected to each other via a bus 218.

記憶装置806はHDD、SSD、フラッシュメモリ等によって実現できる。記憶媒体としての記憶装置806には、コンピュータ800をコンパイラ装置701として機能させるためのコンパイラプログラム900が記憶される。また、記憶装置806は、テンプレートの各々が記憶されるテンプレート記憶領域350を有する。また、記憶装置806は、記録表が記録される記録表記憶領域354と、指定処理記録表が記録される指定処理記録表記憶領域958とを有する。   The storage device 806 can be realized by an HDD, an SSD, a flash memory, or the like. A storage device 806 as a storage medium stores a compiler program 900 for causing the computer 800 to function as the compiler device 701. The storage device 806 includes a template storage area 350 in which each template is stored. Further, the storage device 806 has a recording table storage area 354 in which a recording table is recorded, and a designated process recording table storage area 958 in which a designated process recording table is recorded.

CPU802は、コンパイラプログラム900を記憶装置806から読みだしてメモリ804に展開する。また、CPU802は、コンパイラプログラム900が有するプロセスを順次実行する。また、CPU802は、指定処理記録表記憶領域958に記憶された指定処理記録表を読み出し、メモリ804に展開する。他の記憶領域に記憶された各種データも、第1実施形態と同様に、メモリ504に展開する。   The CPU 802 reads the compiler program 900 from the storage device 806 and expands it in the memory 804. The CPU 802 sequentially executes processes included in the compiler program 900. Further, the CPU 802 reads the designated process record table stored in the designated process record table storage area 958 and develops it in the memory 804. Various data stored in other storage areas are also expanded in the memory 504 as in the first embodiment.

コンパイラプログラム900は、引数解析プロセス902と、字句構文解析プロセス304と、最適化プロセス906と、命令生成プロセス308と、目的プログラム出力プロセス310とを有する。   The compiler program 900 includes an argument analysis process 902, a lexical syntax analysis process 304, an optimization process 906, an instruction generation process 308, and an object program output process 310.

CPU802は、引数解析プロセス902を実行することで、図48に示す引数解析部722として動作する。また、CPU802は、最適化プロセス906を実行することで、図48に示す最適化部726として動作する。他のプロセスについては、第1実施形態におけるコンパイラプログラム300のプロセスと同様である。   The CPU 802 operates as the argument analysis unit 722 illustrated in FIG. 48 by executing the argument analysis process 902. Further, the CPU 802 operates as the optimization unit 726 illustrated in FIG. 48 by executing the optimization process 906. Other processes are the same as those of the compiler program 300 in the first embodiment.

なお、コンパイラ装置701は、例えば半導体集積回路、より詳しくはASIC等で実現することも可能である。   The compiler device 701 can be realized by, for example, a semiconductor integrated circuit, more specifically, an ASIC or the like.

次に、第3の実施形態に係るコンパイラ装置701の作用について説明する。まず、利用者端末3から受信された入力情報をコンパイラ装置701が受け付けると、コンパイラ装置701において、図50に示すコンパイル処理が実行される。なお、コンパイラ装置701により実行されるコンパイル処理は、開示する技術のコンパイラ方法の一例である   Next, the operation of the compiler apparatus 701 according to the third embodiment will be described. First, when the compiler apparatus 701 receives input information received from the user terminal 3, the compiler apparatus 701 executes a compilation process shown in FIG. Note that the compilation processing executed by the compiler device 701 is an example of a compiler method of the disclosed technology.

図50は、コンパイル処理の一例を示すフローチャートである。図50に示すコンパイル処理のフローチャートにおいて、まず、ステップS1100で、引数解析部722は、指定処理記録表記憶部748から指定処理記録表を取得する。   FIG. 50 is a flowchart illustrating an example of the compiling process. In the flowchart of the compilation process shown in FIG. 50, first, in step S1100, the argument analysis unit 722 acquires a designated process record table from the designated process record table storage unit 748.

次に、ステップS1102で、引数解析部722は、引数解析を行う。   Next, in step S1102, the argument analysis unit 722 performs argument analysis.

ステップS106の次のステップS1104で、最適化部726は、ステップS104において取得した構文木の各々について、ステップS1102において取得したオプション解析の結果に基づいて、最適化を実施する。   In step S1104 following step S106, the optimization unit 726 performs optimization on each syntax tree acquired in step S104 based on the result of the option analysis acquired in step S1102.

上述のステップS1102の引数解析の処理について、図51において詳細に説明する。なお、図51において、図示は省略するが、第1の実施形態のステップS100において実施された引数解析処理も、当該引数解析処理において行われるものとする。図51は、ステップS1102の引数解析処理の一例を示すフローチャートである。図51に示す引数解析処理のフローチャートにおいて、まず、ステップS1150で、引数解析部722は、入力情報において、抑止の対象から外す入力値の精度に敏感な演算を指定するオプションが指定されているか否かを判定する。引数解析部722が、抑止の対象から外す入力値の精度に敏感な演算を指定するオプションが指定されていると判定した場合には、引数解析処理は、ステップS1152へ移行する。一方、引数解析部722が、抑止の対象から外す入力値の精度に敏感な演算を指定するオプションが指定されていないと判定した場合には、引数解析処理を終了する。   The argument analysis processing in step S1102 will be described in detail with reference to FIG. In FIG. 51, although not shown, the argument analysis process performed in step S100 of the first embodiment is also performed in the argument analysis process. FIG. 51 is a flowchart illustrating an example of the argument analysis processing in step S1102. In the flowchart of the argument analysis processing shown in FIG. 51, first, in step S1150, the argument analysis unit 722 determines whether or not an option for specifying an operation sensitive to the accuracy of the input value to be excluded from the suppression target is specified in the input information. Determine whether. If the argument analysis unit 722 determines that an option for specifying an operation sensitive to the accuracy of the input value to be excluded from the suppression target is specified, the argument analysis process proceeds to step S1152. On the other hand, when the argument analysis unit 722 determines that the option for specifying the operation sensitive to the accuracy of the input value to be excluded from the suppression target is not specified, the argument analysis process is terminated.

次に、ステップS1152で、引数解析部722は、ステップS1150において取得した抑止の対象から外す入力値の精度に敏感な演算を指定するオプションの文字列を切り出す。   Next, in step S1152, the argument analysis unit 722 cuts out an optional character string that specifies an operation sensitive to the accuracy of the input value excluded from the suppression target acquired in step S1150.

次に、ステップS1154で、引数解析部722は、ステップS1100において取得した指定処理記録表の「オプション文字列」の欄が、ステップS1152において取得した文字列となる、「抑止対象外」の欄を「YES」に変更する。   Next, in step S1154, the argument analysis unit 722 sets the “non-suppression target” field in which the “option character string” field of the designation processing record table acquired in step S1100 is the character string acquired in step S1152. Change to "YES".

上述のステップS1104の最適化処理について、図52において詳細に説明する。図52は、ステップS1104の最適化処理の一例を示すフローチャートである。図52に示す最適化処理のフローチャートにおいて、ステップS200の次のステップS1200で、最適化部726は、ステップS106において取得した構文木の各々について、構文木の探索を行う。また、最適化部726は、探索された構文木の入力値の精度に敏感な演算の入力値に関わる演算に関わるノードに対して印を付加する。   The optimization process in step S1104 described above will be described in detail with reference to FIG. FIG. 52 is a flowchart illustrating an example of the optimization process in step S1104. In the optimization processing flowchart shown in FIG. 52, in step S1200 subsequent to step S200, the optimization unit 726 searches the syntax tree for each of the syntax trees acquired in step S106. Further, the optimization unit 726 adds a mark to a node related to an operation related to an input value of an operation sensitive to the accuracy of the input value of the searched syntax tree.

上述のステップS1200の構文木の探索と印付け処理について、図53において詳細に説明する。図53は、ステップS1200の構文木の探索と印の付加処理の一例を示すフローチャートである。図53に示す構文木の探索と印の付加処理のフローチャートにおいて、ステップS300の次のステップS1300で、最適化部726は、処理対象となる構文木について探索を行い、対象となるノードに印を付加する。   The syntax tree search and marking process in step S1200 will be described in detail with reference to FIG. FIG. 53 is a flowchart illustrating an example of syntax tree search and mark addition processing in step S1200. In the flowchart of the syntax tree search and mark addition process shown in FIG. 53, in step S1300 subsequent to step S300, the optimization unit 726 searches for the syntax tree to be processed and marks the target node. Append.

上述のステップS1300の構文木の探索処理について、図54において詳細に説明する。図54は、ステップS1300の構文木の探索処理の一例を示すフローチャートである。図54に示す構文木の探索処理のフローチャートにおいて、ステップS402で、処理対象のノードが示す演算が対象の演算であるとして、肯定判定されると、構文木の探索処理はステップS1400へ移行する。ステップS1400で、最適化部726は、処理対象のノードが示す演算が、ステップS1100において取得した指定処理記録表に存在し、当該演算に対応する「抑止対象外」の欄が「YES」か否かを判定する。最適化部726が、指定処理記録表に存在し、当該演算に対応する「抑止対象外」の欄が「YES」であると判定した場合には、構文木の探索処理は、ステップS404へ移行する。一方、最適化部726が、指定処理記録表に存在しない、又は、当該演算に対応する「抑止対象外」の欄が「No」であると判定した場合には、構文木の探索処理は、ステップS406へ移行する。   The syntax tree search process in step S1300 will be described in detail with reference to FIG. FIG. 54 is a flowchart illustrating an example of syntax tree search processing in step S1300. In the flowchart of the syntax tree search process shown in FIG. 54, if an affirmative determination is made in step S402 that the operation indicated by the processing target node is the target operation, the syntax tree search process proceeds to step S1400. In step S1400, the optimization unit 726 determines whether or not the operation indicated by the processing target node exists in the designated processing record table acquired in step S1100, and the “non-suppression subject” column corresponding to the operation is “YES”. Determine whether. If the optimization unit 726 determines that the “non-suppression subject” column corresponding to the calculation is “YES”, the syntax tree search process proceeds to step S404. To do. On the other hand, when the optimization unit 726 determines that the column of “non-suppression target” corresponding to the calculation does not exist or “No” is “No”, The process proceeds to step S406.

以上説明したように、第3の実施形態によれば、入力値の精度に敏感な演算の精度を落とさずに、プログラムの他の部分の演算を高速化することができる。   As described above, according to the third embodiment, it is possible to speed up operations in other parts of the program without degrading the accuracy of operations sensitive to the accuracy of input values.

また、入力値の精度に敏感な演算を積極的な最適化の抑止の対象外とするオプションを指定可能とすることで、より高速化を実現することができる。例えば、当該データに、プログラムに積極的な最適化を適用した場合に通常の最適化と異なる結果を生成するような特殊な値を含まないと判断できる場合、それらの積極的な最適化は抑止の対象から外すことができる。   Further, it is possible to realize a higher speed by making it possible to specify an option that excludes an operation that is sensitive to the accuracy of the input value from the object of aggressive optimization suppression. For example, if it can be determined that the data does not contain special values that produce results that differ from normal optimization when aggressive optimization is applied to the program, such aggressive optimization is suppressed. Can be removed from the target.

また、上記では、開示する技術に係る各プログラムが記憶装置206、506、及び806に予め記憶(インストール)されている態様を説明したが、これに限定されない。開示の技術に係る各プログラムは、CD−ROM、DVD−ROM、USBメモリ等の記録媒体に記録された形態で提供することも可能である。   In the above description, the mode in which the programs according to the disclosed technology are stored (installed) in advance in the storage devices 206, 506, and 806 has been described. However, the present invention is not limited to this. Each program according to the disclosed technology can be provided in a form recorded on a recording medium such as a CD-ROM, a DVD-ROM, or a USB memory.

以上の実施形態に関し、更に以下の付記を開示する。   Regarding the above embodiment, the following additional notes are disclosed.

(付記1)
コンパイルの対象となる第1プログラムに含まれる複数の演算の各々を表す複数の構造体と、前記複数の演算間のデータの入出力の関係を表すデータ依存関係とを取得し、
前記取得された構造体の各々について、前記取得された前記構造体によって表わされる前記演算が、入力値の精度に応じて出力結果が特定の影響を受ける演算である場合に前記構造体に印を付加し、
前記取得されたデータ依存関係に基づいて、前記印が付加された前記構造体によって表わされる演算に対して特定のデータ依存関係を有する演算を表す構造体に他の印を付加し、
前記印が付加されていない構造体のうち、前記第1プログラムに対して前記コンパイルを施すことによって取得予定の第2プログラムの実行が特定の条件下で異なる結果を生成する演算の内容に置き換える最適化の対象となる構造体に対して前記最適化を実施する、
ことを含む処理をコンピュータに実行させるコンパイラプログラム。
(付記2)
前記複数の構造体を取得する処理は、更に、データを読み出す命令を表す構造体と、データを格納する命令を表す構造体と、演算及び読み出す命令の間のデータ依存関係とを取得し、
前記データ依存関係を有する演算を表す構造体に印を付す処理は、前記取得されたデータ依存関係に基づいて、前記印が付加された前記構造体の演算との間でデータ依存関係を有する演算を表す構造体、及び前記印が付加された前記構造体の演算との間でデータ依存関係を有する前記読み出す命令を表す構造体に他の印を付加し、前記印が付加された前記構造体の読み出し命令が読み出すデータを格納する命令を表す構造体に他の印を付加する付記1記載のコンパイラプログラム。
(付記3)
前記最適化を実施する処理は、更に、前記最適化の対象となる演算のうち、抑止対象外として指定された前記最適化の対象となる演算を表す前記構造体であって、かつ、前記印が付加された前記構造体に対して前記最適化を実施する付記1又は2記載のコンパイラプログラム。
(付記4)
前記演算である場合に前記構造体に印を付加する処理は、前記取得された演算を表す構造体の各々について、前記演算が、入力値の精度に応じて出力結果が特定の影響を受ける演算である場合であって、かつ、前記最適化の対象となる演算のうち、抑止対象外として指定された前記最適化の対象となる前記演算でない場合に前記構造体に印を付加する付記1又は2記載のコンパイラプログラム。
(付記5)
コンパイルの対象となる第1プログラムに含まれる複数の演算の各々を表す複数の構造体と、前記複数の演算間のデータの入出力の関係を表すデータ依存関係とを取得し、
前記取得された構造体の各々について、前記取得された前記構造体によって表わされる前記演算が、入力値の精度に応じて出力結果が特定の影響を受ける演算である場合に前記構造体に印を付加し、
前記取得されたデータ依存関係に基づいて、前記印が付加された前記構造体によって表わされる演算に対して特定のデータ依存関係を有する演算を表す構造体に他の印を付加し、
前記印が付加されていない構造体のうち、前記第1プログラムに対して前記コンパイルを施すことによって取得予定の第2プログラムの実行が特定の条件下で異なる結果を生成する演算の内容に置き換える最適化の対象となる構造体に対して前記最適化を実施する、
ことを含むコンパイラ方法。
(付記6)
前記複数の構造体を取得する処理は、更に、データを読み出す命令を表す構造体と、データを格納する命令を表す構造体と、演算及び読み出す命令の間のデータ依存関係とを取得し、
前記データ依存関係を有する演算を表す構造体に印を付す処理は、前記取得されたデータ依存関係に基づいて、前記印が付加された前記構造体の演算との間でデータ依存関係を有する演算を表す構造体、及び前記印が付加された前記構造体の演算との間でデータ依存関係を有する前記読み出す命令を表す構造体に他の印を付加し、前記印が付加された前記構造体の読み出し命令が読み出すデータを格納する命令を表す構造体に他の印を付加する付記5記載のコンパイラ方法。
(付記7)
前記最適化を実施する処理は、更に、前記最適化の対象となる演算のうち、抑止対象外として指定された前記最適化の対象となる演算を表す前記構造体であって、かつ、前記印が付加された前記構造体に対して前記最適化を実施する付記5又は6記載のコンパイラ方法。
(付記8)
前記演算である場合に前記構造体に印を付加する処理は、前記取得された演算を表す構造体の各々について、前記演算が、入力値の精度に応じて出力結果が特定の影響を受ける演算である場合であって、かつ、前記最適化の対象となる演算のうち、抑止対象外として指定された前記最適化の対象となる前記演算でない場合に前記構造体に印を付加する付記5又は6記載のコンパイラ方法。
(付記9)
コンパイルの対象となる第1プログラムに含まれる複数の演算の各々を表す複数の構造体と、前記複数の演算間のデータの入出力の関係を表すデータ依存関係とを取得する字句構文解析部と、
前記取得された構造体の各々について、前記取得された前記構造体によって表わされる前記演算が、入力値の精度に応じて出力結果が特定の影響を受ける演算である場合に前記構造体に印を付加し、
前記取得されたデータ依存関係に基づいて、前記印が付加された前記構造体によって表わされる演算に対して特定のデータ依存関係を有する演算を表す構造体に他の印を付加し、
前記印が付加されていない構造体のうち、前記第1プログラムに対して前記コンパイルを施すことによって取得予定の第2プログラムの実行が特定の条件下で異なる結果を生成する演算の内容に置き換える最適化の対象となる構造体に対して前記最適化を実施する最適化部と、
を含むコンパイラ装置。
(付記10)
前記字句構文解析部は、更に、データを読み出す命令を表す構造体と、データを格納する命令を表す構造体と、演算及び読み出す命令の間のデータ依存関係とを取得し、
前記最適化部は、前記取得されたデータ依存関係に基づいて、前記印が付加された前記構造体の演算との間でデータ依存関係を有する演算を表す構造体、及び前記印が付加された前記構造体の演算との間でデータ依存関係を有する前記読み出す命令を表す構造体に他の印を付加し、前記印が付加された前記構造体の読み出し命令が読み出すデータを格納する命令を表す構造体に他の印を付加する付記9項記載のコンパイラ装置。
(付記11)
前記最適化部は、更に、前記最適化の対象となる演算のうち、抑止対象外として指定された前記最適化の対象となる演算を表す前記構造体であって、かつ、前記印が付加された前記構造体に対して前記最適化を実施する付記9又は10記載のコンパイラ装置。
(付記12)
前記最適化部は、前記取得された演算を表す構造体の各々について、前記演算が、入力値の精度に応じて出力結果が特定の影響を受ける演算である場合であって、かつ、前記最適化の対象となる演算のうち、抑止対象外として指定された前記最適化の対象となる前記演算でない場合に前記構造体に印を付加する付記9又は10記載のコンパイラ装置。
(付記13)
コンパイルの対象となる第1プログラムに含まれる複数の演算の各々を表す複数の構造体と、前記複数の演算間のデータの入出力の関係を表すデータ依存関係とを取得する字句構文解析部と、
前記取得された構造体の各々について、前記取得された前記構造体によって表わされる前記演算が、入力値の精度に応じて出力結果が特定の影響を受ける演算である場合に前記構造体に印を付加し、
前記取得されたデータ依存関係に基づいて、前記印が付加された前記構造体によって表わされる演算に対して特定のデータ依存関係を有する演算を表す構造体に他の印を付加し、
前記印が付加されていない構造体のうち、前記第1プログラムに対して前記コンパイルを施すことによって取得予定の第2プログラムの実行が特定の条件下で異なる結果を生成する演算の内容に置き換える最適化の対象となる構造体に対して前記最適化を実施する最適化部と、
を含むコンパイラ装置と、
利用者の操作により入力情報を前記コンパイラ装置へ送信する情報端末と、
を含む、コンパイラシステム。
(付記14)
コンパイルの対象となる第1プログラムに含まれる複数の演算の各々を表す複数の構造体と、前記複数の演算間のデータの入出力の関係を表すデータ依存関係とを取得し、
前記取得された構造体の各々について、前記取得された前記構造体によって表わされる前記演算が、入力値の精度に応じて出力結果が特定の影響を受ける演算である場合に前記構造体に印を付加し、
前記取得されたデータ依存関係に基づいて、前記印が付加された前記構造体によって表わされる演算に対して特定のデータ依存関係を有する演算を表す構造体に他の印を付加し、
前記印が付加されていない構造体のうち、前記第1プログラムに対して前記コンパイルを施すことによって取得予定の第2プログラムの実行が特定の条件下で異なる結果を生成する演算の内容に置き換える最適化の対象となる構造体に対して前記最適化を実施する、
ことを含む処理をコンピュータに実行させるコンパイラプログラムを記憶した記録媒体。
(Appendix 1)
Obtaining a plurality of structures representing each of a plurality of operations included in the first program to be compiled, and a data dependency representing a data input / output relationship between the plurality of operations;
For each of the acquired structures, the structure is marked when the operation represented by the acquired structure is an operation whose output result is specifically affected according to the accuracy of the input value. Add
Based on the acquired data dependency relationship, another mark is added to the structure representing an operation having a specific data dependency relationship with respect to the operation represented by the structure to which the mark is added,
Of the structures not marked with the mark, the optimal replacement of the first program with the content of the operation that generates a different result under a specific condition by executing the compilation on the first program Performing the optimization on the structure to be optimized,
Compiler program that causes a computer to execute a process including the above.
(Appendix 2)
The process of obtaining the plurality of structures further obtains a structure representing an instruction for reading data, a structure representing an instruction for storing data, and a data dependency relationship between the operation and the instruction to be read.
The process of marking a structure representing an operation having the data dependency relationship is an operation having a data dependency relationship with the operation of the structure to which the mark is added based on the acquired data dependency relationship. The structure having the mark added thereto by adding another mark to the structure representing the read instruction having a data dependency relationship with the structure of the structure to which the mark is added and the operation of the structure to which the mark has been added The compiler program according to appendix 1, wherein another mark is added to a structure representing an instruction for storing data read by the read instruction.
(Appendix 3)
The process of performing the optimization is further the structure representing the optimization target operation that is designated as the suppression target out of the optimization target operations, and the mark The compiler program according to appendix 1 or 2, wherein the optimization is performed on the structure to which is added.
(Appendix 4)
The process of adding a mark to the structure in the case of the operation is an operation in which, for each of the structures representing the acquired operation, the operation has a specific influence on the output result according to the accuracy of the input value. Or 1 to add a mark to the structure when the calculation is not targeted for the optimization among the calculations targeted for optimization. 2. The compiler program described in 2.
(Appendix 5)
Obtaining a plurality of structures representing each of a plurality of operations included in the first program to be compiled, and a data dependency representing a data input / output relationship between the plurality of operations;
For each of the acquired structures, the structure is marked when the operation represented by the acquired structure is an operation whose output result is specifically affected according to the accuracy of the input value. Add
Based on the acquired data dependency relationship, another mark is added to the structure representing an operation having a specific data dependency relationship with respect to the operation represented by the structure to which the mark is added,
Of the structures not marked with the mark, the optimal replacement of the first program with the content of the operation that generates a different result under a specific condition by executing the compilation on the first program Performing the optimization on the structure to be optimized,
A compiler method that includes:
(Appendix 6)
The process of obtaining the plurality of structures further obtains a structure representing an instruction for reading data, a structure representing an instruction for storing data, and a data dependency relationship between the operation and the instruction to be read.
The process of marking a structure representing an operation having the data dependency relationship is an operation having a data dependency relationship with the operation of the structure to which the mark is added based on the acquired data dependency relationship. The structure having the mark added thereto by adding another mark to the structure representing the read instruction having a data dependency relationship with the structure of the structure to which the mark is added and the operation of the structure to which the mark has been added The compiler method according to appendix 5, wherein another mark is added to a structure representing an instruction for storing data read by the read instruction.
(Appendix 7)
The process of performing the optimization is further the structure representing the optimization target operation that is designated as the suppression target out of the optimization target operations, and the mark The compiler method according to appendix 5 or 6, wherein the optimization is performed on the structure to which is added.
(Appendix 8)
The process of adding a mark to the structure in the case of the operation is an operation in which, for each of the structures representing the acquired operation, the operation has a specific influence on the output result according to the accuracy of the input value Or 5 for adding a mark to the structure when the calculation is not targeted for optimization among the calculations targeted for optimization 6. The compiler method according to 6.
(Appendix 9)
A lexical parsing unit for acquiring a plurality of structures representing each of a plurality of operations included in a first program to be compiled, and a data dependency representing a data input / output relationship between the plurality of operations; ,
For each of the acquired structures, the structure is marked when the operation represented by the acquired structure is an operation whose output result is specifically affected according to the accuracy of the input value. Add
Based on the acquired data dependency relationship, another mark is added to the structure representing an operation having a specific data dependency relationship with respect to the operation represented by the structure to which the mark is added,
Of the structures not marked with the mark, the optimal replacement of the first program with the content of the operation that generates a different result under a specific condition by executing the compilation on the first program An optimization unit that performs the optimization on the structure to be optimized;
Compiler device including
(Appendix 10)
The lexical parsing unit further acquires a structure representing an instruction for reading data, a structure representing an instruction for storing data, and a data dependency relationship between the operation and the instruction to be read.
The optimization unit includes a structure representing an operation having a data dependency relationship with the operation of the structure to which the mark is added based on the acquired data dependency relationship, and the mark is added. Another mark is added to the structure representing the read instruction having data dependency with the operation of the structure, and the read instruction of the structure to which the mark is added represents the instruction to store the read data The compiler apparatus according to appendix 9, wherein another mark is added to the structure.
(Appendix 11)
The optimization unit is the structure that represents the optimization target operation that is designated as a non-suppression target among the optimization target operations, and the mark is added. The compiler apparatus according to appendix 9 or 10, wherein the optimization is performed on the structure.
(Appendix 12)
The optimization unit is a case where, for each of the structures representing the acquired operations, the operation is an operation whose output result has a specific influence according to the accuracy of an input value, and the optimum 11. The compiler apparatus according to appendix 9 or 10, wherein a mark is added to the structure when the operation to be optimized is not the operation to be optimized that is designated as not subject to suppression.
(Appendix 13)
A lexical parsing unit for acquiring a plurality of structures representing each of a plurality of operations included in a first program to be compiled, and a data dependency representing a data input / output relationship between the plurality of operations; ,
For each of the acquired structures, the structure is marked when the operation represented by the acquired structure is an operation whose output result is specifically affected according to the accuracy of the input value. Add
Based on the acquired data dependency relationship, another mark is added to the structure representing an operation having a specific data dependency relationship with respect to the operation represented by the structure to which the mark is added,
Of the structures not marked with the mark, the optimal replacement of the first program with the content of the operation that generates a different result under a specific condition by executing the compilation on the first program An optimization unit that performs the optimization on the structure to be optimized;
A compiler apparatus including
An information terminal for transmitting input information to the compiler device by a user operation;
Including compiler system.
(Appendix 14)
Obtaining a plurality of structures representing each of a plurality of operations included in the first program to be compiled, and a data dependency representing a data input / output relationship between the plurality of operations;
For each of the acquired structures, the structure is marked when the operation represented by the acquired structure is an operation whose output result is specifically affected according to the accuracy of the input value. Add
Based on the acquired data dependency relationship, another mark is added to the structure representing an operation having a specific data dependency relationship with respect to the operation represented by the structure to which the mark is added,
Of the structures not marked with the mark, the optimal replacement of the first program with the content of the operation that generates a different result under a specific condition by executing the compilation on the first program Performing the optimization on the structure to be optimized,
The recording medium which stored the compiler program which makes a computer perform the process including this.

1、401、701 コンパイラ装置
2 ネットワーク
3 利用者端末
5、405、705 コンパイラシステム
20、420、720 コンパイラ
22、422、722 引数解析部
24 字句構文解析部
26、426、726 最適化部
28 命令生成部
30 目的プログラム出力部
32 テンプレート記憶部
40、 外部ディスク
42 ソースプログラム記憶部
44 記録表記憶部
46 目的プログラム記憶部
448 最適化記録表記憶部
748 指定処理記録表記憶部
1, 401, 701 Compiler device 2 Network 3 User terminal 5, 405, 705 Compiler system 20, 420, 720 Compiler 22, 422, 722 Argument analysis unit 24 Lexical syntax analysis unit 26, 426, 726 Optimization unit 28 Instruction generation Unit 30 target program output unit 32 template storage unit 40, external disk 42 source program storage unit 44 recording table storage unit 46 target program storage unit 448 optimization recording table storage unit 748 designation processing recording table storage unit

Claims (7)

コンパイルの対象となる第1プログラムに含まれる複数の演算の各々を表す複数の構造体と、前記複数の演算間のデータの入出力の関係を表すデータ依存関係とを取得し、
前記取得された構造体の各々について、前記取得された前記構造体によって表わされる前記演算が、入力値の精度に応じて出力結果が特定の影響を受ける演算である場合に前記構造体に印を付加し、
前記取得されたデータ依存関係に基づいて、前記印が付加された前記構造体によって表わされる演算に対して特定のデータ依存関係を有する演算を表す構造体に他の印を付加し、
前記印が付加されていない構造体のうち、前記第1プログラムに対して前記コンパイルを施すことによって取得予定の第2プログラムの実行が特定の条件下で異なる結果を生成する演算の内容に置き換える最適化の対象となる構造体に対して前記最適化を実施する、
ことを含む処理をコンピュータに実行させるコンパイラプログラム。
Obtaining a plurality of structures representing each of a plurality of operations included in the first program to be compiled, and a data dependency representing a data input / output relationship between the plurality of operations;
For each of the acquired structures, the structure is marked when the operation represented by the acquired structure is an operation whose output result is specifically affected according to the accuracy of the input value. Add
Based on the acquired data dependency relationship, another mark is added to the structure representing an operation having a specific data dependency relationship with respect to the operation represented by the structure to which the mark is added,
Of the structures not marked with the mark, the optimal replacement of the first program with the content of the operation that generates a different result under a specific condition by executing the compilation on the first program Performing the optimization on the structure to be optimized,
Compiler program that causes a computer to execute a process including the above.
前記複数の構造体を取得する処理は、更に、データを読み出す命令を表す構造体と、データを格納する命令を表す構造体と、演算及び読み出す命令の間のデータ依存関係とを取得し、
前記データ依存関係を有する演算を表す構造体に印を付す処理は、前記取得されたデータ依存関係に基づいて、前記印が付加された前記構造体の演算との間でデータ依存関係を有する演算を表す構造体、及び前記印が付加された前記構造体の演算との間でデータ依存関係を有する前記読み出す命令を表す構造体に他の印を付加し、前記印が付加された前記構造体の読み出し命令が読み出すデータを格納する命令を表す構造体に他の印を付加する請求項1記載のコンパイラプログラム。
The process of obtaining the plurality of structures further obtains a structure representing an instruction for reading data, a structure representing an instruction for storing data, and a data dependency relationship between the operation and the instruction to be read.
The process of marking a structure representing an operation having the data dependency relationship is an operation having a data dependency relationship with the operation of the structure to which the mark is added based on the acquired data dependency relationship. The structure having the mark added thereto by adding another mark to the structure representing the read instruction having a data dependency relationship with the structure of the structure to which the mark is added and the operation of the structure to which the mark has been added The compiler program according to claim 1, wherein another mark is added to a structure representing an instruction for storing data to be read by the read instruction.
前記最適化を実施する処理は、更に、前記最適化の対象となる演算のうち、抑止対象外として指定された前記最適化の対象となる演算を表す前記構造体であって、かつ、前記印が付加された前記構造体に対して前記最適化を実施する請求項1又は2記載のコンパイラプログラム。   The process of performing the optimization is further the structure representing the optimization target operation that is designated as the suppression target out of the optimization target operations, and the mark The compiler program according to claim 1, wherein the optimization is performed on the structure to which is added. 前記演算である場合に前記構造体に印を付加する処理は、前記取得された演算を表す構造体の各々について、前記演算が、入力値の精度に応じて出力結果が特定の影響を受ける演算である場合であって、かつ、前記最適化の対象となる演算のうち、抑止対象外として指定された前記最適化の対象となる前記演算でない場合に前記構造体に印を付加する請求項1又は2記載のコンパイラプログラム。   The process of adding a mark to the structure in the case of the operation is an operation in which, for each of the structures representing the acquired operation, the operation has a specific influence on the output result according to the accuracy of the input value. The mark is added to the structure when it is not the operation to be the optimization target specified as the suppression target among the operations to be optimized. Or the compiler program of 2 description. コンパイルの対象となる第1プログラムに含まれる複数の演算の各々を表す複数の構造体と、前記複数の演算間のデータの入出力の関係を表すデータ依存関係とを取得し、
前記取得された構造体の各々について、前記取得された前記構造体によって表わされる前記演算が、入力値の精度に応じて出力結果が特定の影響を受ける演算である場合に前記構造体に印を付加し、
前記取得されたデータ依存関係に基づいて、前記印が付加された前記構造体によって表わされる演算に対して特定のデータ依存関係を有する演算を表す構造体に他の印を付加し、
前記印が付加されていない構造体のうち、前記第1プログラムに対して前記コンパイルを施すことによって取得予定の第2プログラムの実行が特定の条件下で異なる結果を生成する演算の内容に置き換える最適化の対象となる構造体に対して前記最適化を実施する、
ことを含むコンパイラ方法。
Obtaining a plurality of structures representing each of a plurality of operations included in the first program to be compiled, and a data dependency representing a data input / output relationship between the plurality of operations;
For each of the acquired structures, the structure is marked when the operation represented by the acquired structure is an operation whose output result is specifically affected according to the accuracy of the input value. Add
Based on the acquired data dependency relationship, another mark is added to the structure representing an operation having a specific data dependency relationship with respect to the operation represented by the structure to which the mark is added,
Of the structures not marked with the mark, the optimal replacement of the first program with the content of the operation that generates a different result under a specific condition by executing the compilation on the first program Performing the optimization on the structure to be optimized,
A compiler method that includes:
コンパイルの対象となる第1プログラムに含まれる複数の演算の各々を表す複数の構造体と、前記複数の演算間のデータの入出力の関係を表すデータ依存関係とを取得する字句構文解析部と、
前記取得された構造体の各々について、前記取得された前記構造体によって表わされる前記演算が、入力値の精度に応じて出力結果が特定の影響を受ける演算である場合に前記構造体に印を付加し、
前記取得されたデータ依存関係に基づいて、前記印が付加された前記構造体によって表わされる演算に対して特定のデータ依存関係を有する演算を表す構造体に他の印を付加し、
前記印が付加されていない構造体のうち、前記第1プログラムに対して前記コンパイルを施すことによって取得予定の第2プログラムの実行が特定の条件下で異なる結果を生成する演算の内容に置き換える最適化の対象となる構造体に対して前記最適化を実施する最適化部と、
を含むコンパイラ装置。
A lexical parsing unit for acquiring a plurality of structures representing each of a plurality of operations included in a first program to be compiled, and a data dependency representing a data input / output relationship between the plurality of operations; ,
For each of the acquired structures, the structure is marked when the operation represented by the acquired structure is an operation whose output result is specifically affected according to the accuracy of the input value. Add
Based on the acquired data dependency relationship, another mark is added to the structure representing an operation having a specific data dependency relationship with respect to the operation represented by the structure to which the mark is added,
Of the structures not marked with the mark, the optimal replacement of the first program with the content of the operation that generates a different result under a specific condition by executing the compilation on the first program An optimization unit that performs the optimization on the structure to be optimized;
Compiler device including
コンパイルの対象となる第1プログラムに含まれる複数の演算の各々を表す複数の構造体と、前記複数の演算間のデータの入出力の関係を表すデータ依存関係とを取得する字句構文解析部と、
前記取得された構造体の各々について、前記取得された前記構造体によって表わされる前記演算が、入力値の精度に応じて出力結果が特定の影響を受ける演算である場合に前記構造体に印を付加し、
前記取得されたデータ依存関係に基づいて、前記印が付加された前記構造体によって表わされる演算に対して特定のデータ依存関係を有する演算を表す構造体に他の印を付加し、
前記印が付加されていない構造体のうち、前記第1プログラムに対して前記コンパイルを施すことによって取得予定の第2プログラムの実行が特定の条件下で異なる結果を生成する演算の内容に置き換える最適化の対象となる構造体に対して前記最適化を実施する最適化部と、
を含むコンパイラ装置と、
利用者の操作により入力情報を前記コンパイラ装置へ送信する情報端末と、
を含む、コンパイラシステム。
A lexical parsing unit for acquiring a plurality of structures representing each of a plurality of operations included in a first program to be compiled, and a data dependency representing a data input / output relationship between the plurality of operations; ,
For each of the acquired structures, the structure is marked when the operation represented by the acquired structure is an operation whose output result is specifically affected according to the accuracy of the input value. Add
Based on the acquired data dependency relationship, another mark is added to the structure representing an operation having a specific data dependency relationship with respect to the operation represented by the structure to which the mark is added,
Of the structures not marked with the mark, the optimal replacement of the first program with the content of the operation that generates a different result under a specific condition by executing the compilation on the first program An optimization unit that performs the optimization on the structure to be optimized;
A compiler apparatus including
An information terminal for transmitting input information to the compiler device by a user operation;
Including compiler system.
JP2015058504A 2015-03-20 2015-03-20 Compiler program, system, method, and apparatus Active JP6409639B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2015058504A JP6409639B2 (en) 2015-03-20 2015-03-20 Compiler program, system, method, and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2015058504A JP6409639B2 (en) 2015-03-20 2015-03-20 Compiler program, system, method, and apparatus

Publications (2)

Publication Number Publication Date
JP2016177652A JP2016177652A (en) 2016-10-06
JP6409639B2 true JP6409639B2 (en) 2018-10-24

Family

ID=57070335

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2015058504A Active JP6409639B2 (en) 2015-03-20 2015-03-20 Compiler program, system, method, and apparatus

Country Status (1)

Country Link
JP (1) JP6409639B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6940751B2 (en) * 2017-05-10 2021-09-29 富士通株式会社 Information processing equipment, information processing methods and information processing programs

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04135245A (en) * 1990-09-27 1992-05-08 Fujitsu Ltd Compiling processing system
JPH09319722A (en) * 1996-05-23 1997-12-12 Internatl Business Mach Corp <Ibm> Parallel compiling method
JP2006155386A (en) * 2004-11-30 2006-06-15 Matsushita Electric Ind Co Ltd Compiling device and debugging device
JP5775829B2 (en) * 2012-01-30 2015-09-09 日立オートモティブシステムズ株式会社 Software structure visualization program and system

Also Published As

Publication number Publication date
JP2016177652A (en) 2016-10-06

Similar Documents

Publication Publication Date Title
CN108717470B (en) Code segment recommendation method with high accuracy
JP5039948B2 (en) Compiler that optimizes programs
JP6237278B2 (en) Compilation program, compilation method, and compilation apparatus
JP2006243839A (en) Instruction generation device and instruction generation method
US20060200796A1 (en) Program development apparatus, method for developing a program, and a computer program product for executing an application for a program development apparatus
JP2007286671A (en) Software/hardware division program and division method
JP6331756B2 (en) Test case generation program, test case generation method, and test case generation apparatus
US20100037039A1 (en) Instruction operation code generation system
WO2023087720A1 (en) Applet generation method and apparatus, device and storage medium
KR20080038306A (en) Nullable and late binding
WO2022068556A1 (en) Code translation method and apparatus, and device
JP6409639B2 (en) Compiler program, system, method, and apparatus
JP6651974B2 (en) Information processing apparatus, compiling method and compiler program
Sargsyan et al. Scalable and accurate clones detection based on metrics for dependence graph
CN108920149B (en) Compiling method and compiling device
WO2017204139A1 (en) Data processing apparatus, data processing method, and program recording medium
US10108405B2 (en) Compiling apparatus and compiling method
JP5932707B2 (en) Computer, program, and data generation method
JP6897213B2 (en) Code generator, code generator and code generator
CN113031952A (en) Method and device for determining execution code of deep learning model and storage medium
JP2016051367A (en) Data analysis device, data analysis method, and program
JP6137962B2 (en) Information processing apparatus, information processing method, and program
Weiskamp Advanced turbo C programming
CN117785213B (en) Front-end construction tool and construction method based on Rust development
WO2023026409A1 (en) Information processing device, program, and information processing method

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20180115

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20180808

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20180910

R150 Certificate of patent or registration of utility model

Ref document number: 6409639

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150