1 /*--------------------------------------------------------------------*/
4 /*--- (C) 2004-2005, Josef Weidendorfer ---*/
5 /*--------------------------------------------------------------------*/
8 /* Abstractions for 64-bit cost lists (events.h) */
13 #include "pub_tool_basics.h"
15 #define CLG_(str) VGAPPEND(vgCallgrind_,str)
18 typedef struct _EventType EventType;
25 EventType* CLG_(register_eventtype)(Char*);
26 EventType* CLG_(get_eventtype)(Char*);
27 EventType* CLG_(get_eventtype_byindex)(Int id);
29 /* An event set is a ordered list of event types, which comes down
30 * to some description for ordered lists of costs.
31 * Often, costs of 2 event types are related, e.g. one is always smaller
32 * than the other. This is useful to speed up arithmetics on cost lists:
33 * Each event type in the set has a <nextTop>. All indexes before are
34 * promised to hold smaller values than the current.
36 typedef struct _EventSetEntry EventSetEntry;
37 struct _EventSetEntry {
41 typedef struct _EventSet EventSet;
50 /* Some events out of an event set.
51 * Used to print out part of an EventSet, or in another order.
53 typedef struct _EventMapping EventMapping;
54 struct _EventMapping {
62 /* Allocate space for an event set */
63 EventSet* CLG_(get_eventset)(Char* n, Int capacity);
64 /* Incorporate a event type into a set, get start offset */
65 Int CLG_(add_eventtype)(EventSet* dst, EventType*);
66 /* Incorporate event types into a set, with ... < second < first */
67 Int CLG_(add_dep_event2)(EventSet* dst, EventType* e1, EventType* e2);
68 Int CLG_(add_dep_event3)(EventSet* dst,
69 EventType* e1, EventType* e2, EventType* e3);
70 Int CLG_(add_dep_event4)(EventSet* dst,
71 EventType* e1, EventType* e2, EventType* e3,
73 /* Incorporate one event set into another, get start offset */
74 Int CLG_(add_eventset)(EventSet* dst, EventSet* src);
75 /* Returns number of characters written */
76 Int CLG_(sprint_eventset)(Char* buf, EventSet*);
77 /* Allocate cost array for an event set */
78 ULong* CLG_(get_eventset_cost)(EventSet*);
80 /* Operations on costs. A cost pointer of 0 means zero cost.
81 * Functions ending in _lz allocate costs lazy if needed
83 /* Set costs according full capacity of event set to 0 */
84 void CLG_(init_cost)(EventSet*,ULong*);
85 /* This always allocates counter and sets them to 0 */
86 void CLG_(init_cost_lz)(EventSet*,ULong**);
87 /* Set costs of an event set to zero */
88 void CLG_(zero_cost)(EventSet*,ULong*);
89 Bool CLG_(is_zero_cost)(EventSet*,ULong*);
90 Bool CLG_(is_equal_cost)(EventSet*,ULong*,ULong*);
91 void CLG_(copy_cost)(EventSet*,ULong* dst, ULong* src);
92 void CLG_(copy_cost_lz)(EventSet*,ULong** pdst, ULong* src);
93 void CLG_(add_cost)(EventSet*,ULong* dst, ULong* src);
94 void CLG_(add_cost_lz)(EventSet*,ULong** pdst, ULong* src);
95 /* Adds src to dst and zeros src. Returns false if nothing changed */
96 Bool CLG_(add_and_zero_cost)(EventSet*,ULong* dst, ULong* src);
97 Bool CLG_(add_and_zero_cost_lz)(EventSet*,ULong** pdst, ULong* src);
98 /* Adds difference of new and old to to dst, and set old to new.
99 * Returns false if nothing changed */
100 Bool CLG_(add_diff_cost)(EventSet*,ULong* dst, ULong* old, ULong* new_cost);
101 Bool CLG_(add_diff_cost_lz)(EventSet*,ULong** pdst, ULong* old, ULong* new_cost);
102 /* Returns number of characters written */
103 Int CLG_(sprint_cost)(Char* buf, EventSet*, ULong*);
105 /* Allocate space for an event mapping */
106 EventMapping* CLG_(get_eventmapping)(EventSet*);
107 void CLG_(append_event)(EventMapping*, Char*);
108 /* Returns number of characters written */
109 Int CLG_(sprint_eventmapping)(Char* buf, EventMapping*);
110 /* Returns number of characters written */
111 Int CLG_(sprint_mappingcost)(Char* buf, EventMapping*, ULong*);
113 #endif /* CG_EVENTS */