Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport jitlink ppc64 #192

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion interpreter/cling/lib/Interpreter/IncrementalJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ static bool UseJITLink(const Triple& TT) {
// LLJITBuilderState::prepareForConstruction.
if (TT.getArch() == Triple::riscv64 ||
(TT.isOSBinFormatMachO() &&
(TT.getArch() == Triple::aarch64 || TT.getArch() == Triple::x86_64))) {
(TT.getArch() == Triple::aarch64 || TT.getArch() == Triple::x86_64)) ||
(TT.isOSBinFormatELF() && TT.getArch() == Triple::ppc64le)) {
jitLink = true;
}
// Finally, honor the user's choice by setting an environment variable.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//===------ ELF_ppc64.h - JIT link functions for ELF/ppc64 ------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// jit-link functions for ELF/ppc64{le}.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_EXECUTIONENGINE_JITLINK_ELF_PPC64_H
#define LLVM_EXECUTIONENGINE_JITLINK_ELF_PPC64_H

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

namespace llvm::jitlink {

/// Create a LinkGraph from an ELF/ppc64 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.
///
/// WARNING: The big-endian backend has not been tested yet.
Expected<std::unique_ptr<LinkGraph>>
createLinkGraphFromELFObject_ppc64(MemoryBufferRef ObjectBuffer);

/// Create a LinkGraph from an ELF/ppc64le 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_ppc64le(MemoryBufferRef ObjectBuffer);

/// jit-link the given object buffer, which must be a ELF ppc64le object file.
///
/// WARNING: The big-endian backend has not been tested yet.
void link_ELF_ppc64(std::unique_ptr<LinkGraph> G,
std::unique_ptr<JITLinkContext> Ctx);

/// jit-link the given object buffer, which must be a ELF ppc64le object file.
void link_ELF_ppc64le(std::unique_ptr<LinkGraph> G,
std::unique_ptr<JITLinkContext> Ctx);

} // end namespace llvm::jitlink

#endif // LLVM_EXECUTIONENGINE_JITLINK_ELF_PPC64_H
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ template <typename TableManagerImplT> class TableManager {
return *EntryI->second;
}

/// Register a pre-existing entry.
///
/// Objects may include pre-existing table entries (e.g. for GOTs).
/// This method can be used to register those entries so that they will not
/// be duplicated by createEntry the first time that getEntryForTarget is
/// called.
bool registerPreExistingEntry(Symbol &Target, Symbol &Entry) {
assert(Target.hasName() && "Edge cannot point to anonymous target");
auto Res = Entries.insert({
Target.getName(),
&Entry,
});
return Res.second;
}

private:
TableManagerImplT &impl() { return static_cast<TableManagerImplT &>(*this); }
DenseMap<StringRef, Symbol *> Entries;
Expand Down
Loading