Closed dylanmckay closed 3 years ago
I have made a patch to make flash as a builtin macro attribute((addrspace(1))), along with error message if flash is not used the same way as gcc expected.
Clang supports an address_space attribute i.e. you could just define:
This attribute is undocumented unfortunately.
Or if you need to support __flash as a keyword you can simply map to address_spaces early in the parser. This is what we do in OpenCL for global, local, constant, generic.
I don't think so, but there are parallels to this attribute in the OpenCL backend.
http://clang.llvm.org/docs/AttributeReference.html#opencl-address-spaces
Ok. Do we have an attribute to specify an address space?
The only thing required to place a variable into flash memory is to place it into address space '1'.
If we solely place the variable into a specific section, we won't be able to access it correctly because AVR (bring of the Harvard architecture) has separate instructions for accessing program memory, and accessing main memory.
Can't you simply define flash as attribute__((section("foo"))
assigned to @benshi001
Extended Description
Support for the '__flash' keyword will need to be added in order to place data into program memory.
The parser will need to be modified to understand the keyword and then place data into the progmem address space.
Examples of LLVM IR placing variables in the program memory can be found in 'test/CodeGen/AVR/progmem.ll' in LLVM.
http://www.atmel.com/webdoc/AVRLibcReferenceManual/porting_1iar_porting_flash.html