Code generation
Download
1 / 11

Code Generation - PowerPoint PPT Presentation


  • 197 Views
  • Uploaded on

Code Generation. Gülfem Savrun Yeniçeri CS 142 (b) 02/26/2013. Code Generation. Translates intermediate representation into machine code Generated code is target specific x86 ARM. Code Generation. . class file. Parser. SSA Generator. Optimizations. Register Allocator.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Code Generation' - lars


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Code generation

Code Generation

GülfemSavrun Yeniçeri

CS 142 (b)

02/26/2013


Code generation1
Code Generation

  • Translates intermediate representation into machine code

  • Generated code is target specific

    • x86

    • ARM


Code generation2
Code Generation

.class file

Parser

SSA Generator

Optimizations

Register Allocator

Code Generator

x86 code


X 86 instruction format
x86 Instruction Format


X86 instruction format
x86 Instruction Format

  • In project:

    • Opcode

    • ModR/M

    • Immediate


X86 instructions
X86 Instructions

  • Instructions can reference different operands

    • Immediate

    • Register

    • Memory

MOV register, immediate

MOV register, register

MOV register, memory


Calling convention
Calling Convention

  • Protocol between the caller and the callee used during a function invocation

    • Which registers are saved by the caller

    • Which registers are saved by the callee

    • Where parameters and return values are placed


X 86 calling convention
x86 Calling Convention

  • Caller-saved registers

    EAX,ECX,EDX

  • Callee-saved registers

    EBX,EDI,ESI


X 86 calling convention1
x86 Calling Convention

Caller’s frame

Caller-saved registers

Arguments

Return address

Saved frame pointer

Callee-saved registers

Callee’s frame


X86 calling convention
x86 Calling Convention

  • Caller:

    – Saves caller-savedregisters

    –Pushes arguments on stack

    – Executes call instruction


X86 calling convention1
x86 Calling Convention

  • Callee:

    • Pushescaller’s frame pointer on stack

      – Sets up callee’s frame pointer

      – Saves callee-saved registers

      – Allocatesa frame

      – Startexecuting callee’s code