[clang] Add clang atomic control options and attribute (PR #114841)
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 7 09:00:18 PST 2024
================
@@ -1093,6 +1097,169 @@ 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, 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, TYPE, WIDTH, PREVIOUS) +WIDTH
+#include "clang/Basic/AtomicOptions.def"
+ ;
+ static_assert(TotalWidth <= StorageBitSize,
+ "Too short type for AtomicOptions");
+
+private:
+ storage_type Value;
+
+ AtomicOptionsOverride getChangesSlow(const AtomicOptions &Base) const;
+
+public:
+ AtomicOptions() : Value(0) {
+ setNoRemoteMemory(false);
+ setNoFineGrainedMemory(false);
+ setIgnoreDenormalMode(false);
+ }
+ explicit AtomicOptions(const LangOptions &LO) {
+ Value = 0;
+#if 0
----------------
yxsamliu wrote:
will remove this ctor. The relevant language options actually define an AtomicOptionsOverride object, which has a ctor for that.
https://github.com/llvm/llvm-project/pull/114841
More information about the cfe-commits
mailing list