This is an archive of the discontinued LLVM Phabricator instance.

[docs] Clarify variable-width integer (VBR) encoding example.
ClosedPublic

Authored by vsapsai on Aug 9 2021, 6:52 PM.

Details

Summary

Show that the bit chunks are placed starting at the least significant
bit. Select a different number, so the bit chunks have different values
and it is more obvious where they are in the encoded result.

Diff Detail

Event Timeline

vsapsai created this revision.Aug 9 2021, 6:52 PM
vsapsai requested review of this revision.Aug 9 2021, 6:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2021, 6:52 PM

Tested the actual numbers with

TEST(BitstreamWriterTest, emitDocSample) {
  SmallVector<char> Buffer;
  BitstreamWriter W(Buffer);
  W.EmitVBR(30, 4);
  W.FlushToWord();
  EXPECT_EQ((SmallVector<char>{0b0011'1110, 0, 0, 0}), Buffer);
}

in BitstreamWriterTest.cpp. Don't think it is worth keeping as we don't enforce the docs to be in sync with the unit tests.

mehdi_amini accepted this revision.Aug 10 2021, 2:50 AM
This revision is now accepted and ready to land.Aug 10 2021, 2:50 AM

Thanks for the review!