1*0fca6ea1SDimitry Andric //===- DynamicAPInt.cpp - DynamicAPInt Implementation -----------*- C++ -*-===// 2*0fca6ea1SDimitry Andric // 3*0fca6ea1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0fca6ea1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0fca6ea1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0fca6ea1SDimitry Andric // 7*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===// 8*0fca6ea1SDimitry Andric #include "llvm/ADT/DynamicAPInt.h" 9*0fca6ea1SDimitry Andric #include "llvm/ADT/Hashing.h" 10*0fca6ea1SDimitry Andric #include "llvm/Support/Debug.h" 11*0fca6ea1SDimitry Andric #include "llvm/Support/raw_ostream.h" 12*0fca6ea1SDimitry Andric 13*0fca6ea1SDimitry Andric using namespace llvm; 14*0fca6ea1SDimitry Andric hash_value(const DynamicAPInt & X)15*0fca6ea1SDimitry Andrichash_code llvm::hash_value(const DynamicAPInt &X) { 16*0fca6ea1SDimitry Andric if (X.isSmall()) 17*0fca6ea1SDimitry Andric return llvm::hash_value(X.getSmall()); 18*0fca6ea1SDimitry Andric return detail::hash_value(X.getLarge()); 19*0fca6ea1SDimitry Andric } 20*0fca6ea1SDimitry Andric static_assert_layout()21*0fca6ea1SDimitry Andricvoid DynamicAPInt::static_assert_layout() { 22*0fca6ea1SDimitry Andric constexpr size_t ValLargeOffset = 23*0fca6ea1SDimitry Andric offsetof(DynamicAPInt, ValLarge.Val.BitWidth); 24*0fca6ea1SDimitry Andric constexpr size_t ValSmallOffset = offsetof(DynamicAPInt, ValSmall); 25*0fca6ea1SDimitry Andric constexpr size_t ValSmallSize = sizeof(ValSmall); 26*0fca6ea1SDimitry Andric static_assert(ValLargeOffset >= ValSmallOffset + ValSmallSize); 27*0fca6ea1SDimitry Andric } 28*0fca6ea1SDimitry Andric print(raw_ostream & OS) const29*0fca6ea1SDimitry Andricraw_ostream &DynamicAPInt::print(raw_ostream &OS) const { 30*0fca6ea1SDimitry Andric if (isSmall()) 31*0fca6ea1SDimitry Andric return OS << ValSmall; 32*0fca6ea1SDimitry Andric return OS << ValLarge; 33*0fca6ea1SDimitry Andric } 34*0fca6ea1SDimitry Andric dump() const35*0fca6ea1SDimitry Andricvoid DynamicAPInt::dump() const { print(dbgs()); } 36