[libc][doc] Update macros documentation

Update documentaiton now that macros are laid out in a more structured way.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D143911
This commit is contained in:
Guillaume Chatelet
2023-02-13 14:26:59 +00:00
parent 876ccd5643
commit 575310330b

View File

@@ -27,7 +27,7 @@ differences are as follows:
Macro style
===========
We define two kinds of macros: **code defined** and **build defined** macros.
We define two kinds of macros:
#. **Build defined** macros are generated by `CMake` or `Bazel` and are passed
down to the compiler with the ``-D`` command line flag. They start with the
@@ -35,15 +35,27 @@ We define two kinds of macros: **code defined** and **build defined** macros.
They either denote an action or define a constant.
#. **Code defined** macros are defined within the ``src/__support/macros``
folder. They all start with the ``LIBC_`` prefix. They are of two kinds
folder. They all start with the ``LIBC_`` prefix.
* **Properties** - Build related properties like used compiler, target
architecture or enabled CPU features defined by introspecting compiler
defined preprocessor definitions. e.g., ``LIBC_TARGET_ARCH_IS_ARM``,
``LIBC_TARGET_CPU_HAS_AVX2``, ``LIBC_COMPILER_IS_CLANG``, ...
* **Attributes** - Compiler agnostic attributes or functions to handle
specific operations. e.g., ``LIBC_INLINE``, ``LIBC_NO_LOOP_UNROLL``,
``LIBC_LIKELY``, ``LIBC_INLINE_ASM``.
* ``src/__support/macros/properties/`` - Build related properties like
target architecture or enabled CPU features defined by introspecting
compiler defined preprocessor defininitions.
* ``architectures.h`` - Target architecture properties.
e.g., ``LIBC_TARGET_ARCH_IS_ARM``.
* ``compiler.h`` - Host compiler properties.
e.g., ``LIBC_COMPILER_IS_CLANG``.
* ``cpu_features.h`` - Target cpu apu feature availability.
e.g., ``LIBC_TARGET_CPU_HAS_AVX2``.
* ``src/__support/macros/config.h`` - Important compiler and platform
features. Such macros can be used to produce portable code by
parameterizing compilation based on the presence or lack of a given
feature. e.g., ``LIBC_HAS_BUILTIN``
* ``src/__support/macros/attributes.h`` - Attributes for functions, types,
and variables. e.g., ``LIBC_UNUSED``
* ``src/__support/macros/optimization.h`` - Portable macros for performance
optimization. e.g., ``LIBC_LIKELY``, ``LIBC_LOOP_NOUNROLL``
Inline functions and variables defined in header files
======================================================