There are two forms of MSP430X extended shift instructions:
- "RxxM": RRAM, RRUM, RLAM, RRCM e.g. rram #3, r12
- "RxxX": RRAX, RRUX, RLAX, RRCX e.g. rrax r12
RxxM shifts can shift by up to 4 bit positions, whilst RxxX shifts are
more expensive but can shift by up to 16 bit positions.
RxxX shifts do not have a shift count operand, instead the shift count
is set by using the "rpt" directive, which must precede the RxxX
instruction, if it is used at all. This directive sets bits in the
extension word of the 430X instruction, to indicate the number of times
the instruction should be repeated. As this is the first patch to add
430X extended instructions, the patch also adds initial support for the
430X extension word and the "rpt" directive.
RRCM and RRCX are not currently implemented as they are not required
when MSP430TargetLowering only lowers shifts with 8-bit or 16-bit
operands. They could be used in the future to improve the efficiency of
shifts for 32-bit or 64-bit operands.
In addition to the LLVM regression tests, I also ran the dg.exp, execute.exp,
and dg-torture.exp testsuites from GCC, using the MSP430 Binutils simulator.
The results for -mcpu=msp430{,x} were unchanged compared to the results for
-mcpu=msp430 without the patch, which gives some extra confidence that the
changes to how the shifts are lowered are valid.
If the patch is acceptable, I would appreciate it if someone would commit it
for me, as I do not have write access.
There are some pre-existing missed optimizations when shifting memory operands, so I'm going to fix them along with this TODO in a separate commit.