Lecture 192cs415, spring 10Code Generation: Structure of a Compiler (EaC Ch. 7)A compiler is a lot of fast stuff followed by some hard problems→The hard stuff is mostly in code generationand optimization→For superscalars, its allocation & scheduling that is particularly importantInstructionSelectionRegisterAllocationInstructionSchedulingScannerParserAnalysis&OptimizationO(n), O(n log n), … NP-CompleteO(n)O(n)NP-CompleteNP-CompleteEither fast orNP-CompletewordsIRIRasmasmkregsasm∞regs∞regs
Lecture 193cs415, spring 10Review - The Big PictureConventional wisdom says that we lose little by solving these problems independentlyInstruction selection•Use some form of pattern matching •Assume enough registers or target “important” values Instruction scheduling•Within a block, list scheduling is “close” to optimal •Across blocks, build framework to apply list schedulingRegister allocation•Start from virtual registers & map into k •Focus on good priority heuristicOptimal for > 85% of blocksNote: many fuzzyterms here!
has intentionally blurred sections.
Sign up to view the full version.
Lecture 194cs415, spring 10Code ShapeDefinition•All those nebulous properties of the code that impact performance & code “quality”•Includes code, approach for different constructs, cost, storage requirements & mapping, & choice of operations•Code shape is the end product of many decisions (big & small)Impact•Code shape influences algorithm choice & results•Code shape can encode important facts, or hide themRule of thumb: expose as much derived information as possible•Example: explicit branch targets in ILOCsimplify analysis