could I use `global/static variable` in function?
while writing mir-text code...
Yes, you can have bss or data inside the function (between func and endfunc).
Any label (including for bss and data) has module scope. That is why it is possible to use data/bss in func. The actual placement of data/bss relative to function address is undefined but they are not placed inside the function insns.
Yes, you can have bss or data inside the function (between func and endfunc).
Any label (including for bss and data) has module scope. That is why it is possible to use data/bss in func. The actual placement of data/bss relative to function address is undefined but they are not placed inside the function insns.
any example for this? thanks. maybe an existed variable in c/c++ or an mir global varaible
any example for this? thanks.
Here is a MIR textual code storing a value into global var which is declared in function:
test: func
local i64:addr
global: bss 8
extern global
mov addr, var
mov (addr), 42 # store 42 to var
endfunc