ebook img

Basics of compiler design PDF

319 Pages·2010·1.619 MB·English
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Basics of compiler design

Basics of Compiler Design Anniversary edition Torben Ægidius Mogensen DEPARTMENTOFCOMPUTERSCIENCE UNIVERSITYOFCOPENHAGEN Publishedthroughlulu.com. (cid:13)c TorbenÆgidiusMogensen 2000–2010 torbenm@diku.dk DepartmentofComputerScience UniversityofCopenhagen Universitetsparken1 DK-2100Copenhagen DENMARK Bookhomepage: http://www.diku.dk/∼torbenm/Basics Firstpublished2000 Thisedition: August20,2010 ISBN978-87-993154-0-6 Contents 1 Introduction 1 1.1 Whatisacompiler? . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Thephasesofacompiler . . . . . . . . . . . . . . . . . . . . . . 2 1.3 Interpreters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.4 Whylearnaboutcompilers? . . . . . . . . . . . . . . . . . . . . 4 1.5 Thestructureofthisbook . . . . . . . . . . . . . . . . . . . . . . 5 1.6 Tothelecturer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.7 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.8 Permissiontouse . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2 LexicalAnalysis 9 2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.2 Regularexpressions . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.2.1 Shorthands . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.2.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.3 Nondeterministicfiniteautomata . . . . . . . . . . . . . . . . . . 15 2.4 ConvertingaregularexpressiontoanNFA . . . . . . . . . . . . . 18 2.4.1 Optimisations . . . . . . . . . . . . . . . . . . . . . . . . 20 2.5 Deterministicfiniteautomata . . . . . . . . . . . . . . . . . . . . 22 2.6 ConvertinganNFAtoaDFA . . . . . . . . . . . . . . . . . . . . 23 2.6.1 Solvingsetequations . . . . . . . . . . . . . . . . . . . . 23 2.6.2 Thesubsetconstruction. . . . . . . . . . . . . . . . . . . 26 2.7 Sizeversusspeed . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.8 MinimisationofDFAs . . . . . . . . . . . . . . . . . . . . . . . 30 2.8.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.8.2 Deadstates . . . . . . . . . . . . . . . . . . . . . . . . . 34 2.9 Lexersandlexergenerators . . . . . . . . . . . . . . . . . . . . . 35 2.9.1 Lexergenerators . . . . . . . . . . . . . . . . . . . . . . 41 2.10 Propertiesofregularlanguages . . . . . . . . . . . . . . . . . . . 42 2.10.1 Relativeexpressivepower . . . . . . . . . . . . . . . . . 42 2.10.2 Limitstoexpressivepower . . . . . . . . . . . . . . . . . 44 i ii CONTENTS 2.10.3 Closureproperties . . . . . . . . . . . . . . . . . . . . . 45 2.11 Furtherreading . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 3 SyntaxAnalysis 53 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.2 Context-freegrammars . . . . . . . . . . . . . . . . . . . . . . . 54 3.2.1 Howtowritecontextfreegrammars . . . . . . . . . . . . 56 3.3 Derivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.3.1 Syntaxtreesandambiguity . . . . . . . . . . . . . . . . . 60 3.4 Operatorprecedence . . . . . . . . . . . . . . . . . . . . . . . . 63 3.4.1 Rewritingambiguousexpressiongrammars . . . . . . . . 64 3.5 Othersourcesofambiguity . . . . . . . . . . . . . . . . . . . . . 66 3.6 Syntaxanalysis . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 3.7 Predictiveparsing . . . . . . . . . . . . . . . . . . . . . . . . . . 68 3.8 NullableandFIRST . . . . . . . . . . . . . . . . . . . . . . . . . 69 3.9 Predictiveparsingrevisited . . . . . . . . . . . . . . . . . . . . . 73 3.10 FOLLOW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 3.11 Alargerexample . . . . . . . . . . . . . . . . . . . . . . . . . . 77 3.12 LL(1)parsing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 3.12.1 Recursivedescent . . . . . . . . . . . . . . . . . . . . . . 80 3.12.2 Table-drivenLL(1)parsing . . . . . . . . . . . . . . . . . 81 3.12.3 Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . 82 3.13 RewritingagrammarforLL(1)parsing . . . . . . . . . . . . . . 84 3.13.1 Eliminatingleft-recursion . . . . . . . . . . . . . . . . . 84 3.13.2 Left-factorisation . . . . . . . . . . . . . . . . . . . . . . 86 3.13.3 ConstructionofLL(1)parserssummarized . . . . . . . . 87 3.14 SLRparsing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 3.15 ConstructingSLRparsetables . . . . . . . . . . . . . . . . . . . 90 3.15.1 ConflictsinSLRparse-tables . . . . . . . . . . . . . . . 94 3.16 UsingprecedencerulesinLRparsetables . . . . . . . . . . . . . 95 3.17 UsingLR-parsergenerators . . . . . . . . . . . . . . . . . . . . . 98 3.17.1 Declarationsandactions . . . . . . . . . . . . . . . . . . 99 3.17.2 Abstractsyntax . . . . . . . . . . . . . . . . . . . . . . . 99 3.17.3 Conflicthandlinginparsergenerators . . . . . . . . . . . 102 3.18 Propertiesofcontext-freelanguages . . . . . . . . . . . . . . . . 104 3.19 Furtherreading . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 CONTENTS iii 4 ScopesandSymbolTables 113 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 4.2 Symboltables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 4.2.1 Implementationofsymboltables . . . . . . . . . . . . . . 115 4.2.2 Simplepersistentsymboltables . . . . . . . . . . . . . . 115 4.2.3 Asimpleimperativesymboltable . . . . . . . . . . . . . 117 4.2.4 Efficiencyissues . . . . . . . . . . . . . . . . . . . . . . 117 4.2.5 Sharedorseparatenamespaces . . . . . . . . . . . . . . 118 4.3 Furtherreading . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 5 Interpretation 121 5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 5.2 Thestructureofaninterpreter . . . . . . . . . . . . . . . . . . . 122 5.3 Asmallexamplelanguage . . . . . . . . . . . . . . . . . . . . . 122 5.4 Aninterpreterfortheexamplelanguage . . . . . . . . . . . . . . 124 5.4.1 Evaluatingexpressions . . . . . . . . . . . . . . . . . . . 124 5.4.2 Interpretingfunctioncalls . . . . . . . . . . . . . . . . . 126 5.4.3 Interpretingaprogram . . . . . . . . . . . . . . . . . . . 128 5.5 Advantagesanddisadvantagesofinterpretation . . . . . . . . . . 128 5.6 Furtherreading . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 6 TypeChecking 133 6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 6.2 Thedesignspaceoftypes . . . . . . . . . . . . . . . . . . . . . . 133 6.3 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 6.4 Environmentsfortypechecking . . . . . . . . . . . . . . . . . . 135 6.5 Typecheckingexpressions . . . . . . . . . . . . . . . . . . . . . 136 6.6 Typecheckingoffunctiondeclarations . . . . . . . . . . . . . . . 138 6.7 Typecheckingaprogram . . . . . . . . . . . . . . . . . . . . . . 139 6.8 Advancedtypechecking . . . . . . . . . . . . . . . . . . . . . . 140 6.9 Furtherreading . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 7 Intermediate-CodeGeneration 147 7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 7.2 Choosinganintermediatelanguage . . . . . . . . . . . . . . . . . 148 7.3 Theintermediatelanguage . . . . . . . . . . . . . . . . . . . . . 150 7.4 Syntax-directedtranslation . . . . . . . . . . . . . . . . . . . . . 151 7.5 Generatingcodefromexpressions . . . . . . . . . . . . . . . . . 152 7.5.1 Examplesoftranslation. . . . . . . . . . . . . . . . . . . 155 iv CONTENTS 7.6 Translatingstatements . . . . . . . . . . . . . . . . . . . . . . . 156 7.7 Logicaloperators . . . . . . . . . . . . . . . . . . . . . . . . . . 159 7.7.1 Sequentiallogicaloperators . . . . . . . . . . . . . . . . 160 7.8 Advancedcontrolstatements . . . . . . . . . . . . . . . . . . . . 164 7.9 Translatingstructureddata . . . . . . . . . . . . . . . . . . . . . 165 7.9.1 Floating-pointvalues . . . . . . . . . . . . . . . . . . . . 165 7.9.2 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 7.9.3 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 7.9.4 Records/structsandunions . . . . . . . . . . . . . . . . . 171 7.10 Translatingdeclarations . . . . . . . . . . . . . . . . . . . . . . . 172 7.10.1 Example: Simplelocaldeclarations . . . . . . . . . . . . 172 7.11 Furtherreading . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 8 Machine-CodeGeneration 179 8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 8.2 Conditionaljumps . . . . . . . . . . . . . . . . . . . . . . . . . . 180 8.3 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 8.4 Exploitingcomplexinstructions . . . . . . . . . . . . . . . . . . 181 8.4.1 Two-addressinstructions . . . . . . . . . . . . . . . . . . 186 8.5 Optimisations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 8.6 Furtherreading . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 9 RegisterAllocation 191 9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 9.2 Liveness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 9.3 Livenessanalysis . . . . . . . . . . . . . . . . . . . . . . . . . . 193 9.4 Interference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 9.5 Registerallocationbygraphcolouring . . . . . . . . . . . . . . . 199 9.6 Spilling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 9.7 Heuristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 9.7.1 Removingredundantmoves . . . . . . . . . . . . . . . . 205 9.7.2 Usingexplicitregisternumbers . . . . . . . . . . . . . . 205 9.8 Furtherreading . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 10 Functioncalls 209 10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 10.1.1 Thecallstack . . . . . . . . . . . . . . . . . . . . . . . . 209 10.2 Activationrecords . . . . . . . . . . . . . . . . . . . . . . . . . . 210 10.3 Prologues,epiloguesandcall-sequences . . . . . . . . . . . . . . 211 CONTENTS v 10.4 Caller-savesversuscallee-saves . . . . . . . . . . . . . . . . . . 213 10.5 Usingregisterstopassparameters . . . . . . . . . . . . . . . . . 215 10.6 Interactionwiththeregisterallocator . . . . . . . . . . . . . . . . 219 10.7 Accessingnon-localvariables . . . . . . . . . . . . . . . . . . . 221 10.7.1 Globalvariables . . . . . . . . . . . . . . . . . . . . . . 221 10.7.2 Call-by-referenceparameters . . . . . . . . . . . . . . . . 222 10.7.3 Nestedscopes . . . . . . . . . . . . . . . . . . . . . . . . 223 10.8 Variants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 10.8.1 Variable-sizedframes . . . . . . . . . . . . . . . . . . . . 226 10.8.2 Variablenumberofparameters . . . . . . . . . . . . . . . 227 10.8.3 Directionofstack-growthandpositionofFP . . . . . . . 227 10.8.4 Registerstacks . . . . . . . . . . . . . . . . . . . . . . . 228 10.8.5 Functionsasvalues . . . . . . . . . . . . . . . . . . . . . 228 10.9 Furtherreading . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 11 Analysisandoptimisation 231 11.1 Data-flowanalysis. . . . . . . . . . . . . . . . . . . . . . . . . . 232 11.2 Commonsubexpressionelimination . . . . . . . . . . . . . . . . 233 11.2.1 Availableassignments . . . . . . . . . . . . . . . . . . . 233 11.2.2 Exampleofavailable-assignmentsanalysis . . . . . . . . 236 11.2.3 Using available assignment analysis for common subex- pressionelimination . . . . . . . . . . . . . . . . . . . . 237 11.3 Jump-to-jumpelimination . . . . . . . . . . . . . . . . . . . . . 240 11.4 Index-checkelimination . . . . . . . . . . . . . . . . . . . . . . 241 11.5 Limitationsofdata-flowanalyses . . . . . . . . . . . . . . . . . . 244 11.6 Loopoptimisations . . . . . . . . . . . . . . . . . . . . . . . . . 245 11.6.1 Codehoisting . . . . . . . . . . . . . . . . . . . . . . . . 245 11.6.2 Memoryprefetching . . . . . . . . . . . . . . . . . . . . 246 11.7 Optimisationsforfunctioncalls. . . . . . . . . . . . . . . . . . . 248 11.7.1 Inlining . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 11.7.2 Tail-calloptimisation . . . . . . . . . . . . . . . . . . . . 250 11.8 Specialisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 11.9 Furtherreading . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 12 Memorymanagement 257 12.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 12.2 Staticallocation . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 12.2.1 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . 258 12.3 Stackallocation . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 vi CONTENTS 12.4 Heapallocation . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 12.5 Manualmemorymanagement . . . . . . . . . . . . . . . . . . . 259 12.5.1 Asimpleimplementationofmalloc()andfree() . . . . 260 12.5.2 Joiningfreedblocks . . . . . . . . . . . . . . . . . . . . 263 12.5.3 Sortingbyblocksize . . . . . . . . . . . . . . . . . . . . 264 12.5.4 Summaryofmanualmemorymanagement . . . . . . . . 265 12.6 Automaticmemorymanagement . . . . . . . . . . . . . . . . . . 266 12.7 Referencecounting . . . . . . . . . . . . . . . . . . . . . . . . . 266 12.8 Tracinggarbagecollectors . . . . . . . . . . . . . . . . . . . . . 268 12.8.1 Scan-sweepcollection . . . . . . . . . . . . . . . . . . . 269 12.8.2 Two-spacecollection . . . . . . . . . . . . . . . . . . . . 271 12.8.3 Generationalandconcurrentcollectors . . . . . . . . . . 273 12.9 Summaryofautomaticmemorymanagement . . . . . . . . . . . 276 12.10Furtherreading . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 13 Bootstrappingacompiler 281 13.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 13.2 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 13.3 Compilingcompilers . . . . . . . . . . . . . . . . . . . . . . . . 283 13.3.1 Fullbootstrap . . . . . . . . . . . . . . . . . . . . . . . . 285 13.4 Furtherreading . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 A Setnotationandconcepts 291 A.1 Basicconceptsandnotation. . . . . . . . . . . . . . . . . . . . . 291 A.1.1 Operationsandpredicates . . . . . . . . . . . . . . . . . 291 A.1.2 Propertiesofsetoperations . . . . . . . . . . . . . . . . . 292 A.2 Set-buildernotation . . . . . . . . . . . . . . . . . . . . . . . . . 293 A.3 Setsofsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 A.4 Setequations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 A.4.1 Monotonicsetfunctions . . . . . . . . . . . . . . . . . . 295 A.4.2 Distributivefunctions . . . . . . . . . . . . . . . . . . . . 296 A.4.3 Simultaneousequations . . . . . . . . . . . . . . . . . . 297 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 List of Figures 2.1 Regularexpressions . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.2 Somealgebraicpropertiesofregularexpressions . . . . . . . . . 14 2.3 ExampleofanNFA . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.4 ConstructingNFAfragmentsfromregularexpressions . . . . . . 19 2.5 NFAfortheregularexpression(a|b)∗ac . . . . . . . . . . . . . . 20 2.6 OptimisedNFAconstructionforregularexpressionshorthands . . 21 2.7 OptimisedNFAfor[0-9]+ . . . . . . . . . . . . . . . . . . . . . 21 2.8 ExampleofaDFA . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.9 DFAconstructedfromtheNFAinfigure2.5 . . . . . . . . . . . . 29 2.10 Non-minimalDFA . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.11 MinimalDFA . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 2.12 CombinedNFAforseveraltokens . . . . . . . . . . . . . . . . . 38 2.13 CombinedDFAforseveraltokens . . . . . . . . . . . . . . . . . 39 2.14 A4-stateNFAthatgives15DFAstates . . . . . . . . . . . . . . 44 3.1 Fromregularexpressionstocontextfreegrammars . . . . . . . . 56 3.2 Simpleexpressiongrammar . . . . . . . . . . . . . . . . . . . . 57 3.3 Simplestatementgrammar . . . . . . . . . . . . . . . . . . . . . 57 3.4 Examplegrammar . . . . . . . . . . . . . . . . . . . . . . . . . . 59 3.5 Derivationofthestringaabbbccusinggrammar3.4 . . . . . . . 59 3.6 Leftmostderivationofthestringaabbbccusinggrammar3.4 . . . 59 3.7 Syntaxtreeforthestringaabbbccusinggrammar3.4 . . . . . . . 61 3.8 Alternativesyntaxtreeforthestringaabbbccusinggrammar3.4 . 61 3.9 Unambiguousversionofgrammar3.4 . . . . . . . . . . . . . . . 62 3.10 Preferredsyntaxtreefor2+3*4usinggrammar3.2 . . . . . . . . 63 3.11 Unambiguousexpressiongrammar . . . . . . . . . . . . . . . . . 66 3.12 Syntaxtreefor2+3*4usinggrammar3.11 . . . . . . . . . . . . . 67 3.13 Unambiguousgrammarforstatements . . . . . . . . . . . . . . . 68 3.14 Fixed-pointiterationforcalculationofNullable . . . . . . . . . . 71 3.15 Fixed-pointiterationforcalculationofFIRST . . . . . . . . . . . 72 3.16 Recursivedescentparserforgrammar3.9 . . . . . . . . . . . . . 81 vii viii LISTOFFIGURES 3.17 LL(1)tableforgrammar3.9 . . . . . . . . . . . . . . . . . . . . 82 3.18 Programfortable-drivenLL(1)parsing . . . . . . . . . . . . . . 83 3.19 Inputandstackduringtable-drivenLL(1)parsing . . . . . . . . . 83 3.20 Removingleft-recursionfromgrammar3.11 . . . . . . . . . . . . 85 3.21 Left-factorisedgrammarforconditionals . . . . . . . . . . . . . . 87 3.22 SLRtableforgrammar3.9 . . . . . . . . . . . . . . . . . . . . . 90 3.23 AlgorithmforSLRparsing . . . . . . . . . . . . . . . . . . . . . 91 3.24 ExampleSLRparsing . . . . . . . . . . . . . . . . . . . . . . . . 91 3.25 ExamplegrammarforSLR-tableconstruction . . . . . . . . . . . 92 3.26 NFAsfortheproductionsingrammar3.25 . . . . . . . . . . . . . 92 3.27 Epsilon-transitionsaddedtofigure3.26 . . . . . . . . . . . . . . 93 3.28 SLRDFAforgrammar3.9 . . . . . . . . . . . . . . . . . . . . . 94 3.29 SummaryofSLRparse-tableconstruction . . . . . . . . . . . . . 95 3.30 TextualrepresentationofNFAstates . . . . . . . . . . . . . . . . 103 5.1 Examplelanguageforinterpretation . . . . . . . . . . . . . . . . 123 5.2 Evaluatingexpressions . . . . . . . . . . . . . . . . . . . . . . . 125 5.3 Evaluatingafunctioncall . . . . . . . . . . . . . . . . . . . . . . 127 5.4 Interpretingaprogram . . . . . . . . . . . . . . . . . . . . . . . 128 6.1 Thedesignspaceoftypes . . . . . . . . . . . . . . . . . . . . . . 134 6.2 Typecheckingofexpressions . . . . . . . . . . . . . . . . . . . . 137 6.3 Typecheckingafunctiondeclaration . . . . . . . . . . . . . . . . 139 6.4 Typecheckingaprogram . . . . . . . . . . . . . . . . . . . . . . 141 7.1 Theintermediatelanguage . . . . . . . . . . . . . . . . . . . . . 150 7.2 Asimpleexpressionlanguage . . . . . . . . . . . . . . . . . . . 152 7.3 Translatinganexpression . . . . . . . . . . . . . . . . . . . . . . 154 7.4 Statementlanguage . . . . . . . . . . . . . . . . . . . . . . . . . 156 7.5 Translationofstatements . . . . . . . . . . . . . . . . . . . . . . 158 7.6 Translationofsimpleconditions . . . . . . . . . . . . . . . . . . 159 7.7 Examplelanguagewithlogicaloperators . . . . . . . . . . . . . . 161 7.8 Translationofsequentiallogicaloperators . . . . . . . . . . . . . 162 7.9 Translationforone-dimensionalarrays . . . . . . . . . . . . . . . 166 7.10 Atwo-dimensionalarray . . . . . . . . . . . . . . . . . . . . . . 168 7.11 Translationofmulti-dimensionalarrays . . . . . . . . . . . . . . 169 7.12 Translationofsimpledeclarations . . . . . . . . . . . . . . . . . 173 8.1 Pattern/replacementpairsforasubsetoftheMIPSinstructionset . 185 9.1 Genandkillsets. . . . . . . . . . . . . . . . . . . . . . . . . . . 194 9.2 Exampleprogramforlivenessanalysisandregisterallocation . . . 195

See more

The list of books you might like

book image

The Sweetest Oblivion (Made Book 1)

Danielle Lori
·360 Pages
·2018
·1.72 MB

book image

The Silent Patient

Alex Michaelides
·0.52 MB

book image

As Good as Dead

Holly Jackson
·2021
·6.41 MB

book image

Can’t Hurt Me: Master Your Mind and Defy the Odds

David Goggins
·364 Pages
·2018
·2.99 MB

book image

01 Archer FISH BULL 102(2).

12 Pages
·2002
·0.49 MB

book image

Bülten No 32 - Ocak 2014

116 Pages
·2014
·5.67 MB

book image

Centenary Magazine

Centenary College of Louisiana
·2006
·345.5 MB

book image

Stefania coxi

Macculloch, Ross D
·2006
·1.7 MB

book image

Precious Memories by George C. Lambert

Lambert, George C. (George Cannon), 1848-
·2014
·0.12 MB

book image

Cancun & Cozumel Alive! (Hunter Travel Guides)

Bruce Conord
·350 Pages
·1998
·2.35 MB

book image

The Boy Who Would Live Forever

Frederick Pohl
·393 Pages
·2016
·1.87 MB

book image

Reprehensible

Mikey Robins
·2020
·6.438 MB

book image

CougarCountry

West & Scott [West and Scott]
·0.9065 MB

book image

Clairvoyance and Occult Powers

Swami Panchadasi
·2009
·0.272 MB

book image

Blood sugar-2017

10 Pages
·2017
·0.26 MB