10.3.3 Clobber list

The clobber list is a comma-separated list of strings. Each string is the name of a register that the assembly code potentially modifies, but for which the final value is not important. To prevent the compiler from using a register for a template string in an inline assembly string, add the register to the clobber list.

For example, if a register holds a temporary value, include it in the clobber list. The compiler avoids using a register in this list as an input or output operand, or using it to store another value when the assembly code is executed.

In addition to register names, you can use two special names in the clobber list:

"memory"
This string tells the compiler that the assembly code might modify any memory, not just variables that are included in the output constraints.
"cc"
This string tells the compiler that the assembly code might modify any of the condition flags N, Z, C, or V. In AArch64 state, these condition flags are in the NZCV register. In AArch32 state, these condition flags are in the CPSR register.

Example

void enable_aarch64() {
	// Set bit 10 of SCR_EL3, to enale AArch64 at EL2.
	__asm volatile(R"(
		  mrs x0, SCR_EL3
		  orr x0, x0, #(1<<10)
		  msr SCR_EL3, x0
		  )" : /* no outputs */ : /* no inputs */
		  // We used x0 as a temporary register, so we need to mark it as
		  // clobbered, to prevent the compiler from storing a value in it.
		: "x0");
}
Non-ConfidentialPDF file icon PDF versionDUI0774J
Copyright © 2014–2017, 2019 Arm Limited or its affiliates. All rights reserved.