[llvm] b972164 - [JITLink] Rename 'i386' namespace and files to 'x86'.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Wed May 7 18:56:35 PDT 2025


Author: Lang Hames
Date: 2025-05-08T11:35:14+10:00
New Revision: b972164f38133fbc878275f4ae324908ae14d750

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

LOG: [JITLink] Rename 'i386' namespace and files to 'x86'.

When building on i386, both clang and gcc define a builtin 'i386' macro (see
discussion in https://github.com/llvm/llvm-project/pull/137063). This causes
build errors in the JITLink/i386 backend when attempting to build LLVM on i386.

This commit renames the 'i386' backend (namespaces, APIs and files) to 'x86' to
avoid this issue.

Added: 
    llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86.h
    llvm/include/llvm/ExecutionEngine/JITLink/x86.h
    llvm/lib/ExecutionEngine/JITLink/ELF_x86.cpp
    llvm/lib/ExecutionEngine/JITLink/x86.cpp
    llvm/test/ExecutionEngine/JITLink/x86/ELF_external_to_absolute_conversion.s
    llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_absolute_relocations_16.s
    llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_absolute_relocations_32.s
    llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_minimal.s
    llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_pc_relative_relocations_32.s
    llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_small_pic_relocations_got.s
    llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_small_pic_relocations_plt.s
    llvm/test/ExecutionEngine/JITLink/x86/lit.local.cfg

Modified: 
    llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt
    llvm/lib/ExecutionEngine/JITLink/ELF.cpp
    llvm/lib/ExecutionEngine/JITLink/JITLink.cpp

Removed: 
    llvm/include/llvm/ExecutionEngine/JITLink/ELF_i386.h
    llvm/include/llvm/ExecutionEngine/JITLink/i386.h
    llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
    llvm/lib/ExecutionEngine/JITLink/i386.cpp
    llvm/test/ExecutionEngine/JITLink/i386/ELF_external_to_absolute_conversion.s
    llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_absolute_relocations_16.s
    llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_absolute_relocations_32.s
    llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_minimal.s
    llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_pc_relative_relocations_32.s
    llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations_got.s
    llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations_plt.s
    llvm/test/ExecutionEngine/JITLink/i386/lit.local.cfg


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_i386.h b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86.h
similarity index 56%
rename from llvm/include/llvm/ExecutionEngine/JITLink/ELF_i386.h
rename to llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86.h
index 0752f214d9d58..82151f93a00bc 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_i386.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86.h
@@ -1,4 +1,4 @@
-//===--- ELF_i386.h - JIT link functions for ELF/i386 --*- C++ -*----===//
+//===------- ELF_x86.h - JIT link functions for ELF/x86 ------*- C++ -*----===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -8,33 +8,33 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// jit-link functions for ELF/i386.
+// jit-link functions for ELF/x86.
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_EXECUTIONENGINE_JITLINK_ELF_I386_H
-#define LLVM_EXECUTIONENGINE_JITLINK_ELF_I386_H
+#ifndef LLVM_EXECUTIONENGINE_JITLINK_ELF_X86_H
+#define LLVM_EXECUTIONENGINE_JITLINK_ELF_X86_H
 
 #include "llvm/ExecutionEngine/JITLink/JITLink.h"
 
 namespace llvm {
 namespace jitlink {
 
-/// Create a LinkGraph from an ELF/i386 relocatable object
+/// Create a LinkGraph from an ELF/x86 relocatable object
 ///
 /// Note: The graph does not take ownership of the underlying buffer, nor copy
 /// its contents. The caller is responsible for ensuring that the object buffer
 /// outlives the graph.
 Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_i386(MemoryBufferRef ObjectBuffer,
-                                  std::shared_ptr<orc::SymbolStringPool> SSP);
+createLinkGraphFromELFObject_x86(MemoryBufferRef ObjectBuffer,
+                                 std::shared_ptr<orc::SymbolStringPool> SSP);
 
-/// jit-link the given object buffer, which must be a ELF i386 relocatable
+/// jit-link the given object buffer, which must be a ELF x86 relocatable
 /// object file.
-void link_ELF_i386(std::unique_ptr<LinkGraph> G,
-                   std::unique_ptr<JITLinkContext> Ctx);
+void link_ELF_x86(std::unique_ptr<LinkGraph> G,
+                  std::unique_ptr<JITLinkContext> Ctx);
 
 } // end namespace jitlink
 } // end namespace llvm
 
-#endif // LLVM_EXECUTIONENGINE_JITLINK_ELF_I386_H
+#endif // LLVM_EXECUTIONENGINE_JITLINK_ELF_X86_H

diff  --git a/llvm/include/llvm/ExecutionEngine/JITLink/i386.h b/llvm/include/llvm/ExecutionEngine/JITLink/x86.h
similarity index 95%
rename from llvm/include/llvm/ExecutionEngine/JITLink/i386.h
rename to llvm/include/llvm/ExecutionEngine/JITLink/x86.h
index 3900fdc8ec7b1..eb372db88688e 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/i386.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/x86.h
@@ -1,4 +1,4 @@
-//=== i386.h - Generic JITLink i386 edge kinds, utilities -*- C++ -*-===//
+//===----- x86.h - Generic JITLink x86 edge kinds, utilities ----*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,19 +6,20 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// Generic utilities for graphs representing i386 objects.
+// Generic utilities for graphs representing x86 objects.
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_EXECUTIONENGINE_JITLINK_I386_H
-#define LLVM_EXECUTIONENGINE_JITLINK_I386_H
+#ifndef LLVM_EXECUTIONENGINE_JITLINK_X86_H
+#define LLVM_EXECUTIONENGINE_JITLINK_X86_H
 
 #include "llvm/ExecutionEngine/JITLink/JITLink.h"
 #include "llvm/ExecutionEngine/JITLink/TableManager.h"
 
-namespace llvm::jitlink::i386 {
-/// Represets i386 fixups
-enum EdgeKind_i386 : Edge::Kind {
+namespace llvm::jitlink::x86 {
+
+/// Represets x86 fixups
+enum EdgeKind_x86 : Edge::Kind {
 
   /// A plain 32-bit pointer value relocation.
   ///
@@ -174,7 +175,7 @@ enum EdgeKind_i386 : Edge::Kind {
   BranchPCRel32ToPtrJumpStubBypassable,
 };
 
-/// Returns a string name for the given i386 edge. For debugging purposes
+/// Returns a string name for the given x86 edge. For debugging purposes
 /// only
 const char *getEdgeKindName(Edge::Kind K);
 
@@ -249,13 +250,13 @@ inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E,
   return Error::success();
 }
 
-/// i386 pointer size.
+/// x86 pointer size.
 constexpr uint32_t PointerSize = 4;
 
-/// i386 null pointer content.
+/// x86 null pointer content.
 extern const char NullPointerContent[PointerSize];
 
-/// i386 pointer jump stub content.
+/// x86 pointer jump stub content.
 ///
 /// Contains the instruction sequence for an indirect jump via an in-memory
 /// pointer:
@@ -406,6 +407,6 @@ class PLTTableManager : public TableManager<PLTTableManager> {
 /// target
 Error optimizeGOTAndStubAccesses(LinkGraph &G);
 
-} // namespace llvm::jitlink::i386
+} // namespace llvm::jitlink::x86
 
-#endif // LLVM_EXECUTIONENGINE_JITLINK_I386_H
+#endif // LLVM_EXECUTIONENGINE_JITLINK_X86_H

diff  --git a/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt b/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt
index 22e4513e1374c..4669124ebe578 100644
--- a/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt
+++ b/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt
@@ -23,10 +23,10 @@ add_llvm_component_library(LLVMJITLink
   ELFLinkGraphBuilder.cpp
   ELF_aarch32.cpp
   ELF_aarch64.cpp
-  ELF_i386.cpp
   ELF_loongarch.cpp
   ELF_ppc64.cpp
   ELF_riscv.cpp
+  ELF_x86.cpp
   ELF_x86_64.cpp
 
   # COFF
@@ -43,10 +43,10 @@ add_llvm_component_library(LLVMJITLink
   # Architectures:
   aarch32.cpp
   aarch64.cpp
-  i386.cpp
   loongarch.cpp
   ppc64.cpp
   riscv.cpp
+  x86.cpp
   x86_64.cpp
 
   ADDITIONAL_HEADER_DIRS

diff  --git a/llvm/lib/ExecutionEngine/JITLink/ELF.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF.cpp
index 663a883a4bcce..87e451715811f 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF.cpp
@@ -15,10 +15,10 @@
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/ExecutionEngine/JITLink/ELF_aarch32.h"
 #include "llvm/ExecutionEngine/JITLink/ELF_aarch64.h"
-#include "llvm/ExecutionEngine/JITLink/ELF_i386.h"
 #include "llvm/ExecutionEngine/JITLink/ELF_loongarch.h"
 #include "llvm/ExecutionEngine/JITLink/ELF_ppc64.h"
 #include "llvm/ExecutionEngine/JITLink/ELF_riscv.h"
+#include "llvm/ExecutionEngine/JITLink/ELF_x86.h"
 #include "llvm/ExecutionEngine/JITLink/ELF_x86_64.h"
 #include "llvm/Object/ELF.h"
 #include <cstring>
@@ -101,7 +101,7 @@ createLinkGraphFromELFObject(MemoryBufferRef ObjectBuffer,
   case ELF::EM_X86_64:
     return createLinkGraphFromELFObject_x86_64(ObjectBuffer, std::move(SSP));
   case ELF::EM_386:
-    return createLinkGraphFromELFObject_i386(ObjectBuffer, std::move(SSP));
+    return createLinkGraphFromELFObject_x86(ObjectBuffer, std::move(SSP));
   default:
     return make_error<JITLinkError>(
         "Unsupported target machine architecture in ELF object " +
@@ -139,7 +139,7 @@ void link_ELF(std::unique_ptr<LinkGraph> G,
     link_ELF_x86_64(std::move(G), std::move(Ctx));
     return;
   case Triple::x86:
-    link_ELF_i386(std::move(G), std::move(Ctx));
+    link_ELF_x86(std::move(G), std::move(Ctx));
     return;
   default:
     Ctx->notifyFailed(make_error<JITLinkError>(

diff  --git a/llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_x86.cpp
similarity index 70%
rename from llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
rename to llvm/lib/ExecutionEngine/JITLink/ELF_x86.cpp
index 3bde1f1c40a94..8e0f6fb91a607 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86.cpp
@@ -1,4 +1,4 @@
-//===----- ELF_i386.cpp - JIT linker implementation for ELF/i386 ----===//
+//===--------- ELF_x86.cpp - JIT linker implementation for ELF/x86 --------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,16 +6,16 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// ELF/i386 jit-link implementation.
+// ELF/x86 jit-link implementation.
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/ExecutionEngine/JITLink/ELF_i386.h"
+#include "llvm/ExecutionEngine/JITLink/ELF_x86.h"
 #include "DefineExternalSectionStartAndEndSymbols.h"
 #include "ELFLinkGraphBuilder.h"
 #include "JITLinkGeneric.h"
 #include "llvm/BinaryFormat/ELF.h"
-#include "llvm/ExecutionEngine/JITLink/i386.h"
+#include "llvm/ExecutionEngine/JITLink/x86.h"
 #include "llvm/Object/ELFObjectFile.h"
 
 #define DEBUG_TYPE "jitlink"
@@ -26,11 +26,11 @@ using namespace llvm::jitlink;
 namespace {
 constexpr StringRef ELFGOTSymbolName = "_GLOBAL_OFFSET_TABLE_";
 
-Error buildTables_ELF_i386(LinkGraph &G) {
+Error buildTables_ELF_x86(LinkGraph &G) {
   LLVM_DEBUG(dbgs() << "Visiting edges in graph:\n");
 
-  i386::GOTTableManager GOT;
-  i386::PLTTableManager PLT(GOT);
+  x86::GOTTableManager GOT;
+  x86::PLTTableManager PLT(GOT);
   visitExistingEdges(G, GOT, PLT);
   return Error::success();
 }
@@ -38,12 +38,12 @@ Error buildTables_ELF_i386(LinkGraph &G) {
 
 namespace llvm::jitlink {
 
-class ELFJITLinker_i386 : public JITLinker<ELFJITLinker_i386> {
-  friend class JITLinker<ELFJITLinker_i386>;
+class ELFJITLinker_x86 : public JITLinker<ELFJITLinker_x86> {
+  friend class JITLinker<ELFJITLinker_x86>;
 
 public:
-  ELFJITLinker_i386(std::unique_ptr<JITLinkContext> Ctx,
-                    std::unique_ptr<LinkGraph> G, PassConfiguration PassConfig)
+  ELFJITLinker_x86(std::unique_ptr<JITLinkContext> Ctx,
+                   std::unique_ptr<LinkGraph> G, PassConfiguration PassConfig)
       : JITLinker(std::move(Ctx), std::move(G), std::move(PassConfig)) {
     getPassConfig().PostAllocationPasses.push_back(
         [this](LinkGraph &G) { return getOrCreateGOTSymbol(G); });
@@ -59,7 +59,7 @@ class ELFJITLinker_i386 : public JITLinker<ELFJITLinker_i386> {
               if (Sym.getName() != nullptr &&
                   *Sym.getName() == ELFGOTSymbolName)
                 if (auto *GOTSection = G.findSectionByName(
-                        i386::GOTTableManager::getSectionName())) {
+                        x86::GOTTableManager::getSectionName())) {
                   GOTSymbol = &Sym;
                   return {*GOTSection, true};
                 }
@@ -79,7 +79,7 @@ class ELFJITLinker_i386 : public JITLinker<ELFJITLinker_i386> {
     // record it, otherwise we'll create our own.
     // If there's a GOT section but we didn't find an external GOT symbol...
     if (auto *GOTSection =
-            G.findSectionByName(i386::GOTTableManager::getSectionName())) {
+            G.findSectionByName(x86::GOTTableManager::getSectionName())) {
 
       // Check for an existing defined symbol.
       for (auto *Sym : GOTSection->symbols())
@@ -106,52 +106,52 @@ class ELFJITLinker_i386 : public JITLinker<ELFJITLinker_i386> {
   }
 
   Error applyFixup(LinkGraph &G, Block &B, const Edge &E) const {
-    return i386::applyFixup(G, B, E, GOTSymbol);
+    return x86::applyFixup(G, B, E, GOTSymbol);
   }
 };
 
-class ELFLinkGraphBuilder_i386 : public ELFLinkGraphBuilder<object::ELF32LE> {
+class ELFLinkGraphBuilder_x86 : public ELFLinkGraphBuilder<object::ELF32LE> {
 private:
   using ELFT = object::ELF32LE;
 
-  Expected<i386::EdgeKind_i386> getRelocationKind(const uint32_t Type) {
+  Expected<x86::EdgeKind_x86> getRelocationKind(const uint32_t Type) {
     switch (Type) {
     case ELF::R_386_32:
-      return i386::Pointer32;
+      return x86::Pointer32;
     case ELF::R_386_PC32:
-      return i386::PCRel32;
+      return x86::PCRel32;
     case ELF::R_386_16:
-      return i386::Pointer16;
+      return x86::Pointer16;
     case ELF::R_386_PC16:
-      return i386::PCRel16;
+      return x86::PCRel16;
     case ELF::R_386_GOT32:
-      return i386::RequestGOTAndTransformToDelta32FromGOT;
+      return x86::RequestGOTAndTransformToDelta32FromGOT;
     case ELF::R_386_GOT32X:
       // TODO: Add a relaxable edge kind and update relaxation optimization.
-      return i386::RequestGOTAndTransformToDelta32FromGOT;
+      return x86::RequestGOTAndTransformToDelta32FromGOT;
     case ELF::R_386_GOTPC:
-      return i386::Delta32;
+      return x86::Delta32;
     case ELF::R_386_GOTOFF:
-      return i386::Delta32FromGOT;
+      return x86::Delta32FromGOT;
     case ELF::R_386_PLT32:
-      return i386::BranchPCRel32;
+      return x86::BranchPCRel32;
     }
 
     return make_error<JITLinkError>(
-        "In " + G->getName() + ": Unsupported i386 relocation type " +
+        "In " + G->getName() + ": Unsupported x86 relocation type " +
         object::getELFRelocationTypeName(ELF::EM_386, Type));
   }
 
   Error addRelocations() override {
     LLVM_DEBUG(dbgs() << "Adding relocations\n");
     using Base = ELFLinkGraphBuilder<ELFT>;
-    using Self = ELFLinkGraphBuilder_i386;
+    using Self = ELFLinkGraphBuilder_x86;
 
     for (const auto &RelSect : Base::Sections) {
       // Validate the section to read relocation entries from.
       if (RelSect.sh_type == ELF::SHT_RELA)
         return make_error<StringError>(
-            "No SHT_RELA in valid i386 ELF object files",
+            "No SHT_RELA in valid x86 ELF object files",
             inconvertibleErrorCode());
 
       if (Error Err = Base::forEachRelRelocation(RelSect, this,
@@ -187,7 +187,7 @@ class ELFLinkGraphBuilder_i386 : public ELFLinkGraphBuilder<object::ELF32LE> {
                   Base::GraphSymbols.size()),
           inconvertibleErrorCode());
 
-    Expected<i386::EdgeKind_i386> Kind = getRelocationKind(ELFReloc);
+    Expected<x86::EdgeKind_x86> Kind = getRelocationKind(ELFReloc);
     if (!Kind)
       return Kind.takeError();
 
@@ -195,21 +195,21 @@ class ELFLinkGraphBuilder_i386 : public ELFLinkGraphBuilder<object::ELF32LE> {
     int64_t Addend = 0;
 
     switch (*Kind) {
-    case i386::Pointer32:
-    case i386::PCRel32:
-    case i386::RequestGOTAndTransformToDelta32FromGOT:
-    case i386::Delta32:
-    case i386::Delta32FromGOT:
-    case i386::BranchPCRel32:
-    case i386::BranchPCRel32ToPtrJumpStub:
-    case i386::BranchPCRel32ToPtrJumpStubBypassable: {
+    case x86::Pointer32:
+    case x86::PCRel32:
+    case x86::RequestGOTAndTransformToDelta32FromGOT:
+    case x86::Delta32:
+    case x86::Delta32FromGOT:
+    case x86::BranchPCRel32:
+    case x86::BranchPCRel32ToPtrJumpStub:
+    case x86::BranchPCRel32ToPtrJumpStubBypassable: {
       const char *FixupContent = BlockToFix.getContent().data() +
                                  (FixupAddress - BlockToFix.getAddress());
       Addend = *(const support::little32_t *)FixupContent;
       break;
     }
-    case i386::Pointer16:
-    case i386::PCRel16: {
+    case x86::Pointer16:
+    case x86::PCRel16: {
       const char *FixupContent = BlockToFix.getContent().data() +
                                  (FixupAddress - BlockToFix.getAddress());
       Addend = *(const support::little16_t *)FixupContent;
@@ -221,7 +221,7 @@ class ELFLinkGraphBuilder_i386 : public ELFLinkGraphBuilder<object::ELF32LE> {
     Edge GE(*Kind, Offset, *GraphSymbol, Addend);
     LLVM_DEBUG({
       dbgs() << "    ";
-      printEdge(dbgs(), BlockToFix, GE, i386::getEdgeKindName(*Kind));
+      printEdge(dbgs(), BlockToFix, GE, x86::getEdgeKindName(*Kind));
       dbgs() << "\n";
     });
 
@@ -230,17 +230,17 @@ class ELFLinkGraphBuilder_i386 : public ELFLinkGraphBuilder<object::ELF32LE> {
   }
 
 public:
-  ELFLinkGraphBuilder_i386(StringRef FileName, const object::ELFFile<ELFT> &Obj,
-                           std::shared_ptr<orc::SymbolStringPool> SSP,
-                           Triple TT, SubtargetFeatures Features)
+  ELFLinkGraphBuilder_x86(StringRef FileName, const object::ELFFile<ELFT> &Obj,
+                          std::shared_ptr<orc::SymbolStringPool> SSP, Triple TT,
+                          SubtargetFeatures Features)
       : ELFLinkGraphBuilder<ELFT>(Obj, std::move(SSP), std::move(TT),
                                   std::move(Features), FileName,
-                                  i386::getEdgeKindName) {}
+                                  x86::getEdgeKindName) {}
 };
 
 Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_i386(MemoryBufferRef ObjectBuffer,
-                                  std::shared_ptr<orc::SymbolStringPool> SSP) {
+createLinkGraphFromELFObject_x86(MemoryBufferRef ObjectBuffer,
+                                 std::shared_ptr<orc::SymbolStringPool> SSP) {
   LLVM_DEBUG({
     dbgs() << "Building jitlink graph for new input "
            << ObjectBuffer.getBufferIdentifier() << "...\n";
@@ -255,18 +255,18 @@ createLinkGraphFromELFObject_i386(MemoryBufferRef ObjectBuffer,
     return Features.takeError();
 
   assert((*ELFObj)->getArch() == Triple::x86 &&
-         "Only i386 (little endian) is supported for now");
+         "Only x86 (little endian) is supported for now");
 
   auto &ELFObjFile = cast<object::ELFObjectFile<object::ELF32LE>>(**ELFObj);
 
-  return ELFLinkGraphBuilder_i386((*ELFObj)->getFileName(),
-                                  ELFObjFile.getELFFile(), std::move(SSP),
-                                  (*ELFObj)->makeTriple(), std::move(*Features))
+  return ELFLinkGraphBuilder_x86((*ELFObj)->getFileName(),
+                                 ELFObjFile.getELFFile(), std::move(SSP),
+                                 (*ELFObj)->makeTriple(), std::move(*Features))
       .buildGraph();
 }
 
-void link_ELF_i386(std::unique_ptr<LinkGraph> G,
-                   std::unique_ptr<JITLinkContext> Ctx) {
+void link_ELF_x86(std::unique_ptr<LinkGraph> G,
+                  std::unique_ptr<JITLinkContext> Ctx) {
   PassConfiguration Config;
   const Triple &TT = G->getTargetTriple();
   if (Ctx->shouldAddDefaultTargetPasses(TT)) {
@@ -276,15 +276,15 @@ void link_ELF_i386(std::unique_ptr<LinkGraph> G,
       Config.PrePrunePasses.push_back(markAllSymbolsLive);
 
     // Add an in-place GOT and PLT build pass.
-    Config.PostPrunePasses.push_back(buildTables_ELF_i386);
+    Config.PostPrunePasses.push_back(buildTables_ELF_x86);
 
     // Add GOT/Stubs optimizer pass.
-    Config.PreFixupPasses.push_back(i386::optimizeGOTAndStubAccesses);
+    Config.PreFixupPasses.push_back(x86::optimizeGOTAndStubAccesses);
   }
   if (auto Err = Ctx->modifyPassConfig(*G, Config))
     return Ctx->notifyFailed(std::move(Err));
 
-  ELFJITLinker_i386::link(std::move(Ctx), std::move(G), std::move(Config));
+  ELFJITLinker_x86::link(std::move(Ctx), std::move(G), std::move(Config));
 }
 
 } // namespace llvm::jitlink

diff  --git a/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
index e1209e1e95496..355f44d589a2d 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
@@ -15,8 +15,8 @@
 #include "llvm/ExecutionEngine/JITLink/MachO.h"
 #include "llvm/ExecutionEngine/JITLink/XCOFF.h"
 #include "llvm/ExecutionEngine/JITLink/aarch64.h"
-#include "llvm/ExecutionEngine/JITLink/i386.h"
 #include "llvm/ExecutionEngine/JITLink/loongarch.h"
+#include "llvm/ExecutionEngine/JITLink/x86.h"
 #include "llvm/ExecutionEngine/JITLink/x86_64.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -466,7 +466,7 @@ AnonymousPointerCreator getAnonymousPointerCreator(const Triple &TT) {
   case Triple::x86_64:
     return x86_64::createAnonymousPointer;
   case Triple::x86:
-    return i386::createAnonymousPointer;
+    return x86::createAnonymousPointer;
   case Triple::loongarch32:
   case Triple::loongarch64:
     return loongarch::createAnonymousPointer;
@@ -482,7 +482,7 @@ PointerJumpStubCreator getPointerJumpStubCreator(const Triple &TT) {
   case Triple::x86_64:
     return x86_64::createAnonymousPointerJumpStub;
   case Triple::x86:
-    return i386::createAnonymousPointerJumpStub;
+    return x86::createAnonymousPointerJumpStub;
   case Triple::loongarch32:
   case Triple::loongarch64:
     return loongarch::createAnonymousPointerJumpStub;

diff  --git a/llvm/lib/ExecutionEngine/JITLink/i386.cpp b/llvm/lib/ExecutionEngine/JITLink/x86.cpp
similarity index 87%
rename from llvm/lib/ExecutionEngine/JITLink/i386.cpp
rename to llvm/lib/ExecutionEngine/JITLink/x86.cpp
index f714716fb353d..2743d4614743d 100644
--- a/llvm/lib/ExecutionEngine/JITLink/i386.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/x86.cpp
@@ -1,4 +1,4 @@
-//===---- i386.cpp - Generic JITLink i386 edge kinds, utilities -----===//
+//===-------- x86.cpp - Generic JITLink x86 edge kinds, utilities ---------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,15 +6,15 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// Generic utilities for graphs representing i386 objects.
+// Generic utilities for graphs representing x86 objects.
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/ExecutionEngine/JITLink/i386.h"
+#include "llvm/ExecutionEngine/JITLink/x86.h"
 
 #define DEBUG_TYPE "jitlink"
 
-namespace llvm::jitlink::i386 {
+namespace llvm::jitlink::x86 {
 
 const char *getEdgeKindName(Edge::Kind K) {
   switch (K) {
@@ -53,7 +53,7 @@ Error optimizeGOTAndStubAccesses(LinkGraph &G) {
 
   for (auto *B : G.blocks())
     for (auto &E : B->edges()) {
-      if (E.getKind() == i386::BranchPCRel32ToPtrJumpStubBypassable) {
+      if (E.getKind() == x86::BranchPCRel32ToPtrJumpStubBypassable) {
         auto &StubBlock = E.getTarget().getBlock();
         assert(StubBlock.getSize() == sizeof(PointerJumpStubContent) &&
                "Stub block should be stub sized");
@@ -72,7 +72,7 @@ Error optimizeGOTAndStubAccesses(LinkGraph &G) {
 
         int64_t Displacement = TargetAddr - EdgeAddr + 4;
         if (isInt<32>(Displacement)) {
-          E.setKind(i386::BranchPCRel32);
+          E.setKind(x86::BranchPCRel32);
           E.setTarget(GOTTarget);
           LLVM_DEBUG({
             dbgs() << "  Replaced stub branch with direct branch:\n    ";
@@ -86,4 +86,4 @@ Error optimizeGOTAndStubAccesses(LinkGraph &G) {
   return Error::success();
 }
 
-} // namespace llvm::jitlink::i386
+} // namespace llvm::jitlink::x86

diff  --git a/llvm/test/ExecutionEngine/JITLink/i386/ELF_external_to_absolute_conversion.s b/llvm/test/ExecutionEngine/JITLink/x86/ELF_external_to_absolute_conversion.s
similarity index 100%
rename from llvm/test/ExecutionEngine/JITLink/i386/ELF_external_to_absolute_conversion.s
rename to llvm/test/ExecutionEngine/JITLink/x86/ELF_external_to_absolute_conversion.s

diff  --git a/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_absolute_relocations_16.s b/llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_absolute_relocations_16.s
similarity index 100%
rename from llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_absolute_relocations_16.s
rename to llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_absolute_relocations_16.s

diff  --git a/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_absolute_relocations_32.s b/llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_absolute_relocations_32.s
similarity index 100%
rename from llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_absolute_relocations_32.s
rename to llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_absolute_relocations_32.s

diff  --git a/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_minimal.s b/llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_minimal.s
similarity index 100%
rename from llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_minimal.s
rename to llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_minimal.s

diff  --git a/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_pc_relative_relocations_32.s b/llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_pc_relative_relocations_32.s
similarity index 100%
rename from llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_pc_relative_relocations_32.s
rename to llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_pc_relative_relocations_32.s

diff  --git a/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations_got.s b/llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_small_pic_relocations_got.s
similarity index 100%
rename from llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations_got.s
rename to llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_small_pic_relocations_got.s

diff  --git a/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations_plt.s b/llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_small_pic_relocations_plt.s
similarity index 95%
rename from llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations_plt.s
rename to llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_small_pic_relocations_plt.s
index ce565ca2fcdda..e74ee7159f24b 100644
--- a/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations_plt.s
+++ b/llvm/test/ExecutionEngine/JITLink/x86/ELF_x86_small_pic_relocations_plt.s
@@ -21,7 +21,7 @@ main:
 # This produces a Branch32 edge that is resolved like a regular PCRel32 
 # (no PLT entry created).
 # 
-# NOTE - For ELF/i386 we always optimize away the PLT calls as the 
+# NOTE - For ELF/x86 we always optimize away the PLT calls as the 
 # displacement between the target address and the edge address always 
 # fits in an int32_t. Regardless, we always create the PLT stub and GOT entry
 # for position independent code, first, as there may be future use-cases

diff  --git a/llvm/test/ExecutionEngine/JITLink/i386/lit.local.cfg b/llvm/test/ExecutionEngine/JITLink/x86/lit.local.cfg
similarity index 100%
rename from llvm/test/ExecutionEngine/JITLink/i386/lit.local.cfg
rename to llvm/test/ExecutionEngine/JITLink/x86/lit.local.cfg


        


More information about the llvm-commits mailing list