From patchwork Mon Sep 12 12:02:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 1163 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp1845601wrt; Mon, 12 Sep 2022 05:03:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR7DPr23ysABp8LKh1QUnrtSPRx9rsWAFtdZQtIC/5U3Bra+HdCNyehklABbjB7MqS3Yk2RZ X-Received: by 2002:aa7:d341:0:b0:44e:67f1:5a2d with SMTP id m1-20020aa7d341000000b0044e67f15a2dmr22658117edr.175.1662984222288; Mon, 12 Sep 2022 05:03:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662984222; cv=none; d=google.com; s=arc-20160816; b=pbpHn8ApBVmv2RIYwLpT5X5VCJmA3VxDrhnUzf9MZeTyXFepMA8xPSqH9ZX0oluT2q r8FC8dcW+CmEVe09qmNuKkwvzl8FQdmbxtj+PueZ2Mm+uMrUnIvms9nNTw1PeB8Zd/YY gPOaUaIlkruItSj73jxY0At2gqKX6acrBuVM9Tz6AuEWVXmWmcfzHkp+ibqYrerYEeVm B0UKPyfib7uWZTfjhJS1cHuVn+RU0lUozFu9q6+UZ6i3BfCXRY3XyggXbzUnwxmFw9o7 5ZT7L79XA9ETx2Qf85B3+myvarpSY/uovt+jLZoLXKPzcuAIvwIk4Z5rwuZv8Ll7Ic5m fhaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=q+fIEepiqXBLa0LvdP9Jx7ywi7fnFsKEKzQGjUfRnRI=; b=Gw+cVbJqX15j9hvTyD0QZyOXvGL2nbqQ/MTxEEkg6dvisF+F/PgJTOKFxJEdbKB8Sh koi4oOEclWpqrHrhuo+VffCiS67on0UV9EHeXPbm7MTgRIdThPAa3AqNgjv7UvtppdQ+ llS7to1o9bIdZxerp8mltnl4mGUjAWOk9vlJKwNT2KcUCadATY9nvQAoj4lBr5GKxItU RKpKT8W3677FvpY4jFV7yzD1PR9pSRwx0RIQKswfj3j1t/8jNAReoM8AbfkAXCeR2v2J gYriZD5fw9c0f88a/sRxP9KDShrDbNbVwScyLdcVP0p5z0ezAYPkNdLV6q0CfOyMqJeC WnNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=m5WUN30h; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id di16-20020a170906731000b006feb76dbd51si7497560ejc.289.2022.09.12.05.03.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 05:03:42 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=m5WUN30h; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 36F5F385694E for ; Mon, 12 Sep 2022 12:03:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 36F5F385694E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662984221; bh=q+fIEepiqXBLa0LvdP9Jx7ywi7fnFsKEKzQGjUfRnRI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=m5WUN30hXzaK/O6Wvg3wyD9ITNp3w6aTIYWSpIkxJpfQTOiRLGhOQb2u8evPCmyA0 H37uE4pzilmSJ0LzY442ENZ0mVo/nuH6n82REqFZ25W/jgrBvn5OuZZeQSR43uDQrt XIQ0iejds87oCKiVEVbYLHwyIxZzS6Q6MNeHck8M= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id E90893850400 for ; Mon, 12 Sep 2022 12:02:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E90893850400 Received: by mail-pf1-x429.google.com with SMTP id b75so3150515pfb.7 for ; Mon, 12 Sep 2022 05:02:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=q+fIEepiqXBLa0LvdP9Jx7ywi7fnFsKEKzQGjUfRnRI=; b=xo0a8IferBeivfasnwEwa7HByeePxNnCdMaQg5o1DWJPexe2EnFrWgOC++G7iJKRd8 xNpGpf9cvtuMLc/AJNiQLA8exArCSn1HGpJkAapiHOCY8n+E5X/fD8ZJn3Ab2E4aXrkY AoH3VatuQvE5wFswtlrhDrUtOlYxOkB9wwhbZn7OK5BdzQolkvF0iGT8eHrp9zHttdfB CT5fVAwjXPs4zMMOSSGkM7wb6H975Tl+aQt2tlHj8vywkTnb68nwmf4SUmnvaQevAHpA /HRBbw1hoe2nsSIoJ00NUrGvPD9ckvSq/j/d0CnqNbHFvi0CWWRqQA4i8e7IGwFhiMrE s8Hw== X-Gm-Message-State: ACgBeo10Ipy+QI5Z2FiZsMAp/F6t+qc/1/O6vcnmd7KFv/FHi5yhykm8 4/w8DEuLCxmfwd01jlP2Y6QD8q9qt5iKXQ== X-Received: by 2002:a05:6a00:1249:b0:543:aa0a:9c0a with SMTP id u9-20020a056a00124900b00543aa0a9c0amr4837874pfi.2.1662984170223; Mon, 12 Sep 2022 05:02:50 -0700 (PDT) Received: from octofox.metropolis (c-24-130-93-68.hsd1.ca.comcast.net. [24.130.93.68]) by smtp.gmail.com with ESMTPSA id z14-20020aa79e4e000000b00537eb0084f9sm5390131pfq.83.2022.09.12.05.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 05:02:49 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [COMMITTED] xtensa: gcc: fix builtin_apply return value Date: Mon, 12 Sep 2022 05:02:39 -0700 Message-Id: <20220912120239.1281184-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, GIT_PATCH_0, HK_RANDOM_ENVFROM, HK_RANDOM_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Max Filippov via Gcc-patches From: Max Filippov Reply-To: Max Filippov Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743765343916663023?= X-GMAIL-MSGID: =?utf-8?q?1743765343916663023?= xtensa may use up to 4 registers to return a value from a function, but recognition of only one register in the xtensa_function_value_regno_p and missing untyped_call pattern result in that only one register is saved by the __builtin_apply and returned by the __builtin_apply_return. gcc/ * config/xtensa/xtensa.cc (xtensa_function_value_regno_p): Recognize all 4 return registers. * config/xtensa/xtensa.h (GP_RETURN_REG_COUNT): New definition. * config/xtensa/xtensa.md (untyped_call): New pattern. --- gcc/config/xtensa/xtensa.cc | 2 +- gcc/config/xtensa/xtensa.h | 1 + gcc/config/xtensa/xtensa.md | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index ac52c015a94c..f1b3331ea558 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -4472,7 +4472,7 @@ xtensa_libcall_value (machine_mode mode, const_rtx fun ATTRIBUTE_UNUSED) static bool xtensa_function_value_regno_p (const unsigned int regno) { - return (regno == GP_RETURN); + return (regno >= GP_RETURN && regno < GP_RETURN + GP_RETURN_REG_COUNT); } /* The static chain is passed in memory. Provide rtx giving 'mem' diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h index 0f3006d7af8f..16e3d55e8963 100644 --- a/gcc/config/xtensa/xtensa.h +++ b/gcc/config/xtensa/xtensa.h @@ -488,6 +488,7 @@ enum reg_class point, and values of coprocessor and user-defined modes. */ #define GP_RETURN (GP_REG_FIRST + 2 + WINDOW_SIZE) #define GP_OUTGOING_RETURN (GP_REG_FIRST + 2) +#define GP_RETURN_REG_COUNT 4 /* Symbolic macros for the first/last argument registers. */ #define GP_ARG_FIRST (GP_REG_FIRST + 2) diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index f722ea562891..608110c20bcb 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -2305,6 +2305,27 @@ (set_attr "mode" "none") (set_attr "length" "3")]) +(define_expand "untyped_call" + [(parallel [(call (match_operand 0 "") + (const_int 0)) + (match_operand 1 "") + (match_operand 2 "")])] + "" +{ + int i; + + emit_call_insn (gen_call (operands[0], const0_rtx)); + + for (i = 0; i < XVECLEN (operands[2], 0); i++) + { + rtx set = XVECEXP (operands[2], 0, i); + emit_move_insn (SET_DEST (set), SET_SRC (set)); + } + + emit_insn (gen_blockage ()); + DONE; +}) + (define_insn "entry" [(set (reg:SI A1_REG) (unspec_volatile:SI [(match_operand:SI 0 "const_int_operand" "i")]