[PATCH] D78858: [Support] Add APInt support for LEB128 encoding/decoding

Nicolas Guillemot via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 24 23:25:36 PDT 2020


nlguillemot created this revision.
nlguillemot added reviewers: bogner, qcolombet, fhahn.
nlguillemot added a parent revision: D78857: [Support] Generalize operations on ValueT for LEB128 encoding/decoding.

This specializes the LEB128CodecInfo template for APInt, which allows
the input/output iterators used for LEB128 encoding/decoding to be used
with APInt. As a convenience, the encode[U|S]LEB128() functions in
LEB128.h have been overloaded for APInt. The decode[U|S]LEB128()
functions were not customized for APInt. If one wants to decode an
APInt, they can do so with the more general decodeLEB128<T> function.

For testing, new unit tests were created based on the existing LEB128
tests. These tests run the previously existing test inputs, and they
also run a "big" version of the previous inputs. The "big" versions are
created by adding a "big prefix" to the previous "small" inputs. These
"big" versions of the tests exercise the ability of APInt to be usable
to encode and decode values bigger than 64 bits.


https://reviews.llvm.org/D78858

Files:
  llvm/include/llvm/Support/LEB128.h
  llvm/include/llvm/Support/LEB128CodecInfo.h
  llvm/unittests/Support/LEB128Test.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78858.260070.patch
Type: text/x-patch
Size: 15120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200425/f2486760/attachment.bin>


More information about the llvm-commits mailing list