Skip to content

Explain partial byte extraction logic. #92868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,10 @@ void NVPTXAsmPrinter::bufferLEByte(const Constant *CPV, int Bytes,
auto AddIntToBuffer = [AggBuffer, Bytes](const APInt &Val) {
size_t NumBytes = (Val.getBitWidth() + 7) / 8;
SmallVector<unsigned char, 16> Buf(NumBytes);
// `extractBitsAsZExtValue` does not allow the extraction of bits beyond the
// input's bit width, and i1 arrays may not have a length that is a multuple
// of 8. We handle the last byte separately, so we never request out of
// bounds bits.
for (unsigned I = 0; I < NumBytes - 1; ++I) {
Buf[I] = Val.extractBitsAsZExtValue(8, I * 8);
}
Expand Down
Loading