[LLVMdev] [LLVMDev] How do I add a branch to a MachineInstr?

Jeff Kunkel jdkunk3 at gmail.com
Fri Oct 15 05:04:16 PDT 2010


I know this is simple, but I want to be 100 percent sure I am doing
this correctly. Would the following code be enough to add a simple
unconditional branch instruction to a machine instruction? Do I need
to set some key items in the MachineBasicBlock too? Is there more
documentation on this subject?

MachineBasicBlock * mbb = mf->CreateMachineBasicBlock( 0 );
mbb->getNumber();
TargetInstrDesc tid;
tid.Opcode      = TID::Branch;
tid.NumOperands = 1;
MachineInstr * instr = mf->CreateMachineInstr( tid, DebugLoc() );
mbb->insert( mbb->end(), instr );

Thanks,
Jeff Kunkel



More information about the llvm-dev mailing list