Deleted Added
sdiff udiff text old ( 129059 ) new ( 160157 )
full compact
1/*
2Copyright (c) 2003 Hewlett-Packard Development Company, L.P.
3Permission is hereby granted, free of charge, to any person
4obtaining a copy of this software and associated documentation
5files (the "Software"), to deal in the Software without
6restriction, including without limitation the rights to use,
7copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the
9Software is furnished to do so, subject to the following
10conditions:

--- 166 unchanged lines hidden (view full) ---

177 sor = (((int) env->context.special[UWX_REG_CFM] >> 14) & 0x0f) * 8;
178 rrb_gr = ((int) env->context.special[UWX_REG_CFM] >> 18) & 0x7f;
179 if (sor != 0 && rrb_gr != 0 && regid < sor) {
180 regid = (regid + rrb_gr) % sor;
181 }
182 bsp = uwx_add_to_bsp(bsp, regid);
183 natcollp = bsp | 0x01f8;
184 n = (*env->copyin)(UWX_COPYIN_RSTACK, (char *)&natcoll,
185 bsp, DWORDSZ, env->cb_token);
186 if (n != DWORDSZ)
187 return UWX_ERR_COPYIN_RSTK;
188 *natp = (int)(natcoll >> (((int)bsp >> 3) & 0x3f)) & 0x01;
189 }
190 else if (regid == UWX_REG_GR(0))
191 *natp = 0;
192 else
193 status = UWX_ERR_BADREGID;
194 return status;
195}
196
197int uwx_get_spill_loc(struct uwx_env *env, int regid, uint64_t *dispp)
198{
199 int status;
200 int sor;
201 int rrb_gr;
202 uint64_t bsp;
203
204 if (env == 0)
205 return UWX_ERR_NOENV;
206
207 status = UWX_OK;
208
209 if (regid == UWX_REG_GR(12))
210 regid = UWX_REG_SP;
211 if (regid < NSPECIALREG)
212 *dispp = env->history.special[regid];
213 else if (regid >= UWX_REG_GR(4) && regid <= UWX_REG_GR(7))
214 *dispp = env->history.gr[regid - UWX_REG_GR(4)];
215 else if (regid >= UWX_REG_GR(32) && regid <= UWX_REG_GR(127)) {
216 bsp = env->context.special[UWX_REG_BSP];
217 regid -= UWX_REG_GR(32);
218 sor = (((int) env->context.special[UWX_REG_CFM] >> 14) & 0x0f) * 8;
219 rrb_gr = ((int) env->context.special[UWX_REG_CFM] >> 18) & 0x7f;
220 if (sor != 0 && rrb_gr != 0 && regid < sor)

--- 47 unchanged lines hidden (view full) ---

268 }
269 else
270 status = UWX_ERR_BADREGID;
271 return status;
272}
273
274int uwx_set_fr(struct uwx_env *env, int regid, uint64_t *val)
275{
276
277 if (regid >= UWX_REG_FR(2) && regid <= UWX_REG_FR(5))
278 regid -= UWX_REG_FR(2);
279 else if (regid >= UWX_REG_FR(16) && regid <= UWX_REG_FR(31))
280 regid -= UWX_REG_FR(16) - 4;
281 else
282 return UWX_ERR_BADREGID;
283

--- 24 unchanged lines hidden (view full) ---

308 * +---------------------------------------------------------------+
309 * | X X|
310 * +---------------------------------------------------------------+
311 * <-------- bias -------->
312 * <--- nslots --->
313 * ^
314 * |
315 * bsp
316 * <------- adjusted (nslots + bias) ------->
317
318 * When subtracting from bsp, we avoid depending on the sign of
319 * the quotient by adding 63*8 before division and subtracting 8
320 * after division. (Assumes that we will never be called upon
321 * to subtract more than 504 slots from bsp.)
322 *
323 * 0 1f8 3f8
324 * +---------------------------------------------------------------+
325 * | X X|
326 * +---------------------------------------------------------------+
327 * <-- bias -->
328 * <--- |nslots| --->
329 * ^
330 * |
331 * bsp
332 * <----------------->
333 * adjusted |nslots + bias|
334 */
335
336 bias = ((unsigned int)bsp & 0x1f8) / DWORDSZ;
337 nslots += (nslots + bias + 63*8) / 63 - 8;
338 return bsp + nslots * DWORDSZ;
339}
340
341#if 0
342int uwx_selftest_bsp_arithmetic()
343{
344 int i;
345 int j;
346 int r;
347 uint64_t bstore[161];
348 uint64_t *bsp;
349 uint64_t *p;

--- 11 unchanged lines hidden (view full) ---

361
362 printf("uwx_selftest_bsp_arithmetic: plus tests...\n");
363 bsp = bstore;
364 for (i = 0; i < 64; i++) {
365 r = (int)*bsp;
366 if (r >= 1000)
367 r -= 1000;
368 for (j = 0; j < 96; j++) {
369 p = (uint64_t *)uwx_add_to_bsp((uint64_t)bsp, j);
370 if (*p != (r + j)) {
371 failed++;
372 printf("%d [%08lx] + %d -> %08lx ",
373 i, (unsigned int)bsp, j, (unsigned int)p);
374 printf("(read %d instead of %d)\n", (int)*p, r + j);
375 }
376 }
377 bsp++;
378 }
379
380 printf("uwx_selftest_bsp_arithmetic: minus tests...\n");
381 bsp = &bstore[161];
382 for (i = 63; i >= 0; i--) {
383 bsp--;
384 r = (int)*bsp;
385 if (r >= 1000)
386 r -= 1000;
387 for (j = 0; j < 96; j++) {
388 p = (uint64_t *)uwx_add_to_bsp((uint64_t)bsp, -j);
389 if (*p != (r - j)) {
390 failed++;
391 printf("%d [%08lx] - %d -> %08lx ",
392 i, (unsigned int)bsp, j, (unsigned int)p);
393 printf("(read %d instead of %d)\n", (int)*p, r - j);
394 }
395 }
396 }
397
398 return failed;
399}
400#endif