[PATCH] D123200: [compiler-rt][CMake] Add initial support of target AVR

Ben Shi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 19 21:44:54 PDT 2022


benshi001 added a comment.

I added three functions

  __mulqi3: int8 multiplication
  __mulhi3: int16 multiplication
  _exit   : golobal terminator

All of them are contained in libgcc and are necessary.

Some key points,

1. The functions are written in the minimal avrtiny instruction set, so they should be compatible for all devices.

2. We build them to higher/upper AVR ELF files by specifying `CMAKE_CXX_COMPILER` and `CMAKE_C_COMPILER` when doing cmake.

3. I refered to libgcc, but not simple copy. Actually my implementation is shorter than libgcc's, but may cost more cycles. However this is something about tradeoff.

4. I have tested against avr hardware multiplier, the results are all the same.

5. My test program locates at https://github.com/benshi001/avr-test/blob/main/mul.ino, I only added 300 pairs of random numbers as test cases, due to the limitation of my device (atmega328 has only 2KB SRAM, more test cases will lead to `too large data section`). Acutally I have tested 900 pairs.


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

https://reviews.llvm.org/D123200



More information about the cfe-commits mailing list