清华大学:《编译原理》课程教学资源_(英文译文)Chapter 8 Code Generation

COMPILER CONSTRUCTION Principles and practice Kenneth C. louden
COMPILER CONSTRUCTION Principles and Practice Kenneth C. Louden

8. Code Generation PART ONE
8. Code Generation PART ONE

Generate executable code for a target machine that is a faithful representation of the semantics of the source code Depends not only on the characteristics of the source language but also on detailed information about the target architecture. the structure of the runtime environment, and the operating system running on the target machine
• Generate executable code for a target machine that is a faithful representation of the semantics of the source code • Depends not only on the characteristics of the source language but also on detailed information about the target architecture, the structure of the runtime environment, and the operating system running on the target machine

Contents Part one 8.1 Intermediate Code and data Structure for code generation 8. 2 Basic Code generation Techniques Other Parts 8. 3 Code Generation of Data Structure Reference 8.4 Code Generation of Control Statements and logical Expression 8.5 Code Generation of Procedure and Function calls 8.6 Code Generation on Commercial Compilers: Two Case Studies 8.7 TM: A Simple Target machine 8. 8 A Code Generator for the TINy language 8.9 A Survey of Code Optimization Techniques 8.10 Simple Optimizations for TINY Code Generator
Contents Part One 8.1 Intermediate Code and Data Structure for code Generation 8.2 Basic Code Generation Techniques Other Parts 8.3 Code Generation of Data Structure Reference 8.4 Code Generation of Control Statements and Logical Expression 8.5 Code Generation of Procedure and Function calls 8.6 Code Generation on Commercial Compilers: Two Case Studies 8.7 TM: A Simple Target Machine 8.8 A Code Generator for the TINY Language 8.9 A Survey of Code Optimization Techniques 8.10 Simple Optimizations for TINY Code Generator

8.1 Intermediate Code and data Structures for Code generation
8.1 Intermediate Code and Data Structures for Code Generation

8.1.1 Three-Address code
8.1.1 Three-Address Code

a data structure that represents the source program during translation is called an intermediate representation or IR. for short Such an intermediate representation that resembles target code is called intermediate code Intermediate code is particularly useful when the goal of the compiler is to produce extremely efficient code; Intermediate code can also be useful in making a compiler more easily retarget-able Study two popular forms of intermediate code: Three Address code and p-code The most basic instruction of three-address code is designed to represent the evaluation of arithmetic expressions and has the following general form op z
• A data structure that represents the source program during translation is called an intermediate representation, or IR, for short • Such an intermediate representation that resembles target code is called intermediate code – Intermediate code is particularly useful when the goal of the compiler is to produce extremely efficient code; – Intermediate code can also be useful in making a compiler more easily retarget-able. • Study two popular forms of intermediate code: Three - Address code and P-code • The most basic instruction of three-address code is designed to represent the evaluation of arithmetic expressions and has the following general form: X=y op z

2*a+(b-3 )with syntax tree a The corresponding three-address code is T1=2*a T2=b-3 T3=t1+t2
2*a+(b-3) with syntax tree + * - 2 a b 3 The corresponding three-address code is T1 = 2 * a T2 = b – 3 T3 = t1 + t2

Figure 8. 1 Sample tiNY program i sample program in tiNY language -computes factorial readx; input an integer ifo>x then( dont compute ifx<=0) fact: =1 repeat fact: =fact*X X-X until xO write fact( output factorial ofx) ends
Figure 8.1 Sample TINY program: { sample program in TINY language -- computes factorial } read x ; { input an integer } if 0 > x then { don’t compute if x <= 0 } fact:=1; repeat fact:=fact*x; x:=x-1 until x=0; write fact { output factorial of x } ends

The Three-address codes for above tiny program readⅩ t1=x>0 if false tl goto Ll fact=1 label 2 t2=fact*x fact=t2 t3=x-1 X=t3 t4=x==0 if false t4 goto L2 write fact label li halt
• The Three-address codes for above TINY program read x t1=x>0 if_false t1 goto L1 fact=1 label L2 t2=fact*x fact=t2 t3=x-1 x=t3 t4= x= =0 if_false t4 goto L2 write fact label L1 halt
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《NFS报文分析》讲义.doc
- 华中科技大学:《IT项目管理》(本科)(英文版)What makes a good manager.doc
- 华中科技大学:《IT项目管理》(本科)(英文版)Ten attributes of a good employee.doc
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:9 Project Procurement Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:8 Project Risk Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:7 Project Communication Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:6 Project HR Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:5 Project Cost Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:4 Project Time Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:3 Project Scope Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:2 Project The Project Management Context and Processes.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:1 Introduction to Project Management.ppt
- 深圳职业技术学院:《C语言程序设计》第九单元:共用体,枚举(乌云高娃).pdf
- 深圳职业技术学院:《C语言程序设计》第八单元:结构体(乌云高娃).pdf
- 深圳职业技术学院:《C语言程序设计》第八单元(3):指针与结构体(乌云高娃).pdf
- 深圳职业技术学院:《C语言程序设计》第八单元(2):结构体数组(乌云高娃).pdf
- 深圳职业技术学院:《C语言程序设计》第八单元(1):结构体变量的定义、引用、初始化(乌云高娃).pdf
- 深圳职业技术学院:《C语言程序设计》第七单元:指针及其应用(乌云高娃).pdf
- 深圳职业技术学院:《C语言程序设计》第七单元(4):指针数组(乌云高娃).pdf
- 深圳职业技术学院:《C语言程序设计》第七单元(3):字符串指针(乌云高娃).pdf
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 8.1 Intermediate Code and Data.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 8.6 Code Generation in Commercial Compilers:Two Case Studies.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 5.1 Overview of Bottom-UpParsing.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 5.3 SLR(1)Parsing.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 4.1 Top-Down Parsing by Recursive-Descent.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 4.1 Top-Down Parsing byRecursive-Descent.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 1.1 Why? A Brief History.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 7.1 Memory Organization During Program Execution.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 7.4 Dynamic Memory.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 6.1 Attributes and AttributeGrammars.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 6.3 The Symbol Table.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 3.1 The Parsing Process.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 2.1 The Scanning Process.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 2.4 From Regular Expression To DFAs.ppt
- 《多媒体技术》课程教学资源(PPT课件讲稿).ppt
- 《JAVA基础实例200题》Java例题(一).pdf
- 《JAVA基础实例200题》Java例题(二).pdf
- 《JAVA基础实例200题》Java例题(三).pdf
- 《JAVA基础实例200题》Java例题(四).pdf
- 《JAVA基础实例200题》Java例题(五).pdf