[llvm] [JITLink][AArch32] Add dynamic lookup for relocation fixup infos (PR #71649)

Stefan Gränitz via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 1 06:08:03 PST 2023


================
@@ -163,65 +164,107 @@ struct HalfWords {
   const uint16_t Lo; // Second halfword
 };
 
-/// Collection of named constants per fixup kind. It may contain but is not
-/// limited to the following entries:
+/// FixupInfo base class is required for dynamic lookups.
+struct FixupInfoBase {
+  static const FixupInfoBase *getDynFixupInfo(Edge::Kind K);
+  virtual ~FixupInfoBase() {}
+};
+
+/// FixupInfo checks for Arm edge kinds work on 32-bit words
+struct FixupInfoArm : public FixupInfoBase {
+  bool (*checkOpcode)(uint32_t Wd) = nullptr;
+};
+
+/// FixupInfo check for Thumb32 edge kinds work on a pair of 16-bit halfwords
+struct FixupInfoThumb : public FixupInfoBase {
+  bool (*checkOpcode)(uint16_t Hi, uint16_t Lo) = nullptr;
+};
+
+/// Collection of named constants per fixup kind
 ///
+/// Mandatory entries:
 ///   Opcode      - Values of the op-code bits in the instruction, with
 ///                 unaffected bits nulled
 ///   OpcodeMask  - Mask with all bits set that encode the op-code
+///
+/// Other common entries:
 ///   ImmMask     - Mask with all bits set that encode the immediate value
 ///   RegMask     - Mask with all bits set that encode the register
 ///
+/// Specializations can add further custom fields without restrictions.
+///
 template <EdgeKind_aarch32 Kind> struct FixupInfo {};
 
-template <> struct FixupInfo<Arm_Jump24> {
+namespace {
----------------
weliveindetail wrote:

Oh interesting, thanks for the note! Do you have an explanation why GCC thinks the anonymous namespace is a problem here? (I didn't see this in neither Clang nor MSVC.)

To answer your question, no it's not strictly necessary. The original goal was to indicate that these are "only" helper structs. I have a follow-up patch that avoids these helper classes, but it will have to wait a bit since it needs polishing and I have no time for it right now.

If this is an issue for you, please go ahead and drop them. If it's not a big deal, you can wait and the warnings will disappear before the end of the year 🙂 

https://github.com/llvm/llvm-project/pull/71649


More information about the llvm-commits mailing list