diff options
author | David Chisnall <csdavec@swan.ac.uk> | 2012-01-16 17:27:18 +0000 |
---|---|---|
committer | David Chisnall <csdavec@swan.ac.uk> | 2012-01-16 17:27:18 +0000 |
commit | fa35df628a4ab331347dc448ccde573d6a7fa81d (patch) | |
tree | bfd08bb857ccb2b66b87541d23e8a439ab0b336e /clang/lib/Frontend/InitPreprocessor.cpp | |
parent | 44a2895a0369ba2149f6ed4dc5f90197e854b5be (diff) | |
download | bcm5719-llvm-fa35df628a4ab331347dc448ccde573d6a7fa81d.tar.gz bcm5719-llvm-fa35df628a4ab331347dc448ccde573d6a7fa81d.zip |
Some improvements to the handling of C11 atomic types:
- Add atomic-to/from-nonatomic cast types
- Emit atomic operations for arithmetic on atomic types
- Emit non-atomic stores for initialisation of atomic types, but atomic stores and loads for every other store / load
- Add a __atomic_init() intrinsic which does a non-atomic store to an _Atomic() type. This is needed for the corresponding C11 stdatomic.h function.
- Enables the relevant __has_feature() checks. The feature isn't 100% complete yet, but it's done enough that we want people testing it.
Still to do:
- Make the arithmetic operations on atomic types (e.g. Atomic(int) foo = 1; foo++;) use the correct LLVM intrinsic if one exists, not a loop with a cmpxchg.
- Add a signal fence builtin
- Properly set the fenv state in atomic operations on floating point values
- Correctly handle things like _Atomic(_Complex double) which are too large for an atomic cmpxchg on some platforms (this requires working out what 'correctly' means in this context)
- Fix the many remaining corner cases
llvm-svn: 148242
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
-rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index c736ca3ccc5..93c99890200 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -325,6 +325,14 @@ static void InitializePredefinedMacros(const TargetInfo &TI, Builder.defineMacro("__GNUC__", "4"); Builder.defineMacro("__GXX_ABI_VERSION", "1002"); + // Define macros for the C11 / C++11 memory orderings + Builder.defineMacro("__ATOMIC_RELAXED", "0"); + Builder.defineMacro("__ATOMIC_CONSUME", "1"); + Builder.defineMacro("__ATOMIC_ACQUIRE", "2"); + Builder.defineMacro("__ATOMIC_RELEASE", "3"); + Builder.defineMacro("__ATOMIC_ACQ_REL", "4"); + Builder.defineMacro("__ATOMIC_SEQ_CST", "5"); + // As sad as it is, enough software depends on the __VERSION__ for version // checks that it is necessary to report 4.2.1 (the base GCC version we claim // compatibility with) first. |