LCOV - code coverage report
Current view: top level - backends - aarch64_regs.c (source / functions) Hit Total Coverage
Test: elfutils-0.189 Lines: 23 25 92.0 %
Date: 2023-10-25 13:46:23 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 14 71.4 %

           Branch data     Line data    Source code
       1                 :            : /* Register names and numbers for AArch64 DWARF.
       2                 :            :    Copyright (C) 2013, 2014 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 <stdio.h>
      34                 :            : #include <string.h>
      35                 :            : #include <dwarf.h>
      36                 :            : #include <stdarg.h>
      37                 :            : 
      38                 :            : #define BACKEND aarch64_
      39                 :            : #include "libebl_CPU.h"
      40                 :            : 
      41                 :            : __attribute__ ((format (printf, 7, 8)))
      42                 :            : static ssize_t
      43                 :        618 : do_regtype (const char *setname, int type,
      44                 :            :            const char **setnamep, int *typep,
      45                 :            :            char *name, size_t namelen, const char *fmt, ...)
      46                 :            : {
      47                 :        618 :   *setnamep = setname;
      48                 :        618 :   *typep = type;
      49                 :            : 
      50                 :        618 :   va_list ap;
      51                 :        618 :   va_start (ap, fmt);
      52         [ +  - ]:        618 :   int s = vsnprintf (name, namelen, fmt, ap);
      53                 :        618 :   va_end(ap);
      54                 :            : 
      55   [ +  -  +  - ]:        618 :   if (s < 0 || (unsigned) s >= namelen)
      56                 :            :     return -1;
      57                 :        618 :   return s + 1;
      58                 :            : }
      59                 :            : 
      60                 :            : ssize_t
      61                 :        878 : aarch64_register_info (Ebl *ebl __attribute__ ((unused)),
      62                 :            :                        int regno, char *name, size_t namelen,
      63                 :            :                        const char **prefix, const char **setnamep,
      64                 :            :                        int *bits, int *typep)
      65                 :            : {
      66         [ +  + ]:        878 :   if (name == NULL)
      67                 :            :     return 128;
      68                 :            : 
      69                 :            : 
      70                 :        870 :   *prefix = "";
      71                 :        870 :   *bits = 64;
      72                 :            : 
      73                 :            : #define regtype(setname, type, ...) \
      74                 :            :     do_regtype(setname, type, setnamep, typep, name, namelen, __VA_ARGS__)
      75                 :            : 
      76   [ +  +  +  +  :        870 :   switch (regno)
                   -  + ]
      77                 :            :     {
      78                 :        332 :     case 0 ... 30:
      79                 :        332 :       return regtype ("integer", DW_ATE_signed, "x%d", regno);
      80                 :            : 
      81                 :         26 :     case 31:
      82                 :         26 :       return regtype ("integer", DW_ATE_address, "sp");
      83                 :            : 
      84                 :            :     case 32:
      85                 :            :       return 0;
      86                 :            : 
      87                 :          4 :     case 33:
      88                 :          4 :       return regtype ("integer", DW_ATE_address, "elr");
      89                 :            : 
      90                 :            :     case 34 ... 63:
      91                 :            :       return 0;
      92                 :            : 
      93                 :        256 :     case 64 ... 95:
      94                 :            :       /* FP/SIMD register file supports a variety of data types--it
      95                 :            :          can be thought of as a register holding a single integer or
      96                 :            :          floating-point value, or a vector of 8-, 16-, 32- or 64-bit
      97                 :            :          integers.  128-bit quad-word is the only singular value that
      98                 :            :          covers the whole register, so mark the register thus.  */
      99                 :        256 :       *bits = 128;
     100                 :        256 :       return regtype ("FP/SIMD", DW_ATE_unsigned, "v%d", regno - 64);
     101                 :            : 
     102                 :            :     case 96 ... 127:
     103                 :            :       return 0;
     104                 :            : 
     105                 :          0 :     default:
     106                 :          0 :       return -1;
     107                 :            :     }
     108                 :            : }

Generated by: LCOV version 1.16