2018-05-24 05:27:07 +08:00
|
|
|
//===-------------- IRTransformLayer.cpp - IR Transform Layer -------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// 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
|
2018-05-24 05:27:07 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
|
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace orc {
|
|
|
|
|
2018-10-16 06:56:10 +08:00
|
|
|
IRTransformLayer::IRTransformLayer(ExecutionSession &ES,
|
2018-05-24 05:27:07 +08:00
|
|
|
IRLayer &BaseLayer,
|
|
|
|
TransformFunction Transform)
|
|
|
|
: IRLayer(ES), BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
|
|
|
|
|
2018-10-17 04:13:06 +08:00
|
|
|
void IRTransformLayer::emit(MaterializationResponsibility R,
|
|
|
|
ThreadSafeModule TSM) {
|
2018-09-26 09:24:12 +08:00
|
|
|
assert(TSM.getModule() && "Module must not be null");
|
2018-05-24 05:27:07 +08:00
|
|
|
|
2018-09-29 05:49:53 +08:00
|
|
|
if (auto TransformedTSM = Transform(std::move(TSM), R))
|
2018-10-17 04:13:06 +08:00
|
|
|
BaseLayer.emit(std::move(R), std::move(*TransformedTSM));
|
2018-05-24 05:27:07 +08:00
|
|
|
else {
|
|
|
|
R.failMaterialization();
|
2018-09-26 09:24:12 +08:00
|
|
|
getExecutionSession().reportError(TransformedTSM.takeError());
|
2018-05-24 05:27:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // End namespace orc.
|
|
|
|
} // End namespace llvm.
|