Libav 0.7.1
libavcodec/mips/mathops.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
00003  *
00004  * This file is part of Libav.
00005  *
00006  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 
00021 #ifndef AVCODEC_MIPS_MATHOPS_H
00022 #define AVCODEC_MIPS_MATHOPS_H
00023 
00024 #include <stdint.h>
00025 #include "config.h"
00026 #include "libavutil/common.h"
00027 
00028 #if HAVE_INLINE_ASM
00029 
00030 #if HAVE_LOONGSON
00031 
00032 static inline av_const int64_t MAC64(int64_t d, int a, int b)
00033 {
00034     int64_t m;
00035     __asm__ ("dmult.g %1, %2, %3 \n\t"
00036              "daddu   %0, %0, %1 \n\t"
00037              : "+r"(d), "=&r"(m) : "r"(a), "r"(b));
00038     return d;
00039 }
00040 #define MAC64(d, a, b) ((d) = MAC64(d, a, b))
00041 
00042 static inline av_const int64_t MLS64(int64_t d, int a, int b)
00043 {
00044     int64_t m;
00045     __asm__ ("dmult.g %1, %2, %3 \n\t"
00046              "dsubu   %0, %0, %1 \n\t"
00047              : "+r"(d), "=&r"(m) : "r"(a), "r"(b));
00048     return d;
00049 }
00050 #define MLS64(d, a, b) ((d) = MLS64(d, a, b))
00051 
00052 #elif ARCH_MIPS64
00053 
00054 static inline av_const int64_t MAC64(int64_t d, int a, int b)
00055 {
00056     int64_t m;
00057     __asm__ ("dmult %2, %3     \n\t"
00058              "mflo  %1         \n\t"
00059              "daddu %0, %0, %1 \n\t"
00060              : "+r"(d), "=&r"(m) : "r"(a), "r"(b));
00061     return d;
00062 }
00063 #define MAC64(d, a, b) ((d) = MAC64(d, a, b))
00064 
00065 static inline av_const int64_t MLS64(int64_t d, int a, int b)
00066 {
00067     int64_t m;
00068     __asm__ ("dmult %2, %3     \n\t"
00069              "mflo  %1         \n\t"
00070              "dsubu %0, %0, %1 \n\t"
00071              : "+r"(d), "=&r"(m) : "r"(a), "r"(b));
00072     return d;
00073 }
00074 #define MLS64(d, a, b) ((d) = MLS64(d, a, b))
00075 
00076 #endif
00077 
00078 #endif /* HAVE_INLINE_ASM */
00079 
00080 #endif /* AVCODEC_MIPS_MATHOPS_H */