[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PATCH 1/3] scripts: add muldiv64() checking coccinelle s
From: |
Laurent Vivier |
Subject: |
[Qemu-trivial] [PATCH 1/3] scripts: add muldiv64() checking coccinelle scripts |
Date: |
Wed, 4 May 2016 15:04:06 +0200 |
Signed-off-by: Laurent Vivier <address@hidden>
---
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)
address@hidden@
+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
+
address@hidden@
+position filter.p;
+expression a, b, c;
+@@
+
+-muldiv64(a,b,c)@p
++muldiv64(b,a,c)
--
2.5.5