Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/IceInstrumentation.cpp

Issue 2042063002: Created Ice::Instrumentation base class and accompanying hooks. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Added minimum build checks, fixed other issues. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/IceGlobalContext.cpp ('K') | « src/IceInstrumentation.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 //===- subzero/src/IceInstrumentation.cpp - ICE instrumentation framework -===//
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 Implements the Ice::Instrumentation class.
12 ///
13 /// Subclasses can override particular instrumentation methods to specify how
14 /// the the target program should be instrumented.
15 ///
16 //===----------------------------------------------------------------------===//
17
18 #include "IceInstrumentation.h"
19
20 #include "IceCfg.h"
21 #include "IceInst.h"
22 #include "IceTargetLowering.h"
23
24 namespace Ice {
25
26 // Iterate through the instructions in the given CFG and instrument each one.
27 // Also instrument the beginning of the function.
28 void Instrumentation::instrumentFunc(Cfg *Func) {
29 assert(Func);
30 assert(!Func->getNodes().empty());
31
32 LoweringContext Context;
33 Context.init(Func->getNodes().front());
34 instrumentFuncStart(Context);
35 for (CfgNode *Node : Func->getNodes()) {
36 Context.init(Node);
37 while (!Context.atEnd())
38 instrumentInst(Context);
39 }
40 }
41
42 void Instrumentation::instrumentInst(LoweringContext &Context) {
43 assert(!Context.atEnd());
44 Inst *Instr = iteratorToInst(Context.getCur());
Karl 2016/06/07 14:42:41 You probably should check to verify the instructio
tlively 2016/06/07 18:14:42 Context.advanceNext() skips deleted instructions.
45 switch (Instr->getKind()) {
46 case Inst::Alloca:
47 instrumentAlloca(Context, llvm::cast<InstAlloca>(Instr));
48 break;
49 case Inst::Arithmetic:
50 instrumentArithmetic(Context, llvm::cast<InstArithmetic>(Instr));
51 break;
52 case Inst::Br:
53 instrumentBr(Context, llvm::cast<InstBr>(Instr));
54 break;
55 case Inst::Call:
56 instrumentCall(Context, llvm::cast<InstCall>(Instr));
57 break;
58 case Inst::Cast:
59 instrumentCast(Context, llvm::cast<InstCast>(Instr));
60 break;
61 case Inst::ExtractElement:
62 instrumentExtractElement(Context, llvm::cast<InstExtractElement>(Instr));
63 break;
64 case Inst::Fcmp:
65 instrumentFcmp(Context, llvm::cast<InstFcmp>(Instr));
66 break;
67 case Inst::Icmp:
68 instrumentIcmp(Context, llvm::cast<InstIcmp>(Instr));
69 break;
70 case Inst::InsertElement:
71 instrumentInsertElement(Context, llvm::cast<InstInsertElement>(Instr));
72 break;
73 case Inst::IntrinsicCall:
74 instrumentIntrinsicCall(Context, llvm::cast<InstIntrinsicCall>(Instr));
75 break;
76 case Inst::Load:
77 instrumentLoad(Context, llvm::cast<InstLoad>(Instr));
78 break;
79 case Inst::Phi:
80 instrumentPhi(Context, llvm::cast<InstPhi>(Instr));
81 break;
82 case Inst::Ret:
83 instrumentRet(Context, llvm::cast<InstRet>(Instr));
84 break;
85 case Inst::Select:
86 instrumentSelect(Context, llvm::cast<InstSelect>(Instr));
87 break;
88 case Inst::Store:
89 instrumentStore(Context, llvm::cast<InstStore>(Instr));
90 break;
91 case Inst::Switch:
92 instrumentSwitch(Context, llvm::cast<InstSwitch>(Instr));
93 break;
94 case Inst::Unreachable:
95 instrumentUnreachable(Context, llvm::cast<InstUnreachable>(Instr));
96 break;
97 default:
98 // Only instrument high-level ICE instructions
99 assert(false && "Instrumentation encountered an unexpected instruction");
100 break;
101 }
102
103 Context.advanceCur();
104 Context.advanceNext();
105 }
106
107 } // end of namespace Ice
OLDNEW
« src/IceGlobalContext.cpp ('K') | « src/IceInstrumentation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698