public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
* [PATCH olang v1 0/1] deref operation returning value
@ 2024-10-17  2:48 Carlos Maniero
  2024-10-17  2:48 ` [PATCH olang v1 1/1] codegen: x64: deref returns pointer value Carlos Maniero
  0 siblings, 1 reply; 6+ messages in thread
From: Carlos Maniero @ 2024-10-17  2:48 UTC (permalink / raw)
  To: ~johnnyrichard/olang-devel; +Cc: Carlos Maniero

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.

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

 src/codegen_x86_64.c | 61 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 52 insertions(+), 9 deletions(-)

-- 
2.46.1


^ permalink raw reply	[flat|nested] 6+ messages in thread
* [PATCH olang v1 0/1] deref operation returning value
@ 2024-10-19 14:10 Carlos Maniero
  2024-10-19 14:14 ` Carlos Maniero
  0 siblings, 1 reply; 6+ messages in thread
From: Carlos Maniero @ 2024-10-19 14:10 UTC (permalink / raw)
  To: ~johnnyrichard/olang-devel; +Cc: Carlos Maniero

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


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

end of thread, other threads:[~2024-10-19 14:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-17  2:48 [PATCH olang v1 0/1] deref operation returning value Carlos Maniero
2024-10-17  2:48 ` [PATCH olang v1 1/1] codegen: x64: deref returns pointer value Carlos Maniero
2024-10-17  2:49   ` [olang/patches/.build.yml] build failed builds.sr.ht
2024-10-17  2:52     ` Carlos Maniero
2024-10-19 14:10 [PATCH olang v1 0/1] deref operation returning value Carlos Maniero
2024-10-19 14:14 ` Carlos Maniero

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