| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target powerpc_prefixed_addr } */ |
| 3 |
/* { dg-require-effective-target lp64 } */ |
| 4 |
/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ |
| 5 |
/* If -mstrict-align is enabled by default, we don't get the expected opcodes. |
| 6 |
{ dg-additional-options "-mno-strict-align" { target opt_mstrict_align } } */ |
| 7 |
|
| 8 |
/* Tests whether we generate a prefixed load/store operation for addresses that |
| 9 |
don't meet DS/DQ offset constraints. 64-bit is needed for testing the use |
| 10 |
of the PLWA instruciton. */ |
| 11 |
|
| 12 |
struct packed_struct |
| 13 |
{ |
| 14 |
long long pad; /* offset 0 bytes. */ |
| 15 |
unsigned char pad_uc; /* offset 8 bytes. */ |
| 16 |
unsigned char uc; /* offset 9 bytes. */ |
| 17 |
|
| 18 |
unsigned char pad_sc[sizeof (long long) - sizeof (unsigned char)]; |
| 19 |
unsigned char sc; /* offset 17 bytes. */ |
| 20 |
|
| 21 |
unsigned char pad_us[sizeof (long long) - sizeof (signed char)]; |
| 22 |
unsigned short us; /* offset 25 bytes. */ |
| 23 |
|
| 24 |
unsigned char pad_ss[sizeof (long long) - sizeof (unsigned short)]; |
| 25 |
short ss; /* offset 33 bytes. */ |
| 26 |
|
| 27 |
unsigned char pad_ui[sizeof (long long) - sizeof (short)]; |
| 28 |
unsigned int ui; /* offset 41 bytes. */ |
| 29 |
|
| 30 |
unsigned char pad_si[sizeof (long long) - sizeof (unsigned int)]; |
| 31 |
unsigned int si; /* offset 49 bytes. */ |
| 32 |
|
| 33 |
unsigned char pad_f[sizeof (long long) - sizeof (int)]; |
| 34 |
float f; /* offset 57 bytes. */ |
| 35 |
|
| 36 |
unsigned char pad_d[sizeof (long long) - sizeof (float)]; |
| 37 |
double d; /* offset 65 bytes. */ |
| 38 |
__float128 f128; /* offset 73 bytes. */ |
| 39 |
} __attribute__((packed)); |
| 40 |
|
| 41 |
unsigned char |
| 42 |
load_uc (struct packed_struct *p) |
| 43 |
{ |
| 44 |
return p->uc; /* LBZ 3,9(3). */ |
| 45 |
} |
| 46 |
|
| 47 |
signed char |
| 48 |
load_sc (struct packed_struct *p) |
| 49 |
{ |
| 50 |
return p->sc; /* LBZ 3,17(3) + EXTSB 3,3. */ |
| 51 |
} |
| 52 |
|
| 53 |
unsigned short |
| 54 |
load_us (struct packed_struct *p) |
| 55 |
{ |
| 56 |
return p->us; /* LHZ 3,25(3). */ |
| 57 |
} |
| 58 |
|
| 59 |
short |
| 60 |
load_ss (struct packed_struct *p) |
| 61 |
{ |
| 62 |
return p->ss; /* LHA 3,33(3). */ |
| 63 |
} |
| 64 |
|
| 65 |
unsigned int |
| 66 |
load_ui (struct packed_struct *p) |
| 67 |
{ |
| 68 |
return p->ui; /* LWZ 3,41(3). */ |
| 69 |
} |
| 70 |
|
| 71 |
int |
| 72 |
load_si (struct packed_struct *p) |
| 73 |
{ |
| 74 |
return p->si; /* PLWA 3,49(3). */ |
| 75 |
} |
| 76 |
|
| 77 |
float |
| 78 |
load_float (struct packed_struct *p) |
| 79 |
{ |
| 80 |
return p->f; /* LFS 1,57(3). */ |
| 81 |
} |
| 82 |
|
| 83 |
double |
| 84 |
load_double (struct packed_struct *p) |
| 85 |
{ |
| 86 |
return p->d; /* LFD 1,65(3). */ |
| 87 |
} |
| 88 |
|
| 89 |
__float128 |
| 90 |
load_float128 (struct packed_struct *p) |
| 91 |
{ |
| 92 |
return p->f128; /* PLXV 34,73(3). */ |
| 93 |
} |
| 94 |
|
| 95 |
void |
| 96 |
store_uc (struct packed_struct *p, unsigned char uc) |
| 97 |
{ |
| 98 |
p->uc = uc; /* STB 4,9(3). */ |
| 99 |
} |
| 100 |
|
| 101 |
void |
| 102 |
store_sc (struct packed_struct *p, signed char sc) |
| 103 |
{ |
| 104 |
p->sc = sc; /* STB 4,17(3). */ |
| 105 |
} |
| 106 |
|
| 107 |
void |
| 108 |
store_us (struct packed_struct *p, unsigned short us) |
| 109 |
{ |
| 110 |
p->us = us; /* STH 4,25(3). */ |
| 111 |
} |
| 112 |
|
| 113 |
void |
| 114 |
store_ss (struct packed_struct *p, signed short ss) |
| 115 |
{ |
| 116 |
p->ss = ss; /* STH 4,33(3). */ |
| 117 |
} |
| 118 |
|
| 119 |
void |
| 120 |
store_ui (struct packed_struct *p, unsigned int ui) |
| 121 |
{ |
| 122 |
p->ui = ui; /* STW 4,41(3). */ |
| 123 |
} |
| 124 |
|
| 125 |
void |
| 126 |
store_si (struct packed_struct *p, signed int si) |
| 127 |
{ |
| 128 |
p->si = si; /* STW 4,49(3). */ |
| 129 |
} |
| 130 |
|
| 131 |
void |
| 132 |
store_float (struct packed_struct *p, float f) |
| 133 |
{ |
| 134 |
p->f = f; /* STFS 1,57(3). */ |
| 135 |
} |
| 136 |
|
| 137 |
void |
| 138 |
store_double (struct packed_struct *p, double d) |
| 139 |
{ |
| 140 |
p->d = d; /* STFD 1,65(3). */ |
| 141 |
} |
| 142 |
|
| 143 |
void |
| 144 |
store_float128 (struct packed_struct *p, __float128 f128) |
| 145 |
{ |
| 146 |
p->f128 = f128; /* PSTXV 34,1(3). */ |
| 147 |
} |
| 148 |
|
| 149 |
/* { dg-final { scan-assembler-times {\mextsb\M} 1 } } */ |
| 150 |
/* { dg-final { scan-assembler-times {\mlbz\M} 2 } } */ |
| 151 |
/* { dg-final { scan-assembler-times {\mlfd\M} 1 } } */ |
| 152 |
/* { dg-final { scan-assembler-times {\mlfs\M} 1 } } */ |
| 153 |
/* { dg-final { scan-assembler-times {\mlha\M} 1 } } */ |
| 154 |
/* { dg-final { scan-assembler-times {\mlhz\M} 1 } } */ |
| 155 |
/* { dg-final { scan-assembler-times {\mlwz\M} 1 } } */ |
| 156 |
/* { dg-final { scan-assembler-times {\mplwa\M} 1 } } */ |
| 157 |
/* { dg-final { scan-assembler-times {\mplxv\M} 1 } } */ |
| 158 |
/* { dg-final { scan-assembler-times {\mpstxv\M} 1 } } */ |
| 159 |
/* { dg-final { scan-assembler-times {\mstb\M} 2 } } */ |
| 160 |
/* { dg-final { scan-assembler-times {\mstfd\M} 1 } } */ |
| 161 |
/* { dg-final { scan-assembler-times {\mstfs\M} 1 } } */ |
| 162 |
/* { dg-final { scan-assembler-times {\msth\M} 2 } } */ |
| 163 |
/* { dg-final { scan-assembler-times {\mstw\M} 2 } } */ |