summaryrefslogtreecommitdiffstats
path: root/src/llvm/include/llvm-soft-perfmon.h
blob: c55201e740d611a7ebb2ff7f5d3c70e1e8a61571 (plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
/*
 *  (C) 2010 by Computer System Laboratory, IIS, Academia Sinica, Taiwan.
 *      See COPYRIGHT in top-level directory.
 */

#ifndef __LLVM_SOFT_PERFMON_H
#define __LLVM_SOFT_PERFMON_H

#include "utils.h"

#define MAX_SPM_THREADS 256

#define SPM_NONE      (uint64_t)0
#define SPM_BASIC     ((uint64_t)1 << 0)
#define SPM_TRACE     ((uint64_t)1 << 1)
#define SPM_CACHE     ((uint64_t)1 << 2)
#define SPM_PASS      ((uint64_t)1 << 3)
#define SPM_HPM       ((uint64_t)1 << 4)
#define SPM_EXIT      ((uint64_t)1 << 5)
#define SPM_HOTSPOT   ((uint64_t)1 << 6)
#define SPM_ALL       SPM_BASIC | SPM_TRACE | SPM_CACHE | SPM_PASS | SPM_HPM | \
                      SPM_EXIT | SPM_HOTSPOT
#define SPM_NUM       9


/*
 * Software Performance Monitor (SPM)
 */
class SoftwarePerfmon {
public:
    typedef void (*ExitFuncPtr)(void);

    uint64_t Mode;         /* Profile level */
    uint64_t NumInsns;     /* Number of instructions */
    uint64_t NumBranches;  /* Number of branches */
    uint64_t NumLoads;     /* Number of memory loads */
    uint64_t NumStores;    /* Number of memory stores */
    uint64_t NumTraceExits;    /* Count of trace exits */
    uint64_t SampleTime;   /* Process time of the sampling handler. */
    unsigned CoverSet;
    std::vector<std::vector<uint64_t> *> SampleListVec;

    SoftwarePerfmon()
        : Mode(SPM_NONE), NumInsns(0), NumBranches(0), NumLoads(0), NumStores(0),
          NumTraceExits(0), SampleTime(0), CoverSet(90) {}
    SoftwarePerfmon(std::string &ProfileLevel) : SoftwarePerfmon() {
        ParseProfileMode(ProfileLevel);
    }

    bool isEnabled() {
        return Mode != SPM_NONE;
    }

    void registerExitFn(ExitFuncPtr F) {
        ExitFunc.push_back(F);
    }

    void printProfile();

private:
    std::vector<ExitFuncPtr> ExitFunc;

    void ParseProfileMode(std::string &ProfileLevel);
    void printBlockProfile();
    void printTraceProfile();
};

extern SoftwarePerfmon *SP;

#endif /* __LLVM_SOFT_PERFMON_H */

/*
 * vim: ts=8 sts=4 sw=4 expandtab
 */
OpenPOWER on IntegriCloud