From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1880) id 0126C3857004; Mon, 12 Sep 2022 12:01:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0126C3857004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662984090; bh=+k6NHMxFLFy9yKapwwGClm8q429J0rQHc+K8d56BXpo=; h=From:To:Subject:Date:From; b=VoesjwARQdPCdw8eq/2jMinmiIt3JZfuT/YWThBqk6cPWbzHxiNST2DUZBVhFt7mU ROzJldzmEm5cuefnNIIfiOc7VNksRsU/kiQ9CoFyEtR7Id1ujkIrAkCg54+eTrbzbp z6vRbp3QHSUvV0xk840KsOQH6c2CLYHT5S2qban4= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Max Filippov To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2623] xtensa: gcc: fix builtin_apply return value X-Act-Checkin: gcc X-Git-Author: Max Filippov X-Git-Refname: refs/heads/master X-Git-Oldrev: c092d894265f3db590585804c30c1ae3cb7b3773 X-Git-Newrev: 71cd6a0430ca2a2c44e3cf4cc9f3c96d3aef1ab7 Message-Id: <20220912120130.0126C3857004@sourceware.org> Date: Mon, 12 Sep 2022 12:01:30 +0000 (GMT) List-Id: https://gcc.gnu.org/g:71cd6a0430ca2a2c44e3cf4cc9f3c96d3aef1ab7 commit r13-2623-g71cd6a0430ca2a2c44e3cf4cc9f3c96d3aef1ab7 Author: Max Filippov Date: Sat Sep 10 17:31:07 2022 -0700 xtensa: gcc: fix builtin_apply return value 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. Diff: --- 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 ac52c015a94..f1b3331ea55 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 0f3006d7af8..16e3d55e896 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 f722ea56289..608110c20bc 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")]