blob: 8b7e2e78f0c9cfa2b12349d4ff92704534d32b01 [file] [log] [blame]
Thomas Livelyaab70992016-06-07 13:54:59 -07001//===- subzero/src/IceInstrumentation.h - ICE instrumentation ---*- C++ -*-===//
2//
3// The Subzero Code Generator
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9///
10/// \file
11/// \brief Declares the Ice::Instrumentation class.
12///
13/// Instrumentation is an abstract class used to drive the instrumentation
14/// process for tools such as AddressSanitizer and MemorySanitizer. It uses a
15/// LoweringContext to enable the insertion of new instructions into a given
16/// Cfg. Although Instrumentation is an abstract class, each of its virtual
17/// functions has a trivial default implementation to make subclasses more
18/// succinct.
19///
20/// If instrumentation is required by the command line arguments, a single
21/// Instrumentation subclass is instantiated and installed in the
22/// GlobalContext. If multiple types of instrumentation are requested, a single
23/// subclass is still responsible for driving the instrumentation, but it can
24/// use other Instrumentation subclasses however it needs to.
25///
26//===----------------------------------------------------------------------===//
27
28#ifndef SUBZERO_SRC_ICEINSTRUMENTATION_H
29#define SUBZERO_SRC_ICEINSTRUMENTATION_H
30
31#include "IceDefs.h"
32
33namespace Ice {
34
35class LoweringContext;
36
37class Instrumentation {
38 Instrumentation() = delete;
39 Instrumentation(const Instrumentation &) = delete;
40 Instrumentation &operator=(const Instrumentation &) = delete;
41
42public:
43 Instrumentation(GlobalContext *Ctx) : Ctx(Ctx) {}
Thomas Lively3f5cb6f2016-06-13 11:23:29 -070044 virtual void instrumentGlobals(VariableDeclarationList &) {}
Thomas Livelyaab70992016-06-07 13:54:59 -070045 void instrumentFunc(Cfg *Func);
46
47private:
48 void instrumentInst(LoweringContext &Context);
Thomas Lively3f5cb6f2016-06-13 11:23:29 -070049 virtual void instrumentFuncStart(LoweringContext &) {}
50 virtual void instrumentAlloca(LoweringContext &, const class InstAlloca *) {}
51 virtual void instrumentArithmetic(LoweringContext &,
52 const class InstArithmetic *) {}
53 virtual void instrumentBr(LoweringContext &, const class InstBr *) {}
54 virtual void instrumentCall(LoweringContext &, const class InstCall *) {}
55 virtual void instrumentCast(LoweringContext &, const class InstCast *) {}
56 virtual void instrumentExtractElement(LoweringContext &,
57 const class InstExtractElement *) {}
58 virtual void instrumentFcmp(LoweringContext &, const class InstFcmp *) {}
59 virtual void instrumentIcmp(LoweringContext &, const class InstIcmp *) {}
60 virtual void instrumentInsertElement(LoweringContext &,
61 const class InstInsertElement *) {}
62 virtual void instrumentIntrinsicCall(LoweringContext &,
63 const class InstIntrinsicCall *) {}
64 virtual void instrumentLoad(LoweringContext &, const class InstLoad *) {}
65 virtual void instrumentPhi(LoweringContext &, const class InstPhi *) {}
66 virtual void instrumentRet(LoweringContext &, const class InstRet *) {}
67 virtual void instrumentSelect(LoweringContext &, const class InstSelect *) {}
68 virtual void instrumentStore(LoweringContext &, const class InstStore *) {}
69 virtual void instrumentSwitch(LoweringContext &, const class InstSwitch *) {}
70 virtual void instrumentUnreachable(LoweringContext &,
71 const class InstUnreachable *) {}
Thomas Lively4e81fe02016-06-15 10:00:21 -070072 virtual void instrumentStart(Cfg *) {}
Thomas Lively3f5cb6f2016-06-13 11:23:29 -070073 virtual void instrumentLocalVars(Cfg *) {}
Thomas Livelyaab70992016-06-07 13:54:59 -070074
75protected:
76 GlobalContext *Ctx;
77};
78
79} // end of namespace Ice
80
81#endif // SUBZERO_SRC_ICEINSTRUMENTATION_H