[PATCH] D78796: [Support] Refactor LEB128 encoding into an input iterator

Nicolas Guillemot via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 23:57:33 PDT 2020


nlguillemot created this revision.
nlguillemot added reviewers: bogner, qcolombet, fhahn.
nlguillemot added a parent revision: D78795: [Support] Add raw_ostream_iterator: ostream_iterator for raw_ostream..
nlguillemot added a child revision: D78797: [Support] Refactor LEB128 decoding into an output iterator.
nlguillemot added a comment.

The end goal of this series of patches is to support encoding/decoding `APInt` to/from `[U|S]LEB128`. This patch is an initial step in that direction. It refactors the logic to avoid code duplication and makes the interface to LEB128 encoding much more generic, as shown by the existing cases becoming very short.

In a later patch, I'd like to do some template magic to support `LEB128InputIterator<APInt>` in a way that tries to share code with the `uint64_t`/`int64_t` implementations.


Refactors the logic for LEB128 encoding into a std iterator style input
iterator. This allows the output of LEB128 encoding to be passed into std
algorithms. Furthermore, this allowed refactoring the existing LEB128 encoding
functions to become syntactical sugar for calls to std::copy.


https://reviews.llvm.org/D78796

Files:
  llvm/include/llvm/Support/LEB128.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78796.259813.patch
Type: text/x-patch
Size: 9597 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200424/17437a57/attachment.bin>


More information about the llvm-commits mailing list