x86/Intel: adjust representation of embedded broadcast
[binutils-gdb.git] / gas / expr.h
index 1d968e7ca47078cad3db2a52a374bdb08ecb8e0b..dff408574275e02ba112450ff442a59997cd24fb 100644 (file)
@@ -1,12 +1,11 @@
 /* expr.h -> header file for expr.c
-   Copyright 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1987-2022 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
    GAS is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
+   the Free Software Foundation; either version 3, or (at your option)
    any later version.
 
    GAS is distributed in the hope that it will be useful,
 
    You should have received a copy of the GNU General Public License
    along with GAS; see the file COPYING.  If not, write to the Free
-   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
-
-/*
- * By popular demand, we define a struct to represent an expression.
- * This will no doubt mutate as expressions become baroque.
- *
- * Currently, we support expressions like "foo OP bar + 42".  In other
- * words we permit a (possibly undefined) symbol, a (possibly
- * undefined) symbol and the operation used to combine the symbols,
- * and an (absolute) augend.  RMS says this is so we can have 1-pass
- * assembly for any compiler emissions, and a 'case' statement might
- * emit 'undefined1 - undefined2'.
- *
- * The type of an expression used to be stored as a segment.  That got
- * confusing because it overloaded the concept of a segment.  I added
- * an operator field, instead.
- */
+   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+/* By popular demand, we define a struct to represent an expression.
+   This will no doubt mutate as expressions become baroque.
+
+   Currently, we support expressions like "foo OP bar + 42".  In other
+   words we permit a (possibly undefined) symbol, a (possibly
+   undefined) symbol and the operation used to combine the symbols,
+   and an (absolute) augend.  RMS says this is so we can have 1-pass
+   assembly for any compiler emissions, and a 'case' statement might
+   emit 'undefined1 - undefined2'.
+
+   The type of an expression used to be stored as a segment.  That got
+   confusing because it overloaded the concept of a segment.  I added
+   an operator field, instead.  */
 
 /* This is the type of an expression.  The operator types are also
    used while parsing an expression.
 
    NOTE: This enumeration must match the op_rank array in expr.c.  */
 
-typedef enum {
+typedef enum
+{
   /* An illegal expression.  */
   O_illegal,
   /* A nonexistent expression.  */
@@ -51,6 +49,8 @@ typedef enum {
   O_symbol,
   /* X_add_symbol + X_add_number - the base address of the image.  */
   O_symbol_rva,
+  /* The section index of X_add_symbol.  */
+  O_secidx,
   /* A register (X_add_number is register number).  */
   O_register,
   /* A big value.  If X_add_number is negative or 0, the value is in
@@ -113,7 +113,8 @@ typedef enum {
   O_max
 } operatorT;
 
-typedef struct expressionS {
+typedef struct expressionS
+{
   /* The main symbol.  */
   symbolS *X_add_symbol;
   /* The second symbol, if needed.  */
@@ -136,6 +137,11 @@ typedef struct expressionS {
      when performing arithmetic on these values).
      FIXME: This field is not set very reliably.  */
   unsigned int X_unsigned : 1;
+  /* This is used to implement "word size + 1 bit" arithmetic, so that e.g.
+     expressions used with .sleb128 directives can use the full range available
+     for an unsigned word, but can also properly represent all values of a
+     signed word.  */
+  unsigned int X_extrabit : 1;
 
   /* 7 additional bits can be defined if needed.  */
 
@@ -143,8 +149,17 @@ typedef struct expressionS {
   unsigned short X_md;
 } expressionS;
 
+enum expr_mode
+{
+  expr_evaluate,
+  expr_normal,
+  expr_defer
+};
+
 /* "result" should be type (expressionS *).  */
-#define expression(result) expr (0, result)
+#define expression(result) expr (0, result, expr_normal)
+#define expression_and_evaluate(result) expr (0, result, expr_evaluate)
+#define deferred_expression(result) expr (0, result, expr_defer)
 
 /* If an expression is O_big, look here for its value. These common
    data may be clobbered whenever expr() is called.  */
@@ -157,15 +172,22 @@ extern LITTLENUM_TYPE generic_bignum[];
 
 typedef char operator_rankT;
 
-extern char get_symbol_end (void);
+extern char get_symbol_name (char **);
+extern char restore_line_pointer (char);
 extern void expr_begin (void);
 extern void expr_set_precedence (void);
-extern segT expr (int rank, expressionS * resultP);
+extern void expr_set_rank (operatorT, operator_rankT);
+extern void add_to_result (expressionS *, offsetT, int);
+extern void subtract_from_result (expressionS *, offsetT, int);
+extern segT expr (int, expressionS *, enum expr_mode);
 extern unsigned int get_single_number (void);
 extern symbolS *make_expr_symbol (expressionS * expressionP);
-extern int expr_symbol_where (symbolS *, char **, unsigned int *);
-
+extern int expr_symbol_where (symbolS *, const char **, unsigned int *);
+extern void current_location (expressionS *);
 extern symbolS *expr_build_uconstant (offsetT);
-extern symbolS *expr_build_unary (operatorT, symbolS *);
-extern symbolS *expr_build_binary (operatorT, symbolS *, symbolS *);
 extern symbolS *expr_build_dot (void);
+extern uint32_t generic_bignum_to_int32 (void);
+extern uint64_t generic_bignum_to_int64 (void);
+extern int resolve_expression (expressionS *);
+
+extern bool literal_prefix_dollar_hex;