How do I get MachineFunctions?

Hi everybody,

I know that this may be a very silly question, but seriously, I’m totally lost.

So, what I want to know is how from my Module I can get MachineFunctions or MachineBasicBlocks.

I’m able to read a file with LLVM IR, create the Module and I also managed to create some passes for it, but what I want is to see the x86-64 assembly that this IR generates and map MachineBasicBlocks with BasicBlocks.

I know that I should follow the Instruction Selection steps from, but I couldn’t figure it out how to do this. I also tried to read the llc’s code, but it didn’t help me so much.

I would be grateful if somebody show me an example of how from a Module I can get MachineBasicBlocks.

Thank you,

Vanderson M. Rosario

Dear Vanderson,

You need to write a MachineFunctionPass instead of a ModulePass or FunctionPass. A MachineFunctionPass is given a MachineFunction to analyze/transform in its runOnFunction() method.

MachineFunctionPass'es are run by llc and other LLVM-based tools that generate native code (such as the libLTO plugin and Clang).


John Criswell