From patchwork Tue May 30 12:30:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 41891 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp2426740pzb; Tue, 30 May 2023 05:30:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5DVhbbLm18BvdV/bMTh+ih0z53OcUNf1c8cZXYeU7kDJxZXNCsUmNMsbktCAZoChRA3+Jt X-Received: by 2002:a17:906:58d1:b0:94a:653b:ba41 with SMTP id e17-20020a17090658d100b0094a653bba41mr2788983ejs.15.1685449856348; Tue, 30 May 2023 05:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685449856; cv=none; d=google.com; s=arc-20160816; b=lnXFDQkUXCajXUDto9fqHR9S67tPb7M2uZQrTUHlHeWEQTeqJYgXWNr4+EHISzxtpg oGohxaDP2BSVaDXFieufqYG0qrrUw5hmkafb7bjj0NhPfDgB4jF7iuKYEZeM4Yv2DYph LJhe4qk9PZKIqlAoTMkd4O88UmHPTMV07oMrh1Flc1gzLTECDGKQ6NIlik7SGJsMOgn+ e6EGN0J0aDG9Xk6w56LuhUCyHpa+1pyJKUUMx8L2Qg+FNB0jfDTNEN5rpdPUBVvME4w/ gEsbW2tZJ4H+FqQ4OA5kaNBCgG5DJhYbsThqC8llDQYvaP+xvt07z6OrFEBjQwDGoHCu nYfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=IGTAUoO0+i4SDhV0Pv09dQeX/wp/9fDDbX/9ofF6pjE=; b=U75clz9f4Kge40SGmAgx6N9ZWYeFsDbrNzUyxmrUYFDuhcx8EGGU30to28WK9esGTV sK110bfZ1DevEtJUR1K9gl+HEhhUBuRr1+eEojAlLxoJ4UsX6ADDYgyDZnWDNVD8C7C7 h107mqaaQt+9gd58qzS5F4oV76047AgC1VpjHd3Z7mu1CrNXUutbkQQxa4sNqIB4rw8E JSsLD7oZ5OhAvXr+l/CHSDxoGAG2oke7NFW5dBQjoRCMqIK0iVnIalHSVesOZ1hAqT9D L0IkuJPwkU4cCQqHGQTT/oJ1Fnt4ZXohypkmcj8R+5LEc0RVnHCdCasWRZSxRlzDUuMv +3GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20221208.gappssmtp.com header.s=20221208 header.b=kqfIt0LF; 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 sc32-20020a1709078a2000b0096f70608f91si2094957ejc.149.2023.05.30.05.30.55; Tue, 30 May 2023 05:30:56 -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=@martin-st.20221208.gappssmtp.com header.s=20221208 header.b=kqfIt0LF; 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 A390668C20F; Tue, 30 May 2023 15:30:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 647DB68C033 for ; Tue, 30 May 2023 15:30:45 +0300 (EEST) Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-4f4e71a09a7so4883754e87.1 for ; Tue, 30 May 2023 05:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20221208.gappssmtp.com; s=20221208; t=1685449844; x=1688041844; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=flfg/l3g4m7HFSKYXQZiF5SeKw07UNZYyRlgRM9O4Vg=; b=kqfIt0LF3hxJrBKE3did21hKXFH+A0h439XcQ+jlL5GHAjPaE0Tdb+oUdr4e0UQlF1 9GpcWtmKZasHAhMS2yE67JqVJ6SfM3ZB3Tg2Po1uX1hyCXE9dCsOOoY+Id5pOO4I8PwL oRiStMa8j3T3vr1a76Ib9+mzmaDn8GxK0D3qOTguP37BSQiIl93NtEpKSY/1aZfK8xWh qAqWRITpn4XyS+TLQx7qL9amasnA0pMyyIx2lfHHm8nCTh9XmypnAsUdfs2Iyidydifd ixrlIlzIjjakfeZdABANnY/Ffi5Msb5XsmYamF7nUOApR6aRJIYFTFZxG7oN3e0X0Mnd HiXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685449844; x=1688041844; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=flfg/l3g4m7HFSKYXQZiF5SeKw07UNZYyRlgRM9O4Vg=; b=X0v/07kSnOLkkNDrYtf1ui+ojK1Yyt98g7eUvDbMnbsvZVb8miIyS6aHmUOs42yQPM 0a/FEKkOxT54DhRKfrvJKGdJwKbRofbXDUeQzCTH3D7wOfc3cCZtETMENBL9yM9V3jLK mhlsw3p7rbP5TCX//3erd9cE2iJYLlrOqOezvnmu6zpe+cdhk/8NwnKDVgf1GHMys4ab QF79+N1LA+z/xcwzw0JmcVg/+yoWJpHTNOtmiZWRfIclS6ABe+wj7Ue0rpkfFXIi2cJt TC6r4EHOFk6zLqRrHbjeHsepLNLc0G9kOR+SGjGZQL7J+f91MbDC4pwbQO5agaOYn6mU SkqQ== X-Gm-Message-State: AC+VfDzOTWhKX0/9gyrbxqMfpt7zciCvyHubDoqKG2J13kXEn0Emw4Eb XjN4BGaE2F6tQtJVfG5oq+McaBQah33dUacC0G4YQw== X-Received: by 2002:ac2:4464:0:b0:4eb:3cac:23b9 with SMTP id y4-20020ac24464000000b004eb3cac23b9mr737085lfl.9.1685449844417; Tue, 30 May 2023 05:30:44 -0700 (PDT) Received: from localhost (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id q20-20020ac25294000000b004f3945751b2sm331029lfm.43.2023.05.30.05.30.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 May 2023 05:30:43 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Tue, 30 May 2023 15:30:39 +0300 Message-Id: <20230530123043.52940-1-martin@martin.st> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/5] configure: aarch64: Support assembling the dotprod and i8mm arch extensions 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Sg03X3W6MQjo These are available since ARMv8.4-a and ARMv8.6-a respectively, but can also be available optionally since ARMv8.2-a. Check if ".arch armv8.2-a" and ".arch_extension {dotprod,i8mm}" are supported, and check if the instructions can be assembled. Current clang versions fail to support the dotprod and i8mm features in the .arch_extension directive, but do support them if enabled with -march=armv8.4-a on the command line. (Curiously, lowering the arch level with ".arch armv8.2-a" doesn't make the extensions unavailable if they were enabled with -march; if that changes, Clang should also learn to support these extensions via .arch_extension for them to remain usable here.) --- Simplified the detection logic somewhat; check if ".arch armv8.2-a" and ".arch_extension {dotprod,i8mm}" are available, then check if the instruction can be assembled. This way, we check exactly the same thing as we are going to assemble in the end, so there shouldn't be any risk of build breakage due to testing and building subtly different things. --- configure | 81 ++++++++++++++++++++++++++++++++++++++++- libavutil/aarch64/asm.S | 11 ++++++ 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 495493aa0e..50eb27ba0e 100755 --- a/configure +++ b/configure @@ -454,6 +454,8 @@ Optimization options (experts only): --disable-armv6t2 disable armv6t2 optimizations --disable-vfp disable VFP optimizations --disable-neon disable NEON optimizations + --disable-dotprod disable DOTPROD optimizations + --disable-i8mm disable I8MM optimizations --disable-inline-asm disable use of inline assembly --disable-x86asm disable use of standalone x86 assembly --disable-mipsdsp disable MIPS DSP ASE R1 optimizations @@ -1154,6 +1156,43 @@ check_insn(){ check_as ${1}_external "$2" } +check_arch_level(){ + log check_arch_level "$@" + level="$1" + check_as tested_arch_level ".arch $level" + enabled tested_arch_level && as_arch_level="$level" +} + +check_archext_insn(){ + log check_archext_insn "$@" + feature="$1" + instr="$2" + # Check if the assembly is accepted in inline assembly. + check_inline_asm ${feature}_inline "\"$instr\"" + # We don't check if the instruction is supported out of the box by the + # external assembler (we don't try to set ${feature}_external) as we don't + # need to use these instructions in non-runtime detected codepaths. + + disable $feature + + enabled as_arch_directive && arch_directive=".arch $as_arch_level" || arch_directive="" + + # Test if the assembler supports the .arch_extension $feature directive. + arch_extension_directive=".arch_extension $feature" + test_as <>$TMPH +enabled aarch64 && + echo "#define AS_ARCH_LEVEL $as_arch_level" >>$TMPH + if enabled x86asm; then append config_files $TMPASM cat > $TMPASM <