llvm.org GIT mirror
Move helper functions for optimizing division by constant into the APInt class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70488 91177308-0d34-0410-b5e6-96231b3b80d8 Jay Foad 11 years ago
3 changed file(s) with 119 addition(s) and 101 deletion(s).
 1257 1257 APInt multiplicativeInverse(const APInt& modulo) const; 1258 1258 1259 1259 /// @} 1260 /// @name Support for division by constant 1261 /// @{ 1262 1263 /// Calculate the magic number for signed division by a constant. 1264 struct ms; 1265 ms magic() const; 1266 1267 /// Calculate the magic number for unsigned division by a constant. 1268 struct mu; 1269 mu magicu() const; 1270 1271 /// @} 1260 1272 /// @name Building-block Operations for APInt and APFloat 1261 1273 /// @{ 1262 1274 1387 1399 /// @} 1388 1400 }; 1389 1401 1402 /// Magic data for optimising signed division by a constant. 1403 struct APInt::ms { 1404 APInt m; ///< magic number 1405 unsigned s; ///< shift amount 1406 }; 1407 1408 /// Magic data for optimising unsigned division by a constant. 1409 struct APInt::mu { 1410 APInt m; ///< magic number 1411 bool a; ///< add indicator 1412 unsigned s; ///< shift amount 1413 }; 1414 1390 1415 inline bool operator==(uint64_t V1, const APInt& V2) { 1391 1416 return V2 == V1; 1392 1417 }