mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-05-14 19:18:36 +00:00

So far we had no way to distinguish between JITLink and RuntimeDyld in lli. Instead, we used implicit knowledge that RuntimeDyld would be used for linking ELF. In order to get D97337 to work with lli though, we have to move on and allow JITLink for ELF. This patch uses extensible RTTI to allow external clients to add their own layers without touching the LLVM sources. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D97338
45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
//===---------- ObjectTransformLayer.cpp - Object Transform Layer ---------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
|
|
#include "llvm/Support/MemoryBuffer.h"
|
|
|
|
namespace llvm {
|
|
namespace orc {
|
|
|
|
char ObjectTransformLayer::ID;
|
|
|
|
using BaseT = RTTIExtends<ObjectTransformLayer, ObjectLayer>;
|
|
|
|
ObjectTransformLayer::ObjectTransformLayer(ExecutionSession &ES,
|
|
ObjectLayer &BaseLayer,
|
|
TransformFunction Transform)
|
|
: BaseT(ES), BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
|
|
|
|
void ObjectTransformLayer::emit(
|
|
std::unique_ptr<MaterializationResponsibility> R,
|
|
std::unique_ptr<MemoryBuffer> O) {
|
|
assert(O && "Module must not be null");
|
|
|
|
// If there is a transform set then apply it.
|
|
if (Transform) {
|
|
if (auto TransformedObj = Transform(std::move(O)))
|
|
O = std::move(*TransformedObj);
|
|
else {
|
|
R->failMaterialization();
|
|
getExecutionSession().reportError(TransformedObj.takeError());
|
|
return;
|
|
}
|
|
}
|
|
|
|
BaseLayer.emit(std::move(R), std::move(O));
|
|
}
|
|
|
|
} // End namespace orc.
|
|
} // End namespace llvm.
|