[arm64] Negative immediates

Marc Glisse marc.glisse at inria.fr
Sun Sep 21 09:51:34 UTC 2014


a cross-build of GMP for aarch64 with clang currently fails for me with:

tmp-lshift.s:77:14: error: expected compatible register, symbol or integer 
in range [0, 4095]
         add     x1, x1, #-8

According to the ARM doc for the arithmetic operations (the rules are 
different for other operations):

A “programmer-friendly” assembler may accept a negative immediate between 
-(2²⁴-1) and -1 inclusive, causing it to convert a requested ADD 
operation to a SUB, or vice versa, and then encode the absolute value of 
the immediate as for uimm24. However this behaviour is not required by the 
architectural assembly language.

So I guess we should not rely on it. Is this just meant to be:
 	sub	x1, x1, #8

Marc Glisse

More information about the gmp-bugs mailing list