@@ -6,6 +6,7 @@ use super::Matcher;
66
77#[ derive( PartialEq , Clone ) ]
88enum CastMatcherKind {
9+ Any ,
910 Trunc ,
1011 IntToPtr ,
1112 PtrToInt ,
@@ -23,19 +24,42 @@ enum CastMatcherKind {
2324impl CastMatcherKind {
2425 pub fn match_llvm_opcode ( & self , llvm_op : LLVMOpcode ) -> bool {
2526 match llvm_op {
26- LLVMOpcode :: LLVMTrunc => matches ! ( self , CastMatcherKind :: Trunc ) ,
27- LLVMOpcode :: LLVMFPToUI => matches ! ( self , CastMatcherKind :: FPToUI ) ,
28- LLVMOpcode :: LLVMFPToSI => matches ! ( self , CastMatcherKind :: FPToSI ) ,
29- LLVMOpcode :: LLVMFPTrunc => matches ! ( self , CastMatcherKind :: FPTrunc ) ,
30-
31- LLVMOpcode :: LLVMFPExt => matches ! ( self , CastMatcherKind :: Ext | CastMatcherKind :: FPExt ) ,
32- LLVMOpcode :: LLVMZExt => matches ! ( self , CastMatcherKind :: Ext | CastMatcherKind :: ZExt ) ,
33- LLVMOpcode :: LLVMSExt => matches ! ( self , CastMatcherKind :: Ext | CastMatcherKind :: SExt ) ,
34-
35- LLVMOpcode :: LLVMIntToPtr => matches ! ( self , CastMatcherKind :: IntToPtr ) ,
36- LLVMOpcode :: LLVMPtrToInt => matches ! ( self , CastMatcherKind :: PtrToInt ) ,
37- LLVMOpcode :: LLVMBitCast => matches ! ( self , CastMatcherKind :: BitCast ) ,
38- LLVMOpcode :: LLVMAddrSpaceCast => matches ! ( self , CastMatcherKind :: AddrSpaceCast ) ,
27+ LLVMOpcode :: LLVMTrunc => matches ! ( self , CastMatcherKind :: Any | CastMatcherKind :: Trunc ) ,
28+ LLVMOpcode :: LLVMFPToUI => {
29+ matches ! ( self , CastMatcherKind :: Any | CastMatcherKind :: FPToUI )
30+ }
31+ LLVMOpcode :: LLVMFPToSI => {
32+ matches ! ( self , CastMatcherKind :: Any | CastMatcherKind :: FPToSI )
33+ }
34+ LLVMOpcode :: LLVMFPTrunc => {
35+ matches ! ( self , CastMatcherKind :: Any | CastMatcherKind :: FPTrunc )
36+ }
37+
38+ LLVMOpcode :: LLVMFPExt => matches ! (
39+ self ,
40+ CastMatcherKind :: Any | CastMatcherKind :: Ext | CastMatcherKind :: FPExt
41+ ) ,
42+ LLVMOpcode :: LLVMZExt => matches ! (
43+ self ,
44+ CastMatcherKind :: Any | CastMatcherKind :: Ext | CastMatcherKind :: ZExt
45+ ) ,
46+ LLVMOpcode :: LLVMSExt => matches ! (
47+ self ,
48+ CastMatcherKind :: Any | CastMatcherKind :: Ext | CastMatcherKind :: SExt
49+ ) ,
50+
51+ LLVMOpcode :: LLVMIntToPtr => {
52+ matches ! ( self , CastMatcherKind :: Any | CastMatcherKind :: IntToPtr )
53+ }
54+ LLVMOpcode :: LLVMPtrToInt => {
55+ matches ! ( self , CastMatcherKind :: Any | CastMatcherKind :: PtrToInt )
56+ }
57+ LLVMOpcode :: LLVMBitCast => {
58+ matches ! ( self , CastMatcherKind :: Any | CastMatcherKind :: BitCast )
59+ }
60+ LLVMOpcode :: LLVMAddrSpaceCast => {
61+ matches ! ( self , CastMatcherKind :: Any | CastMatcherKind :: AddrSpaceCast )
62+ }
3963 _ => false ,
4064 }
4165 }
@@ -57,6 +81,10 @@ impl CastInstMatcher {
5781}
5882
5983impl CastInstMatcher {
84+ pub fn create_any ( value_matcher : Box < dyn Matcher < LLVMValueRef > > ) -> CastInstMatcher {
85+ CastInstMatcher :: new ( value_matcher, CastMatcherKind :: Any )
86+ }
87+
6088 pub fn create_trunc ( value_matcher : Box < dyn Matcher < LLVMValueRef > > ) -> CastInstMatcher {
6189 CastInstMatcher :: new ( value_matcher, CastMatcherKind :: Trunc )
6290 }
0 commit comments