Hello How to get the type of an Operand ? so for example I want to get the type of the operand(0) in this istruction %arrayidx22 = getelementptr [1000 x double]* %C, i64 0, i64 %indvar67 ; <double*> [#uses=1] I tried (II->getOperand(0))->getType() ) but this give me an adress (I think) (some think like 0x1253.. ) also I tried to get the type of the instruction with switch (II->getType()->getTypeID()) { case Type::FloatTyID: case Type::DoubleTyID: case Type::IntegerTyID: default: ; } It works well exept for the getelementptr instruction !!! ?? so Please how to get the Operand type ? (I mean that tell me it is a Double or a float .... ) Thank you so much -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100423/74d9945e/attachment.html>
khaled hamidouche wrote:> Hello > > How to get the type of an Operand ? > > so for example I want to get the type of the operand(0) in this > istruction > > %arrayidx22 = getelementptr [1000 x double]* %C, i64 0, i64 %indvar67 > ; <double*> [#uses=1] > > I tried (II->getOperand(0))->getType() ) but this give me an adress > (I think) (some think like 0x1253.. )The getType() method returns a pointer to an object that describes the type. The object will be of class Type or one of Type's subclasses. This is what you want. Type objects are unique in LLVM. The methods for creating type objects ensure that only one Type object is ever created for a particular LLVM type. This means that comparing types for equality can be done by comparing the Type pointers. Code like this is guaranteed to work: Value * V1 = ... Value * V2 = ... if (V1->getType() == V2->getType()) // V1 and V2 have the same type else // V1 and V2 have different types The document at http://llvm.org/docs/ProgrammersManual.html#Type briefly describes this feature of the LLVM API. It also says that there is a isFloatingPointTy() method of the Type class that will tell you if the type if a floating point type. -- John T.