@@ -181,14 +181,14 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
181
181
if (TheTriple.isOSBinFormatCOFF () && !IsResolved)
182
182
Value &= 0xfff ;
183
183
// Unsigned 12-bit immediate
184
- if (Value >= 0x1000 )
184
+ if (!isUInt< 12 >(Value) )
185
185
Ctx.reportError (Fixup.getLoc (), " fixup value out of range" );
186
186
return Value;
187
187
case AArch64::fixup_aarch64_ldst_imm12_scale2:
188
188
if (TheTriple.isOSBinFormatCOFF () && !IsResolved)
189
189
Value &= 0xfff ;
190
190
// Unsigned 12-bit immediate which gets multiplied by 2
191
- if (Value >= 0x2000 )
191
+ if (!isUInt< 13 >(Value) )
192
192
Ctx.reportError (Fixup.getLoc (), " fixup value out of range" );
193
193
if (Value & 0x1 )
194
194
Ctx.reportError (Fixup.getLoc (), " fixup must be 2-byte aligned" );
@@ -197,7 +197,7 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
197
197
if (TheTriple.isOSBinFormatCOFF () && !IsResolved)
198
198
Value &= 0xfff ;
199
199
// Unsigned 12-bit immediate which gets multiplied by 4
200
- if (Value >= 0x4000 )
200
+ if (!isUInt< 14 >(Value) )
201
201
Ctx.reportError (Fixup.getLoc (), " fixup value out of range" );
202
202
if (Value & 0x3 )
203
203
Ctx.reportError (Fixup.getLoc (), " fixup must be 4-byte aligned" );
@@ -206,7 +206,7 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
206
206
if (TheTriple.isOSBinFormatCOFF () && !IsResolved)
207
207
Value &= 0xfff ;
208
208
// Unsigned 12-bit immediate which gets multiplied by 8
209
- if (Value >= 0x8000 )
209
+ if (!isUInt< 15 >(Value) )
210
210
Ctx.reportError (Fixup.getLoc (), " fixup value out of range" );
211
211
if (Value & 0x7 )
212
212
Ctx.reportError (Fixup.getLoc (), " fixup must be 8-byte aligned" );
@@ -215,7 +215,7 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
215
215
if (TheTriple.isOSBinFormatCOFF () && !IsResolved)
216
216
Value &= 0xfff ;
217
217
// Unsigned 12-bit immediate which gets multiplied by 16
218
- if (Value >= 0x10000 )
218
+ if (!isUInt< 16 >(Value) )
219
219
Ctx.reportError (Fixup.getLoc (), " fixup value out of range" );
220
220
if (Value & 0xf )
221
221
Ctx.reportError (Fixup.getLoc (), " fixup must be 16-byte aligned" );
@@ -306,7 +306,7 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
306
306
}
307
307
case AArch64::fixup_aarch64_pcrel_branch14:
308
308
// Signed 16-bit immediate
309
- if (SignedValue > 32767 || SignedValue < - 32768 )
309
+ if (!isInt< 16 >( SignedValue) )
310
310
Ctx.reportError (Fixup.getLoc (), " fixup value out of range" );
311
311
// Low two bits are not encoded (4-byte alignment assumed).
312
312
if (Value & 0x3 )
@@ -315,7 +315,7 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
315
315
case AArch64::fixup_aarch64_pcrel_branch26:
316
316
case AArch64::fixup_aarch64_pcrel_call26:
317
317
// Signed 28-bit immediate
318
- if (SignedValue > 134217727 || SignedValue < - 134217728 )
318
+ if (!isInt< 28 >( SignedValue) )
319
319
Ctx.reportError (Fixup.getLoc (), " fixup value out of range" );
320
320
// Low two bits are not encoded (4-byte alignment assumed).
321
321
if (Value & 0x3 )
0 commit comments