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]

Re: How to save and restore a symbol value in Aarch64?




On 20/04/17 11:54, Jeffrey Walton wrote:
On Thu, Apr 20, 2017 at 6:02 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
On Apr 20 2017, Jeffrey Walton <noloader@gmail.com> wrote:

I need the method to get the previous .cpu value
.cpu is not a symbol, it is a directive, so you cannot get its "value".
The effect of the directive is to modify the internal state of the
assembler, which is not directly accessible to the assembler input.
Thanks Andreas.

Does '.set push, .cpu' and '.set pop, .cpu' work as {expected|desired}
for Aarch32 and Aarch64?

It will not work as you expected.
They are simply treating "push/pop" as symbols, and their value will be the string ".cpu".


Below is a purely work around for your reference that you can escape assembler's architecture requirement check.

__inline unsigned int GCC_INLINE_ATTRIB
CRC32B(unsigned int crc, unsigned char v)
{
        unsigned int r;
        asm (
                        "\t.set raw_x0, 0\n"
                        "\t.set raw_x1, 1\n"
                        "\t.set raw_x2, 2\n"
                        "\t.set raw_x3, 3\n"
                        "\t.set raw_x4, 4\n"
                        "\t.set raw_x5, 5\n"
                        "\t.set raw_x6, 6\n"
                        "\t.set raw_x7, 7\n"
                        "\t#crc32w %w2, %w1, %w0\n"
                        "\t.inst\t0x1ac04800 | (raw_%2) | (raw_%1 << 5) | (raw_%0 << 16)\n"
                        : "=r"(r) : "r"(crc), "r"((unsigned int)v)
            );
        return r;
}

Regards,
Jiong


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