Partial preview of the text
Download system programming and compiler construction and more Lecture notes System Programming in PDF only on Docsity!
Assignment Ne, 5 a Explin the phase ses_ ef Goopiles with the help of example. As> Pcompileh 's a seftunne tool thod convents. high-teve 3 —piegramutng code into machine Code thal a coupubs .Co1n_umd ety Feuncl curd ercecute - dt acls o Ee i _ between umes headable code and machine level testaelans - J ly enabling fb icient Preghay execubion, The process ot . Y 1 . ' a | Compilation is Uvideel telo Six Phases : : le As Lex teal Paralysig : This phase takes as inpa the souhee_ pextun, _audifthe elements of the Phoghon ane cathect , [tgechls - | _Stheam of tokens - 4 | 2+ Syntax Analysis ! This phase takes as ivpub fhetefens enehote by lextea| “analysis h nol if the tax is — _¢g d alaudysis phase ands syntax is | Cosmet it genebates a psdse thee. 2, Semantic. Pralysist This Phase pontohms the Type cutin lane makes the vecescady rtodiPications jv the parse thee 1 | grepreseys afin. f le. Lnfem mediate Cole Generation: This phase genehetes aa ——~ {9 i tutetmroliate code whith helps to heduce the complexity of te] | code ——ae ie Code Ophimi zedion' This phase penforwe the a ey that nesatting febgel prog ham vould get execute Hes 1G. Code (reutrction: This phase |» desponsible Fon the gererahy pf tongel phoghaun - Lf the tecef phogham is assuably auguage_ =| Then after covspilen , we veed_an Assembler de geuttote Lmachtne languciy e phages, ——— fA 42: Syupo) Table? It is used Fob Keeping a thac 7 * sda} Se h ent ~ oie ch ln anya te compton phastS._. 4 || %, a =n ae =} ' | Escaumple! | Gs = b+ ¢ * 60” > Source Phopsraum emp iT nm d ER Leaieg| Aralysis idd = ido +ld3 & 60 _ 2 __ : Mz Syntax tnalysis ¥ ee — a 9 —.__ ee ue ec Analysis = _ =i ape , = a i is | Tatemmecdiate Code genehetion tL= 60:0 i _ f2r=tds*% tis uel Ts = ide + Ta | idd= ts | J Code optimization Ta std? * go.0 idi = td2 * to db code genevation | _ Mov R1, 60.0 | MOV R2, tds ae MUL At, Reo | Mov R3,id2 a! i. | ADD R3,R4 ema | MOV Rut, RBOR EDUCATIONAL A aa N | | Ko aet | 7 i ___ 12. Dnected Aepelia tr tap AG) | le f compte ssed Loum of DST thal eliefvotes comvron | sulbex phessions. |. Prevents tedundont Comp dati on by heusing pire vious} | Computed Values: rs | Exoun pe: | fom X= w+ Py - Ta Pa © 4, the Daw clouds | avoids hecowputetiau ot _b/y. us Contne) flew Graph CFG) . Rete ht le cl + Nooles hephesent. basic blacks (sequences a7 iwel without jumps). «Used iv tzatio on. Example! Fair aia if-else condition | Stant “ET 50) —- Yes ——> Block | Gi ' No Block B ] END ae -. Kandararh FOR EDUCATIONAL USE Viz “Salic Single Assignment CSSA): Soe is assigned exaclly once. ee Ts , p= functions isi 7 edad | values in diffetien gs ehe " ive) lelsect in _wedebm opti LV M1 | Excwsple: 2% = £0 | lE(y > 6) | : xe2exlLt& ) else | X2exxt —-S h sy = plier, x3) // Merging Xt aud x3 6. Postfix Ne fefian Che vebse. Polish Nef - RPN) ' Opetatots che written atfos “opetroud le Ne need fe b ae ZL waking ial evaldlie petticlent ow ssfow? y*C Postfix: : Tiwi omer A) Constou t FolcUng : Conpebes “constant ex poess comple tine instead of Suntine, — feemeple 1 jin t x c 10% 29 —> Opfinlzed int x =200) | Exounp be: + Comtan E pie pag ad fon! !Repla ves veatabhe tial bold | Covstant nite with thet valees » | Iut ase: , _» oplintzecl —> futb = = Sto; | int beatro; 2 1c) Zovmen Sabeephesslon E linda CCSE) ! Ef totunies hecdun dant computodions. Exam ple: I tut x= (ax b)+ We Naat i mp-=arb Int ¥= G@*b)+d) int 2¢ = temp4e | inf y = = temp dj A) Dead Code C)tuif nat'on ! Renoves cece Ttroy. ever Onecutes 0% has po effect. | Example: Ivf a=)! 2. A=10} L5_!s nevth Used , soitis tenova. © Leop-detatedion! : » Loop Untrelling 1 ExPands loop iterations to WAve bhanchlne Oven head « ‘Loop in yoStant Code Motion: Moyes Coympulations adick the loo ptt they heme wichoug ed: Example + Optimized int 20210 * 8 fen (int jaej} optimized inf xei <3} 2. Machine - Dependent Optimizations L These optimizations take into accouut the bosclecaye m__latchitectesre aud Imphove efficiency based onthe et wach!ne- Common tech viques ave : a) Registeh A) location Tu struction Scheduling c) Peep hale O ptiw) zed iow a ———Enise a. Wb. ..¢af Pr. aecahe Founo(s) = {hi ot ea : Follae(f) = pee tiFinst (@) = 25+ ‘rsa «Dame. é (Ss fees . FoLlow (mh) = b,c, $4 4 Sg! : @ Foto) Rule 2 es — == ——— —— — Conditlent is Thue ‘U Cendifien 2 fs thue i Trg, NM FOLLOW (RS = iat 23 Nf~bc ch “> Given gSroum mah Is “LLts) + ‘ 2 pe BE eg ee L wey ‘goto Li dt sa 8 ___hyi Design qadnuple and Flple fas falling exh | a= Core 14 Py ‘She. ft: ‘(renebrothas hued ie ANTON +2 = bt I Compt Cbtc) t2 zdre Coupe (dre) , Li tow pute (b te) * fd+e) | teeter pie a a=t3 ff Assign oe g | Step 2! Quadruple Be phes eabatiou iF [Inder | Optrote% Ags i Axe | Regu {| 4 i b*. (Gp ti | oe ot qi d 22 MMB 8 1 3 cus fa 2 (Aue % = +3 = a Se Steps) Tip le Reptesarfadion _ a — 1) Design Dit tephesentation den given exphessinas i —_ A=latyfa-c) DAG > Directed Bexclic (nbaph) —_Stept : Break Pown into subexpressions Be) 3-H = oth 12. fz =A. _ 13. te ati rte a y. a=ts F Step: DAG Constiuction I Nedes nephesent exphestlons ob values » Edges wnepresent deperclencies between Cpetalions ls (ovumion subexpressions ane ghatreel in DRO —_——— ————_ ot ane | _ tf — 7S ee |