1 /*
2  * Copyright (C) 2012-2019  Free Software Foundation, Inc.
3  *
4  * This file is part of GNU lightning.
5  *
6  * GNU lightning is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published
8  * by the Free Software Foundation; either version 3, or (at your option)
9  * any later version.
10  *
11  * GNU lightning is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14  * License for more details.
15  *
16  * Authors:
17  *      Paulo Cesar Pereira de Andrade
18  */
19 
20 #ifndef _jit_x86_h
21 #define _jit_x86_h
22 
23 #if __WORDSIZE == 32
24 # if defined(__x86_64__)
25 #  define __X64    1
26 #  define __X64_32 1
27 #  define __X32    0
28 # else
29 #  define __X64    0
30 #  define __X64_32 0
31 #  define __X32    1
32 # endif
33 #else
34 #  define __X64    1
35 #  define __X64_32 0
36 #  define __X32    0
37 #endif
38 
39 #define _RAX     JIT_GPR(0)
40 #define _RCX     JIT_GPR(1)
41 #define _RDX     JIT_GPR(2)
42 #define _RBX     JIT_GPR(3)
43 #define _RSP     JIT_GPR(4)
44 #define _RBP     JIT_GPR(5)
45 #define _RSI     JIT_GPR(6)
46 #define _RDI     JIT_GPR(7)
47 
48 #define _XMM0    JIT_FPR(0)
49 #define _XMM1    JIT_FPR(1)
50 #define _XMM2    JIT_FPR(2)
51 #define _XMM3    JIT_FPR(3)
52 #define _XMM4    JIT_FPR(4)
53 #define _XMM5    JIT_FPR(5)
54 #define _XMM6    JIT_FPR(6)
55 #define _XMM7    JIT_FPR(7)
56 
57 #if __X64
58 #  define _R8      JIT_GPR(8)
59 #  define _R9      JIT_GPR(9)
60 #  define _R10     JIT_GPR(10)
61 #  define _R11     JIT_GPR(11)
62 #  define _R12     JIT_GPR(12)
63 #  define _R13     JIT_GPR(13)
64 #  define _R14     JIT_GPR(14)
65 #  define _R15     JIT_GPR(15)
66 #  define _XMM8    JIT_FPR(8)
67 #  define _XMM9    JIT_FPR(9)
68 #  define _XMM10   JIT_FPR(10)
69 #  define _XMM11   JIT_FPR(11)
70 #  define _XMM12   JIT_FPR(12)
71 #  define _XMM13   JIT_FPR(13)
72 #  define _XMM14   JIT_FPR(14)
73 #  define _XMM15   JIT_FPR(15)
74 #endif
75 
76 #define JIT_SP     _RSP
77 #define JIT_LR     JIT_TMP0
78 #if __X32
79 #  define JIT_R0   _RAX
80 #  define JIT_R1   _RCX
81 #  define JIT_R2   _RDX
82 #  define JIT_V0   _RBP
83 #  define JIT_V1   _RSI
84 #  define JIT_V2   _RDI
85 #  define JIT_TMP0 _RBX
86 #  define JIT_F0   _XMM0
87 #  define JIT_F1   _XMM1
88 #  define JIT_F2   _XMM2
89 #  define JIT_F3   _XMM3
90 #  define JIT_F4   _XMM4
91 #  define JIT_F5   _XMM5
92 #  define JIT_F6   _XMM6
93 #  define JIT_FTMP _XMM7
94 #  define JIT_PLATFORM_CALLEE_SAVE_GPRS JIT_TMP0
95 #elif __CYGWIN__
96 #  define JIT_R0   _RAX
97 #  define JIT_R1   _RCX
98 #  define JIT_R2   _RDX
99 #  define JIT_R3   _R8
100 #  define JIT_R4   _R9
101 #  define JIT_R5   _R10
102 #  define JIT_TMP0 _R11
103 #  define JIT_V0   _RBX
104 #  define JIT_V1   _RSI
105 #  define JIT_V2   _RDI
106 #  define JIT_V3   _R12
107 #  define JIT_V4   _R13
108 #  define JIT_V5   _R14
109 #  define JIT_V6   _R15
110 #  define JIT_F0   _XMM0
111 #  define JIT_F1   _XMM1
112 #  define JIT_F2   _XMM2
113 #  define JIT_F3   _XMM3
114 #  define JIT_F4   _XMM4
115 #  define JIT_FTMP  _XMM5
116 #  define JIT_VF0  _XMM6
117 #  define JIT_VF1  _XMM7
118 #  define JIT_VF2  _XMM8
119 #  define JIT_VF3  _XMM9
120 #  define JIT_VF4  _XMM10
121 #  define JIT_VF5  _XMM11
122 #  define JIT_VF6  _XMM12
123 #  define JIT_VF7  _XMM13
124 #  define JIT_VF8  _XMM14
125 #  define JIT_VF9  _XMM15
126 #  define JIT_PLATFORM_CALLEE_SAVE_GPRS /**/
127 #else
128 #  define JIT_R0   _RAX
129 #  define JIT_R1   _RCX
130 #  define JIT_R2   _RDX
131 #  define JIT_R3   _RSI
132 #  define JIT_R4   _RDI
133 #  define JIT_R5   _R8
134 #  define JIT_R6   _R9
135 #  define JIT_R7   _R10
136 #  define JIT_TMP0 _R11
137 #  define JIT_V0   _RBX
138 #  define JIT_V1   _R12
139 #  define JIT_V2   _R13
140 #  define JIT_V3   _R14
141 #  define JIT_V4   _R15
142 #  define JIT_F0   _XMM0
143 #  define JIT_F1   _XMM1
144 #  define JIT_F2   _XMM2
145 #  define JIT_F3   _XMM3
146 #  define JIT_F4   _XMM4
147 #  define JIT_F5   _XMM5
148 #  define JIT_F6   _XMM6
149 #  define JIT_F7   _XMM7
150 #  define JIT_F8   _XMM8
151 #  define JIT_F9   _XMM9
152 #  define JIT_F10  _XMM10
153 #  define JIT_F11  _XMM11
154 #  define JIT_F12  _XMM12
155 #  define JIT_F13  _XMM13
156 #  define JIT_F14  _XMM14
157 #  define JIT_FTMP _XMM15
158 #  define JIT_PLATFORM_CALLEE_SAVE_GPRS /**/
159 #endif
160 
161 #endif /* _jit_x86_h */
162