JP2003157176A - Compiler, its memory area allocation method, and its program - Google Patents

Compiler, its memory area allocation method, and its program

Info

Publication number
JP2003157176A
JP2003157176A JP2001356204A JP2001356204A JP2003157176A JP 2003157176 A JP2003157176 A JP 2003157176A JP 2001356204 A JP2001356204 A JP 2001356204A JP 2001356204 A JP2001356204 A JP 2001356204A JP 2003157176 A JP2003157176 A JP 2003157176A
Authority
JP
Japan
Prior art keywords
item
alignment
memory
allocating
embedding
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
JP2001356204A
Other languages
Japanese (ja)
Inventor
Shuichi Nasu
秀一 那須
Shinji Hirai
真二 平井
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.)
Renesas Micro Systems Co Ltd
Original Assignee
Renesas Micro Systems Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Renesas Micro Systems Co Ltd filed Critical Renesas Micro Systems Co Ltd
Priority to JP2001356204A priority Critical patent/JP2003157176A/en
Publication of JP2003157176A publication Critical patent/JP2003157176A/en
Withdrawn legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PROBLEM TO BE SOLVED: To reduce a memory area for memory allocation of a compiler. SOLUTION: A memory optimization and allocation means is constituted of a control means 11 for controlling an entire system, a memory allocation means 12 for allocating variable items on a memory, a maximum alignment item acquisition means 13 for acquiring the variable item of the maximum alignment out of items to be allocated, and a filling item acquisition means 16 for acquiring a variable item for filling up an empty area at occurrence of the empty area. The maximum alignment item acquisition means 13 is provided with an alignment determination process 14 for acquiring alignment values of variable items and an item acquisition process 15 for acquiring items to be allocated. The filling item acquisition means 16 is provided with a structure body member backward close location process 17 for locating members of a structure body backward closely in order from the member of the largest alignment and the alignment determination process 14 for acquiring alignment values of variable items.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【発明の属する技術分野】本発明は、コンパイラ、その
記憶領域割り付け方法およびそのプログラムに係わり、
特にプログラミング言語などにおいて宣言される変数や
構造体のメモリ配置を行うコンパイラ技術、すなわち一
般的に記憶領域割り付けと呼ばれる技術のコンパイラ、
その記憶領域割り付け方法およびそのプログラムに関す
るものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a compiler, a storage area allocation method thereof, and a program thereof,
In particular, compiler technology for allocating memory for variables and structures declared in programming languages, that is, a compiler of technology generally called storage area allocation,
The present invention relates to the storage area allocation method and the program.

【0002】[0002]

【従来の技術】半導体素子の微細化の進展に伴い、半導
体素子で構成されるマイクロコンピュータの機能も複雑
かつ、大規模化し、家電製品を始めパーソナルコンピュ
ータやコピー機等のOA関連機器、あるいは工業用ロボ
ットや自動化生産設備等に広く利用されている。
2. Description of the Related Art With the progress of miniaturization of semiconductor devices, the functions of microcomputers composed of semiconductor devices have become complicated and large-scaled, and home appliances, OA-related equipment such as personal computers and copy machines, or industrial equipment. It is widely used in robots and automated production equipment.

【0003】これらの機器に応用されるマイクロコンピ
ュータを搭載するマイコン応用製品開発も仕様の複雑化
とともにプログラム容量も増大し、開発時間の増大とな
って現れている。
Development of a microcomputer application product equipped with a microcomputer applied to these devices has been accompanied by an increase in development time as the specifications are complicated and the program capacity is increased.

【0004】しかし、市場の要求に応えるためには短時
間で、複雑化したプログラム開発に対処しなければなら
ず効率的なマイコン開発支援ツールが必要となる。
However, in order to meet market demands, complicated program development must be dealt with in a short time, and an efficient microcomputer development support tool is required.

【0005】プログラム、すなわちソフト開発はコーデ
ィング、アセンブル、およびデバッグを繰り返し行って
完成するが、コーディング終了後、ホストマシンのエデ
ィタを用いてソース・プログラムを作成し、その後ソー
ス・プログラムのアセンブルを行う。
A program, that is, software development is completed by repeatedly coding, assembling, and debugging. After the coding is completed, a source program is created using an editor of the host machine, and then the source program is assembled.

【0006】アセンブル結果にエラーがあれば、再びエ
ディタでエラー箇所を修正し、アセンブルを行う処理の
繰り返しでエラーを取り除いた後に、デバッグ処理を行
う。このデバッグにはインサーキット・エミュレータ等
のデバッガを使用し、プログラムの流れ、割り込みや入
出力の非同期関係の検証を行った後、プログラムをライ
タを用いて不揮発性半導体メモリに書き込み、評価ツー
ルに搭載した実際のマイクロコンピュータを動作させな
がらデバッグを行っている。
If there is an error in the assemble result, the error location is corrected again by the editor, the error is removed by repeating the assembly process, and then the debug process is performed. For this debugging, a debugger such as an in-circuit emulator is used to verify the flow of the program and the asynchronous relationship between interrupts and input / output, and then the program is written to the nonvolatile semiconductor memory using the writer and installed in the evaluation tool. I am debugging while operating the actual microcomputer.

【0007】上述したプログラム、つまり、プログラミ
ング言語は、機械語、アッセンブラ言語、高級言語の区
別があり、機械語はコンピュータが直接理解できる言語
で、コンピュータの種類に依存し、人間が理解すること
は非常に困難である。
The above-mentioned program, that is, the programming language has a distinction between a machine language, an assembler language, and a high-level language. The machine language is a language that can be directly understood by a computer. Very difficult.

【0008】アッセンブラ言語も機械語と同様にコンピ
ュータの種類に依存するが、人間が理解できるようにコ
ンピュータの命令が対応する単語になっている。
Like the machine language, the assembler language depends on the type of computer, but the instructions of the computer correspond to the words for human understanding.

【0009】それに対して高級言語というものは、基本
的にはコンピュータの種類には依存せず、高級言語でか
かれたプログラムは、コンピュータに合ったコンパイラ
を使用すればどのコンピュータでも実行することができ
るものである。
On the other hand, a high-level language basically does not depend on the type of computer, and a program written in a high-level language can be executed on any computer by using a compiler suitable for the computer. It is a thing.

【0010】通常、高級言語は、高級言語ソースプログ
ラム→コンパイラ→中間言語→リンカ→機械語のように
して機械語に変換される。
Generally, a high-level language is converted into a machine language as in a high-level language source program → compiler → intermediate language → linker → machine language.

【0011】すなわち、高級言語、いわゆるソース・コ
ードはコンパイラ・プログラムによってアセンブリ言語
に変換される。このアセンブリ言語はオブジェクト・コ
ードと呼ばれる2進形式のコードでコンピュータに所望
の処理を実行させるための機械語である。
That is, a high-level language, so-called source code is converted into an assembly language by a compiler program. This assembly language is a machine code for causing a computer to execute a desired process with a binary code called an object code.

【0012】高級言語であるC言語では、文字列の定数
はメモリー上に固定の文字列が示す番地が値であり、定
数に対して変数もメモリー上に可変の値があり、その値
が変数の値である。
In C, which is a high-level language, a constant of a character string has a value at an address indicated by a fixed character string in memory, and a variable has a variable value in memory for the constant. Is the value of.

【0013】C言語で扱える整数の変数には、1バイ
ト、2バイト、4バイト、8バイトのバイト数を使用す
る。これらをC言語では次の様に表現する。
The number of bytes of 1 byte, 2 bytes, 4 bytes, and 8 bytes is used as an integer variable that can be handled in the C language. These are expressed in C language as follows.

【0014】charは符号ありの1バイトの整数の変
数、unsigned charは符号なしの1バイト
の整数の変数、shortは符号ありの2バイトの整数
の変数、unsigned shortは符号なしの2
バイトの整数の変数、intは符号ありの2または4バ
イトの整数の変数、unsigned intは符号な
しの2または4バイトの整数の変数、longは符号あ
りの4または8バイトの整数の変数、unsigned
longは符号なしの4または8バイトの整数の変数
である。
Char is a signed 1-byte integer variable, unsigned char is an unsigned 1-byte integer variable, short is a signed 2-byte integer variable, and unsigned short is an unsigned 2
Byte integer variable, int is a signed 2 or 4 byte integer variable, unsigned int is an unsigned 2 or 4 byte integer variable, long is a signed 4 or 8 byte integer variable, unsigned
long is an unsigned 4- or 8-byte integer variable.

【0015】すなわち、変数などをメモリに配置する
時、ハードウェアのメモリアクセスの制限により、変数
の大きさによって配置する位置に制限がある場合があ
る。例えば2バイト変数(short)の場合、2で割
り切れるアドレスに配置する(2バイトアライメントと
呼ぶ)。
That is, when arranging variables and the like in the memory, there are cases in which there is a limit in the position where they are arranged depending on the size of the variables due to memory access restrictions of the hardware. For example, in the case of a 2-byte variable (short), it is arranged at an address divisible by 2 (called 2-byte alignment).

【0016】同様に、4バイト変数(long)の場合
は、4で割り切れるアドレスに配置する(4バイトアラ
イメントと呼ぶ)。1バイト変数(char)は任意の
アドレスに配置できる。
Similarly, in the case of a 4-byte variable (long), it is arranged at an address divisible by 4 (called 4-byte alignment). The 1-byte variable (char) can be placed at any address.

【0017】変数宣言をしてメモリ割り付けを行う一例
が特開平9−212369号公報に記載されている。同
公報記載のメモリ割り付けの説明を容易にするための、
変数宣言例1を以下に示す。
An example of declaring variables and allocating memory is described in Japanese Patent Laid-Open No. 9-212369. To facilitate the explanation of the memory allocation described in the publication,
Variable declaration example 1 is shown below.

【0018】 char c1; short s1; char c2; この変数宣言例1を参照すると、この変数宣言では、c
har c1,short s1,char c2があ
り、合わせて3つの変数である。2個のcharのうち
1つ目の変数charは1バイト変数c1、2つ目の変
数charも1バイト変数c2、変数shortは2バ
イト変数s1である。
Char c1; short s1; char c2; Referring to this variable declaration example 1, in this variable declaration, c
There are har c1, short s1, and char c2, which are three variables in total. Of the two chars, the first variable char is a 1-byte variable c1, the second variable char is also a 1-byte variable c2, and the variable short is a 2-byte variable s1.

【0019】上述した変数のメモリ割り付け例を示した
図7を参照すると、例えばアドレスXX00に1バイト
変数c1、アドレスXX01は空き、XX02にバイト
変数s1、XX04に1バイト変数c2の順に割り付け
る。つまり、2バイト変数s1は2バイトアライメント
の位置に配置されるため、変数s1の前のアドレスXX
01に1バイトの空き領域(ギャップ)が出来ることに
なる。
Referring to FIG. 7 showing an example of memory allocation of the above variables, for example, a 1-byte variable c1 is allocated to address XX00, an address XX01 is empty, a byte variable s1 is allocated to XX02, and a 1-byte variable c2 is allocated to XX04. That is, since the 2-byte variable s1 is arranged at the position of 2-byte alignment, the address XX before the variable s1 is set.
01 will have a free area (gap) of 1 byte.

【0020】また、変数宣言例2を以下に示す。A variable declaration example 2 is shown below.

【0021】 この変数宣言例2を参照すると、この変数宣言では1つ
の構造体(struct)xxと2つの変数がある。構
造体xxの変数としてshort s1,char c
1がある。他に変数short s2,char c2
があり、合わせて3つの変数である。
[0021] Referring to this variable declaration example 2, this variable declaration has one structure (struct) xx and two variables. Short s1, char c as variables of structure xx
There is one. Other variables short s2, char c2
There are three variables in total.

【0022】2個のcharのうち1つ目の変数cha
rは1バイト変数c1、2つ目の変数charは1バイ
ト変数c2、2個のshortのうち1つ目の変数sh
ortは2バイト変数s1、2つ目の変数shortも
2バイト変数s2である。
The first variable cha of the two chars
r is a 1-byte variable c1, the second variable char is a 1-byte variable c2, and the first variable sh of the two shorts
ort is a 2-byte variable s1, and the second variable short is also a 2-byte variable s2.

【0023】1つめの構造体xxは2バイト変数s1と
1バイト変数c1を有し、次に2バイト変数s2と1バ
イト変数c2がある。
The first structure xx has a 2-byte variable s1 and a 1-byte variable c1, followed by a 2-byte variable s2 and a 1-byte variable c2.

【0024】これをメモリに割り付けた結果を示した図
12を参照すると、構造体xx、2バイト変数s2、1
バイト変数c2の順に割り付けるが、2バイト変数s2
は2バイトアライメントの位置に配置されるため例えば
アドレスXX04〜05となり、変数s2の前のアドレ
スXX03に1バイトの空き領域が出来る。
Referring to FIG. 12 showing the result of allocating this to the memory, the structure xx, the 2-byte variables s2, 1
Byte variable c2 is allocated in order, but 2 byte variable s2
Is located at a 2-byte alignment position, for example, addresses XX04 to 05, and a free area of 1 byte is created at address XX03 before variable s2.

【0025】このように変数領域を宣言されたままの順
番で確保すると、アライメントのため空き領域が出来て
しまう場合がある。
If the variable areas are secured in the order in which they are declared in this way, an empty area may be created due to alignment.

【0026】この空き領域の発生を避けるために上述し
た特開平9−212369号公報の従来技術では、変数
のアライメントでの「ソート」と「穴埋め」、例えば、
変数をアライメントの大きい順に「ソート」して配置
し、空き領域が生じる場合はその空き領域に割り付け可
能な項目を割り付けて「穴埋め」することで空き領域を
無くしている。
In order to avoid the occurrence of this empty area, in the prior art of Japanese Patent Laid-Open No. 9-212369 mentioned above, "sort" and "fill in" in the alignment of variables, for example,
Variables are arranged by "sorting" in descending order of alignment, and when a free space is created, the free space is eliminated by allocating items that can be allocated to the free space and "filling in".

【0027】従来のコンパイラの構成の一例を示した図
8を参照すると、コンパイラは全体の制御を行う制御処
理手段21と、プリプロセス処理手段22と、ソース解
析手段23と、メモリ最適化配置手段24と、コード生
成手段25とから構成されている。
Referring to FIG. 8 showing an example of the configuration of a conventional compiler, the compiler has a control processing means 21 for performing overall control, a preprocessing processing means 22, a source analysis means 23, and a memory optimizing arrangement means. 24 and code generation means 25.

【0028】プリプロセス処理手段22は、コンパイル
対象のソースプログラムを入力するソースプログラム入
力手段221と、“#”から始まるプリプロセス式に対
する展開処理を行う定義/条件式展開手段222とを備
えている。
The preprocess processing means 22 is provided with a source program input means 221 for inputting a source program to be compiled and a definition / conditional expression expanding means 222 for expanding a preprocess expression starting from "#". .

【0029】ソース解析手段23は、ソースプログラム
を、数字、演算式、変数等のトークンに分解する字句解
析手段231と、分解されたトークンを式として構築す
る構文解析手段232とを備えている。
The source analysis means 23 comprises a lexical analysis means 231 for decomposing the source program into tokens such as numbers, arithmetic expressions, variables, etc., and a syntax analysis means 232 for constructing the decomposed tokens as expressions.

【0030】コード生成手段25は、最適化処理まで終
わったプログラムをオブジェクトコードに変換するオブ
ジェクトコード生成手段251と、結果をプログラムと
して出力するオブジェクトプログラム出力手段252と
を備えている。
The code generation means 25 is provided with an object code generation means 251 for converting the program that has been subjected to the optimization processing into an object code, and an object program output means 252 for outputting the result as a program.

【0031】上述したコンパイラにおいて、ソースプロ
グラムはプリプロセス処理手段22によってプリプロセ
ス式の展開処理が行われ、ソース解析手段23によって
ソースプログラムが式に分解され、メモリ最適化配置手
段24によってメモリへの割り付けが行われ、コード生
成手段25によって各式に対応したオブジェクトコード
が生成され、ソースプログラムのコンパイル処理は完了
する。
In the above-mentioned compiler, the source program is processed by the preprocess processing means 22 to expand the preprocessed expression, the source analysis means 23 decomposes the source program into expressions, and the memory optimizing and arranging means 24 stores them in the memory. Allocation is performed, the object code corresponding to each expression is generated by the code generation means 25, and the compilation process of the source program is completed.

【0032】上述した従来技術のメモリ最適化配置手段
24の構成を本発明のコンパイラの構成に対比させて示
した示した図9を参照すると、全体の制御を行う制御手
段31と、項目をメモリ上に配置するメモリ割り付け手
段32と、割り付けすべき項目のなかから最大アライメ
ントの項目を取得する最大アライメント項目取得手段3
3と、空き領域が発生した時に空き領域を埋める項目を
取得する埋め込み用項目取得手段36とから構成されて
いる。
Referring to FIG. 9 which shows the structure of the above-mentioned conventional memory optimizing and arranging means 24 in comparison with the structure of the compiler of the present invention, the control means 31 for controlling the whole and the memory for the items. The memory allocation means 32 arranged above and the maximum alignment item acquisition means 3 for acquiring the maximum alignment item from the items to be allocated.
3 and an embedding item acquisition unit 36 that acquires an item for filling the empty area when the empty area occurs.

【0033】最大アライメント項目取得手段33は、項
目のアライメント値を取得するアライメント判定処理3
4と、割り付けすべき項目を取得する項目取得処理35
を備えている。
The maximum alignment item acquisition means 33 is an alignment determination process 3 for acquiring the alignment value of the item.
4 and item acquisition processing 35 for acquiring the items to be allocated
Is equipped with.

【0034】最大アライメント項目取得手段33によっ
て取得した項目が、メモリ割り付け手段32によって順
次、メモリ上に割り付けられていく。その際、メモリに
空き領域が生じる場合は、埋め込み用項目取得手段36
を使用し、空き領域の穴(埋め込み穴)に一致する項目
を検索し、該当するものがあればその項目を割り付ける
ことでことで空き領域を無くしている。
The items acquired by the maximum alignment item acquisition means 33 are sequentially allocated on the memory by the memory allocation means 32. At that time, if there is an empty area in the memory, the embedded item acquisition unit 36
To search for an item that matches a hole (embedded hole) in the empty area, and if there is a corresponding item, allocate that item to eliminate the empty area.

【0035】次に、上述したコンパイラの全体の動作説
明用のフローチャートを示した図10を参照すると、割
り付け項目がなくなるまで、最大アライメント項目取得
手段33を用いて最大アライメント項目を取得し(ステ
ップC11およびステップC12)、メモリ割り付け手
段32を用いてその項目を割り付ける(ステップC1
3)。
Next, referring to FIG. 10 which is a flow chart for explaining the overall operation of the above-mentioned compiler, the maximum alignment item acquisition means 33 is used to acquire the maximum alignment item until there are no more allocation items (step C11). And step C12), the item is allocated using the memory allocation means 32 (step C1).
3).

【0036】アライメントのため空き領域が生じる場
合、埋め込みが必要であると判断され(ステップC1
4)、埋め込み用項目取得手段36を用いて、埋め込み
穴に割り付けできる最大アライメント項目を取得し(ス
テップC15)、割り付け可能な項目がある場合は、メ
モリ割り付け手段32を用いてその項目を割り付ける
(ステップC17)。一致するものがなければその空き
領域に対する埋め込みは行わずに次へ進む。
If there is a free area due to alignment, it is judged that embedding is necessary (step C1).
4) Using the embedding item acquisition unit 36, the maximum alignment item that can be allocated to the embedding hole is acquired (step C15). If there is an allocable item, the memory allocation unit 32 is used to allocate the item (Step C15). Step C17). If there is no match, the empty area is not embedded and the process proceeds to the next step.

【0037】以上の処理を割り付け項目がなくなるまで
繰り返す。
The above processing is repeated until there are no more allocation items.

【0038】次に具体例を用いて従来技術の動作を説明
する。前述した図8、図9および前述した変数宣言例1
の最適化を示した図11を参照すると、変数を割り付け
る場合、割り付け項目がなくなるまで最大アライメント
の項目を取得し(ステップC11およびステップC1
2)その項目を割り付けている(ステップC13)。
Next, the operation of the prior art will be described using a specific example. 8 and 9 described above and the variable declaration example 1 described above.
Referring to FIG. 11 showing the optimization of, when variables are allocated, items of maximum alignment are acquired until there are no allocation items (step C11 and step C1).
2) The item is assigned (step C13).

【0039】その結果、図11示すように、アライメン
トの大きい変数s1が先頭に割り付けられ、その下位ア
ドレスに変数c1、変数c2が割り付けられるため、空
き領域は生じない。これは「ソート」の処理が効果を生
じた例である。
As a result, as shown in FIG. 11, the variable s1 having a large alignment is allocated to the head, and the variables c1 and c2 are allocated to the lower addresses, so that no empty area is generated. This is an example of the effect of the "sort" process.

【0040】一方、前述した変数宣言例2およびその割
り付け結果を示した図12および穴埋めによる最適化を
示した図13を参照すると、変数宣言例2を割り付ける
場合、アライメントの大きいものから順番に、まず、構
造体xxを割り付ける。なお、構造体xxは1つの項目
として扱い、構造体の変数のうち最大のアライメントの
ものをその構造体のアライメントとみなす。
On the other hand, referring to FIG. 12 showing the above-mentioned variable declaration example 2 and its allocation result and FIG. 13 showing the optimization by padding, when allocating the variable declaration example 2, from the one with the largest alignment, First, the structure xx is allocated. The structure xx is treated as one item, and the variable with the largest alignment among the variables of the structure is regarded as the alignment of the structure.

【0041】したがって、構造体xxはサイズは3バイ
トで、アライメントは2バイトとみなしている。次に変
数s2を構造体xxの下位アドレスに配置するが、変数
s2は2バイトアライメントであるので、その前のアド
レスに1バイトの空きが生じてしまう。
Therefore, the structure xx is considered to have a size of 3 bytes and an alignment of 2 bytes. Next, the variable s2 is arranged at the lower address of the structure xx, but since the variable s2 has 2-byte alignment, there is a space of 1 byte at the previous address.

【0042】そのため、埋め込みが必要であると判断さ
れ(ステップC14)、埋め込み穴に割り付けできる最
大アライメント項目を得る処理(ステップC15)に進
み、割り付け可能な項目として、変数c2が得られ、図
13に示すようにその項目がメモリに割り付けられる
(ステップC17)。そのため、空き領域は生じない。
Therefore, it is judged that the embedding is necessary (step C14), the process proceeds to the process of obtaining the maximum alignment item that can be assigned to the embedding hole (step C15), and the variable c2 is obtained as the assignable item. The item is allocated to the memory as shown in (step C17). Therefore, there is no free area.

【0043】これは「穴埋め」の処理が効果を生じた例
である。
This is an example in which the "fill-in" processing has produced an effect.

【0044】[0044]

【発明が解決しようとする課題】上述した従来のコンパ
イラは、次のような問題点があった。すなわち、さらに
他の変数宣言例3を次に示す。この変数宣言例3および
その割り付け例を示した図14を併せて参照しながら割
り付け処理を説明する。
The conventional compiler described above has the following problems. That is, still another variable declaration example 3 is shown below. The allocation process will be described with reference to FIG. 14 showing this variable declaration example 3 and its allocation example.

【0045】 この例では2つの構造体xxおよびyyと1つの変数l
ongがあり、1つめの構造体xxは4バイト変数lo
1と1バイト変数c1を有し、次に単独で変数4バイト
変数lo2があり、2つめの構造体yyは2バイト変数
s1と1バイト変数c2を有する。
[0045] In this example, two structures xx and yy and one variable l
and the first structure xx is a 4-byte variable lo.
It has a 1 and a 1 byte variable c1, then independently a variable 4 byte variable lo2, and a second structure yy has a 2 byte variable s1 and a 1 byte variable c2.

【0046】構造体xxのアライメントは4バイトであ
り、構造体yyのアライメントは2バイトとなる。
The alignment of the structure xx is 4 bytes, and the alignment of the structure yy is 2 bytes.

【0047】これをメモリ割り付けする場合、アライメ
ントが大きいものから順に割り付けるため、図14に示
すように、構造体xxをアドレスXX00〜04に割り
付け、次に変数lo2を例えばアドレスXX08〜11
に割り付ける。
When the memory is allocated, the structures are allocated in order from the largest alignment. Therefore, as shown in FIG. 14, the structure xx is allocated to the addresses XX00 to 04, and then the variable lo2 is allocated to the addresses XX08 to 11, for example.
Assign to.

【0048】この時、変数lo2は4バイトアライメン
トであるので、その前のアドレスXX05〜07に3バ
イトの空きを生じる。このため、埋め込みが必要と判断
され(ステップC14)、埋め込み穴に割り付けできる
最大アライメント項目を得る処理(ステップC15)に
分岐するが、埋めることのできる変数が無いため、空き
を埋めることができず、空き領域が生じてしまうという
問題が起こる。
At this time, since the variable lo2 has a 4-byte alignment, a space of 3 bytes is generated at the address XX05 to 07 in front of it. Therefore, it is determined that the embedding is necessary (step C14), and the process branches to the process of obtaining the maximum alignment item that can be assigned to the embedding hole (step C15), but there is no variable that can be filled, and therefore the space cannot be filled. However, there is a problem that free space will be created.

【0049】なお、ここで空き領域を埋める変数の候補
としては構造体yyがある。構造体yyはサイズが3バ
イトでアライメントは2バイトとみなされる。構造体y
yは空き領域とサイズが一致しているが空き領域のアド
レスは奇数番地アドレスXX05であり、2バイトアラ
イメントである構造体yyとはアライメントが一致せず
配置できない。
Here, the structure yy is a candidate for a variable for filling the empty area. The structure yy is considered to have a size of 3 bytes and an alignment of 2 bytes. Structure y
Although y has the same size as the empty area, the address of the empty area is an odd address XX05, and the alignment does not match the structure yy, which is a 2-byte alignment, and cannot be arranged.

【0050】本発明の目的は、上述した従来の欠点に鑑
みなされたものであり、構造体のバイト変数をアライメ
ントの大きいものから順に下位アドレスに詰めて配置す
る後詰め配列の構造体として配置して、コンパイラのメ
モリ割り付けにおけるメモリ領域を削減することにあ
る。
The object of the present invention has been made in view of the above-mentioned conventional drawbacks, in which byte variables of a structure are arranged as a structure of a rear-justified array in which lower byte addresses are arranged in descending order of alignment. To reduce the memory area in the memory allocation of the compiler.

【0051】[0051]

【課題を解決するための手段】本発明のコンパイラの記
憶領域割り付け方法は、プログラミング言語において宣
言される変数や複数のデータが1つのかたまりとして集
合化された構造体を記憶媒体に配置するコンパイラの記
憶領域割り付け時に、1バイト変数および2以上のバイ
ト変数からなる前記構造体をアライメントの制約上配置
できない空き領域であるギャップに対し、前記構造体の
バイト変数をアライメントの大きいものから順に下位ア
ドレスに詰めて配置する後詰め配列の構造体として配置
することを特徴とする。
A storage area allocation method for a compiler according to the present invention is a method for allocating a structure in which variables and a plurality of data declared in a programming language are collected into a storage medium in a storage medium. When allocating a storage area, the byte variables of the structure are assigned to lower addresses in order from the one with the largest alignment to the gap, which is an empty area in which the structure consisting of one byte variable and two or more byte variables cannot be placed due to alignment restrictions. It is characterized in that it is arranged as a structure of a left-justified array that is packed and arranged.

【0052】また、前記後詰め配列の構造体はアライメ
ント位置から先頭位置までにギャップを有し、前記ギャ
ップを上位アドレスの他の構造体の番地にオーバラップ
させ、空き番地が生じないように順次に前記後詰め配列
の構造体を配置することができる。
Further, the structure of the rear-justified array has a gap from the alignment position to the head position, and the gap is overlapped with the address of another structure of the upper address so as not to generate a vacant address. The stuffing arrangement structure can be placed in

【0053】さらに、前記ギャップを上位アドレスの他
の構造体の番地にオーバラップさせる配置を、複数の後
詰め配列の構造体それぞれに適用することもできる。
Further, the arrangement in which the gap is overlapped with the addresses of the other structures of the higher address can be applied to each of the structures of a plurality of right-justified arrangements.

【0054】さらにまた、前記後詰め配列の構造体の配
置は、先に最大アライメントの項目を配置した後に生じ
る前記空き領域に対して実施することもできる。
Furthermore, the arrangement of the structure of the left-justified arrangement can be carried out in the empty area generated after the maximum alignment item is arranged first.

【0055】また、最大アライメントを配置した次のア
ドレスに空き領域が生じた場合、その空き領域のアライ
メントに対して、残りの変数のうち配値出来る最大アラ
イメントがあれば配置し、無ければ残りの変数のうち構
造体メンバを後詰めにしたものを配置し、前記構造体メ
ンバを後詰めにしたものも無いときは残りの変数のうち
最大アライメントをそれぞれ配置することができる。
Further, when a free area is generated at the address next to the position where the maximum alignment is arranged, if there is a maximum alignment that can be assigned a value among the remaining variables with respect to the alignment of the free area, it is arranged. It is possible to arrange the variables with the structure members being left-justified, and to arrange the maximum alignment among the remaining variables when there is no variable with the structure members being left-justified.

【0056】さらに、前記構造体を後詰めにするか否か
の決定をコンパイラの割り付け手段で自動的に行わせる
こともできる。
Further, the allocating means of the compiler can automatically determine whether or not the structure is left-justified.

【0057】さらにまた、前記構造体を後詰めにするか
否かの決定を操作者が構造体ごとに指定することもでき
る。
Furthermore, the operator can also specify for each structure whether or not the structure is to be left-justified.

【0058】また、前記構造体の後詰めを操作者が構造
体ごとに指定する際に、#pragmaで始まる宣言文
で指定することもできる。
When the operator specifies the justification of the structure for each structure, it can be specified by a declaration statement starting with #pragma.

【0059】本発明のコンパイラの記憶領域割り付け方
法の他の特徴は、割り付けすべき項目の中から最大アラ
イメント項目を取得する最大アライメント項目取得手段
と、前記項目をメモリ上に配置するメモリ割り付け手段
と、メモリの空き領域を埋める項目を取得する埋め込み
用項目取得手段とを備え、割り付け項目がなくなるま
で、前記最大アライメント項目取得手段を用いて最大ア
ライメント項目を取得するステップと、取得した項目を
前記メモリ割り付け手段を用いて割り付けるステップ
と、アライメントのために空き領域が生じる場合、埋め
込みが必要であると判断するステップと、前記埋め込み
用項目取得手段を用いて、前記空き領域の埋め込み穴に
割り付けできる最大アライメント項目を取得するステッ
プと、割り付け可能な項目がある場合は、前記メモリ割
り付け手段を用いてその項目を割り付けるステップと、
割り付け可能な項目がない場合は、構造体メンバ後詰め
処理により構造体メンバを後詰めにしたものが前記埋め
込み穴に割り付けできる最大アライメント項目を取得す
るステップと、割り付け可能な項目がある場合は、前記
メモリ割り付け手段を用いてその項目を割り付けるステ
ップと、一致するものがなければその空き領域に対する
埋め込みは行わずに次へ進むステップと、を割り付け項
目がなくなるまで繰り返すことにある。
Another feature of the storage area allocation method of the compiler of the present invention is the maximum alignment item acquisition means for acquiring the maximum alignment item from the items to be allocated, and the memory allocation means for arranging the items on the memory. A step of acquiring a maximum alignment item using the maximum alignment item acquisition means until the allocation item is exhausted, and the acquired item is stored in the memory. The step of allocating using the allocating means, the step of deciding that embedding is necessary when a vacant area occurs due to alignment, and the maximum that can be allocated to the embedding hole of the vacant area using the embedding item acquisition means. Steps to get alignment items and assignable If an eye includes the steps of assigning the item using the memory allocation unit,
If there is no allocatable item, the step of obtaining the maximum alignment item that can be allocated to the embedded hole by the structure member justified by the structure member justification process, and if there is an allocatable item, The step of allocating the item using the memory allocating means and the step of proceeding to the next without embedding in the empty area if there is no match are repeated until there are no allocated items.

【0060】本発明のコンパイラの記憶領域割り付け方
法のまた他の特徴は、割り付けすべき項目の中から最大
アライメント項目を取得する最大アライメント項目取得
手段と、前記項目をメモリ上に配置するメモリ割り付け
手段と、メモリの空き領域を埋める項目を取得する埋め
込み用項目取得手段とを備え、割り付け項目がなくなる
まで、前記最大アライメント項目取得手段を用いて最大
アライメント項目を探すステップと、前記項目がありか
つアライメントのために生じた空き領域に埋め込みが必
要であるか判断するステップと、埋め込みが必要なけれ
ば取得した項目を前記メモリ割り付け手段を用いて割り
付けるステップと、埋め込みが必要なとき割り付けを行
わずにアライメントのみに注目して次の使用可能アドレ
スに割り付けできる最も大きいアライメントの項目を探
すステップと、該当する項目があるかを判断するステッ
プと、該当する項目がある場合はその項目を割り付け、
該当する項目がない場合は構造体の変数を後詰めにした
もので、かつ最も大きいアライメント項目を探すステッ
プと、割り付け可能な項目がある場合はその項目を割り
付け、該当する項目がない場合は前記最大アライメント
項目を探すステップで取得していた項目を割り付けるス
テップと、を割り付け項目がなくなるまで繰り返すこと
にある。
Still another feature of the storage area allocation method of the compiler of the present invention is the maximum alignment item acquisition means for acquiring the maximum alignment item from the items to be allocated, and the memory allocation means for arranging the item on the memory. A step of searching for a maximum alignment item using the maximum alignment item acquisition means until the allocation items are exhausted, and an embedded item acquisition means for acquiring an item that fills an empty area of the memory; For deciding whether or not it is necessary to embed in the empty area generated due to, the step of allocating the acquired item using the memory allocating means if the embedding is not necessary, and the alignment without allocation when the embedding is necessary. Can be assigned to the next available address Allocation and step to find the item of highest alignment, and determining if there is a corresponding item, if there is no such item the item,
If there is no applicable item, the variable of the structure is justified, and the step of searching for the largest alignment item, and if there is an assignable item, that item is assigned. If there is no applicable item, the above item is assigned. The step of allocating the item acquired in the step of searching for the maximum alignment item is repeated until there are no more allocation items.

【0061】本発明のコンパイラは、プログラミング言
語において宣言される変数や複数のデータが1つのかた
まりとして集合化された構造体を記憶媒体に配置するコ
ンパイラの記憶領域割り付け時に、1バイト変数および
2以上のバイト変数からなる前記構造体をアライメント
の制約上配置できない空き領域であるギャップに対し、
前記構造体を前記1バイト変数の下位アドレスに前記2
以上のバイト変数が置かれる後詰め配列の構造体として
配置する機能を有することにある。
The compiler of the present invention allocates a variable declared in a programming language and a structure in which a plurality of data are aggregated as one block to a storage medium when allocating a storage area of the compiler. For the gap which is an empty area where the structure consisting of byte variables of can not be placed due to alignment restrictions,
The structure is set to the lower address of the 1-byte variable, and the 2
It has a function of arranging it as a structure of a left-justified array in which the above byte variables are placed.

【0062】本発明のコンパイラの他の特徴は、全体の
制御を行う制御処理手段で制御され、プログラミング言
語において宣言される変数や構造体のメモリ配置を行う
メモリ最適化配置手段を備えるコンパイラにおいて、前
記メモリ最適化配置手段は、メモリに割り付けすべき項
目をメモリ上に配置するメモリ割り付け手段と、項目の
アライメント値を取得する第1のアライメント判定処理
機能と、割り付けすべき項目を取得する項目取得処理機
能とを有し前記項目の中から最大アライメントの項目を
取得する最大アライメント項目取得手段と、メモリの空
き領域であるギャップが発生したときに前記空き領域を
埋める項目を取得する埋め込み用項目取得手段とを備
え、前記埋め込み用項目取得手段は、前記構造体の変数
をアライメントが大きいものから、かつ前記構造体を構
成する1バイト変数の下位アドレスに2以上のバイト変
数が置かれる後詰めにより配置する構造体メンバ後詰め
処理機能と前記項目のアライメント値を取得する第2の
アライメント判定処理機能とを備えることにある。
Another feature of the compiler of the present invention is that the compiler is equipped with a memory optimizing arrangement means for allocating memory of variables and structures which are controlled by a control processing means for controlling the whole and are declared in a programming language. The memory optimizing and arranging means arranges an item to be allocated in the memory on the memory, a first alignment determination processing function for acquiring an alignment value of the item, and an item acquisition for acquiring an item to be allocated. A maximum alignment item acquisition unit that has a processing function and that acquires an item of maximum alignment from the items, and an item for embedding that acquires an item that fills the empty region when a gap that is a free region of memory occurs. The embedded item acquisition means has a large alignment of the variables of the structure. A second structure for arranging two or more byte variables at the lower address of the one-byte variable that constitutes the structure, and arranging the structure members by the justification function and the alignment value of the item. And an alignment determination processing function.

【0063】また、前後詰め配列の記構造体はアライメ
ント位置から先頭位置までにギャップを有し、前記ギャ
ップを上位アドレスの他の構造体の番地にオーバラップ
させ、空き番地が生じないように順次に前記後詰め配列
の構造体を配置する機能を有することができる。
In addition, the storage structure of the front-back packed array has a gap from the alignment position to the head position, and the gap is overlapped with the address of another structure of the higher address so as not to generate a vacant address. Can have a function of arranging the structure of the rear-justified array.

【0064】さらに、前記ギャップを上位アドレスの他
の構造体の番地にオーバラップさせる配置を、複数の後
詰め配列の構造体それぞれに適用する機能を有すること
もできる。
Further, it is possible to have a function of applying the arrangement in which the gap is overlapped with the addresses of other structures of the upper address to each of the structures of the rear-justified arrangement.

【0065】さらにまた、前記後詰め配列の構造体の配
置は、先に最大アライメントの項目を配置した後に生じ
る前記空き領域に対して実施する機能を有することもで
きる。
Furthermore, the arrangement of the structure of the left-justified array can have a function of performing the empty area generated after the item of maximum alignment is arranged first.

【0066】また、前記構造体メンバ後詰め処理機能に
よる前記後詰め配列の構造体の配置は、先に最大アライ
メントの項目を配置した後に生じる前記空き領域に対し
て実施する機能を有することもできる。
Further, the arrangement of the structure of the rearranged array by the structure member rearrangement processing function may have a function to be performed on the empty area generated after the maximum alignment item is arranged in advance. .

【0067】さらに、最大アライメントを配置した次の
アドレスに前記空き領域が生じた場合、その空き領域の
アライメントに対して、残りの変数のうち配値出来る最
大アライメントがあれば配置し、無ければ残りの変数の
うち構造体メンバを後詰めにしたものを配置し、前記構
造体メンバを後詰めにしたものも無いときは残りの変数
のうち最大アライメントをそれぞれ配置する機能を有す
ることもできる。
Further, when the empty area is generated at the address next to the area where the maximum alignment is arranged, if there is a maximum alignment that can be assigned a value among the remaining variables, the empty area is arranged, and if there is not, the remaining area remains. It is also possible to have a function of arranging the variables of which the structure members are left-justified, and of arranging the maximum alignment of the remaining variables when none of the variables is left-justified.

【0068】さらにまた、前記構造体を後詰めにするか
否かの決定または前記構造体メンバ後詰め処理機能を自
動的に行わせるコンパイラの割り付け手段を有すること
もできる。
Furthermore, it is also possible to have a compiler allocating means for determining whether or not the structure should be left-justified or automatically performing the structure member right-justification processing function.

【0069】また、前記構造体を後詰めにするか否かの
決定を操作者が構造体ごとに指定する機能を有すること
もできる。
It is also possible to have a function for the operator to specify, for each structure, whether or not the structure should be rearranged.

【0070】さらに、前記構造体の後詰めを操作者が構
造体ごとに指定する際に、#pragmaで始まる宣言
文で指定する機能を有することもできる。
Furthermore, when the operator specifies the justification of the structures for each structure, the operator can have a function of specifying the declaration with a declaration statement starting with #pragma.

【0071】本発明のコンパイラのまた他の特徴は、割
り付けすべき項目の中から最大アライメント項目を取得
する最大アライメント項目取得手段と、前記項目をメモ
リ上に配置するメモリ割り付け手段と、メモリの空き領
域を埋める項目を取得する埋め込み用項目取得手段とを
備え、割り付け項目がなくなるまで、前記最大アライメ
ント項目取得手段を用いて最大アライメント項目を取得
する機能と、取得した項目を前記メモリ割り付け手段を
用いて割り付ける機能と、アライメントのために空き領
域が生じる場合、埋め込みが必要であると判断する機能
と、前記埋め込み用項目取得手段を用いて、前記空き領
域の埋め込み穴に割り付けできる最大アライメント項目
を取得する機能と、割り付け可能な項目がある場合は、
前記メモリ割り付け手段を用いてその項目を割り付ける
機能と、割り付け可能な項目がない場合は、構造体メン
バ後詰め処理により構造体メンバを後詰めにしたものが
前記埋め込み穴に割り付けできる最大アライメント項目
を取得する機能と、割り付け可能な項目がある場合は、
前記メモリ割り付け手段を用いてその項目を割り付ける
機能と、一致するものがなければその空き領域に対する
埋め込みは行わずに次へ進む機能とを備えることにあ
る。
Still another feature of the compiler of the present invention is that the maximum alignment item acquiring means for acquiring the maximum alignment item from the items to be allocated, the memory allocating means for arranging the item on the memory, and the free memory space. An embedding item acquisition unit that acquires an item that fills the area is provided, and a function that acquires the maximum alignment item using the maximum alignment item acquisition unit until the allocation item runs out and the acquired item using the memory allocation unit And a function to determine that embedding is necessary when a free area is created due to alignment, and the maximum alignment item that can be allocated to the embedding hole in the empty area is acquired using the embedding item acquisition means. Function and the items that can be assigned,
The function to allocate the item using the memory allocation means, and if there is no item that can be allocated, the maximum alignment item that can be allocated to the embedding hole is the one that the structure member is left-justified by the structure member last-justification process. If there is a function to acquire and an item that can be assigned,
It is provided with a function of allocating the item using the memory allocating means and a function of proceeding to the next without embedding in the empty area if there is no coincidence.

【0072】本発明のコンパイラのさらに他の特徴は、
割り付けすべき項目の中から最大アライメント項目を取
得する最大アライメント項目取得手段と、前記項目をメ
モリ上に配置するメモリ割り付け手段と、メモリの空き
領域を埋める項目を取得する埋め込み用項目取得手段と
を備え、割り付け項目がなくなるまで、前記最大アライ
メント項目取得手段を用いて最大アライメント項目を探
す機能と、前記項目がありかつアライメントのために生
じた空き領域に埋め込みが必要であるか判断する機能
と、埋め込みが必要なければ取得した項目を前記メモリ
割り付け手段を用いて割り付ける機能と、埋め込みが必
要なとき割り付けを行わずにアライメントのみに注目し
て次の使用可能アドレスに割り付けできる最も大きいア
ライメントの項目を探す機能と、該当する項目があるか
を判断する機能と、該当する項目がある場合はその項目
を割り付け、該当する項目がない場合は構造体の変数を
後詰めにしたもので、かつ最も大きいアライメント項目
を探す機能と、割り付け可能な項目がある場合はその項
目を割り付け、該当する項目がない場合は前記最大アラ
イメント項目を探す機能で取得していた項目を割り付け
る機能とを備えることにある。
Still another feature of the compiler of the present invention is that
A maximum alignment item acquisition unit that acquires a maximum alignment item from the items to be allocated, a memory allocation unit that arranges the item on a memory, and an embedding item acquisition unit that acquires an item that fills a free space in the memory. A function of searching for the maximum alignment item using the maximum alignment item acquisition means until the allocation items are exhausted, and a function of determining whether or not there is an item and a blank area created for alignment needs to be embedded. If there is no need for embedding, the function that allocates the acquired items using the memory allocating means, and when the embedding is necessary, paying attention only to the alignment without allocating the item with the largest alignment that can be allocated to the next usable address A function to search and a function to judge whether there is a corresponding item, If there is a corresponding item, that item is allocated, if there is no applicable item, it is a structure variable that is justified, and the function to search for the largest alignment item, and if there is an item that can be allocated, There is a function of allocating an item and a function of allocating an item acquired by the function of searching the maximum alignment item when there is no corresponding item.

【0073】[0073]

【発明の実施の形態】先ず本発明の概要を述べると、プ
ログラミング言語などで宣言されている順番のとおりに
メモリへ割り付けを行うと、アライメントのために空き
領域が生じる場合がある。それを防ぐために従来は、変
数をアライメントの大きさで「ソート」した順番で配置
したり、空き領域にその領域に合う大きさの変数を「穴
埋め」するなどの処理を行っていた。
BEST MODE FOR CARRYING OUT THE INVENTION First, the outline of the present invention will be described. When allocation is performed in a memory in the order declared in a programming language or the like, a free area may be generated for alignment. In order to prevent this, conventionally, processes such as arranging variables in the order of being “sorted” according to the size of the alignment or “filling in” a variable of a size that fits that region in an empty area have been performed.

【0074】本発明では、これに加え、構造体の要素
(メンバ)を、後詰めに配置し、さらにその構造体をア
ライメント+ギャップの位置に配置することにより、ア
ライメントの制約があって配置できなかった場所にも配
置することを可能にし、その結果空き領域の発生を減少
させ、メモリの使用量を減少させることができる。
In the present invention, in addition to this, by arranging the elements (members) of the structure in a left-justified manner, and further arranging the structure in the position of alignment + gap, the structure can be arranged with alignment restrictions. It is also possible to place it in a place where it did not exist, and as a result, it is possible to reduce the occurrence of a free area and reduce the memory usage.

【0075】ここで言う後詰めとは、アライメントの大
きいものから順に下位アドレスに詰めて配置することを
指し、本発明の特徴でもある。
The term "justified" means that the lower addresses are arranged in order from the one having the larger alignment, which is also a feature of the present invention.

【0076】次に本発明の第1の実施の形態を図面を参
照しながら詳細に説明する。
Next, a first embodiment of the present invention will be described in detail with reference to the drawings.

【0077】図1は本発明の第1の実施の形態のコンパ
イラにおけるメモリ最適化配置手段のプログラム構成図
であり、第2図は本発明の第1の実施の形態におけるメ
モリ割り付け方法を示すフローチャートである。
FIG. 1 is a program configuration diagram of the memory optimizing and arranging means in the compiler according to the first embodiment of the present invention, and FIG. 2 is a flow chart showing a memory allocation method according to the first embodiment of the present invention. Is.

【0078】図1を参照すると、本発明のメモリ最適化
配置手段は、全体の制御を行う制御手段11と、変数項
目をメモリ上に配置するメモリ割り付け手段12と、割
り付けすべき項目のなかから最大アライメントの変数項
目を取得する最大アライメント項目取得手段13と、空
き領域が発生した時に空き領域を埋める変数項目を取得
する埋め込み用項目取得手段16とから構成されてい
る。
Referring to FIG. 1, the memory optimizing and arranging means of the present invention includes a control means 11 for performing overall control, a memory allocating means 12 for arranging variable items on a memory, and an item to be allocated. It comprises maximum alignment item acquisition means 13 for acquiring a variable item of maximum alignment, and embedding item acquisition means 16 for acquiring a variable item for filling a free area when a free area occurs.

【0079】最大アライメント項目取得手段13は、変
数項目のアライメント値を取得するアライメント判定処
理14と、割り付けすべき項目を取得する項目取得処理
15とを備えている。
The maximum alignment item acquisition means 13 comprises an alignment determination process 14 for acquiring the alignment value of the variable item and an item acquisition process 15 for acquiring the item to be assigned.

【0080】埋め込み用項目取得手段16は、構造体の
メンバをアライメントが大きいものから後詰めに配置す
る構造体メンバ後詰め処理17と、変数項目のアライメ
ント値を取得するアライメント判定処理18とを備えて
いる。
The embedding item acquisition means 16 is provided with a structure member rearrangement process 17 for arranging the members of the structure from the one with the largest alignment to the rearmost, and an alignment determination process 18 for acquiring the alignment value of the variable item. ing.

【0081】この割り付け方式において、最大アライメ
ント項目取得手段13によって取得した変数項目が、メ
モリ割り付け手段12によって順次、メモリ上に割り付
けられていく。
In this allocation method, the variable items acquired by the maximum alignment item acquisition means 13 are sequentially allocated on the memory by the memory allocation means 12.

【0082】その際、メモリに空き領域が生じる場合
は、埋め込み用項目取得手段16によって埋め込み用の
変数項目を取得し、その変数項目を割り付ける。
At this time, if an empty area is created in the memory, the embedding item acquisition means 16 acquires a variable item for embedding and allocates the variable item.

【0083】埋め込み用項目取得手段16では、まず埋
め込み穴に一致する項目を検索し、得られなかった場合
は、構造体メンバ後詰め処理17により構造体のメンバ
を後詰にしたものから埋め込み穴に一致するものを検索
する。
The embedding item acquisition means 16 first searches for an item that matches the embedding hole, and if no item is obtained, the structure member squeezing process 17 shifts the structure member from the slashed member to the embedding hole. Search for a match.

【0084】埋め込み穴に一致するものを検索した結
果、該当するものがあればその変数項目を割り付けるこ
とで空き領域を無くし、メモリ使用量を削減することを
可能にしている。
As a result of searching for a match with the embedding hole, if there is a corresponding one, the variable item is allocated to eliminate the empty area and reduce the memory usage.

【0085】次に、本実施の形態における全体の動作を
詳細に説明する。
Next, the overall operation of this embodiment will be described in detail.

【0086】図1および図2を参照すると、まず、変数
宣言に基づき、その割り付け項目がなくなるまで、最大
アライメント項目取得手段13を用いて最大アライメン
ト項目を取得する(ステップA11およびステップA1
2)。
Referring to FIGS. 1 and 2, first, based on the variable declaration, the maximum alignment item acquisition means 13 is used to acquire the maximum alignment item until there are no more allocated items (steps A11 and A1).
2).

【0087】メモリ割り付け手段12を用いてその変数
項目を割り付ける(ステップA13)。アライメントの
ため空き領域が生じる場合、埋め込みが必要であると判
断される(ステップA14)。
The memory allocation means 12 is used to allocate the variable item (step A13). When an empty area is generated due to alignment, it is determined that embedding is necessary (step A14).

【0088】埋め込みが必要であるため、埋め込み用項
目取得手段16を用いて、埋め込み穴に割り付けできる
最大アライメント項目を取得する(ステップA15)。
Since embedding is necessary, the embedding item acquisition means 16 is used to acquire the maximum alignment item that can be assigned to the embedding hole (step A15).

【0089】割り付け可能な変数項目がある場合は、メ
モリ割り付け手段12を用いてその割り付け可能な変数
項目を割り付ける(ステップA17)。
If there is a variable item that can be allocated, the memory allocation means 12 is used to allocate the variable item that can be allocated (step A17).

【0090】割り付け可能な変数項目がない場合は、構
造体メンバ後詰め処理17を用いて構造体メンバを後詰
めにしたものを埋め込み穴に割り付けるため、割り付け
できる最大アライメント項目を探し取得する(ステップ
A18)。
If there is no variable item that can be allocated, the structure member rearrangement processing 17 is used to allocate the structure member which is rearranged to the embedding hole, so the maximum alignment item that can be allocated is searched and acquired (step A18).

【0091】割り付け可能な最大アライメント項目があ
る場合は、メモリ割り付け手段12を用いてその項目を
割り付ける(ステップA19,ステップA17)。
If there is a maximum alignment item that can be allocated, that item is allocated using the memory allocation means 12 (step A19, step A17).

【0092】割り付け可能な最大アライメント項目がな
ければその空き領域に対する埋め込みは行わずに次へ進
む。以上の処理を割り付け項目がなくなるまで繰り返
す。
If there is no maximum allocatable alignment item, the empty area is not embedded and the process proceeds to the next step. The above processing is repeated until there are no more allocation items.

【0093】次に具体例を用いて第1の実施の形態の動
作を説明する。
Next, the operation of the first embodiment will be described using a specific example.

【0094】以下に示した変数宣言例3と、その変数宣
言例3のメモリ割り付けを示した図3を参照すると、変
数宣言例3のメモリ割り付け途中経過を示した図3
(a)、構造体yyのメンバの後詰め結果を示した図3
(b)および割り付け結果を示した図3(c)とを併せ
て参照しながら、この宣言をメモリに割り付ける場合に
ついて割り付け手順を説明する。
Referring to FIG. 3 showing the variable declaration example 3 and the memory allocation of the variable declaration example 3 shown below, FIG.
(A), FIG. 3 showing the result of the justification of the members of the structure yy.
The allocation procedure for allocating this declaration to the memory will be described with reference to (b) and FIG. 3C showing the allocation result.

【0095】 先ず最大アライメントの構造体xx(メンバlo1,c
1)を探し、あれば取得し(ステップA11)、メモリ
アドレスXX00〜04に配置する(ステップA1
3)。
[0095] First, the maximum alignment structure xx (members lo1, c
1) is searched for, if any is obtained (step A11), it is arranged at memory addresses XX00-04 (step A1).
3).

【0096】次に同じアライメント数をもつ変数lo2
を取得し(ステップA11)、メモリアドレスXX08
〜11に配置する(ステップA13)。ここで、変数l
o2は4バイトアライメントであるので、図3(a)に
示すように、その前のアドレスXX05〜07に3バイ
トの空き領域が生じる。
Next, a variable lo2 having the same alignment number
Is obtained (step A11), and the memory address XX08
To 11 (step A13). Where the variable l
Since o2 is a 4-byte alignment, as shown in FIG. 3 (a), a 3-byte empty area is generated at the address XX05-07 before it.

【0097】そこで、埋め込みが必要と判断され(ステ
ップA14)、埋め込み穴に割り付けできる最大アライ
メント項目を探して得る処理(ステップA15)に分岐
するが、この埋め込み穴に該当するものは見つからな
い。
Then, it is judged that the embedding is necessary (step A14), and the process branches to a process (step A15) in which the maximum alignment item that can be assigned to the embedding hole is obtained, but the one corresponding to this embedding hole cannot be found.

【0098】そこで構造体メンバを後詰めにしたものが
埋め込み穴に割り付けできる最大アライメント項目を得
る処理(ステップA18)へ分岐する。残っている構造
体yyの変数を後詰めにすると、図3(b)に示すよう
に1バイト変数c2が上位アドレス、例えばXX05
に、2バイト変数s1が下位アドレス、例えばXX06
に配置される。
Therefore, the process branches to the process (step A18) of obtaining the maximum alignment item which can be assigned to the embedding hole by the structure members which are justified. When the remaining variables of the structure yy are left-justified, the 1-byte variable c2 is assigned a higher address, for example, XX05, as shown in FIG.
2 byte variable s1 is a lower address, for example XX06
Is located in.

【0099】この構造体は2バイトアライメントである
が、アライメント位置から構造体の先頭のメンバc2ま
でに1バイトのギャップが生じる。ギャップが生じる場
合、構造体を配置する位置をアライメント数+ギャップ
の数の位置とみなす。
Although this structure has a 2-byte alignment, a gap of 1 byte occurs from the alignment position to the first member c2 of the structure. When a gap occurs, the position where the structure is arranged is regarded as the position of (alignment number) + (gap number).

【0100】したがってこの場合、2バイトアライメン
ト+1バイトの位置、つまり奇数番地を構造体の配置位
置とみなす。そのため埋め込み穴に一致する。したがっ
て構造体yyを埋め込み項目と判断し、項目を割り付け
る処理(ステップA17)で割り付けを行う。
Therefore, in this case, the position of 2 byte alignment + 1 byte, that is, the odd address is regarded as the arrangement position of the structure. Therefore, it matches the embedded hole. Therefore, the structure yy is determined as an embedded item, and the item is allocated in the process of allocating the item (step A17).

【0101】その結果、図3(c)の割り付け結果に示
すように、例えばアドレスXX00〜04に構造体xx
が配置され、アドレスXX05〜07に構造体yyが配
置され、アドレスXX08〜11に4バイト変数lo2
がそれぞれ配置される。
As a result, as shown in the allocation result of FIG. 3C, for example, the structure xx is assigned to the addresses XX00-04.
Is placed, the structure yy is placed at addresses XX05 to 07, and the 4-byte variable lo2 is placed at addresses XX08 to 11.
Are arranged respectively.

【0102】すなわち、空き領域は生じず、メモリ使用
量の削減が行える。
That is, there is no free area, and the amount of memory used can be reduced.

【0103】上述したように、従来は15バイトであっ
た領域が12バイトに削減できた例であり、このような
構造体変数が多数存在する場合はその個数分だけ領域削
減の効果がある。
As described above, this is an example in which the area of 15 bytes in the past can be reduced to 12 bytes, and when there are many such structure variables, there is an effect of reducing the area by that number.

【0104】また、この発明の適用により領域の使用量
が多く(悪く)なることは無く、比較的簡単な処理の追
加で効果が得られる。
Further, the application of the present invention does not increase (deteriorate) the usage of the area, and the effect can be obtained by adding a relatively simple process.

【0105】次に第2の実施の形態を説明する。第2の
実施の形態におけるメモリ割り付け方法のフローチャー
トを示した図4を参照して説明する。
Next, a second embodiment will be described. Description will be made with reference to FIG. 4 showing a flowchart of a memory allocation method according to the second embodiment.

【0106】上述した第1の実施の実施の形態では、ま
ず最大アライメントの項目を取得し、取得した項目を割
り当ててから、埋め込みが必要か判断し、埋め込み穴に
適当な項目を埋め込みを行っていた。
In the first embodiment described above, the item of maximum alignment is first acquired, the acquired item is assigned, then it is judged whether embedding is necessary, and an appropriate item is embedded in the embedding hole. It was

【0107】しかし、この方式では、埋め込み穴の大き
さが固定されてしまい、それより大きな項目は埋め込む
ことが出来ない。構造体のメンバを後詰めにしてアライ
メントの点では配置することが可能になっても穴の大き
さが足りなくて配置できなくなる場合がある。
However, in this method, the size of the embedding hole is fixed, and items larger than that size cannot be embedded. Even if it becomes possible to arrange the members of the structure in a rearward-aligned manner in terms of alignment, there are cases in which the holes cannot be arranged due to the insufficient size of the holes.

【0108】そのようなことを防ぐため、第2の実施の
形態では、まず、変数宣言に基づき、その割り付け項目
がなくなるまで、最大アライメント項目取得手段13を
用いて最大アライメント項目を取得する(ステップB1
1およびステップB12)。
In order to prevent such a situation, in the second embodiment, first, based on the variable declaration, the maximum alignment item acquisition means 13 is used to acquire the maximum alignment item until there are no more allocated items (step). B1
1 and step B12).

【0109】ここで、第1の実施の形態ではメモリ割り
付け手段12を用いてその変数項目を割り付けたが、こ
の第2の実施の形態では割り付けを行わずに、埋め込み
が必要か判断し(ステップB13)、埋め込みが必要で
なければ取得した項目を割り付け(ステップB14)、
埋め込みが必要と判断した場合、次の使用可能アドレス
に割り付け出来る最大アライメント項目を検索する処理
に移行する(ステップB15)。
Here, in the first embodiment, the variable items are allocated by using the memory allocating means 12, but in the second embodiment, it is judged whether the embedding is necessary without performing the allocation (step B13), if the embedding is not necessary, the acquired item is allocated (step B14),
When it is determined that the embedding is necessary, the process shifts to a process of searching for the maximum alignment item that can be assigned to the next available address (step B15).

【0110】この処理では、埋め込み穴の大きさではな
くアライメントのみに注目して配置できる最も大きいア
ライメントの項目を取得する。該当する項目がない場合
は、構造体メンバを後詰めにしたものを次の使用可能ア
ドレスに割り付けるために、最大アライメント項目を検
索する(ステップB18)。ここでも、穴埋めではない
ので項目そのものの大きさの制限はない。
In this process, the largest alignment item that can be arranged is obtained by paying attention only to the alignment, not the size of the embedding hole. If there is no corresponding item, the maximum alignment item is searched in order to allocate the structure member which is left-justified to the next available address (step B18). Again, there is no limit to the size of the item itself, as it is not a fill in.

【0111】割り付け可能な変数項目がある場合は、そ
の項目を割り付ける(ステップB17)。割り付け可能
な変数項目がない場合は、先の処理(ステップB11)
の最大アライメント項目を取得する処理で取得していた
項目を割り付ける(ステップB20)。
If there is a variable item that can be assigned, that item is assigned (step B17). If there is no variable item that can be assigned, the previous processing (step B11)
The item acquired in the process of acquiring the maximum alignment item is allocated (step B20).

【0112】次に、図4と、次に示す変数宣言例4と、
その変数宣言例4のメモリ割り付けを示した図5におけ
る変数宣言例4のメモリ割り付け途中経過を示した図5
(a)および割り付け結果を示した図5(b)を併せて
参照しながら、この宣言をメモリに割り付ける場合につ
いて割り付け手順を説明する。
Next, FIG. 4 and the following variable declaration example 4,
5 showing the memory allocation of the variable declaration example 4 and FIG. 5 showing the progress of memory allocation of the variable declaration example 4 in FIG.
The allocation procedure for allocating this declaration to the memory will be described with reference to (a) and FIG. 5B showing the allocation result.

【0113】 この変数宣言例4の宣言をメモリに割り付ける場合、上
述した第1の実施の形態では図5(a)に示すようにま
ず最大アライメントの構造体xxをアドレスXX00〜
04に配置し、次に同じアライメントの変数lo2をア
ドレスXX08〜11に配置する。
[0113] When allocating the declaration of the variable declaration example 4 to the memory, in the above-described first embodiment, first, the structure xx of the maximum alignment is set to the addresses XX00 to XX00 as shown in FIG.
04, and then the same alignment variable lo2 is allocated to addresses XX08-11.

【0114】ここで、変数lo2は4バイトアライメン
トであるので、その上位アドレスに3バイトの空き領域
が生じる。そこで、埋め込みが必要と判断されるが、残
っている構造体yyは、埋め込み穴よりサイズが大きい
ので埋め込み出来ない。
Here, since the variable lo2 has a 4-byte alignment, a 3-byte empty area is generated at its upper address. Therefore, it is determined that embedding is necessary, but the remaining structure yy cannot be embedded because it has a larger size than the embedding hole.

【0115】そこで埋め込みは行わずに変数lo2の下
位アドレスXX12〜16に構造体yyを配置し、図5
(b)に示すように、アドレスXX05〜07に3バイ
トの空きがある状態で配置されることになる。
Therefore, the structure yy is arranged at the lower addresses XX12 to 16 of the variable lo2 without performing the padding, and the structure shown in FIG.
As shown in (b), the addresses XX05 to 07 are arranged with a space of 3 bytes.

【0116】同じく変数宣言例4を、第2の実施の形態
で配置した場合について、図4と、割り付け途中経過1
を示した図6(a)と、構造体yyのメンバの後詰め結
果を示した図6(b)と、割り付け途中経過2を示した
図6(c)と、割り付け結果を示した図6(d)とを併
せて参照しながら割り付け手順を説明する。
Similarly, in the case where the variable declaration example 4 is arranged in the second embodiment, FIG.
6 (a) showing the result, FIG. 6 (b) showing the result of rearranging the members of the structure yy, FIG. 6 (c) showing the progress 2 of the allocation, and FIG. 6 showing the result of the allocation. The allocation procedure will be described with reference to FIG.

【0117】まず最大アライメントの構造体xxを取得
し(ステップB11)、アドレスXX00〜04に配置
する(ステップB14、図6(a))。次に同じアライ
メントの変数lo2を取得するが(ステップB11)、
変数lo2は4バイトアライメントであるので、配置す
るにはその前のアドレスに3バイトの空き領域が生じる
ので、埋め込みが必要と判断される(ステップB1
3)。
First, the structure xx with the maximum alignment is acquired (step B11), and is placed at addresses XX00-04 (step B14, FIG. 6A). Next, the variable lo2 of the same alignment is acquired (step B11),
Since the variable lo2 has a 4-byte alignment, a 3-byte empty area is generated at the address before the variable lo2 to be arranged, so it is determined that embedding is necessary (step B1).
3).

【0118】割り付けを行わずに、次の使用可能アドレ
スに割り付けできる最大アライメント項目を得る処理
(ステップB15)に移行する。次の使用可能アドレス
に割り付けできる最大アライメント項目を得る処理(ス
テップB15)では、次の使用可能アドレスに割り付け
できる項目を検索するが、残りの変数lo2と構造体y
yは、アライメントが大きくて割り付けできないと判断
される(ステップB16)。
Without allocating, the process proceeds to the process of obtaining the maximum alignment item that can be allocated to the next usable address (step B15). In the process of obtaining the maximum alignment item that can be assigned to the next available address (step B15), the item that can be assigned to the next available address is searched, but the remaining variable lo2 and structure y are searched.
It is determined that y cannot be assigned because the alignment is large (step B16).

【0119】構造体メンバを後詰めにしたものが次の使
用可能アドレスに割り付けできる最大アライメント項目
を得る処理(ステップB18)に分岐する。残りの項目
の構造体yyを後詰めすると図6(b)に示すように、
例えば先頭のアドレスXX04に1バイトのギャップが
生じ、2バイトアライメント+1バイトの位置、つまり
奇数番地が構造体の配置位置とみなされるため、配置可
能と判断される(ステップB19)。
The structure member which is left-justified is branched to the process (step B18) of obtaining the maximum alignment item which can be allocated to the next usable address. When the structure yy of the remaining items is left-justified, as shown in FIG.
For example, a gap of 1 byte occurs at the top address XX04, and a position of 2 bytes alignment + 1 byte, that is, an odd address is regarded as the arrangement position of the structure, so it is determined that the structure can be arranged (step B19).

【0120】この配置可能と判断される変数項目をアド
レスXX05〜09に配置する(ステップB17)。配
置した結果、図6(c)に示すように空きは生じない。
次に残りの変数lo2を配置して処理を終了する。
The variable items judged to be allocable are allocated to the addresses XX05 to 09 (step B17). As a result of the arrangement, there is no vacancy as shown in FIG.
Next, the remaining variable lo2 is arranged and the processing is terminated.

【0121】この方式により、アライメントが合致すれ
は埋め込み穴よりも大きな構造体も割付できるという利
点が生まれる。
This method has the advantage that even if the alignment is matched, a structure larger than the embedded hole can be allocated.

【0122】その結果、この第2の実施の形態において
も前述した第1の実施の形態と同様に、空き領域は生じ
ず、メモリ使用量の削減が行える。
As a result, in the second embodiment as well, similar to the first embodiment described above, there is no free area and the memory usage can be reduced.

【0123】また、このような構造体変数が多数存在す
る場合はその個数分だけ領域削減の効果がある。
When there are many such structure variables, there is an effect of reducing the area by the number.

【0124】さらに、この発明の適用により領域の使用
量が多く(悪く)なることは無く、比較的簡単な処理の
追加で効果が得られる。
Further, the application of the present invention does not increase (deteriorate) the usage of the area, and the effect can be obtained by adding a relatively simple process.

【0125】次に第3の実施の形態を説明する。Next, a third embodiment will be described.

【0126】前述した第1の実施の形態では、構造体を
後詰めにするかどうかの決定はコンパイラなどの割り付
け装置により自動的に行われている。しかし、本発明は
それに限定するものではなく、操作者が明示的にどの構
造体を後詰めにするかを指定することもできる。
In the above-described first embodiment, the allocation device such as the compiler automatically determines whether or not the structure is left-justified. However, the present invention is not so limited, and the operator can explicitly specify which structure is to be left-justified.

【0127】例えばソース中に#pragmaで始まる
次の宣言文の指定例を参照すると、 ソース中に#pragmaで始まる宣言文を書くことで
構造体のメンバの割り付けを後詰めにして行うという指
定ができるようにする。
For example, referring to the specification example of the following declaration statement starting with #pragma in the source, By writing a declaration statement that starts with #pragma in the source, it is possible to specify that the members of the structure will be allocated in a late order.

【0128】この例では、本来の構造体のアライメント
は2バイトであるが、後詰めにすることで1バイト変数
c2が先に、2バイト変数s1が後に配置され、奇数番
地に配置するという指定になる。
In this example, the alignment of the original structure is 2 bytes, but by rearranging, the 1-byte variable c2 is placed first, the 2-byte variable s1 is placed later, and it is placed at an odd address. become.

【0129】すなわち、ソース中に#pragmaで始
まる宣言文を書くことでこの第3の実施の形態において
も前述した第1の実施の形態と同様に、空き領域は生じ
ず、メモリ使用量の削減が行える。
That is, by writing a declaration statement starting with #pragma in the source, in the third embodiment also, as in the first embodiment described above, no empty area is generated and the memory usage is reduced. Can be done.

【0130】このような構造体変数が多数存在する場合
はその個数分だけ領域削減の効果がある。
When there are many such structure variables, there is an effect of reducing the area by the number.

【0131】また、この発明の適用により領域の使用量
が多く(悪く)なることは無く、比較的簡単な処理の追
加で効果が得られる。
Further, the application of the present invention does not increase (deteriorate) the usage of the area, and the effect can be obtained by adding a relatively simple process.

【0132】上述した実施の形態のうち第1および第2
の実施の形態では、それぞれ一例として、後詰め構造体
の配置を2バイトアライメント+1として説明したが、
4バイトアライメント+2のように複数のギャップを有
するケースにも対応できる。
First and second of the above-described embodiments
In the above embodiments, as an example, the arrangement of the left-justified structure has been described as the 2-byte alignment + 1.
It can also be applied to a case having a plurality of gaps such as 4-byte alignment + 2.

【0133】すなわち、後詰め配列の記構造体はアライ
メント位置から先頭位置までにギャップを有する。その
ギャップを上位アドレスに配置される他の構造体の番地
にオーバラップさせ、空き番地が生じないように順次に
後詰め配列の構造体を配置する。
That is, the write structure of the left-justified array has a gap from the alignment position to the head position. The gaps are overlapped with the addresses of other structures arranged at the higher address, and the structures of the rear-justified array are sequentially arranged so that no vacant addresses are generated.

【0134】なお、上述の「+」の後は必ずアライメン
トより小さい数になる。
The number after the above "+" is always smaller than the alignment.

【0135】例えば、2バイトアライメントの場合は、
「2バイトアライメント」、「2バイトアライメント+
1」となり、4バイトアライメントの場合は、「4バイ
トアライメント」、「4バイトアライメント+1」、
「4バイトアライメント+2」、「4バイトアライメン
ト+3」といったパタンがある。
For example, in the case of 2-byte alignment,
"2-byte alignment", "2-byte alignment +
1 ", and in the case of 4-byte alignment," 4 byte alignment "," 4 byte alignment + 1 ",
There are patterns such as "4 byte alignment +2" and "4 byte alignment +3".

【0136】[0136]

【発明の効果】上述したように、本発明のコンパイラ、
その記憶領域割り付け方法およびプログラムは、プログ
ラミング言語において宣言される変数や複数のデータが
1つのかたまりとして集合化された構造体を記憶媒体に
配置するコンパイラの記憶領域割り付け時に、1バイト
変数および2以上のバイト変数からなる構造体をアライ
メントの制約上配置できない空き領域に対し、構造体の
バイト変数をアライメントの大きいものから順に下位ア
ドレスに詰めて配置する後詰め配列の構造体として配置
するので、従来は15バイトであった領域が12バイト
に削減できる。構造体変数が多数存在する場合はその個
数分だけ領域削減の効果がある。
As described above, the compiler of the present invention,
The storage area allocating method and program use a 1-byte variable and two or more variables when allocating a storage area of a compiler that allocates a variable declared in a programming language and a structure in which a plurality of data are aggregated as one lump to a storage medium. Since the structure consisting of the byte variables of the above is arranged as a structure of a left-justified array in which the byte variables of the structure are packed in the lower addresses in order from the one with the largest alignment, to the empty area where the structure cannot be allocated due to alignment restrictions, The area that was 15 bytes can be reduced to 12 bytes. When there are many structure variables, there is an effect of reducing the area by the number.

【0137】また、この発明の適用により領域の使用量
が多く(悪く)なることは無く、比較的簡単な処理の追
加で効果が得られる。
Further, the application of the present invention does not increase (deteriorate) the amount of use of the area, and the effect can be obtained by adding a relatively simple process.

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

【図1】本発明の第1の実施の形態のコンパイラにおけ
るメモリ最適化配置手段のプログラム構成図である。
FIG. 1 is a program configuration diagram of a memory optimizing placement unit in a compiler according to a first embodiment of this invention.

【図2】第1の実施の形態におけるメモリ割り付け方法
を示すフローチャートである。
FIG. 2 is a flowchart showing a memory allocation method according to the first embodiment.

【図3】変数宣言例3のメモリ割り付けを示した図であ
る。
FIG. 3 is a diagram showing memory allocation in variable declaration example 3;

【図4】第2の実施の形態におけるメモリ割り付け方法
のフローチャートである。
FIG. 4 is a flowchart of a memory allocation method according to the second embodiment.

【図5】第1の実施の形態に変数宣言例4を適用したと
きの割り付けを示した図である。
FIG. 5 is a diagram showing allocation when a variable declaration example 4 is applied to the first exemplary embodiment.

【図6】第2の実施の形態に変数宣言例4を適用したと
きの割り付けを示す図である。
FIG. 6 is a diagram showing allocation when a variable declaration example 4 is applied to the second embodiment.

【図7】最適化を行わない場合の変数宣言例1の割り付
け結果を示す図である。
FIG. 7 is a diagram showing an allocation result of a variable declaration example 1 when optimization is not performed.

【図8】従来のコンパイラの一例の構成図である。FIG. 8 is a configuration diagram of an example of a conventional compiler.

【図9】従来技術のメモリ最適化配置手段24の構成図
である。
FIG. 9 is a block diagram of a conventional memory optimizing and arranging means 24.

【図10】従来のコンパイラの全体の動作説明用のフロ
ーチャートである。
FIG. 10 is a flowchart for explaining the overall operation of a conventional compiler.

【図11】並べ替えによる変数宣言例1の最適化を示す
図である。
FIG. 11 is a diagram showing optimization of variable declaration example 1 by rearrangement.

【図12】最適化を行わない場合の変数宣言例2の割り
付け結果を示す図である。
FIG. 12 is a diagram showing an allocation result of variable declaration example 2 when optimization is not performed.

【図13】穴埋めによる変数宣言例2の最適化を示す図
である。
FIG. 13 is a diagram showing optimization of variable declaration example 2 by padding.

【図14】変数宣言例3の割り付け結果を示す図であ
る。
FIG. 14 is a diagram showing an allocation result of variable declaration example 3;

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

11、31 制御手段 12、32 メモリ割り付け手段 13、33 最大アライメント項目取得手段 14、34 アライメント判定処理 15、35 項目取得処理 16、36 埋め込み用項目取得手段 17 構造体メンバ後詰め処理 18 アライメント判定処理 21 制御処理手段 22 プリプロセス処理手段 23 ソース解析手段 24 メモリ最適化配置手段 25 コード生成手段 11, 31 Control means 12, 32 memory allocation means 13, 33 Maximum alignment item acquisition means 14, 34 Alignment judgment processing 15, 35 item acquisition process 16, 36 Embedded item acquisition means 17 Structure member justification processing 18 Alignment judgment processing 21 Control processing means 22 Preprocessing means 23 Source Analysis Means 24 memory optimization placement means 25 Code generation means

フロントページの続き (72)発明者 平井 真二 神奈川県川崎市中原区小杉町一丁目403番 53 エヌイーシーマイクロシステム株式会 社内 Fターム(参考) 5B081 AA06 CC28 Continued front page    (72) Shinji Hirai, Inventor             1-403 Kosugi-cho, Nakahara-ku, Kawasaki-shi, Kanagawa             53 NC Micro Systems Stock Association             In-house F-term (reference) 5B081 AA06 CC28

Claims (24)

【特許請求の範囲】[Claims] 【請求項1】 プログラミング言語において宣言される
変数や複数のデータが1つのかたまりとして集合化され
た構造体を記憶媒体に配置するコンパイラの記憶領域割
り付け時に、1バイト変数および2以上のバイト変数か
らなる前記構造体をアライメントの制約上配置できない
空き領域であるギャップに対し、前記構造体のバイト変
数をアライメントの大きいものから順に下位アドレスに
詰めて配置する後詰め配列の構造体として配置すること
を特徴とするコンパイラの記憶領域割り付け方法。
1. When allocating a storage area of a compiler for allocating a variable declared in a programming language or a structure in which a plurality of data are aggregated as one lump in a storage medium, from a 1-byte variable and 2 or more byte variables For the gap, which is a free area where the structure cannot be placed due to the alignment constraint, the byte variables of the structure are arranged as a structure of a rear-justified array in which the byte variables of the structure are arranged in the lower addresses in order from the largest alignment. A method for allocating storage areas of a characteristic compiler.
【請求項2】 前記後詰め配列の構造体はアライメント
位置から先頭位置までにギャップを有し、前記ギャップ
を上位アドレスの他の構造体の番地にオーバラップさ
せ、空き番地が生じないように順次に前記後詰め配列の
構造体を配置する請求項1記載のコンパイラの記憶領域
割り付け方法。
2. The structure of the left-justified array has a gap from the alignment position to the head position, and the gap is overlapped with the address of another structure of the higher address so as to avoid a vacant address. The storage area allocating method for a compiler according to claim 1, wherein the structure of the rear-justified array is arranged in the.
【請求項3】 前記ギャップを上位アドレスの他の構造
体の番地にオーバラップさせる配置を、複数の後詰め配
列の構造体それぞれに適用する請求項2記載のコンパイ
ラの記憶領域割り付け方法。
3. A storage area allocating method for a compiler according to claim 2, wherein the arrangement for overlapping the gap with the address of another structure of the upper address is applied to each of a plurality of structures of a justified array.
【請求項4】 前記後詰め配列の構造体の配置は、先に
最大アライメントの項目を配置した後に生じる前記空き
領域に対して実施する請求項1、2または3記載のコン
パイラの記憶領域割り付け方法。
4. The method for allocating a storage area of a compiler according to claim 1, wherein the arrangement of the structure of the left-justified array is performed on the empty area generated after the item of maximum alignment is arranged first. .
【請求項5】 最大アライメントを配置した次のアドレ
スに空き領域が生じた場合、その空き領域のアライメン
トに対して、残りの変数のうち配値出来る最大アライメ
ントがあれば配置し、無ければ残りの変数のうち構造体
メンバを後詰めにしたものを配置し、前記構造体メンバ
を後詰めにしたものも無いときは残りの変数のうち最大
アライメントをそれぞれ配置する請求項1、2、3また
は4記載のコンパイラの記憶領域割り付け方法。
5. When an empty area is generated at the address next to the position where the maximum alignment is arranged, if there is a maximum alignment that can be assigned a value among the remaining variables to the alignment of the empty area, it is arranged. 5. A variable whose structure members are left-justified is arranged, and a maximum alignment is arranged among the remaining variables when there is no such structure member being left-justified, respectively. Storage area allocation method of the described compiler.
【請求項6】 前記構造体を後詰めにするか否かの決定
をコンパイラの割り付け手段で自動的に行わせる請求項
1,2,3,4または5記載のコンパイラの記憶領域割
り付け方法。
6. A storage area allocating method for a compiler according to claim 1, 2, 3, 4, or 5, wherein the allocating means of the compiler automatically determines whether or not the structure is left-justified.
【請求項7】 前記構造体を後詰めにするか否かの決定
を操作者が構造体ごとに指定する請求項1,2,3,4
または5記載のコンパイラの記憶領域割り付け方法。
7. The operator designates, for each structure, a decision as to whether or not the structure should be left-justified.
Or the storage area allocation method of the compiler described in 5.
【請求項8】 前記構造体の後詰めを操作者が構造体ご
とに指定する際に、#pragmaで始まる宣言文で指
定する請求項7記載のコンパイラの記憶領域割り付け方
法。
8. The storage area allocating method for a compiler according to claim 7, wherein when the operator specifies the justification of the structure for each structure, the operator specifies it by a declaration statement starting with #pragma.
【請求項9】 割り付けすべき項目の中から最大アライ
メント項目を取得する最大アライメント項目取得手段
と、前記項目をメモリ上に配置するメモリ割り付け手段
と、メモリの空き領域を埋める項目を取得する埋め込み
用項目取得手段とを備え、割り付け項目がなくなるま
で、前記最大アライメント項目取得手段を用いて最大ア
ライメント項目を取得するステップと、取得した項目を
前記メモリ割り付け手段を用いて割り付けるステップ
と、アライメントのために空き領域が生じる場合、埋め
込みが必要であると判断するステップと、前記埋め込み
用項目取得手段を用いて、前記空き領域の埋め込み穴に
割り付けできる最大アライメント項目を取得するステッ
プと、割り付け可能な項目がある場合は、前記メモリ割
り付け手段を用いてその項目を割り付けるステップと、
割り付け可能な項目がない場合は、構造体メンバ後詰め
処理により構造体メンバを後詰めにしたものが前記埋め
込み穴に割り付けできる最大アライメント項目を取得す
るステップと、割り付け可能な項目がある場合は、前記
メモリ割り付け手段を用いてその項目を割り付けるステ
ップと、一致するものがなければその空き領域に対する
埋め込みは行わずに次へ進むステップと、を割り付け項
目がなくなるまで繰り返すことを特徴とするコンパイラ
の記憶領域割り付け方法。
9. A maximum alignment item acquiring means for acquiring a maximum alignment item from among items to be allocated, a memory allocating means for arranging the item on a memory, and an embedding for acquiring an item for filling an empty area of the memory. And a step of acquiring a maximum alignment item by using the maximum alignment item acquisition means, a step of allocating the acquired item by using the memory allocation means, and alignment until there is no allocation item. When an empty area is generated, a step of determining that embedding is necessary, a step of using the embedding item acquisition means to obtain a maximum alignment item that can be allocated to the embedding hole of the empty area, and an item that can be allocated are If there is, use the memory allocation means to The steps of eye-catching,
If there is no allocatable item, the step of obtaining the maximum alignment item that can be allocated to the embedded hole by the structure member justified by the structure member justification process, and if there is an allocatable item, Memory of the compiler characterized by repeating the step of allocating the item using the memory allocating means and the step of proceeding to the next without embedding in the empty area if there is no match until the allocation item is exhausted. Area allocation method.
【請求項10】 割り付けすべき項目の中から最大アラ
イメント項目を取得する最大アライメント項目取得手段
と、前記項目をメモリ上に配置するメモリ割り付け手段
と、メモリの空き領域を埋める項目を取得する埋め込み
用項目取得手段とを備え、割り付け項目がなくなるま
で、前記最大アライメント項目取得手段を用いて最大ア
ライメント項目を探すステップと、前記項目がありかつ
アライメントのために生じた空き領域に埋め込みが必要
であるか判断するステップと、埋め込みが必要なければ
取得した項目を前記メモリ割り付け手段を用いて割り付
けるステップと、埋め込みが必要なとき割り付けを行わ
ずにアライメントのみに注目して次の使用可能アドレス
に割り付けできる最も大きいアライメントの項目を探す
ステップと、該当する項目があるかを判断するステップ
と、該当する項目がある場合はその項目を割り付け、該
当する項目がない場合は構造体の変数を後詰めにしたも
ので、かつ最も大きいアライメント項目を探すステップ
と、割り付け可能な項目がある場合はその項目を割り付
け、該当する項目がない場合は前記最大アライメント項
目を探すステップで取得していた項目を割り付けるステ
ップと、を割り付け項目がなくなるまで繰り返すことを
特徴とするコンパイラの記憶領域割り付け方法。
10. A maximum alignment item acquiring means for acquiring a maximum alignment item from among items to be allocated, a memory allocating means for arranging the item on a memory, and an embedding for acquiring an item for filling an empty area of the memory. And a step of searching for the maximum alignment item using the maximum alignment item acquisition means until the allocation items are exhausted, and whether or not it is necessary to embed in the empty area where the item exists and is created for alignment. The step of judging, the step of allocating the acquired item using the memory allocating means if the embedding is not necessary, and the step of allocating to the next usable address paying attention only to the alignment without allocating when the embedding is necessary Steps to find items with large alignment and applicable A step of determining whether there is an item, a step of allocating the item if there is a corresponding item, and a step of locating the variable of the structure after the item if there is no corresponding item and searching for the largest alignment item. If there is an item that can be allocated, that item is allocated, and if there is no applicable item, the step of allocating the item acquired in the step of finding the maximum alignment item is repeated until there are no allocated items. Storage area allocation method for the compiler
【請求項11】 プログラミング言語において宣言され
る変数や複数のデータが1つのかたまりとして集合化さ
れた構造体を記憶媒体に配置するコンパイラの記憶領域
割り付け時に、1バイト変数および2以上のバイト変数
からなる前記構造体をアライメントの制約上配置できな
い空き領域であるギャップに対し、前記構造体を前記1
バイト変数の下位アドレスに前記2以上のバイト変数が
置かれる後詰め配列の構造体として配置する機能を有す
ることを特徴とするコンパイラ。
11. When allocating a storage area of a compiler for allocating a variable declared in a programming language or a structure in which a plurality of data are aggregated as one lump in a storage medium, from a 1-byte variable and 2 or more byte variables. In the gap that is an empty area in which the structure cannot be placed due to alignment restrictions,
A compiler having a function of arranging as a structure of a left-justified array in which the two or more byte variables are placed at a lower address of a byte variable.
【請求項12】 全体の制御を行う制御処理手段で制御
され、プログラミング言語において宣言される変数や構
造体のメモリ配置を行うメモリ最適化配置手段を備える
コンパイラにおいて、前記メモリ最適化配置手段は、メ
モリに割り付けすべき項目をメモリ上に配置するメモリ
割り付け手段と、項目のアライメント値を取得する第1
のアライメント判定処理機能と、割り付けすべき項目を
取得する項目取得処理機能とを有し前記項目の中から最
大アライメントの項目を取得する最大アライメント項目
取得手段と、メモリの空き領域であるギャップが発生し
たときに前記空き領域を埋める項目を取得する埋め込み
用項目取得手段とを備え、前記埋め込み用項目取得手段
は、前記構造体の変数をアライメントが大きいものか
ら、かつ前記構造体を構成する1バイト変数の下位アド
レスに2以上のバイト変数が置かれる後詰めにより配置
する構造体メンバ後詰め処理機能と前記項目のアライメ
ント値を取得する第2のアライメント判定処理機能とを
備えることを特徴とするコンパイラ。
12. A compiler comprising memory optimizing allocation means for allocating memory of variables and structures controlled by a control processing means for controlling the whole and declared in a programming language, wherein the memory optimizing allocation means comprises: A memory allocating means for allocating an item to be allocated to a memory on the memory, and a first for acquiring an alignment value of the item
Alignment determination processing function and an item acquisition processing function that acquires an item to be allocated, and a maximum alignment item acquisition unit that acquires the item with the maximum alignment from the items, and a gap that is a free area of memory occurs. And an embedding item acquisition unit that acquires an item for filling the empty area, the embedding item acquisition unit having a variable of the structure having a large alignment and one byte forming the structure. A compiler having a structure member rearrangement processing function that arranges two or more byte variables at the lower address of a variable by rearrangement and a second alignment determination processing function that acquires the alignment value of the item. .
【請求項13】 前記後詰め配列の構造体はアライメン
ト位置から先頭位置までにギャップを有し、前記ギャッ
プを上位アドレスの他の構造体の番地にオーバラップさ
せ、空き番地が生じないように順次に前記後詰め配列の
構造体を配置する機能を有する請求項11または12記
載のコンパイラ。
13. The structure of the left-justified array has a gap from an alignment position to a leading position, and the gap is overlapped with an address of another structure of a higher address so as to avoid a vacant address. The compiler according to claim 11 or 12, which has a function of arranging the structure of the left-justified array in the.
【請求項14】 前記ギャップを上位アドレスの他の構
造体の番地にオーバラップさせる配置を、複数の後詰め
配列の構造体それぞれに適用する機能を有する請求項1
3記載のコンパイラ。
14. The arrangement having a function of applying an arrangement in which the gap overlaps an address of another structure of a high-order address to each structure of a plurality of right-justified arrangements.
The compiler according to 3.
【請求項15】 前記後詰め配列の構造体の配置は、先
に最大アライメントの項目を配置した後に生じる前記空
き領域に対して実施する機能を有する請求項11記載の
コンパイラ。
15. The compiler according to claim 11, wherein the arrangement of the structure of the left-justified array has a function of performing the empty area generated after the maximum alignment item is arranged first.
【請求項16】 前記構造体メンバ後詰め処理機能によ
る前記後詰め配列の構造体の配置は、先に最大アライメ
ントの項目を配置した後に生じる前記空き領域に対して
実施する機能を有する請求項12記載のコンパイラ。
16. The arrangement of the structure of the rearranged array by the structure member rearrangement processing function has a function of performing the empty area generated after the maximum alignment item is arranged first. The listed compiler.
【請求項17】 最大アライメントを配置した次のアド
レスに前記空き領域が生じた場合、その空き領域のアラ
イメントに対して、残りの変数のうち配値出来る最大ア
ライメントがあれば配置し、無ければ残りの変数のうち
構造体メンバを後詰めにしたものを配置し、前記構造体
メンバを後詰めにしたものも無いときは残りの変数のう
ち最大アライメントをそれぞれ配置する機能を有する請
求項11または12記載のコンパイラ。
17. When the empty area is generated at the address next to the position where the maximum alignment is arranged, if there is a maximum alignment that can be assigned a value among the remaining variables for the alignment of the empty area, it is arranged, and if there is not, it remains. 11. A variable having a structure member that is left-justified is arranged, and when there is no structure member that is left-justified, a maximum alignment is arranged among the remaining variables. The listed compiler.
【請求項18】 前記構造体を後詰めにするか否かの決
定または前記構造体メンバ後詰め処理機能を自動的に行
わせるコンパイラの割り付け手段を有する請求項11,
12,13,14,15,16または17記載のコンパ
イラ
18. A allocating means of a compiler for automatically deciding whether or not the structure is left-justified or automatically performing the structure member last-justification processing function.
Compiler of 12, 13, 14, 15, 16 or 17
【請求項19】 前記構造体を後詰めにするか否かの決
定を操作者が構造体ごとに指定する機能を有する請求項
11,12,13,14,15、16または17記載の
コンパイラ。
19. The compiler according to claim 11, which has a function of allowing an operator to specify, for each structure, whether or not the structure is to be left-justified.
【請求項20】 前記構造体の後詰めを操作者が構造体
ごとに指定する際に、#pragmaで始まる宣言文で
指定する機能を有する請求項19記載のコンパイラ。
20. The compiler according to claim 19, wherein the compiler has a function of designating the trailing justification of the structure for each structure by a declaration statement starting with #pragma.
【請求項21】 割り付けすべき項目の中から最大アラ
イメント項目を取得する最大アライメント項目取得手段
と、前記項目をメモリ上に配置するメモリ割り付け手段
と、メモリの空き領域を埋める項目を取得する埋め込み
用項目取得手段とを備え、割り付け項目がなくなるま
で、前記最大アライメント項目取得手段を用いて最大ア
ライメント項目を取得する機能と、取得した項目を前記
メモリ割り付け手段を用いて割り付ける機能と、アライ
メントのために空き領域が生じる場合、埋め込みが必要
であると判断する機能と、前記埋め込み用項目取得手段
を用いて、前記空き領域の埋め込み穴に割り付けできる
最大アライメント項目を取得する機能と、割り付け可能
な項目がある場合は、前記メモリ割り付け手段を用いて
その項目を割り付ける機能と、割り付け可能な項目がな
い場合は、構造体メンバ後詰め処理により構造体メンバ
を後詰めにしたものが前記埋め込み穴に割り付けできる
最大アライメント項目を取得する機能と、割り付け可能
な項目がある場合は、前記メモリ割り付け手段を用いて
その項目を割り付ける機能と、一致するものがなければ
その空き領域に対する埋め込みは行わずに次へ進む機能
とを備えることを特徴とするコンパイラ。
21. A maximum alignment item acquisition means for acquiring a maximum alignment item from among items to be allocated, a memory allocation means for arranging the item on a memory, and an embedding for acquiring an item for filling a vacant area of the memory. And a function for acquiring the maximum alignment item using the maximum alignment item acquisition means, a function for allocating the acquired item using the memory allocation means, and for alignment until the allocation items are exhausted. When an empty area is generated, there is a function of determining that embedding is necessary, a function of using the embedding item acquisition unit to acquire the maximum alignment item that can be allocated to the embedding hole of the empty area, and an allocatable item. If there is, allocate the item using the memory allocation means There is a function and a function that, if there is no item that can be assigned, a function that the structure member is left-justified by the structure member justification process to obtain the maximum alignment item that can be assigned to the embedded hole, and an item that can be assigned. In this case, the compiler is provided with a function of allocating the item using the memory allocating means, and a function of proceeding to the next without embedding in the empty area if there is no match.
【請求項22】 割り付けすべき項目の中から最大アラ
イメント項目を取得する最大アライメント項目取得手段
と、前記項目をメモリ上に配置するメモリ割り付け手段
と、メモリの空き領域を埋める項目を取得する埋め込み
用項目取得手段とを備え、割り付け項目がなくなるま
で、前記最大アライメント項目取得手段を用いて最大ア
ライメント項目を探す機能と、前記項目がありかつアラ
イメントのために生じた空き領域に埋め込みが必要であ
るか判断する機能と、埋め込みが必要なければ取得した
項目を前記メモリ割り付け手段を用いて割り付ける機能
と、埋め込みが必要なとき割り付けを行わずにアライメ
ントのみに注目して次の使用可能アドレスに割り付けで
きる最も大きいアライメントの項目を探す機能と、該当
する項目があるかを判断する機能と、該当する項目があ
る場合はその項目を割り付け、該当する項目がない場合
は構造体の変数を後詰めにしたもので、かつ最も大きい
アライメント項目を探す機能と、割り付け可能な項目が
ある場合はその項目を割り付け、該当する項目がない場
合は前記最大アライメント項目を探す機能で取得してい
た項目を割り付ける機能とを備えることを特徴とするコ
ンパイラ。
22. A maximum alignment item obtaining means for obtaining a maximum alignment item from among items to be assigned, a memory allocating means for arranging the item on a memory, and an embedding for obtaining an item for filling an empty area of the memory. A function for searching for the maximum alignment item by using the maximum alignment item acquisition means and an embedding in the empty area which is present due to the alignment are required until the allocation items are exhausted, provided with the item acquisition means. A function to judge, a function to allocate the acquired item using the memory allocation means if embedding is not necessary, and a function to allocate to the next available address paying attention only to the alignment without allocation when embedding is necessary. Ability to search for items with large alignment and determine if there is a corresponding item A function to turn off, a function to allocate the corresponding item if there is a corresponding item, and a function to find the largest alignment item that is a structure variable justified if there is no applicable item, and a assignable item A compiler having a function of allocating the item when there is a corresponding item, and a function of allocating the item acquired by the function of searching the maximum alignment item when there is no corresponding item.
【請求項23】 割り付けすべき項目の中から最大アラ
イメント項目を取得する最大アライメント項目取得手段
と、前記項目をメモリ上に配置するメモリ割り付け手段
と、メモリの空き領域を埋める項目を取得する埋め込み
用項目取得手段とを備え、割り付け項目がなくなるま
で、前記最大アライメント項目取得手段を用いて最大ア
ライメント項目を取得するステップと、取得した項目を
前記メモリ割り付け手段を用いて割り付けるステップ
と、アライメントのために空き領域が生じる場合、埋め
込みが必要であると判断するステップと、前記埋め込み
用項目取得手段を用いて、前記空き領域の埋め込み穴に
割り付けできる最大アライメント項目を取得するステッ
プと、割り付け可能な項目がある場合は、前記メモリ割
り付け手段を用いてその項目を割り付けるステップと、
割り付け可能な項目がない場合は、構造体メンバ後詰め
処理により構造体メンバを後詰めにしたものが前記埋め
込み穴に割り付けできる最大アライメント項目を取得す
るステップと、割り付け可能な項目がある場合は、前記
メモリ割り付け手段を用いてその項目を割り付けるステ
ップと、一致するものがなければその空き領域に対する
埋め込みは行わずに次へ進むステップとを割り付け項目
がなくなるまで繰り返すことをコンパイラの制御手段に
実行させるプログラム。
23. A maximum alignment item obtaining means for obtaining a maximum alignment item from among items to be assigned, a memory allocating means for arranging the item on a memory, and an embedding for obtaining an item for filling an empty area of the memory. And a step of acquiring a maximum alignment item by using the maximum alignment item acquisition means, a step of allocating the acquired item by using the memory allocation means, and alignment until there is no allocation item. When an empty area is generated, a step of determining that embedding is necessary, a step of using the embedding item acquisition means to obtain a maximum alignment item that can be allocated to the embedding hole of the empty area, and an item that can be allocated are If there is, use the memory allocation means to The step of assigning items,
If there is no allocatable item, the step of obtaining the maximum alignment item that can be allocated to the embedded hole by the structure member justified by the structure member justification process, and if there is an allocatable item, Causes the control means of the compiler to repeat the step of allocating the item using the memory allocating means and the step of proceeding to the next step without embedding in the empty area if there is no match until the allocation item is exhausted. program.
【請求項24】 割り付けすべき項目の中から最大アラ
イメント項目を取得する最大アライメント項目取得手段
と、前記項目をメモリ上に配置するメモリ割り付け手段
と、メモリの空き領域を埋める項目を取得する埋め込み
用項目取得手段とを備え、割り付け項目がなくなるま
で、前記最大アライメント項目取得手段を用いて最大ア
ライメント項目を探すステップと、前記項目がありかつ
アライメントのために生じた空き領域に埋め込みが必要
であるか判断するステップと、埋め込みが必要なければ
取得した項目を前記メモリ割り付け手段を用いて割り付
けるステップと、埋め込みが必要なとき割り付けを行わ
ずにアライメントのみに注目して次の使用可能アドレス
に割り付けできる最も大きいアライメントの項目を探す
ステップと、該当する項目があるかを判断するステップ
と、該当する項目がある場合はその項目を割り付け、該
当する項目がない場合は構造体の変数を後詰めにしたも
ので、かつ最も大きいアライメント項目を探すステップ
と、割り付け可能な項目がある場合はその項目を割り付
け、該当する項目がない場合は前記最大アライメント項
目を探すステップで取得していた項目を割り付けるステ
ップと、を割り付け項目がなくなるまで繰り返すことを
コンパイラの制御手段に実行させるプログラム。
24. A maximum alignment item acquisition means for acquiring a maximum alignment item from among items to be allocated, a memory allocation means for arranging the item on a memory, and an embedding for acquiring an item for filling an empty area of the memory. And a step of searching for the maximum alignment item using the maximum alignment item acquisition means until the allocation items are exhausted, and whether or not it is necessary to embed in the empty area where the item exists and is created for alignment. The step of judging, the step of allocating the acquired item by using the memory allocating means if the embedding is not necessary, and the step of allocating to the next usable address paying attention only to the alignment without allocating when the embedding is necessary Steps to find items with large alignment and applicable A step of determining whether there is an item, a step of allocating the item if there is a corresponding item, and a step of locating the variable of the structure after the item if there is no corresponding item and searching for the largest alignment item. , If there is an item that can be allocated, allocate that item, and if there is no applicable item, repeat the steps of allocating the item acquired in the step of searching the maximum alignment item until there are no allocated items. A program to be executed by the control means.
JP2001356204A 2001-11-21 2001-11-21 Compiler, its memory area allocation method, and its program Withdrawn JP2003157176A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2001356204A JP2003157176A (en) 2001-11-21 2001-11-21 Compiler, its memory area allocation method, and its program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2001356204A JP2003157176A (en) 2001-11-21 2001-11-21 Compiler, its memory area allocation method, and its program

Publications (1)

Publication Number Publication Date
JP2003157176A true JP2003157176A (en) 2003-05-30

Family

ID=19167771

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2001356204A Withdrawn JP2003157176A (en) 2001-11-21 2001-11-21 Compiler, its memory area allocation method, and its program

Country Status (1)

Country Link
JP (1) JP2003157176A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110333870A (en) * 2019-06-28 2019-10-15 潍柴动力股份有限公司 Processing method, device and the equipment of Simulink model variable distribution

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110333870A (en) * 2019-06-28 2019-10-15 潍柴动力股份有限公司 Processing method, device and the equipment of Simulink model variable distribution

Similar Documents

Publication Publication Date Title
US5551039A (en) Compiling a source code vector instruction by generating a subgrid loop for iteratively processing array elements by plural processing elements
US8122442B2 (en) Method and system for array optimization
US7103881B2 (en) Virtual machine to provide compiled code to processing elements embodied on a processor device
Traub et al. Quality and speed in linear-scan register allocation
US6708331B1 (en) Method for automatic parallelization of software
US6832369B1 (en) Object oriented method and apparatus for class variable initialization
US5457799A (en) Optimizer for program loops
Bik et al. Compilation techniques for sparse matrix computations
Agrawal et al. Interprocedural partial redundancy elimination and its application to distributed memory compilation
JP4041248B2 (en) COMPILER DEVICE, COMPUTER-READABLE RECORDING MEDIUM CONTAINING COMPILING PROGRAM, AND COMPILING METHOD
Keep et al. A nanopass framework for commercial compiler development
US8037463B2 (en) Computer program functional partitioning system for heterogeneous multi-processing systems
JP3802058B2 (en) System, method and compiler preprocessor for conditionally compiling software compilation units
US7478376B2 (en) Computer program code size partitioning method for multiple memory multi-processing systems
Lu et al. Compiler optimization of implicit reductions for distributed memory multiprocessors
JPH07319710A (en) Compiling processing method
US20010044930A1 (en) Loop optimization method and a compiler
Merlin Techniques for the automatic parallelisation ofDistributed Fortran 90'
US7240341B2 (en) Global constant pool to allow deletion of constant pool entries
US20040064811A1 (en) Optimal register allocation in compilers
Pizka Design and implementation of the GNU INSEL-compiler gic
JP2003157176A (en) Compiler, its memory area allocation method, and its program
Bik et al. The automatic generation of sparse primitives
Leupers Register allocation for common subexpressions in DSP data paths
US6173443B1 (en) Method of compiling a loop

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