[PATCH] D109324: [MSP430] Add support for MSP430X extended shift instructions

Jozef Lawrynowicz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 6 07:10:43 PDT 2021


jozefl created this revision.
jozefl added reviewers: asl, atrosinenko.
Herald added a subscriber: hiraditya.
jozefl requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109324

Files:
  llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp
  llvm/lib/Target/MSP430/Disassembler/MSP430Disassembler.cpp
  llvm/lib/Target/MSP430/MCTargetDesc/MSP430InstPrinter.cpp
  llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp
  llvm/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp
  llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
  llvm/lib/Target/MSP430/MSP430ISelLowering.h
  llvm/lib/Target/MSP430/MSP430InstrFormats.td
  llvm/lib/Target/MSP430/MSP430InstrInfo.h
  llvm/lib/Target/MSP430/MSP430InstrInfo.td
  llvm/lib/Target/MSP430/MSP430InstrInfoExtended.td
  llvm/test/CodeGen/MSP430/shift-amount-threshold.ll
  llvm/test/CodeGen/MSP430/shifts-430x-byte.ll
  llvm/test/CodeGen/MSP430/shifts-430x-word.ll
  llvm/test/CodeGen/MSP430/shifts.ll
  llvm/test/MC/MSP430/shifts-430x-invalid.s
  llvm/test/MC/MSP430/shifts-430x.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109324.370915.patch
Type: text/x-patch
Size: 69617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210906/8a3458fe/attachment.bin>


More information about the llvm-commits mailing list