xref: /netbsd/external/gpl3/gdb/dist/gas/config/tc-tic6x.h (revision 1424dfb3)
1*1424dfb3Schristos /* Definitions for TI C6X assembler.
2*1424dfb3Schristos    Copyright (C) 2010-2020 Free Software Foundation, Inc.
3*1424dfb3Schristos 
4*1424dfb3Schristos    This file is part of GAS, the GNU Assembler.
5*1424dfb3Schristos 
6*1424dfb3Schristos    GAS is free software; you can redistribute it and/or modify
7*1424dfb3Schristos    it under the terms of the GNU General Public License as published by
8*1424dfb3Schristos    the Free Software Foundation; either version 3, or (at your option)
9*1424dfb3Schristos    any later version.
10*1424dfb3Schristos 
11*1424dfb3Schristos    GAS is distributed in the hope that it will be useful,
12*1424dfb3Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*1424dfb3Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*1424dfb3Schristos    GNU General Public License for more details.
15*1424dfb3Schristos 
16*1424dfb3Schristos    You should have received a copy of the GNU General Public License
17*1424dfb3Schristos    along with GAS; see the file COPYING.  If not, write to the Free
18*1424dfb3Schristos    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
19*1424dfb3Schristos    02110-1301, USA.  */
20*1424dfb3Schristos 
21*1424dfb3Schristos #define TC_TIC6X 1
22*1424dfb3Schristos #define TARGET_BYTES_BIG_ENDIAN 0
23*1424dfb3Schristos #define WORKING_DOT_WORD
24*1424dfb3Schristos #define DOUBLEBAR_PARALLEL
25*1424dfb3Schristos #define DWARF2_LINE_MIN_INSN_LENGTH 2
26*1424dfb3Schristos #define MD_APPLY_SYM_VALUE(FIX) 0
27*1424dfb3Schristos #define TC_PREDICATE_START_CHAR '['
28*1424dfb3Schristos #define TC_PREDICATE_END_CHAR ']'
29*1424dfb3Schristos /* For TI C6X, we keep spaces in what the preprocessor considers
30*1424dfb3Schristos    operands as they may separate functional unit specifiers from
31*1424dfb3Schristos    operands.  */
32*1424dfb3Schristos #define TC_KEEP_OPERAND_SPACES 1
33*1424dfb3Schristos 
34*1424dfb3Schristos #define TARGET_ARCH 	bfd_arch_tic6x
35*1424dfb3Schristos #define TARGET_FORMAT	(target_big_endian	\
36*1424dfb3Schristos 			 ? "elf32-tic6x-be"	\
37*1424dfb3Schristos 			 : "elf32-tic6x-le")
38*1424dfb3Schristos 
39*1424dfb3Schristos typedef struct tic6x_label_list
40*1424dfb3Schristos {
41*1424dfb3Schristos   struct tic6x_label_list *next;
42*1424dfb3Schristos   symbolS *label;
43*1424dfb3Schristos } tic6x_label_list;
44*1424dfb3Schristos 
45*1424dfb3Schristos /* Must be consistent with the enum in tc-tic6x.c.  */
46*1424dfb3Schristos #define TIC6X_NUM_UNWIND_REGS 13
47*1424dfb3Schristos 
48*1424dfb3Schristos /* Unwinding information state.  */
49*1424dfb3Schristos typedef struct tic6x_unwind_info {
50*1424dfb3Schristos     int personality_index;
51*1424dfb3Schristos     symbolS *personality_routine;
52*1424dfb3Schristos     symbolS *function_start;
53*1424dfb3Schristos     segT saved_seg;
54*1424dfb3Schristos     subsegT saved_subseg;
55*1424dfb3Schristos     /* NULL if table entry is inline.  */
56*1424dfb3Schristos     symbolS *table_entry;
57*1424dfb3Schristos     char *frag_start;
58*1424dfb3Schristos     valueT data;
59*1424dfb3Schristos     /* 0 before .cfi_startproc
60*1424dfb3Schristos       -1 between .cfi_startproc and .handlerdata
61*1424dfb3Schristos       >0 between .handlerdata and .endp */
62*1424dfb3Schristos     int data_bytes;
63*1424dfb3Schristos 
64*1424dfb3Schristos     offsetT reg_offset[TIC6X_NUM_UNWIND_REGS];
65*1424dfb3Schristos     bfd_boolean reg_saved[TIC6X_NUM_UNWIND_REGS];
66*1424dfb3Schristos     int cfa_reg;
67*1424dfb3Schristos     int return_reg;
68*1424dfb3Schristos     unsigned safe_mask;
69*1424dfb3Schristos     unsigned compact_mask;
70*1424dfb3Schristos     unsigned reg_saved_mask;
71*1424dfb3Schristos     offsetT cfa_offset;
72*1424dfb3Schristos     bfd_boolean pop_rts;
73*1424dfb3Schristos     /* Only valid for UNWIND_OP_POP_REG */
74*1424dfb3Schristos     int saved_reg_count;
75*1424dfb3Schristos } tic6x_unwind_info;
76*1424dfb3Schristos 
77*1424dfb3Schristos typedef struct
78*1424dfb3Schristos {
79*1424dfb3Schristos   /* Any labels seen since the last instruction or data.  If not NULL,
80*1424dfb3Schristos      a following instruction may not have parallel bars, but must
81*1424dfb3Schristos      start a new execute packet.  */
82*1424dfb3Schristos   tic6x_label_list *label_list;
83*1424dfb3Schristos 
84*1424dfb3Schristos   /* Whether compact instructions are forbidden here.  */
85*1424dfb3Schristos   bfd_boolean nocmp;
86*1424dfb3Schristos 
87*1424dfb3Schristos   /* If there is a current execute packet, the frag being used for
88*1424dfb3Schristos      that execute packet.  */
89*1424dfb3Schristos   fragS *execute_packet_frag;
90*1424dfb3Schristos 
91*1424dfb3Schristos   /* If there is a current execute packet, a pointer to the
92*1424dfb3Schristos      least-significant byte of the last instruction in it (for setting
93*1424dfb3Schristos      the p-bit).  */
94*1424dfb3Schristos   char *last_insn_lsb;
95*1424dfb3Schristos 
96*1424dfb3Schristos   /* If there has been an SPMASK instruction in the current execute
97*1424dfb3Schristos      packet, a pointer to the first byte in it (for processing
98*1424dfb3Schristos      ||^); otherwise NULL.  */
99*1424dfb3Schristos   char *spmask_addr;
100*1424dfb3Schristos 
101*1424dfb3Schristos   /* The functional units used in the current execute packet, recorded
102*1424dfb3Schristos      by setting the same bits as would be set in the 32-bit SPMASK
103*1424dfb3Schristos      instruction.  */
104*1424dfb3Schristos   unsigned int func_units_used;
105*1424dfb3Schristos 
106*1424dfb3Schristos   /* If an SPLOOP-family instruction has been seen, and a following
107*1424dfb3Schristos      SPKERNEL-family instruction has not yet been seen, the ii value
108*1424dfb3Schristos      from the SPLOOP instruction (in the range 1 to 14); otherwise
109*1424dfb3Schristos      0.  */
110*1424dfb3Schristos   int sploop_ii;
111*1424dfb3Schristos 
112*1424dfb3Schristos   /* Bit N indicates that an R_C6000_NONE relocation has been output for
113*1424dfb3Schristos      __c6xabi_unwind_cpp_prN already if set. This enables dependencies to be
114*1424dfb3Schristos      emitted only once per section, to save unnecessary bloat.  */
115*1424dfb3Schristos   unsigned int marked_pr_dependency;
116*1424dfb3Schristos 
117*1424dfb3Schristos   tic6x_unwind_info *unwind;
118*1424dfb3Schristos   tic6x_unwind_info *text_unwind;
119*1424dfb3Schristos } tic6x_segment_info_type;
120*1424dfb3Schristos #define TC_SEGMENT_INFO_TYPE tic6x_segment_info_type
121*1424dfb3Schristos 
122*1424dfb3Schristos typedef struct
123*1424dfb3Schristos {
124*1424dfb3Schristos   /* Whether this machine-dependent frag is used for instructions (as
125*1424dfb3Schristos      opposed to code alignment).  */
126*1424dfb3Schristos   bfd_boolean is_insns;
127*1424dfb3Schristos 
128*1424dfb3Schristos   /* For a frag used for instructions, whether it is may cross a fetch
129*1424dfb3Schristos      packet boundary (subject to alignment requirements).  */
130*1424dfb3Schristos   bfd_boolean can_cross_fp_boundary;
131*1424dfb3Schristos } tic6x_frag_info;
132*1424dfb3Schristos #define TC_FRAG_TYPE tic6x_frag_info
133*1424dfb3Schristos #define TC_FRAG_INIT(fragP, max_bytes) tic6x_frag_init (fragP)
134*1424dfb3Schristos extern void tic6x_frag_init (fragS *fragp);
135*1424dfb3Schristos 
136*1424dfb3Schristos typedef struct
137*1424dfb3Schristos {
138*1424dfb3Schristos   /* Whether this fix was for an ADDA instruction.  If so, a constant
139*1424dfb3Schristos      resulting from resolving the fix should be implicitly shifted
140*1424dfb3Schristos      left (it represents a value to be encoded literally in the
141*1424dfb3Schristos      instruction, whereas a non-constant represents a DP-relative
142*1424dfb3Schristos      value counting in the appropriate units).  */
143*1424dfb3Schristos   bfd_boolean fix_adda;
144*1424dfb3Schristos   /* The symbol to be subtracted in case of a PCR_H16 or PCR_L16
145*1424dfb3Schristos      reloc.  */
146*1424dfb3Schristos   symbolS *fix_subsy;
147*1424dfb3Schristos } tic6x_fix_info;
148*1424dfb3Schristos #define TC_FIX_TYPE tic6x_fix_info
149*1424dfb3Schristos #define TC_INIT_FIX_DATA(fixP) tic6x_init_fix_data (fixP)
150*1424dfb3Schristos struct fix;
151*1424dfb3Schristos extern void tic6x_init_fix_data (struct fix *fixP);
152*1424dfb3Schristos 
153*1424dfb3Schristos #define md_after_parse_args() tic6x_after_parse_args ()
154*1424dfb3Schristos extern void tic6x_after_parse_args (void);
155*1424dfb3Schristos 
156*1424dfb3Schristos #define md_cleanup() tic6x_cleanup ()
157*1424dfb3Schristos extern void tic6x_cleanup (void);
158*1424dfb3Schristos 
159*1424dfb3Schristos #define md_cons_align(n) tic6x_cons_align (n)
160*1424dfb3Schristos extern void tic6x_cons_align (int n);
161*1424dfb3Schristos 
162*1424dfb3Schristos #define md_do_align(n, fill, len, max, label)	\
163*1424dfb3Schristos   do {						\
164*1424dfb3Schristos     if (tic6x_do_align (n, fill, len, max))	\
165*1424dfb3Schristos       goto label;				\
166*1424dfb3Schristos   } while (0)
167*1424dfb3Schristos extern bfd_boolean tic6x_do_align (int n, char *fill, int len, int max);
168*1424dfb3Schristos 
169*1424dfb3Schristos #define CONVERT_SYMBOLIC_ATTRIBUTE(name)	\
170*1424dfb3Schristos   tic6x_convert_symbolic_attribute (name)
171*1424dfb3Schristos extern int tic6x_convert_symbolic_attribute (const char *);
172*1424dfb3Schristos 
173*1424dfb3Schristos #define md_end() tic6x_end ();
174*1424dfb3Schristos extern void tic6x_end (void);
175*1424dfb3Schristos 
176*1424dfb3Schristos #define md_parse_name(name, exprP, mode, nextcharP)	\
177*1424dfb3Schristos   tic6x_parse_name (name, exprP, mode, nextcharP)
178*1424dfb3Schristos extern int tic6x_parse_name (const char *name, expressionS *exprP,
179*1424dfb3Schristos 			     enum expr_mode mode, char *nextchar);
180*1424dfb3Schristos 
181*1424dfb3Schristos #define MD_PCREL_FROM_SECTION(FIX, SEC) tic6x_pcrel_from_section (FIX, SEC)
182*1424dfb3Schristos extern long tic6x_pcrel_from_section (struct fix *fixp, segT sec);
183*1424dfb3Schristos 
184*1424dfb3Schristos #define md_start_line_hook() tic6x_start_line_hook ()
185*1424dfb3Schristos extern void tic6x_start_line_hook (void);
186*1424dfb3Schristos 
187*1424dfb3Schristos #define TC_CONS_FIX_NEW(frag, where, size, exp, reloc)	\
188*1424dfb3Schristos   tic6x_cons_fix_new (frag, where, size, exp, reloc)
189*1424dfb3Schristos extern void tic6x_cons_fix_new (fragS *, int, int, expressionS *,
190*1424dfb3Schristos 				bfd_reloc_code_real_type);
191*1424dfb3Schristos 
192*1424dfb3Schristos #define tc_fix_adjustable(FIX) tic6x_fix_adjustable (FIX)
193*1424dfb3Schristos extern bfd_boolean tic6x_fix_adjustable (struct fix *);
194*1424dfb3Schristos 
195*1424dfb3Schristos #define tc_frob_label(sym) tic6x_frob_label (sym)
196*1424dfb3Schristos extern void tic6x_frob_label (symbolS *sym);
197*1424dfb3Schristos 
198*1424dfb3Schristos #define tc_init_after_args() tic6x_init_after_args ()
199*1424dfb3Schristos extern void tic6x_init_after_args (void);
200*1424dfb3Schristos 
201*1424dfb3Schristos #define tc_unrecognized_line(c) tic6x_unrecognized_line (c)
202*1424dfb3Schristos extern int tic6x_unrecognized_line (int c);
203*1424dfb3Schristos 
204*1424dfb3Schristos /* We want .cfi_* pseudo-ops for generating unwind info.  */
205*1424dfb3Schristos #define TARGET_USE_CFIPOP              1
206*1424dfb3Schristos 
207*1424dfb3Schristos /* CFI hooks.  */
208*1424dfb3Schristos #define tc_regname_to_dw2regnum            tic6x_regname_to_dw2regnum
209*1424dfb3Schristos int tic6x_regname_to_dw2regnum (char *regname);
210*1424dfb3Schristos 
211*1424dfb3Schristos #define tc_cfi_frame_initial_instructions  tic6x_frame_initial_instructions
212*1424dfb3Schristos void tic6x_frame_initial_instructions (void);
213*1424dfb3Schristos 
214*1424dfb3Schristos /* The return register is B3.  */
215*1424dfb3Schristos #define DWARF2_DEFAULT_RETURN_COLUMN  (16 + 3)
216*1424dfb3Schristos 
217*1424dfb3Schristos /* Registers are generally saved at negative offsets to the CFA.  */
218*1424dfb3Schristos #define DWARF2_CIE_DATA_ALIGNMENT     (-4)
219*1424dfb3Schristos 
220*1424dfb3Schristos #define tc_cfi_startproc tic6x_cfi_startproc
221*1424dfb3Schristos void tic6x_cfi_startproc (void);
222*1424dfb3Schristos 
223*1424dfb3Schristos #define tc_cfi_endproc tic6x_cfi_endproc
224*1424dfb3Schristos struct fde_entry;
225*1424dfb3Schristos void tic6x_cfi_endproc (struct fde_entry *fde);
226*1424dfb3Schristos 
227*1424dfb3Schristos #define tc_cfi_section_name ".c6xabi.exidx"
228