brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 9def5c7 Raw
38 lines · cpp
1//===- DynamicAPInt.cpp - DynamicAPInt Implementation -----------*- 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-exception6//7//===----------------------------------------------------------------------===//8#include "llvm/ADT/DynamicAPInt.h"9#include "llvm/ADT/Hashing.h"10#include "llvm/Support/Debug.h"11#include "llvm/Support/raw_ostream.h"12 13using namespace llvm;14 15hash_code llvm::hash_value(const DynamicAPInt &X) {16  if (X.isSmall())17    return llvm::hash_value(X.getSmall());18  return detail::hash_value(X.getLarge());19}20 21void DynamicAPInt::static_assert_layout() {22  constexpr size_t ValLargeOffset =23      offsetof(DynamicAPInt, ValLarge.Val.BitWidth);24  constexpr size_t ValSmallOffset = offsetof(DynamicAPInt, ValSmall);25  constexpr size_t ValSmallSize = sizeof(ValSmall);26  static_assert(ValLargeOffset >= ValSmallOffset + ValSmallSize);27}28 29raw_ostream &DynamicAPInt::print(raw_ostream &OS) const {30  if (isSmall())31    return OS << ValSmall;32  return OS << ValLarge;33}34 35#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)36LLVM_DUMP_METHOD void DynamicAPInt::dump() const { print(dbgs()); }37#endif38