1 /* expr.h -> header file for expr.c
2 Copyright (C) 1987, 1992, 1993 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 * By popular demand, we define a struct to represent an expression.
22 * This will no doubt mutate as expressions become baroque.
24 * Currently, we support expressions like "foo OP bar + 42". In other
25 * words we permit a (possibly undefined) symbol, a (possibly
26 * undefined) symbol and the operation used to combine the symbols,
27 * and an (absolute) augend. RMS says this is so we can have 1-pass
28 * assembly for any compiler emissions, and a 'case' statement might
29 * emit 'undefined1 - undefined2'.
31 * The type of an expression used to be stored as a segment. That got
32 * confusing because it overloaded the concept of a segment. I added
33 * an operator field, instead.
36 /* This is the type of an expression. The operator types are also
37 used while parsing an expression.
39 NOTE: This enumeration must match the op_rank array in expr.c. */
43 /* An illegal expression. */
45 /* A nonexistent expression. */
47 /* X_add_number (a constant expression). */
49 /* X_add_symbol + X_add_number. */
51 /* A register (X_add_number is register number). */
53 /* A big value. If X_add_number is negative or 0, the value is in
54 generic_floating_point_number. Otherwise the value is in
55 generic_bignum, and X_add_number is the number of LITTLENUMs in
58 /* (- X_add_symbol) + X_add_number. */
60 /* (~ X_add_symbol) + X_add_number. */
62 /* (X_add_symbol * X_op_symbol) + X_add_number. */
64 /* (X_add_symbol / X_op_symbol) + X_add_number. */
66 /* X_add_symbol % X_op_symbol) + X_add_number. */
68 /* X_add_symbol << X_op_symbol) + X_add_number. */
70 /* X_add_symbol >> X_op_symbol) + X_add_number. */
72 /* X_add_symbol | X_op_symbol) + X_add_number. */
74 /* X_add_symbol |~ X_op_symbol) + X_add_number. */
76 /* X_add_symbol ^ X_op_symbol) + X_add_number. */
78 /* X_add_symbol & X_op_symbol) + X_add_number. */
80 /* X_add_symbol + X_op_symbol) + X_add_number. */
82 /* X_add_symbol - X_op_symbol) + X_add_number. */
86 typedef struct expressionS
88 /* The type of the expression. */
90 /* The main symbol. */
91 struct symbol
*X_add_symbol
;
92 /* The second symbol, if needed. */
93 struct symbol
*X_op_symbol
;
94 /* A number to add. */
96 /* Non-zero if X_add_number should be regarded as unsigned. This is
97 only valid for O_constant expressions. It is only used when an
98 O_constant must be extended into a bignum (i.e., it is not used
99 when performing arithmetic on these values).
100 FIXME: This field is not set very reliably.
101 If we ever need more flags here, we can make them bitfields. */
105 /* "result" should be type (expressionS *). */
106 #define expression(result) expr (0, result)
108 /* If an expression is O_big, look here for its value. These common
109 data may be clobbered whenever expr() is called. */
110 /* Flonums returned here. Big enough to hold most precise flonum. */
111 extern FLONUM_TYPE generic_floating_point_number
;
112 /* Bignums returned here. */
113 extern LITTLENUM_TYPE generic_bignum
[];
114 /* Number of littlenums in above. */
115 #define SIZE_OF_LARGE_NUMBER (20)
117 typedef char operator_rankT
;
119 char get_symbol_end
PARAMS ((void));
120 segT expr
PARAMS ((int rank
, expressionS
* resultP
));
121 unsigned int get_single_number
PARAMS ((void));
122 symbolS
*make_expr_symbol
PARAMS ((expressionS
* expressionP
));