[PATCH] D115982: [clang][AVR] Implement '__flashN' for variables on different flash banks
Ben Shi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 4 07:03:26 PST 2022
benshi001 added a comment.
In D115982#3218124 <https://reviews.llvm.org/D115982#3218124>, @aykevl wrote:
> avr-gcc checks whether the device supports the flash bank used. For example:
>
> $ cat test.c
> int d = 5;
> const int ro = 5;
> __flash const int f = 5;
> __flash1 const int f1 = 5;
> __flash2 const int f2 = 5;
>
> $ avr-gcc -mmcu=attiny84 -Os -c -o test.o test.c
> test.c:4:20: error: variable ‘f1’ located in address space ‘__flash1’ beyond flash of 64 KiB
> __flash1 const int f1 = 5;
> ^
> test.c:5:20: error: variable ‘f2’ located in address space ‘__flash2’ beyond flash of 64 KiB
> __flash2 const int f2 = 5;
> ^
>
> It does not appear that this patch has a similar check, while I think that would be useful. Or did you leave it out intentionally?
Sorry, it might be that I have misunderstood your concern. Yes, I do added a test for checking the rejection of unsupported flash banks, as shown in the test file clang/test/Sema/avr-flash.c.
The best error message should be something like ` address space ‘__flash2’ is not supported on current device`, but actually the real error in my patch is `unknown type name '__flash2'`, so I write a `TOTO` line for that
// TODO: It would be better to report "'__flash5' is not supported on at908515".
I will try to fix it in my future patches, and current patch implements
1. support `__flashN` on different devices, and deny `__flashN` that beyond the real flash size of user specified device (though the error message is inexact)
2. generate corresponding address space attributes for `__flashN`
So I hope current patch can be accepted and I will fix the inaccurate error message in the future.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115982/new/
https://reviews.llvm.org/D115982
More information about the cfe-commits
mailing list