public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: discuss@x86-64.org, GCC <gcc@gcc.gnu.org>,
	 	"Girkar, Milind" <milind.girkar@intel.com>,
	 	"Dmitriev, Serguei N" <serguei.n.dmitriev@intel.com>
Subject: RFC: Extend x86-64 psABI for 256bit AVX register
Date: Thu, 05 Jun 2008 14:31:00 -0000	[thread overview]
Message-ID: <6dc9ffc80806050731s77b49d63id048d142d76560c9@mail.gmail.com> (raw)

Hi,

x86-64 psABI defines

typedef struct
{
  unsigned int gp_offset;
  unsigned int fp_offset;
  void *overflow_arg_area;
  void *reg_save_area;
} va_list[1];

for variable argument list. "va_list" is used to access variable argument
list:

void
bar (const char *format, va_list ap)
{
  if (va_arg (ap, int) != 0)
    abort ();
}

void
foo(char *fmt, ...)
{
  va_list ap;
  va_start (fmt, ap);
  bar (fmt, ap);
  va_end (ap);
}

foo and bar may be compiled with different compilers. We have to keep
the current layout for va_list so that we can mix va_list codes compiled
with AVX and non-AVX compilers. We need to extend the variable argument
handling in the x86-64 psABI to support passing __m256/__m256d/__m256i
on the variable argument list. We propose 2 ways to extend the register
save area to add 256bit AVX registers support:

1. Extend the register save area to put upper 128bit at the end.
  Pros:
    Aligned access.
    Save stack space if 256bit registers are used.
  Cons
    Split access. Require more split access beyond 256bit.

2. Extend the register save area to put full 265bit YMMs at the end.
The first DWORD after the register save area has the offset of
the extended array for YMM registers. The next DWORD has the
element size of the extended array. Unaligned access will be used.
  Pros:
    No split access.
    Easily extendable beyond 256bit.
    Limited unaligned access penalty if stack is aligned at 32byte.
  Cons:
    May require store both the lower 128bit and full 256bit register
    content. We may avoid saving the lower 128bit if correct type
    is required when accessing variable argument list, similar to int
    vs. double.
    Waste 272 byte on stack when 256bit registers are used.
    Unaligned load and store.

We should agree on one approach to ensure compatibility between
different compilers.

Personally, I prefer #2 for its simplicity. Does anyone else have a
preference?

Thanks.

-- 
H.J.

             reply	other threads:[~2008-06-05 14:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-05 14:31 H.J. Lu [this message]
2008-06-05 14:49 ` Richard Guenther
2008-06-05 15:52   ` H.J. Lu
2008-06-05 15:15 ` Jan Hubicka
2008-06-05 16:14   ` H.J. Lu
2008-06-06  8:29     ` Jan Hubicka
2008-06-06 13:50       ` H.J. Lu
2008-06-06 14:28         ` H.J. Lu
2008-06-06 14:31           ` Richard Guenther
2008-06-06 14:41             ` H.J. Lu
2008-06-06 14:44               ` Richard Guenther
2008-06-09 14:41           ` Jan Hubicka
2008-06-10 11:24             ` Jakub Jelinek
2008-06-10 11:32               ` Jan Hubicka
2008-06-10 13:48                 ` H.J. Lu
2008-06-10 14:50                   ` Jan Hubicka
2008-06-10 14:57                     ` Jakub Jelinek
2008-06-10 15:41                       ` H.J. Lu
2008-06-10 15:49                         ` Jan Hubicka
2008-06-10 16:18                           ` H.J. Lu
2008-06-11 14:49                           ` H.J. Lu
2008-06-15 22:37                             ` Jakub Jelinek
2008-06-16  1:49                               ` Jan Hubicka
2008-06-18 23:16                                 ` H.J. Lu
2008-06-06 15:01 ` Jakub Jelinek

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=6dc9ffc80806050731s77b49d63id048d142d76560c9@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=discuss@x86-64.org \
    --cc=gcc@gcc.gnu.org \
    --cc=milind.girkar@intel.com \
    --cc=serguei.n.dmitriev@intel.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).