I plan to do some pre register allocation optimizations.
I already know my way around LLVM but I could use some more experience.
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.
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.
create a method "addNop()" in the MRegisterInfo class, and make it concrete on the targets that you are planning to use. For instance, in the x86, the opcode for NOP is 0x90 (le'me just use this opportunity to thank Anton for telling me the opcode
use the method "copyRegToReg" as an example of how to add further methods into MRegisterInfo.
The bad thing is that your version of LLVM will be off with the distributed version. Well, because more people have had this necessity of adding Nop's into the code, maybe the LLVM guys could consider adding this method officially to the MRegisterInfo class... and also a "swapRegs()" method into that class. It is very useful in register allocation.
This is a good way to do a single instruction. You can also use the splice method, which allows you to move around ranges of instructions in constant time. It works the same was as std::list::splice.
Creates a vector with "total" null elements in it, it doesn't reserve space. This means that this loop:
for(int i = 0; i< total; ++i)
BB->push_back(positionmap[i]);
Inserts all these nulls into the BB. I'm surprised this doesn't explode.
Yup,
You are right. That exploded.
I missed some lines in between.
there was a .reserve(total) in the actual code.
But, there is some side effect I still could not find.
Just for the update, I found my way around like this:
rts is my optimizer.
for (int i = 0; i < rts.total_emmited(); ++i)
{
MachineInstr * mi = rts.emmited_instruction(i);
MachineInstr* last = BB->remove(mi);
BB->push_back(last);
}