OneStopGate.Com
OnestopGate   OnestopGate
   Monday, December 23, 2024 Login  
OnestopGate
Home | Overview | Syllabus | Tutorials | FAQs | Downloads | Recommended Websites | Advertise | Payments | Contact Us | Forum
OneStopGate

GATE Resources
Gate Articles
Gate Books
Gate Colleges 
Gate Downloads 
Gate Faqs
Gate Jobs
Gate News 
Gate Sample Papers
Training Institutes

GATE Overview
Overview
GATE Eligibility
Structure Of GATE
GATE Coaching Centers
Colleges Providing M.Tech/M.E.
GATE Score
GATE Results
PG with Scholarships
Article On GATE
Admission Process For M.Tech/ MCP-PhD
GATE Topper 2012-13
GATE Forum




GATE 2025 Exclusive
Organizing Institute
Important Dates
How to Apply
Discipline Codes
GATE 2025 Exam Structure

GATE 2025 Syllabus
Aerospace Engg..
Agricultural Engg..
Architecture and Planning
Chemical Engg..
Chemistry
Civil Engg..
Computer Science / IT
Electronics & Communication Engg..
Electrical Engg..
Engineering Sciences
Geology and Geophysics
Instrumentation Engineering
Life Sciences
Mathematics
Mechanical Engg..
Metallurgical Engg..
Mining Engg..
Physics
Production & Industrial Engg..
Pharmaceutical Sciences
Textile Engineering and Fibre Science

GATE Study Material
Aerospace Engg..
Agricultural Engg..
Chemical Engg..
Chemistry
Civil Engg..
Computer Science / IT
Electronics & Communication Engg..
Electrical Engg..
Engineering Sciences
Instrumentation Engg..
Life Sciences
Mathematics
Mechanical Engg..
Physics
Pharmaceutical Sciences
Textile Engineering  and Fibre Science

GATE Preparation
GATE Pattern
GATE Tips N Tricks
Compare Evaluation
Sample Papers 
Gate Downloads 
Experts View

CEED 2013
CEED Exams
Eligibility
Application Forms
Important Dates
Contact Address
Examination Centres
CEED Sample Papers

Discuss GATE
GATE Forum
Exam Cities
Contact Details
Bank Details

Miscellaneous
Advertisment
Contact Us


Home » GATE Study Material » Computer Science » Compiler Design>

Compiler Design

Looking for GATE Preparation Material? Join & Get here now!

** Gate 2013 Question Papers.. ** CEED 2013 Results.. ** Gate 2013 Question Papers With Solutions.. ** GATE 2013 CUT-OFFs.. ** GATE 2013 Results.. **

<<Previous Next>>
Instruction Selection

The nature of the instruction set of the target machine determines the difficulty of instruction selection. The uniformity and completeness of the instruction set are important factors. If the target machine does not support each data type in a uniform manner, then each exception to the general rule requires special handling.

Instruction speeds and machine idioms are other important factors. If we do not care about the efficiency of the target program, instruction selection is straightforward. For each type of three- address statement we can design a code skeleton that outlines the target code to be generated for that construct.

For example, every three address statement of the form x := y + z, where x, y, and z are statically allocated, can be translated into the code sequence

MOV y, R0 /* load y into register R0 */ ADD z, R0 /* add z to R0 */ MOV R0, x /* store R0 into x */

Unfortunately, this kind of statement � by - statement code generation often produces poor code. For example, the sequence of statements

a := b + c d := a + e

would be translated into

MOV b, R0 ADD c, R0 MOV R0, a MOV a, R0 ADD e, R0 MOV R0, d

Here the fourth statement is redundant, and so is the third if �a� is not subsequently used.

The quality of the generated code is determined by its speed and size.

A target machine with a rich instruction set may provide several ways of implementing a given operation. Since the cost differences between different implementations may be significant, a naive translation of the intermediate code may lead to correct, but unacceptably inefficient target code. For example if the target machine has an �increment� instruction (INC), then the three address statement a := a+1 may be implemented more efficiently by the single instruction INC a, rather than by a more obvious sequence that loads a into a register, add one to the register, and then stores the result back into a.

MOV a, R0 ADD #1,R0 MOV R0, a

Instruction speeds are needed to design good code sequence but unfortunately, accurate timing information is often difficult to obtain. Deciding which machine code sequence is best for a given three address construct may also require knowledge about the context in which that construct appears.

REGISTER ALLOCATION

Instructions involving register operands are usually shorter and faster than those involving operands in memory. Therefore, efficient utilization of register is particularly important in generating good code. The use of registers is often subdivided into two subproblems:

1. During register allocation, we select the set of variables that will reside in registers at a point in the program.

2. During a subsequent register assignment phase, we pick the specific register that a variable will reside in.

Finding an optimal assignment of registers to variables is difficult, even with single register values. Mathematically, the problem is NP-complete. The problem is further complicated because the hardware and/or the operating system of the target machine may require that certain register usage conventions be observed.

Certain machines require register pairs (an even and next odd numbered register) for some operands and results. For example, in the IBM System/370 machines integer multiplication and integer division involve register pairs. The multiplication instruction is of the form

M x, y

where x, is the multiplicand, is the even register of an even/odd register pair.

The multiplicand value is taken from the odd register pair. The multiplier y is a single register. The product occupies the entire even/odd register pair.

The division instruction is of the form

D x, y

where the 64-bit dividend occupies an even/odd register pair whose even register is x; y represents the divisor. After division, the even register holds the remainder and the odd register the quotient.

Now consider the two three address code sequences (a) and (b) in which the only difference is the operator in the second statement. The shortest assembly sequence for (a) and (b) are given in(c).

Ri stands for register i. L, ST and A stand for load, store and add respectively. The optimal choice for the register into which �a� is to be loaded depends on what will ultimately happen to e.

t := a + b t := a + b t := t * c t := t + c t := t / d t := t / d (a) (b) fig. 2 Two three address code sequences L R1, a L R0, a A R1, b A R0, b M R0, c A R0, c D R0, d SRDA R0, 32 ST R1, t D R0, d ST R1, t (a) (b) fig.3 Optimal machine code sequence

CHOICE OF EVALUATION ORDER

The order in which computations are performed can affect the efficiency of the target code. Some computation orders require fewer registers to hold intermediate results than others. Picking a best order is another difficult, NP-complete problem. Initially, we shall avoid the problem by generating code for the three -address statements in the order in which they have been produced by the intermediate code generator.

APPROCHES TO CODE GENERATION

The most important criterion for a code generator is that it produce correct code. Correctness takes on special significance because of the number of special cases that code generator must face. Given the premium on correctness, designing a code generator so it can be easily implemented, tested, and maintained is an important design goal.

<<Previous Next>>
1 | 2



Discussion Center

Discuss/
Query

Papers/
Syllabus

Feedback/
Suggestion

Yahoo
Groups

Sirfdosti
Groups

Contact
Us

MEMBERS LOGIN
  
Email ID:
Password:

  Forgot Password?
 New User? Register!

INTERVIEW EBOOK
Get 9,000+ Interview Questions & Answers in an eBook. Interview Question & Answer Guide
  • 9,000+ Interview Questions
  • All Questions Answered
  • 5 FREE Bonuses
  • Free Upgrades
GATE RESOURCES
 
  • Gate Books
  • Training Institutes
  • Gate FAQs
  • GATE BOOKS
     
  • Mechanical Engineeering Books
  • Robotics Automations Engineering Books
  • Civil Engineering Books
  • Chemical Engineering Books
  • Environmental Engineering Books
  • Electrical Engineering Books
  • Electronics Engineering Books
  • Information Technology Books
  • Software Engineering Books
  • GATE Preparation Books
  • Exciting Offers



    GATE Exam, Gate 2009, Gate Papers, Gate Preparation & Related Pages


    GATE Overview | GATE Eligibility | Structure Of GATE | GATE Training Institutes | Colleges Providing M.Tech/M.E. | GATE Score | GATE Results | PG with Scholarships | Article On GATE | GATE Forum | GATE 2009 Exclusive | GATE 2009 Syllabus | GATE Organizing Institute | Important Dates for GATE Exam | How to Apply for GATE | Discipline / Branch Codes | GATE Syllabus for Aerospace Engineering | GATE Syllabus for Agricultural Engineering | GATE Syllabus for Architecture and Planning | GATE Syllabus for Chemical Engineering | GATE Syllabus for Chemistry | GATE Syllabus for Civil Engineering | GATE Syllabus for Computer Science / IT | GATE Syllabus for Electronics and Communication Engineering | GATE Syllabus for Engineering Sciences | GATE Syllabus for Geology and Geophysics | GATE Syllabus for Instrumentation Engineering | GATE Syllabus for Life Sciences | GATE Syllabus for Mathematics | GATE Syllabus for Mechanical Engineering | GATE Syllabus for Metallurgical Engineering | GATE Syllabus for Mining Engineering | GATE Syllabus for Physics | GATE Syllabus for Production and Industrial Engineering | GATE Syllabus for Pharmaceutical Sciences | GATE Syllabus for Textile Engineering and Fibre Science | GATE Preparation | GATE Pattern | GATE Tips & Tricks | GATE Compare Evaluation | GATE Sample Papers | GATE Downloads | Experts View on GATE | CEED 2009 | CEED 2009 Exam | Eligibility for CEED Exam | Application forms of CEED Exam | Important Dates of CEED Exam | Contact Address for CEED Exam | CEED Examination Centres | CEED Sample Papers | Discuss GATE | GATE Forum of OneStopGATE.com | GATE Exam Cities | Contact Details for GATE | Bank Details for GATE | GATE Miscellaneous Info | GATE FAQs | Advertisement on GATE | Contact Us on OneStopGATE |
    Copyright © 2024. One Stop Gate.com. All rights reserved Testimonials |Link To Us |Sitemap |Privacy Policy | Terms and Conditions|About Us
    Our Portals : Academic Tutorials | Best eBooksworld | Beyond Stats | City Details | Interview Questions | India Job Forum | Excellent Mobiles | Free Bangalore | Give Me The Code | Gog Logo | Free Classifieds | Jobs Assist | Interview Questions | One Stop FAQs | One Stop GATE | One Stop GRE | One Stop IAS | One Stop MBA | One Stop SAP | One Stop Testing | Web Hosting | Quick Site Kit | Sirf Dosti | Source Codes World | Tasty Food | Tech Archive | Software Testing Interview Questions | Free Online Exams | The Galz | Top Masala | Vyom | Vyom eBooks | Vyom International | Vyom Links | Vyoms | Vyom World
    C Interview Questions | C++ Interview Questions | Send Free SMS | Placement Papers | SMS Jokes | Cool Forwards | Romantic Shayari