- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
编译_chapter07
Translation to Intermediate Code 邱锡鹏复旦大学计算机科学技术学院mailto:xpqiu@xpqiu@/~xpqiu/compiler/~/~xpqiu/compilerxpqiu/compilerReferences/class/cs143//class/cs143/class/cs143//Partial contents are copied from the slides of Alex AikenOutlineIR TreesTranslation into TreesWhy Intermediate Representations (IR)?Individual pieces of abstract syntax can be complicated thingssuch as array subscripts, procedure calls, and so onIndividual “real machine” instructions can also a complicated effect.Therefore, the IR should be have individual components that describe only extremely simple thing:a single fetch, store, add, move or jump.Intermediate Representations (IR)What makes a good IR ? easy to convert from the AST; easy to convert into the machine code; must be clear and simple; must support various machine-independent optimizing transformations;VS Intermediate languageA popular format for intermediate languages is three address code.C is used as an intermediate language by many programming languages.Sun’s Java bytecode and Microsofts Common Intermediate LanguageIntermediate CodeUsually two IRs:Low-level IRMachine independent(but closer to machine)High-level IRLanguage-independent(but closer to language)Several IRsSome modern compilers use several IRs ( e.g., k=3 in SML/NJ ) each IR in later phase is a little closer (to the machine code) than the previous phase.AST == IR1 == IR2 ... == IRk == machine codepros : make the compiler cleaner, simpler, and easier to maintaincons : multiple passes of code-traversal --- compilation may be slowHigh-level IRTree node structure very similar to the ASTContains high-level constructs common to many languagesExpression nodesStatement nodesExpression nodes for:Integers and program variablesBinary operations: e1 OP e2Arithmetic operationsLogic operationsComparisonsUnary operations: OP eArray accesses: e1[e2]High-level IRStatement nodes:Block statements (statement sequences): (s1, …, sN)Variable assignments: v = eArray assignments: e1[e2] = e3If-then-
您可能关注的文档
最近下载
- 中式烹调师高级工理论知识练习题库(附参考答案).docx
- 中央厨房卫生规范与管理指南.docx VIP
- 2025年人工智能工程师(高级)题库.docx VIP
- 社会团体成立登记表.docx
- MITSUBISHI三菱MDS-EM EMH系列规格说明书.pdf
- 高血压科普健康宣教ppt课件.pptx VIP
- 2025入党积极分子发展对象考试题库(含答案).pdf VIP
- YD-T 4244-2023电信网和互联网数据分类分级技术要求与测试方法.pdf VIP
- 2025年新版成人考试模拟真题及答案.doc VIP
- 0523S01019-理解当代中国:汉英翻译-2023版人才培养方案课程教学大纲.docx VIP
文档评论(0)