[PATCH] D143576: [LowerTypeTests] Support generating Armv6-M jump tables.

Simon Tatham via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 8 05:46:04 PST 2023


simon_tatham created this revision.
simon_tatham added reviewers: eugenis, pcc, lenary, ostannard, chill.
Herald added subscribers: ormris, s.egerton, simoncook, hiraditya, kristof.beyls.
Herald added a project: All.
simon_tatham requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.

The LowerTypeTests pass emits a jump table in the form of an
`inlineasm` IR node containing a string representation of some
assembly. It tests the target triple to see what architecture it
should be generating assembly for. But that's not good enough for
`Triple::thumb`, because the 32-bit PC-relative `b.w` branch
instruction isn't available in all supported architecture versions. In
particular, Armv6-M doesn't support that instruction (although the
similar Armv8-M Baseline does).

Most of this patch is concerned with working out whether the
compilation target is Armv6-M or not, which I'm doing by going through
all the functions in the module, retrieving a TargetTransformInfo for
each one, and querying it via a new method I've added to check its
SubtargetInfo. If any function's TTI indicates that it's targeting an
architecture supporting B.W, then we assume we're also allowed to use
B.W in the jump table.

The Armv6-M compatible jump table format requires a temporary
register, and therefore also has to use the stack in order to restore
that register.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143576

Files:
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
  llvm/lib/Target/ARM/ARMTargetTransformInfo.h
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/test/Transforms/LowerTypeTests/function-arm-thumb.ll
  llvm/test/Transforms/LowerTypeTests/function.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143576.495814.patch
Type: text/x-patch
Size: 14359 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230208/8e448440/attachment.bin>


More information about the llvm-commits mailing list