Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1381819

[PATCH 4/8] arm64: introduce mov_q macro to move a constant into a 64-bit register

From Ard Biesheuvel <ard.biesheuvel@linaro.org>
Newsgroups linux.kernel
Subject [PATCH 4/8] arm64: introduce mov_q macro to move a constant into a 64-bit register
Date 2016-04-18 17:20 +0200
Message-ID <rpj7Z-7JL-43@gated-at.bofh.it> (permalink)
References <rpj7X-7JL-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Implement a macro mov_q that can be used to move an immediate constant
into a 64-bit register, using between 2 and 4 movz/movk instructions
(depending on the operand)

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 arch/arm64/include/asm/assembler.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
index 70f7b9e04598..9ea846ded55c 100644
--- a/arch/arm64/include/asm/assembler.h
+++ b/arch/arm64/include/asm/assembler.h
@@ -233,4 +233,24 @@ lr	.req	x30		// link register
 	.long	\sym\()_hi32
 	.endm
 
+	/*
+	 * mov_q - move an immediate constant into a 64-bit register using
+	 *         between 2 and 4 movz/movk instructions (depending on the
+	 *         magnitude and sign of the operand)
+	 */
+	.macro	mov_q, reg, val
+	.if (((\val) >> 31) == 0 || ((\val) >> 31) == 0x1ffffffff)
+	movz	\reg, :abs_g1_s:\val
+	.else
+	.if (((\val) >> 47) == 0 || ((\val) >> 47) == 0x1ffff)
+	movz	\reg, :abs_g2_s:\val
+	.else
+	movz	\reg, :abs_g3:\val
+	movk	\reg, :abs_g2_nc:\val
+	.endif
+	movk	\reg, :abs_g1_nc:\val
+	.endif
+	movk	\reg, :abs_g0_nc:\val
+	.endm
+
 #endif	/* __ASM_ASSEMBLER_H */
-- 
2.5.0

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/8] arm64: kaslr cleanups and improvements Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-04-18 17:20 +0200
  [PATCH 4/8] arm64: introduce mov_q macro to move a constant into a 64-bit register Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-04-18 17:20 +0200
  [PATCH 8/8] arm64: kaslr: increase randomization granularity Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-04-18 17:20 +0200
    Re: [PATCH 8/8] arm64: kaslr: increase randomization granularity Will Deacon <will.deacon@arm.com> - 2016-04-26 13:30 +0200
      Re: [PATCH 8/8] arm64: kaslr: increase randomization granularity Matt Fleming <matt@codeblueprint.co.uk> - 2016-04-26 17:30 +0200
  [PATCH 1/8] arm64: kernel: don't export local symbols from head.S Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-04-18 17:20 +0200
    Re: [PATCH 1/8] arm64: kernel: don't export local symbols from head.S Mark Rutland <mark.rutland@arm.com> - 2016-04-18 17:40 +0200
  [PATCH 2/8] arm64: kernel: use literal for relocated address of __secondary_switched Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-04-18 17:20 +0200
    Re: [PATCH 2/8] arm64: kernel: use literal for relocated address of  __secondary_switched Mark Rutland <mark.rutland@arm.com> - 2016-04-18 18:00 +0200
  Re: [PATCH 0/8] arm64: kaslr cleanups and improvements Catalin Marinas <catalin.marinas@arm.com> - 2016-04-25 18:40 +0200

csiph-web