Skip to content

Commit b972164

Browse files
lhamesLang Hames
authored and
Lang Hames
committed
[JITLink] Rename 'i386' namespace and files to 'x86'.
When building on i386, both clang and gcc define a builtin 'i386' macro (see discussion in llvm#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.
1 parent c7f350f commit b972164

15 files changed

+96
-95
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- ELF_i386.h - JIT link functions for ELF/i386 --*- C++ -*----===//
1+
//===------- ELF_x86.h - JIT link functions for ELF/x86 ------*- C++ -*----===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,33 +8,33 @@
88
//
99
//===----------------------------------------------------------------------===//
1010
//
11-
// jit-link functions for ELF/i386.
11+
// jit-link functions for ELF/x86.
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
#ifndef LLVM_EXECUTIONENGINE_JITLINK_ELF_I386_H
16-
#define LLVM_EXECUTIONENGINE_JITLINK_ELF_I386_H
15+
#ifndef LLVM_EXECUTIONENGINE_JITLINK_ELF_X86_H
16+
#define LLVM_EXECUTIONENGINE_JITLINK_ELF_X86_H
1717

1818
#include "llvm/ExecutionEngine/JITLink/JITLink.h"
1919

2020
namespace llvm {
2121
namespace jitlink {
2222

23-
/// Create a LinkGraph from an ELF/i386 relocatable object
23+
/// Create a LinkGraph from an ELF/x86 relocatable object
2424
///
2525
/// Note: The graph does not take ownership of the underlying buffer, nor copy
2626
/// its contents. The caller is responsible for ensuring that the object buffer
2727
/// outlives the graph.
2828
Expected<std::unique_ptr<LinkGraph>>
29-
createLinkGraphFromELFObject_i386(MemoryBufferRef ObjectBuffer,
30-
std::shared_ptr<orc::SymbolStringPool> SSP);
29+
createLinkGraphFromELFObject_x86(MemoryBufferRef ObjectBuffer,
30+
std::shared_ptr<orc::SymbolStringPool> SSP);
3131

32-
/// jit-link the given object buffer, which must be a ELF i386 relocatable
32+
/// jit-link the given object buffer, which must be a ELF x86 relocatable
3333
/// object file.
34-
void link_ELF_i386(std::unique_ptr<LinkGraph> G,
35-
std::unique_ptr<JITLinkContext> Ctx);
34+
void link_ELF_x86(std::unique_ptr<LinkGraph> G,
35+
std::unique_ptr<JITLinkContext> Ctx);
3636

3737
} // end namespace jitlink
3838
} // end namespace llvm
3939

40-
#endif // LLVM_EXECUTIONENGINE_JITLINK_ELF_I386_H
40+
#endif // LLVM_EXECUTIONENGINE_JITLINK_ELF_X86_H

llvm/include/llvm/ExecutionEngine/JITLink/i386.h renamed to llvm/include/llvm/ExecutionEngine/JITLink/x86.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
//=== i386.h - Generic JITLink i386 edge kinds, utilities -*- C++ -*-===//
1+
//===----- x86.h - Generic JITLink x86 edge kinds, utilities ----*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// Generic utilities for graphs representing i386 objects.
9+
// Generic utilities for graphs representing x86 objects.
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#ifndef LLVM_EXECUTIONENGINE_JITLINK_I386_H
14-
#define LLVM_EXECUTIONENGINE_JITLINK_I386_H
13+
#ifndef LLVM_EXECUTIONENGINE_JITLINK_X86_H
14+
#define LLVM_EXECUTIONENGINE_JITLINK_X86_H
1515

1616
#include "llvm/ExecutionEngine/JITLink/JITLink.h"
1717
#include "llvm/ExecutionEngine/JITLink/TableManager.h"
1818

19-
namespace llvm::jitlink::i386 {
20-
/// Represets i386 fixups
21-
enum EdgeKind_i386 : Edge::Kind {
19+
namespace llvm::jitlink::x86 {
20+
21+
/// Represets x86 fixups
22+
enum EdgeKind_x86 : Edge::Kind {
2223

2324
/// A plain 32-bit pointer value relocation.
2425
///
@@ -174,7 +175,7 @@ enum EdgeKind_i386 : Edge::Kind {
174175
BranchPCRel32ToPtrJumpStubBypassable,
175176
};
176177

177-
/// Returns a string name for the given i386 edge. For debugging purposes
178+
/// Returns a string name for the given x86 edge. For debugging purposes
178179
/// only
179180
const char *getEdgeKindName(Edge::Kind K);
180181

@@ -249,13 +250,13 @@ inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E,
249250
return Error::success();
250251
}
251252

252-
/// i386 pointer size.
253+
/// x86 pointer size.
253254
constexpr uint32_t PointerSize = 4;
254255

255-
/// i386 null pointer content.
256+
/// x86 null pointer content.
256257
extern const char NullPointerContent[PointerSize];
257258

258-
/// i386 pointer jump stub content.
259+
/// x86 pointer jump stub content.
259260
///
260261
/// Contains the instruction sequence for an indirect jump via an in-memory
261262
/// pointer:
@@ -406,6 +407,6 @@ class PLTTableManager : public TableManager<PLTTableManager> {
406407
/// target
407408
Error optimizeGOTAndStubAccesses(LinkGraph &G);
408409

409-
} // namespace llvm::jitlink::i386
410+
} // namespace llvm::jitlink::x86
410411

411-
#endif // LLVM_EXECUTIONENGINE_JITLINK_I386_H
412+
#endif // LLVM_EXECUTIONENGINE_JITLINK_X86_H

llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ add_llvm_component_library(LLVMJITLink
2323
ELFLinkGraphBuilder.cpp
2424
ELF_aarch32.cpp
2525
ELF_aarch64.cpp
26-
ELF_i386.cpp
2726
ELF_loongarch.cpp
2827
ELF_ppc64.cpp
2928
ELF_riscv.cpp
29+
ELF_x86.cpp
3030
ELF_x86_64.cpp
3131

3232
# COFF
@@ -43,10 +43,10 @@ add_llvm_component_library(LLVMJITLink
4343
# Architectures:
4444
aarch32.cpp
4545
aarch64.cpp
46-
i386.cpp
4746
loongarch.cpp
4847
ppc64.cpp
4948
riscv.cpp
49+
x86.cpp
5050
x86_64.cpp
5151

5252
ADDITIONAL_HEADER_DIRS

llvm/lib/ExecutionEngine/JITLink/ELF.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#include "llvm/BinaryFormat/ELF.h"
1616
#include "llvm/ExecutionEngine/JITLink/ELF_aarch32.h"
1717
#include "llvm/ExecutionEngine/JITLink/ELF_aarch64.h"
18-
#include "llvm/ExecutionEngine/JITLink/ELF_i386.h"
1918
#include "llvm/ExecutionEngine/JITLink/ELF_loongarch.h"
2019
#include "llvm/ExecutionEngine/JITLink/ELF_ppc64.h"
2120
#include "llvm/ExecutionEngine/JITLink/ELF_riscv.h"
21+
#include "llvm/ExecutionEngine/JITLink/ELF_x86.h"
2222
#include "llvm/ExecutionEngine/JITLink/ELF_x86_64.h"
2323
#include "llvm/Object/ELF.h"
2424
#include <cstring>
@@ -101,7 +101,7 @@ createLinkGraphFromELFObject(MemoryBufferRef ObjectBuffer,
101101
case ELF::EM_X86_64:
102102
return createLinkGraphFromELFObject_x86_64(ObjectBuffer, std::move(SSP));
103103
case ELF::EM_386:
104-
return createLinkGraphFromELFObject_i386(ObjectBuffer, std::move(SSP));
104+
return createLinkGraphFromELFObject_x86(ObjectBuffer, std::move(SSP));
105105
default:
106106
return make_error<JITLinkError>(
107107
"Unsupported target machine architecture in ELF object " +
@@ -139,7 +139,7 @@ void link_ELF(std::unique_ptr<LinkGraph> G,
139139
link_ELF_x86_64(std::move(G), std::move(Ctx));
140140
return;
141141
case Triple::x86:
142-
link_ELF_i386(std::move(G), std::move(Ctx));
142+
link_ELF_x86(std::move(G), std::move(Ctx));
143143
return;
144144
default:
145145
Ctx->notifyFailed(make_error<JITLinkError>(

0 commit comments

Comments
 (0)