LLVM  11.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  ObjectLayer &BaseLayer,
17  TransformFunction Transform)
18  : ObjectLayer(ES), BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
19 
21  std::unique_ptr<MemoryBuffer> O) {
22  assert(O && "Module must not be null");
23 
24  // If there is a transform set then apply it.
25  if (Transform) {
26  if (auto TransformedObj = Transform(std::move(O)))
27  O = std::move(*TransformedObj);
28  else {
30  getExecutionSession().reportError(TransformedObj.takeError());
31  return;
32  }
33  }
34 
35  BaseLayer.emit(std::move(R), std::move(O));
36 }
37 
38 } // End namespace orc.
39 } // End namespace llvm.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Definition: BitVector.h:959
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition: Core.h:410
ExecutionSession & getExecutionSession()
Returns the execution session for this layer.
Definition: Layer.h:134
virtual void emit(MaterializationResponsibility R, std::unique_ptr< MemoryBuffer > O)=0
Emit should materialize the given IR.
void emit(MaterializationResponsibility R, std::unique_ptr< MemoryBuffer > O) override
Emit should materialize the given IR.
An ExecutionSession represents a running JIT program.
Definition: Core.h:1088
std::function< Expected< std::unique_ptr< MemoryBuffer > >(std::unique_ptr< MemoryBuffer >)> TransformFunction
void reportError(Error Err)
Report a error for this execution session.
Definition: Core.h:1170
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void failMaterialization()
Notify all not-yet-emitted covered by this MaterializationResponsibility instance that an error has o...
Definition: Core.cpp:242
ObjectTransformLayer(ExecutionSession &ES, ObjectLayer &BaseLayer, TransformFunction Transform=TransformFunction())
Interface for Layers that accept object files.
Definition: Layer.h:128