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> {
23 static unsigned getHashValue(const wasm::WasmSignature &Sig) {
24 uintptr_t H = hash_value(Sig.State);
25 for (auto Ret : Sig.Returns)
26 H = hash_combine(H, Ret);
27 for (auto Param : Sig.Params)
28 H = hash_combine(H, Param);
29 return H;
30 }
31 static bool isEqual(const wasm::WasmSignature &LHS,
32 const wasm::WasmSignature &RHS) {
33 return LHS == RHS;
34 }
35};
36
37// Traits for using WasmGlobalType in a DenseMap
38template <> struct DenseMapInfo<wasm::WasmGlobalType, void> {
39 static unsigned getHashValue(const wasm::WasmGlobalType &GlobalType) {
40 return hash_combine(GlobalType.Type, GlobalType.Mutable);
41 }
42 static bool isEqual(const wasm::WasmGlobalType &LHS,
44 return LHS == RHS;
45 }
46};
47
48// Traits for using WasmLimits in a DenseMap
49template <> struct DenseMapInfo<wasm::WasmLimits, void> {
50 static unsigned getHashValue(const wasm::WasmLimits &Limits) {
51 unsigned Hash = hash_value(Limits.Flags);
52 Hash = hash_combine(Hash, Limits.Minimum);
54 Hash = hash_combine(Hash, Limits.Maximum);
55 }
56 return Hash;
57 }
58 static bool isEqual(const wasm::WasmLimits &LHS,
59 const wasm::WasmLimits &RHS) {
60 return LHS == RHS;
61 }
62};
63
64// Traits for using WasmTableType in a DenseMap
65template <> struct DenseMapInfo<wasm::WasmTableType, void> {
66 static unsigned getHashValue(const wasm::WasmTableType &TableType) {
67 return hash_combine(
68 TableType.ElemType,
70 }
71 static bool isEqual(const wasm::WasmTableType &LHS,
72 const wasm::WasmTableType &RHS) {
73 return LHS == RHS;
74 }
75};
76
77} // end namespace llvm
78
79#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:305
static unsigned getHashValue(const wasm::WasmGlobalType &GlobalType)
Definition WasmTraits.h:39
static bool isEqual(const wasm::WasmGlobalType &LHS, const wasm::WasmGlobalType &RHS)
Definition WasmTraits.h:42
static bool isEqual(const wasm::WasmLimits &LHS, const wasm::WasmLimits &RHS)
Definition WasmTraits.h:58
static unsigned getHashValue(const wasm::WasmLimits &Limits)
Definition WasmTraits.h:50
static bool isEqual(const wasm::WasmSignature &LHS, const wasm::WasmSignature &RHS)
Definition WasmTraits.h:31
static unsigned getHashValue(const wasm::WasmSignature &Sig)
Definition WasmTraits.h:23
static unsigned getHashValue(const wasm::WasmTableType &TableType)
Definition WasmTraits.h:66
static bool isEqual(const wasm::WasmTableType &LHS, const wasm::WasmTableType &RHS)
Definition WasmTraits.h:71
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