CD Shivani



There is document - CD Shivani available here for reading and downloading. Use the download button below or simple online reader.
The file extension - PDF and ranks to the Documents category.


416

views

on

Extension: DOCX

Category:

Documents

Pages: 14

Download: 74



Sharing files


Tags
Related

Comments
Log in to leave a message!

Description
ASSIGNMENT COMPILER DESIGN Submitted To:Ms Shweta Submitted By:Rajanarora Branch:CSE Sec:B1 Roll No:071076 Que1 : - Differentiate between i Phase and pass of compiler Ans:- a phase is a logically cohesive operation operation that takes as input one representation of the source program and produces as output another representation A compiler takes input a source program and produces output an equivalent machine language instruction It is not reasonable to consider entire process occurring
Transcripts
  ASSIGNMENTCOMPILER DESIGN Submitted To:Ms ShwetaSubmitted By:RajanaroraBranch:CSESec:B1Roll No:071076  Que1 : - Differentiate between i   Phase and pass of comp il er Ans:- a phase i s a l og i ca lly cohes iv e operat i on operat i on that takes as i nput onerepresentat i on of the source program and produces as output another representat i on Acomp il er takes i nput a source program and produces output an equ iv a l ent mach i ne l anguage i nstruct i on It i s not reasonab l e to cons i der ent i re process occurr i ng i n one step So wepart i t i on comp il at i on process i nto ser i es of subprogram ca ll ed phases L i sted be l ow are v ar i ous phases of comp il er:-1)   l ex i ca l ana ly s i s( separate source l anguage i nto groups that l og i ca lly be l ong togetherca ll ed tokens)2)   S y ntax ana ly s i s (group tokens i nto s y ntact i c structures ca ll ed express i on )3)   i ntermed i ate code generat i on( use structure produce to create s i mp l e i nstruct i on)4)   code opt i m iz at i on( i mpro v e i ntermed i ate code so that program runs faster)5)   code generat i on( produce f  i na l object code b y dec i d i ng memor y   l ocat i ons etc)Port i ons of one or more phases are comb i ned i nto a modu l e ca ll ed a pass A pass reads thesource program of the output of the pre vi ous pass, makes the transformat i ons spec i f  i ed b y   i ts phases,and wr i tes output i nto an i ntermed i ate f  il e, wh i ch ma y then be read b y a subsequent pass Thenumber of passes and the group i ng of phases i n d i ctated b y part i cu l ar l anguage and mach i ne Var i ousfactors affect i ng number of passes i n comp il er are;1)   forward reference2)   storage li m i tat i on3)   opt i m iz at i on ii )   code opt i m iz at i on and code generat i on Ans:- code opt i m iz at i on i s a techn i que that a comp il er emp l o y s to produce an i mpro v ed object code of source code It i mpro v es execut i on eff  i c i enc y of object code Programs that are expected to run man y  t i mes opt i m iz at i on i s necessar y , i t w ill   i mpro v es i ts execut i on t i me So th i s phase i n wh i ch a faster orsma ll er object l anguage program i s created i s ca ll ed opt i m iz at i on phase When app lyi ng an y  opt i m izi ng transformat i on, fo ll ow i ng cr i ter i a i s app li ed,1) Opt i m iz at i on shou l d be such that mean i ng of program i s not a l tered2) Opt i m iz at i on shou l d reduce t i me and space used b y object code3) Opt i m iz at i on shou l d capture most i mpro v ements w i th l ess amount of effort  Code generat i on phase con v erts the i ntermed i ate code i nto the sequence of the mach i ne i nstruct i on  A s i mp l e m i nded code generator m i ght map the statementA=B+C i nto the mach i ne code sequenceLOAD B  ADD CSTORE ATh i s target program ma y conta i n man y redundant l oads and stores and ut iliz e mach i ne recourses i neff  i c i ent ly So to a v o i d th i s code generator m i ght keep track of the run t i me contents of thereg i sters Code generator generates l oad and stores on ly when necessar y Factors affect i ng codegenerat i on are,1) Target code structure (structure i f target code contro l s the comp l ex i t y of code generat i on)2) Input ( i f operates, data t y pes are not stra i ght forward mapped then a good amount of effort Ma y  bee requ i red) iii )   mu l t i pass and s i ng l e pass comp il er Ans:-In computer programming, a one-pass compiler is a compiler that passes through thesource code of each compilation unit only once In other words, a one-pass compiler does not"look back" at code it previously processed Another term sometimes used is narrowcompiler , which emphasizes the limited scope a one-pass compiler is obliged to use This is incontrast to a multi-pass compiler which traverses the source code and/or the abstract syntaxtree several times, building one or more intermediate representations that can be arbitrarilyrefinedWhile one-pass compilers may be faster than multi-pass compilers, they are unable to generateas efficient programs, due to the limited scope available (Many optimizations require multiple passes over a program, subroutine, or basic block) In addition, some programming languagessimply cannot be compiled in a single pass, as a result of their designA multi-pass compiler is a type of compiler that processes the source code or abstract syntaxtree of a program several times This is in contrast to a one-pass compiler, which traverses the program only once Each pass takes the result of the previous pass as the input, and creates anintermediate output In this way, the (intermediate) code is improved pass by pass, until thefinal pass emits the final codeMulti-pass compilers are sometimes called wide compilers referring to the greater scope of the passes: they can "see" the entire program being compiled, instead of just a small portion of itThe wider scope thus available to these compilers allows better code generation (eg smaller code size, faster code) compared to the output of one-pass compilers, at the cost of higher compiler time and memory consumption In addition, some languages cannot be compiled in asingle pass, as a result of their design iv )   reg i ster a ll ocat i on and ass i gnment







Recommended
CD Shivani

CD Shivani

Shivani Arora

407 views

Shivani

Shivani

Anjana Iyer

388 views

Shivani Dixit

Shivani Dixit

Saree Blake

344 views

Shivani resume

Shivani resume

Grover Camillo

456 views

Dr Shivani Sachdev Gour

Dr Shivani Sachdev Gour

Niti Singh

286 views

Shivani Horoscope

Shivani Horoscope

wyomesh

316 views

NShima Xenakis

NShima Xenakis

490 views

E Se domani

E Se domani

331 views

Choking

Choking

331 views

Swara Chintamani

Swara Chintamani

luck00_

498 views

Surat Siaran

Surat Siaran

549 views

PP Dianpinsat

PP Dianpinsat

360 views