From 3e3f5fb3a31a7f043b2d2874907fef0240ad3968 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Wed, 14 Mar 2018 15:58:16 +0000 Subject: [PATCH] [WebAssembly] Use DenseMapInfo traits from LLVM repo. NFC Differential Revision: https://reviews.llvm.org/D44150 llvm-svn: 327527 --- lld/wasm/Writer.cpp | 26 ++------------------------ lld/wasm/WriterUtils.h | 24 +----------------------- 2 files changed, 3 insertions(+), 47 deletions(-) diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp index 3c6a90b..5043ebd 100644 --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -21,6 +21,7 @@ #include "lld/Common/Threads.h" #include "llvm/ADT/DenseSet.h" #include "llvm/BinaryFormat/Wasm.h" +#include "llvm/Object/WasmTraits.h" #include "llvm/Support/FileOutputBuffer.h" #include "llvm/Support/Format.h" #include "llvm/Support/FormatVariadic.h" @@ -41,29 +42,6 @@ static constexpr int kInitialTableOffset = 1; namespace { -// Traits for using WasmSignature in a DenseMap. -struct WasmSignatureDenseMapInfo { - static WasmSignature getEmptyKey() { - WasmSignature Sig; - Sig.ReturnType = 1; - return Sig; - } - static WasmSignature getTombstoneKey() { - WasmSignature Sig; - Sig.ReturnType = 2; - return Sig; - } - static unsigned getHashValue(const WasmSignature &Sig) { - unsigned H = hash_value(Sig.ReturnType); - for (int32_t Param : Sig.ParamTypes) - H = hash_combine(H, Param); - return H; - } - static bool isEqual(const WasmSignature &LHS, const WasmSignature &RHS) { - return LHS == RHS; - } -}; - // An init entry to be written to either the synthetic init func or the // linking metadata. struct WasmInitEntry { @@ -120,7 +98,7 @@ private: uint32_t MaxMemoryPages = 0; std::vector Types; - DenseMap TypeIndices; + DenseMap TypeIndices; std::vector ImportedSymbols; unsigned NumImportedFunctions = 0; unsigned NumImportedGlobals = 0; diff --git a/lld/wasm/WriterUtils.h b/lld/wasm/WriterUtils.h index 6721ef4..c920485 100644 --- a/lld/wasm/WriterUtils.h +++ b/lld/wasm/WriterUtils.h @@ -17,28 +17,6 @@ using llvm::raw_ostream; -// Needed for WasmSignatureDenseMapInfo -inline bool operator==(const llvm::wasm::WasmSignature &LHS, - const llvm::wasm::WasmSignature &RHS) { - return LHS.ReturnType == RHS.ReturnType && LHS.ParamTypes == RHS.ParamTypes; -} - -inline bool operator!=(const llvm::wasm::WasmSignature &LHS, - const llvm::wasm::WasmSignature &RHS) { - return !(LHS == RHS); -} - -// Used for general comparison -inline bool operator==(const llvm::wasm::WasmGlobalType &LHS, - const llvm::wasm::WasmGlobalType &RHS) { - return LHS.Type == RHS.Type && LHS.Mutable == RHS.Mutable; -} - -inline bool operator!=(const llvm::wasm::WasmGlobalType &LHS, - const llvm::wasm::WasmGlobalType &RHS) { - return !(LHS == RHS); -} - namespace lld { namespace wasm { @@ -75,7 +53,7 @@ void writeExport(raw_ostream &OS, const llvm::wasm::WasmExport &Export); } // namespace wasm -std::string toString(const llvm::wasm::ValType Type); +std::string toString(llvm::wasm::ValType Type); std::string toString(const llvm::wasm::WasmSignature &Sig); std::string toString(const llvm::wasm::WasmGlobalType &Sig); -- 2.7.4