| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options " -Os -march=rv32e_zca_zcmp -mabi=ilp32e -mcmodel=medlow" } */ |
| 3 |
/* { dg-skip-if "" { *-*-* } {"-O0" "-O1" "-O2" "-Og" "-O3" "-Oz" "-flto"} } */ |
| 4 |
/* { dg-final { check-function-bodies "**" "" } } */ |
| 5 |
|
| 6 |
char |
| 7 |
my_getchar (); |
| 8 |
float |
| 9 |
getf (); |
| 10 |
int __attribute__ ((noinline)) |
| 11 |
incoming_stack_args (int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, |
| 12 |
int arg6, int arg7, int arg8); |
| 13 |
int |
| 14 |
getint (); |
| 15 |
void |
| 16 |
PrintInts (int n, ...); // varargs |
| 17 |
void __attribute__ ((noinline)) PrintIntsNoVaStart (int n, ...); // varargs |
| 18 |
void |
| 19 |
PrintInts2 (int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int n, |
| 20 |
...); |
| 21 |
extern void |
| 22 |
f1 (void); |
| 23 |
extern void |
| 24 |
f2 (void); |
| 25 |
|
| 26 |
/* |
| 27 |
**test1: |
| 28 |
** ... |
| 29 |
** cm.push {ra, s0-s1}, -64 |
| 30 |
** ... |
| 31 |
** cm.popret {ra, s0-s1}, 64 |
| 32 |
** ... |
| 33 |
*/ |
| 34 |
int |
| 35 |
test1 () |
| 36 |
{ |
| 37 |
char volatile array[3120]; |
| 38 |
float volatile farray[3120]; |
| 39 |
|
| 40 |
float sum = 0; |
| 41 |
for (int i = 0; i < 3120; i++) |
| 42 |
{ |
| 43 |
array[i] = my_getchar (); |
| 44 |
farray[i] = my_getchar () * 1.2; |
| 45 |
sum += array[i] + farray[i]; |
| 46 |
} |
| 47 |
return sum; |
| 48 |
} |
| 49 |
|
| 50 |
/* |
| 51 |
**test2_step1_0_size: |
| 52 |
** ... |
| 53 |
** cm.push {ra, s0}, -64 |
| 54 |
** ... |
| 55 |
** cm.popret {ra, s0}, 64 |
| 56 |
** ... |
| 57 |
*/ |
| 58 |
int |
| 59 |
test2_step1_0_size () |
| 60 |
{ |
| 61 |
int volatile iarray[3120 + 1824 / 4 - 8]; |
| 62 |
|
| 63 |
for (int i = 0; i < 3120 + 1824 / 4 - 8; i++) |
| 64 |
{ |
| 65 |
iarray[i] = my_getchar () * 2; |
| 66 |
} |
| 67 |
return iarray[0] + iarray[1]; |
| 68 |
} |
| 69 |
|
| 70 |
/* |
| 71 |
**test3: |
| 72 |
** ... |
| 73 |
** cm.push {ra, s0-s1}, -64 |
| 74 |
** ... |
| 75 |
** cm.popret {ra, s0-s1}, 64 |
| 76 |
** ... |
| 77 |
*/ |
| 78 |
float |
| 79 |
test3 () |
| 80 |
{ |
| 81 |
char volatile array[3120]; |
| 82 |
float volatile farray[3120]; |
| 83 |
|
| 84 |
float sum = 0, f1 = 0, f2 = 0, f3 = 0, f4 = 0, f5 = 0, f6 = 0, f7 = 0; |
| 85 |
|
| 86 |
for (int i = 0; i < 3120; i++) |
| 87 |
{ |
| 88 |
f1 = getf (); |
| 89 |
f2 = getf (); |
| 90 |
f3 = getf (); |
| 91 |
f4 = getf (); |
| 92 |
array[i] = my_getchar (); |
| 93 |
farray[i] = my_getchar () * 1.2; |
| 94 |
sum += array[i] + farray[i] + f1 + f2 + f3 + f4; |
| 95 |
} |
| 96 |
return sum; |
| 97 |
} |
| 98 |
|
| 99 |
/* |
| 100 |
**outgoing_stack_args: |
| 101 |
** ... |
| 102 |
** cm.push {ra, s0}, -32 |
| 103 |
** ... |
| 104 |
** cm.popret {ra, s0}, 32 |
| 105 |
** ... |
| 106 |
*/ |
| 107 |
int |
| 108 |
outgoing_stack_args () |
| 109 |
{ |
| 110 |
int local = getint (); |
| 111 |
return local + incoming_stack_args (0, 1, 2, 3, 4, 5, 6, 7, 8); |
| 112 |
} |
| 113 |
|
| 114 |
/* |
| 115 |
**callPrintInts: |
| 116 |
** ... |
| 117 |
** cm.push {ra}, -32 |
| 118 |
** ... |
| 119 |
** cm.popret {ra}, 32 |
| 120 |
** ... |
| 121 |
*/ |
| 122 |
float |
| 123 |
callPrintInts () |
| 124 |
{ |
| 125 |
volatile float f = getf (); // f in local |
| 126 |
PrintInts (9, 1, 2, 3, 4, 5, 6, 7, 8, 9); |
| 127 |
return f; |
| 128 |
} |
| 129 |
|
| 130 |
/* |
| 131 |
**callPrint: |
| 132 |
** ... |
| 133 |
** cm.push {ra}, -32 |
| 134 |
** ... |
| 135 |
** cm.popret {ra}, 32 |
| 136 |
** ... |
| 137 |
*/ |
| 138 |
float |
| 139 |
callPrint () |
| 140 |
{ |
| 141 |
volatile float f = getf (); // f in local |
| 142 |
PrintIntsNoVaStart (0, 1, 2, 3, 4, 5, 6, 7, 8, 9); |
| 143 |
return f; |
| 144 |
} |
| 145 |
|
| 146 |
/* |
| 147 |
**callPrint_S: |
| 148 |
** ... |
| 149 |
** cm.push {ra, s0}, -32 |
| 150 |
** ... |
| 151 |
** cm.popret {ra, s0}, 32 |
| 152 |
** ... |
| 153 |
*/ |
| 154 |
float |
| 155 |
callPrint_S () |
| 156 |
{ |
| 157 |
float f = getf (); |
| 158 |
PrintIntsNoVaStart (0, 1, 2, 3, 4, 5, 6, 7, 8, 9); |
| 159 |
return f; |
| 160 |
} |
| 161 |
|
| 162 |
/* |
| 163 |
**callPrint_2: |
| 164 |
** ... |
| 165 |
** cm.push {ra, s0}, -32 |
| 166 |
** ... |
| 167 |
** cm.popret {ra, s0}, 32 |
| 168 |
** ... |
| 169 |
*/ |
| 170 |
float |
| 171 |
callPrint_2 () |
| 172 |
{ |
| 173 |
float f = getf (); |
| 174 |
PrintInts2 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9); |
| 175 |
return f; |
| 176 |
} |
| 177 |
|
| 178 |
/* |
| 179 |
**test_step1_0bytes_save_restore: |
| 180 |
** ... |
| 181 |
** cm.push {ra}, -16 |
| 182 |
** ... |
| 183 |
** cm.popret {ra}, 16 |
| 184 |
** ... |
| 185 |
*/ |
| 186 |
int |
| 187 |
test_step1_0bytes_save_restore () |
| 188 |
{ |
| 189 |
int a = 9; |
| 190 |
int b = my_getchar (); |
| 191 |
return a + b; |
| 192 |
} |
| 193 |
|
| 194 |
/* |
| 195 |
**test_s0: |
| 196 |
** ... |
| 197 |
** cm.push {ra, s0}, -16 |
| 198 |
** ... |
| 199 |
** cm.popret {ra, s0}, 16 |
| 200 |
** ... |
| 201 |
*/ |
| 202 |
int |
| 203 |
test_s0 () |
| 204 |
{ |
| 205 |
int a = my_getchar (); |
| 206 |
int b = my_getchar (); |
| 207 |
return a + b; |
| 208 |
} |
| 209 |
|
| 210 |
/* |
| 211 |
**test_s1: |
| 212 |
** ... |
| 213 |
** cm.push {ra, s0-s1}, -16 |
| 214 |
** ... |
| 215 |
** cm.popret {ra, s0-s1}, 16 |
| 216 |
** ... |
| 217 |
*/ |
| 218 |
int |
| 219 |
test_s1 () |
| 220 |
{ |
| 221 |
int s0 = my_getchar (); |
| 222 |
int s1 = my_getchar (); |
| 223 |
int b = my_getchar (); |
| 224 |
return s1 + s0 + b; |
| 225 |
} |
| 226 |
|
| 227 |
/* |
| 228 |
**test_f0: |
| 229 |
** ... |
| 230 |
** cm.push {ra, s0-s1}, -16 |
| 231 |
** ... |
| 232 |
** cm.popret {ra, s0-s1}, 16 |
| 233 |
** ... |
| 234 |
*/ |
| 235 |
int |
| 236 |
test_f0 () |
| 237 |
{ |
| 238 |
int s0 = my_getchar (); |
| 239 |
float f0 = getf (); |
| 240 |
int b = my_getchar (); |
| 241 |
return f0 + s0 + b; |
| 242 |
} |
| 243 |
|
| 244 |
/* |
| 245 |
**foo: |
| 246 |
** cm.push {ra}, -16 |
| 247 |
** call f1(?:@plt)? |
| 248 |
** cm.pop {ra}, 16 |
| 249 |
** tail f2(?:@plt)? |
| 250 |
*/ |
| 251 |
void |
| 252 |
foo (void) |
| 253 |
{ |
| 254 |
f1 (); |
| 255 |
f2 (); |
| 256 |
} |
| 257 |
|
| 258 |
/* |
| 259 |
**test_popretz: |
| 260 |
** cm.push {ra}, -16 |
| 261 |
** call f1(?:@plt)? |
| 262 |
** li a0,0 |
| 263 |
** cm.popret {ra}, 16 |
| 264 |
*/ |
| 265 |
long |
| 266 |
test_popretz () |
| 267 |
{ |
| 268 |
f1 (); |
| 269 |
return 0; |
| 270 |
} |