accessibility of codegen headers

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

accessibility of codegen headers

Jochen Wilhelmy
Hi!

is it possible to move the following headers into the include directory:

CodeGenTypes.h
CodeGenModule.h
CGRecordLayout.h

I use them to extract some infos (layout of records) while compiling.
Currently I have to set
an include directory into the clang/lib/CodeGen directory which of course
is a hack.

- Jochen

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: accessibility of codegen headers

Chris Lattner

On Jun 16, 2010, at 2:45 PM, Jochen Wilhelmy wrote:

> Hi!
>
> is it possible to move the following headers into the include directory:
>
> CodeGenTypes.h
> CodeGenModule.h
> CGRecordLayout.h
>
> I use them to extract some infos (layout of records) while compiling.
> Currently I have to set
> an include directory into the clang/lib/CodeGen directory which of course
> is a hack.

What are you using these for?  They should be private implementation details of the IR generation module.  The layout information for structs is known in the AST level.

-Chris


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: accessibility of codegen headers

Jochen Wilhelmy

> What are you using these for?  They should be private implementation details of the IR generation module.  The layout information for structs is known in the AST level.
>    

In the AST level there is no information about the alignment, e.g.
struct {char a; double b}; may result in a being at index 0 and
b being at index 2 because some alignment padding is between a and b.

I need the index of a and b as they appear in the resulting IR because
(in my
custom application) I need to know if a getelementptr accesses a or b.
Currently the only way for me to find this out is using CGRecordLayout.

-Jochen

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: accessibility of codegen headers

Chris Lattner

On Jun 17, 2010, at 1:22 AM, Jochen Wilhelmy wrote:

>
>> What are you using these for?  They should be private implementation details of the IR generation module.  The layout information for structs is known in the AST level.
>>  
>
> In the AST level there is no information about the alignment, e.g.
> struct {char a; double b}; may result in a being at index 0 and
> b being at index 2 because some alignment padding is between a and b.
>
> I need the index of a and b as they appear in the resulting IR because (in my
> custom application) I need to know if a getelementptr accesses a or b.
> Currently the only way for me to find this out is using CGRecordLayout.

This information should be available at the AST level, because offsetof and sizeof structs needs to be evaluated without codegen.  Take a look at the include/clang/AST/RecordLayout.h header.

-Chris
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: accessibility of codegen headers

Jochen Wilhelmy

> This information should be available at the AST level, because offsetof and sizeof structs needs to be evaluated without codegen.  Take a look at the include/clang/AST/RecordLayout.h header.
>  

It looks that AST/RecordLayout hast info about alignment, field offsets
and struct size,
but not about field index of the resulting llvm type.
For this I would need a getFieldIndexInIR(unsigned FieldNo) method.

-Jochen

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: accessibility of codegen headers

Chris Lattner

On Jun 19, 2010, at 3:53 AM, Jochen Wilhelmy wrote:

>
>> This information should be available at the AST level, because offsetof and sizeof structs needs to be evaluated without codegen.  Take a look at the include/clang/AST/RecordLayout.h header.
>>  
>
> It looks that AST/RecordLayout hast info about alignment, field offsets and struct size,
> but not about field index of the resulting llvm type.
> For this I would need a getFieldIndexInIR(unsigned FieldNo) method.

Given the offset, you can compute that with TargetData's StructLayout helper, the StructLayout::getElementContainingOffset method does it.

-Chris
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev