Félix Cloutier via llvm-dev
2015-Oct-24 03:53 UTC
[llvm-dev] Matching instruction patterns from a FunctionPass
Hi all, I'm working on a pass that would need to match a pattern of instructions. In pseudo-IR: %0 = sub %a, %b %1 = xor %a, %b %2 = xor %0, %a %3 = and %1, %2 After this instruction sequence, %3's most significant bit tells whether the subtraction overflowed. I would like to find occurrences of this pattern from a FunctionPass. However, this has a couple of possible permutations. And and Xor are both commutative, meaning that there are 8 valid ways to express this. Since I might not be the first person to run into this kind of issue, I was wondering if there is a common way to handle this. Thanks! Félix
Félix Cloutier via llvm-dev
2015-Oct-24 16:45 UTC
[llvm-dev] Matching instruction patterns from a FunctionPass
Looks like llvm/IR/PatternMatch.h is what I'm looking for. Félix> Le 23 oct. 2015 à 23:53:44, Félix Cloutier <felixcca at yahoo.ca> a écrit : > > Hi all, > > I'm working on a pass that would need to match a pattern of instructions. In pseudo-IR: > > %0 = sub %a, %b > %1 = xor %a, %b > %2 = xor %0, %a > %3 = and %1, %2 > > After this instruction sequence, %3's most significant bit tells whether the subtraction overflowed. I would like to find occurrences of this pattern from a FunctionPass. > > However, this has a couple of possible permutations. And and Xor are both commutative, meaning that there are 8 valid ways to express this. Since I might not be the first person to run into this kind of issue, I was wondering if there is a common way to handle this. > > Thanks! > > Félix