LCOV - code coverage report
Current view: top level - include/llvm/Object - WasmTraits.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 7 7 100.0 %
Date: 2018-06-17 00:07:59 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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> {
      26             :   static wasm::WasmSignature getEmptyKey() {
      27        1210 :     return wasm::WasmSignature{{}, 1};
      28             :   }
      29             :   static wasm::WasmSignature getTombstoneKey() {
      30         986 :     return wasm::WasmSignature{{}, 2};
      31             :   }
      32         906 :   static unsigned getHashValue(const wasm::WasmSignature &Sig) {
      33        1812 :     unsigned H = hash_value(Sig.ReturnType);
      34         906 :     for (int32_t Param : Sig.ParamTypes)
      35         172 :       H = hash_combine(H, Param);
      36         906 :     return H;
      37             :   }
      38             :   static bool isEqual(const wasm::WasmSignature &LHS,
      39             :                       const wasm::WasmSignature &RHS) {
      40             :     return LHS == RHS;
      41             :   }
      42             : };
      43             : 
      44             : // Traits for using WasmGlobalType in a DenseMap
      45             : template <> struct DenseMapInfo<wasm::WasmGlobalType> {
      46             :   static wasm::WasmGlobalType getEmptyKey() {
      47             :     return wasm::WasmGlobalType{1, true};
      48             :   }
      49             :   static wasm::WasmGlobalType getTombstoneKey() {
      50             :     return wasm::WasmGlobalType{2, true};
      51             :   }
      52             :   static unsigned getHashValue(const wasm::WasmGlobalType &GlobalType) {
      53             :     return hash_combine(GlobalType.Type, GlobalType.Mutable);
      54             :   }
      55             :   static bool isEqual(const wasm::WasmGlobalType &LHS,
      56             :                       const wasm::WasmGlobalType &RHS) {
      57             :     return LHS == RHS;
      58             :   }
      59             : };
      60             : 
      61             : } // end namespace llvm
      62             : 
      63             : #endif // LLVM_OBJECT_WASMTRAITS_H

Generated by: LCOV version 1.13