Libav
|
00001 /* 00002 * Copyright (c) 2010 Alexander Strange <astrange@ithinksw.com> 00003 * 00004 * This file is part of FFmpeg. 00005 * 00006 * FFmpeg is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * FFmpeg is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with FFmpeg; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 #ifndef AVUTIL_X86_INTREADWRITE_H 00022 #define AVUTIL_X86_INTREADWRITE_H 00023 00024 #include <stdint.h> 00025 #include "config.h" 00026 #include "libavutil/attributes.h" 00027 00028 #if HAVE_MMX 00029 00030 #if !HAVE_FAST_64BIT && defined(__MMX__) 00031 00032 #define AV_COPY64 AV_COPY64 00033 static av_always_inline void AV_COPY64(void *d, const void *s) 00034 { 00035 __asm__("movq %1, %%mm0 \n\t" 00036 "movq %%mm0, %0 \n\t" 00037 : "=m"(*(uint64_t*)d) 00038 : "m" (*(const uint64_t*)s) 00039 : "mm0"); 00040 } 00041 00042 #define AV_SWAP64 AV_SWAP64 00043 static av_always_inline void AV_SWAP64(void *a, void *b) 00044 { 00045 __asm__("movq %1, %%mm0 \n\t" 00046 "movq %0, %%mm1 \n\t" 00047 "movq %%mm0, %0 \n\t" 00048 "movq %%mm1, %1 \n\t" 00049 : "+m"(*(uint64_t*)a), "+m"(*(uint64_t*)b) 00050 ::"mm0", "mm1"); 00051 } 00052 00053 #define AV_ZERO64 AV_ZERO64 00054 static av_always_inline void AV_ZERO64(void *d) 00055 { 00056 __asm__("pxor %%mm0, %%mm0 \n\t" 00057 "movq %%mm0, %0 \n\t" 00058 : "=m"(*(uint64_t*)d) 00059 :: "mm0"); 00060 } 00061 00062 #endif /* !HAVE_FAST_64BIT && defined(__MMX__) */ 00063 00064 #ifdef __SSE__ 00065 00066 #define AV_COPY128 AV_COPY128 00067 static av_always_inline void AV_COPY128(void *d, const void *s) 00068 { 00069 struct v {uint64_t v[2];}; 00070 00071 __asm__("movaps %1, %%xmm0 \n\t" 00072 "movaps %%xmm0, %0 \n\t" 00073 : "=m"(*(struct v*)d) 00074 : "m" (*(const struct v*)s) 00075 : "xmm0"); 00076 } 00077 00078 #endif /* __SSE__ */ 00079 00080 #ifdef __SSE2__ 00081 00082 #define AV_ZERO128 AV_ZERO128 00083 static av_always_inline void AV_ZERO128(void *d) 00084 { 00085 struct v {uint64_t v[2];}; 00086 00087 __asm__("pxor %%xmm0, %%xmm0 \n\t" 00088 "movdqa %%xmm0, %0 \n\t" 00089 : "=m"(*(struct v*)d) 00090 :: "xmm0"); 00091 } 00092 00093 #endif /* __SSE2__ */ 00094 00095 #endif /* HAVE_MMX */ 00096 00097 #endif /* AVUTIL_X86_INTREADWRITE_H */