Index: src/IceInstrumentation.cpp |
diff --git a/src/IceInstrumentation.cpp b/src/IceInstrumentation.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bbe345c6717cfde81965b0f3cde5f3d8be7ca9de |
--- /dev/null |
+++ b/src/IceInstrumentation.cpp |
@@ -0,0 +1,100 @@ |
+//===- subzero/src/IceInstrumentation.cpp - ICE intrumentation framework --===// |
Karl
2016/06/06 22:27:03
Spelling intrumentation?
tlively
2016/06/07 00:43:06
Done.
|
+// |
+// The Subzero Code Generator |
+// |
+// This file is distributed under the University of Illinois Open Source |
+// License. See LICENSE.TXT for details. |
+// |
+//===----------------------------------------------------------------------===// |
+/// |
+/// \file |
+/// \brief Implements the Ice::Instrumentation class. |
+/// |
+/// Subclasses can override particular instrumentation methods to specify how |
+/// the the target program should be instrumented. |
+/// |
+//===----------------------------------------------------------------------===// |
+ |
+#include "IceInstrumentation.h" |
+ |
+#include "IceCfg.h" |
+#include "IceInst.h" |
+#include "IceTargetLowering.h" |
+ |
+namespace Ice { |
+ |
+void Instrumentation::instrumentFunc(Cfg *Func) { |
+ assert(Func); |
+ LoweringContext Context; |
+ for (CfgNode *Node : Func->getNodes()) { |
+ Context.init(Node); |
+ instrumentFuncStart(Context); |
Karl
2016/06/06 22:27:02
Since there is no implementation details, it is ha
tlively
2016/06/07 00:43:06
This call should have been outside the loop. Fixed
|
+ while (!Context.atEnd()) |
+ instrumentInst(Context); |
+ } |
+} |
+ |
+void Instrumentation::instrumentInst(LoweringContext &Context) { |
+ assert(!Context.atEnd()); |
+ Inst *Instr = iteratorToInst(Context.getCur()); |
+ switch (Instr->getKind()) { |
+ case Inst::Alloca: |
+ instrumentAlloca(Context, llvm::cast<InstAlloca>(Instr)); |
+ break; |
+ case Inst::Arithmetic: |
+ instrumentArithmetic(Context, llvm::cast<InstArithmetic>(Instr)); |
+ break; |
+ case Inst::Br: |
+ instrumentBr(Context, llvm::cast<InstBr>(Instr)); |
+ break; |
+ case Inst::Call: |
+ instrumentCall(Context, llvm::cast<InstCall>(Instr)); |
+ break; |
+ case Inst::Cast: |
+ instrumentCast(Context, llvm::cast<InstCast>(Instr)); |
+ break; |
+ case Inst::ExtractElement: |
+ instrumentExtractElement(Context, llvm::cast<InstExtractElement>(Instr)); |
+ break; |
+ case Inst::Fcmp: |
+ instrumentFcmp(Context, llvm::cast<InstFcmp>(Instr)); |
+ break; |
+ case Inst::Icmp: |
+ instrumentIcmp(Context, llvm::cast<InstIcmp>(Instr)); |
+ break; |
+ case Inst::InsertElement: |
+ instrumentInsertElement(Context, llvm::cast<InstInsertElement>(Instr)); |
+ break; |
+ case Inst::IntrinsicCall: |
+ instrumentIntrinsicCall(Context, llvm::cast<InstIntrinsicCall>(Instr)); |
+ break; |
+ case Inst::Load: |
+ instrumentLoad(Context, llvm::cast<InstLoad>(Instr)); |
+ break; |
+ case Inst::Phi: |
+ instrumentPhi(Context, llvm::cast<InstPhi>(Instr)); |
+ break; |
+ case Inst::Ret: |
+ instrumentRet(Context, llvm::cast<InstRet>(Instr)); |
+ break; |
+ case Inst::Select: |
+ instrumentSelect(Context, llvm::cast<InstSelect>(Instr)); |
+ break; |
+ case Inst::Store: |
+ instrumentStore(Context, llvm::cast<InstStore>(Instr)); |
+ break; |
+ case Inst::Switch: |
+ instrumentSwitch(Context, llvm::cast<InstSwitch>(Instr)); |
+ break; |
+ case Inst::Unreachable: |
+ instrumentUnreachable(Context, llvm::cast<InstUnreachable>(Instr)); |
+ break; |
+ default: |
Roland McGrath
2016/06/06 22:28:45
This will silently ignore any other kinds of instr
tlively
2016/06/07 00:43:05
I added an assert with documentation of why the ot
|
+ break; |
+ } |
+ |
+ Context.advanceCur(); |
+ Context.advanceNext(); |
+} |
+ |
+} // end of namespace Ice |