Commit | Line | Data |
---|---|---|
aa137e4d | 1 | /* tc-tilepro.c -- Assemble for a TILEPro chip. |
82704155 | 2 | Copyright (C) 2011-2019 Free Software Foundation, Inc. |
aa137e4d NC |
3 | |
4 | This file is part of GAS, the GNU Assembler. | |
5 | ||
6 | This program 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 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program 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 this program; if not, write to the Free Software | |
18 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
19 | MA 02110-1301, USA. */ | |
20 | ||
21 | #include "as.h" | |
aa137e4d NC |
22 | #include "subsegs.h" |
23 | ||
24 | #include "elf/tilepro.h" | |
25 | #include "opcode/tilepro.h" | |
26 | ||
27 | #include "dwarf2dbg.h" | |
28 | #include "dw2gencfi.h" | |
29 | ||
30 | #include "safe-ctype.h" | |
31 | ||
32 | ||
33 | /* Special registers. */ | |
34 | #define TREG_IDN0 57 | |
35 | #define TREG_IDN1 58 | |
36 | #define TREG_UDN0 59 | |
37 | #define TREG_UDN1 60 | |
38 | #define TREG_UDN2 61 | |
39 | #define TREG_UDN3 62 | |
40 | #define TREG_ZERO 63 | |
41 | ||
42 | ||
43 | /* Generic assembler global variables which must be defined by all | |
44 | targets. */ | |
45 | ||
46 | /* Characters which always start a comment. */ | |
47 | const char comment_chars[] = "#"; | |
48 | ||
49 | /* Characters which start a comment at the beginning of a line. */ | |
50 | const char line_comment_chars[] = "#"; | |
51 | ||
52 | /* Characters which may be used to separate multiple commands on a | |
53 | single line. */ | |
54 | const char line_separator_chars[] = ";"; | |
55 | ||
56 | /* Characters which are used to indicate an exponent in a floating | |
57 | point number. */ | |
58 | const char EXP_CHARS[] = "eE"; | |
59 | ||
60 | /* Characters which mean that a number is a floating point constant, | |
61 | as in 0d1.0. */ | |
62 | const char FLT_CHARS[] = "rRsSfFdDxXpP"; | |
63 | ||
64 | const char *md_shortopts = "VQ:"; | |
65 | ||
66 | struct option md_longopts[] = | |
67 | { | |
68 | {NULL, no_argument, NULL, 0} | |
69 | }; | |
70 | ||
71 | size_t md_longopts_size = sizeof (md_longopts); | |
72 | ||
73 | int | |
17b9d67d | 74 | md_parse_option (int c, const char *arg ATTRIBUTE_UNUSED) |
aa137e4d NC |
75 | { |
76 | switch (c) | |
77 | { | |
78 | /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section | |
79 | should be emitted or not. FIXME: Not implemented. */ | |
80 | case 'Q': | |
81 | break; | |
82 | ||
83 | /* -V: SVR4 argument to print version ID. */ | |
84 | case 'V': | |
85 | print_version_id (); | |
86 | break; | |
87 | ||
88 | default: | |
89 | return 0; | |
90 | } | |
91 | ||
92 | return 1; | |
93 | } | |
94 | ||
95 | void | |
96 | md_show_usage (FILE *stream) | |
97 | { | |
98 | fprintf (stream, _("\ | |
99 | -Q ignored\n\ | |
100 | -V print assembler version number\n")); | |
101 | } | |
102 | ||
103 | /* Extra expression types. */ | |
104 | ||
6f7be959 WL |
105 | #define O_lo16 O_md1 |
106 | #define O_hi16 O_md2 | |
107 | #define O_ha16 O_md3 | |
108 | #define O_got O_md4 | |
aa137e4d NC |
109 | #define O_got_lo16 O_md5 |
110 | #define O_got_hi16 O_md6 | |
111 | #define O_got_ha16 O_md7 | |
6f7be959 | 112 | #define O_plt O_md8 |
aa137e4d NC |
113 | #define O_tls_gd O_md9 |
114 | #define O_tls_gd_lo16 O_md10 | |
115 | #define O_tls_gd_hi16 O_md11 | |
116 | #define O_tls_gd_ha16 O_md12 | |
117 | #define O_tls_ie O_md13 | |
118 | #define O_tls_ie_lo16 O_md14 | |
119 | #define O_tls_ie_hi16 O_md15 | |
120 | #define O_tls_ie_ha16 O_md16 | |
6f7be959 WL |
121 | #define O_tls_le O_md17 |
122 | #define O_tls_le_lo16 O_md18 | |
123 | #define O_tls_le_hi16 O_md19 | |
124 | #define O_tls_le_ha16 O_md20 | |
125 | #define O_tls_gd_call O_md21 | |
126 | #define O_tls_gd_add O_md22 | |
127 | #define O_tls_ie_load O_md23 | |
aa137e4d NC |
128 | |
129 | static struct hash_control *special_operator_hash; | |
130 | ||
131 | /* Hash tables for instruction mnemonic lookup. */ | |
132 | static struct hash_control *op_hash; | |
133 | ||
134 | /* Hash table for spr lookup. */ | |
135 | static struct hash_control *spr_hash; | |
136 | ||
137 | /* True temporarily while parsing an SPR expression. This changes the | |
138 | * namespace to include SPR names. */ | |
139 | static int parsing_spr; | |
140 | ||
141 | /* Are we currently inside `{ ... }'? */ | |
142 | static int inside_bundle; | |
143 | ||
144 | struct tilepro_instruction | |
145 | { | |
146 | const struct tilepro_opcode *opcode; | |
147 | tilepro_pipeline pipe; | |
148 | expressionS operand_values[TILEPRO_MAX_OPERANDS]; | |
149 | }; | |
150 | ||
151 | /* This keeps track of the current bundle being built up. */ | |
152 | static struct tilepro_instruction | |
153 | current_bundle[TILEPRO_MAX_INSTRUCTIONS_PER_BUNDLE]; | |
154 | ||
155 | /* Index in current_bundle for the next instruction to parse. */ | |
156 | static int current_bundle_index; | |
157 | ||
158 | /* Allow 'r63' in addition to 'zero', etc. Normally we disallow this as | |
159 | 'zero' is not a real register, so using it accidentally would be a | |
160 | nasty bug. For other registers, such as 'sp', code using multiple names | |
161 | for the same physical register is excessively confusing. | |
162 | ||
163 | The '.require_canonical_reg_names' pseudo-op turns this error on, | |
164 | and the '.no_require_canonical_reg_names' pseudo-op turns this off. | |
165 | By default the error is on. */ | |
166 | static int require_canonical_reg_names; | |
167 | ||
168 | /* Allow bundles that do undefined or suspicious things like write | |
169 | two different values to the same register at the same time. | |
170 | ||
171 | The '.no_allow_suspicious_bundles' pseudo-op turns this error on, | |
172 | and the '.allow_suspicious_bundles' pseudo-op turns this off. */ | |
173 | static int allow_suspicious_bundles; | |
174 | ||
175 | ||
176 | /* A hash table of main processor registers, mapping each register name | |
177 | to its index. | |
178 | ||
179 | Furthermore, if the register number is greater than the number | |
180 | of registers for that processor, the user used an illegal alias | |
181 | for that register (e.g. r63 instead of zero), so we should generate | |
182 | a warning. The attempted register number can be found by clearing | |
183 | NONCANONICAL_REG_NAME_FLAG. */ | |
184 | static struct hash_control *main_reg_hash; | |
185 | ||
186 | ||
187 | /* We cannot unambiguously store a 0 in a hash table and look it up, | |
188 | so we OR in this flag to every canonical register. */ | |
189 | #define CANONICAL_REG_NAME_FLAG 0x1000 | |
190 | ||
191 | /* By default we disallow register aliases like r63, but we record | |
192 | them in the hash table in case the .no_require_canonical_reg_names | |
193 | directive is used. Noncanonical names have this value added to them. */ | |
194 | #define NONCANONICAL_REG_NAME_FLAG 0x2000 | |
195 | ||
196 | /* Discards flags for register hash table entries and returns the | |
197 | reg number. */ | |
198 | #define EXTRACT_REGNO(p) ((p) & 63) | |
199 | ||
200 | /* This function is called once, at assembler startup time. It should | |
201 | set up all the tables, etc., that the MD part of the assembler will | |
202 | need. */ | |
203 | void | |
204 | md_begin (void) | |
205 | { | |
206 | const struct tilepro_opcode *op; | |
207 | int i; | |
208 | ||
209 | /* Guarantee text section is aligned. */ | |
210 | bfd_set_section_alignment (stdoutput, text_section, | |
211 | TILEPRO_LOG2_BUNDLE_ALIGNMENT_IN_BYTES); | |
212 | ||
213 | require_canonical_reg_names = 1; | |
214 | allow_suspicious_bundles = 0; | |
215 | current_bundle_index = 0; | |
216 | inside_bundle = 0; | |
217 | ||
218 | /* Initialize special operator hash table. */ | |
219 | special_operator_hash = hash_new (); | |
220 | #define INSERT_SPECIAL_OP(name) \ | |
221 | hash_insert (special_operator_hash, #name, (void *)O_##name) | |
222 | ||
223 | INSERT_SPECIAL_OP(lo16); | |
224 | INSERT_SPECIAL_OP(hi16); | |
225 | INSERT_SPECIAL_OP(ha16); | |
226 | INSERT_SPECIAL_OP(got); | |
227 | INSERT_SPECIAL_OP(got_lo16); | |
228 | INSERT_SPECIAL_OP(got_hi16); | |
229 | INSERT_SPECIAL_OP(got_ha16); | |
230 | INSERT_SPECIAL_OP(plt); | |
231 | INSERT_SPECIAL_OP(tls_gd); | |
232 | INSERT_SPECIAL_OP(tls_gd_lo16); | |
233 | INSERT_SPECIAL_OP(tls_gd_hi16); | |
234 | INSERT_SPECIAL_OP(tls_gd_ha16); | |
235 | INSERT_SPECIAL_OP(tls_ie); | |
236 | INSERT_SPECIAL_OP(tls_ie_lo16); | |
237 | INSERT_SPECIAL_OP(tls_ie_hi16); | |
238 | INSERT_SPECIAL_OP(tls_ie_ha16); | |
6f7be959 WL |
239 | INSERT_SPECIAL_OP(tls_le); |
240 | INSERT_SPECIAL_OP(tls_le_lo16); | |
241 | INSERT_SPECIAL_OP(tls_le_hi16); | |
242 | INSERT_SPECIAL_OP(tls_le_ha16); | |
243 | INSERT_SPECIAL_OP(tls_gd_call); | |
244 | INSERT_SPECIAL_OP(tls_gd_add); | |
245 | INSERT_SPECIAL_OP(tls_ie_load); | |
aa137e4d NC |
246 | #undef INSERT_SPECIAL_OP |
247 | ||
248 | /* Initialize op_hash hash table. */ | |
249 | op_hash = hash_new (); | |
250 | for (op = &tilepro_opcodes[0]; op->name != NULL; op++) | |
251 | { | |
252 | const char *hash_err = hash_insert (op_hash, op->name, (void *)op); | |
253 | if (hash_err != NULL) | |
254 | { | |
255 | as_fatal (_("Internal Error: Can't hash %s: %s"), | |
256 | op->name, hash_err); | |
257 | } | |
258 | } | |
259 | ||
260 | /* Initialize the spr hash table. */ | |
261 | parsing_spr = 0; | |
262 | spr_hash = hash_new (); | |
263 | for (i = 0; i < tilepro_num_sprs; i++) | |
264 | hash_insert (spr_hash, tilepro_sprs[i].name, | |
265 | (void *) &tilepro_sprs[i]); | |
266 | ||
267 | /* Set up the main_reg_hash table. We use this instead of | |
268 | * creating a symbol in the register section to avoid ambiguities | |
269 | * with labels that have the same names as registers. */ | |
270 | main_reg_hash = hash_new (); | |
271 | for (i = 0; i < TILEPRO_NUM_REGISTERS; i++) | |
272 | { | |
273 | char buf[64]; | |
274 | ||
275 | hash_insert (main_reg_hash, tilepro_register_names[i], | |
276 | (void *) (long)(i | CANONICAL_REG_NAME_FLAG)); | |
277 | ||
278 | /* See if we should insert a noncanonical alias, like r63. */ | |
279 | sprintf (buf, "r%d", i); | |
280 | if (strcmp (buf, tilepro_register_names[i]) != 0) | |
281 | hash_insert (main_reg_hash, xstrdup (buf), | |
282 | (void *) (long)(i | NONCANONICAL_REG_NAME_FLAG)); | |
283 | } | |
284 | ||
285 | /* Insert obsolete backwards-compatibility register names. */ | |
286 | hash_insert (main_reg_hash, "io0", | |
287 | (void *) (long) (TREG_IDN0 | CANONICAL_REG_NAME_FLAG)); | |
288 | hash_insert (main_reg_hash, "io1", | |
289 | (void *) (long) (TREG_IDN1 | CANONICAL_REG_NAME_FLAG)); | |
290 | hash_insert (main_reg_hash, "us0", | |
291 | (void *) (long) (TREG_UDN0 | CANONICAL_REG_NAME_FLAG)); | |
292 | hash_insert (main_reg_hash, "us1", | |
293 | (void *) (long) (TREG_UDN1 | CANONICAL_REG_NAME_FLAG)); | |
294 | hash_insert (main_reg_hash, "us2", | |
295 | (void *) (long) (TREG_UDN2 | CANONICAL_REG_NAME_FLAG)); | |
296 | hash_insert (main_reg_hash, "us3", | |
297 | (void *) (long) (TREG_UDN3 | CANONICAL_REG_NAME_FLAG)); | |
298 | ||
299 | } | |
300 | ||
301 | ||
302 | #define BUNDLE_TEMPLATE_MASK(p0, p1, p2) \ | |
303 | ((p0) | ((p1) << 8) | ((p2) << 16)) | |
304 | #define BUNDLE_TEMPLATE(p0, p1, p2) \ | |
305 | { { (p0), (p1), (p2) }, \ | |
306 | BUNDLE_TEMPLATE_MASK(1 << (p0), 1 << (p1), (1 << (p2))) \ | |
307 | } | |
308 | ||
309 | #define NO_PIPELINE TILEPRO_NUM_PIPELINE_ENCODINGS | |
310 | ||
311 | struct bundle_template | |
312 | { | |
313 | tilepro_pipeline pipe[TILEPRO_MAX_INSTRUCTIONS_PER_BUNDLE]; | |
314 | unsigned int pipe_mask; | |
315 | }; | |
316 | ||
317 | static const struct bundle_template bundle_templates[] = | |
318 | { | |
319 | /* In Y format we must always have something in Y2, since it has | |
320 | * no fnop, so this conveys that Y2 must always be used. */ | |
321 | BUNDLE_TEMPLATE(TILEPRO_PIPELINE_Y0, TILEPRO_PIPELINE_Y2, NO_PIPELINE), | |
322 | BUNDLE_TEMPLATE(TILEPRO_PIPELINE_Y1, TILEPRO_PIPELINE_Y2, NO_PIPELINE), | |
323 | BUNDLE_TEMPLATE(TILEPRO_PIPELINE_Y2, TILEPRO_PIPELINE_Y0, NO_PIPELINE), | |
324 | BUNDLE_TEMPLATE(TILEPRO_PIPELINE_Y2, TILEPRO_PIPELINE_Y1, NO_PIPELINE), | |
325 | ||
326 | /* Y format has three instructions. */ | |
327 | BUNDLE_TEMPLATE(TILEPRO_PIPELINE_Y0, TILEPRO_PIPELINE_Y1, TILEPRO_PIPELINE_Y2), | |
328 | BUNDLE_TEMPLATE(TILEPRO_PIPELINE_Y0, TILEPRO_PIPELINE_Y2, TILEPRO_PIPELINE_Y1), | |
329 | BUNDLE_TEMPLATE(TILEPRO_PIPELINE_Y1, TILEPRO_PIPELINE_Y0, TILEPRO_PIPELINE_Y2), | |
330 | BUNDLE_TEMPLATE(TILEPRO_PIPELINE_Y1, TILEPRO_PIPELINE_Y2, TILEPRO_PIPELINE_Y0), | |
331 | BUNDLE_TEMPLATE(TILEPRO_PIPELINE_Y2, TILEPRO_PIPELINE_Y0, TILEPRO_PIPELINE_Y1), | |
332 | BUNDLE_TEMPLATE(TILEPRO_PIPELINE_Y2, TILEPRO_PIPELINE_Y1, TILEPRO_PIPELINE_Y0), | |
333 | ||
334 | /* X format has only two instructions. */ | |
335 | BUNDLE_TEMPLATE(TILEPRO_PIPELINE_X0, TILEPRO_PIPELINE_X1, NO_PIPELINE), | |
336 | BUNDLE_TEMPLATE(TILEPRO_PIPELINE_X1, TILEPRO_PIPELINE_X0, NO_PIPELINE) | |
337 | }; | |
338 | ||
339 | ||
340 | static void | |
341 | prepend_nop_to_bundle (tilepro_mnemonic mnemonic) | |
342 | { | |
343 | memmove (¤t_bundle[1], ¤t_bundle[0], | |
344 | current_bundle_index * sizeof current_bundle[0]); | |
345 | current_bundle[0].opcode = &tilepro_opcodes[mnemonic]; | |
346 | ++current_bundle_index; | |
347 | } | |
348 | ||
349 | ||
350 | static tilepro_bundle_bits | |
351 | insert_operand (tilepro_bundle_bits bits, | |
352 | const struct tilepro_operand *operand, | |
353 | int operand_value, | |
3b4dbbbf | 354 | const char *file, |
aa137e4d NC |
355 | unsigned lineno) |
356 | { | |
357 | /* Range-check the immediate. */ | |
358 | int num_bits = operand->num_bits; | |
359 | ||
360 | operand_value >>= operand->rightshift; | |
361 | ||
362 | if (bfd_check_overflow (operand->is_signed | |
363 | ? complain_overflow_signed | |
364 | : complain_overflow_unsigned, | |
365 | num_bits, | |
366 | 0, | |
367 | bfd_arch_bits_per_address (stdoutput), | |
368 | operand_value) | |
369 | != bfd_reloc_ok) | |
370 | { | |
371 | offsetT min, max; | |
372 | if (operand->is_signed) | |
373 | { | |
374 | min = -(1 << (num_bits - 1)); | |
375 | max = (1 << (num_bits - 1)) - 1; | |
376 | } | |
377 | else | |
378 | { | |
379 | min = 0; | |
380 | max = (1 << num_bits) - 1; | |
381 | } | |
382 | as_bad_value_out_of_range (_("operand"), operand_value, min, max, | |
383 | file, lineno); | |
384 | } | |
385 | ||
386 | /* Write out the bits for the immediate. */ | |
387 | return bits | operand->insert (operand_value); | |
388 | } | |
389 | ||
390 | ||
391 | static int | |
392 | apply_special_operator (operatorT op, int num) | |
393 | { | |
394 | switch (op) | |
395 | { | |
396 | case O_lo16: | |
aa137e4d NC |
397 | return (signed short)num; |
398 | ||
399 | case O_hi16: | |
aa137e4d NC |
400 | return (signed short)(num >> 16); |
401 | ||
402 | case O_ha16: | |
aa137e4d NC |
403 | return (signed short)((num + 0x8000) >> 16); |
404 | ||
405 | default: | |
406 | abort (); | |
407 | } | |
408 | } | |
409 | ||
410 | ||
411 | static tilepro_bundle_bits | |
412 | emit_tilepro_instruction (tilepro_bundle_bits bits, | |
413 | int num_operands, | |
414 | const unsigned char *operands, | |
415 | expressionS *operand_values, | |
416 | char *bundle_start) | |
417 | { | |
418 | int i; | |
419 | ||
420 | for (i = 0; i < num_operands; i++) | |
421 | { | |
422 | const struct tilepro_operand *operand = | |
423 | &tilepro_operands[operands[i]]; | |
424 | expressionS *operand_exp = &operand_values[i]; | |
425 | int is_pc_relative = operand->is_pc_relative; | |
426 | ||
427 | if (operand_exp->X_op == O_register | |
428 | || (operand_exp->X_op == O_constant && !is_pc_relative)) | |
429 | { | |
430 | /* We know what the bits are right now, so insert them. */ | |
431 | bits = insert_operand (bits, operand, operand_exp->X_add_number, | |
432 | NULL, 0); | |
433 | } | |
434 | else | |
435 | { | |
436 | bfd_reloc_code_real_type reloc = operand->default_reloc; | |
437 | expressionS subexp; | |
438 | int die = 0, use_subexp = 0, require_symbol = 0; | |
439 | fixS *fixP; | |
440 | ||
441 | /* Take an expression like hi16(x) and turn it into x with | |
442 | a different reloc type. */ | |
443 | switch (operand_exp->X_op) | |
444 | { | |
445 | #define HANDLE_OP16(suffix) \ | |
446 | switch (reloc) \ | |
447 | { \ | |
448 | case BFD_RELOC_TILEPRO_IMM16_X0: \ | |
449 | reloc = BFD_RELOC_TILEPRO_IMM16_X0_##suffix; \ | |
450 | break; \ | |
451 | case BFD_RELOC_TILEPRO_IMM16_X1: \ | |
452 | reloc = BFD_RELOC_TILEPRO_IMM16_X1_##suffix; \ | |
453 | break; \ | |
454 | default: \ | |
455 | die = 1; \ | |
456 | break; \ | |
457 | } \ | |
458 | use_subexp = 1 | |
459 | ||
460 | case O_lo16: | |
461 | HANDLE_OP16 (LO); | |
462 | break; | |
463 | ||
464 | case O_hi16: | |
465 | HANDLE_OP16 (HI); | |
466 | break; | |
467 | ||
468 | case O_ha16: | |
469 | HANDLE_OP16 (HA); | |
470 | break; | |
471 | ||
472 | case O_got: | |
473 | HANDLE_OP16 (GOT); | |
474 | require_symbol = 1; | |
475 | break; | |
476 | ||
477 | case O_got_lo16: | |
478 | HANDLE_OP16 (GOT_LO); | |
479 | require_symbol = 1; | |
480 | break; | |
481 | ||
482 | case O_got_hi16: | |
483 | HANDLE_OP16 (GOT_HI); | |
484 | require_symbol = 1; | |
485 | break; | |
486 | ||
487 | case O_got_ha16: | |
488 | HANDLE_OP16 (GOT_HA); | |
489 | require_symbol = 1; | |
490 | break; | |
491 | ||
492 | case O_tls_gd: | |
493 | HANDLE_OP16 (TLS_GD); | |
494 | require_symbol = 1; | |
495 | break; | |
496 | ||
497 | case O_tls_gd_lo16: | |
498 | HANDLE_OP16 (TLS_GD_LO); | |
499 | require_symbol = 1; | |
500 | break; | |
501 | ||
502 | case O_tls_gd_hi16: | |
503 | HANDLE_OP16 (TLS_GD_HI); | |
504 | require_symbol = 1; | |
505 | break; | |
506 | ||
507 | case O_tls_gd_ha16: | |
508 | HANDLE_OP16 (TLS_GD_HA); | |
509 | require_symbol = 1; | |
510 | break; | |
511 | ||
512 | case O_tls_ie: | |
513 | HANDLE_OP16 (TLS_IE); | |
514 | require_symbol = 1; | |
515 | break; | |
516 | ||
517 | case O_tls_ie_lo16: | |
518 | HANDLE_OP16 (TLS_IE_LO); | |
519 | require_symbol = 1; | |
520 | break; | |
521 | ||
522 | case O_tls_ie_hi16: | |
523 | HANDLE_OP16 (TLS_IE_HI); | |
524 | require_symbol = 1; | |
525 | break; | |
526 | ||
527 | case O_tls_ie_ha16: | |
528 | HANDLE_OP16 (TLS_IE_HA); | |
529 | require_symbol = 1; | |
530 | break; | |
531 | ||
6f7be959 WL |
532 | case O_tls_le: |
533 | HANDLE_OP16 (TLS_LE); | |
534 | require_symbol = 1; | |
535 | break; | |
536 | ||
537 | case O_tls_le_lo16: | |
538 | HANDLE_OP16 (TLS_LE_LO); | |
539 | require_symbol = 1; | |
540 | break; | |
541 | ||
542 | case O_tls_le_hi16: | |
543 | HANDLE_OP16 (TLS_LE_HI); | |
544 | require_symbol = 1; | |
545 | break; | |
546 | ||
547 | case O_tls_le_ha16: | |
548 | HANDLE_OP16 (TLS_LE_HA); | |
549 | require_symbol = 1; | |
550 | break; | |
551 | ||
aa137e4d NC |
552 | #undef HANDLE_OP16 |
553 | ||
554 | case O_plt: | |
555 | switch (reloc) | |
556 | { | |
557 | case BFD_RELOC_TILEPRO_JOFFLONG_X1: | |
558 | reloc = BFD_RELOC_TILEPRO_JOFFLONG_X1_PLT; | |
559 | break; | |
560 | default: | |
561 | die = 1; | |
562 | break; | |
563 | } | |
564 | use_subexp = 1; | |
565 | require_symbol = 1; | |
566 | break; | |
567 | ||
6f7be959 WL |
568 | case O_tls_gd_call: |
569 | switch (reloc) | |
570 | { | |
571 | case BFD_RELOC_TILEPRO_JOFFLONG_X1: | |
572 | reloc = BFD_RELOC_TILEPRO_TLS_GD_CALL; | |
573 | break; | |
574 | default: | |
575 | die = 1; | |
576 | break; | |
577 | } | |
578 | use_subexp = 1; | |
579 | require_symbol = 1; | |
580 | break; | |
581 | ||
582 | case O_tls_gd_add: | |
583 | switch (reloc) | |
584 | { | |
585 | case BFD_RELOC_TILEPRO_IMM8_X0: | |
586 | reloc = BFD_RELOC_TILEPRO_IMM8_X0_TLS_GD_ADD; | |
587 | break; | |
588 | case BFD_RELOC_TILEPRO_IMM8_X1: | |
589 | reloc = BFD_RELOC_TILEPRO_IMM8_X1_TLS_GD_ADD; | |
590 | break; | |
591 | case BFD_RELOC_TILEPRO_IMM8_Y0: | |
592 | reloc = BFD_RELOC_TILEPRO_IMM8_Y0_TLS_GD_ADD; | |
593 | break; | |
594 | case BFD_RELOC_TILEPRO_IMM8_Y1: | |
595 | reloc = BFD_RELOC_TILEPRO_IMM8_Y1_TLS_GD_ADD; | |
596 | break; | |
597 | default: | |
598 | die = 1; | |
599 | break; | |
600 | } | |
601 | use_subexp = 1; | |
602 | require_symbol = 1; | |
603 | break; | |
604 | ||
605 | case O_tls_ie_load: | |
606 | switch (reloc) | |
607 | { | |
608 | case BFD_RELOC_TILEPRO_IMM8_X1: | |
609 | reloc = BFD_RELOC_TILEPRO_TLS_IE_LOAD; | |
610 | break; | |
611 | default: | |
612 | die = 1; | |
613 | break; | |
614 | } | |
615 | use_subexp = 1; | |
616 | require_symbol = 1; | |
617 | break; | |
618 | ||
aa137e4d NC |
619 | default: |
620 | /* Do nothing. */ | |
621 | break; | |
622 | } | |
623 | ||
624 | if (die) | |
625 | { | |
626 | as_bad (_("Invalid operator for operand.")); | |
627 | } | |
628 | else if (use_subexp) | |
629 | { | |
8d1015a8 | 630 | expressionS *sval = NULL; |
aa137e4d NC |
631 | /* Now that we've changed the reloc, change ha16(x) into x, |
632 | etc. */ | |
633 | ||
8d1015a8 AM |
634 | if (symbol_symbolS (operand_exp->X_add_symbol)) |
635 | sval = symbol_get_value_expression (operand_exp->X_add_symbol); | |
636 | if (sval && sval->X_md) | |
aa137e4d | 637 | { |
aa137e4d NC |
638 | /* HACK: We used X_md to mark this symbol as a fake wrapper |
639 | around a real expression. To unwrap it, we just grab its | |
640 | value here. */ | |
8d1015a8 | 641 | operand_exp = sval; |
e8b9f508 WL |
642 | |
643 | if (require_symbol) | |
644 | { | |
645 | /* Look at the expression, and reject it if it's not a | |
646 | plain symbol. */ | |
647 | if (operand_exp->X_op != O_symbol | |
648 | || operand_exp->X_add_number != 0) | |
649 | as_bad (_("Operator may only be applied to symbols.")); | |
650 | } | |
aa137e4d NC |
651 | } |
652 | else | |
653 | { | |
654 | /* The value of this expression is an actual symbol, so | |
655 | turn that into an expression. */ | |
656 | memset (&subexp, 0, sizeof subexp); | |
657 | subexp.X_op = O_symbol; | |
658 | subexp.X_add_symbol = operand_exp->X_add_symbol; | |
659 | operand_exp = &subexp; | |
660 | } | |
661 | } | |
662 | ||
663 | /* Create a fixup to handle this later. */ | |
664 | fixP = fix_new_exp (frag_now, | |
665 | bundle_start - frag_now->fr_literal, | |
666 | (operand->num_bits + 7) >> 3, | |
667 | operand_exp, | |
668 | is_pc_relative, | |
669 | reloc); | |
670 | fixP->tc_fix_data = operand; | |
671 | ||
672 | /* Don't do overflow checking if we are applying a function like | |
673 | ha16. */ | |
674 | fixP->fx_no_overflow |= use_subexp; | |
675 | } | |
676 | } | |
677 | return bits; | |
678 | } | |
679 | ||
680 | ||
681 | /* Detects and complains if two instructions in current_bundle write | |
682 | to the same register, either implicitly or explicitly, or if a | |
683 | read-only register is written. */ | |
684 | static void | |
685 | check_illegal_reg_writes (void) | |
686 | { | |
687 | BFD_HOST_U_64_BIT all_regs_written = 0; | |
688 | int j; | |
689 | ||
690 | for (j = 0; j < current_bundle_index; j++) | |
691 | { | |
692 | const struct tilepro_instruction *instr = ¤t_bundle[j]; | |
693 | int k; | |
694 | BFD_HOST_U_64_BIT regs = | |
695 | ((BFD_HOST_U_64_BIT)1) << instr->opcode->implicitly_written_register; | |
696 | BFD_HOST_U_64_BIT conflict; | |
697 | ||
698 | for (k = 0; k < instr->opcode->num_operands; k++) | |
699 | { | |
700 | const struct tilepro_operand *operand = | |
701 | &tilepro_operands[instr->opcode->operands[instr->pipe][k]]; | |
702 | ||
703 | if (operand->is_dest_reg) | |
704 | { | |
705 | int regno = instr->operand_values[k].X_add_number; | |
706 | BFD_HOST_U_64_BIT mask = ((BFD_HOST_U_64_BIT)1) << regno; | |
707 | ||
708 | if ((mask & ( (((BFD_HOST_U_64_BIT)1) << TREG_IDN1) | |
709 | | (((BFD_HOST_U_64_BIT)1) << TREG_UDN1) | |
710 | | (((BFD_HOST_U_64_BIT)1) << TREG_UDN2) | |
711 | | (((BFD_HOST_U_64_BIT)1) << TREG_UDN3))) != 0 | |
712 | && !allow_suspicious_bundles) | |
713 | { | |
714 | as_bad (_("Writes to register '%s' are not allowed."), | |
715 | tilepro_register_names[regno]); | |
716 | } | |
717 | ||
718 | regs |= mask; | |
719 | } | |
720 | } | |
721 | ||
722 | /* Writing to the zero register doesn't count. */ | |
723 | regs &= ~(((BFD_HOST_U_64_BIT)1) << TREG_ZERO); | |
724 | ||
725 | conflict = all_regs_written & regs; | |
726 | if (conflict != 0 && !allow_suspicious_bundles) | |
727 | { | |
728 | /* Find which register caused the conflict. */ | |
729 | const char *conflicting_reg_name = "???"; | |
730 | int i; | |
731 | ||
732 | for (i = 0; i < TILEPRO_NUM_REGISTERS; i++) | |
733 | { | |
734 | if (((conflict >> i) & 1) != 0) | |
735 | { | |
736 | conflicting_reg_name = tilepro_register_names[i]; | |
737 | break; | |
738 | } | |
739 | } | |
740 | ||
741 | as_bad (_("Two instructions in the same bundle both write " | |
742 | "to register %s, which is not allowed."), | |
743 | conflicting_reg_name); | |
744 | } | |
745 | ||
746 | all_regs_written |= regs; | |
747 | } | |
748 | } | |
749 | ||
750 | ||
751 | static void | |
752 | tilepro_flush_bundle (void) | |
753 | { | |
754 | unsigned i; | |
755 | int j, addr_mod; | |
756 | unsigned compatible_pipes; | |
757 | const struct bundle_template *match; | |
758 | char *f; | |
759 | ||
760 | inside_bundle = 0; | |
761 | ||
762 | switch (current_bundle_index) | |
763 | { | |
764 | case 0: | |
765 | /* No instructions. */ | |
766 | return; | |
767 | case 1: | |
768 | if (current_bundle[0].opcode->can_bundle) | |
769 | { | |
770 | /* Simplify later logic by adding an explicit fnop. */ | |
771 | prepend_nop_to_bundle (TILEPRO_OPC_FNOP); | |
772 | } | |
773 | else | |
774 | { | |
775 | /* This instruction cannot be bundled with anything else. | |
776 | Prepend an explicit 'nop', rather than an 'fnop', because | |
777 | fnops can be replaced by later binary-processing tools | |
778 | while nops cannot. */ | |
779 | prepend_nop_to_bundle (TILEPRO_OPC_NOP); | |
780 | } | |
781 | break; | |
782 | default: | |
783 | if (!allow_suspicious_bundles) | |
784 | { | |
785 | /* Make sure all instructions can be bundled with other | |
786 | instructions. */ | |
787 | const struct tilepro_opcode *cannot_bundle = NULL; | |
788 | bfd_boolean seen_non_nop = FALSE; | |
789 | ||
790 | for (j = 0; j < current_bundle_index; j++) | |
791 | { | |
792 | const struct tilepro_opcode *op = current_bundle[j].opcode; | |
793 | ||
794 | if (!op->can_bundle && cannot_bundle == NULL) | |
795 | cannot_bundle = op; | |
796 | else if (op->mnemonic != TILEPRO_OPC_NOP | |
797 | && op->mnemonic != TILEPRO_OPC_INFO | |
798 | && op->mnemonic != TILEPRO_OPC_INFOL) | |
799 | seen_non_nop = TRUE; | |
800 | } | |
801 | ||
802 | if (cannot_bundle != NULL && seen_non_nop) | |
803 | { | |
804 | current_bundle_index = 0; | |
805 | as_bad (_("'%s' may not be bundled with other instructions."), | |
806 | cannot_bundle->name); | |
807 | return; | |
808 | } | |
809 | } | |
810 | break; | |
811 | } | |
812 | ||
813 | compatible_pipes = | |
814 | BUNDLE_TEMPLATE_MASK(current_bundle[0].opcode->pipes, | |
815 | current_bundle[1].opcode->pipes, | |
816 | (current_bundle_index == 3 | |
817 | ? current_bundle[2].opcode->pipes | |
818 | : (1 << NO_PIPELINE))); | |
819 | ||
820 | /* Find a template that works, if any. */ | |
821 | match = NULL; | |
822 | for (i = 0; i < sizeof bundle_templates / sizeof bundle_templates[0]; i++) | |
823 | { | |
824 | const struct bundle_template *b = &bundle_templates[i]; | |
825 | if ((b->pipe_mask & compatible_pipes) == b->pipe_mask) | |
826 | { | |
827 | match = b; | |
828 | break; | |
829 | } | |
830 | } | |
831 | ||
832 | if (match == NULL) | |
833 | { | |
834 | current_bundle_index = 0; | |
835 | as_bad (_("Invalid combination of instructions for bundle.")); | |
836 | return; | |
837 | } | |
838 | ||
839 | /* If the section seems to have no alignment set yet, go ahead and | |
840 | make it large enough to hold code. */ | |
841 | if (bfd_get_section_alignment (stdoutput, now_seg) == 0) | |
842 | bfd_set_section_alignment (stdoutput, now_seg, | |
843 | TILEPRO_LOG2_BUNDLE_ALIGNMENT_IN_BYTES); | |
844 | ||
845 | for (j = 0; j < current_bundle_index; j++) | |
846 | current_bundle[j].pipe = match->pipe[j]; | |
847 | ||
848 | if (current_bundle_index == 2 && !tilepro_is_x_pipeline(match->pipe[0])) | |
849 | { | |
850 | /* We are in Y mode with only two instructions, so add an FNOP. */ | |
851 | prepend_nop_to_bundle (TILEPRO_OPC_FNOP); | |
852 | ||
853 | /* Figure out what pipe the fnop must be in via arithmetic. | |
854 | * p0 + p1 + p2 must sum to the sum of TILEPRO_PIPELINE_Y[012]. */ | |
855 | current_bundle[0].pipe = | |
856 | (tilepro_pipeline)((TILEPRO_PIPELINE_Y0 | |
857 | + TILEPRO_PIPELINE_Y1 | |
858 | + TILEPRO_PIPELINE_Y2) - | |
859 | (current_bundle[1].pipe + current_bundle[2].pipe)); | |
860 | } | |
861 | ||
862 | check_illegal_reg_writes (); | |
863 | ||
864 | f = frag_more (TILEPRO_BUNDLE_SIZE_IN_BYTES); | |
865 | ||
866 | /* Check to see if this bundle is at an offset that is a multiple of 8-bytes | |
867 | from the start of the frag. */ | |
868 | addr_mod = frag_now_fix () & (TILEPRO_BUNDLE_ALIGNMENT_IN_BYTES - 1); | |
869 | if (frag_now->has_code && frag_now->insn_addr != addr_mod) | |
870 | as_bad (_("instruction address is not a multiple of 8")); | |
871 | frag_now->insn_addr = addr_mod; | |
872 | frag_now->has_code = 1; | |
873 | ||
874 | tilepro_bundle_bits bits = 0; | |
875 | for (j = 0; j < current_bundle_index; j++) | |
876 | { | |
877 | struct tilepro_instruction *instr = ¤t_bundle[j]; | |
878 | tilepro_pipeline pipeline = instr->pipe; | |
879 | const struct tilepro_opcode *opcode = instr->opcode; | |
880 | ||
881 | bits |= emit_tilepro_instruction (opcode->fixed_bit_values[pipeline], | |
882 | opcode->num_operands, | |
883 | &opcode->operands[pipeline][0], | |
884 | instr->operand_values, | |
885 | f); | |
886 | } | |
887 | ||
888 | number_to_chars_littleendian (f, (unsigned int)bits, 4); | |
889 | number_to_chars_littleendian (f + 4, (unsigned int)(bits >> 32), 4); | |
890 | current_bundle_index = 0; | |
891 | ||
892 | /* Emit DWARF2 debugging information. */ | |
893 | dwarf2_emit_insn (TILEPRO_BUNDLE_SIZE_IN_BYTES); | |
894 | } | |
895 | ||
896 | ||
897 | /* Extend the expression parser to handle hi16(label), etc. | |
898 | as well as SPR names when in the context of parsing an SPR. */ | |
899 | int | |
900 | tilepro_parse_name (char *name, expressionS *e, char *nextcharP) | |
901 | { | |
902 | operatorT op = O_illegal; | |
903 | ||
904 | if (parsing_spr) | |
905 | { | |
906 | void *val = hash_find (spr_hash, name); | |
907 | if (val == NULL) | |
908 | return 0; | |
909 | ||
910 | memset (e, 0, sizeof *e); | |
911 | e->X_op = O_constant; | |
912 | e->X_add_number = ((const struct tilepro_spr *)val)->number; | |
913 | return 1; | |
914 | } | |
915 | ||
916 | if (*nextcharP != '(') | |
917 | { | |
918 | /* hi16, etc. not followed by a paren is just a label with that | |
919 | name. */ | |
920 | return 0; | |
921 | } | |
922 | else | |
923 | { | |
924 | /* Look up the operator in our table. */ | |
925 | void *val = hash_find (special_operator_hash, name); | |
926 | if (val == 0) | |
927 | return 0; | |
928 | op = (operatorT)(long)val; | |
929 | } | |
930 | ||
931 | /* Restore old '(' and skip it. */ | |
932 | *input_line_pointer = '('; | |
933 | ++input_line_pointer; | |
934 | ||
935 | expression (e); | |
936 | ||
937 | if (*input_line_pointer != ')') | |
938 | { | |
939 | as_bad (_("Missing ')'")); | |
940 | *nextcharP = *input_line_pointer; | |
941 | return 0; | |
942 | } | |
943 | /* Skip ')'. */ | |
944 | ++input_line_pointer; | |
945 | ||
946 | if (e->X_op == O_register || e->X_op == O_absent) | |
947 | { | |
948 | as_bad (_("Invalid expression.")); | |
949 | e->X_op = O_constant; | |
950 | e->X_add_number = 0; | |
951 | } | |
952 | else | |
953 | { | |
954 | /* Wrap subexpression with a unary operator. */ | |
955 | symbolS *sym = make_expr_symbol (e); | |
956 | ||
957 | if (sym != e->X_add_symbol) | |
958 | { | |
959 | /* HACK: mark this symbol as a temporary wrapper around a proper | |
960 | expression, so we can unwrap it later once we have communicated | |
961 | the relocation type. */ | |
8d1015a8 | 962 | symbol_get_value_expression (sym)->X_md = 1; |
aa137e4d NC |
963 | } |
964 | ||
965 | memset (e, 0, sizeof *e); | |
966 | e->X_op = op; | |
967 | e->X_add_symbol = sym; | |
968 | e->X_add_number = 0; | |
969 | } | |
970 | ||
971 | *nextcharP = *input_line_pointer; | |
972 | return 1; | |
973 | } | |
974 | ||
975 | ||
976 | /* Parses an expression which must be a register name. */ | |
977 | ||
978 | static void | |
979 | parse_reg_expression (expressionS* expression) | |
980 | { | |
981 | /* Zero everything to make sure we don't miss any flags. */ | |
982 | memset (expression, 0, sizeof *expression); | |
983 | ||
2d011dc1 | 984 | char *regname; |
d02603dc | 985 | char terminating_char = get_symbol_name (®name); |
aa137e4d NC |
986 | |
987 | void* pval = hash_find (main_reg_hash, regname); | |
988 | ||
989 | if (pval == NULL) | |
990 | as_bad (_("Expected register, got '%s'."), regname); | |
991 | ||
992 | int regno_and_flags = (int)(size_t)pval; | |
993 | int regno = EXTRACT_REGNO(regno_and_flags); | |
994 | ||
995 | if ((regno_and_flags & NONCANONICAL_REG_NAME_FLAG) | |
996 | && require_canonical_reg_names) | |
997 | as_warn (_("Found use of non-canonical register name %s; " | |
998 | "use %s instead."), | |
999 | regname, tilepro_register_names[regno]); | |
1000 | ||
1001 | /* Restore the old character following the register name. */ | |
d02603dc | 1002 | (void) restore_line_pointer (terminating_char); |
aa137e4d NC |
1003 | |
1004 | /* Fill in the expression fields to indicate it's a register. */ | |
1005 | expression->X_op = O_register; | |
1006 | expression->X_add_number = regno; | |
1007 | } | |
1008 | ||
1009 | ||
1010 | /* Parses and type-checks comma-separated operands in input_line_pointer. */ | |
1011 | static void | |
1012 | parse_operands (const char *opcode_name, | |
1013 | const unsigned char *operands, | |
1014 | int num_operands, | |
1015 | expressionS *operand_values) | |
1016 | { | |
1017 | int i; | |
1018 | ||
1019 | memset (operand_values, 0, num_operands * sizeof operand_values[0]); | |
1020 | ||
1021 | SKIP_WHITESPACE (); | |
1022 | for (i = 0; i < num_operands; i++) | |
1023 | { | |
1024 | tilepro_operand_type type = tilepro_operands[operands[i]].type; | |
1025 | ||
1026 | SKIP_WHITESPACE (); | |
1027 | ||
1028 | if (type == TILEPRO_OP_TYPE_REGISTER) | |
1029 | { | |
1030 | parse_reg_expression (&operand_values[i]); | |
1031 | } | |
1032 | else if (*input_line_pointer == '}') | |
1033 | { | |
1034 | operand_values[i].X_op = O_absent; | |
1035 | } | |
1036 | else if (type == TILEPRO_OP_TYPE_SPR) | |
1037 | { | |
1038 | /* Modify the expression parser to add SPRs to the namespace. */ | |
1039 | parsing_spr = 1; | |
1040 | expression (&operand_values[i]); | |
1041 | parsing_spr = 0; | |
1042 | } | |
1043 | else | |
1044 | { | |
1045 | expression (&operand_values[i]); | |
1046 | } | |
1047 | ||
1048 | SKIP_WHITESPACE (); | |
1049 | ||
1050 | if (i + 1 < num_operands) | |
1051 | { | |
1052 | int separator = (unsigned char)*input_line_pointer++; | |
1053 | ||
1054 | if (is_end_of_line[separator] || (separator == '}')) | |
1055 | { | |
1056 | as_bad (_("Too few operands to '%s'."), opcode_name); | |
1057 | return; | |
1058 | } | |
1059 | else if (separator != ',') | |
1060 | { | |
1061 | as_bad (_("Unexpected character '%c' after operand %d to %s."), | |
1062 | (char)separator, i + 1, opcode_name); | |
1063 | return; | |
1064 | } | |
1065 | } | |
1066 | ||
1067 | /* Arbitrarily use the first valid pipe to get the operand type, | |
1068 | since they are all the same. */ | |
1069 | switch (tilepro_operands[operands[i]].type) | |
1070 | { | |
1071 | case TILEPRO_OP_TYPE_REGISTER: | |
1072 | /* Handled in parse_reg_expression already. */ | |
1073 | break; | |
1074 | case TILEPRO_OP_TYPE_SPR: | |
1075 | /* Fall through */ | |
1076 | case TILEPRO_OP_TYPE_IMMEDIATE: | |
1077 | /* Fall through */ | |
1078 | case TILEPRO_OP_TYPE_ADDRESS: | |
1079 | if ( operand_values[i].X_op == O_register | |
1080 | || operand_values[i].X_op == O_illegal | |
1081 | || operand_values[i].X_op == O_absent) | |
1082 | as_bad (_("Expected immediate expression")); | |
1083 | break; | |
1084 | default: | |
1085 | abort (); | |
1086 | } | |
1087 | } | |
1088 | ||
1089 | if (!is_end_of_line[(unsigned char)*input_line_pointer]) | |
1090 | { | |
1091 | switch (*input_line_pointer) | |
1092 | { | |
1093 | case '}': | |
1094 | if (!inside_bundle) | |
1095 | as_bad (_("Found '}' when not bundling.")); | |
1096 | ++input_line_pointer; | |
1097 | inside_bundle = 0; | |
1098 | demand_empty_rest_of_line (); | |
1099 | break; | |
1100 | ||
1101 | case ',': | |
1102 | as_bad (_("Too many operands")); | |
1103 | break; | |
1104 | ||
1105 | default: | |
1106 | /* Use default error for unrecognized garbage. */ | |
1107 | demand_empty_rest_of_line (); | |
1108 | break; | |
1109 | } | |
1110 | } | |
1111 | } | |
1112 | ||
1113 | ||
1114 | /* This is the guts of the machine-dependent assembler. STR points to a | |
1115 | machine dependent instruction. This function is supposed to emit | |
1116 | the frags/bytes it assembles to. */ | |
1117 | void | |
1118 | md_assemble (char *str) | |
1119 | { | |
1120 | char old_char; | |
1121 | size_t opname_len; | |
1122 | char *old_input_line_pointer; | |
1123 | const struct tilepro_opcode *op; | |
1124 | int first_pipe; | |
1125 | ||
1126 | /* Split off the opcode and look it up. */ | |
1127 | opname_len = strcspn (str, " {}"); | |
1128 | old_char = str[opname_len]; | |
1129 | str[opname_len] = '\0'; | |
1130 | ||
1131 | op = hash_find(op_hash, str); | |
1132 | str[opname_len] = old_char; | |
1133 | if (op == NULL) | |
1134 | { | |
1135 | as_bad (_("Unknown opcode `%.*s'."), (int)opname_len, str); | |
1136 | return; | |
1137 | } | |
1138 | ||
1139 | /* Prepare to parse the operands. */ | |
1140 | old_input_line_pointer = input_line_pointer; | |
1141 | input_line_pointer = str + opname_len; | |
1142 | SKIP_WHITESPACE (); | |
1143 | ||
1144 | if (current_bundle_index == TILEPRO_MAX_INSTRUCTIONS_PER_BUNDLE) | |
1145 | { | |
1146 | as_bad (_("Too many instructions for bundle.")); | |
1147 | tilepro_flush_bundle (); | |
1148 | } | |
1149 | ||
1150 | /* Make sure we have room for the upcoming bundle before we | |
1151 | create any fixups. Otherwise if we have to switch to a new | |
1152 | frag the fixup dot_value fields will be wrong. */ | |
1153 | frag_grow (TILEPRO_BUNDLE_SIZE_IN_BYTES); | |
1154 | ||
1155 | /* Find a valid pipe for this opcode. */ | |
1156 | for (first_pipe = 0; (op->pipes & (1 << first_pipe)) == 0; first_pipe++) | |
1157 | ; | |
1158 | ||
1159 | /* Call the function that assembles this instruction. */ | |
1160 | current_bundle[current_bundle_index].opcode = op; | |
1161 | parse_operands (op->name, | |
1162 | &op->operands[first_pipe][0], | |
1163 | op->num_operands, | |
1164 | current_bundle[current_bundle_index].operand_values); | |
1165 | ++current_bundle_index; | |
1166 | ||
1167 | /* Restore the saved value of input_line_pointer. */ | |
1168 | input_line_pointer = old_input_line_pointer; | |
1169 | ||
1170 | /* If we weren't inside curly braces, go ahead and emit | |
1171 | this lone instruction as a bundle right now. */ | |
1172 | if (!inside_bundle) | |
1173 | tilepro_flush_bundle (); | |
1174 | } | |
1175 | ||
1176 | static void | |
1177 | s_require_canonical_reg_names (int require) | |
1178 | { | |
1179 | demand_empty_rest_of_line (); | |
1180 | require_canonical_reg_names = require; | |
1181 | } | |
1182 | ||
1183 | static void | |
1184 | s_allow_suspicious_bundles (int allow) | |
1185 | { | |
1186 | demand_empty_rest_of_line (); | |
1187 | allow_suspicious_bundles = allow; | |
1188 | } | |
1189 | ||
1190 | const pseudo_typeS md_pseudo_table[] = | |
1191 | { | |
1192 | {"align", s_align_bytes, 0}, /* Defaulting is invalid (0). */ | |
1193 | {"word", cons, 4}, | |
1194 | {"require_canonical_reg_names", s_require_canonical_reg_names, 1 }, | |
1195 | {"no_require_canonical_reg_names", s_require_canonical_reg_names, 0 }, | |
1196 | {"allow_suspicious_bundles", s_allow_suspicious_bundles, 1 }, | |
1197 | {"no_allow_suspicious_bundles", s_allow_suspicious_bundles, 0 }, | |
1198 | { NULL, 0, 0 } | |
1199 | }; | |
1200 | ||
1201 | /* Equal to MAX_PRECISION in atof-ieee.c */ | |
1202 | #define MAX_LITTLENUMS 6 | |
1203 | ||
1204 | /* Turn the string pointed to by litP into a floating point constant | |
1205 | of type TYPE, and emit the appropriate bytes. The number of | |
1206 | LITTLENUMS emitted is stored in *SIZEP. An error message is | |
1207 | returned, or NULL on OK. */ | |
1208 | ||
6d4af3c2 | 1209 | const char * |
aa137e4d NC |
1210 | md_atof (int type, char *litP, int *sizeP) |
1211 | { | |
1212 | int prec; | |
1213 | LITTLENUM_TYPE words[MAX_LITTLENUMS]; | |
1214 | LITTLENUM_TYPE *wordP; | |
1215 | char *t; | |
1216 | ||
1217 | switch (type) | |
1218 | { | |
1219 | case 'f': | |
1220 | case 'F': | |
1221 | prec = 2; | |
1222 | break; | |
1223 | ||
1224 | case 'd': | |
1225 | case 'D': | |
1226 | prec = 4; | |
1227 | break; | |
1228 | ||
1229 | default: | |
1230 | *sizeP = 0; | |
1231 | return _("Bad call to md_atof ()"); | |
1232 | } | |
1233 | t = atof_ieee (input_line_pointer, type, words); | |
1234 | if (t) | |
1235 | input_line_pointer = t; | |
1236 | ||
1237 | *sizeP = prec * sizeof (LITTLENUM_TYPE); | |
1238 | /* This loops outputs the LITTLENUMs in REVERSE order; in accord with | |
1239 | the bigendian 386. */ | |
1240 | for (wordP = words + prec - 1; prec--;) | |
1241 | { | |
1242 | md_number_to_chars (litP, (valueT) (*wordP--), sizeof (LITTLENUM_TYPE)); | |
1243 | litP += sizeof (LITTLENUM_TYPE); | |
1244 | } | |
1245 | return 0; | |
1246 | } | |
1247 | ||
1248 | ||
1249 | /* We have no need to default values of symbols. */ | |
1250 | ||
1251 | symbolS * | |
1252 | md_undefined_symbol (char *name ATTRIBUTE_UNUSED) | |
1253 | { | |
1254 | return NULL; | |
1255 | } | |
1256 | ||
1257 | ||
1258 | void | |
1259 | tilepro_cons_fix_new (fragS *frag, | |
1260 | int where, | |
1261 | int nbytes, | |
1262 | expressionS *exp) | |
1263 | { | |
1264 | expressionS subexp; | |
1265 | bfd_reloc_code_real_type reloc = BFD_RELOC_NONE; | |
1266 | int no_overflow = 0; | |
1267 | fixS *fixP; | |
1268 | ||
1269 | /* See if it's one of our special functions. */ | |
1270 | switch (exp->X_op) | |
1271 | { | |
1272 | case O_lo16: | |
1273 | reloc = BFD_RELOC_LO16; | |
1274 | no_overflow = 1; | |
1275 | break; | |
1276 | case O_hi16: | |
1277 | reloc = BFD_RELOC_HI16; | |
1278 | no_overflow = 1; | |
1279 | break; | |
1280 | case O_ha16: | |
1281 | reloc = BFD_RELOC_HI16_S; | |
1282 | no_overflow = 1; | |
1283 | break; | |
1284 | ||
1285 | default: | |
1286 | /* Do nothing. */ | |
1287 | break; | |
1288 | } | |
1289 | ||
1290 | if (reloc != BFD_RELOC_NONE) | |
1291 | { | |
1292 | if (nbytes != 2) | |
1293 | { | |
1294 | as_bad (_("This operator only produces two byte values.")); | |
1295 | nbytes = 2; | |
1296 | } | |
1297 | ||
1298 | memset (&subexp, 0, sizeof subexp); | |
1299 | subexp.X_op = O_symbol; | |
1300 | subexp.X_add_symbol = exp->X_add_symbol; | |
1301 | exp = &subexp; | |
1302 | } | |
1303 | else | |
1304 | { | |
1305 | switch (nbytes) | |
1306 | { | |
1307 | case 1: | |
1308 | reloc = BFD_RELOC_8; | |
1309 | break; | |
1310 | case 2: | |
1311 | reloc = BFD_RELOC_16; | |
1312 | break; | |
1313 | case 4: | |
1314 | reloc = BFD_RELOC_32; | |
1315 | break; | |
1316 | case 8: | |
1317 | reloc = BFD_RELOC_64; | |
1318 | break; | |
1319 | default: | |
1320 | as_bad (_("unsupported BFD relocation size %d"), nbytes); | |
1321 | reloc = BFD_RELOC_32; | |
1322 | break; | |
1323 | } | |
1324 | } | |
1325 | ||
1326 | fixP = fix_new_exp (frag, where, nbytes, exp, 0, reloc); | |
1327 | fixP->tc_fix_data = NULL; | |
1328 | fixP->fx_no_overflow |= no_overflow; | |
1329 | } | |
1330 | ||
1331 | ||
1332 | void | |
1333 | md_apply_fix (fixS *fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED) | |
1334 | { | |
1335 | const struct tilepro_operand *operand; | |
1336 | valueT value = *valP; | |
1337 | char *p; | |
1338 | ||
1339 | /* Leave these for the linker. */ | |
1340 | if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT | |
1341 | || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY) | |
1342 | return; | |
1343 | ||
1344 | if (fixP->fx_subsy != (symbolS *) NULL) | |
1345 | { | |
1346 | /* We can't actually support subtracting a symbol. */ | |
1347 | as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex")); | |
1348 | } | |
1349 | ||
1350 | /* Correct relocation types for pc-relativeness. */ | |
1351 | switch (fixP->fx_r_type) | |
1352 | { | |
1353 | #define FIX_PCREL(rtype) \ | |
1354 | case rtype: \ | |
1355 | if (fixP->fx_pcrel) \ | |
1356 | fixP->fx_r_type = rtype##_PCREL; \ | |
1357 | break; \ | |
1358 | \ | |
1359 | case rtype##_PCREL: \ | |
1360 | if (!fixP->fx_pcrel) \ | |
1361 | fixP->fx_r_type = rtype; \ | |
1362 | break | |
1363 | ||
1364 | FIX_PCREL (BFD_RELOC_8); | |
1365 | FIX_PCREL (BFD_RELOC_16); | |
1366 | FIX_PCREL (BFD_RELOC_32); | |
1367 | FIX_PCREL (BFD_RELOC_TILEPRO_IMM16_X0); | |
1368 | FIX_PCREL (BFD_RELOC_TILEPRO_IMM16_X1); | |
1369 | FIX_PCREL (BFD_RELOC_TILEPRO_IMM16_X0_LO); | |
1370 | FIX_PCREL (BFD_RELOC_TILEPRO_IMM16_X1_LO); | |
1371 | FIX_PCREL (BFD_RELOC_TILEPRO_IMM16_X0_HI); | |
1372 | FIX_PCREL (BFD_RELOC_TILEPRO_IMM16_X1_HI); | |
1373 | FIX_PCREL (BFD_RELOC_TILEPRO_IMM16_X0_HA); | |
1374 | FIX_PCREL (BFD_RELOC_TILEPRO_IMM16_X1_HA); | |
1375 | ||
1376 | #undef FIX_PCREL | |
1377 | ||
1378 | default: | |
1379 | /* Do nothing */ | |
1380 | break; | |
1381 | } | |
1382 | ||
1383 | if (fixP->fx_addsy != NULL) | |
1384 | { | |
1385 | #ifdef OBJ_ELF | |
1386 | switch (fixP->fx_r_type) | |
1387 | { | |
6f7be959 WL |
1388 | case BFD_RELOC_TILEPRO_IMM8_X0_TLS_GD_ADD: |
1389 | case BFD_RELOC_TILEPRO_IMM8_X1_TLS_GD_ADD: | |
1390 | case BFD_RELOC_TILEPRO_IMM8_Y0_TLS_GD_ADD: | |
1391 | case BFD_RELOC_TILEPRO_IMM8_Y1_TLS_GD_ADD: | |
aa137e4d NC |
1392 | case BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD: |
1393 | case BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD: | |
aa137e4d NC |
1394 | case BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD_LO: |
1395 | case BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD_LO: | |
aa137e4d NC |
1396 | case BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD_HI: |
1397 | case BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD_HI: | |
aa137e4d NC |
1398 | case BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD_HA: |
1399 | case BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD_HA: | |
6f7be959 WL |
1400 | case BFD_RELOC_TILEPRO_IMM16_X0_TLS_IE: |
1401 | case BFD_RELOC_TILEPRO_IMM16_X1_TLS_IE: | |
1402 | case BFD_RELOC_TILEPRO_IMM16_X0_TLS_IE_LO: | |
1403 | case BFD_RELOC_TILEPRO_IMM16_X1_TLS_IE_LO: | |
1404 | case BFD_RELOC_TILEPRO_IMM16_X0_TLS_IE_HI: | |
1405 | case BFD_RELOC_TILEPRO_IMM16_X1_TLS_IE_HI: | |
aa137e4d NC |
1406 | case BFD_RELOC_TILEPRO_IMM16_X0_TLS_IE_HA: |
1407 | case BFD_RELOC_TILEPRO_IMM16_X1_TLS_IE_HA: | |
6f7be959 WL |
1408 | case BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE: |
1409 | case BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE: | |
1410 | case BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_LO: | |
1411 | case BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_LO: | |
1412 | case BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HI: | |
1413 | case BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HI: | |
1414 | case BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HA: | |
1415 | case BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HA: | |
1416 | case BFD_RELOC_TILEPRO_TLS_GD_CALL: | |
1417 | case BFD_RELOC_TILEPRO_TLS_IE_LOAD: | |
aa137e4d NC |
1418 | case BFD_RELOC_TILEPRO_TLS_DTPMOD32: |
1419 | case BFD_RELOC_TILEPRO_TLS_DTPOFF32: | |
1420 | case BFD_RELOC_TILEPRO_TLS_TPOFF32: | |
1421 | S_SET_THREAD_LOCAL (fixP->fx_addsy); | |
1422 | break; | |
1423 | ||
1424 | default: | |
1425 | /* Do nothing */ | |
1426 | break; | |
1427 | } | |
1428 | #endif | |
1429 | return; | |
1430 | } | |
1431 | ||
1432 | /* Apply lo16, hi16, ha16, etc. munging. */ | |
1433 | switch (fixP->fx_r_type) | |
1434 | { | |
aa137e4d NC |
1435 | case BFD_RELOC_LO16: |
1436 | case BFD_RELOC_TILEPRO_IMM16_X0_LO: | |
1437 | case BFD_RELOC_TILEPRO_IMM16_X1_LO: | |
1438 | case BFD_RELOC_TILEPRO_IMM16_X0_LO_PCREL: | |
1439 | case BFD_RELOC_TILEPRO_IMM16_X1_LO_PCREL: | |
1440 | *valP = value = apply_special_operator (O_lo16, value); | |
1441 | break; | |
1442 | ||
aa137e4d NC |
1443 | case BFD_RELOC_HI16: |
1444 | case BFD_RELOC_TILEPRO_IMM16_X0_HI: | |
1445 | case BFD_RELOC_TILEPRO_IMM16_X1_HI: | |
1446 | case BFD_RELOC_TILEPRO_IMM16_X0_HI_PCREL: | |
1447 | case BFD_RELOC_TILEPRO_IMM16_X1_HI_PCREL: | |
1448 | *valP = value = apply_special_operator (O_hi16, value); | |
1449 | break; | |
1450 | ||
aa137e4d NC |
1451 | case BFD_RELOC_HI16_S: |
1452 | case BFD_RELOC_TILEPRO_IMM16_X0_HA: | |
1453 | case BFD_RELOC_TILEPRO_IMM16_X1_HA: | |
1454 | case BFD_RELOC_TILEPRO_IMM16_X0_HA_PCREL: | |
1455 | case BFD_RELOC_TILEPRO_IMM16_X1_HA_PCREL: | |
1456 | *valP = value = apply_special_operator (O_ha16, value); | |
1457 | break; | |
1458 | ||
aa137e4d NC |
1459 | default: |
1460 | /* Do nothing */ | |
1461 | break; | |
1462 | } | |
1463 | ||
1464 | p = fixP->fx_frag->fr_literal + fixP->fx_where; | |
1465 | ||
1466 | operand = fixP->tc_fix_data; | |
1467 | if (operand != NULL) | |
1468 | { | |
1469 | /* It's an instruction operand. */ | |
1470 | tilepro_bundle_bits bits = | |
1471 | insert_operand (0, operand, value, fixP->fx_file, fixP->fx_line); | |
1472 | ||
1473 | /* Note that we might either be writing out bits for a bundle or a | |
1474 | static network instruction, which are different sizes, so it's | |
1475 | important to stop touching memory once we run out of bits. ORing in | |
1476 | values is OK since we know the existing bits for this operand are | |
1477 | zero. */ | |
1478 | for (; bits != 0; bits >>= 8) | |
1479 | *p++ |= (char)bits; | |
1480 | } | |
1481 | else | |
1482 | { | |
1483 | /* Some other kind of relocation. */ | |
1484 | switch (fixP->fx_r_type) | |
1485 | { | |
1486 | case BFD_RELOC_8: | |
1487 | case BFD_RELOC_8_PCREL: | |
1488 | md_number_to_chars (p, value, 1); | |
1489 | break; | |
1490 | ||
1491 | case BFD_RELOC_16: | |
1492 | case BFD_RELOC_16_PCREL: | |
1493 | md_number_to_chars (p, value, 2); | |
1494 | break; | |
1495 | ||
1496 | case BFD_RELOC_32: | |
1497 | case BFD_RELOC_32_PCREL: | |
1498 | md_number_to_chars (p, value, 4); | |
1499 | break; | |
1500 | ||
1501 | default: | |
1502 | /* Leave it for the linker. */ | |
1503 | return; | |
1504 | } | |
1505 | } | |
1506 | ||
1507 | fixP->fx_done = 1; | |
1508 | } | |
1509 | ||
1510 | ||
1511 | /* Generate the BFD reloc to be stuck in the object file from the | |
1512 | fixup used internally in the assembler. */ | |
1513 | ||
1514 | arelent * | |
1515 | tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED, fixS *fixp) | |
1516 | { | |
1517 | arelent *reloc; | |
1518 | ||
add39d23 TS |
1519 | reloc = XNEW (arelent); |
1520 | reloc->sym_ptr_ptr = XNEW (asymbol *); | |
aa137e4d NC |
1521 | *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); |
1522 | reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; | |
1523 | ||
1524 | /* Make sure none of our internal relocations make it this far. | |
1525 | They'd better have been fully resolved by this point. */ | |
1526 | gas_assert ((int) fixp->fx_r_type > 0); | |
1527 | ||
1528 | reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); | |
1529 | if (reloc->howto == NULL) | |
1530 | { | |
1531 | as_bad_where (fixp->fx_file, fixp->fx_line, | |
1532 | _("cannot represent `%s' relocation in object file"), | |
1533 | bfd_get_reloc_code_name (fixp->fx_r_type)); | |
1534 | return NULL; | |
1535 | } | |
1536 | ||
1537 | if (!fixp->fx_pcrel != !reloc->howto->pc_relative) | |
1538 | { | |
1539 | as_fatal (_("internal error? cannot generate `%s' relocation (%d, %d)"), | |
1540 | bfd_get_reloc_code_name (fixp->fx_r_type), | |
1541 | fixp->fx_pcrel, reloc->howto->pc_relative); | |
1542 | } | |
1543 | gas_assert (!fixp->fx_pcrel == !reloc->howto->pc_relative); | |
1544 | ||
1545 | reloc->addend = fixp->fx_offset; | |
1546 | ||
1547 | return reloc; | |
1548 | } | |
1549 | ||
1550 | ||
1551 | /* The location from which a PC relative jump should be calculated, | |
1552 | given a PC relative reloc. */ | |
1553 | ||
1554 | long | |
1555 | md_pcrel_from (fixS *fixP) | |
1556 | { | |
1557 | return fixP->fx_frag->fr_address + fixP->fx_where; | |
1558 | } | |
1559 | ||
1560 | ||
1561 | /* Return 1 if it's OK to adjust a reloc by replacing the symbol with | |
1562 | a section symbol plus some offset. */ | |
1563 | int | |
1564 | tilepro_fix_adjustable (fixS *fix) | |
1565 | { | |
1566 | /* Prevent all adjustments to global symbols */ | |
1567 | if (S_IS_EXTERNAL (fix->fx_addsy) || S_IS_WEAK (fix->fx_addsy)) | |
1568 | return 0; | |
1569 | ||
1570 | return 1; | |
1571 | } | |
1572 | ||
1573 | ||
1574 | int | |
1575 | tilepro_unrecognized_line (int ch) | |
1576 | { | |
1577 | switch (ch) | |
1578 | { | |
1579 | case '{': | |
1580 | if (inside_bundle) | |
1581 | { | |
1582 | as_bad (_("Found '{' when already bundling.")); | |
1583 | } | |
1584 | else | |
1585 | { | |
1586 | inside_bundle = 1; | |
1587 | current_bundle_index = 0; | |
1588 | } | |
1589 | return 1; | |
1590 | ||
1591 | case '}': | |
1592 | if (!inside_bundle) | |
1593 | { | |
1594 | as_bad (_("Found '}' when not bundling.")); | |
1595 | } | |
1596 | else | |
1597 | { | |
1598 | tilepro_flush_bundle (); | |
1599 | } | |
1600 | ||
1601 | /* Allow '{' to follow on the same line. We also allow ";;", but that | |
1602 | happens automatically because ';' is an end of line marker. */ | |
1603 | SKIP_WHITESPACE (); | |
1604 | if (input_line_pointer[0] == '{') | |
1605 | { | |
1606 | input_line_pointer++; | |
1607 | return tilepro_unrecognized_line ('{'); | |
1608 | } | |
1609 | ||
1610 | demand_empty_rest_of_line (); | |
1611 | return 1; | |
1612 | ||
1613 | default: | |
1614 | break; | |
1615 | } | |
1616 | ||
1617 | /* Not a valid line. */ | |
1618 | return 0; | |
1619 | } | |
1620 | ||
1621 | ||
1622 | /* This is called from HANDLE_ALIGN in write.c. Fill in the contents | |
1623 | of an rs_align_code fragment. */ | |
1624 | ||
1625 | void | |
1626 | tilepro_handle_align (fragS *fragp) | |
1627 | { | |
1628 | int bytes, fix; | |
1629 | char *p; | |
1630 | ||
1631 | if (fragp->fr_type != rs_align_code) | |
1632 | return; | |
1633 | ||
1634 | bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix; | |
1635 | p = fragp->fr_literal + fragp->fr_fix; | |
1636 | fix = 0; | |
1637 | ||
1638 | /* Determine the bits for NOP. */ | |
1639 | const struct tilepro_opcode *nop_opcode = | |
1640 | &tilepro_opcodes[TILEPRO_OPC_NOP]; | |
1641 | tilepro_bundle_bits nop = | |
1642 | ( nop_opcode->fixed_bit_values[TILEPRO_PIPELINE_X0] | |
1643 | | nop_opcode->fixed_bit_values[TILEPRO_PIPELINE_X1]); | |
1644 | ||
1645 | if ((bytes & (TILEPRO_BUNDLE_SIZE_IN_BYTES - 1)) != 0) | |
1646 | { | |
1647 | fix = bytes & (TILEPRO_BUNDLE_SIZE_IN_BYTES - 1); | |
1648 | memset (p, 0, fix); | |
1649 | p += fix; | |
1650 | bytes -= fix; | |
1651 | } | |
1652 | ||
1653 | number_to_chars_littleendian (p, (unsigned int)nop, 4); | |
1654 | number_to_chars_littleendian (p + 4, (unsigned int)(nop >> 32), 4); | |
1655 | fragp->fr_fix += fix; | |
1656 | fragp->fr_var = TILEPRO_BUNDLE_SIZE_IN_BYTES; | |
1657 | } | |
1658 | ||
1659 | /* Standard calling conventions leave the CFA at SP on entry. */ | |
1660 | void | |
1661 | tilepro_cfi_frame_initial_instructions (void) | |
1662 | { | |
1663 | cfi_add_CFA_def_cfa_register (54); | |
1664 | } | |
1665 | ||
1666 | int | |
1667 | tc_tilepro_regname_to_dw2regnum (char *regname) | |
1668 | { | |
1669 | int i; | |
1670 | ||
1671 | for (i = 0; i < TILEPRO_NUM_REGISTERS; i++) | |
1672 | { | |
1673 | if (!strcmp (regname, tilepro_register_names[i])) | |
1674 | return i; | |
1675 | } | |
1676 | ||
1677 | return -1; | |
1678 | } |