toolchain
toolchain copied to clipboard
Document %U GNU In-line Assembly modifier
In some existing in-line assembly code we use %U1
opcode modifier like ld%U1 %0, %1
in the Linux' accessors (see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arc/include/asm/io.h#n78):
static inline u32 __raw_readl(const volatile void __iomem *addr)
{
u32 w; __asm__ __volatile__(
" ld%U1 %0, %1 \n"
: "=r" (w)
: "m" (*(volatile u32 __force *)addr)
: "memory"); return w;
}
Would be good to have a clear documentation on what does that modifier really do.
As per @claziss it is used for .as
or .ab
/.a
flags.
For the record PowerPC uses something similar and that what they have in the docs (https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html):
m - A memory operand. Normally, m does not allow addresses that update the base register. If the < or > constraint is also used, they are allowed and therefore on PowerPC targets in that case it is only safe to use m<> in an asm statement if that asm statement accesses the operand exactly once. The asm statement must also use %U
asm ("st%U0 %1,%0" : "=m<>" (mem) : "r" (val));
is correct but:
asm ("st %1,%0" : "=m<>" (mem) : "r" (val));
is not.
FWIW, for ARC64 this is not a documentation issue - but feature missing issue ;-)
I cannot understand what is missing see. The 'U' modifier is used in arc64.md in all ST/LD instructions.