Chapter-5 - Intermediate Code Generationfsjfksjkfjsdjfdkjf
Chapter-5 - Intermediate Code Generationfsjfksjkfjsdjfdkjf
Cenerotion
Intesmediate Code:
ComPiles ConvestS ehe SoUdce
mto ecsy to P am
dePresemt cmuage
lamguoge
eTmediate Called
CeCC
+ho
directYlungucge in+o
befos
befotee trans lcatI
latin2
macwne
mucne uvuage
The dePre S
avauce Prorm.
rjam,
entction of Hhe
ngucge Caum be
Classilies jntesmedi ate
(1) Hiah level as:
KePres entadt ion:
T + is closesto h e
Souce
T etang Progam
T + is hePaogaUm 9¥TuCture
easy togenesate rom Hhe
u t in
He, Code P he 1]p
ilp Paq1a,
Paejra
zatiom is n ot
S+Saight toTOaTd.
Ex Syn+ax tree
Pos+fix ExPTessioM,
DA
Lo vel ePresentatoL
3T4 is C os es fo h e
T+ 7s ecsy to taxa eA mactinee
fvom fis,
3enerote tara
tasa et Code
et Code
I+ Tequres mo e
1ow ew el effor+S o
En
t e r mediate Code enerete
Cede aom
>om
Three - addreSs Source Code.
Code.
Code.
Sumtax Iec :
T+ S S C ComPact oTm of PaTse
tee +het
ePesenE
he ieracica
S+TUCAUTe o h e PoUA
I n SvmtcAx m.
tre e
Imterio odebaamch
+he OPeCHOD S, nodeg TePTesents
LeLeef nodel Tevmimcd node
+he OPedAndS. de Presents
CL
Umimuß b Uminus
Umins
C
Example (A + B) *CC+D)
Pos+tix motC+ion : AB CDt*
hsee Address Code
The 4esm }hree Odddess Code" Conains
+hree
And
addesses,fwo toa +Hhe oPerandS
Ome o r h e desult.
Thre e
addre ss Code is a Sequemce ot
Statememt of +he. o t r :
a : b OP C
here, CL,b and C the ae
het Com be names OPeTand s
o r Consaunt=
OP StamdS t o r amy
SPeTtoT.
Ex a =b+ C+d X X *Y +
z-X
Thsee address Code 1s:
ti X*Y
t i = b +c
t2 t1+ Z
ta t1+d t3 t2 -X
a t2 X t3B
xamPle 3 X = -
CL* b t - al*b
t CL
t2 t1 *b Three Address Code
t3-CL
t4 t3 * b
ts t z t t y
X
t5
Qucdurle
T+ is
Repesentathom 2
Such as
aSHucAUre c h
cUim ct most
OP, CAsg1 , mos t
ars2 and zesult.tou
tour tieds
tieds
OPerator Asgi Ay2 Result
(oUminus a t1
C * ti b t2
(Uminus aL t
(3 Lab
C + t ty ts
G5)= ts
Tirle RePresentation
not used
Im riple, temPoraries are
SYmo)
nsed of h c t Pointers i n he
OP A Ars2
(o Umimus a
C1 (0)
Cz mimus a
(3 (2
C4 C1 C3)
CS (4)
SHatemet OP A1 Aaj2
Co14) Co minus CL
CIS Ct C14D b
C1
C2 mimus C
(2 (16
C3C17D C3 C16) b
(4 + C15) C14
(4 C18)
CsC11
C C18)
*Cons+Tuttion tSyntux Tee DAG
S4ePS
exPression into P0SttiX
Comvert he
0 4 C+ion
Cseate modes vntax t c e
3Coms+a t SynCIX ree.
Pa
P6
41Pa
SteP 4
ConstTMCE odes ot DACT.
T TDAG, nodes are
manmes as
onstTuCted in Samne
Symtax tree ex Cept +het modess
O Common odes
Subex PTESs\on are Csecut ed
nce Only
S o 4em the Set of
mod es Ot Svntex tYee of
ven cxPTessiOn, m odes
P6, PT and P% r e
Avoided in DA and
Amd fA are uced insted modeS:
P2, P
TePre sent he
TesPec4ivey
Same
as ey
+hey
Cmd PS. OPeaetlonL as P6, P+
See 5:
Cos+Tu c4 DAGT
idb