Generating storage reference instructions in an optimizing compiler
First Claim
1. A method for use in an optimizing compiler for generating code for subsequent machine execution which is more efficient in terms of storage references, said method comprising,first generating intermediate code that completely avoids the SR, RS and SS instructions for arithmetic-like data, said code referring to main memory only via "load" and "store" instructions, and wherein all computations are done in registers (register ops) using symbolic RR instructions, optimizing the program by standard techniques including commoning, code motion out of loops, strength reduction, dead code elimination, andlocating predetermined patterns in the code, comprising a `load` op followed by a `register` op or a `store` op referring to the same object(s) and replacing these patterns with a shorter instruction sequence of SR, RS or SS instructions if said predetermined patterns exist.
1 Assignment
0 Petitions
Accused Products
Abstract
A method for improving the quality of code generated by a compiler in terms of execution time, object code space, or both. The method is applicable to computers that have a redundancy of instructions, in that the same operation exists in forms that operate between registers, between main storage locations, and between registers and main storage. The method selects the best form of each such instruction to use, for the context in which the instruction lies.
49 Citations
7 Claims
-
1. A method for use in an optimizing compiler for generating code for subsequent machine execution which is more efficient in terms of storage references, said method comprising,
first generating intermediate code that completely avoids the SR, RS and SS instructions for arithmetic-like data, said code referring to main memory only via "load" and "store" instructions, and wherein all computations are done in registers (register ops) using symbolic RR instructions, optimizing the program by standard techniques including commoning, code motion out of loops, strength reduction, dead code elimination, and locating predetermined patterns in the code, comprising a `load` op followed by a `register` op or a `store` op referring to the same object(s) and replacing these patterns with a shorter instruction sequence of SR, RS or SS instructions if said predetermined patterns exist.
-
2. A method for use during the instruction selection phase of an optimizing compiler after the intermediate language generation phase in which all arithmetic operations are defined in terms of symbolic register ops and in which all memory operations are defined in terms of load and store ops and combined with necessary register ops, said method comprising;
- sequentially accessing the intermediate code instructions and processing the same as follows;
determining if an instruction is a label, if so obtaining the next instruction, if not, determining if it is a load instruction, if not, obtaining the next instruction, if so, determining first if it and the following instructions corresponds to a first pattern of a load operation followed by a register operation followed by a store operation all involving the same objects, if so, replacing the store operation by the RS form of the operation and deleting the load operation and the register operation and accessing the next instruction, if the operation sequence did not follow the pattern, determining second if the following instructions correspond to a second pattern of a load operation followed by a register operation, if so, replacing the register operation by its SR form and deleting the load operation, and if the operation sequence did not follow this pattern, determining third if the following instructions correspond to a third pattern of a load operation followed by a store operation, if so, replacing the store instruction by an SS move instruction and deleting the load instruction and obtaining the next instruction, if none of the three patterns specified are present, obtaining the next instruction in the sequence. - View Dependent Claims (3, 4, 5, 6)
- sequentially accessing the intermediate code instructions and processing the same as follows;
-
7. A method for use in an optimizing compiler for generating code for subsequent machine execution which is more efficient in terms of storage references, said method comprising,
first generating intermediate code that completely avoids the SR, RS and SS instructions for arithmetic-like data, said code referring to main memory only via "load" and "store" instructions, and wherein all computations are done in registers (register ops) using symbolic RR instructions, optimizing the program by standard techniques including commoning, code motion out of loops, strength reduction, dead code elimination, locating predetermined patterns in the code, comprising a `load` op followed by a `register` op or a `store` op referring to the same object and replacing these patterns with a different pattern of SR, RS or SS instructions if said predetermined patterns exist, assigning real registers to each instruction by replacing each symbolic register with a real machine register, and generating "spill" code where necessary and again, locating said predetermined patterns in the code produced by the previous step and replacing these patterns with a different pattern of SR, RS or SS instructions if said predetermined patterns exist and, generating machine code from the intermediate code produced by said previous step.
Specification