From patchwork Wed Aug 12 01:19:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Turner X-Patchwork-Id: 141157 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C6BF14B99F54 for ; Wed, 12 Aug 2026 01:25:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6BF14B99F54 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=Su4gqcNK X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yx1-xb134.google.com (mail-yx1-xb134.google.com [IPv6:2607:f8b0:4864:20::b134]) by sourceware.org (Postfix) with ESMTPS id 461B14BA2E03 for ; Wed, 12 Aug 2026 01:20:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 461B14BA2E03 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 461B14BA2E03 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b134 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786497623; cv=none; b=V4lDt6PvgNwzmXDNxNWk85iisNbwltMG2wAtvHfhfKdBSWjeoKJaJM1k+ObIa+tM5k5j835R24hEKGBxTmViYinFlY9MC73BYYkmGehputDp8xLO+sO/A2z1zT/M6MWpFmEaAEiEYdnCarEYwytecmB2AO1fDBzkLz53tb9NGJk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786497623; c=relaxed/simple; bh=URnqzF/ETJ67Ky9NPEA7RcHBl1xpSZCXAw7ulbnkIhA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=L7JX1iMEqgfDEBlJ5rhX5tZRozuLiCXsnwk00MVkezt/aupj3HVd7CFWzW7RVNo/llRuu6PgzdIPmbWayUCHBTfPZW7P9tf0KWcoIE/D7bnJlhYr0j+tHZTBAQkZ3aOFXZKlzkvqalhKw10MbLmSlt6aVBxinOxMFA02wx/0DE4= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=Su4gqcNK DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 461B14BA2E03 Received: by mail-yx1-xb134.google.com with SMTP id 956f58d0204a3-6680ae2031fso539750d50.3 for ; Tue, 11 Aug 2026 18:20:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786497622; x=1787102422; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=HteST/pVr5MvYnnhNEqW7VI5cjtl5Df5lTQfJQ+De4Y=; b=Su4gqcNKfvz+rvtp5NlH5IgSWrCzW2k/SRsXxKstk6Ar/si8JGtDS/2DlhbxFJRLpK ncUc/g4Flv5v/U9PN+zdgZlTPg6+3u5yBWXwXzubBNwnp2CaNDrZ4s8hBNaonT1fJecg Ttzd/xtIEQnm2RNPpCv4kGGx38+QYMl6S9uS21MqSMaNW8jqHpvDnibcGQiDdBy+q31w 0YZi13UB3T/WAemHinhLMN6udhGBXmn793llOrjuPJ4i9sVMo/FjNHhCoE80fFdUeVdT 3VOt+3+GfDqrzriR/9k4fck0FtGDh/nxK3rcaZTZIEnVNH4TY7lPB8NOO2S+3wVDrwZj kzVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786497622; x=1787102422; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=HteST/pVr5MvYnnhNEqW7VI5cjtl5Df5lTQfJQ+De4Y=; b=L7aoJ4V0XcsxazALrXWgq8ygL9ZGKv4JPwUt8t7YMM9ptT0TOcQUtE6xVpD5I0odsY dK2Yda/uGd3H1qDt/4x4ZQKRF780O68gdA0TaSQGgPPGLY3JtDEpzkYgLhfQrS9tUARE DTTma5p1G333lNtyetXXpu9AENTuPW9rYim9QcXCMFdJEY4oQsbsULx5IuGLThGfm/ec p5G+GmS41VfmAHnNvUNY4mbWFerlAp3AgcewzGj5A95g2PImZ+9GDXd4cLRs0DTXGt5E tXr4K9x8PniHiRj2i+1qkeENxlh5Ou8uKHFcoSXyZlgcUi7QzSv6WrwnmxoODXff3oV1 OHrg== X-Gm-Message-State: AOJu0YxZi5bzychuwmeyJiqT4vQ3/DaNFnj38upicB7oxnq8FshL01sm nWMKuQf/1hwttRrCSpW609TE0kkeDOVqTPjhEqU6P5YDfOjHG96kdqvHcV4K7e0SSEw= X-Gm-Gg: AR+sD13Qxrl6kDWu2au+BVDbWA5K9Qf2vkoyx6tVvpbcXWdJFObXj757LrnoN5oaGtO oxpxb76IPF2FK9Y14FPjrY3Xgg7nzQ5z1QIYI5Ym9pQOZyqoSAaCt0P/fm4kGK3cdO5UtWcfDOL WZklaqCweOIKTFVyEknjI1StK+l/x0+GpQ8SLYFBuaEZYCpciYAiixp9XDxdAbcAea80wLd/ceT kr3QUXelKajyJntYexaR56TD3OcEJnV3Q/rVbs5ynwgc72W1q1so0iIgBB+VfqSWHTmWz9k/1Jr qXY7EU5vtvAsYqn5tHSB9Fcczdfih4VGr5jJso/WZxti3jvMyatkWqXQEDpcAZaRMfS996P50Tv eATYuqj2KSy63c89PuaAEHFKmKFDZluT8jqpP/ulzuidiNSbWjXLWm308q7nQNvtL82nBaMiMrR eU4HDajO5lrNqLpwAnsRi5hGPVRfWVn40kqB5tBBPq+vF7r7uSAbeo7tJKPuQ= X-Received: by 2002:a53:d088:0:b0:668:9e51:5239 with SMTP id 956f58d0204a3-66b346fb2famr531017d50.44.1786497622621; Tue, 11 Aug 2026 18:20:22 -0700 (PDT) Received: from localhost ([2600:1702:7a90:6f9f:482:39fe:7891:c084]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-66b1ef5f935sm2087164d50.1.2026.08.11.18.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2026 18:20:21 -0700 (PDT) From: Matt Turner To: libc-alpha@sourceware.org Cc: Magnus Lindholm , Michael Cree Subject: [PATCH 11/20] alpha: add assembly mempcpy sharing the ev6 memcpy Date: Tue, 11 Aug 2026 21:19:48 -0400 Message-ID: <169c689ace6b5b034c5517a34d1b68dd517d867a.1786497497.git.mattst88@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Alpha had no assembly mempcpy and used the generic C. mempcpy differs from memcpy only in its return value (dest + n rather than dest), so build it from the ev6 memcpy with USE_AS_MEMPCPY, following the established convention used by other architectures. memcpy.S gains two small, behaviour-preserving changes so it can be reused: the entry computes the return value through USE_AS_MEMPCPY, and the misaligned path now derives its working dest pointer and alignment from the (still original) $16 instead of $0, freeing $0 to carry dest + n for mempcpy. The plain memcpy path is unchanged ($0 == $16 on entry). --- sysdeps/alpha/alphaev6/memcpy.S | 13 ++++++++++--- sysdeps/alpha/alphaev6/mempcpy.S | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 sysdeps/alpha/alphaev6/mempcpy.S diff --git ./sysdeps/alpha/alphaev6/memcpy.S ./sysdeps/alpha/alphaev6/memcpy.S index d5b72d4961..d11138420d 100644 --- ./sysdeps/alpha/alphaev6/memcpy.S +++ ./sysdeps/alpha/alphaev6/memcpy.S @@ -40,7 +40,11 @@ ENTRY(memcpy) .prologue 0 - mov $16, $0 # E : copy dest to return +#ifdef USE_AS_MEMPCPY + addq $16, $18, $0 # E : mempcpy returns dest + n +#else + mov $16, $0 # E : memcpy returns dest +#endif ble $18, $nomoredata # U : done with the copy? xor $16, $17, $1 # E : are source and dest alignments the same? and $1, 7, $1 # E : are they the same mod 8? @@ -289,8 +293,9 @@ $tail_bytes: nop # E : $misaligned: - mov $0, $4 # E : dest temp - and $0, 7, $1 # E : dest alignment mod8 + mov $16, $4 # E : dest temp (orig dest still in $16 here; + # $0 may hold dest+n for mempcpy) + and $16, 7, $1 # E : dest alignment mod8 beq $1, $dest_0mod8 # U : life doesn't totally suck nop @@ -367,4 +372,6 @@ $nomoredata: nop # E : END(memcpy) +#ifndef USE_AS_MEMPCPY libc_hidden_builtin_def (memcpy) +#endif diff --git ./sysdeps/alpha/alphaev6/mempcpy.S ./sysdeps/alpha/alphaev6/mempcpy.S new file mode 100644 index 0000000000..95385e4111 --- /dev/null +++ ./sysdeps/alpha/alphaev6/mempcpy.S @@ -0,0 +1,27 @@ +/* Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +/* mempcpy is the ev6 memcpy with USE_AS_MEMPCPY, which only changes the + return value (dest + n instead of dest) and the exported symbol. */ + +#define USE_AS_MEMPCPY +#define memcpy __mempcpy +#include + +libc_hidden_def (__mempcpy) +weak_alias (__mempcpy, mempcpy) +libc_hidden_builtin_def (mempcpy)