CMSC 435: Assignment 10
Overview
Create a CodeGenVisitor class that emits LLVM IR.
Use CodeGenVisitor.hh as a basis
for your code generator visitor, that will use the visitor design
pattern to walk the AST and generate intermediate code. If necessary,
modify the appropriate AST node definitions in Ast.hh for
this purpose.
Input Specification
Take the name of a C- program as a command-line argument. If no
argument is specified read from standard input (this is NECESSARY for
the grading scripts). Use .cm as the extension for C-
source files. You may add zero or more optional flags.
> ./CMinus [ --flag ]* [ <Program.cm> ]
Output Specification
Output “Valid!” if the program is a valid sentence in C- AND it has no symbol errors. Output the AST to a text file if and only if there are no errors. Output errors as in previous assignments.
If there are no syntax or semantic errors, perform the last pass with
a CodeGenVisitor to emit LLVM IR to X.ll,
where X is the base name of the source file. If reading
from stdin, output code to Default.ll (and the tree to
Default.ast). Once the LLVM IR code is generated,
programmatically invoke clang (via system) on
the generated code and Runtime.c to produce an executable
named X (or Default).
Use PRECISELY the format below with the EXACT same SPACING and SPELLING.
> ./CMinus Gcd.cm
Valid!
AST output: Gcd.ast
IR output: Gcd.ll
Executable: Gcd
Logistics
You may work with a partner. Only ONE team member should submit. Ensure each team member’s name is listed in all submitted files.
Submission
Submit ALL necessary source files and a Makefile. ENSURE
your Makefile is named Makefile, properly builds your
program, and that make clean removes all generated files
(binaries, object files, *.ll, and *.ast).
ALSO, submit a text file Team.txt listing your team
members (even if you’re the only member), each member’s contributions,
what functionality works, what doesn’t, and the areas with which you
struggled.
NOTE: NO submissions will be accepted after the due date.
Final Compiler Presentation
You will have 10 minutes (+/- two minutes) to present your work. No slides are required. Discuss at least the points below.
each team member’s contributions.
what your compiler handles CORRECTLY.
what your compiler handles INCORRECTLY.
what areas you struggled with.
unique design elements (e.g., classes beyond the ones we discussed, modern C++ usage).
non-required functionality.
a demo of your compiler handling TWO non-trivial input programs (at least three functions, argument passing, and arrays).
Hints
Use Runtime.c to provide support for the I/O functions.
Gary M. Zoppetti, Ph.D.