1/* This file is tc-m68k.h
2   Copyright (C) 1987-2020 Free Software Foundation, Inc.
3
4   This file is part of GAS, the GNU Assembler.
5
6   GAS is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 3, or (at your option)
9   any later version.
10
11   GAS is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with GAS; see the file COPYING.  If not, write to the Free
18   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
19   02110-1301, USA.  */
20
21#define TC_M68K 1
22
23struct fix;
24
25#define TARGET_BYTES_BIG_ENDIAN 1
26
27#define TARGET_FORMAT "elf32-m68k"
28#define TARGET_ARCH bfd_arch_m68k
29
30#define tc_comment_chars m68k_comment_chars
31extern const char *m68k_comment_chars;
32
33#define LISTING_WORD_SIZE 2	/* A word is 2 bytes */
34#define LISTING_LHS_WIDTH 2	/* One word on the first line */
35#define LISTING_LHS_WIDTH_SECOND 2	/* One word on the second line */
36#define LISTING_LHS_CONT_LINES 4/* And 4 lines max */
37#define LISTING_HEADER "68K GAS "
38
39#ifndef REGISTER_PREFIX
40#define REGISTER_PREFIX '%'
41#endif
42
43#ifndef REGISTER_PREFIX_OPTIONAL
44#define REGISTER_PREFIX_OPTIONAL 0
45#endif
46
47extern void m68k_mri_mode_change (int);
48#define MRI_MODE_CHANGE(i) m68k_mri_mode_change (i)
49
50extern int m68k_conditional_pseudoop (const pseudo_typeS *);
51#define tc_conditional_pseudoop(pop) m68k_conditional_pseudoop (pop)
52
53extern void m68k_frob_label (symbolS *);
54#define tc_frob_label(sym) m68k_frob_label (sym)
55
56extern void m68k_flush_pending_output (void);
57#define md_flush_pending_output() m68k_flush_pending_output ()
58
59extern void m68k_frob_symbol (symbolS *);
60
61#define tc_frob_symbol(sym,punt)				\
62do								\
63  {								\
64    if (S_GET_SEGMENT (sym) == reg_section)			\
65      punt = 1;							\
66    m68k_frob_symbol (sym);					\
67  }								\
68while (0)
69
70#define NO_RELOC BFD_RELOC_NONE
71#define RELAX_RELOC_ABS8  BFD_RELOC_8
72#define RELAX_RELOC_ABS16 BFD_RELOC_16
73#define RELAX_RELOC_ABS32 BFD_RELOC_32
74#define RELAX_RELOC_PC8   BFD_RELOC_8_PCREL
75#define RELAX_RELOC_PC16  BFD_RELOC_16_PCREL
76#define RELAX_RELOC_PC32  BFD_RELOC_32_PCREL
77
78#define tc_fix_adjustable(X) tc_m68k_fix_adjustable(X)
79extern int tc_m68k_fix_adjustable (struct fix *);
80
81/* Target *-*-elf implies an embedded target.  No shared libs.
82   *-*-uclinux also requires special casing to prevent GAS from
83   generating unsupported R_68K_PC16 relocs.  */
84#define EXTERN_FORCE_RELOC \
85  ((strcmp (TARGET_OS, "elf") != 0) && (strcmp (TARGET_OS, "uclinux") != 0))
86
87/* Values passed to md_apply_fix don't include symbol values.  */
88#define MD_APPLY_SYM_VALUE(FIX) 0
89
90#define elf_tc_final_processing m68k_elf_final_processing
91extern void m68k_elf_final_processing (void);
92
93#define DIFF_EXPR_OK
94
95extern int m68k_parse_long_option (char *);
96#define md_parse_long_option m68k_parse_long_option
97
98#define md_operand(x)
99
100extern struct relax_type md_relax_table[];
101#define TC_GENERIC_RELAX_TABLE md_relax_table
102
103/* We can't do a byte jump to the next instruction, so in that case
104   force word mode by faking AIM.  */
105#define md_prepare_relax_scan(fragP, address, aim, this_state, this_type) \
106  do									  \
107    {								 	  \
108      if (aim == 0 && this_type->rlx_forward == 127)			  \
109        aim = 128;							  \
110    }									  \
111  while (0)
112
113#define DWARF2_LINE_MIN_INSN_LENGTH 2
114
115/* We want .cfi_* pseudo-ops for generating unwind info.  */
116#define TARGET_USE_CFIPOP 1
117
118#define DWARF2_DEFAULT_RETURN_COLUMN 24
119#define DWARF2_CIE_DATA_ALIGNMENT (-4)
120
121#define tc_regname_to_dw2regnum tc_m68k_regname_to_dw2regnum
122extern int tc_m68k_regname_to_dw2regnum (const char *regname);
123
124#define tc_cfi_frame_initial_instructions tc_m68k_frame_initial_instructions
125extern void tc_m68k_frame_initial_instructions (void);
126
127#ifdef TE_UCLINUX
128/* elf2flt does not honor PT_LOAD's from the executable.
129   .text and .eh_frame sections will not end up in the same segment and so
130   we cannot use PC-relative encoding for CFI.  */
131# define CFI_DIFF_EXPR_OK 0
132
133/* However, follow compiler's guidance when it specifies encoding for LSDA.  */
134# define CFI_DIFF_LSDA_OK 1
135#endif
136
137struct broken_word;
138#define TC_CHECK_ADJUSTED_BROKEN_DOT_WORD(new_offset, brokw) \
139  tc_m68k_check_adjusted_broken_word ((offsetT) (new_offset), (brokw))
140extern void tc_m68k_check_adjusted_broken_word (offsetT,
141						struct broken_word *);
142