Hi

I have asked the clang mailing list if it can be done in clang.

However, i would like to also check if it

can be done as a BC level transformation.

I would like to address aggregates (structures, arrays) in a

linear fashion and in terms of the simplest target type that is

embedded in these data structures, So a 2 dimensional array becomes

a single dimension array. A structure with a character and array is

addressed in terms of the target size of character. So hopefully

express the

address calculation in terms of one GEP(base, offset) or if GEP cant

express it use my intrinsic.

Is that feasible ? If so, can that be done as a bc transformation.

thanks'

shrey

Hi shrey,

I would like to address aggregates (structures, arrays) in a

linear fashion and in terms of the simplest target type that is

embedded in these data structures, So a 2 dimensional array becomes

a single dimension array. A structure with a character and array is

addressed in terms of the target size of character. So hopefully

express the

address calculation in terms of one GEP(base, offset) or if GEP cant

express it use my intrinsic.

Is that feasible ? If so, can that be done as a bc transformation.

it sounds like you want to turn GEP into pointer arithmetic. It is easy

to do this directly, but here is a trick: suppose you originally have

%p = GEP(base, offset0, offset1, ...)

Form

%q = GEP(0, offset0, offset1, ...)

i.e. where you replaced base by a null pointer. Now do

%r = ptrtoint %q to i64

So %r holds the offset in octets from base. Then the original GEP is the

same as

$p2 = GEP(base, %r)

Ciao, Duncan.

PS: If you constant fold %r probably it will get turned into a more explicit

value.