1 / 11

Code Generation

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.

lars
Télécharger la présentation

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Code Generation GülfemSavrun Yeniçeri CS 142 (b) 02/26/2013

  2. Code Generation • Translates intermediate representation into machine code • Generated code is target specific • x86 • ARM

  3. Code Generation .class file Parser SSA Generator Optimizations Register Allocator Code Generator x86 code

  4. x86 Instruction Format

  5. x86 Instruction Format • In project: • Opcode • ModR/M • Immediate

  6. X86 Instructions • Instructions can reference different operands • Immediate • Register • Memory MOV register, immediate MOV register, register MOV register, memory

  7. 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

  8. x86 Calling Convention • Caller-saved registers EAX,ECX,EDX • Callee-saved registers EBX,EDI,ESI

  9. x86 Calling Convention Caller’s frame Caller-saved registers Arguments Return address Saved frame pointer Callee-saved registers Callee’s frame

  10. x86 Calling Convention • Caller: – Saves caller-savedregisters –Pushes arguments on stack – Executes call instruction

  11. 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

More Related