[LLVMdev] Changing basic blocks

Emílio Wuerges wuerges at gmail.com
Wed Aug 8 22:18:04 PDT 2007


Hi Tanya and everybody,

Ty for your support.

I too believe it should not be complicated.
But I was not being able to do it.

For instance, I tried to run this code below:

  BB->push_back(&(BB->front()));
  BB->pop_front();

But it did not work (kinda obvious why).

Nor this:

  BB->push_back(BB->begin());
  BB->pop_front();

But also did not work. It seams the same instruction may not be duplicated
in the base block.

Finally, after some thinking (and tinkering), this worked like a charm:

  MachineInstr* mi = BB->remove(BB->begin());
  BB->push_back(mi);

=D

But, is there a better way to do it?
And for inserting a NOP ? Is there a simple way?

Ty again.


2007/8/8, Tanya M. Lattner <tonic at nondot.org>:
>
>
> > I need a way to reorder instructions inside MachineBasicBlocks or
> > MachineFunctions.
> > I've been searching for it but I have not found an example in the code
> yet.
>
> For MachineBasicBlocks, check out this doc:
> http://llvm.org/doxygen/classllvm_1_1MachineBasicBlock.html
>
> I believe its basically the same as basic blocks in that you can
> manipulate the instruction list.
>
> Otherwise, you need to write a MachineFunction Pass:
> http://llvm.org/docs/WritingAnLLVMPass.html#MachineFunctionPass
>
> -Tanya
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



-- 
Emilio Wuerges
LAPS - Laboratorio de Automacao de Projeto de Sistemas
UFSC - Universidade Federal de Santa Catarina
Brasil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070809/db2f6b9d/attachment.html>


More information about the llvm-dev mailing list