mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-21 04:25:45 -04:00

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
18 lines
564 B
C
18 lines
564 B
C
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
|
|
typedef double vector4double __attribute__((__vector_size__(32)));
|
|
typedef float vector8float __attribute__((__vector_size__(32)));
|
|
|
|
vector8float foo1(vector4double x) {
|
|
return __builtin_convertvector(x, vector8float); // expected-error {{same number of elements}}
|
|
}
|
|
|
|
float foo2(vector4double x) {
|
|
return __builtin_convertvector(x, float); // expected-error {{must be a vector type}}
|
|
}
|
|
|
|
vector8float foo3(double x) {
|
|
return __builtin_convertvector(x, vector8float); // expected-error {{must be a vector}}
|
|
}
|
|
|