From patchwork Mon Jun 8 03:30:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 20208 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:bac9:0:0:0:0:0 with SMTP id a9csp4198292ybk; Sun, 7 Jun 2020 20:31:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaYPjIPboO3Rvs7YitMEYqlczG96blPIIaxg+kWHn4EPQAyOymtPXSIknb4A47mCZ+/KLH X-Received: by 2002:a1c:3987:: with SMTP id g129mr14502319wma.139.1591587084979; Sun, 07 Jun 2020 20:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591587084; cv=none; d=google.com; s=arc-20160816; b=XnAbL1E7hkee2ikuQwTIFK90O9POacaomvaNKI/LEm+iWfyQ99NXSa3CVpx/nMOjt5 cb/m1CW5T7JVyWvIEXWcNnhFdqBczeyrqAAaE2YvheUUHFaj++J4sa4LH69dpVVNngjI gPQwnbt2IetjCR4GIklwDBpQe3xEYNAo0w6wb6KXhfG3d4Z3fmKfSuyNvGkZSyEHfKhm Qp2jQ+jdxiMPkvhx/5qyZYtGP0JMFc4WAvjjhB8E4UV5eUJPU5htm3bWQV/wv8Js0bg4 9C2ffrZQQfTlmqrOb5ntjpGIVrxa7jyTrZo+Cfq0PinN29+O1HnRG7ieDXdZEeXmSQPN iEIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:ai-spam-status :dkim-signature:delivered-to; bh=YCC/QnxqpUcmqlZsIm+5BmFiJw8y5+VIoCKA/wItOrA=; b=EUhigcJPPjsCOSg5RuubnyHEA49T7gjGlizduyvqkjGnHL5H56E+Ba4t6pUeQXpZb2 Cm7rm7XINJsBMXMFcJ75SDILGYul5U1zRUi1xk+9qgkVIeNC3bC9Bu3WgFq1fruzIlBp XJYfM9Sphx+5fqSnTgxdLde/4dH2HH//n2iZa7O86qkecWkY7YWrcZFuTFzpjeGnkFrT 1It1Ufc1T7swcHbzuJqm+Im0CCVEmy343sk7w8FmkMbf2oapA8fcIXr0G9XbJgSxMKzj Ic1AqtEl9B1ATxfPf+wkNpRD3soOusKlpRwqgZjTQeyfYXWQSEmiJdPoxCRz/G9FgzQC etdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mymailcheap.com header.s=default header.b=elMoAPsC; dkim=neutral (body hash did not verify) header.i=@flygoat.com header.s=default header.b=c3ekmsiH; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j7si16609689wmj.113.2020.06.07.20.31.24; Sun, 07 Jun 2020 20:31:24 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@mymailcheap.com header.s=default header.b=elMoAPsC; dkim=neutral (body hash did not verify) header.i=@flygoat.com header.s=default header.b=c3ekmsiH; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E796E68B14F; Mon, 8 Jun 2020 06:31:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay2.mymailcheap.com (relay2.mymailcheap.com [151.80.165.199]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 473DE68B0E6 for ; Mon, 8 Jun 2020 06:31:02 +0300 (EEST) Received: from filter2.mymailcheap.com (filter2.mymailcheap.com [91.134.140.82]) by relay2.mymailcheap.com (Postfix) with ESMTPS id 587F73E90B; Mon, 8 Jun 2020 05:31:01 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by filter2.mymailcheap.com (Postfix) with ESMTP id 38BCA2A8BA; Mon, 8 Jun 2020 05:31:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mymailcheap.com; s=default; t=1591587061; bh=4WvzDHPKPy32fR3JYC+X6T8j43jVMvoreuBSinzPMaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=elMoAPsCXooRN61wnSvVWgf93cmMNpGyI6tk8Z3j4wZM5nfIO6Nt/n7AM0G7Wj50f N8R9Xs/H5D6BHyXxxc4J1rdxqxIrblr4Ty8KBhrORNPQqCvkufC9jtrhcwc9drrjG/ O1BGiaElPfLLA7xT8o16YITeYjrZMg4Wgf/yP6EU= X-Virus-Scanned: Debian amavisd-new at filter2.mymailcheap.com Received: from filter2.mymailcheap.com ([127.0.0.1]) by localhost (filter2.mymailcheap.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nHxWAcwhbde9; Mon, 8 Jun 2020 05:31:00 +0200 (CEST) Received: from mail20.mymailcheap.com (mail20.mymailcheap.com [51.83.111.147]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by filter2.mymailcheap.com (Postfix) with ESMTPS; Mon, 8 Jun 2020 05:31:00 +0200 (CEST) Received: from [213.133.102.83] (ml.mymailcheap.com [213.133.102.83]) by mail20.mymailcheap.com (Postfix) with ESMTP id C693B414D1; Mon, 8 Jun 2020 03:30:59 +0000 (UTC) Authentication-Results: mail20.mymailcheap.com; dkim=pass (1024-bit key; unprotected) header.d=flygoat.com header.i=@flygoat.com header.b="c3ekmsiH"; dkim-atps=neutral AI-Spam-Status: Not processed Received: from rush.localdomain (unknown [60.177.191.23]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail20.mymailcheap.com (Postfix) with ESMTPSA id 5CE47414D1; Mon, 8 Jun 2020 03:30:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=flygoat.com; s=default; t=1591587015; bh=4WvzDHPKPy32fR3JYC+X6T8j43jVMvoreuBSinzPMaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c3ekmsiHwgU8K/lXM936gclKGrpHaALP9g7PlU0pEdNSLpG4fI7ixGBbopnarbj8K TcnfhLNyX2TO3/4en+/OZnw2pmrFK5RwEgLYIlqWdbUvSG4O1oVkeN4IhmwQ/kVdiU fx8/NgHRdZJB1m4jdwPUfZGX6W0Mu12CbOFrKyXU= From: Jiaxun Yang To: ffmpeg-devel@ffmpeg.org Date: Mon, 8 Jun 2020 11:30:02 +0800 Message-Id: <20200608033004.2635-3-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200608033004.2635-1-jiaxun.yang@flygoat.com> References: <20200608033004.2635-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: C693B414D1 X-Spamd-Result: default: False [4.90 / 10.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(0.00)[flygoat.com:s=default]; RECEIVED_SPAMHAUS_PBL(0.00)[60.177.191.23:received]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; R_SPF_SOFTFAIL(0.00)[~all:c]; TO_DN_SOME(0.00)[]; ML_SERVERS(-3.10)[213.133.102.83]; DKIM_TRACE(0.00)[flygoat.com:+]; DMARC_POLICY_ALLOW(0.00)[flygoat.com,none]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[213.133.102.83:from]; DMARC_POLICY_ALLOW_WITH_FAILURES(0.00)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:213.133.96.0/19, country:DE]; RCVD_COUNT_TWO(0.00)[2]; HFILTER_HELO_BAREIP(3.00)[213.133.102.83,1] X-Rspamd-Server: mail20.mymailcheap.com X-Spam: Yes Subject: [FFmpeg-devel] [PATCH v4 2/4] libavutils: Add parse_r helper for MIPS X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: yinshiyou@loongson.cn, Jiaxun Yang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: fxG3uYnzeznB Content-Length: 3222 That helper grab from kernel code can allow us to inline newer instructions (not implemented by the assembler) in a elegant manner. Signed-off-by: Jiaxun Yang --- libavutil/mips/asmdefs.h | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/libavutil/mips/asmdefs.h b/libavutil/mips/asmdefs.h index 748119918a..7e0e4cf575 100644 --- a/libavutil/mips/asmdefs.h +++ b/libavutil/mips/asmdefs.h @@ -55,4 +55,46 @@ # define PTR_SLL "sll " #endif +/* + * parse_r var, r - Helper assembler macro for parsing register names. + * + * This converts the register name in $n form provided in \r to the + * corresponding register number, which is assigned to the variable \var. It is + * needed to allow explicit encoding of instructions in inline assembly where + * registers are chosen by the compiler in $n form, allowing us to avoid using + * fixed register numbers. + * + * It also allows newer instructions (not implemented by the assembler) to be + * transparently implemented using assembler macros, instead of needing separate + * cases depending on toolchain support. + * + * Simple usage example: + * __asm__ __volatile__("parse_r __rt, %0\n\t" + * ".insn\n\t" + * "# di %0\n\t" + * ".word (0x41606000 | (__rt << 16))" + * : "=r" (status); + */ + +/* Match an individual register number and assign to \var */ +#define _IFC_REG(n) \ + ".ifc \\r, $" #n "\n\t" \ + "\\var = " #n "\n\t" \ + ".endif\n\t" + +__asm__(".macro parse_r var r\n\t" + "\\var = -1\n\t" + _IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3) + _IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7) + _IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11) + _IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15) + _IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19) + _IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23) + _IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27) + _IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31) + ".iflt \\var\n\t" + ".error \"Unable to parse register name \\r\"\n\t" + ".endif\n\t" + ".endm"); + #endif /* AVCODEC_MIPS_ASMDEFS_H */