Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:52

0001 //===- EPCGenericMemoryAccess.h - Generic EPC MemoryAccess impl -*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // Implements ExecutorProcessControl::MemoryAccess by making calls to
0010 // ExecutorProcessControl::callWrapperAsync.
0011 //
0012 // This simplifies the implementaton of new ExecutorProcessControl instances,
0013 // as this implementation will always work (at the cost of some performance
0014 // overhead for the calls).
0015 //
0016 //===----------------------------------------------------------------------===//
0017 
0018 #ifndef LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H
0019 #define LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H
0020 
0021 #include "llvm/ExecutionEngine/Orc/Core.h"
0022 
0023 namespace llvm {
0024 namespace orc {
0025 
0026 class EPCGenericMemoryAccess : public ExecutorProcessControl::MemoryAccess {
0027 public:
0028   /// Function addresses for memory access.
0029   struct FuncAddrs {
0030     ExecutorAddr WriteUInt8s;
0031     ExecutorAddr WriteUInt16s;
0032     ExecutorAddr WriteUInt32s;
0033     ExecutorAddr WriteUInt64s;
0034     ExecutorAddr WriteBuffers;
0035     ExecutorAddr WritePointers;
0036   };
0037 
0038   /// Create an EPCGenericMemoryAccess instance from a given set of
0039   /// function addrs.
0040   EPCGenericMemoryAccess(ExecutorProcessControl &EPC, FuncAddrs FAs)
0041       : EPC(EPC), FAs(FAs) {}
0042 
0043   void writeUInt8sAsync(ArrayRef<tpctypes::UInt8Write> Ws,
0044                         WriteResultFn OnWriteComplete) override {
0045     using namespace shared;
0046     EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt8Write>)>(
0047         FAs.WriteUInt8s, std::move(OnWriteComplete), Ws);
0048   }
0049 
0050   void writeUInt16sAsync(ArrayRef<tpctypes::UInt16Write> Ws,
0051                          WriteResultFn OnWriteComplete) override {
0052     using namespace shared;
0053     EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt16Write>)>(
0054         FAs.WriteUInt16s, std::move(OnWriteComplete), Ws);
0055   }
0056 
0057   void writeUInt32sAsync(ArrayRef<tpctypes::UInt32Write> Ws,
0058                          WriteResultFn OnWriteComplete) override {
0059     using namespace shared;
0060     EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt32Write>)>(
0061         FAs.WriteUInt32s, std::move(OnWriteComplete), Ws);
0062   }
0063 
0064   void writeUInt64sAsync(ArrayRef<tpctypes::UInt64Write> Ws,
0065                          WriteResultFn OnWriteComplete) override {
0066     using namespace shared;
0067     EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt64Write>)>(
0068         FAs.WriteUInt64s, std::move(OnWriteComplete), Ws);
0069   }
0070 
0071   void writeBuffersAsync(ArrayRef<tpctypes::BufferWrite> Ws,
0072                          WriteResultFn OnWriteComplete) override {
0073     using namespace shared;
0074     EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessBufferWrite>)>(
0075         FAs.WriteBuffers, std::move(OnWriteComplete), Ws);
0076   }
0077 
0078   void writePointersAsync(ArrayRef<tpctypes::PointerWrite> Ws,
0079                           WriteResultFn OnWriteComplete) override {
0080     using namespace shared;
0081     EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessPointerWrite>)>(
0082         FAs.WritePointers, std::move(OnWriteComplete), Ws);
0083   }
0084 
0085 private:
0086   ExecutorProcessControl &EPC;
0087   FuncAddrs FAs;
0088 };
0089 
0090 } // end namespace orc
0091 } // end namespace llvm
0092 
0093 #endif // LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H