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

Method sext

ext/src/llvm/APInt.cpp:911–932  ·  view source on GitHub ↗

Sign extend to a new width.

Source from the content-addressed store, hash-verified

909
910// Sign extend to a new width.
911APInt APInt::sext(unsigned Width) const {
912 assert(Width > BitWidth && "Invalid APInt SignExtend request");
913
914 if (Width <= APINT_BITS_PER_WORD)
915 return APInt(Width, SignExtend64(U.VAL, BitWidth));
916
917 APInt Result(getMemory(getNumWords(Width)), Width);
918
919 // Copy words.
920 std::memcpy(Result.U.pVal, getRawData(), getNumWords() * APINT_WORD_SIZE);
921
922 // Sign extend the last word since there may be unused bits in the input.
923 Result.U.pVal[getNumWords() - 1] =
924 SignExtend64(Result.U.pVal[getNumWords() - 1],
925 ((BitWidth - 1) % APINT_BITS_PER_WORD) + 1);
926
927 // Fill with sign bits.
928 std::memset(Result.U.pVal + getNumWords(), isNegative() ? -1 : 0,
929 (Result.getNumWords() - getNumWords()) * APINT_WORD_SIZE);
930 Result.clearUnusedBits();
931 return Result;
932}
933
934// Zero extend to a new width.
935APInt APInt::zext(unsigned width) const {

Callers 1

Calls 7

assertClass · 0.85
SignExtend64Function · 0.85
getMemoryFunction · 0.85
getNumWordsFunction · 0.85
getRawDataFunction · 0.85
APIntFunction · 0.50
isNegativeFunction · 0.50

Tested by

no test coverage detected