欢迎来到天天文库
浏览记录
ID:34232912
大小:2.10 MB
页数:117页
时间:2019-03-04
《东南大学编译原理课件cp》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Chapter9CodeOptimizationZhaiYuqingZhouXiaoyuOverviewPositionofcodeoptimizerFrontendSourceprogramCodeoptimizerCodegeneratorIntermediatecodeIntermediatecodetargetprogramPurposeofCodeOptimizertogetbetterefficiencyRunfasterTakelessspacePlacesforPotentialImprovementsSour
2、cecodeUsercanprofileprogram,changealgorithmortransformloops.IntermediatecodeCompilercanimproveloops,procedurecallsoraddresscalculationsPlacesforPotentialImprovementsTargetcodeCompilercanuseregisters,selectinstructionsordopeepholetransformationsOrganizationofthecodeO
3、ptimizerControl-FlowAnalysisIdentifyblocksandloopsintheflowgraphofaprogramData-flowanalysisCollectinformationabouttheprogramasawholeandtodistributethisinformationtoeachblockintheflowgraph.Control-flowanalysisData-flowanalysistransformationsBasicblocksMaximalsequence
4、sofconsecutivethree-addressinstructionswiththepropertiesthatTheflowofcontrolcanonlyenterthebasicblockthroughthefirstinstructionintheblock.Controlwillleavetheblockwithouthaltingorbranching,exceptpossiblyatthelastinstructionintheblock.AnExampleT1=a*aT2=a*bT3=2*T2T4=T1
5、+T3T5=b*bT6=T4+T5TheUseofaNameSupposethree-addressstatementiassignsavaluetox.Ifstatementjhasxasanoperand,andcontrolcanflowfromstatementitojalongapaththathasnointerveningassignmentstox,thenwesaystatementjusesthevalueofxcomputedatstatementi.LivevariableWefurthersaytha
6、txisliveatstatementi.Anameinabasicblockissaidtobeliveatagivenpointifitsvalueisusedafterthatpointintheprogram,perhapsinanotherbasicblock.PartitionintoBasicBlocksInput:Asequenceofthree-addressstatementsOutput:Alistofbasicblockswitheachthree-addressstatementinexactlyon
7、eblock.Method:Wefirstdeterminethesetofleaders,thefirststatementsofbasicblocks.DeterminationofLeadersofBasicBlocks(1)Thefirststatementisaleader.(2)Anystatementthatisthetargetofaconditionalorunconditionalgotoisaleader.(3)Anystatementthatimmediatelyfollowsagotoorcondit
8、ionalgotostatementisaleader.PartitionintoBasicBlocksForeachleader,itsbasicblockconsistsoftheleaderandallstatementsuptobutnotincludingthene
此文档下载收益归作者所有