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#include <string>
21
22namespace llvm {
23namespace orc {
24
25class ObjectTransformLayer
26 : public RTTIExtends<ObjectTransformLayer, ObjectLayer> {
27public:
28 static char ID;
29
30 using TransformFunction =
31 std::function<Expected<std::unique_ptr<MemoryBuffer>>(
32 std::unique_ptr<MemoryBuffer>)>;
33
34 ObjectTransformLayer(ExecutionSession &ES, ObjectLayer &BaseLayer,
35 TransformFunction Transform = TransformFunction());
36
37 void emit(std::unique_ptr<MaterializationResponsibility> R,
38 std::unique_ptr<MemoryBuffer> O) override;
39
40 void setTransform(TransformFunction Transform) {
41 this->Transform = std::move(Transform);
42 }
43
44private:
45 ObjectLayer &BaseLayer;
46 TransformFunction Transform;
47};
48
49} // end namespace orc
50} // end namespace llvm
51
52#endif // LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H
53