diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp +++ b/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)