JP2002182926A - Compiling method and computer readable recording medium - Google Patents

Compiling method and computer readable recording medium

Info

Publication number
JP2002182926A
JP2002182926A JP2000376956A JP2000376956A JP2002182926A JP 2002182926 A JP2002182926 A JP 2002182926A JP 2000376956 A JP2000376956 A JP 2000376956A JP 2000376956 A JP2000376956 A JP 2000376956A JP 2002182926 A JP2002182926 A JP 2002182926A
Authority
JP
Japan
Prior art keywords
variable
grouping
instruction
variables
code
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
Application number
JP2000376956A
Other languages
Japanese (ja)
Inventor
Yasuhiko Saito
靖彦 斎藤
Masahiro Uminaga
正博 海永
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.)
Hitachi Ltd
Original Assignee
Hitachi 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 Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP2000376956A priority Critical patent/JP2002182926A/en
Publication of JP2002182926A publication Critical patent/JP2002182926A/en
Withdrawn legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To provide a compiling method to realize reduction of an object code and enhancement of execution performance without burdening a programmer. SOLUTION: The object code such as an assembly code is generated so that a compiler (compilation program) makes a group of variables into structure in an internal processing process of compilation (S4), a variable reference point in the source program is replaced with a member reference code of the structure (S5) and a memory address in the case of member reference is realized by the sum of the base address and offset (S6) by giving an instruction to the compiler so that a group of variables with mutually close reference points in the source program and to be frequently referred by the structure is grouped by the structure (S1). Grouping of global variables is possible without accompanying logical change of the existing source program itself, no description of a complicated structure member reference code is required, reduction of code size of a program and enhancement of practicability is realized.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明は、計算機システムを
用いてソースプログラムからオブジェクトコードを生成
するコンパイル方法、そしてコンパイルプログラムを格
納した記録媒体に関し、例えば、大域変数等の変数の参
照を多用するRISCプロセッサのためのプログラムサ
イズの縮小化に適用して有効な高級言語コンパイル技術
に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a compile method for generating an object code from a source program using a computer system, and a recording medium storing the compile program. The present invention relates to a high-level language compiling technique that is effective when applied to a reduction in program size for a processor.

【0002】[0002]

【従来の技術】高級プログラミング言語の一つであるC
言語でのプログラミング手法を要約すれば、まず実現し
たい処理を一連の手続き(procedure)に分割
し、必要に応じて手続き呼び出しを行い、計算結果に応
じて次の処理を行うというのが典型的な処理の流れであ
る。これら手続きは、いくつかの変数を介して計算が行
われるため、手続き型言語と呼ばれることもある。C言
語では手続きを関数とも呼ぶ。変数はプログラミングを
簡易にできるようにいくつかの属性をもつことが可能で
ある。属性のひとつにはスコープ属性があり、これは、
各手続きからその変数がどのように見えるか、つまりど
うのようアクセスできるかを定めるものである。スコー
プ属性としては、例えば、関数が起動される毎に生起・
消滅する自動変数(auto)若しくは動的変数、大域変
数としての外部変数(extern)、プログラムの実行
中に存在しつづける静的変数(static)などがあ
る。
2. Description of the Related Art C, one of high-level programming languages
To summarize the programming technique in a language, it is typical to first divide a process to be realized into a series of procedures, call a procedure as necessary, and perform the next process according to a calculation result. It is a processing flow. These procedures are sometimes called procedural languages because the calculations are performed through several variables. In C language, a procedure is also called a function. Variables can have several attributes to make programming easier. One of the attributes is the scope attribute, which is
It determines how the variable looks from each procedure, that is, how it can be accessed. As the scope attribute, for example, each time a function is invoked,
There are an automatic variable (auto) or a dynamic variable that disappears, an external variable (extern) as a global variable, a static variable (static) that continues to exist during the execution of the program, and the like.

【0003】変数はスコープ属性に応じて、そのメモリ
アドレスを持つため、Cコンパイラはその変数アクセス
コードを属性に応じて生成する必要がある。
Since a variable has its memory address according to a scope attribute, a C compiler must generate a variable access code according to the attribute.

【0004】近年、組み込み機器分野において、さまざ
まなマイクロプロセッサが活用されている。これらマイ
クロプロセッサにおいても、C言語等の高級言語による
プログラミングが主流である。組み込み機器分野でよく
活用されるマイクロプロセッサのアーキテクチャとし
て、RISC(Reduced Instruction Set Computer)型
マイクロプロセッサがある。これは一連の計算をメモリ
からプロセッサ上のレジスタへ値をロードし、プロセッ
サ上のレジスタ間で演算を行い、演算結果を保持するレ
ジスタの値をメモリにストアするため、ロード・ストア
・アーキテクチャとも呼ばれる。
In recent years, various microprocessors have been utilized in the field of embedded devices. Also in these microprocessors, programming in a high-level language such as C language is mainstream. As a microprocessor architecture often used in the field of embedded devices, there is a reduced instruction set computer (RISC) type microprocessor. This is also called a load-store architecture, because a series of calculations loads values from memory into registers on the processor, performs operations between registers on the processor, and stores the values of the registers that hold the operation results in memory. .

【0005】レジスタのビットサイズとしては32ビッ
トがよく選ばれる。さらに、RISC型マイクロプロセ
ッサにおいては命令長は固定であり、32ビット長や1
6ビット長命令のものがある。組み込み分野ではプログ
ラムサイズをできるだけ小さくすることが望まれるた
め、命令長を32ビットではなく、16ビットにしたR
ISC型マイクロプロセッサもよく活用されている。こ
の組み込みマイクロプロセッサの分野でのプログラム開
発において重要なことは、与えられた処理をできるだけ
小さなプログラムのコードサイズで実現するとともに、
コードそのものの性能、すなわち、実行時間を短縮する
ようなコードを開発することである。命令長を16ビッ
トにすることで、一般的にコードサイズを小さくできる
反面、所要の機能を実現するのに複数の命令実行が必要
となり、プログラムサイズが増えたり、命令数の増加に
より性能が向上しなかったりする場合がある。
As a bit size of a register, 32 bits are often selected. Further, in the RISC type microprocessor, the instruction length is fixed, and the instruction length is 32 bits or 1 bit.
There is a 6-bit instruction. In the embedded field, it is desirable to reduce the program size as much as possible.
ISC-type microprocessors are also widely used. What is important in program development in the field of embedded microprocessors is to realize a given process with the smallest possible program code size,
To develop code that reduces the performance of the code itself, that is, the execution time. By setting the instruction length to 16 bits, the code size can be reduced in general, but the execution of multiple instructions is required to realize the required function, and the program size is increased and the performance is improved by increasing the number of instructions. Or not.

【0006】コードサイズを小さくし、さらにプログラ
ムの実行速度を向上させるコンパイル技術として、例え
ば特開平10−124325号公報に記載のものがあ
る。これは、プログラミングツールにより、プログラム
を解析し、アクセス頻度の高い変数を選択して、それら
を低位のアドレス領域に最適配置するものである。要す
るに、アクセス頻度の大きな変数をよりアドレス指定サ
イズが小さなアドレス領域に配置するとういものであ
る。これは、大域変数を16ビットの部分アドレス空間
(アドレス指定サイズが小さなアドレス領域)に存在さ
せるという保証をプログラマが与えていたものを、大域
変数の低位アドレス(アドレス指定のサイズが小さなア
ドレス領域)への割りつけをコンパイラで行うようにし
たものである。
As a compiling technique for reducing the code size and further improving the execution speed of a program, there is, for example, a technique described in Japanese Patent Application Laid-Open No. 10-124325. In this method, a program is analyzed by a programming tool, variables that are frequently accessed are selected, and those are optimally arranged in a lower address area. In short, a variable with a high access frequency is arranged in an address area having a smaller addressing size. This means that the programmer has been assured that a global variable exists in a 16-bit partial address space (an address area with a small addressing size), but the lower-order address of the global variable (an address area with a small addressing size) Is assigned by the compiler.

【0007】[0007]

【発明が解決しようとする課題】本発明者は前記RIS
C型マイクロプロセッサ、特に16ビット固定長命令の
RISC型マイクロプロセッサでの外部変数参照技術に
ついて以下の検討を行った。
SUMMARY OF THE INVENTION The present inventor has proposed the RIS
The following study was made on the external variable reference technology in a C-type microprocessor, particularly a RISC-type microprocessor with a 16-bit fixed-length instruction.

【0008】リンケージエディタに入力される前の個別
オブジェクトにおける外部変数アクセスコードのCコン
パイラによる生成方式として例えば次の2種類が考えら
れる。例として図13のコード1をみると、ここでは大
域変数gvarが定義され、関数func内のRef1
の部分で参照される。この参照Ref1は変数gvar
の値をレジスタregに代入するという操作である。こ
のCソースファイルを一旦アセンブリ言語ソースにコン
パイルするとして、この参照コードRef1の実現方式
として2通りが考えられる。一つは、変数gvarのア
ドレスをそのまま命令の埋め込むことができないとき、
ロード命令の前に変数gvarの32ビットアドレスを
確定させる方式(これをここでは方式Aと呼ぶ)と、ロ
ード命令そのものに32ビットアドレスを埋め込む方式
(これをここでは方式Bと呼ぶ)である。例えば16ビ
ット固定命令長RISCマイクロプロセッサでは32ビ
ットのアドレス情報を命令に埋め込むことは不可能であ
るから前記A方式を採用せざるを得ない。方式Bは可変
長命令を実行するマイクロプロセッサで採用可能な方式
例である。
For example, the following two methods can be considered as a method of generating an external variable access code in an individual object before being input to the linkage editor by the C compiler. 13 as an example, here, a global variable gvar is defined, and Ref1 in the function func is defined.
Referred to in the section. This reference Ref1 is a variable gvar
Is substituted into the register reg. Assuming that the C source file is once compiled into an assembly language source, there are two possible methods for implementing the reference code Ref1. One is when the address of the variable gvar cannot be embedded in the instruction as it is,
There are a method of determining the 32-bit address of the variable gvar before the load instruction (this is referred to as method A), and a method of embedding the 32-bit address in the load instruction itself (this is referred to as method B). For example, in the case of a 16-bit fixed instruction length RISC microprocessor, it is impossible to embed 32-bit address information in an instruction, so the A method must be adopted. Method B is an example of a method that can be employed in a microprocessor that executes a variable-length instruction.

【0009】図13におけるコードa1の命令「mo
v.L Laddr,r0」は、変数gvarのメモリア
ドレスLaddrにある4バイト値をレジスタr0にロ
ードする命令である。この命令において、メモリアドレ
スLaddrにある4バイト値は、大域変数gvarの
メモリアドレスである。この命令は、命令長が16ビッ
トのように短いとき、命令そのものにアクセスしたい3
2ビットのメモリアドレスを埋めこむことができないた
め、16ビット長命令でアクセス可能なメモリ領域(ア
ドレスLaddrの近くに割り当てられる)に、実際に
アクセスしたい32ビットのメモリアドレスを保持す
る。その次の命令「mov.L @r0,R1」では、メ
モリアドレスを格納するレジスタr0の値を読込み、読
込んだ値をメモリアドレスとしてそこから実際に得られ
る大域変数gvarの値をレジスタr1にロードする。
The instruction "mo" of the code a1 in FIG.
“v.L Laddr, r0” is an instruction to load the 4-byte value at the memory address Laddr of the variable gvar into the register r0. In this instruction, the 4-byte value at the memory address Laddr is the memory address of the global variable gvar. This instruction requires access to the instruction itself when the instruction length is as short as 16 bits.
Since a 2-bit memory address cannot be embedded, a 32-bit memory address to be actually accessed is held in a memory area accessible by a 16-bit length instruction (allocated near an address Laddr). In the next instruction “mov.L @ r0, R1”, the value of the register r0 storing the memory address is read, and the read value is used as the memory address, and the value of the global variable gvar actually obtained therefrom is stored in the register r1. To load.

【0010】図13のコードa1では、コード1におけ
る大域変数の参照Ref1が2個のロード命令と1個の
メモリ領域で実現されている。図13のコードa2に、
そのアセンブリコードをアセンブルした場合の機械語イ
メージを図示する。2つのロード命令「mov.L ・
…」はそれぞれ、2バイトであり、大域変数gvarの
メモリアドレスを格納するメモリ領域は4バイトであ
り、参照コードRef1を実現するコードは全部で8バ
イト必要になる。
In code a1 of FIG. 13, reference Ref1 of the global variable in code 1 is realized by two load instructions and one memory area. In code a2 in FIG.
A machine language image when the assembly code is assembled is illustrated. Two load instructions "mov.L
.. "Are each 2 bytes, the memory area for storing the memory address of the global variable gvar is 4 bytes, and the code for implementing the reference code Ref1 requires a total of 8 bytes.

【0011】一方、図13のコードb1は大域変数gv
arの値のロード命令そのものに、大域変数gvarの
メモリアドレス32ビットを埋め込むも方式Bに基づく
アセンブリコード例であり、ロード命令「mov @gv
ar,r0」一つで大域変数gvarの値をレジスタr
0にロードすることができる。図13のコードb2には
このアセンブリコードをアセンブルした場合の機械語イ
メージを図示する。1つのロード命令「mov ・…」は
2バイトの主命令と、大域変数gvarのメモリアドレ
スを格納する4バイトにより構成され、参照コードRe
f1を実現するコードは6バイト必要となる。
On the other hand, the code b1 in FIG.
A 32-bit memory address of the global variable gvar is embedded in the load instruction of the value of ar itself.
ar, r0 ”to register the value of the global variable gvar in the register r
0 can be loaded. The code b2 in FIG. 13 shows a machine language image when this assembly code is assembled. One load instruction “mov...” Is composed of a 2-byte main instruction and 4 bytes for storing the memory address of the global variable gvar.
The code for implementing f1 requires 6 bytes.

【0012】コードb1の方が、コードサイズ的にはコ
ードa1より小さいのでよいといえるが、方式Aのメモ
リ領域「Laddr:・…」部分が再利用される状況で
は、コードa1は実質的に4バイトと見なせるので、コ
ードa1とb1のどちらがよいとは一概に言えない。ま
た、コードa1は一つの大域変数参照にロード命令を2
命令実行する必要があるのに比べ、コードb1はロード
命令を1命令実行すればよい。プログラムの実行性能の
向上の観点からすれば、大域変数参照を一つのロード命
令で実現するのが望ましい。
It can be said that the code b1 is smaller than the code a1 in terms of the code size. However, in a situation where the memory area “Laddr:. Since it can be regarded as 4 bytes, it cannot be unconditionally determined which of the codes a1 and b1 is better. Also, the code a1 has two load instructions for one global variable reference.
In contrast to the need to execute an instruction, the code b1 only needs to execute one load instruction. From the viewpoint of improving the execution performance of the program, it is desirable to implement the global variable reference with one load instruction.

【0013】上記より本発明者による第1の検討結果と
して、16ビット固定長命令に代表されるようにアドレ
ス情報のビット数が命令のアドレス情報指定フィールド
のビット数よりも大きい場合、変数の参照には、変数の
アドレス情報をレジスタにロードするロード命令と、そ
のレジスタが保持する値で示されるアドレスから変数を
読込んでそれをディスティネーションレジスタなどにを
ロードするロード命令が必要になり、更に変数のアドレ
ス情報を保持するメモリエリアも必要になり、コード量
が増え、処理の実行時間も長くなってしまうことが明ら
かにされた。
As a result of the first study by the present inventors, when the number of bits of the address information is larger than the number of bits of the address information designation field of the instruction, as typified by a 16-bit fixed-length instruction, the variable is referred to. Requires a load instruction to load the address information of a variable into a register, a load instruction to read a variable from the address indicated by the value held by the register and load it into a destination register, etc. It is also necessary to have a memory area for holding the address information, and the code amount is increased, and the execution time of the process is prolonged.

【0014】次に、方式Aにおいてコードサイズを低減
するために、大域変数を16ビットの部分アドレス空間
に存在させるという保証をプログラマが与えると、コン
パイラは、大域変数のメモリアドレスを保持するメモリ
領域を32ビットから16ビットに変更できる。図14
のコードa3は、大域変数gvarが16ビットアドレ
スで参照できるという保証を与えた場合のアセンブリコ
ード例であり、コードa4がそれに必要なメモリサイズ
を示す。この場合には、大域変数参照に必要なコードサ
イズが8バイトから6バイトに低減される。同様に、図
14のコードb3には、16ビットアドレス指定の保証
を行った場合における方式Bのアセンブリコード例を示
し、それに必要なメモリサイズをコードb4に示す。大
域変数参照に必要なコードサイズが6バイトから4バイ
トに低減される。
Next, in order to reduce the code size in the method A, if the programmer gives a guarantee that the global variable is present in the 16-bit partial address space, the compiler operates in the memory area holding the memory address of the global variable. Can be changed from 32 bits to 16 bits. FIG.
Is an assembly code example in a case where a guarantee that the global variable gvar can be referred to by a 16-bit address is given, and a code a4 indicates a memory size required for the assembly. In this case, the code size required for global variable reference is reduced from 8 bytes to 6 bytes. Similarly, a code b3 in FIG. 14 shows an example of an assembly code of the method B in a case where the 16-bit address specification is guaranteed, and a memory size required for the assembly code is shown in a code b4. The code size required for global variable references is reduced from 6 bytes to 4 bytes.

【0015】すなわち、図14の場合には方式Aでは、
8バイトから6バイトに低減されるが、サイズの減りよ
うが少なく、実行命令数は低減されない。さらに、方式
Bは可変長命令アーキテクチャであり、16ビット固定
長RISCマイコンには採用できない。この例でわかる
ように、大域変数アクセスが頻発するプログラムの場合
には、16ビット固定長命令のRISC型マイクロプロ
セッサのプログラムサイズは、32ビット以上の長さを
もつRISC型マイクロプロセッサのプログラムサイズ
よりも膨らんでしまう。プログラムのコードサイズ低減
及び実行性能の向上にとって大域変数の取り扱いは究め
て重要である。
That is, in the case of FIG.
Although the size is reduced from 8 bytes to 6 bytes, the size is not likely to be reduced, and the number of executed instructions is not reduced. Further, the method B has a variable-length instruction architecture, and cannot be adopted in a 16-bit fixed-length RISC microcomputer. As can be seen from this example, in the case of a program in which global variable accesses frequently occur, the program size of the RISC microprocessor having 16-bit fixed-length instructions is larger than the program size of the RISC microprocessor having a length of 32 bits or more. Also swells. The handling of global variables is extremely important for reducing the code size of a program and improving execution performance.

【0016】上記より第2の検討結果とし、特開平10
−124325号公報に記載の技術に代表されるよう
に、アクセス頻度の大きな変数をよりアドレス指定のサ
イズが小さなアドレス領域に配置するというコンパイル
技術を採用しても固定長命令のビット数との関係によ
り、コードサイズを小さくして更にプログラムの実行速
度を向上させるには限界の有ることが本発明者によって
明らかにされた。
[0016] Based on the above, the results of the second study are described in
As represented by the technology described in Japanese Patent Application Laid-Open No. 124325/1992, the relationship with the number of bits of fixed-length instructions even when a compile technology in which a variable with a high access frequency is arranged in an address area with a smaller address designation is adopted. As a result, the present inventor has revealed that there is a limit in reducing the code size and further improving the execution speed of the program.

【0017】そこで本発明者は、第3の検討結果とし
て、アドレス指定サイズを小さくするには、16ビット
固定長RISC命令のように命令のビット数と命令のア
ドレス指定フィールドのビット数に制限のある命令アー
キテクチャーにおける変数参照に際して、ベースアドレ
スとオフセットアドレスを利用するようにコンパイルす
ることの優位性を見出した。要するに、プログラム内で
の参照時点が互いに近く頻繁に参照されるような大域変
数を構造体のようにグループ化すれば、コードサイズの
低減および実行命令数の低減による性能向上が実現でき
る機会が増える。
As a result of the third study, the present inventor has found that in order to reduce the addressing size, the number of bits of the instruction and the number of bits of the addressing field of the instruction are limited as in the 16-bit fixed-length RISC instruction. We found the advantage of compiling to use the base address and offset address when referring to variables in an instruction architecture. In short, grouping global variables whose reference points in a program are close to each other and are frequently referred to like a structure increases the chances of realizing performance improvement by reducing the code size and the number of executed instructions. .

【0018】これに対し、本発明者は更に第4の検討結
果として、大域変数を構造体でグループ化するとき、プ
ログラマがソースプログラム中で構造体記述を逐一行お
うとすると、煩雑な構造体メンバ参照コードを記述しな
ければならず、データ型による構造化の概念も適用でき
ない場合が想定され、プログラムの意味に可読性が損な
われる虞もあり、プログラマの負担も甚大であり、その
上、バグの原因にもなり易い、という問題点を生ずる虞
のあることを見出した。
On the other hand, as a fourth study result, the present inventor has found that, when grouping global variables by structure, when a programmer tries to describe the structure one by one in a source program, complicated structure members are required. It is assumed that reference codes must be written, and the concept of structuring by data type cannot be applied.Therefore, the readability of the program may be impaired, the burden on the programmer is enormous, and the It has been found that there is a possibility of causing a problem that it is likely to be a cause.

【0019】本発明の目的は、大域変数参照に必要な命
令数と必要なメモリ領域サイズの低減、プログラムのコ
ードサイズの低減、及び実行時の性能向上を可能とす
る、16ビット固定命令長RISC型マイクロプロセッ
サのようなデータ処理装置のソースプログラムに対する
コンパイル方法、そしてそのコンパイル方法を実現する
コンパイルプログラムをコンピュータ読み取り可能に記
録した記録媒体を提供することにある。
An object of the present invention is to provide a 16-bit fixed instruction length RISC capable of reducing the number of instructions required for global variable reference and the required memory area size, reducing the code size of a program, and improving the performance at the time of execution. It is an object of the present invention to provide a method for compiling a source program of a data processing device such as a type microprocessor, and a computer-readable recording medium for recording a compile program for implementing the method.

【0020】本発明の別の目的は、変数参照に際してベ
ースアドレスとオフセットアドレスを利用可能にすると
き、ソースプログラムに煩雑な構造体メンバ参照コード
を記述せず、ソースプログラムの意味の可読性が損なわ
れず、プログラマに大きな負担もかけず、その上、ソー
スプログラムにバグを誘発する虞も無い、ソースプログ
ラムから固定長命令のオブジェクトコードをコンパイル
する方法、そして、そのコンパイル方法を実現するコン
パイルプログラムをコンピュータ読み取り可能に記録し
た記録媒体を提供することにある。
Another object of the present invention is to make a base address and an offset address available for variable reference without writing a complicated structure member reference code in a source program, and without impairing the readability of the meaning of the source program. A method of compiling object code of fixed-length instructions from a source program without placing a great burden on a programmer and causing a bug in the source program, and a computer-readable reading of a compile program realizing the compile method An object of the present invention is to provide a recording medium on which recording is possible.

【0021】本発明の前記並びにその他の目的と新規な
特徴は本明細書の記述及び添付図面から明らかになるで
あろう。
The above and other objects and novel features of the present invention will become apparent from the description of the present specification and the accompanying drawings.

【0022】[0022]

【課題を解決するための手段】本願において開示される
発明のうち代表的なものの概要を簡単に説明すれば下記
の通りである。
The following is a brief description of an outline of a typical invention among the inventions disclosed in the present application.

【0023】〔1〕本発明に係るコンパイル方法は、ソ
ースプログラム内での参照時点が互いに近く頻繁に参照
される大域変数のような変数群を構造体でグループ化す
るようにコンパイラ(コンパイルプログラム)に指示を
与えることにより(S1)、コンパイラがコンパイルの
内部処理過程において指示された変数群を構造体化し
(S4)、ソースプログラム内の当該変数参照個所を構
造体のメンバ参照コードに置き換え(S5)、メンバ参
照時のメモリアドレスを、ベースアドレスとオフセット
の和で実現する(S6)ように、アセンブリコード等の
オブジェクトコードを生成する。
[1] The compile method according to the present invention provides a compiler (compile program) such that variable groups such as global variables whose reference points in a source program are close to each other and are frequently referred to are grouped by a structure. (S1), the compiler structuring the group of variables designated in the internal processing of the compilation (S4), and replaces the variable reference location in the source program with the member reference code of the structure (S5). ), An object code such as an assembly code is generated so that the memory address at the time of member reference is realized by the sum of the base address and the offset (S6).

【0024】詳述すると、ソースプログラムから固定長
命令のオブジェクトコードを生成するコンパイル方法
は、ソースプログラムにおいて全体として関連付けのな
い変数群に対するグループ化の指示を検出する処理と、
前記グループ化の指示を検出したとき、その指示に基づ
いて前記変数群をグループ化する処理と、グループ化さ
れた変数の参照個所をソースプログラムから検出する処
理と、前記検出された変数参照個所に対し、当該変数が
属するグループに共通のベースアドレスに変数のオフセ
ットアドレスを加えて当該変数参照を行うように、オブ
ジェクトコードを生成する処理と、を含む。
More specifically, a compiling method for generating an object code of a fixed-length instruction from a source program includes a process of detecting a grouping instruction for a group of variables that are not entirely related in the source program;
When detecting the grouping instruction, a process of grouping the variable group based on the instruction, a process of detecting a reference location of the grouped variable from a source program, and On the other hand, a process of generating an object code so as to refer to the variable by adding the offset address of the variable to the base address common to the group to which the variable belongs.

【0025】上記方法により、既存のソースプログラム
そのものの論理的な変更をともなわず、大域変数のグル
ープ化が可能となり、プログラムのコードサイズ低減と
実行性能向上を実現できる。また、煩雑な構造体メンバ
参照コードを記述しなくとも、コンパイラが内部的に構
造体メンバ参照に解釈するので、プログラマの負担が軽
減し、且つソースプログラムそのものの可読性を損なわ
ない。
According to the above-mentioned method, global variables can be grouped without logically changing the existing source program itself, and the code size of the program can be reduced and the execution performance can be improved. Further, even if a complicated structure member reference code is not described, the compiler internally interprets the structure member reference code, so that the burden on the programmer is reduced and the readability of the source program itself is not impaired.

【0026】前記固定長命令が、アドレス情報のビット
数が命令のアドレス指定フィールドのビット数よりも多
いものであるとき、上記効果は特に顕著である。
The above effect is particularly remarkable when the fixed-length instruction has a greater number of bits in the address information than the number of bits in the addressing field of the instruction.

【0027】〔2〕コンパイルプログラムをコンピュー
タ読み取り可能に記録したコンピュータ読取り可能な記
録媒体は、ソースプログラムから固定長命令のオブジェ
クトコードを生成するために、ソースプログラムにおい
て全体として関連付けのない変数群に対するグループ化
の指示を検出する処理と、前記グループ化の指示を検出
したとき、その指示に基づいて前記変数群をグループ化
する処理と、前記グループ化された同一グループに属す
る変数の参照には、当該グループに共通のベースアドレ
スに変数のオフセットアドレスを加えたアドレスを用い
るようにして、変数参照に応ずるオブジェクトコードを
生成する処理とを実行させる、コンパイルプログラムを
コンピュータ読み取り可能に記録してある。
[2] A computer-readable recording medium on which a compiled program is recorded in a computer-readable manner is a group for a variable group which is not entirely related in a source program in order to generate an object code of a fixed-length instruction from the source program. Processing for detecting an instruction for grouping, processing for grouping the variable group based on the instruction when the instruction for grouping is detected, and reference to a variable belonging to the same group that has been grouped, A compilation program is recorded in a computer-readable manner to execute a process of generating an object code corresponding to a variable reference by using an address obtained by adding a variable offset address to a base address common to the group.

【0028】上記記憶媒体を介して前記コンパイルプロ
グラムを提供することにより、そのコンパイルプログラ
ムによる処理を即座に実行でき、既存のソースプログラ
ムそのものの論理的な変更をともなわず、大域変数のグ
ループ化が可能となり、プログラムのコードサイズ低減
と実行性能向上を実現できる。また、煩雑な構造体メン
バ参照コードを記述しなくとも、コンパイラが内部的に
構造体メンバ参照に解釈するので、プログラマの負担が
軽減し、且つソースプログラムそのものの可読性を損な
わない、という効果を容易に得ることができるようにな
る。
By providing the compile program via the storage medium, processing by the compile program can be executed immediately, and global variables can be grouped without logically changing the existing source program itself. Thus, the code size of the program can be reduced and the execution performance can be improved. In addition, since the compiler internally interprets the structure member reference without writing complicated structure member reference codes, the burden on the programmer is reduced and the readability of the source program itself is not impaired. You can get to.

【0029】〔3〕前記ソースプログラムにおいて全体
として関連付けのない変数は、全部又は一部が構造体と
して規定されていない変数群である。したがって、離散
的な複数の構造体記述の変数群を統一的なグループに再
編成したり、構造体記述の変数群と非構造体の変数群と
を統一的なグループに再編成したりする場合も本発明思
想の範疇とされる。
[3] Variables that are not associated as a whole in the source program are variable groups that are not entirely or partially defined as structures. Therefore, when reorganizing a variable group of discrete structure descriptions into a unified group, or reorganizing a variable group of a structure description and a non-structure variable group into a unified group Are also included in the scope of the present invention.

【0030】〔4〕前記グループ化の指示は、第1の態
様では、ソースプログラムに含まれるグループ化指示文
により与えるものである。具体的には、各ソースファイ
ル中に構造体化したい変数群のリストをプラグマ文(図
5のコードC3内の指示文P1)で指示する方法であ
る。プログラマは、ソースプログラムに前記グループ化
指示文を記述することになっても、複雑な構造体メンバ
参照コードを記述することを要しない。
[4] In the first embodiment, the grouping instruction is given by a grouping instruction sentence included in the source program. Specifically, a method of designating a list of variables to be structured in each source file by a pragma statement (a directive statement P1 in the code C3 in FIG. 5). The programmer does not need to write a complicated structure member reference code even if the grouping directive is described in the source program.

【0031】前記グループ化の指示の第2の態様は、所
定のコンパイルオプションにより与えられ、前記コンパ
イルオプションは、ソースプログラム以外の別ファイル
として与えられるグループ化指示ファイルの読み込み
と、読み込んだグループ化指示ファイルで指定される変
数に対するグループ化とを指示するものとする。具体的
には、一つの構造体化指示ファイル内に構造体化したい
変数群のリストを記述し(図5のコードC4内の指示文
P1)、各ソースファイルの個別コンパイル時に構造体
化指示ファイルを読みこむようにコンパイルオプション
で指定する。プログラマはソースプログラムとは別に構
造体指示ファイルを作成することになっても、複雑な構
造体メンバ参照コードをソースプログラムに記述する必
要はない。
A second aspect of the grouping instruction is given by a predetermined compile option, and the compile option is read by a grouping instruction file provided as a separate file other than the source program, and read by the read grouping instruction. Assume that grouping is performed on variables specified in the file. Specifically, a list of variables to be structured is described in one structuring instruction file (the directive P1 in the code C4 in FIG. 5), and the structuring instruction file is compiled when each source file is individually compiled. Specify in the compile option to read. Even if the programmer creates a structure instruction file separately from the source program, there is no need to write complicated structure member reference codes in the source program.

【0032】前記グループ化指示の第3の態様は、所定
のコンパイルオプションにより与えられ、前記コンパイ
ルオプションは、ソースプログラム以外の別ファイルと
して与えられるグループ化指示ファイルの読み込みと、
読み込んだグループ化指示ファイルで指定されるソース
プログラムの変数の走査と、走査された変数に対するグ
ループ化とを指示するものとする。具体的には、プログ
ラマが変数を指定していちいちグループ化指示を行わな
くても済む方法であり、コンパイラが自動的に近接する
外部変数を認識し構造体化する。
A third mode of the grouping instruction is given by a predetermined compile option, and the compile option is obtained by reading a grouping instruction file given as a separate file other than the source program;
It is assumed that the scanning of the variables of the source program specified by the read grouping instruction file and the grouping of the scanned variables are instructed. More specifically, the method does not require the programmer to specify a variable and issue a grouping instruction each time, and the compiler automatically recognizes a nearby external variable and forms a structure.

【0033】〔5〕16ビット等の固定長命令では、オ
ペランドの指定ビットフィールドサイズの制約が大きい
場合もあるので、ターゲットとするマイクロプロセッサ
のスケーリング即値つきロード命令の即値フィールドサ
イズに合わせて、グループを複数に分割して、一つのベ
ースアドレスから参照できるメモリ領域にたくさんの大
域変数をパッキングできるようにする機能をコンパイラ
に持たせるとよい。
[5] In a fixed-length instruction such as 16 bits, there is a case where the restriction on the designated bit field size of the operand is large. Therefore, the group is adjusted according to the immediate field size of the load instruction with scaling immediate value of the target microprocessor. May be divided into a plurality of parts, and the compiler may have a function of packing many global variables in a memory area that can be referred to from one base address.

【0034】例えば、前記グループ化する処理は、処理
対象とされる変数をデータサイズの順番に並べ替えた変
数リストを作成する処理と、前記ベースアドレスに加算
するオフセットアドレスとしてオブジェクトコードの即
値を用いるとき、オブジェクトコードの即値が採る得る
ビット数と前記オフセットアドレスのビット数との関係
に基づき必要な場合には変数リストの変数を別のグルー
プに分割する処理と、を含ませるようにする。
For example, the grouping process includes a process of creating a variable list in which variables to be processed are arranged in the order of data size, and using an immediate value of an object code as an offset address to be added to the base address. At this time, if necessary, a process of dividing the variables of the variable list into another group based on the relationship between the number of bits that can be taken by the immediate value of the object code and the number of bits of the offset address is included.

【0035】前記変数リストの変数を別のグループに分
割する処理は、前記変数リスト中の変数をグループのベ
ースアドレスを基点にデータサイズの小さいものから順
番に配置するとしたとき、ベースアドレスに対するオフ
セットが前記オブジェクトコードの即値に基づいて指定
可能な範囲を超えることを条件に、当該変数を別のグル
ープに分割する。
In the process of dividing the variables in the variable list into different groups, when the variables in the variable list are arranged in ascending order of data size based on the base address of the group, the offset with respect to the base address is The variable is divided into another group on the condition that it exceeds a specifiable range based on the immediate value of the object code.

【0036】前記オブジェクトコードは、参照するデー
タサイズに応じて即値を整数倍してベースアドレスに加
算する、即値のスケーリング機能を有する。
The object code has an immediate value scaling function of multiplying the immediate value by an integer according to the data size to be referred to and adding it to the base address.

【0037】〔6〕前記グループ化された変数群をソー
スプログラム言語による構造体のメンバとして解釈し、
当該変数へのアクセスをソースプログラム言語における
構造体メンバへの参照コードに変換してソースファイル
に出力する処理を更に行ってもよい。
[6] The grouped variables are interpreted as members of a structure in a source program language,
A process of converting the access to the variable into a reference code to a structure member in the source program language and outputting the code to a source file may be further performed.

【0038】[0038]

【発明の実施の形態】《コンパイル方法の概要》図2に
はオブジェクトコードの一般的な生成手順が例示され
る。先ず、C言語で記述されたソースププログラムのフ
ァイル20をCコンパイラ(C言語で記述されたソース
プログラム用のコンパイラ)21によりコンパイルす
る。この段階で、各ソースファイルはそれぞれオブジェ
クトモージュール(アセンブルコード等のオブジェクト
コードの集合)22にコンパイルされる。このままで
は、各オブジェクトファイル間での関数呼び出しや変数
参照に必要なアドレスが未解決のままである。次にリン
ケージエディタ24が各ファイル間の外部名(外部変数
名、外部関数名)の参照を解決して一つの仮想アドレス
空間を生成し、ロードモジュール25を生成する。一連
の個別オブジェクトファイルで定義された名前は仮想ア
ドレス空間で一意的なアドレスを与えられ、それら名前
を参照するコード部分は、適切な値が埋め込まれ、実行
時のメモリアクセスに必要な論理的なアドレス計算命令
列が整う。リンケージエディタ24によるリンクではラ
イブラリ23として用意されているオブジェクトファイ
ルも併せて利用することが可能である。
DESCRIPTION OF THE PREFERRED EMBODIMENTS Outline of Compiling Method FIG. 2 illustrates a general procedure for generating an object code. First, a file 20 of a source program written in C language is compiled by a C compiler (compiler for a source program written in C language) 21. At this stage, each source file is compiled into an object module (a set of object codes such as assembly code) 22. In this state, addresses required for function calls and variable references between object files remain unresolved. Next, the linkage editor 24 resolves references to external names (external variable names, external function names) between the files to generate one virtual address space, and generates the load module 25. The names defined in the set of individual object files are given unique addresses in the virtual address space, and the code parts that refer to those names are embedded with the appropriate values and the logical values required for memory access at runtime. The address calculation instruction sequence is ready. When linking with the linkage editor 24, an object file prepared as the library 23 can be used together.

【0039】図3には前記ロードモジュールを実行する
マイクロプロセッサの要部が例示される。前記ロードモ
ジュール25はマイクロプロセッサの動作プログラムと
して図示を省略するメモリに保持される。前記プログラ
ムを構成する命令は16ビット固定長命令である。分岐
/デコードユニットU1は、前記図示を省略するメモリ
から命令バスB1を介して命令を読み込みデコードを行
う。演算ユニットU2はレジスタファイルU3からレジ
スタを読み出し分岐/デコードユニットU1で指示され
た処理を行う。レジスタファイルU1は32ビット幅の
汎用レジスタを16本もつとする。汎用レジスタ以外に
も浮動小数点レジスタをもつことも可能である。演算結
果はデータバスB2を経由して、図には記述していない
がキャッシュメモリなどへも格納される。
FIG. 3 illustrates a main part of a microprocessor for executing the load module. The load module 25 is stored in a memory (not shown) as an operation program of the microprocessor. The instructions constituting the program are 16-bit fixed-length instructions. Branch
The / decode unit U1 reads and decodes an instruction from the memory (not shown) via the instruction bus B1. The operation unit U2 reads the register from the register file U3 and performs the processing specified by the branch / decode unit U1. It is assumed that the register file U1 has 16 general-purpose registers having a 32-bit width. It is possible to have a floating-point register in addition to the general-purpose register. Although not shown in the figure, the operation result is also stored in a cache memory or the like via the data bus B2.

【0040】《大域変数グループ化処理の第1態様》前
記Cコンパイラ21は、ソースプログラム20からオブ
ジェクトモジュール22を生成するとき、ソースプログ
ラムにおいて全体として関連付けのない変数群に対する
グループ化の指示を検出したとき、その指示に基づいて
前記変数群をグループ化し、グループ化された同一グル
ープに属する変数の参照には、当該グループに共通のベ
ースアドレスに変数のオフセットアドレスを加えたアド
レスを用いるようにして、変数参照に応ずるオブジェク
トコードを生成する。要するに、ソースプログラムの変
数群に対するグループ化の指示に基づいて大域変数を構
造体化する処理を行う。
<< First Mode of Global Variable Grouping Processing >> When generating the object module 22 from the source program 20, the C compiler 21 detects a grouping instruction for a variable group that is not entirely related in the source program. At this time, the variable group is grouped based on the instruction, and the variables belonging to the same group are referred to using an address obtained by adding a variable offset address to a base address common to the group, Generate object code corresponding to variable reference. In short, a process is performed in which global variables are structured based on an instruction to group variables in the source program.

【0041】前記大域変数の構造体化処理を説明する前
に、構造体化処理を考慮する前のソースコードについて
図4を参照しながら説明する。図4のソースコードは各
種データ型に関して大域変数c0,c1,…,j5,j
6が定義されている。このソースコードの関数func
()内のコード片Ref2で例示される操作は大域変数
間のコピー、すなわち、変数d0の値を変数c0に代入
する操作を意味する。このように図4のコード片Ref
2は大域変数間のコピーを行うものであるが、これをア
センブリコードにコンパイルすると、コードASM1の
中のコード片Ref3のようになり、大域変数コピーに
メモリアクセス命令が4命令必要となる。一般にロード
命令はメモリからレジスタにデータをロードするため、
レジスタ同士の演算よりも時間がかかる傾向にあり、実
行時性能向上の観点からすれば、できるだけロード命令
を使用しないのが望ましい。しかしながら、コード片R
ef3では、2つの大域変数のメモリアドレスの参照に
それぞれロード命令を使用している。このように、図4
のコードC1で示されるように、大域変数アクセスが頻
発するプログラムでは、個々の大域変数アクセスに必要
な命令数と必要なメモリ領域サイズが大きくなり、プロ
グラム全体のコードサイズが大きくなり、更に実行時の
性能も低下することが懸念される。
Before describing the global variable structuring process, a source code before considering the structuring process will be described with reference to FIG. 4 are global variables c0, c1,..., J5, j for various data types.
6 are defined. Function func of this source code
The operation exemplified by the code fragment Ref2 in parentheses means an operation of copying between global variables, that is, an operation of substituting the value of the variable d0 for the variable c0. Thus, the code fragment Ref of FIG.
Numeral 2 is for copying between global variables. When this is compiled into assembly code, it becomes a code fragment Ref3 in the code ASM1, and the global variable copy requires four memory access instructions. In general, load instructions load data from memory into registers,
It tends to take longer than the operation between registers, and it is desirable not to use a load instruction as much as possible from the viewpoint of improving the runtime performance. However, the code fragment R
In ef3, a load instruction is used to refer to the memory addresses of two global variables. Thus, FIG.
In a program in which global variable access frequently occurs, the number of instructions required for each global variable access and the required memory area size increase, the code size of the entire program increases, and the There is a concern that the performance of the device will also decrease.

【0042】これに対して前記大域変数の構造体化処理
を考慮する場合には、プログラマは図4に例示されるよ
うなコードC1内では複数の大域変数へのアクセスが同
一関数内で発生する傾向にあるという認識の元で、これ
らをグループ化してコードサイズの低減と実行時性能の
向上を図るため、図5のコードC3に例示されるよう
に、コードC1の内容にグループ化指示文P1を追加す
る。このグループ化指示文P1は、図6のコードC2を
コンパイラに入力とした場合と同様のコード生成処理を
Cコンパイラ21に処理させることを指示するものであ
る。
On the other hand, when considering the global variable structuring process, the programmer accesses a plurality of global variables in the same function in the code C1 as exemplified in FIG. Based on the recognition that there is a tendency, these are grouped to reduce the code size and improve the runtime performance, and as shown in the code C3 in FIG. 5, the grouping directive P1 is added to the contents of the code C1. Add. The grouping directive P1 instructs the C compiler 21 to perform the same code generation processing as when the code C2 in FIG. 6 is input to the compiler.

【0043】図1には前記グループ化指示文P1等によ
ってグループ化指示を受けたコンパイラ21によるコン
パイル処理が例示される。コンパイラ21は図1に示す
アルゴリズムに従って、図5のコードC3に対してグル
ープ化指示文P1で指示される内部処理を行い、図6の
コードC2が入力ソースファイルの場合とほぼ同様のコ
ード生成を行い、オブジェクトモジュール22を生成す
る。グループ化指示文P1を含んだ各ソースファイルお
よびグループ化指示文P1を含まない通常のソースファ
イルはそれぞれ、オブジェクトモジュール22にコンパ
イルされ、リンケージエディタ24がライブラリ23内
の必要な関数とオブジェクトモジュール22をリンクし
てロードモジュール25を生成する。
FIG. 1 illustrates a compile process by the compiler 21 which has received a grouping instruction by the grouping instruction sentence P1 or the like. The compiler 21 performs internal processing indicated by the grouping directive P1 on the code C3 in FIG. 5 according to the algorithm shown in FIG. 1, and generates substantially the same code as in the case where the code C2 in FIG. 6 is an input source file. Then, the object module 22 is generated. Each source file including the grouping directive P1 and a normal source file not including the grouping directive P1 are compiled into an object module 22, and the linkage editor 24 determines the necessary functions in the library 23 and the object module 22. The link module is generated by linking.

【0044】コンパイラ21によるコンパイル方法が従
来のコンパイル手法と違う点は、言語仕様としての構造
体記述を必要とせずに、グループ化指示文P1に対応す
る内部処理を図1に示すアルゴリズムに従って行うこと
であり、これについて詳述する。
The difference between the compiling method using the compiler 21 and the conventional compiling method is that the internal processing corresponding to the grouping directive P1 is performed according to the algorithm shown in FIG. 1 without requiring a structure description as a language specification. This will be described in detail.

【0045】図1に示す処理は各ソースファイルについ
て行われることになる。ステップS1において、入力し
たソースファイル内部を走査し、ソースファイル中にグ
ループ化指示文P1があるかを確認する。このとき、グ
ループ化指示文P1はインクルードファイル中に記述さ
れてもよく、ここでは、コンパイラの通常の前処理後に
ステップS1が行われるとする。ステップS1でもしグ
ループ化指示文P1が検出されなければステップS7に
進み、当該ソースファイルは通常のコンパイル処理を受
ける。
The processing shown in FIG. 1 is performed for each source file. In step S1, the inside of the input source file is scanned to check whether the source file contains a grouping instruction P1. At this time, the grouping directive P1 may be described in the include file. Here, it is assumed that step S1 is performed after the normal preprocessing of the compiler. If the grouping instruction sentence P1 is not detected in step S1, the process proceeds to step S7, and the source file undergoes a normal compiling process.

【0046】もし、グループ化指示文P1が検出された
場合、ステップS2に進み、当該指示文P1内で記述さ
れている大域変数名のリストを作成する。このとき、各
大域変数名はそのデータサイズを属性としてもつ。各大
域変数名のデータサイズは、当該Cソースファイルの大
域変数参照宣言または定義文から得られる。例えば、図
5のコードC3のグループ化指示文group1での変
数名c0のデータサイズは当該Cソースファイル内の大
域変数宣言「 char c0,c1,・…;」よりデータ
型が「char」型であることより、1バイトのデータ
サイズであることが得られる。この例では、グループ化
指示文P1内の大域変数名に対応する宣言が、グループ
化指示文P1が記述されているソースファイルまたは、
インクルードファイル中に存在していることが必要であ
る。
If the grouping directive P1 is detected, the flow advances to step S2 to create a list of global variable names described in the directive P1. At this time, each global variable name has its data size as an attribute. The data size of each global variable name is obtained from the global variable reference declaration or definition statement of the C source file. For example, the data size of the variable name c0 in the grouping directive sentence group1 of the code C3 in FIG. 5 is “char” type from the global variable declaration “char c0, c1,...” In the C source file. As a result, a data size of 1 byte can be obtained. In this example, the declaration corresponding to the global variable name in the grouping directive P1 is a source file in which the grouping directive P1 is described, or
Must exist in the include file.

【0047】ステップS3では、ステップS2で得たグ
ループ化指示文P1内の各変数名リストを、当該変数の
サイズで並べ替え、小さいデータサイズをもつ変数名が
最初の方にくるようにする。例えば、図5の指示文gr
oup1の場合、名前がcで始まる変数はサイズが1バ
イトであり、名前がsで始まる変数はサイズが2バイト
であり、名前がiで始まる変数はサイズが4バイトであ
るので、変数名列「s0,s1,s2,s3,s4,s
5,s6,c0,c1,c2,c3,c4,c5,c
6,i0,i1,i2,i3,i4,i5,i6」はサ
イズで並べ替えると「c0,c1,c2,c3,c4,
c5,c6,s0,s1,s2,s3,s4,s5,s
6,i0,i1,i2,i3,i4,i5,i6」とな
る。
In step S3, each variable name list in the grouping directive P1 obtained in step S2 is rearranged by the size of the variable so that the variable name having the smaller data size comes first. For example, the directive gr in FIG.
In the case of up1, a variable whose name starts with c is 1 byte in size, a variable whose name starts with s is 2 bytes, and a variable whose name starts with i is 4 bytes. "S0, s1, s2, s3, s4, s
5, s6, c0, c1, c2, c3, c4, c5, c
6, i0, i1, i2, i3, i4, i5, i6 "are rearranged by size into" c0, c1, c2, c3, c4,
c5, c6, s0, s1, s2, s3, s4, s5, s
6, i0, i1, i2, i3, i4, i5, i6 ".

【0048】ステップS4はステップS3で得られた各
リストからターゲットとするマイクロプロセッサがもつ
スケーリング即値つきロード命令の即値フィールドサイ
ズに合わせて、必要に応じてさらに各リストを分割し、
分割後の各リストを構造体として解釈する。これは、一
つのベースアドレスから参照できるメモリ領域に多くの
大域変数をパッキングすることで、コードサイズ低減お
よび実行時性能を向上させるものである。
In step S4, each list is further divided as necessary in accordance with the immediate field size of the load instruction with scaling immediate which the target microprocessor has from each list obtained in step S3.
Interpret each split list as a structure. This is to reduce code size and improve runtime performance by packing many global variables in a memory area that can be referenced from one base address.

【0049】前記スケーリング即値付きロード命令は例
えば図7のに示される命令フォーマットとソースアドレ
ス演算方法を有する。(1)はソースアドレスを「レジ
スタ+オフセット」で計算する例である。ここで命令長
は16ビットであり、フィールドF1がオプコード(オ
ペレーションコード)を示し、フィールドF2がターゲ
ットレジスタRnを表す。フィールドF3はベースレジ
スタRmを示す。フィールドF4はベースレジスタから
のオフセットを示す即値フィールドであり、4ビット幅
である。このフォーマットではF4がスケーリング即値
のフィールドであり、サイズは4ビットであるから、メ
モリアクセスのデータサイズによらず、同一サイズの変
数を最大16個指定可能となる。データサイズが混合す
る場合は、(b)に例示されるように、1バイトのデー
タをベースアドレスから開始して16個配置し、その後
ろに、2バイトのデータを8個配置し、更にその後ろに
4バイトのデータを8個配置することで、最大32個所
のメモリアドレスを、「一つのベースレジスタ+スケー
リング4ビット即値」で表現することできる。これによ
るマッピングの様子は図8のメモリ領域M3に示される
ようになる。
The load instruction with a scaling immediate has, for example, an instruction format and a source address calculation method shown in FIG. (1) is an example in which the source address is calculated by “register + offset”. Here, the instruction length is 16 bits, a field F1 indicates an opcode (operation code), and a field F2 indicates a target register Rn. Field F3 indicates base register Rm. Field F4 is an immediate field indicating an offset from the base register, and has a width of 4 bits. In this format, F4 is a field of a scaling immediate value and its size is 4 bits, so that up to 16 variables of the same size can be specified regardless of the data size of memory access. When the data sizes are mixed, as shown in (b), 16 1-byte data are arranged starting from the base address, followed by 8 2-byte data, and By arranging eight 4-byte data at the end, memory addresses at a maximum of 32 locations can be expressed by "one base register + scaling 4-bit immediate value". The state of the mapping by this is as shown in the memory area M3 of FIG.

【0050】例えば、ロード命令「MOV.B @(1,
R5),R0」はベースレジスタR5の値に即値1をス
ケーリングして加えたものをソースメモリアドレスとし
て、レジスタR0に当該データ1バイトをロードするも
のである。スケーリング即値付きロード命令では、ソー
スメモリアドレスは「(データサイズ)×即値+ベース
レジスタ」で計算されるので、この場合、ソースメモリ
アドレスは「(1バイト)×1+R5」で計算される。
「MOV.W @(1,R5),R0」はデータ2バイトを
ロードするスケーリング即値つきロード命令で、この場
合、ソースメモリアドレスは「(2バイト)×1+R
5」で計算される。同様に「MOV.L @(1,R5),
R0」はデータ4バイトをロードするスケーリング即値
つきロード命令で、この場合、ソースメモリアドレスは
「(4バイト)×1+R5」で計算される。このように
即値スケーリングを行うことで、少ない即値フィールド
サイズでも、4バイト、2バイト、1バイトそれぞれで
のアクセスサイズで、ベースレジスタからのオフセット
を同一個数指定可能である。
For example, the load instruction “MOV.B @ (1,
R5), R0 "loads one byte of the data into the register R0 using the value obtained by scaling the value of the base register R5 and the immediate value 1 as the source memory address. In the load instruction with scaling immediate value, the source memory address is calculated by “(data size) × immediate value + base register”. In this case, the source memory address is calculated by “(1 byte) × 1 + R5”.
“MOV.W @ (1, R5), R0” is a load instruction with a scaling immediate value for loading 2 bytes of data. In this case, the source memory address is “(2 bytes) × 1 + R
5 ". Similarly, "MOV.L @ (1, R5),
“R0” is a load instruction with a scaling immediate value for loading 4 bytes of data. In this case, the source memory address is calculated by “(4 bytes) × 1 + R5”. By performing the immediate scaling in this way, even with a small immediate field size, the same number of offsets from the base register can be specified with an access size of 4 bytes, 2 bytes, and 1 byte.

【0051】尚、図7の(2)はロード命令「mov.
L Laddr,r0」に代表されるようなフォーマッ
トであり、命令長は16ビット、フィールドF5がオプ
コードを示し、フィールドF6がターゲットレジスタR
nを表す。フィールドF7はベースレジスタからのオフ
セットを示す即値フィールドであり、8ビット幅であ
る。この命令のアドレシングモードはいわゆるPC相対
とされ、ソースアドレスは、プログラムカウンタの値
(PC)と適切なオフセット(disp)の和で表され
る。
FIG. 7B shows a load instruction “mov.
L Laddr, r0 ", the instruction length is 16 bits, the field F5 indicates the opcode, and the field F6 is the target register R.
represents n. Field F7 is an immediate field indicating an offset from the base register, and has an 8-bit width. The addressing mode of this instruction is so-called PC relative, and the source address is represented by the sum of the value (PC) of the program counter and an appropriate offset (disp).

【0052】ここで、前記ステップS4による変数リス
トの構造体化処理の具体例を説明する。ステップS3で
得た変数リストを分割し、それぞれのリストを構造体と
して解釈する具体例について説明する。
Here, a specific example of the variable list structuring process in step S4 will be described. A specific example of dividing the variable list obtained in step S3 and interpreting each list as a structure will be described.

【0053】第1の例として図5のgroup1,gr
oup2を考える。ステップS3でサイズ順に並べ替え
られた変数リストの要素を始めからサーチして、1バイ
トサイズの変数を16個まで選び構造体g1のメンバと
して登録する。もし、16個を超える場合は、別の構造
体g2を生成して、超える分を構造体g2の最初のメン
バとして登録する。超えない場合は、すべて構造体g1
のメンバとして登録する。この構造体g1のメモリイメ
ージを図9のメモリ領域M1,M2に示す。グループ化
指示文(プラグマ指示文)group1をステップS
2,S3、S4で処理すると、必要な構造体は一つとな
り、そのCソースイメージは、図6のStruct1と
なり、そのメモリイメージは図9のメモリ領域M1のよ
うになる。同様に、プラグマ指示文group2をステ
ップS2,S3、S4で処理すると、必要な構造体は一
つとなり、そのCソースイメージは、図6のStruc
t2となり、そのメモリイメージは図9のメモリ領域M
2のようになる。
As a first example, group1, gr in FIG.
Consider up2. The elements of the variable list rearranged in the size order in step S3 are searched from the beginning, and up to 16 one-byte size variables are selected and registered as members of the structure g1. If it exceeds 16, another structure g2 is generated and the excess is registered as the first member of the structure g2. Otherwise, all structures g1
Register as a member of The memory image of the structure g1 is shown in the memory areas M1 and M2 in FIG. Grouping directive (pragma directive) group1 is converted to step S
When the processing is performed in steps S2, S3, and S4, the required structure becomes one, the C source image becomes Struct1 in FIG. 6, and the memory image becomes a memory area M1 in FIG. Similarly, when the pragma directive sentence group2 is processed in steps S2, S3, and S4, the required structure becomes one, and its C source image is Struc in FIG.
t2, and the memory image is the memory area M in FIG.
It looks like 2.

【0054】第2の例として図5のgroup3を考え
る。この場合には、1バイトデータc0,…,c7、d
0,…,d7はメモリアドレス_g3から_g3+15ま
での範囲に配置される。その後ろの領域には2バイトサ
イズの変数を構造体_g3のベースアドレスから32
(=16×2)バイトを超えない範囲に配置していく。
今の場合すでに、_g3+15まで使用しているので、_
g3+16から_g3+31までの範囲に配置することに
なる。s0,…,s6,およびt0まで配置し、次のt
1を配置しようとするとオフセットが32バイトになる
ので、新たに構造体g4を生成し、残りの2バイトデー
タ変数t1,…,d6は構造体g4のメンバとして登録
する。次に4バイトデータサイズの変数をメモリアドレ
ス_g3+64(=16×4)バイトを超えない範囲で、
構造体g3に登録する。i0,…,i6,j0を構造体
g1に登録したところで、メモリアドレス_g1+63バ
イトまで活用するので、残った変数j1,…,j6はす
でに生成されている別の構造体g4のメンバとして登録
する。以上のようにグループ化指示文group3の変
数群をステップS4で構造体にグループ化した場合、2
つの構造体g3,g4が生成され、それぞれのメモリイ
メージは図8のメモリ領域M3およびメモリ領域M4で
表現される。グループ化指示文group3の対象とな
る大域変数群はCコンパイラの内部で、図8の(C)に
示される二つの構造体Sturct3、Struct4
と同意義として解釈される。
As a second example, consider group3 in FIG. In this case, 1-byte data c0,..., C7, d
0,..., D7 are arranged in a range from memory addresses _g3 to _g3 + 15. In the area after that, a 2-byte variable is stored from the base address of structure_g3 to 32.
(= 16 × 2) bytes.
In this case, we have already used up to _g3 + 15,
It will be arranged in the range from g3 + 16 to _g3 + 31. s0, ..., s6, and t0, and the next t
Since the offset becomes 32 bytes when 1 is to be arranged, a structure g4 is newly generated, and the remaining two-byte data variables t1,..., D6 are registered as members of the structure g4. Next, a 4-byte data size variable is set within a range not exceeding memory address_g3 + 64 (= 16 × 4) bytes.
Register in the structure g3. When i0,..., i6, j0 are registered in the structure g1, since up to the memory address_g1 + 63 bytes are utilized, the remaining variables j1,..., j6 are used as members of another structure g4 that has already been generated. register. When the group of variables of the grouping directive sentence group3 is grouped into a structure in step S4 as described above, 2
One structure g3, g4 is generated, and each memory image is represented by the memory area M3 and the memory area M4 in FIG. The global variable group to be the target of the grouping directive sentence group3 is, within the C compiler, two structures Struct3 and Struct4 shown in FIG.
Is interpreted as the same meaning.

【0055】もし、変数リスト内の変数をすべて単純に
サイズの小さい順に構造体メンバに割り当てて一つの構
造体で実現すると、4ビットオフセットの範囲外に割り
当てられる変数がある場合、その変数のアドレス生成に
は余計な命令が必要となり、コードサイズ低減の目的に
反する。一方、上記ステップS4のように一つのベース
アドレスから4ビットスケーリング即値でアクセス可能
な変数を増やすように構造体のメンバ登録を行うことに
より、コードサイズおよび実行命令数が低減される。
If all the variables in the variable list are simply assigned to structure members in ascending order of size and realized by one structure, if there is a variable assigned outside the range of the 4-bit offset, the address of the variable The generation requires extra instructions, which is against the purpose of reducing the code size. On the other hand, the code size and the number of executed instructions are reduced by registering the members of the structure so as to increase the number of variables that can be accessed with a 4-bit scaling immediate value from one base address as in step S4.

【0056】尚、コンパイラオプションにより、グルー
プ化指示文を含むCソースコード内の大域変数参照を構
造体参照に変換したCソースコードを出力すれば、コー
ドの保守やデバッグ処理、他のコンパイラでのコンパイ
ルなども可能である。
If a C source code in which a global variable reference in a C source code including a grouping directive is converted into a structure reference is output by a compiler option, code maintenance, debugging processing, and the use of another compiler can be performed. Compilation is also possible.

【0057】次にステップS5では、Cソースファイル
内をファイル先頭から走査し、グループ化指示文で構造
体化された大域変数への参照個所を検出する。入力Cソ
ースファイルが図5のコードC3であるとき、グループ
化指示文group1,gourp2でグループ化され
た大域変数への参照個所として、例えば図5の参照Re
f2aに含まれる、大域変数、c0,d0への参照を検
出できる。これら参照を「構造体ベースアドレス+オフ
セット」で実現するために、c0,d0への参照をそれ
ぞれ図6のRef4に示すように大域構造体メンバへの
参照g1.c0,g2.d0と解釈する。実際はCコンパ
イラの内部処理において当該変数への参照を構造体メン
バ参照となるように中間語などのレベルで変換すればよ
い。入力ソースファイル中の大域変数参照に対してステ
ップ5を終了した後は、通常のCコンパイル処理を行
う。
Next, in step S5, the C source file is scanned from the beginning of the file, and a reference point to a global variable structured by a grouping directive is detected. When the input C source file is the code C3 in FIG. 5, as a reference location to the global variable grouped by the grouping directives group1 and group2, for example, the reference Re in FIG.
References to global variables c0 and d0 included in f2a can be detected. In order to realize these references by “structure base address + offset”, references to c0 and d0 are interpreted as references g1.c0 and g2.d0 to global structure members, respectively, as shown by Ref4 in FIG. . Actually, in the internal processing of the C compiler, the reference to the variable may be converted at the level of an intermediate language or the like so as to become a structure member reference. After ending Step 5 for the global variable reference in the input source file, normal C compilation processing is performed.

【0058】ステップS6では、従来のコード生成処理
の一部として、特に構造体メンバ参照個所に対応するコ
ード生成時に、スケール付き即値ロード・ストア命令を
活用する。例えば、図5のコードC3内部の参照Ref
2を、ステップS5で図6のコードC2の参照Ref4
のように解釈した個所に対しては、図6の(B)のコー
ドASM2内の参照Ref5に示すような命令列を生成
する。構造体のベースアドレス(DATA.L_g1)
等が既にロードされていれば、構造体ベースアドレスの
ロード命令は不要である。
In step S6, a scaled immediate load / store instruction is used as part of the conventional code generation processing, particularly when generating a code corresponding to a structure member reference location. For example, the reference Ref inside the code C3 in FIG.
2 in step S5, reference Ref4 of code C2 in FIG.
Is generated, an instruction sequence as shown by reference Ref5 in the code ASM2 of FIG. 6B is generated. Base address of the structure (DATA.L_g1)
Etc. are already loaded, the load instruction of the structure base address is unnecessary.

【0059】ステップS7では、機械語への変換などの
通常コンパイル処理を行う。
In step S7, normal compile processing such as conversion into machine language is performed.

【0060】以上により、図5のグループ化指示文gr
oup1,group2を含むコードC3における大域
変数の参照に対してコードサイズを低減し、実行時性能
を向上させたオブジェクトモジュールが得られる。同様
に図5の(B)のグループ化指示文P3を用いる場合も
コードサイズの低減と実行性能向上を実現することがで
きる。
As described above, the grouping instruction statement gr in FIG.
An object module with reduced code size and improved execution-time performance with respect to global variable reference in code C3 including up1 and group2 is obtained. Similarly, when the grouping directive P3 of FIG. 5B is used, the code size can be reduced and the execution performance can be improved.

【0061】他のコンパイル対象に対しても同様の処理
を行う。例えばコードC3のグループ化指示文grou
p1に含まれる大域変数を他のCソースファイルが参照
している場合、そのCソースファイル中にもグループ化
指示文を記述しておくことにより、全てのファイル間で
グループ化された大域変数へのアクセスコードの整合性
が保たれる。
The same processing is performed for other compilation targets. For example, the grouping instruction statement grou of the code C3
When a global variable included in p1 is referred to by another C source file, a grouping directive is also described in the C source file, so that a global variable grouped among all files can be obtained. Access code integrity is maintained.

【0062】前述の如くグループ化指示文による処理結
果は、言語仕様として構造体記述を行ったソースプログ
ラムに対するコンパイル結果と実質的に同じ結果にな
る。例えば、図4のコードC1と同様の機能をもつコー
ドで、しかも、必要な命令数と必要なメモリ領域がコー
ドC1よりも少なくて済むコードとして、図6のコード
C2で記述したのと同じ結果を得られる。図6のコード
C2は、コードC1で個別に定義された大域変数を、2
つの構造体Struct1とStruct2でグループ
化し、コードC1の各大域変数参照を、コードC2で
は、構造体のメンバ参照で実現している。コードC1の
コード片Ref2と同様の機能はコードC2のコード片
Ref4で実現されている。コード片Ref4をコンパ
イルしたアセンブリコードをコードASM2においてコ
ード片Ref5で示す。ここでは例えば大域構造体変数
G2のメンバd0のメモリアドレスを、大域構造体変数
G2のメモリアドレス「_g2」をベースとしレジスタ
R5にロードしておき、そこからのオフセットを即値で
表し、「ベースレジスタ+即値」で生成する。ベースは
32ビットアドレスであり、オフセットは例えば4ビッ
トサイズで表現できる範囲とすれば、16個のメモリア
ドレスを指定できる。メンバd0は構造体G2の最初の
メンバであり、オフセットは0となる。同様にコードC
1の大域変数c0に対応して、構造体G1のメンバc0
に対応し、c0のメモリアドレスも大域構造体変数G1
のメモリアドレス「_g1」をベースとしレジスタR4
にロードしておき、そこからのオフセットを即値で表
し、「ベースレジスタ+即値」で生成する。
As described above, the result of processing by the grouping directive is substantially the same as the result of compiling a source program having a structure description as a language specification. For example, a code having the same function as the code C1 in FIG. 4 and having the required number of instructions and the required memory area smaller than the code C1 has the same result as the code C2 in FIG. Can be obtained. The code C2 in FIG. 6 represents the global variables defined individually in the code C1 as 2
Two structures Struct1 and Struct2 are grouped, and each global variable reference of the code C1 is realized by a code member reference of the structure C2. The same function as the code fragment Ref2 of the code C1 is realized by the code fragment Ref4 of the code C2. An assembly code obtained by compiling the code fragment Ref4 is indicated by a code fragment Ref5 in the code ASM2. Here, for example, the memory address of the member d0 of the global structure variable G2 is loaded into the register R5 based on the memory address “_g2” of the global structure variable G2, and the offset therefrom is represented by an immediate value. + Immediate value ". The base is a 32-bit address, and if the offset has a range that can be expressed by, for example, a 4-bit size, 16 memory addresses can be specified. The member d0 is the first member of the structure G2, and the offset is 0. Similarly, code C
1 corresponding to the global variable c0 of the member G0 of the structure G1.
And the memory address of c0 is also the global structure variable G1
Register R4 based on the memory address “_g1” of
, And the offset therefrom is represented by an immediate value, and is generated by “base register + immediate value”.

【0063】コードC2のコード片Ref5では、変数
d0の参照を構造体変数のベースをあらかじめロードし
ておき、即値つきメモリアクセス命令1個で実現できる
ため、コード片Ref4では4命令とメモリ領域8バイ
ト必要だった機能を、コード片Ref5では、2命令と
メモリ領域0バイトで実現できる。
In the code fragment Ref5 of the code C2, the reference to the variable d0 can be realized by loading the base of the structure variable in advance and using one memory access instruction with an immediate value. In the code fragment Ref5, the function that required a byte can be realized with two instructions and a memory area of 0 byte.

【0064】本発明に係るグループ化指示文を用いる場
合と、図6のように上記C言語仕様上の構造体記述を行
う場合とを比較すると、コンパイル結果は実質的に同じ
であるが、ソースプログラムを作成するプログラマに対
する負担という点では、前者は、煩雑な構造体メンバ参
照コードを記述しなくとも、Cコンパイラがグループ化
指示文を内部的に構造体メンバ参照として解釈するの
で、Cプログラマの負担が軽減し、且つCソースプログ
ラムそのものの可読性を損なわないという有利な効果を
奏する。また、16ビット固定長命令に代表されるよう
に、アドレス情報のビット数に対して命令のアドレス指
定フィールドのビット数が少ないという制約の下で、プ
ログラムのコードサイズの低減及び実行時の性能向上と
いう問題意識を持たなければ、バグを誘発したり可読性
を犠牲にするような構造体の概念としては無意味で単に
記述を複雑化するだけの構造体記述を行うことは、通常
のプログラマにとってプログラムの技術常識に反するも
のである。したがって、そのような技術常識に反してま
でも図6のような構造体記述を採用すること自体につい
ても、そうしようとすることについてのモチベーション
がなければ容易に到達し得るものではない。要するに、
図6の構成は本発明の契機と同じ観点をもって初めて実
現し得る記述内容であり、それ自体容易に考え出せるも
のではない。
When the case where the grouping directive according to the present invention is used is compared with the case where the structure description in the C language specification is made as shown in FIG. 6, the compile results are substantially the same, but the source In terms of the burden on the programmer who creates the program, the former requires the C compiler to interpret the grouping directive internally as a structure member reference without writing complicated structure member reference codes. This has an advantageous effect that the burden is reduced and the readability of the C source program itself is not impaired. Also, under the constraint that the number of bits in the addressing field of the instruction is smaller than the number of bits of the address information, as represented by a 16-bit fixed-length instruction, the code size of the program is reduced and the performance during execution is improved If you are not aware of the problem, it is meaningless as a concept of a structure that induces bugs or sacrifices readability, and it is difficult for ordinary programmers to write a structure description that simply complicates the description. This is contrary to common technical knowledge. Therefore, even if it is against such common technical knowledge, the adoption of the structure description as shown in FIG. 6 cannot be easily achieved without motivation to do so. in short,
The configuration shown in FIG. 6 is description content that can be realized only from the same viewpoint as the opportunity of the present invention, and cannot itself be easily conceived.

【0065】図10には本発明に係るグループ化、方式
A、方式Bによる全体のコードサイズ及び実行命令数の
比較例が示される。
FIG. 10 shows a comparison example of the total code size and the number of executed instructions according to the grouping, method A, and method B according to the present invention.

【0066】コードC1においてメモリアドレスを一般
的な32ビット長で実現した場合、(A)に示される前
記方式Aによるコードサイズはaddr32の欄に示す
ように336バイト必要で、(B)に示される前記方式
Aによる実行命令数はaddr32の欄に示すように8
4命令必要である。これに対して、グループ化指示文に
より大域変数を構造体化した場合(この場合はコードC
2のように大域変数を構造体でグループ化した場合に匹
敵する)、コードサイズは(A)における「方式A+g
roup」のaddr32の欄に示すように98バイト
必要で、実行命令数は(B)における「方式A+gro
up」の欄に示すように44命令必要である。すなわ
ち、構造体化によりコードサイズは約1/3に低減さ
れ、実行命令数は約1/2に低減される。方式Bは可変
長命令をサポートするマイクロプロセッサによるもので
あるが、(A)の「方式B」および「方式A+grou
p」のaddr32の欄でみると「方式A+grou
p」の方がコードサイズが小さくて済むことがわかる。
また、(B)の「方式B」および「方式A+grou
p」のaddr32の欄でみると「方式A+grou
p」の実行命令数は「方式B」と同等であることがわか
る。また、アドレスを16ビットに保証しても、「方式
A+group」の優位性は図10により同様に理解す
ることができる。
When the memory address is realized with a general 32-bit length in the code C1, the code size according to the method A shown in (A) requires 336 bytes as shown in the column of addr32, and shown in (B). The number of executable instructions according to the method A is 8 as shown in the column of addr32.
Four instructions are required. In contrast, when a global variable is structured by a grouping directive (in this case, code C
(Comparable to the case where global variables are grouped by structure as in FIG. 2), the code size is “method A + g” in (A).
As shown in the column of addr32 of “loop”, 98 bytes are required, and the number of execution instructions is “method A + gro” in (B).
As shown in the "up" column, 44 instructions are required. That is, the structuring reduces the code size to about / and the number of executed instructions to about 2. Method B is based on a microprocessor that supports variable-length instructions, but “Method B” and “Method A + grou” in FIG.
Looking at the column of addr32 of "p", "method A + grou
It can be seen that "p" requires a smaller code size.
Also, “method B” and “method A + grou” in (B)
Looking at the column of addr32 of "p", "method A + grou
It can be seen that the number of execution instructions of “p” is equivalent to that of “method B”. Further, even if the address is guaranteed to be 16 bits, the superiority of “method A + group” can be similarly understood from FIG.

【0067】以上説明してきたように、本発明の大域変
数のグループ化指示文に従って、大域変数を構造体化す
るCコンパイラによれば、既存のCソースプログラムそ
のものの論理的な変更をともなわず、大域変数のグルー
プ化が可能となり、プログラムのコードサイズ低減と実
行性能向上を実現できる。また、煩雑な構造体メンバ参
照コードを記述しなくとも、Cコンパイラが内部的に構
造体メンバ参照に解釈するので、Cプログラマの負担が
軽減し、且つCソースプログラムそのものの可読性を損
なわずに済む。
As described above, according to the C compiler for structuring global variables according to the global variable grouping directive of the present invention, the existing C source program itself is not logically changed. Global variables can be grouped, and the code size of the program can be reduced and the execution performance can be improved. Further, even if a complicated structure member reference code is not described, the C compiler internally interprets it as a structure member reference, so that the load on the C programmer is reduced and the readability of the C source program itself is not impaired. .

【0068】《大域変数グループ化の第2態様》プログ
ラマによるグループ化指示に基づいて、大域変数を構造
体化する更に別の例を述べる。前記図5の(A),
(B)の例では大域変数のグループ化を個別のCソース
プログラムファイル中にグループ化指示文P1,gro
up3を記述することにより実現したが、別の実現方法
として、図5の(C)のようにインクルードファイルに
グループ化指示文を記述することでも実現可能である。
Cコンパイラにグループ化指示文を記述したインクルー
ドファイルを参照するコンパイルオプションを設けて、
個別Cソースファイルのコンパイル時にこのインクルー
ドファイルを読みこむオプションを指定してコンパイル
することにより、Cソースファイル中に直接グループ化
指示文を記述する場合と同様に、コードサイズを低減
し、実行性能の向上したオブジェクトを生成できる。こ
の別ファイルによるグループ化指示方式の場合、プログ
ラマが個別Cソースファイル中にグループ化指示文を埋
めこむ必要がなく、簡易に全てのファイル間でグループ
化された大域変数へのアクセスコードの整合性が保たれ
る。
<< Second Aspect of Global Variable Grouping >> Still another example in which global variables are structured based on a grouping instruction from a programmer will be described. FIG. 5 (A),
In the example of (B), grouping of global variables is performed by grouping directives P1 and gro in individual C source program files.
Up3 is described, but as another implementation method, it is also possible to describe a grouping directive in an include file as shown in FIG. 5C.
A compile option that refers to an include file that describes a grouping directive is provided in the C compiler.
By compiling with the option to read this include file when compiling an individual C source file, the code size can be reduced and the execution performance can be reduced, as in the case where the grouping directive is written directly in the C source file. Can generate improved objects. In the case of the grouping instruction method using this separate file, the programmer does not need to embed the grouping instruction statement in the individual C source file, and the consistency of the access code to the global variables grouped between all the files is simplified. Is kept.

【0069】《大域変数グループ化処理の第3態様》さ
らにプログラマがいちいちグループ化指示を行わなくて
も済む別の例を述べる。コンパイル対象となるCソース
ファイルおよびインクルードファイルをコンパイルオプ
ションでコンパイラに指示する。コンパイラは図11の
フローにしたがって、指定されたファイル内の大域変数
を構造体化したコードを生成する。ステップS1では、
コンパイルオプションで指定された順番にCソースファ
イルを走査し、スカラ型外部変数の定義名称をサイズ毎
にリストアップする。例えば、最初に走査されるファイ
ルが図4のコードC1で構成される場合、バイトサイズ
のスカラ型外部変数の定義名称のリストは「{c0,c
1,c2,c3,c4,c5,c6,d0,d1,d
2,d3,d4,d5,d6}」となり、2バイトサイ
ズのスカラ型外部変数の定義名称のリストは「{s0,
s1,s2,s3,s4,s5,s6,t0,t1,t
2,t3,t4,t5,t6}」となり、4バイトサイ
ズのスカラ型外部変数の定義名称のリストは「{i0,
i1,i2,i3,i4,i5,i6,j0,j1,j
2,j3,j4,j5,j6}」となる。そし次のソー
スファイルを走査し、これらリストを伸ばしていく。
<< Third Aspect of Global Variable Grouping Process >> Another example in which the programmer does not have to issue a grouping instruction each time will be described. The compiler specifies a C source file and an include file to be compiled with a compile option. The compiler generates a code in which global variables in the specified file are structured according to the flow of FIG. In step S1,
The C source files are scanned in the order specified by the compile option, and the definition names of the scalar type external variables are listed for each size. For example, if the file to be scanned first is composed of the code C1 in FIG. 4, the list of definition names of byte-size scalar type external variables is “{c0, c
1, c2, c3, c4, c5, c6, d0, d1, d
2, d3, d4, d5, d6} ”, and the list of definition names of scalar type external variables of 2 byte size is“ {s0,
s1, s2, s3, s4, s5, s6, t0, t1, t
2, t3, t4, t5, t6} ”, and the list of definition names of the 4-byte scalar type external variable is“ {i0,
i1, i2, i3, i4, i5, i6, j0, j1, j
2, j3, j4, j5, j6} ". It scans the next source file and extends these lists.

【0070】ステップS2では、ステップS1で得られ
たリストにもとづいて、リストを分割し、構造体に割り
当てていく。ここでは、図1のステップS4で説明した
のとほぼ同様に、ターゲットとするマイクロプロセッサ
がもつスケーリング即値つきロード命令の即値フィール
ドサイズに合わせて、一つのベースアドレスから参照で
きるメモリ領域にできるだけ多くの大域変数をパッキン
グする。これにより、図4のコードC1を含むファイル
から得られるスカラ型外部変数の定義名称から、図6の
コードC2に示されるような大域変数の構造体化が得ら
れる。
In step S2, the list is divided based on the list obtained in step S1 and assigned to structures. Here, almost as much as possible in the memory area that can be referred to from one base address in accordance with the immediate field size of the scaling immediate load instruction of the target microprocessor, almost as described in step S4 of FIG. Pack global variables. As a result, a global variable structure as shown in code C2 in FIG. 6 is obtained from the definition name of the scalar type external variable obtained from the file including the code C1 in FIG.

【0071】ステップS3では、各入力ファイルの外部
変数参照個所を、ステップS2で得られた構造体のメン
バ参照に置き換えたコンパイラ処理の内部表現を得る。
この内部表現は図6のソースコードを通常にコンパイル
したものとほぼ同様である。
In step S3, an internal expression of a compiler process is obtained in which the external variable reference portion of each input file is replaced with the member reference of the structure obtained in step S2.
This internal representation is almost the same as a normal compilation of the source code of FIG.

【0072】ステップS4では、ステップS3で置きか
えられた構造体メンバ参照をスケーリング即値つきロー
ド/ストア命令を活用したコード生成を行う。
In step S4, the structure member reference replaced in step S3 is subjected to code generation utilizing a load / store instruction with a scaling immediate value.

【0073】以上により、プログラマによる大域変数の
構造体化指示がない場合でも、ある程度大域変数のグル
ープ化とコードサイズを低減し、実行時性能を向上させ
たオブジェクトモジュールが得られる。図11の例では
アクセス頻度予測なしで大域変数のファイル出現順に構
造体化しているが、更に、シミュレーションなどによる
アクセス頻度予測にもとづいて、ステップS11で得ら
れたリストを並べ替えれば、コードサイズをより低減
し、実行時性能をより向上させたオブジェクトの生成が
可能である。
As described above, even when the programmer does not instruct the structuring of global variables, an object module can be obtained in which the grouping of global variables and the code size are reduced to some extent, and the runtime performance is improved. In the example of FIG. 11, the structure is structured in the order in which the global variables appear in the file without access frequency prediction. However, if the list obtained in step S11 is rearranged based on access frequency prediction by simulation or the like, the code size can be reduced. It is possible to generate an object with a reduced size and improved runtime performance.

【0074】《コンパイルプログラムの記録媒体》図1
2には図1や図11のコンパイル方法を実現するプログ
ラム開発システムが例示される。同図に示されるシステ
ムはエンジニアリングワークステーション又はパーソナ
ルコンピュータシステムなどによって実現され、入力手
段としてのキーボード1、表示手段としてのディスプレ
イ2、CPU3A及メインメモリ3Bなどが実装された
CPUボードやインタフェースボードを有するデータ処
理手段としてのコンピュータユニット3、補助記憶装置
4、並びにターミナルアダプタやモデム等の通信インタ
フェース回路5を有して成る。通信インタフェース回路
5も入力手段の一例を成す。補助記憶装置4は、特に制
限されないが、磁気ディスクを固定的に備えたハードデ
ィスク装置、フラッシュメモリーカードが着脱可能なメ
モリカード装置、フロッピー(登録商標)ディスクに対
してリード・ライト可能なフロッピーディスクドライブ
装置、CD−ROMをリード可能なCD−ROMドライ
ブ装置、MOディスクに対してリード・ライト可能なM
Oドライブ装置等によって構成される。4Aは補助記憶
装置4の記録媒体を総称する。補助記憶装置4も入力手
段の一例を成す。前記通信インタフェース回路5は公衆
回線網6等に接続可能にされる。CPU3Aは、特に制
限されないが、記録媒体4Aから読み取ったプログラム
又は通信インタフェース手段5を介してダウンロードし
たプログラムをメインメモリ3B等にロードして実行す
る。プログラムの実行に必要なデータは、同じく記録媒
体4から読み込み、或いは通信インタフェース5を利用
してダウンロードし、更にはキーボード1より入力す
る。
<< Compilation Program Recording Medium >> FIG.
2 exemplifies a program development system that realizes the compiling method shown in FIGS. The system shown in FIG. 1 is realized by an engineering workstation or a personal computer system, and has a keyboard 1 as input means, a display 2 as display means, a CPU board and an interface board on which a CPU 3A and a main memory 3B are mounted. It comprises a computer unit 3 as data processing means, an auxiliary storage device 4, and a communication interface circuit 5 such as a terminal adapter or a modem. The communication interface circuit 5 also forms an example of an input unit. The auxiliary storage device 4 includes, but is not limited to, a hard disk device having a fixed magnetic disk, a memory card device to which a flash memory card can be attached and detached, and a floppy disk drive that can read and write from a floppy (registered trademark) disk. Device, CD-ROM drive capable of reading CD-ROM, M capable of reading / writing to MO disk
It is composed of an O drive device and the like. 4A is a general term for recording media of the auxiliary storage device 4. The auxiliary storage device 4 also forms an example of an input unit. The communication interface circuit 5 can be connected to a public line network 6 or the like. Although not particularly limited, the CPU 3A loads a program read from the recording medium 4A or a program downloaded via the communication interface unit 5 into the main memory 3B or the like and executes it. Data necessary for executing the program is read from the recording medium 4 or downloaded using the communication interface 5 and further input from the keyboard 1.

【0075】プログラム開発システムにおいて、前記補
助記憶装置4又は通信インタフェース回路5は前記ソー
スプログラム等を入力可能である。
In the program development system, the auxiliary storage device 4 or the communication interface circuit 5 can input the source program and the like.

【0076】前記コンピュータユニット3が前記コンパ
イル処理を行う為の動作プログラムは、コンピュータ読
取り可能な記録媒体4Aで提供される。このプログラム
は、図1や図11で説明した処理をコンピュータユニッ
ト3が実行するために必要な機械語によって構成されて
いる。記録媒体4Aを介して必要なプログラムを提供す
ることにより、前記コンパイル方法をコンピュータで実
現することが容易になる。
An operation program for the computer unit 3 to perform the compiling process is provided on a computer-readable recording medium 4A. This program is configured by machine language necessary for the computer unit 3 to execute the processing described in FIG. 1 and FIG. By providing a necessary program via the recording medium 4A, it becomes easy to realize the compiling method by a computer.

【0077】以上本発明者によってなされた発明を実施
形態に基づいて具体的に説明したが、本発明はそれに限
定されるものではなく、その要旨を逸脱しない範囲にお
いて種々変更可能であることは言うまでもない。
Although the invention made by the present inventor has been specifically described based on the embodiment, it is needless to say that the present invention is not limited to the embodiment and can be variously modified without departing from the gist thereof. No.

【0078】例えば、前記ソースプログラムにおいて全
体として関連付けのない変数は全部が構造体として予め
規定されていない変数群であっても、或いは一部だけが
構造体として規定されている変数群であってよい。した
がって、離散的な複数の構造体記述の変数群を統一的な
グループに再編成したり、構造体記述の変数群と非構造
体の変数群とを統一的なグループに再編成したりする場
合も本発明は適用ある。
For example, in the source program, variables that are not associated as a whole may be variables that are not entirely defined as structures, or variables that are partially defined as structures. Good. Therefore, when reorganizing a variable group of discrete structure descriptions into a unified group, or reorganizing a variable group of a structure description and a non-structure variable group into a unified group The present invention is also applicable.

【0079】また、ソースプログラムの内容は上記の例
に限定されない。また、レジスタ相対のようなアドレシ
ングモードはスケーリング即値付きロード命令に代表さ
れるようなアドレシングモードに限定されず、スケーリ
ング即値付きは無くてもよい。
The contents of the source program are not limited to the above example. The addressing mode such as register relative is not limited to the addressing mode represented by the load instruction with a scaling immediate value, and may not have the scaling immediate value.

【0080】[0080]

【発明の効果】本願において開示される発明のうち代表
的なものによって得られる効果を簡単に説明すれば下記
の通りである。
The effects obtained by typical ones of the inventions disclosed in the present application will be briefly described as follows.

【0081】ソースプログラムにおいて全体として関連
付けのない変数群に対してはグループ化の指示を与える
ことによって構造体化処理を行い、当該変数が属するグ
ループに共通のベースアドレスに変数のオフセットアド
レスを加えて変数参照を実現させるから、変数参照に必
要な命令数と必要なメモリ領域サイズの低減、プログラ
ムのコードサイズの低減、及び実行時の性能向上を実現
することができる。
In the source program, structuring processing is performed by giving a grouping instruction to a group of variables that are not entirely related to each other, and a variable offset address is added to a base address common to the group to which the variable belongs. Since the variable reference is realized, it is possible to reduce the number of instructions required for the variable reference and the required memory area size, reduce the code size of the program, and improve the performance at the time of execution.

【0082】変数参照に際してベースアドレスとオフセ
ットアドレスを利用可能にするとき、プログラマはソー
スプログラムに構造体記述を行うことを要しないから、
ソースプログラムに煩雑な構造体メンバ参照コードを記
述せず、ソースプログラムの意味の可読性が損なわれ
ず、プログラマに大きな負担もかけず、その上、ソース
プログラムにバグを誘発する虞も無く、上記効果を実現
する事ができる。
When making the base address and offset address available for variable reference, the programmer does not need to describe the structure in the source program.
The source program does not include complicated structure member reference codes, does not impair the readability of the meaning of the source program, does not impose a large burden on the programmer, and has no risk of inducing a bug in the source program. Can be realized.

【0083】ターゲットとするマイクロプロセッサのス
ケーリング即値つきロード命令の即値フィールドサイズ
に合わせて、グループを複数に分割可能であるから、一
つのベースアドレスから参照できるメモリ領域に多くの
大域変数をパッキングすることが可能になる。
Since the group can be divided into a plurality of groups in accordance with the immediate field size of the load instruction with immediate scaling of the target microprocessor, packing many global variables in a memory area that can be referred to from one base address. Becomes possible.

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

【図1】本発明に係るコンパイル方法の一例を示すフロ
ーチャートである。
FIG. 1 is a flowchart illustrating an example of a compiling method according to the present invention.

【図2】ソースプログラムからロードモジュールを生成
するまでの生成手順を例示するフローチャートである。
FIG. 2 is a flowchart illustrating a generation procedure from generation of a load module to a source program.

【図3】前記ロードモジュールを実行するマイクロプロ
セッサの要部を例示するブロック図である。
FIG. 3 is a block diagram illustrating a main part of a microprocessor that executes the load module.

【図4】大域変数の構造体化処理を考慮する前のソース
コード及びアセンブリコードを例示する説明図である。
FIG. 4 is an explanatory diagram exemplifying a source code and an assembly code before considering a global variable structuring process.

【図5】ソースプログラムとグループ化指示文とを例示
する説明図である。
FIG. 5 is an explanatory diagram illustrating a source program and a grouping directive.

【図6】構造体記述を有するソースプログラム及びその
アセンブリコードを例示する説明図である。
FIG. 6 is an explanatory diagram illustrating a source program having a structure description and its assembly code.

【図7】スケーリング即値付きロード命令の命令フォー
マット及び即値を用いたソースアドレス演算手法を例示
する説明図である。
FIG. 7 is an explanatory diagram illustrating an instruction format of a load instruction with a scaling immediate value and a source address calculating method using the immediate value;

【図8】スケーリング即値付きロード命令による大域変
数分割方式の一例を示す説明図である。
FIG. 8 is an explanatory diagram showing an example of a global variable division method using a load instruction with a scaling immediate value.

【図9】スケーリング即値付きロード命令による大域変
数分割方式の別の例を示す説明図である。
FIG. 9 is an explanatory diagram showing another example of a global variable division method using a load instruction with a scaling immediate value.

【図10】グループ化指示方式、方式A、方式Bの夫々
による全体のコードサイズ及び実行命令数を対比する説
明図である。
FIG. 10 is an explanatory diagram comparing the overall code size and the number of executed instructions according to each of the grouping instruction method, method A, and method B.

【図11】大域変数グループ化処理の別の例を示すフロ
ーチャートである。
FIG. 11 is a flowchart illustrating another example of the global variable grouping process.

【図12】図1のコンパイル方法を実現するプログラム
開発システムを例示するシステム構成図である。
FIG. 12 is a system configuration diagram illustrating a program development system for realizing the compiling method of FIG. 1;

【図13】アドレスが32ビットの大域変数アクセスコ
ードの説明図である。
FIG. 13 is an explanatory diagram of a global variable access code having an address of 32 bits.

【図14】アドレスが16ビットの大域変数アクセスコ
ードの説明図である。
FIG. 14 is an explanatory diagram of a global variable access code having an address of 16 bits.

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

S1,S2,…,S7 大域変数グループ化処理を示す
ステップ 20 ソースプログラム 21 Cコンパイラ 22 オブジェクトモジュール 24 リンケージエディタ 25 ロードモジュール Ref1,Ref2,…,Ref5 変数参照を含むコ
ード片例 Struct1,Struct2,…,Struct4
構造体表現例 group1,group2,group3,P1 グ
ループ化指示文 F1 オペレーションコードフィールド F2 ターゲットレジスタ指定フィールド F3 ベースレジスタ指定フィールド F4 即値フィールド 3 コンピュータユニット 3A CPU 3B メインメモリ 4 補助記憶装置 4A 記録媒体
S1, S2,..., S7 Steps indicating global variable grouping processing 20 Source program 21 C compiler 22 Object module 24 Linkage editor 25 Load module Ref1, Ref2,. Struct4
Structure representation example group1, group2, group3, P1 Grouping directive F1 Operation code field F2 Target register specification field F3 Base register specification field F4 Immediate field 3 Computer unit 3A CPU 3B Main memory 4 Auxiliary storage device 4A Recording medium

Claims (19)

【特許請求の範囲】[Claims] 【請求項1】 ソースプログラムから固定長命令のオブ
ジェクトコードを生成するコンパイル方法であって、 ソースプログラムにおいて全体として関連付けのない変
数群に対するグループ化の指示を検出する処理と、 前記グループ化の指示を検出したとき、その指示に基づ
いて前記変数群をグループ化する処理と、 グループ化された変数の参照個所をソースプログラムか
ら検出する処理と、 前記検出された変数参照個所に対し、当該変数が属する
グループに共通のベースアドレスに変数のオフセットア
ドレスを加えて当該変数参照を行うように、オブジェク
トコードを生成する処理と、を含むことを特徴とするコ
ンパイル方法。
1. A compiling method for generating object code of fixed-length instructions from a source program, comprising: a process of detecting a grouping instruction for a group of variables that are not entirely related in the source program; When detecting, a process of grouping the variable group based on the instruction, a process of detecting a reference location of the grouped variable from a source program, and a process in which the variable belongs to the detected variable reference location. A process of generating an object code so as to add a variable offset address to a base address common to the group and to refer to the variable.
【請求項2】 前記固定長命令は、アドレス情報のビッ
ト数が命令のアドレス指定フィールドのビット数よりも
多いものであることを特徴とする請求項1記載のコンパ
イル方法。
2. The compiling method according to claim 1, wherein said fixed-length instruction has a bit number of address information larger than a bit number of an address designation field of the instruction.
【請求項3】 ソースプログラムにおいて全体として関
連付けのない変数は、全部又は一部が構造体として規定
されていない変数群であることを特徴とする請求項1記
載のコンパイル方法。
3. The compiling method according to claim 1, wherein the variables that are not related as a whole in the source program are a group of variables not entirely or partially defined as a structure.
【請求項4】 前記グループ化の指示は、ソースプログ
ラムに含まれるグループ化指示文により与えられるもの
であることを特徴とする請求項1記載のコンパイル方
法。
4. The compiling method according to claim 1, wherein the grouping instruction is given by a grouping instruction sentence included in a source program.
【請求項5】 前記グループ化の指示は、所定のコンパ
イルオプションにより与えられ、前記コンパイルオプシ
ョンは、ソースプログラム以外の別ファイルとして与え
られるグループ化指示ファイルの読み込みと、読み込ん
だグループ化指示ファイルで指定される変数に対するグ
ループ化とを指示することを特徴とする請求項1記載の
コンパイル方法。
5. The grouping instruction is given by a predetermined compile option, and the compile option is read by reading a grouping instruction file given as another file other than the source program, and specified by the read grouping instruction file. 2. The compiling method according to claim 1, wherein grouping is performed on variables to be performed.
【請求項6】 前記グループ化の指示は、所定のコンパ
イルオプションにより与えられ、前記コンパイルオプシ
ョンは、ソースプログラム以外の別ファイルとして与え
られるグループ化指示ファイルの読み込みと、読み込ん
だグループ化指示ファイルで指定されるソースプログラ
ムの変数の走査と、走査された変数に対するグループ化
とを指示することを特徴とする請求項1記載のコンパイ
ル方法。
6. The grouping instruction is given by a predetermined compile option, and the compile option is read by reading a grouping instruction file given as another file other than the source program, and specified by the read grouping instruction file. 2. The compiling method according to claim 1, wherein scanning of the variables of the source program to be performed and grouping of the scanned variables are instructed.
【請求項7】 前記グループ化する処理は、処理対象と
される変数をデータサイズの順番に並べ替えた変数リス
トを作成する処理と、 前記ベースアドレスに加算するオフセットアドレスとし
てオブジェクトコードの即値を用いるとき、オブジェク
トコードの即値が採る得るビット数と前記オフセットア
ドレスのビット数との関係に基づき必要な場合には変数
リストの変数を別のグループに分割する処理と、を含む
ことを特徴とする請求項2乃至6の何れか1項記載のコ
ンパイル方法。
7. The grouping process includes a process of creating a variable list in which variables to be processed are rearranged in the order of data size, and using an immediate value of an object code as an offset address to be added to the base address. And, if necessary, dividing the variables in the variable list into another group based on the relationship between the number of bits that can be taken by the immediate value of the object code and the number of bits of the offset address. 7. The compiling method according to any one of items 2 to 6.
【請求項8】 前記変数リストの変数を別のグループに
分割する処理は、前記変数リスト中の変数をグループの
ベースアドレスを基点にデータサイズの小さいものから
順番に配置するとしたとき、ベースアドレスに対するオ
フセットが前記オブジェクトコードの即値に基づいて指
定可能な範囲を超えることを条件に、当該変数を別のグ
ループに分割することを特徴とする請求項7記載のコン
パイル方法。
8. The process of dividing the variables in the variable list into different groups includes the step of arranging the variables in the variable list in ascending order of data size based on the base address of the group. 8. The compiling method according to claim 7, wherein the variable is divided into another group on condition that the offset exceeds a range that can be specified based on the immediate value of the object code.
【請求項9】 前記オブジェクトコードは、参照するデ
ータサイズに応じて即値を整数倍してベースアドレスに
加算する、即値のスケーリング機能を有することを特徴
とする請求項8記載のコンパイル方法。
9. The compiling method according to claim 8, wherein the object code has an immediate value scaling function of multiplying an immediate value by an integer according to a data size to be referenced and adding the result to a base address.
【請求項10】 前記グループ化された変数群をソース
プログラム言語による構造体のメンバとして解釈し、当
該変数へのアクセスをソースプログラム言語における構
造体メンバへの参照コードに変換してソースファイルに
出力する処理を更に行うことを特徴とする請求項1乃至
6の何れか1項記載のコンパイル方法。
10. Interpreting the grouped variables as a member of a structure in a source program language, converting access to the variable into a reference code to a structure member in the source program language, and outputting the code to a source file 7. The compiling method according to claim 1, further comprising the step of:
【請求項11】 ソースプログラムから固定長命令のオ
ブジェクトコードを生成するために、 ソースプログラムにおいて全体として関連付けのない変
数群に対するグループ化の指示を検出する処理と、 前記グループ化の指示を検出したとき、その指示に基づ
いて前記変数群をグループ化する処理と、 前記グループ化された同一グループに属する変数の参照
には、当該グループに共通のベースアドレスに変数のオ
フセットアドレスを加えたアドレスを用いるようにし
て、変数参照に応ずるオブジェクトコードを生成する処
理とを実行させる、コンパイルプログラムをコンピュー
タ読み取り可能に記録したものであることを特徴とする
コンピュータ読取り可能な記録媒体。
11. A process for detecting a grouping instruction for a group of variables that are not entirely related in a source program in order to generate an object code of a fixed-length instruction from a source program, and when the grouping instruction is detected. In the process of grouping the variable groups based on the instruction, and for referring to the variables belonging to the same group that has been grouped, an address obtained by adding a variable offset address to a base address common to the group is used. A computer-readable recording medium storing a compile program for executing a process of generating an object code corresponding to a variable reference.
【請求項12】 前記固定長命令は、アドレス情報のビ
ット数が命令のアドレス指定フィールドのビット数より
も多いものであることを特徴とする請求項11記載のコ
ンピュータ読取り可能な記録媒体。
12. The computer-readable recording medium according to claim 11, wherein the fixed-length instruction has a bit number of address information larger than a bit number of an address designation field of the instruction.
【請求項13】 ソースプログラムにおいて全体として
関連付けのない変数は、全部又は一部が構造体として規
定されていない変数群であることを特徴とする請求項1
1記載のコンピュータ読取り可能な記録媒体。
13. The variable which is not associated as a whole in the source program is a variable group not entirely or partially defined as a structure.
The computer-readable recording medium according to claim 1.
【請求項14】 前記グループ化の指示は、ソースプロ
グラムに含まれるグループ化指示文により与えられるも
のであることを特徴とする請求項11記載のコンピュー
タ読取り可能な記録媒体。
14. The computer-readable recording medium according to claim 11, wherein the instruction for grouping is given by a grouping instruction sentence included in a source program.
【請求項15】 前記グループ化の指示は、所定のコン
パイルオプションにより与えられ、前記コンパイルオプ
ションは、ソースプログラム以外の別ファイルとして与
えられるグループ化指示ファイルの読み込みと、読み込
んだグループ化指示ファイルで指定される変数に対する
グループ化とを指示することを特徴とする請求項11記
載のコンピュータ読取り可能な記録媒体。
15. The grouping instruction is given by a predetermined compile option, and the compile option is read by a grouping instruction file provided as a separate file other than the source program, and specified by the read grouping instruction file. 12. The computer-readable recording medium according to claim 11, wherein the instructions indicate grouping of the variables to be performed.
【請求項16】 前記グループ化の指示は、所定のコン
パイルオプションにより与えられ、前記コンパイルオプ
ションは、ソースプログラム以外の別ファイルとして与
えられるグループ化指示ファイルの読み込みと、読み込
んだグループ化指示ファイルで指定されるソースプログ
ラムの変数の走査と、走査された変数に対するグループ
化とを指示することを特徴とする請求項11記載のコン
ピュータ読取り可能な記録媒体。
16. The grouping instruction is given by a predetermined compile option. The compile option is read by reading a grouping instruction file given as another file other than the source program, and specified by the read grouping instruction file. 12. The computer-readable recording medium according to claim 11, wherein instructions for scanning the variables of the source program to be performed and grouping the scanned variables are provided.
【請求項17】 前記グループ化する処理は、処理対象
とされる変数をデータサイズの順番に並べ替えた変数リ
ストを作成する処理と、 前記ベースアドレスに加算するオフセットアドレスとし
てオブジェクトコードの即値を用いるとき、オブジェク
トコードの即値が採る得るビット数と前記オフセットア
ドレスのビット数との関係に基づき必要な場合には変数
リストの変数を別のグループに分割する処理とを含むこ
とを特徴とする請求項11記載のコンピュータ読取り可
能な記録媒体。
17. The grouping process includes a process of creating a variable list in which variables to be processed are rearranged in order of data size, and using an immediate value of an object code as an offset address to be added to the base address. And, if necessary, dividing a variable in a variable list into another group based on a relationship between the number of bits that can be taken by an immediate value of the object code and the number of bits of the offset address. 12. The computer-readable recording medium according to item 11.
【請求項18】 前記変数リストの変数を別のグループ
に分割する処理は、前記変数リスト中の変数をグループ
のベースアドレスを基点にデータサイズの小さいものか
ら順番に配置するとしたとき、ベースアドレスに対する
オフセットが前記オブジェクトコードの即値に基づいて
指定可能な範囲を超えることを条件に、当該変数を別の
グループに分割することを特徴とする請求項17記載の
コンピュータ読取り可能な記録媒体。
18. The process of dividing the variables in the variable list into different groups includes the step of arranging the variables in the variable list in ascending order of data size based on the base address of the group. 18. The computer-readable recording medium according to claim 17, wherein the variable is divided into another group on condition that the offset exceeds a range that can be specified based on the immediate value of the object code.
【請求項19】 前記オブジェクトコードは、参照する
データサイズに応じて即値を整数倍してベースアドレス
に加算する、即値のスケーリング機能を有することを特
徴とする請求項18記載のコンピュータ読取り可能な記
録媒体。
19. The computer-readable recording according to claim 18, wherein said object code has an immediate value scaling function of multiplying an immediate value by an integer according to a data size to be referenced and adding the result to a base address. Medium.
JP2000376956A 2000-12-12 2000-12-12 Compiling method and computer readable recording medium Withdrawn JP2002182926A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2000376956A JP2002182926A (en) 2000-12-12 2000-12-12 Compiling method and computer readable recording medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2000376956A JP2002182926A (en) 2000-12-12 2000-12-12 Compiling method and computer readable recording medium

Publications (1)

Publication Number Publication Date
JP2002182926A true JP2002182926A (en) 2002-06-28

Family

ID=18845739

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2000376956A Withdrawn JP2002182926A (en) 2000-12-12 2000-12-12 Compiling method and computer readable recording medium

Country Status (1)

Country Link
JP (1) JP2002182926A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005122506A (en) * 2003-10-17 2005-05-12 Matsushita Electric Ind Co Ltd Compiler device
US7971163B2 (en) 2008-02-28 2011-06-28 Nec Corporation Property generating apparatus, property generating method and program
JP2012014526A (en) * 2010-07-01 2012-01-19 Hitachi Ltd Structure conversion apparatus for program code, and code structure conversion program
JP2012038219A (en) * 2010-08-10 2012-02-23 Toshiba Corp Program conversion device and its program
WO2013050892A1 (en) * 2011-10-03 2013-04-11 International Business Machines Corporation Compiling code for enhanced application binary interface (abi) with decode time instruction optimization
US8607211B2 (en) 2011-10-03 2013-12-10 International Business Machines Corporation Linking code for an enhanced application binary interface (ABI) with decode time instruction optimization
US8713547B2 (en) 2011-10-03 2014-04-29 International Business Machines Corporation Generating compiled code that indicates register liveness

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005122506A (en) * 2003-10-17 2005-05-12 Matsushita Electric Ind Co Ltd Compiler device
US7971163B2 (en) 2008-02-28 2011-06-28 Nec Corporation Property generating apparatus, property generating method and program
JP2012014526A (en) * 2010-07-01 2012-01-19 Hitachi Ltd Structure conversion apparatus for program code, and code structure conversion program
JP2012038219A (en) * 2010-08-10 2012-02-23 Toshiba Corp Program conversion device and its program
WO2013050892A1 (en) * 2011-10-03 2013-04-11 International Business Machines Corporation Compiling code for enhanced application binary interface (abi) with decode time instruction optimization
US8607211B2 (en) 2011-10-03 2013-12-10 International Business Machines Corporation Linking code for an enhanced application binary interface (ABI) with decode time instruction optimization
US8612959B2 (en) 2011-10-03 2013-12-17 International Business Machines Corporation Linking code for an enhanced application binary interface (ABI) with decode time instruction optimization
US8615745B2 (en) 2011-10-03 2013-12-24 International Business Machines Corporation Compiling code for an enhanced application binary interface (ABI) with decode time instruction optimization
US8615746B2 (en) 2011-10-03 2013-12-24 International Business Machines Corporation Compiling code for an enhanced application binary interface (ABI) with decode time instruction optimization
US8713547B2 (en) 2011-10-03 2014-04-29 International Business Machines Corporation Generating compiled code that indicates register liveness
CN103858100A (en) * 2011-10-03 2014-06-11 国际商业机器公司 Compiling code for enhanced application binary interface (ABI) with decode time instruction optimization
US8756591B2 (en) 2011-10-03 2014-06-17 International Business Machines Corporation Generating compiled code that indicates register liveness
GB2509438A (en) * 2011-10-03 2014-07-02 Ibm Compiling code for enhanced application binary interface (abi) with decode time instruction optimization
GB2509438B (en) * 2011-10-03 2015-09-09 Ibm Compiling code for enhanced application binary interface (abi) with decode time instruction optimization
CN103858100B (en) * 2011-10-03 2017-02-15 国际商业机器公司 System and method for optimizing compilation of code for enhancing application binary interface

Similar Documents

Publication Publication Date Title
US8166450B2 (en) Methods and apparatus for compiling instructions for a data processor
US7707566B2 (en) Software development infrastructure
US5339238A (en) Register usage tracking in translating code for different machine architectures by forward and reverse tracing through the program flow graph
US5307492A (en) Mapping assembly language argument list references in translating code for different machine architectures
JP3602857B2 (en) Multi-model compatible information processing system and method
US5301325A (en) Use of stack depth to identify architechture and calling standard dependencies in machine code
EP1280056B1 (en) Generation of debugging information
JP5851396B2 (en) Processing method
KR100643268B1 (en) Method for improving performance of Java virtual machine and system employing the method
US7530061B2 (en) Programmatic access to the widest mode floating-point arithmetic supported by a processor
IE920749A1 (en) Automatic flowgraph generation for program analysis and¹translation
JP2004280795A (en) Extreme pipeline and optimization/rearrangement technique
US7320121B2 (en) Computer-implemented system and method for generating embedded code to add functionality to a user application
US20070271553A1 (en) Method and system for translating assembler code to a target language
US5822591A (en) Virtual code system
JPH10269082A (en) System, method and device for executing directly archtecture-indpendent binary program
CN107408054B (en) Method and computer readable medium for flow control in a device
Bothner A GCC-based Java implementation
JP2002182926A (en) Compiling method and computer readable recording medium
US20080104372A1 (en) Method, apparatus and computer program for executing a program
JP2002229778A (en) Pc relative branching method with high-speed displacement
US8438549B1 (en) Data processing with microcode designed with source coding
EP0735464A1 (en) Method and apparatus for computer code processing in a code translator
US20090319994A1 (en) System for debugging computer program
JP2002182925A (en) Compiling method and computer readable recording medium

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