[llvm] 06c4634 - [JITLink] Sink ELFX86RelocationKind into implementation file (ELF_x86_64.cpp).

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 13:36:59 PDT 2022


Author: Lang Hames
Date: 2022-09-01T13:36:49-07:00
New Revision: 06c46344838858623e17e64dde57a2edce05bbac

URL: https://github.com/llvm/llvm-project/commit/06c46344838858623e17e64dde57a2edce05bbac
DIFF: https://github.com/llvm/llvm-project/commit/06c46344838858623e17e64dde57a2edce05bbac.diff

LOG: [JITLink] Sink ELFX86RelocationKind into implementation file (ELF_x86_64.cpp).

The ELF/x86-64 backend uses the generic x86_64 edges now, so the
ELFX86RelocationKind is just an implementation detail.

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h
    llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h
index f5fa9e96c5949..fbe5765438d24 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h
@@ -18,24 +18,6 @@
 namespace llvm {
 namespace jitlink {
 
-namespace ELF_x86_64_Edges {
-enum ELFX86RelocationKind : Edge::Kind {
-  Branch32 = Edge::FirstRelocation,
-  Pointer32Signed,
-  Pointer64,
-  PCRel32,
-  PCRel32GOTLoad,
-  PCRel32GOTLoadRelaxable,
-  PCRel32REXGOTLoadRelaxable,
-  PCRel32TLV,
-  PCRel64GOT,
-  GOTOFF64,
-  GOT64,
-  Delta64,
-};
-
-} // end namespace ELF_x86_64_Edges
-
 /// Create a LinkGraph from an ELF/x86-64 relocatable object.
 ///
 /// Note: The graph does not take ownership of the underlying buffer, nor copy
@@ -48,8 +30,6 @@ createLinkGraphFromELFObject_x86_64(MemoryBufferRef ObjectBuffer);
 void link_ELF_x86_64(std::unique_ptr<LinkGraph> G,
                      std::unique_ptr<JITLinkContext> Ctx);
 
-/// Return the string name of the given ELF x86-64 edge kind.
-const char *getELFX86RelocationKindName(Edge::Kind R);
 } // end namespace jitlink
 } // end namespace llvm
 

diff  --git a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
index 8f21274bd1a3c..60d44d5f0ce6e 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
@@ -27,7 +27,6 @@
 
 using namespace llvm;
 using namespace llvm::jitlink;
-using namespace llvm::jitlink::ELF_x86_64_Edges;
 
 namespace {
 
@@ -106,34 +105,48 @@ class ELFLinkGraphBuilder_x86_64 : public ELFLinkGraphBuilder<object::ELF64LE> {
 private:
   using ELFT = object::ELF64LE;
 
-  static Expected<ELF_x86_64_Edges::ELFX86RelocationKind>
-  getRelocationKind(const uint32_t Type) {
+  enum ELFX86RelocationKind : Edge::Kind {
+    Branch32 = Edge::FirstRelocation,
+    Pointer32Signed,
+    Pointer64,
+    PCRel32,
+    PCRel32GOTLoad,
+    PCRel32GOTLoadRelaxable,
+    PCRel32REXGOTLoadRelaxable,
+    PCRel32TLV,
+    PCRel64GOT,
+    GOTOFF64,
+    GOT64,
+    Delta64,
+  };
+
+  static Expected<ELFX86RelocationKind> getRelocationKind(const uint32_t Type) {
     switch (Type) {
     case ELF::R_X86_64_32S:
-      return ELF_x86_64_Edges::ELFX86RelocationKind::Pointer32Signed;
+      return ELFX86RelocationKind::Pointer32Signed;
     case ELF::R_X86_64_PC32:
-      return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32;
+      return ELFX86RelocationKind::PCRel32;
     case ELF::R_X86_64_PC64:
     case ELF::R_X86_64_GOTPC64:
-      return ELF_x86_64_Edges::ELFX86RelocationKind::Delta64;
+      return ELFX86RelocationKind::Delta64;
     case ELF::R_X86_64_64:
-      return ELF_x86_64_Edges::ELFX86RelocationKind::Pointer64;
+      return ELFX86RelocationKind::Pointer64;
     case ELF::R_X86_64_GOTPCREL:
-      return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32GOTLoad;
+      return ELFX86RelocationKind::PCRel32GOTLoad;
     case ELF::R_X86_64_GOTPCRELX:
-      return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32GOTLoadRelaxable;
+      return ELFX86RelocationKind::PCRel32GOTLoadRelaxable;
     case ELF::R_X86_64_REX_GOTPCRELX:
-      return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32REXGOTLoadRelaxable;
+      return ELFX86RelocationKind::PCRel32REXGOTLoadRelaxable;
     case ELF::R_X86_64_GOTPCREL64:
-      return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel64GOT;
+      return ELFX86RelocationKind::PCRel64GOT;
     case ELF::R_X86_64_GOT64:
-      return ELF_x86_64_Edges::ELFX86RelocationKind::GOT64;
+      return ELFX86RelocationKind::GOT64;
     case ELF::R_X86_64_GOTOFF64:
-      return ELF_x86_64_Edges::ELFX86RelocationKind::GOTOFF64;
+      return ELFX86RelocationKind::GOTOFF64;
     case ELF::R_X86_64_PLT32:
-      return ELF_x86_64_Edges::ELFX86RelocationKind::Branch32;
+      return ELFX86RelocationKind::Branch32;
     case ELF::R_X86_64_TLSGD:
-      return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32TLV;
+      return ELFX86RelocationKind::PCRel32TLV;
     }
     return make_error<JITLinkError>(
         "Unsupported x86-64 relocation type " + formatv("{0:d}: ", Type) +
@@ -399,32 +412,5 @@ void link_ELF_x86_64(std::unique_ptr<LinkGraph> G,
 
   ELFJITLinker_x86_64::link(std::move(Ctx), std::move(G), std::move(Config));
 }
-const char *getELFX86RelocationKindName(Edge::Kind R) {
-  switch (R) {
-  case Branch32:
-    return "Branch32";
-  case Pointer32Signed:
-    return "Pointer32Signed";
-  case Pointer64:
-    return "Pointer64";
-  case PCRel32:
-    return "PCRel32";
-  case PCRel32GOTLoad:
-    return "PCRel32GOTLoad";
-  case PCRel32GOTLoadRelaxable:
-    return "PCRel32GOTLoadRelaxable";
-  case PCRel32REXGOTLoadRelaxable:
-    return "PCRel32REXGOTLoad";
-  case PCRel64GOT:
-    return "PCRel64GOT";
-  case Delta64:
-    return "Delta64";
-  case GOT64:
-    return "GOT64";
-  case GOTOFF64:
-    return "GOTOFF64";
-  }
-  return getGenericEdgeKindName(static_cast<Edge::Kind>(R));
-}
 } // end namespace jitlink
 } // end namespace llvm


        


More information about the llvm-commits mailing list