ObjectTransformLayer.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- ObjectTransformLayer.h - Run all objects through functor -*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // Run all objects passed in through a user supplied functor.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H
  18. #define LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H
  19. #include "llvm/ExecutionEngine/JITSymbol.h"
  20. #include "llvm/ExecutionEngine/Orc/Layer.h"
  21. #include <algorithm>
  22. #include <memory>
  23. #include <string>
  24. namespace llvm {
  25. namespace orc {
  26. class ObjectTransformLayer : public ObjectLayer {
  27. public:
  28. using TransformFunction =
  29. std::function<Expected<std::unique_ptr<MemoryBuffer>>(
  30. std::unique_ptr<MemoryBuffer>)>;
  31. ObjectTransformLayer(ExecutionSession &ES, ObjectLayer &BaseLayer,
  32. TransformFunction Transform = TransformFunction());
  33. void emit(std::unique_ptr<MaterializationResponsibility> R,
  34. std::unique_ptr<MemoryBuffer> O) override;
  35. void setTransform(TransformFunction Transform) {
  36. this->Transform = std::move(Transform);
  37. }
  38. private:
  39. ObjectLayer &BaseLayer;
  40. TransformFunction Transform;
  41. };
  42. } // end namespace orc
  43. } // end namespace llvm
  44. #endif // LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H
  45. #ifdef __GNUC__
  46. #pragma GCC diagnostic pop
  47. #endif