61 lines
2.1 KiB
C++
61 lines
2.1 KiB
C++
/* -*- C++ -*-
|
|
* Serene programming language.
|
|
*
|
|
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
#ifndef SERENE_LLVM_PATCHES_H
|
|
#define SERENE_LLVM_PATCHES_H
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
|
|
namespace llvm {
|
|
|
|
// Our specialization of DensMapInfo for string type. This will allow use to use
|
|
// string
|
|
template <>
|
|
struct DenseMapInfo<std::string> {
|
|
static inline std::string getEmptyKey() { return ""; }
|
|
|
|
static inline std::string getTombstoneKey() {
|
|
// Maybe we need to use something else beside strings ????
|
|
return "0TOMBED";
|
|
}
|
|
|
|
static unsigned getHashValue(std::string Val) {
|
|
assert(Val != getEmptyKey() && "Cannot hash the empty key!");
|
|
assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!");
|
|
return (unsigned)(llvm::hash_value(Val));
|
|
}
|
|
|
|
static bool isEqual(std::string LHS, std::string RHS) {
|
|
if (RHS == getEmptyKey())
|
|
return LHS == getEmptyKey();
|
|
if (RHS == getTombstoneKey())
|
|
return LHS == getTombstoneKey();
|
|
return LHS == RHS;
|
|
}
|
|
};
|
|
|
|
} // namespace llvm
|
|
|
|
#endif
|