I am adding a new target to LLVM (a DSP processor).<br>Resulting code size on an embedded system is as important as code efficiency.<br><br>So my first question is:<br>How to introduce code size criteria in the instruction selection ?<br>
Is there any scheme already in place for that purpose ?<br><br>My second question is related to my target.<br>On this target, arithmetic and bitwise instructions that modify the flag register (overflow flag, zero flag, ...) are smaller that the ones that do not modify the flag register.<br>
So, I have basically 2 choices (you might have other ideas...):<br>1) In the InstrInfo.td, I indicate that all the arithmetic and bitwise instructions modify the flags (using Defs = [FlagReg]).<br>   The pros: it selects instructions that are smaller.<br>
   The cons: if I have a comparison whose result is used twice (or more), and some arithmetic instructions are used in between, the comparison has to be done again (the flags have been overwritten).<br>2) In the InstrInfo.td, the selection generates the target instruction that do not modify the flags.<br>
In this case, in order to reduce code size, I was planning to write a preEmit pass to turn instructions that do not modify flags into instructions that modify flags when there is no impact (basically when the flag register is not needed and so can be safely overwritten).<br>
<br>  Thank you.<br>  <br>