clang-notes.rst 1.0 KB

123456789101112131415161718192021222324252627282930
  1. .. contents::
  2. .. sectnum::
  3. ==========================
  4. Clang implementation notes
  5. ==========================
  6. This document provides more details specific to the Clang/LLVM implementation of the eBPF instruction set.
  7. Versions
  8. ========
  9. Clang defined "CPU" versions, where a CPU version of 3 corresponds to the current eBPF ISA.
  10. Clang can select the eBPF ISA version using ``-mcpu=v3`` for example to select version 3.
  11. Arithmetic instructions
  12. =======================
  13. For CPU versions prior to 3, Clang v7.0 and later can enable ``BPF_ALU`` support with
  14. ``-Xclang -target-feature -Xclang +alu32``. In CPU version 3, support is automatically included.
  15. Atomic operations
  16. =================
  17. Clang can generate atomic instructions by default when ``-mcpu=v3`` is
  18. enabled. If a lower version for ``-mcpu`` is set, the only atomic instruction
  19. Clang can generate is ``BPF_ADD`` *without* ``BPF_FETCH``. If you need to enable
  20. the atomics features, while keeping a lower ``-mcpu`` version, you can use
  21. ``-Xclang -target-feature -Xclang +alu32``.