[cfe-dev] Adding new data type

kalyan ponnala ponnala.kalyan at gmail.com
Fri Apr 30 17:38:21 PDT 2010


Hi guys,

I was trying to add this header file named "NEW_DATATYPES.h"  with the
following information into clang.

typedef int int_2 __attribute__((ext_vector_type(2)));

I added it to clang\lib\Headers. And in the source program when I try to do:
>>code-1:

int main()
{
    int_2 abc = { 1, 2 };
    int_2 bbc = { 3, 4} ;
    abc.x = bbc.y;
return 0;
}

clang gives me an error. saying that it does not identify int_2.
When I add the header file's name "NEW_DATATYPES.h" to the source like
below, clang compiles the code fine.
>>code2:

#include "NEW_DATATYPES.h"
int main()
{
    int_2 abc = { 1, 2 };
    int_2 bbc = { 3, 4} ;
    abc.x = bbc.y;
return 0;
}

But what I want is that the clang should be able to compile the code-1 fine
where I dont have to add the header file explicitly. Can someone please tell
me how to do this without actually making any changes to the existing clang
architecture. I am trying not to disturb the code.

Thanks a ton.

Kalyan

On Fri, Apr 30, 2010 at 2:08 AM, kalyan ponnala <ponnala.kalyan at gmail.com>wrote:

>
> hi,
>
> Thanks for the replies. @john :  I am looking into "typedef int int_4
> __attribute__((ext_vector_type(4)));" way of adding the vector data type. I
> do not want to change the array type to vector type. Right now I am trying
> to add this as a header file into the clang architecture so that it won't
> look bad and at the same time it would make the new data type "int_4" look
> like its a built in data type in clang when we write code at source level. I
> am still trying to figure it out. It looks like headers added to
> clang/lib/Headers are not recognized as I thought they would be. I am using
> visual studio 2008 on windows 7.
>
> Thanks.
>
>
>
> On Thu, Apr 29, 2010 at 7:29 PM, Douglas Gregor <dgregor at apple.com> wrote:
>
>>
>> On Apr 29, 2010, at 4:28 PM, kalyan ponnala wrote:
>>
>> Thanks for letting me know about the vector types Douglas. I think I can
>> use this to implement the new vector datatype. Can you tell me a better way
>> to add this as a header file to Clang. I dont want this typedef way to be
>> visible on the source side. (I dont want to add this as a header file on the
>> source side.). If I wanted the header file to contain something like
>> typedef int int_4 __attribute__((ext_vector_type(4)));
>>
>> Where can I add this header file inside clang so that it can understand
>> something like int_4 on the source code, i mean to which target should I add
>> it?
>>
>>
>> Look in clang/libs/Headers for other Clang-supplied headers.
>>
>> - Doug
>>
>> Thanks again.
>>
>> On Thu, Apr 29, 2010 at 4:59 PM, Douglas Gregor <dgregor at apple.com>wrote:
>>
>>>
>>> On Apr 29, 2010, at 1:35 PM, kalyan ponnala wrote:
>>>
>>> > Hi guys,
>>> >
>>> > Thanks for the replies. I am trying to add support to a new
>>> architecture called Line Associative Registers. It has vector registers in
>>> it. I would like to add a vector data type such as int[4] which could access
>>> a register with a width of 4 integers in it (max). Since it has to be
>>> mentioned in the source as
>>> >
>>> > int[4] = {1, 2, 3, 4}
>>> >
>>> > I am not sure about how to proceed. This form looks like an array with
>>> 4 elements but I want it to be a datatype.
>>> > I was looking into targetinfo.h and initpreprocessor.cpp. it looks like
>>> I can add a new type here or change the existing one. And about the type.h
>>> in ClangAST target, will it work if I added this type here.
>>> >
>>> > Any advices about how to proceed would be really appreciated.
>>>
>>> Clang already has vector types (VectorType) and "extended" vector types
>>> (ExtVectorType). They're created using attributes, e.g.,
>>>
>>>        typedef int v4si __attribute__ ((vector_size (16)));
>>>
>>> You could probably just re-use these vector types, possibly tweaking
>>> their semantics a bit, for your architecture.
>>>
>>>        - Doug
>>
>>
>>
>>
>> --
>> Kalyan Ponnala
>> phone: 8163772059
>>
>>
>>
>
>
> --
> Kalyan Ponnala
> phone: 8163772059
>



-- 
Kalyan Ponnala
phone: 8163772059
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100430/0588dbe8/attachment.html>


More information about the cfe-dev mailing list