[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] [PATCH 0/4] stdatomic: code generators

From: Dmitry Selyutin
Subject: [Tinycc-devel] [PATCH 0/4] stdatomic: code generators
Date: Sun, 14 Feb 2021 22:52:03 +0300


I've prepared new patches aiming to introduce stdatomic support. Big
thanks to Michael Matz, who kindly and patiently explained some
details of code generation aspects.

The first patch introduces a set of routines which any platform which
wants to support atomics must implement. I don't quite like that
there's a lot of code duplication, but I haven't come up with a good
idea on how to avoid it (I've been thinking of some trick with weak
functions, though). I'm also not sure of ST_STATIC specifier; any tips
regarding its usage are highly appreciated. I added it as I saw it's
used in the code around; perhaps this is not required, so I can make
the routines weak by default?

The second patch adjusts tokenizer and generator appropriately, and
also fixes some minor issues. From now on, the count of tokens matches
count of atomic routines, and calls platform-specific code instead of
calling usual functions. I'd like to keep this approach in order to
make the code a bit more flexible. This is not for speed but, rather,
for being able to tune per-platform code in the future. I'm totally
open for the discussion.

The third patch extends x86_64 code generator to generate code from
the binary buffers, not byte-by-byte, as with g() routine. This
functionality will be used in the ultimate patch, if it gets accepted.

The last patch is the implementation for x86_64. This patch is likely
a controversial one. I tried to make the code somewhat generic to
different argument sizes, at the same time making it look like a
function call. It's also caused by the fact that I checked the code
generated by gcc for cases when usual stdatomic routines are wrapped
into simple routines. I'm pretty sure a lot there can be improved;
perhaps many of you will find the approach to be unorthodox to some
degree. This is just the idea; I'm totally open for discussion.

This is my first journey into tcc code generation; please, don't be
too severe. :-)

P.S. If the implementation is acceptable, we might re-use or even
share the code from x86_64 in i386. That said, I'd rather like seeing
other registers on i386 (e.g. eax/edx/ecx, not edi/esi/edx).

Dmitry Selyutin (4):
  stdatomic: atomic generator routines
  stdatomic: refactor atomic parser and generator
  x86_64: multibyte code emit
  stdatomic: x86_64 implementation

 arm-gen.c     |  55 +++++++++
 arm64-gen.c   |  55 +++++++++
 c67-gen.c     |  55 +++++++++
 i386-gen.c    |  55 +++++++++
 riscv64-gen.c |  56 +++++++++
 tcc.h         |  18 +++
 tccgen.c      | 137 +++++++++++----------
 tcctok.h      |  31 ++---
 x86_64-gen.c  | 323 ++++++++++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 704 insertions(+), 81 deletions(-)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]