diff options
| author | Shankar Easwaran <shankare@codeaurora.org> | 2014-11-11 00:40:36 +0000 |
|---|---|---|
| committer | Shankar Easwaran <shankare@codeaurora.org> | 2014-11-11 00:40:36 +0000 |
| commit | 48b9fc7981d78a0d3fac3b09041dd2af9b380b3b (patch) | |
| tree | cb6f705318a377a02232d1e8c4bbfe816aea3414 | |
| parent | 1987862287f7e222bf60b266c01be8c78bf661a6 (diff) | |
| download | bcm5719-llvm-48b9fc7981d78a0d3fac3b09041dd2af9b380b3b.tar.gz bcm5719-llvm-48b9fc7981d78a0d3fac3b09041dd2af9b380b3b.zip | |
Revert "Add support library."
This reverts commit r221583.
llvm-svn: 221649
| -rw-r--r-- | lld/include/lld/Support/NumParse.h | 45 | ||||
| -rw-r--r-- | lld/lib/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | lld/lib/Makefile | 2 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/LinkerScript.cpp | 109 | ||||
| -rw-r--r-- | lld/lib/Support/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | lld/lib/Support/NumParse.cpp | 133 | ||||
| -rw-r--r-- | lld/tools/lld/Makefile | 4 | ||||
| -rw-r--r-- | lld/unittests/DriverTests/Makefile | 4 | ||||
| -rw-r--r-- | lld/utils/linker-script-test/Makefile | 2 |
10 files changed, 112 insertions, 192 deletions
diff --git a/lld/include/lld/Support/NumParse.h b/lld/include/lld/Support/NumParse.h deleted file mode 100644 index a375402405b..00000000000 --- a/lld/include/lld/Support/NumParse.h +++ /dev/null @@ -1,45 +0,0 @@ -//===-- lld/Support/NumParse.h - Number parsing -----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -/// -/// \file -/// \brief Parses string in various formats to decimal. -/// -//===----------------------------------------------------------------------===// - -#ifndef LLD_SUPPORT_NUM_PARSE_H -#define LLD_SUPPORT_NUM_PARSE_H - -#include "lld/Core/LLVM.h" -#include "llvm/ADT/StringSwitch.h" -#include "llvm/Support/ErrorOr.h" -#include "llvm/Support/raw_ostream.h" -#include <memory> -#include <system_error> -#include <vector> - -namespace lld { - -/// \brief Convert a string in decimal to decimal. -llvm::ErrorOr<uint64_t> parseDecimal(StringRef str); - -/// \brief Convert a string in octal to decimal. -llvm::ErrorOr<uint64_t> parseOctal(StringRef str); - -/// \brief Convert a string in Binary to decimal. -llvm::ErrorOr<uint64_t> parseBinary(StringRef str); - -/// \brief Convert a string in Hexadecimal to decimal. -llvm::ErrorOr<uint64_t> parseHex(StringRef str); - -/// \brief Parse a number represested in a string as -// Hexadecimal, Octal, Binary or Decimal to decimal -llvm::ErrorOr<uint64_t> parseNum(StringRef str, bool parseExtensions = true); -} - -#endif // LLD_SUPPORT_NUM_PARSE_H diff --git a/lld/lib/CMakeLists.txt b/lld/lib/CMakeLists.txt index 5054b66e208..157099d3c31 100644 --- a/lld/lib/CMakeLists.txt +++ b/lld/lib/CMakeLists.txt @@ -3,4 +3,3 @@ add_subdirectory(Core) add_subdirectory(Driver) add_subdirectory(Passes) add_subdirectory(ReaderWriter) -add_subdirectory(Support) diff --git a/lld/lib/Makefile b/lld/lib/Makefile index ff2bd93cf67..375d50510fb 100644 --- a/lld/lib/Makefile +++ b/lld/lib/Makefile @@ -9,7 +9,7 @@ LLD_LEVEL := .. # ARCMigrate and Rewrite are always needed because of libclang. -PARALLEL_DIRS = Config Core Driver Passes ReaderWriter Support +PARALLEL_DIRS = Config Core Driver Passes ReaderWriter include $(LLD_LEVEL)/../../Makefile.config diff --git a/lld/lib/ReaderWriter/CMakeLists.txt b/lld/lib/ReaderWriter/CMakeLists.txt index 7ac719321ad..587d8594a8c 100644 --- a/lld/lib/ReaderWriter/CMakeLists.txt +++ b/lld/lib/ReaderWriter/CMakeLists.txt @@ -18,5 +18,4 @@ add_lld_library(lldReaderWriter target_link_libraries(lldReaderWriter ${cmake_2_8_12_INTERFACE} lldCore lldPasses - lldSupport ) diff --git a/lld/lib/ReaderWriter/LinkerScript.cpp b/lld/lib/ReaderWriter/LinkerScript.cpp index 080e5336498..3984408b605 100644 --- a/lld/lib/ReaderWriter/LinkerScript.cpp +++ b/lld/lib/ReaderWriter/LinkerScript.cpp @@ -13,7 +13,6 @@ //===----------------------------------------------------------------------===// #include "lld/ReaderWriter/LinkerScript.h" -#include "lld/Support/NumParse.h" namespace lld { namespace script { @@ -90,7 +89,56 @@ void Token::dump(raw_ostream &os) const { os << _range << "\n"; } -bool parseHexToByteStream(StringRef str, std::string &buf) { +static llvm::ErrorOr<uint64_t> parseDecimal(StringRef str) { + uint64_t res = 0; + for (auto &c : str) { + res *= 10; + if (c < '0' || c > '9') + return llvm::ErrorOr<uint64_t>(std::make_error_code(std::errc::io_error)); + res += c - '0'; + } + return res; +} + +static llvm::ErrorOr<uint64_t> parseOctal(StringRef str) { + uint64_t res = 0; + for (auto &c : str) { + res <<= 3; + if (c < '0' || c > '7') + return llvm::ErrorOr<uint64_t>(std::make_error_code(std::errc::io_error)); + res += c - '0'; + } + return res; +} + +static llvm::ErrorOr<uint64_t> parseBinary(StringRef str) { + uint64_t res = 0; + for (auto &c : str) { + res <<= 1; + if (c != '0' && c != '1') + return llvm::ErrorOr<uint64_t>(std::make_error_code(std::errc::io_error)); + res += c - '0'; + } + return res; +} + +static llvm::ErrorOr<uint64_t> parseHex(StringRef str) { + uint64_t res = 0; + for (auto &c : str) { + res <<= 4; + if (c >= '0' && c <= '9') + res += c - '0'; + else if (c >= 'a' && c <= 'f') + res += c - 'a' + 10; + else if (c >= 'A' && c <= 'F') + res += c - 'A' + 10; + else + return llvm::ErrorOr<uint64_t>(std::make_error_code(std::errc::io_error)); + } + return res; +} + +static bool parseHexToByteStream(StringRef str, std::string &buf) { unsigned char byte = 0; bool dumpByte = str.size() % 2; for (auto &c : str) { @@ -130,6 +178,63 @@ static void dumpByteStream(raw_ostream &os, StringRef stream) { } } +static llvm::ErrorOr<uint64_t> parseNum(StringRef str) { + unsigned multiplier = 1; + enum NumKind { decimal, hex, octal, binary }; + NumKind kind = llvm::StringSwitch<NumKind>(str) + .StartsWith("0x", hex) + .StartsWith("0X", hex) + .StartsWith("0", octal) + .Default(decimal); + + // Parse scale + if (str.endswith("K")) { + multiplier = 1 << 10; + str = str.drop_back(); + } else if (str.endswith("M")) { + multiplier = 1 << 20; + str = str.drop_back(); + } + + // Parse type + if (str.endswith_lower("o")) { + kind = octal; + str = str.drop_back(); + } else if (str.endswith_lower("h")) { + kind = hex; + str = str.drop_back(); + } else if (str.endswith_lower("d")) { + kind = decimal; + str = str.drop_back(); + } else if (str.endswith_lower("b")) { + kind = binary; + str = str.drop_back(); + } + + llvm::ErrorOr<uint64_t> res(0); + switch (kind) { + case hex: + if (str.startswith_lower("0x")) + str = str.drop_front(2); + res = parseHex(str); + break; + case octal: + res = parseOctal(str); + break; + case decimal: + res = parseDecimal(str); + break; + case binary: + res = parseBinary(str); + break; + } + if (res.getError()) + return res; + + *res = *res * multiplier; + return res; +} + bool Lexer::canStartNumber(char c) const { return '0' <= c && c <= '9'; } diff --git a/lld/lib/Support/CMakeLists.txt b/lld/lib/Support/CMakeLists.txt deleted file mode 100644 index 6e6a2eae9d9..00000000000 --- a/lld/lib/Support/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_lld_library(lldSupport - NumParse.cpp - ) diff --git a/lld/lib/Support/NumParse.cpp b/lld/lib/Support/NumParse.cpp deleted file mode 100644 index 5f1d525f3d1..00000000000 --- a/lld/lib/Support/NumParse.cpp +++ /dev/null @@ -1,133 +0,0 @@ -//===-- lld/Support/NumParse.cpp - Number parsing ---------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -/// -/// \file -/// \brief Parses string in various formats to decimal. -/// -//===----------------------------------------------------------------------===// - -#include "lld/Support/NumParse.h" - -using namespace llvm; - -namespace lld { -/// \brief Convert a string in decimal to decimal. -llvm::ErrorOr<uint64_t> parseDecimal(StringRef str) { - uint64_t res = 0; - for (auto &c : str) { - res *= 10; - if (c < '0' || c > '9') - return llvm::ErrorOr<uint64_t>(std::make_error_code(std::errc::io_error)); - res += c - '0'; - } - return res; -} - -/// \brief Convert a string in octal to decimal. -llvm::ErrorOr<uint64_t> parseOctal(StringRef str) { - uint64_t res = 0; - for (auto &c : str) { - res <<= 3; - if (c < '0' || c > '7') - return llvm::ErrorOr<uint64_t>(std::make_error_code(std::errc::io_error)); - res += c - '0'; - } - return res; -} - -/// \brief Convert a string in Binary to decimal. -llvm::ErrorOr<uint64_t> parseBinary(StringRef str) { - uint64_t res = 0; - for (auto &c : str) { - res <<= 1; - if (c != '0' && c != '1') - return llvm::ErrorOr<uint64_t>(std::make_error_code(std::errc::io_error)); - res += c - '0'; - } - return res; -} - -/// \brief Convert a string in Hexadecimal to decimal. -llvm::ErrorOr<uint64_t> parseHex(StringRef str) { - uint64_t res = 0; - for (auto &c : str) { - res <<= 4; - if (c >= '0' && c <= '9') - res += c - '0'; - else if (c >= 'a' && c <= 'f') - res += c - 'a' + 10; - else if (c >= 'A' && c <= 'F') - res += c - 'A' + 10; - else - return llvm::ErrorOr<uint64_t>(std::make_error_code(std::errc::io_error)); - } - return res; -} - -/// \brief Parse a number represested in a string as -// Hexadecimal, Octal, Binary or Decimal to decimal -llvm::ErrorOr<uint64_t> parseNum(StringRef str, bool parseExtensions) { - unsigned multiplier = 1; - enum NumKind { decimal, hex, octal, binary }; - NumKind kind = llvm::StringSwitch<NumKind>(str) - .StartsWith("0x", hex) - .StartsWith("0X", hex) - .StartsWith("0", octal) - .Default(decimal); - - if (parseExtensions) { - // Parse scale - if (str.endswith("K")) { - multiplier = 1 << 10; - str = str.drop_back(); - } else if (str.endswith("M")) { - multiplier = 1 << 20; - str = str.drop_back(); - } - - // Parse type - if (str.endswith_lower("o")) { - kind = octal; - str = str.drop_back(); - } else if (str.endswith_lower("h")) { - kind = hex; - str = str.drop_back(); - } else if (str.endswith_lower("d")) { - kind = decimal; - str = str.drop_back(); - } else if (str.endswith_lower("b")) { - kind = binary; - str = str.drop_back(); - } - } - - llvm::ErrorOr<uint64_t> res(0); - switch (kind) { - case hex: - if (str.startswith_lower("0x")) - str = str.drop_front(2); - res = parseHex(str); - break; - case octal: - res = parseOctal(str); - break; - case decimal: - res = parseDecimal(str); - break; - case binary: - res = parseBinary(str); - break; - } - if (res.getError()) - return res; - - *res = *res * multiplier; - return res; -} -} diff --git a/lld/tools/lld/Makefile b/lld/tools/lld/Makefile index 929c838debc..b0aeaec4b2e 100644 --- a/lld/tools/lld/Makefile +++ b/lld/tools/lld/Makefile @@ -19,9 +19,9 @@ LEVEL := $(LLD_LEVEL)/../.. include $(LEVEL)/Makefile.config LINK_COMPONENTS := $(TARGETS_TO_BUILD) -USEDLIBS = lldDriver.a lldConfig.a lldSupport.a \ +USEDLIBS = lldDriver.a lldConfig.a \ lldELF.a lldMachO.a lldPasses.a lldPECOFF.a lldYAML.a \ - lldReaderWriter.a lldCore.a lldSupport.a lldNative.a \ + lldReaderWriter.a lldCore.a lldNative.a \ lldHexagonELFTarget.a lldPPCELFTarget.a lldMipsELFTarget.a \ lldX86ELFTarget.a lldX86_64ELFTarget.a lldAArch64ELFTarget.a \ LLVMOption.a diff --git a/lld/unittests/DriverTests/Makefile b/lld/unittests/DriverTests/Makefile index b8ab2b401ab..1b4fe97a43b 100644 --- a/lld/unittests/DriverTests/Makefile +++ b/lld/unittests/DriverTests/Makefile @@ -15,7 +15,5 @@ USEDLIBS = lldDriver.a lldConfig.a \ lldHexagonELFTarget.a lldPPCELFTarget.a lldMipsELFTarget.a \ lldX86ELFTarget.a lldX86_64ELFTarget.a lldYAML.a \ LLVMObject.a LLVMMCParser.a LLVMMC.a LLVMBitReader.a \ - LLVMCore.a LLVMOption.a LLVMSupport.a lldAArch64ELFTarget.a \ - lldSupport.a - + LLVMCore.a LLVMOption.a LLVMSupport.a lldAArch64ELFTarget.a include $(LLD_LEVEL)/unittests/Makefile diff --git a/lld/utils/linker-script-test/Makefile b/lld/utils/linker-script-test/Makefile index db15e6a2d5c..de40ca54d25 100644 --- a/lld/utils/linker-script-test/Makefile +++ b/lld/utils/linker-script-test/Makefile @@ -19,6 +19,6 @@ LEVEL := $(LLD_LEVEL)/../.. include $(LEVEL)/Makefile.config LINK_COMPONENTS := $(TARGETS_TO_BUILD) -USEDLIBS = lldReaderWriter.a lldSupport.a LLVMSupport.a +USEDLIBS = lldReaderWriter.a LLVMSupport.a include $(LLD_LEVEL)/Makefile |

