LLVM  14.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 
12 namespace llvm {
13 namespace orc {
14 
16 
17 using 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.
MemoryBuffer.h
llvm::orc::BaseT
RTTIExtends< ObjectLinkingLayer, ObjectLayer > BaseT
Definition: ObjectLinkingLayer.cpp:614
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::orc::ObjectTransformLayer::emit
void emit(std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< MemoryBuffer > O) override
Definition: ObjectTransformLayer.cpp:24
llvm::orc::ObjectTransformLayer::ObjectTransformLayer
ObjectTransformLayer(ExecutionSession &ES, ObjectLayer &BaseLayer, TransformFunction Transform=TransformFunction())
Definition: ObjectTransformLayer.cpp:19
ObjectTransformLayer.h
llvm::orc::ObjectTransformLayer::TransformFunction
std::function< Expected< std::unique_ptr< MemoryBuffer > >(std::unique_ptr< MemoryBuffer >)> TransformFunction
Definition: ObjectTransformLayer.h:31
llvm::orc::ObjectLayer
Interface for Layers that accept object files.
Definition: Layer.h:134
llvm::RTTIExtends< ObjectLinkingLayer, ObjectLayer >
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:192
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
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:1609
llvm::orc::ObjectLayer::emit
virtual void emit(std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< MemoryBuffer > O)=0
Emit should materialize the given IR.
std
Definition: BitVector.h:838
llvm::orc::ExecutionSession
An ExecutionSession represents a running JIT program.
Definition: Core.h:1275
llvm::orc::ObjectTransformLayer::ID
static char ID
Definition: ObjectTransformLayer.h:27