Thomas Lively | aab7099 | 2016-06-07 13:54:59 -0700 | [diff] [blame^] | 1 | //===- 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 | |
| 33 | namespace Ice { |
| 34 | |
| 35 | class LoweringContext; |
| 36 | |
| 37 | class Instrumentation { |
| 38 | Instrumentation() = delete; |
| 39 | Instrumentation(const Instrumentation &) = delete; |
| 40 | Instrumentation &operator=(const Instrumentation &) = delete; |
| 41 | |
| 42 | public: |
| 43 | Instrumentation(GlobalContext *Ctx) : Ctx(Ctx) {} |
| 44 | virtual void instrumentGlobals() {}; |
| 45 | void instrumentFunc(Cfg *Func); |
| 46 | |
| 47 | private: |
| 48 | void instrumentInst(LoweringContext &Context); |
| 49 | virtual void instrumentFuncStart(LoweringContext &Context) { |
| 50 | (void) Context; |
| 51 | } |
| 52 | virtual void instrumentAlloca(LoweringContext &Context, |
| 53 | const class InstAlloca *Instr) { |
| 54 | (void) Context; |
| 55 | (void) Instr; |
| 56 | } |
| 57 | virtual void instrumentArithmetic(LoweringContext &Context, |
| 58 | const class InstArithmetic *Instr) { |
| 59 | (void) Context; |
| 60 | (void) Instr; |
| 61 | } |
| 62 | virtual void instrumentBr(LoweringContext &Context, |
| 63 | const class InstBr *Instr) { |
| 64 | (void) Context; |
| 65 | (void) Instr; |
| 66 | } |
| 67 | virtual void instrumentCall(LoweringContext &Context, |
| 68 | const class InstCall *Instr) { |
| 69 | (void) Context; |
| 70 | (void) Instr; |
| 71 | } |
| 72 | virtual void instrumentCast(LoweringContext &Context, |
| 73 | const class InstCast *Instr) { |
| 74 | (void) Context; |
| 75 | (void) Instr; |
| 76 | } |
| 77 | virtual void instrumentExtractElement(LoweringContext &Context, |
| 78 | const class InstExtractElement *Instr) { |
| 79 | (void) Context; |
| 80 | (void) Instr; |
| 81 | } |
| 82 | virtual void instrumentFcmp(LoweringContext &Context, |
| 83 | const class InstFcmp *Instr) { |
| 84 | (void) Context; |
| 85 | (void) Instr; |
| 86 | } |
| 87 | virtual void instrumentIcmp(LoweringContext &Context, |
| 88 | const class InstIcmp *Instr) { |
| 89 | (void) Context; |
| 90 | (void) Instr; |
| 91 | } |
| 92 | virtual void instrumentInsertElement(LoweringContext &Context, |
| 93 | const class InstInsertElement *Instr) { |
| 94 | (void) Context; |
| 95 | (void) Instr; |
| 96 | } |
| 97 | virtual void instrumentIntrinsicCall(LoweringContext &Context, |
| 98 | const class InstIntrinsicCall *Instr) { |
| 99 | (void) Context; |
| 100 | (void) Instr; |
| 101 | } |
| 102 | virtual void instrumentLoad(LoweringContext &Context, |
| 103 | const class InstLoad *Instr) { |
| 104 | (void) Context; |
| 105 | (void) Instr; |
| 106 | } |
| 107 | virtual void instrumentPhi(LoweringContext &Context, |
| 108 | const class InstPhi *Instr) { |
| 109 | (void) Context; |
| 110 | (void) Instr; |
| 111 | } |
| 112 | virtual void instrumentRet(LoweringContext &Context, |
| 113 | const class InstRet *Instr) { |
| 114 | (void) Context; |
| 115 | (void) Instr; |
| 116 | } |
| 117 | virtual void instrumentSelect(LoweringContext &Context, |
| 118 | const class InstSelect *Instr) { |
| 119 | (void) Context; |
| 120 | (void) Instr; |
| 121 | } |
| 122 | virtual void instrumentStore(LoweringContext &Context, |
| 123 | const class InstStore *Instr) { |
| 124 | (void) Context; |
| 125 | (void) Instr; |
| 126 | } |
| 127 | virtual void instrumentSwitch(LoweringContext &Context, |
| 128 | const class InstSwitch *Instr) { |
| 129 | (void) Context; |
| 130 | (void) Instr; |
| 131 | } |
| 132 | virtual void instrumentUnreachable(LoweringContext &Context, |
| 133 | const class InstUnreachable *Instr) { |
| 134 | (void) Context; |
| 135 | (void) Instr; |
| 136 | } |
| 137 | virtual void instrumentLocalVars(Cfg *Func) { |
| 138 | (void) Func; |
| 139 | } |
| 140 | |
| 141 | protected: |
| 142 | GlobalContext *Ctx; |
| 143 | }; |
| 144 | |
| 145 | } // end of namespace Ice |
| 146 | |
| 147 | #endif // SUBZERO_SRC_ICEINSTRUMENTATION_H |