Browse Source

Added Module* constructor argument to Memory and Ext.

cl-refactor
artur-zawlocki 10 years ago
parent
commit
1d17da1e5f
  1. 11
      evmcc/Compiler.cpp
  2. 5
      evmcc/Ext.cpp
  3. 4
      evmcc/Ext.h
  4. 4
      evmcc/Memory.cpp
  5. 2
      evmcc/Memory.h

11
evmcc/Compiler.cpp

@ -166,17 +166,16 @@ std::unique_ptr<llvm::Module> Compiler::compile(const dev::bytes& bytecode)
auto mainFuncType = FunctionType::get(builder.getInt64Ty(), false);
auto mainFunc = Function::Create(mainFuncType, Function::ExternalLinkage, "main", module.get());
// Init stack and memory
auto stack = Stack(builder, module.get());
auto memory = Memory(builder);
auto ext = Ext(builder);
// Create the basic blocks.
auto entryBlock = BasicBlock::Create(context, "entry", mainFunc);
basicBlocks[0] = entryBlock;
createBasicBlocks(bytecode);
// Init runtime structures.
auto stack = Stack(builder, module.get());
auto memory = Memory(builder, module.get());
auto ext = Ext(builder, module.get());
auto userRet = false;
auto finished = false;

5
evmcc/Ext.cpp

@ -43,10 +43,9 @@ struct ExtData
const byte* calldata;
};
Ext::Ext(llvm::IRBuilder<>& _builder)
Ext::Ext(llvm::IRBuilder<>& _builder, llvm::Module* module)
: m_builder(_builder)
{
auto module = m_builder.GetInsertBlock()->getParent()->getParent();
auto&& ctx = _builder.getContext();
auto i256Ty = m_builder.getIntNTy(256);
@ -148,4 +147,4 @@ EXPORT void ext_calldataload(i256* _index, i256* _value)
}
}
}

4
evmcc/Ext.h

@ -13,7 +13,7 @@ namespace evmcc
class Ext
{
public:
Ext(llvm::IRBuilder<>& _builder);
Ext(llvm::IRBuilder<>& _builder, llvm::Module* module);
static void init(std::unique_ptr<dev::eth::ExtVMFace> _ext);
llvm::Value* store(llvm::Value* _index);
@ -43,4 +43,4 @@ private:
};
}
}

4
evmcc/Memory.cpp

@ -26,13 +26,11 @@ using MemoryImpl = dev::bytes;
static MemoryImpl* evmccrt_memory;
Memory::Memory(llvm::IRBuilder<>& _builder)
Memory::Memory(llvm::IRBuilder<>& _builder, llvm::Module* module)
: m_builder(_builder)
{
auto voidTy = m_builder.getVoidTy();
auto i64Ty = m_builder.getInt64Ty();
auto module = _builder.GetInsertBlock()->getParent()->getParent();
auto memRequireTy = llvm::FunctionType::get(m_builder.getInt8PtrTy(), i64Ty, false);
m_memRequire = llvm::Function::Create(memRequireTy,

2
evmcc/Memory.h

@ -10,7 +10,7 @@ namespace evmcc
class Memory
{
public:
Memory(llvm::IRBuilder<>& _builder);
Memory(llvm::IRBuilder<>& _builder, llvm::Module* module);
static const dev::bytes& init();

Loading…
Cancel
Save