3 * Copyright (c) 2001 Tom Barry All rights reserved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * Relicensed for GStreamer from GPL to LGPL with permit from Tom Barry.
23 * See: http://bugzilla.gnome.org/show_bug.cgi?id=163578
26 // Define a few macros for CPU dependent instructions.
27 // I suspect I don't really understand how the C macro preprocessor works but
28 // this seems to get the job done. // TRB 7/01
30 // BEFORE USING THESE YOU MUST SET:
32 // #define SIMD_TYPE MMXEXT (or MMX or 3DNOW)
34 // some macros for pavgb instruction
35 // V_PAVGB(mmr1, mmr2, mmr work register, smask) mmr2 may = mmrw if you can trash it
37 #define V_PAVGB_MMX(mmr1, mmr2, mmrw, smask) \
38 "movq "mmr2", "mmrw"\n\t" \
39 "pand "smask", "mmrw"\n\t" \
40 "psrlw $1, "mmrw"\n\t" \
41 "pand "smask", "mmr1"\n\t" \
42 "psrlw $1, "mmr1"\n\t" \
43 "paddusb "mmrw", "mmr1"\n\t"
44 #define V_PAVGB_MMXEXT(mmr1, mmr2, mmrw, smask) "pavgb "mmr2", "mmr1"\n\t"
45 #define V_PAVGB_3DNOW(mmr1, mmr2, mmrw, smask) "pavgusb "mmr2", "mmr1"\n\t"
46 #define V_PAVGB(mmr1, mmr2, mmrw, smask) V_PAVGB2(mmr1, mmr2, mmrw, smask, SIMD_TYPE)
47 #define V_PAVGB2(mmr1, mmr2, mmrw, smask, simd_type) V_PAVGB3(mmr1, mmr2, mmrw, smask, simd_type)
48 #define V_PAVGB3(mmr1, mmr2, mmrw, smask, simd_type) V_PAVGB_##simd_type(mmr1, mmr2, mmrw, smask)
50 // some macros for pmaxub instruction
51 #define V_PMAXUB_MMX(mmr1, mmr2) \
52 "psubusb "mmr2", "mmr1"\n\t" \
53 "paddusb "mmr2", "mmr1"\n\t"
54 #define V_PMAXUB_MMXEXT(mmr1, mmr2) "pmaxub "mmr2", "mmr1"\n\t"
55 #define V_PMAXUB_3DNOW(mmr1, mmr2) V_PMAXUB_MMX(mmr1, mmr2) // use MMX version
56 #define V_PMAXUB(mmr1, mmr2) V_PMAXUB2(mmr1, mmr2, SIMD_TYPE)
57 #define V_PMAXUB2(mmr1, mmr2, simd_type) V_PMAXUB3(mmr1, mmr2, simd_type)
58 #define V_PMAXUB3(mmr1, mmr2, simd_type) V_PMAXUB_##simd_type(mmr1, mmr2)
60 // some macros for pminub instruction
61 // V_PMINUB(mmr1, mmr2, mmr work register) mmr2 may NOT = mmrw
62 #define V_PMINUB_MMX(mmr1, mmr2, mmrw) \
63 "pcmpeqb "mmrw", "mmrw"\n\t" \
64 "psubusb "mmr2", "mmrw"\n\t" \
65 "paddusb "mmrw", "mmr1"\n\t" \
66 "psubusb "mmrw", "mmr1"\n\t"
67 #define V_PMINUB_MMXEXT(mmr1, mmr2, mmrw) "pminub "mmr2", "mmr1"\n\t"
68 #define V_PMINUB_3DNOW(mmr1, mmr2, mmrw) V_PMINUB_MMX(mmr1, mmr2, mmrw) // use MMX version
69 #define V_PMINUB(mmr1, mmr2, mmrw) V_PMINUB2(mmr1, mmr2, mmrw, SIMD_TYPE)
70 #define V_PMINUB2(mmr1, mmr2, mmrw, simd_type) V_PMINUB3(mmr1, mmr2, mmrw, simd_type)
71 #define V_PMINUB3(mmr1, mmr2, mmrw, simd_type) V_PMINUB_##simd_type(mmr1, mmr2, mmrw)
73 // some macros for movntq instruction
74 // V_MOVNTQ(mmr1, mmr2)
75 #define V_MOVNTQ_MMX(mmr1, mmr2) "movq "mmr2", "mmr1"\n\t"
76 #define V_MOVNTQ_3DNOW(mmr1, mmr2) "movq "mmr2", "mmr1"\n\t"
77 #define V_MOVNTQ_MMXEXT(mmr1, mmr2) "movntq "mmr2", "mmr1"\n\t"
78 #define V_MOVNTQ(mmr1, mmr2) V_MOVNTQ2(mmr1, mmr2, SIMD_TYPE)
79 #define V_MOVNTQ2(mmr1, mmr2, simd_type) V_MOVNTQ3(mmr1, mmr2, simd_type)
80 #define V_MOVNTQ3(mmr1, mmr2, simd_type) V_MOVNTQ_##simd_type(mmr1, mmr2)