Hello all!
I’m working on a simple feature to help me read/understand optimized asm code for my bare metal project. So far ([implementation of @asmLabel(.foo) -> asm volatile("foo:") · ssilnicki-dev/zig@287dcad · GitHub]) the code does simple thing: replacing @asmLabel(.foo) by asm volatile("foo:"), that emits a symbol in linked elf, so everything works as expected.
Now I want to add prefix and suffix to the symbol, namely prefix from function name and suffix from kinda builtin invocation counter to avoid symbol collisions if code is inlined in several places.
Can somebody give a clue where to grab surrounding function node from?
And/or where to establish invocation counter for suffix generation?
1 Like
it was not that difficult with prefix… [implement func's fqn as label prefix · ssilnicki-dev/zig@8afca3b · GitHub].
I anticipate the counter will be harder nut…
as expected, it took some time [implement invocation counter as label suffix · ssilnicki-dev/zig@2eb0dd4 · GitHub].
Need to add optional memory clobber…
seems to be done [cleanup: clobbers unnecessary, but runtime block seems useful · ssilnicki-dev/zig@b129ef1 · GitHub]. It has been interesting journey into zig’s internals ![]()

