Browse code

Blackfin 32bit multiplication primitives MULH MUL16

Originally committed as revision 10262 to svn://svn.ffmpeg.org/ffmpeg/trunk

Marc Hoffman authored on 2007/08/31 00:15:48
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,52 @@
0
+/*
1
+ * mathops.h
2
+ *
3
+ * Copyright (C) 2007 Marc Hoffman <mmhoffm@gmail.com>
4
+ *
5
+ * This file is part of FFmpeg.
6
+ *
7
+ * FFmpeg is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * FFmpeg is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with FFmpeg; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
+ */
21
+#ifndef MATHOPS_BFIN
22
+#define MATHOPS_BFIN
23
+
24
+#ifdef CONFIG_MPEGAUDIO_HP
25
+#define MULH(X,Y) ({ int xxo;                           \
26
+    asm (                                               \
27
+        "a1 = %2.L * %1.L (FU);\n\t"                    \
28
+        "a1 = a1 >> 16;\n\t"                            \
29
+        "a1 += %2.H * %1.L (IS,M);\n\t"                 \
30
+        "a0 = %1.H * %2.H, a1+= %1.H * %2.L (IS,M);\n\t"\
31
+        "a1 = a1 >>> 16;\n\t"                           \
32
+        "%0 = (a0 += a1);\n\t"                          \
33
+        : "=d" (xxo) : "d" (X), "d" (Y)); xxo; })
34
+#else
35
+#define MULH(X,Y) ({ int xxo;                           \
36
+    asm (                                               \
37
+        "a1 = %2.H * %1.L (IS,M);\n\t"                  \
38
+        "a0 = %1.H * %2.H, a1+= %1.H * %2.L (IS,M);\n\t"\
39
+        "a1 = a1 >>> 16;\n\t"                           \
40
+        "%0 = (a0 += a1);\n\t"                          \
41
+        : "=d" (xxo) : "d" (X), "d" (Y)); xxo; })
42
+#endif
43
+
44
+/* signed 16x16 -> 32 multiply */
45
+#define MUL16(a, b) ({ int xxo;                         \
46
+    asm (                                               \
47
+       "%0 = %1.l*%2.l (is);\n\t"                       \
48
+       : "=W" (xxo) : "d" (a), "d" (b));                \
49
+    xxo; })
50
+
51
+#endif