| 1 | //===- EPCGenericMemoryAccessSPS.cpp - SPS memory access ------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "llvm/ExecutionEngine/Orc/EPCGenericMemoryAccessSPS.h" |
| 10 | |
| 11 | #include "llvm/ExecutionEngine/Orc/Core.h" |
| 12 | #include "llvm/ExecutionEngine/Orc/LookupAndApply.h" |
| 13 | #include "llvm/ExecutionEngine/Orc/RecordProxy.h" |
| 14 | |
| 15 | namespace llvm::orc::sps { |
| 16 | |
| 17 | Expected<std::unique_ptr<EPCGenericMemoryAccess>> |
| 18 | createEPCGenericMemoryAccess(JITDylib &JD) { |
| 19 | auto &ES = JD.getExecutionSession(); |
| 20 | EPCGenericMemoryAccess::Funcs Fns; |
| 21 | // The proxies resolve to the specs' default controller-interface names. |
| 22 | if (auto Err = lookupAndApply( |
| 23 | JD, PrepareFns: {recordProxy<MemWriteUInt8sProxySpec>(P: &Fns.WriteUInt8s), |
| 24 | recordProxy<MemWriteUInt16sProxySpec>(P: &Fns.WriteUInt16s), |
| 25 | recordProxy<MemWriteUInt32sProxySpec>(P: &Fns.WriteUInt32s), |
| 26 | recordProxy<MemWriteUInt64sProxySpec>(P: &Fns.WriteUInt64s), |
| 27 | recordProxy<MemWritePointersProxySpec>(P: &Fns.WritePointers), |
| 28 | recordProxy<MemWriteBuffersProxySpec>(P: &Fns.WriteBuffers), |
| 29 | recordProxy<MemReadUInt8sProxySpec>(P: &Fns.ReadUInt8s), |
| 30 | recordProxy<MemReadUInt16sProxySpec>(P: &Fns.ReadUInt16s), |
| 31 | recordProxy<MemReadUInt32sProxySpec>(P: &Fns.ReadUInt32s), |
| 32 | recordProxy<MemReadUInt64sProxySpec>(P: &Fns.ReadUInt64s), |
| 33 | recordProxy<MemReadPointersProxySpec>(P: &Fns.ReadPointers), |
| 34 | recordProxy<MemReadBuffersProxySpec>(P: &Fns.ReadBuffers), |
| 35 | recordProxy<MemReadStringsProxySpec>(P: &Fns.ReadStrings)})) |
| 36 | return std::move(Err); |
| 37 | return std::make_unique<EPCGenericMemoryAccess>(args&: ES, args: std::move(Fns)); |
| 38 | } |
| 39 | |
| 40 | Expected<std::unique_ptr<EPCGenericMemoryAccess>> |
| 41 | createEPCGenericMemoryAccess(ExecutionSession &ES) { |
| 42 | return createEPCGenericMemoryAccess(JD&: ES.getBootstrapJITDylib()); |
| 43 | } |
| 44 | |
| 45 | } // namespace llvm::orc::sps |
| 46 | |