From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65386 invoked by alias); 20 Apr 2017 19:01:28 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 65371 invoked by uid 89); 20 Apr 2017 19:01:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Google-DKIM-Signature:reply-to X-HELO: mail-oi0-f43.google.com Received: from mail-oi0-f43.google.com (HELO mail-oi0-f43.google.com) (209.85.218.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Apr 2017 19:01:26 +0000 Received: by mail-oi0-f43.google.com with SMTP id y11so31451912oie.0 for ; Thu, 20 Apr 2017 12:01:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=y0BJ8qXUOWE+S2zYV8z2BXpW2s06kEmHjmHSwVygPMk=; b=rNb3HWayChNylgY5ZFl5DC74mBLlb7XSKWGoLpkRq7tB8z/ZCnr6L7omRmwNOksfYo +bX9gW+eOtbfW+YO5Owycn5yTOLntxDwU1yRqXaizrbxSaAbJJhkTOjrUt3FrVJeko3B J3CE9HoaZ4H5DnY+S4Yw0crSTzlzvjckAvjFvu/iWyDj4EIWtHiizCEbxHGDr/Mq5NyE Zrs6oNlIbCfwtFI9dKdIBNYDw0Gg84l2HSy1j58IQvXLRTBeJbz07NTI3xBP6OBCEQlM I4Z3f7GPn08N0QpEDc+adgidr9iaUdkt9SgZj0/usd1YDCDMb/tbbt4UXeLru89ikU3/ xTcw== X-Gm-Message-State: AN3rC/7uaBEIWBz1w7h0Jcab/TkTJijQ7smfttWPr8QB2YIiz/szZyFF ewy2RzHta2sGocKDkN4kqvWm/NNyywJcXt0= X-Received: by 10.202.206.198 with SMTP id e189mr5003108oig.158.1492714885290; Thu, 20 Apr 2017 12:01:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.139.199 with HTTP; Thu, 20 Apr 2017 12:01:24 -0700 (PDT) Reply-To: noloader@gmail.com In-Reply-To: References: <87tw5je6r1.fsf@linux-m68k.org> From: Jeffrey Walton Date: Thu, 20 Apr 2017 19:01:00 -0000 Message-ID: Subject: Re: How to save and restore a symbol value in Aarch64? To: Jiong Wang Cc: Binutils Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2017-04/txt/msg00180.txt.bz2 On Thu, Apr 20, 2017 at 8:35 AM, Jiong Wang wrote: > On 20/04/17 11:54, Jeffrey Walton wrote: >> >> ... > > 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; > } Thanks again Jiong. I needed one small change to make things work. I'm posting it back to the list in case someone copies/pastes. The operands needed to be reversed: __inline unsigned int GCC_INLINE_ATTRIB CRC32B(unsigned int crc, unsigned char v) { volatile unsigned int res; asm ( "\t" ".set reg_x0, 0\n" "\t" ".set reg_x1, 1\n" "\t" ".set reg_x2, 2\n" "\t" ".set reg_x3, 3\n" "\t" ".set reg_x4, 4\n" "\t" ".set reg_x5, 5\n" "\t" ".set reg_x6, 6\n" "\t" ".set reg_x7, 7\n" "\t" "#crc32w %w0, %w1, %w2\n" "\t" ".inst 0x1ac04800 | (reg_%2 << 16) | (reg_%1 << 5) | (reg_%0)\n" : "=r"(res) : "r"(crc), "r"(val) ); return res; } Thanks again. Jeff