Unit-4 (Issues in Design of a Code Generator)
Unit-4 (Issues in Design of a Code Generator)
Final phae tn
Compiler. Miodel
. Ta7es inaut as. i intes me diate (code )
Pepresentation CIR)along: klitt Symbol tale
and Prpduue
efuivalent
cutput a s a
target Tmgay Semanttlasly
Sewp ront end Code
Btaiz Csdee yabes tage t
pttmze
Progam lntemudkate Lnbemdiate
Cade
Porogram
code
- Code optrniter and Code generato s
Often referedto as bach end
Cade qeneratohad,tare Primary tasse.
tnnstzclrion. Selckion,
Registesallotalton.and assignment
lnstcion ordeoing
Isshesvin Design
Code
Code,Jeneator
Tereakvr"
The tnput to te Code generabor i's
the intermediat ee epresentatton
Pro goam along hlite tPre informnation
Symbol Table
*Triples
*ndirect Triples
maehihe Representaios.
ais Bjte code .
*Stach machine:s code
Represerntatron
tPosfi x. otatn
Graphite! Represen tatton
.DAG
ln thiue
Sytaz
phase'Tle asaUe
assine syntactteand
Seman tc" s:have beenA detected
meressay
Cone sion
type
hare cherhtng
been tahen plae
and
type
assume enfut
these
arget Poq1am :
Codeeqeneatos, Jenera/es. direrent
typesof;: tasget: codesisincluding .
Absolute Machine Progran
kaagrage Pegan
- Relo catate
CoBject.code. )) "
Assembly kangnage Dqsan
tarqet
imp a t t . : n
hignt code.
Assenanchitekue
aLhine has a
generatq
Signiticant
thati Ppdures
Of t e .
-machihe codi.
quality
A.MsSts Cornnon. tasget ma'hine
arhiteefure,r Q e·.*:.i
-RSe.(Reluced stnscktbr set compute)
-ci[c (.complex lnstutton set Compute)
RisC achine,i.has
- ManyRegisters
-Three addretinsiutrpns,:
isimple Addaesing mde and
inHuetion.set
Set a3chi tects%
CI SCsmacfihe.,sshas
Fe4Regis1s
"TTo SAddsess InstauLftons
rapiely ot'Addressin. i2nade
Sereral hegisterClauis: i ,it
yaiabie tergt. nstuctione
kli te:Sdeeffees
* Absòlute ach'ne'.
has tre adrantage that
Langnage Program
Fixed locaton, Meno y
in
ADD Re,
ST
3ADD:
ST a, Ro Redndant Loa
nd Stogei
ÄDD Ro Roves
d, Ro
.
tasqet mathine has
an lnrement instaution N) then..
three addressi Statement i a :Qt
le mented.by,.
LNCa::
Jettoni ng' Code.s
Reqìster AllocaHon.
Code..qengrattoa S
thè.Primary
desiding how: to nse
I2gistex
There13:ae Four Prinipal, nsesof1:
reqistes
) ÍoG t:'máthine. iarchi teetuseome |0w
all gperand! Shoutdl be in,;KRgistex;
cu) Regiskers : Stor keporarict
(zü) Reqistess hod9lsfal Vales
. (iw. Registex f ten nsed to he. -zLntime
sterage. management
reg,regeq
4. Regis ter and add vess Destripc
Rezister: destriptis jeeps trach of tie
the.
Yariables nameS Dhose Öurent:.alues
in the' "Registesui
Addess descriptor Heeps tract
Location locations iAShere theceNt
ValùeNÖf: tiati ariable .can besteund.
yis mat\, i Ry
y is aheady inn Ry, change Registeo
ofRy that i\sinelydes
as'one.o teralue tn Ry:.
Endinqithebasicibioeh:
For tênporary yalues do- groting
The yalues nhith tsty. afte
the ibo chtHi f s : ' found Some
here'nnermony sto She ,the
lnstructton
thëopesängss
it ris iot.n: used:s.Lateooh.
then ISSSLe $T V,R
tg='e +t
(t
base-Root -|
Next 'hered.-2
LD .R3,:d
LD
ADD :R3,Re, R
LO.Rasb
LD Ri
i3ADDRà, R, R
3. Eraluatng. Expressione:,ii aa lnsnffcient
Supply : Regste i
lhen. these are feje regìstes availaHe.
than the Label the, ot of toee.
Need to add Sbis Some instauetton
to Bko ie Value Subtsee into memo y .
and We. need to load trat values baet
ìnto egistes as neeged:
ex:
LD
LD
LD: Rye
ÀDD .R RiP
LD Kja
ADD RR22