



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




CS553 Lecture Undergraduate Compilers Review 1
Announcements
“sentences” Synthesis optimization code generation target language
IR code generation IR Analysis character stream lexical analysis tokens “words” semantic analysis syntactic analysis AST annotated AST interpreter CS553 Lecture Undergraduate Compilers Review 3
Goal
CS553 Lecture Undergraduate Compilers Review 5
Register Transfer Language (RTL)
*Source code High-level IR (AST) for i = 1 to 10 do a[i] = x * 5; Low-level IR (RTL) i := 1 loop1: t1 := x * 5 t2 := &a t3 := sizeof(int) t4 := t3 * i t5 := t2 + t t5 := t i := i + 1 if i <= 10 goto loop for i 1 10 asg arr a i tms x 5 CS553 Lecture Undergraduate Compilers Review 7
Switch statements
Array declaration
CS553 Lecture Undergraduate Compilers Review 13
Code generation for procedures
Conceptually easy
Assem data structure
class MultipleParams { public static void main(String[] a){ System.out.println(new Foo().testing());}} class Foo { public int testing() { int local1; int local2; int local3; local1 = 1; local2 = 2; local3 = 3; return this.foobar(local1, local2+local3, local3); } public int foobar(int param1, int param2, int param3){ return param1 - param2 * param3 ; } } main:^ .text main_framesize=32 sw $fp, -4($sp) move $fp, $sp L1:^ subu^ $sp, $sp,^ main_framesize sw $ra, -8($fp) L0:^ ...
lw $fp, -4($sp) j $ra .text testing: testing_framesize= sw $fp, -4($sp) move $fp, $sp L3:^ subu^ $sp, $sp,^ testing_framesize sw $ra, -8($fp) li sw $t0, 1$t0, -24($fp) lw $t0, -24($fp) ...^ sw^ $t0, -12($fp)
CS553 Lecture Undergraduate Compilers Review 17
Representations
Reading