9_unoptimized - Segment IV Roadmap Checkpoint Fall 2002...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Fall 2002 Lecture 9: Unoptimized Code Generation From the intermediate representation to the machine code 3 6.035 Anatomy of a compiler ) Saman Amarasinghe ©MIT Fall 2001 Code Generator Intermediate Representation Assembly code High-level IR Lexical Analyzer (Scanner) Syntax Analyzer (Parser) Token Stream Parse Tree Program (character stream Low-level IR Semantic Analyzer Machine Code Generator Should. .. Translate all the instructions in the intermediate representation to assembly language Allocate space for the variables, arrays etc. Adhere to calling conventions Create the necessary symbolic information Saman Amarasinghe 5 6.035 ©MIT Fall 2001 Segment IV Roadmap Checkpoint – On Tuesday 10/22 – Hand-in a tarball of what you have – If you get codegen to work, no effect – If you have problems at end, we will be very harsh if you haven’t done much work by the checkpoint Due on 10/31 Paper discussion – Prof: Amarasinghe Next Monday (17 th ) – Prof: Rinard Next Friday (21 st ) Saman Amarasinghe 2 6.035 ©MIT Fall 2001 4 6.035 DATA low l i l l Saman Amarasinghe ©MIT Fall 2001 Components of a High Level Language CODE Procedures Control F Statements Data Access Globa Stat c Variables Globa Dynamic Data Local Variab es Temporaries Parameter Passing Read-only Data Machines understand. .. LOCATION DATA ASSEMBLY INSTRUCTION 0046 0049 004c 004f 0052 0055 0057 8B45FC 4863F0 8B45FC 4863D0 8B45FC 4898 8B048500 000000 movl -4(%rbp), %eax movslq %eax,%rsi movl -4(%rbp), %eax movslq %eax,%rdx movl -4(%rbp), %eax cltq movl B(,%rax,4), %eax 005e 8B149500 000000 movl A(,%rdx,4), %edx 0065 0067 006a 006c 006e 01C2 8B45FC 4898 89D7 033C8500 000000 addl movl cltq movl addl %eax, %edx -4(%rbp), %eax %edx, %edi C(,%rax,4), %edi 0075 0078 007b 007e 0080 8B45FC 4863C8 8B45F8 4898 8B148500 movl -4(%rbp), %eax movslq %eax,%rcx movl -8(%rbp), %eax cltq movl B(,%rax,4), %edx Saman Amarasinghe 6 6.035 ©MIT Fall 2001 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
7 6.035 ) Saman Amarasinghe ©MIT Fall 2001 Intermediate Representation Program (character stream Code Generator Assembly code High-level IR Lexical Analyzer (Scanner) Syntax Analyzer (Parser) Token Stream Parse Tree Low-level IR Intermediate Code Generator Assembler & linker Binary executable Processor Assembly language Advantages Simplifies code generation due to use of symbolic instructions and symbolic names – Logical abstraction layer – Multiple Architectures can describe by a single assembly language can modify the implementation • macro assembly instructions Disadvantages – Additional process of assembling and linking – Assembler adds overhead Saman Amarasinghe 8 6.035 ©MIT Fall 2001 Assembly language • Relocatable machine language (object modules) – all locations(addresses) represented by symbols – Mapped to memory addresses at link and load time – Flexibility of separate compilation Absolute machine language – addresses are hard-coded – simple and straightforward implementation
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

9_unoptimized - Segment IV Roadmap Checkpoint Fall 2002...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online