[libc-commits] [PATCH] D143911: [libc][doc] Update macros documentation

Guillaume Chatelet via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Feb 13 06:40:35 PST 2023


gchatelet created this revision.
gchatelet added a reviewer: sivachandra.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added projects: libc-project, All.
gchatelet requested review of this revision.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143911

Files:
  libc/docs/code_style.rst


Index: libc/docs/code_style.rst
===================================================================
--- libc/docs/code_style.rst
+++ libc/docs/code_style.rst
@@ -27,7 +27,7 @@
 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 @@
    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 defininitions. 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 defined in header files
 ========================================
@@ -53,7 +65,8 @@
 #. The functions should not be given file-static linkage. There can be class
    static methods defined inline however.
 #. Instead of using the ``inline`` keyword, they should be tagged with the
-   ``LIBC_INLINE`` macro defined in ``src/__support/common.h``. For example:
+   ``LIBC_INLINE`` macro defined in ``src/__support/macros/config.h``.
+   For example:
 
    .. code-block:: c++
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143911.496957.patch
Type: text/x-patch
Size: 2788 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230213/a0054fbb/attachment.bin>


More information about the libc-commits mailing list