2 * Copyright (C) 2015-2019 Free Software Foundation, Inc.
4 * This file is part of GNU lightning.
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)
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.
17 * Paulo Cesar Pereira de Andrade
20 #include <lightning.h>
21 #include <lightning/jit_private.h>
24 # define free_synth_list(node) _free_synth_list(_jit,node)
25 static jit_node_t *_free_synth_list(jit_state_t*,jit_node_t*);
26 #define rewind_prolog() _rewind_prolog(_jit)
27 static void _rewind_prolog(jit_state_t*);
28 #define rewind_prepare() _rewind_prepare(_jit)
29 static void _rewind_prepare(jit_state_t*);
37 _free_synth_list(jit_state_t *_jit, jit_node_t *node)
42 for (node = next; node && (node->flag & jit_flag_synth); node = next) {
50 _rewind_prolog(jit_state_t *_jit)
54 _jitc->function->self.size = stack_framesize;
57 _jitc->function->self.size += 64;
59 #if __mips__ && NEW_ABI
60 /* Only add extra stack space if there are varargs
61 * arguments in registers. */
62 assert(jit_arg_reg_p(_jitc->function->self.argi));
63 _jitc->function->self.size += 64;
65 _jitc->function->self.argi =
66 _jitc->function->self.argf = _jitc->function->self.argn = 0;
67 _jitc->tail = _jitc->function->prolog;
68 node = _jitc->tail->next;
69 _jitc->tail->next = (jit_node_t *)0;
70 _jitc->tail->link = (jit_node_t *)0;
71 for (; node; node = next) {
75 node->next = (jit_node_t *)0;
79 node->next = (jit_node_t *)0;
83 node->next = (jit_node_t *)0;
86 case jit_code_getarg_c:
87 jit_getarg_c(node->u.w, node->v.n);
88 next = free_synth_list(node);
90 case jit_code_getarg_uc:
91 jit_getarg_uc(node->u.w, node->v.n);
92 next = free_synth_list(node);
94 case jit_code_getarg_s:
95 jit_getarg_s(node->u.w, node->v.n);
96 next = free_synth_list(node);
98 case jit_code_getarg_us:
99 jit_getarg_us(node->u.w, node->v.n);
100 next = free_synth_list(node);
102 case jit_code_getarg_i:
103 jit_getarg_i(node->u.w, node->v.n);
104 next = free_synth_list(node);
106 case jit_code_getarg_f:
107 jit_getarg_f(node->u.w, node->v.n);
108 next = free_synth_list(node);
110 case jit_code_getarg_d:
111 jit_getarg_d(node->u.w, node->v.n);
112 next = free_synth_list(node);
114 case jit_code_putargr:
115 jit_putargr(node->u.w, node->v.n);
116 next = free_synth_list(node);
118 case jit_code_putargi:
119 jit_putargi(node->u.w, node->v.n);
120 next = free_synth_list(node);
122 case jit_code_putargr_f:
123 jit_putargr_f(node->u.w, node->v.n);
124 next = free_synth_list(node);
126 case jit_code_putargi_f:
127 jit_putargi_f(node->u.f, node->v.n);
128 next = free_synth_list(node);
130 case jit_code_putargr_d:
131 jit_putargr_d(node->u.w, node->v.n);
132 next = free_synth_list(node);
134 case jit_code_putargi_d:
135 jit_putargi_d(node->u.d, node->v.n);
136 next = free_synth_list(node);
139 node->next = (jit_node_t *)0;
147 _rewind_prepare(jit_state_t *_jit)
151 _jitc->function->call.argi =
152 _jitc->function->call.argf =
153 _jitc->function->call.size = 0;
154 _jitc->tail = _jitc->prepare;
155 node = _jitc->tail->next;
156 _jitc->tail->next = (jit_node_t *)0;
157 _jitc->tail->link = (jit_node_t *)0;
158 for (; node; node = next) {
160 switch (node->code) {
161 case jit_code_pushargr:
162 jit_pushargr(node->u.w);
163 next = free_synth_list(node);
165 case jit_code_pushargi:
166 jit_pushargi(node->u.w);
167 next = free_synth_list(node);
169 case jit_code_pushargr_f:
170 jit_pushargr_f(node->u.w);
171 next = free_synth_list(node);
173 case jit_code_pushargi_f:
174 jit_pushargi_f(node->u.f);
175 next = free_synth_list(node);
177 case jit_code_pushargr_d:
178 jit_pushargr_d(node->u.w);
179 next = free_synth_list(node);
181 case jit_code_pushargi_d:
182 jit_pushargi_d(node->u.d);
183 next = free_synth_list(node);
186 node->next = (jit_node_t *)0;