diff options
| author | Stephen Hines <srhines@google.com> | 2012-09-10 16:47:31 -0700 |
|---|---|---|
| committer | Stephen Hines <srhines@google.com> | 2012-09-10 16:47:31 -0700 |
| commit | 1c4ad5ef4fab105f0c8af7edd026e00502fb6279 (patch) | |
| tree | cb5bdfd58f776d00be450d0a5585f8f0186585da /include/llvm/Support/AlignOf.h | |
| parent | d62cdbe700ab288e9ad447824066edb7d17167d9 (diff) | |
| parent | 1dc2591e9ef0730612902f94976ce85bed6859de (diff) | |
| download | external_llvm-1c4ad5ef4fab105f0c8af7edd026e00502fb6279.zip external_llvm-1c4ad5ef4fab105f0c8af7edd026e00502fb6279.tar.gz external_llvm-1c4ad5ef4fab105f0c8af7edd026e00502fb6279.tar.bz2 | |
Merge branch 'upstream' into merge-2012_09_10
Conflicts:
lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
lib/Support/DynamicLibrary.cpp
lib/Support/LockFileManager.cpp
Change-Id: I91e94c3a7a76e19c688307c5a480a640a3bd2b7e
Diffstat (limited to 'include/llvm/Support/AlignOf.h')
| -rw-r--r-- | include/llvm/Support/AlignOf.h | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/include/llvm/Support/AlignOf.h b/include/llvm/Support/AlignOf.h index cf71251..8c389af 100644 --- a/include/llvm/Support/AlignOf.h +++ b/include/llvm/Support/AlignOf.h @@ -72,6 +72,10 @@ template <size_t Alignment> struct AlignedCharArrayImpl {}; template <> struct AlignedCharArrayImpl<0> { typedef char type; }; + +// MSVC requires special handling here. +#ifndef _MSC_VER + #if __has_feature(cxx_alignas) #define LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \ template <> struct AlignedCharArrayImpl<x> { \ @@ -82,11 +86,6 @@ template <> struct AlignedCharArrayImpl<0> { template <> struct AlignedCharArrayImpl<x> { \ typedef char type __attribute__((aligned(x))); \ } -#elif defined(_MSC_VER) -#define LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \ - template <> struct AlignedCharArrayImpl<x> { \ - typedef __declspec(align(x)) char type; \ - } #else # error No supported align as directive. #endif @@ -104,9 +103,38 @@ LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(1024); LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(2048); LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(4096); LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(8192); + +#undef LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT + +#else // _MSC_VER + +// We provide special variations of this template for the most common +// alignments because __declspec(align(...)) doesn't actually work when it is +// a member of a by-value function argument in MSVC, even if the alignment +// request is something reasonably like 8-byte or 16-byte. +template <> struct AlignedCharArrayImpl<1> { typedef char type; }; +template <> struct AlignedCharArrayImpl<2> { typedef short type; }; +template <> struct AlignedCharArrayImpl<4> { typedef int type; }; +template <> struct AlignedCharArrayImpl<8> { typedef double type; }; + +#define LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \ + template <> struct AlignedCharArrayImpl<x> { \ + typedef __declspec(align(x)) char type; \ + } +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(16); +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(32); +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(64); +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(128); +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(512); +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(1024); +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(2048); +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(4096); +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(8192); // Any larger and MSVC complains. #undef LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT +#endif // _MSC_VER + /// \brief This union template exposes a suitably aligned and sized character /// array member which can hold elements of any of up to four types. /// |
