2 * Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
25 static uint32_t preg_alias(uint8_t v0
, uint8_t v1
, uint8_t v2
, uint8_t v3
)
28 asm volatile("p0 = %1\n\t"
34 : "r"(v0
), "r"(v1
), "r"(v2
), "r"(v3
)
35 : "p0", "p1", "p2", "p3");
39 static uint32_t preg_alias_pair(uint8_t v0
, uint8_t v1
, uint8_t v2
, uint8_t v3
)
42 asm volatile("p0 = %1\n\t"
48 : "r"(v0
), "r"(v1
), "r"(v2
), "r"(v3
)
49 : "p0", "p1", "p2", "p3");
63 static inline void creg_alias(uint32_t cval
, PRegs
*pregs
)
70 : "=r"(pregs
->pregs
.p0
), "=r"(pregs
->pregs
.p1
),
71 "=r"(pregs
->pregs
.p2
), "=r"(pregs
->pregs
.p3
)
73 : "c4", "p0", "p1", "p2", "p3");
76 static inline void creg_alias_pair(uint32_t cval
, PRegs
*pregs
)
78 uint64_t cval_pair
= (0xdeadbeefULL
<< 32) | cval
;
87 : "=r"(pregs
->pregs
.p0
), "=r"(pregs
->pregs
.p1
),
88 "=r"(pregs
->pregs
.p2
), "=r"(pregs
->pregs
.p3
), "=r"(c5
)
90 : "c4", "c5", "p0", "p1", "p2", "p3");
92 check32(c5
, 0xdeadbeef);
95 static void test_packet(void)
98 * Test that setting c4 inside a packet doesn't impact the predicates
99 * that are read during the packet.
103 uint32_t old_val
= 0x0000001c;
105 /* Test a predicated register transfer */
111 " if (!p2) %0 = %3\n\t"
114 : "r"(0xffffffff), "r"(0xff00ffff), "r"(0x837ed653)
115 : "c4", "p0", "p1", "p2", "p3");
116 check32(result
, old_val
);
118 /* Test a predicated store */
123 " if (!p2) memw(%2) = #0\n\t"
126 : "r"(0), "r"(0xffffffff), "r"(&result
)
127 : "c4", "p0", "p1", "p2", "p3", "memory");
128 check32(result
, 0x0);
136 c4
= preg_alias(0xff, 0x00, 0xff, 0x00);
137 check32(c4
, 0x00ff00ff);
138 c4
= preg_alias(0xff, 0x00, 0x00, 0x00);
139 check32(c4
, 0x000000ff);
140 c4
= preg_alias(0x00, 0xff, 0x00, 0x00);
141 check32(c4
, 0x0000ff00);
142 c4
= preg_alias(0x00, 0x00, 0xff, 0x00);
143 check32(c4
, 0x00ff0000);
144 c4
= preg_alias(0x00, 0x00, 0x00, 0xff);
145 check32(c4
, 0xff000000);
146 c4
= preg_alias(0xff, 0xff, 0xff, 0xff);
147 check32(c4
, 0xffffffff);
149 c4
= preg_alias_pair(0xff, 0x00, 0xff, 0x00);
150 check32(c4
, 0x00ff00ff);
151 c4
= preg_alias_pair(0xff, 0x00, 0x00, 0x00);
152 check32(c4
, 0x000000ff);
153 c4
= preg_alias_pair(0x00, 0xff, 0x00, 0x00);
154 check32(c4
, 0x0000ff00);
155 c4
= preg_alias_pair(0x00, 0x00, 0xff, 0x00);
156 check32(c4
, 0x00ff0000);
157 c4
= preg_alias_pair(0x00, 0x00, 0x00, 0xff);
158 check32(c4
, 0xff000000);
159 c4
= preg_alias_pair(0xff, 0xff, 0xff, 0xff);
160 check32(c4
, 0xffffffff);
162 creg_alias(0x00ff00ff, &pregs
);
163 check32(pregs
.creg
, 0x00ff00ff);
164 creg_alias(0x00ffff00, &pregs
);
165 check32(pregs
.creg
, 0x00ffff00);
166 creg_alias(0x00000000, &pregs
);
167 check32(pregs
.creg
, 0x00000000);
168 creg_alias(0xff000000, &pregs
);
169 check32(pregs
.creg
, 0xff000000);
170 creg_alias(0x00ff0000, &pregs
);
171 check32(pregs
.creg
, 0x00ff0000);
172 creg_alias(0x0000ff00, &pregs
);
173 check32(pregs
.creg
, 0x0000ff00);
174 creg_alias(0x000000ff, &pregs
);
175 check32(pregs
.creg
, 0x000000ff);
176 creg_alias(0xffffffff, &pregs
);
177 check32(pregs
.creg
, 0xffffffff);
179 creg_alias_pair(0x00ff00ff, &pregs
);
180 check32(pregs
.creg
, 0x00ff00ff);
181 creg_alias_pair(0x00ffff00, &pregs
);
182 check32(pregs
.creg
, 0x00ffff00);
183 creg_alias_pair(0x00000000, &pregs
);
184 check32(pregs
.creg
, 0x00000000);
185 creg_alias_pair(0xff000000, &pregs
);
186 check32(pregs
.creg
, 0xff000000);
187 creg_alias_pair(0x00ff0000, &pregs
);
188 check32(pregs
.creg
, 0x00ff0000);
189 creg_alias_pair(0x0000ff00, &pregs
);
190 check32(pregs
.creg
, 0x0000ff00);
191 creg_alias_pair(0x000000ff, &pregs
);
192 check32(pregs
.creg
, 0x000000ff);
193 creg_alias_pair(0xffffffff, &pregs
);
194 check32(pregs
.creg
, 0xffffffff);
198 puts(err
? "FAIL" : "PASS");