I am very new to Linux Kernel-based C-coding Style. I am trying to understand the following implementation of the "atomic_add" function from "arch/arm64/include/asm/atomic.h" file (Lines 112-124 of here).
static inline void atomic_add(int i, atomic_t *v)
{
unsigned long tmp;
int result;
asm volatile("// atomic_add\n"
"1: ldxr %w0, %2\n"
" add %w0, %w0, %w3\n"
" stxr %w1, %w0, %2\n"
" cbnz %w1, 1b"
: "=&r" (result), "=&r" (tmp), "+Q" (v->counter)
: "Ir" (I));
}
Please help me to understand the following questions.
What is the meaning of %w0 or %w3? I understand that %2 is referring to the counter value.
Is %w0 referring to the (result) variable or a general-purpose register?
Does the constraint string "Ir" stand for "Immediate Register"?