| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options " -O2 -fno-shrink-wrap-separate -march=rv32imaf_zca_zcmp -mabi=ilp32f" } */ |
| 3 |
/* { dg-skip-if "" { *-*-* } {"-O0" "-O1" "-Os" "-Og" "-O3" "-Oz" "-flto"} } */ |
| 4 |
|
| 5 |
typedef struct MAT_PARAMS_S |
| 6 |
{ |
| 7 |
int N; |
| 8 |
signed short *A; |
| 9 |
signed short *B; |
| 10 |
signed int *C; |
| 11 |
} mat_params; |
| 12 |
|
| 13 |
typedef struct CORE_PORTABLE_S |
| 14 |
{ |
| 15 |
unsigned char portable_id; |
| 16 |
} core_portable; |
| 17 |
|
| 18 |
typedef struct RESULTS_S |
| 19 |
{ |
| 20 |
/* inputs */ |
| 21 |
signed short seed1; /* Initializing seed */ |
| 22 |
signed short seed2; /* Initializing seed */ |
| 23 |
signed short seed3; /* Initializing seed */ |
| 24 |
void *memblock[4]; /* Pointer to safe memory location */ |
| 25 |
unsigned int size; /* Size of the data */ |
| 26 |
unsigned int iterations; /* Number of iterations to execute */ |
| 27 |
unsigned int execs; /* Bitmask of operations to execute */ |
| 28 |
struct list_head_s *list; |
| 29 |
mat_params mat; |
| 30 |
/* outputs */ |
| 31 |
unsigned short crc; |
| 32 |
unsigned short crclist; |
| 33 |
unsigned short crcmatrix; |
| 34 |
unsigned short crcstate; |
| 35 |
signed short err; |
| 36 |
/* ultithread specific */ |
| 37 |
core_portable port; |
| 38 |
} core_results; |
| 39 |
|
| 40 |
extern signed short |
| 41 |
core_bench_state (unsigned int, void *, signed short, signed short, |
| 42 |
signed short, unsigned short); |
| 43 |
|
| 44 |
extern signed short |
| 45 |
core_bench_matrix (mat_params *, signed short, unsigned short); |
| 46 |
|
| 47 |
extern unsigned short |
| 48 |
crcu16 (signed short, unsigned short); |
| 49 |
|
| 50 |
signed short |
| 51 |
calc_func (signed short *pdata, core_results *res) |
| 52 |
{ |
| 53 |
signed short data = *pdata; |
| 54 |
signed short retval; |
| 55 |
unsigned char optype |
| 56 |
= (data >> 7) |
| 57 |
& 1; /* bit 7 indicates if the function result has been cached */ |
| 58 |
if (optype) /* if cached, use cache */ |
| 59 |
return (data & 0x007f); |
| 60 |
else |
| 61 |
{ /* otherwise calculate and cache the result */ |
| 62 |
signed short flag |
| 63 |
= data & 0x7; /* bits 0-2 is type of function to perform */ |
| 64 |
signed short dtype |
| 65 |
= ((data >> 3) & 0xf); /* bits 3-6 is specific data for the operation */ |
| 66 |
dtype |= dtype << 4; /* replicate the lower 4 bits to get an 8b value */ |
| 67 |
switch (flag) |
| 68 |
{ |
| 69 |
case 0: |
| 70 |
if (dtype < 0x22) /* set min period for bit corruption */ |
| 71 |
dtype = 0x22; |
| 72 |
retval = core_bench_state (res->size, res->memblock[3], res->seed1, |
| 73 |
res->seed2, dtype, res->crc); |
| 74 |
if (res->crcstate == 0) |
| 75 |
res->crcstate = retval; |
| 76 |
break; |
| 77 |
case 1: |
| 78 |
retval = core_bench_matrix (&(res->mat), dtype, res->crc); |
| 79 |
if (res->crcmatrix == 0) |
| 80 |
res->crcmatrix = retval; |
| 81 |
break; |
| 82 |
default: |
| 83 |
retval = data; |
| 84 |
break; |
| 85 |
} |
| 86 |
res->crc = crcu16 (retval, res->crc); |
| 87 |
retval &= 0x007f; |
| 88 |
*pdata = (data & 0xff00) | 0x0080 | retval; /* cache the result */ |
| 89 |
return retval; |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
/* { dg-final { scan-assembler "cm\.push" } } */ |