LCOV - code coverage report
Current view: top level - backends - s390_regs.c (source / functions) Hit Total Coverage
Test: elfutils-0.191 Lines: 55 55 100.0 %
Date: 2024-04-17 19:42:11 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 24 25 96.0 %

           Branch data     Line data    Source code
       1                 :            : /* Register names and numbers for S/390 DWARF.
       2                 :            :    Copyright (C) 2006 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 s390_
      37                 :            : #include "libebl_CPU.h"
      38                 :            : 
      39                 :            : 
      40                 :            : /*
      41                 :            : zseries (64)
      42                 :            : 
      43                 :            : 0-15    gpr0-gpr15      x
      44                 :            : 16-19   fpr[0246]
      45                 :            : 20-24   fpr[13578]
      46                 :            : 25-27   fpr1[024]
      47                 :            : 28      fpr9
      48                 :            : 29-31   fpr1[135]
      49                 :            : 32-47   cr0-cr15        x
      50                 :            : 48-63   ar0-ar15        x
      51                 :            : 64      psw_mask
      52                 :            : 65      psw_address
      53                 :            : */
      54                 :            : 
      55                 :            : 
      56                 :            : ssize_t
      57                 :        968 : s390_register_info (Ebl *ebl __attribute__ ((unused)),
      58                 :            :                     int regno, char *name, size_t namelen,
      59                 :            :                     const char **prefix, const char **setname,
      60                 :            :                     int *bits, int *type)
      61                 :            : {
      62         [ +  + ]:        968 :   if (name == NULL)
      63                 :            :     return 66;
      64                 :            : 
      65         [ +  - ]:        952 :   if (regno < 0 || regno > 65 || namelen < 7)
      66                 :            :     return -1;
      67                 :            : 
      68                 :        952 :   *prefix = "%";
      69                 :            : 
      70         [ +  + ]:        952 :   *bits = ebl->class == ELFCLASS64 ? 64 : 32;
      71                 :        952 :   *type = DW_ATE_unsigned;
      72         [ +  + ]:        952 :   if (regno < 16)
      73                 :            :     {
      74                 :        280 :       *setname = "integer";
      75                 :        280 :       *type = DW_ATE_signed;
      76                 :            :     }
      77         [ +  + ]:        672 :   else if (regno < 32)
      78                 :            :     {
      79                 :        256 :       *setname = "FPU";
      80                 :        256 :       *type = DW_ATE_float;
      81                 :        256 :       *bits = 64;
      82                 :            :     }
      83         [ +  + ]:        416 :   else if (regno < 48 || regno > 63)
      84                 :        160 :     *setname = "control";
      85                 :            :   else
      86                 :            :     {
      87                 :        256 :       *setname = "access";
      88                 :        256 :       *bits = 32;
      89                 :            :     }
      90                 :            : 
      91   [ +  +  +  +  :        952 :   switch (regno)
                +  +  + ]
      92                 :            :     {
      93                 :        160 :     case 0 ... 9:
      94                 :        160 :       name[0] = 'r';
      95                 :        160 :       name[1] = regno + '0';
      96                 :        160 :       namelen = 2;
      97                 :        160 :       break;
      98                 :            : 
      99                 :        120 :     case 10 ... 15:
     100                 :        120 :       name[0] = 'r';
     101                 :        120 :       name[1] = '1';
     102                 :        120 :       name[2] = regno - 10 + '0';
     103                 :        120 :       namelen = 3;
     104                 :        120 :       break;
     105                 :            : 
     106                 :        256 :     case 16 ... 31:
     107                 :        256 :       name[0] = 'f';
     108                 :        256 :       regno = (regno & 8) | ((regno & 4) >> 2) | ((regno & 3) << 1);
     109                 :        256 :       namelen = 1;
     110         [ +  + ]:        256 :       if (regno >= 10)
     111                 :            :         {
     112                 :         96 :           regno -= 10;
     113                 :         96 :           name[namelen++] = '1';
     114                 :            :         }
     115                 :        256 :       name[namelen++] = regno + '0';
     116                 :        256 :       break;
     117                 :            : 
     118                 :        240 :     case 32 + 0 ... 32 + 9:
     119                 :            :     case 48 + 0 ... 48 + 9:
     120         [ +  + ]:        240 :       name[0] = regno < 48 ? 'c' : 'a';
     121                 :        240 :       name[1] = (regno & 15) + '0';
     122                 :        240 :       namelen = 2;
     123                 :        240 :       break;
     124                 :            : 
     125                 :        144 :     case 32 + 10 ... 32 + 15:
     126                 :            :     case 48 + 10 ... 48 + 15:
     127         [ +  + ]:        144 :       name[0] = regno < 48 ? 'c' : 'a';
     128                 :        144 :       name[1] = '1';
     129                 :        144 :       name[2] = (regno & 15) - 10 + '0';
     130                 :        144 :       namelen = 3;
     131                 :        144 :       break;
     132                 :            : 
     133                 :            :     case 64:
     134                 :         16 :       return stpcpy (name, "pswm") + 1 - name;
     135                 :         16 :     case 65:
     136                 :         16 :       *type = DW_ATE_address;
     137                 :         16 :       return stpcpy (name, "pswa") + 1 - name;
     138                 :            : 
     139                 :            :     default:
     140                 :            :       *setname = NULL;
     141                 :            :       return 0;
     142                 :            :     }
     143                 :            : 
     144                 :        920 :   name[namelen++] = '\0';
     145                 :        920 :   return namelen;
     146                 :            : }

Generated by: LCOV version 1.16