2000-09-29 Kazu Hirata <kazu@hxi.com>
[external/binutils.git] / ld / ldexp.h
1 /* ldexp.h -
2    Copyright 1991, 92, 93, 94, 95, 98, 2000
3    Free Software Foundation, Inc.
4
5    This file is part of GLD, the Gnu Linker.
6
7    GLD is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2, or (at your option)
10    any later version.
11
12    GLD is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GLD; see the file COPYING.  If not, write to the Free
19    Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20    02111-1307, USA.  */
21
22 #ifndef LDEXP_H
23 #define LDEXP_H
24
25 /* The result of an expression tree */
26 typedef struct
27 {
28   bfd_vma value;
29   struct lang_output_section_statement_struct *section;
30   boolean valid_p;
31 } etree_value_type;
32
33 typedef struct
34 {
35   int node_code;
36   enum { etree_binary,
37            etree_trinary,
38            etree_unary,
39            etree_name,
40            etree_assign,
41            etree_provide,
42            etree_undef,
43            etree_unspec,
44            etree_value,
45            etree_assert,
46            etree_rel } node_class;
47 } node_type;
48
49 typedef union etree_union
50 {
51   node_type type;
52   struct {
53     node_type type;
54     union etree_union *lhs;
55     union etree_union *rhs;
56   } binary;
57   struct {
58     node_type type;
59     union etree_union *cond;
60     union etree_union *lhs;
61     union etree_union *rhs;
62   } trinary;
63   struct {
64     node_type type;
65     CONST char *dst;
66     union etree_union *src;
67   } assign;
68
69   struct {
70     node_type type;
71     union   etree_union *child;
72   } unary;
73   struct {
74     node_type type;
75    CONST char *name;
76   } name;
77   struct {
78     node_type type;
79     bfd_vma value;
80   } value;
81   struct {
82     node_type type;
83     asection *section;
84     bfd_vma value;
85   } rel;
86   struct {
87     node_type type;
88     union etree_union *child;
89     const char *message;
90   } assert_s;
91 } etree_type;
92
93 etree_type *exp_intop PARAMS ((bfd_vma));
94 etree_type *exp_relop PARAMS ((asection *, bfd_vma));
95 etree_value_type invalid PARAMS ((void));
96 etree_value_type exp_fold_tree PARAMS ((etree_type *, struct
97                                         lang_output_section_statement_struct *,
98                                         lang_phase_type,
99                                         bfd_vma, bfd_vma *));
100 etree_type *exp_binop PARAMS ((int, etree_type *, etree_type *));
101 etree_type *exp_trinop PARAMS ((int,etree_type *, etree_type *, etree_type *));
102 etree_type *exp_unop PARAMS ((int, etree_type *));
103 etree_type *exp_nameop PARAMS ((int, CONST char *));
104 etree_type *exp_assop PARAMS ((int, CONST char *, etree_type *));
105 etree_type *exp_provide PARAMS ((const char *, etree_type *));
106 etree_type *exp_assert PARAMS ((etree_type *, const char *));
107 void exp_print_tree PARAMS ((etree_type *));
108 bfd_vma exp_get_vma PARAMS ((etree_type *, bfd_vma, char *, lang_phase_type));
109 int exp_get_value_int PARAMS ((etree_type *, int, char *,lang_phase_type));
110 bfd_vma exp_get_abs_int PARAMS ((etree_type *, int, char *,lang_phase_type));
111
112 #endif