i want to insert a certain machine Instruction when i see a MUL instruction to optimize for a specific processor.
To my understanding this should be possible by inserting a DAG node between the MUL instruction and the instruction that follows.
How could i achieve traversing an DAG of Machine Instructions and manipulating(inserting and deleting nodes)?
or is my understanding of manipulating assembly output in llvm already flawed?
I would appreciate direct advise and refering to examples/literature on that topic
Do you mean DAG or do you mean the MIR, given you talk of Machine Instructions?
I think manipulating MIR should do the trick.
judging by the information i’ve looked through, there is no infromation lost, that i would need.
I think there are at least two options:
-manipulating MIR - creation some custom pass which expands your MUL instruction with additional one
-during processing DAG (instruction selection) - modification/creation custom patterns which select normally MUL in a way that they will generate MUL+YOUR CUSTOM INSTRUCTION
First approach is more flexible one, second might end-up with just few lines changed in …Patterns.td file.