github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/internal/ccall/jit-rules-x86.h (about)

     1  /*
     2   * jit-rules-x86.h - Rules that define the characteristics of the x86.
     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_RULES_X86_H
    24  #define	_JIT_RULES_X86_H
    25  
    26  #ifdef	__cplusplus
    27  extern	"C" {
    28  #endif
    29  
    30  /*
    31   * Information about all of the registers, in allocation order.
    32   */
    33  #define	JIT_REG_X86_FLOAT	\
    34  	(JIT_REG_FLOAT32 | JIT_REG_FLOAT64 | JIT_REG_NFLOAT)
    35  #define	JIT_REG_INFO	\
    36  	{"eax", 0, 2, JIT_REG_WORD | JIT_REG_LONG | JIT_REG_CALL_USED}, \
    37  	{"ecx", 1, 3, JIT_REG_WORD | JIT_REG_LONG | JIT_REG_CALL_USED}, \
    38  	{"edx", 2, -1, JIT_REG_WORD | JIT_REG_CALL_USED}, \
    39  	{"ebx", 3, -1, JIT_REG_WORD | JIT_REG_GLOBAL}, \
    40  	{"esi", 6, -1, JIT_REG_WORD | JIT_REG_GLOBAL}, \
    41  	{"edi", 7, -1, JIT_REG_WORD | JIT_REG_GLOBAL}, \
    42  	{"ebp", 4, -1, JIT_REG_FRAME | JIT_REG_FIXED}, \
    43  	{"esp", 5, -1, JIT_REG_STACK_PTR | JIT_REG_FIXED | JIT_REG_CALL_USED}, \
    44  	{"st",  0, -1, JIT_REG_X86_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK}, \
    45  	{"st1", 1, -1, JIT_REG_X86_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK}, \
    46  	{"st2", 2, -1, JIT_REG_X86_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK}, \
    47  	{"st3", 3, -1, JIT_REG_X86_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK}, \
    48  	{"st4", 4, -1, JIT_REG_X86_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK}, \
    49  	{"st5", 5, -1, JIT_REG_X86_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK}, \
    50  	{"st6", 6, -1, JIT_REG_X86_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK}, \
    51  	{"st7", 7, -1, JIT_REG_X86_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK},
    52  #define	JIT_NUM_REGS		16
    53  #define	JIT_NUM_GLOBAL_REGS	3
    54  
    55  #define JIT_REG_STACK		1
    56  #define JIT_REG_STACK_START	8
    57  #define JIT_REG_STACK_END	15
    58  
    59  /*
    60   * Define to 1 if we should always load values into registers
    61   * before operating on them.  i.e. the CPU does not have reg-mem
    62   * and mem-reg addressing modes.
    63   */
    64  #define	JIT_ALWAYS_REG_REG		0
    65  
    66  /*
    67   * The maximum number of bytes to allocate for the prolog.
    68   * This may be shortened once we know the true prolog size.
    69   */
    70  #define	JIT_PROLOG_SIZE			32
    71  
    72  /*
    73   * Preferred alignment for the start of functions.
    74   */
    75  #define	JIT_FUNCTION_ALIGNMENT	32
    76  
    77  /*
    78   * Define this to 1 if the platform allows reads and writes on
    79   * any byte boundary.  Define to 0 if only properly-aligned
    80   * memory accesses are allowed.
    81   */
    82  #define	JIT_ALIGN_OVERRIDES		1
    83  
    84  /*
    85   * Parameter passing rules.
    86   */
    87  #define	JIT_CDECL_WORD_REG_PARAMS		{-1}
    88  #define	JIT_FASTCALL_WORD_REG_PARAMS	{1, 2, -1}	/* ecx, edx */
    89  #define	JIT_MAX_WORD_REG_PARAMS			2
    90  #define	JIT_INITIAL_STACK_OFFSET		(2 * sizeof(void *))
    91  #define	JIT_INITIAL_FRAME_SIZE			0
    92  
    93  #ifdef	__cplusplus
    94  };
    95  #endif
    96  
    97  #endif	/* _JIT_RULES_X86_H */