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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do compile { target arm*-*-* alpha*-*-* i?86-*-* powerpc*-*-* rs6000-*-* x86_64-*-* s390*-*-* } } */
2
/* { dg-require-effective-target stdint_types } */
3
/* { dg-options "-O2 -fdump-tree-bswap" } */
4
/* { dg-options "-O2 -fdump-tree-bswap -march=z900" { target s390-*-* } } */
5
 
6
#include <stdint.h>
7
 
8
#define __const_swab32(x) ((uint32_t)(                                \
9
        (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) |            \
10
        (((uint32_t)(x) & (uint32_t)0x0000ff00UL) <<  8) |            \
11
        (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >>  8) |            \
12
        (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
13
 
14
/* This byte swap implementation is used by the Linux kernel and the
15
   GNU C library.  */
16
 
17
uint32_t
18
swap32_a (uint32_t in)
19
{
20
  return __const_swab32 (in);
21
}
22
 
23
/* The OpenSSH byte swap implementation.  */
24
uint32_t
25
swap32_b (uint32_t in)
26
{
27
  uint32_t a;
28
 
29
  a = (in << 16) | (in >> 16);
30
  a = ((a & 0x00ff00ff) << 8) | ((a & 0xff00ff00) >> 8);
31
 
32
  return a;
33
}
34
 
35
/* This variant is currently used by libgcc.  The difference is that
36
   the bswap source and destination have a signed integer type which
37
   requires a slightly higher search depth in order to dive through
38
   the cast as well.  */
39
 
40
typedef int SItype __attribute__ ((mode (SI)));
41
 
42
SItype
43
swap32_c (SItype u)
44
{
45
  return ((((u) & 0xff000000) >> 24)
46
          | (((u) & 0x00ff0000) >>  8)
47
          | (((u) & 0x0000ff00) <<  8)
48
          | (((u) & 0x000000ff) << 24));
49
}
50
 
51
/* { dg-final { scan-tree-dump-times "32 bit bswap implementation found at" 3 "bswap" } } */
52
/* { dg-final { cleanup-tree-dump "bswap" } } */

powered by: WebSVN 2.1.0

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