From patchwork Thu Jul 2 15:46:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 20779 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 6D69844B923 for ; Thu, 2 Jul 2020 18:47:06 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5048D68AEEA; Thu, 2 Jul 2020 18:47:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay1.mymailcheap.com (relay1.mymailcheap.com [144.217.248.102]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 021FB68A0BE for ; Thu, 2 Jul 2020 18:46:59 +0300 (EEST) Received: from filter1.mymailcheap.com (filter1.mymailcheap.com [149.56.130.247]) by relay1.mymailcheap.com (Postfix) with ESMTPS id 695AA3F157 for ; Thu, 2 Jul 2020 11:46:57 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by filter1.mymailcheap.com (Postfix) with ESMTP id 520112A3A7 for ; Thu, 2 Jul 2020 11:46:57 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mymailcheap.com; s=default; t=1593704817; bh=8F2XiNA02qK3TBerFnwypjgMRwAjUuo1fn0cURL81cg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KyyXTBfGWTzVVC4ZTYSVJ/+VLFhaKqzN7MFNmwkazR/ERnGSJvLCqDZ3W80z+NqVv WHa8gNkhkc7jjmeuJ/hAT/YvQUyQwZw3JHxmKTtVs1GVjV7WgrLRqFEEO+XM+xHRun 1OfWkId4rSwXlXB6BZ3V3bO0mvPUZ3vvyZXI9Aro= X-Virus-Scanned: Debian amavisd-new at filter1.mymailcheap.com Received: from filter1.mymailcheap.com ([127.0.0.1]) by localhost (filter1.mymailcheap.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n2eewdA3EN-c for ; Thu, 2 Jul 2020 11:46:56 -0400 (EDT) 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 filter1.mymailcheap.com (Postfix) with ESMTPS for ; Thu, 2 Jul 2020 11:46:56 -0400 (EDT) Received: from [213.133.102.83] (ml.mymailcheap.com [213.133.102.83]) by mail20.mymailcheap.com (Postfix) with ESMTP id E5C3C4084C; Thu, 2 Jul 2020 15:46:53 +0000 (UTC) Authentication-Results: mail20.mymailcheap.com; dkim=pass (1024-bit key; unprotected) header.d=flygoat.com header.i=@flygoat.com header.b="WSk+TZVk"; dkim-atps=neutral AI-Spam-Status: Not processed Received: from halation.202.net.flygoat.com (unknown [115.227.164.72]) (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 0F11D403B3; Thu, 2 Jul 2020 15:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=flygoat.com; s=default; t=1593704797; bh=8F2XiNA02qK3TBerFnwypjgMRwAjUuo1fn0cURL81cg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WSk+TZVkjWVIy7NpyeTYidRhDII3445TuT68ik8nBC3odJ8c/vW09M8w0ylprgs3j hyzKXwFSG3BPRzzv71f4Yb3pUhol6QnNgSYm7KDLWNRMlhqyi/du80Md+ZU+ghwZtH RQ5fuK5yHXDoEihAF4Uv+jMqO6amuWlODc7/Q3w4= From: Jiaxun Yang To: ffmpeg-devel@ffmpeg.org Date: Thu, 2 Jul 2020 23:46:18 +0800 Message-Id: <20200702154622.21280-3-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200702154622.21280-1-jiaxun.yang@flygoat.com> References: <20200702154622.21280-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: E5C3C4084C X-Spamd-Result: default: False [4.90 / 10.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(0.00)[flygoat.com:s=default]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; 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]; ML_SERVERS(-3.10)[213.133.102.83]; DKIM_TRACE(0.00)[flygoat.com:+]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[213.133.102.83:from]; DMARC_POLICY_ALLOW(0.00)[flygoat.com,none]; 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 v5 2/6] 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: Jiaxun Yang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 */