Description
Related to #74, where we could do this automatically in some places.
Like with avr-gcc, programmers should be able to explicitly opt-in to having some data automatically reside in flash.
This may not be strictly necessary depending on whether there is an actual need for marking progmem data explicitly if the compiler does it automatically mostly (as might be the case in #74).
Arbitrary example
It could be an attribute like this
#[space(progmem)]
pub static FOOBAR: &'static str = "hello world";
or any number different syntaxes; no thought has really been put into it yet AFAIK.
No changes needed to type system for address space specific references
We won't need to do anything special to the type system to support anything like references that are specific to an address space (i.e. an optional address space quantifier on references &'a [progmem] my_var
). If we simply add addrspace(1)
attributes to immutable static/constant variables, LLVM will constantly track the address space of all pointers to that variable, and so it will always use the correct memory instructions (i.e. RAM: ld
, ldd
, program mem: lpm
) whenever the pointers are dereferenced.