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