(root)/
binutils-2.41/
gas/
config/
tc-loongarch.h
       1  /* tc-loongarch.h -- Header file for tc-loongarch.c.
       2     Copyright (C) 2021-2023 Free Software Foundation, Inc.
       3     Contributed by Loongson Ltd.
       4  
       5     This file is part of GAS.
       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 of the license, or
      10     (at your option) 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 this program; see the file COPYING3.  If not,
      19     see <http://www.gnu.org/licenses/>.  */
      20  
      21  #ifndef TC_LOONGARCH
      22  #define TC_LOONGARCH
      23  
      24  #include "opcode/loongarch.h"
      25  
      26  #define TARGET_BYTES_BIG_ENDIAN 0
      27  #define TARGET_ARCH bfd_arch_loongarch
      28  
      29  #define TARGET_MACH (loongarch_mach ())
      30  extern unsigned long loongarch_mach (void);
      31  
      32  #define WORKING_DOT_WORD 1
      33  #define REPEAT_CONS_EXPRESSIONS
      34  
      35  /* Early than md_begin.  */
      36  #define md_after_parse_args loongarch_after_parse_args
      37  extern void loongarch_after_parse_args (void);
      38  
      39  extern void loongarch_pop_insert (void);
      40  #define md_pop_insert() loongarch_pop_insert ()
      41  
      42  #define TARGET_FORMAT loongarch_target_format ()
      43  extern const char *loongarch_target_format (void);
      44  
      45  #define md_relax_frag(segment, fragp, stretch)	\
      46    loongarch_relax_frag (segment, fragp, stretch)
      47  extern int loongarch_relax_frag (asection *, struct frag *, long);
      48  #define md_section_align(seg, size) (size)
      49  #define md_undefined_symbol(name) (0)
      50  #define md_operand(x)
      51  
      52  extern bool loongarch_frag_align_code (int);
      53  #define md_do_align(N, FILL, LEN, MAX, LABEL)				\
      54    if ((N) != 0 && !(FILL) && !need_pass_2 && subseg_text_p (now_seg))	\
      55      {									\
      56        if (loongarch_frag_align_code (N))				\
      57  	goto LABEL;							\
      58      }
      59  
      60  /* The following two macros let the linker resolve all the relocs
      61     due to relaxation.
      62  
      63     This is called to see whether a reloc against a defined symbol
      64     should be converted into a reloc against a section.
      65  
      66     If relax and norelax have different value may cause ld ".eh_frame_hdr
      67     refers to overlapping FDEs" error when link relax .o and norelax .o.  */
      68  #define tc_fix_adjustable(fixp) 0
      69  
      70  /* Tne difference between same-section symbols may be affected by linker
      71     relaxation, so do not resolve such expressions in the assembler.  */
      72  #define md_allow_local_subtract(l,r,s) 0
      73  
      74  /* Values passed to md_apply_fix don't include symbol values.  */
      75  #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) 1
      76  
      77  #define TC_VALIDATE_FIX_SUB(FIX, SEG) 1
      78  #define DIFF_EXPR_OK 1
      79  
      80  /* Postpone text-section label subtraction calculation until linking, since
      81     linker relaxations might change the deltas.  */
      82  #define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC)	\
      83    (LARCH_opts.relax ?  \
      84      (GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC)	\
      85        || ((SEC)->flags & SEC_CODE) != 0		\
      86        || ((SEC)->flags & SEC_DEBUGGING) != 0	\
      87        || TC_FORCE_RELOCATION (FIX)) \
      88      : (GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC))) \
      89  
      90  #define TC_LINKRELAX_FIXUP(seg) ((seg->flags & SEC_CODE)  \
      91  				    || (seg->flags & SEC_DEBUGGING))
      92  
      93  #define TC_FORCE_RELOCATION_LOCAL(FIX) 1
      94  
      95  /* Adjust debug_line after relaxation.  */
      96  #define DWARF2_USE_FIXED_ADVANCE_PC 1
      97  
      98  /* Values passed to md_apply_fix don't include symbol values.  */
      99  #define MD_APPLY_SYM_VALUE(FIX) 0
     100  
     101  #define TARGET_USE_CFIPOP 1
     102  #define DWARF2_DEFAULT_RETURN_COLUMN 1 /* $ra.  */
     103  #define DWARF2_CIE_DATA_ALIGNMENT -4
     104  
     105  #define tc_cfi_frame_initial_instructions	\
     106    loongarch_cfi_frame_initial_instructions
     107  extern void loongarch_cfi_frame_initial_instructions (void);
     108  
     109  #define tc_symbol_new_hook(sym) \
     110    if (0 == strcmp (sym->bsym->name, FAKE_LABEL_NAME)) \
     111      S_SET_OTHER (sym, STV_HIDDEN);
     112  
     113  #define tc_parse_to_dw2regnum tc_loongarch_parse_to_dw2regnum
     114  extern void tc_loongarch_parse_to_dw2regnum (expressionS *);
     115  
     116  extern void loongarch_pre_output_hook (void);
     117  #define md_pre_output_hook loongarch_pre_output_hook ()
     118  
     119  #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
     120  
     121  #define HANDLE_ALIGN(fragp) loongarch_handle_align (fragp)
     122  extern void loongarch_handle_align (struct frag *);
     123  #define MAX_MEM_FOR_RS_ALIGN_CODE (3 + 4)
     124  
     125  #define elf_tc_final_processing loongarch_elf_final_processing
     126  extern void loongarch_elf_final_processing (void);
     127  
     128  #define MAX_RELOC_NUMBER_A_INSN 20
     129  
     130  struct reloc_info
     131  {
     132    bfd_reloc_code_real_type type;
     133    expressionS value;
     134  };
     135  
     136  #define md_finish loongarch_md_finish
     137  extern void loongarch_md_finish (void);
     138  
     139  #endif