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