| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-skip-if "" { ! { clmcpu } } } */ |
| 3 |
/* { dg-options "-mcpu=arc700 -O2 -fpic" } */ |
| 4 |
|
| 5 |
/* Test if the compiler generates a constant address having that uses |
| 6 |
a neg keyword on the pic unspec. */ |
| 7 |
|
| 8 |
typedef unsigned int uint32_t; |
| 9 |
typedef unsigned char uint8_t; |
| 10 |
typedef unsigned short int uint16_t; |
| 11 |
typedef unsigned long long int uint64_t; |
| 12 |
|
| 13 |
enum type { |
| 14 |
t_undef = 0x01, |
| 15 |
t_group = 0x02, |
| 16 |
t_partition = 0x04, |
| 17 |
t_spare = 0x08, |
| 18 |
t_linear = 0x10, |
| 19 |
t_raid0 = 0x20, |
| 20 |
t_raid1 = 0x40, |
| 21 |
t_raid4 = 0x80, |
| 22 |
t_raid5_ls = 0x100, |
| 23 |
t_raid5_rs = 0x200, |
| 24 |
t_raid5_la = 0x400, |
| 25 |
t_raid5_ra = 0x800, |
| 26 |
t_raid6 = 0x1000, |
| 27 |
}; |
| 28 |
|
| 29 |
struct raid_set { |
| 30 |
enum type type; |
| 31 |
}; |
| 32 |
|
| 33 |
void |
| 34 |
_find_factors (struct raid_set *rs, uint8_t * div, uint8_t * sub) |
| 35 |
{ |
| 36 |
struct factors { |
| 37 |
const uint8_t level; |
| 38 |
const uint8_t div, sub; |
| 39 |
}; |
| 40 |
static struct factors factors[] = { |
| 41 |
{0, 1, 0}, |
| 42 |
{1, 2, 0}, |
| 43 |
{2, 2, 0}, |
| 44 |
{5, 1, 1}, |
| 45 |
}; |
| 46 |
struct factors *f = (factors + (sizeof (factors) / sizeof (*factors))); |
| 47 |
|
| 48 |
while (f-- > factors) { |
| 49 |
if (rs->type == f->level) { |
| 50 |
*div = f->div; |
| 51 |
*sub = f->sub; |
| 52 |
return; |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
*div = 1; |
| 57 |
*sub = 0; |
| 58 |
} |