EPCGenericMemoryAccess.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- EPCGenericMemoryAccess.h - Generic EPC MemoryAccess impl -*- 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. // Implements ExecutorProcessControl::MemoryAccess by making calls to
  15. // ExecutorProcessControl::callWrapperAsync.
  16. //
  17. // This simplifies the implementaton of new ExecutorProcessControl instances,
  18. // as this implementation will always work (at the cost of some performance
  19. // overhead for the calls).
  20. //
  21. //===----------------------------------------------------------------------===//
  22. #ifndef LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H
  23. #define LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H
  24. #include "llvm/ExecutionEngine/Orc/Core.h"
  25. namespace llvm {
  26. namespace orc {
  27. class EPCGenericMemoryAccess : public ExecutorProcessControl::MemoryAccess {
  28. public:
  29. /// Function addresses for memory access.
  30. struct FuncAddrs {
  31. ExecutorAddr WriteUInt8s;
  32. ExecutorAddr WriteUInt16s;
  33. ExecutorAddr WriteUInt32s;
  34. ExecutorAddr WriteUInt64s;
  35. ExecutorAddr WriteBuffers;
  36. };
  37. /// Create an EPCGenericMemoryAccess instance from a given set of
  38. /// function addrs.
  39. EPCGenericMemoryAccess(ExecutorProcessControl &EPC, FuncAddrs FAs)
  40. : EPC(EPC), FAs(FAs) {}
  41. void writeUInt8sAsync(ArrayRef<tpctypes::UInt8Write> Ws,
  42. WriteResultFn OnWriteComplete) override {
  43. using namespace shared;
  44. EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt8Write>)>(
  45. FAs.WriteUInt8s, std::move(OnWriteComplete), Ws);
  46. }
  47. void writeUInt16sAsync(ArrayRef<tpctypes::UInt16Write> Ws,
  48. WriteResultFn OnWriteComplete) override {
  49. using namespace shared;
  50. EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt16Write>)>(
  51. FAs.WriteUInt16s, std::move(OnWriteComplete), Ws);
  52. }
  53. void writeUInt32sAsync(ArrayRef<tpctypes::UInt32Write> Ws,
  54. WriteResultFn OnWriteComplete) override {
  55. using namespace shared;
  56. EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt32Write>)>(
  57. FAs.WriteUInt32s, std::move(OnWriteComplete), Ws);
  58. }
  59. void writeUInt64sAsync(ArrayRef<tpctypes::UInt64Write> Ws,
  60. WriteResultFn OnWriteComplete) override {
  61. using namespace shared;
  62. EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt64Write>)>(
  63. FAs.WriteUInt64s, std::move(OnWriteComplete), Ws);
  64. }
  65. void writeBuffersAsync(ArrayRef<tpctypes::BufferWrite> Ws,
  66. WriteResultFn OnWriteComplete) override {
  67. using namespace shared;
  68. EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessBufferWrite>)>(
  69. FAs.WriteBuffers, std::move(OnWriteComplete), Ws);
  70. }
  71. private:
  72. ExecutorProcessControl &EPC;
  73. FuncAddrs FAs;
  74. };
  75. } // end namespace orc
  76. } // end namespace llvm
  77. #endif // LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H
  78. #ifdef __GNUC__
  79. #pragma GCC diagnostic pop
  80. #endif