2 * Copyright (C) 2015-2023 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->alist = NULL;
59 _jitc->function->alist = NULL;
61 _jitc->function->self.argi =
62 _jitc->function->self.argf = _jitc->function->self.argn = 0;
63 _jitc->tail = _jitc->function->prolog;
64 node = _jitc->tail->next;
65 _jitc->tail->next = (jit_node_t *)0;
66 _jitc->tail->link = (jit_node_t *)0;
67 for (; node; node = next) {
70 case jit_code_arg_c: case jit_code_arg_s:
71 case jit_code_arg_i: case jit_code_arg_l:
72 node->next = (jit_node_t *)0;
73 jit_make_arg(node, node->code);
76 node->next = (jit_node_t *)0;
80 node->next = (jit_node_t *)0;
83 case jit_code_getarg_c:
84 jit_getarg_c(node->u.w, node->v.n);
85 next = free_synth_list(node);
87 case jit_code_getarg_uc:
88 jit_getarg_uc(node->u.w, node->v.n);
89 next = free_synth_list(node);
91 case jit_code_getarg_s:
92 jit_getarg_s(node->u.w, node->v.n);
93 next = free_synth_list(node);
95 case jit_code_getarg_us:
96 jit_getarg_us(node->u.w, node->v.n);
97 next = free_synth_list(node);
99 case jit_code_getarg_i:
100 jit_getarg_i(node->u.w, node->v.n);
101 next = free_synth_list(node);
103 case jit_code_getarg_f:
104 jit_getarg_f(node->u.w, node->v.n);
105 next = free_synth_list(node);
107 case jit_code_getarg_d:
108 jit_getarg_d(node->u.w, node->v.n);
109 next = free_synth_list(node);
111 case jit_code_putargr:
112 jit_putargr(node->u.w, node->v.n);
113 next = free_synth_list(node);
115 case jit_code_putargi:
116 jit_putargi(node->u.w, node->v.n);
117 next = free_synth_list(node);
119 case jit_code_putargr_f:
120 jit_putargr_f(node->u.w, node->v.n);
121 next = free_synth_list(node);
123 case jit_code_putargi_f:
124 jit_putargi_f(node->u.f, node->v.n);
125 next = free_synth_list(node);
127 case jit_code_putargr_d:
128 jit_putargr_d(node->u.w, node->v.n);
129 next = free_synth_list(node);
131 case jit_code_putargi_d:
132 jit_putargi_d(node->u.d, node->v.n);
133 next = free_synth_list(node);
136 node->next = (jit_node_t *)0;
144 _rewind_prepare(jit_state_t *_jit)
148 _jitc->function->call.argi =
149 _jitc->function->call.argf =
150 _jitc->function->call.size = 0;
151 _jitc->tail = _jitc->prepare;
152 node = _jitc->tail->next;
153 _jitc->tail->next = (jit_node_t *)0;
154 _jitc->tail->link = (jit_node_t *)0;
155 for (; node; node = next) {
157 switch (node->code) {
158 case jit_code_pushargr:
159 jit_pushargr(node->u.w);
160 next = free_synth_list(node);
162 case jit_code_pushargi:
163 jit_pushargi(node->u.w);
164 next = free_synth_list(node);
166 case jit_code_pushargr_f:
167 jit_pushargr_f(node->u.w);
168 next = free_synth_list(node);
170 case jit_code_pushargi_f:
171 jit_pushargi_f(node->u.f);
172 next = free_synth_list(node);
174 case jit_code_pushargr_d:
175 jit_pushargr_d(node->u.w);
176 next = free_synth_list(node);
178 case jit_code_pushargi_d:
179 jit_pushargi_d(node->u.d);
180 next = free_synth_list(node);
183 node->next = (jit_node_t *)0;