LLVM 20.0.0git
ObjectTransformLayer.cpp
Go to the documentation of this file.
1//===---------- ObjectTransformLayer.cpp - Object Transform Layer ---------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11
12namespace llvm {
13namespace orc {
14
16
17using BaseT = RTTIExtends<ObjectTransformLayer, ObjectLayer>;
18
20 ObjectLayer &BaseLayer,
21 TransformFunction Transform)
22 : BaseT(ES), BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
23
25 std::unique_ptr<MaterializationResponsibility> R,
26 std::unique_ptr<MemoryBuffer> O) {
27 assert(O && "Module must not be null");
28
29 // If there is a transform set then apply it.
30 if (Transform) {
31 if (auto TransformedObj = Transform(std::move(O)))
32 O = std::move(*TransformedObj);
33 else {
34 R->failMaterialization();
35 getExecutionSession().reportError(TransformedObj.takeError());
36 return;
37 }
38 }
39
40 BaseLayer.emit(std::move(R), std::move(O));
41}
42
43} // End namespace orc.
44} // End namespace llvm.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
An ExecutionSession represents a running JIT program.
Definition: Core.h:1431
Interface for Layers that accept object files.
Definition: Layer.h:133
virtual void emit(std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< MemoryBuffer > O)=0
Emit should materialize the given IR.
std::function< Expected< std::unique_ptr< MemoryBuffer > >(std::unique_ptr< MemoryBuffer >)> TransformFunction
void emit(std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< MemoryBuffer > O) override
ObjectTransformLayer(ExecutionSession &ES, ObjectLayer &BaseLayer, TransformFunction Transform=TransformFunction())
RTTIExtends< ObjectLinkingLayer, ObjectLayer > BaseT
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1849
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858