annotate lwasm/pass6.c @ 367:34dfc9747f23

Reduction passes complete
author lost@starbug
date Thu, 15 Apr 2010 21:56:06 -0600
parents
children 898a41f7eb59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
367
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
1 /*
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
2 pass6.c
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
3
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
4 Copyright © 2010 William Astle
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
5
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
6 This file is part of LWTOOLS.
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
7
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
8 LWTOOLS is free software: you can redistribute it and/or modify it under the
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
9 terms of the GNU General Public License as published by the Free Software
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
10 Foundation, either version 3 of the License, or (at your option) any later
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
11 version.
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
12
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
13 This program is distributed in the hope that it will be useful, but WITHOUT
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
16 more details.
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
17
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
18 You should have received a copy of the GNU General Public License along with
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
19 this program. If not, see <http://www.gnu.org/licenses/>.
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
20 */
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
21
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
22 #include <config.h>
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
23
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
24 #include <stdio.h>
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
25 #include <string.h>
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
26
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
27 #include <lw_alloc.h>
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
28 #include <lw_string.h>
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
29
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
30 #include "lwasm.h"
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
31 #include "instab.h"
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
32
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
33 /*
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
34 Finalize Pass
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
35
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
36 Reduce all expressions in a final pass.
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
37
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
38 Observation:
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
39
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
40 Everything should reduce as far as it is going to in a single pass
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
41 because all line addresses are now constant (or section-base offset)
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
42
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
43 */
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
44 void do_pass6(asmstate_t *as)
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
45 {
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
46 line_t *cl;
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
47 struct line_expr_s *le;
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
48
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
49 for (cl = as -> line_head; cl; cl = cl -> next)
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
50 {
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
51 as -> cl = cl;
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
52 for (le = cl -> exprs; le; le = le -> next)
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
53 {
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
54 lwasm_reduce_expr(as, le -> expr);
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
55 }
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
56 }
34dfc9747f23 Reduction passes complete
lost@starbug
parents:
diff changeset
57 }