toolchain icon indicating copy to clipboard operation
toolchain copied to clipboard

Document %U GNU In-line Assembly modifier

Open abrodkin opened this issue 4 years ago • 3 comments

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.

abrodkin avatar Jun 22 '20 13:06 abrodkin

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 as a placeholder for the “update” flag in the corresponding load or store instruction. For example:

    asm ("st%U0 %1,%0" : "=m<>" (mem) : "r" (val));

is correct but:

    asm ("st %1,%0" : "=m<>" (mem) : "r" (val));

is not.

abrodkin avatar Jun 22 '20 13:06 abrodkin

FWIW, for ARC64 this is not a documentation issue - but feature missing issue ;-)

vineetgarc avatar Jun 24 '20 23:06 vineetgarc

I cannot understand what is missing see. The 'U' modifier is used in arc64.md in all ST/LD instructions.

claziss avatar Jun 25 '20 06:06 claziss