This work contains an interference graph generator pass, a deep learning model, and a registor allocation pass. Two passes were implemented in the LLVM source code. That means you have to download LLVM into your local directory and put two passes there.
-
- This python file controls the workflow. It runs X86IGGenerator.cpp pass, then deep learning model, and RegAlloc.cpp pass.
-
- It is the script run by entry.py to call X86IGGenerator.cpp pass.
- -O1 optimization is applied.
-
- It is the scrip run by entry.py to call RegAlloc.cpp pass.
- -O1 optimization is applied.
-
- The saved checkpoint
-
- Architecture of the model.
-
- It keeps track the information of virtural registers corresponding to the interference graph.
-
- It is a machine function pass to generate interference graph from C/C++ program.
-
- It is a machine function pass to assign physical registers to virtual registers based on the output from the model. Assume source code only have main function for now.
We used LLVM with 16.x version. After installing, put RegAlloc.cpp under "llvm-project/llvm/lib/CodeGen/RegAlloc.cpp", and put X86IGGenerator under "llvm-project/llvm/lib/Target/X86/X86IGGenerator.cpp".
- For X86IGGenerator pass
- add
FunctionPass *createX86IGGeneratorPass();
inX86.h
- add
addPass(createX86IGGeneratorPass());
under functionX86PassConfig::addRegAssignAndRewriteOptimized()
inX86TargetMachine.cpp
- Put pass name under the CMakeList under
X86
folder
- add
- For RegAlloc pass
- add
initializeRegAllocGraphColoringPass(Registry);
inlib/CodeGen/CodeGen.cpp
- Put pass name under the CMakeList under
lib/CodeGen
folder - add
(void) llvm::createColorRegisterAllocator();
ininclude/llvm/CodeGen/LinkAllCodegenComponents.h
- add
void initializeRegAllocGraphColoringPass(PassRegistry&);
ininclude/llvm/InitializePasses.h
- replace
/home/chrenx/Desktop/eecs583/final-project/demo/vr_tracking.csv
and other directory with your own path
- add
- $ conda activate eecs583
- $ pip install -r requirements.txt
- Put the C program under the demo folder
- $ cd demo
- $ python -m entry -f c_program_file_name