MLIR  19.0.0git
MPInt.cpp
Go to the documentation of this file.
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 
11 #include "llvm/ADT/Hashing.h"
12 #include "llvm/Support/raw_ostream.h"
13 
14 using namespace mlir;
15 using namespace presburger;
16 
17 llvm::hash_code mlir::presburger::hash_value(const MPInt &x) {
18  if (x.isSmall())
19  return llvm::hash_value(x.getSmall());
20  return detail::hash_value(x.getLarge());
21 }
22 
23 /// ---------------------------------------------------------------------------
24 /// Printing.
25 /// ---------------------------------------------------------------------------
26 llvm::raw_ostream &MPInt::print(llvm::raw_ostream &os) const {
27  if (isSmall())
28  return os << valSmall;
29  return os << valLarge;
30 }
31 
32 void MPInt::dump() const { print(llvm::errs()); }
33 
34 llvm::raw_ostream &mlir::presburger::operator<<(llvm::raw_ostream &os,
35  const MPInt &x) {
36  x.print(os);
37  return os;
38 }
This class provides support for multi-precision arithmetic.
Definition: MPInt.h:87
detail::SlowMPInt valLarge
Definition: MPInt.h:91
llvm::raw_ostream & print(llvm::raw_ostream &os) const
Definition: MPInt.cpp:26
void dump() const
Definition: MPInt.cpp:32
llvm::hash_code hash_value(const SlowMPInt &x)
llvm::raw_ostream & operator<<(llvm::raw_ostream &os, const Fraction &x)
Definition: Fraction.h:158
llvm::hash_code hash_value(const MPInt &x)
Redeclarations of friend declaration above to make it discoverable by lookups.
Definition: MPInt.cpp:17
Include the generated interface declarations.