2004-05-05 00:24:50 +02:00
|
|
|
/* libunwind - a platform-independent unwind library
|
2005-05-17 15:24:49 +02:00
|
|
|
Copyright (C) 2002-2005 Hewlett-Packard Co
|
2004-05-05 00:24:50 +02:00
|
|
|
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
|
|
|
|
|
|
|
|
This file is part of libunwind.
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
a copy of this software and associated documentation files (the
|
|
|
|
"Software"), to deal in the Software without restriction, including
|
|
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be
|
|
|
|
included in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
|
2002-04-03 08:51:34 +02:00
|
|
|
#include "unwind_i.h"
|
|
|
|
|
2003-08-20 20:02:30 +02:00
|
|
|
/* Apply rotation to a general register. REG must be in the range 0-127. */
|
2002-04-03 08:51:34 +02:00
|
|
|
|
|
|
|
static inline int
|
2002-12-19 08:16:50 +01:00
|
|
|
rotate_gr (struct cursor *c, int reg)
|
2002-04-03 08:51:34 +02:00
|
|
|
{
|
2003-08-20 20:02:30 +02:00
|
|
|
unsigned int rrb_gr, sor;
|
2003-01-23 19:47:51 +01:00
|
|
|
int preg;
|
2002-04-03 08:51:34 +02:00
|
|
|
|
2003-01-23 19:47:51 +01:00
|
|
|
sor = 8 * ((c->cfm >> 14) & 0xf);
|
|
|
|
rrb_gr = (c->cfm >> 18) & 0x7f;
|
2002-04-03 08:51:34 +02:00
|
|
|
|
2003-08-20 20:02:30 +02:00
|
|
|
if ((unsigned) (reg - 32) >= sor)
|
|
|
|
preg = reg;
|
2002-04-03 08:51:34 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
preg = reg + rrb_gr; /* apply rotation */
|
2003-08-20 20:02:30 +02:00
|
|
|
if ((unsigned) (preg - 32) >= sor)
|
2002-04-03 08:51:34 +02:00
|
|
|
preg -= sor; /* wrap around */
|
|
|
|
}
|
2003-02-21 08:36:26 +01:00
|
|
|
if (sor)
|
2004-03-19 03:38:39 +01:00
|
|
|
Debug (15, "sor=%u rrb.gr=%u, r%d -> r%d\n", sor, rrb_gr, reg, preg);
|
2002-04-03 08:51:34 +02:00
|
|
|
return preg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Apply rotation to a floating-point register. The number REG must
|
|
|
|
be in the range of 0-127. */
|
|
|
|
|
|
|
|
static inline int
|
2002-12-19 08:16:50 +01:00
|
|
|
rotate_fr (struct cursor *c, int reg)
|
2002-04-03 08:51:34 +02:00
|
|
|
{
|
|
|
|
unsigned int rrb_fr;
|
2003-01-23 19:47:51 +01:00
|
|
|
int preg;
|
2002-04-03 08:51:34 +02:00
|
|
|
|
2003-01-23 19:47:51 +01:00
|
|
|
rrb_fr = (c->cfm >> 25) & 0x7f;
|
2002-04-03 08:51:34 +02:00
|
|
|
if (reg < 32)
|
|
|
|
preg = reg; /* register not part of the rotating partition */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
preg = reg + rrb_fr; /* apply rotation */
|
|
|
|
if (preg > 127)
|
|
|
|
preg -= 96; /* wrap around */
|
|
|
|
}
|
2003-02-21 08:36:26 +01:00
|
|
|
if (rrb_fr)
|
2004-03-19 03:38:39 +01:00
|
|
|
Debug (15, "rrb.fr=%u, f%d -> f%d\n", rrb_fr, reg, preg);
|
2002-04-03 08:51:34 +02:00
|
|
|
return preg;
|
|
|
|
}
|