Asm labels?

2024-08-08 Thread Joe Finney
Hi, 

I am writing a Hare backend using libgccjit. Hare uses periods in symbol names 
for modules (eg fmt.println is the asm name for fmt::println). With gcc I can 
achieve this with 'asm ("fmt.println")' in the function declaration. Is there a 
convenient way to do it with libgccjit? If not, would a patch adding that 
feature be appreciated? 

:),
spxtr

Re: Self-referential union?

2025-02-02 Thread Joe Finney
Thanks for the response.

> On most reasonable computers, every data pointer has the same size and
> representation (so same size, same alignment, internally represented as some
> "word" eg 64 bits).
>
> So you could at least make the libgccjit calls to build the equivalent of 
>
> union u {
>int x;
>void* p;
> };
>
> and then use libgccjit casts to transform the p to a union u* pointer.
>
> Assuming your libgccjit context has some optimization enabled, the generated
> code should be the same.

I was either thinking of doing this, or else wrapping the union in a
struct, as in

struct s {
union {
int x;
struct s* p;
} u;
};

I think in both cases the generated code should optimize to the same? I
suspect that it would be a pretty substantial change to introduce a
gcc_jit_union type and gcc_jit_context_new_opaque_union, to match
structs, but not having those makes this feature significantly more
complicated to implement.


Self-referential union?

2025-02-02 Thread Joe Finney
Is it straightforward to make a union that references itself?

union u {
int x;
union u *p;
}

With structs, I can use gcc_jit_context_new_opaque_struct, but there
doesn't seem to be an equivalent for unions.