1*cdbc5f1eSArjun P //===- MPInt.cpp - MLIR MPInt Class ---------------------------------------===//
2*cdbc5f1eSArjun P //
3*cdbc5f1eSArjun P // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*cdbc5f1eSArjun P // See https://llvm.org/LICENSE.txt for license information.
5*cdbc5f1eSArjun P // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*cdbc5f1eSArjun P //
7*cdbc5f1eSArjun P //===----------------------------------------------------------------------===//
8*cdbc5f1eSArjun P 
9*cdbc5f1eSArjun P #include "mlir/Analysis/Presburger/MPInt.h"
10*cdbc5f1eSArjun P #include "llvm/Support/MathExtras.h"
11*cdbc5f1eSArjun P 
12*cdbc5f1eSArjun P using namespace mlir;
13*cdbc5f1eSArjun P using namespace presburger;
14*cdbc5f1eSArjun P 
hash_value(const MPInt & x)15*cdbc5f1eSArjun P llvm::hash_code mlir::presburger::hash_value(const MPInt &x) {
16*cdbc5f1eSArjun P   if (x.isSmall())
17*cdbc5f1eSArjun P     return llvm::hash_value(x.getSmall());
18*cdbc5f1eSArjun P   return detail::hash_value(x.getLarge());
19*cdbc5f1eSArjun P }
20*cdbc5f1eSArjun P 
21*cdbc5f1eSArjun P /// ---------------------------------------------------------------------------
22*cdbc5f1eSArjun P /// Printing.
23*cdbc5f1eSArjun P /// ---------------------------------------------------------------------------
print(llvm::raw_ostream & os) const24*cdbc5f1eSArjun P llvm::raw_ostream &MPInt::print(llvm::raw_ostream &os) const {
25*cdbc5f1eSArjun P   if (isSmall())
26*cdbc5f1eSArjun P     return os << valSmall;
27*cdbc5f1eSArjun P   return os << valLarge;
28*cdbc5f1eSArjun P }
29*cdbc5f1eSArjun P 
dump() const30*cdbc5f1eSArjun P void MPInt::dump() const { print(llvm::errs()); }
31*cdbc5f1eSArjun P 
operator <<(llvm::raw_ostream & os,const MPInt & x)32*cdbc5f1eSArjun P llvm::raw_ostream &mlir::presburger::operator<<(llvm::raw_ostream &os,
33*cdbc5f1eSArjun P                                                 const MPInt &x) {
34*cdbc5f1eSArjun P   x.print(os);
35*cdbc5f1eSArjun P   return os;
36*cdbc5f1eSArjun P }
37