Like tests, pass the benchmarks if XLEN disagrees
[riscv-tests.git] / benchmarks / dhrystone / dhrystone.c
1 // See LICENSE for license details.
2
3 #pragma GCC optimize ("no-inline")
4
5 #include "dhrystone.h"
6
7 #ifndef REG
8 #define REG
9 /* REG becomes defined as empty */
10 /* i.e. no register variables */
11 #else
12 #undef REG
13 #define REG register
14 #endif
15
16 extern int Int_Glob;
17 extern char Ch_1_Glob;
18
19
20 Proc_6 (Enum_Val_Par, Enum_Ref_Par)
21 /*********************************/
22 /* executed once */
23 /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
24
25 Enumeration Enum_Val_Par;
26 Enumeration *Enum_Ref_Par;
27 {
28 *Enum_Ref_Par = Enum_Val_Par;
29 if (! Func_3 (Enum_Val_Par))
30 /* then, not executed */
31 *Enum_Ref_Par = Ident_4;
32 switch (Enum_Val_Par)
33 {
34 case Ident_1:
35 *Enum_Ref_Par = Ident_1;
36 break;
37 case Ident_2:
38 if (Int_Glob > 100)
39 /* then */
40 *Enum_Ref_Par = Ident_1;
41 else *Enum_Ref_Par = Ident_4;
42 break;
43 case Ident_3: /* executed */
44 *Enum_Ref_Par = Ident_2;
45 break;
46 case Ident_4: break;
47 case Ident_5:
48 *Enum_Ref_Par = Ident_3;
49 break;
50 } /* switch */
51 } /* Proc_6 */
52
53
54 Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
55 /**********************************************/
56 /* executed three times */
57 /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */
58 /* Int_Par_Ref becomes 7 */
59 /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
60 /* Int_Par_Ref becomes 17 */
61 /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
62 /* Int_Par_Ref becomes 18 */
63 One_Fifty Int_1_Par_Val;
64 One_Fifty Int_2_Par_Val;
65 One_Fifty *Int_Par_Ref;
66 {
67 One_Fifty Int_Loc;
68
69 Int_Loc = Int_1_Par_Val + 2;
70 *Int_Par_Ref = Int_2_Par_Val + Int_Loc;
71 } /* Proc_7 */
72
73
74 Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
75 /*********************************************************************/
76 /* executed once */
77 /* Int_Par_Val_1 == 3 */
78 /* Int_Par_Val_2 == 7 */
79 Arr_1_Dim Arr_1_Par_Ref;
80 Arr_2_Dim Arr_2_Par_Ref;
81 int Int_1_Par_Val;
82 int Int_2_Par_Val;
83 {
84 REG One_Fifty Int_Index;
85 REG One_Fifty Int_Loc;
86
87 Int_Loc = Int_1_Par_Val + 5;
88 Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
89 Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
90 Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
91 for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
92 Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
93 Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
94 Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
95 Int_Glob = 5;
96 } /* Proc_8 */
97
98
99 Enumeration Func_1 (Ch_1_Par_Val, Ch_2_Par_Val)
100 /*************************************************/
101 /* executed three times */
102 /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */
103 /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */
104 /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */
105
106 Capital_Letter Ch_1_Par_Val;
107 Capital_Letter Ch_2_Par_Val;
108 {
109 Capital_Letter Ch_1_Loc;
110 Capital_Letter Ch_2_Loc;
111
112 Ch_1_Loc = Ch_1_Par_Val;
113 Ch_2_Loc = Ch_1_Loc;
114 if (Ch_2_Loc != Ch_2_Par_Val)
115 /* then, executed */
116 return (Ident_1);
117 else /* not executed */
118 {
119 Ch_1_Glob = Ch_1_Loc;
120 return (Ident_2);
121 }
122 } /* Func_1 */
123
124
125 Boolean Func_2 (Str_1_Par_Ref, Str_2_Par_Ref)
126 /*************************************************/
127 /* executed once */
128 /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
129 /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
130
131 Str_30 Str_1_Par_Ref;
132 Str_30 Str_2_Par_Ref;
133 {
134 REG One_Thirty Int_Loc;
135 Capital_Letter Ch_Loc;
136
137 Int_Loc = 2;
138 while (Int_Loc <= 2) /* loop body executed once */
139 if (Func_1 (Str_1_Par_Ref[Int_Loc],
140 Str_2_Par_Ref[Int_Loc+1]) == Ident_1)
141 /* then, executed */
142 {
143 Ch_Loc = 'A';
144 Int_Loc += 1;
145 } /* if, while */
146 if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
147 /* then, not executed */
148 Int_Loc = 7;
149 if (Ch_Loc == 'R')
150 /* then, not executed */
151 return (true);
152 else /* executed */
153 {
154 if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0)
155 /* then, not executed */
156 {
157 Int_Loc += 7;
158 Int_Glob = Int_Loc;
159 return (true);
160 }
161 else /* executed */
162 return (false);
163 } /* if Ch_Loc */
164 } /* Func_2 */
165
166
167 Boolean Func_3 (Enum_Par_Val)
168 /***************************/
169 /* executed once */
170 /* Enum_Par_Val == Ident_3 */
171 Enumeration Enum_Par_Val;
172 {
173 Enumeration Enum_Loc;
174
175 Enum_Loc = Enum_Par_Val;
176 if (Enum_Loc == Ident_3)
177 /* then, executed */
178 return (true);
179 else /* not executed */
180 return (false);
181 } /* Func_3 */
182
183 void debug_printf(const char* str, ...)
184 {
185 }