From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mnementh.co.uk (mail.mnementh.co.uk [IPv6:2a07:4580:b0d:4f0::c573]) by sourceware.org (Postfix) with ESMTPS id 7B7CA3858D28 for ; Sat, 18 Dec 2021 17:47:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7B7CA3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=mnementh.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=mnementh.co.uk Received: from 115.24.187.81.in-addr.arpa ([81.187.24.115] helo=[192.168.1.16]) by mnementh.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mydo1-0007nY-Vw for gcc-help@gcc.gnu.org; Sat, 18 Dec 2021 17:47:38 +0000 Message-ID: <5093a413-50c3-14d0-7708-44f95f8d3dce@mnementh.co.uk> Date: Sat, 18 Dec 2021 17:47:37 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Subject: Re: RFC: AVR interrupt handling issue Content-Language: en-GB To: gcc-help@gcc.gnu.org References: <58038025-f6b3-4f41-00bb-31e28467420e@blueice.be> From: Ian Molton In-Reply-To: <58038025-f6b3-4f41-00bb-31e28467420e@blueice.be> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00, DEAR_SOMETHING, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KHOP_HELO_FCRDNS, NICE_REPLY_A, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Dec 2021 17:47:40 -0000 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)