DESKTOP

Algorithms for Compiler Design

7/24/2010 8:05:00 PM
11.2 PROBLEMS THAT HINDER GOOD CODE GENERATION

There are three main difficulties that we face when attempting to generate efficient object code, namely:

  1. Selection of the most-efficient instructions to represent the computation specified by the three-address statement;

  2. Deciding on a computation order that leads to the generation of the more-efficient object code; and

  3. Deciding which registers to use.

Selecting the Most-Efficient Instructions to Represent the Computation Specified by the Three-Address Statement

Many machines allow certain computations to be done in more than one way. For example, if a machine permits an instruction AOS for incrementing the contents of a storage location directly, then for a three-address statement a = a + 1, it is possible to generate the instruction AOS a, rather than a sequence of instructions like the following:

MOVE a, R
ADD #1, R
MOVE R, a

Now, deciding which instruction sequence is better is the problem. This decision requires an extensive knowledge about the context in which these three-address statements will appear.

Deciding on the Computation Order that Will Lead to the Generation of More-Efficient Object Code

Some computation orders require fewer registers to hold intermediate results than others. Now, deciding the best order is very difficult. For example, consider the basic block:

If the order of computation used is the one given in the basic block t1-t2-t3-t4, then the number of registers required for holding the intermediate result is more than when the order t2-t3-t1-t4 is used.

Deciding on Registers

Deciding which register should handle the computation is another problem that stands in the way of good code generation. The problem is further complicated when a machine requires register-pairs for some operands and results.


Other  
 
Most View
Windows Vista : Build Your Network (part 7) - Troubleshoot Network Connections, Test an IP Address
Android Application Development : Rolling Your Own Widgets (part 3) - Canvas Drawing - Drawing text, Matrix transformations
Compact Liquid Cooling System Roundup – Front Runners (Part 2)
Smart, But Not Pricey : LG Optimus L7, Nokia Lumia 610, Sony Xperia U, Micromax A90S, BlackBerry Curve 9320, Nokia Lumia 710
AMD A10-6800 - AMD Accelerated Processors for Desktop PCs
Microsoft Lync Server 2010 : Microsoft Communicator Client for Macintosh - Audio/Video Calls and Conferencing
The Best Deals On Cool-Running Components And Passive Cooling Solutions
Are Your Passwords Safe? (Part 1)
Take Encoding Up A Level (Part 1)
Toshiba Satellite Pro L830 10J – An Affordable 13.3in Laptop
Top 10
Olympus Stylus 1 - The Pied Piper (Part 3)
Olympus Stylus 1 - The Pied Piper (Part 2)
Olympus Stylus 1 - The Pied Piper (Part 1)
Olympus Pen E-PL5 - April 2014
Nikon 1 J3 – April 2014
New Camera For You – Nikon 1 AW1
Phase One IQ250, Hasselblad H5D-50c - Medium-format Media Systems: Bigger Gets Better
Kaveri APU - AMD A10-7700K
Fujifilm X-M1 – Review April 2014
Fujifilm X-T1 : Good To Go