<NME> unwind_decoder.h
<BEF> /* libunwind - a platform-independent unwind library
   Copyright (C) 2001-2002 Hewlett-Packard Co
        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.  */

/*
 * Generic IA-64 unwind info decoder.
 *
 * This file is used both by the Linux kernel and objdump.  Please keep
 * the two copies of this file in sync.
 *
 * You need to customize the decoder by defining the following
 * macros/constants before including this file:
 *
 *  Types:
 *      unw_word        Unsigned integer type with at least 64 bits
 *
 *  Register names:
 *      UNW_REG_BSP
 *      UNW_REG_BSPSTORE
 *      UNW_REG_FPSR
 *      UNW_REG_LC
 *      UNW_REG_PFS
 *      UNW_REG_PR
 *      UNW_REG_RNAT
 *      UNW_REG_PSP
 *      UNW_REG_RP
 *      UNW_REG_UNAT
 *
 *  Decoder action macros:
 *      UNW_DEC_BAD_CODE(code)
 *      UNW_DEC_ABI(fmt,abi,context,arg)
 *      UNW_DEC_BR_GR(fmt,brmask,gr,arg)
 *      UNW_DEC_BR_MEM(fmt,brmask,arg)
 *      UNW_DEC_COPY_STATE(fmt,label,arg)
 *      UNW_DEC_EPILOGUE(fmt,t,ecount,arg)
 *      UNW_DEC_FRGR_MEM(fmt,grmask,frmask,arg)
 *      UNW_DEC_FR_MEM(fmt,frmask,arg)
 *      UNW_DEC_GR_GR(fmt,grmask,gr,arg)
 *      UNW_DEC_GR_MEM(fmt,grmask,arg)
 *      UNW_DEC_LABEL_STATE(fmt,label,arg)
 *      UNW_DEC_MEM_STACK_F(fmt,t,size,arg)
 *      UNW_DEC_MEM_STACK_V(fmt,t,arg)
 *      UNW_DEC_PRIUNAT_GR(fmt,r,arg)
 *      UNW_DEC_PRIUNAT_WHEN_GR(fmt,t,arg)
 *      UNW_DEC_PRIUNAT_WHEN_MEM(fmt,t,arg)
 *      UNW_DEC_PRIUNAT_WHEN_PSPREL(fmt,pspoff,arg)
 *      UNW_DEC_PRIUNAT_WHEN_SPREL(fmt,spoff,arg)
 *      UNW_DEC_PROLOGUE(fmt,body,rlen,arg)
 *      UNW_DEC_PROLOGUE_GR(fmt,rlen,mask,grsave,arg)
 *      UNW_DEC_REG_PSPREL(fmt,reg,pspoff,arg)
 *      UNW_DEC_REG_REG(fmt,src,dst,arg)
 *      UNW_DEC_REG_SPREL(fmt,reg,spoff,arg)
 *      UNW_DEC_REG_WHEN(fmt,reg,t,arg)
 *      UNW_DEC_RESTORE(fmt,t,abreg,arg)
 *      UNW_DEC_RESTORE_P(fmt,qp,t,abreg,arg)
 *      UNW_DEC_SPILL_BASE(fmt,pspoff,arg)
 *      UNW_DEC_SPILL_MASK(fmt,imaskp,arg)
 *      UNW_DEC_SPILL_PSPREL(fmt,t,abreg,pspoff,arg)
 *      UNW_DEC_SPILL_PSPREL_P(fmt,qp,t,abreg,pspoff,arg)
 *      UNW_DEC_SPILL_REG(fmt,t,abreg,x,ytreg,arg)
 *      UNW_DEC_SPILL_REG_P(fmt,qp,t,abreg,x,ytreg,arg)
 *      UNW_DEC_SPILL_SPREL(fmt,t,abreg,spoff,arg)
 *      UNW_DEC_SPILL_SPREL_P(fmt,qp,t,abreg,pspoff,arg)
 */

static unw_word
unw_decode_uleb128 (unsigned char **dpp)
{
  unsigned shift = 0;
  unw_word byte, result = 0;
  unsigned char *bp = *dpp;

  while (1)
    {
      byte = *bp++;
      result |= (byte & 0x7f) << shift;
      if ((byte & 0x80) == 0)
        break;
      shift += 7;
    }
  *dpp = bp;
  return result;
}

static unsigned char *
unw_decode_x1 (unsigned char *dp, unsigned char code, void *arg)
{
  unsigned char byte1, abreg;
  unw_word t, off;

  byte1 = *dp++;
  t = unw_decode_uleb128 (&dp);
  off = unw_decode_uleb128 (&dp);
  abreg = (byte1 & 0x7f);
  if (byte1 & 0x80)
          UNW_DEC_SPILL_SPREL(X1, t, abreg, off, arg);
  else
          UNW_DEC_SPILL_PSPREL(X1, t, abreg, off, arg);
  return dp;
}

static unsigned char *
unw_decode_x2 (unsigned char *dp, unsigned char code, void *arg)
{
  unsigned char byte1, byte2, abreg, x, ytreg;
  unw_word t;

  byte1 = *dp++; byte2 = *dp++;
  t = unw_decode_uleb128 (&dp);
  abreg = (byte1 & 0x7f);
  ytreg = byte2;
  x = (byte1 >> 7) & 1;
  if ((byte1 & 0x80) == 0 && ytreg == 0)
    UNW_DEC_RESTORE(X2, t, abreg, arg);
  else
    UNW_DEC_SPILL_REG(X2, t, abreg, x, ytreg, arg);
  return dp;
}

static unsigned char *
unw_decode_x3 (unsigned char *dp, unsigned char code, void *arg)
{
  unsigned char byte1, byte2, abreg, qp;
  unw_word t, off;

  byte1 = *dp++; byte2 = *dp++;
  t = unw_decode_uleb128 (&dp);
  off = unw_decode_uleb128 (&dp);

  qp = (byte1 & 0x3f);
  abreg = (byte2 & 0x7f);

  if (byte1 & 0x80)
    UNW_DEC_SPILL_SPREL_P(X3, qp, t, abreg, off, arg);
  else
    UNW_DEC_SPILL_PSPREL_P(X3, qp, t, abreg, off, arg);
  return dp;
}

static unsigned char *
unw_decode_x4 (unsigned char *dp, unsigned char code, void *arg)
{
  unsigned char byte1, byte2, byte3, qp, abreg, x, ytreg;
  unw_word t;

  byte1 = *dp++; byte2 = *dp++; byte3 = *dp++;
  t = unw_decode_uleb128 (&dp);

  qp = (byte1 & 0x3f);
  abreg = (byte2 & 0x7f);
  x = (byte2 >> 7) & 1;
  ytreg = byte3;

  if ((byte2 & 0x80) == 0 && byte3 == 0)
    UNW_DEC_RESTORE_P(X4, qp, t, abreg, arg);
  else
    UNW_DEC_SPILL_REG_P(X4, qp, t, abreg, x, ytreg, arg);
  return dp;
}

static unsigned char *
unw_decode_r1 (unsigned char *dp, unsigned char code, void *arg)
{
  int body = (code & 0x20) != 0;
  unw_word rlen;

  rlen = (code & 0x1f);
  UNW_DEC_PROLOGUE(R1, body, rlen, arg);
  return dp;
}

static unsigned char *
unw_decode_r2 (unsigned char *dp, unsigned char code, void *arg)
{
  unsigned char byte1, mask, grsave;
  unw_word rlen;

  byte1 = *dp++;

  mask = ((code & 0x7) << 1) | ((byte1 >> 7) & 1);
  grsave = (byte1 & 0x7f);
  rlen = unw_decode_uleb128 (&dp);
  UNW_DEC_PROLOGUE_GR(R2, rlen, mask, grsave, arg);
  return dp;
}

static unsigned char *
unw_decode_r3 (unsigned char *dp, unsigned char code, void *arg)
{
  unw_word rlen;

  rlen = unw_decode_uleb128 (&dp);
  UNW_DEC_PROLOGUE(R3, ((code & 0x3) == 1), rlen, arg);
  return dp;
}

static unsigned char *
unw_decode_p1 (unsigned char *dp, unsigned char code, void *arg)
{
  unsigned char brmask = (code & 0x1f);

  UNW_DEC_BR_MEM(P1, brmask, arg);
  return dp;
}

static unsigned char *
unw_decode_p2_p5 (unsigned char *dp, unsigned char code, void *arg)
{
  if ((code & 0x10) == 0)
    {
      unsigned char byte1 = *dp++;

      UNW_DEC_BR_GR(P2, ((code & 0xf) << 1) | ((byte1 >> 7) & 1),
                    (byte1 & 0x7f), arg);
    }
  else if ((code & 0x08) == 0)
    {
      unsigned char byte1 = *dp++, r, dst;

      r = ((code & 0x7) << 1) | ((byte1 >> 7) & 1);
      dst = (byte1 & 0x7f);
      switch (r)
        {
        case 0: UNW_DEC_REG_GR(P3, UNW_REG_PSP, dst, arg); break;
        case 1: UNW_DEC_REG_GR(P3, UNW_REG_RP, dst, arg); break;
        case 2: UNW_DEC_REG_GR(P3, UNW_REG_PFS, dst, arg); break;
        case 3: UNW_DEC_REG_GR(P3, UNW_REG_PR, dst, arg); break;
        case 4: UNW_DEC_REG_GR(P3, UNW_REG_UNAT, dst, arg); break;
        case 5: UNW_DEC_REG_GR(P3, UNW_REG_LC, dst, arg); break;
        case 6: UNW_DEC_RP_BR(P3, dst, arg); break;
        case 7: UNW_DEC_REG_GR(P3, UNW_REG_RNAT, dst, arg); break;
        case 8: UNW_DEC_REG_GR(P3, UNW_REG_BSP, dst, arg); break;
        case 9: UNW_DEC_REG_GR(P3, UNW_REG_BSPSTORE, dst, arg); break;
        case 10: UNW_DEC_REG_GR(P3, UNW_REG_FPSR, dst, arg); break;
        case 11: UNW_DEC_PRIUNAT_GR(P3, dst, arg); break;
        default: UNW_DEC_BAD_CODE(r); break;
        }
    }
  else if ((code & 0x7) == 0)
    UNW_DEC_SPILL_MASK(P4, dp, arg);
  else if ((code & 0x7) == 1)
    {
      unw_word grmask, frmask, byte1, byte2, byte3;

      byte1 = *dp++; byte2 = *dp++; byte3 = *dp++;
      grmask = ((byte1 >> 4) & 0xf);
      frmask = ((byte1 & 0xf) << 16) | (byte2 << 8) | byte3;
      UNW_DEC_FRGR_MEM(P5, grmask, frmask, arg);
    }
  else
    UNW_DEC_BAD_CODE(code);
  return dp;
}

static unsigned char *
unw_decode_p6 (unsigned char *dp, unsigned char code, void *arg)
{
  int gregs = (code & 0x10) != 0;
  unsigned char mask = (code & 0x0f);

  if (gregs)
    UNW_DEC_GR_MEM(P6, mask, arg);
  else
    UNW_DEC_FR_MEM(P6, mask, arg);
  return dp;
}

static unsigned char *
unw_decode_p7_p10 (unsigned char *dp, unsigned char code, void *arg)
{
  unsigned char r, byte1, byte2;
  unw_word t, size;

  if ((code & 0x10) == 0)
    {
      r = (code & 0xf);
      t = unw_decode_uleb128 (&dp);
      switch (r)
        {
        case 0:
          size = unw_decode_uleb128 (&dp);
          UNW_DEC_MEM_STACK_F(P7, t, size, arg);
          break;

        case 1: UNW_DEC_MEM_STACK_V(P7, t, arg); break;
        case 2: UNW_DEC_SPILL_BASE(P7, t, arg); break;
        case 3: UNW_DEC_REG_SPREL(P7, UNW_REG_PSP, t, arg); break;
        case 4: UNW_DEC_REG_WHEN(P7, UNW_REG_RP, t, arg); break;
        case 5: UNW_DEC_REG_PSPREL(P7, UNW_REG_RP, t, arg); break;
        case 6: UNW_DEC_REG_WHEN(P7, UNW_REG_PFS, t, arg); break;
        case 7: UNW_DEC_REG_PSPREL(P7, UNW_REG_PFS, t, arg); break;
        case 8: UNW_DEC_REG_WHEN(P7, UNW_REG_PR, t, arg); break;
        case 9: UNW_DEC_REG_PSPREL(P7, UNW_REG_PR, t, arg); break;
        case 10: UNW_DEC_REG_WHEN(P7, UNW_REG_LC, t, arg); break;
        case 11: UNW_DEC_REG_PSPREL(P7, UNW_REG_LC, t, arg); break;
        case 12: UNW_DEC_REG_WHEN(P7, UNW_REG_UNAT, t, arg); break;
        case 13: UNW_DEC_REG_PSPREL(P7, UNW_REG_UNAT, t, arg); break;
        case 14: UNW_DEC_REG_WHEN(P7, UNW_REG_FPSR, t, arg); break;
        case 15: UNW_DEC_REG_PSPREL(P7, UNW_REG_FPSR, t, arg); break;
        default: UNW_DEC_BAD_CODE(r); break;
        }
    }
  else
    {
      switch (code & 0xf)
        {
        case 0x0: /* p8 */
          {
            r = *dp++;
            t = unw_decode_uleb128 (&dp);
            switch (r)
              {
              case  1: UNW_DEC_REG_SPREL(P8, UNW_REG_RP, t, arg); break;
              case  2: UNW_DEC_REG_SPREL(P8, UNW_REG_PFS, t, arg); break;
              case  3: UNW_DEC_REG_SPREL(P8, UNW_REG_PR, t, arg); break;
              case  4: UNW_DEC_REG_SPREL(P8, UNW_REG_LC, t, arg); break;
              case  5: UNW_DEC_REG_SPREL(P8, UNW_REG_UNAT, t, arg); break;
              case  6: UNW_DEC_REG_SPREL(P8, UNW_REG_FPSR, t, arg); break;
              case  7: UNW_DEC_REG_WHEN(P8, UNW_REG_BSP, t, arg); break;
              case  8: UNW_DEC_REG_PSPREL(P8, UNW_REG_BSP, t, arg); break;
              case  9: UNW_DEC_REG_SPREL(P8, UNW_REG_BSP, t, arg); break;
              case 10: UNW_DEC_REG_WHEN(P8, UNW_REG_BSPSTORE, t, arg); break;
              case 11: UNW_DEC_REG_PSPREL(P8, UNW_REG_BSPSTORE, t, arg); break;
              case 12: UNW_DEC_REG_SPREL(P8, UNW_REG_BSPSTORE, t, arg); break;
              case 13: UNW_DEC_REG_WHEN(P8, UNW_REG_RNAT, t, arg); break;
              case 14: UNW_DEC_REG_PSPREL(P8, UNW_REG_RNAT, t, arg); break;
              case 15: UNW_DEC_REG_SPREL(P8, UNW_REG_RNAT, t, arg); break;
              case 16: UNW_DEC_PRIUNAT_WHEN_GR(P8, t, arg); break;
              case 17: UNW_DEC_PRIUNAT_PSPREL(P8, t, arg); break;
              case 18: UNW_DEC_PRIUNAT_SPREL(P8, t, arg); break;
              case 19: UNW_DEC_PRIUNAT_WHEN_MEM(P8, t, arg); break;
              default: UNW_DEC_BAD_CODE(r); break;
            }
          }
          break;

        case 0x1:
          byte1 = *dp++; byte2 = *dp++;
          UNW_DEC_GR_GR(P9, (byte1 & 0xf), (byte2 & 0x7f), arg);
          break;

        case 0xf: /* p10 */
          byte1 = *dp++; byte2 = *dp++;
          UNW_DEC_ABI(P10, byte1, byte2, arg);
          break;

        case 0x9:
          return unw_decode_x1 (dp, code, arg);

        case 0xa:
          return unw_decode_x2 (dp, code, arg);

        case 0xb:
          return unw_decode_x3 (dp, code, arg);

        case 0xc:
          return unw_decode_x4 (dp, code, arg);

        default:
          UNW_DEC_BAD_CODE(code);
          break;
        }
    }
  return dp;
}

static unsigned char *
unw_decode_b1 (unsigned char *dp, unsigned char code, void *arg)
{
  unw_word label = (code & 0x1f);

  if ((code & 0x20) != 0)
    UNW_DEC_COPY_STATE(B1, label, arg);
  else
    UNW_DEC_LABEL_STATE(B1, label, arg);
  return dp;
}

static unsigned char *
unw_decode_b2 (unsigned char *dp, unsigned char code, void *arg)
{
  unw_word t;

  t = unw_decode_uleb128 (&dp);
  UNW_DEC_EPILOGUE(B2, t, (code & 0x1f), arg);
  return dp;
}

static unsigned char *
unw_decode_b3_x4 (unsigned char *dp, unsigned char code, void *arg)
{
  unw_word t, ecount, label;

  if ((code & 0x10) == 0)
    {
      t = unw_decode_uleb128 (&dp);
      ecount = unw_decode_uleb128 (&dp);
      UNW_DEC_EPILOGUE(B3, t, ecount, arg);
    }
  else if ((code & 0x07) == 0)
    {
      label = unw_decode_uleb128 (&dp);
      if ((code & 0x08) != 0)
        UNW_DEC_COPY_STATE(B4, label, arg);
      else
        UNW_DEC_LABEL_STATE(B4, label, arg);
    }
  else
    switch (code & 0x7)
      {
      case 1: return unw_decode_x1 (dp, code, arg);
      case 2: return unw_decode_x2 (dp, code, arg);
      case 3: return unw_decode_x3 (dp, code, arg);
      case 4: return unw_decode_x4 (dp, code, arg);
      default: UNW_DEC_BAD_CODE(code); break;
      }
  return dp;
}

typedef unsigned char *(*unw_decoder) (unsigned char *, unsigned char, void *);

static unw_decoder unw_decode_table[2][8] =
{
  /* prologue table: */
  {
    unw_decode_r1,	/* 0 */
    unw_decode_r1,
    unw_decode_r2,
    unw_decode_r3,
    unw_decode_p1,	/* 4 */
    unw_decode_p2_p5,
    unw_decode_p6,
    unw_decode_p7_p10
  },
  {
    unw_decode_r1,	/* 0 */
    unw_decode_r1,
    unw_decode_r2,
    unw_decode_r3,
    unw_decode_b1,	/* 4 */
    unw_decode_b1,
    unw_decode_b2,
    unw_decode_b3_x4
  }
};

/*
 * Decode one descriptor and return address of next descriptor.
 */
static inline unsigned char *
unw_decode (unsigned char *dp, int inside_body, void *arg)
{
  unw_decoder decoder;
  unsigned char code;

  code = *dp++;
  decoder = unw_decode_table[inside_body][code >> 5];
  dp = (*decoder) (dp, code, arg);
  return dp;
}

<MSG> (unw_decode_r1): "inline" it.
(unw_decode_r2): Likewise.
(unw_decode_r3): Likewise.
(unw_decode_p1): Likewise.
(unw_decode_p2_p5): Likewise.
(unw_decode_p6): Likewise.
(unw_decode_p7_p10): Likewise.
(unw_decode_b1): Likewise.
(unw_decode_b3_x4): Likewise.
(unw_decode_table): Remove.
(unw_decode): Do the first-level of decoding inline, rather than
	through the unw_decode_table.

(Logical change 1.148)

<DFF> @@ -179,7 +179,7 @@ unw_decode_x4 (unsigned char *dp, unsigned char code, void *arg)
   return dp;
 }
 
-static unsigned char *
+static inline unsigned char *
 unw_decode_r1 (unsigned char *dp, unsigned char code, void *arg)
 {
   int body = (code & 0x20) != 0;
@@ -190,7 +190,7 @@ unw_decode_r1 (unsigned char *dp, unsigned char code, void *arg)
   return dp;
 }
 
-static unsigned char *
+static inline unsigned char *
 unw_decode_r2 (unsigned char *dp, unsigned char code, void *arg)
 {
   unsigned char byte1, mask, grsave;
@@ -205,7 +205,7 @@ unw_decode_r2 (unsigned char *dp, unsigned char code, void *arg)
   return dp;
 }
 
-static unsigned char *
+static inline unsigned char *
 unw_decode_r3 (unsigned char *dp, unsigned char code, void *arg)
 {
   unw_word rlen;
@@ -215,7 +215,7 @@ unw_decode_r3 (unsigned char *dp, unsigned char code, void *arg)
   return dp;
 }
 
-static unsigned char *
+static inline unsigned char *
 unw_decode_p1 (unsigned char *dp, unsigned char code, void *arg)
 {
   unsigned char brmask = (code & 0x1f);
@@ -224,7 +224,7 @@ unw_decode_p1 (unsigned char *dp, unsigned char code, void *arg)
   return dp;
 }
 
-static unsigned char *
+static inline unsigned char *
 unw_decode_p2_p5 (unsigned char *dp, unsigned char code, void *arg)
 {
   if ((code & 0x10) == 0)
@@ -273,7 +273,7 @@ unw_decode_p2_p5 (unsigned char *dp, unsigned char code, void *arg)
   return dp;
 }
 
-static unsigned char *
+static inline unsigned char *
 unw_decode_p6 (unsigned char *dp, unsigned char code, void *arg)
 {
   int gregs = (code & 0x10) != 0;
@@ -286,7 +286,7 @@ unw_decode_p6 (unsigned char *dp, unsigned char code, void *arg)
   return dp;
 }
 
-static unsigned char *
+static inline unsigned char *
 unw_decode_p7_p10 (unsigned char *dp, unsigned char code, void *arg)
 {
   unsigned char r, byte1, byte2;
@@ -385,7 +385,7 @@ unw_decode_p7_p10 (unsigned char *dp, unsigned char code, void *arg)
   return dp;
 }
 
-static unsigned char *
+static inline unsigned char *
 unw_decode_b1 (unsigned char *dp, unsigned char code, void *arg)
 {
   unw_word label = (code & 0x1f);
@@ -397,7 +397,7 @@ unw_decode_b1 (unsigned char *dp, unsigned char code, void *arg)
   return dp;
 }
 
-static unsigned char *
+static inline unsigned char *
 unw_decode_b2 (unsigned char *dp, unsigned char code, void *arg)
 {
   unw_word t;
@@ -407,7 +407,7 @@ unw_decode_b2 (unsigned char *dp, unsigned char code, void *arg)
   return dp;
 }
 
-static unsigned char *
+static inline unsigned char *
 unw_decode_b3_x4 (unsigned char *dp, unsigned char code, void *arg)
 {
   unw_word t, ecount, label;
@@ -440,42 +440,38 @@ unw_decode_b3_x4 (unsigned char *dp, unsigned char code, void *arg)
 
 typedef unsigned char *(*unw_decoder) (unsigned char *, unsigned char, void *);
 
-static unw_decoder unw_decode_table[2][8] =
-{
-  /* prologue table: */
-  {
-    unw_decode_r1,	/* 0 */
-    unw_decode_r1,
-    unw_decode_r2,
-    unw_decode_r3,
-    unw_decode_p1,	/* 4 */
-    unw_decode_p2_p5,
-    unw_decode_p6,
-    unw_decode_p7_p10
-  },
-  {
-    unw_decode_r1,	/* 0 */
-    unw_decode_r1,
-    unw_decode_r2,
-    unw_decode_r3,
-    unw_decode_b1,	/* 4 */
-    unw_decode_b1,
-    unw_decode_b2,
-    unw_decode_b3_x4
-  }
-};
-
 /*
  * Decode one descriptor and return address of next descriptor.
  */
 static inline unsigned char *
 unw_decode (unsigned char *dp, int inside_body, void *arg)
 {
-  unw_decoder decoder;
-  unsigned char code;
+  unsigned char code, primary;
 
   code = *dp++;
-  decoder = unw_decode_table[inside_body][code >> 5];
-  dp = (*decoder) (dp, code, arg);
+  primary = code >> 5;
+
+  if (primary < 2)
+    dp = unw_decode_r1 (dp, code, arg);
+  else if (primary == 2)
+    dp = unw_decode_r2 (dp, code, arg);
+  else if (primary == 3)
+    dp = unw_decode_r3 (dp, code, arg);
+  else if (inside_body)
+    switch (primary)
+      {
+      case 4:
+      case 5: dp = unw_decode_b1 (dp, code, arg); break;
+      case 6: dp = unw_decode_b2 (dp, code, arg); break;
+      case 7: dp = unw_decode_b3_x4 (dp, code, arg); break;
+      }
+  else
+    switch (primary)
+      {
+      case 4: dp = unw_decode_p1 (dp, code, arg); break;
+      case 5: dp = unw_decode_p2_p5 (dp, code, arg); break;
+      case 6: dp = unw_decode_p6 (dp, code, arg); break;
+      case 7: dp = unw_decode_p7_p10 (dp, code, arg); break;
+      }
   return dp;
 }

{'commit': 'diff --git a/src/ia64/unwind_decoder.h b/src/ia64/unwind_decoder.h\nindex afd7fecc..f12c21d1 100644\n--- a/src/ia64/unwind_decoder.h\n+++ b/src/ia64/unwind_decoder.h\n@@ -179,7 +179,7 @@ unw_decode_x4 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_r1 (unsigned char *dp, unsigned char code, void *arg)\n {\n   int body = (code & 0x20) != 0;\n@@ -190,7 +190,7 @@ unw_decode_r1 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_r2 (unsigned char *dp, unsigned char code, void *arg)\n {\n   unsigned char byte1, mask, grsave;\n@@ -205,7 +205,7 @@ unw_decode_r2 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_r3 (unsigned char *dp, unsigned char code, void *arg)\n {\n   unw_word rlen;\n@@ -215,7 +215,7 @@ unw_decode_r3 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_p1 (unsigned char *dp, unsigned char code, void *arg)\n {\n   unsigned char brmask = (code & 0x1f);\n@@ -224,7 +224,7 @@ unw_decode_p1 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_p2_p5 (unsigned char *dp, unsigned char code, void *arg)\n {\n   if ((code & 0x10) == 0)\n@@ -273,7 +273,7 @@ unw_decode_p2_p5 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_p6 (unsigned char *dp, unsigned char code, void *arg)\n {\n   int gregs = (code & 0x10) != 0;\n@@ -286,7 +286,7 @@ unw_decode_p6 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_p7_p10 (unsigned char *dp, unsigned char code, void *arg)\n {\n   unsigned char r, byte1, byte2;\n@@ -385,7 +385,7 @@ unw_decode_p7_p10 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_b1 (unsigned char *dp, unsigned char code, void *arg)\n {\n   unw_word label = (code & 0x1f);\n@@ -397,7 +397,7 @@ unw_decode_b1 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_b2 (unsigned char *dp, unsigned char code, void *arg)\n {\n   unw_word t;\n@@ -407,7 +407,7 @@ unw_decode_b2 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_b3_x4 (unsigned char *dp, unsigned char code, void *arg)\n {\n   unw_word t, ecount, label;\n@@ -440,42 +440,38 @@ unw_decode_b3_x4 (unsigned char *dp, unsigned char code, void *arg)\n \n typedef unsigned char *(*unw_decoder) (unsigned char *, unsigned char, void *);\n \n-static unw_decoder unw_decode_table[2][8] =\n-{\n-  /* prologue table: */\n-  {\n-    unw_decode_r1,\t/* 0 */\n-    unw_decode_r1,\n-    unw_decode_r2,\n-    unw_decode_r3,\n-    unw_decode_p1,\t/* 4 */\n-    unw_decode_p2_p5,\n-    unw_decode_p6,\n-    unw_decode_p7_p10\n-  },\n-  {\n-    unw_decode_r1,\t/* 0 */\n-    unw_decode_r1,\n-    unw_decode_r2,\n-    unw_decode_r3,\n-    unw_decode_b1,\t/* 4 */\n-    unw_decode_b1,\n-    unw_decode_b2,\n-    unw_decode_b3_x4\n-  }\n-};\n-\n /*\n  * Decode one descriptor and return address of next descriptor.\n  */\n static inline unsigned char *\n unw_decode (unsigned char *dp, int inside_body, void *arg)\n {\n-  unw_decoder decoder;\n-  unsigned char code;\n+  unsigned char code, primary;\n \n   code = *dp++;\n-  decoder = unw_decode_table[inside_body][code >> 5];\n-  dp = (*decoder) (dp, code, arg);\n+  primary = code >> 5;\n+\n+  if (primary < 2)\n+    dp = unw_decode_r1 (dp, code, arg);\n+  else if (primary == 2)\n+    dp = unw_decode_r2 (dp, code, arg);\n+  else if (primary == 3)\n+    dp = unw_decode_r3 (dp, code, arg);\n+  else if (inside_body)\n+    switch (primary)\n+      {\n+      case 4:\n+      case 5: dp = unw_decode_b1 (dp, code, arg); break;\n+      case 6: dp = unw_decode_b2 (dp, code, arg); break;\n+      case 7: dp = unw_decode_b3_x4 (dp, code, arg); break;\n+      }\n+  else\n+    switch (primary)\n+      {\n+      case 4: dp = unw_decode_p1 (dp, code, arg); break;\n+      case 5: dp = unw_decode_p2_p5 (dp, code, arg); break;\n+      case 6: dp = unw_decode_p6 (dp, code, arg); break;\n+      case 7: dp = unw_decode_p7_p10 (dp, code, arg); break;\n+      }\n   return dp;\n }\n', 'commit_subject': '(unw_decode_r1): "inline" it. (unw_decode_r2): Likewise. (unw_decode_r3): Likewise. (unw_decode_p1): Likewise. (unw_decode_p2_p5): Likewise. (unw_decode_p6): Likewise. (unw_decode_p7_p10): Likewise. (unw_decode_b1): Likewise. (unw_decode_b3_x4): Likewise. (unw_decode_table): Remove. (unw_decode): Do the first-level of decoding inline, rather than \tthrough the unw_decode_table.', 'repo_name': 'libunwind/libunwind', 'committer': {'name': 'mostang.com!davidm', 'email': 'mostang.com!davidm', 'time_sec': '1071991288', 'tz_offset': '0', 'date': {'seconds': '1071991288'}}, 'commit_tree': '15496ff9936c3a2d8ccbadc4aa2c3348de50df99', 'commit_message': '(unw_decode_r1): "inline" it.\n(unw_decode_r2): Likewise.\n(unw_decode_r3): Likewise.\n(unw_decode_p1): Likewise.\n(unw_decode_p2_p5): Likewise.\n(unw_decode_p6): Likewise.\n(unw_decode_p7_p10): Likewise.\n(unw_decode_b1): Likewise.\n(unw_decode_b3_x4): Likewise.\n(unw_decode_table): Remove.\n(unw_decode): Do the first-level of decoding inline, rather than\n\tthrough the unw_decode_table.\n\n(Logical change 1.148)\n', 'language_name': 'C', 'license': 'mit', 'hunks': '@@ -179,7 +179,7 @@ unw_decode_x4 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_r1 (unsigned char *dp, unsigned char code, void *arg)\n {\n   int body = (code & 0x20) != 0;\n@@ -190,7 +190,7 @@ unw_decode_r1 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_r2 (unsigned char *dp, unsigned char code, void *arg)\n {\n   unsigned char byte1, mask, grsave;\n@@ -205,7 +205,7 @@ unw_decode_r2 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_r3 (unsigned char *dp, unsigned char code, void *arg)\n {\n   unw_word rlen;\n@@ -215,7 +215,7 @@ unw_decode_r3 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_p1 (unsigned char *dp, unsigned char code, void *arg)\n {\n   unsigned char brmask = (code & 0x1f);\n@@ -224,7 +224,7 @@ unw_decode_p1 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_p2_p5 (unsigned char *dp, unsigned char code, void *arg)\n {\n   if ((code & 0x10) == 0)\n@@ -273,7 +273,7 @@ unw_decode_p2_p5 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_p6 (unsigned char *dp, unsigned char code, void *arg)\n {\n   int gregs = (code & 0x10) != 0;\n@@ -286,7 +286,7 @@ unw_decode_p6 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_p7_p10 (unsigned char *dp, unsigned char code, void *arg)\n {\n   unsigned char r, byte1, byte2;\n@@ -385,7 +385,7 @@ unw_decode_p7_p10 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_b1 (unsigned char *dp, unsigned char code, void *arg)\n {\n   unw_word label = (code & 0x1f);\n@@ -397,7 +397,7 @@ unw_decode_b1 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_b2 (unsigned char *dp, unsigned char code, void *arg)\n {\n   unw_word t;\n@@ -407,7 +407,7 @@ unw_decode_b2 (unsigned char *dp, unsigned char code, void *arg)\n   return dp;\n }\n \n-static unsigned char *\n+static inline unsigned char *\n unw_decode_b3_x4 (unsigned char *dp, unsigned char code, void *arg)\n {\n   unw_word t, ecount, label;\n@@ -440,42 +440,38 @@ unw_decode_b3_x4 (unsigned char *dp, unsigned char code, void *arg)\n \n typedef unsigned char *(*unw_decoder) (unsigned char *, unsigned char, void *);\n \n-static unw_decoder unw_decode_table[2][8] =\n-{\n-  /* prologue table: */\n-  {\n-    unw_decode_r1,\t/* 0 */\n-    unw_decode_r1,\n-    unw_decode_r2,\n-    unw_decode_r3,\n-    unw_decode_p1,\t/* 4 */\n-    unw_decode_p2_p5,\n-    unw_decode_p6,\n-    unw_decode_p7_p10\n-  },\n-  {\n-    unw_decode_r1,\t/* 0 */\n-    unw_decode_r1,\n-    unw_decode_r2,\n-    unw_decode_r3,\n-    unw_decode_b1,\t/* 4 */\n-    unw_decode_b1,\n-    unw_decode_b2,\n-    unw_decode_b3_x4\n-  }\n-};\n-\n /*\n  * Decode one descriptor and return address of next descriptor.\n  */\n static inline unsigned char *\n unw_decode (unsigned char *dp, int inside_body, void *arg)\n {\n-  unw_decoder decoder;\n-  unsigned char code;\n+  unsigned char code, primary;\n \n   code = *dp++;\n-  decoder = unw_decode_table[inside_body][code >> 5];\n-  dp = (*decoder) (dp, code, arg);\n+  primary = code >> 5;\n+\n+  if (primary < 2)\n+    dp = unw_decode_r1 (dp, code, arg);\n+  else if (primary == 2)\n+    dp = unw_decode_r2 (dp, code, arg);\n+  else if (primary == 3)\n+    dp = unw_decode_r3 (dp, code, arg);\n+  else if (inside_body)\n+    switch (primary)\n+      {\n+      case 4:\n+      case 5: dp = unw_decode_b1 (dp, code, arg); break;\n+      case 6: dp = unw_decode_b2 (dp, code, arg); break;\n+      case 7: dp = unw_decode_b3_x4 (dp, code, arg); break;\n+      }\n+  else\n+    switch (primary)\n+      {\n+      case 4: dp = unw_decode_p1 (dp, code, arg); break;\n+      case 5: dp = unw_decode_p2_p5 (dp, code, arg); break;\n+      case 6: dp = unw_decode_p6 (dp, code, arg); break;\n+      case 7: dp = unw_decode_p7_p10 (dp, code, arg); break;\n+      }\n   return dp;\n }\n', 'addition_count': 35, 'deletion_count': 39, 'src_file': 'a/src/ia64/unwind_decoder.h', 'tgt_file': 'b/src/ia64/unwind_decoder.h', 'file_extension': '.h', 'before_file': '/* libunwind - a platform-independent unwind library\n   Copyright (C) 2001-2002 Hewlett-Packard Co\n        Contributed by David Mosberger-Tang <davidm@hpl.hp.com>\n\nThis file is part of libunwind.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n"Software"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */\n\n/*\n * Generic IA-64 unwind info decoder.\n *\n * This file is used both by the Linux kernel and objdump.  Please keep\n * the two copies of this file in sync.\n *\n * You need to customize the decoder by defining the following\n * macros/constants before including this file:\n *\n *  Types:\n *      unw_word        Unsigned integer type with at least 64 bits\n *\n *  Register names:\n *      UNW_REG_BSP\n *      UNW_REG_BSPSTORE\n *      UNW_REG_FPSR\n *      UNW_REG_LC\n *      UNW_REG_PFS\n *      UNW_REG_PR\n *      UNW_REG_RNAT\n *      UNW_REG_PSP\n *      UNW_REG_RP\n *      UNW_REG_UNAT\n *\n *  Decoder action macros:\n *      UNW_DEC_BAD_CODE(code)\n *      UNW_DEC_ABI(fmt,abi,context,arg)\n *      UNW_DEC_BR_GR(fmt,brmask,gr,arg)\n *      UNW_DEC_BR_MEM(fmt,brmask,arg)\n *      UNW_DEC_COPY_STATE(fmt,label,arg)\n *      UNW_DEC_EPILOGUE(fmt,t,ecount,arg)\n *      UNW_DEC_FRGR_MEM(fmt,grmask,frmask,arg)\n *      UNW_DEC_FR_MEM(fmt,frmask,arg)\n *      UNW_DEC_GR_GR(fmt,grmask,gr,arg)\n *      UNW_DEC_GR_MEM(fmt,grmask,arg)\n *      UNW_DEC_LABEL_STATE(fmt,label,arg)\n *      UNW_DEC_MEM_STACK_F(fmt,t,size,arg)\n *      UNW_DEC_MEM_STACK_V(fmt,t,arg)\n *      UNW_DEC_PRIUNAT_GR(fmt,r,arg)\n *      UNW_DEC_PRIUNAT_WHEN_GR(fmt,t,arg)\n *      UNW_DEC_PRIUNAT_WHEN_MEM(fmt,t,arg)\n *      UNW_DEC_PRIUNAT_WHEN_PSPREL(fmt,pspoff,arg)\n *      UNW_DEC_PRIUNAT_WHEN_SPREL(fmt,spoff,arg)\n *      UNW_DEC_PROLOGUE(fmt,body,rlen,arg)\n *      UNW_DEC_PROLOGUE_GR(fmt,rlen,mask,grsave,arg)\n *      UNW_DEC_REG_PSPREL(fmt,reg,pspoff,arg)\n *      UNW_DEC_REG_REG(fmt,src,dst,arg)\n *      UNW_DEC_REG_SPREL(fmt,reg,spoff,arg)\n *      UNW_DEC_REG_WHEN(fmt,reg,t,arg)\n *      UNW_DEC_RESTORE(fmt,t,abreg,arg)\n *      UNW_DEC_RESTORE_P(fmt,qp,t,abreg,arg)\n *      UNW_DEC_SPILL_BASE(fmt,pspoff,arg)\n *      UNW_DEC_SPILL_MASK(fmt,imaskp,arg)\n *      UNW_DEC_SPILL_PSPREL(fmt,t,abreg,pspoff,arg)\n *      UNW_DEC_SPILL_PSPREL_P(fmt,qp,t,abreg,pspoff,arg)\n *      UNW_DEC_SPILL_REG(fmt,t,abreg,x,ytreg,arg)\n *      UNW_DEC_SPILL_REG_P(fmt,qp,t,abreg,x,ytreg,arg)\n *      UNW_DEC_SPILL_SPREL(fmt,t,abreg,spoff,arg)\n *      UNW_DEC_SPILL_SPREL_P(fmt,qp,t,abreg,pspoff,arg)\n */\n\nstatic unw_word\nunw_decode_uleb128 (unsigned char **dpp)\n{\n  unsigned shift = 0;\n  unw_word byte, result = 0;\n  unsigned char *bp = *dpp;\n\n  while (1)\n    {\n      byte = *bp++;\n      result |= (byte & 0x7f) << shift;\n      if ((byte & 0x80) == 0)\n        break;\n      shift += 7;\n    }\n  *dpp = bp;\n  return result;\n}\n\nstatic unsigned char *\nunw_decode_x1 (unsigned char *dp, unsigned char code, void *arg)\n{\n  unsigned char byte1, abreg;\n  unw_word t, off;\n\n  byte1 = *dp++;\n  t = unw_decode_uleb128 (&dp);\n  off = unw_decode_uleb128 (&dp);\n  abreg = (byte1 & 0x7f);\n  if (byte1 & 0x80)\n          UNW_DEC_SPILL_SPREL(X1, t, abreg, off, arg);\n  else\n          UNW_DEC_SPILL_PSPREL(X1, t, abreg, off, arg);\n  return dp;\n}\n\nstatic unsigned char *\nunw_decode_x2 (unsigned char *dp, unsigned char code, void *arg)\n{\n  unsigned char byte1, byte2, abreg, x, ytreg;\n  unw_word t;\n\n  byte1 = *dp++; byte2 = *dp++;\n  t = unw_decode_uleb128 (&dp);\n  abreg = (byte1 & 0x7f);\n  ytreg = byte2;\n  x = (byte1 >> 7) & 1;\n  if ((byte1 & 0x80) == 0 && ytreg == 0)\n    UNW_DEC_RESTORE(X2, t, abreg, arg);\n  else\n    UNW_DEC_SPILL_REG(X2, t, abreg, x, ytreg, arg);\n  return dp;\n}\n\nstatic unsigned char *\nunw_decode_x3 (unsigned char *dp, unsigned char code, void *arg)\n{\n  unsigned char byte1, byte2, abreg, qp;\n  unw_word t, off;\n\n  byte1 = *dp++; byte2 = *dp++;\n  t = unw_decode_uleb128 (&dp);\n  off = unw_decode_uleb128 (&dp);\n\n  qp = (byte1 & 0x3f);\n  abreg = (byte2 & 0x7f);\n\n  if (byte1 & 0x80)\n    UNW_DEC_SPILL_SPREL_P(X3, qp, t, abreg, off, arg);\n  else\n    UNW_DEC_SPILL_PSPREL_P(X3, qp, t, abreg, off, arg);\n  return dp;\n}\n\nstatic unsigned char *\nunw_decode_x4 (unsigned char *dp, unsigned char code, void *arg)\n{\n  unsigned char byte1, byte2, byte3, qp, abreg, x, ytreg;\n  unw_word t;\n\n  byte1 = *dp++; byte2 = *dp++; byte3 = *dp++;\n  t = unw_decode_uleb128 (&dp);\n\n  qp = (byte1 & 0x3f);\n  abreg = (byte2 & 0x7f);\n  x = (byte2 >> 7) & 1;\n  ytreg = byte3;\n\n  if ((byte2 & 0x80) == 0 && byte3 == 0)\n    UNW_DEC_RESTORE_P(X4, qp, t, abreg, arg);\n  else\n    UNW_DEC_SPILL_REG_P(X4, qp, t, abreg, x, ytreg, arg);\n  return dp;\n}\n\nstatic unsigned char *\nunw_decode_r1 (unsigned char *dp, unsigned char code, void *arg)\n{\n  int body = (code & 0x20) != 0;\n  unw_word rlen;\n\n  rlen = (code & 0x1f);\n  UNW_DEC_PROLOGUE(R1, body, rlen, arg);\n  return dp;\n}\n\nstatic unsigned char *\nunw_decode_r2 (unsigned char *dp, unsigned char code, void *arg)\n{\n  unsigned char byte1, mask, grsave;\n  unw_word rlen;\n\n  byte1 = *dp++;\n\n  mask = ((code & 0x7) << 1) | ((byte1 >> 7) & 1);\n  grsave = (byte1 & 0x7f);\n  rlen = unw_decode_uleb128 (&dp);\n  UNW_DEC_PROLOGUE_GR(R2, rlen, mask, grsave, arg);\n  return dp;\n}\n\nstatic unsigned char *\nunw_decode_r3 (unsigned char *dp, unsigned char code, void *arg)\n{\n  unw_word rlen;\n\n  rlen = unw_decode_uleb128 (&dp);\n  UNW_DEC_PROLOGUE(R3, ((code & 0x3) == 1), rlen, arg);\n  return dp;\n}\n\nstatic unsigned char *\nunw_decode_p1 (unsigned char *dp, unsigned char code, void *arg)\n{\n  unsigned char brmask = (code & 0x1f);\n\n  UNW_DEC_BR_MEM(P1, brmask, arg);\n  return dp;\n}\n\nstatic unsigned char *\nunw_decode_p2_p5 (unsigned char *dp, unsigned char code, void *arg)\n{\n  if ((code & 0x10) == 0)\n    {\n      unsigned char byte1 = *dp++;\n\n      UNW_DEC_BR_GR(P2, ((code & 0xf) << 1) | ((byte1 >> 7) & 1),\n                    (byte1 & 0x7f), arg);\n    }\n  else if ((code & 0x08) == 0)\n    {\n      unsigned char byte1 = *dp++, r, dst;\n\n      r = ((code & 0x7) << 1) | ((byte1 >> 7) & 1);\n      dst = (byte1 & 0x7f);\n      switch (r)\n        {\n        case 0: UNW_DEC_REG_GR(P3, UNW_REG_PSP, dst, arg); break;\n        case 1: UNW_DEC_REG_GR(P3, UNW_REG_RP, dst, arg); break;\n        case 2: UNW_DEC_REG_GR(P3, UNW_REG_PFS, dst, arg); break;\n        case 3: UNW_DEC_REG_GR(P3, UNW_REG_PR, dst, arg); break;\n        case 4: UNW_DEC_REG_GR(P3, UNW_REG_UNAT, dst, arg); break;\n        case 5: UNW_DEC_REG_GR(P3, UNW_REG_LC, dst, arg); break;\n        case 6: UNW_DEC_RP_BR(P3, dst, arg); break;\n        case 7: UNW_DEC_REG_GR(P3, UNW_REG_RNAT, dst, arg); break;\n        case 8: UNW_DEC_REG_GR(P3, UNW_REG_BSP, dst, arg); break;\n        case 9: UNW_DEC_REG_GR(P3, UNW_REG_BSPSTORE, dst, arg); break;\n        case 10: UNW_DEC_REG_GR(P3, UNW_REG_FPSR, dst, arg); break;\n        case 11: UNW_DEC_PRIUNAT_GR(P3, dst, arg); break;\n        default: UNW_DEC_BAD_CODE(r); break;\n        }\n    }\n  else if ((code & 0x7) == 0)\n    UNW_DEC_SPILL_MASK(P4, dp, arg);\n  else if ((code & 0x7) == 1)\n    {\n      unw_word grmask, frmask, byte1, byte2, byte3;\n\n      byte1 = *dp++; byte2 = *dp++; byte3 = *dp++;\n      grmask = ((byte1 >> 4) & 0xf);\n      frmask = ((byte1 & 0xf) << 16) | (byte2 << 8) | byte3;\n      UNW_DEC_FRGR_MEM(P5, grmask, frmask, arg);\n    }\n  else\n    UNW_DEC_BAD_CODE(code);\n  return dp;\n}\n\nstatic unsigned char *\nunw_decode_p6 (unsigned char *dp, unsigned char code, void *arg)\n{\n  int gregs = (code & 0x10) != 0;\n  unsigned char mask = (code & 0x0f);\n\n  if (gregs)\n    UNW_DEC_GR_MEM(P6, mask, arg);\n  else\n    UNW_DEC_FR_MEM(P6, mask, arg);\n  return dp;\n}\n\nstatic unsigned char *\nunw_decode_p7_p10 (unsigned char *dp, unsigned char code, void *arg)\n{\n  unsigned char r, byte1, byte2;\n  unw_word t, size;\n\n  if ((code & 0x10) == 0)\n    {\n      r = (code & 0xf);\n      t = unw_decode_uleb128 (&dp);\n      switch (r)\n        {\n        case 0:\n          size = unw_decode_uleb128 (&dp);\n          UNW_DEC_MEM_STACK_F(P7, t, size, arg);\n          break;\n\n        case 1: UNW_DEC_MEM_STACK_V(P7, t, arg); break;\n        case 2: UNW_DEC_SPILL_BASE(P7, t, arg); break;\n        case 3: UNW_DEC_REG_SPREL(P7, UNW_REG_PSP, t, arg); break;\n        case 4: UNW_DEC_REG_WHEN(P7, UNW_REG_RP, t, arg); break;\n        case 5: UNW_DEC_REG_PSPREL(P7, UNW_REG_RP, t, arg); break;\n        case 6: UNW_DEC_REG_WHEN(P7, UNW_REG_PFS, t, arg); break;\n        case 7: UNW_DEC_REG_PSPREL(P7, UNW_REG_PFS, t, arg); break;\n        case 8: UNW_DEC_REG_WHEN(P7, UNW_REG_PR, t, arg); break;\n        case 9: UNW_DEC_REG_PSPREL(P7, UNW_REG_PR, t, arg); break;\n        case 10: UNW_DEC_REG_WHEN(P7, UNW_REG_LC, t, arg); break;\n        case 11: UNW_DEC_REG_PSPREL(P7, UNW_REG_LC, t, arg); break;\n        case 12: UNW_DEC_REG_WHEN(P7, UNW_REG_UNAT, t, arg); break;\n        case 13: UNW_DEC_REG_PSPREL(P7, UNW_REG_UNAT, t, arg); break;\n        case 14: UNW_DEC_REG_WHEN(P7, UNW_REG_FPSR, t, arg); break;\n        case 15: UNW_DEC_REG_PSPREL(P7, UNW_REG_FPSR, t, arg); break;\n        default: UNW_DEC_BAD_CODE(r); break;\n        }\n    }\n  else\n    {\n      switch (code & 0xf)\n        {\n        case 0x0: /* p8 */\n          {\n            r = *dp++;\n            t = unw_decode_uleb128 (&dp);\n            switch (r)\n              {\n              case  1: UNW_DEC_REG_SPREL(P8, UNW_REG_RP, t, arg); break;\n              case  2: UNW_DEC_REG_SPREL(P8, UNW_REG_PFS, t, arg); break;\n              case  3: UNW_DEC_REG_SPREL(P8, UNW_REG_PR, t, arg); break;\n              case  4: UNW_DEC_REG_SPREL(P8, UNW_REG_LC, t, arg); break;\n              case  5: UNW_DEC_REG_SPREL(P8, UNW_REG_UNAT, t, arg); break;\n              case  6: UNW_DEC_REG_SPREL(P8, UNW_REG_FPSR, t, arg); break;\n              case  7: UNW_DEC_REG_WHEN(P8, UNW_REG_BSP, t, arg); break;\n              case  8: UNW_DEC_REG_PSPREL(P8, UNW_REG_BSP, t, arg); break;\n              case  9: UNW_DEC_REG_SPREL(P8, UNW_REG_BSP, t, arg); break;\n              case 10: UNW_DEC_REG_WHEN(P8, UNW_REG_BSPSTORE, t, arg); break;\n              case 11: UNW_DEC_REG_PSPREL(P8, UNW_REG_BSPSTORE, t, arg); break;\n              case 12: UNW_DEC_REG_SPREL(P8, UNW_REG_BSPSTORE, t, arg); break;\n              case 13: UNW_DEC_REG_WHEN(P8, UNW_REG_RNAT, t, arg); break;\n              case 14: UNW_DEC_REG_PSPREL(P8, UNW_REG_RNAT, t, arg); break;\n              case 15: UNW_DEC_REG_SPREL(P8, UNW_REG_RNAT, t, arg); break;\n              case 16: UNW_DEC_PRIUNAT_WHEN_GR(P8, t, arg); break;\n              case 17: UNW_DEC_PRIUNAT_PSPREL(P8, t, arg); break;\n              case 18: UNW_DEC_PRIUNAT_SPREL(P8, t, arg); break;\n              case 19: UNW_DEC_PRIUNAT_WHEN_MEM(P8, t, arg); break;\n              default: UNW_DEC_BAD_CODE(r); break;\n            }\n          }\n          break;\n\n        case 0x1:\n          byte1 = *dp++; byte2 = *dp++;\n          UNW_DEC_GR_GR(P9, (byte1 & 0xf), (byte2 & 0x7f), arg);\n          break;\n\n        case 0xf: /* p10 */\n          byte1 = *dp++; byte2 = *dp++;\n          UNW_DEC_ABI(P10, byte1, byte2, arg);\n          break;\n\n        case 0x9:\n          return unw_decode_x1 (dp, code, arg);\n\n        case 0xa:\n          return unw_decode_x2 (dp, code, arg);\n\n        case 0xb:\n          return unw_decode_x3 (dp, code, arg);\n\n        case 0xc:\n          return unw_decode_x4 (dp, code, arg);\n\n        default:\n          UNW_DEC_BAD_CODE(code);\n          break;\n        }\n    }\n  return dp;\n}\n\nstatic unsigned char *\nunw_decode_b1 (unsigned char *dp, unsigned char code, void *arg)\n{\n  unw_word label = (code & 0x1f);\n\n  if ((code & 0x20) != 0)\n    UNW_DEC_COPY_STATE(B1, label, arg);\n  else\n    UNW_DEC_LABEL_STATE(B1, label, arg);\n  return dp;\n}\n\nstatic unsigned char *\nunw_decode_b2 (unsigned char *dp, unsigned char code, void *arg)\n{\n  unw_word t;\n\n  t = unw_decode_uleb128 (&dp);\n  UNW_DEC_EPILOGUE(B2, t, (code & 0x1f), arg);\n  return dp;\n}\n\nstatic unsigned char *\nunw_decode_b3_x4 (unsigned char *dp, unsigned char code, void *arg)\n{\n  unw_word t, ecount, label;\n\n  if ((code & 0x10) == 0)\n    {\n      t = unw_decode_uleb128 (&dp);\n      ecount = unw_decode_uleb128 (&dp);\n      UNW_DEC_EPILOGUE(B3, t, ecount, arg);\n    }\n  else if ((code & 0x07) == 0)\n    {\n      label = unw_decode_uleb128 (&dp);\n      if ((code & 0x08) != 0)\n        UNW_DEC_COPY_STATE(B4, label, arg);\n      else\n        UNW_DEC_LABEL_STATE(B4, label, arg);\n    }\n  else\n    switch (code & 0x7)\n      {\n      case 1: return unw_decode_x1 (dp, code, arg);\n      case 2: return unw_decode_x2 (dp, code, arg);\n      case 3: return unw_decode_x3 (dp, code, arg);\n      case 4: return unw_decode_x4 (dp, code, arg);\n      default: UNW_DEC_BAD_CODE(code); break;\n      }\n  return dp;\n}\n\ntypedef unsigned char *(*unw_decoder) (unsigned char *, unsigned char, void *);\n\nstatic unw_decoder unw_decode_table[2][8] =\n{\n  /* prologue table: */\n  {\n    unw_decode_r1,\t/* 0 */\n    unw_decode_r1,\n    unw_decode_r2,\n    unw_decode_r3,\n    unw_decode_p1,\t/* 4 */\n    unw_decode_p2_p5,\n    unw_decode_p6,\n    unw_decode_p7_p10\n  },\n  {\n    unw_decode_r1,\t/* 0 */\n    unw_decode_r1,\n    unw_decode_r2,\n    unw_decode_r3,\n    unw_decode_b1,\t/* 4 */\n    unw_decode_b1,\n    unw_decode_b2,\n    unw_decode_b3_x4\n  }\n};\n\n/*\n * Decode one descriptor and return address of next descriptor.\n */\nstatic inline unsigned char *\nunw_decode (unsigned char *dp, int inside_body, void *arg)\n{\n  unw_decoder decoder;\n  unsigned char code;\n\n  code = *dp++;\n  decoder = unw_decode_table[inside_body][code >> 5];\n  dp = (*decoder) (dp, code, arg);\n  return dp;\n}\n', 'message': '(unw_decode_r1): "inline" it.\n(unw_decode_r2): Likewise.\n(unw_decode_r3): Likewise.\n(unw_decode_p1): Likewise.\n(unw_decode_p2_p5): Likewise.\n(unw_decode_p6): Likewise.\n(unw_decode_p7_p10): Likewise.\n(unw_decode_b1): Likewise.\n(unw_decode_b3_x4): Likewise.\n(unw_decode_table): Remove.\n(unw_decode): Do the first-level of decoding inline, rather than\n\tthrough the unw_decode_table.\n\n(Logical change 1.148)\n', 'author_name': 'mostang.com!davidm', 'lang': 'h'}