1 //===- MPInt.cpp - MLIR MPInt Class ---------------------------------------===//
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "mlir/Analysis/Presburger/MPInt.h"
10 #include "llvm/Support/MathExtras.h"
11 
12 using namespace mlir;
13 using namespace presburger;
14 
hash_value(const MPInt & x)15 llvm::hash_code mlir::presburger::hash_value(const MPInt &x) {
16   if (x.isSmall())
17     return llvm::hash_value(x.getSmall());
18   return detail::hash_value(x.getLarge());
19 }
20 
21 /// ---------------------------------------------------------------------------
22 /// Printing.
23 /// ---------------------------------------------------------------------------
print(llvm::raw_ostream & os) const24 llvm::raw_ostream &MPInt::print(llvm::raw_ostream &os) const {
25   if (isSmall())
26     return os << valSmall;
27   return os << valLarge;
28 }
29 
dump() const30 void MPInt::dump() const { print(llvm::errs()); }
31 
operator <<(llvm::raw_ostream & os,const MPInt & x)32 llvm::raw_ostream &mlir::presburger::operator<<(llvm::raw_ostream &os,
33                                                 const MPInt &x) {
34   x.print(os);
35   return os;
36 }
37