Compiler for optimizing memory instruction sequences by marking instructions not having multiple memory address paths
AssigneeMatsushita Electric Industrial Co., Ltd.
InventorsKensuke Odani, Akira Tanaka, Hirohisa Tanaka
Life of this patent
Estimating the term…
Abstract
Internal variables generated by a compiler are assigned to machine resources such as registers and memory by the resource assigning unit 11, and when the assembler code generation unit 18 has outputted an instruction sequence, the alias accessibility analyzing unit 19 registers memory access instructions in the instruction sequence in the assigned resource information 14 according to whether the instructions have a possibility of access by alias. The assembler code optimization unit 20 refers to the assigned resource information 14 and performs optimization at assembler level, thereby reducing the program size and execution time of the instruction sequence.
Claims44
An optimizing apparatus for optimizing a sequence of instructions obtained as a result of a compiler translating a source program composed of statements written in a programming language, wherein the compiler includes resource assigning means for assigning a plurality of resources to a plurality of variables included in the statements of the source program, and classifying the plurality of variables into different types;
- and instruction generating means for generating a sequence of instructions based on the source program, and classifying the instructions of the generated sequence into a type which corresponds to any of the statements in the source program and a type which does not correspond to any of the statements in the source program, the optimizing apparatus comprising:
- extracting means for extracting memory access instructions from the sequence of instructions which specify a memory address as an access target;
- judging means for judging, each extracted memory access instruction, to determine whether the memory address specified as an access target by the memory access instruction corresponds to a variable which is accessed by an operation involving another variable in the source program, in accordance with the classification results of the resource assigning means and the instruction generating means;
- appending means for adding a mark, showing that there is no possibility of access by alias, to each extracted memory access instruction whose access target is judged as not being accessed by an operation involving another variable;
- and
- optimizing means for referring to the marks appended by the appending means and optimizing the sequence of instructions.
A compiler for translating a source program composed of statements written in a programming language into a sequence of instructions, the translated sequence of instructions then being optimized by an optimizing apparatus, the compiler comprising:
- resource assigning means for assigning a plurality of resources to a plurality of variables included in the statements composing the source program, and classifying plurality of variables into local variables and temporary variables, the local variables being a type of variable that is not subjected to address referencing in the source program, and the temporary variables being a type of variable that has been inserted out of convenience into an intermediate code statement when the statements in the source program are converted into intermediate code statements;
- instruction generating means for generating the sequence of instructions based on the source program, and classifying the instructions of the generated sequence into a type of instruction which corresponds to any of the statements in the source program and a type of instruction which does not correspond to any of the statements in the source program, with each instruction that saves a stored value of a register being classified as the type of instruction which does not correspond to any of the statements;
- and
- optimizing apparatus for judging each memory access instruction included in the sequence of instructions, to determine whether a memory address specified as an access target of the memory access instruction corresponds to a variable which is accessed by an operation involving another variable in the source program, in accordance with the classification results of the resource assigning means and the instruction generating means and optimizing the sequence of instructions based on the judgment results.
A computer-readable recording medium that stores an optimization program for optimizing a sequence of instructions obtained as a result of a compiler translating a source program composed of statements written in a programming language, wherein the compiler includes a resource assigning step for assigning a plurality of resources to a plurality of variables included in the statements of the source program, and classifying the plurality of variables into different types;
- and an instruction generating step for generating the sequence of instructions based on the source program, and classifying the instructions of the generated sequence into a type of instruction which corresponds to any of the statements in the source program and a type of instruction which does not correspond to any of the statements in the source program, the optimization program comprising:
- an extracting step for extracting memory access instructions from the sequence of instructions which specify a memory address as an access target;
- a judging step for judging each extracted memory access instruction to determine whether a memory address specified as an access target of the memory access instruction corresponds to a variable which is accessed by an operation involving another variable in the source program, in accordance with the classification results of the resource assigning step and the instruction generating step;
- an appending step for adding a mark, showing that there is no possibility of access by alias, to each extracted memory access instruction whose access target is judge as not being accessed by an operation involving another variable;
- and
- an optimizing step for referring to the marks appended by the appending step and optimizing the sequence of instructions.
A computer-readable recording medium that stores a compiler program that translates a source program composed of statements written in a programming language into a sequence of instructions, the translated sequence of instructions then being optimized by an optimization program, the compiler program comprising:
- a resource assigning step for assigning a plurality of resources to a plurality of variables included in the statements composing the source program, and classifying the plurality of variables into local variables and temporary variables, the local variables being a type of variable that is not subjected to address referencing in the source program, and the temporary variables being a type of variable that has been inserted out of convenience into an intermediate code statement when the statements in the source program are converted into intermediate code statements;
- an instruction generating step for generating the sequence of instructions based on the source program, and classifying the instructions of the generated sequence into a type of instruction which corresponds to any of the statements in the source program and a type of instruction which does not correspond to any of the statements in the source program, with each instruction that saves a stored value of a register being classified as the type of instruction which does not correspond to any of the statements;
- and
- a judging step for judging each memory access instruction included in the sequence of instructions, to determine whether a memory address specified as an access target of the memory access instruction corresponds to a variable which is accessed by an operation involving another variable in the source program, in accordance with the classification results of the resource assigning step and the instruction generating step, and optimizing the sequence of instructions based on the judgement results.
Dependencies are inferred from the claim text.