You are on page 1of 12
BPE WIE e Amol Pr In compiler design, storage organization is the FU Uta oer eet SSIS whichis shared between the com Pectin] System, anditarget machine. The logical address Chor perce aue tec) SS CUMa eer as Chua RRA ec Se om Coeur ner Seer Reel PCa ecuis kann ck cits ita Coeur ham nCircle esi Cea coe) es q ees Ren Uru keucte NRT) meu Ess eum ROR y Perera ae een St environment is the structure of the target eC cee musa Ru ce ek Cee | Peotone ete Me Se CsA) Cees SES eC CE et Ua Cupar’ ecco Rica cc Ce Cum eek Wek: 7) BS Ure De eee eae enc rca cht Bree mart aes ancon i oni eee + Heap storage allocation: This is the most flexible allocation scheme. Memory can be allocated Pe ere icc Ree ems Ree ee eure Trea Peete ioe UR ee MRC Uy en Cuic uc Causa ee en a BPE ATE Sea} rs 6 google.com/search?q) + @& ene eres In compiler design, stack allocation is Pitania ese Slarisenca Foaling ere ese teats | iis lel Pe Md Lae nuke) Breen ee eae ol aa Se cue PO eee eee ete ees ee Cee Rr ee lucutee en halted eee tee sete es and end. Each call of a procedure has an activation record that contains storage for the eee kurta Dee Ree cece Teese stone In stack-based allocation, a fixed-sized stack Coe eee eck rede icu) Cia oon Apa lis declared, a variable is assigned a memory location on the stack. This memory location can be freed when the variable's scope goes out. © Stack allocation takes place on contiguous ee eeu Keesler eed SRA eka co Variable specified in the program. © LOC Re ag ce eu Oo RT sad eae eras Reus Masked to + Iteliminates the feasibility of running out of Cee hee en Bera ere seus eee ron | procedure in which stack is used|to organ Rare ete Muse at Ms ele eect 12:03 AM | 165KB/s Z © Ea eT CnMCCLYAC LAA Access to Nonlocal Data on the Stack 1 Data Access Without Nested Procedures 2 Issues With Nested Procedures 3 A Language With Nested Procedure Declarations 4 Nesting Depth 5 Access Links 6 Manipulating Access Links 7 Access Links for Procedure Parameters 8 Displays 9 Exercises for Section 7.3 In this section, we conser how procedures access thelr data, Especially important isthe mechanism for Riding data used within a procedure p but that does not belong 1 p. Access hecames more complicated m languages whe procedures can be declared inside other procedures, We therefore begin withthe simple ease of functions, and then Introduce language, ML, that ‘permits both nested function declarations and tunetions fas “frstelass objects” that is, functions can take functions as arguments and return functions as values. ‘This capability can be supported by modifying the Implementation of the run-time stack, and we shall ‘consider several options for modifying the stack frames orsection 7.2, 1. Data Access Without Nested Procedures In the © family of languages, all variables are defined ‘either within a single function or outside any function (globally). Most importantly, Its impossible to declare ‘one procedure whose scope is entirely within another procedure, Rather, a global variable » has a scope isting of ll the functions tha fellow the declaration ‘of v, except where there is a local definition Identier Variables declared within a funetion have a scope consisting ofthat function only, oF par of I fh function has nested blocks, a discussed in Section 1.63, Discover elated toples Inplementation ofa Simple Stack location Scheme > Records > Accote Database > 12:03 AM | 136KB/s 2 © ! ‘Global variables are allocated state storage. The locations of these variables remain fixed and are ‘known at compile time, So to access any variable that Is not local fo the currently executing procedure, we simply use the statically determined address top ofthe sack y other name must be local tothe activation atthe We may access these variables through the topsp pointer ofthe stack, ‘an smportant benent of state allocation for global #¢ that declared prove-dures may be passed as parameters for returned a5 results Gin C @polater tothe function Is passed), with no substantial change in the data-accest strategy. With the © statiescoping rule, and without nested procedures, any name nonlocal (© one procedure is nonlocal to all procedures, regardless of how they are activated, Similarly, if a procedure ie returned as @ result, then any nonlocal name refers to the storage statically allocated fori 2. Issues With Nested Procedures ‘Access becomes far more complicated when a language allows procedure declarations to be nested and also uses the normal static scoping rule; that is, a procedure ‘can access variables of the procedures whose eclarations surround its own declaration, following the neste scoping rule deseribed for blocks i Section 1.63. ‘The reason is that knowing at compile time that the ‘ecaration of ps urmmediately nested within g does not tell us the relative postions of their activation records at run thme, In fas, slace either p or qor both may be recursive, there may be several activation records of p andjor q on the stack, Finding the declaration that apples to # nonlocal name xin qnested procedure pis @ stale dectsion; It ean be ‘done by an extension ofthe stallescope rule or Blacks ‘Suppose x is deelared in the enclosing procedure q Finding the relevant activation of @ from an activation ‘of pis a dynamie decision it re Master FrontendlBackene Full Devslonmeat Coding Sule Neos you de this ina inate aearart Apnly now to our DSA ta Drveloumeat Prnocum ae our counselor DT pe enews Splen OENS Canpatretas Dgaloge Simple Code Generator such a5 analyzing the soutce code ar rodcng a intermediate representation om it perorming ‘ootinintans on the IR to produce «target machine cod, and panerating atonal eoresetations (Ol for programs sac in debugging a tstng, In this paper, we desc ofr te mprove he desian of ple language gonerator, We ioduce 8 new reussle companent called “Stnpla Code Generator programming tagutge The SCG compenent consis of two parte: Ht t contains Into the target program, In thor words. a coce generator translates an abstract sntax tre to abatac ant tap insoles two ets one for eonstracting the abstract synte t60 nother foe ‘The fret stop involves constructing an Abstract Symi Tree (AST) by traversing all posable psthe ‘trough yeur api fle). Th tee wil contain Information about evry BR of dt in your program ae to compiling] orrntine nome eee Register Descriptor Register scoters ate data sinutues at store inormation abet the feiss sed i the rowan. Thi dee the registration number and ie name, along with Re type. The compen uses this ‘This is done by waking trop each ofthe reise and determining they contain vals Sats oF no. ‘her's thing in rele, than ican be used for oter purposes Adress Descriptor varktess deers sued to repeesent the memory locations sed by = program Acres decotre ‘ra reted bythe getReg fumeion, whieh vtume a sretue containing information about how to acose registers or onthe stale howaver, ony one stanc fen addres dotristor wil exit at en given tne lurtess another tess excutn) \Wmen the veer wants to retrieve data from ono re value fag. "M), whit the er should i Aly acessng ‘ts contents vin inect calls Uke LondFramBater) or Code Generation Algorithm ‘The aloo & spit into four parts: register desaptor setup, bs (} tes OF BOUS. Compaen DalapcendBegn CPs Index nt an ara of all posible values fo tha typeof reir (32. te alto stores information about ‘machine intructons usta lefrnation frm both ou ELF fil erat las the ones grated GCC) a8 ‘machine code for parca CPUs This fs where we start to se8 the magic of how comers werk a vated (22), Ti being peered (6. selon) and thee ‘we might know that 32-bit addition reques two registers ne to hold the value blag added, and one Instruction Scheduling: Ths stp ceerders instructions 0 tha they exacted eficanty on a partic srcitectue to detrinw the bat order for executing operations. also considers things Uke whether fot we have anaugh registers to stare values (some are in sel, i there's 8 battloneck somewhere Decign of the Function getReg ei return al ites values al estes. noting elseif thor ave othr parameters ter his ono (2nd arama than hey be sated foe ao hat en evaluated steady — this way we cont wacte any Hina praeztng data when nething haan a all there lent anything ater those two tes bu stan ensty sting (°F den nating ‘The outout of this phate ea sequence of machine Instructions that can bs executed with the bet of ‘ado forthe target computer. The code ganerte is tespenible for generating tho assembly language for ‘me tarot computer It takes a nat an interact format (somtimes calle compl IF, which hae The cade generators also response for generating object code that can be exgcuted on the target dita though several ahasss a camalaan whieh ture i into machine insrvetons Conclusion ‘readbla and concze as posible, wth no extraneous nie or cater Hotes 2 comolct radmin for yout bacon 3 deuloper Learn OSA > Matter FontendlBackene/Fll ‘Sack > Bul Projects» Keep Appiving te bs And why go anyn/ere else when our DSALO ‘eusoameat Casing Guise neps you do this na inate arearart < Previous Ieever, Importance and Applications of

You might also like