xref: /netbsd-src/external/gpl3/binutils/dist/gprofng/src/IndexObject.h (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1*cb63e24eSchristos /* Copyright (C) 2021-2024 Free Software Foundation, Inc.
24f645668Schristos    Contributed by Oracle.
34f645668Schristos 
44f645668Schristos    This file is part of GNU Binutils.
54f645668Schristos 
64f645668Schristos    This program is free software; you can redistribute it and/or modify
74f645668Schristos    it under the terms of the GNU General Public License as published by
84f645668Schristos    the Free Software Foundation; either version 3, or (at your option)
94f645668Schristos    any later version.
104f645668Schristos 
114f645668Schristos    This program is distributed in the hope that it will be useful,
124f645668Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
134f645668Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
144f645668Schristos    GNU General Public License for more details.
154f645668Schristos 
164f645668Schristos    You should have received a copy of the GNU General Public License
174f645668Schristos    along with this program; if not, write to the Free Software
184f645668Schristos    Foundation, 51 Franklin Street - Fifth Floor, Boston,
194f645668Schristos    MA 02110-1301, USA.  */
204f645668Schristos 
214f645668Schristos #ifndef _INDEXOBJECT_H
224f645668Schristos #define _INDEXOBJECT_H
234f645668Schristos 
244f645668Schristos #include "Histable.h"
254f645668Schristos #include "Expression.h"
264f645668Schristos 
274f645668Schristos class IndexObject : public Histable
284f645668Schristos {
294f645668Schristos public:
304f645668Schristos   IndexObject (int _indextype, uint64_t _index);
314f645668Schristos   IndexObject (int _indextype, Histable *_obj);
324f645668Schristos   bool requires_string_sort (); // name column should be sorted using name text
334f645668Schristos 
344f645668Schristos   virtual Histable_type
get_type()354f645668Schristos   get_type ()
364f645668Schristos   {
374f645668Schristos     return INDEXOBJ;
384f645668Schristos   }
394f645668Schristos 
404f645668Schristos   virtual char *get_name (NameFormat = NA);
414f645668Schristos   virtual void set_name (char*);
424f645668Schristos   virtual void set_name_from_context (Expression::Context *);
434f645668Schristos   virtual Histable *convertto (Histable_type, Histable* = NULL);
444f645668Schristos 
454f645668Schristos   virtual uint64_t
get_addr()464f645668Schristos   get_addr ()
474f645668Schristos   {
484f645668Schristos     return id;
494f645668Schristos   }
504f645668Schristos 
514f645668Schristos   uint64_t
get_index()524f645668Schristos   get_index ()
534f645668Schristos   {
544f645668Schristos     return id;
554f645668Schristos   }
564f645668Schristos 
574f645668Schristos   Histable *
get_obj()584f645668Schristos   get_obj ()
594f645668Schristos   {
604f645668Schristos     return obj;
614f645668Schristos   }
624f645668Schristos 
634f645668Schristos   // for use in index object definitions
644f645668Schristos   static const uint64_t INDXOBJ_EXPGRID_SHIFT   = 60;
654f645668Schristos   static const uint64_t INDXOBJ_EXPID_SHIFT     = 32;
664f645668Schristos   static const uint64_t INDXOBJ_PAYLOAD_SHIFT   = 0;
674f645668Schristos   static const uint64_t INDXOBJ_EXPGRID_MASK    =
684f645668Schristos 	((1LLU << (64 - INDXOBJ_EXPGRID_SHIFT)) - 1);
694f645668Schristos   static const uint64_t INDXOBJ_EXPID_MASK      =
704f645668Schristos 	((1LLU << (INDXOBJ_EXPGRID_SHIFT - INDXOBJ_EXPID_SHIFT)) - 1);
714f645668Schristos   static const uint64_t INDXOBJ_PAYLOAD_MASK    =
724f645668Schristos 	((1LLU << (INDXOBJ_EXPID_SHIFT - INDXOBJ_PAYLOAD_SHIFT)) - 1);
734f645668Schristos 
744f645668Schristos private:
754f645668Schristos 
764f645668Schristos   int indextype;
774f645668Schristos   Histable *obj;
784f645668Schristos   bool nameIsFinal;
794f645668Schristos };
804f645668Schristos 
814f645668Schristos typedef enum IndexObjTypes
824f645668Schristos {
834f645668Schristos   INDEX_THREADS = 0,
844f645668Schristos   INDEX_CPUS,
854f645668Schristos   INDEX_SAMPLES,
864f645668Schristos   INDEX_GCEVENTS,
874f645668Schristos   INDEX_SECONDS,
884f645668Schristos   INDEX_PROCESSES,
894f645668Schristos   INDEX_EXPERIMENTS,
904f645668Schristos   INDEX_BYTES,
914f645668Schristos   INDEX_DURATION,
924f645668Schristos   INDEX_LAST    // never used; marks the count of precompiled items
934f645668Schristos } IndexObjTypes_t;
944f645668Schristos 
954f645668Schristos class IndexObjType_t
964f645668Schristos {
974f645668Schristos public:
984f645668Schristos   IndexObjType_t ();
994f645668Schristos   ~IndexObjType_t ();
1004f645668Schristos   int type;
1014f645668Schristos   char *name;           // used as input
1024f645668Schristos   char *i18n_name;      // used for output
1034f645668Schristos   char *index_expr_str;
1044f645668Schristos   Expression *index_expr;
1054f645668Schristos   char mnemonic;
1064f645668Schristos   char *short_description;
1074f645668Schristos   char *long_description;
1084f645668Schristos   MemObjType_t *memObj;
1094f645668Schristos };
1104f645668Schristos 
1114f645668Schristos #endif  /* _INDEXOBJECT_H */
112