[cfe-dev] [PATCH] Add __builtin_convertvector

Erik Schnetter schnetter at gmail.com
Fri Sep 13 10:38:51 PDT 2013


Hal

__builtin_astype is not a builtin that is recognized by the front-end -- at least Builtins.def does not define it. Is this because one expects to be able to use type cases for this? Note that this does not work in OpenCL, where type casts between vector types are illegal. To implement OpenCL's astype functions, an explicit __builtin_astype (similar to __builtin_convervector) would be handy.

-erik

On 2013-09-13, at 9:16 , hfinkel at anl.gov wrote:

> Hi eli.friedman,
> 
> LLVM supports applying conversion instructions to vectors of the same number of elements (fptrunc, fptosi, etc.) but currently there is 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, I'd like to add this new intrinsic (patterned after the OpenCL __builtin_astype intrinsic). This will 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).
> 
> Please review.
> 
> http://llvm-reviews.chandlerc.com/D1677
> 
> Files:
>  docs/LanguageExtensions.rst
>  include/clang/AST/Expr.h
>  include/clang/AST/RecursiveASTVisitor.h
>  include/clang/Basic/Builtins.def
>  include/clang/Basic/DiagnosticSemaKinds.td
>  include/clang/Basic/StmtNodes.td
>  include/clang/Basic/TokenKinds.def
>  include/clang/Sema/Sema.h
>  include/clang/Serialization/ASTBitCodes.h
>  lib/AST/Expr.cpp
>  lib/AST/ExprClassification.cpp
>  lib/AST/ExprConstant.cpp
>  lib/AST/ItaniumMangle.cpp
>  lib/AST/StmtPrinter.cpp
>  lib/AST/StmtProfile.cpp
>  lib/CodeGen/CGExprScalar.cpp
>  lib/Parse/ParseExpr.cpp
>  lib/Sema/SemaExceptionSpec.cpp
>  lib/Sema/SemaExpr.cpp
>  lib/Sema/TreeTransform.h
>  lib/Serialization/ASTReaderStmt.cpp
>  lib/Serialization/ASTWriterStmt.cpp
>  lib/StaticAnalyzer/Core/ExprEngine.cpp
>  test/CodeGen/convertvector.c
>  test/PCH/exprs.h
>  test/Preprocessor/feature_tests.c
>  test/Sema/convertvector.c
>  tools/libclang/CXCursor.cpp
>  tools/libclang/RecursiveASTVisitor.h
> <D1677.1.patch>_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-- 
Erik Schnetter <schnetter at gmail.com>
http://www.perimeterinstitute.ca/personal/eschnetter/

My email is as private as my paper mail. I therefore support encrypting
and signing email messages. Get my PGP key from http://pgp.mit.edu/.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130913/ed0ac8f7/attachment.sig>


More information about the cfe-dev mailing list