31
|
1 /*
|
|
2 * mmx.h
|
|
3 * Copyright (C) 1997-2001 H. Dietz and R. Fisher
|
|
4 */
|
0
|
5
|
31
|
6 /*
|
|
7 * The type of an value that fits in an MMX register (note that long
|
|
8 * long constant values MUST be suffixed by LL and unsigned long long
|
|
9 * values by ULL, lest they be truncated by the compiler)
|
|
10 */
|
0
|
11
|
|
12 typedef union {
|
|
13 long long q; /* Quadword (64-bit) value */
|
|
14 unsigned long long uq; /* Unsigned Quadword */
|
|
15 int d[2]; /* 2 Doubleword (32-bit) values */
|
|
16 unsigned int ud[2]; /* 2 Unsigned Doubleword */
|
|
17 short w[4]; /* 4 Word (16-bit) values */
|
|
18 unsigned short uw[4]; /* 4 Unsigned Word */
|
|
19 char b[8]; /* 8 Byte (8-bit) values */
|
|
20 unsigned char ub[8]; /* 8 Unsigned Byte */
|
|
21 float s[2]; /* Single-precision (32-bit) value */
|
31
|
22 } mmx_t; /* On an 8-byte (64-bit) boundary */
|
0
|
23
|
|
24
|
31
|
25 #define mmx_i2r(op,imm,reg) \
|
0
|
26 __asm__ __volatile__ (#op " %0, %%" #reg \
|
|
27 : /* nothing */ \
|
|
28 : "i" (imm) )
|
|
29
|
31
|
30 #define mmx_m2r(op,mem,reg) \
|
0
|
31 __asm__ __volatile__ (#op " %0, %%" #reg \
|
|
32 : /* nothing */ \
|
|
33 : "m" (mem))
|
|
34
|
31
|
35 #define mmx_r2m(op,reg,mem) \
|
0
|
36 __asm__ __volatile__ (#op " %%" #reg ", %0" \
|
|
37 : "=m" (mem) \
|
|
38 : /* nothing */ )
|
|
39
|
31
|
40 #define mmx_r2r(op,regs,regd) \
|
0
|
41 __asm__ __volatile__ (#op " %" #regs ", %" #regd)
|
|
42
|
|
43
|
31
|
44 #define emms() __asm__ __volatile__ ("emms")
|
|
45
|
|
46 #define movd_m2r(var,reg) mmx_m2r (movd, var, reg)
|
|
47 #define movd_r2m(reg,var) mmx_r2m (movd, reg, var)
|
|
48 #define movd_r2r(regs,regd) mmx_r2r (movd, regs, regd)
|
0
|
49
|
31
|
50 #define movq_m2r(var,reg) mmx_m2r (movq, var, reg)
|
|
51 #define movq_r2m(reg,var) mmx_r2m (movq, reg, var)
|
|
52 #define movq_r2r(regs,regd) mmx_r2r (movq, regs, regd)
|
|
53
|
|
54 #define packssdw_m2r(var,reg) mmx_m2r (packssdw, var, reg)
|
|
55 #define packssdw_r2r(regs,regd) mmx_r2r (packssdw, regs, regd)
|
|
56 #define packsswb_m2r(var,reg) mmx_m2r (packsswb, var, reg)
|
|
57 #define packsswb_r2r(regs,regd) mmx_r2r (packsswb, regs, regd)
|
0
|
58
|
31
|
59 #define packuswb_m2r(var,reg) mmx_m2r (packuswb, var, reg)
|
|
60 #define packuswb_r2r(regs,regd) mmx_r2r (packuswb, regs, regd)
|
0
|
61
|
31
|
62 #define paddb_m2r(var,reg) mmx_m2r (paddb, var, reg)
|
|
63 #define paddb_r2r(regs,regd) mmx_r2r (paddb, regs, regd)
|
|
64 #define paddd_m2r(var,reg) mmx_m2r (paddd, var, reg)
|
|
65 #define paddd_r2r(regs,regd) mmx_r2r (paddd, regs, regd)
|
|
66 #define paddw_m2r(var,reg) mmx_m2r (paddw, var, reg)
|
|
67 #define paddw_r2r(regs,regd) mmx_r2r (paddw, regs, regd)
|
0
|
68
|
31
|
69 #define paddsb_m2r(var,reg) mmx_m2r (paddsb, var, reg)
|
|
70 #define paddsb_r2r(regs,regd) mmx_r2r (paddsb, regs, regd)
|
|
71 #define paddsw_m2r(var,reg) mmx_m2r (paddsw, var, reg)
|
|
72 #define paddsw_r2r(regs,regd) mmx_r2r (paddsw, regs, regd)
|
0
|
73
|
31
|
74 #define paddusb_m2r(var,reg) mmx_m2r (paddusb, var, reg)
|
|
75 #define paddusb_r2r(regs,regd) mmx_r2r (paddusb, regs, regd)
|
|
76 #define paddusw_m2r(var,reg) mmx_m2r (paddusw, var, reg)
|
|
77 #define paddusw_r2r(regs,regd) mmx_r2r (paddusw, regs, regd)
|
0
|
78
|
31
|
79 #define pand_m2r(var,reg) mmx_m2r (pand, var, reg)
|
|
80 #define pand_r2r(regs,regd) mmx_r2r (pand, regs, regd)
|
|
81
|
|
82 #define pandn_m2r(var,reg) mmx_m2r (pandn, var, reg)
|
|
83 #define pandn_r2r(regs,regd) mmx_r2r (pandn, regs, regd)
|
0
|
84
|
31
|
85 #define pcmpeqb_m2r(var,reg) mmx_m2r (pcmpeqb, var, reg)
|
|
86 #define pcmpeqb_r2r(regs,regd) mmx_r2r (pcmpeqb, regs, regd)
|
|
87 #define pcmpeqd_m2r(var,reg) mmx_m2r (pcmpeqd, var, reg)
|
|
88 #define pcmpeqd_r2r(regs,regd) mmx_r2r (pcmpeqd, regs, regd)
|
|
89 #define pcmpeqw_m2r(var,reg) mmx_m2r (pcmpeqw, var, reg)
|
|
90 #define pcmpeqw_r2r(regs,regd) mmx_r2r (pcmpeqw, regs, regd)
|
0
|
91
|
31
|
92 #define pcmpgtb_m2r(var,reg) mmx_m2r (pcmpgtb, var, reg)
|
|
93 #define pcmpgtb_r2r(regs,regd) mmx_r2r (pcmpgtb, regs, regd)
|
|
94 #define pcmpgtd_m2r(var,reg) mmx_m2r (pcmpgtd, var, reg)
|
|
95 #define pcmpgtd_r2r(regs,regd) mmx_r2r (pcmpgtd, regs, regd)
|
|
96 #define pcmpgtw_m2r(var,reg) mmx_m2r (pcmpgtw, var, reg)
|
|
97 #define pcmpgtw_r2r(regs,regd) mmx_r2r (pcmpgtw, regs, regd)
|
|
98
|
|
99 #define pmaddwd_m2r(var,reg) mmx_m2r (pmaddwd, var, reg)
|
|
100 #define pmaddwd_r2r(regs,regd) mmx_r2r (pmaddwd, regs, regd)
|
|
101
|
|
102 #define pmulhw_m2r(var,reg) mmx_m2r (pmulhw, var, reg)
|
|
103 #define pmulhw_r2r(regs,regd) mmx_r2r (pmulhw, regs, regd)
|
|
104
|
|
105 #define pmullw_m2r(var,reg) mmx_m2r (pmullw, var, reg)
|
|
106 #define pmullw_r2r(regs,regd) mmx_r2r (pmullw, regs, regd)
|
0
|
107
|
31
|
108 #define por_m2r(var,reg) mmx_m2r (por, var, reg)
|
|
109 #define por_r2r(regs,regd) mmx_r2r (por, regs, regd)
|
0
|
110
|
31
|
111 #define pslld_i2r(imm,reg) mmx_i2r (pslld, imm, reg)
|
|
112 #define pslld_m2r(var,reg) mmx_m2r (pslld, var, reg)
|
|
113 #define pslld_r2r(regs,regd) mmx_r2r (pslld, regs, regd)
|
|
114 #define psllq_i2r(imm,reg) mmx_i2r (psllq, imm, reg)
|
|
115 #define psllq_m2r(var,reg) mmx_m2r (psllq, var, reg)
|
|
116 #define psllq_r2r(regs,regd) mmx_r2r (psllq, regs, regd)
|
|
117 #define psllw_i2r(imm,reg) mmx_i2r (psllw, imm, reg)
|
|
118 #define psllw_m2r(var,reg) mmx_m2r (psllw, var, reg)
|
|
119 #define psllw_r2r(regs,regd) mmx_r2r (psllw, regs, regd)
|
0
|
120
|
31
|
121 #define psrad_i2r(imm,reg) mmx_i2r (psrad, imm, reg)
|
|
122 #define psrad_m2r(var,reg) mmx_m2r (psrad, var, reg)
|
|
123 #define psrad_r2r(regs,regd) mmx_r2r (psrad, regs, regd)
|
|
124 #define psraw_i2r(imm,reg) mmx_i2r (psraw, imm, reg)
|
|
125 #define psraw_m2r(var,reg) mmx_m2r (psraw, var, reg)
|
|
126 #define psraw_r2r(regs,regd) mmx_r2r (psraw, regs, regd)
|
0
|
127
|
31
|
128 #define psrld_i2r(imm,reg) mmx_i2r (psrld, imm, reg)
|
|
129 #define psrld_m2r(var,reg) mmx_m2r (psrld, var, reg)
|
|
130 #define psrld_r2r(regs,regd) mmx_r2r (psrld, regs, regd)
|
|
131 #define psrlq_i2r(imm,reg) mmx_i2r (psrlq, imm, reg)
|
|
132 #define psrlq_m2r(var,reg) mmx_m2r (psrlq, var, reg)
|
|
133 #define psrlq_r2r(regs,regd) mmx_r2r (psrlq, regs, regd)
|
|
134 #define psrlw_i2r(imm,reg) mmx_i2r (psrlw, imm, reg)
|
|
135 #define psrlw_m2r(var,reg) mmx_m2r (psrlw, var, reg)
|
|
136 #define psrlw_r2r(regs,regd) mmx_r2r (psrlw, regs, regd)
|
0
|
137
|
31
|
138 #define psubb_m2r(var,reg) mmx_m2r (psubb, var, reg)
|
|
139 #define psubb_r2r(regs,regd) mmx_r2r (psubb, regs, regd)
|
|
140 #define psubd_m2r(var,reg) mmx_m2r (psubd, var, reg)
|
|
141 #define psubd_r2r(regs,regd) mmx_r2r (psubd, regs, regd)
|
|
142 #define psubw_m2r(var,reg) mmx_m2r (psubw, var, reg)
|
|
143 #define psubw_r2r(regs,regd) mmx_r2r (psubw, regs, regd)
|
0
|
144
|
31
|
145 #define psubsb_m2r(var,reg) mmx_m2r (psubsb, var, reg)
|
|
146 #define psubsb_r2r(regs,regd) mmx_r2r (psubsb, regs, regd)
|
|
147 #define psubsw_m2r(var,reg) mmx_m2r (psubsw, var, reg)
|
|
148 #define psubsw_r2r(regs,regd) mmx_r2r (psubsw, regs, regd)
|
|
149
|
|
150 #define psubusb_m2r(var,reg) mmx_m2r (psubusb, var, reg)
|
|
151 #define psubusb_r2r(regs,regd) mmx_r2r (psubusb, regs, regd)
|
|
152 #define psubusw_m2r(var,reg) mmx_m2r (psubusw, var, reg)
|
|
153 #define psubusw_r2r(regs,regd) mmx_r2r (psubusw, regs, regd)
|
0
|
154
|
31
|
155 #define punpckhbw_m2r(var,reg) mmx_m2r (punpckhbw, var, reg)
|
|
156 #define punpckhbw_r2r(regs,regd) mmx_r2r (punpckhbw, regs, regd)
|
|
157 #define punpckhdq_m2r(var,reg) mmx_m2r (punpckhdq, var, reg)
|
|
158 #define punpckhdq_r2r(regs,regd) mmx_r2r (punpckhdq, regs, regd)
|
|
159 #define punpckhwd_m2r(var,reg) mmx_m2r (punpckhwd, var, reg)
|
|
160 #define punpckhwd_r2r(regs,regd) mmx_r2r (punpckhwd, regs, regd)
|
0
|
161
|
31
|
162 #define punpcklbw_m2r(var,reg) mmx_m2r (punpcklbw, var, reg)
|
|
163 #define punpcklbw_r2r(regs,regd) mmx_r2r (punpcklbw, regs, regd)
|
|
164 #define punpckldq_m2r(var,reg) mmx_m2r (punpckldq, var, reg)
|
|
165 #define punpckldq_r2r(regs,regd) mmx_r2r (punpckldq, regs, regd)
|
|
166 #define punpcklwd_m2r(var,reg) mmx_m2r (punpcklwd, var, reg)
|
|
167 #define punpcklwd_r2r(regs,regd) mmx_r2r (punpcklwd, regs, regd)
|
0
|
168
|
31
|
169 #define pxor_m2r(var,reg) mmx_m2r (pxor, var, reg)
|
|
170 #define pxor_r2r(regs,regd) mmx_r2r (pxor, regs, regd)
|
0
|
171
|
|
172
|
31
|
173 /* 3DNOW extensions */
|
0
|
174
|
31
|
175 #define pavgusb_m2r(var,reg) mmx_m2r (pavgusb, var, reg)
|
|
176 #define pavgusb_r2r(regs,regd) mmx_r2r (pavgusb, regs, regd)
|
|
177
|
|
178
|
|
179 /* AMD MMX extensions - also available in intel SSE */
|
0
|
180
|
|
181
|
31
|
182 #define mmx_m2ri(op,mem,reg,imm) \
|
|
183 __asm__ __volatile__ (#op " %1, %0, %%" #reg \
|
|
184 : /* nothing */ \
|
|
185 : "X" (mem), "X" (imm))
|
|
186 #define mmx_r2ri(op,regs,regd,imm) \
|
|
187 __asm__ __volatile__ (#op " %0, %%" #regs ", %%" #regd \
|
|
188 : /* nothing */ \
|
|
189 : "X" (imm) )
|
0
|
190
|
31
|
191 #define mmx_fetch(mem,hint) \
|
|
192 __asm__ __volatile__ ("prefetch" #hint " %0" \
|
|
193 : /* nothing */ \
|
|
194 : "X" (mem))
|
0
|
195
|
|
196
|
31
|
197 #define maskmovq(regs,maskreg) mmx_r2ri (maskmovq, regs, maskreg)
|
|
198
|
|
199 #define movntq_r2m(mmreg,var) mmx_r2m (movntq, mmreg, var)
|
0
|
200
|
31
|
201 #define pavgb_m2r(var,reg) mmx_m2r (pavgb, var, reg)
|
|
202 #define pavgb_r2r(regs,regd) mmx_r2r (pavgb, regs, regd)
|
|
203 #define pavgw_m2r(var,reg) mmx_m2r (pavgw, var, reg)
|
|
204 #define pavgw_r2r(regs,regd) mmx_r2r (pavgw, regs, regd)
|
|
205
|
|
206 #define pextrw_r2r(mmreg,reg,imm) mmx_r2ri (pextrw, mmreg, reg, imm)
|
0
|
207
|
31
|
208 #define pinsrw_r2r(reg,mmreg,imm) mmx_r2ri (pinsrw, reg, mmreg, imm)
|
0
|
209
|
31
|
210 #define pmaxsw_m2r(var,reg) mmx_m2r (pmaxsw, var, reg)
|
|
211 #define pmaxsw_r2r(regs,regd) mmx_r2r (pmaxsw, regs, regd)
|
0
|
212
|
31
|
213 #define pmaxub_m2r(var,reg) mmx_m2r (pmaxub, var, reg)
|
|
214 #define pmaxub_r2r(regs,regd) mmx_r2r (pmaxub, regs, regd)
|
|
215
|
|
216 #define pminsw_m2r(var,reg) mmx_m2r (pminsw, var, reg)
|
|
217 #define pminsw_r2r(regs,regd) mmx_r2r (pminsw, regs, regd)
|
0
|
218
|
31
|
219 #define pminub_m2r(var,reg) mmx_m2r (pminub, var, reg)
|
|
220 #define pminub_r2r(regs,regd) mmx_r2r (pminub, regs, regd)
|
0
|
221
|
31
|
222 #define pmovmskb(mmreg,reg) \
|
|
223 __asm__ __volatile__ ("movmskps %" #mmreg ", %" #reg)
|
0
|
224
|
31
|
225 #define pmulhuw_m2r(var,reg) mmx_m2r (pmulhuw, var, reg)
|
|
226 #define pmulhuw_r2r(regs,regd) mmx_r2r (pmulhuw, regs, regd)
|
0
|
227
|
31
|
228 #define prefetcht0(mem) mmx_fetch (mem, t0)
|
|
229 #define prefetcht1(mem) mmx_fetch (mem, t1)
|
|
230 #define prefetcht2(mem) mmx_fetch (mem, t2)
|
|
231 #define prefetchnta(mem) mmx_fetch (mem, nta)
|
0
|
232
|
31
|
233 #define psadbw_m2r(var,reg) mmx_m2r (psadbw, var, reg)
|
|
234 #define psadbw_r2r(regs,regd) mmx_r2r (psadbw, regs, regd)
|
0
|
235
|
31
|
236 #define pshufw_m2r(var,reg,imm) mmx_m2ri(pshufw, var, reg, imm)
|
|
237 #define pshufw_r2r(regs,regd,imm) mmx_r2ri(pshufw, regs, regd, imm)
|
0
|
238
|
31
|
239 #define sfence() __asm__ __volatile__ ("sfence\n\t")
|