Skip to content

Commit 9c607e7

Browse files
[JITLink][AArch32] Refactor StubsManager (NFC)
1 parent a979797 commit 9c607e7

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -318,21 +318,22 @@ inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E,
318318
llvm_unreachable("Relocation must be of class Data, Arm or Thumb");
319319
}
320320

321-
/// Stubs builder for a specific StubsFlavor
321+
/// Stubs builder for v7 emits non-position-independent Thumb stubs.
322322
///
323323
/// Right now we only have one default stub kind, but we want to extend this
324324
/// and allow creation of specific kinds in the future (e.g. branch range
325325
/// extension or interworking).
326326
///
327327
/// Let's keep it simple for the moment and not wire this through a GOT.
328328
///
329-
template <StubsFlavor Flavor>
330-
class StubsManager : public TableManager<StubsManager<Flavor>> {
329+
class StubsManager_v7 : public TableManager<StubsManager_v7> {
331330
public:
332-
StubsManager() = default;
331+
StubsManager_v7() = default;
333332

334333
/// Name of the object file section that will contain all our stubs.
335-
static StringRef getSectionName();
334+
static StringRef getSectionName() {
335+
return "__llvm_jitlink_aarch32_STUBS_Thumbv7";
336+
}
336337

337338
/// Implements link-graph traversal via visitExistingEdges().
338339
bool visitEdge(LinkGraph &G, Block *B, Edge &E) {
@@ -354,7 +355,7 @@ class StubsManager : public TableManager<StubsManager<Flavor>> {
354355
return false;
355356
}
356357

357-
/// Create a branch range extension stub for the class's flavor.
358+
/// Create a branch range extension stub with Thumb encoding for v7 CPUs.
358359
Symbol &createEntry(LinkGraph &G, Symbol &Target);
359360

360361
private:
@@ -378,14 +379,6 @@ class StubsManager : public TableManager<StubsManager<Flavor>> {
378379
Section *StubsSection = nullptr;
379380
};
380381

381-
/// Create a branch range extension stub with Thumb encoding for v7 CPUs.
382-
template <>
383-
Symbol &StubsManager<StubsFlavor::v7>::createEntry(LinkGraph &G, Symbol &Target);
384-
385-
template <> inline StringRef StubsManager<StubsFlavor::v7>::getSectionName() {
386-
return "__llvm_jitlink_aarch32_STUBS_Thumbv7";
387-
}
388-
389382
} // namespace aarch32
390383
} // namespace jitlink
391384
} // namespace llvm

llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,12 @@ class ELFLinkGraphBuilder_aarch32
216216
ArmCfg(std::move(ArmCfg)) {}
217217
};
218218

219-
template <aarch32::StubsFlavor Flavor>
219+
template <typename StubsManagerType>
220220
Error buildTables_ELF_aarch32(LinkGraph &G) {
221221
LLVM_DEBUG(dbgs() << "Visiting edges in graph:\n");
222222

223-
aarch32::StubsManager<Flavor> PLT;
224-
visitExistingEdges(G, PLT);
223+
StubsManagerType StubsManager;
224+
visitExistingEdges(G, StubsManager);
225225
return Error::success();
226226
}
227227

@@ -311,7 +311,7 @@ void link_ELF_aarch32(std::unique_ptr<LinkGraph> G,
311311
switch (ArmCfg.Stubs) {
312312
case aarch32::StubsFlavor::v7:
313313
PassCfg.PostPrunePasses.push_back(
314-
buildTables_ELF_aarch32<aarch32::StubsFlavor::v7>);
314+
buildTables_ELF_aarch32<aarch32::StubsManager_v7>);
315315
break;
316316
case aarch32::StubsFlavor::Unsupported:
317317
llvm_unreachable("Check before building graph");

llvm/lib/ExecutionEngine/JITLink/aarch32.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,7 @@ const uint8_t Thumbv7ABS[] = {
684684
0x60, 0x47 // bx r12
685685
};
686686

687-
template <>
688-
Symbol &StubsManager<StubsFlavor::v7>::createEntry(LinkGraph &G, Symbol &Target) {
687+
Symbol &StubsManager_v7::createEntry(LinkGraph &G, Symbol &Target) {
689688
constexpr uint64_t Alignment = 4;
690689
Block &B = addStub(G, Thumbv7ABS, Alignment);
691690
LLVM_DEBUG({

0 commit comments

Comments
 (0)