In this assignment you will implement the Lazy Code Motion algorithm (notes, video). You have already implemented the first part of it (Anticipated Expressions Analysis) in previous lab. In this lab, you will implement the remaining bits. If you didn't complete the previous lab, you might want to do that first.
As with previous lab, you will work with the Compilerai framework.
Follow Getting started of previous lab to complete initial setup.
Now, pull lab 2 specific changes with git pull origin col729_lab2
in both top-level directory (superopt-project
) and superopt
directory.
In most cases, the merging should happen automatically. If it does not and you are unable to resolve the conflicts manually, post a note on Piazza.
The primary places where you need to make changes have been marked with COL729_LAB2 TODO. Search for them using git grep 'COL729_LAB2 TODO'
.
Before starting the implementation, you might want to review material from previous lab for a quick recap.
You will implement the four analyses of Lazy Code Motion algorithm. We will stop short of the last step where the result of the analyses is used for code transformation. The DFA implementation will remain similar to previous lab, however, you must keep the following representational differences between TFGs and CFGs in mind:
As before, the classes corresponding to the four analyses have been created for you, along with all the boilerplate code. You just need to supply the core logic in places marked with COL729_LAB2 TODO:
include/graph/anticipated_exprs{,_dfa}.h
include/graph/missing_exprs{,_dfa}.h
include/graph/earliest_exprs.h
include/graph/postponable_exprs{,_dfa}.h
include/graph/latest_exprs.h
include/graph/used_exprs{,_dfa}.h
Once you have filled-in the required code, you need to first uncomment the comment block marked with COL729_LAB2_UNCOMMENT_ME to run the four analyses.
The steps for building and running the code remain same as before except the name of test directory which is lab2_test
.
The results of your analyses will be available in serialized format in the output TFG file. The format for PC bound results remain same as before.
The format for edge bound results refers to an edge instead of a PC. For example:
=Earliest expressions in src.llvm.sum =earliest expressions at L0%0%1=>Lentry%1%1 in src.llvm.sum =earliest_exprs begin =expr 1 : 0 : BV:32 2 : input.src.llvm-%n : BV:32 3 : bvslt(1, 2) : BOOL =expr =earliest_exprs end ... ... ...
The above example represents the following information: for the edge from L0%0%1
to Lentry%1%1
, the earliest expressions set contains bvslt(0, input.src.llvm-%n)
.
superopt
repository in the form of a compressed patch file:
git diff col729_lab2 | gzip > ${your_group_members_entry_nums}.gz
${your_group_members_entry_nums}.gz
to moodleNOTE: It is your responsibility to ensure that a sequence of gunzip -c ${your_group_members_entry_nums}.gz | patch -p1
, when executed in superopt
root with HEAD at col728_lab2
, produces a tree equivalent to yours.