I am adding a new target to LLVM (a DSP processor).
Resulting code size on an embedded system is as important as code
efficiency.
So my first question is:
How to introduce code size criteria in the instruction selection ?
Is there any scheme already in place for that purpose ?
My second question is related to my target.
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.
So, I have basically 2 choices (you might have other ideas...):
1) In the InstrInfo.td, I indicate that all the arithmetic and bitwise
instructions modify the flags (using Defs = [FlagReg]).
The pros: it selects instructions that are smaller.
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).
2) In the InstrInfo.td, the selection generates the target instruction that
do not modify the flags.
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).
Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20110131/7cf9eec1/attachment.html>