[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 06:36:36 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?

I have updated my patch, in the newly added test `clang/test/Sema/avr-flash.c`, all `__flash1`/`__flash2`/`__flash3`/`__flash4`/`__flash5` are denied when running clang against at90s8515( which belongs to the avr-2 family).

I intentionally using at90s8515 instead of attiny84, due to the compiler generates wrong code (use of register r0~r15 can be generated) for the avrtiny family. Actually I plan to

1. deny compiling c code for the avr-0 family, and only assembly code is accepted by clang, that behavior matches avr-gcc's.
2. Temporarily disable compiling c code for the avr-tiny family, report an error like "c code is not supported on avrtiny currently", until the support of avr-tiny is fully done.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115982/new/

https://reviews.llvm.org/D115982



More information about the cfe-commits mailing list