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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [builtin-prefetch-3.c] - Blame information for rev 297

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 297 jeremybenn
/* Test that __builtin_prefetch does no harm.
2
 
3
   Prefetch data using a variety of storage classes and address
4
   expressions with volatile variables and pointers.  */
5
 
6
int glob_int_arr[100];
7
int glob_int = 4;
8
volatile int glob_vol_int_arr[100];
9
int * volatile glob_vol_ptr_int = glob_int_arr;
10
volatile int *glob_ptr_vol_int = glob_vol_int_arr;
11
volatile int * volatile glob_vol_ptr_vol_int = glob_vol_int_arr;
12
volatile int glob_vol_int;
13
 
14
static stat_int_arr[100];
15
static volatile int stat_vol_int_arr[100];
16
static int * volatile stat_vol_ptr_int = stat_int_arr;
17
static volatile int *stat_ptr_vol_int = stat_vol_int_arr;
18
static volatile int * volatile stat_vol_ptr_vol_int = stat_vol_int_arr;
19
static volatile int stat_vol_int;
20
 
21
struct S {
22
  int a;
23
  short b, c;
24
  char d[8];
25
  struct S *next;
26
};
27
 
28
struct S str;
29
volatile struct S vol_str;
30
struct S * volatile vol_ptr_str = &str;
31
volatile struct S *ptr_vol_str = &vol_str;
32
volatile struct S * volatile vol_ptr_vol_str = &vol_str;
33
 
34
/* Prefetch volatile global variables using the address of the variable.  */
35
 
36
void
37
simple_vol_global ()
38
{
39
  __builtin_prefetch (glob_vol_int_arr, 0, 0);
40
  __builtin_prefetch (glob_vol_ptr_int, 0, 0);
41
  __builtin_prefetch (glob_ptr_vol_int, 0, 0);
42
  __builtin_prefetch (glob_vol_ptr_vol_int, 0, 0);
43
  __builtin_prefetch (&glob_vol_int, 0, 0);
44
}
45
 
46
/* Prefetch volatile static variables using the address of the variable.  */
47
 
48
void
49
simple_vol_file ()
50
{
51
  __builtin_prefetch (stat_vol_int_arr, 0, 0);
52
  __builtin_prefetch (stat_vol_ptr_int, 0, 0);
53
  __builtin_prefetch (stat_ptr_vol_int, 0, 0);
54
  __builtin_prefetch (stat_vol_ptr_vol_int, 0, 0);
55
  __builtin_prefetch (&stat_vol_int, 0, 0);
56
}
57
 
58
/* Prefetch using address expressions involving volatile global variables.  */
59
 
60
void
61
expr_vol_global (void)
62
{
63
  __builtin_prefetch (&vol_str, 0, 0);
64
  __builtin_prefetch (ptr_vol_str, 0, 0);
65
  __builtin_prefetch (vol_ptr_str, 0, 0);
66
  __builtin_prefetch (vol_ptr_vol_str, 0, 0);
67
  __builtin_prefetch (&vol_str.b, 0, 0);
68
  __builtin_prefetch (&ptr_vol_str->b, 0, 0);
69
  __builtin_prefetch (&vol_ptr_str->b, 0, 0);
70
  __builtin_prefetch (&vol_ptr_vol_str->b, 0, 0);
71
  __builtin_prefetch (&vol_str.d, 0, 0);
72
  __builtin_prefetch (&vol_ptr_str->d, 0, 0);
73
  __builtin_prefetch (&ptr_vol_str->d, 0, 0);
74
  __builtin_prefetch (&vol_ptr_vol_str->d, 0, 0);
75
  __builtin_prefetch (vol_str.next, 0, 0);
76
  __builtin_prefetch (vol_ptr_str->next, 0, 0);
77
  __builtin_prefetch (ptr_vol_str->next, 0, 0);
78
  __builtin_prefetch (vol_ptr_vol_str->next, 0, 0);
79
  __builtin_prefetch (vol_str.next->d, 0, 0);
80
  __builtin_prefetch (vol_ptr_str->next->d, 0, 0);
81
  __builtin_prefetch (ptr_vol_str->next->d, 0, 0);
82
  __builtin_prefetch (vol_ptr_vol_str->next->d, 0, 0);
83
 
84
  __builtin_prefetch (&glob_vol_int_arr, 0, 0);
85
  __builtin_prefetch (glob_vol_ptr_int, 0, 0);
86
  __builtin_prefetch (glob_ptr_vol_int, 0, 0);
87
  __builtin_prefetch (glob_vol_ptr_vol_int, 0, 0);
88
  __builtin_prefetch (&glob_vol_int_arr[2], 0, 0);
89
  __builtin_prefetch (&glob_vol_ptr_int[3], 0, 0);
90
  __builtin_prefetch (&glob_ptr_vol_int[3], 0, 0);
91
  __builtin_prefetch (&glob_vol_ptr_vol_int[3], 0, 0);
92
  __builtin_prefetch (glob_vol_int_arr+3, 0, 0);
93
  __builtin_prefetch (glob_vol_int_arr+glob_vol_int, 0, 0);
94
  __builtin_prefetch (glob_vol_ptr_int+5, 0, 0);
95
  __builtin_prefetch (glob_ptr_vol_int+5, 0, 0);
96
  __builtin_prefetch (glob_vol_ptr_vol_int+5, 0, 0);
97
  __builtin_prefetch (glob_vol_ptr_int+glob_vol_int, 0, 0);
98
  __builtin_prefetch (glob_ptr_vol_int+glob_vol_int, 0, 0);
99
  __builtin_prefetch (glob_vol_ptr_vol_int+glob_vol_int, 0, 0);
100
}
101
 
102
int
103
main ()
104
{
105
  simple_vol_global ();
106
  simple_vol_file ();
107
 
108
  str.next = &str;
109
  vol_str.next = &str;
110
  expr_vol_global ();
111
 
112
  exit (0);
113
}

powered by: WebSVN 2.1.0

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