Commit c6f87713 authored by Sandeep Tripathy's avatar Sandeep Tripathy Committed by Carles Cufi
Browse files

arch: arm64: macro for mov immediate



Single mov instruction can not be used to move non-zero
64b immediate value to the 64b register.
Implement macro to generate mov/ movk and movz sequences
depending on immediate value width.

Signed-off-by: default avatarSandeep Tripathy <sandeep.tripathy@broadcom.com>
parent b65bbd28
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -8,6 +8,29 @@
#define _MACRO_H_

#ifdef _ASMLANGUAGE
/*
 * macro to support mov of immediate constant to 64 bit register
 * It will generate instruction sequence of 'mov'/ 'movz' and one
 * to three 'movk' depending on the immediate value.
 */
.macro mov_imm, xreg, imm
	.if ((\imm) == 0)
		mov	\xreg, \imm
	.else
		.if (((\imm) >> 31) == 0 || ((\imm) >> 31) == 0x1ffffffff)
			movz    \xreg, (\imm >> 16) & 0xffff, lsl 16
		.else
			.if (((\imm) >> 47) == 0 || ((\imm) >> 47) == 0x1ffff)
				movz    \xreg, (\imm >> 32) & 0xffff, lsl 32
			.else
				movz    \xreg, (\imm >> 48) & 0xffff, lsl 48
				movk    \xreg, (\imm >> 32) & 0xffff, lsl 32
			.endif
			movk    \xreg, (\imm >> 16) & 0xffff, lsl 16
		.endif
		movk    \xreg, (\imm) & 0xffff, lsl 0
	.endif
.endm

.macro	switch_el, xreg, el3_label, el2_label, el1_label
	mrs	\xreg, CurrentEL