ffmpeg / libavcodec / alpha / asm.h @ 1e98dffb
History | View | Annotate | Download (3.12 KB)
1 |
/*
|
---|---|
2 |
* Alpha optimized DSP utils
|
3 |
* Copyright (c) 2002 Falk Hueffner <falk@debian.org>
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
8 |
* (at your option) any later version.
|
9 |
*
|
10 |
* This program 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
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
18 |
*/
|
19 |
|
20 |
#ifndef LIBAVCODEC_ALPHA_ASM_H
|
21 |
#define LIBAVCODEC_ALPHA_ASM_H
|
22 |
|
23 |
#include <stdint.h> |
24 |
|
25 |
#define AMASK_BWX (1 << 0) |
26 |
#define AMASK_FIX (1 << 1) |
27 |
#define AMASK_MVI (1 << 8) |
28 |
|
29 |
static inline uint64_t BYTE_VEC(uint64_t x) |
30 |
{ |
31 |
x |= x << 8;
|
32 |
x |= x << 16;
|
33 |
x |= x << 32;
|
34 |
return x;
|
35 |
} |
36 |
static inline uint64_t WORD_VEC(uint64_t x) |
37 |
{ |
38 |
x |= x << 16;
|
39 |
x |= x << 32;
|
40 |
return x;
|
41 |
} |
42 |
|
43 |
static inline int32_t ldl(const void* p) |
44 |
{ |
45 |
return *(const int32_t*) p; |
46 |
} |
47 |
static inline uint64_t ldq(const void* p) |
48 |
{ |
49 |
return *(const uint64_t*) p; |
50 |
} |
51 |
/* FIXME ccc doesn't seem to get it? Use inline asm? */
|
52 |
static inline uint64_t ldq_u(const void* p) |
53 |
{ |
54 |
return *(const uint64_t*) ((uintptr_t) p & ~7ul); |
55 |
} |
56 |
static inline void stl(uint32_t l, void* p) |
57 |
{ |
58 |
*(uint32_t*) p = l; |
59 |
} |
60 |
static inline void stq(uint64_t l, void* p) |
61 |
{ |
62 |
*(uint64_t*) p = l; |
63 |
} |
64 |
|
65 |
#ifdef __GNUC__
|
66 |
#define OPCODE1(name) \
|
67 |
static inline uint64_t name(uint64_t l) \ |
68 |
{ \ |
69 |
uint64_t r; \ |
70 |
asm (#name " %1, %0" : "=r" (r) : "r" (l)); \ |
71 |
return r; \
|
72 |
} |
73 |
|
74 |
#define OPCODE2(name) \
|
75 |
static inline uint64_t name(uint64_t l1, uint64_t l2) \ |
76 |
{ \ |
77 |
uint64_t r; \ |
78 |
asm (#name " %1, %2, %0" : "=r" (r) : "r" (l1), "rI" (l2)); \ |
79 |
return r; \
|
80 |
} |
81 |
|
82 |
/* We don't want gcc to move this around or combine it with another
|
83 |
rpcc, so mark it volatile. */
|
84 |
static inline uint64_t rpcc(void) |
85 |
{ |
86 |
uint64_t r; |
87 |
asm volatile ("rpcc %0" : "=r" (r)); |
88 |
return r;
|
89 |
} |
90 |
|
91 |
static inline uint64_t uldq(const void* v) |
92 |
{ |
93 |
struct foo {
|
94 |
unsigned long l; |
95 |
} __attribute__((packed)); |
96 |
|
97 |
return ((const struct foo*) v)->l; |
98 |
} |
99 |
|
100 |
#elif defined(__DECC) /* Compaq "ccc" compiler */ |
101 |
|
102 |
#include <c_asm.h> |
103 |
#define OPCODE1(name) \
|
104 |
static inline uint64_t name(uint64_t l) \ |
105 |
{ \ |
106 |
return asm (#name " %a0, %v0", l); \ |
107 |
} |
108 |
|
109 |
#define OPCODE2(name) \
|
110 |
static inline uint64_t name(uint64_t l1, uint64_t l2) \ |
111 |
{ \ |
112 |
return asm (#name " %a0, %a1, %v0", l1, l2); \ |
113 |
} |
114 |
|
115 |
static inline uint64_t rpcc(void) |
116 |
{ |
117 |
return asm ("rpcc %v0"); |
118 |
} |
119 |
|
120 |
static inline uint64_t uldq(const void* v) |
121 |
{ |
122 |
return *(const __unaligned uint64_t *) v; |
123 |
} |
124 |
|
125 |
#endif
|
126 |
|
127 |
OPCODE1(amask); |
128 |
OPCODE1(unpkbw); |
129 |
OPCODE1(pkwb); |
130 |
OPCODE2(extql); |
131 |
OPCODE2(extqh); |
132 |
OPCODE2(zap); |
133 |
OPCODE2(cmpbge); |
134 |
OPCODE2(minsw4); |
135 |
OPCODE2(minuw4); |
136 |
OPCODE2(minub8); |
137 |
OPCODE2(maxsw4); |
138 |
OPCODE2(maxuw4); |
139 |
OPCODE2(perr); |
140 |
|
141 |
#endif /* LIBAVCODEC_ALPHA_ASM_H */ |