]> git.karo-electronics.de Git - karo-tx-linux.git/commit
ARM: 7509/1: opcodes: Make opcode byteswapping macros assembly-compatible
authorDave Martin <dave.martin@linaro.org>
Mon, 3 Sep 2012 12:49:23 +0000 (13:49 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 7 Sep 2012 19:35:33 +0000 (20:35 +0100)
commitc4c2041a7ee668368d81502cb1c1e6ea86bf9d0c
tree7ecc0f119d608dc3193ba6118633f9612a92558b
parent687e73554fd1de12dd174e3fbe0a51f65ea627eb
ARM: 7509/1: opcodes: Make opcode byteswapping macros assembly-compatible

Most of the existing macros don't work with assembler, due to the
use of type casts and C functions from <linux/swab.h>.

This patch abstracts out those operations and provides simple
explicit versions for use in assembly code.

__opcode_is_thumb32() and __opcode_is_thumb16() are also converted
to do bitmask-based testing to avoid confusion if these are used in
assembly code (the assembler typically treats all arithmetic values
as signed).

These changes avoid the need for the compiler to pre-evaluate
constant expressions used to generate opcodes.  By ensuring that
the forms of these expressions can be evaluated directly by the
assembler, we can just stringify the expressions directly into the
asm during the preprocessing pass.  The alternative approach
(passing the evaluated expression via an inline asm "i" constraint)
gets painful because the contents of the asm and the constraints
must be kept in sync.  This makes the resulting macros awkward to
use.

Retaining the C forms of the macros allows more efficient code to
be generated when opcodes are generated programmatically at run-
time, but there is no way to embed run-time-generated opcodes in
asm() blocks.

Signed-off-by: Dave Martin <dave.martin@linaro.org>
Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/include/asm/opcodes.h