Signed-off-by: Laurent Vivier <lviv...@redhat.com> --- scripts/coccinelle/remove_muldiv64.cocci | 6 +++++ scripts/coccinelle/swap_muldiv64.cocci | 46 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 scripts/coccinelle/remove_muldiv64.cocci create mode 100644 scripts/coccinelle/swap_muldiv64.cocci
diff --git a/scripts/coccinelle/remove_muldiv64.cocci b/scripts/coccinelle/remove_muldiv64.cocci new file mode 100644 index 0000000..4c10bd5 --- /dev/null +++ b/scripts/coccinelle/remove_muldiv64.cocci @@ -0,0 +1,6 @@ +// replace muldiv64(a, 1, b) by "a / b" +@@ +expression a, b; +@@ +-muldiv64(a, 1, b) ++a / b diff --git a/scripts/coccinelle/swap_muldiv64.cocci b/scripts/coccinelle/swap_muldiv64.cocci new file mode 100644 index 0000000..39a278d --- /dev/null +++ b/scripts/coccinelle/swap_muldiv64.cocci @@ -0,0 +1,46 @@ +// replace muldiv64(i32, i64, x) by muldiv64(i64, i32, x) +@filter@ +typedef uint64_t; +typedef int64_t; +typedef uint32_t; +typedef int32_t; +uint64_t u64; +int64_t s64; +uint32_t u32; +int32_t s32; +int si; +unsigned int ui; +long sl; +unsigned long ul; +expression b; +position p; +@@ + muldiv64( +( +si +| +ui +| +s32 +| +u32 +) +, +( +sl +| +ul +| +u64 +| +s64 +) +, b)@p + +@swap@ +position filter.p; +expression a, b, c; +@@ + +-muldiv64(a,b,c)@p ++muldiv64(b,a,c) -- 2.5.5