1 /* Lattice Mico32 opcode support. -*- C -*-
2 Copyright 2008, 2009 Free Software Foundation, Inc.
3 Contributed by Jon Beniston <jon@beniston.com>
5 This file is part of the GNU Binutils.
7 This program 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.
12 This program 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.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
24 /* Allows reason codes to be output when assembler errors occur. */
25 #define CGEN_VERBOSE_ASSEMBLER_ERRORS
27 #define CGEN_DIS_HASH_SIZE 64
28 #define CGEN_DIS_HASH(buf,value) ((value >> 26) & 0x3f)
32 /* Handle signed/unsigned literal. */
35 parse_imm (CGEN_CPU_DESC cd,
38 unsigned long *valuep)
43 errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value);
46 unsigned long x = value & 0xFFFF0000;
47 if (x != 0 && x != 0xFFFF0000)
48 errmsg = _("immediate value out of range");
50 *valuep = (value & 0xFFFF);
58 parse_hi16 (CGEN_CPU_DESC cd,
61 unsigned long *valuep)
63 if (strncasecmp (*strp, "hi(", 3) == 0)
65 enum cgen_parse_operand_result result_type;
70 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_HI16,
71 &result_type, &value);
73 return _("missing `)'");
77 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
78 value = (value >> 16) & 0xffff;
84 return parse_imm (cd, strp, opindex, valuep);
90 parse_lo16 (CGEN_CPU_DESC cd,
93 unsigned long *valuep)
95 if (strncasecmp (*strp, "lo(", 3) == 0)
98 enum cgen_parse_operand_result result_type;
102 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LO16,
103 &result_type, &value);
105 return _("missing `)'");
108 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
114 return parse_imm (cd, strp, opindex, valuep);
120 parse_gp16 (CGEN_CPU_DESC cd,
125 if (strncasecmp (*strp, "gp(", 3) == 0)
128 enum cgen_parse_operand_result result_type;
132 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_GPREL16,
133 & result_type, & value);
135 return _("missing `)'");
138 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
144 return _("expecting gp relative address: gp(symbol)");
150 parse_got16 (CGEN_CPU_DESC cd,
155 if (strncasecmp (*strp, "got(", 4) == 0)
158 enum cgen_parse_operand_result result_type;
162 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LM32_16_GOT,
163 & result_type, & value);
165 return _("missing `)'");
168 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
174 return _("expecting got relative address: got(symbol)");
177 /* Handle gotoffhi16() */
180 parse_gotoff_hi16 (CGEN_CPU_DESC cd,
185 if (strncasecmp (*strp, "gotoffhi16(", 11) == 0)
188 enum cgen_parse_operand_result result_type;
192 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LM32_GOTOFF_HI16,
193 & result_type, & value);
195 return _("missing `)'");
198 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
204 return _("expecting got relative address: gotoffhi16(symbol)");
207 /* Handle gotofflo16() */
210 parse_gotoff_lo16 (CGEN_CPU_DESC cd,
215 if (strncasecmp (*strp, "gotofflo16(", 11) == 0)
218 enum cgen_parse_operand_result result_type;
222 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LM32_GOTOFF_LO16,
223 &result_type, &value);
225 return _("missing `)'");
228 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
234 return _("expecting got relative address: gotofflo16(symbol)");