LCOV - code coverage report
Current view: top level - backends - sparc_regs.c (source / functions) Hit Total Coverage
Test: elfutils-0.178 Lines: 40 40 100.0 %
Date: 2019-11-26 23:55:16 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Register names and numbers for SPARC DWARF.
       2             :    Copyright (C) 2005, 2006, 2015 Red Hat, Inc.
       3             :    This file is part of elfutils.
       4             : 
       5             :    This file is free software; you can redistribute it and/or modify
       6             :    it under the terms of either
       7             : 
       8             :      * the GNU Lesser General Public License as published by the Free
       9             :        Software Foundation; either version 3 of the License, or (at
      10             :        your option) any later version
      11             : 
      12             :    or
      13             : 
      14             :      * the GNU General Public License as published by the Free
      15             :        Software Foundation; either version 2 of the License, or (at
      16             :        your option) any later version
      17             : 
      18             :    or both in parallel, as here.
      19             : 
      20             :    elfutils is distributed in the hope that it will be useful, but
      21             :    WITHOUT ANY WARRANTY; without even the implied warranty of
      22             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      23             :    General Public License for more details.
      24             : 
      25             :    You should have received copies of the GNU General Public License and
      26             :    the GNU Lesser General Public License along with this program.  If
      27             :    not, see <http://www.gnu.org/licenses/>.  */
      28             : 
      29             : #ifdef HAVE_CONFIG_H
      30             : # include <config.h>
      31             : #endif
      32             : 
      33             : #include <string.h>
      34             : #include <dwarf.h>
      35             : 
      36             : #define BACKEND sparc_
      37             : #include "libebl_CPU.h"
      38             : 
      39             : ssize_t
      40         160 : sparc_register_info (Ebl *ebl,
      41             :                      int regno, char *name, size_t namelen,
      42             :                      const char **prefix, const char **setname,
      43             :                      int *bits, int *type)
      44             : {
      45         160 :   const int nfp = 32 + (ebl->class == ELFCLASS32 ? 0 : 16);
      46         160 :   const int nspec = ebl->class == ELFCLASS32 ? 8 : 6;
      47             : 
      48         160 :   if (name == NULL)
      49           2 :     return 32 + nfp + nspec;
      50             : 
      51         158 :   if (regno < 0 || regno >= 32 + nfp + nspec || namelen < 6)
      52             :     return -1;
      53             : 
      54         158 :   *bits = ebl->class == ELFCLASS32 ? 32 : 64;
      55         158 :   *type = DW_ATE_signed;
      56             : 
      57         158 :   *prefix = "%";
      58             : 
      59         158 :   if (regno >= 32 + nfp)
      60             :     {
      61          14 :       regno -= 32 + nfp;
      62          14 :       static const char names[2][8][6] =
      63             :         {
      64             :           { "y", "psr", "wim", "tbr", "pc", "npc", "fsr", "csr" }, /* v8 */
      65             :           { "pc", "npc", "state", "fsr", "fprs", "y" } /* v9 */
      66             :         };
      67          14 :       *setname = "control";
      68          14 :       *type = DW_ATE_unsigned;
      69          22 :       if ((ebl->class == ELFCLASS64 ? 0 : 4) + 1 - (unsigned int) regno <= 1)
      70           4 :         *type = DW_ATE_address;
      71          14 :       return stpncpy (name, names[ebl->class == ELFCLASS64][regno],
      72          14 :                       namelen) + 1 - name;
      73             :     }
      74             : 
      75         144 :   if (regno < 32)
      76             :     {
      77          64 :       *setname = "integer";
      78          64 :       name[0] = "goli"[regno >> 3];
      79          64 :       name[1] = (regno & 7) + '0';
      80          64 :       namelen = 2;
      81          64 :       if ((regno & 8) && (regno & 7) == 6)
      82           4 :         *type = DW_ATE_address;
      83             :     }
      84             :   else
      85             :     {
      86          80 :       *setname = "FPU";
      87          80 :       *type = DW_ATE_float;
      88             : 
      89          80 :       regno -= 32;
      90          80 :       if (regno >= 32)
      91          16 :         regno = 32 + 2 * (regno - 32);
      92             :       else
      93          64 :         *bits = 32;
      94             : 
      95          80 :       name[0] = 'f';
      96          80 :       if (regno < 10)
      97             :         {
      98          20 :           name[1] = regno + '0';
      99          20 :           namelen = 2;
     100             :         }
     101             :       else
     102             :         {
     103          60 :           name[1] = regno / 10 + '0';
     104          60 :           name[2] = regno % 10 + '0';
     105          60 :           namelen = 3;
     106             :         }
     107             :     }
     108             : 
     109         144 :   name[namelen++] = '\0';
     110         144 :   return namelen;
     111             : }

Generated by: LCOV version 1.13