00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AVCODEC_ALPHA_ASM_H
00023 #define AVCODEC_ALPHA_ASM_H
00024
00025 #include <inttypes.h>
00026
00027 #include "libavutil/common.h"
00028
00029 #if AV_GCC_VERSION_AT_LEAST(2,96)
00030 # define likely(x) __builtin_expect((x) != 0, 1)
00031 # define unlikely(x) __builtin_expect((x) != 0, 0)
00032 #else
00033 # define likely(x) (x)
00034 # define unlikely(x) (x)
00035 #endif
00036
00037 #define AMASK_BWX (1 << 0)
00038 #define AMASK_FIX (1 << 1)
00039 #define AMASK_CIX (1 << 2)
00040 #define AMASK_MVI (1 << 8)
00041
00042 static inline uint64_t BYTE_VEC(uint64_t x)
00043 {
00044 x |= x << 8;
00045 x |= x << 16;
00046 x |= x << 32;
00047 return x;
00048 }
00049 static inline uint64_t WORD_VEC(uint64_t x)
00050 {
00051 x |= x << 16;
00052 x |= x << 32;
00053 return x;
00054 }
00055
00056 #define sextw(x) ((int16_t) (x))
00057
00058 #ifdef __GNUC__
00059 #define ldq(p) \
00060 (((const union { \
00061 uint64_t __l; \
00062 __typeof__(*(p)) __s[sizeof (uint64_t) / sizeof *(p)]; \
00063 } *) (p))->__l)
00064 #define ldl(p) \
00065 (((const union { \
00066 int32_t __l; \
00067 __typeof__(*(p)) __s[sizeof (int32_t) / sizeof *(p)]; \
00068 } *) (p))->__l)
00069 #define stq(l, p) \
00070 do { \
00071 (((union { \
00072 uint64_t __l; \
00073 __typeof__(*(p)) __s[sizeof (uint64_t) / sizeof *(p)]; \
00074 } *) (p))->__l) = l; \
00075 } while (0)
00076 #define stl(l, p) \
00077 do { \
00078 (((union { \
00079 int32_t __l; \
00080 __typeof__(*(p)) __s[sizeof (int32_t) / sizeof *(p)]; \
00081 } *) (p))->__l) = l; \
00082 } while (0)
00083 struct unaligned_long { uint64_t l; } __attribute__((packed));
00084 #define ldq_u(p) (*(const uint64_t *) (((uint64_t) (p)) & ~7ul))
00085 #define uldq(a) (((const struct unaligned_long *) (a))->l)
00086
00087 #if AV_GCC_VERSION_AT_LEAST(3,3)
00088 #define prefetch(p) __builtin_prefetch((p), 0, 1)
00089 #define prefetch_en(p) __builtin_prefetch((p), 0, 0)
00090 #define prefetch_m(p) __builtin_prefetch((p), 1, 1)
00091 #define prefetch_men(p) __builtin_prefetch((p), 1, 0)
00092 #define cmpbge __builtin_alpha_cmpbge
00093
00094 #define extql(a, b) __builtin_alpha_extql(a, (uint64_t) (b))
00095 #define extwl(a, b) __builtin_alpha_extwl(a, (uint64_t) (b))
00096 #define extqh(a, b) __builtin_alpha_extqh(a, (uint64_t) (b))
00097 #define zap __builtin_alpha_zap
00098 #define zapnot __builtin_alpha_zapnot
00099 #define amask __builtin_alpha_amask
00100 #define implver __builtin_alpha_implver
00101 #define rpcc __builtin_alpha_rpcc
00102 #else
00103 #define prefetch(p) __asm__ volatile("ldl $31,%0" : : "m"(*(const char *) (p)) : "memory")
00104 #define prefetch_en(p) __asm__ volatile("ldq $31,%0" : : "m"(*(const char *) (p)) : "memory")
00105 #define prefetch_m(p) __asm__ volatile("lds $f31,%0" : : "m"(*(const char *) (p)) : "memory")
00106 #define prefetch_men(p) __asm__ volatile("ldt $f31,%0" : : "m"(*(const char *) (p)) : "memory")
00107 #define cmpbge(a, b) ({ uint64_t __r; __asm__ ("cmpbge %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
00108 #define extql(a, b) ({ uint64_t __r; __asm__ ("extql %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
00109 #define extwl(a, b) ({ uint64_t __r; __asm__ ("extwl %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
00110 #define extqh(a, b) ({ uint64_t __r; __asm__ ("extqh %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
00111 #define zap(a, b) ({ uint64_t __r; __asm__ ("zap %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
00112 #define zapnot(a, b) ({ uint64_t __r; __asm__ ("zapnot %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
00113 #define amask(a) ({ uint64_t __r; __asm__ ("amask %1,%0" : "=r" (__r) : "rI" (a)); __r; })
00114 #define implver() ({ uint64_t __r; __asm__ ("implver %0" : "=r" (__r)); __r; })
00115 #define rpcc() ({ uint64_t __r; __asm__ volatile ("rpcc %0" : "=r" (__r)); __r; })
00116 #endif
00117 #define wh64(p) __asm__ volatile("wh64 (%0)" : : "r"(p) : "memory")
00118
00119 #if AV_GCC_VERSION_AT_LEAST(3,3) && defined(__alpha_max__)
00120 #define minub8 __builtin_alpha_minub8
00121 #define minsb8 __builtin_alpha_minsb8
00122 #define minuw4 __builtin_alpha_minuw4
00123 #define minsw4 __builtin_alpha_minsw4
00124 #define maxub8 __builtin_alpha_maxub8
00125 #define maxsb8 __builtin_alpha_maxsb8
00126 #define maxuw4 __builtin_alpha_maxuw4
00127 #define maxsw4 __builtin_alpha_maxsw4
00128 #define perr __builtin_alpha_perr
00129 #define pklb __builtin_alpha_pklb
00130 #define pkwb __builtin_alpha_pkwb
00131 #define unpkbl __builtin_alpha_unpkbl
00132 #define unpkbw __builtin_alpha_unpkbw
00133 #else
00134 #define minub8(a, b) ({ uint64_t __r; __asm__ (".arch ev6; minub8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
00135 #define minsb8(a, b) ({ uint64_t __r; __asm__ (".arch ev6; minsb8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
00136 #define minuw4(a, b) ({ uint64_t __r; __asm__ (".arch ev6; minuw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
00137 #define minsw4(a, b) ({ uint64_t __r; __asm__ (".arch ev6; minsw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
00138 #define maxub8(a, b) ({ uint64_t __r; __asm__ (".arch ev6; maxub8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
00139 #define maxsb8(a, b) ({ uint64_t __r; __asm__ (".arch ev6; maxsb8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
00140 #define maxuw4(a, b) ({ uint64_t __r; __asm__ (".arch ev6; maxuw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
00141 #define maxsw4(a, b) ({ uint64_t __r; __asm__ (".arch ev6; maxsw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
00142 #define perr(a, b) ({ uint64_t __r; __asm__ (".arch ev6; perr %r1,%r2,%0" : "=r" (__r) : "%rJ" (a), "rJ" (b)); __r; })
00143 #define pklb(a) ({ uint64_t __r; __asm__ (".arch ev6; pklb %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
00144 #define pkwb(a) ({ uint64_t __r; __asm__ (".arch ev6; pkwb %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
00145 #define unpkbl(a) ({ uint64_t __r; __asm__ (".arch ev6; unpkbl %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
00146 #define unpkbw(a) ({ uint64_t __r; __asm__ (".arch ev6; unpkbw %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
00147 #endif
00148
00149 #elif defined(__DECC)
00150
00151 #include <c_asm.h>
00152 #define ldq(p) (*(const uint64_t *) (p))
00153 #define ldl(p) (*(const int32_t *) (p))
00154 #define stq(l, p) do { *(uint64_t *) (p) = (l); } while (0)
00155 #define stl(l, p) do { *(int32_t *) (p) = (l); } while (0)
00156 #define ldq_u(a) asm ("ldq_u %v0,0(%a0)", a)
00157 #define uldq(a) (*(const __unaligned uint64_t *) (a))
00158 #define cmpbge(a, b) asm ("cmpbge %a0,%a1,%v0", a, b)
00159 #define extql(a, b) asm ("extql %a0,%a1,%v0", a, b)
00160 #define extwl(a, b) asm ("extwl %a0,%a1,%v0", a, b)
00161 #define extqh(a, b) asm ("extqh %a0,%a1,%v0", a, b)
00162 #define zap(a, b) asm ("zap %a0,%a1,%v0", a, b)
00163 #define zapnot(a, b) asm ("zapnot %a0,%a1,%v0", a, b)
00164 #define amask(a) asm ("amask %a0,%v0", a)
00165 #define implver() asm ("implver %v0")
00166 #define rpcc() asm ("rpcc %v0")
00167 #define minub8(a, b) asm ("minub8 %a0,%a1,%v0", a, b)
00168 #define minsb8(a, b) asm ("minsb8 %a0,%a1,%v0", a, b)
00169 #define minuw4(a, b) asm ("minuw4 %a0,%a1,%v0", a, b)
00170 #define minsw4(a, b) asm ("minsw4 %a0,%a1,%v0", a, b)
00171 #define maxub8(a, b) asm ("maxub8 %a0,%a1,%v0", a, b)
00172 #define maxsb8(a, b) asm ("maxsb8 %a0,%a1,%v0", a, b)
00173 #define maxuw4(a, b) asm ("maxuw4 %a0,%a1,%v0", a, b)
00174 #define maxsw4(a, b) asm ("maxsw4 %a0,%a1,%v0", a, b)
00175 #define perr(a, b) asm ("perr %a0,%a1,%v0", a, b)
00176 #define pklb(a) asm ("pklb %a0,%v0", a)
00177 #define pkwb(a) asm ("pkwb %a0,%v0", a)
00178 #define unpkbl(a) asm ("unpkbl %a0,%v0", a)
00179 #define unpkbw(a) asm ("unpkbw %a0,%v0", a)
00180 #define wh64(a) asm ("wh64 %a0", a)
00181
00182 #else
00183 #error "Unknown compiler!"
00184 #endif
00185
00186 #endif