Senior Fitness - Exercise and Nutrition for Aging Men and Women
FREE Article Feed for your website.
Home Ownership Magazine
Party Planning Information
Article Marketing Resources
Bio-Medical Research Article Database
Informative Articles on Life, Love and Happiness
Tutorials on Business to Writing
Famous Quotes from Famous People
Song Lyric Information
New US Patent Information
Comprehensive List of Content by Category
Online Auctions and Shopping Related Articles
Article Search
Most Recent Articles
Title: Wireless, ground link-based aircraft data communication system with roaming feature
Patent Number: 7,426,387 Issued on 09/16/2008 to Wright,   et al.

Title: Beam laydown for hopped satellite downlink with adaptable duty cycle
Patent Number: 7,426,386 Issued on 09/16/2008 to Yousefi,   et al.

Title: Communication device and method for communicating over a digital mobile network
Patent Number: 7,426,385 Issued on 09/16/2008 to Mortensen,   et al.

Title: Network communication system including a database of codes and corresponding telephone numbers
Patent Number: 7,426,384 Issued on 09/16/2008 to Murray,   et al.

Title: Wireless LAN intrusion detection based on location
Patent Number: 7,426,383 Issued on 09/16/2008 to Wang,   et al.

Title: Contact validation and trusted contact updating in mobile wireless communications devices
Patent Number: 7,426,382 Issued on 09/16/2008 to Aerrabotu,   et al.

Title: Device billing agent
Patent Number: 7,426,381 Issued on 09/16/2008 to Maes

Title: Location derived presence information
Patent Number: 7,426,380 Issued on 09/16/2008 to Hines,   et al.

Title: Method and system for sound mitigation during initiation of a packet-based real-time media session
Patent Number: 7,426,379 Issued on 09/16/2008 to Stewart,   et al.

Title: Separation of cochannel FM signals
Patent Number: 7,426,378 Issued on 09/16/2008 to Stanners

Title: Sigma delta (.SIGMA..DELTA.) transmitter circuits and transceiver using the same
Patent Number: 7,426,377 Issued on 09/16/2008 to Tanaka,   et al.

Title: Receiver having digital automatic gain control
Patent Number: 7,426,376 Issued on 09/16/2008 to Srinivasan,   et al.

Title: Combination of high-side and low-side current sensing in system for providing power over communication link
Patent Number: 7,426,374 Issued on 09/16/2008 to Dwelley,   et al.

Title: Electrically tuned resonance circuit using piezo and magnetostrictive materials
Patent Number: 7,426,373 Issued on 09/16/2008 to Clingman,   et al.

Title: Piecewise linearizer circuit for radio frequency amplification
Patent Number: 7,426,372 Issued on 09/16/2008 to Quilligan

Title: Radio communication quality measuring apparatus, radio communication quality measuring method and radio base station
Patent Number: 7,426,370 Issued on 09/16/2008 to Nakao,   et al.

Title: Bluetooth appliance having non-memory programmable identification address storing device and telecommunication method thereof
Patent Number: 7,426,369 Issued on 09/16/2008 to Lee

Title: Satellite broadcasting converter, control circuit incorporated therein, and detector circuit used in such control circuit
Patent Number: 7,426,368 Issued on 09/16/2008 to Hirai

Title: Sheet processing apparatus and image forming apparatus
Patent Number: 7,426,367 Issued on 09/16/2008 to Hirai

Title: Image forming apparatus and paper ejection method of image forming apparatus
Patent Number: 7,426,366 Issued on 09/16/2008 to Shishikura

Title: Waste toner collecting apparatus and image forming apparatus
Patent Number: 7,426,365 Issued on 09/16/2008 to Uchihashi

Title: Fixing method, fixing device, and image forming apparatus
Patent Number: 7,426,364 Issued on 09/16/2008 to Kagawa,   et al.

Title: Developer supply container with shutter movement prevention feature
Patent Number: 7,426,363 Issued on 09/16/2008 to Murakami,   et al.

Title: Conveyor device and image forming apparatus
Patent Number: 7,426,362 Issued on 09/16/2008 to Takami

Title: Developer mixing apparatus having four ribbon blenders
Patent Number: 7,426,361 Issued on 09/16/2008 to Thompson,   et al.

Title: Developing apparatus
Patent Number: 7,426,360 Issued on 09/16/2008 to Arimoto,   et al.

Title: Color image forming device having a movable toner supply member being disposable in a laser light path
Patent Number: 7,426,359 Issued on 09/16/2008 to Tanda

Title: Image forming apparatus and method having a cleanerless image forming unit
Patent Number: 7,426,358 Issued on 09/16/2008 to Yoshida,   et al.

Title: Fixing unit and image forming apparatus equipped with the fixing unit
Patent Number: 7,426,357 Issued on 09/16/2008 to Mori

Title: Developer cartridge, print process cartridge, and image forming apparatus
Patent Number: 7,426,356 Issued on 09/16/2008 to Ota

Title: Tandem photosensitive-member unit having grip part
Patent Number: 7,426,355 Issued on 09/16/2008 to Okabe

Title: Image forming device and process cartridge
Patent Number: 7,426,354 Issued on 09/16/2008 to Ozawa,   et al.

Title: Image forming apparatus with variable convey speed control between transfer device and fixing device
Patent Number: 7,426,353 Issued on 09/16/2008 to Sakakibara

Title: Image formation apparatus
Patent Number: 7,426,352 Issued on 09/16/2008 to Moriyama,   et al.

Title: Image forming apparatus and layer thickness calculating method
Patent Number: 7,426,351 Issued on 09/16/2008 to Yamaguchi,   et al.

Title: Mass flowmeter and method for correcting the measurement signal of a mass flowmeter
Patent Number: 6,889,561 Issued on 05/10/2005 to Hussain,   et al.

Title: Method and device for generating an air stream in a duplicating machine
Patent Number: 6,889,609 Issued on 05/10/2005 to Braun,   et al.

Title: Low operating pressure gas scrubber
Patent Number: 6,893,484 Issued on 05/17/2005 to Thomas

Title: Process for the production of grain oriented electrical steel strips
Patent Number: 6,893,510 Issued on 05/17/2005 to Fortunati,   et al.

Title: Antidepressant drugs and methods
Patent Number: 6,759,435 Issued on 07/06/2004 to Chen

Title: Method of manufacturing a semiconductor device with self-aligned contacts
Patent Number: 7,151,025 Issued on 12/19/2006 to Itabashi,   et al.

Title: Method and apparatus for adjusting power control setpoint in a wireless communication system
Patent Number: 6,763,244 Issued on 07/13/2004 to Chen,   et al.

Title: LNG production in cryogenic natural gas processing plants
Patent Number: 6,889,523 Issued on 05/10/2005 to Wilkinson,   et al.

Title: Game calling device
Patent Number: 7,145,067 Issued on 12/05/2006 to Pfortmiller,   et al.

Title: Fiber optic connector and method
Patent Number: 7,147,385 Issued on 12/12/2006 to Zimmel,   et al.

Title: System and method of adaptively reconfiguring buffers
Patent Number: 7,143,263 Issued on 11/28/2006 to Anand,   et al.

Title: Semiconductor device and method for manufacturing the same
Patent Number: 7,151,034 Issued on 12/19/2006 to Lee,   et al.

Title: Laser assisted magnetic recording apparatus and method
Patent Number: 6,762,977 Issued on 07/13/2004 to Gage,   et al.

Title: Disposal of cement waste from chute
Patent Number: 7,147,360 Issued on 12/12/2006 to Elefsrud

Title: Semiconductor memory device having a circuit for fast operation
Patent Number: 6,762,967 Issued on 07/13/2004 to Tanizaki,   et al.

Title: Method of manufacturing semiconductor device
Patent Number: 7,151,017 Issued on 12/19/2006 to Ohnuma

Title: Semiconductor wafer test system
Patent Number: 7,151,003 Issued on 12/19/2006 to Oishi

Title: Patient support pad with repositionable pressure source
Patent Number: 7,146,660 Issued on 12/12/2006 to Heimbrock

Title: Digital broadcast receiving device
Patent Number: 7,146,633 Issued on 12/05/2006 to Yamaguchi,   et al.

Title: Multi-site cardiac stimulation device and method for detecting retrograde conduction
Patent Number: 7,146,215 Issued on 12/05/2006 to Mo

Title: Funnel in cathode ray tube
Patent Number: 6,765,343 Issued on 07/20/2004 to Kim

Title: Open hydraulic circuit including a relief valve device
Patent Number: 7,150,150 Issued on 12/19/2006 to Bigo,   et al.

Title: System for and method of toner flow control
Patent Number: 6,760,555 Issued on 07/06/2004 to Dougherty,   et al.

Title: Semiconductor filter circuit and method
Patent Number: 6,953,980 Issued on 10/11/2005 to Escoffier,   et al.

Title: Gas turbine engine
Patent Number: 7,153,091 Issued on 12/26/2006 to Stephenson,   et al.

Title: Modular air conditioner for a bus
Patent Number: 6,761,038 Issued on 07/13/2004 to Bushnell,   et al.

Title: Method for fabricating electrical connection structure of circuit board
Patent Number: 7,151,050 Issued on 12/19/2006 to Hsu,   et al.

Title: Water heater having self-powered low NOx burner/fuel-air delivery system
Patent Number: 6,761,134 Issued on 07/13/2004 to Trant

Title: Satellite broadcast receiving converter with lower power consumption
Patent Number: 7,136,618 Issued on 11/14/2006 to Kato,   et al.

Title: Apparatus and method for managing power of a battery
Patent Number: 6,765,369 Issued on 07/20/2004 to Rhee,   et al.

Title: Pneumatic surgical prone head support and system
Patent Number: 7,146,664 Issued on 12/12/2006 to Grosvenor

Title: Semiconductor device with flexible redundancy system
Patent Number: 6,762,964 Issued on 07/13/2004 to Takase

Title: Hydraulic actuator having disc valve assembly
Patent Number: 7,143,684 Issued on 12/05/2006 to Dourson,   et al.

Title: Method of manufacturing thin-film magnetic head
Patent Number: 7,155,809 Issued on 01/02/2007 to Sasaki,   et al.

Title: Fire extinguisher kit, device and method of using same
Patent Number: 7,147,061 Issued on 12/12/2006 to Tsutaoka,   et al.

Title: On-line system and method for processing information relating to the wear of turbine components
Patent Number: 7,149,632 Issued on 12/12/2006 to Gao,   et al.

Title: Control of software via bundling
Patent Number: 7,158,248 Issued on 01/02/2007 to Smith,   et al.

Title: Cardiac harness for treating congestive heart failure and for defibrillating and/or pacing/sensing
Patent Number: 7,149,588 Issued on 12/12/2006 to Lau,   et al.

Title: Fabrication apparatus for an assembly of vanes for an architectural covering
Patent Number: 7,146,694 Issued on 12/12/2006 to Colson,   et al.

Title: System and method for automated play of lottery games
Patent Number: 6,964,611 Issued on 11/15/2005 to Packes, Jr.,   et al.

Method and system for register allocation Number:7,386,843 from the United States Patent and Trademark Office (PTO) owispatent

Home    Author Login    Submit Article    Article Search    Add Your Link    Edit Your Link    Contact Us    Advertising    Disclaimer

   

 
Web LinkGrinder.com

Top Breaking News
     Greek, Cypriot Leaders Resume Unification Talks in Nicosia by Nathan Morley
     Indonesia Tobacco Sales Grow, Raising Health Fears
     South Korea Allows Top Defector to Travel Overseas by VOA News

Title: Method and system for register allocation

Abstract: Inserting spill code optimized for a complex instruction set computing (CISC) two-address machine. The spill code is generated in a single pass. Copy propagation and dead-code elimination are performed to remove unnecessary loads and stores from the stack. Memory operands are substituted in place of load and store instructions on CISC machines. The number of occurrences of a temporary variable is checked before a load is inserted into the new instructions and before a temporary variable is removed from use. If the variable has only occurred once then the memory operand of the temporary is used in place of the load of the temporary variable saving a load instruction. If the temporary variable is about to be removed from use and the temporary variable has only occurred one time then the variable is not stored saving a store instruction within the spill code.

Patent Number: 7,386,843 Issued on 06/10/2008 to Tarditi


Inventors: Tarditi; David R. (Kirkland, WA)
Assignee: Microsoft Corporation (Redmond, WA)
Appl. No.: 10/864,708
Filed: June 9, 2004


Related U.S. Patent Documents

Application NumberFiling DatePatent NumberIssue Date
09792395Feb., 20016925639

Current U.S. Class: 717/151
Field of Search: 717/140-161


References Cited [Referenced By]

U.S. Patent Documents
4571678 February 1986 Chaitin
5761514 June 1998 Aizikowitz et al.
6925639 August 2005 Tarditi

Other References

G J. Chaitin, "Register Allocation & Spilling via Graph Coloring", ACM, 1982. cited by examiner .
R. Fitzgerald et al., "Marmot: An Optimizing Compiler for Java", Microsoft Research, Jun. 16, 1999. cited by examiner .
P. Briggs et al., "Coloring Heuristics for Register Allocation", ACM, 1989 (Retrospective portion published 1999). cited by examiner .
Timothy Kong and Kent Wilken, "Precise Register Allocation for Irregular Architectures", Proceedings of the 31.sup.st annual ACM/IEEE International Symposium on Microarchitecture, 1998. cited by examiner .
Andrew Appel and Lal George, "Optimal Spilling for CISC Machines with Few Registers", Princeton University Computer Science TR-630-00, Nov. 14, 2000, retrieved from: http://www.cs.princeton.edu/research/techreps/TR-630-00. cited by examiner.

Primary Examiner: An; Meng-Al T.
Assistant Examiner: Wang; Jue
Attorney, Agent or Firm: Merchant & Gould P.C.

Parent Case Text



RELATED APPLICATIONS

This application is a continuation of application Ser. No. 09/792,395, filed Feb. 23, 2001, now U.S. Pat. No. 6,925,639, which application is incorporated herein by reference.
Claims



I claim:

1. A method of inserting spill code to handle a set of spilled variables, the spilled variables being identified by a register allocation procedure, into a plurality of instructions generated by a compiler, the spill code adapted for a CISC machine having registers used when executing instructions, comprising: processing each instruction in the plurality of instructions by: when a variable within the instruction is dead after the instruction: generating a spill code load instruction for each spilled variable included in a set of spilled variables to be loaded, the set of spilled variables to be loaded being a subset of the set of spilled variables; removing all variables for which a spill code load instruction was generated from the set of spilled variables to be loaded; and removing all entries for the variables within the instruction from a mapping from spilled variables to temporary variables; determining if the instruction includes a variable in the set of spilled variables, and if so, for each such variable: adding an entry to the mapping from spilled variables to temporary variables; and generating a store instruction to store the variable to a stack location if a store to the stack location for the variable is necessary, and generating a substitute instruction by applying the mapping from spilled variables to temporary variables such that the temporary variables are substituted for the spilled variables; generating a spill code load instruction for each variable in the set of spilled variables to be loaded; and inserting the generated instructions; wherein the instructions are adapted for the CISC machine having registers for executing instructions.

2. The method of claim 1, wherein processing each instruction in the plurality of instructions is done in reverse order.

3. The method of claim 2, wherein generating a spill code load instruction for each variable in the set of spilled variables to be loaded is done after processing all instructions in the plurality of instructions.

4. The method of claim 2, wherein adding the entry to the mapping from spilled variables to temporary variables, further comprises determining if the mapping maps the spilled variable to a temporary variable, and if not, further: (a) adding the spilled variable to a set of variables that are to be loaded; (b) creating the temporary variable; and (c) updating the mapping from spilled variables to temporary variables to map the spilled variable to the temporary variable.

5. A computer-readable storage media storing computer-executable instructions for inserting spill code to handle a set of spilled variables, the spilled variables being identified by a register allocation procedure, into a plurality of instructions, the spill code adapted for a CISC machine having registers for executing instructions, comprising: processing each instruction in the plurality of instructions by: determining if a variable within the instruction is dead after the instruction, and if so: generating a spill code load instruction for each spilled variable included in a set of spilled variables to be loaded, the set of spilled variables to be loaded being a subset of the set of spilled variables; removing all variables for which a spill code load instruction was generated from the set of spilled variables to be loaded; and removing all entries for the variables within the instruction from a mapping from spilled variables to temporary variables; determining if the instruction includes a variable in the set of spilled variables, and if so, for each such variable: adding an entry to a mapping from spilled variables to temporary variables; and generating a store instruction to store the variable to the stack location if a store to a stack location for the variable is necessary, and generating a substitute instruction by applying the mapping from spilled variables to temporary variables such that the temporary variables are substituted for the spilled variables; generating a spill code load instruction for each variable in the set of spilled variables to be loaded; and inserting the generated instructions; wherein the instructions are adapted for the CISC machine having registers for executing instructions.

6. The computer-readable storage media of claim 5, wherein processing each instruction within the code block is done in reverse order.

7. The computer-readable storage media of claim 6, wherein generating the spill code load instruction for each variable in the set of spilled variables to be loaded is completed after processing all instructions in the plurality of instructions.

8. The computer-readable storage media of claim 7, wherein adding the entry to the mapping from spilled variables to temporary variables, further comprises when the mapping does not already map the spilled variable to the temporary variable, further; adding the variable to a set of variables that are to be loaded from a stack; creating a temporary variable; and updating the mapping from spilled variables to temporary variables to map the spilled variable to the temporary variable.
Description



FIELD OF THE INVENTION

The present invention relates generally to computer software, and more particularly to inserting spill code.

BACKGROUND

Processors have a limited number of hardware registers to use when executing instructions. In cases where there are not enough registers to hold all program variables currently in use some of the variables used by the instructions may be "spilled" into memory to free registers. When a variable is spilled, a compiler creates spill code that is inserted into the low-level code created by the compiler to manage these spilled variables. Selecting how to spill variables depends on many different factors, including machine architecture, complexity of program, and compiler efficiency. For example, RISC machines generally have many more hardware registers as compared with CISC machines making efficient spill code much less important on the RISC machines.

Generally, the need for registers increases with the complexity of programs. This complexity, in turn, creates more spilled variables and low-level spill code. Memory operations, however, are generally significantly slower than register accesses causing the program instructions that include spill code to run slower. In order to help alleviate the register pressure created by an excess of variables over available registers, various register allocation methods have been developed to determine which variables to spill.

Some of these allocation methods are widely used in optimizing compilers. One such method is a graph-coloring register allocation method known as a Chaitin-style allocation method. Generally, the method constructs an interference graph for all variables used within a procedure. A color is then assigned to each available hardware register on the processor. For example, if seven hardware registers are available then seven distinct colors for coloring the graph are available. An attempt to color each node within the interference graph with a distinct color is then made. If the coloring fails, the method chooses a variable(s) from the graph to spill and spill code is generated for the spilled variables. This method is repeated until coloring of the nodes is successful.

While methods exist to allocate registers, they are not optimized for complex instruction set computing (CISC) two-address machines. Instead, the development of allocation methods has been directed to three-address reduced instruction set computing (RISC) machines.

SUMMARY

The present invention is directed at providing a system and method for inserting spill code. According to one aspect of the invention, spill code is optimized for a complex instruction set computing (CISC) two-address machine, such as a machine utilizing an 80.times.86 processor.

In another aspect of the invention, the spill code is inserted in a single pass. A single pass algorithm decreases compile time as compared to a compiler that optimizes using multiple passes.

According to another aspect of the invention, copy propagation and dead-code elimination are performed to remove unnecessary loads from the stack and unnecessary stores to the stack.

In yet another aspect of the invention, the instructions contained within the program block are processed in reverse order.

According to yet another aspect of the invention, temporary variables are not extended to the point that they may become spilled by a register allocation procedure.

In yet another aspect, stores to stack locations for spilled variables may be inserted. A store to a stack location is inserted if the stack location is not dead. A stack location is not dead if there not a store to the stack location before the stack location is read. In this way, the stack location itself is essentially used in place of a register. A store to a stack location is also inserted in the cases where a spilled variable is alive in an exception-handling block that guards the block.

In still yet another aspect of the invention, memory operands are substituted when beneficial in place of load and store instructions on CISC machines. As the instructions are being processed, the number of places where a temporary variable associated with a spilled variable has been substituted for the spilled variable within the instructions is counted. In addition to keeping track of the number of places, the location of the last instruction where the temporary variable was substituted for the spilled variable is maintained. The number of places where the temporary variable has been substituted for the spilled variable is checked before a load is inserted into the new instructions as well as before a temporary variable is removed from use. If the temporary variable has been substituted at only one place for the spilled variable and that place can be replaced by a memory operand, then the memory location for the spilled variable is substituted in place of the temporary variable. This technique saves a load instruction within the spill code. If the memory location is substituted for the temporary variable in an instruction that also writes the memory location, the following instruction in the list of new instructions may be a store of the temporary variable to the stack. If so, this store instruction is removed. This technique saves a store instruction within the spill code.

These and various other features and advantages, which characterize the present invention, will be apparent from a reading of the following detailed description in conjunction with the associated drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a functional block diagram of one computing device adapted to implement one embodiment of the invention;

FIG. 2 is a functional block diagram illustrating a system adapted to insert spill code, according to one embodiment of the invention;

FIG. 3 illustrates a diagram showing a register holding exemplary instructions, according to one embodiment of the invention;

FIG. 4 is an overview flowchart illustrating inserting spill code;

FIG. 5 is an overview flowchart illustrating processing instructions within a code block, according to one embodiment of the invention;

FIG. 6 is a flowchart illustrating another process for inserting appropriate spill code instructions within a code block;

FIG. 7 is a flowchart illustrating inserting loads if a variable has died, according to one embodiment of the invention;

FIG. 8 is a flowchart illustrating assigning temporary variables to spilled variables, according to one embodiment of the invention;

FIG. 9 is a flowchart illustrating processing defined variables that are spilled, according to one embodiment of the invention;

FIG. 10 is a flowchart illustrating changing the spill code inserting loads if a variable dies; according to one embodiment of the invention; and

FIG. 11 is a flowchart representing updating the occurrence count of a variable, according to one embodiment of the invention.

DETAILED DESCRIPTION

The present invention is directed at providing a system and method for inserting spill code. Spill code is intermediate code generated by a compiler to temporarily store and retrieve "spilled" variables. A "spilled" variable is a variable that is stored temporarily in memory outside of a hardware register until needed by a program. A register allocation procedure identifies variables within the program to spill.

Referring to FIG. 1, an exemplary system for implementing the invention includes a computing device, such as computing device 100. In a very basic configuration, computing device 100 typically includes at least one processing unit 102 and system memory 104. Depending on the exact configuration and type of computing device, system memory 104 may be volatile (such as RAM), non-volatile (such as ROM, flash memory, etc.) or some combination of the two. System memory 104 typically includes an operating system 105, one or more program modules 106, and may include program data 107. This basic configuration is illustrated in FIG. 1 by those components within dashed line 108.

Computing device 100 may also have additional features or functionality. For example, computing device 100 may also include additional data storage devices (removable and/or non-removable) such as, for example, magnetic disks, optical disks, or tape. Such additional storage is illustrated in FIG. 1 by removable storage 109 and non-removable storage 110. Computer storage media may include volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information, such as computer readable instructions, data structures, program modules or other data. System memory 104, removable storage 109 and non-removable storage 110 are all examples of computer storage media. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by computing device 100. Any such computer storage media may be part of device 100. Computing device 100 may also have input device(s) 112 such as keyboard, mouse, pen, voice input device, touch input device, etc. Output device(s) 114 such as a display, speakers, printer, etc. may also be included. All these devices are known in the art and need not be discussed at length here.

Computing device 100 may also contain communications connection(s) 116 that allow the device to communicate with other computing devices 118, such as over a network. Communications connection(s) 116 is an example of communication media. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. The term "modulated data signal" means a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communication media includes wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, RF, infrared and other wireless media. The term computer readable media as used herein includes both storage media and communication media.

FIG. 2 is a functional block diagram illustrating several components according to the present invention. This embodiment of the invention includes a processing unit 102 having registers 220, a binary executable 205 that includes a front-end 210, a converter to intermediate program representation 215, an intermediate program representation 216, register allocator 230, spill code inserter 240, and binary writer 245, a source program 249, and a new binary executable 250.

Processing unit 102 operates as described in conjunction with FIG. 1. Processing unit 102 includes registers 220. Generally, a register is a set of bits of high-speed memory within a microprocessor or other electronic device, used to hold data for a particular purpose. Each register in a central processing unit is referred to in assembly language programs by a name such as AX (the register that contains the results of arithmetic operations in an Intel 80.times.86 processor) or SP (the register that contains the memory address of the top of the stack in various processors). The number of individual registers is limited according to computing device 100. A register configuration similar to the one shown in registers 220 may be used.

Processing unit 102 runs binary executable 205. Binary executable 205 is an example of a compiler. The front-end 210 reads source code program 249 and converts it to a syntax tree 212. The converter to intermediate program representation 215 converts each procedure represented in the syntax tree to an intermediate program representation 216. The intermediate program representation 216 consists of a code block that is a list of assembly language instructions and other data representing the procedure.

Register allocator 230 is configured to receive the intermediate program representation 216 for the procedure. Register allocator 230 generates a list of variables to spill based on the code block and available number of registers. It then sends this information to spill code inserter 240.

Spill code inserter 240 is configured to receive register allocation information. For example, the register allocation may be provided by a graph-coloring register allocation method. One particular example is a Chaitin-style allocator as is well known in the art. After spill code inserter 240 receives allocation information, it rewrites the intermediate representation 216 for the procedure to insert spill code to handle the variables for which there are not available hardware registers. Execution then returns to register allocator 230.

If no variables need to be spilled, register allocator modifies the intermediate representation 216 for the procedure to replace all variables with the appropriate register names. It then passes the intermediate representation to binary writer 245. Binary writer 245 writes binary executable 250, which may be stored in RAM, on disk, or in some other suitable computer readable memory.

FIG. 3 illustrates instructions contained in intermediate representation 216. Instructions 301 through 306 in FIG. 3 are for illustrative purposes only. The instructions contained in code block 300 may contain any sequence of instructions executable on a processor. A processor includes physical processors already constructed, those in design, multiple processors acting together, virtual processors, and any other device capable of interpreting intermediate representation 216' sinstructions. According to one embodiment of the invention, the instructions are for a two-address CISC machine, such as a machine utilizing an 80.times.86 processor.

FIG. 4 is an overview flow diagram illustrating a method for inserting spill code. Starting at block 410, a code block is accessed. According to one embodiment of the invention, a compiler accesses the code block. A code block is a list of instructions contained within an intermediate representation program. The code block may be the entire list of instructions for a program, a single procedure within a program, a group of procedures, or any number of instructions contained within the program.

Moving to block 420, the first instruction within the code block is accessed. According to one embodiment of the invention, the instructions are processed in reverse order. Therefore, according to this particular embodiment, the first instruction is actually the last instruction within the code block. Processing the instructions in reverse order allows the spill code inserter to easily track the number of uses of the variables throughout the code block as well as determine if variables are live or dead after the instructions have been processed. Additionally, the reverse processing helps to avoid the use of temporary variables.

At block 430, the instruction is processed to create spill code if required (See FIGS. 5 and 6 and related discussions). Decision block 440 determines whether or not to insert spill code for the instruction being processed or modify the instruction being processed.

If no spill code is to be inserted and the instruction is not to be modified, then the instruction is simply added to a temporary list of instructions (block 455).

If spill code is to be inserted or the instruction is to be modified, then at block 450 zero or more spill code instruction are generated and these instructions are added to the temporary list of instructions. In addition, a modified copy of the instruction is also added to the temporary list of instructions. Applying a mapping from spilled variables to temporary variables modifies the instruction. For each occurrence of a spilled variable in the instruction, the mapping is consulted for a corresponding temporary variable and the temporary variable is substituted for the spilled variable. For example, if there are not enough registers to hold all variables currently in use at that point in the program, some of the variables in use may be "spilled" into memory and stored there.

In one particular embodiment, the spill code is optimized for a complex instruction set computing (CISC) machine, such as a machine utilizing an 80.times.86 processor. Additionally, the spill code generated is optimized for a two-address machine.

Decision block 460 determines if there are any more instructions within the code block. If so, the logical flow returns to block 430. Otherwise, the code block is modified to use a copy of the temporary list of instructions (block 470).

According to one embodiment, the compiler generates the spill code in a single pass. A single pass decreases compile time as compared to a compiler that optimizes using multiple passes. It will be appreciated, however, that multiple passes may be used.

FIG. 5 is an overview flowchart illustrating processing instructions according to one embodiment of the invention. Starting at block 510, a determination is made as to whether a variable dies after the instruction being processed. A variable dies if the code block no longer uses the current value of the variable after the instruction has executed. If a variable dies, spill code may be generated.

At block 520, temporary variables are created for each spilled variable depending on the use of the variables in the instruction being processed (See FIG. 6 and related discussion).

Moving to block 530, stores to stack locations may be inserted for spilled variables defined by the instruction. For example, a store may be inserted if a variable within the instruction is alive in an exception handler guarding the block.

FIG. 6 is a flowchart illustrating another process for inserting appropriate spill code instructions within a code block according to another embodiment of the invention. Starting at block 610, variables within the instruction being processed are categorized as used, defined, or used and defined. A variable is used if the value of the variable used during execution of the instruction. For example, variable B is used when the instruction is MULT A, B. A variable is defined if it is modified during execution of the instruction. A variable is used and defined if the value of the variable is both used and the variable is also modified during the execution of the instruction. This process keeps a map from spilled variables to temporary variables. The map is updated as appropriate.

At block 620 loads are inserted if a variable within the instruction dies (See FIG. 7 and related discussion). A variable dies after an instruction if the value of the variable is not accessed again after the processor executes the instruction. Since the instructions are being processed in reverse order, whether a variable is live is kept track of as the instructions are processed.

Moving to block 630, spilled variables are assigned temporary variables. Temporary variables are created for any variables to be spilled that are defined or used within the instruction being processed (See FIG. 8 and related discussion), if the spilled variables do not have an entry in the mapping from spilled variables to temporary variables.

Defined variables within the instruction are processed at block 640. A determination is made whether a variable within the instruction is alive in an exception handler guarding the code block and, if not, whether the variable is not within a dead stores list (See FIG. 9 and related discussion).

Next, at block 650 the spill code may be modified if a variable used or defined by the instruction dies after the instruction. A memory operand is used in place of a load instruction and/or store instruction if appropriate (See FIG. 10 and related discussion).

Moving to block 660, the counts of the times the temporary variables have been substituted for the spilled variables within the instructions are monitored along with the last location where each temporary variable has been used in place of the spilled variable. Additionally, memory operands are used instead of a store instruction based on the occurrence counts of the temporary variables (See FIG. 10 and related discussion).

FIG. 7 is a flowchart illustrating a process for inserting loads if a variable has died. Determination block 710 determines if there is at least one variable within the instruction that is used or defined that is not alive after the instruction is executed. Processing the instructions in reverse order allows this determination to easily be made since the use of variables in later instructions is known before accessing the current instruction.

If a variable is dead after the instruction, then, at block 720, any of the variables that need to be loaded and are not defined by the instruction are identified. In one embodiment of the invention, the variables that need to be loaded from the stack are maintained in a data structure accessed by the spill code inserter 240.

Moving to block 730, for each of the identified variables, a load is inserted. According to one actual embodiment of the invention, the load is placed in a the temporary list of instructions. At block 740, the variable is removed from the mapping of spilled variables to temporaries. Next, at block 750, the variable is removed from the dead stores list ensuring that stores to the variables stack location occur.

After all identified variables are processed, the set of variables that need to be loaded are updated and all identified variables are removed from the set (block 760).

FIG. 8 is a flowchart generally illustrating a process for assigning temporary variables to spilled variables. Determination block 810 identifies the spilled variables within the instruction that are used or defined and do not have an entry in the mapping from spilled variables to temporary variables. Such variables will also not be in the set of spilled variables that need to be loaded.

At block 820, for each identified variable a temporary variable is created. For example, if variable x is to be spilled and variable x is contained within the instruction being processed then some new variable will be created. Moving to block 830, the spilled variable is added to the set of variables that need to be loaded. Next, at block 840, the mapping from spilled variables to temporary variables is updated to map the variable to the new temporary variable. In one embodiment of the invention, the mapping is maintained in a data structure, such as an array. The mapping is then applied to the instruction being processed (block 850). For example, if variable x was mapped to temporary t1, then x is replaced with t1 for all occurrences of x within the instruction being processed.

FIG. 9 is a flowchart illustrating processing defined variables that are spilled. Starting the logical flow, determination block 910 identifies the variables within the instruction being processed that are defined and spilled. For each identified variable, decision block 920 determines if any of the identified variables are located in exception handlers guarding the code block. For each of the variables identified by decision block 920, a store to a stack location is inserted in the cases where a spilled variable is alive in a routine that guards the block (block 930). In one embodiment, the stores to a stack location are added to the temporary list of instructions for the code block.

Determination block 940 determines the variables not in an exception handler guarding the code block but are not in the set of dead store variables. Each such variable is added to the dead stores list (block 950). The dead stores list contains the variables whose stack locations are dead. In addition, for each such variable a store to a stack location is inserted (block 960).

Moving to block 970, the new instruction (created by block 850) is added to the temporary list of instructions. Variables that are defined but not used are removed from the need to be loaded set (block 980). This prevents variables from being loaded that do not need to be loaded since they are never used. At block 990 the entries for these spilled variables are removed from the mapping from spilled variables to temporary variables.

FIG. 10 is a flowchart illustrating changing the insertion of loads and stores if a variable dies (FIG. 7). If a variable dies, any associated temporary variable is removed. This prevents the temporary variable from being extended to the point that it may become spilled by a register allocation procedure. Decision block 1010 determines if there is at least one variable that is used or defined and is not alive after the instruction. If so, block 1020 determines the variables contained within the instruction that need to be loaded but are not defined by the instruction. For each of these identified variables, the following steps occur. A determination is made as to how many times the temporary variable associated with the spilled variable has been substituted in instructions for the spilled variable during processing of the code block to this point (block 1030). Decision block 1040 determines if the temporary variable has been substituted only once. If so, then a memory operand is used in place of the temporary variable (block 1050), if a memory operand is allowed. This saves a load instruction within the spill code. Otherwise the load instruction is added the temporary list of instructions. In addition, if the memory operand is defined by the instruction, a store instruction may follow the modified instruction in the temporary list of instructions. If this store instruction stores the temporary variable to the stack, it is removed, as the occurrence of the temporary variable has also been removed. This saves a store instruction in the spill code. The counter for the spilled variable that keeps track of how many times the associated temporary variable has been substituted for the spilled variable is reset to zero (block 1060).

FIG. 11 represents updating the count of places where a temporary variable has been substituted for a spilled variable. At block 1110, the count is increased by one for each occurrence of a spilled variable within the current instruction. Next, at block 1120, all spilled variables that are defined but not used are identified. At block 1130 for each identified variable a determination is made as to whether the variable occurs only one time. If so, at block 1140, a memory operand is tried in place of a store instruction. This saves a store operation within the spill code. The counter keeping track of the occurrences of the variable is reset to zero.

In one embodiment of the invention, copy propagation and dead-code elimination are performed to remove unnecessary loads and stores from the stack as is well known in the art. The method and system produce measurably faster code than generated using naive register allocation procedures.

The above specification, examples and data provide a complete description of the manufacture and use of the composition of the invention. Since many embodiments of the invention can be made without departing from the spirit and scope of the invention, the invention resides in the claims hereinafter appended.

*


Free Web Sudoku Puzzles.
Solve with your browser.
6   7            
5       4 2 6    
    8     3      
9   5         2 4
      7   4      
3 4         1   8
      4     2    
    3 8 6       5
            8   6
What is it?



Add Your Site · Terms Of Service · Privacy Policy


DISCLAIMER
Linkgrinder is a free service that searches the Internet and indexes all files found so that you may search quickly and easily for shared files. These files are created and made available individually by users whose identity we are not aware of and who we have no control over. In essence we function like a search engine tool; these files ARE NOT STORED OR SERVED BY OUR NETWORK. We are not responsible for any materials obtained by using our service. We do not monitor any of the contents of these files. These files may contain viruses, illegal materials, materials inappropriate for minors, offensive files and the like. BY USING OUR SERVICE, YOU ASSUME FULL RESPONSIBILITY FOR DOWNLOADING THESE MATERIALS AND WILL INDEMNIFY US FOR ANY DAMAGES THAT MAY BE INCURRED.

For More Specific Information VIEW OUR TERMS OF SERVICE.

Thank you and Enjoy!