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

Slides:



Advertisements
Similar presentations
Machine-Level Programming III: Procedures Feb. 8, 2000 Topics IA32 stack Stack-based languages Stack frames Register saving conventions Creating pointers.
Advertisements

Calling sequence ESP.
University of Washington Procedures and Stacks II The Hardware/Software Interface CSE351 Winter 2013.
Procedure call frame: Hold values passed to a procedure as arguments
C Programming and Assembly Language Janakiraman V – NITK Surathkal 2 nd August 2014.
Review: Software Security David Brumley Carnegie Mellon University.
Compiler Construction Intermediate Representation III Activation Records Ran Shaham and Ohad Shacham School of Computer Science Tel-Aviv University.
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Prelim Review.
University of Washington Last Time For loops  for loop → while loop → do-while loop → goto version  for loop → while loop → goto “jump to middle” version.
1 Storage Registers vs. memory Access to registers is much faster than access to memory Goal: store as much data as possible in registers Limitations/considerations:
Machine-Level Programming III: Procedures Apr. 17, 2006 Topics IA32 stack discipline Register saving conventions Creating pointers to local variables CS213.
1 Handling nested procedures Method 1 : static (access) links –Reference to the frame of the lexically enclosing procedure –Static chains of such links.
1 Lecture 5: Procedures Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
1 Function Calls Professor Jennifer Rexford COS 217 Reading: Chapter 4 of “Programming From the Ground Up” (available online from the course Web site)
Accessing parameters from the stack and calling functions.
Practical Session 3. The Stack The stack is an area in memory that its purpose is to provide a space for temporary storage of addresses and data items.
– 1 – , F’02 ICS05 Instructor: Peter A. Dinda TA: Bin Lin Recitation 4.
Intro to Computer Architecture
Run time vs. Compile time
Assembly תרגול 8 פונקציות והתקפת buffer.. Procedures (Functions) A procedure call involves passing both data and control from one part of the code to.
28/06/2015CMPUT Functions (2)  Function calling convention  Various conventions available  One is specified by CMPUT229  Recursive functions.
September 22, 2014 Pengju (Jimmy) Jin Section E
Compiler Construction Activation records Code Generation Rina Zviel-Girshin and Ohad Shacham School of Computer Science Tel-Aviv University.
Stack Activation Records Topics IA32 stack discipline Register saving conventions Creating pointers to local variables February 6, 2003 CSCE 212H Computer.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 7 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
1 Carnegie Mellon Stacks : Introduction to Computer Systems Recitation 5: September 24, 2012 Joon-Sup Han Section F.
CSc 453 Runtime Environments Saumya Debray The University of Arizona Tucson.
Fabián E. Bustamante, Spring 2007 Machine-Level Programming III - Procedures Today IA32 stack discipline Register saving conventions Creating pointers.
CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Execution of Machine Code Machine State and Operations Apps O/S.
Computer Architecture Instruction Set Architecture Lynn Choi Korea University.
Activation Records CS 671 February 7, CS 671 – Spring The Compiler So Far Lexical analysis Detects inputs with illegal tokens Syntactic analysis.
Activation Records (in Tiger) CS 471 October 24, 2007.
Lecture 19: 11/7/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Machine-Level Programming III: Procedures Topics IA32 stack discipline Register-saving conventions Creating pointers to local variables CS 105 “Tour of.
Procedure (Method) Calls Ellen Spertus MCS 111 September 25, 2003.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 21: Calling.
Machine-level Programming III: Procedures Topics –IA32 stack discipline –Register saving conventions –Creating pointers to local variables.
Compiler Construction Code Generation Activation Records
Reminder Bomb lab is due tomorrow! Attack lab is released tomorrow!!
University of Amsterdam Computer Systems – the instruction set architecture Arnoud Visser 1 Computer Systems The instruction set architecture.
Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition Carnegie Mellon Instructor: San Skulrattanakulchai Machine-Level Programming.
1 Assembly Language: Function Calls Jennifer Rexford.
Overview of Back-end for CComp Zhaopeng Li Software Security Lab. June 8, 2009.
Microprocessor, Programming & Interfacing Tutorial 2- Module 3.
ICS51 Introductory Computer Organization Accessing parameters from the stack and calling functions.
Section 5: Procedures & Stacks
Programs – Calling Conventions
Recitation 3: Procedures and the Stack
Assembly function call convention
Reading Condition Codes (Cont.)
Assembly language.
C function call conventions and the stack
143A: Principles of Operating Systems Lecture 4: Calling conventions
Homework In-line Assembly Code Machine Language
Introduction to Compilers Tim Teitelbaum
Machine-Level Programming 4 Procedures
Application Binary Interface (ABI)
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures
MIPS Instructions.
MIPS Procedure Calls CSE 378 – Section 3.
Practical Session 4.
Multi-modules programming
X86 Assembly Review.
ICS51 Introductory Computer Organization
Computer Architecture and System Programming Laboratory
Computer Architecture and System Programming Laboratory
Runtime Stack Activation record for hanoi;
Presentation transcript:

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 Parser SSA Generator Register Allocator Code Generator Optimizations.class file x86 code

x86 Instruction Format

In project: – Opcode – ModR/M – Immediate

X86 Instructions Instructions can reference different operands – Immediate – Register – Memory MOV register, immediate MOV register, register MOV register, memory

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

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

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

x86 Calling Convention Caller: – Saves caller-saved registers – Pushes arguments on stack – Executes call instruction

x86 Calling Convention Callee: – Pushes caller’s frame pointer on stack – Sets up callee’s frame pointer – Saves callee-saved registers – Allocates a frame – Start executing callee’s code