130 likes | 281 Views
CSE 504-Compiler Project. Group: 05 Supreet Padhi Aman Jain Duckjin Kang Wai -kit Sze Mandeep Singh. Lexical Analysis + Syntax Analysis. Event matcher DFA generation. AST generation + Type Checker. High level code optimizer. Intermediate code generator. Intermediate code optimizer.
E N D
CSE 504-Compiler Project Group: 05 Supreet Padhi Aman Jain Duckjin Kang Wai-kit Sze Mandeep Singh
Lexical Analysis + Syntax Analysis Event matcher DFA generation AST generation + Type Checker High level code optimizer Intermediate code generator Intermediate code optimizer Abstract machine code generator TypeChecker High Level Optimization 3-Address Code Intermediate Code Optimization Peephole Optimzation Machine Independent Optimization Final Code Generation
TypeChecker/AST Changes • Type checker as per specification provided • Changes to AST • addition for while, break and print statements • Detecting recursion in functions
High Level Optimization • Function Inlining • Criteria - # of statements <=5 • Can be improved to dynamic factor • Loop Invariant Motion • Assignments in a loop which are independent of the loop variables are moved outside.
Final code generation • Instruction selection • Professor’s abstract code • Check type to select instruction • Register allocation • Procedure call support • Activation records • Save/restore register (caller) • Memory management • Use stack and registers only • No dynamic, static memory allocation
Intermediate Optimization • Within a basic block • Constant propagation • Static evaluation • Available expression • Across basic blocks (global optimization) • Live variable analysis for dead variable/code removal • Reachability definition for killing unused code • Jump threading optimization • Peephole optimization / Template based optimization • Removal of empty/unreachable basic blocks
Event Matcher • Derivative technique to construct DFA. • Parameters are not handled. • O(1) time for transition based on table lookup.
Abstract Machine Code Generator • Convert the 3 address code into the abstract machine code • Maintaining the stack for activation record
Roles • Type Checker/AST/High level Optimiation • Supreet • 3-Address Code/System bring-up • Duckjin • Machine Code generation/Performance evaluation • Duckjin/Aman • Optimization • Peter/Mandeep • Event Matcher • Supreet/Peter