LLVM 23.0.0git
WasmTraits.h
Go to the documentation of this file.
1//===- WasmTraits.h - DenseMap traits for the Wasm structures ---*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file provides llvm::DenseMapInfo traits for the Wasm structures.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_BINARYFORMAT_WASMTRAITS_H
14#define LLVM_BINARYFORMAT_WASMTRAITS_H
15
16#include "llvm/ADT/Hashing.h"
18
19namespace llvm {
20
21// Traits for using WasmSignature in a DenseMap.
22template <> struct DenseMapInfo<wasm::WasmSignature, void> {
28 static unsigned getHashValue(const wasm::WasmSignature &Sig) {
29 uintptr_t H = hash_value(Sig.State);
30 for (auto Ret : Sig.Returns)
31 H = hash_combine(H, Ret);
32 for (auto Param : Sig.Params)
33 H = hash_combine(H, Param);
34 return H;
35 }
36 static bool isEqual(const wasm::WasmSignature &LHS,
37 const wasm::WasmSignature &RHS) {
38 return LHS == RHS;
39 }
40};
41
42// Traits for using WasmGlobalType in a DenseMap
43template <> struct DenseMapInfo<wasm::WasmGlobalType, void> {
45 return wasm::WasmGlobalType{1, true};
46 }
47 static unsigned getHashValue(const wasm::WasmGlobalType &GlobalType) {
48 return hash_combine(GlobalType.Type, GlobalType.Mutable);
49 }
50 static bool isEqual(const wasm::WasmGlobalType &LHS,
52 return LHS == RHS;
53 }
54};
55
56// Traits for using WasmLimits in a DenseMap
57template <> struct DenseMapInfo<wasm::WasmLimits, void> {
59 return wasm::WasmLimits{0xff, 0xff, 0xff, 0xff};
60 }
61 static unsigned getHashValue(const wasm::WasmLimits &Limits) {
62 unsigned Hash = hash_value(Limits.Flags);
63 Hash = hash_combine(Hash, Limits.Minimum);
65 Hash = hash_combine(Hash, Limits.Maximum);
66 }
67 return Hash;
68 }
69 static bool isEqual(const wasm::WasmLimits &LHS,
70 const wasm::WasmLimits &RHS) {
71 return LHS == RHS;
72 }
73};
74
75// Traits for using WasmTableType in a DenseMap
76template <> struct DenseMapInfo<wasm::WasmTableType, void> {
81 static unsigned getHashValue(const wasm::WasmTableType &TableType) {
82 return hash_combine(
83 TableType.ElemType,
85 }
86 static bool isEqual(const wasm::WasmTableType &LHS,
87 const wasm::WasmTableType &RHS) {
88 return LHS == RHS;
89 }
90};
91
92} // end namespace llvm
93
94#endif // LLVM_BINARYFORMAT_WASMTRAITS_H
#define H(x, y, z)
Definition MD5.cpp:56
Value * RHS
Value * LHS
@ WASM_LIMITS_FLAG_HAS_MAX
Definition Wasm.h:168
This is an optimization pass for GlobalISel generic memory operations.
hash_code hash_value(const FixedPointSemantics &Val)
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition Hashing.h:325
static unsigned getHashValue(const wasm::WasmGlobalType &GlobalType)
Definition WasmTraits.h:47
static bool isEqual(const wasm::WasmGlobalType &LHS, const wasm::WasmGlobalType &RHS)
Definition WasmTraits.h:50
static wasm::WasmGlobalType getEmptyKey()
Definition WasmTraits.h:44
static wasm::WasmLimits getEmptyKey()
Definition WasmTraits.h:58
static bool isEqual(const wasm::WasmLimits &LHS, const wasm::WasmLimits &RHS)
Definition WasmTraits.h:69
static unsigned getHashValue(const wasm::WasmLimits &Limits)
Definition WasmTraits.h:61
static bool isEqual(const wasm::WasmSignature &LHS, const wasm::WasmSignature &RHS)
Definition WasmTraits.h:36
static wasm::WasmSignature getEmptyKey()
Definition WasmTraits.h:23
static unsigned getHashValue(const wasm::WasmSignature &Sig)
Definition WasmTraits.h:28
static unsigned getHashValue(const wasm::WasmTableType &TableType)
Definition WasmTraits.h:81
static wasm::WasmTableType getEmptyKey()
Definition WasmTraits.h:77
static bool isEqual(const wasm::WasmTableType &LHS, const wasm::WasmTableType &RHS)
Definition WasmTraits.h:86
An information struct used to provide DenseMap with the various necessary components for a given valu...
enum llvm::wasm::WasmSignature::@046365007015066125334353001273331261330074126041 State
SmallVector< ValType, 1 > Returns
Definition Wasm.h:516
SmallVector< ValType, 4 > Params
Definition Wasm.h:517