mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
Remove dummy int argument in entry function
This commit is contained in:
parent
2e1c90f828
commit
47d92e933a
3 changed files with 7 additions and 8 deletions
|
|
@ -157,10 +157,9 @@ std::unique_ptr<llvm::Module> Compiler::compile(bytes const& _bytecode)
|
||||||
auto module = std::unique_ptr<llvm::Module>(new llvm::Module("main", m_builder.getContext()));
|
auto module = std::unique_ptr<llvm::Module>(new llvm::Module("main", m_builder.getContext()));
|
||||||
|
|
||||||
// Create main function
|
// Create main function
|
||||||
llvm::Type* mainFuncArgTypes[] = {m_builder.getInt32Ty(), Type::RuntimePtr}; // There must be int in first place because LLVM does not support other signatures
|
auto mainFuncType = llvm::FunctionType::get(Type::MainReturn, Type::RuntimePtr, false);
|
||||||
auto mainFuncType = llvm::FunctionType::get(Type::MainReturn, mainFuncArgTypes, false);
|
|
||||||
m_mainFunc = llvm::Function::Create(mainFuncType, llvm::Function::ExternalLinkage, "main", module.get());
|
m_mainFunc = llvm::Function::Create(mainFuncType, llvm::Function::ExternalLinkage, "main", module.get());
|
||||||
m_mainFunc->arg_begin()->getNextNode()->setName("rt");
|
m_mainFunc->getArgumentList().front().setName("rt");
|
||||||
|
|
||||||
// Create the basic blocks.
|
// Create the basic blocks.
|
||||||
auto entryBlock = llvm::BasicBlock::Create(m_builder.getContext(), "entry", m_mainFunc);
|
auto entryBlock = llvm::BasicBlock::Create(m_builder.getContext(), "entry", m_mainFunc);
|
||||||
|
|
|
||||||
|
|
@ -111,14 +111,14 @@ namespace
|
||||||
{
|
{
|
||||||
ReturnCode runEntryFunc(ExecBundle const& _exec, Runtime* _runtime)
|
ReturnCode runEntryFunc(ExecBundle const& _exec, Runtime* _runtime)
|
||||||
{
|
{
|
||||||
typedef ReturnCode(*EntryFuncPtr)(int, Runtime*);
|
typedef ReturnCode(*EntryFuncPtr)(Runtime*);
|
||||||
auto entryFuncVoidPtr = _exec.engine->getPointerToFunction(_exec.entryFunc);
|
auto entryFuncVoidPtr = _exec.engine->getPointerToFunction(_exec.entryFunc);
|
||||||
auto entryFuncPtr = static_cast<EntryFuncPtr>(entryFuncVoidPtr);
|
auto entryFuncPtr = static_cast<EntryFuncPtr>(entryFuncVoidPtr);
|
||||||
|
|
||||||
ReturnCode returnCode{};
|
ReturnCode returnCode{};
|
||||||
auto sj = setjmp(_runtime->getJmpBuf());
|
auto sj = setjmp(_runtime->getJmpBuf());
|
||||||
if (sj == 0)
|
if (sj == 0)
|
||||||
returnCode = entryFuncPtr(0, _runtime); // FIXME: Remove int argument
|
returnCode = entryFuncPtr(_runtime);
|
||||||
else
|
else
|
||||||
returnCode = static_cast<ReturnCode>(sj);
|
returnCode = static_cast<ReturnCode>(sj);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ RuntimeManager::RuntimeManager(llvm::IRBuilder<>& _builder): CompilerHelper(_bui
|
||||||
|
|
||||||
// Export data
|
// Export data
|
||||||
auto mainFunc = getMainFunction();
|
auto mainFunc = getMainFunction();
|
||||||
llvm::Value* rtPtr = &mainFunc->getArgumentList().back();
|
llvm::Value* rtPtr = &mainFunc->getArgumentList().front();
|
||||||
m_builder.CreateStore(rtPtr, m_rtPtr);
|
m_builder.CreateStore(rtPtr, m_rtPtr);
|
||||||
auto dataPtr = m_builder.CreateStructGEP(rtPtr, 0, "dataPtr");
|
auto dataPtr = m_builder.CreateStructGEP(rtPtr, 0, "dataPtr");
|
||||||
auto data = m_builder.CreateLoad(dataPtr, "data");
|
auto data = m_builder.CreateLoad(dataPtr, "data");
|
||||||
|
|
@ -95,7 +95,7 @@ llvm::Value* RuntimeManager::getRuntimePtr()
|
||||||
{
|
{
|
||||||
// FIXME: Data ptr
|
// FIXME: Data ptr
|
||||||
//if (auto mainFunc = getMainFunction())
|
//if (auto mainFunc = getMainFunction())
|
||||||
// return mainFunc->arg_begin()->getNextNode(); // Runtime is the second parameter of main function
|
// return mainFunc->arg_begin(); // Runtime is the parameter of main function
|
||||||
return m_builder.CreateLoad(m_rtPtr, "rt");
|
return m_builder.CreateLoad(m_rtPtr, "rt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,7 +103,7 @@ llvm::Value* RuntimeManager::getDataPtr()
|
||||||
{
|
{
|
||||||
// FIXME: Data ptr
|
// FIXME: Data ptr
|
||||||
//if (auto mainFunc = getMainFunction())
|
//if (auto mainFunc = getMainFunction())
|
||||||
// return mainFunc->arg_begin()->getNextNode(); // Runtime is the second parameter of main function
|
// return mainFunc->arg_begin(); // Runtime is the parameter of main function
|
||||||
return m_builder.CreateLoad(m_dataPtr, "data");
|
return m_builder.CreateLoad(m_dataPtr, "data");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue