Revision 8384dd67 cpu-all.h
b/cpu-all.h | ||
---|---|---|
233 | 233 |
int val; |
234 | 234 |
__asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); |
235 | 235 |
return val; |
236 |
#elif defined(__sparc__) |
|
237 |
#ifndef ASI_PRIMARY_LITTLE |
|
238 |
#define ASI_PRIMARY_LITTLE 0x88 |
|
239 |
#endif |
|
240 |
|
|
241 |
int val; |
|
242 |
__asm__ __volatile__ ("lduha [%1] %2, %0" : "=r" (val) : "r" (ptr), |
|
243 |
"i" (ASI_PRIMARY_LITTLE)); |
|
244 |
return val; |
|
236 | 245 |
#else |
237 | 246 |
uint8_t *p = ptr; |
238 | 247 |
return p[0] | (p[1] << 8); |
... | ... | |
245 | 254 |
int val; |
246 | 255 |
__asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); |
247 | 256 |
return (int16_t)val; |
257 |
#elif defined(__sparc__) |
|
258 |
int val; |
|
259 |
__asm__ __volatile__ ("ldsha [%1] %2, %0" : "=r" (val) : "r" (ptr), |
|
260 |
"i" (ASI_PRIMARY_LITTLE)); |
|
261 |
return val; |
|
248 | 262 |
#else |
249 | 263 |
uint8_t *p = ptr; |
250 | 264 |
return (int16_t)(p[0] | (p[1] << 8)); |
... | ... | |
257 | 271 |
int val; |
258 | 272 |
__asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (ptr)); |
259 | 273 |
return val; |
274 |
#elif defined(__sparc__) |
|
275 |
int val; |
|
276 |
__asm__ __volatile__ ("lduwa [%1] %2, %0" : "=r" (val) : "r" (ptr), |
|
277 |
"i" (ASI_PRIMARY_LITTLE)); |
|
278 |
return val; |
|
260 | 279 |
#else |
261 | 280 |
uint8_t *p = ptr; |
262 | 281 |
return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); |
... | ... | |
265 | 284 |
|
266 | 285 |
static inline uint64_t ldq_le_p(void *ptr) |
267 | 286 |
{ |
287 |
#if defined(__sparc__) |
|
288 |
uint64_t val; |
|
289 |
__asm__ __volatile__ ("ldxa [%1] %2, %0" : "=r" (val) : "r" (ptr), |
|
290 |
"i" (ASI_PRIMARY_LITTLE)); |
|
291 |
return val; |
|
292 |
#else |
|
268 | 293 |
uint8_t *p = ptr; |
269 | 294 |
uint32_t v1, v2; |
270 | 295 |
v1 = ldl_le_p(p); |
271 | 296 |
v2 = ldl_le_p(p + 4); |
272 | 297 |
return v1 | ((uint64_t)v2 << 32); |
298 |
#endif |
|
273 | 299 |
} |
274 | 300 |
|
275 | 301 |
static inline void stw_le_p(void *ptr, int v) |
276 | 302 |
{ |
277 | 303 |
#ifdef __powerpc__ |
278 | 304 |
__asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*(uint16_t *)ptr) : "r" (v), "r" (ptr)); |
305 |
#elif defined(__sparc__) |
|
306 |
__asm__ __volatile__ ("stha %1, [%2] %3" : "=m" (*(uint16_t *)ptr) : "r" (v), |
|
307 |
"r" (ptr), "i" (ASI_PRIMARY_LITTLE)); |
|
279 | 308 |
#else |
280 | 309 |
uint8_t *p = ptr; |
281 | 310 |
p[0] = v; |
... | ... | |
287 | 316 |
{ |
288 | 317 |
#ifdef __powerpc__ |
289 | 318 |
__asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*(uint32_t *)ptr) : "r" (v), "r" (ptr)); |
319 |
#elif defined(__sparc__) |
|
320 |
__asm__ __volatile__ ("stwa %1, [%2] %3" : "=m" (*(uint32_t *)ptr) : "r" (v), |
|
321 |
"r" (ptr), "i" (ASI_PRIMARY_LITTLE)); |
|
290 | 322 |
#else |
291 | 323 |
uint8_t *p = ptr; |
292 | 324 |
p[0] = v; |
... | ... | |
298 | 330 |
|
299 | 331 |
static inline void stq_le_p(void *ptr, uint64_t v) |
300 | 332 |
{ |
333 |
#if defined(__sparc__) |
|
334 |
__asm__ __volatile__ ("stxa %1, [%2] %3" : "=m" (*(uint64_t *)ptr) : "r" (v), |
|
335 |
"r" (ptr), "i" (ASI_PRIMARY_LITTLE)); |
|
336 |
#undef ASI_PRIMARY_LITTLE |
|
337 |
#else |
|
301 | 338 |
uint8_t *p = ptr; |
302 | 339 |
stl_le_p(p, (uint32_t)v); |
303 | 340 |
stl_le_p(p + 4, v >> 32); |
341 |
#endif |
|
304 | 342 |
} |
305 | 343 |
|
306 | 344 |
/* float access */ |
Also available in: Unified diff