Skip to content

rjschave/python-student-support-code

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-student-support-code

Support code for students (Python version).

The runtime.c file needs to be compiled by doing the following

   gcc -c -g -std=c99 runtime.c

This will produce a file named runtime.o. The -g flag is to tell the compiler to produce debug information that you may need to use the gdb (or lldb) debugger.

On a Mac with an M1 (ARM) processor, use the -arch x86_64 flag to compile the runtime:

   gcc -c -g -std=c99 -arch x86_64 runtime.c

Using the Racket x86 interpreters

This section describes how you can use racket_interp_x86 and racket_interp_pseudo_x86 interpreters defined in the racket_interp_x86.py file. The x86 interpreter defined in the interp_x86 directory doesn't support the x86-like languages generated by the select instructions pass of every compiler starting from the chapter on tuples. The interpreters in racket_interp_x86.py will help you interpret these x86-like languages along with actual x86 code. As the name suggests, these interpreters run using the x86 interpreter in the Racket version of this repository.

Setup instructions

  1. Install Racket from here.

  2. Clone the Racket version of this repository into the parent directory of this repository. The directory into which you clone the repository is important because racket_interp_x86.py is hardcoded to look for the Racket version of the x86 interpreter in the parent directory.

  3. Add racket_interp_pseudo_x86 interpreter to your interp_dict for passes before assign homes. For the remaining passes, use racket_interp_x86.

Caveats

  • Since your x86 code is interpreted in Racket, any errors occurring during interpretation will show up in the output diff and not as a Python exception.
  • You will need to add the following fields to a root AST dataclass object or a FunctionDef dataclass object before passing it to the interpreter:
    • num_params: This field needs to be added to FunctionDef objects. The value of this field will be the number of parameters that the function associated with the FunctionDef object accepts.
    • num_root_spills: This field needs to be added to both X86Program and FunctionDef objects. The value of this field will be the number of tuple variables that have been spilled into the root stack.

About

Support for for students (Python)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 95.2%
  • C 4.8%