LLVM: lib/Support/SlowDynamicAPInt.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

13

14using namespace llvm;

16

18 : Val(64, Val, true) {}

24SlowDynamicAPInt::operator int64_t() const { return Val.getSExtValue(); }

25

29

30

31

32

48

82

116

118 return std::max(A.getBitWidth(), B.getBitWidth());

119}

120

121

122

123

124

125

127 unsigned Width = getMaxWidth(Val, O.Val);

128 return Val.sext(Width) == O.Val.sext(Width);

129}

131 unsigned Width = getMaxWidth(Val, O.Val);

132 return Val.sext(Width) != O.Val.sext(Width);

133}

135 unsigned Width = getMaxWidth(Val, O.Val);

136 return Val.sext(Width).sgt(O.Val.sext(Width));

137}

139 unsigned Width = getMaxWidth(Val, O.Val);

140 return Val.sext(Width).slt(O.Val.sext(Width));

141}

143 unsigned Width = getMaxWidth(Val, O.Val);

144 return Val.sext(Width).sle(O.Val.sext(Width));

145}

147 unsigned Width = getMaxWidth(Val, O.Val);

148 return Val.sext(Width).sge(O.Val.sext(Width));

149}

150

151

152

153

154

155

156

157

158

162 bool Overflow;

164 APInt Ret = Op(A.sext(Width), B.sext(Width), Overflow);

165 if (!Overflow)

166 return Ret;

167

168 Width *= 2;

169 Ret = Op(A.sext(Width), B.sext(Width), Overflow);

170 assert(!Overflow && "double width should be sufficient to avoid overflow!");

171 return Ret;

172}

173

191 return X >= 0 ? X : -X;

192}

195 if (RHS == -1)

196 return -LHS;

197 unsigned Width = getMaxWidth(LHS.Val, RHS.Val);

200}

203 if (RHS == -1)

204 return -LHS;

205 unsigned Width = getMaxWidth(LHS.Val, RHS.Val);

208}

209

210

213 assert(RHS >= 1 && "mod is only supported for positive divisors!");

214 return LHS % RHS < 0 ? LHS % RHS + RHS : LHS % RHS;

215}

216

219 assert(A >= 0 && B >= 0 && "operands must be non-negative!");

223}

224

225

230 return (X * Y) / gcd(X, Y);

231}

232

233

235 unsigned Width = std::max(Val.getBitWidth(), O.Val.getBitWidth());

236 return SlowDynamicAPInt(Val.sext(Width).srem(O.Val.sext(Width)));

237}

238

240 if (Val.isMinSignedValue()) {

241

242 APInt Ret = Val.sext(2 * Val.getBitWidth());

244 }

246}

247

248

249

250

252 *this = *this + O;

253 return *this;

254}

256 *this = *this - O;

257 return *this;

258}

260 *this = *this * O;

261 return *this;

262}

264 *this = *this / O;

265 return *this;

266}

268 *this = *this % O;

269 return *this;

270}

272 *this += 1;

273 return *this;

274}

275

277 *this -= 1;

278 return *this;

279}

280

281

282

283

285

286#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

288#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

#define LLVM_DUMP_METHOD

Mark debug helper function definitions like dump() that should not be stripped from debug builds.

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).

Definition SlowDynamicAPInt.cpp:159

static unsigned getMaxWidth(const APInt &A, const APInt &B)

Definition SlowDynamicAPInt.cpp:117

static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")

static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")

Class for arbitrary precision integers.

LLVM_ABI APInt sadd_ov(const APInt &RHS, bool &Overflow) const

LLVM_ABI APInt sdiv_ov(const APInt &RHS, bool &Overflow) const

LLVM_ABI APInt smul_ov(const APInt &RHS, bool &Overflow) const

LLVM_ABI APInt sext(unsigned width) const

Sign extend to a new width.

LLVM_ABI APInt ssub_ov(const APInt &RHS, bool &Overflow) const

A simple class providing dynamic arbitrary-precision arithmetic.

LLVM_ABI void print(raw_ostream &OS) const

Definition SlowDynamicAPInt.cpp:284

LLVM_ABI SlowDynamicAPInt()

Definition SlowDynamicAPInt.cpp:19

LLVM_ABI SlowDynamicAPInt operator%(const SlowDynamicAPInt &O) const

This operation cannot overflow.

Definition SlowDynamicAPInt.cpp:234

LLVM_ABI SlowDynamicAPInt operator*(const SlowDynamicAPInt &O) const

Definition SlowDynamicAPInt.cpp:182

LLVM_ABI SlowDynamicAPInt & operator+=(const SlowDynamicAPInt &O)

Definition SlowDynamicAPInt.cpp:251

LLVM_ABI SlowDynamicAPInt & operator--()

Definition SlowDynamicAPInt.cpp:276

LLVM_ABI bool operator<=(const SlowDynamicAPInt &O) const

Definition SlowDynamicAPInt.cpp:142

LLVM_ABI SlowDynamicAPInt & operator-=(const SlowDynamicAPInt &O)

Definition SlowDynamicAPInt.cpp:255

LLVM_ABI SlowDynamicAPInt & operator*=(const SlowDynamicAPInt &O)

Definition SlowDynamicAPInt.cpp:259

LLVM_ABI SlowDynamicAPInt & operator=(int64_t Val)

Definition SlowDynamicAPInt.cpp:21

LLVM_ABI SlowDynamicAPInt & operator++()

Definition SlowDynamicAPInt.cpp:271

LLVM_ABI SlowDynamicAPInt operator-() const

Definition SlowDynamicAPInt.cpp:239

LLVM_ABI bool operator!=(const SlowDynamicAPInt &O) const

Definition SlowDynamicAPInt.cpp:130

LLVM_ABI bool operator>(const SlowDynamicAPInt &O) const

Definition SlowDynamicAPInt.cpp:134

LLVM_ABI SlowDynamicAPInt(int64_t Val)

Definition SlowDynamicAPInt.cpp:17

LLVM_ABI bool operator==(const SlowDynamicAPInt &O) const

Definition SlowDynamicAPInt.cpp:126

LLVM_ABI SlowDynamicAPInt operator/(const SlowDynamicAPInt &O) const

Definition SlowDynamicAPInt.cpp:186

LLVM_DUMP_METHOD void dump() const

Definition SlowDynamicAPInt.cpp:287

LLVM_ABI SlowDynamicAPInt & operator/=(const SlowDynamicAPInt &O)

Definition SlowDynamicAPInt.cpp:263

LLVM_ABI SlowDynamicAPInt & operator%=(const SlowDynamicAPInt &O)

Definition SlowDynamicAPInt.cpp:267

LLVM_ABI bool operator<(const SlowDynamicAPInt &O) const

Definition SlowDynamicAPInt.cpp:138

LLVM_ABI bool operator>=(const SlowDynamicAPInt &O) const

Definition SlowDynamicAPInt.cpp:146

LLVM_ABI SlowDynamicAPInt operator+(const SlowDynamicAPInt &O) const

Definition SlowDynamicAPInt.cpp:174

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.

LLVM_ABI APInt RoundingSDiv(const APInt &A, const APInt &B, APInt::Rounding RM)

Return A sign-divided by B, rounded by the given rounding mode.

LLVM_ABI APInt GreatestCommonDivisor(APInt A, APInt B)

Compute GCD of two unsigned APInt values.

A self-contained host- and target-independent arbitrary-precision floating-point software implementat...

LLVM_ABI SlowDynamicAPInt abs(const SlowDynamicAPInt &X)

Redeclarations of friend declarations above to make it discoverable by lookups.

Definition SlowDynamicAPInt.cpp:190

LLVM_ABI bool operator>=(const SlowDynamicAPInt &A, int64_t B)

Definition SlowDynamicAPInt.cpp:64

LLVM_ABI SlowDynamicAPInt ceilDiv(const SlowDynamicAPInt &LHS, const SlowDynamicAPInt &RHS)

Definition SlowDynamicAPInt.cpp:193

LLVM_ABI SlowDynamicAPInt operator/(const SlowDynamicAPInt &A, int64_t B)

Definition SlowDynamicAPInt.cpp:76

LLVM_ABI SlowDynamicAPInt operator+(const SlowDynamicAPInt &A, int64_t B)

Definition SlowDynamicAPInt.cpp:67

LLVM_ABI hash_code hash_value(const IEEEFloat &Arg)

LLVM_ABI SlowDynamicAPInt operator-(const SlowDynamicAPInt &A, int64_t B)

Definition SlowDynamicAPInt.cpp:70

bool operator!=(const DenseSetImpl< ValueT, MapTy, ValueInfoT > &LHS, const DenseSetImpl< ValueT, MapTy, ValueInfoT > &RHS)

Inequality comparison for DenseSet.

LLVM_ABI SlowDynamicAPInt gcd(const SlowDynamicAPInt &A, const SlowDynamicAPInt &B)

Definition SlowDynamicAPInt.cpp:217

LLVM_ABI SlowDynamicAPInt floorDiv(const SlowDynamicAPInt &LHS, const SlowDynamicAPInt &RHS)

Definition SlowDynamicAPInt.cpp:201

LLVM_ABI bool operator>(const SlowDynamicAPInt &A, int64_t B)

Definition SlowDynamicAPInt.cpp:55

LLVM_ABI SlowDynamicAPInt & operator+=(SlowDynamicAPInt &A, int64_t B)

Definition SlowDynamicAPInt.cpp:33

LLVM_ABI SlowDynamicAPInt operator%(const SlowDynamicAPInt &A, int64_t B)

Definition SlowDynamicAPInt.cpp:79

LLVM_ABI SlowDynamicAPInt operator*(const SlowDynamicAPInt &A, int64_t B)

Definition SlowDynamicAPInt.cpp:73

LLVM_ABI bool operator<=(const SlowDynamicAPInt &A, int64_t B)

Definition SlowDynamicAPInt.cpp:61

LLVM_ABI SlowDynamicAPInt & operator/=(SlowDynamicAPInt &A, int64_t B)

Definition SlowDynamicAPInt.cpp:42

LLVM_ABI SlowDynamicAPInt lcm(const SlowDynamicAPInt &A, const SlowDynamicAPInt &B)

Returns the least common multiple of A and B.

Definition SlowDynamicAPInt.cpp:226

bool operator==(const DenseSetImpl< ValueT, MapTy, ValueInfoT > &LHS, const DenseSetImpl< ValueT, MapTy, ValueInfoT > &RHS)

Equality comparison for DenseSet.

LLVM_ABI SlowDynamicAPInt mod(const SlowDynamicAPInt &LHS, const SlowDynamicAPInt &RHS)

Returns the remainder of dividing LHS by RHS.

Definition SlowDynamicAPInt.cpp:211

LLVM_ABI SlowDynamicAPInt & operator*=(SlowDynamicAPInt &A, int64_t B)

Definition SlowDynamicAPInt.cpp:39

LLVM_ABI bool operator<(const SlowDynamicAPInt &A, int64_t B)

Definition SlowDynamicAPInt.cpp:58

LLVM_ABI SlowDynamicAPInt & operator-=(SlowDynamicAPInt &A, int64_t B)

Definition SlowDynamicAPInt.cpp:36

LLVM_ABI SlowDynamicAPInt & operator%=(SlowDynamicAPInt &A, int64_t B)

Definition SlowDynamicAPInt.cpp:45

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

DWARFExpression::Operation Op