xref: /llvm-project/flang/runtime/assign-impl.h (revision 43cb424a54c9452b60d96ef07d0699fc3b1ceb87)
1 //===-- runtime/assign-impl.h -----------------------------------*- C++ -*-===//
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 #ifndef FORTRAN_RUNTIME_ASSIGN_IMPL_H_
10 #define FORTRAN_RUNTIME_ASSIGN_IMPL_H_
11 
12 #include "flang/Runtime/freestanding-tools.h"
13 
14 namespace Fortran::runtime {
15 class Descriptor;
16 class Terminator;
17 
18 using MemmoveFct = void *(*)(void *, const void *, std::size_t);
19 
20 // Assign one object to another via allocate statement from source specifier.
21 // Note that if allocate object and source expression have the same rank, the
22 // value of the allocate object becomes the value provided; otherwise the value
23 // of each element of allocate object becomes the value provided (9.7.1.2(7)).
24 #ifdef RT_DEVICE_COMPILATION
25 static RT_API_ATTRS void *MemmoveWrapper(
26     void *dest, const void *src, std::size_t count) {
27   return Fortran::runtime::memmove(dest, src, count);
28 }
29 RT_API_ATTRS void DoFromSourceAssign(Descriptor &, const Descriptor &,
30     Terminator &, MemmoveFct memmoveFct = &MemmoveWrapper);
31 #else
32 RT_API_ATTRS void DoFromSourceAssign(Descriptor &, const Descriptor &,
33     Terminator &, MemmoveFct memmoveFct = &Fortran::runtime::memmove);
34 #endif
35 
36 } // namespace Fortran::runtime
37 #endif // FORTRAN_RUNTIME_ASSIGN_IMPL_H_
38