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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.target/] [powerpc/] [bswap-run.c] - Blame information for rev 859

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

Line No. Rev Author Line
1 322 jeremybenn
/* { dg-do run { target powerpc*-*-* } } */
2
/* { dg-options "-O2 -std=gnu99" } */
3
 
4
extern void abort (void);
5
 
6
static unsigned char bytes[] = { 0, 1, 2, 0x80, 0xff };
7
 
8
unsigned short b16a (unsigned short *p) { return __builtin_bswap16 (*p); }
9
void b16b (unsigned short *p, unsigned short a) { *p = __builtin_bswap16 (a); }
10
int b16c (unsigned short a) { return __builtin_bswap16 (a); }
11
 
12
unsigned int b32a (unsigned int *p) { return __builtin_bswap32 (*p); }
13
void b32b (unsigned int *p, unsigned int a) { *p = __builtin_bswap32 (a); }
14
static unsigned int b32c (unsigned int a) { return __builtin_bswap32 (a); }
15
 
16
unsigned long long b64a (unsigned long long *p) { return __builtin_bswap64 (*p); }
17
void b64b (unsigned long long *p, unsigned long long a) { *p = __builtin_bswap64 (a); }
18
unsigned long long b64c (unsigned long long a) { return __builtin_bswap64 (a); }
19
 
20
int
21
main (void)
22
{
23
  unsigned i1, i2, i3, i4, i5;
24
  unsigned b1, b2, b3, b4, b5;
25
  unsigned short b16_inp, b16_exp, b16_var;
26
  unsigned int b32_inp, b32_exp, b32_var;
27
  unsigned long long b64_inp, b64_exp, b64_var;
28
 
29
  for (i1 = 0; i1 < sizeof (bytes); i1++)
30
    {
31
      b1 = bytes[i1];
32
      for (i2 = 0; i2 < sizeof (bytes); i2++)
33
        {
34
          b2 = bytes[i2];
35
          b16_inp = (b1 << 8) | b2;
36
          b16_exp = (b2 << 8) | b1;
37
 
38
          if (b16a (&b16_inp) != b16_exp)
39
            abort ();
40
 
41
          b16b (&b16_var, b16_inp);
42
          if (b16_var != b16_exp)
43
            abort ();
44
 
45
          if (b16c (b16_inp) != b16_exp)
46
            abort ();
47
 
48
          for (i3 = 0; i3 < sizeof (bytes); i3++)
49
            {
50
              b3 = bytes[i3];
51
              for (i4 = 0; i4 < sizeof (bytes); i4++)
52
                {
53
                  b4 = bytes[i4];
54
                  b32_inp = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
55
                  b32_exp = (b4 << 24) | (b3 << 16) | (b2 << 8) | b1;
56
 
57
                  if (b32a (&b32_inp) != b32_exp)
58
                    abort ();
59
 
60
                  b32b (&b32_var, b32_inp);
61
                  if (b32_var != b32_exp)
62
                    abort ();
63
 
64
                  if (b32c (b32_inp) != b32_exp)
65
                    abort ();
66
 
67
                  for (i5 = 0; i5 < sizeof (bytes); i5++)
68
                    {
69
                      b5 = bytes[i5];
70
                      b64_inp = (((unsigned long long)b32_inp) << 32) | b5;
71
                      b64_exp = (((unsigned long long)b5) << 56) | b32_exp;
72
 
73
                      if (b64a (&b64_inp) != b64_exp)
74
                        abort ();
75
 
76
                      b64b (&b64_var, b64_inp);
77
                      if (b64_var != b64_exp)
78
                        abort ();
79
 
80
                      if (b64c (b64_inp) != b64_exp)
81
                        abort ();
82
 
83
                      b64_inp = (((unsigned long long)b5) << 56) | b32_inp;
84
                      b64_exp = (((unsigned long long)b32_exp) << 32) | b5;
85
 
86
                      if (b64a (&b64_inp) != b64_exp)
87
                        abort ();
88
 
89
                      b64b (&b64_var, b64_inp);
90
                      if (b64_var != b64_exp)
91
                        abort ();
92
 
93
                      if (b64c (b64_inp) != b64_exp)
94
                        abort ();
95
                    }
96
                }
97
            }
98
        }
99
    }
100
 
101
  return 0;
102
}

powered by: WebSVN 2.1.0

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