Typical PHI instruction in LLVM goes like this: %P = phi i32* [%A, %BB1], [%B, %BB2] When I try to access all the source operands, only %A and %B are included. I checked the methods in instruction.h, but I didn't find any methods obtaining the label fields i.e. %BB1, %BB2. I notice that each label of a basic block is related with a value which can be referenced in 'br' instructions. Suppose BBPtr is a pointer of a basic block, when I use errs()<<BBPtr, I will get a string like '0x984402'. Similarly, I see both instruction pointer and operand pointer are able to return this kind of string which can be used to identify different object instances. The question is that whether there is any method that can return the string '0x984402'. I try errs<<getOperand(int i), and it can also display '0x984402'. Since getOperand(int i) returns Value* . I guess there must be some overload function of Value* to help display '0x984402'. But I didn't find it. Any suggestions about this are appreciated. -- View this message in context: http://old.nabble.com/How-to-get-the-label-field-of-PHI-instruction--tp33763660p33763660.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Duncan Sands
2012-May-10 08:19 UTC
[LLVMdev] How to get the label field of PHI instruction?
Hi Launcher,> Typical PHI instruction in LLVM goes like this: > %P = phi i32* [%A, %BB1], [%B, %BB2] > > When I try to access all the source operands, only %A and %B are included. I > checked the methods in instruction.h, but I didn't find any methods > obtaining the label fields i.e. %BB1, %BB2.use getIncomingBlock. You can also use getIncomingValue for getting the values %A, %B rather than using getOperand.> I notice that each label of a basic block is related with a value which can > be referenced in 'br' instructions. Suppose BBPtr is a pointer of a basic > block, when I use errs()<<BBPtr, I will get a string like '0x984402'. > Similarly, I see both instruction pointer and operand pointer are able to > return this kind of string which can be used to identify different object > instances. The question is that whether there is any method that can return > the string '0x984402'. I try errs<<getOperand(int i), and it can also > display '0x984402'. Since getOperand(int i) returns Value* . I guess there > must be some overload function of Value* to help display '0x984402'. But I > didn't find it. Any suggestions about this are appreciated.Use dump, eg: phi->getIncomingBlock(i)->dump(). Ciao, Duncan.