1 / 22

Abstract Syntax Description Language(ASDL ) In LCC

Abstract Syntax Description Language(ASDL ) In LCC. By: Bagher Salami. Outline. Compiler background Retargetable compilers Little C compiler (lcc) Compiler Importance What is ASDL? The lcc Code-Generation Interface Dividing lcc Evaluation Conclusions. Assem- bler. OBJ. Linker.

tyrell
Download Presentation

Abstract Syntax Description Language(ASDL ) In LCC

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Abstract Syntax Description Language(ASDL) In LCC Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012 By: Bagher Salami

  2. Outline • Compiler background • Retargetable compilers • Little C compiler (lcc) • Compiler Importance • What is ASDL? • The lcc Code-Generation Interface • Dividing lcc • Evaluation • Conclusions Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  3. Assem- bler OBJ Linker ASM EXE Compiler background • Compiler is a quite complex software package • Compilers must be particularly reliable • Design requires separation into multiple phases • Compiler followed by Assembler, Linker Compiler phases C src Frontend IR Optimi- zations IR Backend ASM Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012 LIBS

  4. Retargetable compilers Retargetable compiler “Classical” compiler processor model source code source code Compiler Compiler Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012 ASM code ASM code

  5. Little C compiler (lcc) • “Lightweight” public-domain C compiler (Princeton Univ.) • ANSI C frontend, few built-in optimizations • Generate compilers are very fast • Mainly for RISC and CISC targets • Small amount of source code • Excellent documentation Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  6. Compiler Importance • High-quality compilers are essential for researches such as: • computer architecture • are required to run benchmarks for evaluating new ideas in architecture • programming languages and environments • compilers for new languages need optimizers, code generators Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012 So we need to enhance the compiler performance (enhance lcc performance)

  7. ASDL • ASDL is a language for specifying the tree data structures in compiler IR. • The ASDL generator reads an ASDL specification and generates code to construct, read, and write instances of the trees specified. • Using ASDL permits a compiler to be decomposed into semi-independent components. Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  8. ASDL This experience is valuable for two reasons: lcc is perhaps the simplest C compiler available and thus provides a `basis' test case for ASDL. lcc wasn't designed to be decomposed into reusable program components, so doing so suggests how difficult it is to retrfiotASDL into existing compilers. Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  9. ASDL Advantage of using ASDL: partition a compiler into several independent programs Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012 A front end reads source code and builds an IR (pickle) using the asdlGen. Subsequent phases read and write pickles as necessary. pickles are independent of both language and host platform. Thus, compiler phases can be written in whatever ASDL-supported language best suits.

  10. ASDL ASDL is such a simple language that examples suffice to explain nearly all of its features. The following ASDL specification describes an IR for a language of arithmetic expressions, assignment statements, and print statements. Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  11. ASDL Given an ASDL specification, asdlGen emits an interface (IR.h) and an implementation (IR.c). The snippets from the interface (IR.h) that writes asdlGen. Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  12. ASDL The implementation, (IR.c), contains the definitions for the functions declared in IR.h. For example, the constructor IR_SEQ is Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  13. The lcc Code-Generation Interface • Communication between lcc's target-independent front end and its target-dependent back ends is specified by a small code-generation interface. • This interface consists of: • a few shared data structures • 33-operator tree IR that represents executable code • 18 procedures that manipulate and modify shared data structures • The shared data structures include: • tree nodes • symbol-table entries • types Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  14. The lcc Code-Generation Interface The 33 tree IR operators Each of these generic operators can be specialized by appending an operand type suffix and a size in bytes. The 6 type suffixes are: F float I integer U unsigned P pointer B `block' (aggregate) V void Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  15. The lcc Code-Generation Interface The purpose of the 18 code-generation procedures. Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  16. Dividing lcc lcc is a monolithic compiler: back ends can make calls to functions provided by the front end, and the front end reads data structures written by the back ends. Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  17. Dividing lcc • lcc is small, it omits some components, most notably a global optimizer. • One way to add more functionality is to split lcc into a separate front end and back ends so that an optimizer can be run between these programs. • This design would also make it easier to use lcc in research projects. Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  18. Dividing lcc • Splitting lcc into two separate programs requires either massive revisions. • ASDL facilitates dividing lcc into separate programs with no change to the code-generation interface. So, the existing back ends can be used unmodified. Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  19. Evaluation Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  20. conclusions • Revising lcc to use ASDL was provide an improved platform for compiler-related research using lcc. • It is now possible to insert additional passes into the compilation pipeline without modifying or even understanding the front and back ends. • The obvious first candidate is a global optimization pass Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  21. References [1] D. R. Hanson. Early experience with ASDL in lcc. Software - Practice and Experience, 29(5):417–435, 1999. [2] P. Ienne and R. Leupers, editors. Customizable Embedded Processors. Morgan Kauffman, 2006. Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

  22. Thank You ! Advanced Computer Architecture -Department of Computer Engineering-Ferdowsi University Of Mashhad February 2012

More Related