1#ifndef _EXPR_H_ 2#define _EXPR_H_ 3/* expr.h -> header file for expr.c 4 Copyright (C) 1987 Free Software Foundation, Inc. 5 6This file is part of GAS, the GNU Assembler. 7 8GAS is free software; you can redistribute it and/or modify 9it under the terms of the GNU General Public License as published by 10the Free Software Foundation; either version 1, or (at your option) 11any later version. 12 13GAS is distributed in the hope that it will be useful, 14but WITHOUT ANY WARRANTY; without even the implied warranty of 15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16GNU General Public License for more details. 17 18You should have received a copy of the GNU General Public License 19along with GAS; see the file COPYING. If not, write to 20the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 21 22#include "as.h" 23#import "struc-symbol.h" 24#import "bignum.h" 25#import "flonum.h" 26 27enum { 28 /* FROM expr.h line 46 */ 29 /* A nonexistent expression. */ 30 O_absent = SEG_NONE, /* HACK, this isn't going to work, absent ones come up 31 illegal currently. */ 32 /* X_add_symbol + X_add_number. */ 33 O_symbol = SEG_SECT, 34 /* X_add_number (a constant expression). */ 35 O_constant = SEG_ABSOLUTE, 36 /* A big value. If X_add_number is negative or 0, the value is in 37 generic_floating_point_number. Otherwise the value is in 38 generic_bignum, and X_add_number is the number of LITTLENUMs in 39 the value. */ 40 O_big = SEG_BIG, 41}; 42 43extern char *seg_name[]; 44extern segT N_TYPE_seg[]; 45 46/* 47 * When an expression is SEG_BIG, it is in these globals (see comments above 48 * about SEG_BIG). This data may be clobbered whenever expr() is called. 49 */ 50extern FLONUM_TYPE generic_floating_point_number; 51extern LITTLENUM_TYPE generic_bignum[]; 52#define SIZE_OF_LARGE_NUMBER (20) /* Number of littlenums in above */ 53 /* generic_bignum which is enough to */ 54 /* hold most precise flonum. */ 55 56/* 57 * Abbreviations (mnemonics). 58 * 59 * O operator 60 * Q quantity, operand 61 * X eXpression 62 */ 63 64/* 65 * By popular demand, we define a struct to represent an expression. 66 * This will no doubt mutate as expressions become baroque. 67 * 68 * Currently, we support expressions like "foo-bar+42". 69 * In other words we permit a (possibly undefined) minuend, a 70 * (possibly undefined) subtrahend and an (absolute) augend. 71 * RMS says this is so we can have 1-pass assembly for any compiler 72 * emmissions, and a 'case' statement might emit 'undefined1 - undefined2'. 73 * 74 * To simplify table-driven dispatch, we also have a "segment" for the 75 * entire expression. That way we don't require complex reasoning about 76 * whether particular components are defined; and we can change component 77 * semantics without re-working all the dispatch tables in the assembler. 78 * In other words the "type" of an expression is its segment. 79 */ 80 81// This isn't really up to date with GNU as, but it helps for source 82// compatibility. 83#define X_op X_seg 84#define X_op_symbol X_add_symbol 85 86/* 87 * To allow 32-bit architectures to use things like .quad we need to make 88 * all expressions be 64-bit regardless of the target architecture's address 89 * size. 90 */ 91#include <stdint.h> 92typedef int64_t signed_expr_t; 93 94typedef struct { 95 symbolS *X_add_symbol; /* foo */ 96 symbolS *X_subtract_symbol; /* bar */ 97 signed_expr_t 98 X_add_number; /* 42 (must be signed) */ 99 segT X_seg; /* What segment (expr type) */ 100 101 /* Non-zero if X_add_number should be regarded as unsigned. This is 102 only valid for O_constant expressions. It is only used when an 103 O_constant must be extended into a bignum (i.e., it is not used 104 when performing arithmetic on these values). 105 FIXME: This field is not set very reliably. */ 106 unsigned int X_unsigned : 1, 107 108 /* Non-zero if we have the special assembly time constant expression 109 of the difference of two symbols defined in the same section then divided 110 by exactly 2. */ 111 X_sectdiff_divide_by_two : 1; 112} expressionS; 113 114extern segT expression( 115 expressionS *resultP); 116extern char get_symbol_end( 117 void); 118extern segT try_to_make_absolute( 119 expressionS *expressionP); 120/* FROM line 165 */ 121extern symbolS *make_expr_symbol (expressionS * expressionP); 122 123extern symbolS *expr_build_uconstant (offsetT); 124#endif /* _EXPR_H_ */ 125