JPH05342012A - Compiling method and compiler - Google Patents
Compiling method and compilerInfo
- Publication number
- JPH05342012A JPH05342012A JP17627392A JP17627392A JPH05342012A JP H05342012 A JPH05342012 A JP H05342012A JP 17627392 A JP17627392 A JP 17627392A JP 17627392 A JP17627392 A JP 17627392A JP H05342012 A JPH05342012 A JP H05342012A
- Authority
- JP
- Japan
- Prior art keywords
- dsp
- unit
- digital signal
- code
- language
- 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.)
- Withdrawn
Links
Landscapes
- Complex Calculations (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
(57)【要約】
【目的】 ディジタルシグナルプロセッサおよび言語に
依存せずに、プログラムをコンパイルする。
【構成】 言語Ln用フロントエンド部1nにおいて、言
語Ln(n=1,2,・・・,N)で記述されたプログ
ラムのソースコードに対して、言語Lnに対応した前処
理が行われ、言語L1乃至LNに共通の中間コードが出力
される。共通モジュール部2において、その中間コード
に対して、言語L1乃至LNおよびDSP1乃至DSPMに
依存しない処理が行われ、ディジタルシグナルプロセッ
サDSPm用バックエンド部3m(m=1,2,・・・,
M)において、共通モジュール部2の出力に対して後処
理が施されて、ディジタルシグナルプロセッサDSPm
に対応したオブジェクトコードが出力される。
(57) [Abstract] [Purpose] A program is compiled independently of a digital signal processor and language. [Structure] In the language L n front-end unit 1 n , the preprocessing corresponding to the language L n is performed on the source code of the program described in the language L n (n = 1, 2, ..., N). Is performed and an intermediate code common to the languages L 1 to L N is output. In the common module section 2, the intermediate code is subjected to processing independent of the languages L 1 to L N and DSP 1 to DSP M , and the back end section 3 m (m = 1, 2) for the digital signal processor DSP m .・ ・ ・ ・ ・ ・
In M), post-processing is performed on the output of the common module unit 2, and the digital signal processor DSP m
The object code corresponding to is output.
Description
【0001】[0001]
【産業上の利用分野】本発明は、例えば音声処理や画像
処理などのディジタル信号処理に用いられるDSP(デ
ィジタルシグナルプロセッサ)のプログラムをコンパイ
ルする場合に用いて好適なコンパイル方法並びにコンパ
イラに関する。BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a compiling method and a compiler suitable for compiling a DSP (digital signal processor) program used for digital signal processing such as voice processing and image processing.
【0002】[0002]
【従来の技術】近年の音声処理や画像処理などにおいて
は、多くの場合、信号(音声信号や画像信号)をサンプ
リングし、即ち信号をディジタル化し、例えばDFT
(離散フーリエ変換),FFT(高速フーリエ変換)、
またはDCT(離散コサイン変換)などにより、時間軸
上の信号を周波数軸上の信号(スペクトル)に変換し
て、パラメータの抽出や圧縮符号化処理が行われる。2. Description of the Related Art In recent years, in audio processing and image processing, in many cases, a signal (audio signal or image signal) is sampled, that is, the signal is digitized and, for example, DFT.
(Discrete Fourier transform), FFT (fast Fourier transform),
Alternatively, a signal on the time axis is converted into a signal (spectrum) on the frequency axis by DCT (discrete cosine transform) or the like, and parameter extraction and compression encoding processing are performed.
【0003】このような、ディジタル信号の時間軸と周
波数軸との相互変換(DFT(逆DFT),FFT(逆
FFT)、およびDCT(逆DCT)など)処理に代表
されるディジタル信号処理においては、積和演算の回数
が非常に多く、この処理を、例えば汎用的なCPUなど
で実現した場合には、実時間処理を行うことが困難であ
った。In such digital signal processing represented by the mutual conversion (DFT (inverse DFT), FFT (inverse FFT), DCT (inverse DCT), etc.) processing between the time axis and the frequency axis of the digital signal. The number of product-sum operations is extremely large, and when this processing is realized by, for example, a general-purpose CPU, it is difficult to perform real-time processing.
【0004】そこで、いわゆるパイプライン処理や並列
処理に適したアーキテクチャを有し、積和演算を、例え
ば数10乃至数100n秒で行うことのできる、いわば
積和演算処理を得意とするDSP(ディジタルシグナル
プロセッサ)が開発され、近年、このDSPを用いた多
くのディジタル信号処理装置(例えば画像処理装置や音
声処理装置など)が実現されている。Therefore, a DSP (digital) having an architecture suitable for so-called pipeline processing and parallel processing and capable of performing a product-sum operation in, for example, several tens to several hundreds of nanoseconds, which is, so to speak, good at a product-sum operation process. Signal processors) have been developed, and in recent years, many digital signal processing devices (for example, image processing devices and audio processing devices) using this DSP have been realized.
【0005】[0005]
【発明が解決しようとする課題】ところで、このDSP
に、ディジタル信号処理を実行させるには、まず、その
DSP用の言語でディジタル信号処理プログラムを記述
し、そのソースコードをコンパイラでコンパイルしてオ
ブジェクトコードに変換する必要がある。By the way, this DSP
In order to execute digital signal processing, first, it is necessary to write a digital signal processing program in the language for the DSP, compile the source code thereof with a compiler, and convert it into object code.
【0006】しかしながら、ディジタル信号処理プログ
ラムを記述するための言語は、DSPにより異なる場合
が多く、また同じDSPであってもプログラムを記述す
るための言語が複数種類提供されている場合もあり、従
って、例えばM個のDSPのプログラムが、N種類の言
語で記述することができるときには、各DSPおよび各
言語に対応したM×N個のコンパイラを用意しなければ
ならず、不便であった。However, the language for describing the digital signal processing program is often different depending on the DSP, and even the same DSP may provide a plurality of languages for describing the program. For example, when a program of M DSPs can be written in N kinds of languages, M × N compilers corresponding to each DSP and each language must be prepared, which is inconvenient.
【0007】なお、言語がDSPにより異なる場合と
は、言語の種類がDSPにより異なる場合の他、同じ言
語であってもその系統がDSPにより異なる場合(例え
ば、コンピュータ言語でいえば、同じC言語でも、コン
パイラの提供メーカにより異なる場合)を含む。Note that the case where the language is different depending on the DSP means that the type of language is different depending on the DSP, and that the system is different depending on the DSP even if it is the same language (for example, the same C language in computer language). However, it depends on the manufacturer of the compiler).
【0008】さらに、コンパイラは、プログラムをコン
パイルする過程を分割した、複数の論理的な操作単位
(フェーズ)よりなっているが、上述した各DSPおよ
び各言語に対応した各コンパイラには、DSPおよび言
語に依存しない、互いに共用することができるフェーズ
が、少なからず含まれており、各コンパイラにこのフェ
ーズを設けることは無駄であった。Further, the compiler is composed of a plurality of logical operation units (phases) obtained by dividing the process of compiling a program. The above-mentioned DSPs and compilers corresponding to respective languages have DSPs and There are quite a few language-independent phases that can be shared with each other, and it was useless to provide this phase for each compiler.
【0009】本発明は、このような状況に鑑みてなされ
たものであり、DSPおよび言語に依存せずに、プログ
ラムをコンパイルすることができるようにするものであ
る。The present invention has been made in view of such a situation, and makes it possible to compile a program without depending on the DSP and the language.
【0010】[0010]
【課題を解決するための手段】請求項1に記載のコンパ
イル方法は、ディジタルシグナルプロセッサのプログラ
ムのソースコードを中間コードに変換し、中間コードを
ディジタルシグナルプロセッサに対応したオブジェクト
コードに変換するコンパイル方法において、中間コード
は、ディジタルシグナルプロセッサのプログラムを記述
するための複数の言語、または複数のディジタルシグナ
ルプロセッサにそれぞれ対応したオブジェクトコードに
共通であることを特徴とする。A compiling method according to claim 1, wherein a source code of a program of a digital signal processor is converted into an intermediate code, and the intermediate code is converted into an object code corresponding to the digital signal processor. In the above, the intermediate code is common to a plurality of languages for writing a program of the digital signal processor or an object code corresponding to each of the plurality of digital signal processors.
【0011】請求項2に記載のコンパイラは、ディジタ
ルシグナルプロセッサDSP1乃至DSPMのプログラム
のソースコードを中間コードに変換する前処理手段とし
てのフロントエンド部1(言語L1用フロントエンド部
11乃至言語LN用フロントエンド部1N)と、フロント
エンド部1より出力される中間コードを解析して最適化
する共通処理手段としての共通モジュール部2と、共通
モジュール部2からの出力をディジタルシグナルプロセ
ッサDSP1乃至DSPMに対応したオブジェクトコード
に変換する後処理手段としてのバックエンド部3(DS
P1用バックエンド部31乃至DSPM用バックエンド部
3M)とを備え、フロントエンド部1(言語L1用フロン
トエンド部11乃至言語LN用フロントエンド部1N)
は、ディジタルシグナルプロセッサDSP1乃至DSPM
のプログラムを記述するための複数の言語L1乃至LNに
共通の中間コードを出力し、バックエンド部3(DSP
1用バックエンド部31乃至DSPM用バックエンド部
3M)は、中間コードを複数のディジタルシグナルプロ
セッサDSP1乃至DSPMにそれぞれ対応したオブジェ
クトコードに変換することを特徴とする。[0011] The compiler according to claim 2, a digital signal processor DSP 1 to the front end portion 1 (front language L 1 end portion 1 1 of the pre-processing means for converting the source code of a program of DSP M into an intermediate code To a language L N front end unit 1 N ), a common module unit 2 as a common processing unit for analyzing and optimizing an intermediate code output from the front end unit 1, and a digital output from the common module unit 2. Back-end unit 3 (DS) as a post-processing unit for converting into object code corresponding to the signal processors DSP 1 to DSP M
P 1 back end unit 3 1 to DSP M back end unit 3 M ) and a front end unit 1 (language L 1 front end unit 1 1 to language L N front end unit 1 N )
Is a digital signal processor DSP 1 to DSP M
Output intermediate code common to a plurality of languages L 1 to L N for describing the program of the back end unit 3 (DSP).
Back end unit 3 1 to the back-end portion 3 M for DSP M) for 1, and converting the intermediate code into an object code corresponding to the plurality of digital signal processors DSP 1 to DSP M.
【0012】請求項3に記載のコンパイラは、共通モジ
ュール部2に、中間コードに対して、DSP1乃至DS
PMのどれにも依存しない最適化処理を施させることを
特徴とする。According to a third aspect of the present invention, the common module section 2 provides the common module section 2 with DSP 1 to DS for intermediate code.
It is characterized in that an optimization process that does not depend on any of P M is performed.
【0013】請求項4に記載のコンパイラは、バックエ
ンド部3(DSP1用バックエンド部31乃至DSPM用
バックエンド部3M)に、中間コードを並列に実行可能
な単位に分割させ、DSP1乃至DSPMに割り当てさせ
ることを特徴とする。According to a fourth aspect of the compiler, the back end unit 3 (the DSP 1 back end unit 3 1 to the DSP M back end unit 3 M ) divides the intermediate code into units that can be executed in parallel. It is characterized by being assigned to DSP 1 to DSP M.
【0014】請求項5に記載のコンパイラは、バックエ
ンド部3(DSP1用バックエンド部31乃至DSPM用
バックエンド部3M)に、レジスタ割付を行わせること
を特徴とする。[0014] The compiler according to claim 5, the back end unit 3 (DSP 1 for the back-end portion 3 1 to the back-end portion 3 M for DSP M), characterized in that to perform register allocation.
【0015】[0015]
【作用】請求項1に記載のコンパイル方法においては、
ディジタルシグナルプロセッサのプログラムのソースコ
ードを、ディジタルシグナルプロセッサのプログラムを
記述するための複数の言語、または複数のディジタルシ
グナルプロセッサにそれぞれ対応したオブジェクトコー
ドに共通の中間コードに変換し、その中間コードをディ
ジタルシグナルプロセッサに対応したオブジェクトコー
ドに変換する。従って、DSP(ディジタルシグナルプ
ロセッサ)および言語に依存せずに、プログラムをコン
パイルすることができる。In the compiling method according to claim 1,
The source code of the program of the digital signal processor is converted into an intermediate code common to a plurality of languages for writing the program of the digital signal processor, or an object code corresponding to each of the digital signal processors, and the intermediate code is digitally converted. Convert to the object code corresponding to the signal processor. Therefore, the program can be compiled independent of the DSP (digital signal processor) and the language.
【0016】請求項2に記載のコンパイラにおいては、
DSP1乃至DSPMのプログラムのソースコードを言語
L1乃至LNに共通の中間コードに変換し、その中間コー
ドを解析して最適化する。そして、最適化した中間コー
ドをDSP1乃至DSPMにそれぞれ対応したオブジェク
トコードに変換する。従って、DSP(ディジタルシグ
ナルプロセッサ)および言語に依存せずに、プログラム
をコンパイルすることができる。In the compiler according to claim 2,
The source code of the program of DSP 1 to DSP M is converted into an intermediate code common to the languages L 1 to L N , and the intermediate code is analyzed and optimized. Then, the optimized intermediate code is converted into object codes respectively corresponding to DSP 1 to DSP M. Therefore, the program can be compiled independent of the DSP (digital signal processor) and the language.
【0017】請求項3に記載のコンパイラにおいては、
共通モジュール部2に、中間コードに対して、DSP1
乃至DSPMのどれにも依存しない最適化処理を施させ
るので、重複したフェーズによる無駄な処理が防止され
る。In the compiler according to claim 3,
In the common module section 2, for the intermediate code, DSP 1
Since the optimization processing independent of any of DSP to DSP M is performed, useless processing due to overlapping phases is prevented.
【0018】請求項4に記載のコンパイラは、バックエ
ンド部3(DSP1用バックエンド部31乃至DSPM用
バックエンド部3M)に、中間コードを並列に実行可能
な単位に分割させ、DSP1乃至DSPMに割り当てさせ
るので、並列処理をすることができるDSP(ディジタ
ルシグナルプロセッサ)の機能を有効に利用することが
できる。According to a fourth aspect of the compiler, the back-end unit 3 (the DSP 1 back-end unit 3 1 to the DSP M back-end unit 3 M ) divides the intermediate code into units that can be executed in parallel. Since it is assigned to DSP 1 to DSP M , it is possible to effectively use the function of a DSP (digital signal processor) capable of parallel processing.
【0019】請求項5に記載のコンパイラは、バックエ
ンド部3(DSP1用バックエンド部31乃至DSPM用
バックエンド部3M)に、レジスタ割付を行わせるの
で、DSP(ディジタルシグナルプロセッサ)のレジス
タを効率的に利用することができる。According to a fifth aspect of the compiler, the back end unit 3 (the DSP 1 back end unit 3 1 to the DSP M back end unit 3 M ) performs register allocation, so that a DSP (digital signal processor) is provided. The registers of can be used efficiently.
【0020】[0020]
【実施例】図1は、本発明のコンパイラの一実施例の構
成を示すブロック図である。フロントエンド部1は、M
個のディジタルシグナルプロセッサDSP1乃至DSPM
(以下、DSP1乃至DSPM)のいずれかのプログラム
記述用言語L1乃至LNで記述されたプログラムのソース
コードを、言語L1乃至LNに共通の中間言語で記述され
る中間コードにそれぞれ変換する言語L1用フロントエ
ンド部11乃至言語LN用フロントエンド部1Nから構成
される。各言語Ln用フロントエンド部1n(n=1,
2,・・・,N)は、図2に示すフェーズ(コンパイル
の処理単位)としての、字句解析部11n、構文解析部
12n、および意味解析部13nから構成され、言語Ln
に依存した処理を行う。1 is a block diagram showing the configuration of an embodiment of a compiler according to the present invention. Front end 1 is M
Digital signal processors DSP 1 to DSP M
(Hereinafter, DSP 1 to DSP M ) A source code of a program described in any one of the program description languages L 1 to L N is converted into an intermediate code described in an intermediate language common to the languages L 1 to L N. It is composed of a language L 1 front end unit 1 1 to a language L N front end unit 1 N to be converted. Each language L n for the front-end unit 1 n (n = 1,
2, · · ·, N) is constructed as a phase (the processing unit of compilation) shown in FIG. 2, lexical analyzer 11 n, the parsing unit 12 n, and the semantic analysis unit 13 n, the language L n
Perform processing depending on.
【0021】即ち、言語Ln用フロントエンド部1nの字
句解析部11nは、言語Lnで記述されたプログラムのソ
ースコードを、論理的に扱うことのできる最小単位の文
字列(字句)に分離する。構文解析部12nは、字句解
析部11nより出力される字句からなる構文を構造解析
し、言語Lnの構文構造として許されているか否かを検
査(構文チェック)する。意味解析部13nは、字句か
らなる構文を意味解析し、構文の意味上の間違いをチェ
ックし、間違いがなければソースコードを、言語L1乃
至LNのすべてに共通の中間コードに変換する。[0021] That is, the language L lexical analyzer 11 n of the front end portion 1 n for n is the source code for a program written in a language L n, a minimum unit that can be handled logically string (token) To separate. The syntax analysis unit 12 n structurally analyzes the syntax composed of the lexical output from the lexical analysis unit 11 n, and checks whether the syntax structure of the language L n is allowed (syntax check). The semantic analysis unit 13 n performs a semantic analysis on a syntax composed of lexical words, checks a semantic error in the syntax, and if there is no error, converts the source code into an intermediate code common to all the languages L 1 to L N. ..
【0022】共通モジュール部2は、図3に示すフェー
ズとしての依存解析部21および最適化部22より構成
され、言語L1用フロントエンド部11乃至言語LN用フ
ロントエンド部1Nから出力される中間コードに対し
て、言語L1乃至LNおよびDSP1乃至DSPMに依存し
ない処理を行う。The common module section 2 is composed of a phase dependence analysis section 21 and an optimization section 22 shown in FIG. 3, and outputs from the language L 1 front end section 1 1 to the language L N front end section 1 N. The intermediate code to be processed is processed independent of the languages L 1 to L N and DSP 1 to DSP M.
【0023】即ち、共通モジュール部2の依存解析部2
1は、フロントエンド部1より出力される中間コードに
おける、データの参照または定義の依存関係(データ依
存)を解析し、この依存関係(データ依存)を、いわゆ
るデータフローグラフと呼ばれるデータ構造に変換す
る。最適化部22は、必要に応じて依存解析部21で作
成されたデータフローグラフを参照し、フロントエンド
部1より出力される中間コードに対して、例えば定数の
畳み込みや共通部分式の識別など、言語L1乃至LNおよ
びDSP1乃至DSPMに依存しない最適化処理を施す。That is, the dependency analysis unit 2 of the common module unit 2
Reference numeral 1 analyzes the data reference or definition dependency (data dependency) in the intermediate code output from the front end unit 1 and converts this dependency (data dependency) into a data structure called a so-called data flow graph. To do. The optimizing unit 22 refers to the data flow graph created by the dependency analyzing unit 21 as necessary, and with respect to the intermediate code output from the front end unit 1, for example, convolution of constants, identification of common subexpressions, etc. , L 1 to L N and DSP 1 to DSP M independent optimization processing.
【0024】バックエンド部3は、共通モジュール部2
で最適化された中間コードから、DSP1乃至DSPMに
対応したオブジェクトコードをそれぞれ生成するDSP
1用バックエンド部31乃至DSPM用バックエンド部3M
から構成される。各DSPm用バックエンド部3m(m=
1,2,・・・,M)は、図4に示すフェーズとして
の、スケジューリング部31m、コード生成/レジスタ
割付部32m、および最適化部33mから構成され、DS
Pmに依存した処理を行う。The back end unit 3 is the common module unit 2
DSP that generates object code corresponding to DSP 1 to DSP M from the intermediate code optimized by
1 back-end section 3 1 to DSP M back-end section 3 M
Composed of. Back end unit for each DSP m 3 m (m =
1, 2, ..., M) is composed of a scheduling unit 31 m , a code generation / register allocation unit 32 m , and an optimization unit 33 m as the phase shown in FIG.
Perform processing depending on P m .
【0025】即ち、スケジューリング部31mは、例え
ばDSPmのアーキテクチャが並列処理を行うことがで
きるものである場合、共通モジュール部2で最適化され
た中間コードを、並列に実行可能な単位(タスク)に分
割し、DSPmを構成する、例えばALU、乗算器、加
算器、またはシフタなどに割り当てる。コード生成/レ
ジスタ割付部32mは、共通モジュール部2(最適化部
22)より出力される中間コードから、DSPmに対応
したオブジェクトコードを生成するとともに、DSPm
の有するレジスタに、効率的に変数を割り付けるための
レジスタ割付を行う。最適化部33mは、必要に応じて
共通モジュール部2の依存解析部21で作成されたデー
タフローグラフを参照し、コード生成/レジスタ割付部
32mで生成されたDSPmに対応したオブジェクトコー
ドに対して、DSPmに依存した最適化処理を施す。That is, when the architecture of the DSP m is such that the architecture of the DSP m can perform parallel processing, the scheduling unit 31 m can execute the intermediate code optimized by the common module unit 2 in units (tasks) that can be executed in parallel. ) And configure DSP m , for example, ALU, multiplier, adder, or shifter. Code generation / register allocation unit 32 m, from the intermediate code output from common module unit 2 (optimizing unit 22), generates an object code corresponding to the DSP m, DSP m
Performs register allocation for efficiently allocating variables to the registers of. The optimization unit 33 m refers to the data flow graph created by the dependency analysis unit 21 of the common module unit 2 as necessary, and the object code corresponding to the DSP m created by the code creation / register allocation unit 32 m. Is subjected to optimization processing depending on DSP m .
【0026】このように構成されるコンパイラにおい
て、言語Lnで記述されたDSPm用のプログラムがコン
パイルされる場合、まずフロントエンド部1の言語Ln
用フロントエンド部1nにそのプログラムが読み込まれ
る。そして、言語Ln用フロントエンド部1nの字句解析
部11n(図2)において、言語Lnで記述されたプログ
ラムのソースコードが、例えば手掛かり語(例えば、C
言語やFORTRANでいうところのdo,while,if、お
よびforなど)、識別子(例えば、プログラムにおける
変数など)、定数、並びに演算子(例えば、+,−,
*、および/など)など、論理的に扱うことのできる最
小単位の文字列(字句)に分離される。When a program for DSP m written in the language L n is compiled in the compiler configured as described above, first, the language L n of the front end unit 1 is written.
The program is read into the front end unit 1 n for use. Then, in the language L n for the front end portion 1 n of the lexical analyzer 11 n (Fig. 2), the source code of a program written in a language L n, e.g. clue words (for example, C
Language, FORTRAN, such as do, while, if, and for), identifiers (eg, variables in a program), constants, and operators (eg, +, −,
*, And / or the like) is separated into a character string (lexical) of the smallest unit that can be logically handled.
【0027】即ち、字句解析部11nにおいて、例えば IF (5.EQ.MAX) GOTO 100 というFORTRAN文は、 IF,(,5,.EQ.,MAX,),GOTO、およ
び100 という8つの字句に分離される。That is, in the lexical analysis unit 11 n , for example, the FORTRAN statement of IF (5.EQ.MAX) GOTO 100 is the eight lexical phrases of IF, (, 5..EQ., MAX,), GOTO, and 100. Is separated into
【0028】字句解析部11nで分離された字句は構文
解析部12nに入力され、構文解析部12nにおいて、こ
の字句からなる構文が構造解析され、言語Lnの構文構
造として許されているか否かが検査(構文チェック)さ
れる。即ち、例えば字句A,+、およびBが入力された
場合、構文解析部12nにおいて、字句A,+、および
Bからなる構文A+Bが、式と名付ける構文構造を有す
ると構造解析され、構文A+Bが言語Lnで記述された
式として許されているか否かが検査(構文チェック)さ
れる。構文解析部12nで、任意の構文が、構文チェッ
クで使用不可と判定された場合には、コンパイル(以後
の処理)が中止される。The lexical separated by lexical analyzer 11 n is input to the parsing unit 12 n, the syntax analyzing unit 12 n, the syntax comprising the lexical is structural analysis, allowed the syntactic structure of the language L n The presence or absence is checked (syntax check). That is, for example, when the lexical characters A, +, and B are input, the syntax analysis unit 12 n structurally analyzes the syntax A + B composed of the lexical characters A, +, and B as having a syntactic structure named as an expression, and the syntax A + B. Is checked (syntax check) as to whether or not is allowed as an expression described in the language L n . If the syntax analysis unit 12 n determines that an arbitrary syntax cannot be used in the syntax check, the compilation (the subsequent processing) is stopped.
【0029】構文解析部12nでの構文チェックをパス
した構文は、意味解析部13nで、意味解析され、構文
の意味上の間違いがチェックされる。即ち、意味解析部
13nにおいて、例えば整数型の変数A、演算子+、お
よび実数型の変数Bの3つの字句からなる構文A+B
が、整数型と実数型の加算式であると解析され、整数と
実数との加算が間違いか否かがチェックされる。言語L
nの仕様で、整数と実数との加算が許されていなけれ
ば、意味解析部13nで、構文A+Bは使用不可とさ
れ、コンパイル(以後の処理)が中止される。The syntax that has passed the syntax check by the syntax analysis unit 12 n is semantically analyzed by the semantic analysis unit 13 n to check the semantic error of the syntax. That is, in the semantic analysis unit 13 n , for example, a syntax A + B including three tokens of an integer type variable A, an operator +, and a real number type variable B.
Is analyzed as an addition expression of integer type and real number type, and it is checked whether addition of integer and real number is wrong. Language L
If the specification of n does not allow addition of an integer and a real number, the semantic analysis unit 13 n disables the syntax A + B, and compilation (subsequent processing) is stopped.
【0030】意味解析部13nで、構文の意味上の間違
いがチェックされた構文に間違いがなければ、ソースコ
ードが、言語L1乃至LNのすべてに共通の中間コードに
変換され、共通モジュール部2の依存解析部21(図
3)に出力される。The semantic analysis unit 13 n has checked the semantic meaning of the syntax. If the syntax is correct, the source code is converted into an intermediate code common to all the languages L 1 to L N , and the common module is used. It is output to the dependency analysis unit 21 (FIG. 3) of the unit 2.
【0031】依存解析部21において、意味解析部13
nより出力された中間コードにおける、データの参照ま
たは定義の依存関係(データ依存)が解析され、この依
存関係(データ依存)が、いわゆるデータフローグラフ
と呼ばれるデータ構造に変換される。In the dependency analysis unit 21, the semantic analysis unit 13
In the intermediate code output from n , the data reference or definition dependency (data dependency) is analyzed, and this dependency (data dependency) is converted into a data structure called a so-called data flow graph.
【0032】即ち、例えば A=B+C (1) B=A+E (2) B=F+G (3) という3つの式が、式(1),(2),(3)の順番で
実行されるように、プログラムが記述されているとする
と、依存解析部21では、 ・式(1)で定義されたAが式(2)で参照されている
(フロー依存)。 ・式(1)で参照されたBが式(2)で定義されている
(逆依存)。 ・式(1)で参照されたBが式(3)で定義されている
(逆依存)。 ・式(2)で定義されたBが式(3)で再定義されてい
る(出力依存)。 のように依存解析がなされ、このデータの参照または定
義の依存関係(データ依存)がいわゆるデータフローグ
ラフと呼ばれるデータ構造に変換される。That is, for example, three equations A = B + C (1) B = A + E (2) B = F + G (3) are executed in the order of the equations (1), (2) and (3). Assuming that a program is described, the dependency analysis unit 21: A defined in Expression (1) is referenced in Expression (2) (flow dependence). B referenced in equation (1) is defined in equation (2) (reverse dependency). B referenced in equation (1) is defined in equation (3) (reverse dependency). B defined in equation (2) is redefined in equation (3) (output dependent). The dependency analysis is performed as described above, and the dependency relation (data dependency) of the reference or definition of this data is converted into a data structure called a so-called data flow graph.
【0033】依存解析部21でデータフローグラフが作
成された後、最適化部22において、必要に応じてこの
データフローグラフが参照され、意味解析部13nより
出力された中間コードに対して、例えば定数の畳み込み
や共通部分式の識別など、DSP1乃至DSPMに依存し
ない最適化処理が施される。After the data flow graph is created by the dependency analysis unit 21, the data flow graph is referred to by the optimization unit 22 as needed, and the intermediate code output from the semantic analysis unit 13 n is For example, optimization processing that does not depend on DSP 1 to DSP M , such as constant folding and common subexpression identification, is performed.
【0034】即ち、例えば I=4 A=I*B という構文がプログラムの中に言語Lnで記述されてい
ると、最適化部22において、上記の構文は、 A=4*B と最適化され、これにより定義(I=4)の回数を減ら
すことができる。That is, for example, if the syntax I = 4 A = I * B is described in the language L n in the program, the optimization unit 22 optimizes the above syntax as A = 4 * B. As a result, the number of definitions (I = 4) can be reduced.
【0035】また、例えば A[I+1]=B[I+1]*C[I+1] いう構文がプログラムの中に言語Lnで記述されている
と、最適化部22において、上記の構文は、 J=I+1 A[J]=B[J]*C[J] と最適化され、これにより加算(I+1)の回数を3回
から1回に減らすことができる。Further, for example, if the syntax A [I + 1] = B [I + 1] * C [I + 1] is described in the language L n in the program, the above-mentioned syntax is J = Optimized as I + 1 A [J] = B [J] * C [J], which can reduce the number of additions (I + 1) from 3 to 1.
【0036】共通モジュール部2の最適化部22で最適
化された中間コードは、DSPm用バックエンド部3mの
スケジューリング部31m(図4)に出力され、スケジ
ューリング部31mにおいて、DSPmのアーキテクチャ
が並列処理を行うことができるものである場合には、共
通モジュール部2で最適化された中間コードが、並列に
実行可能な単位(タスク)に分割され、分割された各タ
スクが、DSPmを構成する、例えばALU、乗算器、
加算器、またはシフタなどに割り当てられる(スケジュ
ーリングされる)。The optimized intermediate code in the common module unit 2 of the optimization unit 22 is output to the DSP m for the back-end portion 3 m of the scheduling section 31 m (Fig. 4), in the scheduling section 31 m, DSP m If the architecture of is capable of performing parallel processing, the intermediate code optimized by the common module unit 2 is divided into units (tasks) that can be executed in parallel, and each divided task is The DSP m is composed of, for example, an ALU, a multiplier,
It is assigned (scheduled) to an adder, a shifter, or the like.
【0037】そして、コード生成/レジスタ割付部32
mにおいて、共通モジュール部2の最適化部22より出
力された中間コードから、DSPmに対応したオブジェ
クトコードが生成されるとともに、DSPmの有するレ
ジスタに、効率的に変数を割り付けるためのレジスタ割
付が行われ、DSPmに対応したオブジェクトコードが
最適化部33mに出力される。最適化部33mにおいて、
必要に応じて共通モジュール部2の依存解析部21で作
成されたデータフローグラフが参照され、コード生成/
レジスタ割付部32mより出力されたオブジェクトコー
ドに対して、DSPmに依存した最適化処理が施され、
言語Lnで記述されたDSPm用のプログラムのコンパイ
ルが終了する。The code generating / register allocating unit 32
In m , an object code corresponding to DSP m is generated from the intermediate code output from the optimizing unit 22 of the common module unit 2, and register allocation for efficiently allocating variables to registers of DSP m It is carried out, and an object code corresponding to the DSP m is output to the optimization unit 33 m. In the optimization unit 33 m ,
If necessary, the data flow graph created by the dependency analysis unit 21 of the common module unit 2 is referred to, and the code generation /
The object code output from the register allocating unit 32 m is subjected to optimization processing depending on DSP m ,
Compiling of the program for DSP m described in the language L n is completed.
【0038】以下、DSPm で3タップのFIR型ディ
ジタルフィルタを実現するプログラム y(0)=h(0)*x(0)+h(1)*x(1)+h(2)*x(2) y(1)=h(0)*x(1)+h(1)*x(2)+h(2)*x(3) y(2)=h(0)*x(2)+h(1)*x(3)+h(2)*x(4) を例にして、DSPm用バックエンド部3mのスケジュー
リング部31m、コード生成/レジスタ割付部32m、お
よび最適化部33mの動作を、さらに説明する。なお、
このプログラムにおいて、h(0),h(1)、および
h(2)はフィルタの係数、x(0),x(1),・・
・はフィルタへの入力信号、y(0),y(1),・・
・はフィルタ出力を示す。A program for realizing a 3-tap FIR digital filter with DSP m is as follows: y (0) = h (0) * x (0) + h (1) * x (1) + h (2) * x (2 ) Y (1) = h (0) * x (1) + h (1) * x (2) + h (2) * x (3) y (2) = h (0) * x (2) + h (1 ) * x (3) + h (2) * x (4) as an example, the scheduling unit 31 m of the back-end portion 3 m for DSP m, code generation / register allocation unit 32 m, and the optimization unit 33 m The operation will be further described. In addition,
In this program, h (0), h (1), and h (2) are filter coefficients, x (0), x (1), ...
• is the input signal to the filter, y (0), y (1), ...
・ Indicates the filter output.
【0039】上記のソースコードを中間コードで表現す
ると、 temp1=h(0)*x(0) (a1) temp2=h(1)*x(1) (a2) temp3=h(2)*x(2) (a3) temp4=temp1+temp2 (a4) y(0)=temp3+temp4 (a5) temp5=h(0)*x(1) (b1) temp6=h(1)*x(2) (b2) temp7=h(2)*x(3) (b3) temp8=temp5+temp6 (b4) y(1)=temp7+temp8 (b5) temp9=h(0)*x(2) (c1) temp10=h(1)*x(3) (c2) temp11=h(2)*x(4) (c3) temp12=temp9+temp10 (c4) y(2)=temp11+temp12 (c5) となる。When the above source code is expressed as an intermediate code, temp1 = h (0) * x (0) (a1) temp2 = h (1) * x (1) (a2) temp3 = h (2) * x (2) (a3) temp4 = temp1 + temp2 (a4) y (0) = temp3 + temp4 (a5) temp5 = h (0) * x (1) (b1) temp6 = h (1) * x (2) (b2) temp7 = H (2) * x (3) (b3) temp8 = temp5 + temp6 (b4) y (1) = temp7 + temp8 (b5) temp9 = h (0) * x (2) (c1) temp10 = h (1) * x (3) (c2) temp11 = h (2) * x (4) (c3) temp12 = temp9 + temp10 (c4) y (2) = temp11 + temp1 To become (c5).
【0040】ここで、DSPmが、充分な数のレジスタ
を有するとすると、式(a1)乃至(a5)、式(b
1)乃至(b5)、および式(c1)乃至(c5)(以
下、式(a1)乃至(c5)と記載する)のデータ依存
は、前述したフロー依存のみとなり、式(a1)および
式(a2)での定義が、式(a4)で参照されていると
いうフロー依存を (a1),(a2)→(a4) と表すと、式(a1)乃至(a5)、式(b1)乃至
(b5)、および式(c1)乃至(c5)のデータ依存
は、 (a1),(a2)→(a4) (a3),(a4)→(a5) (b1),(b2)→(b4) (b3),(b4)→(b5) (c1),(c2)→(c4) (c3),(c4)→(c5) となる。Assuming that DSP m has a sufficient number of registers, equations (a1) to (a5) and equation (b) are used.
1) to (b5) and equations (c1) to (c5) (hereinafter, referred to as equations (a1) to (c5)) have only the data dependence described above, that is, the equation (a1) and the equation (a1) When the flow dependence that the definition in a2) is referred to in expression (a4) is expressed as (a1), (a2) → (a4), expressions (a1) to (a5) and expressions (b1) to (b1) to (b1) b5) and the data dependence of the expressions (c1) to (c5) are (a1), (a2) → (a4) (a3), (a4) → (a5) (b1), (b2) → (b4). (B3), (b4) → (b5) (c1), (c2) → (c4) (c3), (c4) → (c5).
【0041】DSPmが並列に実行可能なアーキテクチ
ャを有さない場合、即ち例えば演算器として2入力1出
力の演算器を1つだけDSPmが有する場合、スケジュ
ーリング部31mにおいて、式(a1)乃至(c5)で
示される演算が、DSPmが内蔵する1つだけの演算器
に、図5に示すように割り当てられる(スケジューリン
グされる)。When the DSP m does not have an architecture that can be executed in parallel, that is, when the DSP m has only one 2-input 1-output arithmetic unit as an arithmetic unit, the scheduling unit 31 m uses the formula (a1) The operations indicated by (c5) to (c5) are assigned (scheduled) to only one arithmetic unit incorporated in the DSP m as shown in FIG.
【0042】即ち、DSPmが内蔵する演算器が1クロ
ックで動作するとすると、スケジューリング部31mで
は、式(a1)乃至(c5)で示される演算が、それぞ
れ1乃至15クロック目に、演算器で行われるように割
り当てられる。That is, if the arithmetic unit incorporated in the DSP m operates in one clock, the scheduling unit 31 m executes the arithmetic operations represented by the expressions (a1) to (c5) at the 1st to 15th clocks, respectively. Assigned to be done in.
【0043】また、DSPmが並列に実行可能なアーキ
テクチャを有する場合、即ち例えば演算器として、9個
の、2入力1出力の乗算器X1乃至X9、および6個の、
2入力1出力の加算器Y1乃至Y6をDSPmが有する場
合、スケジューリング部31mにおいて、式(a1)乃
至(c5)で示される演算が、DSPmが内蔵する乗算
器X1乃至X9および加算器Y1乃至Y6に、図6に示すよ
うに割り当てられる(スケジューリングされる)。When the DSP m has an architecture capable of being executed in parallel, that is, as the arithmetic units, for example, nine 2-input 1-output multipliers X 1 to X 9 and 6
When the DSP m has the 2-input 1-output adders Y 1 to Y 6 , the scheduling unit 31 m performs the operations represented by the expressions (a1) to (c5) by the multipliers X 1 to X included in the DSP m. 9 and adders Y 1 to Y 6 are assigned (scheduled) as shown in FIG.
【0044】即ち、乗算器X1乃至X9および加算器Y1
乃至Y6が1クロックで動作するとすると、スケジュー
リング部31mにおいて、1クロック目に、式(a1)
乃至(a3)、式(b1)乃至(b3)、または式(c
1)乃至(c3)で示される演算(乗算)が、乗算器X
1乃至X9でそれぞれ行われるように割り当てられ、2ク
ロック目に、式(a4),(b4)、または(c4)で
示される演算(加算)が、加算器Y1,Y3、またはY5
でそれぞれ行われるように割り当てられるとともに、3
クロック目に、式(a5),(b5)、または(c5)
で示される演算(加算)が、加算器Y2,Y4、またはY
6でそれぞれ行われるように割り当てられる。That is, the multipliers X 1 to X 9 and the adder Y 1
If Y to Y 6 operate in one clock, in the scheduling unit 31 m , at the first clock, the formula (a1)
To (a3), formulas (b1) to (b3), or formula (c
The operations (multiplication) indicated by 1) to (c3) are performed by the multiplier X.
1 to X 9 , respectively, and the operation (addition) represented by the formula (a4), (b4), or (c4) is performed by the adder Y 1 , Y 3 , or Y at the second clock. Five
Assigned to take place respectively in 3
At the clock eye, expression (a5), (b5), or (c5)
The operation (addition) indicated by is the adder Y 2 , Y 4 , or Y
Assigned as done in 6 respectively.
【0045】さらに、DSPmが、例えば演算器とし
て、3個の、2入力1出力の乗算器X1乃至X3、並びに
2個の、2入力1出力の加算器Y1およびY2を有する場
合、スケジューリング部31mにおいて、式(a1)乃
至(c5)で示される演算が、DSPmが内蔵する乗算
器X1乃至X3並びに加算器Y1およびY2に、図7に示す
ように割り当てられる(スケジューリングされる)。Further, the DSP m has, for example, three 2-input 1-output multipliers X 1 to X 3 and two 2-input 1-output adders Y 1 and Y 2 as arithmetic units. In this case, in the scheduling unit 31 m , the operations represented by the formulas (a1) to (c5) are performed by the multipliers X 1 to X 3 and the adders Y 1 and Y 2 incorporated in the DSP m as shown in FIG. Assigned (scheduled).
【0046】即ち、乗算器X1乃至X3並びに加算器Y1
およびY2が1クロックで動作するとすると、スケジュ
ーリング部31mにおいて、1クロック目に、式(a
1)乃至(a3)で示される演算が、乗算器X1乃至X3
でそれぞれ行われるように割り当てられ、2クロック目
に、式(b1)乃至(b3)、または式(a4)で示さ
れる演算が、乗算器X1乃至X3、または加算器Y1でそ
れぞれ行われるように割り当てられるとともに、3クロ
ック目に、式(c1)乃至(c3)、式(b4)、また
は式(a5)で示される演算が、乗算器X1乃至X3、加
算器Y1またはY2でそれぞれ行われるように割り当てら
れる。さらに、4クロック目には、式(c4)または式
(b5)で示される演算が、加算器Y1またはY2でそれ
ぞれ行われるように割り当てられ、5クロック目に、式
(c5)で示される演算が、加算器Y2で行われるよう
に割り当てられる。That is, the multipliers X 1 to X 3 and the adder Y 1
If Y 2 and Y 2 operate in one clock, the scheduling unit 31 m outputs the formula (a
The operations shown in 1) to (a3) are performed by the multipliers X 1 to X 3
And the operations represented by the formulas (b1) to (b3) or the formula (a4) are performed by the multipliers X 1 to X 3 or the adder Y 1 at the second clock, respectively. And the operations represented by the formulas (c1) to (c3), the formula (b4), or the formula (a5) are assigned to the multipliers X 1 to X 3 , the adder Y 1 or Assigned as done in Y 2 , respectively. Further, at the 4th clock, the operation represented by the formula (c4) or the formula (b5) is assigned to be performed by the adder Y 1 or Y 2 , respectively, and at the 5th clock, the formula (c5) is represented. The operations performed are assigned to be performed in adder Y 2 .
【0047】また、DSPmが、例えば演算器として、
2個の、2入力1出力の乗算器X1およびX2、並びに1
個の、2入力1出力の加算器Y1を有する場合、スケジ
ューリング部31mにおいて、式(a1)乃至(c5)
で示される演算が、DSPmが内蔵する乗算器X1および
X2並びに加算器Y1に、図8に示すように割り当てられ
る(スケジューリングされる)。Further, the DSP m is, for example, as an arithmetic unit,
Two 2-input 1-output multipliers X 1 and X 2 and 1
In the case of having two 2-input 1-output adders Y 1 , in the scheduling unit 31 m , equations (a1) to (c5)
The operation indicated by is assigned (scheduled) to the multipliers X 1 and X 2 and the adder Y 1 incorporated in the DSP m as shown in FIG.
【0048】即ち、乗算器X1およびX2並びに加算器Y
1が1クロックで動作するとすると、スケジューリング
部31mにおいて、乗算器X1で、式(a1),(a
3),(b2),(c1)、または(c3)で示される
演算が、1乃至5クロック目にそれぞれ行われるように
割り当てられ、乗算器X2で、式(a2),(b1),
(b3)、または(c2)で示される演算が、1乃至4
クロック目にそれぞれ行われるように割り当てられると
ともに、加算器Y1で、式(a4),(a5),(b
4),(b5),(c4)、または(c5)で示される
演算が、2乃至7クロック目にそれぞれ行われるように
割り当てられる。That is, the multipliers X 1 and X 2 and the adder Y
When 1 is to operate in one clock, in the scheduling section 31 m, a multiplier X 1, formula (a1), (a
3), (b2), (c1), or (c3) is assigned to be performed at each of the 1st to 5th clocks, and the multiplier X 2 uses the expressions (a2), (b1),
The calculation represented by (b3) or (c2) is 1 to 4
It is assigned so as to be performed at each clock cycle, and at the adder Y 1 , the equations (a4), (a5), (b
4), (b5), (c4), or (c5) is assigned so as to be performed at the second to seventh clocks, respectively.
【0049】スケジューリング部31mでのスケジュー
リングが終了すると、コード生成/レジスタ割付部32
mにおいて、DSPmの有するレジスタに、効率的に変数
を割り付けるためのレジスタ割付が行われながら、式
(a1)乃至式(c5)に示す中間コードから、DSP
mに対応したオブジェクトコードが生成される。When the scheduling by the scheduling unit 31 m is completed, the code generation / register allocation unit 32
In m , while register allocation for efficiently allocating variables to the register of DSP m is performed, the DSP is changed from the intermediate code shown in formulas (a1) to (c5) to
The object code corresponding to m is generated.
【0050】DSPmが3つのレジスタreg1乃至r
eg3を有する場合、コード生成/レジスタ割付部32
mにおいて、式(a1)乃至式(c5)における変数t
emp1乃至temp12が、レジスタreg1乃至r
eg3に割り付けられながら、式(a1)乃至式(c
5)で示された中間コードから、DSPmに対応したオ
ブジェクトコードが、例えば MUL h(0),x(0),reg1 (A1) MUL h(1),x(1),reg2 (A2) MUL h(2),x(2),reg3 (A3) ST reg3,mem1 (A4) ADD reg1,reg2,reg3 (A5) LD mem1,reg1 (A6) ADD reg1,reg3,y(0) (A7) MUL h(0),x(1),reg1 (B1) MUL h(1),x(2),reg2 (B2) MUL h(2),x(3),reg3 (B3) ST reg3,mem2 (B4) ADD reg1,reg2,reg3 (B5) LD mem2,reg1 (B6) ADD reg1,reg3,y(1) (B7) MUL h(0),x(2),reg1 (C1) MUL h(1),x(3),reg2 (C2) MUL h(2),x(4),reg3 (C3) ST reg3,mem3 (C4) ADD reg1,reg2,reg3 (C5) LD mem3,reg1 (C6) ADD reg1,reg3,y(2) (C7) のように生成される。DSP m has three registers reg1 through r
In the case of having eg3, the code generation / register allocation unit 32
In m , the variable t in equations (a1) to (c5)
emp1 to temp12 are registers reg1 to r
While being assigned to eg3, equations (a1) to (c)
From the intermediate code shown in 5), the object code corresponding to DSP m is, for example, MUL h (0), x (0), reg1 (A1) MUL h (1), x (1), reg2 (A2) MUL h (2), x (2), reg3 (A3) ST reg3, mem1 (A4) ADD reg1, reg2, reg3 (A5) LD mem1, reg1 (A6) ADD reg1, reg3, y (0) (A7) MUL h (0), x (1), reg1 (B1) MUL h (1), x (2), reg2 (B2) MUL h (2), x (3), reg3 (B3) ST reg3, mem2 ( B4) ADD reg1, reg2, reg3 (B5) LD mem2, reg1 (B6) ADD reg1, reg3, y (1) (B7) MUL h (0), x (2 ), Reg1 (C1) MUL h (1), x (3), reg2 (C2) MUL h (2), x (4), reg3 (C3) ST reg3, mem3 (C4) ADD reg1, reg2, reg3 ( C5) LD mem3, reg1 (C6) is generated as ADD reg1, reg3, y (2) (C7).
【0051】オブジェクトコード(A1)乃至(A3)
は、 reg1=h(0)*x(0), reg2=h(1)*x(1)、または reg3=h(2)*x(2) をそれぞれ示し、式(a1)乃至(a3)に対応する。
DSPmには、3つのレジスタreg1乃至reg3し
かないので、式(a4)を計算するために、オブジェク
トコード(A4)で、レジスタreg3の内容(式(a
3)の変数temp3の内容)がスタックmem1に退
避され(ストアされ)、オブジェクトコード(A5)
で、式(a4)に対応する reg3=reg1+reg2 が計算される。Object code (A1) to (A3)
Are reg1 = h (0) * x (0), reg2 = h (1) * x (1), or reg3 = h (2) * x (2), respectively, and are expressed by equations (a1) to (a3). Corresponding to.
Since the DSP m has only three registers reg1 to reg3, the contents of the register reg3 (expression (a (a4)
The contents of the variable temp3 in 3) is saved (stored) in the stack mem1 and the object code (A5)
Then, reg3 = reg1 + reg2 corresponding to the equation (a4) is calculated.
【0052】そして、オブジェクトコード(A6)で、
スタックmem1にストアされた式(a3)の変数te
mp3の内容(h(2)*x(2))が、レジスタre
g1にロードされ、オブジェクトコード(A7)で、式
(a5)に対応する y(0)=reg1+reg3 が計算される。Then, in the object code (A6),
The variable te of the expression (a3) stored in the stack mem1
The contents of mp3 (h (2) * x (2)) are stored in the register re
The object code (A7) is loaded into g1 and y (0) = reg1 + reg3 corresponding to the expression (a5) is calculated.
【0053】オブジェクトコード(B1)乃至(B
7)、または(C1)乃至(C7)でも、上記したオブ
ジェクトコード(A1)乃至(A7)における場合と同
様にして、式(b1)乃至(b5)、または(c1)乃
至(c5)にそれぞれ対応する処理がなされる。Object codes (B1) to (B
7), or (C1) to (C7), in the same manner as in the case of the above object codes (A1) to (A7), the formulas (b1) to (b5) or (c1) to (c5) are respectively added. Corresponding processing is performed.
【0054】なお、DSPmが、例えば1クロックで動
作する演算器として、3個の、2入力1出力の乗算器X
1乃至X3、並びに2個の、2入力1出力の加算器Y1お
よびY2を有し、データのロードおよびストアを1クロ
ックで行うとすると、上記のオブジェクトコード(A
1)乃至(A7),(B1)乃至(B7)、および(C
1)乃至(C7)は、図9に示すように実行される。It should be noted that the DSP m is, for example, three multipliers X each having two inputs and one output, which operate as one clock.
1 to X 3 , and two 2-input 1-output adders Y 1 and Y 2 , and if the data is loaded and stored in one clock, the above object code (A
1) to (A7), (B1) to (B7), and (C
1) to (C7) are executed as shown in FIG.
【0055】即ち、1クロック目に、オブジェクトコー
ド(A1)乃至(A3)に対応する式(a1)乃至(a
3)で示される演算が、乗算器X1乃至X3でそれぞれ行
われ、2クロック目に、オブジェクトコード(B1)乃
至(B3)に対応する式(b1)乃至(b3)で示され
る演算が、乗算器X1乃至X3でそれぞれ行われるととも
に、オブジェクトコード(A4)に対応するレジスタr
eg3のスタックmem1へのストアが行われる。That is, at the first clock, the expressions (a1) to (a) corresponding to the object codes (A1) to (A3).
The operation shown in 3) is performed in each of the multipliers X 1 to X 3 , and at the second clock, the operations shown in the expressions (b1) to (b3) corresponding to the object codes (B1) to (B3) are performed. , Multipliers X 1 to X 3 respectively, and register r corresponding to the object code (A4)
Store to the stack mem1 of eg3.
【0056】3クロック目に、オブジェクトコード(C
1)乃至(C3)または(A5)に対応する式(c1)
乃至(c3)、または式(a4)で示される演算が、乗
算器X1乃至X3、加算器Y1でそれぞれ行われるととも
に、オブジェクトコード(B4)に対応するレジスタr
eg3のスタックmem2へのストアが行われ、4クロ
ック目に、オブジェクトコード(B5)に対応する式
(b4)で示される演算が、加算器Y1で行われるとと
もに、オブジェクトコード(C4)に対応するレジスタ
reg3のスタックmem3へのストアと、オブジェク
トコード(A6)に対応するスタックmem1からレジ
スタreg1へのロードが行われる。At the third clock, the object code (C
Formula (c1) corresponding to 1) to (C3) or (A5)
To (c3) or the equation (a4) is performed in each of the multipliers X 1 to X 3 and the adder Y 1 , and the register r corresponding to the object code (B4)
The store of the eg3 to the stack mem2 is performed, and at the fourth clock, the operation represented by the expression (b4) corresponding to the object code (B5) is performed by the adder Y 1 and the operation corresponding to the object code (C4) is performed. The register reg3 is stored in the stack mem3, and the register reg1 is loaded from the stack mem1 corresponding to the object code (A6).
【0057】5クロック目には、オブジェクトコード
(C5)または(A7)に対応する式(c4)または
(a5)で示される演算が、加算器Y1またはY2でそれ
ぞれ行われるとともに、オブジェクトコード(B6)に
対応するスタックmem2からレジスタreg1へのロ
ードが行われ、6クロック目に、オブジェクトコード
(B7)に対応する式(b5)で示される演算が、加算
器Y2で行われるとともに、オブジェクトコード(C
6)に対応するスタックmem3からレジスタreg1
へのロードが行われる。At the 5th clock, the operation represented by the equation (c4) or (a5) corresponding to the object code (C5) or (A7) is performed by the adder Y 1 or Y 2 , respectively, and the object code The register reg1 is loaded from the stack mem2 corresponding to (B6), and at the sixth clock, the operation represented by the expression (b5) corresponding to the object code (B7) is performed by the adder Y 2 and Object code (C
Register reg1 from stack mem3 corresponding to 6)
Is loaded.
【0058】そして、7クロック目に、オブジェクトコ
ード(C7)に対応する式(c5)で示される演算が、
加算器Y2で行われ、処理を終了する。At the 7th clock, the operation represented by the equation (c5) corresponding to the object code (C7) is
The processing is completed by the adder Y 2 .
【0059】次に、上記のような、DSPmに対応した
オブジェクトコードが、最適化部33mに供給される
と、最適化部33mにおいて、このオブジェクトコード
に対して、DSPmに依存した最適化処理が施される。Next, as described above, an object code corresponding to the DSP m is, when supplied to the optimization unit 33 m, in the optimization unit 33 m, with respect to the object code, depending on the DSP m Optimization processing is performed.
【0060】即ち、例えば LD mem,reg (D1) ST reg,mem (D2) のような、メモリmemからレジスタregにデータを
ロードし(D1)、すぐにレジスタregのデータをメ
モリmemにストアする(D2)ことを示すオブジェク
トコードにおいては、同じ内容(データ)を、メモリm
emにストアすることは無駄であるから、最適化部33
mにおいて、オブジェクトコード(D2)が削除される
(冗長なロード/ストア命令の削除)。That is, data is loaded from the memory mem to the register reg (D1) such as LD mem, reg (D1) ST reg, mem (D2), and the data of the register reg is immediately stored in the memory mem. In the object code indicating (D2), the same content (data) is stored in the memory m.
Since storing in em is useless, the optimization unit 33
At m , the object code (D2) is deleted (redundant load / store instruction deletion).
【0061】また、例えば ADD 0,reg,reg (E1) MUL 1,reg,reg (E2) のような、レジスタregに0を加算して、レジスタr
egに記憶させたり(E1)、レジスタregに1を乗
じて、レジスタregに記憶させたりする(E2)オブ
ジェクトコードにおいては、0の加算や1の乗算は結果
が変わらないので、やはり無駄であるから、最適化部3
3mにおいて、オブジェクトコード(E1)および(E
1)とも削除される(代数的簡約化)。Further, 0 is added to the register reg, such as ADD 0, reg, reg (E1) MUL 1, reg, reg (E2), and the register r is added.
In object code in which the result is stored in eg (E1) or the register reg is multiplied by 1 and stored in the register reg (E2), the addition of 0 and the multiplication of 1 do not change the result, which is also useless. From the optimization unit 3
At 3 m , the object code (E1) and (E
Both 1) are deleted (algebraic reduction).
【0062】以上のように、このコンパイラでは、プロ
グラムを記述した言語L1乃至LNに対応した言語L1用
フロントエンド部11乃至言語LNフロントエンド部1N
で前処理を行い、DSP1乃至DSPMに対応したオブジ
ェクトコードを出力するDSP1用バックエンド部31乃
至DSPM用バックエンド部3Mで後処理を行うととも
に、言語L1乃至LNおよびDSP1乃至DSPMに依存し
ない処理(フェーズ)を共通モジュール部2で行うよう
にしたので、言語L1乃至LNのうちのどの言語で記述さ
れたプログラムでも、また、DSP1乃至DSPMのうち
のどのDSPに対応するプログラムでもコンパイルする
ことができる。[0062] As described above, in this compiler front end portion 1 1 to Language language L 1 corresponding to the language L 1 to L N describing the program L N front end portion 1 N
In Preprocess, performs post-processing in DSP 1 to DSP 1 for the back-end portion 3 1 to the back for DSP M end portion 3 to output the object code corresponding to the DSP M M, languages L 1 to L N and Since the common module unit 2 performs the processing (phase) that does not depend on the DSP 1 to DSP M , the program written in any of the languages L 1 to L N , and the DSP 1 to DSP M A program compatible with any of the DSPs can be compiled.
【0063】[0063]
【発明の効果】請求項1に記載のコンパイル方法によれ
ば、ディジタルシグナルプロセッサ(DSP)のプログ
ラムのソースコードを、DSPのプログラムを記述する
ための複数の言語、または複数のDSPにそれぞれ対応
したオブジェクトコードに共通の中間コードに変換し、
その中間コードをDSPに対応したオブジェクトコード
に変換する。従って、DSPおよび言語に依存せずに、
プログラムをコンパイルすることができる。According to the compiling method of the first aspect, the source code of the digital signal processor (DSP) program corresponds to a plurality of languages for describing the DSP program or a plurality of DSPs. Converted to intermediate code common to object code,
The intermediate code is converted into an object code compatible with DSP. Therefore, regardless of DSP and language,
The program can be compiled.
【0064】請求項2に記載のコンパイラによれば、デ
ィジタルシグナルプロセッサ(DSP)のプログラムの
ソースコードを言語に共通の中間コードに変換し、その
中間コードを解析して最適化する。そして、最適化した
中間コードを複数のDSPにそれぞれ対応したオブジェ
クトコードに変換する。従って、DSPおよび言語に依
存せずに、プログラムをコンパイルすることができる。According to the compiler of the second aspect, the source code of the program of the digital signal processor (DSP) is converted into an intermediate code common to the language, and the intermediate code is analyzed and optimized. Then, the optimized intermediate code is converted into an object code corresponding to each of the plurality of DSPs. Therefore, the program can be compiled independently of the DSP and the language.
【0065】請求項3に記載のコンパイラによれば、共
通処理手段に、中間コードに対して、複数のDSPのど
れにも依存しない最適化処理を施させるので、重複した
フェーズによる無駄な処理が防止される。According to the third aspect of the compiler, since the common processing means is caused to perform the optimization processing that does not depend on any of the plurality of DSPs with respect to the intermediate code, wasteful processing due to overlapping phases is eliminated. To be prevented.
【0066】請求項4に記載のコンパイラは、後処理手
段に、中間コードを並列に実行可能な単位に分割させ、
DSPに割り当てさせるので、並列処理をすることがで
きるDSPの機能を有効に利用することができる。A compiler according to a fourth aspect causes the post-processing means to divide the intermediate code into units that can be executed in parallel,
Since it is assigned to the DSP, it is possible to effectively use the function of the DSP capable of parallel processing.
【0067】請求項5に記載のコンパイラは、後処理手
段に、レジスタ割付を行わせるので、DSPのレジスタ
を効率的に利用することができる。The compiler according to the fifth aspect causes the post-processing means to perform register allocation, so that the registers of the DSP can be efficiently used.
【図1】本発明のコンパイラの一実施例の構成を示すブ
ロック図である。FIG. 1 is a block diagram showing a configuration of an embodiment of a compiler of the present invention.
【図2】図1の実施例の言語L1用フロントエンド部11
乃至言語LNフロントエンド部1Nのより詳細を示す図で
ある。FIG. 2 is a front end section 1 1 for a language L 1 of the embodiment shown in FIG.
FIG. 6 is a diagram showing more details of the language L N front end unit 1 N.
【図3】図1の実施例の共通モジュール部2のより詳細
を示す図である。FIG. 3 is a diagram showing more details of a common module unit 2 of the embodiment of FIG.
【図4】図1の実施例のDSP1用バックエンド部31乃
至DSPM用バックエンド部3Mのより詳細を示す図であ
る。FIG. 4 is a diagram showing more details of the DSP 1 back-end unit 3 1 to the DSP M back-end unit 3 M in the embodiment of FIG.
【図5】図4のスケジューリング部で行われるスケジュ
ーリングを説明するための図である。5 is a diagram for explaining the scheduling performed by the scheduling unit of FIG.
【図6】図4のスケジューリング部で行われるスケジュ
ーリングを説明するための図である。FIG. 6 is a diagram for explaining scheduling performed by the scheduling unit of FIG.
【図7】図4のスケジューリング部で行われるスケジュ
ーリングを説明するための図である。FIG. 7 is a diagram for explaining scheduling performed by the scheduling unit of FIG.
【図8】図4のスケジューリング部で行われるスケジュ
ーリングを説明するための図である。FIG. 8 is a diagram for explaining scheduling performed by the scheduling unit in FIG.
【図9】図4のコード生成/レジスタ割付部32mで生
成されたDSPmに対応したオブジェクトコードが実行
される様子を説明するための図である。9 is a diagram for explaining how the object code corresponding to the DSP m generated by the code generation / register allocation unit 32 m in FIG. 4 is executed.
1 フロントエンド部 11乃至1N 言語L1用フロントエンド部乃至言語LNフ
ロントエンド部 2 共通モジュール部 3 バックエンド部 31乃至3M DSP1用バックエンド部乃至DSPM用バ
ックエンド部 11n 字句解析部 12n 構文解析部 13n 意味解析部 21 依存解析部 22 最適化部 31m スケジューリング部 32m コード生成/レジスタ割付部 33m 最適化部1 Front End Part 1 1 to 1 N Front End Part for Language L 1 to Language L N Front End Part 2 Common Module Part 3 Back End Part 3 1 to 3 M Back End Part for DSP 1 to Back End Part for DSP M 11n Lexical analysis unit 12n Syntax analysis unit 13n Semantic analysis unit 21 Dependency analysis unit 22 Optimization unit 31m Scheduling unit 32m Code generation / register allocation unit 33m Optimization unit
Claims (5)
ラムのソースコードを中間コードに変換し、 前記中間コードを前記ディジタルシグナルプロセッサに
対応したオブジェクトコードに変換するコンパイル方法
において、 前記中間コードは、前記ディジタルシグナルプロセッサ
のプログラムを記述するための複数の言語、または複数
のディジタルシグナルプロセッサにそれぞれ対応したオ
ブジェクトコードに共通であることを特徴とするコンパ
イル方法。1. A compiling method for converting a source code of a program of a digital signal processor into an intermediate code, and converting the intermediate code into an object code corresponding to the digital signal processor, wherein the intermediate code is of the digital signal processor. A compiling method characterized by being common to object codes corresponding to a plurality of languages for writing a program or a plurality of digital signal processors.
ラムのソースコードを中間コードに変換する前処理手段
と、 前記前処理手段より出力される中間コードを解析して最
適化する共通処理手段と、 前記共通処理手段からの出力を前記ディジタルシグナル
プロセッサに対応したオブジェクトコードに変換する後
処理手段とを備え、 前記前処理手段は、前記ディジタルシグナルプロセッサ
のプログラムを記述するための複数の言語に共通の中間
コードを出力し、 前記後処理手段は、前記中間コードを複数のディジタル
シグナルプロセッサにそれぞれ対応したオブジェクトコ
ードに変換することを特徴とするコンパイラ。2. Preprocessing means for converting the source code of the program of the digital signal processor into intermediate code, common processing means for analyzing and optimizing the intermediate code output from the preprocessing means, and the common processing means. Post-processing means for converting the output from the digital signal processor into an object code corresponding to the digital signal processor, wherein the pre-processing means outputs an intermediate code common to a plurality of languages for describing a program of the digital signal processor. The post-processing means converts the intermediate code into object code corresponding to a plurality of digital signal processors, respectively.
対して、前記複数のディジタルシグナルプロセッサのど
れにも依存しない最適化処理を施すことを特徴とする請
求項2に記載のコンパイラ。3. The compiler according to claim 2, wherein the common processing means performs an optimization process on the intermediate code that does not depend on any of the plurality of digital signal processors.
列に実行可能な単位に分割し、前記ディジタルシグナル
プロセッサに割り当てることを特徴とする請求項2また
は3に記載のコンパイラ。4. The compiler according to claim 2, wherein the post-processing unit divides the intermediate code into units that can be executed in parallel and assigns the units to the digital signal processor.
ことを特徴とする請求項2,3、または4に記載のコン
パイラ。5. The compiler according to claim 2, 3 or 4, wherein the post-processing means performs register allocation.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP17627392A JPH05342012A (en) | 1992-06-10 | 1992-06-10 | Compiling method and compiler |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP17627392A JPH05342012A (en) | 1992-06-10 | 1992-06-10 | Compiling method and compiler |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| JPH05342012A true JPH05342012A (en) | 1993-12-24 |
Family
ID=16010697
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP17627392A Withdrawn JPH05342012A (en) | 1992-06-10 | 1992-06-10 | Compiling method and compiler |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JPH05342012A (en) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2008505422A (en) * | 2004-07-02 | 2008-02-21 | エヌヴィディア コーポレイション | Optimized chaining of vertex and fragment programs |
| JP2011501325A (en) * | 2007-10-26 | 2011-01-06 | クゥアルコム・インコーポレイテッド | Server-based code compilation |
| US9075913B2 (en) | 2012-02-27 | 2015-07-07 | Qualcomm Incorporated | Validation of applications for graphics processing unit |
-
1992
- 1992-06-10 JP JP17627392A patent/JPH05342012A/en not_active Withdrawn
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2008505422A (en) * | 2004-07-02 | 2008-02-21 | エヌヴィディア コーポレイション | Optimized chaining of vertex and fragment programs |
| JP2011501325A (en) * | 2007-10-26 | 2011-01-06 | クゥアルコム・インコーポレイテッド | Server-based code compilation |
| US9075913B2 (en) | 2012-02-27 | 2015-07-07 | Qualcomm Incorporated | Validation of applications for graphics processing unit |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| Leupers | Retargetable code generation for digital signal processors | |
| Huang et al. | Pylog: An algorithm-centric python-based FPGA programming and synthesis flow | |
| Goossens et al. | Embedded software in real-time signal processing systems: Design technologies | |
| JP7669342B2 (en) | AUTOMATIC TRANSFORMATION OF PROCEDURAL PROGRAMMING LANGUAGE PROGRAMMING PROGRAMS INTO DATAFLOW GRAPHS AND ASSOCIATED SYSTEMS AND METHODS - Patent application | |
| Franke et al. | Array recovery and high-level transformations for DSP applications | |
| Cattaneo et al. | TAFFO: The compiler-based precision tuner | |
| Zhang et al. | Snowflake: A lightweight portable stencil dsl | |
| JPH05342012A (en) | Compiling method and compiler | |
| Gauthier et al. | HDLRuby: A Ruby extension for hardware description and its translation to synthesizable Verilog HDL | |
| Hinsen et al. | Using B SP and Python to simplify parallel programming | |
| Brandner et al. | Automatic generation of compiler backends | |
| JP7407192B2 (en) | Method and apparatus for optimizing code for field programmable gate arrays | |
| Rudi et al. | CodeFlow: A code generation system for Flash-X orchestration runtime | |
| Becker et al. | From scilab to high performance embedded multicore systems: The alma approach | |
| Zou et al. | Aquas: Enhancing Domain Specialization through Holistic Hardware-Software Co-Optimization based on MLIR | |
| Nawaz et al. | Recursive variable expansion: A loop transformation for reconfigurable systems | |
| Parfieniuk et al. | A Compiler for a Domain-Specific Language for Rapid Implementation of DSP Transforms and Filter Banks | |
| EP3827336B1 (en) | Method and apparatus for optimizing code for field programmable gate arrays | |
| Henriques et al. | Using source-to-source to target risc-v custom extensions: Uve case-study | |
| Mego et al. | Tool for algorithms mapping with help of signal-flow graph approach | |
| Ding | Automated translation between graphical and textual representations of intensional programs in the GIPSY | |
| Kasyanov et al. | Methods and Tools for Constructing Specialized Versions of General-Purpose Cloud Sisal Programs | |
| Silverthorn et al. | Guidelines for software development efficiency on the TMS320C6000 VelociTI architecture | |
| Tabbara et al. | Architectural Optimizations | |
| Latifis et al. | A Retargetable MATLAB-to-C Compiler Exploiting Custom Instructions and Data Parallelism |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A300 | Withdrawal of application because of no request for examination |
Free format text: JAPANESE INTERMEDIATE CODE: A300 Effective date: 19990831 |