[PATCH] D152843: Switch magic numbers to library functions in fixup
Daniel Hoekwater via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 27 14:30:17 PDT 2023
This revision was automatically updated to reflect the committed changes.
dhoekwater marked 3 inline comments as done.
Closed by commit rGf1c21faeb2f6: [AArch64] Switch magic numbers to library functions in fixup (authored by dhoekwater).
Changed prior to commit:
https://reviews.llvm.org/D152843?vs=533723&id=544932#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152843/new/
https://reviews.llvm.org/D152843
Files:
llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
Index: llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
===================================================================
--- llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
+++ llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
@@ -181,14 +181,14 @@
if (TheTriple.isOSBinFormatCOFF() && !IsResolved)
Value &= 0xfff;
// Unsigned 12-bit immediate
- if (Value >= 0x1000)
+ if (!isUInt<12>(Value))
Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
return Value;
case AArch64::fixup_aarch64_ldst_imm12_scale2:
if (TheTriple.isOSBinFormatCOFF() && !IsResolved)
Value &= 0xfff;
// Unsigned 12-bit immediate which gets multiplied by 2
- if (Value >= 0x2000)
+ if (!isUInt<13>(Value))
Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
if (Value & 0x1)
Ctx.reportError(Fixup.getLoc(), "fixup must be 2-byte aligned");
@@ -197,7 +197,7 @@
if (TheTriple.isOSBinFormatCOFF() && !IsResolved)
Value &= 0xfff;
// Unsigned 12-bit immediate which gets multiplied by 4
- if (Value >= 0x4000)
+ if (!isUInt<14>(Value))
Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
if (Value & 0x3)
Ctx.reportError(Fixup.getLoc(), "fixup must be 4-byte aligned");
@@ -206,7 +206,7 @@
if (TheTriple.isOSBinFormatCOFF() && !IsResolved)
Value &= 0xfff;
// Unsigned 12-bit immediate which gets multiplied by 8
- if (Value >= 0x8000)
+ if (!isUInt<15>(Value))
Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
if (Value & 0x7)
Ctx.reportError(Fixup.getLoc(), "fixup must be 8-byte aligned");
@@ -215,7 +215,7 @@
if (TheTriple.isOSBinFormatCOFF() && !IsResolved)
Value &= 0xfff;
// Unsigned 12-bit immediate which gets multiplied by 16
- if (Value >= 0x10000)
+ if (!isUInt<16>(Value))
Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
if (Value & 0xf)
Ctx.reportError(Fixup.getLoc(), "fixup must be 16-byte aligned");
@@ -306,7 +306,7 @@
}
case AArch64::fixup_aarch64_pcrel_branch14:
// Signed 16-bit immediate
- if (SignedValue > 32767 || SignedValue < -32768)
+ if (!isInt<16>(SignedValue))
Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
// Low two bits are not encoded (4-byte alignment assumed).
if (Value & 0x3)
@@ -315,7 +315,7 @@
case AArch64::fixup_aarch64_pcrel_branch26:
case AArch64::fixup_aarch64_pcrel_call26:
// Signed 28-bit immediate
- if (SignedValue > 134217727 || SignedValue < -134217728)
+ if (!isInt<28>(SignedValue))
Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
// Low two bits are not encoded (4-byte alignment assumed).
if (Value & 0x3)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152843.544932.patch
Type: text/x-patch
Size: 2815 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230727/59c3eede/attachment.bin>
More information about the llvm-commits
mailing list