From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27431 invoked by alias); 24 Aug 2009 05:19:45 -0000 Received: (qmail 27422 invoked by uid 22791); 24 Aug 2009 05:19:44 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from rv-out-0708.google.com (HELO rv-out-0708.google.com) (209.85.198.241) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 24 Aug 2009 05:19:37 +0000 Received: by rv-out-0708.google.com with SMTP id c5so700648rvf.56 for ; Sun, 23 Aug 2009 22:19:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.141.44.18 with SMTP id w18mr2007640rvj.272.1251091175104; Sun, 23 Aug 2009 22:19:35 -0700 (PDT) In-Reply-To: <4A5E2616.1070308@redhat.com> References: <4A5E2616.1070308@redhat.com> From: Mohamed Shafi Date: Mon, 24 Aug 2009 13:41:00 -0000 Message-ID: Subject: Re: Function argument passing To: Richard Henderson Cc: GCC Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-08/txt/msg00431.txt.bz2 2009/7/16 Richard Henderson : > On 07/13/2009 07:35 AM, Mohamed Shafi wrote: >> >> So i made both TARGET_STRICT_ARGUMENT_NAMING and >> PRETEND_OUTGOING_VARARGS_NAMED to return false. Is this correct? > > Yes. > >> How to make the varargs argument to be promoted to 32bits when the >> normal argument don't require promotion as mentioned in point (1) ? > > There is no way at present. =A0You'll have to extend the promote_function= _args > hook to accept a "bool named" parameter. > >> 4. A long long return value is returned in R6 and R7, R6 containing >> the most significant =A0long word and R7 containing the least >> significant long word, regardless of the endianess mode. >> Solution: Used TARGET_RETURN_IN_MSB to return true when the mode is >> little endian > > I don't believe this is correct. =A0RETURN_IN_MSB is supposed to be handl= ing > the case where the data to be returned is smaller than the register in wh= ich > it is returned -- e.g. a 3 byte structure returned in a 32-bit register. = =A0I > believe you should be using... > >> 5. If the first argument is a long long , it is passed in R6 and R7, >> R6 containing the most significant long word and R7 containing the >> least significant long word, regardless of the endianess mode. >> For return value, i have done as mentioned in (4) but I am not sure >> how to control the argument passing so that R6 contains the msw and R7 >> contains lsw, regardless of the endianess mode. > > For both return values and arguments, we support a PARALLEL which allows = the > target to indicate where each piece of the value is located. =A0It's also= true > that the generated rtl is more complicated, so you'd want to avoid this > solution in big-endian mode, when it isn't needed. > > So here you would do > > if (WORDS_BIG_ENDIAN) > =A0return gen_rtx_REG (DImode, 6); > else > =A0{ > =A0 =A0rtx r6, r7, par; > > =A0 =A0r7 =3D gen_rtx_REG (SImode, 7); > =A0 =A0r7 =3D gen_rtx_EXPR_LIST (SImode, r7, GEN_INT (0)); > =A0 =A0r6 =3D gen_rtx_REG (SImode, 6); > =A0 =A0r6 =3D gen_rtx_EXPR_LIST (SImode, r6, GEN_INT (4)); > =A0 =A0par =3D gen_rtx_PARALLEL (DImode, gen_rtvec (2, r7, r6))); > =A0 =A0return par; > =A0} > > See the docs for FUNCTION_ARG for details. > I am getting the following error when i make a function call. (call_insn 18 17 19 3 1.c:29 (set (parallel:DI [ (expr_list:REG_UNUSED (reg:SI 7 d7) (const_int 0 [0x0])) (expr_list:REG_UNUSED (reg:SI 6 d6) (const_int 4 [0x4])) ]) (call:SI (mem:SI (symbol_ref:SI ("dd1") [flags 0x41] ) [0 S4 A8]) (const_int 8 [0x8]))) -1 (nil) (expr_list:REG_DEP_TRUE (use (reg:SI 7 d7)) (expr_list:REG_DEP_TRUE (use (reg:SI 6 d6)) (nil)))) How do i write a pattern for this? Another question is in LITTLE ENDIAN mode for the return value will the compiler know that values are actually stored the other way.. in big endian format? And generate the code accordingly for the rest of the program? Regards, Shafi