[LLVMdev] Inserting a custom switch instruction implementation in backend

Marcello Maggioni marcello at codeplay.com
Sat Sep 21 04:43:27 PDT 2013


Hi,

in implementing a backend for a target we work on, I ended up needing to 
lower the switch instruction in a very specific way that is quite 
different from the standard llvm way with the decision trees.

The custom implementation wants to get rid of the decision blocks that 
llvm generates between the actual cases basic blocks and the switch root 
block. What I do currently is basically deleting these blocks manually 
and moving all the successors (updating the PHIs) to the switch root 
block and splicing the instructions in the decision blocks into the 
switch root block manually and then proceed to the removal of these blocks.

This seems to work fine, but is a solution that I not like very much. I 
would prefer being able to lower the switch instructions in my own way 
directly instead of having to let llvm do it its own way and "morph" the 
result into my own.

There is a clean way to custom lower the switch instruction in the 
backend without substituting the entire SelectionDAGBuilder?

Cheers,
Marcello



More information about the llvm-dev mailing list