diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ba4431e2..e00919a18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,13 +50,14 @@ set(SUPPORT_MODULES_CONFIG_trace "-DTRACE") foreach(ARCH arm mips x86_64 i386 s390x) set(OUTPUT "early-linked-${ARCH}.ll") add_custom_command(OUTPUT "${OUTPUT}" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/early-linked.c" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/runtime/early-linked.c" COMMAND "${CLANG}" - ARGS "${CMAKE_CURRENT_SOURCE_DIR}/early-linked.c" + ARGS "${CMAKE_CURRENT_SOURCE_DIR}/runtime/early-linked.c" -o "${OUTPUT}" -S -emit-llvm -g -DTARGET_${ARCH} - -I"${CMAKE_CURRENT_SOURCE_DIR}/") + -I"${CMAKE_CURRENT_SOURCE_DIR}/runtime" + -I"${CMAKE_CURRENT_SOURCE_DIR}/include") add_custom_target("early-linked-module-${OUTPUT}" ALL DEPENDS "${OUTPUT}") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT}" DESTINATION share/revamb) @@ -64,13 +65,14 @@ foreach(ARCH arm mips x86_64 i386 s390x) foreach(CONFIG ${SUPPORT_MODULES_CONFIGS}) set(OUTPUT "support-${ARCH}-${CONFIG}.ll") add_custom_command(OUTPUT "${OUTPUT}" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/support.c" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/runtime/support.c" COMMAND "${CLANG}" - ARGS "${CMAKE_CURRENT_SOURCE_DIR}/support.c" + ARGS "${CMAKE_CURRENT_SOURCE_DIR}/runtime/support.c" -o "${OUTPUT}" -S -emit-llvm -g -DTARGET_${ARCH} - -I"${CMAKE_CURRENT_SOURCE_DIR}" + -I"${CMAKE_CURRENT_SOURCE_DIR}/runtime" + -I"${CMAKE_CURRENT_SOURCE_DIR}/include" ${SUPPORT_MODULES_CONFIG_${CONFIG}}) add_custom_target("support-module-${OUTPUT}" ALL DEPENDS "${OUTPUT}") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT}" @@ -138,59 +140,19 @@ set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}") include_directories(./ include/) add_subdirectory(lib) +add_subdirectory(tools) -add_executable(revamb - binaryfile.cpp - codegenerator.cpp - cpustateaccessanalysis.cpp - debug.cpp - debughelper.cpp - externaljumpshandler.cpp - functionboundariesdetection.cpp - functioncallidentification.cpp - generatedcodebasicinfo.cpp - instructiontranslator.cpp - jumptargetmanager.cpp - main.cpp - noreturnanalysis.cpp - osra.cpp - ptcdump.cpp - reachingdefinitions.cpp - revng-assert.cpp - set.cpp - simplifycomparisons.cpp - statistics.cpp - variablemanager.cpp - argparse/argparse.c) -target_link_libraries(revamb dl m ${LLVM_LIBRARIES}) -install(TARGETS revamb RUNTIME DESTINATION bin) - -add_executable(revamb-dump - dump.cpp - collectcfg.cpp - collectnoreturn.cpp - debug.cpp - collectfunctionboundaries.cpp - debughelper.cpp - generatedcodebasicinfo.cpp - isolatefunctions.cpp - revng-assert.cpp - statistics.cpp - argparse/argparse.c) -target_link_libraries(revamb-dump StackAnalysis ${LLVM_LIBRARIES}) -install(TARGETS revamb-dump RUNTIME DESTINATION bin) - -configure_file(csv-to-ld-options "${CMAKE_BINARY_DIR}/csv-to-ld-options" COPYONLY) -configure_file(support.c "${CMAKE_BINARY_DIR}/support.c" COPYONLY) -configure_file(support.h "${CMAKE_BINARY_DIR}/support.h" COPYONLY) -configure_file(commonconstants.h "${CMAKE_BINARY_DIR}/commonconstants.h" COPYONLY) -configure_file(early-linked.c "${CMAKE_BINARY_DIR}/early-linked.c" COPYONLY) -configure_file(translate "${CMAKE_BINARY_DIR}/translate" COPYONLY) -configure_file(merge-dynamic.py "${CMAKE_BINARY_DIR}/merge-dynamic.py" COPYONLY) -install(PROGRAMS translate csv-to-ld-options merge-dynamic.py DESTINATION bin) -install(FILES support.c DESTINATION share/revamb) -install(FILES support.h DESTINATION share/revamb) -install(FILES commonconstants.h DESTINATION share/revamb) +configure_file(scripts/csv-to-ld-options "${CMAKE_BINARY_DIR}/csv-to-ld-options" COPYONLY) +configure_file(runtime/support.c "${CMAKE_BINARY_DIR}/support.c" COPYONLY) +configure_file(runtime/support.h "${CMAKE_BINARY_DIR}/support.h" COPYONLY) +configure_file(include/revng/Runtime/commonconstants.h "${CMAKE_BINARY_DIR}/commonconstants.h" COPYONLY) +configure_file(runtime/early-linked.c "${CMAKE_BINARY_DIR}/early-linked.c" COPYONLY) +configure_file(scripts/translate "${CMAKE_BINARY_DIR}/translate" COPYONLY) +configure_file(scripts/merge-dynamic.py "${CMAKE_BINARY_DIR}/merge-dynamic.py" COPYONLY) +install(PROGRAMS scripts/translate scripts/csv-to-ld-options scripts/merge-dynamic.py DESTINATION bin) +install(FILES runtime/support.c DESTINATION share/revamb) +install(FILES runtime/support.h DESTINATION share/revamb) +install(FILES include/revng/Runtime/commonconstants.h DESTINATION share/revamb) # Remove -rdynamic set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) diff --git a/lazysmallbitvector.h b/include/revng/ADT/LazySmallBitVector.h similarity index 99% rename from lazysmallbitvector.h rename to include/revng/ADT/LazySmallBitVector.h index c62024f2a..a23822a06 100644 --- a/lazysmallbitvector.h +++ b/include/revng/ADT/LazySmallBitVector.h @@ -6,7 +6,6 @@ // // Standard includes -#include "revng-assert.h" #include #include #include @@ -18,6 +17,9 @@ extern "C" { // Boost includes #include +// Local libraries includes +#include "revng/Support/Assert.h" + // TODO: implement shrinking // TODO: implement using __builtin_clz if available diff --git a/datastructures.h b/include/revng/ADT/Queue.h similarity index 51% rename from datastructures.h rename to include/revng/ADT/Queue.h index 936b631a3..9c8914b8b 100644 --- a/datastructures.h +++ b/include/revng/ADT/Queue.h @@ -1,16 +1,16 @@ -#ifndef DATASTRUCTURES_H -#define DATASTRUCTURES_H +#ifndef QUEUE_H +#define QUEUE_H // // This file is distributed under the MIT License. See LICENSE.md for details. // // Standard includes -#include "revng-assert.h" -#include #include #include -#include + +// Local libraries includes +#include "revng/Support/Assert.h" /// \brief Queue where an element cannot be re-inserted if it's already in the /// queue @@ -59,42 +59,4 @@ using UniquedQueue = QueueImpl; template using OnceQueue = QueueImpl; -/// \brief Stack where an element cannot be re-inserted in it's already in the -/// stack -template -class UniquedStack { -public: - void insert(T Element) { - if (Set.count(Element) == 0) { - revng_assert(Element->getParent() != nullptr); - Set.insert(Element); - Queue.push_back(Element); - } - } - - bool empty() const { return Queue.empty(); } - - T pop() { - T Result = Queue.back(); - Queue.pop_back(); - Set.erase(Result); - return Result; - } - - /// \brief Reverses the stack in its current status - void reverse() { std::reverse(Queue.begin(), Queue.end()); } - - size_t size() const { return Queue.size(); } - -private: - std::set Set; - std::vector Queue; -}; - -template -inline void freeContainer(T &Container) { - T Empty; - Empty.swap(Container); -} - -#endif // DATASTRUCTURES_H +#endif // QUEUE_H diff --git a/SmallMap.h b/include/revng/ADT/SmallMap.h similarity index 99% rename from SmallMap.h rename to include/revng/ADT/SmallMap.h index 9bf569a01..2f492ef8b 100644 --- a/SmallMap.h +++ b/include/revng/ADT/SmallMap.h @@ -12,8 +12,8 @@ // Boost includes #include -// Local includes -#include "revng-assert.h" +// Local libraries includes +#include "revng/Support/Assert.h" // TODO: test SmallMap diff --git a/include/revng/ADT/UniquedStack.h b/include/revng/ADT/UniquedStack.h new file mode 100644 index 000000000..10ff485ec --- /dev/null +++ b/include/revng/ADT/UniquedStack.h @@ -0,0 +1,48 @@ +#ifndef UNIQUEDSTACK_H +#define UNIQUEDSTACK_H + +// +// This file is distributed under the MIT License. See LICENSE.md for details. +// + +// Standard includes +#include +#include +#include + +// Local libraries includes +#include "revng/Support/Assert.h" + +/// \brief Stack where an element cannot be re-inserted in it's already in the +/// stack +template +class UniquedStack { +public: + void insert(T Element) { + if (Set.count(Element) == 0) { + revng_assert(Element->getParent() != nullptr); + Set.insert(Element); + Queue.push_back(Element); + } + } + + bool empty() const { return Queue.empty(); } + + T pop() { + T Result = Queue.back(); + Queue.pop_back(); + Set.erase(Result); + return Result; + } + + /// \brief Reverses the stack in its current status + void reverse() { std::reverse(Queue.begin(), Queue.end()); } + + size_t size() const { return Queue.size(); } + +private: + std::set Set; + std::vector Queue; +}; + +#endif // UNIQUEDSTACK_H diff --git a/functioncallidentification.h b/include/revng/BasicAnalyses/FunctionCallIdentification.h similarity index 95% rename from functioncallidentification.h rename to include/revng/BasicAnalyses/FunctionCallIdentification.h index dbee94b17..a54a429df 100644 --- a/functioncallidentification.h +++ b/include/revng/BasicAnalyses/FunctionCallIdentification.h @@ -12,9 +12,9 @@ #include "llvm/Pass.h" #include "llvm/Support/Casting.h" -// Local includes -#include "generatedcodebasicinfo.h" -#include "ir-helpers.h" +// Local libraries includes +#include "revng/BasicAnalyses/GeneratedCodeBasicInfo.h" +#include "revng/Support/IRHelpers.h" /// \brief Identify function call instructions /// diff --git a/generatedcodebasicinfo.h b/include/revng/BasicAnalyses/GeneratedCodeBasicInfo.h similarity index 98% rename from generatedcodebasicinfo.h rename to include/revng/BasicAnalyses/GeneratedCodeBasicInfo.h index 69ff7e330..ee848c852 100644 --- a/generatedcodebasicinfo.h +++ b/include/revng/BasicAnalyses/GeneratedCodeBasicInfo.h @@ -14,9 +14,9 @@ #include "llvm/Pass.h" #include "llvm/Support/Casting.h" -// Local includes -#include "ir-helpers.h" -#include "revamb.h" +// Local libraries includes +#include "revng/Support/IRHelpers.h" +#include "revng/Support/revng.h" // Forward declarations namespace llvm { @@ -244,7 +244,7 @@ public: /// \brief Calls \p Visitor for each instruction preceeding \p I /// - /// See visitPredecessors in ir-helpers.h + /// See visitPredecessors in revng/Support/IRHelpers.h void visitPredecessors(llvm::Instruction *I, RVisitorFunction Visitor); llvm::BasicBlock *anyPC() { return AnyPC; } diff --git a/debughelper.h b/include/revng/DebugHelper/DebugHelper.h similarity index 98% rename from debughelper.h rename to include/revng/DebugHelper/DebugHelper.h index 632989ca2..a24b52aa8 100644 --- a/debughelper.h +++ b/include/revng/DebugHelper/DebugHelper.h @@ -13,8 +13,8 @@ // LLVM includes #include "llvm/IR/DIBuilder.h" -// Local includes -#include "revamb.h" +// Local libraries includes +#include "revng/Support/revng.h" namespace llvm { class DIBuilder; diff --git a/commonconstants.h b/include/revng/Runtime/commonconstants.h similarity index 100% rename from commonconstants.h rename to include/revng/Runtime/commonconstants.h diff --git a/include/revng/StackAnalysis/functionssummary.h b/include/revng/StackAnalysis/FunctionsSummary.h similarity index 99% rename from include/revng/StackAnalysis/functionssummary.h rename to include/revng/StackAnalysis/FunctionsSummary.h index 1b3bec23a..270b94797 100644 --- a/include/revng/StackAnalysis/functionssummary.h +++ b/include/revng/StackAnalysis/FunctionsSummary.h @@ -11,11 +11,12 @@ #include #include -// Local includes -#include "debug.h" +// Local libraries includes +#include "revng/Support/Debug.h" namespace llvm { class BasicBlock; +class GlobalVariable; class Instruction; class Module; } // namespace llvm diff --git a/include/revng/StackAnalysis/stackanalysis.h b/include/revng/StackAnalysis/StackAnalysis.h similarity index 84% rename from include/revng/StackAnalysis/stackanalysis.h rename to include/revng/StackAnalysis/StackAnalysis.h index 093b98ee0..079c4513d 100644 --- a/include/revng/StackAnalysis/stackanalysis.h +++ b/include/revng/StackAnalysis/StackAnalysis.h @@ -11,10 +11,10 @@ // LLVM includes #include "llvm/Pass.h" -// Local includes -#include "functioncallidentification.h" -#include "functionssummary.h" -#include "generatedcodebasicinfo.h" +// Local libraries includes +#include "revng/BasicAnalyses/FunctionCallIdentification.h" +#include "revng/BasicAnalyses/GeneratedCodeBasicInfo.h" +#include "revng/StackAnalysis/FunctionsSummary.h" namespace StackAnalysis { diff --git a/revng-assert.h b/include/revng/Support/Assert.h similarity index 100% rename from revng-assert.h rename to include/revng/Support/Assert.h diff --git a/valgrindhelpers.h b/include/revng/Support/Callgrind.h similarity index 100% rename from valgrindhelpers.h rename to include/revng/Support/Callgrind.h diff --git a/classsentinel.h b/include/revng/Support/ClassSentinel.h similarity index 97% rename from classsentinel.h rename to include/revng/Support/ClassSentinel.h index b728f5a04..350ebcdb6 100644 --- a/classsentinel.h +++ b/include/revng/Support/ClassSentinel.h @@ -1,17 +1,15 @@ #ifndef CLASSSENTINEL_H #define CLASSSENTINEL_H -// Standard includes -#include "revng-assert.h" - #ifdef SENTINEL_STACKTRACES extern "C" { #include } #endif -// Local includes -#include "debug.h" +// Local libraries includes +#include "revng/Support/Assert.h" +#include "revng/Support/Debug.h" #ifdef SENTINEL_STACKTRACES class StackTrace { diff --git a/debug.h b/include/revng/Support/Debug.h similarity index 99% rename from debug.h rename to include/revng/Support/Debug.h index d07148716..afdc2da09 100644 --- a/debug.h +++ b/include/revng/Support/Debug.h @@ -17,8 +17,8 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" -// Local includes -#include "revng-assert.h" +// Local libraries includes +#include "revng/Support/Assert.h" // TODO: use a dedicated namespace extern bool DebuggingEnabled; diff --git a/ir-helpers.h b/include/revng/Support/IRHelpers.h similarity index 99% rename from ir-helpers.h rename to include/revng/Support/IRHelpers.h index 46176cf51..dbe2bd69e 100644 --- a/ir-helpers.h +++ b/include/revng/Support/IRHelpers.h @@ -22,14 +22,20 @@ #include "llvm/IR/Metadata.h" #include "llvm/IR/Module.h" -// Local includes -#include "debug.h" +// Local libraries includes +#include "revng/Support/Debug.h" template inline bool contains(T Range, typename T::value_type V) { return std::find(std::begin(Range), std::end(Range), V) != std::end(Range); } +template +inline void freeContainer(T &Container) { + T Empty; + Empty.swap(Container); +} + /// Helper function to destroy an unconditional branch and, in case, the target /// basic block, if it doesn't have any predecessors left. inline void purgeBranch(llvm::BasicBlock::iterator I) { diff --git a/iteratorwrapper.h b/include/revng/Support/IteratorWrapper.h similarity index 100% rename from iteratorwrapper.h rename to include/revng/Support/IteratorWrapper.h diff --git a/rai.h b/include/revng/Support/RandomAccessIterator.h similarity index 97% rename from rai.h rename to include/revng/Support/RandomAccessIterator.h index 63df66478..e3b4e220f 100644 --- a/rai.h +++ b/include/revng/Support/RandomAccessIterator.h @@ -5,9 +5,12 @@ // This file is distributed under the MIT License. See LICENSE.md for details. // -#include "revng-assert.h" +// Standard includes #include +// Local libraries includes +#include "revng/Support/Assert.h" + template class RandomAccessIterator : public std::iterator { diff --git a/range.h b/include/revng/Support/Range.h similarity index 100% rename from range.h rename to include/revng/Support/Range.h diff --git a/statistics.h b/include/revng/Support/Statistics.h similarity index 98% rename from statistics.h rename to include/revng/Support/Statistics.h index 1ac6efad2..4c9d08f9b 100644 --- a/statistics.h +++ b/include/revng/Support/Statistics.h @@ -19,8 +19,8 @@ extern "C" { #include "llvm/ADT/Twine.h" #include "llvm/Support/ManagedStatic.h" -// Local includes -#include "debug.h" +// Local libraries includes +#include "revng/Support/Debug.h" const size_t MaxCounterMapDump = 32; diff --git a/transformadapter.h b/include/revng/Support/Transform.h similarity index 96% rename from transformadapter.h rename to include/revng/Support/Transform.h index 90f16b103..9f36d8a97 100644 --- a/transformadapter.h +++ b/include/revng/Support/Transform.h @@ -8,9 +8,9 @@ // Standard includes #include -// Local includes -#include "iteratorwrapper.h" -#include "range.h" +// Local libraries includes +#include "revng/Support/IteratorWrapper.h" +#include "revng/Support/Range.h" template class TransformIterator : public IteratorWrapper { diff --git a/revamb.h b/include/revng/Support/revng.h similarity index 99% rename from revamb.h rename to include/revng/Support/revng.h index 4a1f5fc8c..4ebac3699 100644 --- a/revamb.h +++ b/include/revng/Support/revng.h @@ -17,8 +17,8 @@ #include "llvm/ADT/Triple.h" #include "llvm/Support/ELF.h" -// Local includes -#include "ir-helpers.h" +// Local libraries includes +#include "revng/Support/IRHelpers.h" namespace llvm { class GlobalVariable; diff --git a/argparse/argparse.h b/include/revng/argparse/argparse.h similarity index 100% rename from argparse/argparse.h rename to include/revng/argparse/argparse.h diff --git a/lib/BasicAnalyses/CMakeLists.txt b/lib/BasicAnalyses/CMakeLists.txt new file mode 100644 index 000000000..1a36e8805 --- /dev/null +++ b/lib/BasicAnalyses/CMakeLists.txt @@ -0,0 +1 @@ +add_library(BasicAnalyses STATIC GeneratedCodeBasicInfo.cpp FunctionCallIdentification.cpp) diff --git a/functioncallidentification.cpp b/lib/BasicAnalyses/FunctionCallIdentification.cpp similarity index 98% rename from functioncallidentification.cpp rename to lib/BasicAnalyses/FunctionCallIdentification.cpp index bc17e44df..e381df7eb 100644 --- a/functioncallidentification.cpp +++ b/lib/BasicAnalyses/FunctionCallIdentification.cpp @@ -6,9 +6,9 @@ // This file is distributed under the MIT License. See LICENSE.md for details. // -// Local includes -#include "functioncallidentification.h" -#include "debug.h" +// Local libraries includes +#include "revng/BasicAnalyses/FunctionCallIdentification.h" +#include "revng/Support/Debug.h" using namespace llvm; diff --git a/generatedcodebasicinfo.cpp b/lib/BasicAnalyses/GeneratedCodeBasicInfo.cpp similarity index 97% rename from generatedcodebasicinfo.cpp rename to lib/BasicAnalyses/GeneratedCodeBasicInfo.cpp index 85bf01c0e..37f4978d9 100644 --- a/generatedcodebasicinfo.cpp +++ b/lib/BasicAnalyses/GeneratedCodeBasicInfo.cpp @@ -14,9 +14,9 @@ #include "llvm/IR/Function.h" #include "llvm/IR/Instructions.h" -// Local includes -#include "debug.h" -#include "generatedcodebasicinfo.h" +// Local libraries includes +#include "revng/BasicAnalyses/GeneratedCodeBasicInfo.h" +#include "revng/Support/Debug.h" using namespace llvm; diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 90f911533..d9781f8c3 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -2,4 +2,8 @@ # This file is distributed under the MIT License. See LICENSE.md for details. # +add_subdirectory(Support) +add_subdirectory(DebugHelper) +add_subdirectory(argparse) +add_subdirectory(BasicAnalyses) add_subdirectory(StackAnalysis) diff --git a/lib/DebugHelper/CMakeLists.txt b/lib/DebugHelper/CMakeLists.txt new file mode 100644 index 000000000..69602f671 --- /dev/null +++ b/lib/DebugHelper/CMakeLists.txt @@ -0,0 +1 @@ +add_library(DebugHelper STATIC DebugHelper.cpp) diff --git a/debughelper.cpp b/lib/DebugHelper/DebugHelper.cpp similarity index 99% rename from debughelper.cpp rename to lib/DebugHelper/DebugHelper.cpp index bdd0308cf..08b2fcbd3 100644 --- a/debughelper.cpp +++ b/lib/DebugHelper/DebugHelper.cpp @@ -16,8 +16,8 @@ #include "llvm/Support/FormattedStream.h" #include "llvm/Support/raw_os_ostream.h" -// Local includes -#include "debughelper.h" +// Local libraries includes +#include "revng/DebugHelper/DebugHelper.h" using namespace llvm; diff --git a/lib/StackAnalysis/abidataflows-footer.h b/lib/StackAnalysis/ABIDataFlows-footer.h similarity index 100% rename from lib/StackAnalysis/abidataflows-footer.h rename to lib/StackAnalysis/ABIDataFlows-footer.h diff --git a/lib/StackAnalysis/abidataflows-header.h b/lib/StackAnalysis/ABIDataFlows-header.h similarity index 73% rename from lib/StackAnalysis/abidataflows-header.h rename to lib/StackAnalysis/ABIDataFlows-header.h index 0e8600bed..b5283aec3 100644 --- a/lib/StackAnalysis/abidataflows-header.h +++ b/lib/StackAnalysis/ABIDataFlows-header.h @@ -8,9 +8,9 @@ // This file has been automatically generated, please don't change it // Standard includes -#include "revng-assert.h" #include #include -// Local includes -#include "debug.h" +// Local libraries includes +#include "revng/Support/Assert.h" +#include "revng/Support/Debug.h" diff --git a/lib/StackAnalysis/abiir.cpp b/lib/StackAnalysis/ABIIR.cpp similarity index 99% rename from lib/StackAnalysis/abiir.cpp rename to lib/StackAnalysis/ABIIR.cpp index 88cbaf624..938890f28 100644 --- a/lib/StackAnalysis/abiir.cpp +++ b/lib/StackAnalysis/ABIIR.cpp @@ -10,7 +10,7 @@ #include "llvm/ADT/PostOrderIterator.h" // Local includes -#include "abiir.h" +#include "ABIIR.h" namespace StackAnalysis { diff --git a/lib/StackAnalysis/abiir.h b/lib/StackAnalysis/ABIIR.h similarity index 99% rename from lib/StackAnalysis/abiir.h rename to lib/StackAnalysis/ABIIR.h index 7a5355eb9..2ddf8dba2 100644 --- a/lib/StackAnalysis/abiir.h +++ b/lib/StackAnalysis/ABIIR.h @@ -13,8 +13,8 @@ #include "llvm/ADT/StringRef.h" // Local includes -#include "asslot.h" -#include "functionabi.h" +#include "ASSlot.h" +#include "FunctionABI.h" namespace StackAnalysis { diff --git a/lib/StackAnalysis/asslot.h b/lib/StackAnalysis/ASSlot.h similarity index 99% rename from lib/StackAnalysis/asslot.h rename to lib/StackAnalysis/ASSlot.h index e247019ef..539c0231c 100644 --- a/lib/StackAnalysis/asslot.h +++ b/lib/StackAnalysis/ASSlot.h @@ -8,8 +8,8 @@ #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/Module.h" -// Local includes -#include "debug.h" +// Local libraries includes +#include "revng/Support/Debug.h" extern Logger<> SaDiffLog; diff --git a/lib/StackAnalysis/basicblockinstructionpair.h b/lib/StackAnalysis/BasicBlockInstructionPair.h similarity index 96% rename from lib/StackAnalysis/basicblockinstructionpair.h rename to lib/StackAnalysis/BasicBlockInstructionPair.h index 59ab8b32d..591c38a2f 100644 --- a/lib/StackAnalysis/basicblockinstructionpair.h +++ b/lib/StackAnalysis/BasicBlockInstructionPair.h @@ -5,9 +5,9 @@ // This file is distributed under the MIT License. See LICENSE.md for details. // -// Local includes -#include "debug.h" -#include "ir-helpers.h" +// Local libraries includes +#include "revng/Support/Debug.h" +#include "revng/Support/IRHelpers.h" namespace llvm { class BasicBlock; diff --git a/lib/StackAnalysis/CMakeLists.txt b/lib/StackAnalysis/CMakeLists.txt index 2d574bbf9..3be675e2f 100644 --- a/lib/StackAnalysis/CMakeLists.txt +++ b/lib/StackAnalysis/CMakeLists.txt @@ -11,7 +11,7 @@ execute_process(COMMAND python -c "import pygraphviz" if(NOT HAS_PYGRAPHVIZ EQUAL "0") # Don't drop the whitespaces message(FATAL_ERROR " - Cannot find the pygraphviz module: abidataflows.h cannot be generated. + Cannot find the pygraphviz module: ABIDataFlows.h cannot be generated. Please try one of the following commands: Debian/Ubuntu: @@ -30,26 +30,33 @@ endif() # Generate classes for the ABI data flow analyses set(ABIDATAFLOWS_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/abidataflows-header.h" - "${CMAKE_CURRENT_SOURCE_DIR}/abidataflows-footer.h" - "${CMAKE_CURRENT_SOURCE_DIR}/dead-register-arguments-of-function.dot" - "${CMAKE_CURRENT_SOURCE_DIR}/dead-return-values-of-function-call.dot" - "${CMAKE_CURRENT_SOURCE_DIR}/register-arguments-of-function-call.dot" - "${CMAKE_CURRENT_SOURCE_DIR}/used-arguments-of-function.dot" - "${CMAKE_CURRENT_SOURCE_DIR}/used-return-values-of-function-call.dot" - "${CMAKE_CURRENT_SOURCE_DIR}/used-return-values-of-function.dot") -add_custom_command(OUTPUT abidataflows.h + "${CMAKE_CURRENT_SOURCE_DIR}/ABIDataFlows-header.h" + "${CMAKE_CURRENT_SOURCE_DIR}/ABIDataFlows-footer.h" + "${CMAKE_CURRENT_SOURCE_DIR}/DeadRegisterArgumentsOfFunction.dot" + "${CMAKE_CURRENT_SOURCE_DIR}/DeadReturnValuesOfFunctionCall.dot" + "${CMAKE_CURRENT_SOURCE_DIR}/RegisterArgumentsOfFunctionCall.dot" + "${CMAKE_CURRENT_SOURCE_DIR}/UsedArgumentsOfFunction.dot" + "${CMAKE_CURRENT_SOURCE_DIR}/UsedReturnValuesOfFunctionCall.dot" + "${CMAKE_CURRENT_SOURCE_DIR}/UsedReturnValuesOfFunction.dot") +add_custom_command(OUTPUT ABIDataFlows.h COMMAND "${CMAKE_SOURCE_DIR}/scripts/monotone-framework.py" - --call-arcs ${ABIDATAFLOWS_SOURCES} > abidataflows.h + --call-arcs ${ABIDATAFLOWS_SOURCES} > ABIDataFlows.h DEPENDS "${CMAKE_SOURCE_DIR}/scripts/monotone-framework.py" ${ABIDATAFLOWS_SOURCES} VERBATIM) -add_custom_target(abidataflows DEPENDS abidataflows.h) +add_custom_target(abidataflows DEPENDS ABIDataFlows.h) -add_library(StackAnalysis STATIC - stackanalysis.cpp functionssummary.cpp intraprocedural.cpp interprocedural.cpp - element.cpp functionabi.cpp cache.cpp abiir.cpp incoherentcallsanalysis.cpp - monotoneframeworkexample.cpp) +add_library(StackAnalysis + ABIIR.cpp + Cache.cpp + Element.cpp + FunctionABI.cpp + FunctionsSummary.cpp + IncoherentCallsAnalysis.cpp + InterproceduralAnalysis.cpp + Intraprocedural.cpp + StackAnalysis.cpp) +target_link_libraries(StackAnalysis Support) target_include_directories(StackAnalysis PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/lib/StackAnalysis/cache.cpp b/lib/StackAnalysis/Cache.cpp similarity index 99% rename from lib/StackAnalysis/cache.cpp rename to lib/StackAnalysis/Cache.cpp index b7667cf00..0995aaf59 100644 --- a/lib/StackAnalysis/cache.cpp +++ b/lib/StackAnalysis/Cache.cpp @@ -6,7 +6,7 @@ // // Local includes -#include "cache.h" +#include "Cache.h" using llvm::BasicBlock; using llvm::BinaryOperator; diff --git a/lib/StackAnalysis/cache.h b/lib/StackAnalysis/Cache.h similarity index 98% rename from lib/StackAnalysis/cache.h rename to lib/StackAnalysis/Cache.h index c57dd0f42..fd60283cf 100644 --- a/lib/StackAnalysis/cache.h +++ b/lib/StackAnalysis/Cache.h @@ -2,8 +2,8 @@ #define CACHE_H // Local includes -#include "element.h" -#include "intraproceduralfunctionsummary.h" +#include "Element.h" +#include "IntraproceduralFunctionSummary.h" namespace StackAnalysis { diff --git a/lib/StackAnalysis/dead-register-arguments-of-function.dot b/lib/StackAnalysis/DeadRegisterArgumentsOfFunction.dot similarity index 100% rename from lib/StackAnalysis/dead-register-arguments-of-function.dot rename to lib/StackAnalysis/DeadRegisterArgumentsOfFunction.dot diff --git a/lib/StackAnalysis/dead-return-values-of-function-call.dot b/lib/StackAnalysis/DeadReturnValuesOfFunctionCall.dot similarity index 100% rename from lib/StackAnalysis/dead-return-values-of-function-call.dot rename to lib/StackAnalysis/DeadReturnValuesOfFunctionCall.dot diff --git a/lib/StackAnalysis/element.cpp b/lib/StackAnalysis/Element.cpp similarity index 99% rename from lib/StackAnalysis/element.cpp rename to lib/StackAnalysis/Element.cpp index 852dbd2cd..c6d5a4f7c 100644 --- a/lib/StackAnalysis/element.cpp +++ b/lib/StackAnalysis/Element.cpp @@ -5,9 +5,11 @@ // This file is distributed under the MIT License. See LICENSE.md for details. // +// Local libraries includes +#include "revng/Support/Debug.h" + // Local includes -#include "element.h" -#include "debug.h" +#include "Element.h" using llvm::Module; diff --git a/lib/StackAnalysis/element.h b/lib/StackAnalysis/Element.h similarity index 98% rename from lib/StackAnalysis/element.h rename to lib/StackAnalysis/Element.h index cfd330aac..37046a71c 100644 --- a/lib/StackAnalysis/element.h +++ b/lib/StackAnalysis/Element.h @@ -4,11 +4,13 @@ // Standard includes #include +// Local libraries includes +#include "revng/ADT/LazySmallBitVector.h" +#include "revng/Support/Statistics.h" + // Local includes -#include "asslot.h" -#include "basicblockinstructionpair.h" -#include "lazysmallbitvector.h" -#include "statistics.h" +#include "ASSlot.h" +#include "BasicBlockInstructionPair.h" /// \brief Average number of slots tracked by an address space extern RunningStatistics AddressSpaceSizeStats; diff --git a/lib/StackAnalysis/monotoneframeworkexample.cpp b/lib/StackAnalysis/ExampleAnalysis.cpp similarity index 98% rename from lib/StackAnalysis/monotoneframeworkexample.cpp rename to lib/StackAnalysis/ExampleAnalysis.cpp index 7072ca048..3c7576859 100644 --- a/lib/StackAnalysis/monotoneframeworkexample.cpp +++ b/lib/StackAnalysis/ExampleAnalysis.cpp @@ -13,7 +13,7 @@ class Module; } // Local includes -#include "monotoneframework.h" +#include "MonotoneFramework.h" namespace StackAnalysis { diff --git a/lib/StackAnalysis/functionabi.cpp b/lib/StackAnalysis/FunctionABI.cpp similarity index 99% rename from lib/StackAnalysis/functionabi.cpp rename to lib/StackAnalysis/FunctionABI.cpp index 3823b452e..88b879899 100644 --- a/lib/StackAnalysis/functionabi.cpp +++ b/lib/StackAnalysis/FunctionABI.cpp @@ -6,9 +6,9 @@ // // Local includes -#include "functionabi.h" -#include "abiir.h" -#include "monotoneframework.h" +#include "FunctionABI.h" +#include "ABIIR.h" +#include "MonotoneFramework.h" using std::conditional; using std::tuple; diff --git a/lib/StackAnalysis/functionabi.h b/lib/StackAnalysis/FunctionABI.h similarity index 98% rename from lib/StackAnalysis/functionabi.h rename to lib/StackAnalysis/FunctionABI.h index 7da129ed8..ad1e97c9f 100644 --- a/lib/StackAnalysis/functionabi.h +++ b/lib/StackAnalysis/FunctionABI.h @@ -5,12 +5,12 @@ #include // Local includes -#include "SmallMap.h" -#include "abidataflows.h" -#include "asslot.h" -#include "basicblockinstructionpair.h" -#include "revng/StackAnalysis/functionssummary.h" -#include "statistics.h" +#include "ABIDataFlows.h" +#include "ASSlot.h" +#include "BasicBlockInstructionPair.h" +#include "revng/ADT/SmallMap.h" +#include "revng/StackAnalysis/FunctionsSummary.h" +#include "revng/Support/Statistics.h" extern Logger<> SaABI; diff --git a/lib/StackAnalysis/functionssummary.cpp b/lib/StackAnalysis/FunctionsSummary.cpp similarity index 99% rename from lib/StackAnalysis/functionssummary.cpp rename to lib/StackAnalysis/FunctionsSummary.cpp index 4a536eaa2..dbc6cccf5 100644 --- a/lib/StackAnalysis/functionssummary.cpp +++ b/lib/StackAnalysis/FunctionsSummary.cpp @@ -9,10 +9,12 @@ // Boost includes #include +// Local libraries includes +#include "revng/StackAnalysis/FunctionsSummary.h" +#include "revng/Support/IRHelpers.h" + // Local includes -#include "asslot.h" -#include "ir-helpers.h" -#include "revng/StackAnalysis/functionssummary.h" +#include "ASSlot.h" using llvm::BasicBlock; using llvm::BlockAddress; diff --git a/lib/StackAnalysis/incoherentcallsanalysis.cpp b/lib/StackAnalysis/IncoherentCallsAnalysis.cpp similarity index 99% rename from lib/StackAnalysis/incoherentcallsanalysis.cpp rename to lib/StackAnalysis/IncoherentCallsAnalysis.cpp index 5461b17a7..533a9ffd3 100644 --- a/lib/StackAnalysis/incoherentcallsanalysis.cpp +++ b/lib/StackAnalysis/IncoherentCallsAnalysis.cpp @@ -7,8 +7,8 @@ // // Local includes -#include "abiir.h" -#include "monotoneframework.h" +#include "ABIIR.h" +#include "MonotoneFramework.h" using llvm::Module; diff --git a/lib/StackAnalysis/interprocedural.cpp b/lib/StackAnalysis/InterproceduralAnalysis.cpp similarity index 99% rename from lib/StackAnalysis/interprocedural.cpp rename to lib/StackAnalysis/InterproceduralAnalysis.cpp index f7d15050e..3c1c76adf 100644 --- a/lib/StackAnalysis/interprocedural.cpp +++ b/lib/StackAnalysis/InterproceduralAnalysis.cpp @@ -8,10 +8,12 @@ // Standard includes #include +// Local libraries includes +#include "revng/Support/Statistics.h" + // Local includes -#include "cache.h" -#include "interprocedural.h" -#include "statistics.h" +#include "Cache.h" +#include "InterproceduralAnalysis.h" using llvm::BasicBlock; using llvm::GlobalVariable; diff --git a/lib/StackAnalysis/interprocedural.h b/lib/StackAnalysis/InterproceduralAnalysis.h similarity index 98% rename from lib/StackAnalysis/interprocedural.h rename to lib/StackAnalysis/InterproceduralAnalysis.h index 3e97e13a3..4189b1aeb 100644 --- a/lib/StackAnalysis/interprocedural.h +++ b/lib/StackAnalysis/InterproceduralAnalysis.h @@ -18,10 +18,12 @@ #include "llvm/IR/User.h" #include "llvm/Support/Casting.h" +// Local libraries includes +#include "revng/Support/Debug.h" +#include "revng/Support/IRHelpers.h" + // Local includes -#include "debug.h" -#include "intraprocedural.h" -#include "ir-helpers.h" +#include "Intraprocedural.h" /// \brief Logger for messages concerning the interprocedural analysis extern Logger<> SaInterpLog; diff --git a/lib/StackAnalysis/intraprocedural.cpp b/lib/StackAnalysis/Intraprocedural.cpp similarity index 99% rename from lib/StackAnalysis/intraprocedural.cpp rename to lib/StackAnalysis/Intraprocedural.cpp index 010db9ac5..6f7d1d16d 100644 --- a/lib/StackAnalysis/intraprocedural.cpp +++ b/lib/StackAnalysis/Intraprocedural.cpp @@ -9,9 +9,9 @@ #include // Local includes -#include "cache.h" -#include "interprocedural.h" -#include "intraprocedural.h" +#include "Cache.h" +#include "InterproceduralAnalysis.h" +#include "Intraprocedural.h" using llvm::AllocaInst; using llvm::ArrayRef; diff --git a/lib/StackAnalysis/intraprocedural.h b/lib/StackAnalysis/Intraprocedural.h similarity index 98% rename from lib/StackAnalysis/intraprocedural.h rename to lib/StackAnalysis/Intraprocedural.h index ddaaf014a..552f5aa16 100644 --- a/lib/StackAnalysis/intraprocedural.h +++ b/lib/StackAnalysis/Intraprocedural.h @@ -15,15 +15,17 @@ // LLVM includes #include "llvm/ADT/SmallVector.h" +// Local libraries includes +#include "revng/BasicAnalyses/GeneratedCodeBasicInfo.h" +#include "revng/Support/Debug.h" +#include "revng/Support/IRHelpers.h" + // Local includes -#include "abiir.h" -#include "debug.h" -#include "element.h" -#include "functionabi.h" -#include "generatedcodebasicinfo.h" -#include "intraproceduralfunctionsummary.h" -#include "ir-helpers.h" -#include "monotoneframework.h" +#include "ABIIR.h" +#include "Element.h" +#include "FunctionABI.h" +#include "IntraproceduralFunctionSummary.h" +#include "MonotoneFramework.h" template inline bool compareOptional(llvm::Optional LHS, llvm::Optional RHS) { diff --git a/lib/StackAnalysis/intraproceduralfunctionsummary.h b/lib/StackAnalysis/IntraproceduralFunctionSummary.h similarity index 99% rename from lib/StackAnalysis/intraproceduralfunctionsummary.h rename to lib/StackAnalysis/IntraproceduralFunctionSummary.h index d0dedd206..0ec72f9e1 100644 --- a/lib/StackAnalysis/intraproceduralfunctionsummary.h +++ b/lib/StackAnalysis/IntraproceduralFunctionSummary.h @@ -2,8 +2,8 @@ #define INTRAPROCEDURALFUNCTIONSUMMARY_H // Local includes -#include "element.h" -#include "functionabi.h" +#include "Element.h" +#include "FunctionABI.h" namespace StackAnalysis { diff --git a/lib/StackAnalysis/monotoneframework.h b/lib/StackAnalysis/MonotoneFramework.h similarity index 99% rename from lib/StackAnalysis/monotoneframework.h rename to lib/StackAnalysis/MonotoneFramework.h index 0bd49bf1a..a2eaa0b77 100644 --- a/lib/StackAnalysis/monotoneframework.h +++ b/lib/StackAnalysis/MonotoneFramework.h @@ -14,9 +14,9 @@ #include "llvm/ADT/PostOrderIterator.h" #include "llvm/ADT/SmallVector.h" -// Local includes -#include "datastructures.h" -#include "debug.h" +// Local libraries includes +#include "revng/ADT/Queue.h" +#include "revng/Support/Debug.h" namespace StackAnalysis { diff --git a/lib/StackAnalysis/register-arguments-of-function-call.dot b/lib/StackAnalysis/RegisterArgumentsOfFunctionCall.dot similarity index 100% rename from lib/StackAnalysis/register-arguments-of-function-call.dot rename to lib/StackAnalysis/RegisterArgumentsOfFunctionCall.dot diff --git a/lib/StackAnalysis/stackanalysis.cpp b/lib/StackAnalysis/StackAnalysis.cpp similarity index 95% rename from lib/StackAnalysis/stackanalysis.cpp rename to lib/StackAnalysis/StackAnalysis.cpp index dbb128456..74e053c28 100644 --- a/lib/StackAnalysis/stackanalysis.cpp +++ b/lib/StackAnalysis/StackAnalysis.cpp @@ -16,12 +16,14 @@ #include "llvm/IR/Function.h" #include "llvm/Pass.h" +// Local libraries includes +#include "revng/StackAnalysis/StackAnalysis.h" +#include "revng/Support/IRHelpers.h" + // Local includes -#include "cache.h" -#include "interprocedural.h" -#include "intraprocedural.h" -#include "ir-helpers.h" -#include "revng/StackAnalysis/stackanalysis.h" +#include "Cache.h" +#include "InterproceduralAnalysis.h" +#include "Intraprocedural.h" using llvm::BasicBlock; using llvm::Function; diff --git a/lib/StackAnalysis/used-arguments-of-function.dot b/lib/StackAnalysis/UsedArgumentsOfFunction.dot similarity index 100% rename from lib/StackAnalysis/used-arguments-of-function.dot rename to lib/StackAnalysis/UsedArgumentsOfFunction.dot diff --git a/lib/StackAnalysis/used-return-values-of-function.dot b/lib/StackAnalysis/UsedReturnValuesOfFunction.dot similarity index 100% rename from lib/StackAnalysis/used-return-values-of-function.dot rename to lib/StackAnalysis/UsedReturnValuesOfFunction.dot diff --git a/lib/StackAnalysis/used-return-values-of-function-call.dot b/lib/StackAnalysis/UsedReturnValuesOfFunctionCall.dot similarity index 100% rename from lib/StackAnalysis/used-return-values-of-function-call.dot rename to lib/StackAnalysis/UsedReturnValuesOfFunctionCall.dot diff --git a/revng-assert.cpp b/lib/Support/Assert.cpp similarity index 95% rename from revng-assert.cpp rename to lib/Support/Assert.cpp index ebcad46c6..3d47efb5c 100644 --- a/revng-assert.cpp +++ b/lib/Support/Assert.cpp @@ -9,8 +9,8 @@ #include "llvm/Support/Signals.h" #include "llvm/Support/raw_os_ostream.h" -// Local includes -#include "revng-assert.h" +// Local libraries includes +#include "revng/Support/Assert.h" static void print_stack_trace() { llvm::raw_os_ostream Output(std::cout); diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt new file mode 100644 index 000000000..a3c7552a8 --- /dev/null +++ b/lib/Support/CMakeLists.txt @@ -0,0 +1 @@ +add_library(Support STATIC Assert.cpp Statistics.cpp Debug.cpp) diff --git a/debug.cpp b/lib/Support/Debug.cpp similarity index 96% rename from debug.cpp rename to lib/Support/Debug.cpp index 4b88d1bd2..2eb3a4ef3 100644 --- a/debug.cpp +++ b/lib/Support/Debug.cpp @@ -14,8 +14,8 @@ // LLVM includes #include "llvm/IR/Value.h" -// Local includes -#include "debug.h" +// Local libraries includes +#include "revng/Support/Debug.h" static size_t MaxLoggerNameLength = 0; LogTerminator DoLog; diff --git a/statistics.cpp b/lib/Support/Statistics.cpp similarity index 96% rename from statistics.cpp rename to lib/Support/Statistics.cpp index 5a550d78d..01461ead7 100644 --- a/statistics.cpp +++ b/lib/Support/Statistics.cpp @@ -5,8 +5,8 @@ // This file is distributed under the MIT License. See LICENSE.md for details. // -// Local includes -#include "statistics.h" +// Local libraries includes +#include "revng/Support/Statistics.h" struct Handler { int Signal; diff --git a/lib/argparse/CMakeLists.txt b/lib/argparse/CMakeLists.txt new file mode 100644 index 000000000..a9bc0dda9 --- /dev/null +++ b/lib/argparse/CMakeLists.txt @@ -0,0 +1 @@ +add_library(argparse STATIC argparse.c) diff --git a/argparse/LICENSE b/lib/argparse/LICENSE similarity index 100% rename from argparse/LICENSE rename to lib/argparse/LICENSE diff --git a/argparse/argparse.c b/lib/argparse/argparse.c similarity index 99% rename from argparse/argparse.c rename to lib/argparse/argparse.c index 7541347cc..5301e2f33 100644 --- a/argparse/argparse.c +++ b/lib/argparse/argparse.c @@ -5,7 +5,9 @@ * Use of this source code is governed by a MIT-style license that can be found * in the LICENSE file. */ -#include "argparse.h" + +// Local libraries includes +#include "revng/argparse/argparse.h" #define OPT_UNSET 1 #define OPT_LONG 1 << 1 diff --git a/early-linked.c b/runtime/early-linked.c similarity index 100% rename from early-linked.c rename to runtime/early-linked.c diff --git a/support.c b/runtime/support.c similarity index 99% rename from support.c rename to runtime/support.c index 30a958e23..501a79e60 100644 --- a/support.c +++ b/runtime/support.c @@ -25,8 +25,10 @@ #include #endif +// Local libraries includes +#include "revng/Runtime/commonconstants.h" + // Local includes -#include "commonconstants.h" #include "support.h" // Save the program arguments for meaningful error reporting diff --git a/support.h b/runtime/support.h similarity index 100% rename from support.h rename to runtime/support.h diff --git a/scripts/check-conventions.sh b/scripts/check-conventions.sh index 5db1edbf4..de8fa7d65 100755 --- a/scripts/check-conventions.sh +++ b/scripts/check-conventions.sh @@ -60,7 +60,7 @@ fi done # Things should never match (except in support.c) - FILTERED_FILES="$(echo $FILES | sed 's|\bsupport\.c\b||g; s|\brevng-assert\.cpp\b||g;')" + FILTERED_FILES="$(echo $FILES | sed 's|\bruntime/support\.c\b||g; s|\blib/Support/Assert\.cpp\b||g;')" for REGEXP in '\babort(' '\bassert(' 'assert(false' 'llvm_unreachable'; do $GREP "$REGEXP" $FILTERED_FILES | cat done diff --git a/csv-to-ld-options b/scripts/csv-to-ld-options similarity index 100% rename from csv-to-ld-options rename to scripts/csv-to-ld-options diff --git a/merge-dynamic.py b/scripts/merge-dynamic.py similarity index 100% rename from merge-dynamic.py rename to scripts/merge-dynamic.py diff --git a/translate b/scripts/translate similarity index 100% rename from translate rename to scripts/translate diff --git a/tests/Analysis/AnalysisTests.cmake b/tests/Analysis/AnalysisTests.cmake index 5fe736b66..f05294f6e 100644 --- a/tests/Analysis/AnalysisTests.cmake +++ b/tests/Analysis/AnalysisTests.cmake @@ -77,13 +77,13 @@ foreach(ARCH ${SUPPORTED_ARCHITECTURES}) # Translate the compiled binary add_test(NAME translate-${TEST_NAME}-${ARCH} - COMMAND $ --functions-boundaries --use-debug-symbols -g ll "${BINARY}" "${BINARY}.ll") + COMMAND "${CMAKE_CURRENT_BINARY_DIR}/revamb" --functions-boundaries --use-debug-symbols -g ll "${BINARY}" "${BINARY}.ll") set_tests_properties(translate-${TEST_NAME}-${ARCH} PROPERTIES LABELS "analysis;translate;${TEST_NAME}-${ARCH}") # Extract all the information in a single shot add_test(NAME extract-info-${TEST_NAME}-${ARCH} - COMMAND $ + COMMAND "${CMAKE_CURRENT_BINARY_DIR}/revamb-dump" --cfg "${BINARY}${OUTPUT_SUFFIX_cfg}" --noreturn "${BINARY}${OUTPUT_SUFFIX_noreturn}" --functions-boundaries "${BINARY}${OUTPUT_SUFFIX_functionsboundaries}" diff --git a/tests/Unit/UnitTests.cmake b/tests/Unit/UnitTests.cmake index 119cb845e..151d97f77 100644 --- a/tests/Unit/UnitTests.cmake +++ b/tests/Unit/UnitTests.cmake @@ -9,24 +9,19 @@ set(SRC "${CMAKE_SOURCE_DIR}/tests/Unit") set(Boost_ADDITIONAL_VERSIONS "1.63" "1.63.0") find_package(Boost 1.63.0 REQUIRED COMPONENTS unit_test_framework) -add_executable(test_lazysmallbitvector - "${SRC}/lazysmallbitvector.cpp" - "${CMAKE_SOURCE_DIR}/revng-assert.cpp") +add_executable(test_lazysmallbitvector "${SRC}/lazysmallbitvector.cpp") target_include_directories(test_lazysmallbitvector PRIVATE "${CMAKE_SOURCE_DIR}" "${Boost_INCLUDE_DIRS}") target_compile_definitions(test_lazysmallbitvector PRIVATE "BOOST_TEST_DYN_LINK=1") target_link_libraries(test_lazysmallbitvector + Support ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${LLVM_LIBRARIES}) add_test(NAME test_lazysmallbitvector COMMAND test_lazysmallbitvector) -add_executable(test_stackanalysis - "${SRC}/stackanalysis.cpp" - "${CMAKE_SOURCE_DIR}/debug.cpp" - "${CMAKE_SOURCE_DIR}/statistics.cpp" - "${CMAKE_SOURCE_DIR}/revng-assert.cpp") +add_executable(test_stackanalysis "${SRC}/stackanalysis.cpp") target_include_directories(test_stackanalysis PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/lib/StackAnalysis" @@ -36,20 +31,19 @@ target_compile_definitions(test_stackanalysis PRIVATE "BOOST_TEST_DYN_LINK=1") target_link_libraries(test_stackanalysis StackAnalysis + Support ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${LLVM_LIBRARIES}) add_test(NAME test_stackanalysis COMMAND test_stackanalysis) -add_executable(test_classsentinel - "${SRC}/classsentinel.cpp" - "${CMAKE_SOURCE_DIR}/debug.cpp" - "${CMAKE_SOURCE_DIR}/revng-assert.cpp") +add_executable(test_classsentinel "${SRC}/classsentinel.cpp") target_include_directories(test_classsentinel PRIVATE "${CMAKE_SOURCE_DIR}" "${Boost_INCLUDE_DIRS}") target_compile_definitions(test_classsentinel PRIVATE "BOOST_TEST_DYN_LINK=1") target_link_libraries(test_classsentinel + Support ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${LLVM_LIBRARIES}) add_test(NAME test_classsentinel COMMAND test_classsentinel) diff --git a/tests/Unit/classsentinel.cpp b/tests/Unit/classsentinel.cpp index fb13e9a34..7c87397a7 100644 --- a/tests/Unit/classsentinel.cpp +++ b/tests/Unit/classsentinel.cpp @@ -5,15 +5,13 @@ // This file is distributed under the MIT License. See LICENSE.md for details. // -// Standard includes - // Boost includes #define BOOST_TEST_MODULE StackAnalysis bool init_unit_test(); #include -// Local includes -#include "classsentinel.h" +// Local libraries includes +#include "revng/Support/ClassSentinel.h" struct TestClass { ClassSentinel Sentinel; diff --git a/tests/Unit/lazysmallbitvector.cpp b/tests/Unit/lazysmallbitvector.cpp index d540bff54..476e64e6d 100644 --- a/tests/Unit/lazysmallbitvector.cpp +++ b/tests/Unit/lazysmallbitvector.cpp @@ -16,8 +16,8 @@ bool init_unit_test(); #include -// Local includes -#include "lazysmallbitvector.h" +// Local libraries includes +#include "revng/ADT/LazySmallBitVector.h" static const unsigned FirstLargeBit = sizeof(uintptr_t) * CHAR_BIT; diff --git a/tests/Unit/stackanalysis.cpp b/tests/Unit/stackanalysis.cpp index d415960c9..7a9c11541 100644 --- a/tests/Unit/stackanalysis.cpp +++ b/tests/Unit/stackanalysis.cpp @@ -11,7 +11,7 @@ bool init_unit_test(); #include // Local includes -#include "intraprocedural.h" +#include "Intraprocedural.h" using namespace StackAnalysis; diff --git a/tests/get-function-virtual-address b/tests/get-function-virtual-address deleted file mode 100755 index fe307b82e..000000000 --- a/tests/get-function-virtual-address +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# - -PROGRAM=$1 -FUNCTION=$2 - -VA=`readelf --wide -s $PROGRAM | grep $FUNCTION | grep GLOBAL | grep FUNC | head -n1 | awk -F' ' '{ print strtonum("0x" $2) }'` - -echo $VA diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 000000000..f9340053c --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1,6 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +add_subdirectory(revamb) +add_subdirectory(revamb-dump) diff --git a/tools/revamb-dump/CMakeLists.txt b/tools/revamb-dump/CMakeLists.txt new file mode 100644 index 000000000..6ca2cebe4 --- /dev/null +++ b/tools/revamb-dump/CMakeLists.txt @@ -0,0 +1,20 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +add_executable(revamb-dump + Main.cpp + CollectCFG.cpp + CollectFunctionBoundaries.cpp + CollectNoreturn.cpp + IsolateFunctions.cpp) +target_link_libraries(revamb-dump + argparse + Support + DebugHelper + StackAnalysis + BasicAnalyses + ${LLVM_LIBRARIES}) +add_custom_command(TARGET revamb-dump POST_BUILD VERBATIM + COMMAND ${CMAKE_COMMAND} -E copy "$" "${CMAKE_BINARY_DIR}/") +install(TARGETS revamb-dump RUNTIME DESTINATION bin) diff --git a/collectcfg.cpp b/tools/revamb-dump/CollectCFG.cpp similarity index 94% rename from collectcfg.cpp rename to tools/revamb-dump/CollectCFG.cpp index 62ca48e6d..b0983eb47 100644 --- a/collectcfg.cpp +++ b/tools/revamb-dump/CollectCFG.cpp @@ -9,10 +9,12 @@ #include "llvm/IR/Function.h" #include "llvm/IR/Instructions.h" +// Local libraries includes +#include "revng/ADT/Queue.h" +#include "revng/Support/IRHelpers.h" + // Local includes -#include "collectcfg.h" -#include "datastructures.h" -#include "ir-helpers.h" +#include "CollectCFG.h" using namespace llvm; diff --git a/collectcfg.h b/tools/revamb-dump/CollectCFG.h similarity index 100% rename from collectcfg.h rename to tools/revamb-dump/CollectCFG.h diff --git a/collectfunctionboundaries.cpp b/tools/revamb-dump/CollectFunctionBoundaries.cpp similarity index 97% rename from collectfunctionboundaries.cpp rename to tools/revamb-dump/CollectFunctionBoundaries.cpp index 6ea51366d..935304977 100644 --- a/collectfunctionboundaries.cpp +++ b/tools/revamb-dump/CollectFunctionBoundaries.cpp @@ -12,7 +12,7 @@ #include "llvm/IR/Metadata.h" // Local includes -#include "collectfunctionboundaries.h" +#include "CollectFunctionBoundaries.h" using namespace llvm; diff --git a/collectfunctionboundaries.h b/tools/revamb-dump/CollectFunctionBoundaries.h similarity index 100% rename from collectfunctionboundaries.h rename to tools/revamb-dump/CollectFunctionBoundaries.h diff --git a/collectnoreturn.cpp b/tools/revamb-dump/CollectNoreturn.cpp similarity index 97% rename from collectnoreturn.cpp rename to tools/revamb-dump/CollectNoreturn.cpp index f6b4b9e2a..b097fd1d1 100644 --- a/collectnoreturn.cpp +++ b/tools/revamb-dump/CollectNoreturn.cpp @@ -12,7 +12,7 @@ #include "llvm/IR/Instructions.h" // Local includes -#include "collectnoreturn.h" +#include "CollectNoreturn.h" using namespace llvm; diff --git a/collectnoreturn.h b/tools/revamb-dump/CollectNoreturn.h similarity index 100% rename from collectnoreturn.h rename to tools/revamb-dump/CollectNoreturn.h diff --git a/isolatefunctions.cpp b/tools/revamb-dump/IsolateFunctions.cpp similarity index 99% rename from isolatefunctions.cpp rename to tools/revamb-dump/IsolateFunctions.cpp index 5f38f8b00..e7563ab7c 100644 --- a/isolatefunctions.cpp +++ b/tools/revamb-dump/IsolateFunctions.cpp @@ -13,12 +13,14 @@ #include "llvm/Support/raw_os_ostream.h" #include "llvm/Transforms/Utils/Cloning.h" +// Local libraries includes +#include "revng/BasicAnalyses/GeneratedCodeBasicInfo.h" +#include "revng/Runtime/commonconstants.h" +#include "revng/Support/Debug.h" +#include "revng/Support/IRHelpers.h" + // Local includes -#include "commonconstants.h" -#include "debug.h" -#include "generatedcodebasicinfo.h" -#include "ir-helpers.h" -#include "isolatefunctions.h" +#include "IsolateFunctions.h" using namespace llvm; diff --git a/isolatefunctions.h b/tools/revamb-dump/IsolateFunctions.h similarity index 88% rename from isolatefunctions.h rename to tools/revamb-dump/IsolateFunctions.h index 84292c36f..043d755a7 100644 --- a/isolatefunctions.h +++ b/tools/revamb-dump/IsolateFunctions.h @@ -11,8 +11,8 @@ // LLVM includes #include "llvm/Pass.h" -// Local includes -#include "generatedcodebasicinfo.h" +// Local libraries includes +#include "revng/BasicAnalyses/GeneratedCodeBasicInfo.h" class IsolateFunctions : public llvm::FunctionPass { public: diff --git a/dump.cpp b/tools/revamb-dump/Main.cpp similarity index 94% rename from dump.cpp rename to tools/revamb-dump/Main.cpp index d80bba2f5..3f4551dce 100644 --- a/dump.cpp +++ b/tools/revamb-dump/Main.cpp @@ -16,17 +16,19 @@ #include "llvm/IRReader/IRReader.h" #include "llvm/Support/SourceMgr.h" +// Local libraries includes +#include "revng/DebugHelper/DebugHelper.h" +#include "revng/StackAnalysis/StackAnalysis.h" +#include "revng/Support/Callgrind.h" +#include "revng/Support/Debug.h" +#include "revng/Support/Statistics.h" +#include "revng/argparse/argparse.h" + // Local includes -#include "argparse.h" -#include "collectcfg.h" -#include "collectfunctionboundaries.h" -#include "collectnoreturn.h" -#include "debug.h" -#include "debughelper.h" -#include "isolatefunctions.h" -#include "revng/StackAnalysis/stackanalysis.h" -#include "statistics.h" -#include "valgrindhelpers.h" +#include "CollectCFG.h" +#include "CollectFunctionBoundaries.h" +#include "CollectNoreturn.h" +#include "IsolateFunctions.h" using namespace llvm; diff --git a/binaryfile.cpp b/tools/revamb/BinaryFile.cpp similarity index 99% rename from binaryfile.cpp rename to tools/revamb/BinaryFile.cpp index 514a52c48..a813239d9 100644 --- a/binaryfile.cpp +++ b/tools/revamb/BinaryFile.cpp @@ -24,9 +24,11 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/LEB128.h" +// Local libraries includes +#include "revng/Support/Debug.h" + // Local includes -#include "binaryfile.h" -#include "debug.h" +#include "BinaryFile.h" // using directives using namespace llvm; diff --git a/binaryfile.h b/tools/revamb/BinaryFile.h similarity index 99% rename from binaryfile.h rename to tools/revamb/BinaryFile.h index d8160b5ff..9ecbefff3 100644 --- a/binaryfile.h +++ b/tools/revamb/BinaryFile.h @@ -15,8 +15,8 @@ #include "llvm/Object/Binary.h" #include "llvm/Object/ELFTypes.h" -// Local includes -#include "revamb.h" +// Local libraries includes +#include "revng/Support/revng.h" namespace llvm { namespace object { diff --git a/tools/revamb/CMakeLists.txt b/tools/revamb/CMakeLists.txt new file mode 100644 index 000000000..c14198007 --- /dev/null +++ b/tools/revamb/CMakeLists.txt @@ -0,0 +1,31 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +add_executable(revamb + Main.cpp + BinaryFile.cpp + CodeGenerator.cpp + CPUStateAccessAnalysisPass.cpp + ExternalJumpsHandler.cpp + FunctionBoundariesDetectionPass.cpp + InstructionTranslator.cpp + JumpTargetManager.cpp + NoReturnAnalysis.cpp + OSRA.cpp + PTCDump.cpp + ReachingDefinitionsPass.cpp + SET.cpp + SimplifyComparisonsPass.cpp + VariableManager.cpp) +target_link_libraries(revamb + dl + m + Support + DebugHelper + argparse + BasicAnalyses + ${LLVM_LIBRARIES}) +add_custom_command(TARGET revamb POST_BUILD VERBATIM + COMMAND ${CMAKE_COMMAND} -E copy "$" "${CMAKE_BINARY_DIR}/") +install(TARGETS revamb RUNTIME DESTINATION bin) diff --git a/cpustateaccessanalysis.cpp b/tools/revamb/CPUStateAccessAnalysisPass.cpp similarity index 99% rename from cpustateaccessanalysis.cpp rename to tools/revamb/CPUStateAccessAnalysisPass.cpp index 4806e69e1..bce73d97a 100644 --- a/cpustateaccessanalysis.cpp +++ b/tools/revamb/CPUStateAccessAnalysisPass.cpp @@ -21,11 +21,13 @@ #include "llvm/IR/Verifier.h" #include "llvm/Support/Casting.h" +// Local libraries includes +#include "revng/Support/Debug.h" +#include "revng/Support/IRHelpers.h" + // Local includes -#include "cpustateaccessanalysis.h" -#include "debug.h" -#include "ir-helpers.h" -#include "variablemanager.h" +#include "CPUStateAccessAnalysisPass.h" +#include "VariableManager.h" namespace llvm { class DataLayout; diff --git a/cpustateaccessanalysis.h b/tools/revamb/CPUStateAccessAnalysisPass.h similarity index 99% rename from cpustateaccessanalysis.h rename to tools/revamb/CPUStateAccessAnalysisPass.h index 64212d905..d14bc616a 100644 --- a/cpustateaccessanalysis.h +++ b/tools/revamb/CPUStateAccessAnalysisPass.h @@ -14,8 +14,8 @@ #include "llvm/Pass.h" #include "llvm/Support/raw_ostream.h" -// Local includes -#include "revng-assert.h" +// Local libraries includes +#include "revng/Support/Assert.h" namespace llvm { class Instruction; diff --git a/codegenerator.cpp b/tools/revamb/CodeGenerator.cpp similarity index 98% rename from codegenerator.cpp rename to tools/revamb/CodeGenerator.cpp index 51d459b2b..ad83f51dd 100644 --- a/codegenerator.cpp +++ b/tools/revamb/CodeGenerator.cpp @@ -38,17 +38,19 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" +// Local libraries includes +#include "revng/DebugHelper/DebugHelper.h" +#include "revng/Support/Debug.h" +#include "revng/Support/revng.h" + // Local includes -#include "codegenerator.h" -#include "debug.h" -#include "debughelper.h" -#include "externaljumpshandler.h" -#include "functionboundariesdetection.h" -#include "instructiontranslator.h" -#include "jumptargetmanager.h" -#include "ptcinterface.h" -#include "revamb.h" -#include "variablemanager.h" +#include "CodeGenerator.h" +#include "ExternalJumpsHandler.h" +#include "FunctionBoundariesDetectionPass.h" +#include "InstructionTranslator.h" +#include "JumpTargetManager.h" +#include "PTCInterface.h" +#include "VariableManager.h" using namespace llvm; diff --git a/codegenerator.h b/tools/revamb/CodeGenerator.h similarity index 98% rename from codegenerator.h rename to tools/revamb/CodeGenerator.h index d8eff4265..daa951cf0 100644 --- a/codegenerator.h +++ b/tools/revamb/CodeGenerator.h @@ -13,9 +13,11 @@ // LLVM includes #include "llvm/ADT/ArrayRef.h" +// Local libraries includes +#include "revng/Support/revng.h" + // Local includes -#include "binaryfile.h" -#include "revamb.h" +#include "BinaryFile.h" // Forward declarations namespace llvm { diff --git a/externaljumpshandler.cpp b/tools/revamb/ExternalJumpsHandler.cpp similarity index 98% rename from externaljumpshandler.cpp rename to tools/revamb/ExternalJumpsHandler.cpp index 8d69285f4..661a2629d 100644 --- a/externaljumpshandler.cpp +++ b/tools/revamb/ExternalJumpsHandler.cpp @@ -18,11 +18,14 @@ #include "llvm/IR/Module.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" +// Local libraries includes +#include "revng/Support/Debug.h" + // Local includes -#include "binaryfile.h" -#include "debug.h" -#include "externaljumpshandler.h" -#include "jumptargetmanager.h" +#include "BinaryFile.h" +#include "ExternalJumpsHandler.h" +#include "JumpTargetManager.h" +#include "revng/Support/Debug.h" using namespace llvm; using std::string; diff --git a/externaljumpshandler.h b/tools/revamb/ExternalJumpsHandler.h similarity index 97% rename from externaljumpshandler.h rename to tools/revamb/ExternalJumpsHandler.h index c4a30bfa7..0f1fcca6e 100644 --- a/externaljumpshandler.h +++ b/tools/revamb/ExternalJumpsHandler.h @@ -13,10 +13,12 @@ #include "llvm/IR/Instruction.h" #include "llvm/Pass.h" +// Local libraries includes +#include "revng/Support/revng.h" + // Local includes -#include "binaryfile.h" -#include "jumptargetmanager.h" -#include "revamb.h" +#include "BinaryFile.h" +#include "JumpTargetManager.h" /// \brief Inject code to support jumping in non-translated code and handling /// the comeback. diff --git a/functionboundariesdetection.cpp b/tools/revamb/FunctionBoundariesDetectionPass.cpp similarity index 98% rename from functionboundariesdetection.cpp rename to tools/revamb/FunctionBoundariesDetectionPass.cpp index e5d1fae7b..e51137e87 100644 --- a/functionboundariesdetection.cpp +++ b/tools/revamb/FunctionBoundariesDetectionPass.cpp @@ -26,12 +26,14 @@ #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" +// Local libraries includes +#include "revng/ADT/Queue.h" +#include "revng/Support/Debug.h" +#include "revng/Support/IRHelpers.h" + // Local includes -#include "datastructures.h" -#include "debug.h" -#include "functionboundariesdetection.h" -#include "ir-helpers.h" -#include "jumptargetmanager.h" +#include "FunctionBoundariesDetectionPass.h" +#include "JumpTargetManager.h" using namespace llvm; diff --git a/functionboundariesdetection.h b/tools/revamb/FunctionBoundariesDetectionPass.h similarity index 100% rename from functionboundariesdetection.h rename to tools/revamb/FunctionBoundariesDetectionPass.h diff --git a/instructiontranslator.cpp b/tools/revamb/InstructionTranslator.cpp similarity index 99% rename from instructiontranslator.cpp rename to tools/revamb/InstructionTranslator.cpp index 42579fba4..ef3a1674c 100644 --- a/instructiontranslator.cpp +++ b/tools/revamb/InstructionTranslator.cpp @@ -7,7 +7,7 @@ // // Standard includes -#include "revng-assert.h" +#include "revng/Support/Assert.h" #include #include #include @@ -21,15 +21,16 @@ #include "llvm/IR/Module.h" #include "llvm/Support/Casting.h" +// Local libraries includes +#include "revng/Support/IRHelpers.h" +#include "revng/Support/RandomAccessIterator.h" +#include "revng/Support/Range.h" +#include "revng/Support/Transform.h" + // Local includes -#include "datastructures.h" -#include "instructiontranslator.h" -#include "ir-helpers.h" -#include "ptcinterface.h" -#include "rai.h" -#include "range.h" -#include "transformadapter.h" -#include "variablemanager.h" +#include "InstructionTranslator.h" +#include "PTCInterface.h" +#include "VariableManager.h" using namespace llvm; diff --git a/instructiontranslator.h b/tools/revamb/InstructionTranslator.h similarity index 97% rename from instructiontranslator.h rename to tools/revamb/InstructionTranslator.h index 6a47e7a88..88129c25b 100644 --- a/instructiontranslator.h +++ b/tools/revamb/InstructionTranslator.h @@ -15,10 +15,12 @@ #include "llvm/Pass.h" #include "llvm/Support/ErrorOr.h" +// Local libraries includes +#include "revng/Support/revng.h" + // Local includes -#include "jumptargetmanager.h" -#include "ptcdump.h" -#include "revamb.h" +#include "JumpTargetManager.h" +#include "PTCDump.h" // Forward declarations namespace llvm { diff --git a/jumptargetmanager.cpp b/tools/revamb/JumpTargetManager.cpp similarity index 99% rename from jumptargetmanager.cpp rename to tools/revamb/JumpTargetManager.cpp index 40673cc35..05ae2d55e 100644 --- a/jumptargetmanager.cpp +++ b/tools/revamb/JumpTargetManager.cpp @@ -8,7 +8,7 @@ // // Standard includes -#include "revng-assert.h" +#include "revng/Support/Assert.h" #include #include #include @@ -31,16 +31,18 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/Cloning.h" +// Local libraries includes +#include "revng/ADT/Queue.h" +#include "revng/BasicAnalyses/GeneratedCodeBasicInfo.h" +#include "revng/Support/Debug.h" +#include "revng/Support/IRHelpers.h" +#include "revng/Support/revng.h" + // Local includes -#include "datastructures.h" -#include "debug.h" -#include "generatedcodebasicinfo.h" -#include "ir-helpers.h" -#include "jumptargetmanager.h" -#include "revamb.h" -#include "set.h" -#include "simplifycomparisons.h" -#include "subgraph.h" +#include "JumpTargetManager.h" +#include "SET.h" +#include "SimplifyComparisonsPass.h" +#include "SubGraph.h" using namespace llvm; diff --git a/jumptargetmanager.h b/tools/revamb/JumpTargetManager.h similarity index 99% rename from jumptargetmanager.h rename to tools/revamb/JumpTargetManager.h index e2f47412b..91f3906d7 100644 --- a/jumptargetmanager.h +++ b/tools/revamb/JumpTargetManager.h @@ -20,12 +20,13 @@ #include "llvm/ADT/Optional.h" #include "llvm/IR/Instructions.h" +// Local libraries includes +#include "revng/Support/IRHelpers.h" +#include "revng/Support/revng.h" + // Local includes -#include "binaryfile.h" -#include "datastructures.h" -#include "ir-helpers.h" -#include "noreturnanalysis.h" -#include "revamb.h" +#include "BinaryFile.h" +#include "NoReturnAnalysis.h" // Forward declarations namespace llvm { diff --git a/main.cpp b/tools/revamb/Main.cpp similarity index 98% rename from main.cpp rename to tools/revamb/Main.cpp index 05ba34706..906fac2ed 100644 --- a/main.cpp +++ b/tools/revamb/Main.cpp @@ -28,14 +28,16 @@ extern "C" { #include "llvm/Object/Binary.h" #include "llvm/Object/ELF.h" +// Local libraries includes +#include "revng/Support/Debug.h" +#include "revng/Support/Statistics.h" +#include "revng/Support/revng.h" +#include "revng/argparse/argparse.h" + // Local includes -#include "argparse.h" -#include "binaryfile.h" -#include "codegenerator.h" -#include "debug.h" -#include "ptcinterface.h" -#include "revamb.h" -#include "statistics.h" +#include "BinaryFile.h" +#include "CodeGenerator.h" +#include "PTCInterface.h" PTCInterface ptc = {}; ///< The interface with the PTC library. static std::string LibTinycodePath; diff --git a/memoryaccess.h b/tools/revamb/MemoryAccess.h similarity index 99% rename from memoryaccess.h rename to tools/revamb/MemoryAccess.h index eba592fe3..502b2bd12 100644 --- a/memoryaccess.h +++ b/tools/revamb/MemoryAccess.h @@ -16,8 +16,8 @@ #include "llvm/IR/Intrinsics.h" #include "llvm/Support/Casting.h" -// Local includes -#include "ir-helpers.h" +// Local libraries includes +#include "revng/Support/IRHelpers.h" class TypeSizeProvider { public: diff --git a/noreturnanalysis.cpp b/tools/revamb/NoReturnAnalysis.cpp similarity index 98% rename from noreturnanalysis.cpp rename to tools/revamb/NoReturnAnalysis.cpp index 88d61da93..ea96e11f5 100644 --- a/noreturnanalysis.cpp +++ b/tools/revamb/NoReturnAnalysis.cpp @@ -12,11 +12,13 @@ #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" +// Local libraries includes +#include "revng/ADT/Queue.h" +#include "revng/Support/Debug.h" +#include "revng/Support/IRHelpers.h" + // Local includes -#include "datastructures.h" -#include "debug.h" -#include "ir-helpers.h" -#include "noreturnanalysis.h" +#include "NoReturnAnalysis.h" using namespace llvm; diff --git a/noreturnanalysis.h b/tools/revamb/NoReturnAnalysis.h similarity index 97% rename from noreturnanalysis.h rename to tools/revamb/NoReturnAnalysis.h index fe4c4f904..27ca19e57 100644 --- a/noreturnanalysis.h +++ b/tools/revamb/NoReturnAnalysis.h @@ -15,9 +15,11 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" +// Local libraries includes +#include "revng/Support/revng.h" + // Local includes -#include "reachingdefinitions.h" -#include "revamb.h" +#include "ReachingDefinitionsPass.h" namespace llvm { class BasicBlock; diff --git a/osra.cpp b/tools/revamb/OSRA.cpp similarity index 99% rename from osra.cpp rename to tools/revamb/OSRA.cpp index 3e68aaaf1..0820830ec 100644 --- a/osra.cpp +++ b/tools/revamb/OSRA.cpp @@ -25,13 +25,15 @@ #include "llvm/Support/FormattedStream.h" #include "llvm/Support/raw_os_ostream.h" +// Local libraries includes +#include "revng/ADT/Queue.h" +#include "revng/Support/Debug.h" +#include "revng/Support/IRHelpers.h" +#include "revng/Support/revng.h" + // Local includes -#include "datastructures.h" -#include "debug.h" -#include "ir-helpers.h" -#include "memoryaccess.h" -#include "osra.h" -#include "revamb.h" +#include "MemoryAccess.h" +#include "OSRA.h" using namespace llvm; diff --git a/osra.h b/tools/revamb/OSRA.h similarity index 99% rename from osra.h rename to tools/revamb/OSRA.h index e31cc2970..072ee83fc 100644 --- a/osra.h +++ b/tools/revamb/OSRA.h @@ -12,11 +12,13 @@ // LLVM includes #include "llvm/Pass.h" +// Local libraries includes +#include "revng/BasicAnalyses/FunctionCallIdentification.h" +#include "revng/Support/IRHelpers.h" + // Local includes -#include "functioncallidentification.h" -#include "ir-helpers.h" -#include "reachingdefinitions.h" -#include "simplifycomparisons.h" +#include "ReachingDefinitionsPass.h" +#include "SimplifyComparisonsPass.h" // Forward declarations namespace llvm { diff --git a/ptcdump.cpp b/tools/revamb/PTCDump.cpp similarity index 99% rename from ptcdump.cpp rename to tools/revamb/PTCDump.cpp index c37eeb034..74d692440 100644 --- a/ptcdump.cpp +++ b/tools/revamb/PTCDump.cpp @@ -6,7 +6,7 @@ // // Standard includes -#include "revng-assert.h" +#include "revng/Support/Assert.h" #include #include #include @@ -14,8 +14,8 @@ #include // Local includes -#include "ptcdump.h" -#include "ptcinterface.h" +#include "PTCDump.h" +#include "PTCInterface.h" static const int MAX_TEMP_NAME_LENGTH = 128; diff --git a/ptcdump.h b/tools/revamb/PTCDump.h similarity index 100% rename from ptcdump.h rename to tools/revamb/PTCDump.h diff --git a/ptcinterface.h b/tools/revamb/PTCInterface.h similarity index 90% rename from ptcinterface.h rename to tools/revamb/PTCInterface.h index 5b961c2e5..d671e927e 100644 --- a/ptcinterface.h +++ b/tools/revamb/PTCInterface.h @@ -9,8 +9,10 @@ #include #include +// Local libraries includes +#include "revng/Support/revng.h" + // Local includes -#include "revamb.h" #define USE_DYNAMIC_PTC #include "ptc.h" diff --git a/reachingdefinitions.cpp b/tools/revamb/ReachingDefinitionsPass.cpp similarity index 99% rename from reachingdefinitions.cpp rename to tools/revamb/ReachingDefinitionsPass.cpp index e44b1bb14..7e882afe9 100644 --- a/reachingdefinitions.cpp +++ b/tools/revamb/ReachingDefinitionsPass.cpp @@ -22,12 +22,14 @@ #include "llvm/IR/Module.h" #include "llvm/Support/Casting.h" +// Local libraries includes +#include "revng/ADT/UniquedStack.h" +#include "revng/BasicAnalyses/FunctionCallIdentification.h" +#include "revng/Support/Debug.h" +#include "revng/Support/IRHelpers.h" + // Local includes -#include "datastructures.h" -#include "debug.h" -#include "functioncallidentification.h" -#include "ir-helpers.h" -#include "reachingdefinitions.h" +#include "ReachingDefinitionsPass.h" using namespace llvm; diff --git a/reachingdefinitions.h b/tools/revamb/ReachingDefinitionsPass.h similarity index 99% rename from reachingdefinitions.h rename to tools/revamb/ReachingDefinitionsPass.h index c0dd8eb09..661ef979d 100644 --- a/reachingdefinitions.h +++ b/tools/revamb/ReachingDefinitionsPass.h @@ -15,9 +15,9 @@ #include "llvm/Pass.h" // Local includes -#include "datastructures.h" -#include "debug.h" -#include "memoryaccess.h" +#include "MemoryAccess.h" +#include "revng/Support/Debug.h" +#include "revng/Support/IRHelpers.h" #define BitVector SmallBitVector diff --git a/set.cpp b/tools/revamb/SET.cpp similarity index 99% rename from set.cpp rename to tools/revamb/SET.cpp index 537991b81..d4c25dd79 100644 --- a/set.cpp +++ b/tools/revamb/SET.cpp @@ -16,14 +16,15 @@ #include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Module.h" +// Local libraries includes +#include "revng/Support/Debug.h" +#include "revng/Support/IRHelpers.h" +#include "revng/Support/revng.h" + // Local includes -#include "datastructures.h" -#include "debug.h" -#include "ir-helpers.h" -#include "jumptargetmanager.h" -#include "osra.h" -#include "revamb.h" -#include "set.h" +#include "JumpTargetManager.h" +#include "OSRA.h" +#include "SET.h" using namespace llvm; using std::make_pair; diff --git a/set.h b/tools/revamb/SET.h similarity index 100% rename from set.h rename to tools/revamb/SET.h diff --git a/simplifycomparisons.cpp b/tools/revamb/SimplifyComparisonsPass.cpp similarity index 98% rename from simplifycomparisons.cpp rename to tools/revamb/SimplifyComparisonsPass.cpp index 57f25612f..5daf14b37 100644 --- a/simplifycomparisons.cpp +++ b/tools/revamb/SimplifyComparisonsPass.cpp @@ -18,11 +18,12 @@ #include "llvm/IR/Module.h" #include "llvm/Support/Casting.h" +// Local libraries includes +#include "revng/Support/Debug.h" +#include "revng/Support/IRHelpers.h" + // Local include -#include "datastructures.h" -#include "debug.h" -#include "ir-helpers.h" -#include "simplifycomparisons.h" +#include "SimplifyComparisonsPass.h" using namespace llvm; diff --git a/simplifycomparisons.h b/tools/revamb/SimplifyComparisonsPass.h similarity index 98% rename from simplifycomparisons.h rename to tools/revamb/SimplifyComparisonsPass.h index 9d60e4920..ce699271a 100644 --- a/simplifycomparisons.h +++ b/tools/revamb/SimplifyComparisonsPass.h @@ -12,7 +12,7 @@ #include "llvm/Pass.h" // Local includes -#include "reachingdefinitions.h" +#include "ReachingDefinitionsPass.h" /// \brief Look for sophisticated comparisons that can be simplified /// This pass looks for comparisons checkin for the sign of a value, and, if diff --git a/subgraph.h b/tools/revamb/SubGraph.h similarity index 98% rename from subgraph.h rename to tools/revamb/SubGraph.h index 233051990..d40d001aa 100644 --- a/subgraph.h +++ b/tools/revamb/SubGraph.h @@ -9,6 +9,9 @@ #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/SmallVector.h" +// Local libraries includes +#include "revng/ADT/Queue.h" + /// \brief Data structure implementing a subgraph of an object providing /// GraphTraits /// diff --git a/variablemanager.cpp b/tools/revamb/VariableManager.cpp similarity index 99% rename from variablemanager.cpp rename to tools/revamb/VariableManager.cpp index 786873d07..76ebb4ac8 100644 --- a/variablemanager.cpp +++ b/tools/revamb/VariableManager.cpp @@ -23,13 +23,15 @@ #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/ValueMapper.h" +// Local libraries includes +#include "revng/Support/Debug.h" +#include "revng/Support/IRHelpers.h" +#include "revng/Support/revng.h" + // Local includes -#include "debug.h" -#include "ir-helpers.h" -#include "ptcdump.h" -#include "ptcinterface.h" -#include "revamb.h" -#include "variablemanager.h" +#include "PTCDump.h" +#include "PTCInterface.h" +#include "VariableManager.h" using namespace llvm; diff --git a/variablemanager.h b/tools/revamb/VariableManager.h similarity index 98% rename from variablemanager.h rename to tools/revamb/VariableManager.h index 0f22ca546..de815f747 100644 --- a/variablemanager.h +++ b/tools/revamb/VariableManager.h @@ -14,10 +14,12 @@ #include "llvm/IR/IRBuilder.h" #include "llvm/Pass.h" +// Local libraries includes +#include "revng/Support/revng.h" + // Local includes -#include "cpustateaccessanalysis.h" -#include "ptcdump.h" -#include "revamb.h" +#include "CPUStateAccessAnalysisPass.h" +#include "PTCDump.h" namespace llvm { class AllocaInst;