public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: MegaIng <trampchamp@hotmail.de>
To: Paul Koning <paulkoning@comcast.net>
Cc: gcc@gcc.gnu.org
Subject: Re: Porting to a custom ISA
Date: Tue, 15 Aug 2023 16:38:15 +0200	[thread overview]
Message-ID: <DU0PR03MB97298F2825C91B595EB4BB20A214A@DU0PR03MB9729.eurprd03.prod.outlook.com> (raw)
In-Reply-To: <D0E7DFB2-A980-4376-8DE4-6936A2714FC9@comcast.net>


On 2023-08-15 15:30, Paul Koning wrote:
>
>> On Aug 15, 2023, at 8:56 AM, MegaIng <trampchamp@hotmail.de> wrote:
>>
>>
>> Am 2023-08-15 um 14:48 schrieb Paul Koning:
>>>> On Aug 15, 2023, at 8:06 AM, Richard Biener via Gcc <gcc@gcc.gnu.org> wrote:
>>>>
>>>> On Tue, Aug 15, 2023 at 1:38 PM MegaIng via Gcc <gcc@gcc.gnu.org> wrote:
>>>>> ...
>>>>> And a bit more concrete with something I am having a hard time
>>>>> debugging. I am getting errors `invalid_void`, seemingly triggered by an
>>>>> absent of `gen_return` when compiling with anything higher than -O0. How
>>>>> do I correctly provide an implementation for that? Or disable it's
>>>>> usage? Our epilogue is non-trivial, and it doesn't look like the other
>>>>> backends use something like `(define_insn "return" ...)`.
>>>> Somebody else has to answer this.
>>> Again using pdp11 as an example -- it doesn't define any of the *return patterns either.  Instead it has a define_expand "epilogue" which calls a function to generate all the necessary elements, the last of which is a machine-specific pattern that will produce the final return instruction.
>>>
>>> This is using the RTL flavor of prologue/epilogue.  At one point in the past that target directly emitted the assembly code for those, which isn't the recommended approach.  I tried the RTL flavor and found it to be a better answer, and it certainly works for all the optimization levels.
>> Yeah, I am also using define_expand with prologue and epilogue, but for some reason gcc still calls gen_return from cfgrtl.cc line 1705 (might be out-of-sync with master) inside force_nonfallthru_and_redirect, and I don't really understand how to avoid that call. Do I need to define some extra target hooks or undefine some that I have?
> I can't think of anything, but I wrote that code a while ago.
>
> Does your epilog RTL end with an jump type RTL that will produce the actual function return instruction?  See pdp11.cc line 446 -- that's the final instruction of the epilog.  I made it an "emit_jump_insn" because that seemed the right thing to do, but it may be it's necessary for that to be a jump type RTL.

Yes, I also tried switching to `emit_jump_insn(ret_rtx)` instead, which 
a few backends use, but this doesn't make a difference. It seems to be 
that the error is unrelated to the epilogue. It fails during the "branch 
reordiering" pass, using code the docs attributed to a different pass 
from what I can tell.

during RTL pass: bbro
../test2.c: In function ‘display’:
../test2.c:18:1: internal compiler error: in invalid_void, at 
./insn-target-def.h:189
    18 | }
       | ^
0x77bf12 invalid_void
         ./insn-target-def.h:189
0x9d4a64 force_nonfallthru_and_redirect(edge_def*, basic_block_def*, 
rtx_def*)
         ../../gcc/cfgrtl.cc:1705
0x9d618c fixup_reorder_chain
         ../../gcc/cfgrtl.cc:4080
0x9d618c cfg_layout_finalize()
         ../../gcc/cfgrtl.cc:4575
0x14d8d50 execute
         ../../gcc/bb-reorder.cc:2682

I will try if I can find any difference in the settings between our 
setup and what pdp11 does.

MegaIng


  parent reply	other threads:[~2023-08-15 14:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-15 11:37 MegaIng
2023-08-15 12:06 ` Richard Biener
2023-08-15 12:48   ` Paul Koning
     [not found]     ` <DU0PR03MB972974FA63A93A6D67754428A214A@DU0PR03MB9729.eurprd03.prod.outlook.com>
     [not found]       ` <D0E7DFB2-A980-4376-8DE4-6936A2714FC9@comcast.net>
2023-08-15 14:38         ` MegaIng [this message]
2023-08-21 14:16   ` Georg-Johann Lay
2023-08-15 12:40 ` Paul Koning
2023-08-15 12:49   ` MegaIng
2023-08-15 13:01     ` Paul Koning
2023-08-15 13:26 ` Jeff Law

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=DU0PR03MB97298F2825C91B595EB4BB20A214A@DU0PR03MB9729.eurprd03.prod.outlook.com \
    --to=trampchamp@hotmail.de \
    --cc=gcc@gcc.gnu.org \
    --cc=paulkoning@comcast.net \
    /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).