Good morning everyone,
I want to introduce my new side project LLQL Github Repository
LLQL allow you to run SQL queries on LLVM IR/BC files and perform pattern matchers functions inspired by InstCombine functions
Example:
If we have LLVM IR function like this, and we want to match add
instruction that has result of sub instruction as Left hand side and result of mul instruction as Right hand side.
define i32 @function(i32 %a, i32 %b) {
%sub = sub i32 %a, %b
%mull = mul i32 %a, %b
%add = add i32 %sub, %mull
ret i32 %add
}
We can query to print the instruction with this query
SELECT instruction FROM instructions WHERE m_inst(instruction, m_add(m_sub(), m_mul()))
Or for example you can query how many times this pattern exists in each function
SELECT function_name, count() FROM instructions WHERE m_inst(instruction, m_add(m_sub(), m_mul())) GROUP BY function_name
Looking forward for your feedback,
Thanks