diff options
author | Bill Wendling <isanbard@gmail.com> | 2011-03-22 00:24:04 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2011-03-22 00:24:04 +0000 |
commit | 9a68f59e14795fc50ff69c8e422115a500ef998e (patch) | |
tree | ae59dd9c00bdf9faa5b704bfbbfed8e4d8d72297 | |
parent | 59fb1a0544547dc3a17072544d09d95f97cb9235 (diff) | |
download | llvm-9a68f59e14795fc50ff69c8e422115a500ef998e.zip llvm-9a68f59e14795fc50ff69c8e422115a500ef998e.tar.gz llvm-9a68f59e14795fc50ff69c8e422115a500ef998e.tar.bz2 |
- r127238 mingw-w64 should define __MINGW32__, too.
- r127329 declarations of __builtin_ia32_crc32**()
- r127652 Tweak InitHeaderSearch.cpp for mingw-w64-gcc
- r127654 _mm_malloc tweak
- r127655 Tweak __declspec and __attribute__ for mingw
--- Merging r127238 into '.':
U lib/Basic/Targets.cpp
--- Merging r127329 into '.':
A test/Sema/builtins-decl.c
U include/clang/Basic/BuiltinsX86.def
--- Merging r127652 into '.':
U lib/Frontend/InitHeaderSearch.cpp
--- Merging r127654 into '.':
U lib/Headers/mm_malloc.h
--- Merging r127655 into '.':
G lib/Basic/Targets.cpp
llvm-svn: 128046
-rw-r--r-- | clang/include/clang/Basic/BuiltinsX86.def | 8 | ||||
-rw-r--r-- | clang/lib/Basic/Targets.cpp | 21 | ||||
-rw-r--r-- | clang/lib/Frontend/InitHeaderSearch.cpp | 36 | ||||
-rw-r--r-- | clang/lib/Headers/mm_malloc.h | 2 | ||||
-rw-r--r-- | clang/test/Sema/builtins-decl.c | 8 |
5 files changed, 57 insertions, 18 deletions
diff --git a/clang/include/clang/Basic/BuiltinsX86.def b/clang/include/clang/Basic/BuiltinsX86.def index da106da..1584498 100644 --- a/clang/include/clang/Basic/BuiltinsX86.def +++ b/clang/include/clang/Basic/BuiltinsX86.def @@ -342,10 +342,10 @@ BUILTIN(__builtin_ia32_pcmpestriz128, "iV16ciV16cic","") BUILTIN(__builtin_ia32_pcmpgtq, "V2LLiV2LLiV2LLi", "") -BUILTIN(__builtin_ia32_crc32qi, "iic", "") -BUILTIN(__builtin_ia32_crc32hi, "iis", "") -BUILTIN(__builtin_ia32_crc32si, "iii", "") -BUILTIN(__builtin_ia32_crc32di, "LLiLLiLLi", "") +BUILTIN(__builtin_ia32_crc32qi, "UiUiUc", "") +BUILTIN(__builtin_ia32_crc32hi, "UiUiUs", "") +BUILTIN(__builtin_ia32_crc32si, "UiUiUi", "") +BUILTIN(__builtin_ia32_crc32di, "ULLiULLiULLi", "") // AES BUILTIN(__builtin_ia32_aesenc128, "V2LLiV2LLiV2LLi", "") diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 55321f2..02b1610 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -1481,7 +1481,15 @@ public: Builder.defineMacro("_X86_"); Builder.defineMacro("__MSVCRT__"); Builder.defineMacro("__MINGW32__"); - Builder.defineMacro("__declspec", "__declspec"); + + // mingw32-gcc provides __declspec(a) as alias of __attribute__((a)). + // In contrast, clang-cc1 provides __declspec(a) with -fms-extensions. + if (Opts.Microsoft) + // Provide "as-is" __declspec. + Builder.defineMacro("__declspec", "__declspec"); + else + // Provide alias of __attribute__ like mingw32-gcc. + Builder.defineMacro("__declspec(a)", "__attribute__((a))"); } }; } // end anonymous namespace @@ -1629,8 +1637,17 @@ public: WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder); DefineStd(Builder, "WIN64", Opts); Builder.defineMacro("__MSVCRT__"); + Builder.defineMacro("__MINGW32__"); Builder.defineMacro("__MINGW64__"); - Builder.defineMacro("__declspec", "__declspec"); + + // mingw32-gcc provides __declspec(a) as alias of __attribute__((a)). + // In contrast, clang-cc1 provides __declspec(a) with -fms-extensions. + if (Opts.Microsoft) + // Provide "as-is" __declspec. + Builder.defineMacro("__declspec", "__declspec"); + else + // Provide alias of __attribute__ like mingw32-gcc. + Builder.defineMacro("__declspec(a)", "__attribute__((a))"); } }; } // end anonymous namespace diff --git a/clang/lib/Frontend/InitHeaderSearch.cpp b/clang/lib/Frontend/InitHeaderSearch.cpp index 60c3e9c..78634d8 100644 --- a/clang/lib/Frontend/InitHeaderSearch.cpp +++ b/clang/lib/Frontend/InitHeaderSearch.cpp @@ -76,6 +76,10 @@ public: llvm::StringRef Arch, llvm::StringRef Version); + /// AddMinGW64CXXPaths - Add the necessary paths to support + /// libstdc++ of x86_64-w64-mingw32 aka mingw-w64. + void AddMinGW64CXXPaths(llvm::StringRef Base); + /// AddDelimitedPaths - Add a list of paths delimited by the system PATH /// separator. The processing follows that of the CPATH variable for gcc. void AddDelimitedPaths(llvm::StringRef String); @@ -207,6 +211,15 @@ void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(llvm::StringRef Base, CXXSystem, true, false, false); } +void InitHeaderSearch::AddMinGW64CXXPaths(llvm::StringRef Base) { + AddPath(Base, + CXXSystem, true, false, false); + AddPath(Base + "/x86_64-w64-mingw32", + CXXSystem, true, false, false); + AddPath(Base + "/backward", + CXXSystem, true, false, false); +} + // FIXME: This probably should goto to some platform utils place. #ifdef _MSC_VER @@ -534,6 +547,10 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, AddPath("/usr/include/w32api", System, true, false, false); break; case llvm::Triple::MinGW32: + // FIXME: We should be aware of i686-w64-mingw32. + if (triple.getArch() == llvm::Triple::x86_64) + AddPath("c:/mingw/x86_64-w64-mingw32/include", + System, true, false, false); AddPath("/mingw/include", System, true, false, false); AddPath("c:/mingw/include", System, true, false, false); break; @@ -571,18 +588,13 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple) { AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "3.4.4"); break; case llvm::Triple::MinGW32: - // mingw-w64-20110207 - AddPath("c:/MinGW/include/c++/4.5.3", CXXSystem, true, false, false); - AddPath("c:/MinGW/include/c++/4.5.3/x86_64-w64-mingw32", CXXSystem, true, - false, false); - AddPath("c:/MinGW/include/c++/4.5.3/backward", CXXSystem, true, false, - false); - // mingw-w64-20101129 - AddPath("c:/MinGW/include/c++/4.5.2", CXXSystem, true, false, false); - AddPath("c:/MinGW/include/c++/4.5.2/x86_64-w64-mingw32", CXXSystem, true, - false, false); - AddPath("c:/MinGW/include/c++/4.5.2/backward", CXXSystem, true, false, - false); + // FIXME: We should be aware of i686-w64-mingw32. + if (triple.getArch() == llvm::Triple::x86_64) { + // mingw-w64-20110207 + AddMinGW64CXXPaths("c:/mingw/x86_64-w64-mingw32/include/c++/4.5.3"); + // mingw-w64-20101129 + AddMinGW64CXXPaths("c:/mingw/x86_64-w64-mingw32/include/c++/4.5.2"); + } // Try gcc 4.5.2 (MSYS) AddMinGWCPlusPlusIncludePaths("/mingw/lib/gcc", "mingw32", "4.5.2"); // Try gcc 4.5.0 diff --git a/clang/lib/Headers/mm_malloc.h b/clang/lib/Headers/mm_malloc.h index e7da543..ec92362 100644 --- a/clang/lib/Headers/mm_malloc.h +++ b/clang/lib/Headers/mm_malloc.h @@ -40,6 +40,7 @@ extern "C" int posix_memalign(void **memptr, size_t alignment, size_t size); #endif #endif +#if !(defined(_WIN32) && defined(_mm_malloc)) static __inline__ void *__attribute__((__always_inline__, __nodebug__, __malloc__)) _mm_malloc(size_t size, size_t align) @@ -67,5 +68,6 @@ _mm_free(void *p) { free(p); } +#endif #endif /* __MM_MALLOC_H */ diff --git a/clang/test/Sema/builtins-decl.c b/clang/test/Sema/builtins-decl.c new file mode 100644 index 0000000..19bdb84 --- /dev/null +++ b/clang/test/Sema/builtins-decl.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=i686-mingw32 +// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-mingw32 + +// mingw-w64's intrin.h has decls below. +// we should accept them. +extern unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char); +extern unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short); +extern unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int); |