MCPcopy Create free account
hub / github.com/ablab/spades / rotateModulo

Function rotateModulo

ext/src/llvm/APInt.cpp:1056–1066  ·  view source on GitHub ↗

Calculate the rotate amount modulo the bit width.

Source from the content-addressed store, hash-verified

1054
1055// Calculate the rotate amount modulo the bit width.
1056static unsigned rotateModulo(unsigned BitWidth, const APInt &rotateAmt) {
1057 unsigned rotBitWidth = rotateAmt.getBitWidth();
1058 APInt rot = rotateAmt;
1059 if (rotBitWidth < BitWidth) {
1060 // Extend the rotate APInt, so that the urem doesn't divide by 0.
1061 // e.g. APInt(1, 32) would give APInt(1, 0).
1062 rot = rotateAmt.zext(BitWidth);
1063 }
1064 rot = rot.urem(APInt(rot.getBitWidth(), BitWidth));
1065 return rot.getLimitedValue(BitWidth);
1066}
1067
1068APInt APInt::rotl(const APInt &rotateAmt) const {
1069 return rotl(rotateModulo(BitWidth, rotateAmt));

Callers 2

rotlMethod · 0.85
rotrMethod · 0.85

Calls 3

zextMethod · 0.80
uremMethod · 0.80
APIntFunction · 0.50

Tested by

no test coverage detected