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) {} |
Thomas Lively | 3f5cb6f | 2016-06-13 11:23:29 -0700 | [diff] [blame] | 44 | virtual void instrumentGlobals(VariableDeclarationList &) {} |
Thomas Lively | aab7099 | 2016-06-07 13:54:59 -0700 | [diff] [blame] | 45 | void instrumentFunc(Cfg *Func); |
| 46 | |
| 47 | private: |
| 48 | void instrumentInst(LoweringContext &Context); |
Thomas Lively | 3f5cb6f | 2016-06-13 11:23:29 -0700 | [diff] [blame] | 49 | 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 Lively | 4e81fe0 | 2016-06-15 10:00:21 -0700 | [diff] [blame^] | 72 | virtual void instrumentStart(Cfg *) {} |
Thomas Lively | 3f5cb6f | 2016-06-13 11:23:29 -0700 | [diff] [blame] | 73 | virtual void instrumentLocalVars(Cfg *) {} |
Thomas Lively | aab7099 | 2016-06-07 13:54:59 -0700 | [diff] [blame] | 74 | |
| 75 | protected: |
| 76 | GlobalContext *Ctx; |
| 77 | }; |
| 78 | |
| 79 | } // end of namespace Ice |
| 80 | |
| 81 | #endif // SUBZERO_SRC_ICEINSTRUMENTATION_H |