[PATCH] D27479: ELF/AArch64: Refactor R_AARCH64_LDST{8, 15, 32, 64, 128}_ABS_LO12_NC Relocations
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 6 13:27:21 PST 2016
ruiu added inline comments.
================
Comment at: ELF/Target.cpp:1329-1335
+// Return the bits [Start, End] from Val shifted Start bits. For instance,
+// getBits<4,8>(0xF0) returns 0xF.
+template <uint8_t Start, uint8_t End>
+static uint64_t getBits(uint64_t Val) {
+ uint64_t Mask = ((uint64_t)1 << ((End+1) - Start))-1;
+ return (Val >> Start) & Mask;
+}
----------------
Maybe we should add this to llvm/Support/MathExtras.h? We have a bunch of bit manipulation functions there.
I don't see a reason to make it a template. Start and End can be passed as arguments.
Please run clang-format-diff to format in the LLVM style.
You don't need a parentheses around `(End + 1)` because `End - Start + 1` is the same as `(End + 1) - Start`.
Repository:
rL LLVM
https://reviews.llvm.org/D27479
More information about the llvm-commits
mailing list