Documentation_compiler
Documentation_compiler
------------------------------------COMPILATHON--------------------------------------
Team :
Overview :
This document describes a compiler that transforms C++ matrix operations into custom instruction set
architecture (ISA) commands for a Processor-in-Memory (PIM) system. The process involves generating
LLVM Intermediate Representation, extracting Three-Address Code, and converting this code into machine
instructions compatible with the PIM architecture.
Process Flow :
C++ Code → LLVM IR → TAC Extraction → ISA Generation → Parallel Execution
Key Components :
Clang / LLVM: Converts C++ to LLVM IR and provides analysis tools
Target Architecture: Uses 24-bit instruction format designed for DRAM subarray parallel processing
Implementation Steps :
1. Starting Point
Begin with a C++ program containing predefined matrices and a matrix multiplication function.
2. Generate LLVM IR
Output : matrix_ops.ll
Used ( -01 ) : Disables optnone attribute , allowing the LLVM pass to analyze the IR.
Custom LLVM pass (TACGenPass.cpp) identifies load, store, and arithmetic operations
The pass outputs operations to tac_output.txt
Compilation command:
Compile the pass : clang++ -shared -fPIC TACGenPass.cpp -o tacgen.so $(llvm-config --cxxflags --ldflags
--system-libs --libs core)
Run the pass : opt -load-pass-plugin ./tacgen.so -passes="tacgen" matrix_ops.ll -o /dev/null 2> tac_output.txt
OUTPUT : tac_output.txt
OUTPUT : parallal_output.isa
ISA Instruction Format
24-bit instruction with the following fields:
Example Instruction
o nuw (No Unsigned Wrap) and nsw (No Signed Wrap) are LLVM flags indicating no
overflow occurs.
2. GEP: %12 = getelementptr inbounds [2 x i32], ptr %2, i64 %5, i64 %11
o This stores the value 0 into memory at %12. This likely corresponds to initializing C[i][j] = 0.
5. GEP: %19 = getelementptr inbounds [2 x i32], ptr %0, i64 %5, i64 %17
7. GEP: %21 = getelementptr inbounds [2 x i32], ptr %1, i64 %17, i64 %11
}
}