Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Some design notes
- Input address space 1 corresponds to __flash (ordinrary flash < 64KB), addrspace 2 -> __flash1 (extended program memory bank1, 64-128KB), ..., addrspace 6 -> __flash5 (extended program memory bank 5, 320KB-384KB). And all other addrspaces fall back to SRAM.
- For MCU with neither FeatureLPM nor FeatureELPM, all input address spaces fall back to SRAM, and no LPM/ELPM instruction will be generated.
- For MCU with only FeatureLPM but not FeatureELPM, all access to address space 2-6 fall back to ordinary program space (0-64KB), and only LPM will be generated, and no ELPM will be generated.
I wonder whether we should generate an error instead of falling back to other memory areas? That would be more consistent with avr-gcc and I think that would also be more correct.
llvm/test/CodeGen/AVR/sections.ll | ||
---|---|---|
32 | Why not check for what it should be, instead of what it should not be? Something like this (untested): ; CHECK8515: .section .data,"a" |
Actually an error will be reported by clang as in https://reviews.llvm.org/D115982, which is indeed consistent with avr-gcc.
And in current patch, a brief error will be reported too (though the location information needs to be filled by future patches).
Looks good to me! A few suggestions below (which aren't necessary, just ideas).
llvm/lib/Target/AVR/AVR.h | ||
---|---|---|
49 | Suggestion: you could also call this NumAddrSpaces because it contains the number of address spaces. | |
llvm/lib/Target/AVR/AVRTargetObjectFile.cpp | ||
45–62 | To be honest, I don't think this error checking is needed. If there is a section in address space 3 for example, but this is compiled for an atmega328p (which only supports address space 0 and 1), then the necessary ELPM instructions will already cause a compiler error. Having .progmem2.data that the program can't access doesn't harm. But it doesn't harm either, so feel free to leave it in. |
llvm/lib/Target/AVR/AVR.h | ||
---|---|---|
49 | I will change it to NumAddrSpaces while commiting. |
Suggestion: you could also call this NumAddrSpaces because it contains the number of address spaces.