Files
clang-p2996/clang/test/Preprocessor/feature_tests.c
Hal Finkel c4d7c82c7f Add the intrinsic __builtin_convertvector
LLVM supports applying conversion instructions to vectors of the same number of
elements (fptrunc, fptosi, etc.) but there had been no way for a Clang user to
cause such instructions to be generated when using builtin vector types.

C-style casting on vectors is already defined in terms of bitcasts, and so
cannot be used for these conversions as well (without leading to a very
confusing set of semantics). As a result, this adds a __builtin_convertvector
intrinsic (patterned after the OpenCL __builtin_astype intrinsic). This is
intended to aid the creation of vector intrinsic headers that create generic IR
instead of target-dependent intrinsics (in other words, this is a generic
_mm_cvtepi32_ps). As noted in the documentation, the action of
__builtin_convertvector is defined in terms of the action of a C-style cast on
each vector element.

llvm-svn: 190915
2013-09-18 03:29:45 +00:00

56 lines
1.6 KiB
C

// RUN: %clang_cc1 %s -triple=i686-apple-darwin9
// RUN: %clang_cc1 %s -E -triple=i686-apple-darwin9
#ifndef __has_feature
#error Should have __has_feature
#endif
#if __has_feature(something_we_dont_have)
#error Bad
#endif
#if !__has_builtin(__builtin_huge_val) || \
!__has_builtin(__builtin_shufflevector) || \
!__has_builtin(__builtin_convertvector) || \
!__has_builtin(__builtin_trap) || \
!__has_builtin(__c11_atomic_init) || \
!__has_feature(attribute_analyzer_noreturn) || \
!__has_feature(attribute_overloadable)
#error Clang should have these
#endif
#if __has_builtin(__builtin_insanity)
#error Clang should not have this
#endif
#if !__has_feature(__attribute_deprecated_with_message__)
#error Feature name in double underscores does not work
#endif
// Make sure we have x86 builtins only (forced with target triple).
#if !__has_builtin(__builtin_ia32_emms) || \
__has_builtin(__builtin_altivec_abs_v4sf)
#error Broken handling of target-specific builtins
#endif
// Macro expansion does not occur in the parameter to __has_builtin,
// __has_feature, etc. (as is also expected behaviour for ordinary
// macros), so the following should not expand:
#define MY_ALIAS_BUILTIN __c11_atomic_init
#define MY_ALIAS_FEATURE attribute_overloadable
#if __has_builtin(MY_ALIAS_BUILTIN) || __has_feature(MY_ALIAS_FEATURE)
#error Alias expansion not allowed
#endif
// But deferring should expand:
#define HAS_BUILTIN(X) __has_builtin(X)
#define HAS_FEATURE(X) __has_feature(X)
#if !HAS_BUILTIN(MY_ALIAS_BUILTIN) || !HAS_FEATURE(MY_ALIAS_FEATURE)
#error Expansion should have occurred
#endif