# Programming Exercise 7: Register Allocation This is the continuation of hw06. You can continue from your own code or use the parser from the website as starting point. ## Implementation Implement a register allocator and annotate your instruction-selected-LLVM-IR with the allocation, inserting appropriate spill code (if necessary). There is no requirement on the complexity of the algorithm, it should "just work". Annotate the output of each instruction with metadata to indicate the register. Note that for function calls, the arguments and return value have fixed locations and observe that the calling convention may permit the callee to clobber more registers. You may assume that all parameters are passed in registers (you don't need to handle functions requiring parameters to be passed on the stack). If you choose to implement a more advanced algorithm, it might be easier to first restrict to block-local allocation and assignment. You can use the following snippet to attach metadata to an instruction: auto val = llvm::ValueAsMetadata::get(llvm::ConstantInt::get(i64ty, regidx)); inst->setMetadata("reg", llvm::MDNode::get(ctx, {val})); # Submission Send an e-mail to engelke+cghomework@in.tum.de until 2022-12-21, 23:59 with: - Subject: "Homework 7: YourMatrNr YourName" - A single(!) .tar.xz file attached named with "hw7-YourMatrNr-YourLastName.tar.xz", which contains a single folder "hw7-YourMatrNr-YourLastName", which contains your submission - The message body can remain empty - Include a Makefile with compilation directives s.t. `make` compiles the code - Specify correct dependencies in the Makefile - Use `llvm-config --cppflags --ldflags --libs` to find LLVM. - Avoid external dependencies and complex build systems (no cmake, cargo, etc.) - Put the source in a single source file (if easily possible) - Include answers to theory questions as comments in the source file