GetElementPtrConstantExpr question

Hi all,

I just come across an IR instruction like this:

  %0 = getelementptr i32* getelementptr inbounds ([42 x i32]* @aaa,
i32 0, i32 0), i32 %2

What does the part "i32* getelementptr inbounds ([42 x i32]* @aaa, i32
0, i32 0)" mean? As far as I could understand this is a
GetElementPtrConstantExpr, isn't it?

My question is: how can I instantiate a class that represents that
instruction part so that I can perform some changes in it? I tried the
class GetElementPtrConstantExpr but it seems to be a private class to
Constants.cpp (I saw a comment in lib/VMCore/ConstantsContext.h about
that).

Thanks in advance,
Eduardo

Hi all,

I just come across an IR instruction like this:

  %0 = getelementptr i32* getelementptr inbounds ([42 x i32]* @aaa,
i32 0, i32 0), i32 %2

What does the part "i32* getelementptr inbounds ([42 x i32]* @aaa, i32
0, i32 0)" mean? As far as I could understand this is a
GetElementPtrConstantExpr, isn't it?

My question is: how can I instantiate a class that represents that
instruction part so that I can perform some changes in it? I tried the
class GetElementPtrConstantExpr but it seems to be a private class to
Constants.cpp (I saw a comment in lib/VMCore/ConstantsContext.h about
that).

One way to answer questions like this is to use the LLVM Demo
(http://llvm.org/demo) & the "LLVM C++ API code" target.

Eduardo <erocha.ssa@gmail.com> writes:

I just come across an IR instruction like this:

  %0 = getelementptr i32* getelementptr inbounds ([42 x i32]* @aaa,
i32 0, i32 0), i32 %2

What does the part "i32* getelementptr inbounds ([42 x i32]* @aaa, i32
0, i32 0)" mean? As far as I could understand this is a
GetElementPtrConstantExpr, isn't it?

My question is: how can I instantiate a class that represents that
instruction part so that I can perform some changes in it? I tried the
class GetElementPtrConstantExpr but it seems to be a private class to
Constants.cpp (I saw a comment in lib/VMCore/ConstantsContext.h about
that).

See llvm::ConstantExpr:

http://llvm.org/docs/doxygen/html/classllvm_1_1ConstantExpr.html

More precisely, the static methods getGetElementPtr and
getInBoundsGetElementPtr.