90 likes | 188 Vues
This project covers DFA generation, AST creation, type checking, high-level code optimization, intermediate code generator and optimizer, abstract machine code generation, and final code generation. Includes adding new statements to AST, recursion detection, high-level optimizations, and 3-address code generation. Also, features advanced optimizations like loop invariant motion, constant propagation, and peephole optimizations. Event matching using derivative technique and roles delegated for efficient workflow.
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.
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