public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Molton <gcc_help-ian@mnementh.co.uk>
To: gcc-help@gcc.gnu.org
Subject: Re: RFC: AVR interrupt handling issue
Date: Sat, 18 Dec 2021 17:47:37 +0000	[thread overview]
Message-ID: <5093a413-50c3-14d0-7708-44f95f8d3dce@mnementh.co.uk> (raw)
In-Reply-To: <58038025-f6b3-4f41-00bb-31e28467420e@blueice.be>

On 18/12/2021 16:31, Henri Cloetens wrote:
> Dear Sir,
> 
> To customize the stack/unstacking, you need to modify the code of
> your backend port.

I can see that - but thats a very invasive thing to change solely for
the use of my project.

I'd prefer to make a more generic change to the backend (I already found
the location), but I dont want to base an entire project off a change
that has no hope of ever being merged into gcc, as would be the case if
I pushed my entire custom IRQ handling into gcc. Theres just no way.

I want to get gcc to either emit modifiable code that I can then
reassemble, or get gcc to understand how to insert custom
"pro-prologues" and "epi-epilogues", as I would have thought such
changes would have more chance of being accepted into the gcc codebase.

> I mean, the emitting of the stack/unstacking for the normal case (no 
> interrupt, but function call), is in the backend part, NOT in the
> 'main' files, that are not intended to be modified. I would recommend
> you look there, and also in other backends, to find out how to do
> this.

I have, as I mentioned in my previous email.


I could modify gcc/config/avr/avr.c here (below), in order to generate
ISR prologues with some register saves omitted (the ones performed in my
own pro-prologue).

This would cause gcc to output trivially modifiable code, which could be
fed to a script that can insert the pro-prologue and epi-epilogue
assembler fragments.


/*  Output function prologue.  */

void
avr_expand_prologue (void)
{
  HARD_REG_SET set;
  HOST_WIDE_INT size;

  size = get_frame_size() + avr_outgoing_args_size();

  cfun->machine->stack_usage = 0;

  /* Prologue: naked.  */
  if (cfun->machine->is_naked)
    {
      return;
    }

/// MODIFY HERE
   if (no-save-isr-prologue)
   {
     // FIXME Remove registers my custom prologue saves from the set
     ...
   }
/// END MODIFICATION

  avr_regs_to_save (&set);

  if (cfun->machine->is_interrupt || cfun->machine->is_signal)

  reply	other threads:[~2021-12-18 17:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-18 16:00 Ian Molton
2021-12-18 16:31 ` Henri Cloetens
2021-12-18 17:47   ` Ian Molton [this message]
2021-12-18 18:07     ` Ian Molton
2021-12-20 21:06   ` gcc not generating dwarf prologue_end and epilogue_begin .loc directives (was: Re: RFC: AVR interrupt handling issue) Ian Molton

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=5093a413-50c3-14d0-7708-44f95f8d3dce@mnementh.co.uk \
    --to=gcc_help-ian@mnementh.co.uk \
    --cc=gcc-help@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).