Here include all sorts of theory question from chapter one to chapter four and try to give the solution of some other questions.
FIFTH SEMESTER COMPUTER CS6551 NETWORKS TWO MARK WITH ANSWER
DSP 2m Unit1-Unit 5 With AnswerFull description
book
Outline of Compiler DesignFull description
Full description
MS Access Question & AnswersFull description
TQM 2&16 Mark with answer
CA
Wind TunneL 2 MarK and 16 MarK With AnsweRFull description
Full description
cd lab manual for btechFull description
fffffffff
Gate Compiler design book is very useful for student who want to prepare for GATE. This book is part of GATE correspondence course study material by THE GATE ACADEMY. http://thegateacademy.com/
Question Bank
Full description
Bootstrapping is the process of writing a compiler (or assembler) in the target programming language which it is intended to compile. Get your copy of Term Paper/ Journal here. Get Bootstra…Full description
book
Principles of Compiler DesignFull description
VTU specified compiler design programms...!!
cd
two marks with answers
Full description
COMPILER DESIGN
[Year]
K.L.N. COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION INFORMATION TECHNOLOGY T ECHNOLOGY UNIT IV CODE OPTIMIZATION AND CODE GENERATION TWO MARK WITH ANSWERS 1.What is code optim optimization? ization? The code optimization is required to produce an efficient target code. There are two important issues that need to be considered while applying the techniques for code optimization and those are: The semantic equivalence of the source program must must not be changed. The improvement over the program efficiently must be achieved without changing the algorithm of the program. 2.Explain Machine dependent optimization optimization.. properties that can reduce the It has some special machine properties amount of code or execution time. It is dependent on the source language and target machine. Using immediate instruction sequences. allocation, Utilization Utilization of special machine machine Ex:Register allocation, instruction sequences. 3.Explain Machine Indepentent optimization. optimization. arithmetic Operation in the IT depends only on the arithmetic language and not on the target machine. The program transformations improve the target code without taking into consideration any properties of the target machine. unreachable code from the source program. Elimination unreachable 4.Properties of Optimizing compiler. The source code should be such that it should produce minimum amount amount of target code. There should not be any unreachable code.
COMPILER DESIGN
[Year]
Dead code should be completely removed removed from source so urce language. The Optimizing compilers should apply following code improving transformations on source language. Common sub expression Elimination Dead code Elimination E limination Code movement movement Strength reduction 5.Transformation 5.Transform ation techniques that can be applied applied in code Optimization. Constant folding propagation Constant propagation Common sub expression Common propagation Variable propagation Code Movement Strength Reduction Dead code Elimination Loop Invariant computation Optimization Loop Optimization 6.What 6.What is constant Folding Intuition:Based on deducing at compile time, that the value of expression is a constant. Constant folding is the transformation that substitutesnan expression with a constant. Constant folding is useful to discover dead code Ex: if(x) goto L. x is always false. We can eliminate both the if test and jump to L. 7.Explain Constant Propagat Propagation. ion. In This technique the value of variable is replaced and computation computation of expression is done at the compile time. A=Pi*r*r Ex: Pi=3.14 r=5 Pi is replaced by 3.14, r is 5 then comput computation ation of 3.14*5*5 is done during computation. computation. 8.Explain Common Sub Expression. i s called Common sub An occurance of an expression E is Expression. If E was previous computed and values of
COMPILER DESIGN
[Year]
variables in E have no changed,since the previous computation. Assignments to temporary variables involving common sub expression can be eliminated. 9.Explain Dead code Elimination. Intiuition:A variable is live at a point in a program if it value can be used subsequently otherwise is dead. computed is never Deadcode:A piece of code is dead, if data computed used elsewhere and can be eliminated.. Useless code can better be eliminated. Dead code may appear as the result of previous transformation.Dead transformation.Dead code works well w ell together with copy propagation. propagation we can see that x is never nev er reused Ex: After copy propagation all over the code. 10.Define Code motion o ptimization ization can be obtained by moving The loop invariant optim some amount of code outside the loop and placing it just before entering in the loop. It moves code outside the loop. The transformation takes an expression that yields the same results independent of the number of times a loop is executed and place the expression before the loop. statement Ex: Consider the statement while(i<= limit-2) Code motion t:limit-2 while(i<=t) 11.Explain Induction variable elimination. elimination. A variable x is an Induction variable of a loop if every time the variable variable x changes values, values, it is incremented incremented or decremented decremented by some constant. variables. In general when there are two or more Induction variables. It is possible to get rid of all but one. 12.Explain Reduction in strength strength.. computation with a less It is based on the replacement of a computation expensive one.
COMPILER DESIGN
[Year]
This replacement will speed up the object code if addition takes less time than multiplication as is the case in i n many machines. 13.Define Loop unrolling. method the number of jumps and test test can be In this method reduced by writing the code two times. 14.Define Peephole Optimization. It is a method for trying to improve the performance of the target program by examining a short sequence of target instructions and replacing those instructions by a shorter or faster sequence wherever possible. The peephole is a small moving window on the target program. 15.State the role of a code co de generator.
As we see that the final phase in any compiler is the code generator.
In takes as input an intermediate representation of the source program and produces as output an equivalent target program, as shown in the figure.
Optimization phase is optional as far as compiler’s correct working is considered. In order to have a good compiler following conditions should hold:
COMPILER DESIGN
[Year]
16.Explain the various form of object code.(RE)
Absolute machine code: Producing an absolute machine language program as
output has
the advantage that it can be placed in a fixed
location in memory memory and immediately immediately executed.
Relocatable machine code:
Producing a relocatable machine language program as output allows subprograms to be compiled separately. A set of relocatable object modules can be linked together and loaded for execution by a linking loader. If the target machine does not handle relocation automatically, the compiler must provide explicit relocation information to the loader, to link the separately compiled program segments.
Assembly code: Producing an assembly language program as output
makes the process of code generatio ge neration n some what easier.
17.Define Intermediate code generation?
Retargeting is facilitated. facilitated. That is, a compiler for a different machine can be created by attaching a back end for the new machine to an existing front fr ont end.
A machine-independent code optimizer can be applied to the intermediate intermediate representation.
COMPILER DESIGN
[Year]
18.State the application of DAG. DAGs are useful for: 1. Removing common local sub-expressions. 2. Renaming temporaries. 3. Finding names names used inside the block but evaluated outside. 4. Finding statements in the block that could have their computed values used outside the block. block. 5.Statements 5.Statements that can be reordered (or executed in parallel). 19.fuction Getreg()
The function getreg() when called upon to return where the computations specifications by the three address statements x=y op z should be performed returns a location l.
20.Register and address descriptors.
The code generation algorithm uses descriptors to keep track of register contents and address for names.
Register descriptors: A register descriptor is a pointer to a list containing information about the current contents of each register. Initially,all the registers can be empty.
Address descriptors: an address descriptors keeps track of the location where the current values of the names can be found at runtime. This information can be stored in the symbol table.