Code generation
This presentation is the property of its rightful owner.
Sponsored Links
1 / 11

Code Generation PowerPoint PPT Presentation


  • 143 Views
  • Uploaded on
  • Presentation posted in: General

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.

Download Presentation

Code Generation

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


  • Login