LCOV - code coverage report
Current view: top level - backends - s390_regs.c (source / functions) Hit Total Coverage
Test: elfutils-0.178 Lines: 55 58 94.8 %
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 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         496 : 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         496 :   if (name == NULL)
      63             :     return 66;
      64             : 
      65         488 :   if (regno < 0 || regno > 65 || namelen < 7)
      66             :     return -1;
      67             : 
      68         488 :   *prefix = "%";
      69             : 
      70         488 :   *bits = ebl->class == ELFCLASS64 ? 64 : 32;
      71         488 :   *type = DW_ATE_unsigned;
      72         488 :   if (regno < 16)
      73             :     {
      74         152 :       *setname = "integer";
      75         152 :       *type = DW_ATE_signed;
      76             :     }
      77         336 :   else if (regno < 32)
      78             :     {
      79         128 :       *setname = "FPU";
      80         128 :       *type = DW_ATE_float;
      81         128 :       *bits = 64;
      82             :     }
      83         208 :   else if (regno < 48 || regno > 63)
      84          80 :     *setname = "control";
      85             :   else
      86             :     {
      87         128 :       *setname = "access";
      88         128 :       *bits = 32;
      89             :     }
      90             : 
      91         488 :   switch (regno)
      92             :     {
      93          80 :     case 0 ... 9:
      94          80 :       name[0] = 'r';
      95          80 :       name[1] = regno + '0';
      96          80 :       namelen = 2;
      97          80 :       break;
      98             : 
      99          72 :     case 10 ... 15:
     100          72 :       name[0] = 'r';
     101          72 :       name[1] = '1';
     102          72 :       name[2] = regno - 10 + '0';
     103          72 :       namelen = 3;
     104          72 :       break;
     105             : 
     106         128 :     case 16 ... 31:
     107         128 :       name[0] = 'f';
     108         128 :       regno = (regno & 8) | ((regno & 4) >> 2) | ((regno & 3) << 1);
     109         128 :       namelen = 1;
     110         128 :       if (regno >= 10)
     111             :         {
     112          48 :           regno -= 10;
     113          48 :           name[namelen++] = '1';
     114             :         }
     115         128 :       name[namelen++] = regno + '0';
     116         128 :       break;
     117             : 
     118         120 :     case 32 + 0 ... 32 + 9:
     119             :     case 48 + 0 ... 48 + 9:
     120         120 :       name[0] = regno < 48 ? 'c' : 'a';
     121         120 :       name[1] = (regno & 15) + '0';
     122         120 :       namelen = 2;
     123         120 :       break;
     124             : 
     125          72 :     case 32 + 10 ... 32 + 15:
     126             :     case 48 + 10 ... 48 + 15:
     127          72 :       name[0] = regno < 48 ? 'c' : 'a';
     128          72 :       name[1] = '1';
     129          72 :       name[2] = (regno & 15) - 10 + '0';
     130          72 :       namelen = 3;
     131          72 :       break;
     132             : 
     133             :     case 64:
     134          16 :       return stpcpy (name, "pswm") + 1 - name;
     135           8 :     case 65:
     136           8 :       *type = DW_ATE_address;
     137          16 :       return stpcpy (name, "pswa") + 1 - name;
     138             : 
     139           0 :     default:
     140           0 :       *setname = NULL;
     141           0 :       return 0;
     142             :     }
     143             : 
     144         472 :   name[namelen++] = '\0';
     145         472 :   return namelen;
     146             : }

Generated by: LCOV version 1.13