$30
CMPE 230 Systems Programming
Homework 1
( This project can be implemented only in C/C++ or Java )
LLVM (low level virtual machine - http://llvm.org/ ) is a compiler infrastructure that provides IR (intermediate representation) that can be used to generate code for various target architectures.
In this project you will develop a translator called STM2IR that will input assignment statements and expressions (one on each line). STM2IR will generate low level LLVM IR code that will compute and output these statements.
For example, given the following code in file.stm:
Syntax Error Handling
When there is a syntax error on the given statement file, the program should exit without generating LLVM IR code (when it encounters the first error) and write an error message on the standard output stream. The error message will have the following template:
Error: Line <number: <message
The exact wording of the error message is not important, but it should be informative about the error and it should point the correct line number of the given statement file. Please note the following about the IR code:
• LLVM IR uses static single assignment (SSA) based representation. In assignment statements, variables are assigned a value once.
• alloca is used to allocate space for variables and return address of allocation.
• In IR, variables start with % sign.
• The keyword i8, i16 and i32 means 8 bit, 16 bit and 32 bit type respectively.
• The keyword i32 * means 32 bit pointer.
• Variables %i (where i is an integer) are temporary variables.
• The yellow colored code defines the module name and the prototype for the printf output statement. Generate this part as it is shown in the above example.
• The green colored code is for printing the value of a variable using the printf function.
• You can assume only binary operations (+,-,*, / ) will be used in the expressions. All variables and operations are integer operations. Division operation gives the quotient.
Note that you are implementing only the stm2ir program. The others are LLVM commands. You should prepare a makefile that compiles your source code. Your project will be graded according to the following criteria:
Documentation (written document describing 12% how you implemented your project)
Comments in your code 8%
Implementation and tests 80%
Submission
You can enroll canvas web site following this url: https://canvas.instructure.com/enroll/9Y7HEC You will navigate to Assignments and choose Homework1. You will upload only your source codes, Makefile and documentation file as a single compressed file.
Late Submission
If the project is submitted late, the following penalties will be applied:
• 0 < hours late <= 24 : 25%
• 24 < hours late <= 48 : 50%
• hours late 48 : 100%
Proof of Existence
Before you submit your project, please notarize your project zip file at http://virtual-notary.org/ by using the “Notarize a document” button and save the details of the notary log. Do NOT lose the
notary log and the project zip file. It is a proof that your project zip file existed during the time of submission. If for some reason something went wrong with submission, notary log and the corresponding project zip file will prove that your project zip file existed. Only the project zip file that matches the notary log will be accepted. If you show a project zip file that does not match (correspond to) the notary log, it will NOT be accepted !.