github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/internal/ccall/jit-apply-arm.h (about) 1 /* 2 * jit-apply-arm.h - Special definitions for ARM function application. 3 * 4 * Copyright (C) 2004 Southern Storm Software, Pty Ltd. 5 * 6 * This file is part of the libjit library. 7 * 8 * The libjit library is free software: you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public License 10 * as published by the Free Software Foundation, either version 2.1 of 11 * the License, or (at your option) any later version. 12 * 13 * The libjit library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with the libjit library. If not, see 20 * <http://www.gnu.org/licenses/>. 21 */ 22 23 #ifndef _JIT_APPLY_ARM_H 24 #define _JIT_APPLY_ARM_H 25 26 /* 27 * The maximum number of bytes that are needed to represent a closure, 28 * and the alignment to use for the closure. 29 */ 30 #define jit_closure_size 128 31 #define jit_closure_align 16 32 33 /* 34 * The number of bytes that are needed for a redirector stub. 35 * This includes any extra bytes that are needed for alignment. 36 */ 37 #define jit_redirector_size 128 38 39 /* 40 * The number of bytes that are needed for a indirector stub. 41 * This includes any extra bytes that are needed for alignment. 42 */ 43 #define jit_indirector_size 24 44 45 /* 46 * We should pad unused code space with NOP's. 47 */ 48 #define jit_should_pad 1 49 50 /* 51 * Defines the alignment for the stack pointer at a public interface. 52 * As of the "Procedure Call Standard for the ARM Architecture" (AAPCS release 2.07) 53 * SP mod 8 = 0 54 * must always be true at every public interface (function calls, etc) 55 */ 56 #define JIT_SP_ALIGN_PUBLIC 8 57 58 /* 59 * Redefine jit_builtin_apply in order to correctly align the stack pointer 60 * to JIT_SP_ALING_PUBLIC bytes before calling __builtin_apply to execute the 61 * jit-compiled function 62 */ 63 #define jit_builtin_apply(func,args,size,return_float,return_buf) \ 64 do { \ 65 register void *sp asm("sp"); \ 66 sp = (void *) (((unsigned) sp) & ~(JIT_SP_ALIGN_PUBLIC - 1)); \ 67 (return_buf) = __builtin_apply \ 68 ((void (*)())(func), (args), (size)); \ 69 } while (0) 70 71 #endif /* _JIT_APPLY_ARM_H */