comparison lib/ExecutionEngine/Interpreter/Interpreter.h @ 95:afa8332a0e37 LLVM3.8

LLVM 3.8
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Tue, 13 Oct 2015 17:48:58 +0900
parents 60c9769439b8
children 7d135dc70f03
comparison
equal deleted inserted replaced
84:f3e34b893a5f 95:afa8332a0e37
93 93
94 // Interpreter - This class represents the entirety of the interpreter. 94 // Interpreter - This class represents the entirety of the interpreter.
95 // 95 //
96 class Interpreter : public ExecutionEngine, public InstVisitor<Interpreter> { 96 class Interpreter : public ExecutionEngine, public InstVisitor<Interpreter> {
97 GenericValue ExitValue; // The return value of the called function 97 GenericValue ExitValue; // The return value of the called function
98 DataLayout TD;
99 IntrinsicLowering *IL; 98 IntrinsicLowering *IL;
100 99
101 // The runtime stack of executing code. The top of the stack is the current 100 // The runtime stack of executing code. The top of the stack is the current
102 // function record. 101 // function record.
103 std::vector<ExecutionContext> ECStack; 102 std::vector<ExecutionContext> ECStack;
106 // registered with the atexit() library function. 105 // registered with the atexit() library function.
107 std::vector<Function*> AtExitHandlers; 106 std::vector<Function*> AtExitHandlers;
108 107
109 public: 108 public:
110 explicit Interpreter(std::unique_ptr<Module> M); 109 explicit Interpreter(std::unique_ptr<Module> M);
111 ~Interpreter(); 110 ~Interpreter() override;
112 111
113 /// runAtExitHandlers - Run any functions registered by the program's calls to 112 /// runAtExitHandlers - Run any functions registered by the program's calls to
114 /// atexit(3), which we intercept and store in AtExitHandlers. 113 /// atexit(3), which we intercept and store in AtExitHandlers.
115 /// 114 ///
116 void runAtExitHandlers(); 115 void runAtExitHandlers();
125 std::string *ErrorStr = nullptr); 124 std::string *ErrorStr = nullptr);
126 125
127 /// run - Start execution with the specified function and arguments. 126 /// run - Start execution with the specified function and arguments.
128 /// 127 ///
129 GenericValue runFunction(Function *F, 128 GenericValue runFunction(Function *F,
130 const std::vector<GenericValue> &ArgValues) override; 129 ArrayRef<GenericValue> ArgValues) override;
131 130
132 void *getPointerToNamedFunction(StringRef Name, 131 void *getPointerToNamedFunction(StringRef Name,
133 bool AbortOnFailure = true) override { 132 bool AbortOnFailure = true) override {
134 // FIXME: not implemented. 133 // FIXME: not implemented.
135 return nullptr; 134 return nullptr;
136 } 135 }
137 136
138 // Methods used to execute code: 137 // Methods used to execute code:
139 // Place a call on the stack 138 // Place a call on the stack
140 void callFunction(Function *F, const std::vector<GenericValue> &ArgVals); 139 void callFunction(Function *F, ArrayRef<GenericValue> ArgVals);
141 void run(); // Execute instructions until nothing left to do 140 void run(); // Execute instructions until nothing left to do
142 141
143 // Opcode Implementations 142 // Opcode Implementations
144 void visitReturnInst(ReturnInst &I); 143 void visitReturnInst(ReturnInst &I);
145 void visitBranchInst(BranchInst &I); 144 void visitBranchInst(BranchInst &I);
192 errs() << I << "\n"; 191 errs() << I << "\n";
193 llvm_unreachable("Instruction not interpretable yet!"); 192 llvm_unreachable("Instruction not interpretable yet!");
194 } 193 }
195 194
196 GenericValue callExternalFunction(Function *F, 195 GenericValue callExternalFunction(Function *F,
197 const std::vector<GenericValue> &ArgVals); 196 ArrayRef<GenericValue> ArgVals);
198 void exitCalled(GenericValue GV); 197 void exitCalled(GenericValue GV);
199 198
200 void addAtExitHandler(Function *F) { 199 void addAtExitHandler(Function *F) {
201 AtExitHandlers.push_back(F); 200 AtExitHandlers.push_back(F);
202 } 201 }