public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Yulia Koval <vaalfreja@gmail.com>
To: Jeff Law <law@redhat.com>
Cc: "Koval, Julia" <julia.koval@intel.com>,
		"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	"Lu, Hongjiu" <hongjiu.lu@intel.com>,
		"ubizjak@gmail.com" <ubizjak@gmail.com>,
	"Zamyatin, Igor" <igor.zamyatin@intel.com>
Subject: Re: [PATCH] x86 interrupt attribute patch [1/2]
Date: Thu, 28 Apr 2016 18:22:00 -0000	[thread overview]
Message-ID: <CAE0nxxg+ohuFOxbSdxewqCctG_k_4t5RO2gHgTjKccatQprQuw@mail.gmail.com> (raw)
In-Reply-To: <739bb353-4440-f6da-400b-c3f9464ff2e9@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 4843 bytes --]

Thank you,
Here is the repost.

Update TARGET_FUNCTION_INCOMING_ARG documentation

    On x86, interrupt handlers are only called by processors which push
    interrupt data onto stack at the address where the normal return address
    is.  Since interrupt handlers must access interrupt data via pointers so
    that they can update interrupt data, the pointer argument is passed as
    "argument pointer - word".

    TARGET_FUNCTION_INCOMING_ARG defines how callee sees its argument.
    Normally it returns REG, NULL, or CONST_INT.  This patch adds arbitrary
    address computation based on hard register, which can be forced into a
    register, to the list.

    When copying an incoming argument onto stack, assign_parm_setup_stack
    has:

    if (argument in memory)
      copy argument in memory to stack
    else
      move argument to stack

    Since an arbitrary address computation may be passed as an argument, we
    change it to:

    if (argument in memory)
      copy argument in memory to stack
    else
      {
        if (argument isn't in register)
          force argument into a register
        move argument to stack
      }

        * function.c (assign_parm_setup_stack): Force source into a
        register if needed.
        * target.def (function_incoming_arg): Update documentation to
        allow arbitrary address computation based on hard register.
        * doc/tm.texi: Regenerated.


Br,
Yulia

On Thu, Apr 28, 2016 at 7:32 PM, Jeff Law <law@redhat.com> wrote:
> On 04/20/2016 07:48 AM, Koval, Julia wrote:
>>
>> Sorry, here is the right patch.
>>
>> -----Original Message-----
>> From: Koval, Julia
>> Sent: Wednesday, April 20, 2016 4:42 PM
>> To: 'gcc-patches@gcc.gnu.org' <gcc-patches@gcc.gnu.org>
>> Cc: Lu, Hongjiu <hongjiu.lu@intel.com>; 'vaalfreja@gmail.com'
>> <vaalfreja@gmail.com>; 'ubizjak@gmail.com' <ubizjak@gmail.com>;
>> 'law@redhat.com' <law@redhat.com>; Zamyatin, Igor <igor.zamyatin@intel.com>
>> Subject: [PATCH] x86 interrupt attribute patch [1/2]
>>
>> Hi,
>> Here is the new version of interrupt attribute patch.
>> Bootstraped/regtested for Linux/x86_64. Ok for trunk?
>>
>> Update TARGET_FUNCTION_INCOMING_ARG documentation
>>
>>     On x86, interrupt handlers are only called by processors which push
>>     interrupt data onto stack at the address where the normal return
>> address
>>     is.  Since interrupt handlers must access interrupt data via pointers
>> so
>>     that they can update interrupt data, the pointer argument is passed as
>>     "argument pointer - word".
>>
>>     TARGET_FUNCTION_INCOMING_ARG defines how callee sees its argument.
>>     Normally it returns REG, NULL, or CONST_INT.  This patch adds
>> arbitrary
>>     address computation based on hard register, which can be forced into a
>>     register, to the list.
>>
>>     When copying an incoming argument onto stack, assign_parm_setup_stack
>>     has:
>>
>>     if (argument in memory)
>>       copy argument in memory to stack
>>     else
>>       move argument to stack
>>
>>     Since an arbitrary address computation may be passed as an argument,
>> we
>>     change it to:
>>
>>     if (argument in memory)
>>       copy argument in memory to stack
>>     else
>>       {
>>         if (argument isn't in register)
>>           force argument into a register
>>         move argument to stack
>>       }
>>
>>         * function.c (assign_parm_setup_stack): Force source into a
>>         register if needed.
>>         * target.def (function_incoming_arg): Update documentation to
>>         allow arbitrary address computation based on hard register.
>>         * doc/tm.texi: Regenerated.
>>
> So I think the function.c changes are fine.  But I think we need to do a
> tiny bit more on the documentation side before we can install the change.
>
> While I think a rewrite of the whole argument passing section would be
> advisable, that may be a bit much to expect.  So let's try to just cleanup
> FUNCTION_INCOMING_ARG.
>
> FUNCTION_INCOMING_ARG has text like "Define this hook if the target machine
> has register windows ..."
>
> I'd change that text to be something like
>
> "Define this hook if the caller and callee on the target have different
> views of where arguments are passed.  Also define this hook if there are
> functions that are never directly called, but are invoked by the hardware
> and which have nonstandard calling conventions."
>
> Or something along those lines.
>
>
> At one time I thought we'd want to specify how the cumulative args structure
> would or would not be updated for these special arguments. But after further
> reflection, I think that can be a target dependent implementation detail.
>
>
>
> I think with that one documentation update this will be OK, but I would like
> you to repost it so I can look at it one final time.
>
> jeff
>
>

[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 3796 bytes --]

commit 0eb8b47ef6635d44c9c90bc87c3991dcc33d2e92
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Feb 5 04:43:15 2016 -0800

    Update TARGET_FUNCTION_INCOMING_ARG documentation
    
    On x86, interrupt handlers are only called by processors which push
    interrupt data onto stack at the address where the normal return address
    is.  Since interrupt handlers must access interrupt data via pointers so
    that they can update interrupt data, the pointer argument is passed as
    "argument pointer - word".
    
    TARGET_FUNCTION_INCOMING_ARG defines how callee sees its argument.
    Normally it returns REG, NULL, or CONST_INT.  This patch adds arbitrary
    address computation based on hard register, which can be forced into a
    register, to the list.
    
    When copying an incoming argument onto stack, assign_parm_setup_stack
    has:
    
    if (argument in memory)
      copy argument in memory to stack
    else
      move argument to stack
    
    Since an arbitrary address computation may be passed as an argument, we
    change it to:
    
    if (argument in memory)
      copy argument in memory to stack
    else
      {
        if (argument isn't in register)
          force argument into a register
        move argument to stack
      }
    
    	* function.c (assign_parm_setup_stack): Force source into a
    	register if needed.
    	* target.def (function_incoming_arg): Update documentation to
    	allow arbitrary address computation based on hard register.
    	* doc/tm.texi: Regenerated.

diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 745910f..826f8fb 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -3949,6 +3949,10 @@ which the caller passes the value, and
 fashion to tell the function being called where the arguments will
 arrive.
 
+@code{TARGET_FUNCTION_INCOMING_ARG} can also return arbitrary address
+computation using hard register, which can be forced into a register,
+so that it can be used to pass special arguments.
+
 If @code{TARGET_FUNCTION_INCOMING_ARG} is not defined,
 @code{TARGET_FUNCTION_ARG} serves both purposes.
 @end deftypefn
diff --git a/gcc/function.c b/gcc/function.c
index 1ac8e26..c42e865 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -3466,7 +3466,11 @@ assign_parm_setup_stack (struct assign_parm_data_all *all, tree parm,
 			   BLOCK_OP_NORMAL);
 	}
       else
-	emit_move_insn (dest, src);
+	{
+	  if (!REG_P (src))
+	    src = force_reg (GET_MODE (src), src);
+	  emit_move_insn (dest, src);
+	}
     }
 
   if (to_conversion)
diff --git a/gcc/target.def b/gcc/target.def
index 20f2b32..0725214 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -4468,8 +4468,10 @@ a register.",
        bool named),
  default_function_arg)
 
-/* Likewise, but for machines with register windows.  Return the
-   location where the argument will appear to the callee.  */
+/* Define this hook if the caller and callee on the target have different
+   views of where arguments are passed.  Also define this hook if there are
+   functions that are never directly called, but are invoked by the hardware
+   and which have nonstandard calling conventions.  */
 DEFHOOK
 (function_incoming_arg,
  "Define this hook if the target machine has ``register windows'', so\n\
@@ -4483,6 +4485,10 @@ which the caller passes the value, and\n\
 fashion to tell the function being called where the arguments will\n\
 arrive.\n\
 \n\
+@code{TARGET_FUNCTION_INCOMING_ARG} can also return arbitrary address\n\
+computation using hard register, which can be forced into a register,\n\
+so that it can be used to pass special arguments.\n\
+\n\
 If @code{TARGET_FUNCTION_INCOMING_ARG} is not defined,\n\
 @code{TARGET_FUNCTION_ARG} serves both purposes.",
  rtx, (cumulative_args_t ca, machine_mode mode, const_tree type,

  reply	other threads:[~2016-04-28 18:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-20 13:48 Koval, Julia
2016-04-28 16:32 ` Jeff Law
2016-04-28 18:22   ` Yulia Koval [this message]
2016-04-28 19:32     ` H.J. Lu
2016-04-29  4:09       ` Yulia Koval
2016-05-17  7:53         ` Koval, Julia
2016-06-01 16:43         ` Jeff Law
  -- strict thread matches above, loose matches on Subject: below --
2016-04-20 13:42 Koval, Julia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAE0nxxg+ohuFOxbSdxewqCctG_k_4t5RO2gHgTjKccatQprQuw@mail.gmail.com \
    --to=vaalfreja@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hongjiu.lu@intel.com \
    --cc=igor.zamyatin@intel.com \
    --cc=julia.koval@intel.com \
    --cc=law@redhat.com \
    --cc=ubizjak@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).