SPCC Assignment 3-8

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

.

3
Dousn faning Bottorn - up Tagng
Top
teeh niq +hat
I. ts a pagng technique that L. T4's a
pomihg
l6west leve the
the I0ol at tthe
(Gok at the hughet levet o wore the
tree an woy own the
page tvee by uith the ales
fa ge fee by jing the ules Pase
qvamner.
gromm attenpt to veduca the
2.Tt attempts to hd tha let- 2. It
mast deyvation for an Input-st nhg nput stnhg to the staot symbol

3, Thiu teehnigue ses (yt-mst B. Thii techniqus use


Rght
nost Deyvation.
Denvation
letmost deuyon is 4. The main eus{on is to selet
4. The maih
to seleet shat production ule to when to paductio
<onstuct ule to reute t e stnng to
Use Yde to

st nn. qet the stavtng symbo


easier to mlement and
5. His Complex to
5. H is
understand. implement.
6. Cormmanly used alqonthms
Comn ants used alqonthms R (O), LRCS, LALR.
Rev u s e Decnt

fre dictve Povsin 7. T is sutable fo


wide
7. TA is suitabe tor l gramme.
Redue PoTS e.
Re cukne Deut rars e 8. sh

FOR EDUCATIONAL USE


Hundatanm,
Code opthimizotion techniqus on be mto to

types.
) Machine Inedependent aptimi zaion.

Thiy code optmization phose attempt to impve the


inteme ctiate code to bette tavqet cace a an Gutput
The pant the intemeiak c e shich is tron
yOmad
hene does t ihvelve ahy (PU i sten er abS8\u
emsnY
Iaz atton).
C6hstant Fotang

include < st dio.h


int main CS
tnt a =l0;
int b= 20;
1nt c= atb;

pnntt(%d;<); Vcanstant tolamg: It can be computet at &


empe tma.

- Ih thu exampe, the kpreian atb' in ve lve (ahstant


'1o' and '20! Dunng machine hdeperdent eptmi zaton,the
compilee Cah eyalua te
Thi xpeysr on at com pile tm and
at b' th the con itant value 30' e timinattn9 the
heed tor the aodition spevation at untima..

Sundaram FOR EDUCATIONAL USE


2) Machime Deptndent aptmization.
- machne Dependent ptmization is cona ajtu the tarqet cede
hay ben
qeneratd ond cahen the code is transformed
acerdingalvey
- It mw
to the
torqet rqet
registes
machune architectue
and may hane abselute
eeren e Yathar than
relate, herer
eren ces.
- machne Depndent eptmizey put elot to toke maimun
aduartag
Eg- Registy Allsation. hievarehy
#netude <staio.h
int man(){

int b= 20;
iht c= a t b lResul t stod in
printf( The
Ketum 0;

(X nplQ, he sult the addition


stred in
Speetor atb' is
memoy. Moere in, machina
depend ent spthmizmi zati on, the
compley (an all oeate CPU
nqisten to stoe ntemediae
values ilk la! b' e' nsttad so stonng Thi
reouey mem ace e tt me and imprey the sver al!
Fomarn te. Gehitetu
umted

Sundaramy FOR EDUCATIONALUSE


1. Tha tranil ation sf cote into the objet code
an pvodu ta idle - leve
for targetet machine, a compl can
code
uage. bohich Commonlq len6on ay. intemetiate.
lanquag
<eprekntati as foll ows:
) Pasiti on Notatio
2) syntax Thee
<) Thac adey cote ;
i)Ruadrapley
ii) Tiples
ü) Indivet Fnples.

Positi on Notation:
- Posii on otahon also known reyek p i s h notaHons is
F
expe1on whe copeyator tallows
speands.
Itis linear repreyentation thot avsidy the nee for paentheis
ello) Stict opevotor precudence
preee
Expeyion :- (s+ 3)* 4
Fotion Motaton :- 5 + 4 *
Evaluat on Poy om let to

Syntax Tree:
Syntax Trea alyo knon
Abstvact suntaxsouTcs
tree ae thee
dala stuctue that neprexnt stucture o card.
Each leal nae cescbe each interor ngde
eescnes on pevotor
Sundaran FOR EDUCATIONAL USE
atb *c-d.
Cxprem on :

Three Addres Code: am each


ohere
- tis lËnean entatian
repreyentatio
mot thre and ahd are
opey oandy
Inytucti on conjist o at
Gperaton vaniabley yer o
USe
I# maleay expicit
eyoluati on addreyyes
- Three Adde Code In eluce threg
and two
KAyu't

)auacple Yecord stuctus oith fietdy toY Gperat on


- 4 make se
erand
sub-dvided
- 4ietd
fsturOwt
iete hold coevator
wÝ hoids spevontsI|
next t o holds
and 2

(ayt ohe holdy vyult.

FOR EDUCATIONAL USE

Sundaram
i) Tnples:
- In the content o sperondy l 2 ave stored eyutt
field ave qenerally pethter to Symhol necor
- Three hetd ave videt ay:
O Fiyt contany operafor
Next two hol va'uu opevandy
a = bte k

te= bt ti
a= t2

ii) Inrret Tnplet:


It-i uye to list pnten to
tiples nitea uting taple
themselves
Thu method aray statcment (o list
in ceSIred order. peinter to tiples

Sundaram) FOR EDUCATIONALUSE


6
cGmpilers cate
Code genaration is a poan by ashieh
code into tom
genevato eonyert intemgl repnentati on
that cah e ene utd by mach) ne.
2.. lsjuL ote qenerati on phase ae:

OInput -eote aata Jor code genevation


-Input reeived by 1enevater to pro duce tarqet cote
ang muning vates
thtexnetiate
- Cade qeneratos typicaly code oich should
SoUSe,

accurately captum se

Tavqet Poram machne cde


Targ qet Proaram eqem to (anqua
compler qenerating ener ated code may vany stahi cantly
Dpendng
3)Intuzti on selection:
machine mututon
setection appYoprak
to implemant each spration
Compil e ned to select tnybueiany both sementÉ cally
CoYYeet and icient

alocaion aiqhment
frocen a aíqnanq variahley to hardwae vqstem
to mineihe
vanaley.
Sundaram) FOR EDUCATIONAL USE
9ptinmization:
qenevahng optimiza cade is a
VayiouS apttmizati on technique to incre uSe the

OExa ption Manlnq and Enor ttandirg:


- Main qal is to ceote q e sde t a t orectty hanles
exeaption, e n , abnoYmat p%qram behavou
s19nti contty înceases reliabltty o qeneatee code

Code si ze:
the qenated cade ) impostant
munimuzng
Compiley înctude teehnique Nlee eoee co mprenion, 4unctn
Inurin9. dead coe elimin ati on c.
The phaes cAmptlea folou.
I. Lexical Anatysis:
Thii phase taky al tnput poqram and
elemnt the a e conret it qeneat1 s1ream

to can
-fox the sttemant PERtR-s*3", the toon) id entiiet by
the texical analys e o uld Fe e, =,R, t,R, -s,*,3,

2. Syntax Anatysis:
Thy phaje ta key an input to kan genatated kby lexieat analyser
phaye and the syntax iS Loret.it qeneratea paNe teQ.
Fax the stat ement above, the pase mgnt be

z. Semantic Analysis: ahd maleey the


Thiù phase peym the tyf checting
F°severeyntation.
ne Lerany motiicati ony t he

For the statement


P t R - s * 3 * . the semantic analyseL
t hat eR, and s am ppery decared
nye
Opeyatony (t, -,) ahe cSmpatible wth
vaiable and the
1he tata type. o the opeand.
FOR EDUCATIONAL USE

Sundaram
4. Intemediak Code
Genevator:
Thi phaye qeneates an itemiate cote which halp to
Smpily the complety poram.tto
tey t he state n t PQ4R -S# z <te
intemediae
might lsek lilea:
t = *z
ta R+Q
tz = t - t i
P=t3
5. Coele Optmizatitn:
Tha phaje perom cspttnË zation so that the veyuting taYqet
Prram crutd_get exe utd fater.
For the stat ement p R t R-S*3', the optti z s
conytnt folting to Ropla caCest3
M côNtant, i 's' is a
contant Value.

6. Cocle qeneya tibn:


vesp anyble for genaaion o tarqet pqram
foy the statement P=+ R-s*3", tha code qenerator
qenerate machine intweti ony to peom the neceyiay
anthmetic apevationy end the reyult otll þe stoed in the
able
memo4 lgaion corveyponeihg to the vari
P.

7. EroY tantting and Symbol (able Manaqement:


Thoughout the the ccmple mantainy a s4mbol
table to lceep a track ol vanables, unetiony eq.data kype.
nune that ahy deteeted
Handlinq merhanum
are mpoted to cye in
dunhg The camp1laHen phaey
FOR EDUCATIONAA USE apppmak lomat.
daram

You might also like