https://github.com/espressif/llvm-xtensa
https://github.com/espressif/clang-xtensa
The compiler is now in the stage of active development and testing. It was successfully tested using GCC torture testsuite and multiple ESP-IDF applications (although ESP-IDF versions available on Github do not support LLVM/Clang out of the box, yet).
Current release can generate Xtensa assembly code as output (not object files!), and has to be used together with GNU Binutils and GCC-built libraries (libgcc, libstdc++, newlib) to create object and binary files.
Current Xtensa architecture features implemented in compiler:
- support Xtensa Core Architecture instructions
- support Code Density option
- support Windowed Register option
- support Floating-Point Coprocessor option
- support Boolean option (only a subset of instructions)
- support Thread Pointer option
- support atomic operations
Current Xtensa target list:
- ESP32 target (used by default, can be selected with -target xtensa -mcpu=esp32 flags)
- ESP8266 target (can be selected with -target xtensa -mcpu=esp8266 flags)
Compiler optimization levels include O0/O1/O2/O3/Os options.
Installation
Since at the current release is not intended for developers who just want to build ESP-IDF apps, we do not provide binary releases of LLVM for Xtensa, yet. To compile LLVM from source, follow these steps:
Code: Select all
git clone https://github.com/espressif/llvm-xtensa.git
git clone https://github.com/espressif/clang-xtensa.git llvm-xtensa/tools/clang
mkdir llvm_build
cd llvm_build
cmake ../llvm-xtensa -DLLVM_TARGETS_TO_BUILD=Xtensa -DCMAKE_BUILD_TYPE=Release -G "Ninja"
cmake --build .
Create a test.c source file and run:
Code: Select all
llvm_build/bin/clang -target xtensa -fomit-frame-pointer -S test.c -o test.S
Plans for next releases
Development of the compiler and its testing is constantly ongoing. In future releases, improved performance is planned, such as support for Zero Overhead Loop optimization, support for various architectures and targets.
Object code generation and standalone toolchain based on Clang/LLVM is also planned.
Summary features which will be implemented in next releases:
- rebasing on the upstream version of LLVM, following the new monorepo layout (https://github.com/llvm/llvm-project/).
- object code generation
- support for LX106 target (ESP8266)
- binary releases on Github
- support for using LLVM to build ESP-IDF apps
- improvements of generated code performance
- support for zero-overhead loop option
- MAC16 option
- PSRAM cache workaround for ESP32 chip
Issues and feedback
For general questions and feedback, please post in this forum thread. For specific bug reports (code generation, handling of some language features) please use https://github.com/espressif/llvm-xtensa/issues.
Updated 2019/03/26: support for both ESP32 and ESP8266 targets (-mcpu=esp32, -mcpu=esp8266)