1  /* This file is tc-alpha.h
       2     Copyright (C) 1994-2023 Free Software Foundation, Inc.
       3     Written by Ken Raeburn <raeburn@cygnus.com>.
       4  
       5     This file is part of GAS, the GNU Assembler.
       6  
       7     GAS 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 3, or (at your option)
      10     any later version.
      11  
      12     GAS 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 GAS; see the file COPYING.  If not, write to the Free
      19     Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
      20     02110-1301, USA.  */
      21  
      22  #define TC_ALPHA
      23  
      24  #define TARGET_BYTES_BIG_ENDIAN 0
      25  
      26  #define WORKING_DOT_WORD
      27  
      28  #define TARGET_ARCH			bfd_arch_alpha
      29  
      30  #ifdef TE_FreeBSD
      31  #define ELF_TARGET_FORMAT	"elf64-alpha-freebsd"
      32  #endif
      33  #ifndef ELF_TARGET_FORMAT
      34  #define ELF_TARGET_FORMAT	"elf64-alpha"
      35  #endif
      36  
      37  #define TARGET_FORMAT (OUTPUT_FLAVOR == bfd_target_ecoff_flavour	\
      38  		       ? "ecoff-littlealpha"				\
      39  		       : OUTPUT_FLAVOR == bfd_target_elf_flavour	\
      40  		       ? ELF_TARGET_FORMAT				\
      41  		       : OUTPUT_FLAVOR == bfd_target_evax_flavour	\
      42  		       ? "vms-alpha"					\
      43  		       : "unknown-format")
      44  
      45  #define NEED_LITERAL_POOL
      46  #define REPEAT_CONS_EXPRESSIONS
      47  
      48  struct fix;
      49  struct alpha_reloc_tag;
      50  
      51  extern int alpha_force_relocation (struct fix *);
      52  extern int alpha_fix_adjustable   (struct fix *);
      53  
      54  extern unsigned long alpha_gprmask, alpha_fprmask;
      55  extern valueT alpha_gp_value;
      56  
      57  #define TC_FORCE_RELOCATION(FIX)	alpha_force_relocation (FIX)
      58  #define tc_fix_adjustable(FIX)		alpha_fix_adjustable (FIX)
      59  #define RELOC_REQUIRES_SYMBOL
      60  
      61  /* Values passed to md_apply_fix don't include the symbol value.  */
      62  #define MD_APPLY_SYM_VALUE(FIX) 0
      63  
      64  #define md_convert_frag(b,s,f)		as_fatal ("alpha convert_frag\n")
      65  #define md_estimate_size_before_relax(f,s) \
      66  			(as_fatal ("estimate_size_before_relax called"),1)
      67  #define md_operand(x)
      68  
      69  #ifdef OBJ_EVAX
      70  #define TC_VALIDATE_FIX_SUB(FIX, SEG) 1
      71  
      72  #define tc_canonicalize_symbol_name evax_shorten_name
      73  
      74  #define TC_CONS_FIX_NEW(FRAG,OFF,LEN,EXP,RELOC)	\
      75        (void) RELOC,				\
      76        fix_new_exp (FRAG, OFF, (int)LEN, EXP, 0, \
      77  	LEN == 2 ? BFD_RELOC_16 \
      78  	: LEN == 4 ? BFD_RELOC_32 \
      79  	: LEN == 8 ? BFD_RELOC_64 \
      80  	: BFD_RELOC_ALPHA_LINKAGE);
      81  #endif
      82  
      83  #ifdef OBJ_EVAX
      84  #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) (P2VAR) = 3
      85  #else
      86  #define TC_IMPLICIT_LCOMM_ALIGNMENT(size, align) \
      87    do							\
      88      {							\
      89        align = 0;					\
      90        if (size > 1)					\
      91  	{						\
      92  	  addressT temp = 1;				\
      93  	  while ((size & temp) == 0)			\
      94  	    ++align, temp <<= 1;			\
      95  	}						\
      96      }							\
      97    while (0)
      98  #endif
      99  
     100  #define md_number_to_chars		number_to_chars_littleendian
     101  
     102  extern int tc_get_register (int);
     103  extern void alpha_frob_ecoff_data (void);
     104  
     105  #define tc_frob_label(sym) alpha_define_label (sym)
     106  extern void alpha_define_label (symbolS *);
     107  
     108  #define md_cons_align(nbytes) alpha_cons_align (nbytes)
     109  extern void alpha_cons_align (int);
     110  
     111  #define HANDLE_ALIGN(fragp) alpha_handle_align (fragp)
     112  extern void alpha_handle_align (struct frag *);
     113  
     114  #define MAX_MEM_FOR_RS_ALIGN_CODE  (3 + 4 + 8)
     115  
     116  #ifdef OBJ_ECOFF
     117  #define tc_frob_file_before_adjust() alpha_frob_file_before_adjust ()
     118  extern void alpha_frob_file_before_adjust (void);
     119  
     120  #define TC_VALIDATE_FIX_SUB(FIX, SEG) \
     121    ((md_register_arithmetic || (SEG) != reg_section)	\
     122     && ((FIX)->fx_r_type == BFD_RELOC_GPREL32		\
     123         || (FIX)->fx_r_type == BFD_RELOC_GPREL16))
     124  #endif
     125  
     126  #define DIFF_EXPR_OK   /* foo-. gets turned into PC relative relocs.  */
     127  
     128  #ifdef OBJ_ELF
     129  #define md_elf_section_letter		alpha_elf_section_letter
     130  extern bfd_vma alpha_elf_section_letter (int, const char **);
     131  #define md_elf_section_flags		alpha_elf_section_flags
     132  extern flagword alpha_elf_section_flags (flagword, bfd_vma, int);
     133  #endif
     134  
     135  /* Whether to add support for explicit !relocation_op!sequence_number.  At the
     136     moment, only do this for ELF, though ECOFF could use it as well.  */
     137  
     138  #ifdef OBJ_ELF
     139  #define RELOC_OP_P
     140  #endif
     141  
     142  #ifndef OBJ_EVAX
     143  /* Before the relocations are written, reorder them, so that user
     144     supplied !lituse relocations follow the appropriate !literal
     145     relocations.  Also convert the gas-internal relocations to the
     146     appropriate linker relocations.  */
     147  #define tc_frob_file_before_fix() alpha_before_fix ()
     148  extern void alpha_before_fix (void);
     149  #endif
     150  
     151  #ifdef OBJ_ELF
     152  #define md_finish  alpha_elf_md_finish
     153  extern void alpha_elf_md_finish (void);
     154  #endif
     155  
     156  /* New fields for supporting explicit relocations (such as !literal to mark
     157     where a pointer is loaded from the global table, and !lituse_base to track
     158     all of the normal uses of that pointer).  */
     159  
     160  #define TC_FIX_TYPE struct alpha_fix_tag
     161  
     162  struct alpha_fix_tag
     163  {
     164    struct fix *next_reloc;		/* Next !lituse or !gpdisp.  */
     165    struct alpha_reloc_tag *info;		/* Other members with same sequence.  */
     166  };
     167  
     168  /* Initialize the TC_FIX_TYPE field.  */
     169  #define TC_INIT_FIX_DATA(FIX)						\
     170  do {									\
     171    FIX->tc_fix_data.next_reloc = NULL;					\
     172    FIX->tc_fix_data.info = NULL;						\
     173  } while (0)
     174  
     175  /* Work with DEBUG5 to print fields in tc_fix_type.  */
     176  #define TC_FIX_DATA_PRINT(STREAM, FIX)					\
     177  do {									\
     178    if (FIX->tc_fix_data.info)						\
     179      fprintf (STREAM, "\tinfo = 0x%lx, next_reloc = 0x%lx\n", \
     180  	     (long) FIX->tc_fix_data.info,				\
     181  	     (long) FIX->tc_fix_data.next_reloc);			\
     182  } while (0)
     183  
     184  #define TARGET_USE_CFIPOP 1
     185  
     186  #define tc_cfi_frame_initial_instructions alpha_cfi_frame_initial_instructions
     187  extern void alpha_cfi_frame_initial_instructions (void);
     188  
     189  #define DWARF2_LINE_MIN_INSN_LENGTH	4
     190  #define DWARF2_DEFAULT_RETURN_COLUMN	26
     191  #define DWARF2_CIE_DATA_ALIGNMENT	(-8)