Vexu / arocc

A C compiler written in Zig.
http://aro.vexu.eu/
MIT License
1.15k stars 56 forks source link

Store values for initializer nodes? #783

Open ehaas opened 1 month ago

ehaas commented 1 month ago

I started working on an assembly backend and one thing I ran into is needing the value of initializer nodes that are the result of an expression. For example given the following (x is global):

int x = 2 + 2;

I want to be able to get the initializer value of 4 without having to recompute it in the backend. As things currently work I think I'd have to recompute it, unless I'm missing something.

Vexu commented 1 month ago

I don't remember any reason not to store the value and would have expected it to already be done. At least changing it is easy.