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

     1  /*
     2   * jit-rules-x86-64.h - Rules that define the characteristics of the x86_64.
     3   *
     4   * Copyright (C) 2008  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_64_H
    24  #define	_JIT_RULES_X86_64_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_64_FLOAT	\
    34  	(JIT_REG_FLOAT32 | JIT_REG_FLOAT64 | JIT_REG_NFLOAT)
    35  #define	JIT_REG_X86_64_XMM	\
    36  	(JIT_REG_FLOAT32 | JIT_REG_FLOAT64)
    37  #define JIT_REG_X86_64_GENERAL	\
    38  	(JIT_REG_WORD | JIT_REG_LONG)
    39  #define	JIT_REG_INFO	\
    40  	{"rax", 0, -1, JIT_REG_X86_64_GENERAL | JIT_REG_CALL_USED}, \
    41  	{"rcx", 1, -1, JIT_REG_X86_64_GENERAL | JIT_REG_CALL_USED}, \
    42  	{"rdx", 2, -1, JIT_REG_X86_64_GENERAL | JIT_REG_CALL_USED}, \
    43  	{"rbx", 3, -1, JIT_REG_X86_64_GENERAL | JIT_REG_GLOBAL}, \
    44  	{"rsi", 6, -1, JIT_REG_X86_64_GENERAL | JIT_REG_CALL_USED}, \
    45  	{"rdi", 7, -1, JIT_REG_X86_64_GENERAL | JIT_REG_CALL_USED}, \
    46  	{"r8",  8, -1, JIT_REG_X86_64_GENERAL | JIT_REG_CALL_USED}, \
    47  	{"r9",  9, -1, JIT_REG_X86_64_GENERAL | JIT_REG_CALL_USED}, \
    48  	{"r10", 10, -1, JIT_REG_X86_64_GENERAL | JIT_REG_CALL_USED}, \
    49  	{"r11", 11, -1, JIT_REG_X86_64_GENERAL | JIT_REG_CALL_USED}, \
    50  	{"r12", 12, -1, JIT_REG_X86_64_GENERAL | JIT_REG_GLOBAL}, \
    51  	{"r13", 13, -1, JIT_REG_X86_64_GENERAL | JIT_REG_GLOBAL}, \
    52  	{"r14", 14, -1, JIT_REG_X86_64_GENERAL | JIT_REG_GLOBAL}, \
    53  	{"r15", 15, -1, JIT_REG_X86_64_GENERAL | JIT_REG_GLOBAL}, \
    54  	{"rbp", 5, -1, JIT_REG_FRAME | JIT_REG_FIXED | JIT_REG_CALL_USED}, \
    55  	{"rsp", 4, -1, JIT_REG_STACK_PTR | JIT_REG_FIXED | JIT_REG_CALL_USED}, \
    56  	{"xmm0", 0, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    57  	{"xmm1", 1, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    58  	{"xmm2", 2, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    59  	{"xmm3", 3, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    60  	{"xmm4", 4, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    61  	{"xmm5", 5, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    62  	{"xmm6", 6, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    63  	{"xmm7", 7, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    64  	{"xmm8", 8, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    65  	{"xmm9", 9, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    66  	{"xmm10", 10, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    67  	{"xmm11", 11, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    68  	{"xmm12", 12, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    69  	{"xmm13", 13, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    70  	{"xmm14", 14, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    71  	{"xmm15", 15, -1, JIT_REG_X86_64_XMM | JIT_REG_CALL_USED}, \
    72  	{"st0", 0, -1, JIT_REG_X86_64_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK}, \
    73  	{"st1", 1, -1, JIT_REG_X86_64_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK}, \
    74  	{"st2", 2, -1, JIT_REG_X86_64_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK}, \
    75  	{"st3", 3, -1, JIT_REG_X86_64_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK}, \
    76  	{"st4", 4, -1, JIT_REG_X86_64_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK}, \
    77  	{"st5", 5, -1, JIT_REG_X86_64_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK}, \
    78  	{"st6", 6, -1, JIT_REG_X86_64_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK}, \
    79  	{"st7", 7, -1, JIT_REG_X86_64_FLOAT | JIT_REG_CALL_USED | JIT_REG_IN_STACK},
    80  #define	JIT_NUM_REGS		40
    81  #define	JIT_NUM_GLOBAL_REGS	5
    82  
    83  #define JIT_REG_STACK		1
    84  #define JIT_REG_STACK_START	32
    85  #define JIT_REG_STACK_END	39
    86  
    87  /*
    88   * Define to 1 if we should always load values into registers
    89   * before operating on them.  i.e. the CPU does not have reg-mem
    90   * and mem-reg addressing modes.
    91   */
    92  #define	JIT_ALWAYS_REG_REG		0
    93  
    94  /*
    95   * The maximum number of bytes to allocate for the prolog.
    96   * This may be shortened once we know the true prolog size.
    97   */
    98  #define	JIT_PROLOG_SIZE			64
    99  
   100  /*
   101   * Preferred alignment for the start of functions.
   102   */
   103  #define	JIT_FUNCTION_ALIGNMENT		32
   104  
   105  /*
   106   * Define this to 1 if the platform allows reads and writes on
   107   * any byte boundary.  Define to 0 if only properly-aligned
   108   * memory accesses are allowed.
   109   */
   110  #define	JIT_ALIGN_OVERRIDES		1
   111  
   112  /*
   113   * Extra state information that is added to the "jit_gencode" structure.
   114   */
   115  
   116  #define jit_extra_gen_state	\
   117  	void *alloca_fixup
   118  
   119  #define jit_extra_gen_init(gen)	\
   120  	do {	\
   121  		(gen)->alloca_fixup = 0;	\
   122  	} while (0)
   123  
   124  #define jit_extra_gen_cleanup(gen)	do { ; } while (0)
   125  
   126  /*
   127   * Parameter passing rules.
   128   */
   129  #define	JIT_INITIAL_STACK_OFFSET	(2 * sizeof(void *))
   130  #define	JIT_INITIAL_FRAME_SIZE		0
   131  
   132  /*
   133   * We are using the param area on x86_64
   134   */
   135  #define JIT_USE_PARAM_AREA
   136  
   137  #ifdef	__cplusplus
   138  };
   139  #endif
   140  
   141  #endif	/* _JIT_RULES_X86_64_H */