1//===- SlowDynamicAPInt.cpp - SlowDynamicAPInt Implementation -------------===// 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 7//===----------------------------------------------------------------------===// 17SlowDynamicAPInt::SlowDynamicAPInt(int64_t Val)
18 : Val(64, Val,
/*isSigned=*/true) {}
24SlowDynamicAPInt::operator int64_t()
const{
return Val.getSExtValue(); }
30/// --------------------------------------------------------------------------- 31/// Convenience operator overloads for int64_t. 32/// --------------------------------------------------------------------------- 118return std::max(
A.getBitWidth(),
B.getBitWidth());
121/// --------------------------------------------------------------------------- 122/// Comparison operators. 123/// --------------------------------------------------------------------------- 125// TODO: consider instead making APInt::compare available and using that. 128return Val.
sext(Width) == O.Val.sext(Width);
132return Val.
sext(Width) != O.Val.sext(Width);
136return Val.
sext(Width).
sgt(O.Val.sext(Width));
140return Val.
sext(Width).
slt(O.Val.sext(Width));
144return Val.
sext(Width).
sle(O.Val.sext(Width));
148return Val.
sext(Width).
sge(O.Val.sext(Width));
151/// --------------------------------------------------------------------------- 152/// Arithmetic operators. 153/// --------------------------------------------------------------------------- 155/// Bring a and b to have the same width and then call op(a, b, overflow). 156/// If the overflow bit becomes set, resize a and b to double the width and 157/// call op(a, b, overflow), returning its result. The operation with double 158/// widths should not also overflow. 164APInt Ret =
Op(
A.sext(Width),
B.sext(Width), Overflow);
169 Ret =
Op(
A.sext(Width),
B.sext(Width), Overflow);
170assert(!Overflow &&
"double width should be sufficient to avoid overflow!");
209// The RHS is always expected to be positive, and the result 210/// is always non-negative. 213assert(
RHS >= 1 &&
"mod is only supported for positive divisors!");
219assert(
A >= 0 &&
B >= 0 &&
"operands must be non-negative!");
225/// Returns the least common multiple of A and B. 233/// This operation cannot overflow. 235unsigned Width = std::max(Val.
getBitWidth(), O.Val.getBitWidth());
241 /// Overflow only occurs when the value is the minimum possible value. 248/// --------------------------------------------------------------------------- 249/// Assignment operators, preincrement, predecrement. 250/// --------------------------------------------------------------------------- 281/// --------------------------------------------------------------------------- 283/// --------------------------------------------------------------------------- static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
APInt runOpWithExpandOnOverflow(const APInt &A, const APInt &B, function_ref< APInt(const APInt &, const APInt &, bool &Overflow)> Op)
Bring a and b to have the same width and then call op(a, b, overflow).
static unsigned getMaxWidth(const APInt &A, const APInt &B)
Class for arbitrary precision integers.
bool isMinSignedValue() const
Determine if this is the smallest signed value.
bool sgt(const APInt &RHS) const
Signed greater than comparison.
unsigned getBitWidth() const
Return the number of bits in the APInt.
APInt sadd_ov(const APInt &RHS, bool &Overflow) const
bool sle(const APInt &RHS) const
Signed less or equal comparison.
APInt sdiv_ov(const APInt &RHS, bool &Overflow) const
APInt srem(const APInt &RHS) const
Function for signed remainder operation.
APInt smul_ov(const APInt &RHS, bool &Overflow) const
APInt sext(unsigned width) const
Sign extend to a new width.
bool slt(const APInt &RHS) const
Signed less than comparison.
bool sge(const APInt &RHS) const
Signed greater or equal comparison.
APInt ssub_ov(const APInt &RHS, bool &Overflow) const
This class represents an Operation in the Expression.
A simple class providing dynamic arbitrary-precision arithmetic.
void print(raw_ostream &OS) const
SlowDynamicAPInt operator%(const SlowDynamicAPInt &O) const
This operation cannot overflow.
SlowDynamicAPInt operator*(const SlowDynamicAPInt &O) const
SlowDynamicAPInt & operator+=(const SlowDynamicAPInt &O)
SlowDynamicAPInt & operator--()
LLVM_DUMP_METHOD void dump() const
bool operator<=(const SlowDynamicAPInt &O) const
SlowDynamicAPInt & operator-=(const SlowDynamicAPInt &O)
SlowDynamicAPInt & operator*=(const SlowDynamicAPInt &O)
SlowDynamicAPInt & operator=(int64_t Val)
SlowDynamicAPInt & operator++()
SlowDynamicAPInt operator-() const
bool operator!=(const SlowDynamicAPInt &O) const
bool operator>(const SlowDynamicAPInt &O) const
bool operator==(const SlowDynamicAPInt &O) const
SlowDynamicAPInt operator/(const SlowDynamicAPInt &O) const
SlowDynamicAPInt & operator/=(const SlowDynamicAPInt &O)
SlowDynamicAPInt & operator%=(const SlowDynamicAPInt &O)
bool operator<(const SlowDynamicAPInt &O) const
bool operator>=(const SlowDynamicAPInt &O) const
SlowDynamicAPInt operator+(const SlowDynamicAPInt &O) const
An efficient, type-erasing, non-owning reference to a callable.
An opaque object representing a hash code.
This class implements an extremely fast bulk output stream that can only output to a stream.
APInt RoundingSDiv(const APInt &A, const APInt &B, APInt::Rounding RM)
Return A sign-divided by B, rounded by the given rounding mode.
APInt GreatestCommonDivisor(APInt A, APInt B)
Compute GCD of two unsigned APInt values.
SlowDynamicAPInt abs(const SlowDynamicAPInt &X)
Redeclarations of friend declarations above to make it discoverable by lookups.
bool operator>=(const SlowDynamicAPInt &A, int64_t B)
SlowDynamicAPInt ceilDiv(const SlowDynamicAPInt &LHS, const SlowDynamicAPInt &RHS)
SlowDynamicAPInt operator/(const SlowDynamicAPInt &A, int64_t B)
SlowDynamicAPInt operator+(const SlowDynamicAPInt &A, int64_t B)
hash_code hash_value(const IEEEFloat &Arg)
SlowDynamicAPInt operator-(const SlowDynamicAPInt &A, int64_t B)
bool operator!=(const DenseSetImpl< ValueT, MapTy, ValueInfoT > &LHS, const DenseSetImpl< ValueT, MapTy, ValueInfoT > &RHS)
Inequality comparison for DenseSet.
SlowDynamicAPInt gcd(const SlowDynamicAPInt &A, const SlowDynamicAPInt &B)
SlowDynamicAPInt floorDiv(const SlowDynamicAPInt &LHS, const SlowDynamicAPInt &RHS)
bool operator>(const SlowDynamicAPInt &A, int64_t B)
SlowDynamicAPInt & operator+=(SlowDynamicAPInt &A, int64_t B)
SlowDynamicAPInt operator%(const SlowDynamicAPInt &A, int64_t B)
SlowDynamicAPInt operator*(const SlowDynamicAPInt &A, int64_t B)
bool operator<=(const SlowDynamicAPInt &A, int64_t B)
SlowDynamicAPInt & operator/=(SlowDynamicAPInt &A, int64_t B)
SlowDynamicAPInt lcm(const SlowDynamicAPInt &A, const SlowDynamicAPInt &B)
Returns the least common multiple of A and B.
bool operator==(const DenseSetImpl< ValueT, MapTy, ValueInfoT > &LHS, const DenseSetImpl< ValueT, MapTy, ValueInfoT > &RHS)
Equality comparison for DenseSet.
SlowDynamicAPInt mod(const SlowDynamicAPInt &LHS, const SlowDynamicAPInt &RHS)
Returns the remainder of dividing LHS by RHS.
SlowDynamicAPInt & operator*=(SlowDynamicAPInt &A, int64_t B)
bool operator<(const SlowDynamicAPInt &A, int64_t B)
SlowDynamicAPInt & operator-=(SlowDynamicAPInt &A, int64_t B)
SlowDynamicAPInt & operator%=(SlowDynamicAPInt &A, int64_t B)
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
DWARFExpression::Operation Op