1*2a6b7db3Sskrll /* tc-cr16.h -- Header file for tc-cr16.c, the CR16 GAS port.
2*2a6b7db3Sskrll    Copyright 2007 Free Software Foundation, Inc.
3*2a6b7db3Sskrll 
4*2a6b7db3Sskrll    Contributed by M R Swami Reddy <MR.Swami.Reddy@nsc.com>
5*2a6b7db3Sskrll 
6*2a6b7db3Sskrll    This file is part of GAS, the GNU Assembler.
7*2a6b7db3Sskrll 
8*2a6b7db3Sskrll    GAS is free software; you can redistribute it and/or modify
9*2a6b7db3Sskrll    it under the terms of the GNU General Public License as published by
10*2a6b7db3Sskrll    the Free Software Foundation; either version 3, or (at your option)
11*2a6b7db3Sskrll    any later version.
12*2a6b7db3Sskrll 
13*2a6b7db3Sskrll    GAS is distributed in the hope that it will be useful,
14*2a6b7db3Sskrll    but WITHOUT ANY WARRANTY; without even the implied warranty of
15*2a6b7db3Sskrll    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*2a6b7db3Sskrll    GNU General Public License for more details.
17*2a6b7db3Sskrll 
18*2a6b7db3Sskrll    You should have received a copy of the GNU General Public License
19*2a6b7db3Sskrll    along with GAS; see the file COPYING.  If not, write to the
20*2a6b7db3Sskrll    Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
21*2a6b7db3Sskrll    MA 02110-1301, USA.  */
22*2a6b7db3Sskrll 
23*2a6b7db3Sskrll #ifndef TC_CR16_H
24*2a6b7db3Sskrll #define TC_CR16_H
25*2a6b7db3Sskrll 
26*2a6b7db3Sskrll #define TC_CR16 1
27*2a6b7db3Sskrll 
28*2a6b7db3Sskrll #define TARGET_BYTES_BIG_ENDIAN 0
29*2a6b7db3Sskrll 
30*2a6b7db3Sskrll #define TARGET_FORMAT "elf32-cr16"
31*2a6b7db3Sskrll #define TARGET_ARCH   bfd_arch_cr16
32*2a6b7db3Sskrll 
33*2a6b7db3Sskrll #define WORKING_DOT_WORD
34*2a6b7db3Sskrll #define LOCAL_LABEL_PREFIX '.'
35*2a6b7db3Sskrll 
36*2a6b7db3Sskrll #define md_undefined_symbol(s)  0
37*2a6b7db3Sskrll #define md_number_to_chars      number_to_chars_littleendian
38*2a6b7db3Sskrll 
39*2a6b7db3Sskrll /* We do relaxing in the assembler as well as the linker.  */
40*2a6b7db3Sskrll extern const struct relax_type md_relax_table[];
41*2a6b7db3Sskrll #define TC_GENERIC_RELAX_TABLE md_relax_table
42*2a6b7db3Sskrll 
43*2a6b7db3Sskrll /* We do not want to adjust any relocations to make implementation of
44*2a6b7db3Sskrll    linker relaxations easier.  */
45*2a6b7db3Sskrll #define tc_fix_adjustable(fixP)  0
46*2a6b7db3Sskrll 
47*2a6b7db3Sskrll /* We need to force out some relocations when relaxing.  */
48*2a6b7db3Sskrll #define TC_FORCE_RELOCATION(FIXP) cr16_force_relocation (FIXP)
49*2a6b7db3Sskrll extern int cr16_force_relocation (struct fix *);
50*2a6b7db3Sskrll 
51*2a6b7db3Sskrll /* Fixup debug sections since we will never relax them.  */
52*2a6b7db3Sskrll #define TC_LINKRELAX_FIXUP(seg) (seg->flags & SEC_ALLOC)
53*2a6b7db3Sskrll 
54*2a6b7db3Sskrll /* CR16 instructions, with operands included, are a multiple
55*2a6b7db3Sskrll    of two bytes long.  */
56*2a6b7db3Sskrll #define DWARF2_LINE_MIN_INSN_LENGTH 2
57*2a6b7db3Sskrll 
58*2a6b7db3Sskrll extern void cr16_cons_fix_new (struct frag *, int, int, struct expressionS *);
59*2a6b7db3Sskrll /* This is called by emit_expr when creating a reloc for a cons.
60*2a6b7db3Sskrll    We could use the definition there, except that we want to handle
61*2a6b7db3Sskrll    the CR16 reloc type specially, rather than the BFD_RELOC type.  */
62*2a6b7db3Sskrll #define TC_CONS_FIX_NEW(FRAG, OFF, LEN, EXP) \
63*2a6b7db3Sskrll   cr16_cons_fix_new (FRAG, OFF, LEN, EXP)
64*2a6b7db3Sskrll 
65*2a6b7db3Sskrll /* Give an error if a frag containing code is not aligned to a 2-byte
66*2a6b7db3Sskrll    boundary.  */
67*2a6b7db3Sskrll #define md_frag_check(FRAGP) \
68*2a6b7db3Sskrll   if ((FRAGP)->has_code                                                \
69*2a6b7db3Sskrll       && (((FRAGP)->fr_address + (FRAGP)->insn_addr) & 1) != 0)        \
70*2a6b7db3Sskrll      as_bad_where ((FRAGP)->fr_file, (FRAGP)->fr_line,                 \
71*2a6b7db3Sskrll                   _("instruction address is not a multiple of 2"));
72*2a6b7db3Sskrll 
73*2a6b7db3Sskrll #endif /* TC_CR16_H */
74