[cfe-dev] TreeTransform: QualType for OpenCL float4
Sahasrabuddhe, Sameer
Sameer.Sahasrabuddhe at amd.com
Thu Jan 22 10:46:52 PST 2015
Sema::addImplicitTypedef() seems to be meant for registering a "name" for a type, although I have never used it myself! Can't make out if this will help your purpose, which is to print "float16" instead of the entire extended vector syntax.
Sameer.
________________________________________
From: Christoph Viebig (lists) [lists at christoph-viebig.de]
Sent: Thursday, January 22, 2015 5:31 PM
To: cfe-dev at cs.uiuc.edu; Sahasrabuddhe, Sameer
Subject: Re: [cfe-dev] TreeTransform: QualType for OpenCL float4
Hi Sameer,
thank you very much for your answer. It indeed works fine, altough it seems that
pointer types can not be converted by
SemaRef.getASTContext().getExtVectorType(Param->getType(), 4);
because assert(vecType->isBuiltinType() || vecType->isDependentType()); is
failing in ASTContext.cpp.
The print method returns for such a transformed ParmVarDecl:
float data __attribute__((ext_vector_type(4)))
which is also reflected in the AST dump:
ParmVarDecl 0x2aa64f0 <line:2:5, col:11> col:11 data 'float
__attribute__((ext_vector_type(4)))'
If I declare a float16 variable in the program that's parsed the original type
name is preserved (float16):
'float16':'float __attribute__((ext_vector_type(16)))'
as you can see here:
DeclStmt 0x2aa63e0 <line:4:5, col:26>
`-VarDecl 0x2aa6350 <col:5,
../libclc/generic/include/clc/float/definitions.h:1:25>
demoMinReductionKernel.cl:4:13 agg 'float16':'float
__attribute__((ext_vector_type(16)))' cinit
`-ImplicitCastExpr 0x2aa63c8
<../libclc/generic/include/clc/float/definitions.h:1:25> 'float16':'float
__attribute__((ext_vector_type(16)))' <VectorSplat>
`-FloatingLiteral 0x2aa63a8 <col:25> 'float' 3.402823e+38
Do you now if there is some sort of alias that needs to be modified or set as
well?
Best regards
Christoph
> Sameer Sahasrabuddhe <sameer.sahasrabuddhe at amd.com> hat am 22. Januar 2015 um
> 07:53 geschrieben:
>
> On 1/21/2015 11:35 PM, Christoph Viebig (lists) wrote:
>
> > >
> > My question is now: How can I construct or retrieve an instance of
> > Type that represents OpenCL float4 (e.g. from Sema or Context)?
> >
> > > OpenCL vector types are represented as "extended vectors" in Clang
>
> http://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors
>
> AstContext provides a method to construct these as a QualType:
> http://clang.llvm.org/doxygen/classclang_1_1ASTContext.html
>
> QualType getExtVectorType (QualType VectorType, unsigned NumElts) const
> Return the unique reference to an extended vector type of the specified
> element type and size.
>
> Is this what you need?
>
> Sameer.
>
More information about the cfe-dev
mailing list