Lines Matching +full:docs +full:- +full:flang +full:- +full:html
1 <!--===- docs/InternalProcedureTrampolines.md
5 SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 -->
28 its host procedure, e.g. to access `local` variable. Flang achieves this by passing
46 This document describes Flang implementation to support it.
52 ## Flang current implementation
162 ### Usage of trampolines in Flang
175 MOV static-chain-address, R#
176 JMP callee-address
180 - `callee-address` is the address of function `callee()`.
181 - `static-chain-address` - the address of the static chain
183 - `R#` is a target specific register.
188 llvm.call @llvm.init.trampoline(%8, %9, %7) : (!llvm.ptr<i8>, !llvm.ptr<i8>, !llvm.ptr<i8>) -> ()
189 %10 = llvm.call @llvm.adjust.trampoline(%8) : (!llvm.ptr<i8>) -> !llvm.ptr<i8>
191 llvm.call @_QMotherPfoo(%11) {fastmathFlags = #llvm.fastmath<fast>} : (!llvm.ptr<func<void ()>>) -> ()
203 llvm.func @_QFhostPcallee(%arg0: !llvm.ptr<struct<(ptr<i32>)>> {fir.host_assoc, llvm.nest}) -> i32 attributes {fir.internal_proc} {
208 Currently used [llvm.init.trampoline intrinsic](https://llvm.org/docs/LangRef.html#trampoline-intrinsics)
213 `@llvm.init.trampoline` intrinsic initializes the trampoline area in a target-specific manner
214 so that being executed: the trampoline sets a target-specific register to be equal to the third argument
218 e.g. [call](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/builtins/trampoline_setup.c)
223 The target-specific address of the new trampoline function must be taken via another intrinsic call:
230 a requirement - this is partly [why](https://lists.llvm.org/pipermail/llvm-dev/2011-August/042845.html)
242 > NOTE: LLVM's AArch64 backend supports `nest` attribute, but it requires the compiler-rt runtime selected via the `-rtlib=compiler-rt` flag.
251 The trampolines may be located in non-writeable executable memory:
270 * The static chain address still has to be passed in fixed target-specific register,
271 and the implementations that rely on LLVM back-ends can use `nest` attribute for this.
328 * non-null \p scratch it will be used as a writeable/executable
351 * Optional: may be no-op, if LLVM trampolines are used underneath.
380 %handle = llvm.call @_FortranAInitTrampoline(%nullptr, %9, %7) : (!llvm.ptr<i8>, !llvm.ptr<i8>, !llvm.ptr<i8>) -> !llvm.ptr<i8>
382 %10 = llvm.call @_FortranAAdjustTrampoline(%handle) : (!llvm.ptr<i8>) -> !llvm.ptr<i8>
384 llvm.call @_QMotherPfoo(%11) {fastmathFlags = #llvm.fastmath<fast>} : (!llvm.ptr<func<void ()>>) -> ()
386 llvm.call @_FortranAFreeTrampoline(%handle) : (!llvm.ptr<i8>) -> ()
393 * Follow-up patches:
398 * The author (@madvenka786) initially [proposed](https://sourceware.org/pipermail/libffi-discuss/2021/002587.html) to make the trampoline APIs public,
402 into separate library (e.g. `libstatictramp` as mentioned [here](https://sourceware.org/pipermail/libffi-discuss/2021/002592.html)).
404 Flang's own implementation for trampolines have an advantage that,
411 support in Flang runtime.