[clang] Add clang atomic control options and attribute (PR #114841)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 3 11:34:35 PST 2025


================
@@ -1096,6 +1100,177 @@ inline void FPOptions::applyChanges(FPOptionsOverride FPO) {
   *this = FPO.applyOverrides(*this);
 }
 
+/// Atomic control options
+class AtomicOptionsOverride;
+class AtomicOptions {
+public:
+  using storage_type = uint16_t;
+
+  static constexpr unsigned StorageBitSize = 8 * sizeof(storage_type);
+
+  static constexpr storage_type FirstShift = 0, FirstWidth = 0;
+#define OPTION(NAME, STR, TYPE, WIDTH, PREVIOUS)                               \
+  static constexpr storage_type NAME##Shift =                                  \
+      PREVIOUS##Shift + PREVIOUS##Width;                                       \
+  static constexpr storage_type NAME##Width = WIDTH;                           \
+  static constexpr storage_type NAME##Mask = ((1 << NAME##Width) - 1)          \
+                                             << NAME##Shift;
+#include "clang/Basic/AtomicOptions.def"
+
+  static constexpr storage_type TotalWidth = 0
+#define OPTION(NAME, STR, TYPE, WIDTH, PREVIOUS) +WIDTH
----------------
erichkeane wrote:

This whole thing just seems too cute for me.  Could we instead generate this as a type with bitfields, so that only the width is important/necessary? 

https://github.com/llvm/llvm-project/pull/114841


More information about the cfe-commits mailing list