This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
AS, and saving and restoring .cpu directive on ARM?
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Wed, 19 Apr 2017 12:38:38 -0400
- Subject: AS, and saving and restoring .cpu directive on ARM?
- Authentication-results: sourceware.org; auth=none
- Reply-to: noloader at gmail dot com
I'm trying to make ARMv8's CRC instruction available regardless of GCC
configure options, CFLAGS and CXXFLAGS. The use of the hardware
instructions are guarded at runtime, so its OK if they are present.
Here's where I am at, but I feel like the .cpu needs to be saved and restored:
#define GCC_INLINE_ATTRIB __attribute__((__gnu_inline__,
__always_inline__, __artificial__))
#if defined(__GNUC__) && (defined(__aarch32__) || defined(__aarch64))
&& !defined(__ARM_FEATURE_CRC32)
__inline unsigned int GCC_INLINE_ATTRIB
CRC32B(unsigned int crc, unsigned char v)
{
unsigned int r;
asm (".cpu generic+fp+simd+crc+crypto \n"
"crc32b %w2, %w1, %w0 \n"
: "=r"(r) : "r"(crc), "r"((unsigned int)v));
return r;
}
#else
// just use the intrinsic
# define CRC32B (a,b) __crc32b(a,b)
#endif
Looking at a listing produced by Linaro's GCC 4.9.4, the preamble is
only ".cpu generic+fp+simd". I found adding ".cpu
generic+fp+simd+crc+crypto \n" got me past assembler errors.
I see the manual talks about saving and restoring directives on MIPS
(https://sourceware.org/binutils/docs/as/MIPS-Option-Stack.html#MIPS-Option-Stack),
but I don't see it for other architectures. I tried to add ".set push"
to the head and ".set pop" to the tail of the inline ASM to save and
restore the context, but it resulted in an assembler error.
I have two questions:
1) Does the .cpu directive need to be saved and restored in the inline
assembly block?
2) If so, then how do I do it under ARM?
Thanks in advance