LLVM  8.0.1
WasmTraits.h
Go to the documentation of this file.
1 //===- WasmTraits.h - DenseMap traits for the Wasm structures ---*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file provides llvm::DenseMapInfo traits for the Wasm structures.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_OBJECT_WASMTRAITS_H
15 #define LLVM_OBJECT_WASMTRAITS_H
16 
17 #include "llvm/ADT/Hashing.h"
18 #include "llvm/BinaryFormat/Wasm.h"
19 
20 namespace llvm {
21 
22 template <typename T> struct DenseMapInfo;
23 
24 // Traits for using WasmSignature in a DenseMap.
25 template <> struct DenseMapInfo<wasm::WasmSignature> {
29  return Sig;
30  }
34  return Sig;
35  }
36  static unsigned getHashValue(const wasm::WasmSignature &Sig) {
37  uintptr_t H = hash_value(Sig.State);
38  for (auto Ret : Sig.Returns)
39  H = hash_combine(H, Ret);
40  for (auto Param : Sig.Params)
41  H = hash_combine(H, Param);
42  return H;
43  }
44  static bool isEqual(const wasm::WasmSignature &LHS,
45  const wasm::WasmSignature &RHS) {
46  return LHS == RHS;
47  }
48 };
49 
50 // Traits for using WasmGlobalType in a DenseMap
51 template <> struct DenseMapInfo<wasm::WasmGlobalType> {
53  return wasm::WasmGlobalType{1, true};
54  }
56  return wasm::WasmGlobalType{2, true};
57  }
58  static unsigned getHashValue(const wasm::WasmGlobalType &GlobalType) {
59  return hash_combine(GlobalType.Type, GlobalType.Mutable);
60  }
61  static bool isEqual(const wasm::WasmGlobalType &LHS,
62  const wasm::WasmGlobalType &RHS) {
63  return LHS == RHS;
64  }
65 };
66 
67 } // end namespace llvm
68 
69 #endif // LLVM_OBJECT_WASMTRAITS_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
SmallVector< wasm::ValType, 1 > Returns
Definition: Wasm.h:309
static wasm::WasmGlobalType getEmptyKey()
Definition: WasmTraits.h:52
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
Definition: APFloat.cpp:4431
static wasm::WasmGlobalType getTombstoneKey()
Definition: WasmTraits.h:55
#define H(x, y, z)
Definition: MD5.cpp:57
static bool isEqual(const wasm::WasmGlobalType &LHS, const wasm::WasmGlobalType &RHS)
Definition: WasmTraits.h:61
enum llvm::wasm::WasmSignature::@148 State
static unsigned getHashValue(const wasm::WasmGlobalType &GlobalType)
Definition: WasmTraits.h:58
static wasm::WasmSignature getEmptyKey()
Definition: WasmTraits.h:26
static unsigned getHashValue(const wasm::WasmSignature &Sig)
Definition: WasmTraits.h:36
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition: Hashing.h:601
static wasm::WasmSignature getTombstoneKey()
Definition: WasmTraits.h:31
static bool isEqual(const wasm::WasmSignature &LHS, const wasm::WasmSignature &RHS)
Definition: WasmTraits.h:44
SmallVector< wasm::ValType, 4 > Params
Definition: Wasm.h:310