Re: [PATCH] D12512: [libcxxabi] Manually align pointers in __cxa_allocate_exception - Fixes PR24604

2015-09-06 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 34128.
EricWF added a comment.

Address @joerg's comment and use `posix_memalign` when available. This patch 
does not fix the case where `posix_memalign` is unavailable but that should be 
rare and can come in another patch.

Thi patch also defers all changes to `fallback_malloc` to 
http://reviews.llvm.org/D12669.


http://reviews.llvm.org/D12512

Files:
  CMakeLists.txt
  cmake/config-ix.cmake
  src/cxa_exception.cpp
  test/test_cxa_allocate_exception.pass.cpp

Index: test/test_cxa_allocate_exception.pass.cpp
===
--- /dev/null
+++ test/test_cxa_allocate_exception.pass.cpp
@@ -0,0 +1,65 @@
+//===- test_fallback_malloc.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: c++98, c++03
+
+// void* __cxa_allocate_exception(size_t);
+// void  __cxa_free_exception(void*);
+// void* __cxa_allocate_dependent_exception();
+// void  __cxa_free_dependent_exception();
+
+// __cxa_exception is specified with __attribute__((aligned)) for GNU unwind.
+// This means that during 32 bit builds __cxa_exception is "over aligned". This
+// test checks that __cxa_allocate_exception return correctly overaligned memory.
+// See PR24604 - https://llvm.org/bugs/show_bug.cgi?id=24604
+
+#include "../src/cxa_exception.hpp"
+#include  // for std::max_align_t
+#include 
+
+#if defined(__GNUC__) && !defined(_LP64)
+#define SHOULD_BE_OVERALIGNED 1
+#endif
+
+using namespace __cxxabiv1;
+
+const std::size_t max_alignment = alignof(std::max_align_t);
+const std::size_t required_alignment = alignof(__cxa_exception);
+const bool requires_over_alignment = max_alignment < required_alignment;
+
+static_assert(alignof(__cxa_exception) == alignof(__cxa_dependent_exception),
+  "They should have the same alignment requirements");
+
+#if defined(__GNUC__) && !defined(_LP64)
+static_assert(alignof(__cxa_exception) > alignof(std::max_align_t),
+  "On 32 bit platforms __cxa_exception is expected to be over aligned.");
+#endif
+
+void test_cxa_allocate_exception() {
+for (int i=0; i < 4096; ++i) {
+void* ptr = __cxa_allocate_exception(i);
+assert(ptr);
+assert(reinterpret_cast(ptr) % required_alignment == 0);
+__cxa_free_exception(ptr);
+}
+}
+
+void test_cxa_allocate_dependent_exception() {
+for (int i=0; i < 100; ++i) {
+void* ptr = __cxa_allocate_dependent_exception();
+assert(ptr);
+assert(reinterpret_cast(ptr) % required_alignment == 0);
+__cxa_free_dependent_exception(ptr);
+}
+}
+
+int main() {
+test_cxa_allocate_exception();
+test_cxa_allocate_dependent_exception();
+}
Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -118,13 +118,22 @@
 
 //  Allocate some memory from _somewhere_
 static void *do_malloc(size_t size) {
-void *ptr = std::malloc(size);
+void* ptr = nullptr;
+#ifndef LIBCXXABI_HAS_NO_POSIX_MEMALIGN
+(void)posix_memalign(&ptr, alignof(__cxa_exception), size);
+#else
+// FIXME: The output of malloc needs to be manually aligned to a 16 byte
+// on 32 bit targets.
+ptr = std::malloc(size);
+#endif
 if (NULL == ptr) // if malloc fails, fall back to emergency stash
 ptr = fallback_malloc(size);
 return ptr;
 }
 
 static void do_free(void *ptr) {
+// NOTE: std::free can free pointers allocated with both std::malloc
+// and posix_memalign.
 is_fallback_ptr(ptr) ? fallback_free(ptr) : std::free(ptr);
 }
 
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -1,6 +1,7 @@
 include(CheckLibraryExists)
 include(CheckCCompilerFlag)
 include(CheckCXXCompilerFlag)
+include(CheckSymbolExists)
 
 # Check compiler flags
 check_c_compiler_flag(-funwind-tables LIBCXXABI_HAS_FUNWIND_TABLES)
@@ -45,3 +46,6 @@
 check_library_exists(gcc_eh _Unwind_GetRegionStart "" LIBCXXABI_HAS_GCC_EH_LIB)
 check_library_exists(c __cxa_thread_atexit_impl ""
   LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)
+
+# Check symbols
+check_symbol_exists(posix_memalign stdlib.h LIBCXXABI_HAS_POSIX_MEMALIGN)
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -275,6 +275,10 @@
   add_definitions(-DLIBCXXABI_HAS_NO_THREADS=1)
 endif()
 
+if (NOT LIBCXXABI_HAS_POSIX_MEMALIGN)
+  add_definitions(-DLIBCXXABI_HAS_NO_POSIX_MEMALIGN=1)
+endif()
+
 # This is the _ONLY_ place where add_definitions is called.
 if (MSVC)
   add_definitions(-D_CRT_SECURE_NO_WA

[PATCH] D12669: [libcxxabi] Fix alignment of pointers returned by fallback_malloc

2015-09-06 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: mclow.lists, compnerd, joerg, jroelofs.
EricWF added a subscriber: cfe-commits.

Currently the pointers returned by fallback_malloc do not have *ANY* alignment 
guarantees. This is caused by two different problems is `fallback_malloc.ipp`. 

The first reason is because the `heap` array used by fallback malloc only has 
an alignment requirement of '1'. Currently we try and put the first heap_node 
directly at the start of `heap` even though 'heap_node' has an alignment 
requirement of at least 2 bytes. This patch fixes this issue by manually 
aligning `heap` using `alignas(heap_node)`.

The second reason is because fallback_malloc returns the pointers that are 
exactly `sizeof(heap_node)` bytes after the heap_node header itself. Because 
heap_nodes only have an alignment requirement of '2' the resulting pointers 
also only have an alignment requirement of '2' even though an alignment of '16' 
bytes is required. This patch fixes this problem by
manually requiring that all heap_nodes  have an address that is 4 bytes before 
a 16 byte boundary.




http://reviews.llvm.org/D12669

Files:
  src/cxa_exception.cpp
  src/fallback_malloc.ipp
  test/test_fallback_malloc.pass.cpp

Index: test/test_fallback_malloc.pass.cpp
===
--- test/test_fallback_malloc.pass.cpp
+++ test/test_fallback_malloc.pass.cpp
@@ -9,29 +9,39 @@
 
 #include 
 #include 
+#include 
 
 #include 
 
-typedef std::deque container;
-
 // #define  DEBUG_FALLBACK_MALLOC
 #define INSTRUMENT_FALLBACK_MALLOC
+#include "../src/config.h"
 #include "../src/fallback_malloc.ipp"
+#include "../src/cxa_exception.hpp"
+
+typedef std::deque container;
+
+void assertAlignment(void* ptr) {
+assert(reinterpret_cast(ptr) % alignof(FallbackMaxAlignType) == 0);
+}
 
 container alloc_series ( size_t sz ) {
 container ptrs;
 void *p;
 
-while ( NULL != ( p = fallback_malloc ( sz )))
+while ( NULL != ( p = fallback_malloc ( sz ))) {
+assertAlignment(p);
 ptrs.push_back ( p );
+}
 return ptrs;
 }
 
 container alloc_series ( size_t sz, float growth ) {
 container ptrs;
 void *p;
 
 while ( NULL != ( p = fallback_malloc ( sz ))) {
+assertAlignment(p);
 ptrs.push_back ( p );
 sz *= growth;
 }
@@ -47,6 +57,7 @@
 for ( const size_t *iter = first; iter != last; ++iter ) {
 if ( NULL == (p = fallback_malloc ( *iter )))
 break;
+assertAlignment(p);
 ptrs.push_back ( p );
 }
 
Index: src/fallback_malloc.ipp
===
--- src/fallback_malloc.ipp
+++ src/fallback_malloc.ipp
@@ -11,7 +11,18 @@
 //  
 //===--===//
 
-#include "config.h"
+// fallback_malloc.ipp cannot include any headers but it requires certain headers
+// already be included. These checks help to ensure the proper headers have
+// already been included.
+#ifndef LIBCXXABI_CONFIG_H
+#error config.h needs to be included before this file!
+#endif
+#ifndef assert
+#error  needs to be included before this file!
+#endif
+#ifndef _ALIGNAS_TYPE
+#error The required macro '_ALIGNAS_TYPE' is not defined.
+#endif
 
 //  A small, simple heap manager based (loosely) on 
 //  the startup heap manager from FreeBSD, optimized for space.
@@ -47,41 +58,77 @@
 #if !LIBCXXABI_HAS_NO_THREADS
 pthread_mutex_t *mtx_;
 #endif
-};
+};
 
-
-#define HEAP_SIZE   512
-char heap [ HEAP_SIZE ];
 
 typedef unsigned short heap_offset;
 typedef unsigned short heap_size;
 
+// On both 64 and 32 bit targets heap_node should have the following properties
+// Size: 4
+// Alignment: 2
 struct heap_node {
 heap_offset next_node;  // offset into heap
 heap_size   len;// size in units of "sizeof(heap_node)"
 };
 
-static const heap_node *list_end = (heap_node *) ( &heap [ HEAP_SIZE ] );   // one past the end of the heap
+
+// All pointers returned by fallback_malloc must be at least aligned
+// as RequiredAligned. Note that RequiredAlignment can be greater than
+// alignof(std::max_align_t) on 64 bit systems compiling 32 bit code.
+struct FallbackMaxAlignType {} __attribute__((aligned));
+const size_t RequiredAlignment = alignof(FallbackMaxAlignType);
+
+static_assert(alignof(FallbackMaxAlignType) % sizeof(heap_node) == 0,
+"The required alignment must be evenly divisible by the sizeof(heap_node)");
+
+// The number of heap_node's that can fit in a chunk of memory with the size
+// of the RequiredAlignment. On 64 bit targets NodesPerAlignment should be 4.
+const size_t NodesPerAlignment = alignof(FallbackMaxAlignType) / sizeof(heap_node);
+
+char heap _ALIGNAS_TYPE(heap_node) [512];
+const size_t HeapSize = sizeof(heap) / sizeof(heap_node);
+
+static const heap_node *list_end = ((heap_node *)heap) + HeapSize; // one past the end of the heap

Re: [PATCH] D11619: [OPENMP] allow static local variable on data-sharing attribute clause

2015-09-06 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

LG


http://reviews.llvm.org/D11619



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r246952 - Cleanup BuildingLibcxx.rst and remove TODO

2015-09-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Sep  6 18:31:16 2015
New Revision: 246952

URL: http://llvm.org/viewvc/llvm-project?rev=246952&view=rev
Log:
Cleanup BuildingLibcxx.rst and remove TODO

Modified:
libcxx/trunk/docs/BuildingLibcxx.rst

Modified: libcxx/trunk/docs/BuildingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/BuildingLibcxx.rst?rev=246952&r1=246951&r2=246952&view=diff
==
--- libcxx/trunk/docs/BuildingLibcxx.rst (original)
+++ libcxx/trunk/docs/BuildingLibcxx.rst Sun Sep  6 18:31:16 2015
@@ -34,7 +34,7 @@ The basic steps needed to build libc++ a
 
 #. Configure and build libc++ with libc++abi:
 
-   `CMake `_ is the only supported configuration system. Unlike 
other LLVM
+   CMake is the only supported configuration system. Unlike other LLVM
projects autotools is not supported for either libc++ or libc++abi.
 
Clang is the preferred compiler when building and using libc++.
@@ -69,8 +69,8 @@ The instructions are for building libc++
 FreeBSD, Linux, or Mac using `libc++abi`_ as the C++ ABI library.
 On Linux, it is also possible to use :ref:`libsupc++ ` or libcxxrt.
 
-It is sometimes beneficial to build outside of the LLVM tree. To build
-libc++ TODO
+It is sometimes beneficial to build outside of the LLVM tree. An out-of-tree
+build would look like this:
 
 .. code-block:: bash
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r246951 - Fix another bad link in the new docs

2015-09-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Sep  6 18:22:02 2015
New Revision: 246951

URL: http://llvm.org/viewvc/llvm-project?rev=246951&view=rev
Log:
Fix another bad link in the new docs

Modified:
libcxx/trunk/docs/index.rst

Modified: libcxx/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/index.rst?rev=246951&r1=246950&r2=246951&view=diff
==
--- libcxx/trunk/docs/index.rst (original)
+++ libcxx/trunk/docs/index.rst Sun Sep  6 18:22:02 2015
@@ -117,9 +117,9 @@ This list contains known issues with lib
   must be used during configuration.
 
 
-A full list of currently open libc++ bugs can be `found here `_.
+A full list of currently open libc++ bugs can be `found here`__.
 
-.. _`libcxx bug list`: 
https://llvm.org/bugs/buglist.cgi?component=All%20Bugs&product=libc%2B%2B&query_format=advanced&resolution=---&order=changeddate%20DESC%2Cassigned_to%20DESC%2Cbug_status%2Cpriority%2Cbug_id&list_id=74184
+.. __:  
https://llvm.org/bugs/buglist.cgi?component=All%20Bugs&product=libc%2B%2B&query_format=advanced&resolution=---&order=changeddate%20DESC%2Cassigned_to%20DESC%2Cbug_status%2Cpriority%2Cbug_id&list_id=74184
 
 Design Documents
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r246950 - Try to fix links for libcxx.llvm.org/docs again.

2015-09-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Sep  6 18:09:54 2015
New Revision: 246950

URL: http://llvm.org/viewvc/llvm-project?rev=246950&view=rev
Log:
Try to fix links for libcxx.llvm.org/docs again.

Modified:
libcxx/trunk/docs/index.rst

Modified: libcxx/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/index.rst?rev=246950&r1=246949&r2=246950&view=diff
==
--- libcxx/trunk/docs/index.rst (original)
+++ libcxx/trunk/docs/index.rst Sun Sep  6 18:09:54 2015
@@ -102,14 +102,9 @@ C++ Dialect Support
 -
 
 * C++11 - Complete
-* `C++14 - Complete `_
-* `C++1z - In Progress `_
-* `Post C++14 Technical Specifications - In Progress `_
-
-.. _cxx14 status: http://libcxx.llvm.org/cxx1y_status.html
-.. _cxx1z status: http://libcxx.llvm.org/cxx1z_status.html
-.. _ts status: http://libcxx.llvm.org/ts1z_status.html
-
+* `C++14 - Complete `__
+* `C++1z - In Progress `__
+* `Post C++14 Technical Specifications - In Progress 
`__
 
 Notes and Known Issues
 --
@@ -132,9 +127,9 @@ Design Documents
 * ` design `_
 * ` design `_
 * `Status of debug mode `_
-* `Notes by Marshall Clow `_
+* `Notes by Marshall Clow`__
 
-.. _clow notes: 
https://cplusplusmusings.wordpress.com/2012/07/05/clang-and-standard-libraries-on-mac-os-x/
+.. __: 
https://cplusplusmusings.wordpress.com/2012/07/05/clang-and-standard-libraries-on-mac-os-x/
 
 Build Bots
 ---
@@ -152,37 +147,30 @@ and `Getting started with LLVM `_. Please include [libcxx] in the subject and
+`Phabricator `_. Please include 
[libcxx] in the subject and
 add `cfe-commits` as a subscriber. Also make sure you are subscribed to the
-`cfe-commits mailing list `_.
+`cfe-commits mailing list 
`_.
 
 **Discussion and Questions**
 
-Send discussions and questions to the `cfe-dev mailing list `_.
+Send discussions and questions to the
+`cfe-dev mailing list `_.
 Please include [libcxx] in the subject.
 
-.. _phab doc: http://llvm.org/docs/Phabricator.html
 
 
 Quick Links
 ===
-* `LLVM Homepage `_
-* `libc++abi Homepage `_
-* `LLVM Bugzilla`_
-* `cfe-commits Mailing List `_
-* `cfe-dev Mailing List `_
+* `LLVM Homepage `_
+* `libc++abi Homepage `_
+* `LLVM Bugzilla `_
+* `cfe-commits Mailing List`_
+* `cfe-dev Mailing List`_
 * `Browse libc++ -- SVN `_
 * `Browse libc++ -- ViewVC 
`_
-
-
-.. _`llvm`: http://llvm.org/
-.. _`libc++abi`: http://libcxxabi.llvm.org/
-.. _`LLVM Bugzilla`: http://llvm.org/bugs/
-.. _cfe-dev: http://lists.llvm.org/mailman/listinfo/cfe-dev
-.. _cfe-commits: http://lists.llvm.org/mailman/listinfo/cfe-commits


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r246948 - [X86][SSSE3] Added SSSE3 IR + assembly codegen builtin tests

2015-09-06 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Sun Sep  6 12:06:22 2015
New Revision: 246948

URL: http://llvm.org/viewvc/llvm-project?rev=246948&view=rev
Log:
[X86][SSSE3] Added SSSE3 IR + assembly codegen builtin tests

Transferred SSSE3 instructions from sse-builtins.c

Added:
cfe/trunk/test/CodeGen/ssse3-builtins.c
Modified:
cfe/trunk/test/CodeGen/sse-builtins.c

Modified: cfe/trunk/test/CodeGen/sse-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse-builtins.c?rev=246948&r1=246947&r2=246948&view=diff
==
--- cfe/trunk/test/CodeGen/sse-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse-builtins.c Sun Sep  6 12:06:22 2015
@@ -478,16 +478,6 @@ __m128 test_mm_bsrli_si128(__m128 a) {
   return _mm_bsrli_si128(a, 5);
 }
 
-__m128i test_mm_alignr_epi8(__m128i a, __m128i b) {
-  // CHECK: shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <16 x i32> 

-  return _mm_alignr_epi8(a, b, 2);
-}
-
-__m128i test2_mm_alignr_epi8(__m128i a, __m128i b) {
-  // CHECK: shufflevector <16 x i8> %{{.*}}, <16 x i8> zeroinitializer, <16 x 
i32> 
-  return _mm_alignr_epi8(a, b, 17);
-}
-
 __m128 test_mm_undefined_ps() {
   // CHECK-LABEL: @test_mm_undefined_ps
   // CHECK: ret <4 x float> undef

Added: cfe/trunk/test/CodeGen/ssse3-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ssse3-builtins.c?rev=246948&view=auto
==
--- cfe/trunk/test/CodeGen/ssse3-builtins.c (added)
+++ cfe/trunk/test/CodeGen/ssse3-builtins.c Sun Sep  6 12:06:22 2015
@@ -0,0 +1,127 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +ssse3 
-emit-llvm -o - -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +ssse3 
-S -o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include 
+
+__m128i test_mm_abs_epi8(__m128i a) {
+  // CHECK-LABEL: test_mm_abs_epi8
+  // CHECK: call <16 x i8> @llvm.x86.ssse3.pabs.b.128
+  // CHECK-ASM: pabsb %xmm{{.*}}, %xmm{{.*}}
+  return _mm_abs_epi8(a);
+}
+
+__m128i test_mm_abs_epi16(__m128i a) {
+  // CHECK-LABEL: test_mm_abs_epi16
+  // CHECK: call <8 x i16> @llvm.x86.ssse3.pabs.w.128
+  // CHECK-ASM: pabsw %xmm{{.*}}, %xmm{{.*}}
+  return _mm_abs_epi16(a);
+}
+
+__m128i test_mm_abs_epi32(__m128i a) {
+  // CHECK-LABEL: test_mm_abs_epi32
+  // CHECK: call <4 x i32> @llvm.x86.ssse3.pabs.d.128
+  // CHECK-ASM: pabsd %xmm{{.*}}, %xmm{{.*}}
+  return _mm_abs_epi32(a);
+}
+
+__m128i test_mm_alignr_epi8(__m128i a, __m128i b) {
+  // CHECK-LABEL: test_mm_alignr_epi8
+  // CHECK: shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <16 x i32> 

+  // CHECK-ASM: palignr $2, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_alignr_epi8(a, b, 2);
+}
+
+__m128i test2_mm_alignr_epi8(__m128i a, __m128i b) {
+  // CHECK-LABEL: test2_mm_alignr_epi8
+  // CHECK: shufflevector <16 x i8> %{{.*}}, <16 x i8> zeroinitializer, <16 x 
i32> 
+  // CHECK-ASM: psrldq $1, %xmm{{.*}}
+  return _mm_alignr_epi8(a, b, 17);
+}
+
+__m128i test_mm_hadd_epi16(__m128i a, __m128i b) {
+  // CHECK-LABEL: test_mm_hadd_epi16
+  // CHECK: call <8 x i16> @llvm.x86.ssse3.phadd.w.128
+  // CHECK-ASM: phaddw %xmm{{.*}}, %xmm{{.*}}
+  return _mm_hadd_epi16(a, b);
+}
+
+__m128i test_mm_hadd_epi32(__m128i a, __m128i b) {
+  // CHECK-LABEL: test_mm_hadd_epi32
+  // CHECK: call <4 x i32> @llvm.x86.ssse3.phadd.d.128
+  // CHECK-ASM: phaddd %xmm{{.*}}, %xmm{{.*}}
+  return _mm_hadd_epi32(a, b);
+}
+
+__m128i test_mm_hadds_epi16(__m128i a, __m128i b) {
+  // CHECK-LABEL: test_mm_hadds_epi16
+  // CHECK: call <8 x i16> @llvm.x86.ssse3.phadd.sw.128
+  // CHECK-ASM: phaddsw %xmm{{.*}}, %xmm{{.*}}
+  return _mm_hadds_epi16(a, b);
+}
+
+__m128i test_mm_hsub_epi16(__m128i a, __m128i b) {
+  // CHECK-LABEL: test_mm_hsub_epi16
+  // CHECK: call <8 x i16> @llvm.x86.ssse3.phsub.w.128
+  // CHECK-ASM: phsubw %xmm{{.*}}, %xmm{{.*}}
+  return _mm_hsub_epi16(a, b);
+}
+
+__m128i test_mm_hsub_epi32(__m128i a, __m128i b) {
+  // CHECK-LABEL: test_mm_hsub_epi32
+  // CHECK: call <4 x i32> @llvm.x86.ssse3.phsub.d.128
+  // CHECK-ASM: phsubd %xmm{{.*}}, %xmm{{.*}}
+  return _mm_hsub_epi32(a, b);
+}
+
+__m128i test_mm_hsubs_epi16(__m128i a, __m128i b) {
+  // CHECK-LABEL: test_mm_hsubs_epi16
+  // CHECK: call <8 x i16> @llvm.x86.ssse3.phsub.sw.128
+  // CHECK-ASM: phsubsw %xmm{{.*}}, %xmm{{.*}}
+  return _mm_hsubs_epi16(a, b);
+}
+
+__m128i test_mm_maddubs_epi16(__m128i a, __m128i b) {
+  // CHECK-LABEL: test_mm_maddubs_epi16
+  // CHECK: call <8 x i16> @llvm.x86.ssse3.pmadd.ub.sw.128
+  // CHECK-ASM: pmaddubsw %xmm{{.*}},  %xmm{{.*}}
+  return _mm_maddubs_epi16(a, b);
+}
+
+__m128i test_mm_mulhrs_epi16(__m128i a, __m128i b) {
+  // CHECK-LABEL: test_mm_mulhrs_epi16
+  // CHECK: call <8 x i16> @llvm.x86.ssse3.pmul.hr.sw.128
+  // CHECK-ASM: pmulh

r246947 - [X86]][SSE3] Added SSE41 IR + assembly codegen builtin tests

2015-09-06 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Sun Sep  6 11:38:17 2015
New Revision: 246947

URL: http://llvm.org/viewvc/llvm-project?rev=246947&view=rev
Log:
[X86]][SSE3] Added SSE41 IR + assembly codegen builtin tests

Transferred SSE41 instructions from sse-builtins.c

Added:
cfe/trunk/test/CodeGen/sse41-builtins.c
Modified:
cfe/trunk/test/CodeGen/sse-builtins.c

Modified: cfe/trunk/test/CodeGen/sse-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse-builtins.c?rev=246947&r1=246946&r2=246947&view=diff
==
--- cfe/trunk/test/CodeGen/sse-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse-builtins.c Sun Sep  6 11:38:17 2015
@@ -135,54 +135,6 @@ __m128i test_loadl_epi64(void* y) {
   return _mm_loadl_epi64(y);
 }
 
-__m128i test_mm_minpos_epu16(__m128i x) {
-  // CHECK: define {{.*}} @test_mm_minpos_epu16
-  // CHECK: @llvm.x86.sse41.phminposuw
-  return _mm_minpos_epu16(x);
-}
-
-__m128i test_mm_mpsadbw_epu8(__m128i x, __m128i y) {
-  // CHECK: define {{.*}} @test_mm_mpsadbw_epu8
-  // CHECK: @llvm.x86.sse41.mpsadbw
-  return _mm_mpsadbw_epu8(x, y, 1);
-}
-
-__m128 test_mm_dp_ps(__m128 x, __m128 y) {
-  // CHECK: define {{.*}} @test_mm_dp_ps
-  // CHECK: @llvm.x86.sse41.dpps
-  return _mm_dp_ps(x, y, 2);
-}
-
-__m128d test_mm_dp_pd(__m128d x, __m128d y) {
-  // CHECK: define {{.*}} @test_mm_dp_pd
-  // CHECK: @llvm.x86.sse41.dppd
-  return _mm_dp_pd(x, y, 2);
-}
-
-__m128 test_mm_round_ps(__m128 x) {
-  // CHECK: define {{.*}} @test_mm_round_ps
-  // CHECK: @llvm.x86.sse41.round.ps
-  return _mm_round_ps(x, 2);
-}
-
-__m128 test_mm_round_ss(__m128 x, __m128 y) {
-  // CHECK: define {{.*}} @test_mm_round_ss
-  // CHECK: @llvm.x86.sse41.round.ss
-  return _mm_round_ss(x, y, 2);
-}
-
-__m128d test_mm_round_pd(__m128d x) {
-  // CHECK: define {{.*}} @test_mm_round_pd
-  // CHECK: @llvm.x86.sse41.round.pd
-  return _mm_round_pd(x, 2);
-}
-
-__m128d test_mm_round_sd(__m128d x, __m128d y) {
-  // CHECK: define {{.*}} @test_mm_round_sd
-  // CHECK: @llvm.x86.sse41.round.sd
-  return _mm_round_sd(x, y, 2);
-}
-
 void test_storel_epi64(__m128i x, void* y) {
   // CHECK-LABEL: define void @test_storel_epi64
   // CHECK: store {{.*}} i64* {{.*}}, align 1{{$}}
@@ -214,48 +166,6 @@ void test_extract_epi16(__m128i __a) {
   _mm_extract_epi16(__a, 8);
 }
 
-int test_extract_ps(__m128i __a) {
-  // CHECK-LABEL: @test_extract_ps
-  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
-  return _mm_extract_ps(__a, 4);
-}
-
-int test_extract_epi8(__m128i __a) {
-  // CHECK-LABEL: @test_extract_epi8
-  // CHECK: extractelement <16 x i8> %{{.*}}, i32 0
-  return _mm_extract_epi8(__a, 16);
-}
-
-int test_extract_epi32(__m128i __a) {
-  // CHECK-LABEL: @test_extract_epi32
-  // CHECK: extractelement <4 x i32> %{{.*}}, i32 0
-  return _mm_extract_epi32(__a, 4);
-}
-
-void test_insert_epi32(__m128i __a, int b) {
-  // CHECK-LABEL: @test_insert_epi32
-  // CHECK: insertelement <4 x i32> %{{.*}}, i32 %{{.*}}, i32 0
-   _mm_insert_epi32(__a, b, 4);
-}
-
-__m128d test_blend_pd(__m128d V1, __m128d V2) {
-  // CHECK-LABEL: @test_blend_pd
-  // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x 
i32> 
-  return _mm_blend_pd(V1, V2, 1);
-}
-
-__m128 test_blend_ps(__m128 V1, __m128 V2) {
-  // CHECK-LABEL: @test_blend_ps
-  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> 

-  return _mm_blend_ps(V1, V2, 5);
-}
-
-__m128i test_blend_epi16(__m128i V1, __m128i V2) {
-  // CHECK-LABEL: @test_blend_epi16
-  // CHECK: shufflevector <8 x i16> %{{.*}}, <8 x i16> %{{.*}}, <8 x i32> 
-  return _mm_blend_epi16(V1, V2, 42);
-}
-
 __m128 test_mm_cmpeq_ss(__m128 __a, __m128 __b) {
   // CHECK-LABEL: @test_mm_cmpeq_ss
   // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 
0)
@@ -578,78 +488,6 @@ __m128i test2_mm_alignr_epi8(__m128i a,
   return _mm_alignr_epi8(a, b, 17);
 }
 
-__m128i test_mm_cvtepi8_epi16(__m128i a) {
-  // CHECK-LABEL: @test_mm_cvtepi8_epi16
-  // CHECK: call <8 x i16> @llvm.x86.sse41.pmovsxbw(<16 x i8> {{.*}})
-  return _mm_cvtepi8_epi16(a);
-}
-
-__m128i test_mm_cvtepi8_epi32(__m128i a) {
-  // CHECK-LABEL: @test_mm_cvtepi8_epi32
-  // CHECK: call <4 x i32> @llvm.x86.sse41.pmovsxbd(<16 x i8> {{.*}})
-  return _mm_cvtepi8_epi32(a);
-}
-
-__m128i test_mm_cvtepi8_epi64(__m128i a) {
-  // CHECK-LABEL: @test_mm_cvtepi8_epi64
-  // CHECK: call <2 x i64> @llvm.x86.sse41.pmovsxbq(<16 x i8> {{.*}})
-  return _mm_cvtepi8_epi64(a);
-}
-
-__m128i test_mm_cvtepi16_epi32(__m128i a) {
-  // CHECK-LABEL: @test_mm_cvtepi16_epi32
-  // CHECK: call <4 x i32> @llvm.x86.sse41.pmovsxwd(<8 x i16> {{.*}})
-  return _mm_cvtepi16_epi32(a);
-}
-
-__m128i test_mm_cvtepi16_epi64(__m128i a) {
-  // CHECK-LABEL: @test_mm_cvtepi16_epi64
-  // CHECK: call <2 x i64> @llvm.x86.sse41.pmovsxwq(<8 x i16> {{.*}})
-  return _mm_cvtepi16_epi64(a);
-}
-
-__m128i test_mm_cvtepi32_epi64(__m128i a) {
-  // CHECK-LABEL: @t

r246946 - Refactoring of how ARMTargetInfo handles default target features.

2015-09-06 Thread Alexandros Lamprineas via cfe-commits
Author: alelab01
Date: Sun Sep  6 11:15:45 2015
New Revision: 246946

URL: http://llvm.org/viewvc/llvm-project?rev=246946&view=rev
Log:
Refactoring of how ARMTargetInfo handles default target features.

Differential Revision: http://reviews.llvm.org/D11299

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGen/arm-target-features.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=246946&r1=246945&r2=246946&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Sun Sep  6 11:15:45 2015
@@ -4442,37 +4442,20 @@ public:
   bool initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine 
&Diags,
   StringRef CPU,
   std::vector &FeaturesVec) const override {
-if (CPU == "arm1136jf-s" || CPU == "arm1176jzf-s" || CPU == "mpcore")
-  Features["vfp2"] = true;
-else if (CPU == "cortex-a8" || CPU == "cortex-a9") {
-  Features["vfp3"] = true;
-  Features["neon"] = true;
-}
-else if (CPU == "cortex-a5") {
-  Features["vfp4"] = true;
-  Features["neon"] = true;
-} else if (CPU == "swift" || CPU == "cortex-a7" ||
-   CPU == "cortex-a12" || CPU == "cortex-a15" ||
-   CPU == "cortex-a17" || CPU == "krait") {
-  Features["vfp4"] = true;
-  Features["neon"] = true;
-  Features["hwdiv"] = true;
-  Features["hwdiv-arm"] = true;
-} else if (CPU == "cyclone" || CPU == "cortex-a53" || CPU == "cortex-a57" 
||
-   CPU == "cortex-a72") {
-  Features["fp-armv8"] = true;
-  Features["neon"] = true;
-  Features["hwdiv"] = true;
-  Features["hwdiv-arm"] = true;
-  Features["crc"] = true;
-  Features["crypto"] = true;
-} else if (CPU == "cortex-r5" || CPU == "cortex-r7" || ArchVersion == 8) {
-  Features["hwdiv"] = true;
-  Features["hwdiv-arm"] = true;
-} else if (CPU == "cortex-m3" || CPU == "cortex-m4" || CPU == "cortex-m7" 
||
-   CPU == "sc300" || CPU == "cortex-r4" || CPU == "cortex-r4f") {
-  Features["hwdiv"] = true;
-}
+   
+std::vector TargetFeatures;
+
+// get default FPU features
+unsigned FPUKind = llvm::ARM::getDefaultFPU(CPU);
+llvm::ARM::getFPUFeatures(FPUKind, TargetFeatures);
+
+// get default Extension features
+unsigned Extensions = llvm::ARM::getDefaultExtensions(CPU);
+llvm::ARM::getExtensionFeatures(Extensions, TargetFeatures);
+
+for (const char *Feature : TargetFeatures)
+  if (Feature[0] == '+')
+Features[Feature+1] = true; 
 
 if (ArchVersion < 6  || 
(ArchVersion == 6 && ArchProfile == llvm::ARM::PK_M))

Modified: cfe/trunk/test/CodeGen/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-target-features.c?rev=246946&r1=246945&r2=246946&view=diff
==
--- cfe/trunk/test/CodeGen/arm-target-features.c (original)
+++ cfe/trunk/test/CodeGen/arm-target-features.c Sun Sep  6 11:15:45 2015
@@ -1,10 +1,13 @@
 // REQUIRES: arm-registered-target
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a8 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3
-// RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a9 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3
 // CHECK-VFP3: "target-features"="+neon,+vfp3"
 
 
+// RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a9 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-FP16
+// CHECK-VFP3-FP16: "target-features"="+fp16,+neon,+vfp3"
+
+
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a5 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4
 // CHECK-VFP4: "target-features"="+neon,+vfp4"
 
@@ -25,10 +28,30 @@
 // CHECK-BASIC-V8: 
"target-features"="+crc,+crypto,+fp-armv8,+hwdiv,+hwdiv-arm,+neon"
 
 
+// RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-r5f 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-D16-DIV
+// CHECK-VFP3-D16-DIV: "target-features"="+d16,+hwdiv,+hwdiv-arm,+vfp3"
+
+
+// RUN: %clang_cc1 -triple armv7-linux-gnueabi -target-cpu cortex-r4f 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-D16-THUMB-DIV
+// CHECK-VFP3-D16-THUMB-DIV: "target-features"="+d16,+hwdiv,+vfp3"
+
+
+// RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-r7 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-D16-FP16-DIV
+// CHECK-VFP3-D16-FP16-DIV: 
"target-features"="+d16,+fp16,+hwdiv,+hwdiv-arm,+vfp3"
+
+
+// RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-m4f 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-D16-SP-THUMB-DIV
+// CHECK-VFP4-D16-SP-THUMB-DIV: 
"target-features"="+d16,+fp-only-sp,+hwdiv,+vfp4"
+
+
+// RUN: %clang

r246945 - [X86]][SSE3] Added SSE3 IR + assembly codegen builtin tests

2015-09-06 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Sun Sep  6 09:45:13 2015
New Revision: 246945

URL: http://llvm.org/viewvc/llvm-project?rev=246945&view=rev
Log:
[X86]][SSE3] Added SSE3 IR + assembly codegen builtin tests

Added:
cfe/trunk/test/CodeGen/sse3-builtins.c

Added: cfe/trunk/test/CodeGen/sse3-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse3-builtins.c?rev=246945&view=auto
==
--- cfe/trunk/test/CodeGen/sse3-builtins.c (added)
+++ cfe/trunk/test/CodeGen/sse3-builtins.c Sun Sep  6 09:45:13 2015
@@ -0,0 +1,85 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +sse3 
-emit-llvm -o - -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +sse3 -S 
-o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include 
+
+__m128d test_mm_addsub_pd(__m128d A, __m128d B) {
+  // CHECK-LABEL: test_mm_addsub_pd
+  // CHECK: call <2 x double> @llvm.x86.sse3.addsub.pd
+  // CHECK-ASM: addsubpd %xmm{{.*}}, %xmm{{.*}}
+  return _mm_addsub_pd(A, B);
+}
+
+__m128 test_mm_addsub_ps(__m128 A, __m128 B) {
+  // CHECK-LABEL: test_mm_addsub_ps
+  // CHECK: call <4 x float> @llvm.x86.sse3.addsub.ps
+  // CHECK-ASM: addsubps %xmm{{.*}}, %xmm{{.*}}
+  return _mm_addsub_ps(A, B);
+}
+
+__m128d test_mm_hadd_pd(__m128d A, __m128d B) {
+  // CHECK-LABEL: test_mm_hadd_pd
+  // CHECK: call <2 x double> @llvm.x86.sse3.hadd.pd
+  // CHECK-ASM: haddpd %xmm{{.*}}, %xmm{{.*}}
+  return _mm_hadd_pd(A, B);
+}
+
+__m128 test_mm_hadd_ps(__m128 A, __m128 B) {
+  // CHECK-LABEL: test_mm_hadd_ps
+  // CHECK: call <4 x float> @llvm.x86.sse3.hadd.ps
+  // CHECK-ASM: haddps %xmm{{.*}}, %xmm{{.*}}
+  return _mm_hadd_ps(A, B);
+}
+
+__m128d test_mm_hsub_pd(__m128d A, __m128d B) {
+  // CHECK-LABEL: test_mm_hsub_pd
+  // CHECK: call <2 x double> @llvm.x86.sse3.hsub.pd
+  // CHECK-ASM: hsubpd %xmm{{.*}}, %xmm{{.*}}
+  return _mm_hsub_pd(A, B);
+}
+
+__m128 test_mm_hsub_ps(__m128 A, __m128 B) {
+  // CHECK-LABEL: test_mm_hsub_ps
+  // CHECK: call <4 x float> @llvm.x86.sse3.hsub.ps
+  // CHECK-ASM: hsubps %xmm{{.*}}, %xmm{{.*}}
+  return _mm_hsub_ps(A, B);
+}
+
+__m128i test_mm_lddqu_si128(__m128i const* P) {
+  // CHECK-LABEL: test_mm_lddqu_si128
+  // CHECK: call <16 x i8> @llvm.x86.sse3.ldu.dq
+  // CHECK-ASM: lddqu
+  return _mm_lddqu_si128(P);
+}
+
+__m128d test_mm_loaddup_pd(double const* P) {
+  // CHECK-LABEL: test_mm_loaddup_pd
+  // CHECK: load double*
+  // CHECK-ASM: movddup %xmm{{.*}}
+  return _mm_loaddup_pd(P);
+}
+
+__m128d test_mm_movedup_pd(__m128d A) {
+  // CHECK-LABEL: test_mm_movedup_pd
+  // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x 
i32> zeroinitializer
+  // CHECK-ASM: movddup %xmm{{.*}}, %xmm{{.*}}
+  return _mm_movedup_pd(A);
+}
+
+__m128 test_mm_movehdup_ps(__m128 A) {
+  // CHECK-LABEL: test_mm_movehdup_ps
+  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> 

+  // CHECK-ASM: movshdup %xmm{{.*}}, %xmm{{.*}}
+  return _mm_movehdup_ps(A);
+}
+
+__m128 test_mm_movedup_ps(__m128 A) {
+  // CHECK-LABEL: test_mm_movedup_ps
+  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> 

+  // CHECK-ASM: movsldup %xmm{{.*}}, %xmm{{.*}}
+  return _mm_moveldup_ps(A);
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r246944 - [X86]][SSE42] Added SSE42 IR + assembly codegen builtin tests

2015-09-06 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Sun Sep  6 09:05:33 2015
New Revision: 246944

URL: http://llvm.org/viewvc/llvm-project?rev=246944&view=rev
Log:
[X86]][SSE42] Added SSE42 IR + assembly codegen builtin tests

Added:
cfe/trunk/test/CodeGen/sse42-builtins.c

Added: cfe/trunk/test/CodeGen/sse42-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse42-builtins.c?rev=246944&view=auto
==
--- cfe/trunk/test/CodeGen/sse42-builtins.c (added)
+++ cfe/trunk/test/CodeGen/sse42-builtins.c Sun Sep  6 09:05:33 2015
@@ -0,0 +1,141 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +sse4.2 
-emit-llvm -o - -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +sse4.2 
-S -o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include 
+
+__m128i test_mm_cmpgt_epi64(__m128i A, __m128i B) {
+  // CHECK-LABEL: test_mm_cmpgt_epi64
+  // CHECK: icmp sgt <2 x i64>
+  // CHECK-ASM: pcmpgtq %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpgt_epi64(A, B);
+}
+
+int test_mm_cmpestra(__m128i A, int LA, __m128i B, int LB) {
+  // CHECK-LABEL: test_mm_cmpestra
+  // CHECK: @llvm.x86.sse42.pcmpestria128
+  // CHECK-ASM: pcmpestri $7, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpestra(A, LA, B, LB, 7);
+}
+
+int test_mm_cmpestrc(__m128i A, int LA, __m128i B, int LB) {
+  // CHECK-LABEL: test_mm_cmpestrc
+  // CHECK: @llvm.x86.sse42.pcmpestric128
+  // CHECK-ASM: pcmpestri $7, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpestrc(A, LA, B, LB, 7);
+}
+
+int test_mm_cmpestri(__m128i A, int LA, __m128i B, int LB) {
+  // CHECK-LABEL: test_mm_cmpestri
+  // CHECK: @llvm.x86.sse42.pcmpestri128
+  // CHECK-ASM: pcmpestri $7, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpestri(A, LA, B, LB, 7);
+}
+
+__m128i test_mm_cmpestrm(__m128i A, int LA, __m128i B, int LB) {
+  // CHECK-LABEL: test_mm_cmpestrm
+  // CHECK: @llvm.x86.sse42.pcmpestrm128
+  // CHECK-ASM: pcmpestrm $7, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpestrm(A, LA, B, LB, 7);
+}
+
+int test_mm_cmpestro(__m128i A, int LA, __m128i B, int LB) {
+  // CHECK-LABEL: test_mm_cmpestro
+  // CHECK: @llvm.x86.sse42.pcmpestrio128
+  // CHECK-ASM: pcmpestri $7, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpestro(A, LA, B, LB, 7);
+}
+
+int test_mm_cmpestrs(__m128i A, int LA, __m128i B, int LB) {
+  // CHECK-LABEL: test_mm_cmpestrs
+  // CHECK: @llvm.x86.sse42.pcmpestris128
+  // CHECK-ASM: pcmpestri $7, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpestrs(A, LA, B, LB, 7);
+}
+
+int test_mm_cmpestrz(__m128i A, int LA, __m128i B, int LB) {
+  // CHECK-LABEL: test_mm_cmpestrz
+  // CHECK: @llvm.x86.sse42.pcmpestriz128
+  // CHECK-ASM: pcmpestri $7, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpestrz(A, LA, B, LB, 7);
+}
+
+int test_mm_cmpistra(__m128i A, __m128i B) {
+  // CHECK-LABEL: test_mm_cmpistra
+  // CHECK: @llvm.x86.sse42.pcmpistria128
+  // CHECK-ASM: pcmpistri $7, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpistra(A, B, 7);
+}
+
+int test_mm_cmpistrc(__m128i A, __m128i B) {
+  // CHECK-LABEL: test_mm_cmpistrc
+  // CHECK: @llvm.x86.sse42.pcmpistric128
+  // CHECK-ASM: pcmpistri $7, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpistrc(A, B, 7);
+}
+
+int test_mm_cmpistri(__m128i A, __m128i B) {
+  // CHECK-LABEL: test_mm_cmpistri
+  // CHECK: @llvm.x86.sse42.pcmpistri128
+  // CHECK-ASM: pcmpistri $7, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpistri(A, B, 7);
+}
+
+__m128i test_mm_cmpistrm(__m128i A, __m128i B) {
+  // CHECK-LABEL: test_mm_cmpistrm
+  // CHECK: @llvm.x86.sse42.pcmpistrm128
+  // CHECK-ASM: pcmpistrm $7, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpistrm(A, B, 7);
+}
+
+int test_mm_cmpistro(__m128i A, __m128i B) {
+  // CHECK-LABEL: test_mm_cmpistro
+  // CHECK: @llvm.x86.sse42.pcmpistrio128
+  // CHECK-ASM: pcmpistri $7, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpistro(A, B, 7);
+}
+
+int test_mm_cmpistrs(__m128i A, __m128i B) {
+  // CHECK-LABEL: test_mm_cmpistrs
+  // CHECK: @llvm.x86.sse42.pcmpistris128
+  // CHECK-ASM: pcmpistri $7, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpistrs(A, B, 7);
+}
+
+int test_mm_cmpistrz(__m128i A, __m128i B) {
+  // CHECK-LABEL: test_mm_cmpistrz
+  // CHECK: @llvm.x86.sse42.pcmpistriz128
+  // CHECK-ASM: pcmpistri $7, %xmm{{.*}}, %xmm{{.*}}
+  return _mm_cmpistrz(A, B, 7);
+}
+
+unsigned int test_mm_crc32_u8(unsigned int CRC, unsigned char V) {
+  // CHECK-LABEL: test_mm_crc32_u8
+  // CHECK: call i32 @llvm.x86.sse42.crc32.32.8
+  // CHECK-ASM: crc32
+  return _mm_crc32_u8(CRC, V);
+}
+
+unsigned int test_mm_crc32_u16(unsigned int CRC, unsigned short V) {
+  // CHECK-LABEL: test_mm_crc32_u16
+  // CHECK: call i32 @llvm.x86.sse42.crc32.32.16
+  // CHECK-ASM: crc32
+  return _mm_crc32_u16(CRC, V);
+}
+
+unsigned int test_mm_crc32_u32(unsigned int CRC, unsigned int V) {
+  // CHECK-LABEL: test_mm_crc32_u32
+  // CHECK: call i32 @llvm.x86.sse42.crc

[PATCH] D12666: [LibClang] Fix clang_getCursorAvailability

2015-09-06 Thread Sergey Kalinichev via cfe-commits
skalinichev created this revision.
skalinichev added a subscriber: cfe-commits.

Make it report correct availability kind for deleted methods



http://reviews.llvm.org/D12666

Files:
  test/Index/availability.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6400,7 +6400,7 @@
 
 static CXAvailabilityKind getCursorAvailabilityForDecl(const Decl *D) {
   if (isa(D) && cast(D)->isDeleted())
-return CXAvailability_Available;
+return CXAvailability_NotAvailable;
   
   switch (D->getAvailability()) {
   case AR_Available:
Index: test/Index/availability.cpp
===
--- /dev/null
+++ test/Index/availability.cpp
@@ -0,0 +1,13 @@
+void foo() = delete;
+
+struct Foo {
+  int foo() = delete;
+  Foo() = delete;
+};
+
+
+// RUN: c-index-test -test-print-type --std=c++11 %s | FileCheck %s
+// CHECK: FunctionDecl=foo:1:6 (unavailable) [type=void ()] 
[typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]
+// CHECK: StructDecl=Foo:3:8 (Definition) [type=Foo] [typekind=Record] 
[isPOD=1]
+// CHECK: CXXMethod=foo:4:7 (unavailable) [type=int ()] 
[typekind=FunctionProto] [resulttype=int] [resulttypekind=Int] [isPOD=0]
+// CHECK: CXXConstructor=Foo:5:3 (unavailable) [type=void ()] 
[typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6400,7 +6400,7 @@
 
 static CXAvailabilityKind getCursorAvailabilityForDecl(const Decl *D) {
   if (isa(D) && cast(D)->isDeleted())
-return CXAvailability_Available;
+return CXAvailability_NotAvailable;
   
   switch (D->getAvailability()) {
   case AR_Available:
Index: test/Index/availability.cpp
===
--- /dev/null
+++ test/Index/availability.cpp
@@ -0,0 +1,13 @@
+void foo() = delete;
+
+struct Foo {
+  int foo() = delete;
+  Foo() = delete;
+};
+
+
+// RUN: c-index-test -test-print-type --std=c++11 %s | FileCheck %s
+// CHECK: FunctionDecl=foo:1:6 (unavailable) [type=void ()] [typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]
+// CHECK: StructDecl=Foo:3:8 (Definition) [type=Foo] [typekind=Record] [isPOD=1]
+// CHECK: CXXMethod=foo:4:7 (unavailable) [type=int ()] [typekind=FunctionProto] [resulttype=int] [resulttypekind=Int] [isPOD=0]
+// CHECK: CXXConstructor=Foo:5:3 (unavailable) [type=void ()] [typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits