ubsan: nds32: left shift cannot be represented in type 'int'
[deliverable/binutils-gdb.git] / gas / config / tc-xtensa.h
index 99ff19a50c2e8049ae024c68ff7f3e1231bccc43..6889d92a4fb668a35e14899aeb05ee5ba4c4eef2 100644 (file)
@@ -1,11 +1,11 @@
 /* tc-xtensa.h -- Header file for tc-xtensa.c.
-   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2003-2019 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,
 #ifndef TC_XTENSA
 #define TC_XTENSA 1
 
-#ifdef ANSI_PROTOTYPES
 struct fix;
-#endif
-
-#ifndef BFD_ASSEMBLER
-#error Xtensa support requires BFD_ASSEMBLER
-#endif
 
 #ifndef OBJ_ELF
 #error Xtensa support requires ELF object format
@@ -36,7 +30,7 @@ struct fix;
 #include "xtensa-isa.h"
 #include "xtensa-config.h"
 
-#define TARGET_BYTES_BIG_ENDIAN XCHAL_HAVE_BE
+#define TARGET_BYTES_BIG_ENDIAN 0
 
 
 /* Maximum number of opcode slots in a VLIW instruction.  */
@@ -52,6 +46,8 @@ struct fix;
 
 enum xtensa_relax_statesE
 {
+  RELAX_XTENSA_NONE,
+
   RELAX_ALIGN_NEXT_OPCODE,
   /* Use the first opcode of the next fragment to determine the
      alignment requirements.  This is ONLY used for LOOPs currently.  */
@@ -110,7 +106,9 @@ enum xtensa_relax_statesE
   RELAX_LOOP_END_ADD_NOP,
   /* When the code density option is available, this will generate a
      NOP.N marked RELAX_NARROW.  Otherwise, it will create an rs_fill
-     fragment with a NOP in it.  */
+     fragment with a NOP in it.  Once a frag has been converted to
+     RELAX_LOOP_END_ADD_NOP, it should never be changed back to
+     RELAX_LOOP_END.  */
 
   RELAX_LITERAL,
   /* Another fragment could generate an expansion here but has not yet.  */
@@ -126,6 +124,7 @@ enum xtensa_relax_statesE
 
   RELAX_LITERAL_POOL_BEGIN,
   RELAX_LITERAL_POOL_END,
+  RELAX_LITERAL_POOL_CANDIDATE_BEGIN,
   /* Technically these are not relaxations at all but mark a location
      to store literals later.  Note that fr_var stores the frchain for
      BEGIN frags and fr_var stores now_seg for END frags.  */
@@ -137,18 +136,20 @@ enum xtensa_relax_statesE
 
   RELAX_IMMED,
   /* The last instruction in this fragment (at->fr_opcode) contains
-     the value defined by fr_symbol (fr_offset = 0).  If the value
-     does not fit, use the specified expansion.  This is similar to
-     "NARROW", except that these may not be expanded in order to align
-     code.  */
+     an immediate or symbol.  If the value does not fit, relax the
+     opcode using expansions from the relax table.  */
 
   RELAX_IMMED_STEP1,
   /* The last instruction in this fragment (at->fr_opcode) contains a
-     literal.  It has already been expanded at least 1 step.  */
+     literal.  It has already been expanded 1 step.  */
 
   RELAX_IMMED_STEP2,
   /* The last instruction in this fragment (at->fr_opcode) contains a
-     literal.  It has already been expanded at least 2 steps.  */
+     literal.  It has already been expanded 2 steps.  */
+
+  RELAX_IMMED_STEP3,
+  /* The last instruction in this fragment (at->fr_opcode) contains a
+     literal.  It has already been expanded 3 steps.  */
 
   RELAX_SLOTS,
   /* There are instructions within the last VLIW instruction that need
@@ -173,12 +174,24 @@ enum xtensa_relax_statesE
      branch is relaxed, then this frag will be converted to a
      RELAX_UNREACHABLE frag.  */
 
+  RELAX_ORG,
+  /* This marks the location as having previously been an rs_org frag.
+     rs_org frags are converted to fill-zero frags immediately after
+     relaxation.  However, we need to remember where they were so we can
+     prevent the linker from changing the size of any frag between the
+     section start and the org frag.  */
+
+  RELAX_TRAMPOLINE,
+  /* Every few thousand frags, we insert one of these, just in case we may
+     need some space for a trampoline (jump to a jump) because the function
+     has gotten too big. If not needed, it disappears. */
+
   RELAX_NONE
 };
 
 /* This is used as a stopper to bound the number of steps that
    can be taken.  */
-#define RELAX_IMMED_MAXSTEPS (RELAX_IMMED_STEP2 - RELAX_IMMED)
+#define RELAX_IMMED_MAXSTEPS (RELAX_IMMED_STEP3 - RELAX_IMMED)
 
 struct xtensa_frag_type
 {
@@ -219,11 +232,21 @@ struct xtensa_frag_type
      contains an instruction.  */
   unsigned int is_first_loop_insn : 1;
 
+  /* A frag with this bit set is a branch that we are using to
+     align branch targets as if it were a normal narrow instruction.  */
+  unsigned int is_aligning_branch : 1;
+
+  /* A trampoline frag that is located in the middle of code and thus
+     needs a jump around.  */
+  unsigned int needs_jump_around : 1;
+
   /* For text fragments that can generate literals at relax time, this
      variable points to the frag where the literal will be stored.  For
      literal frags, this variable points to the nearest literal pool
      location frag.  This literal frag will be moved to after this
-     location.  */
+     location.  For RELAX_LITERAL_POOL_BEGIN frags, this field points
+     to the frag immediately before the corresponding RELAX_LITERAL_POOL_END
+     frag, to make moving frags for this literal pool efficient.  */
   fragS *literal_frag;
 
   /* The destination segment for literal frags.  (Note that this is only
@@ -240,16 +263,23 @@ struct xtensa_frag_type
   int literal_expansion[MAX_SLOTS];
   int unreported_expansion;
 
+  /* For slots that have a free register for relaxation, record that
+     register.  */
+  expressionS free_reg[MAX_SLOTS];
+
   /* For text fragments that can generate literals at relax time:  */
   fragS *literal_frags[MAX_SLOTS];
   enum xtensa_relax_statesE slot_subtypes[MAX_SLOTS];
   symbolS *slot_symbols[MAX_SLOTS];
-  symbolS *slot_sub_symbols[MAX_SLOTS];
   offsetT slot_offsets[MAX_SLOTS];
 
-  /* The global aligner needs to walk backward through the list of
-     frags.  This field is only valid after xtensa_end.  */
-  fragS *fr_prev;
+  /* For trampoline fragments.  */
+  struct fix *jump_around_fix;
+
+  /* When marking frags after this one in the chain as no transform,
+     cache the last one in the chain, so that we can skip to the
+     end of the chain.  */
+  fragS *no_transform_end;
 };
 
 
@@ -267,6 +297,7 @@ typedef struct xtensa_symfield_type
 {
   unsigned int is_loop_target : 1;
   unsigned int is_branch_target : 1;
+  symbolS *next_expr_symbol;
 } xtensa_symfield_type;
 
 
@@ -309,7 +340,14 @@ extern void xtensa_elf_section_change_hook (void);
 extern int xtensa_unrecognized_line (int);
 extern bfd_boolean xtensa_check_inside_bundle (void);
 extern void xtensa_handle_align (fragS *);
-extern char *xtensa_section_rename (char *);
+extern char *xtensa_section_rename (const char *);
+
+/* We need to set the target endianness in xtensa_init and not in md_begin.
+   This is because xtensa_target_format is called before md_begin, and we
+   want to have all non-statically initialized fields initialized.  */
+
+#define HOST_SPECIAL_INIT xtensa_init
+extern void xtensa_init (int, char **);
 
 #define TARGET_FORMAT                  xtensa_target_format ()
 #define TARGET_ARCH                    bfd_arch_xtensa
@@ -318,11 +356,12 @@ extern char *xtensa_section_rename (char *);
 #define TC_FIX_TYPE                    xtensa_fix_data
 #define TC_INIT_FIX_DATA(x)            xtensa_init_fix_data (x)
 #define TC_FRAG_TYPE                   struct xtensa_frag_type
-#define TC_FRAG_INIT(frag)             xtensa_frag_init (frag)
+#define TC_FRAG_INIT(frag, max_bytes)  xtensa_frag_init (frag)
 #define TC_FORCE_RELOCATION(fix)       xtensa_force_relocation (fix)
 #define TC_FORCE_RELOCATION_SUB_SAME(fix, seg) \
-  (! SEG_NORMAL (seg) || xtensa_force_relocation (fix))
-#define        TC_VALIDATE_FIX_SUB(fix)        xtensa_validate_fix_sub (fix)
+  (GENERIC_FORCE_RELOCATION_SUB_SAME (fix, seg)        \
+   || xtensa_force_relocation (fix))
+#define        TC_VALIDATE_FIX_SUB(fix, seg)   xtensa_validate_fix_sub (fix)
 #define NO_PSEUDO_DOT                  xtensa_check_inside_bundle ()
 #define tc_canonicalize_symbol_name(s) xtensa_section_rename (s)
 #define tc_canonicalize_section_name(s)        xtensa_section_rename (s)
@@ -330,6 +369,7 @@ extern char *xtensa_section_rename (char *);
 #define tc_fix_adjustable(fix)         xtensa_fix_adjustable (fix)
 #define tc_frob_label(sym)             xtensa_frob_label (sym)
 #define tc_unrecognized_line(ch)       xtensa_unrecognized_line (ch)
+#define tc_symbol_new_hook(sym)                xtensa_symbol_new_hook (sym)
 #define md_do_align(a,b,c,d,e)         xtensa_flush_pending_output ()
 #define md_elf_section_change_hook     xtensa_elf_section_change_hook
 #define md_end                         xtensa_end
@@ -339,6 +379,7 @@ extern char *xtensa_section_rename (char *);
 #define DATA_SECTION_NAME              xtensa_section_rename (".data")
 #define BSS_SECTION_NAME               xtensa_section_rename (".bss")
 #define HANDLE_ALIGN(fragP)            xtensa_handle_align (fragP)
+#define MAX_MEM_FOR_RS_ALIGN_CODE      1
 
 
 /* The renumber_section function must be mapped over all the sections
@@ -363,6 +404,10 @@ extern char *xtensa_section_rename (char *);
 #define md_relax_frag(segment, fragP, stretch) \
   xtensa_relax_frag (fragP, stretch, &stretched)
 
+/* Only allow call frame debug info optimization when linker relaxation is
+   not enabled as otherwise we could generate the DWARF directives without
+   the relocs necessary to patch them up.  */
+#define md_allow_eh_opt (linkrelax == 0)
 
 #define LOCAL_LABELS_FB 1
 #define WORKING_DOT_WORD 1
@@ -373,6 +418,9 @@ extern char *xtensa_section_rename (char *);
 #define MD_APPLY_SYM_VALUE(FIX) 0
 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
 
+/* Use line number format that is amenable to linker relaxation.  */
+#define DWARF2_USE_FIXED_ADVANCE_PC (linkrelax != 0)
+
 
 /* Resource reservation info functions.  */
 
@@ -418,7 +466,7 @@ typedef struct
   opcode_num_units_func opcode_num_units;
   opcode_funcUnit_use_unit_func opcode_unit_use;
   opcode_funcUnit_use_stage_func opcode_unit_stage;
-  char **units;
+  unsigned char **units;
 } resource_table;
 
 resource_table *new_resource_table
This page took 0.030416 seconds and 4 git commands to generate.