DOC PREVIEW
CSU CS 453 - Study Guide

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS453 Intro and PA1 1CS453 Lecture x86 code gen and register allocation 1Plan for today Finish instruction selection for x86 Register allocation– spill all– possible improvements over spill allCS453 Lecture x86 code gen and register allocation 2Instruction selection for x86 Registers– EAX, the accumulator– EBX, the base register– ECX, the counter register– EDX, the data register Representations– Constants prefixed with ‘$’, for example $3, $4, $-5, etc– Registers prefixed with ‘%’, for example %eax, %esp, etc. Some Instructions– movl -12(%ebp), %eax // M[%ebp-1] --> %eax– imull -4(%ebp), %eax // M[%ebp-4] * %eax --> %eax– cmpl -4(%ebp), %eax– jge .L2 // if ( M[%ebp-4] >= %eax ) goto .L2•ESI, the source register•EDI, the destination register•ESP, the stack pointer register•EBP, the frame pointer registerCS453 Lecture x86 code gen and register allocation 3Temps as destinations and sources Destination (or Temp defines)– in Translate to IR Trees– pointer to class instance created by NewExp– pointer to start of allocated array– array length is defined– result of function call– holds 0 or 1 to indicate result of a less than– in CodeGen– a Temp holds the result of each expression evaluation Source (or Temp uses)– in Translate, a Temp is used in Tree.Stms generated for same AST node whereTemp is defined– in Translate, false body must come after StmCJUMP, but exit doesn’t necessarilyhave to come after either (POSSIBLE PROBLEM)– in CodeGen, when generating code for a parent node, Temps defined in thechildren nodes are often usedCS453 Lecture x86 code gen and register allocation 4Possible approaches for improving over spill all Linear passes over the Assem.Instrs– after spill all, remove loads from sw-lw pairs where the temp and frame locationare the sameeg. sw $t2, -16($fp) lw $t2, -16($fp)– before spill all, assign each Temp to a callee-saved register until run outeg. t34 ==> frame.RAt35 ==> frame.S0 ...calleeSaves = { RA, S0, S1, S2, S3, S4, S5, S6, S7}– after spill all, assign each frame location to a callee-saved register until run outeg. $fp-12 ==> frame.RA$fp-16 ==> frame.S0...calleeSaves = { RA, S0, S1, S2, S3, S4, S5, S6, S7}CS453 Intro and PA1 2CS453 Lecture x86 code gen and register allocation 5Example .text LS_Start: LS_Start_framesize=100 LS_Start_paramsNregsaves=16 - the above function has (100-16)/4 locals and temps, 21 locals and temps .text LS_Search: LS_Search_framesize=224 LS_Search_paramsNregsaves=16 - the above function has (224-16)/4 locals and temps, 52 locals and


View Full Document

CSU CS 453 - Study Guide

Download Study Guide
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Study Guide and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Study Guide 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?