From 4992aa21c05a8476ea38d4fc2b207231b04d5b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 14 May 2015 10:50:37 +0200 Subject: [PATCH] Remove unused code --- libevmjit/Stack.cpp | 90 --------------------------------------------- libevmjit/Stack.h | 3 -- 2 files changed, 93 deletions(-) diff --git a/libevmjit/Stack.cpp b/libevmjit/Stack.cpp index 7cf514dea..b47567f17 100644 --- a/libevmjit/Stack.cpp +++ b/libevmjit/Stack.cpp @@ -23,96 +23,6 @@ Stack::Stack(llvm::IRBuilder<>& _builder, RuntimeManager& _runtimeManager): m_stack(_builder, "stack") {} -llvm::Function* Stack::getPushFunc() -{ - auto& func = m_push; - if (!func) - { - llvm::Type* argTypes[] = {Type::RuntimePtr, Type::Word}; - func = llvm::Function::Create(llvm::FunctionType::get(Type::Void, argTypes, false), llvm::Function::ExternalLinkage, "stack.push", getModule()); - llvm::Type* extArgTypes[] = {Type::RuntimePtr, Type::WordPtr}; - auto extPushFunc = llvm::Function::Create(llvm::FunctionType::get(Type::Void, extArgTypes, false), llvm::Function::ExternalLinkage, "stack_push", getModule()); - - auto rt = &func->getArgumentList().front(); - rt->setName("rt"); - auto value = rt->getNextNode(); - value->setName("value"); - - InsertPointGuard guard{m_builder}; - auto entryBB = llvm::BasicBlock::Create(m_builder.getContext(), {}, func); - m_builder.SetInsertPoint(entryBB); - auto a = m_builder.CreateAlloca(Type::Word); - m_builder.CreateStore(value, a); - createCall(extPushFunc, {rt, a}); - m_builder.CreateRetVoid(); - } - return func; -} - -llvm::Function* Stack::getSetFunc() -{ - auto& func = m_set; - if (!func) - { - llvm::Type* argTypes[] = {Type::RuntimePtr, Type::Size, Type::Word}; - func = llvm::Function::Create(llvm::FunctionType::get(Type::Void, argTypes, false), llvm::Function::ExternalLinkage, "stack.set", getModule()); - llvm::Type* extArgTypes[] = {Type::RuntimePtr, Type::Size, Type::WordPtr}; - auto extSetFunc = llvm::Function::Create(llvm::FunctionType::get(Type::Void, extArgTypes, false), llvm::Function::ExternalLinkage, "stack_set", getModule()); - - auto rt = &func->getArgumentList().front(); - rt->setName("rt"); - auto index = rt->getNextNode(); - index->setName("index"); - auto value = index->getNextNode(); - value->setName("value"); - - InsertPointGuard guard{m_builder}; - auto entryBB = llvm::BasicBlock::Create(m_builder.getContext(), {}, func); - m_builder.SetInsertPoint(entryBB); - auto a = m_builder.CreateAlloca(Type::Word); - m_builder.CreateStore(value, a); - createCall(extSetFunc, {rt, index, a}); - m_builder.CreateRetVoid(); - } - return func; -} - -llvm::Function* Stack::getPopFunc() -{ - auto& func = m_pop; - if (!func) - { - llvm::Type* argTypes[] = {Type::RuntimePtr, Type::Size, Type::BytePtr}; - func = llvm::Function::Create(llvm::FunctionType::get(Type::Void, argTypes, false), llvm::Function::ExternalLinkage, "stack.pop", getModule()); - llvm::Type* extArgTypes[] = {Type::RuntimePtr, Type::Size}; - auto extPopFunc = llvm::Function::Create(llvm::FunctionType::get(Type::Bool, extArgTypes, false), llvm::Function::ExternalLinkage, "stack_pop", getModule()); - - auto rt = &func->getArgumentList().front(); - rt->setName("rt"); - auto index = rt->getNextNode(); - index->setName("index"); - auto jmpBuf = index->getNextNode(); - jmpBuf->setName("jmpBuf"); - - InsertPointGuard guard{m_builder}; - auto entryBB = llvm::BasicBlock::Create(m_builder.getContext(), {}, func); - auto underflowBB = llvm::BasicBlock::Create(m_builder.getContext(), "Underflow", func); - auto returnBB = llvm::BasicBlock::Create(m_builder.getContext(), "Return", func); - - m_builder.SetInsertPoint(entryBB); - auto ok = createCall(extPopFunc, {rt, index}); - m_builder.CreateCondBr(ok, returnBB, underflowBB); //TODO: Add branch weight - - m_builder.SetInsertPoint(underflowBB); - m_runtimeManager.abort(jmpBuf); - m_builder.CreateUnreachable(); - - m_builder.SetInsertPoint(returnBB); - m_builder.CreateRetVoid(); - } - return func; -} - llvm::Function* Stack::getGetFunc() { auto& func = m_get; diff --git a/libevmjit/Stack.h b/libevmjit/Stack.h index 3c526f0d3..6f7ad1c0b 100644 --- a/libevmjit/Stack.h +++ b/libevmjit/Stack.h @@ -24,10 +24,7 @@ public: void free() { m_stack.free(); } private: - llvm::Function* getPopFunc(); - llvm::Function* getPushFunc(); llvm::Function* getGetFunc(); - llvm::Function* getSetFunc(); RuntimeManager& m_runtimeManager;