ObjectTransformLayer.h 1.7 KB

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