[PATCH] D152843: Switch magic numbers to library functions in fixup

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 14 05:23:36 PDT 2023


peter.smith added a comment.

I have similar opinions to efriedma. Definitely like using isUint and isInt more. I'd prefer to use `isAligned` rather than `alignTo`.

I'm so used to seeing trailing masks, I do find maskTrailingOnes less intuitive, but will go with consensus on that front. Perhaps make a simpler/shorter name with a `using`?



================
Comment at: llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp:175
       Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
-    if (Value & 0x3)
+    if (Value != alignTo<4>(Value))
       Ctx.reportError(Fixup.getLoc(), "fixup not sufficiently aligned");
----------------
While I think they will give the same result as this is a no-op for an already 4-byte aligned quantity it is a more extensive calculation as alignTo aligns to the next 4-byte boundary.

Would isAligned(Value, 4) in Support/Alignment.h be better?





Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152843/new/

https://reviews.llvm.org/D152843



More information about the llvm-commits mailing list