0% found this document useful (0 votes)
4 views11 pages

Sssnakelyzer: Cs335: Compiler Design Python To X86 - 64 Compiler

CS335 Presentation

Uploaded by

ashokgoyal361
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views11 pages

Sssnakelyzer: Cs335: Compiler Design Python To X86 - 64 Compiler

CS335 Presentation

Uploaded by

ashokgoyal361
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

SSSNAKELYZER

CS335: COMPILER DESIGN


PYTHON TO X86_64 COMPILER
Chitwan Goel (210295)
Shrey Bansal (210997)
Talin Gupta (211095)
ACKNOWLEDGEMENT
We would like to thank our professor, Mr. Swarnendu Biswas for teaching
this course. This project seemed very difficult at first but with the constant
guidance and clarifications from the instructor, this was made possible We
would also like to thank our TA Sodanapalli Linga Reddy for constant
evaluation and feedback. We're proud to be the last batch required to take
this course as part of our department's mandatory curriculum.
Introduction
Code Our compiler, sssnakelyzer can run a
Generation python code with all the necessary
features supported, plus some additional
ones.

Lexer

It was a matter of great joy for us when we


saw the python codes executing. Let’s take
you on a journey which spanned over a
3AC Parser period of 2.5 months and saw our efforts
bear fruit…
Milestone 1

Option flags
includes
Node numbers
customizing colors
Used Python 3.8 Flex and Bison used for
of different nodes
grammar used identifying the
(operators,
nodes of AST
delimiters,
keywords)
Milestone 2

Type Checking 3AC generated in the same pass

● Type errors thrown are similar to python ● There is a single pass which involves parsing,
type checking and 3AC generation
● Type compatibility checked based on implicit
type casting ● The 3AC code is stored in quadruples

● Trailered expressions have recursive


type-checking

● Four entries of print function for the 4 primitive


types
3AC conventions Symbol Table

● Temporaries start with “__” ● Global symbol table - contains information


about classes and global functions
● Stack manipulation: push_param, pop_param,
+xxx, -xxx ● Class symbol table - contains entries for
various attributes and member functions
● Name mangling has been used with “@” as
separator ● Function symbol table - contains the entries of
formal parameters and local variables
● Special instructions for making strings, printing
strings and booleans ● For inheritance, we perform lookup in class
hierarchy
Milestone 3

Local Variables and Temporaries Custom functions

● The local variables and ● Custom functions for strcmp, len,


temporaries are pushed on stack allocmem print have been added

● Their local offset relative to rbp is ● Print, strcmp1, allocmem further


used for addressing them call the glibc implementation of
printf, strcmp, malloc
respectively
Three AC to X86 Calling conventions

● The code has been divided ● We pass parameters to functions


according to functions through stack

● Code is generated function-wise ● Return value is in register rax

● We generate code through a ● Popping of params is done in


template matching scheme reverse order in which they appear
in the body of function

● Register saving is done on calls


Optional Features Supported

● Implicit and explicit Line joining

● Multiple function calls in a line (nested function calls)

● Chained attributes (a.b.c.m(), a.b()[].m(), ....)

● Array index out of range check


CODE
WALKTHROUGH

Talk is cheap. Show me the code


THANK
YOU
- Team Pythoneers
Member Contribution (%)

Chitwan Goel 33.33%

Shrey Bansal 33.33%


CREDITS: This presentation template was
created by Slidesgo, and includes icons by
Talin Gupta 33.33%
Flaticon and infographics & images by Freepik

You might also like