This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

AS, and saving and restoring .cpu directive on ARM?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]