[PATCH] D29467: Add support for reading and writing values with runtime-endianness
Zachary Turner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 2 11:14:05 PST 2017
zturner created this revision.
`llvm/Support/Endian.h` contains a bunch of functions and classes for working with values whose endianness is known at compile time. But it does not contain anything for working with values where the endianness is only known at runtime.
This patch adds overloads of `read` and `write` that take the `endianness` not as a template parameter, but as a function argument. The versions of the function that use the template parameter are updated to call the version that takes the runtime argument. Since all these functions are inlined, the demotion from a compile-time value to a runtime value should not incur any additional overhead.
The long term motivation for this is to convert LLDB's endian-aware code to use LLVM instead of reinventing all of their own code for doing byte swaps, theyir own enumeration for representing byte order, etc. For now, this just adds the necessary machinery.
Since the template functions now call the runtime functions, no additional tests are necessary, as there are already tests written against the templated versions of the functions.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 5393 bytes
Desc: not available
More information about the llvm-commits