• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===---------- ObjectTransformLayer.cpp - Object Transform Layer ---------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
11 #include "llvm/Support/MemoryBuffer.h"
12 
13 namespace llvm {
14 namespace orc {
15 
ObjectTransformLayer2(ExecutionSession & ES,ObjectLayer & BaseLayer,TransformFunction Transform)16 ObjectTransformLayer2::ObjectTransformLayer2(ExecutionSession &ES,
17                                              ObjectLayer &BaseLayer,
18                                              TransformFunction Transform)
19     : ObjectLayer(ES), BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
20 
emit(MaterializationResponsibility R,VModuleKey K,std::unique_ptr<MemoryBuffer> O)21 void ObjectTransformLayer2::emit(MaterializationResponsibility R, VModuleKey K,
22                                  std::unique_ptr<MemoryBuffer> O) {
23   assert(O && "Module must not be null");
24 
25   if (auto TransformedObj = Transform(std::move(O)))
26     BaseLayer.emit(std::move(R), std::move(K), std::move(*TransformedObj));
27   else {
28     R.failMaterialization();
29     getExecutionSession().reportError(TransformedObj.takeError());
30   }
31 }
32 
33 } // End namespace orc.
34 } // End namespace llvm.
35