public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Julian Waters <tanksherman27@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: [RFC][C++] Attribute gnu::extended
Date: Wed, 15 Nov 2023 10:59:33 +0800	[thread overview]
Message-ID: <CAP2b4GPjxBLNGBHO9MdhYfrLTSoosjDFTVzECHdx1c+ubkH64g@mail.gmail.com> (raw)

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

I propose a new attribute for C++, labelled gnu::extended. This attribute
is for asm declarations, and the attribute marks them as extended asm. This
attribute shall contain all of the features of existing extended asm, but
also have additional features, described below.

gnu::extended(OutputOperands, InputOperands, Clobbers, Labels, Attributes)

OutputOperands - Output Operands, in the exact same syntax as existing
extended asm
                              Example: [result] "r" (variable)
InputOperands    - Input Operands, in the same syntax as existing extended
asm.
                              Different from extended asm is the fact that
the Input Operands in the
                              extended attribute can take method calls as
proper inputs
                              Example: [parameter] "r" (method(2))
                              This will likely require some patching in the
assembly declaration
Clobbers              - String Literal containing clobbered registers, in
the same syntax as existing
                               extended asm, but each string literal is
separated by spaces rather than
                               commas
Labels                  - List of Goto Labels, in the same syntax as
existing extended asm
Attributes              - List of tokens indicating certain attributes this
asm declaration should have,
                                these are:

singleton:        The asm declaration is only emitted once in the method
body that it is in,
                        subsequent appearances of any asm declarations with
the singleton directive
                        specified are discarded
count "asm name": The asm declaration is only emitted once in the method
body that it is in,
                 subsequent appearances of any asm declarations with the
count directive will
                 simply update %[asm name] in the string literal template
of the very first instance to
                 the number of times the asm declaration has appeared in
the method, including the
                 first time it has appeared
stack:        Forces appearances of %= within the asm declaration to have
stack semantics, that
                  is, references to labels with %= will refer to the
innermost declaration, and each
                  subsequent reference to such labels will refer to the
previous declaration before the
                  innermost declaration, and so on.This is particularly
useful for using labels defined
                  across multiple asm declarations
volatile:      Functions the same as extended asm declared as asm volatile
("");
patch:        For input operands, the patch directive causes the operand
code to be patched into
                  the asm declaration directly above the line of asm code
that uses the operand,
                  rather than before the asm declaration itself, as is done
for existing extended asm

These are the list of features available for this new proposed attribute,
thoughts?

best regards,
Julian

                 reply	other threads:[~2023-11-15  3:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAP2b4GPjxBLNGBHO9MdhYfrLTSoosjDFTVzECHdx1c+ubkH64g@mail.gmail.com \
    --to=tanksherman27@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).