forked from boegel/MICA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmica_utils.h
62 lines (48 loc) · 1.66 KB
/
mica_utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* This file is part of MICA, a Pin tool to collect
* microarchitecture-independent program characteristics using the Pin
* instrumentation framework.
*
* Please see the README.txt file distributed with the MICA release for more
* information.
*/
#include "mica.h"
#ifndef MICA_UTILS
#define MICA_UTILS
/* *** utility functions *** */
#define WRAP(x) #x
#define REWRAP(x) WRAP(x)
#define LOCATION __BASE_FILE__ ":" __FILE__ ":" REWRAP(__LINE__)
#define checked_malloc(size) ({ void *result = malloc (size); if (__builtin_expect (!result, false)) { ERROR_MSG ("Out of memory at " LOCATION "."); exit (1); }; result; })
#define checked_strdup(string) ({ char *result = strdup (string); if (__builtin_expect (!result, false)) { ERROR_MSG ("Out of memory at " LOCATION "."); exit (1); }; result; })
#define checked_realloc(ptr, size) ({ void *result = realloc (ptr, size); if (__builtin_expect (!result, false)) { ERROR_MSG ("Out of memory at " LOCATION "."); exit (1); }; result; })
/* *** struct definitions *** */
/* memory node struct */
typedef struct memNode_type{
/* ilp */
INT32 timeAvailable[MAX_MEM_ENTRIES];
/* memfootprint */
bool numReferenced [MAX_MEM_BLOCK];
} memNode;
/* linked list struct */
typedef struct nlist_type {
ADDRINT id;
memNode* mem;
struct nlist_type* next;
} nlist;
memNode* lookup(nlist** table, ADDRINT key);
memNode* install(nlist** table, ADDRINT key);
void free_nlist(nlist*& np);
typedef struct ins_buffer_entry_type {
ADDRINT insAddr;
BOOL setRead;
BOOL setWritten;
BOOL setRegOpCnt;
INT32 regOpCnt;
INT32 regReadCnt;
REG* regsRead;
INT32 regWriteCnt;
REG* regsWritten;
ins_buffer_entry_type* next;
} ins_buffer_entry;
#endif