OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.target/] [powerpc/] [optimize-bswapsi-2.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 691 jeremybenn
/* { dg-require-effective-target stdint_types } */
2
/* { dg-options "-O2 -mcpu=power5" } */
3
 
4
#include <stdint.h>
5
 
6
/* This is a clone of gcc-dg/optimize-bswapsi-1.c, redone to use load and stores
7
   to test whether lwbrx/stwbrx is generated for normal power systems.  */
8
 
9
#define __const_swab32(x) ((uint32_t)(                                \
10
        (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) |            \
11
        (((uint32_t)(x) & (uint32_t)0x0000ff00UL) <<  8) |            \
12
        (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >>  8) |            \
13
        (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
14
 
15
/* This byte swap implementation is used by the Linux kernel and the
16
   GNU C library.  */
17
 
18
uint32_t
19
swap32_a_load (uint32_t *in)
20
{
21
  return __const_swab32 (*in);
22
}
23
 
24
/* The OpenSSH byte swap implementation.  */
25
uint32_t
26
swap32_b_load (uint32_t *in)
27
{
28
  uint32_t a;
29
 
30
  a = (*in << 16) | (*in >> 16);
31
  a = ((a & 0x00ff00ff) << 8) | ((a & 0xff00ff00) >> 8);
32
 
33
  return a;
34
}
35
 
36
void
37
swap32_a_store (uint32_t *out, uint32_t in)
38
{
39
  *out = __const_swab32 (in);
40
}
41
 
42
/* The OpenSSH byte swap implementation.  */
43
void
44
swap32_b_store (uint32_t *out, uint32_t in)
45
{
46
  uint32_t a;
47
 
48
  a = (in << 16) | (in >> 16);
49
  a = ((a & 0x00ff00ff) << 8) | ((a & 0xff00ff00) >> 8);
50
 
51
  *out = a;
52
}
53
 
54
/* { dg-final { scan-assembler-times "lwbrx" 2 } } */
55
/* { dg-final { scan-assembler-times "stwbrx" 2 } } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.