[LLVMdev] how to dump a Instruction in gdb?

Tianwei tianwei.sheng at gmail.com
Fri Nov 23 02:05:58 PST 2007


On Nov 23, 2007 5:29 PM, Duncan Sands <baldrick at free.fr> wrote:

> Hi,
>
> >    I want to know how to dump the a instruction in gdb. I can dump a
> Module
> > use M.dump(), also is there any such print function which can be used in
> gdb
> > for a single instruction and its operand?
>
> you can dump most things in LLVM the same way as for a module: if I is
> your
> instruction, I.dump() or I->dump() should work, depending on whether it is
> a pointer or a reference.
>
thanks very much. so for following iterator, how can I use the dump
function?
  for (inst_iterator II = inst_begin(F), E = inst_end(F); II != E; ++II) {

}


> > also I'm confused with the concept about " the type a instruction", why
> a
> > instruction should have a type, how we decide the type of a instruction?
> for
> > example, for the following instruction:
> > %i = alloca i32, align 4        ; <i32*> [#uses=2]
> > the following isa is true:
> > isa<PointerType>(II->getType())
> >
> > is that the type of a instruction is decided by the type of the result
> > operand? and it has nothing to do  with the opcode for a instruction?
>
> You can see the type in the assembler above:
>
> %i = alloca i32, align 4        ; <i32*> [#uses=2]
>
> the <i32*> in the comment at the end tells you that %i is an i32*.
> The alloca instruction allocates the given type on the stack and
> returns a pointer to it.  You allocate an i32 so you get a pointer
> to an i32 back.
>
ok,  I will read the language reference manual again. thanks.

>
> I hope this helps,
>
> Duncan.
>



-- 
Sheng, Tianwei
Inst. of High Performance Computing
Dept. of Computer Sci. & Tech.
Tsinghua Univ.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20071123/50e711c5/attachment.html>


More information about the llvm-dev mailing list