public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
From: Carlos Maniero <carlos@maniero.me>
To: ~johnnyrichard/olang-devel@lists.sr.ht
Cc: Carlos Maniero <carlos@maniero.me>
Subject: [PATCH olang v1 0/1] deref operation returning value
Date: Sat, 19 Oct 2024 14:10:05 +0000 (UTC)	[thread overview]
Message-ID: <20241019141000.185147-1-carlos@maniero.me> (raw)

We had discussed over IRC about may adding some extra information on the
deref operation to support this feature, but there are two reasons why I
opted to keep this on code gen:

1) Modifying the AST would require changing the unary data structure
from a struct to an union, but no other operator would be beneficed by
this since only the deref needs some extra information.

2) The assign operation is required to identify if its LHS is a deref,
once the mov instruction will differ from a simple ref: The simple ref
will mov the expression result to a RBP offset and the deref will mov
the expression result to the pointer location.

Also, once we have the IR, this logic could easily fit the layer that
will build the IR.

V2:
- Fix code style
- Allows multiple pointer dereference

Carlos Maniero (1):
  codegen: x64: deref returns pointer value

 src/codegen_x86_64.c                 | 88 +++++++++++++++++++++++++---
 src/parser.c                         | 11 ++--
 tests/olc/0038_pointers_deref.ol     | 24 ++++++++
 tests/olc/0039_pointer_of_pointer.ol | 55 +++++++++++++++++
 4 files changed, 164 insertions(+), 14 deletions(-)
 create mode 100644 tests/olc/0038_pointers_deref.ol
 create mode 100644 tests/olc/0039_pointer_of_pointer.ol


base-commit: 2dbf9a9896e5778535bd3dc1d5069a762d3b94fa
-- 
2.46.1


             reply	other threads:[~2024-10-19 14:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-19 14:10 Carlos Maniero [this message]
2024-10-19 14:10 ` [PATCH olang v2 1/1] codegen: x64: deref returns pointer value Carlos Maniero
2024-10-19 14:11   ` [olang/patches/.build.yml] build success builds.sr.ht
2024-10-19 14:14 ` [PATCH olang v1 0/1] deref operation returning value Carlos Maniero
  -- strict thread matches above, loose matches on Subject: below --
2024-10-17  2:48 Carlos Maniero

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=20241019141000.185147-1-carlos@maniero.me \
    --to=carlos@maniero.me \
    --cc=~johnnyrichard/olang-devel@lists.sr.ht \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.johnnyrichard.com/olang.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox