diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-03-21 10:49:05 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-03-21 10:49:05 +0000 |
commit | 2f2afc1aae898651e26987a5c71f3febb19bca98 (patch) | |
tree | 2caca31db4facdc95c23930c0c745c8ef0dee97d /include/llvm/Support | |
parent | 0f448b841684305c051796982f300c9bff959307 (diff) | |
download | FreeBSD-src-2f2afc1aae898651e26987a5c71f3febb19bca98.zip FreeBSD-src-2f2afc1aae898651e26987a5c71f3febb19bca98.tar.gz |
Update LLVM to r99115.
Diffstat (limited to 'include/llvm/Support')
-rw-r--r-- | include/llvm/Support/Allocator.h | 21 | ||||
-rw-r--r-- | include/llvm/Support/RecyclingAllocator.h | 7 |
2 files changed, 28 insertions, 0 deletions
diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h index b0ed33d..b1f59dc 100644 --- a/include/llvm/Support/Allocator.h +++ b/include/llvm/Support/Allocator.h @@ -15,9 +15,12 @@ #define LLVM_SUPPORT_ALLOCATOR_H #include "llvm/Support/AlignOf.h" +#include "llvm/Support/MathExtras.h" #include "llvm/System/DataTypes.h" +#include <algorithm> #include <cassert> #include <cstdlib> +#include <cstddef> namespace llvm { @@ -175,4 +178,22 @@ public: } // end namespace llvm +inline void *operator new(size_t Size, llvm::BumpPtrAllocator &Allocator) { + struct S { + char c; +#ifdef __GNUC__ + char x __attribute__((aligned)); +#else + union { + double D; + long double LD; + long long L; + void *P; + } x; +#endif + }; + return Allocator.Allocate(Size, std::min((size_t)llvm::NextPowerOf2(Size), + offsetof(S, x))); +} + #endif // LLVM_SUPPORT_ALLOCATOR_H diff --git a/include/llvm/Support/RecyclingAllocator.h b/include/llvm/Support/RecyclingAllocator.h index 609193f..49f7753 100644 --- a/include/llvm/Support/RecyclingAllocator.h +++ b/include/llvm/Support/RecyclingAllocator.h @@ -56,4 +56,11 @@ public: } +template<class AllocatorType, class T, size_t Size, size_t Align> +inline void *operator new(size_t, + llvm::RecyclingAllocator<AllocatorType, + T, Size, Align> &Allocator) { + return Allocator.Allocate(); +} + #endif |