From patchwork Tue Aug 13 14:03:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J. Dekker" X-Patchwork-Id: 51002 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:a746:0:b0:489:2eb3:e4c4 with SMTP id f6csp291698vqm; Tue, 13 Aug 2024 07:11:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW9rasBtG5ggfoSArFMhTRc61Ffq1ZasdxCMMD/afZO3YgIpgOzyWu6j95bZqKgOsM5sslgBPpaOOXWCd89T0tBZZDxiQnYiafw/w== X-Google-Smtp-Source: AGHT+IHk+JijtgmaVk7KSqDwVL6+a5tx04srkyaaqF00JTPxh8YYrgJ4PWfiCH7862ysF4NynUTt X-Received: by 2002:a05:6512:3b90:b0:52f:c337:4c1f with SMTP id 2adb3069b0e04-53214f8272cmr1010196e87.0.1723558278876; Tue, 13 Aug 2024 07:11:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723558278; cv=none; d=google.com; s=arc-20160816; b=UemrRORlQ4d08FDmRyGnlgjMMm0zSoK8rRk709tTTuYVOFDQuewjJMT/KQeJ0+ePAA CX2Ijk6nmr1JPq+rJsDEG8BDJZWVKgxoS7GfCRtUyw0rtv8MZI90rDoUI3Gefus95vmf DZc0HLfq82GoocpmruqMb9nKXoYNGLrJhEtOt3WGuelFFvrR7L5jUbdZZMZYHGVNlMHd LB2e0+J/u7OBVe8LzmdFb+nm5nnE2HssNYA7nCA2fqSigTecBO1RBsTcbKq05msu9KMo ZL3ffUaLNNGwLc6dS9tkF+3ahCpyu14AAQjcOUfLRLRkUhv8l+2ntgsoVUybOoNPoBu3 ew0w== 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:feedback-id:dkim-signature:dkim-signature :delivered-to; bh=ZN4pzCwW6B/Yf2BHsiHtj6c7YlA927+0tw7jl3F8Ows=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=EgbWehRc1L7Yw61WN70JBOlF+5z76OW3yQEOhbJmouuTXSQ97ZkJFLk0KX8E2KLzGC nSdHx/FXZ0N7mHFVW+FCDTQjm2Z5DSNXEDqtUJMs3f3lfGzffQ1ZXe6TTps43PZlpG8H sX1DFCiuS4X7+IJRf84gXGc5E9qHjvd/K18aPqwVqlpNn/cXTpLUm+7EU30Ec9/JQdiJ /4SqEtZGm2xg2sQpP0Xo4zoYa+GOZ+f1kp95sP42jpNYsnZh2k2tetNWhNpTRThaTqOB Bc/IR6yVYZ43g51pb8/fZoo8y0rRuTWMzElNGuJBoIin3sEZaaGcLV/B4YnLxmRuKqGK VjLQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@itanimul.li header.s=fm1 header.b=Rcd6xKtn; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm3 header.b=hErl+yBr; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-53200e96793si2321176e87.84.2024.08.13.07.11.17; Tue, 13 Aug 2024 07:11:18 -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=@itanimul.li header.s=fm1 header.b=Rcd6xKtn; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm3 header.b=hErl+yBr; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4666868DA9E; Tue, 13 Aug 2024 17:03:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from fout6-smtp.messagingengine.com (fout6-smtp.messagingengine.com [103.168.172.149]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4321E68DA82 for ; Tue, 13 Aug 2024 17:03:50 +0300 (EEST) Received: from phl-compute-05.internal (phl-compute-05.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id 514D3138C049; Tue, 13 Aug 2024 10:03:49 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Tue, 13 Aug 2024 10:03:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=itanimul.li; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1723557829; x= 1723644229; bh=xJnkRckIVBt5baXbbD+rW08szHc3SpSU3qFXUvdBY1I=; b=R cd6xKtniHEKVaQ2+qpjyF4AqnVwmxvKVMtXpH9J8ZRTWjvuP24Ky27NkVx8gOI6O 31m8Ax4n6BSMnz1Ul6E4+ZctRZuIBCETrjzvJejngGrIXUWypnI/D2PHghtP2aIK 7wTDPmfaap+iDiMR2tbBJyIVcU9LEEzvg2aFx78eVd7LrTQXTxLfvxh8c74wa6Gw vEL3JYmDhmsa/kyyiMpmqZjEAg3mtqV7C79UM8Fjl0oVkKF1s8ipwB51cD6V1pW/ ksqztOYvf/2IgUhA7hRgF/UoA7c6iW0sO3sljzLfG0U2OxQmfOpH1FSpdjgYDFAE zLlXhxX0JHfLOJuZcZFmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1723557829; x= 1723644229; bh=xJnkRckIVBt5baXbbD+rW08szHc3SpSU3qFXUvdBY1I=; b=h Erl+yBrMtxHgF7UjUoJ/OndLc9opUE6l1KpS8D0t/IznL/5RgxfY5JQrVZnhhhLq sIa6IXS1D/ngyL5kB0yZc6QYjqZ0jb+Apv3NAnDL4goAUnG3oxltDHKk+PYUQq2o iXhytqpLwrnXf4j53+Z9U9Z8SfklEtNLaZxZOwPZKFTjd3hGfIn9MXDh1bFdTsA0 XZrDdoM7liI9IWiZ9i98ivpLRItApQmCUtw/72LfdLZkj/SvWRcnBi85nCmEkr56 0KE/9Yv9HrlWox7pdr0wJPy3IgqDIAivtyOF4Bvld3EBZSHDPNseJk/1CTL4lG/I sHklwLW/KYt1+6NqjTqmw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddtvddgjeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevuf ffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpedflfdrucffvghkkhgvrhdfuceo jhguvghksehithgrnhhimhhulhdrlhhiqeenucggtffrrghtthgvrhhnpedtheekffejgf ektdehgedvieevgeegffdvvedvudeffffhteeiffelhfekvddujeenucffohhmrghinhep rghsmhdrshgsnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrh homhepjhguvghksehithgrnhhimhhulhdrlhhipdhnsggprhgtphhtthhopedvpdhmohgu vgepshhmthhpohhuthdprhgtphhtthhopehffhhmphgvghdquggvvhgvlhesfhhfmhhpvg hgrdhorhhgpdhrtghpthhtohepghhitheshhgrrghsnhdruggvvh X-ME-Proxy: Feedback-ID: i84994747:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 13 Aug 2024 10:03:48 -0400 (EDT) From: "J. Dekker" To: ffmpeg-devel@ffmpeg.org Date: Tue, 13 Aug 2024 16:03:35 +0200 Message-ID: <20240813140338.143045-6-jdek@itanimul.li> X-Mailer: git-send-email 2.44.1 In-Reply-To: <20240813140338.143045-1-jdek@itanimul.li> References: <20240813140338.143045-1-jdek@itanimul.li> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/7] avutil/riscv/asm: add generic push/pop helpers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: k15Hc+Go0kiC From: Niklas Haas Generic helper macros to push/pop multiple registers at once. Expands to a single `addi` plus a sequence of XLEN-sized stores/loads. --- libavutil/riscv/asm.S | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/libavutil/riscv/asm.S b/libavutil/riscv/asm.S index db190e99ca..3955530e4e 100644 --- a/libavutil/riscv/asm.S +++ b/libavutil/riscv/asm.S @@ -288,3 +288,40 @@ .macro count_args args:vararg count_args_inner 0, \args .endm + + /** + * Helper macro to iterate over constant sized elements in memory + * @param op operation to perform on each element (sized load/store) + * @param size size in bytes per element + * @param offset starting offset of first element + * @param addr base address to load/store + * @param regs registers to iterate over + */ + .macro for_mem op, size, offset, addr, reg, regs:vararg + .ifnb \reg + \op \reg, \offset(\addr) + for_mem \op, \size, \offset + \size, \addr, \regs + .endif + .endm + + /** + * Push a variable number of registers to the stack. + * @param n number of registers to push + * @param regs registers to push + */ + .macro push regs:vararg + count_args \regs + addi sp, sp, -(num_args * (__riscv_xlen >> 3)) + for_mem sx, __riscv_xlen >> 3, 0, sp, \regs + .endm + + /** + * Pop a variable number of registers from the stack. + * @param n number of registers to pop + * @param[out] regs registers to pop + */ + .macro pop regs:vararg + count_args \regs + for_mem lx, __riscv_xlen >> 3, 0, sp, \regs + addi sp, sp, num_args * (__riscv_xlen >> 3) + .endm