MCPcopy Create free account
hub / github.com/LUX-Core/lux / compileBasicBlock

Method compileBasicBlock

src/cpp-ethereum/evmjit/libevmjit/Compiler.cpp:213–936  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211
212
213void Compiler::compileBasicBlock(BasicBlock& _basicBlock, RuntimeManager& _runtimeManager,
214 Arith256& _arith, Memory& _memory, Ext& _ext, GasMeter& _gasMeter)
215{
216 m_builder.SetInsertPoint(_basicBlock.llvm());
217 LocalStack stack{m_builder, _runtimeManager};
218
219 for (auto it = _basicBlock.begin(); it != _basicBlock.end(); ++it)
220 {
221 auto inst = Instruction(*it);
222
223 _gasMeter.count(inst);
224
225 switch (inst)
226 {
227
228 case Instruction::ADD:
229 {
230 auto lhs = stack.pop();
231 auto rhs = stack.pop();
232 auto result = m_builder.CreateAdd(lhs, rhs);
233 stack.push(result);
234 break;
235 }
236
237 case Instruction::SUB:
238 {
239 auto lhs = stack.pop();
240 auto rhs = stack.pop();
241 auto result = m_builder.CreateSub(lhs, rhs);
242 stack.push(result);
243 break;
244 }
245
246 case Instruction::MUL:
247 {
248 auto lhs = stack.pop();
249 auto rhs = stack.pop();
250 auto res = m_builder.CreateMul(lhs, rhs);
251 stack.push(res);
252 break;
253 }
254
255 case Instruction::DIV:
256 {
257 auto d = stack.pop();
258 auto n = stack.pop();
259 auto divByZero = m_builder.CreateICmpEQ(n, Constant::get(0));
260 n = m_builder.CreateSelect(divByZero, Constant::get(1), n); // protect against hardware signal
261 auto r = m_builder.CreateUDiv(d, n);
262 r = m_builder.CreateSelect(divByZero, Constant::get(0), r);
263 stack.push(r);
264 break;
265 }
266
267 case Instruction::SDIV:
268 {
269 auto d = stack.pop();
270 auto n = stack.pop();

Callers

nothing calls this directly

Calls 15

readPushDataFunction · 0.85
maxFunction · 0.85
llvmMethod · 0.80
countExpMethod · 0.80
expMethod · 0.80
requireMethod · 0.80
countSha3DataMethod · 0.80
dupMethod · 0.80
loadWordMethod · 0.80
storeWordMethod · 0.80
storeByteMethod · 0.80
sloadMethod · 0.80

Tested by

no test coverage detected