public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Multiple return values and dynamic typing in a new frontend
@ 2023-04-13 10:46 Juhani Viheräkoski
  2023-04-13 11:34 ` Segher Boessenkool
  0 siblings, 1 reply; 3+ messages in thread
From: Juhani Viheräkoski @ 2023-04-13 10:46 UTC (permalink / raw)
  To: gcc-help

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

I recently got an idea of a new programming language and I'm thinking of
implementing it as a gcc frontend. My proposed language has multiple return
values and a possibility to use tagged dynamically typed variables, like in
Lisp. There will also be a possibility to use static typing for variables
that will only ever have a single type during their lifetime. I've read gcc
internals but haven't written any code yet. I plan to use a private
representation for parsing and semantic analysis, then convert to GIMPLE.
Is it preferred to convert multiple return values to extra reference
parameters before converting to GIMPLE or should I rather expand the
middle-end to support them properly? I'm also worried that dynamically
typed variables won't get optimized as they must be implemented as a
language-specific opaque type. But I can live with this and implement
optimization for them later. That optimization would delete unnecessary
type checks if it could prove them unnecessary.

Thank you for your insights :)

BR
Juhani Viheräkoski

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Multiple return values and dynamic typing in a new frontend
  2023-04-13 10:46 Multiple return values and dynamic typing in a new frontend Juhani Viheräkoski
@ 2023-04-13 11:34 ` Segher Boessenkool
  2023-04-13 14:16   ` Juhani Viheräkoski
  0 siblings, 1 reply; 3+ messages in thread
From: Segher Boessenkool @ 2023-04-13 11:34 UTC (permalink / raw)
  To: Juhani Viheräkoski; +Cc: gcc-help

Hi!

On Thu, Apr 13, 2023 at 01:46:06PM +0300, Juhani Viheräkoski via Gcc-help wrote:
> Is it preferred to convert multiple return values to extra reference
> parameters before converting to GIMPLE or should I rather expand the
> middle-end to support them properly?

You can just use a struct type for the return value?  That doesn't force
the backend to put things in memory, it can still have the return value
in multiple registers (depending on ABI).


Segher

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Multiple return values and dynamic typing in a new frontend
  2023-04-13 11:34 ` Segher Boessenkool
@ 2023-04-13 14:16   ` Juhani Viheräkoski
  0 siblings, 0 replies; 3+ messages in thread
From: Juhani Viheräkoski @ 2023-04-13 14:16 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: gcc-help

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

Thank you! This sounds like a good idea and more or less obvious, but I
didn't think about this option before.

to 13. huhtik. 2023 klo 14.36 Segher Boessenkool <segher@kernel.crashing.org>
kirjoitti:

> Hi!
>
> On Thu, Apr 13, 2023 at 01:46:06PM +0300, Juhani Viheräkoski via Gcc-help
> wrote:
> > Is it preferred to convert multiple return values to extra reference
> > parameters before converting to GIMPLE or should I rather expand the
> > middle-end to support them properly?
>
> You can just use a struct type for the return value?  That doesn't force
> the backend to put things in memory, it can still have the return value
> in multiple registers (depending on ABI).
>
>
> Segher
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-13 14:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13 10:46 Multiple return values and dynamic typing in a new frontend Juhani Viheräkoski
2023-04-13 11:34 ` Segher Boessenkool
2023-04-13 14:16   ` Juhani Viheräkoski

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).