1*349cc55cSDimitry Andric //===- EPCGenericMemoryAccess.h - Generic EPC MemoryAccess impl -*- C++ -*-===// 2*349cc55cSDimitry Andric // 3*349cc55cSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*349cc55cSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*349cc55cSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*349cc55cSDimitry Andric // 7*349cc55cSDimitry Andric //===----------------------------------------------------------------------===// 8*349cc55cSDimitry Andric // 9*349cc55cSDimitry Andric // Implements ExecutorProcessControl::MemoryAccess by making calls to 10*349cc55cSDimitry Andric // ExecutorProcessControl::callWrapperAsync. 11*349cc55cSDimitry Andric // 12*349cc55cSDimitry Andric // This simplifies the implementaton of new ExecutorProcessControl instances, 13*349cc55cSDimitry Andric // as this implementation will always work (at the cost of some performance 14*349cc55cSDimitry Andric // overhead for the calls). 15*349cc55cSDimitry Andric // 16*349cc55cSDimitry Andric //===----------------------------------------------------------------------===// 17*349cc55cSDimitry Andric 18*349cc55cSDimitry Andric #ifndef LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H 19*349cc55cSDimitry Andric #define LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H 20*349cc55cSDimitry Andric 21*349cc55cSDimitry Andric #include "llvm/ExecutionEngine/Orc/Core.h" 22*349cc55cSDimitry Andric 23*349cc55cSDimitry Andric namespace llvm { 24*349cc55cSDimitry Andric namespace orc { 25*349cc55cSDimitry Andric 26*349cc55cSDimitry Andric class EPCGenericMemoryAccess : public ExecutorProcessControl::MemoryAccess { 27*349cc55cSDimitry Andric public: 28*349cc55cSDimitry Andric /// Function addresses for memory access. 29*349cc55cSDimitry Andric struct FuncAddrs { 30*349cc55cSDimitry Andric ExecutorAddr WriteUInt8s; 31*349cc55cSDimitry Andric ExecutorAddr WriteUInt16s; 32*349cc55cSDimitry Andric ExecutorAddr WriteUInt32s; 33*349cc55cSDimitry Andric ExecutorAddr WriteUInt64s; 34*349cc55cSDimitry Andric ExecutorAddr WriteBuffers; 35*349cc55cSDimitry Andric }; 36*349cc55cSDimitry Andric 37*349cc55cSDimitry Andric /// Create an EPCGenericMemoryAccess instance from a given set of 38*349cc55cSDimitry Andric /// function addrs. 39*349cc55cSDimitry Andric EPCGenericMemoryAccess(ExecutorProcessControl &EPC, FuncAddrs FAs) 40*349cc55cSDimitry Andric : EPC(EPC), FAs(FAs) {} 41*349cc55cSDimitry Andric 42*349cc55cSDimitry Andric void writeUInt8sAsync(ArrayRef<tpctypes::UInt8Write> Ws, 43*349cc55cSDimitry Andric WriteResultFn OnWriteComplete) override { 44*349cc55cSDimitry Andric using namespace shared; 45*349cc55cSDimitry Andric EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt8Write>)>( 46*349cc55cSDimitry Andric FAs.WriteUInt8s, std::move(OnWriteComplete), Ws); 47*349cc55cSDimitry Andric } 48*349cc55cSDimitry Andric 49*349cc55cSDimitry Andric void writeUInt16sAsync(ArrayRef<tpctypes::UInt16Write> Ws, 50*349cc55cSDimitry Andric WriteResultFn OnWriteComplete) override { 51*349cc55cSDimitry Andric using namespace shared; 52*349cc55cSDimitry Andric EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt16Write>)>( 53*349cc55cSDimitry Andric FAs.WriteUInt16s, std::move(OnWriteComplete), Ws); 54*349cc55cSDimitry Andric } 55*349cc55cSDimitry Andric 56*349cc55cSDimitry Andric void writeUInt32sAsync(ArrayRef<tpctypes::UInt32Write> Ws, 57*349cc55cSDimitry Andric WriteResultFn OnWriteComplete) override { 58*349cc55cSDimitry Andric using namespace shared; 59*349cc55cSDimitry Andric EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt32Write>)>( 60*349cc55cSDimitry Andric FAs.WriteUInt32s, std::move(OnWriteComplete), Ws); 61*349cc55cSDimitry Andric } 62*349cc55cSDimitry Andric 63*349cc55cSDimitry Andric void writeUInt64sAsync(ArrayRef<tpctypes::UInt64Write> Ws, 64*349cc55cSDimitry Andric WriteResultFn OnWriteComplete) override { 65*349cc55cSDimitry Andric using namespace shared; 66*349cc55cSDimitry Andric EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt64Write>)>( 67*349cc55cSDimitry Andric FAs.WriteUInt64s, std::move(OnWriteComplete), Ws); 68*349cc55cSDimitry Andric } 69*349cc55cSDimitry Andric 70*349cc55cSDimitry Andric void writeBuffersAsync(ArrayRef<tpctypes::BufferWrite> Ws, 71*349cc55cSDimitry Andric WriteResultFn OnWriteComplete) override { 72*349cc55cSDimitry Andric using namespace shared; 73*349cc55cSDimitry Andric EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessBufferWrite>)>( 74*349cc55cSDimitry Andric FAs.WriteBuffers, std::move(OnWriteComplete), Ws); 75*349cc55cSDimitry Andric } 76*349cc55cSDimitry Andric 77*349cc55cSDimitry Andric private: 78*349cc55cSDimitry Andric ExecutorProcessControl &EPC; 79*349cc55cSDimitry Andric FuncAddrs FAs; 80*349cc55cSDimitry Andric }; 81*349cc55cSDimitry Andric 82*349cc55cSDimitry Andric } // end namespace orc 83*349cc55cSDimitry Andric } // end namespace llvm 84*349cc55cSDimitry Andric 85*349cc55cSDimitry Andric #endif // LLVM_EXECUTIONENGINE_ORC_EPCGENERICMEMORYACCESS_H 86