[LLVMdev] 2-address and 3-address instructions

bagel bagel99 at gmail.com
Fri Jul 17 13:34:01 PDT 2015


I am writing a backend for an experimental machine that has both 2-address and
3-address versions of some instructions.  The 2-address versions are more
compact and thus preferred when applicable.  How does one go about generating
the most compact version?

1. At instruction selection, is there a predicate that can test whether one of
the input sources is dead, thus allowing the selection of the 2-address version?

2. Or do I generate 2-address and have to have a custom pass that peepholes to 
see if a mov reg-to-reg proceeds or follows a 2-address instruction and turn 
it into a 3-address version?

3. Or do I generate 3-address and have a custom pass that checks if a source
and destination register in a 3-address is the same and turn it into a 2-address?

Anybody done this already?

Thanks,
Bagel



More information about the llvm-dev mailing list