1//===- ObjectTransformLayer.h - Run all objects through functor -*- C++ -*-===// 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// 9// Run all objects passed in through a user supplied functor. 10// 11//===----------------------------------------------------------------------===// 12 13#ifndef LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H 14#define LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H 15 16#include "llvm/ExecutionEngine/JITSymbol.h" 17#include "llvm/ExecutionEngine/Orc/Layer.h" 18#include <algorithm> 19#include <memory> 20 21namespace llvm { 22namespace orc { 23 24class ObjectTransformLayer 25 : public RTTIExtends<ObjectTransformLayer, ObjectLayer> { 26public: 27 static char ID; 28 29 using TransformFunction = 30 std::function<Expected<std::unique_ptr<MemoryBuffer>>( 31 std::unique_ptr<MemoryBuffer>)>; 32 33 ObjectTransformLayer(ExecutionSession &ES, ObjectLayer &BaseLayer, 34 TransformFunction Transform = TransformFunction()); 35 36 void emit(std::unique_ptr<MaterializationResponsibility> R, 37 std::unique_ptr<MemoryBuffer> O) override; 38 39 void setTransform(TransformFunction Transform) { 40 this->Transform = std::move(Transform); 41 } 42 43private: 44 ObjectLayer &BaseLayer; 45 TransformFunction Transform; 46}; 47 48} // end namespace orc 49} // end namespace llvm 50 51#endif // LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H 52