LCOV - code coverage report
Current view: top level - backends - sparc_attrs.c (source / functions) Hit Total Coverage
Test: elfutils-0.189 Lines: 23 23 100.0 %
Date: 2023-10-24 20:27:32 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 12 83.3 %

           Branch data     Line data    Source code
       1                 :            : /* Object attribute tags for SPARC.
       2                 :            :    Copyright (C) 2015 Oracle, 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                 :            : bool
      40                 :          4 : sparc_check_object_attribute (Ebl *ebl __attribute__ ((unused)),
      41                 :            :                               const char *vendor, int tag, uint64_t value,
      42                 :            :                               const char **tag_name, const char **value_name)
      43                 :            : {
      44                 :          4 :   static const char *hwcaps[32] =
      45                 :            :     {
      46                 :            :       "mul32", "div32", "fsmuld", "v8plus", "popc", "vis", "vis2",
      47                 :            :       "asi_blk_init", "fmaf", "vis3", "hpc", "random", "trans",
      48                 :            :       "fjfmau", "ima", "asi_cache_sparing", "aes", "des", "kasumi",
      49                 :            :       "camellia", "md5", "sha1", "sha256", "sha512", "mpmul", "mont",
      50                 :            :       "pause", "cbcond", "crc32c", "resv30", "resv31"
      51                 :            :     };
      52                 :            : 
      53                 :            :   
      54                 :          4 :   static const char *hwcaps2[32] =
      55                 :            :     {
      56                 :            :       "fjathplus", "vis3b", "adp", "sparc5", "mwait", "xmpmul", "xmont",
      57                 :            :       "nsec", "resv8", "resv9" , "resv10", "resv11", "fjathhpc", "fjdes",
      58                 :            :       "fjaes", "resv15", "resv16", "resv17", "resv18", "resv19", "resv20",
      59                 :            :       "resv21", "resv22", "resv23", "resv24", "resv25", "resv26", "resv27",
      60                 :            :       "resv28", "resv29", "resv30", "resv31",
      61                 :            :     };
      62                 :            : 
      63                 :            :   /* NAME should be big enough to hold any possible comma-separated
      64                 :            :      list (no repetitions allowed) of attribute names from one of the
      65                 :            :      arrays above.  */
      66                 :          4 :   static char name[32*17+32+1];
      67                 :          4 :   name[0] = '\0';
      68                 :            : 
      69         [ +  - ]:          4 :   if (!strcmp (vendor, "gnu"))
      70         [ +  - ]:          4 :     switch (tag)
      71                 :            :       {
      72                 :          4 :       case 4:
      73                 :            :       case 8:
      74                 :            :         {
      75                 :          4 :           const char **caps;
      76                 :          4 :           int cap;
      77                 :            :           
      78         [ +  + ]:          4 :           if (tag == 4)
      79                 :            :             {
      80                 :          2 :               *tag_name = "GNU_Sparc_HWCAPS";
      81                 :          2 :               caps = hwcaps;
      82                 :            :             }
      83                 :            :           else
      84                 :            :             {
      85                 :          2 :               *tag_name = "GNU_Sparc_HWCAPS2";
      86                 :          2 :               caps = hwcaps2;
      87                 :            :             }
      88                 :            :           
      89                 :          4 :           char *s = name;
      90         [ +  + ]:        132 :           for (cap = 0; cap < 32; cap++)
      91         [ +  + ]:        128 :             if (value & (1U << cap))
      92                 :            :               {
      93         [ +  + ]:         36 :                 if (*s != '\0')
      94                 :         32 :                   s = strcat (s, ",");
      95                 :         36 :                 s = strcat (s, caps[cap]);
      96                 :            :               }
      97                 :            :           
      98                 :          4 :           *value_name = s;
      99                 :          4 :           return true;
     100                 :            :         }
     101                 :            :       }
     102                 :            : 
     103                 :            :   return false;
     104                 :            : }
     105                 :            : 

Generated by: LCOV version 1.16