1/* This file is tc-m68k.h
2   Copyright (C) 1987-2022 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#ifndef TC_M68K_H
22#define TC_M68K_H
23
24#define TC_M68K 1
25
26struct fix;
27
28#define TARGET_BYTES_BIG_ENDIAN 1
29
30#define TARGET_FORMAT "elf32-m68k"
31#define TARGET_ARCH bfd_arch_m68k
32
33#define tc_comment_chars m68k_comment_chars
34extern const char *m68k_comment_chars;
35
36#define LISTING_WORD_SIZE 2	/* A word is 2 bytes */
37#define LISTING_LHS_WIDTH 2	/* One word on the first line */
38#define LISTING_LHS_WIDTH_SECOND 2	/* One word on the second line */
39#define LISTING_LHS_CONT_LINES 4/* And 4 lines max */
40#define LISTING_HEADER "68K GAS "
41
42#ifndef REGISTER_PREFIX
43#define REGISTER_PREFIX '%'
44#endif
45
46#ifndef REGISTER_PREFIX_OPTIONAL
47#define REGISTER_PREFIX_OPTIONAL 0
48#endif
49
50extern void m68k_mri_mode_change (int);
51#define MRI_MODE_CHANGE(i) m68k_mri_mode_change (i)
52
53extern int m68k_conditional_pseudoop (const pseudo_typeS *);
54#define tc_conditional_pseudoop(pop) m68k_conditional_pseudoop (pop)
55
56extern void m68k_frob_label (symbolS *);
57#define tc_frob_label(sym) m68k_frob_label (sym)
58
59extern void m68k_flush_pending_output (void);
60#define md_flush_pending_output() m68k_flush_pending_output ()
61
62extern void m68k_frob_symbol (symbolS *);
63
64#define tc_frob_symbol(sym,punt)				\
65do								\
66  {								\
67    if (S_GET_SEGMENT (sym) == reg_section)			\
68      punt = 1;							\
69    m68k_frob_symbol (sym);					\
70  }								\
71while (0)
72
73#define NO_RELOC BFD_RELOC_NONE
74#define RELAX_RELOC_ABS8  BFD_RELOC_8
75#define RELAX_RELOC_ABS16 BFD_RELOC_16
76#define RELAX_RELOC_ABS32 BFD_RELOC_32
77#define RELAX_RELOC_PC8   BFD_RELOC_8_PCREL
78#define RELAX_RELOC_PC16  BFD_RELOC_16_PCREL
79#define RELAX_RELOC_PC32  BFD_RELOC_32_PCREL
80
81#define tc_fix_adjustable(X) tc_m68k_fix_adjustable(X)
82extern int tc_m68k_fix_adjustable (struct fix *);
83
84/* Target *-*-elf implies an embedded target.  No shared libs.
85   *-*-uclinux also requires special casing to prevent GAS from
86   generating unsupported R_68K_PC16 relocs.  */
87#define EXTERN_FORCE_RELOC \
88  ((strcmp (TARGET_OS, "elf") != 0) && (strcmp (TARGET_OS, "uclinux") != 0))
89
90/* Values passed to md_apply_fix don't include symbol values.  */
91#define MD_APPLY_SYM_VALUE(FIX) 0
92
93#define elf_tc_final_processing m68k_elf_final_processing
94extern void m68k_elf_final_processing (void);
95
96#define DIFF_EXPR_OK
97
98extern int m68k_parse_long_option (char *);
99#define md_parse_long_option m68k_parse_long_option
100
101#define md_operand(x)
102
103extern struct relax_type md_relax_table[];
104#define TC_GENERIC_RELAX_TABLE md_relax_table
105
106/* We can't do a byte jump to the next instruction, so in that case
107   force word mode by faking AIM.  */
108#define md_prepare_relax_scan(fragP, address, aim, this_state, this_type) \
109  do									  \
110    {								 	  \
111      if (aim == 0 && this_type->rlx_forward == 127)			  \
112        aim = 128;							  \
113    }									  \
114  while (0)
115
116#define DWARF2_LINE_MIN_INSN_LENGTH 2
117
118/* We want .cfi_* pseudo-ops for generating unwind info.  */
119#define TARGET_USE_CFIPOP 1
120
121#define DWARF2_DEFAULT_RETURN_COLUMN 24
122#define DWARF2_CIE_DATA_ALIGNMENT (-4)
123
124#define tc_regname_to_dw2regnum tc_m68k_regname_to_dw2regnum
125extern int tc_m68k_regname_to_dw2regnum (const char *regname);
126
127#define tc_cfi_frame_initial_instructions tc_m68k_frame_initial_instructions
128extern void tc_m68k_frame_initial_instructions (void);
129
130#ifdef TE_UCLINUX
131/* elf2flt does not honor PT_LOAD's from the executable.
132   .text and .eh_frame sections will not end up in the same segment and so
133   we cannot use PC-relative encoding for CFI.  */
134# define CFI_DIFF_EXPR_OK 0
135
136/* However, follow compiler's guidance when it specifies encoding for LSDA.  */
137# define CFI_DIFF_LSDA_OK 1
138#endif
139
140struct broken_word;
141#define TC_CHECK_ADJUSTED_BROKEN_DOT_WORD(new_offset, brokw) \
142  tc_m68k_check_adjusted_broken_word ((offsetT) (new_offset), (brokw))
143extern void tc_m68k_check_adjusted_broken_word (offsetT,
144						struct broken_word *);
145
146/* We want to warn if any text labels are misaligned.  In order to get
147   the right line number, we need to record the line number for each
148   label.  */
149struct m68k_tc_sy
150{
151  const char *file;
152  unsigned int line;
153  int text;
154};
155
156#define TC_SYMFIELD_TYPE struct m68k_tc_sy
157
158#endif /* TC_M68K_H */
159