xref: /netbsd-src/external/gpl3/binutils.old/dist/gprofng/src/IndexObject.h (revision c42dbd0ed2e61fe6eda8590caa852ccf34719964)
1*c42dbd0eSchristos /* Copyright (C) 2021 Free Software Foundation, Inc.
2*c42dbd0eSchristos    Contributed by Oracle.
3*c42dbd0eSchristos 
4*c42dbd0eSchristos    This file is part of GNU Binutils.
5*c42dbd0eSchristos 
6*c42dbd0eSchristos    This program is free software; you can redistribute it and/or modify
7*c42dbd0eSchristos    it under the terms of the GNU General Public License as published by
8*c42dbd0eSchristos    the Free Software Foundation; either version 3, or (at your option)
9*c42dbd0eSchristos    any later version.
10*c42dbd0eSchristos 
11*c42dbd0eSchristos    This program is distributed in the hope that it will be useful,
12*c42dbd0eSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*c42dbd0eSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*c42dbd0eSchristos    GNU General Public License for more details.
15*c42dbd0eSchristos 
16*c42dbd0eSchristos    You should have received a copy of the GNU General Public License
17*c42dbd0eSchristos    along with this program; if not, write to the Free Software
18*c42dbd0eSchristos    Foundation, 51 Franklin Street - Fifth Floor, Boston,
19*c42dbd0eSchristos    MA 02110-1301, USA.  */
20*c42dbd0eSchristos 
21*c42dbd0eSchristos #ifndef _INDEXOBJECT_H
22*c42dbd0eSchristos #define _INDEXOBJECT_H
23*c42dbd0eSchristos 
24*c42dbd0eSchristos #include "Histable.h"
25*c42dbd0eSchristos #include "Expression.h"
26*c42dbd0eSchristos 
27*c42dbd0eSchristos class IndexObject : public Histable
28*c42dbd0eSchristos {
29*c42dbd0eSchristos public:
30*c42dbd0eSchristos   IndexObject (int _indextype, uint64_t _index);
31*c42dbd0eSchristos   IndexObject (int _indextype, Histable *_obj);
32*c42dbd0eSchristos   bool requires_string_sort (); // name column should be sorted using name text
33*c42dbd0eSchristos 
34*c42dbd0eSchristos   virtual Histable_type
get_type()35*c42dbd0eSchristos   get_type ()
36*c42dbd0eSchristos   {
37*c42dbd0eSchristos     return INDEXOBJ;
38*c42dbd0eSchristos   }
39*c42dbd0eSchristos 
40*c42dbd0eSchristos   virtual char *get_name (NameFormat = NA);
41*c42dbd0eSchristos   virtual void set_name (char*);
42*c42dbd0eSchristos   virtual void set_name_from_context (Expression::Context *);
43*c42dbd0eSchristos   virtual Histable *convertto (Histable_type, Histable* = NULL);
44*c42dbd0eSchristos 
45*c42dbd0eSchristos   virtual uint64_t
get_addr()46*c42dbd0eSchristos   get_addr ()
47*c42dbd0eSchristos   {
48*c42dbd0eSchristos     return id;
49*c42dbd0eSchristos   }
50*c42dbd0eSchristos 
51*c42dbd0eSchristos   uint64_t
get_index()52*c42dbd0eSchristos   get_index ()
53*c42dbd0eSchristos   {
54*c42dbd0eSchristos     return id;
55*c42dbd0eSchristos   }
56*c42dbd0eSchristos 
57*c42dbd0eSchristos   Histable *
get_obj()58*c42dbd0eSchristos   get_obj ()
59*c42dbd0eSchristos   {
60*c42dbd0eSchristos     return obj;
61*c42dbd0eSchristos   }
62*c42dbd0eSchristos 
63*c42dbd0eSchristos   // for use in index object definitions
64*c42dbd0eSchristos   static const uint64_t INDXOBJ_EXPGRID_SHIFT   = 60;
65*c42dbd0eSchristos   static const uint64_t INDXOBJ_EXPID_SHIFT     = 32;
66*c42dbd0eSchristos   static const uint64_t INDXOBJ_PAYLOAD_SHIFT   = 0;
67*c42dbd0eSchristos   static const uint64_t INDXOBJ_EXPGRID_MASK    =
68*c42dbd0eSchristos 	((1LLU << (64 - INDXOBJ_EXPGRID_SHIFT)) - 1);
69*c42dbd0eSchristos   static const uint64_t INDXOBJ_EXPID_MASK      =
70*c42dbd0eSchristos 	((1LLU << (INDXOBJ_EXPGRID_SHIFT - INDXOBJ_EXPID_SHIFT)) - 1);
71*c42dbd0eSchristos   static const uint64_t INDXOBJ_PAYLOAD_MASK    =
72*c42dbd0eSchristos 	((1LLU << (INDXOBJ_EXPID_SHIFT - INDXOBJ_PAYLOAD_SHIFT)) - 1);
73*c42dbd0eSchristos 
74*c42dbd0eSchristos private:
75*c42dbd0eSchristos 
76*c42dbd0eSchristos   int indextype;
77*c42dbd0eSchristos   Histable *obj;
78*c42dbd0eSchristos   bool nameIsFinal;
79*c42dbd0eSchristos };
80*c42dbd0eSchristos 
81*c42dbd0eSchristos typedef enum IndexObjTypes
82*c42dbd0eSchristos {
83*c42dbd0eSchristos   INDEX_THREADS = 0,
84*c42dbd0eSchristos   INDEX_CPUS,
85*c42dbd0eSchristos   INDEX_SAMPLES,
86*c42dbd0eSchristos   INDEX_GCEVENTS,
87*c42dbd0eSchristos   INDEX_SECONDS,
88*c42dbd0eSchristos   INDEX_PROCESSES,
89*c42dbd0eSchristos   INDEX_EXPERIMENTS,
90*c42dbd0eSchristos   INDEX_BYTES,
91*c42dbd0eSchristos   INDEX_DURATION,
92*c42dbd0eSchristos   INDEX_LAST    // never used; marks the count of precompiled items
93*c42dbd0eSchristos } IndexObjTypes_t;
94*c42dbd0eSchristos 
95*c42dbd0eSchristos class IndexObjType_t
96*c42dbd0eSchristos {
97*c42dbd0eSchristos public:
98*c42dbd0eSchristos   IndexObjType_t ();
99*c42dbd0eSchristos   ~IndexObjType_t ();
100*c42dbd0eSchristos   int type;
101*c42dbd0eSchristos   char *name;           // used as input
102*c42dbd0eSchristos   char *i18n_name;      // used for output
103*c42dbd0eSchristos   char *index_expr_str;
104*c42dbd0eSchristos   Expression *index_expr;
105*c42dbd0eSchristos   char mnemonic;
106*c42dbd0eSchristos   char *short_description;
107*c42dbd0eSchristos   char *long_description;
108*c42dbd0eSchristos   MemObjType_t *memObj;
109*c42dbd0eSchristos };
110*c42dbd0eSchristos 
111*c42dbd0eSchristos #endif  /* _INDEXOBJECT_H */
112