We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 10
ka yn eran ah
4 Code Gunnin, abi Oe
a lesign tosuess, Enel
@Fachors Adfecdins code. genenabor_/code_gen
The. code. gente. concern, with:
drTnput fo the code erable: The spud to the. code generale 48
sutermediate. sesercbation. dogethor woth. dhe. x sarnallion.
$n the -sprabot fable, aL
2 The Tinged agra: The b of the code generator. 8 :
Typteallys te ciel an doce Gums such oe ae
yaching Las 9 ‘nebcatable sradiine San ard assembly Language,
whl Dodge ob pay deg Ll aad rol
forms hoc How ane at the. fired memeny Location.
Tac pe coal nll a
>the danget machine t Tinplemending code enenelion seegure
undorctanding of the target vraRlee andibectme and, als mnsfrucllm
Atrsbruclim seleeion: Tnedruction selection 23 arpockant to obfarn
~ efficient cade, Suppose we dranlate, Hnee-addvess code,
MOV @,RO
asa+t —\e #4,R0
Mov ROA
ADD 1,0,
COT sest efftctend:
> Register Allocation: Since. tslens ane the fasdead. memay mn
athe. computer , the vdeal allen bcloc oh ie
pet ‘erin a values an reotebess,
We, mus: 100 vi B
Ail Hts prolon hes Se poe nefits abany st toe,
> Ihech, as shod, be. shored, m 2
Which register, shoud cach sdecd to shoe value?
Eanes: fo the, second, problern. 48 thed, off
len. th 2 ston.
* £195 floading —potnce values tn floabin ae ine,
ercbat 7 meg
3 esllers and,
ements for evtnodd nepieber. palrs fon mullafeation /Atvieton,valuation. orden: The orden of the teorped code. can be affected by the
; et. an wht the ee et porknmed. a
. Bast bb ks:
ae Aten block, 16.0 sequence of consecutive mebruchions tr,
vehtch flo of condo! enlas evchn ive and. ext to anobher
paind tlheud hath or Bet 4
by: excep ad the erd.
MOV 4, RO MOV 4520
ADD 2) RO poy i ee
Mov 2, RA. MOL ROsRA
MUL R0,R4 IMP 12.
IMP [9 =
14: MUL 2,R0 L44MUL2; RO
SUB4 RA SUB 45R4
191 MUL, Ra LU MUL 3,24
JMPNZ R44 TMPNZ R41, M4
@Plow Graphs: A flo qreph. 48 geal nepresendection of a
tos A flea graph. canbe
delved. ab the srdonmediabe. cole. loved gy
ot fos gore ste fee eho tog He bach te nl
and. flao-ef-condeel do srt
gitlno eee by direcled. arma, Srmply af Fla of ron oceung
an bagic Ver uence
er poet He pha m of srebruchons Lhen such grt
enue Or alee
DD m RO uo
Mov 2, Rt Mov 2) R41
MUL 6, RA MUL RO,RA4
IMP LO. ump 19
ht MUL 2, RO Ms mvb2, 20
SUB A, RA SUB 4, RA
ho: MUL 3 R4
a LQ MUL BRA
YMPNZ R45 14 sMeNZ Ra LL38.
Ic program ode— menabion. orth,
= na Yn. can be used fo
ale te te mca able a
or Wit ou
Bee, eu ee adove,and add elo
sh heal we agsume. anchucton costs one unlt y Ld
athe 4S. eately be mediffe
the Mount. ae mh mitten can
work ewer $ each ins} ucdton nag alls om ‘cock.
Conbiguens evaluacton: Conpube the. evaluation ef Ts1, Get then evaluale rot,
Nen-tatiquous evaluadion: Broke evaluable ae ple 5 hag eae ra a
megls ister! ‘snexs evaluadeve 5 thor other
The nate programmi rattle. ge conbpriowg
evaluabion te prea 4g a”
» Compute. hobtom—up fr each node n ve te ion. dreT,
anay C of costs, m which to, onerds C} the
pla ed ere mpeg ee caroe lade
a regis eden. assum
and
aloe ng i wegtolers wo. swab forbhe computtatten ”,
», eee te rat ae 4 cleferrnine. vebtely sublrees
>i ei and. 69
crab rg el vebe Teles
the. Subbees cop sdb very el ns pmb vo,4:5 Code Ophinization.
The cede, opdrmntacction. re the. synthests phase. a
pegren- Lesh nondlbe “Tenge » which 4rtes fo coe Lhe, ,
snteomediate code 1h congurne, fewer. regounced, (jue CPU, Mem
0 that aie ae Lhe code, will result. zh
Optratzadin. of the code. ofler perforvned, a the
end of the cleveloprecr stage. atnce. Hf reecluceg veeodaliley and. adde
Code. thet 48 used ty snoseage the pedormance, "FI
5 bode, gine dene
@ Need, ¢ code. ophintzabton. J:shy opbhmtce? 1 AC od “8 Eomihy
Code. opstnrtzaction 93 néeded. because ophimtzalton eps tos
Reduce. Fhe. gpace consumed and. Increases the, speed of compilation,
> Manual] dabasels srvolves a tod ¢ time. H we make
wed lah ie ehh anal, Salah nn
pores i optimization 8 also dedtous and, 13 belle one.
COAL optimizer,
An. ophtmized, code often promotes’ re-usabrlh by
®Crtbera af code. opetinatzation;
> the optimteatton mus be. carrech, iL nn
Cape th main pagan, Me™ ey
> Opbintzaction should, Inereage the
the prgtary speed. and, performance df
>The compilation ts
P Ime. must be
the optinisabin, i“ ne able,
veces _should, not del&
Paste oobinazcdion techniques, Kop],
Mzedtms techmigu clasethed, alo doo cabygontes:
a Shel Zend ophtintzaton, dechniques
> Machine dependent optimtoation dechnyues,
1 Machine Independent ten dep ane pingrare.
Machine. sndependa ection. fechmagues are
deanefonmains daly teagel cok thos aby
constderadion any properties of the. angel ae
the
LAs atts name suggests, af srvates ebbing
cmstands, Yhe expressions dhoct conan Ihe dh consord
e, compile time ane evaluated those. exepressis axe then
. Kanye: Cincumsprence, of Cercle = (22/2) x Draneter
hs Hcbrigve evaluates dhe cxprescin, 20/t af comple Lime,
The. expression 48 then replated with ths sosull 3.14,
Pihis saves ste. ab sud dime,
bGretank fro edhion: Tr. this ecnigue, Sor we be ‘a
asst eS hard value, Morr sf vartab,
wae ate mn the futher pg dui cmptlation,
The cnn $8 tah Bhe vale mle og 4 clos boa,
——_ Fre 314, Roclius— 105 Area of ctrl — Ax Radius x Kadug
rhhre dechique substelules fo sabes ad tyadirn
3 ee ade epee eb dnb
> ion. Acta. woh}
Sirah ele a
Redundant Code Blintnation n, dey, gs eeecluncarf
kt tee lee ck mal Den pra dad
8 unnecessary such 08; cool. Hed 1g never. execufe| lnveachabfe cod)
7 a Dipabez
‘that 48 reechiced, hyp
A= 2404b.AVeriahle. Ro Repagab ny Variable. propageckon rneans use of oe. vartable.
~mateed. of another.
Beample: pe oy
Azpia®
That 48 reduced by, Az pl 1
Sheath reduchont th ravelves reducing the chenglh of expessine,
This Rehinique rest ee eeNe Ta ly ale with.
the simple an
Eeumple, Wale whom 1 Code adler sels
B= Ax2 B=A+h
oe 4g ai Ae ack cl ‘nll spin 2 ighen Shan
erabon alte wpe popes of roe with
Sloop oe CO EAN aS Sie et ttl nc
Code, Mofton./ Frequency Reduction: Th 15 a “ahi ishtch. moves the
code. al the,
Example: vshile (42.5000) Ths canbe, opdtmized. 2a
r= 3*emlh)*coslA); += stnin*cos(A);
(345000)
Ma 4%.
oe oe
to ane, Loop.
sea. da rd TH can be wyellen ag;
for gzttom do on. 42, 21 Lo m% yn do
ata jl=so. alil=10
Cea oe Jumps and deals can be red cod, ly
Sxample: sah 924; DE. caw be, guilles
hile (2-400) nih tot, *
aftl=bea; whale (410)
tes af= bl
4
arty
alad = bis
tts40.
D Machine Di ender 0, tiv ton. Techn ueg
fede cependont eplininb. dep oe asen nol
albedin and. “bik clon pected tithes yakcahs 2 Si
TE 48 ole after the Code taal hens enerabeel avd, us
code. 48 hanson aed aa to
hee A the chan machine. selena,
Rephole. Opbinteation: Perhale ofinteaie’ av simple and effecln
ppd fered oy a roviag I bo ae ets di ox
Amprove. per: ce cf te iy Heth rb
as aa Fg pblon't Sephece dee
ence, iheneve possi
d Eel program, Rede
or ee Hechninues 23s follreg; fy Doar at
o> Ke ha load, are. Shove Ely inadion: tn, és bechnit
2achuncancy 18 dhtiminaded, “= ete pre te
Examples” sy ebral codes Opdirateed, coo
gents;
StS 5
qoys Fy,
2-43 Wea yrs:
We zezy 7
The Pins f Enbrel Optimteation:
Dead, Code, Elimination: 8 trvobves. elimiradh the dead. code fe,
Meblonole peck old ron execuleg chabh,
unrea
Code before optimization lode. adler. gobinnization
20; eee
of (4251) nd
sets:
3
apAvetel Suenp on fump: ‘The unnecess: J S Can ellminale m
Dhe. trbamediale code er he dangel Ll, ma ofthe
We. ed nplace Lhe} Jump Sequences
i ai
Le, +
i Grad ae ence,
Lit gels Jo |Atoebnaic S calron:s Reephole optinnteadion ie an. Heclive.
Aeconse for abgsbrcate etna he pbaboranls, oh 3
PCaUHO of coe tl con be. eliminabed. by peeprle. ophinteaton
dd Machine. sdioms: The donget amstruchins dove uvvalerd machine.
fe te pond Some, operat Hence we can replace
Sa i “ey equivalent mackie. -msbrudione 4n
Example: Some, enachinea hal. aulo—ancnement or aufe-decnenent
addressing modes,
Q Shrenath reduction: TH anvelves veeduing the, sheen fosprscios.
‘thes pechns Ue replaces the expensive a nee uth
the simple” and cheaper. ones. .
Example: Code befne. oplintzation, Codes oflen-opbinenbion
B=AXD BaA+AFE Compiler Design and. Conslruelin (Marking Scheme’ with Duy Ts
Dy meln,
Untbt (Shs): 5 maaks (ulyets phase Spthee ppc vs atop
Unita: (99 Ins): orepoes vs. Mallipsss compl
21 lexiral Aaclusis: 10 martes (dexerres, patfens, tolcons,
thomsons, consdrusction, subsel
212 Syabace fy 88 20 marke construction)
x analyz0r, Leff recursion,
23 Semmarbee Ar Bis} 40 marks Rt son Pens ie
“Medion, SUR psig dables, conn
Dwh3:(4. dnrs)t " cnt
Sypmbct Table Design: Srmankes
Run-time eborage managements, salar
Hiroe.
Unth as (16 Inns)
44 Tnmedtale Cole. Grenoretby t 10 marks (Rate grmediele cool
miter.
42 Coole Generator: B ake DR; Psd nodadion
43 Code Optimtzatim: 5 morkev
if my notes really helped
you,then you can support
me on esewa for my
hardwork.
Esewa ID: 9806470952