1 /* tc-alpha.c - Processor-specific code for the DEC Alpha AXP CPU.
2 Copyright (C) 1989, 93-98, 1999, 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Carnegie Mellon University, 1993.
4 Written by Alessandro Forin, based on earlier gas-1.38 target CPU files.
5 Modified by Ken Raeburn for gas-2.x and ECOFF support.
6 Modified by Richard Henderson for ELF support.
7 Modified by Klaus K"ampf for EVAX (OpenVMS/Alpha) support.
9 This file is part of GAS, the GNU Assembler.
11 GAS is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2, or (at your option)
16 GAS is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with GAS; see the file COPYING. If not, write to the Free
23 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
27 * Mach Operating System
28 * Copyright (c) 1993 Carnegie Mellon University
29 * All Rights Reserved.
31 * Permission to use, copy, modify and distribute this software and its
32 * documentation is hereby granted, provided that both the copyright
33 * notice and this permission notice appear in all copies of the
34 * software, derivative works or modified versions, and any portions
35 * thereof, and that both notices appear in supporting documentation.
37 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
38 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
39 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
41 * Carnegie Mellon requests users of this software to return to
43 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
44 * School of Computer Science
45 * Carnegie Mellon University
46 * Pittsburgh PA 15213-3890
48 * any improvements or extensions that they make and grant Carnegie the
49 * rights to redistribute these changes.
54 #include "struc-symbol.h"
57 #include "opcode/alpha.h"
60 #include "elf/alpha.h"
61 #include "dwarf2dbg.h"
68 #define TOKENIZE_ERROR -1
69 #define TOKENIZE_ERROR_REPORT -2
71 #define MAX_INSN_FIXUPS 2
72 #define MAX_INSN_ARGS 5
76 bfd_reloc_code_real_type reloc;
82 struct alpha_fixup fixups[MAX_INSN_FIXUPS];
83 unsigned sequence[MAX_INSN_FIXUPS];
86 enum alpha_macro_arg {
102 void (*emit) PARAMS ((const expressionS *, int, const PTR));
104 enum alpha_macro_arg argsets[16];
107 /* Extra expression types. */
109 #define O_pregister O_md1 /* O_register, in parentheses */
110 #define O_cpregister O_md2 /* + a leading comma */
113 /* Note, the alpha_reloc_op table below depends on the ordering
114 of O_literal .. O_gprelow. */
115 #define O_literal O_md3 /* !literal relocation */
116 #define O_lituse_base O_md4 /* !lituse_base relocation */
117 #define O_lituse_bytoff O_md5 /* !lituse_bytoff relocation */
118 #define O_lituse_jsr O_md6 /* !lituse_jsr relocation */
119 #define O_gpdisp O_md7 /* !gpdisp relocation */
120 #define O_gprelhigh O_md8 /* !gprelhigh relocation */
121 #define O_gprellow O_md9 /* !gprellow relocation */
123 #define USER_RELOC_P(R) ((R) >= O_literal && (R) <= O_gprellow)
126 /* Macros for extracting the type and number of encoded register tokens */
128 #define is_ir_num(x) (((x) & 32) == 0)
129 #define is_fpr_num(x) (((x) & 32) != 0)
130 #define regno(x) ((x) & 31)
132 /* Something odd inherited from the old assembler */
134 #define note_gpreg(R) (alpha_gprmask |= (1 << (R)))
135 #define note_fpreg(R) (alpha_fprmask |= (1 << (R)))
137 /* Predicates for 16- and 32-bit ranges */
138 /* XXX: The non-shift version appears to trigger a compiler bug when
139 cross-assembling from x86 w/ gcc 2.7.2. */
142 #define range_signed_16(x) \
143 (((offsetT) (x) >> 15) == 0 || ((offsetT) (x) >> 15) == -1)
144 #define range_signed_32(x) \
145 (((offsetT) (x) >> 31) == 0 || ((offsetT) (x) >> 31) == -1)
147 #define range_signed_16(x) ((offsetT) (x) >= -(offsetT) 0x8000 && \
148 (offsetT) (x) <= (offsetT) 0x7FFF)
149 #define range_signed_32(x) ((offsetT) (x) >= -(offsetT) 0x80000000 && \
150 (offsetT) (x) <= (offsetT) 0x7FFFFFFF)
153 /* Macros for sign extending from 16- and 32-bits. */
154 /* XXX: The cast macros will work on all the systems that I care about,
155 but really a predicate should be found to use the non-cast forms. */
158 #define sign_extend_16(x) ((short) (x))
159 #define sign_extend_32(x) ((int) (x))
161 #define sign_extend_16(x) ((offsetT) (((x) & 0xFFFF) ^ 0x8000) - 0x8000)
162 #define sign_extend_32(x) ((offsetT) (((x) & 0xFFFFFFFF) \
163 ^ 0x80000000) - 0x80000000)
166 /* Macros to build tokens */
168 #define set_tok_reg(t, r) (memset (&(t), 0, sizeof (t)), \
169 (t).X_op = O_register, \
170 (t).X_add_number = (r))
171 #define set_tok_preg(t, r) (memset (&(t), 0, sizeof (t)), \
172 (t).X_op = O_pregister, \
173 (t).X_add_number = (r))
174 #define set_tok_cpreg(t, r) (memset (&(t), 0, sizeof (t)), \
175 (t).X_op = O_cpregister, \
176 (t).X_add_number = (r))
177 #define set_tok_freg(t, r) (memset (&(t), 0, sizeof (t)), \
178 (t).X_op = O_register, \
179 (t).X_add_number = (r) + 32)
180 #define set_tok_sym(t, s, a) (memset (&(t), 0, sizeof (t)), \
181 (t).X_op = O_symbol, \
182 (t).X_add_symbol = (s), \
183 (t).X_add_number = (a))
184 #define set_tok_const(t, n) (memset (&(t), 0, sizeof (t)), \
185 (t).X_op = O_constant, \
186 (t).X_add_number = (n))
188 /* Prototypes for all local functions */
190 static int tokenize_arguments PARAMS ((char *, expressionS *, int));
191 static const struct alpha_opcode *find_opcode_match
192 PARAMS ((const struct alpha_opcode *, const expressionS *, int *, int *));
193 static const struct alpha_macro *find_macro_match
194 PARAMS ((const struct alpha_macro *, const expressionS *, int *));
195 static unsigned insert_operand
196 PARAMS ((unsigned, const struct alpha_operand *, offsetT, char *, unsigned));
197 static void assemble_insn
198 PARAMS ((const struct alpha_opcode *, const expressionS *, int,
199 struct alpha_insn *));
200 static void emit_insn PARAMS ((struct alpha_insn *));
201 static void assemble_tokens_to_insn
202 PARAMS ((const char *, const expressionS *, int, struct alpha_insn *));
203 static void assemble_tokens
204 PARAMS ((const char *, const expressionS *, int, int));
206 static int load_expression
207 PARAMS ((int, const expressionS *, int *, expressionS *,
208 const expressionS *));
210 static void emit_ldgp PARAMS ((const expressionS *, int, const PTR));
211 static void emit_division PARAMS ((const expressionS *, int, const PTR));
212 static void emit_lda PARAMS ((const expressionS *, int, const PTR));
213 static void emit_ldah PARAMS ((const expressionS *, int, const PTR));
214 static void emit_ir_load PARAMS ((const expressionS *, int, const PTR));
215 static void emit_loadstore PARAMS ((const expressionS *, int, const PTR));
216 static void emit_jsrjmp PARAMS ((const expressionS *, int, const PTR));
217 static void emit_ldX PARAMS ((const expressionS *, int, const PTR));
218 static void emit_ldXu PARAMS ((const expressionS *, int, const PTR));
219 static void emit_uldX PARAMS ((const expressionS *, int, const PTR));
220 static void emit_uldXu PARAMS ((const expressionS *, int, const PTR));
221 static void emit_ldil PARAMS ((const expressionS *, int, const PTR));
222 static void emit_stX PARAMS ((const expressionS *, int, const PTR));
223 static void emit_ustX PARAMS ((const expressionS *, int, const PTR));
224 static void emit_sextX PARAMS ((const expressionS *, int, const PTR));
225 static void emit_retjcr PARAMS ((const expressionS *, int, const PTR));
227 static void s_alpha_text PARAMS ((int));
228 static void s_alpha_data PARAMS ((int));
230 static void s_alpha_comm PARAMS ((int));
231 static void s_alpha_rdata PARAMS ((int));
234 static void s_alpha_sdata PARAMS ((int));
237 static void s_alpha_section PARAMS ((int));
238 static void s_alpha_ent PARAMS ((int));
239 static void s_alpha_end PARAMS ((int));
240 static void s_alpha_mask PARAMS ((int));
241 static void s_alpha_frame PARAMS ((int));
242 static void s_alpha_prologue PARAMS ((int));
243 static void s_alpha_file PARAMS ((int));
244 static void s_alpha_loc PARAMS ((int));
245 static void s_alpha_stab PARAMS ((int));
246 static void s_alpha_coff_wrapper PARAMS ((int));
249 static void s_alpha_section PARAMS ((int));
251 static void s_alpha_gprel32 PARAMS ((int));
252 static void s_alpha_float_cons PARAMS ((int));
253 static void s_alpha_proc PARAMS ((int));
254 static void s_alpha_set PARAMS ((int));
255 static void s_alpha_base PARAMS ((int));
256 static void s_alpha_align PARAMS ((int));
257 static void s_alpha_stringer PARAMS ((int));
258 static void s_alpha_space PARAMS ((int));
260 static void create_literal_section PARAMS ((const char *, segT *, symbolS **));
262 static void select_gp_value PARAMS ((void));
264 static void alpha_align PARAMS ((int, char *, symbolS *, int));
267 static void alpha_adjust_symtab_relocs PARAMS ((bfd *, asection *, PTR));
270 /* Generic assembler global variables which must be defined by all
273 /* Characters which always start a comment. */
274 const char comment_chars[] = "#";
276 /* Characters which start a comment at the beginning of a line. */
277 const char line_comment_chars[] = "#";
279 /* Characters which may be used to separate multiple commands on a
281 const char line_separator_chars[] = ";";
283 /* Characters which are used to indicate an exponent in a floating
285 const char EXP_CHARS[] = "eE";
287 /* Characters which mean that a number is a floating point constant,
290 const char FLT_CHARS[] = "dD";
292 /* XXX: Do all of these really get used on the alpha?? */
293 char FLT_CHARS[] = "rRsSfFdDxXpP";
297 const char *md_shortopts = "Fm:g+1h:HG:";
299 const char *md_shortopts = "Fm:gG:";
302 struct option md_longopts[] = {
303 #define OPTION_32ADDR (OPTION_MD_BASE)
304 { "32addr", no_argument, NULL, OPTION_32ADDR },
305 #define OPTION_RELAX (OPTION_32ADDR + 1)
306 { "relax", no_argument, NULL, OPTION_RELAX },
308 #define OPTION_MDEBUG (OPTION_RELAX + 1)
309 #define OPTION_NO_MDEBUG (OPTION_MDEBUG + 1)
310 { "mdebug", no_argument, NULL, OPTION_MDEBUG },
311 { "no-mdebug", no_argument, NULL, OPTION_NO_MDEBUG },
313 { NULL, no_argument, NULL, 0 }
316 size_t md_longopts_size = sizeof (md_longopts);
320 #define AXP_REG_R16 16
321 #define AXP_REG_R17 17
323 #define AXP_REG_T9 22
325 #define AXP_REG_T10 23
327 #define AXP_REG_T11 24
329 #define AXP_REG_T12 25
330 #define AXP_REG_AI 25
332 #define AXP_REG_FP 29
335 #define AXP_REG_GP AXP_REG_PV
336 #endif /* OBJ_EVAX */
338 /* The cpu for which we are generating code */
339 static unsigned alpha_target = AXP_OPCODE_BASE;
340 static const char *alpha_target_name = "<all>";
342 /* The hash table of instruction opcodes */
343 static struct hash_control *alpha_opcode_hash;
345 /* The hash table of macro opcodes */
346 static struct hash_control *alpha_macro_hash;
349 /* The $gp relocation symbol */
350 static symbolS *alpha_gp_symbol;
352 /* XXX: what is this, and why is it exported? */
353 valueT alpha_gp_value;
356 /* The current $gp register */
357 static int alpha_gp_register = AXP_REG_GP;
359 /* A table of the register symbols */
360 static symbolS *alpha_register_table[64];
362 /* Constant sections, or sections of constants */
364 static segT alpha_lita_section;
365 static segT alpha_lit4_section;
368 static segT alpha_link_section;
369 static segT alpha_ctors_section;
370 static segT alpha_dtors_section;
372 static segT alpha_lit8_section;
374 /* Symbols referring to said sections. */
376 static symbolS *alpha_lita_symbol;
377 static symbolS *alpha_lit4_symbol;
380 static symbolS *alpha_link_symbol;
381 static symbolS *alpha_ctors_symbol;
382 static symbolS *alpha_dtors_symbol;
384 static symbolS *alpha_lit8_symbol;
386 /* Literal for .litX+0x8000 within .lita */
388 static offsetT alpha_lit4_literal;
389 static offsetT alpha_lit8_literal;
393 /* The active .ent symbol. */
394 static symbolS *alpha_cur_ent_sym;
397 /* Is the assembler not allowed to use $at? */
398 static int alpha_noat_on = 0;
400 /* Are macros enabled? */
401 static int alpha_macros_on = 1;
403 /* Are floats disabled? */
404 static int alpha_nofloats_on = 0;
406 /* Are addresses 32 bit? */
407 static int alpha_addr32_on = 0;
409 /* Symbol labelling the current insn. When the Alpha gas sees
412 and the section happens to not be on an eight byte boundary, it
413 will align both the symbol and the .quad to an eight byte boundary. */
414 static symbolS *alpha_insn_label;
416 /* Whether we should automatically align data generation pseudo-ops.
417 .align 0 will turn this off. */
418 static int alpha_auto_align_on = 1;
420 /* The known current alignment of the current section. */
421 static int alpha_current_align;
423 /* These are exported to ECOFF code. */
424 unsigned long alpha_gprmask, alpha_fprmask;
426 /* Whether the debugging option was seen. */
427 static int alpha_debug;
430 /* Whether we are emitting an mdebug section. */
431 int alpha_flag_mdebug = -1;
434 /* Don't fully resolve relocations, allowing code movement in the linker. */
435 static int alpha_flag_relax;
437 /* What value to give to bfd_set_gp_size. */
438 static int g_switch_value = 8;
441 /* Collect information about current procedure here. */
443 symbolS *symbol; /* proc pdesc symbol */
445 int framereg; /* register for frame pointer */
446 int framesize; /* size of frame */
456 static int alpha_flag_hash_long_names = 0; /* -+ */
457 static int alpha_flag_show_after_trunc = 0; /* -H */
459 /* If the -+ switch is given, then a hash is appended to any name that is
460 * longer than 64 characters, else longer symbol names are truncated.
466 /* A table to map the spelling of a relocation operand into an appropriate
467 bfd_reloc_code_real_type type. The table is assumed to be ordered such
468 that op-O_literal indexes into it. */
470 #define ALPHA_RELOC_TABLE(op) \
471 &alpha_reloc_op[ ((!USER_RELOC_P (op)) \
473 : (int) (op) - (int) O_literal) ]
475 #define LITUSE_BASE 1
476 #define LITUSE_BYTOFF 2
479 static const struct alpha_reloc_op_tag {
480 const char *name; /* string to lookup */
481 size_t length; /* size of the string */
482 bfd_reloc_code_real_type reloc; /* relocation before frob */
483 operatorT op; /* which operator to use */
484 int lituse; /* addened to specify lituse */
485 } alpha_reloc_op[] = {
488 "literal", /* name */
489 sizeof ("literal")-1, /* length */
490 BFD_RELOC_ALPHA_USER_LITERAL, /* reloc */
496 "lituse_base", /* name */
497 sizeof ("lituse_base")-1, /* length */
498 BFD_RELOC_ALPHA_USER_LITUSE_BASE, /* reloc */
499 O_lituse_base, /* op */
500 LITUSE_BASE, /* lituse */
504 "lituse_bytoff", /* name */
505 sizeof ("lituse_bytoff")-1, /* length */
506 BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF, /* reloc */
507 O_lituse_bytoff, /* op */
508 LITUSE_BYTOFF, /* lituse */
512 "lituse_jsr", /* name */
513 sizeof ("lituse_jsr")-1, /* length */
514 BFD_RELOC_ALPHA_USER_LITUSE_JSR, /* reloc */
515 O_lituse_jsr, /* op */
516 LITUSE_JSR, /* lituse */
521 sizeof ("gpdisp")-1, /* length */
522 BFD_RELOC_ALPHA_USER_GPDISP, /* reloc */
528 "gprelhigh", /* name */
529 sizeof ("gprelhigh")-1, /* length */
530 BFD_RELOC_ALPHA_USER_GPRELHIGH, /* reloc */
531 O_gprelhigh, /* op */
536 "gprellow", /* name */
537 sizeof ("gprellow")-1, /* length */
538 BFD_RELOC_ALPHA_USER_GPRELLOW, /* reloc */
544 static const int alpha_num_reloc_op
545 = sizeof (alpha_reloc_op) / sizeof (*alpha_reloc_op);
547 /* Maximum # digits needed to hold the largest sequence # */
548 #define ALPHA_RELOC_DIGITS 25
550 /* Whether a sequence number is valid. */
551 #define ALPHA_RELOC_SEQUENCE_OK(X) ((X) > 0 && ((unsigned) (X)) == (X))
553 /* Structure to hold explict sequence information. */
554 struct alpha_literal_tag
556 fixS *lituse; /* head of linked list of !literals */
557 segT segment; /* segment relocs are in or undefined_section*/
558 int multi_section_p; /* True if more than one section was used */
559 unsigned sequence; /* sequence # */
560 unsigned n_literals; /* # of literals */
561 unsigned n_lituses; /* # of lituses */
562 char string[1]; /* printable form of sequence to hash with */
565 /* Hash table to link up literals with the appropriate lituse */
566 static struct hash_control *alpha_literal_hash;
569 /* A table of CPU names and opcode sets. */
571 static const struct cpu_type {
575 /* Ad hoc convention: cpu number gets palcode, process code doesn't.
576 This supports usage under DU 4.0b that does ".arch ev4", and
577 usage in MILO that does -m21064. Probably something more
578 specific like -m21064-pal should be used, but oh well. */
580 { "21064", AXP_OPCODE_BASE|AXP_OPCODE_EV4 },
581 { "21064a", AXP_OPCODE_BASE|AXP_OPCODE_EV4 },
582 { "21066", AXP_OPCODE_BASE|AXP_OPCODE_EV4 },
583 { "21068", AXP_OPCODE_BASE|AXP_OPCODE_EV4 },
584 { "21164", AXP_OPCODE_BASE|AXP_OPCODE_EV5 },
585 { "21164a", AXP_OPCODE_BASE|AXP_OPCODE_EV5|AXP_OPCODE_BWX },
586 { "21164pc", (AXP_OPCODE_BASE|AXP_OPCODE_EV5|AXP_OPCODE_BWX
588 { "21264", (AXP_OPCODE_BASE|AXP_OPCODE_EV6|AXP_OPCODE_BWX
589 |AXP_OPCODE_MAX|AXP_OPCODE_CIX) },
591 { "ev4", AXP_OPCODE_BASE },
592 { "ev45", AXP_OPCODE_BASE },
593 { "lca45", AXP_OPCODE_BASE },
594 { "ev5", AXP_OPCODE_BASE },
595 { "ev56", AXP_OPCODE_BASE|AXP_OPCODE_BWX },
596 { "pca56", AXP_OPCODE_BASE|AXP_OPCODE_BWX|AXP_OPCODE_MAX },
597 { "ev6", AXP_OPCODE_BASE|AXP_OPCODE_BWX|AXP_OPCODE_MAX|AXP_OPCODE_CIX },
599 { "all", AXP_OPCODE_BASE },
603 /* The macro table */
605 static const struct alpha_macro alpha_macros[] = {
606 /* Load/Store macros */
607 { "lda", emit_lda, NULL,
608 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_LITERAL, MACRO_BASE, MACRO_EOA } },
609 { "ldah", emit_ldah, NULL,
610 { MACRO_IR, MACRO_EXP, MACRO_EOA } },
612 { "ldl", emit_ir_load, "ldl",
613 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
614 { "ldl_l", emit_ir_load, "ldl_l",
615 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
616 { "ldq", emit_ir_load, "ldq",
617 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_LITERAL, MACRO_EOA } },
618 { "ldq_l", emit_ir_load, "ldq_l",
619 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
620 { "ldq_u", emit_ir_load, "ldq_u",
621 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
622 { "ldf", emit_loadstore, "ldf",
623 { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
624 { "ldg", emit_loadstore, "ldg",
625 { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
626 { "lds", emit_loadstore, "lds",
627 { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
628 { "ldt", emit_loadstore, "ldt",
629 { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
631 { "ldb", emit_ldX, (PTR) 0,
632 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
633 { "ldbu", emit_ldXu, (PTR) 0,
634 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
635 { "ldw", emit_ldX, (PTR) 1,
636 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
637 { "ldwu", emit_ldXu, (PTR) 1,
638 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
640 { "uldw", emit_uldX, (PTR) 1,
641 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
642 { "uldwu", emit_uldXu, (PTR) 1,
643 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
644 { "uldl", emit_uldX, (PTR) 2,
645 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
646 { "uldlu", emit_uldXu, (PTR) 2,
647 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
648 { "uldq", emit_uldXu, (PTR) 3,
649 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
651 { "ldgp", emit_ldgp, NULL,
652 { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA } },
654 { "ldi", emit_lda, NULL,
655 { MACRO_IR, MACRO_EXP, MACRO_EOA } },
656 { "ldil", emit_ldil, NULL,
657 { MACRO_IR, MACRO_EXP, MACRO_EOA } },
658 { "ldiq", emit_lda, NULL,
659 { MACRO_IR, MACRO_EXP, MACRO_EOA } },
661 { "ldif" emit_ldiq, NULL,
662 { MACRO_FPR, MACRO_EXP, MACRO_EOA } },
663 { "ldid" emit_ldiq, NULL,
664 { MACRO_FPR, MACRO_EXP, MACRO_EOA } },
665 { "ldig" emit_ldiq, NULL,
666 { MACRO_FPR, MACRO_EXP, MACRO_EOA } },
667 { "ldis" emit_ldiq, NULL,
668 { MACRO_FPR, MACRO_EXP, MACRO_EOA } },
669 { "ldit" emit_ldiq, NULL,
670 { MACRO_FPR, MACRO_EXP, MACRO_EOA } },
673 { "stl", emit_loadstore, "stl",
674 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
675 { "stl_c", emit_loadstore, "stl_c",
676 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
677 { "stq", emit_loadstore, "stq",
678 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
679 { "stq_c", emit_loadstore, "stq_c",
680 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
681 { "stq_u", emit_loadstore, "stq_u",
682 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
683 { "stf", emit_loadstore, "stf",
684 { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
685 { "stg", emit_loadstore, "stg",
686 { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
687 { "sts", emit_loadstore, "sts",
688 { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
689 { "stt", emit_loadstore, "stt",
690 { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
692 { "stb", emit_stX, (PTR) 0,
693 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
694 { "stw", emit_stX, (PTR) 1,
695 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
696 { "ustw", emit_ustX, (PTR) 1,
697 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
698 { "ustl", emit_ustX, (PTR) 2,
699 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
700 { "ustq", emit_ustX, (PTR) 3,
701 { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } },
703 /* Arithmetic macros */
705 { "absl" emit_absl, 1, { IR } },
706 { "absl" emit_absl, 2, { IR, IR } },
707 { "absl" emit_absl, 2, { EXP, IR } },
708 { "absq" emit_absq, 1, { IR } },
709 { "absq" emit_absq, 2, { IR, IR } },
710 { "absq" emit_absq, 2, { EXP, IR } },
713 { "sextb", emit_sextX, (PTR) 0,
714 { MACRO_IR, MACRO_IR, MACRO_EOA,
716 /* MACRO_EXP, MACRO_IR, MACRO_EOA */ } },
717 { "sextw", emit_sextX, (PTR) 1,
718 { MACRO_IR, MACRO_IR, MACRO_EOA,
720 /* MACRO_EXP, MACRO_IR, MACRO_EOA */ } },
722 { "divl", emit_division, "__divl",
723 { MACRO_IR, MACRO_IR, MACRO_IR, MACRO_EOA,
724 MACRO_IR, MACRO_IR, MACRO_EOA,
725 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
726 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
727 { "divlu", emit_division, "__divlu",
728 { MACRO_IR, MACRO_IR, MACRO_IR, MACRO_EOA,
729 MACRO_IR, MACRO_IR, MACRO_EOA,
730 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
731 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
732 { "divq", emit_division, "__divq",
733 { MACRO_IR, MACRO_IR, MACRO_IR, MACRO_EOA,
734 MACRO_IR, MACRO_IR, MACRO_EOA,
735 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
736 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
737 { "divqu", emit_division, "__divqu",
738 { MACRO_IR, MACRO_IR, MACRO_IR, MACRO_EOA,
739 MACRO_IR, MACRO_IR, MACRO_EOA,
740 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
741 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
742 { "reml", emit_division, "__reml",
743 { MACRO_IR, MACRO_IR, MACRO_IR, MACRO_EOA,
744 MACRO_IR, MACRO_IR, MACRO_EOA,
745 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
746 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
747 { "remlu", emit_division, "__remlu",
748 { MACRO_IR, MACRO_IR, MACRO_IR, MACRO_EOA,
749 MACRO_IR, MACRO_IR, MACRO_EOA,
750 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
751 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
752 { "remq", emit_division, "__remq",
753 { MACRO_IR, MACRO_IR, MACRO_IR, MACRO_EOA,
754 MACRO_IR, MACRO_IR, MACRO_EOA,
755 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
756 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
757 { "remqu", emit_division, "__remqu",
758 { MACRO_IR, MACRO_IR, MACRO_IR, MACRO_EOA,
759 MACRO_IR, MACRO_IR, MACRO_EOA,
760 /* MACRO_IR, MACRO_EXP, MACRO_IR, MACRO_EOA,
761 MACRO_IR, MACRO_EXP, MACRO_EOA */ } },
763 { "jsr", emit_jsrjmp, "jsr",
764 { MACRO_PIR, MACRO_EXP, MACRO_JSR, MACRO_EOA,
765 MACRO_PIR, MACRO_JSR, MACRO_EOA,
766 MACRO_IR, MACRO_EXP, MACRO_JSR, MACRO_EOA,
767 MACRO_EXP, MACRO_JSR, MACRO_EOA } },
768 { "jmp", emit_jsrjmp, "jmp",
769 { MACRO_PIR, MACRO_EXP, MACRO_JSR, MACRO_EOA,
770 MACRO_PIR, MACRO_JSR, MACRO_EOA,
771 MACRO_IR, MACRO_EXP, MACRO_JSR, MACRO_EOA,
772 MACRO_EXP, MACRO_JSR, MACRO_EOA } },
773 { "ret", emit_retjcr, "ret",
774 { MACRO_IR, MACRO_EXP, MACRO_EOA,
776 MACRO_PIR, MACRO_EXP, MACRO_EOA,
777 MACRO_PIR, MACRO_EOA,
778 MACRO_EXP, MACRO_EOA,
780 { "jcr", emit_retjcr, "jcr",
781 { MACRO_IR, MACRO_EXP, MACRO_EOA,
783 MACRO_PIR, MACRO_EXP, MACRO_EOA,
784 MACRO_PIR, MACRO_EOA,
785 MACRO_EXP, MACRO_EOA,
787 { "jsr_coroutine", emit_retjcr, "jcr",
788 { MACRO_IR, MACRO_EXP, MACRO_EOA,
790 MACRO_PIR, MACRO_EXP, MACRO_EOA,
791 MACRO_PIR, MACRO_EOA,
792 MACRO_EXP, MACRO_EOA,
796 static const unsigned int alpha_num_macros
797 = sizeof (alpha_macros) / sizeof (*alpha_macros);
799 /* Public interface functions */
801 /* This function is called once, at assembler startup time. It sets
802 up all the tables, etc. that the MD part of the assembler will
803 need, that can be determined before arguments are parsed. */
810 /* Verify that X_op field is wide enough. */
814 assert (e.X_op == O_max);
817 /* Create the opcode hash table */
819 alpha_opcode_hash = hash_new ();
820 for (i = 0; i < alpha_num_opcodes;)
822 const char *name, *retval, *slash;
824 name = alpha_opcodes[i].name;
825 retval = hash_insert (alpha_opcode_hash, name, (PTR) &alpha_opcodes[i]);
827 as_fatal (_("internal error: can't hash opcode `%s': %s"), name, retval);
829 /* Some opcodes include modifiers of various sorts with a "/mod"
830 syntax, like the architecture manual suggests. However, for
831 use with gcc at least, we also need access to those same opcodes
834 if ((slash = strchr (name, '/')) != NULL)
836 char *p = xmalloc (strlen (name));
837 memcpy (p, name, slash - name);
838 strcpy (p + (slash - name), slash + 1);
840 (void) hash_insert (alpha_opcode_hash, p, (PTR) &alpha_opcodes[i]);
841 /* Ignore failures -- the opcode table does duplicate some
842 variants in different forms, like "hw_stq" and "hw_st/q". */
845 while (++i < alpha_num_opcodes
846 && (alpha_opcodes[i].name == name
847 || !strcmp (alpha_opcodes[i].name, name)))
851 /* Create the macro hash table */
853 alpha_macro_hash = hash_new ();
854 for (i = 0; i < alpha_num_macros;)
856 const char *name, *retval;
858 name = alpha_macros[i].name;
859 retval = hash_insert (alpha_macro_hash, name, (PTR) &alpha_macros[i]);
861 as_fatal (_("internal error: can't hash macro `%s': %s"),
864 while (++i < alpha_num_macros
865 && (alpha_macros[i].name == name
866 || !strcmp (alpha_macros[i].name, name)))
870 /* Construct symbols for each of the registers */
872 for (i = 0; i < 32; ++i)
875 sprintf (name, "$%d", i);
876 alpha_register_table[i] = symbol_create (name, reg_section, i,
882 sprintf (name, "$f%d", i - 32);
883 alpha_register_table[i] = symbol_create (name, reg_section, i,
887 /* Create the special symbols and sections we'll be using */
889 /* So .sbss will get used for tiny objects. */
890 bfd_set_gp_size (stdoutput, g_switch_value);
893 create_literal_section (".lita", &alpha_lita_section, &alpha_lita_symbol);
895 /* For handling the GP, create a symbol that won't be output in the
896 symbol table. We'll edit it out of relocs later. */
897 alpha_gp_symbol = symbol_create ("<GP value>", alpha_lita_section, 0x8000,
902 create_literal_section (".link", &alpha_link_section, &alpha_link_symbol);
908 segT sec = subseg_new (".mdebug", (subsegT) 0);
909 bfd_set_section_flags (stdoutput, sec, SEC_HAS_CONTENTS | SEC_READONLY);
910 bfd_set_section_alignment (stdoutput, sec, 3);
914 subseg_set (text_section, 0);
917 /* Create literal lookup hash table. */
918 alpha_literal_hash = hash_new ();
922 /* The public interface to the instruction assembler. */
928 char opname[32]; /* current maximum is 13 */
929 expressionS tok[MAX_INSN_ARGS];
933 /* split off the opcode */
934 opnamelen = strspn (str, "abcdefghijklmnopqrstuvwxyz_/46819");
935 trunclen = (opnamelen < sizeof (opname) - 1
937 : sizeof (opname) - 1);
938 memcpy (opname, str, trunclen);
939 opname[trunclen] = '\0';
941 /* tokenize the rest of the line */
942 if ((ntok = tokenize_arguments (str + opnamelen, tok, MAX_INSN_ARGS)) < 0)
944 if (ntok != TOKENIZE_ERROR_REPORT)
945 as_bad (_("syntax error"));
951 assemble_tokens (opname, tok, ntok, alpha_macros_on);
954 /* Round up a section's size to the appropriate boundary. */
957 md_section_align (seg, size)
961 int align = bfd_get_section_alignment (stdoutput, seg);
962 valueT mask = ((valueT) 1 << align) - 1;
964 return (size + mask) & ~mask;
967 /* Turn a string in input_line_pointer into a floating point constant
968 of type TYPE, and store the appropriate bytes in *LITP. The number
969 of LITTLENUMS emitted is stored in *SIZEP. An error message is
970 returned, or NULL on OK. */
972 /* Equal to MAX_PRECISION in atof-ieee.c */
973 #define MAX_LITTLENUMS 6
975 extern char *vax_md_atof PARAMS ((int, char *, int *));
978 md_atof (type, litP, sizeP)
984 LITTLENUM_TYPE words[MAX_LITTLENUMS];
985 LITTLENUM_TYPE *wordP;
992 /* VAX md_atof doesn't like "G" for some reason. */
996 return vax_md_atof (type, litP, sizeP);
1019 return _("Bad call to MD_ATOF()");
1021 t = atof_ieee (input_line_pointer, type, words);
1023 input_line_pointer = t;
1024 *sizeP = prec * sizeof (LITTLENUM_TYPE);
1026 for (wordP = words + prec - 1; prec--;)
1028 md_number_to_chars (litP, (long) (*wordP--), sizeof (LITTLENUM_TYPE));
1029 litP += sizeof (LITTLENUM_TYPE);
1035 /* Take care of the target-specific command-line options. */
1038 md_parse_option (c, arg)
1045 alpha_nofloats_on = 1;
1049 alpha_addr32_on = 1;
1057 g_switch_value = atoi (arg);
1062 const struct cpu_type *p;
1063 for (p = cpu_types; p->name; ++p)
1064 if (strcmp (arg, p->name) == 0)
1066 alpha_target_name = p->name, alpha_target = p->flags;
1069 as_warn (_("Unknown CPU identifier `%s'"), arg);
1075 case '+': /* For g++. Hash any name > 63 chars long. */
1076 alpha_flag_hash_long_names = 1;
1079 case 'H': /* Show new symbol after hash truncation */
1080 alpha_flag_show_after_trunc = 1;
1083 case 'h': /* for gnu-c/vax compatibility. */
1088 alpha_flag_relax = 1;
1093 alpha_flag_mdebug = 1;
1095 case OPTION_NO_MDEBUG:
1096 alpha_flag_mdebug = 0;
1107 /* Print a description of the command-line options that we accept. */
1110 md_show_usage (stream)
1115 -32addr treat addresses as 32-bit values\n\
1116 -F lack floating point instructions support\n\
1117 -mev4 | -mev45 | -mev5 | -mev56 | -mpca56 | -mev6 | -mall\n\
1118 specify variant of Alpha architecture\n\
1119 -m21064 | -m21066 | -m21164 | -m21164a | -m21164pc | -m21264\n\
1120 these variants include PALcode opcodes\n"),
1125 -+ hash encode (don't truncate) names longer than 64 characters\n\
1126 -H show new symbol after hash truncation\n"),
1131 /* Decide from what point a pc-relative relocation is relative to,
1132 relative to the pc-relative fixup. Er, relatively speaking. */
1135 md_pcrel_from (fixP)
1138 valueT addr = fixP->fx_where + fixP->fx_frag->fr_address;
1139 switch (fixP->fx_r_type)
1141 case BFD_RELOC_ALPHA_GPDISP:
1142 case BFD_RELOC_ALPHA_GPDISP_HI16:
1143 case BFD_RELOC_ALPHA_GPDISP_LO16:
1146 return fixP->fx_size + addr;
1150 /* Attempt to simplify or even eliminate a fixup. The return value is
1151 ignored; perhaps it was once meaningful, but now it is historical.
1152 To indicate that a fixup has been eliminated, set fixP->fx_done.
1154 For ELF, here it is that we transform the GPDISP_HI16 reloc we used
1155 internally into the GPDISP reloc used externally. We had to do
1156 this so that we'd have the GPDISP_LO16 reloc as a tag to compute
1157 the distance to the "lda" instruction for setting the addend to
1161 md_apply_fix (fixP, valueP)
1165 char * const fixpos = fixP->fx_frag->fr_literal + fixP->fx_where;
1166 valueT value = *valueP;
1167 unsigned image, size;
1169 switch (fixP->fx_r_type)
1171 /* The GPDISP relocations are processed internally with a symbol
1172 referring to the current function; we need to drop in a value
1173 which, when added to the address of the start of the function,
1174 gives the desired GP. */
1175 case BFD_RELOC_ALPHA_GPDISP_HI16:
1177 fixS *next = fixP->fx_next;
1178 assert (next->fx_r_type == BFD_RELOC_ALPHA_GPDISP_LO16);
1180 fixP->fx_offset = (next->fx_frag->fr_address + next->fx_where
1181 - fixP->fx_frag->fr_address - fixP->fx_where);
1183 value = (value - sign_extend_16 (value)) >> 16;
1186 fixP->fx_r_type = BFD_RELOC_ALPHA_GPDISP;
1190 case BFD_RELOC_ALPHA_GPDISP_LO16:
1191 value = sign_extend_16 (value);
1192 fixP->fx_offset = 0;
1198 fixP->fx_addsy = section_symbol (now_seg);
1199 md_number_to_chars (fixpos, value, 2);
1204 fixP->fx_r_type = BFD_RELOC_16_PCREL;
1209 fixP->fx_r_type = BFD_RELOC_32_PCREL;
1214 fixP->fx_r_type = BFD_RELOC_64_PCREL;
1217 if (fixP->fx_pcrel == 0 && fixP->fx_addsy == 0)
1219 md_number_to_chars (fixpos, value, size);
1225 case BFD_RELOC_GPREL32:
1226 assert (fixP->fx_subsy == alpha_gp_symbol);
1228 /* FIXME: inherited this obliviousness of `value' -- why? */
1229 md_number_to_chars (fixpos, -alpha_gp_value, 4);
1233 case BFD_RELOC_GPREL32:
1237 case BFD_RELOC_23_PCREL_S2:
1238 if (fixP->fx_pcrel == 0 && fixP->fx_addsy == 0)
1240 image = bfd_getl32 (fixpos);
1241 image = (image & ~0x1FFFFF) | ((value >> 2) & 0x1FFFFF);
1246 case BFD_RELOC_ALPHA_HINT:
1247 if (fixP->fx_pcrel == 0 && fixP->fx_addsy == 0)
1249 image = bfd_getl32 (fixpos);
1250 image = (image & ~0x3FFF) | ((value >> 2) & 0x3FFF);
1256 case BFD_RELOC_ALPHA_LITERAL:
1257 md_number_to_chars (fixpos, value, 2);
1260 case BFD_RELOC_ALPHA_LITUSE:
1264 case BFD_RELOC_ALPHA_ELF_LITERAL:
1265 case BFD_RELOC_ALPHA_LITUSE:
1269 case BFD_RELOC_ALPHA_LINKAGE:
1270 case BFD_RELOC_ALPHA_CODEADDR:
1275 case BFD_RELOC_ALPHA_USER_LITERAL:
1276 case BFD_RELOC_ALPHA_USER_LITUSE_BASE:
1277 case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF:
1278 case BFD_RELOC_ALPHA_USER_LITUSE_JSR:
1281 case BFD_RELOC_ALPHA_USER_GPDISP:
1282 case BFD_RELOC_ALPHA_USER_GPRELHIGH:
1283 case BFD_RELOC_ALPHA_USER_GPRELLOW:
1287 case BFD_RELOC_VTABLE_INHERIT:
1288 case BFD_RELOC_VTABLE_ENTRY:
1293 const struct alpha_operand *operand;
1295 if ((int) fixP->fx_r_type >= 0)
1296 as_fatal (_("unhandled relocation type %s"),
1297 bfd_get_reloc_code_name (fixP->fx_r_type));
1299 assert (-(int) fixP->fx_r_type < (int) alpha_num_operands);
1300 operand = &alpha_operands[-(int) fixP->fx_r_type];
1302 /* The rest of these fixups only exist internally during symbol
1303 resolution and have no representation in the object file.
1304 Therefore they must be completely resolved as constants. */
1306 if (fixP->fx_addsy != 0
1307 && S_GET_SEGMENT (fixP->fx_addsy) != absolute_section)
1308 as_bad_where (fixP->fx_file, fixP->fx_line,
1309 _("non-absolute expression in constant field"));
1311 image = bfd_getl32 (fixpos);
1312 image = insert_operand (image, operand, (offsetT) value,
1313 fixP->fx_file, fixP->fx_line);
1318 if (fixP->fx_addsy != 0 || fixP->fx_pcrel != 0)
1322 as_warn_where (fixP->fx_file, fixP->fx_line,
1323 _("type %d reloc done?\n"), (int) fixP->fx_r_type);
1328 md_number_to_chars (fixpos, image, 4);
1336 * Look for a register name in the given symbol.
1340 md_undefined_symbol (name)
1345 int is_float = 0, num;
1350 if (name[1] == 'p' && name[2] == '\0')
1351 return alpha_register_table[AXP_REG_FP];
1356 if (!isdigit (*++name))
1360 case '0': case '1': case '2': case '3': case '4':
1361 case '5': case '6': case '7': case '8': case '9':
1362 if (name[1] == '\0')
1363 num = name[0] - '0';
1364 else if (name[0] != '0' && isdigit (name[1]) && name[2] == '\0')
1366 num = (name[0] - '0') * 10 + name[1] - '0';
1373 if (!alpha_noat_on && (num + is_float) == AXP_REG_AT)
1374 as_warn (_("Used $at without \".set noat\""));
1375 return alpha_register_table[num + is_float];
1378 if (name[1] == 't' && name[2] == '\0')
1381 as_warn (_("Used $at without \".set noat\""));
1382 return alpha_register_table[AXP_REG_AT];
1387 if (name[1] == 'p' && name[2] == '\0')
1388 return alpha_register_table[alpha_gp_register];
1392 if (name[1] == 'p' && name[2] == '\0')
1393 return alpha_register_table[AXP_REG_SP];
1401 /* @@@ Magic ECOFF bits. */
1404 alpha_frob_ecoff_data ()
1407 /* $zero and $f31 are read-only */
1408 alpha_gprmask &= ~1;
1409 alpha_fprmask &= ~1;
1413 /* Hook to remember a recently defined label so that the auto-align
1414 code can adjust the symbol after we know what alignment will be
1418 alpha_define_label (sym)
1421 alpha_insn_label = sym;
1424 /* Return true if we must always emit a reloc for a type and false if
1425 there is some hope of resolving it a assembly time. */
1428 alpha_force_relocation (f)
1431 if (alpha_flag_relax)
1434 switch (f->fx_r_type)
1436 case BFD_RELOC_ALPHA_GPDISP_HI16:
1437 case BFD_RELOC_ALPHA_GPDISP_LO16:
1438 case BFD_RELOC_ALPHA_GPDISP:
1440 case BFD_RELOC_ALPHA_LITERAL:
1443 case BFD_RELOC_ALPHA_ELF_LITERAL:
1445 case BFD_RELOC_ALPHA_LITUSE:
1446 case BFD_RELOC_GPREL32:
1448 case BFD_RELOC_ALPHA_LINKAGE:
1449 case BFD_RELOC_ALPHA_CODEADDR:
1452 case BFD_RELOC_ALPHA_USER_LITERAL:
1453 case BFD_RELOC_ALPHA_USER_LITUSE_BASE:
1454 case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF:
1455 case BFD_RELOC_ALPHA_USER_LITUSE_JSR:
1456 case BFD_RELOC_ALPHA_USER_GPDISP:
1457 case BFD_RELOC_ALPHA_USER_GPRELHIGH:
1458 case BFD_RELOC_ALPHA_USER_GPRELLOW:
1460 case BFD_RELOC_VTABLE_INHERIT:
1461 case BFD_RELOC_VTABLE_ENTRY:
1464 case BFD_RELOC_23_PCREL_S2:
1467 case BFD_RELOC_ALPHA_HINT:
1471 assert ((int) f->fx_r_type < 0
1472 && -(int) f->fx_r_type < (int) alpha_num_operands);
1477 /* Return true if we can partially resolve a relocation now. */
1480 alpha_fix_adjustable (f)
1484 /* Prevent all adjustments to global symbols */
1485 if (S_IS_EXTERN (f->fx_addsy) || S_IS_WEAK (f->fx_addsy))
1489 /* Are there any relocation types for which we must generate a reloc
1490 but we can adjust the values contained within it? */
1491 switch (f->fx_r_type)
1493 case BFD_RELOC_ALPHA_GPDISP_HI16:
1494 case BFD_RELOC_ALPHA_GPDISP_LO16:
1495 case BFD_RELOC_ALPHA_GPDISP:
1499 case BFD_RELOC_ALPHA_LITERAL:
1502 case BFD_RELOC_ALPHA_ELF_LITERAL:
1505 case BFD_RELOC_ALPHA_USER_LITERAL:
1508 case BFD_RELOC_ALPHA_LINKAGE:
1509 case BFD_RELOC_ALPHA_CODEADDR:
1513 case BFD_RELOC_ALPHA_LITUSE:
1515 case BFD_RELOC_ALPHA_USER_LITUSE_BASE:
1516 case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF:
1517 case BFD_RELOC_ALPHA_USER_LITUSE_JSR:
1518 case BFD_RELOC_ALPHA_USER_GPDISP:
1519 case BFD_RELOC_ALPHA_USER_GPRELHIGH:
1520 case BFD_RELOC_ALPHA_USER_GPRELLOW:
1522 case BFD_RELOC_VTABLE_ENTRY:
1523 case BFD_RELOC_VTABLE_INHERIT:
1526 case BFD_RELOC_GPREL32:
1527 case BFD_RELOC_23_PCREL_S2:
1530 case BFD_RELOC_ALPHA_HINT:
1534 assert ((int) f->fx_r_type < 0
1535 && - (int) f->fx_r_type < (int) alpha_num_operands);
1541 /* Generate the BFD reloc to be stuck in the object file from the
1542 fixup used internally in the assembler. */
1545 tc_gen_reloc (sec, fixp)
1546 asection *sec ATTRIBUTE_UNUSED;
1551 reloc = (arelent *) xmalloc (sizeof (arelent));
1552 reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
1553 *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
1554 reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
1556 /* Make sure none of our internal relocations make it this far.
1557 They'd better have been fully resolved by this point. */
1558 assert ((int) fixp->fx_r_type > 0);
1560 reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
1561 if (reloc->howto == NULL)
1563 as_bad_where (fixp->fx_file, fixp->fx_line,
1564 _("cannot represent `%s' relocation in object file"),
1565 bfd_get_reloc_code_name (fixp->fx_r_type));
1569 if (!fixp->fx_pcrel != !reloc->howto->pc_relative)
1571 as_fatal (_("internal error? cannot generate `%s' relocation"),
1572 bfd_get_reloc_code_name (fixp->fx_r_type));
1574 assert (!fixp->fx_pcrel == !reloc->howto->pc_relative);
1577 if (fixp->fx_r_type == BFD_RELOC_ALPHA_LITERAL)
1579 /* fake out bfd_perform_relocation. sigh */
1580 reloc->addend = -alpha_gp_value;
1585 reloc->addend = fixp->fx_offset;
1588 * Ohhh, this is ugly. The problem is that if this is a local global
1589 * symbol, the relocation will entirely be performed at link time, not
1590 * at assembly time. bfd_perform_reloc doesn't know about this sort
1591 * of thing, and as a result we need to fake it out here.
1593 if ((S_IS_EXTERN (fixp->fx_addsy) || S_IS_WEAK (fixp->fx_addsy))
1594 && !S_IS_COMMON (fixp->fx_addsy))
1595 reloc->addend -= symbol_get_bfdsym (fixp->fx_addsy)->value;
1602 /* Parse a register name off of the input_line and return a register
1603 number. Gets md_undefined_symbol above to do the register name
1606 Only called as a part of processing the ECOFF .frame directive. */
1609 tc_get_register (frame)
1610 int frame ATTRIBUTE_UNUSED;
1612 int framereg = AXP_REG_SP;
1615 if (*input_line_pointer == '$')
1617 char *s = input_line_pointer;
1618 char c = get_symbol_end ();
1619 symbolS *sym = md_undefined_symbol (s);
1621 *strchr (s, '\0') = c;
1622 if (sym && (framereg = S_GET_VALUE (sym)) <= 31)
1625 as_warn (_("frame reg expected, using $%d."), framereg);
1628 note_gpreg (framereg);
1632 /* This is called before the symbol table is processed. In order to
1633 work with gcc when using mips-tfile, we must keep all local labels.
1634 However, in other cases, we want to discard them. If we were
1635 called with -g, but we didn't see any debugging information, it may
1636 mean that gcc is smuggling debugging information through to
1637 mips-tfile, in which case we must generate all local labels. */
1642 alpha_frob_file_before_adjust ()
1644 if (alpha_debug != 0
1645 && ! ecoff_debugging_seen)
1646 flag_keep_locals = 1;
1649 #endif /* OBJ_ECOFF */
1653 /* Before the relocations are written, reorder them, so that user
1654 supplied !lituse relocations follow the appropriate !literal
1655 relocations. Also convert the gas-internal relocations to the
1656 appropriate linker relocations. */
1659 alpha_adjust_symtab ()
1661 if (alpha_literal_hash)
1664 fprintf (stderr, "alpha_adjust_symtab called\n");
1667 /* Go over each section, reordering the relocations so that all
1668 of the explicit LITUSE's are adjacent to the explicit
1670 bfd_map_over_sections (stdoutput, alpha_adjust_symtab_relocs,
1675 /* Inner function to move LITUSE's next to the LITERAL. */
1678 alpha_adjust_symtab_relocs (abfd, sec, ptr)
1679 bfd *abfd ATTRIBUTE_UNUSED;
1681 PTR ptr ATTRIBUTE_UNUSED;
1683 segment_info_type *seginfo = seg_info (sec);
1693 int n_dup_literals = 0;
1696 /* If seginfo is NULL, we did not create this section; don't do
1697 anything with it. By using a pointer to a pointer, we can update
1698 the links in place. */
1699 if (seginfo == NULL)
1702 /* If there are no relocations, skip the section. */
1703 if (! seginfo->fix_root)
1706 /* First rebuild the fixup chain without the expicit lituse's. */
1707 prevP = &(seginfo->fix_root);
1708 for (fixp = seginfo->fix_root; fixp; fixp = next)
1710 next = fixp->fx_next;
1711 fixp->fx_next = (fixS *) 0;
1716 switch (fixp->fx_r_type)
1720 prevP = &(fixp->fx_next);
1723 "alpha_adjust_symtab_relocs: 0x%lx, other relocation %s\n",
1725 bfd_get_reloc_code_name (fixp->fx_r_type));
1729 case BFD_RELOC_ALPHA_USER_LITERAL:
1731 prevP = &(fixp->fx_next);
1732 /* prevent assembler from trying to adjust the offset */
1735 if (fixp->tc_fix_data.info->n_literals != 1)
1738 "alpha_adjust_symtab_relocs: 0x%lx, !literal!%.6d, # literals = %2d\n",
1740 fixp->tc_fix_data.info->sequence,
1741 fixp->tc_fix_data.info->n_literals);
1745 /* do not link in lituse's */
1746 case BFD_RELOC_ALPHA_USER_LITUSE_BASE:
1747 case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF:
1748 case BFD_RELOC_ALPHA_USER_LITUSE_JSR:
1750 if (fixp->tc_fix_data.info->n_literals == 0)
1751 as_bad_where (fixp->fx_file, fixp->fx_line,
1752 _("No !literal!%d was found"),
1753 fixp->tc_fix_data.info->sequence);
1756 "alpha_adjust_symtab_relocs: 0x%lx, !lituse !%.6d, # lituses = %2d, next_lituse = 0x%lx\n",
1758 fixp->tc_fix_data.info->sequence,
1759 fixp->tc_fix_data.info->n_lituses,
1760 (long) fixp->tc_fix_data.next_lituse);
1766 /* If there were any lituses, go and add them to the chain, unless there is
1767 more than one !literal for a given sequence number. They are linked
1768 through the next_lituse field in reverse order, so as we go through the
1769 next_lituse chain, we effectively reverse the chain once again. If there
1770 was more than one !literal, we fall back to loading up the address w/o
1771 optimization. Also, if the !literals/!lituses are spread in different
1772 segments (happens in the Linux kernel semaphores), suppress the
1776 for (fixp = seginfo->fix_root; fixp; fixp = fixp->fx_next)
1778 switch (fixp->fx_r_type)
1783 case BFD_RELOC_ALPHA_USER_LITERAL:
1785 fixp->fx_r_type = BFD_RELOC_ALPHA_ELF_LITERAL;
1787 fixp->fx_r_type = BFD_RELOC_ALPHA_LITERAL; /* XXX check this */
1789 if (fixp->tc_fix_data.info->n_literals == 1
1790 && ! fixp->tc_fix_data.info->multi_section_p)
1792 for (lituse = fixp->tc_fix_data.info->lituse;
1793 lituse != (fixS *) 0;
1794 lituse = lituse->tc_fix_data.next_lituse)
1796 lituse->fx_next = fixp->fx_next;
1797 fixp->fx_next = lituse;
1802 case BFD_RELOC_ALPHA_USER_LITUSE_BASE:
1803 case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF:
1804 case BFD_RELOC_ALPHA_USER_LITUSE_JSR:
1805 fixp->fx_r_type = BFD_RELOC_ALPHA_LITUSE;
1812 fprintf (stderr, "alpha_adjust_symtab_relocs: %s, %d literal%s, %d duplicate literal%s, %d lituse%s\n\n",
1814 n_literals, (n_literals == 1) ? "" : "s",
1815 n_dup_literals, (n_dup_literals == 1) ? "" : "s",
1816 n_lituses, (n_lituses == 1) ? "" : "s");
1820 #endif /* RELOC_OP_P */
1824 debug_exp (tok, ntok)
1830 fprintf (stderr, "debug_exp: %d tokens", ntok);
1831 for (i = 0; i < ntok; i++)
1833 expressionS *t = &tok[i];
1837 default: name = "unknown"; break;
1838 case O_illegal: name = "O_illegal"; break;
1839 case O_absent: name = "O_absent"; break;
1840 case O_constant: name = "O_constant"; break;
1841 case O_symbol: name = "O_symbol"; break;
1842 case O_symbol_rva: name = "O_symbol_rva"; break;
1843 case O_register: name = "O_register"; break;
1844 case O_big: name = "O_big"; break;
1845 case O_uminus: name = "O_uminus"; break;
1846 case O_bit_not: name = "O_bit_not"; break;
1847 case O_logical_not: name = "O_logical_not"; break;
1848 case O_multiply: name = "O_multiply"; break;
1849 case O_divide: name = "O_divide"; break;
1850 case O_modulus: name = "O_modulus"; break;
1851 case O_left_shift: name = "O_left_shift"; break;
1852 case O_right_shift: name = "O_right_shift"; break;
1853 case O_bit_inclusive_or: name = "O_bit_inclusive_or"; break;
1854 case O_bit_or_not: name = "O_bit_or_not"; break;
1855 case O_bit_exclusive_or: name = "O_bit_exclusive_or"; break;
1856 case O_bit_and: name = "O_bit_and"; break;
1857 case O_add: name = "O_add"; break;
1858 case O_subtract: name = "O_subtract"; break;
1859 case O_eq: name = "O_eq"; break;
1860 case O_ne: name = "O_ne"; break;
1861 case O_lt: name = "O_lt"; break;
1862 case O_le: name = "O_le"; break;
1863 case O_ge: name = "O_ge"; break;
1864 case O_gt: name = "O_gt"; break;
1865 case O_logical_and: name = "O_logical_and"; break;
1866 case O_logical_or: name = "O_logical_or"; break;
1867 case O_index: name = "O_index"; break;
1868 case O_pregister: name = "O_pregister"; break;
1869 case O_cpregister: name = "O_cpregister"; break;
1870 case O_literal: name = "O_literal"; break;
1871 case O_lituse_base: name = "O_lituse_base"; break;
1872 case O_lituse_bytoff: name = "O_lituse_bytoff"; break;
1873 case O_lituse_jsr: name = "O_lituse_jsr"; break;
1874 case O_gpdisp: name = "O_gpdisp"; break;
1875 case O_gprelhigh: name = "O_gprelhigh"; break;
1876 case O_gprellow: name = "O_gprellow"; break;
1877 case O_md10: name = "O_md10"; break;
1878 case O_md11: name = "O_md11"; break;
1879 case O_md12: name = "O_md12"; break;
1880 case O_md13: name = "O_md13"; break;
1881 case O_md14: name = "O_md14"; break;
1882 case O_md15: name = "O_md15"; break;
1883 case O_md16: name = "O_md16"; break;
1886 fprintf (stderr, ", %s(%s, %s, %d)", name,
1887 (t->X_add_symbol) ? S_GET_NAME (t->X_add_symbol) : "--",
1888 (t->X_op_symbol) ? S_GET_NAME (t->X_op_symbol) : "--",
1889 (int) t->X_add_number);
1891 fprintf (stderr, "\n");
1896 /* Parse the arguments to an opcode. */
1899 tokenize_arguments (str, tok, ntok)
1904 expressionS *end_tok = tok + ntok;
1905 char *old_input_line_pointer;
1906 int saw_comma = 0, saw_arg = 0;
1908 expressionS *orig_tok = tok;
1912 const struct alpha_reloc_op_tag *r;
1915 int reloc_found_p = 0;
1918 memset (tok, 0, sizeof (*tok) * ntok);
1920 /* Save and restore input_line_pointer around this function */
1921 old_input_line_pointer = input_line_pointer;
1922 input_line_pointer = str;
1924 while (tok < end_tok && *input_line_pointer)
1927 switch (*input_line_pointer)
1934 /* A relocation operand can be placed after the normal operand on an
1935 assembly language statement, and has the following form:
1936 !relocation_type!sequence_number. */
1938 { /* only support one relocation op per insn */
1939 as_bad (_("More than one relocation op per insn"));
1946 for (p = ++input_line_pointer;
1947 ((c = *p) != '!' && c != ';' && c != '#' && c != ','
1948 && !is_end_of_line[c]);
1952 /* Parse !relocation_type */
1953 len = p - input_line_pointer;
1956 as_bad (_("No relocation operand"));
1962 as_bad (_("No !sequence-number after !%s"), input_line_pointer);
1966 r = &alpha_reloc_op[0];
1967 for (i = alpha_num_reloc_op - 1; i >= 0; i--, r++)
1969 if (len == r->length
1970 && memcmp (input_line_pointer, r->name, len) == 0)
1975 as_bad (_("Unknown relocation operand: !%s"),
1976 input_line_pointer);
1980 input_line_pointer = ++p;
1982 /* Parse !sequence_number */
1983 memset (tok, '\0', sizeof (expressionS));
1986 if (tok->X_op != O_constant
1987 || ! ALPHA_RELOC_SEQUENCE_OK (tok->X_add_number))
1989 as_bad (_("Bad sequence number: !%s!%s"),
1990 r->name, input_line_pointer);
2001 ++input_line_pointer;
2002 if (saw_comma || !saw_arg)
2009 char *hold = input_line_pointer++;
2011 /* First try for parenthesized register ... */
2013 if (*input_line_pointer == ')' && tok->X_op == O_register)
2015 tok->X_op = (saw_comma ? O_cpregister : O_pregister);
2018 ++input_line_pointer;
2023 /* ... then fall through to plain expression */
2024 input_line_pointer = hold;
2028 if (saw_arg && !saw_comma)
2032 if (tok->X_op == O_illegal || tok->X_op == O_absent)
2045 input_line_pointer = old_input_line_pointer;
2048 debug_exp (orig_tok, ntok - (end_tok - tok));
2051 return ntok - (end_tok - tok);
2054 input_line_pointer = old_input_line_pointer;
2055 return TOKENIZE_ERROR;
2059 input_line_pointer = old_input_line_pointer;
2060 return TOKENIZE_ERROR_REPORT;
2064 /* Search forward through all variants of an opcode looking for a
2067 static const struct alpha_opcode *
2068 find_opcode_match (first_opcode, tok, pntok, pcpumatch)
2069 const struct alpha_opcode *first_opcode;
2070 const expressionS *tok;
2074 const struct alpha_opcode *opcode = first_opcode;
2076 int got_cpu_match = 0;
2080 const unsigned char *opidx;
2083 /* Don't match opcodes that don't exist on this architecture */
2084 if (!(opcode->flags & alpha_target))
2089 for (opidx = opcode->operands; *opidx; ++opidx)
2091 const struct alpha_operand *operand = &alpha_operands[*opidx];
2093 /* only take input from real operands */
2094 if (operand->flags & AXP_OPERAND_FAKE)
2097 /* when we expect input, make sure we have it */
2100 if ((operand->flags & AXP_OPERAND_OPTIONAL_MASK) == 0)
2105 /* match operand type with expression type */
2106 switch (operand->flags & AXP_OPERAND_TYPECHECK_MASK)
2108 case AXP_OPERAND_IR:
2109 if (tok[tokidx].X_op != O_register
2110 || !is_ir_num (tok[tokidx].X_add_number))
2113 case AXP_OPERAND_FPR:
2114 if (tok[tokidx].X_op != O_register
2115 || !is_fpr_num (tok[tokidx].X_add_number))
2118 case AXP_OPERAND_IR | AXP_OPERAND_PARENS:
2119 if (tok[tokidx].X_op != O_pregister
2120 || !is_ir_num (tok[tokidx].X_add_number))
2123 case AXP_OPERAND_IR | AXP_OPERAND_PARENS | AXP_OPERAND_COMMA:
2124 if (tok[tokidx].X_op != O_cpregister
2125 || !is_ir_num (tok[tokidx].X_add_number))
2129 case AXP_OPERAND_RELATIVE:
2130 case AXP_OPERAND_SIGNED:
2131 case AXP_OPERAND_UNSIGNED:
2132 switch (tok[tokidx].X_op)
2147 /* everything else should have been fake */
2153 /* possible match -- did we use all of our input? */
2162 while (++opcode - alpha_opcodes < alpha_num_opcodes
2163 && !strcmp (opcode->name, first_opcode->name));
2166 *pcpumatch = got_cpu_match;
2171 /* Search forward through all variants of a macro looking for a syntax
2174 static const struct alpha_macro *
2175 find_macro_match (first_macro, tok, pntok)
2176 const struct alpha_macro *first_macro;
2177 const expressionS *tok;
2180 const struct alpha_macro *macro = first_macro;
2185 const enum alpha_macro_arg *arg = macro->argsets;
2199 /* index register */
2201 if (tokidx >= ntok || tok[tokidx].X_op != O_register
2202 || !is_ir_num (tok[tokidx].X_add_number))
2207 /* parenthesized index register */
2209 if (tokidx >= ntok || tok[tokidx].X_op != O_pregister
2210 || !is_ir_num (tok[tokidx].X_add_number))
2215 /* optional parenthesized index register */
2217 if (tokidx < ntok && tok[tokidx].X_op == O_pregister
2218 && is_ir_num (tok[tokidx].X_add_number))
2222 /* leading comma with a parenthesized index register */
2224 if (tokidx >= ntok || tok[tokidx].X_op != O_cpregister
2225 || !is_ir_num (tok[tokidx].X_add_number))
2230 /* floating point register */
2232 if (tokidx >= ntok || tok[tokidx].X_op != O_register
2233 || !is_fpr_num (tok[tokidx].X_add_number))
2238 /* normal expression */
2242 switch (tok[tokidx].X_op)
2252 case O_lituse_bytoff:
2266 /* optional !literal!<number> */
2269 if (tokidx < ntok && tok[tokidx].X_op == O_literal)
2274 /* optional !lituse_base!<number> */
2277 if (tokidx < ntok && tok[tokidx].X_op == O_lituse_base)
2282 /* optional !lituse_bytoff!<number> */
2285 if (tokidx < ntok && tok[tokidx].X_op == O_lituse_bytoff)
2290 /* optional !lituse_jsr!<number> */
2293 if (tokidx < ntok && tok[tokidx].X_op == O_lituse_jsr)
2299 while (*arg != MACRO_EOA)
2307 while (++macro - alpha_macros < alpha_num_macros
2308 && !strcmp (macro->name, first_macro->name));
2313 /* Insert an operand value into an instruction. */
2316 insert_operand (insn, operand, val, file, line)
2318 const struct alpha_operand *operand;
2323 if (operand->bits != 32 && !(operand->flags & AXP_OPERAND_NOOVERFLOW))
2327 if (operand->flags & AXP_OPERAND_SIGNED)
2329 max = (1 << (operand->bits - 1)) - 1;
2330 min = -(1 << (operand->bits - 1));
2334 max = (1 << operand->bits) - 1;
2338 if (val < min || val > max)
2341 _("operand out of range (%s not between %d and %d)");
2342 char buf[sizeof (val) * 3 + 2];
2344 sprint_value (buf, val);
2346 as_warn_where (file, line, err, buf, min, max);
2348 as_warn (err, buf, min, max);
2352 if (operand->insert)
2354 const char *errmsg = NULL;
2356 insn = (*operand->insert) (insn, val, &errmsg);
2361 insn |= ((val & ((1 << operand->bits) - 1)) << operand->shift);
2367 * Turn an opcode description and a set of arguments into
2368 * an instruction and a fixup.
2372 assemble_insn (opcode, tok, ntok, insn)
2373 const struct alpha_opcode *opcode;
2374 const expressionS *tok;
2376 struct alpha_insn *insn;
2378 const unsigned char *argidx;
2382 memset (insn, 0, sizeof (*insn));
2383 image = opcode->opcode;
2385 for (argidx = opcode->operands; *argidx; ++argidx)
2387 const struct alpha_operand *operand = &alpha_operands[*argidx];
2388 const expressionS *t = (const expressionS *) 0;
2390 if (operand->flags & AXP_OPERAND_FAKE)
2392 /* fake operands take no value and generate no fixup */
2393 image = insert_operand (image, operand, 0, NULL, 0);
2399 switch (operand->flags & AXP_OPERAND_OPTIONAL_MASK)
2401 case AXP_OPERAND_DEFAULT_FIRST:
2404 case AXP_OPERAND_DEFAULT_SECOND:
2407 case AXP_OPERAND_DEFAULT_ZERO:
2409 static expressionS zero_exp;
2411 zero_exp.X_op = O_constant;
2412 zero_exp.X_unsigned = 1;
2427 image = insert_operand (image, operand, regno (t->X_add_number),
2432 image = insert_operand (image, operand, t->X_add_number, NULL, 0);
2437 struct alpha_fixup *fixup;
2439 if (insn->nfixups >= MAX_INSN_FIXUPS)
2440 as_fatal (_("too many fixups"));
2442 fixup = &insn->fixups[insn->nfixups++];
2445 fixup->reloc = operand->default_reloc;
2455 * Actually output an instruction with its fixup.
2460 struct alpha_insn *insn;
2465 /* Take care of alignment duties. */
2466 if (alpha_auto_align_on && alpha_current_align < 2)
2467 alpha_align (2, (char *) NULL, alpha_insn_label, 0);
2468 if (alpha_current_align > 2)
2469 alpha_current_align = 2;
2470 alpha_insn_label = NULL;
2472 /* Write out the instruction. */
2474 md_number_to_chars (f, insn->insn, 4);
2477 dwarf2_emit_insn (4);
2480 /* Apply the fixups in order */
2481 for (i = 0; i < insn->nfixups; ++i)
2483 const struct alpha_operand *operand = (const struct alpha_operand *) 0;
2484 struct alpha_fixup *fixup = &insn->fixups[i];
2488 char buffer[ALPHA_RELOC_DIGITS];
2489 struct alpha_literal_tag *info;
2492 /* Some fixups are only used internally and so have no howto */
2493 if ((int) fixup->reloc < 0)
2495 operand = &alpha_operands[-(int) fixup->reloc];
2497 pcrel = ((operand->flags & AXP_OPERAND_RELATIVE) != 0);
2500 switch (fixup->reloc)
2503 /* These relocation types are only used internally. */
2504 case BFD_RELOC_ALPHA_GPDISP_HI16:
2505 case BFD_RELOC_ALPHA_GPDISP_LO16:
2511 /* and these also are internal only relocations */
2512 case BFD_RELOC_ALPHA_USER_LITERAL:
2513 case BFD_RELOC_ALPHA_USER_LITUSE_BASE:
2514 case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF:
2515 case BFD_RELOC_ALPHA_USER_LITUSE_JSR:
2516 case BFD_RELOC_ALPHA_USER_GPDISP:
2517 case BFD_RELOC_ALPHA_USER_GPRELHIGH:
2518 case BFD_RELOC_ALPHA_USER_GPRELLOW:
2526 reloc_howto_type *reloc_howto
2527 = bfd_reloc_type_lookup (stdoutput, fixup->reloc);
2528 assert (reloc_howto);
2530 size = bfd_get_reloc_size (reloc_howto);
2531 pcrel = reloc_howto->pc_relative;
2533 assert (size >= 1 && size <= 4);
2537 fixP = fix_new_exp (frag_now, f - frag_now->fr_literal, size,
2538 &fixup->exp, pcrel, fixup->reloc);
2540 /* Turn off complaints that the addend is too large for some fixups,
2541 and copy in the sequence number for the explicit relocations. */
2542 switch (fixup->reloc)
2544 case BFD_RELOC_ALPHA_GPDISP_LO16:
2546 case BFD_RELOC_ALPHA_LITERAL:
2549 case BFD_RELOC_ALPHA_ELF_LITERAL:
2551 case BFD_RELOC_GPREL32:
2552 fixP->fx_no_overflow = 1;
2556 case BFD_RELOC_ALPHA_USER_LITERAL:
2557 fixP->fx_no_overflow = 1;
2558 sprintf (buffer, "!%u", insn->sequence[i]);
2559 info = ((struct alpha_literal_tag *)
2560 hash_find (alpha_literal_hash, buffer));
2564 size_t len = strlen (buffer);
2567 info = ((struct alpha_literal_tag *)
2568 xcalloc (sizeof (struct alpha_literal_tag) + len, 1));
2570 info->segment = now_seg;
2571 info->sequence = insn->sequence[i];
2572 strcpy (info->string, buffer);
2573 errmsg = hash_insert (alpha_literal_hash, info->string, (PTR) info);
2580 if (info->segment != now_seg)
2581 info->multi_section_p = 1;
2583 fixP->tc_fix_data.info = info;
2586 case BFD_RELOC_ALPHA_USER_LITUSE_BASE:
2587 case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF:
2588 case BFD_RELOC_ALPHA_USER_LITUSE_JSR:
2589 sprintf (buffer, "!%u", insn->sequence[i]);
2590 info = ((struct alpha_literal_tag *)
2591 hash_find (alpha_literal_hash, buffer));
2595 size_t len = strlen (buffer);
2598 info = ((struct alpha_literal_tag *)
2599 xcalloc (sizeof (struct alpha_literal_tag) + len, 1));
2601 info->segment = now_seg;
2602 info->sequence = insn->sequence[i];
2603 strcpy (info->string, buffer);
2604 errmsg = hash_insert (alpha_literal_hash, info->string, (PTR) info);
2609 fixP->tc_fix_data.info = info;
2610 fixP->tc_fix_data.next_lituse = info->lituse;
2611 info->lituse = fixP;
2612 if (info->segment != now_seg)
2613 info->multi_section_p = 1;
2619 if ((int) fixup->reloc < 0)
2621 if (operand->flags & AXP_OPERAND_NOOVERFLOW)
2622 fixP->fx_no_overflow = 1;
2629 /* Given an opcode name and a pre-tokenized set of arguments, assemble
2630 the insn, but do not emit it.
2632 Note that this implies no macros allowed, since we can't store more
2633 than one insn in an insn structure. */
2636 assemble_tokens_to_insn (opname, tok, ntok, insn)
2638 const expressionS *tok;
2640 struct alpha_insn *insn;
2642 const struct alpha_opcode *opcode;
2644 /* search opcodes */
2645 opcode = (const struct alpha_opcode *) hash_find (alpha_opcode_hash, opname);
2649 opcode = find_opcode_match (opcode, tok, &ntok, &cpumatch);
2652 assemble_insn (opcode, tok, ntok, insn);
2656 as_bad (_("inappropriate arguments for opcode `%s'"), opname);
2658 as_bad (_("opcode `%s' not supported for target %s"), opname,
2662 as_bad (_("unknown opcode `%s'"), opname);
2665 /* Given an opcode name and a pre-tokenized set of arguments, take the
2666 opcode all the way through emission. */
2669 assemble_tokens (opname, tok, ntok, local_macros_on)
2671 const expressionS *tok;
2673 int local_macros_on;
2675 int found_something = 0;
2676 const struct alpha_opcode *opcode;
2677 const struct alpha_macro *macro;
2681 if (local_macros_on)
2683 macro = ((const struct alpha_macro *)
2684 hash_find (alpha_macro_hash, opname));
2687 found_something = 1;
2688 macro = find_macro_match (macro, tok, &ntok);
2691 (*macro->emit) (tok, ntok, macro->arg);
2698 if (ntok && USER_RELOC_P (tok[ntok - 1].X_op))
2700 const expressionS *reloc_exp = &tok[ntok - 1];
2701 const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op);
2702 as_bad (_("Cannot use !%s!%d with %s"), r->name,
2703 (int) reloc_exp->X_add_number, opname);
2708 /* search opcodes */
2709 opcode = (const struct alpha_opcode *) hash_find (alpha_opcode_hash, opname);
2712 found_something = 1;
2713 opcode = find_opcode_match (opcode, tok, &ntok, &cpumatch);
2716 struct alpha_insn insn;
2717 assemble_insn (opcode, tok, ntok, &insn);
2723 if (found_something)
2725 as_bad (_("inappropriate arguments for opcode `%s'"), opname);
2727 as_bad (_("opcode `%s' not supported for target %s"), opname,
2730 as_bad (_("unknown opcode `%s'"), opname);
2733 /* Some instruction sets indexed by lg(size) */
2734 static const char * const sextX_op[] = { "sextb", "sextw", "sextl", NULL };
2735 static const char * const insXl_op[] = { "insbl", "inswl", "insll", "insql" };
2736 static const char * const insXh_op[] = { NULL, "inswh", "inslh", "insqh" };
2737 static const char * const extXl_op[] = { "extbl", "extwl", "extll", "extql" };
2738 static const char * const extXh_op[] = { NULL, "extwh", "extlh", "extqh" };
2739 static const char * const mskXl_op[] = { "mskbl", "mskwl", "mskll", "mskql" };
2740 static const char * const mskXh_op[] = { NULL, "mskwh", "msklh", "mskqh" };
2741 static const char * const stX_op[] = { "stb", "stw", "stl", "stq" };
2742 static const char * const ldX_op[] = { "ldb", "ldw", "ldll", "ldq" };
2743 static const char * const ldXu_op[] = { "ldbu", "ldwu", NULL, NULL };
2745 /* Implement the ldgp macro. */
2748 emit_ldgp (tok, ntok, unused)
2749 const expressionS *tok;
2750 int ntok ATTRIBUTE_UNUSED;
2751 const PTR unused ATTRIBUTE_UNUSED;
2756 #if defined(OBJ_ECOFF) || defined(OBJ_ELF)
2757 /* from "ldgp r1,n(r2)", generate "ldah r1,X(R2); lda r1,Y(r1)"
2758 with appropriate constants and relocations. */
2759 struct alpha_insn insn;
2760 expressionS newtok[3];
2764 if (ntok && USER_RELOC_P (tok[ntok - 1].X_op))
2766 const expressionS *reloc_exp = &tok[ntok - 1];
2767 const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op);
2768 as_bad (_("Cannot use !%s!%d with %s"), r->name,
2769 (int) reloc_exp->X_add_number, "ldgp");
2775 if (regno (tok[2].X_add_number) == AXP_REG_PV)
2776 ecoff_set_gp_prolog_size (0);
2780 set_tok_const (newtok[1], 0);
2783 assemble_tokens_to_insn ("ldah", newtok, 3, &insn);
2788 if (addend.X_op != O_constant)
2789 as_bad (_("can not resolve expression"));
2790 addend.X_op = O_symbol;
2791 addend.X_add_symbol = alpha_gp_symbol;
2795 insn.fixups[0].exp = addend;
2796 insn.fixups[0].reloc = BFD_RELOC_ALPHA_GPDISP_HI16;
2800 set_tok_preg (newtok[2], tok[0].X_add_number);
2802 assemble_tokens_to_insn ("lda", newtok, 3, &insn);
2805 addend.X_add_number += 4;
2809 insn.fixups[0].exp = addend;
2810 insn.fixups[0].reloc = BFD_RELOC_ALPHA_GPDISP_LO16;
2813 #endif /* OBJ_ECOFF || OBJ_ELF */
2818 /* Add symbol+addend to link pool.
2819 Return offset from basesym to entry in link pool.
2821 Add new fixup only if offset isn't 16bit. */
2824 add_to_link_pool (basesym, sym, addend)
2829 segT current_section = now_seg;
2830 int current_subsec = now_subseg;
2832 bfd_reloc_code_real_type reloc_type;
2834 segment_info_type *seginfo = seg_info (alpha_link_section);
2837 offset = - *symbol_get_obj (basesym);
2839 /* @@ This assumes all entries in a given section will be of the same
2840 size... Probably correct, but unwise to rely on. */
2841 /* This must always be called with the same subsegment. */
2843 if (seginfo->frchainP)
2844 for (fixp = seginfo->frchainP->fix_root;
2845 fixp != (fixS *) NULL;
2846 fixp = fixp->fx_next, offset += 8)
2848 if (fixp->fx_addsy == sym && fixp->fx_offset == addend)
2850 if (range_signed_16 (offset))
2857 /* Not found in 16bit signed range. */
2859 subseg_set (alpha_link_section, 0);
2863 fix_new (frag_now, p - frag_now->fr_literal, 8, sym, addend, 0,
2866 subseg_set (current_section, current_subsec);
2867 seginfo->literal_pool_size += 8;
2871 #endif /* OBJ_EVAX */
2873 /* Load a (partial) expression into a target register.
2875 If poffset is not null, after the call it will either contain
2876 O_constant 0, or a 16-bit offset appropriate for any MEM format
2877 instruction. In addition, pbasereg will be modified to point to
2878 the base register to use in that MEM format instruction.
2880 In any case, *pbasereg should contain a base register to add to the
2881 expression. This will normally be either AXP_REG_ZERO or
2882 alpha_gp_register. Symbol addresses will always be loaded via $gp,
2883 so "foo($0)" is interpreted as adding the address of foo to $0;
2884 i.e. "ldq $targ, LIT($gp); addq $targ, $0, $targ". Odd, perhaps,
2885 but this is what OSF/1 does.
2887 If explicit relocations of the form !literal!<number> are allowed,
2888 and used, then explict_reloc with be an expression pointer.
2890 Finally, the return value is true if the calling macro may emit a
2891 LITUSE reloc if otherwise appropriate. */
2894 load_expression (targreg, exp, pbasereg, poffset, explicit_reloc)
2896 const expressionS *exp;
2898 expressionS *poffset;
2899 const expressionS *explicit_reloc;
2901 int emit_lituse = 0;
2902 offsetT addend = exp->X_add_number;
2903 int basereg = *pbasereg;
2904 struct alpha_insn insn;
2905 expressionS newtok[3];
2914 /* attempt to reduce .lit load by splitting the offset from
2915 its symbol when possible, but don't create a situation in
2917 if (!range_signed_32 (addend) &&
2918 (alpha_noat_on || targreg == AXP_REG_AT))
2920 lit = add_to_literal_pool (exp->X_add_symbol, addend,
2921 alpha_lita_section, 8);
2926 lit = add_to_literal_pool (exp->X_add_symbol, 0,
2927 alpha_lita_section, 8);
2931 as_fatal (_("overflow in literal (.lita) table"));
2933 /* emit "ldq r, lit(gp)" */
2935 if (basereg != alpha_gp_register && targreg == basereg)
2938 as_bad (_("macro requires $at register while noat in effect"));
2939 if (targreg == AXP_REG_AT)
2940 as_bad (_("macro requires $at while $at in use"));
2942 set_tok_reg (newtok[0], AXP_REG_AT);
2945 set_tok_reg (newtok[0], targreg);
2946 set_tok_sym (newtok[1], alpha_lita_symbol, lit);
2947 set_tok_preg (newtok[2], alpha_gp_register);
2949 assemble_tokens_to_insn ("ldq", newtok, 3, &insn);
2951 assert (explicit_reloc == (const expressionS *) 0);
2952 assert (insn.nfixups == 1);
2953 insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITERAL;
2954 #endif /* OBJ_ECOFF */
2956 /* emit "ldq r, gotoff(gp)" */
2958 if (basereg != alpha_gp_register && targreg == basereg)
2961 as_bad (_("macro requires $at register while noat in effect"));
2962 if (targreg == AXP_REG_AT)
2963 as_bad (_("macro requires $at while $at in use"));
2965 set_tok_reg (newtok[0], AXP_REG_AT);
2968 set_tok_reg (newtok[0], targreg);
2970 /* XXX: Disable this .got minimizing optimization so that we can get
2971 better instruction offset knowledge in the compiler. This happens
2972 very infrequently anyway. */
2974 || (!range_signed_32 (addend)
2975 && (alpha_noat_on || targreg == AXP_REG_AT)))
2982 set_tok_sym (newtok[1], exp->X_add_symbol, 0);
2985 set_tok_preg (newtok[2], alpha_gp_register);
2987 assemble_tokens_to_insn ("ldq", newtok, 3, &insn);
2989 assert (insn.nfixups == 1);
2990 if (!explicit_reloc)
2991 insn.fixups[0].reloc = BFD_RELOC_ALPHA_ELF_LITERAL;
2995 insn.fixups[0].reloc
2996 = (ALPHA_RELOC_TABLE (explicit_reloc->X_op))->reloc;
2997 insn.sequence[0] = explicit_reloc->X_add_number;
3002 #endif /* OBJ_ELF */
3006 /* Find symbol or symbol pointer in link section. */
3008 assert (explicit_reloc == (const expressionS *) 0);
3009 if (exp->X_add_symbol == alpha_evax_proc.symbol)
3011 if (range_signed_16 (addend))
3013 set_tok_reg (newtok[0], targreg);
3014 set_tok_const (newtok[1], addend);
3015 set_tok_preg (newtok[2], basereg);
3016 assemble_tokens_to_insn ("lda", newtok, 3, &insn);
3021 set_tok_reg (newtok[0], targreg);
3022 set_tok_const (newtok[1], 0);
3023 set_tok_preg (newtok[2], basereg);
3024 assemble_tokens_to_insn ("lda", newtok, 3, &insn);
3029 if (!range_signed_32 (addend))
3031 link = add_to_link_pool (alpha_evax_proc.symbol,
3032 exp->X_add_symbol, addend);
3037 link = add_to_link_pool (alpha_evax_proc.symbol,
3038 exp->X_add_symbol, 0);
3040 set_tok_reg (newtok[0], targreg);
3041 set_tok_const (newtok[1], link);
3042 set_tok_preg (newtok[2], basereg);
3043 assemble_tokens_to_insn ("ldq", newtok, 3, &insn);
3045 #endif /* OBJ_EVAX */
3052 if (basereg != alpha_gp_register && basereg != AXP_REG_ZERO)
3054 /* emit "addq r, base, r" */
3056 set_tok_reg (newtok[1], basereg);
3057 set_tok_reg (newtok[2], targreg);
3058 assemble_tokens ("addq", newtok, 3, 0);
3067 assert (explicit_reloc == (const expressionS *) 0);
3071 /* Assume that this difference expression will be resolved to an
3072 absolute value and that that value will fit in 16 bits. */
3074 assert (explicit_reloc == (const expressionS *) 0);
3075 set_tok_reg (newtok[0], targreg);
3077 set_tok_preg (newtok[2], basereg);
3078 assemble_tokens ("lda", newtok, 3, 0);
3081 set_tok_const (*poffset, 0);
3085 if (exp->X_add_number > 0)
3086 as_bad (_("bignum invalid; zero assumed"));
3088 as_bad (_("floating point number invalid; zero assumed"));
3093 as_bad (_("can't handle expression"));
3098 if (!range_signed_32 (addend))
3102 /* for 64-bit addends, just put it in the literal pool */
3105 /* emit "ldq targreg, lit(basereg)" */
3106 lit = add_to_link_pool (alpha_evax_proc.symbol,
3107 section_symbol (absolute_section), addend);
3108 set_tok_reg (newtok[0], targreg);
3109 set_tok_const (newtok[1], lit);
3110 set_tok_preg (newtok[2], alpha_gp_register);
3111 assemble_tokens ("ldq", newtok, 3, 0);
3114 if (alpha_lit8_section == NULL)
3116 create_literal_section (".lit8",
3117 &alpha_lit8_section,
3118 &alpha_lit8_symbol);
3121 alpha_lit8_literal = add_to_literal_pool (alpha_lit8_symbol, 0x8000,
3122 alpha_lita_section, 8);
3123 if (alpha_lit8_literal >= 0x8000)
3124 as_fatal (_("overflow in literal (.lita) table"));
3128 lit = add_to_literal_pool (NULL, addend, alpha_lit8_section, 8) - 0x8000;
3130 as_fatal (_("overflow in literal (.lit8) table"));
3132 /* emit "lda litreg, .lit8+0x8000" */
3134 if (targreg == basereg)
3137 as_bad (_("macro requires $at register while noat in effect"));
3138 if (targreg == AXP_REG_AT)
3139 as_bad (_("macro requires $at while $at in use"));
3141 set_tok_reg (newtok[0], AXP_REG_AT);
3144 set_tok_reg (newtok[0], targreg);
3146 set_tok_sym (newtok[1], alpha_lita_symbol, alpha_lit8_literal);
3149 set_tok_sym (newtok[1], alpha_lit8_symbol, 0x8000);
3151 set_tok_preg (newtok[2], alpha_gp_register);
3153 assemble_tokens_to_insn ("ldq", newtok, 3, &insn);
3155 assert (insn.nfixups == 1);
3157 insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITERAL;
3160 insn.fixups[0].reloc = BFD_RELOC_ALPHA_ELF_LITERAL;
3165 /* emit "ldq litreg, lit(litreg)" */
3167 set_tok_const (newtok[1], lit);
3168 set_tok_preg (newtok[2], newtok[0].X_add_number);
3170 assemble_tokens_to_insn ("ldq", newtok, 3, &insn);
3172 assert (insn.nfixups < MAX_INSN_FIXUPS);
3173 if (insn.nfixups > 0)
3175 memmove (&insn.fixups[1], &insn.fixups[0],
3176 sizeof (struct alpha_fixup) * insn.nfixups);
3179 insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITUSE;
3180 insn.fixups[0].exp.X_op = O_symbol;
3181 insn.fixups[0].exp.X_add_symbol = section_symbol (now_seg);
3182 insn.fixups[0].exp.X_add_number = LITUSE_BASE;
3187 /* emit "addq litreg, base, target" */
3189 if (basereg != AXP_REG_ZERO)
3191 set_tok_reg (newtok[1], basereg);
3192 set_tok_reg (newtok[2], targreg);
3193 assemble_tokens ("addq", newtok, 3, 0);
3195 #endif /* !OBJ_EVAX */
3198 set_tok_const (*poffset, 0);
3199 *pbasereg = targreg;
3203 offsetT low, high, extra, tmp;
3205 /* for 32-bit operands, break up the addend */
3207 low = sign_extend_16 (addend);
3209 high = sign_extend_16 (tmp >> 16);
3211 if (tmp - (high << 16))
3215 high = sign_extend_16 (tmp >> 16);
3220 set_tok_reg (newtok[0], targreg);
3221 set_tok_preg (newtok[2], basereg);
3225 /* emit "ldah r, extra(r) */
3226 set_tok_const (newtok[1], extra);
3227 assemble_tokens ("ldah", newtok, 3, 0);
3228 set_tok_preg (newtok[2], basereg = targreg);
3233 /* emit "ldah r, high(r) */
3234 set_tok_const (newtok[1], high);
3235 assemble_tokens ("ldah", newtok, 3, 0);
3237 set_tok_preg (newtok[2], basereg);
3240 if ((low && !poffset) || (!poffset && basereg != targreg))
3242 /* emit "lda r, low(base)" */
3243 set_tok_const (newtok[1], low);
3244 assemble_tokens ("lda", newtok, 3, 0);
3250 set_tok_const (*poffset, low);
3251 *pbasereg = basereg;
3257 /* The lda macro differs from the lda instruction in that it handles
3258 most simple expressions, particualrly symbol address loads and
3262 emit_lda (tok, ntok, opname)
3263 const expressionS *tok;
3268 const expressionS *reloc = (const expressionS *) 0;
3271 if (ntok && USER_RELOC_P (tok[ntok - 1].X_op))
3273 const struct alpha_reloc_op_tag *r;
3275 reloc = &tok[ntok - 1];
3276 r = ALPHA_RELOC_TABLE (reloc->X_op);
3277 switch (reloc->X_op)
3280 as_bad (_("Cannot use !%s!%d with %s"), r->name,
3281 (int) reloc->X_add_number, (const char *) opname);
3283 reloc = (const expressionS *) 0;
3291 /* For lda $x,0($x)!lituse_base!y, don't use load_expression, since
3292 it is really too general for our needs. Instead just generate the
3296 || tok[0].X_op != O_register
3297 || !is_ir_num (tok[0].X_add_number)
3298 || tok[1].X_op != O_constant
3299 || tok[2].X_op != O_pregister
3300 || !is_ir_num (tok[2].X_add_number))
3302 as_bad (_("bad instruction format for lda !%s!%ld"), r->name,
3303 (long) reloc->X_add_number);
3305 reloc = (const expressionS *) 0;
3310 emit_loadstore (tok, ntok, "lda");
3317 basereg = (tok[1].X_op == O_constant ? AXP_REG_ZERO : alpha_gp_register);
3319 basereg = tok[2].X_add_number;
3321 (void) load_expression (tok[0].X_add_number, &tok[1], &basereg, NULL, reloc);
3324 /* The ldah macro differs from the ldah instruction in that it has $31
3325 as an implied base register. */
3328 emit_ldah (tok, ntok, unused)
3329 const expressionS *tok;
3330 int ntok ATTRIBUTE_UNUSED;
3331 const PTR unused ATTRIBUTE_UNUSED;
3333 expressionS newtok[3];
3336 if (ntok && USER_RELOC_P (tok[ntok - 1].X_op))
3338 const expressionS *reloc_exp = &tok[ntok - 1];
3339 const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op);
3340 as_bad (_("Cannot use !%s!%d with %s"), r->name,
3341 (int) reloc_exp->X_add_number, "ldah");
3348 set_tok_preg (newtok[2], AXP_REG_ZERO);
3350 assemble_tokens ("ldah", newtok, 3, 0);
3353 /* Handle all "simple" integer register loads -- ldq, ldq_l, ldq_u,
3354 etc. They differ from the real instructions in that they do simple
3355 expressions like the lda macro. */
3358 emit_ir_load (tok, ntok, opname)
3359 const expressionS *tok;
3363 int basereg, lituse;
3364 expressionS newtok[3];
3365 struct alpha_insn insn;
3368 const expressionS *reloc = (const expressionS *) 0;
3370 if (ntok && USER_RELOC_P (tok[ntok - 1].X_op))
3372 const struct alpha_reloc_op_tag *r;
3374 reloc = &tok[ntok - 1];
3375 switch (reloc->X_op)
3382 if (strcmp ((const char *) opname, "ldq") == 0)
3384 emit_lda (tok, ntok, opname);
3391 r = ALPHA_RELOC_TABLE (reloc->X_op);
3392 as_bad (_("Cannot use !%s!%d with %s"), r->name,
3393 (int) reloc->X_add_number, (const char *) opname);
3399 basereg = (tok[1].X_op == O_constant ? AXP_REG_ZERO : alpha_gp_register);
3401 basereg = tok[2].X_add_number;
3403 lituse = load_expression (tok[0].X_add_number, &tok[1], &basereg,
3404 &newtok[1], (const expressionS *) 0);
3407 set_tok_preg (newtok[2], basereg);
3409 assemble_tokens_to_insn ((const char *) opname, newtok, 3, &insn);
3414 int nfixups = insn.nfixups;
3415 const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc->X_op);
3417 assert (nfixups < MAX_INSN_FIXUPS);
3418 insn.fixups[nfixups].reloc = r->reloc;
3419 insn.fixups[nfixups].exp.X_op = O_symbol;
3420 insn.fixups[nfixups].exp.X_add_symbol = section_symbol (now_seg);
3421 insn.fixups[nfixups].exp.X_add_number = r->lituse;
3422 insn.sequence[nfixups] = reloc->X_add_number;
3429 assert (insn.nfixups < MAX_INSN_FIXUPS);
3430 if (insn.nfixups > 0)
3432 memmove (&insn.fixups[1], &insn.fixups[0],
3433 sizeof (struct alpha_fixup) * insn.nfixups);
3436 insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITUSE;
3437 insn.fixups[0].exp.X_op = O_symbol;
3438 insn.fixups[0].exp.X_add_symbol = section_symbol (now_seg);
3439 insn.fixups[0].exp.X_add_number = LITUSE_BASE;
3445 /* Handle fp register loads, and both integer and fp register stores.
3446 Again, we handle simple expressions. */
3449 emit_loadstore (tok, ntok, opname)
3450 const expressionS *tok;
3454 int basereg, lituse;
3455 expressionS newtok[3];
3456 struct alpha_insn insn;
3459 const expressionS *reloc = (const expressionS *) 0;
3461 if (ntok && USER_RELOC_P (tok[ntok - 1].X_op))
3463 reloc = &tok[--ntok];
3464 if (reloc->X_op != O_lituse_base)
3466 const struct alpha_reloc_op_tag *r = &alpha_reloc_op[reloc->X_md];
3467 as_bad (_("Cannot use !%s!%d with %s"), r->name,
3468 (int) reloc->X_add_number, (const char *) opname);
3474 basereg = (tok[1].X_op == O_constant ? AXP_REG_ZERO : alpha_gp_register);
3476 basereg = tok[2].X_add_number;
3478 if (tok[1].X_op != O_constant || !range_signed_16 (tok[1].X_add_number))
3481 as_bad (_("macro requires $at register while noat in effect"));
3483 lituse = load_expression (AXP_REG_AT, &tok[1], &basereg, &newtok[1],
3484 (const expressionS *) 0);
3493 set_tok_preg (newtok[2], basereg);
3495 assemble_tokens_to_insn ((const char *) opname, newtok, 3, &insn);
3500 int nfixups = insn.nfixups;
3501 const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc->X_op);
3503 assert (nfixups < MAX_INSN_FIXUPS);
3504 insn.fixups[nfixups].reloc = r->reloc;
3505 insn.fixups[nfixups].exp.X_op = O_symbol;
3506 insn.fixups[nfixups].exp.X_add_symbol = section_symbol (now_seg);
3507 insn.fixups[nfixups].exp.X_add_number = r->lituse;
3508 insn.sequence[nfixups] = reloc->X_add_number;
3515 assert (insn.nfixups < MAX_INSN_FIXUPS);
3516 if (insn.nfixups > 0)
3518 memmove (&insn.fixups[1], &insn.fixups[0],
3519 sizeof (struct alpha_fixup) * insn.nfixups);
3522 insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITUSE;
3523 insn.fixups[0].exp.X_op = O_symbol;
3524 insn.fixups[0].exp.X_add_symbol = section_symbol (now_seg);
3525 insn.fixups[0].exp.X_add_number = LITUSE_BASE;
3531 /* Load a half-word or byte as an unsigned value. */
3534 emit_ldXu (tok, ntok, vlgsize)
3535 const expressionS *tok;
3539 if (alpha_target & AXP_OPCODE_BWX)
3540 emit_ir_load (tok, ntok, ldXu_op[(long) vlgsize]);
3543 expressionS newtok[3];
3546 if (ntok && USER_RELOC_P (tok[ntok - 1].X_op))
3548 const expressionS *reloc_exp = &tok[ntok - 1];
3549 const struct alpha_reloc_op_tag *r
3550 = ALPHA_RELOC_TABLE (reloc_exp->X_op);
3552 as_bad (_("Cannot use !%s!%d with %s"), r->name,
3553 (int) reloc_exp->X_add_number, "ldbu/ldwu");
3559 as_bad (_("macro requires $at register while noat in effect"));
3561 /* emit "lda $at, exp" */
3563 memcpy (newtok, tok, sizeof (expressionS) * ntok);
3564 newtok[0].X_add_number = AXP_REG_AT;
3565 assemble_tokens ("lda", newtok, ntok, 1);
3567 /* emit "ldq_u targ, 0($at)" */
3570 set_tok_const (newtok[1], 0);
3571 set_tok_preg (newtok[2], AXP_REG_AT);
3572 assemble_tokens ("ldq_u", newtok, 3, 1);
3574 /* emit "extXl targ, $at, targ" */
3576 set_tok_reg (newtok[1], AXP_REG_AT);
3577 newtok[2] = newtok[0];
3578 assemble_tokens (extXl_op[(long) vlgsize], newtok, 3, 1);
3582 /* Load a half-word or byte as a signed value. */
3585 emit_ldX (tok, ntok, vlgsize)
3586 const expressionS *tok;
3590 emit_ldXu (tok, ntok, vlgsize);
3591 assemble_tokens (sextX_op[(long) vlgsize], tok, 1, 1);
3594 /* Load an integral value from an unaligned address as an unsigned
3598 emit_uldXu (tok, ntok, vlgsize)
3599 const expressionS *tok;
3603 long lgsize = (long) vlgsize;
3604 expressionS newtok[3];
3607 as_bad (_("macro requires $at register while noat in effect"));
3609 /* emit "lda $at, exp" */
3611 memcpy (newtok, tok, sizeof (expressionS) * ntok);
3612 newtok[0].X_add_number = AXP_REG_AT;
3613 assemble_tokens ("lda", newtok, ntok, 1);
3615 /* emit "ldq_u $t9, 0($at)" */
3617 set_tok_reg (newtok[0], AXP_REG_T9);
3618 set_tok_const (newtok[1], 0);
3619 set_tok_preg (newtok[2], AXP_REG_AT);
3620 assemble_tokens ("ldq_u", newtok, 3, 1);
3622 /* emit "ldq_u $t10, size-1($at)" */
3624 set_tok_reg (newtok[0], AXP_REG_T10);
3625 set_tok_const (newtok[1], (1 << lgsize) - 1);
3626 assemble_tokens ("ldq_u", newtok, 3, 1);
3628 /* emit "extXl $t9, $at, $t9" */
3630 set_tok_reg (newtok[0], AXP_REG_T9);
3631 set_tok_reg (newtok[1], AXP_REG_AT);
3632 set_tok_reg (newtok[2], AXP_REG_T9);
3633 assemble_tokens (extXl_op[lgsize], newtok, 3, 1);
3635 /* emit "extXh $t10, $at, $t10" */
3637 set_tok_reg (newtok[0], AXP_REG_T10);
3638 set_tok_reg (newtok[2], AXP_REG_T10);
3639 assemble_tokens (extXh_op[lgsize], newtok, 3, 1);
3641 /* emit "or $t9, $t10, targ" */
3643 set_tok_reg (newtok[0], AXP_REG_T9);
3644 set_tok_reg (newtok[1], AXP_REG_T10);
3646 assemble_tokens ("or", newtok, 3, 1);
3649 /* Load an integral value from an unaligned address as a signed value.
3650 Note that quads should get funneled to the unsigned load since we
3651 don't have to do the sign extension. */
3654 emit_uldX (tok, ntok, vlgsize)
3655 const expressionS *tok;
3659 emit_uldXu (tok, ntok, vlgsize);
3660 assemble_tokens (sextX_op[(long) vlgsize], tok, 1, 1);
3663 /* Implement the ldil macro. */
3666 emit_ldil (tok, ntok, unused)
3667 const expressionS *tok;
3669 const PTR unused ATTRIBUTE_UNUSED;
3671 expressionS newtok[2];
3674 if (ntok && USER_RELOC_P (tok[ntok - 1].X_op))
3676 const expressionS *reloc_exp = &tok[ntok - 1];
3677 const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op);
3678 as_bad (_("Cannot use !%s!%d with %s"), r->name,
3679 (int) reloc_exp->X_add_number, "ldil");
3684 memcpy (newtok, tok, sizeof (newtok));
3685 newtok[1].X_add_number = sign_extend_32 (tok[1].X_add_number);
3687 assemble_tokens ("lda", newtok, ntok, 1);
3690 /* Store a half-word or byte. */
3693 emit_stX (tok, ntok, vlgsize)
3694 const expressionS *tok;
3698 int lgsize = (int) (long) vlgsize;
3700 if (alpha_target & AXP_OPCODE_BWX)
3701 emit_loadstore (tok, ntok, stX_op[lgsize]);
3704 expressionS newtok[3];
3707 as_bad (_("macro requires $at register while noat in effect"));
3709 /* emit "lda $at, exp" */
3711 memcpy (newtok, tok, sizeof (expressionS) * ntok);
3712 newtok[0].X_add_number = AXP_REG_AT;
3713 assemble_tokens ("lda", newtok, ntok, 1);
3715 /* emit "ldq_u $t9, 0($at)" */
3717 set_tok_reg (newtok[0], AXP_REG_T9);
3718 set_tok_const (newtok[1], 0);
3719 set_tok_preg (newtok[2], AXP_REG_AT);
3720 assemble_tokens ("ldq_u", newtok, 3, 1);
3722 /* emit "insXl src, $at, $t10" */
3725 set_tok_reg (newtok[1], AXP_REG_AT);
3726 set_tok_reg (newtok[2], AXP_REG_T10);
3727 assemble_tokens (insXl_op[lgsize], newtok, 3, 1);
3729 /* emit "mskXl $t9, $at, $t9" */
3731 set_tok_reg (newtok[0], AXP_REG_T9);
3732 newtok[2] = newtok[0];
3733 assemble_tokens (mskXl_op[lgsize], newtok, 3, 1);
3735 /* emit "or $t9, $t10, $t9" */
3737 set_tok_reg (newtok[1], AXP_REG_T10);
3738 assemble_tokens ("or", newtok, 3, 1);
3740 /* emit "stq_u $t9, 0($at) */
3742 set_tok_const (newtok[1], 0);
3743 set_tok_preg (newtok[2], AXP_REG_AT);
3744 assemble_tokens ("stq_u", newtok, 3, 1);
3748 /* Store an integer to an unaligned address. */
3751 emit_ustX (tok, ntok, vlgsize)
3752 const expressionS *tok;
3756 int lgsize = (int) (long) vlgsize;
3757 expressionS newtok[3];
3759 /* emit "lda $at, exp" */
3761 memcpy (newtok, tok, sizeof (expressionS) * ntok);
3762 newtok[0].X_add_number = AXP_REG_AT;
3763 assemble_tokens ("lda", newtok, ntok, 1);
3765 /* emit "ldq_u $9, 0($at)" */
3767 set_tok_reg (newtok[0], AXP_REG_T9);
3768 set_tok_const (newtok[1], 0);
3769 set_tok_preg (newtok[2], AXP_REG_AT);
3770 assemble_tokens ("ldq_u", newtok, 3, 1);
3772 /* emit "ldq_u $10, size-1($at)" */
3774 set_tok_reg (newtok[0], AXP_REG_T10);
3775 set_tok_const (newtok[1], (1 << lgsize) - 1);
3776 assemble_tokens ("ldq_u", newtok, 3, 1);
3778 /* emit "insXl src, $at, $t11" */
3781 set_tok_reg (newtok[1], AXP_REG_AT);
3782 set_tok_reg (newtok[2], AXP_REG_T11);
3783 assemble_tokens (insXl_op[lgsize], newtok, 3, 1);
3785 /* emit "insXh src, $at, $t12" */
3787 set_tok_reg (newtok[2], AXP_REG_T12);
3788 assemble_tokens (insXh_op[lgsize], newtok, 3, 1);
3790 /* emit "mskXl $t9, $at, $t9" */
3792 set_tok_reg (newtok[0], AXP_REG_T9);
3793 newtok[2] = newtok[0];
3794 assemble_tokens (mskXl_op[lgsize], newtok, 3, 1);
3796 /* emit "mskXh $t10, $at, $t10" */
3798 set_tok_reg (newtok[0], AXP_REG_T10);
3799 newtok[2] = newtok[0];
3800 assemble_tokens (mskXh_op[lgsize], newtok, 3, 1);
3802 /* emit "or $t9, $t11, $t9" */
3804 set_tok_reg (newtok[0], AXP_REG_T9);
3805 set_tok_reg (newtok[1], AXP_REG_T11);
3806 newtok[2] = newtok[0];
3807 assemble_tokens ("or", newtok, 3, 1);
3809 /* emit "or $t10, $t12, $t10" */
3811 set_tok_reg (newtok[0], AXP_REG_T10);
3812 set_tok_reg (newtok[1], AXP_REG_T12);
3813 newtok[2] = newtok[0];
3814 assemble_tokens ("or", newtok, 3, 1);
3816 /* emit "stq_u $t9, 0($at)" */
3818 set_tok_reg (newtok[0], AXP_REG_T9);
3819 set_tok_const (newtok[1], 0);
3820 set_tok_preg (newtok[2], AXP_REG_AT);
3821 assemble_tokens ("stq_u", newtok, 3, 1);
3823 /* emit "stq_u $t10, size-1($at)" */
3825 set_tok_reg (newtok[0], AXP_REG_T10);
3826 set_tok_const (newtok[1], (1 << lgsize) - 1);
3827 assemble_tokens ("stq_u", newtok, 3, 1);
3830 /* Sign extend a half-word or byte. The 32-bit sign extend is
3831 implemented as "addl $31, $r, $t" in the opcode table. */
3834 emit_sextX (tok, ntok, vlgsize)
3835 const expressionS *tok;
3839 long lgsize = (long) vlgsize;
3841 if (alpha_target & AXP_OPCODE_BWX)
3842 assemble_tokens (sextX_op[lgsize], tok, ntok, 0);
3845 int bitshift = 64 - 8 * (1 << lgsize);
3846 expressionS newtok[3];
3849 if (ntok && USER_RELOC_P (tok[ntok - 1].X_op))
3851 const expressionS *reloc_exp = &tok[ntok - 1];
3852 const struct alpha_reloc_op_tag *r
3853 = ALPHA_RELOC_TABLE (reloc_exp->X_op);
3855 as_bad (_("Cannot use !%s!%d with %s"), r->name,
3856 (int) reloc_exp->X_add_number, "setxt");
3861 /* emit "sll src,bits,dst" */
3864 set_tok_const (newtok[1], bitshift);
3865 newtok[2] = tok[ntok - 1];
3866 assemble_tokens ("sll", newtok, 3, 1);
3868 /* emit "sra dst,bits,dst" */
3870 newtok[0] = newtok[2];
3871 assemble_tokens ("sra", newtok, 3, 1);
3875 /* Implement the division and modulus macros. */
3879 /* Make register usage like in normal procedure call.
3880 Don't clobber PV and RA. */
3883 emit_division (tok, ntok, symname)
3884 const expressionS *tok;
3888 /* DIVISION and MODULUS. Yech.
3893 * mov x,R16 # if x != R16
3894 * mov y,R17 # if y != R17
3899 * with appropriate optimizations if R0,R16,R17 are the registers
3900 * specified by the compiler.
3905 expressionS newtok[3];
3908 if (ntok && USER_RELOC_P (tok[ntok - 1].X_op))
3910 const expressionS *reloc_exp = &tok[ntok - 1];
3911 const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op);
3912 as_bad (_("Cannot use !%s!%d with %s"), r->name,
3913 (int) reloc_exp->X_add_number, (char char *) symname);
3918 xr = regno (tok[0].X_add_number);
3919 yr = regno (tok[1].X_add_number);
3924 rr = regno (tok[2].X_add_number);
3926 /* Move the operands into the right place */
3927 if (yr == AXP_REG_R16 && xr == AXP_REG_R17)
3929 /* They are in exactly the wrong order -- swap through AT */
3932 as_bad (_("macro requires $at register while noat in effect"));
3934 set_tok_reg (newtok[0], AXP_REG_R16);
3935 set_tok_reg (newtok[1], AXP_REG_AT);
3936 assemble_tokens ("mov", newtok, 2, 1);
3938 set_tok_reg (newtok[0], AXP_REG_R17);
3939 set_tok_reg (newtok[1], AXP_REG_R16);
3940 assemble_tokens ("mov", newtok, 2, 1);
3942 set_tok_reg (newtok[0], AXP_REG_AT);
3943 set_tok_reg (newtok[1], AXP_REG_R17);
3944 assemble_tokens ("mov", newtok, 2, 1);
3948 if (yr == AXP_REG_R16)
3950 set_tok_reg (newtok[0], AXP_REG_R16);
3951 set_tok_reg (newtok[1], AXP_REG_R17);
3952 assemble_tokens ("mov", newtok, 2, 1);
3955 if (xr != AXP_REG_R16)
3957 set_tok_reg (newtok[0], xr);
3958 set_tok_reg (newtok[1], AXP_REG_R16);
3959 assemble_tokens ("mov", newtok, 2, 1);
3962 if (yr != AXP_REG_R16 && yr != AXP_REG_R17)
3964 set_tok_reg (newtok[0], yr);
3965 set_tok_reg (newtok[1], AXP_REG_R17);
3966 assemble_tokens ("mov", newtok, 2, 1);
3970 sym = symbol_find_or_make ((const char *) symname);
3972 set_tok_reg (newtok[0], AXP_REG_AT);
3973 set_tok_sym (newtok[1], sym, 0);
3974 assemble_tokens ("lda", newtok, 2, 1);
3976 /* Call the division routine */
3977 set_tok_reg (newtok[0], AXP_REG_AT);
3978 set_tok_cpreg (newtok[1], AXP_REG_AT);
3979 set_tok_const (newtok[2], 0);
3980 assemble_tokens ("jsr", newtok, 3, 1);
3982 /* Move the result to the right place */
3983 if (rr != AXP_REG_R0)
3985 set_tok_reg (newtok[0], AXP_REG_R0);
3986 set_tok_reg (newtok[1], rr);
3987 assemble_tokens ("mov", newtok, 2, 1);
3991 #else /* !OBJ_EVAX */
3994 emit_division (tok, ntok, symname)
3995 const expressionS *tok;
3999 /* DIVISION and MODULUS. Yech.
4009 * with appropriate optimizations if t10,t11,t12 are the registers
4010 * specified by the compiler.
4015 expressionS newtok[3];
4018 if (ntok && USER_RELOC_P (tok[ntok - 1].X_op))
4020 const expressionS *reloc_exp = &tok[ntok - 1];
4021 const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op);
4022 as_bad (_("Cannot use !%s!%d with %s"), r->name,
4023 (int) reloc_exp->X_add_number, (const char *) symname);
4028 xr = regno (tok[0].X_add_number);
4029 yr = regno (tok[1].X_add_number);
4034 rr = regno (tok[2].X_add_number);
4036 sym = symbol_find_or_make ((const char *) symname);
4038 /* Move the operands into the right place */
4039 if (yr == AXP_REG_T10 && xr == AXP_REG_T11)
4041 /* They are in exactly the wrong order -- swap through AT */
4044 as_bad (_("macro requires $at register while noat in effect"));
4046 set_tok_reg (newtok[0], AXP_REG_T10);
4047 set_tok_reg (newtok[1], AXP_REG_AT);
4048 assemble_tokens ("mov", newtok, 2, 1);
4050 set_tok_reg (newtok[0], AXP_REG_T11);
4051 set_tok_reg (newtok[1], AXP_REG_T10);
4052 assemble_tokens ("mov", newtok, 2, 1);
4054 set_tok_reg (newtok[0], AXP_REG_AT);
4055 set_tok_reg (newtok[1], AXP_REG_T11);
4056 assemble_tokens ("mov", newtok, 2, 1);
4060 if (yr == AXP_REG_T10)
4062 set_tok_reg (newtok[0], AXP_REG_T10);
4063 set_tok_reg (newtok[1], AXP_REG_T11);
4064 assemble_tokens ("mov", newtok, 2, 1);
4067 if (xr != AXP_REG_T10)
4069 set_tok_reg (newtok[0], xr);
4070 set_tok_reg (newtok[1], AXP_REG_T10);
4071 assemble_tokens ("mov", newtok, 2, 1);
4074 if (yr != AXP_REG_T10 && yr != AXP_REG_T11)
4076 set_tok_reg (newtok[0], yr);
4077 set_tok_reg (newtok[1], AXP_REG_T11);
4078 assemble_tokens ("mov", newtok, 2, 1);
4082 /* Call the division routine */
4083 set_tok_reg (newtok[0], AXP_REG_T9);
4084 set_tok_sym (newtok[1], sym, 0);
4085 assemble_tokens ("jsr", newtok, 2, 1);
4087 /* Reload the GP register */
4091 #if defined(OBJ_ECOFF) || defined(OBJ_ELF)
4092 set_tok_reg (newtok[0], alpha_gp_register);
4093 set_tok_const (newtok[1], 0);
4094 set_tok_preg (newtok[2], AXP_REG_T9);
4095 assemble_tokens ("ldgp", newtok, 3, 1);
4098 /* Move the result to the right place */
4099 if (rr != AXP_REG_T12)
4101 set_tok_reg (newtok[0], AXP_REG_T12);
4102 set_tok_reg (newtok[1], rr);
4103 assemble_tokens ("mov", newtok, 2, 1);
4107 #endif /* !OBJ_EVAX */
4109 /* The jsr and jmp macros differ from their instruction counterparts
4110 in that they can load the target address and default most
4114 emit_jsrjmp (tok, ntok, vopname)
4115 const expressionS *tok;
4119 const char *opname = (const char *) vopname;
4120 struct alpha_insn insn;
4121 expressionS newtok[3];
4122 int r, tokidx = 0, lituse = 0;
4125 if (ntok && USER_RELOC_P (tok[ntok - 1].X_op))
4127 const expressionS *reloc_exp = &tok[ntok - 1];
4128 const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op);
4129 as_bad (_("Cannot use !%s!%d with %s"), r->name,
4130 (int) reloc_exp->X_add_number, opname);
4135 if (tokidx < ntok && tok[tokidx].X_op == O_register)
4136 r = regno (tok[tokidx++].X_add_number);
4138 r = strcmp (opname, "jmp") == 0 ? AXP_REG_ZERO : AXP_REG_RA;
4140 set_tok_reg (newtok[0], r);
4142 if (tokidx < ntok &&
4143 (tok[tokidx].X_op == O_pregister || tok[tokidx].X_op == O_cpregister))
4144 r = regno (tok[tokidx++].X_add_number);
4146 /* keep register if jsr $n.<sym> */
4150 int basereg = alpha_gp_register;
4151 lituse = load_expression (r = AXP_REG_PV, &tok[tokidx], &basereg, NULL,
4152 (const expressionS *) 0);
4156 set_tok_cpreg (newtok[1], r);
4159 /* FIXME: Add hint relocs to BFD for evax. */
4162 newtok[2] = tok[tokidx];
4165 set_tok_const (newtok[2], 0);
4167 assemble_tokens_to_insn (opname, newtok, 3, &insn);
4169 /* add the LITUSE fixup */
4172 assert (insn.nfixups < MAX_INSN_FIXUPS);
4173 if (insn.nfixups > 0)
4175 memmove (&insn.fixups[1], &insn.fixups[0],
4176 sizeof (struct alpha_fixup) * insn.nfixups);
4179 insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITUSE;
4180 insn.fixups[0].exp.X_op = O_symbol;
4181 insn.fixups[0].exp.X_add_symbol = section_symbol (now_seg);
4182 insn.fixups[0].exp.X_add_number = LITUSE_JSR;
4188 /* The ret and jcr instructions differ from their instruction
4189 counterparts in that everything can be defaulted. */
4192 emit_retjcr (tok, ntok, vopname)
4193 const expressionS *tok;
4197 const char *opname = (const char *) vopname;
4198 expressionS newtok[3];
4202 if (ntok && USER_RELOC_P (tok[ntok - 1].X_op))
4204 const expressionS *reloc_exp = &tok[ntok - 1];
4205 const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op);
4206 as_bad (_("Cannot use !%s!%d with %s"), r->name,
4207 (int) reloc_exp->X_add_number, opname);
4212 if (tokidx < ntok && tok[tokidx].X_op == O_register)
4213 r = regno (tok[tokidx++].X_add_number);
4217 set_tok_reg (newtok[0], r);
4219 if (tokidx < ntok &&
4220 (tok[tokidx].X_op == O_pregister || tok[tokidx].X_op == O_cpregister))
4221 r = regno (tok[tokidx++].X_add_number);
4225 set_tok_cpreg (newtok[1], r);
4228 newtok[2] = tok[tokidx];
4230 set_tok_const (newtok[2], strcmp (opname, "ret") == 0);
4232 assemble_tokens (opname, newtok, 3, 0);
4235 /* Assembler directives */
4237 /* Handle the .text pseudo-op. This is like the usual one, but it
4238 clears alpha_insn_label and restores auto alignment. */
4246 alpha_insn_label = NULL;
4247 alpha_auto_align_on = 1;
4248 alpha_current_align = 0;
4251 /* Handle the .data pseudo-op. This is like the usual one, but it
4252 clears alpha_insn_label and restores auto alignment. */
4259 alpha_insn_label = NULL;
4260 alpha_auto_align_on = 1;
4261 alpha_current_align = 0;
4264 #if defined (OBJ_ECOFF) || defined (OBJ_EVAX)
4266 /* Handle the OSF/1 and openVMS .comm pseudo quirks.
4267 openVMS constructs a section for every common symbol. */
4270 s_alpha_comm (ignore)
4273 register char *name;
4277 register symbolS *symbolP;
4280 segT current_section = now_seg;
4281 int current_subsec = now_subseg;
4285 name = input_line_pointer;
4286 c = get_symbol_end ();
4288 /* just after name is now '\0' */
4289 p = input_line_pointer;
4294 /* Alpha OSF/1 compiler doesn't provide the comma, gcc does. */
4295 if (*input_line_pointer == ',')
4297 input_line_pointer++;
4300 if ((temp = get_absolute_expression ()) < 0)
4302 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp);
4303 ignore_rest_of_line ();
4308 symbolP = symbol_find_or_make (name);
4311 /* Make a section for the common symbol. */
4312 new_seg = subseg_new (xstrdup (name), 0);
4318 /* alignment might follow */
4319 if (*input_line_pointer == ',')
4323 input_line_pointer++;
4324 align = get_absolute_expression ();
4325 bfd_set_section_alignment (stdoutput, new_seg, align);
4329 if (S_IS_DEFINED (symbolP) && ! S_IS_COMMON (symbolP))
4331 as_bad (_("Ignoring attempt to re-define symbol"));
4332 ignore_rest_of_line ();
4337 if (bfd_section_size (stdoutput, new_seg) > 0)
4339 if (bfd_section_size (stdoutput, new_seg) != temp)
4340 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
4341 S_GET_NAME (symbolP),
4342 (long) bfd_section_size (stdoutput, new_seg),
4346 if (S_GET_VALUE (symbolP))
4348 if (S_GET_VALUE (symbolP) != (valueT) temp)
4349 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
4350 S_GET_NAME (symbolP),
4351 (long) S_GET_VALUE (symbolP),
4358 subseg_set (new_seg, 0);
4359 p = frag_more (temp);
4360 new_seg->flags |= SEC_IS_COMMON;
4361 if (! S_IS_DEFINED (symbolP))
4362 S_SET_SEGMENT (symbolP, new_seg);
4364 S_SET_VALUE (symbolP, (valueT) temp);
4366 S_SET_EXTERNAL (symbolP);
4370 subseg_set (current_section, current_subsec);
4373 know (symbol_get_frag (symbolP) == &zero_address_frag);
4375 demand_empty_rest_of_line ();
4378 #endif /* ! OBJ_ELF */
4382 /* Handle the .rdata pseudo-op. This is like the usual one, but it
4383 clears alpha_insn_label and restores auto alignment. */
4386 s_alpha_rdata (ignore)
4391 temp = get_absolute_expression ();
4392 subseg_new (".rdata", 0);
4393 demand_empty_rest_of_line ();
4394 alpha_insn_label = NULL;
4395 alpha_auto_align_on = 1;
4396 alpha_current_align = 0;
4403 /* Handle the .sdata pseudo-op. This is like the usual one, but it
4404 clears alpha_insn_label and restores auto alignment. */
4407 s_alpha_sdata (ignore)
4412 temp = get_absolute_expression ();
4413 subseg_new (".sdata", 0);
4414 demand_empty_rest_of_line ();
4415 alpha_insn_label = NULL;
4416 alpha_auto_align_on = 1;
4417 alpha_current_align = 0;
4423 /* Handle the .section pseudo-op. This is like the usual one, but it
4424 clears alpha_insn_label and restores auto alignment. */
4427 s_alpha_section (ignore)
4430 obj_elf_section (ignore);
4432 alpha_insn_label = NULL;
4433 alpha_auto_align_on = 1;
4434 alpha_current_align = 0;
4439 int dummy ATTRIBUTE_UNUSED;
4441 if (ECOFF_DEBUGGING)
4442 ecoff_directive_ent (0);
4445 char *name, name_end;
4446 name = input_line_pointer;
4447 name_end = get_symbol_end ();
4449 if (! is_name_beginner (*name))
4451 as_warn (_(".ent directive has no name"));
4452 *input_line_pointer = name_end;
4458 if (alpha_cur_ent_sym)
4459 as_warn (_("nested .ent directives"));
4461 sym = symbol_find_or_make (name);
4462 symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION;
4463 alpha_cur_ent_sym = sym;
4465 /* The .ent directive is sometimes followed by a number. Not sure
4466 what it really means, but ignore it. */
4467 *input_line_pointer = name_end;
4469 if (*input_line_pointer == ',')
4471 input_line_pointer++;
4474 if (isdigit (*input_line_pointer) || *input_line_pointer == '-')
4475 (void) get_absolute_expression ();
4477 demand_empty_rest_of_line ();
4483 int dummy ATTRIBUTE_UNUSED;
4485 if (ECOFF_DEBUGGING)
4486 ecoff_directive_end (0);
4489 char *name, name_end;
4490 name = input_line_pointer;
4491 name_end = get_symbol_end ();
4493 if (! is_name_beginner (*name))
4495 as_warn (_(".end directive has no name"));
4496 *input_line_pointer = name_end;
4502 sym = symbol_find (name);
4503 if (sym != alpha_cur_ent_sym)
4504 as_warn (_(".end directive names different symbol than .ent"));
4506 /* Create an expression to calculate the size of the function. */
4509 symbol_get_obj (sym)->size =
4510 (expressionS *) xmalloc (sizeof (expressionS));
4511 symbol_get_obj (sym)->size->X_op = O_subtract;
4512 symbol_get_obj (sym)->size->X_add_symbol
4513 = symbol_new ("L0\001", now_seg, frag_now_fix (), frag_now);
4514 symbol_get_obj (sym)->size->X_op_symbol = sym;
4515 symbol_get_obj (sym)->size->X_add_number = 0;
4518 alpha_cur_ent_sym = NULL;
4520 *input_line_pointer = name_end;
4522 demand_empty_rest_of_line ();
4530 if (ECOFF_DEBUGGING)
4533 ecoff_directive_fmask (0);
4535 ecoff_directive_mask (0);
4538 discard_rest_of_line ();
4542 s_alpha_frame (dummy)
4543 int dummy ATTRIBUTE_UNUSED;
4545 if (ECOFF_DEBUGGING)
4546 ecoff_directive_frame (0);
4548 discard_rest_of_line ();
4552 s_alpha_prologue (ignore)
4553 int ignore ATTRIBUTE_UNUSED;
4558 arg = get_absolute_expression ();
4559 demand_empty_rest_of_line ();
4561 if (ECOFF_DEBUGGING)
4562 sym = ecoff_get_cur_proc_sym ();
4564 sym = alpha_cur_ent_sym;
4569 case 0: /* No PV required. */
4570 S_SET_OTHER (sym, STO_ALPHA_NOPV
4571 | (S_GET_OTHER (sym) & ~STO_ALPHA_STD_GPLOAD));
4573 case 1: /* Std GP load. */
4574 S_SET_OTHER (sym, STO_ALPHA_STD_GPLOAD
4575 | (S_GET_OTHER (sym) & ~STO_ALPHA_STD_GPLOAD));
4577 case 2: /* Non-std use of PV. */
4581 as_bad (_("Invalid argument %d to .prologue."), arg);
4586 static char *first_file_directive;
4589 s_alpha_file (ignore)
4590 int ignore ATTRIBUTE_UNUSED;
4592 /* Save the first .file directive we see, so that we can change our
4593 minds about whether ecoff debugging should or shouldn't be enabled. */
4594 if (alpha_flag_mdebug < 0 && ! first_file_directive)
4596 char *start = input_line_pointer;
4599 discard_rest_of_line ();
4601 len = input_line_pointer - start;
4602 first_file_directive = xmalloc (len + 1);
4603 memcpy (first_file_directive, start, len);
4604 first_file_directive[len] = '\0';
4606 input_line_pointer = start;
4609 if (ECOFF_DEBUGGING)
4610 ecoff_directive_file (0);
4612 dwarf2_directive_file (0);
4616 s_alpha_loc (ignore)
4617 int ignore ATTRIBUTE_UNUSED;
4619 if (ECOFF_DEBUGGING)
4620 ecoff_directive_loc (0);
4622 dwarf2_directive_loc (0);
4629 /* If we've been undecided about mdebug, make up our minds in favour. */
4630 if (alpha_flag_mdebug < 0)
4632 segT sec = subseg_new (".mdebug", 0);
4633 bfd_set_section_flags (stdoutput, sec, SEC_HAS_CONTENTS | SEC_READONLY);
4634 bfd_set_section_alignment (stdoutput, sec, 3);
4636 ecoff_read_begin_hook ();
4638 if (first_file_directive)
4640 char *save_ilp = input_line_pointer;
4641 input_line_pointer = first_file_directive;
4642 ecoff_directive_file (0);
4643 input_line_pointer = save_ilp;
4644 free (first_file_directive);
4647 alpha_flag_mdebug = 1;
4653 s_alpha_coff_wrapper (which)
4656 static void (* const fns[]) PARAMS ((int)) = {
4657 ecoff_directive_begin,
4658 ecoff_directive_bend,
4659 ecoff_directive_def,
4660 ecoff_directive_dim,
4661 ecoff_directive_endef,
4662 ecoff_directive_scl,
4663 ecoff_directive_tag,
4664 ecoff_directive_val,
4667 assert (which >= 0 && which < (int) (sizeof (fns)/sizeof (*fns)));
4669 if (ECOFF_DEBUGGING)
4673 as_bad (_("ECOFF debugging is disabled."));
4674 ignore_rest_of_line ();
4677 #endif /* OBJ_ELF */
4681 /* Handle the section specific pseudo-op. */
4684 s_alpha_section (secid)
4688 #define EVAX_SECTION_COUNT 5
4689 static char *section_name[EVAX_SECTION_COUNT + 1] =
4690 { "NULL", ".rdata", ".comm", ".link", ".ctors", ".dtors" };
4692 if ((secid <= 0) || (secid > EVAX_SECTION_COUNT))
4694 as_fatal (_("Unknown section directive"));
4695 demand_empty_rest_of_line ();
4698 temp = get_absolute_expression ();
4699 subseg_new (section_name[secid], 0);
4700 demand_empty_rest_of_line ();
4701 alpha_insn_label = NULL;
4702 alpha_auto_align_on = 1;
4703 alpha_current_align = 0;
4706 /* Parse .ent directives. */
4709 s_alpha_ent (ignore)
4713 expressionS symexpr;
4715 alpha_evax_proc.pdsckind = 0;
4716 alpha_evax_proc.framereg = -1;
4717 alpha_evax_proc.framesize = 0;
4718 alpha_evax_proc.rsa_offset = 0;
4719 alpha_evax_proc.ra_save = AXP_REG_RA;
4720 alpha_evax_proc.fp_save = -1;
4721 alpha_evax_proc.imask = 0;
4722 alpha_evax_proc.fmask = 0;
4723 alpha_evax_proc.prologue = 0;
4724 alpha_evax_proc.type = 0;
4726 expression (&symexpr);
4728 if (symexpr.X_op != O_symbol)
4730 as_fatal (_(".ent directive has no symbol"));
4731 demand_empty_rest_of_line ();
4735 symbol = make_expr_symbol (&symexpr);
4736 symbol_get_bfdsym (symbol)->flags |= BSF_FUNCTION;
4737 alpha_evax_proc.symbol = symbol;
4739 demand_empty_rest_of_line ();
4743 /* Parse .frame <framreg>,<framesize>,RA,<rsa_offset> directives. */
4746 s_alpha_frame (ignore)
4751 alpha_evax_proc.framereg = tc_get_register (1);
4754 if (*input_line_pointer++ != ','
4755 || get_absolute_expression_and_terminator (&val) != ',')
4757 as_warn (_("Bad .frame directive 1./2. param"));
4758 --input_line_pointer;
4759 demand_empty_rest_of_line ();
4763 alpha_evax_proc.framesize = val;
4765 (void) tc_get_register (1);
4767 if (*input_line_pointer++ != ',')
4769 as_warn (_("Bad .frame directive 3./4. param"));
4770 --input_line_pointer;
4771 demand_empty_rest_of_line ();
4774 alpha_evax_proc.rsa_offset = get_absolute_expression ();
4780 s_alpha_pdesc (ignore)
4790 segment_info_type *seginfo = seg_info (alpha_link_section);
4792 if (now_seg != alpha_link_section)
4794 as_bad (_(".pdesc directive not in link (.link) section"));
4795 demand_empty_rest_of_line ();
4799 if ((alpha_evax_proc.symbol == 0)
4800 || (!S_IS_DEFINED (alpha_evax_proc.symbol)))
4802 as_fatal (_(".pdesc has no matching .ent"));
4803 demand_empty_rest_of_line ();
4807 *symbol_get_obj (alpha_evax_proc.symbol) =
4808 (valueT) seginfo->literal_pool_size;
4811 if (exp.X_op != O_symbol)
4813 as_warn (_(".pdesc directive has no entry symbol"));
4814 demand_empty_rest_of_line ();
4818 entry_sym = make_expr_symbol (&exp);
4819 /* Save bfd symbol of proc desc in function symbol. */
4820 symbol_get_bfdsym (alpha_evax_proc.symbol)->udata.p
4821 = symbol_get_bfdsym (entry_sym);
4824 if (*input_line_pointer++ != ',')
4826 as_warn (_("No comma after .pdesc <entryname>"));
4827 demand_empty_rest_of_line ();
4832 name = input_line_pointer;
4833 name_end = get_symbol_end ();
4835 if (strncmp (name, "stack", 5) == 0)
4837 alpha_evax_proc.pdsckind = PDSC_S_K_KIND_FP_STACK;
4839 else if (strncmp (name, "reg", 3) == 0)
4841 alpha_evax_proc.pdsckind = PDSC_S_K_KIND_FP_REGISTER;
4843 else if (strncmp (name, "null", 4) == 0)
4845 alpha_evax_proc.pdsckind = PDSC_S_K_KIND_NULL;
4849 as_fatal (_("unknown procedure kind"));
4850 demand_empty_rest_of_line ();
4854 *input_line_pointer = name_end;
4855 demand_empty_rest_of_line ();
4857 #ifdef md_flush_pending_output
4858 md_flush_pending_output ();
4861 frag_align (3, 0, 0);
4863 fixp = fix_new (frag_now, p - frag_now->fr_literal, 8, 0, 0, 0, 0);
4865 seginfo->literal_pool_size += 16;
4867 *p = alpha_evax_proc.pdsckind
4868 | ((alpha_evax_proc.framereg == 29) ? PDSC_S_M_BASE_REG_IS_FP : 0);
4869 *(p + 1) = PDSC_S_M_NATIVE | PDSC_S_M_NO_JACKET;
4871 switch (alpha_evax_proc.pdsckind)
4873 case PDSC_S_K_KIND_NULL:
4877 case PDSC_S_K_KIND_FP_REGISTER:
4878 *(p + 2) = alpha_evax_proc.fp_save;
4879 *(p + 3) = alpha_evax_proc.ra_save;
4881 case PDSC_S_K_KIND_FP_STACK:
4882 md_number_to_chars (p + 2, (valueT) alpha_evax_proc.rsa_offset, 2);
4884 default: /* impossible */
4889 *(p + 5) = alpha_evax_proc.type & 0x0f;
4891 /* Signature offset. */
4892 md_number_to_chars (p + 6, (valueT) 0, 2);
4894 fix_new_exp (frag_now, p - frag_now->fr_literal+8, 8, &exp, 0, BFD_RELOC_64);
4896 if (alpha_evax_proc.pdsckind == PDSC_S_K_KIND_NULL)
4899 /* Add dummy fix to make add_to_link_pool work. */
4901 fixp = fix_new (frag_now, p - frag_now->fr_literal, 8, 0, 0, 0, 0);
4903 seginfo->literal_pool_size += 8;
4905 /* pdesc+16: Size. */
4906 md_number_to_chars (p, (valueT) alpha_evax_proc.framesize, 4);
4908 md_number_to_chars (p + 4, (valueT) 0, 2);
4911 md_number_to_chars (p + 6, alpha_evax_proc.prologue, 2);
4913 if (alpha_evax_proc.pdsckind == PDSC_S_K_KIND_FP_REGISTER)
4916 /* Add dummy fix to make add_to_link_pool work. */
4918 fixp = fix_new (frag_now, p - frag_now->fr_literal, 8, 0, 0, 0, 0);
4920 seginfo->literal_pool_size += 8;
4922 /* pdesc+24: register masks. */
4924 md_number_to_chars (p, alpha_evax_proc.imask, 4);
4925 md_number_to_chars (p + 4, alpha_evax_proc.fmask, 4);
4930 /* Support for crash debug on vms. */
4933 s_alpha_name (ignore)
4938 segment_info_type *seginfo = seg_info (alpha_link_section);
4940 if (now_seg != alpha_link_section)
4942 as_bad (_(".name directive not in link (.link) section"));
4943 demand_empty_rest_of_line ();
4948 if (exp.X_op != O_symbol)
4950 as_warn (_(".name directive has no symbol"));
4951 demand_empty_rest_of_line ();
4955 demand_empty_rest_of_line ();
4957 #ifdef md_flush_pending_output
4958 md_flush_pending_output ();
4961 frag_align (3, 0, 0);
4963 seginfo->literal_pool_size += 8;
4965 fix_new_exp (frag_now, p - frag_now->fr_literal, 8, &exp, 0, BFD_RELOC_64);
4971 s_alpha_linkage (ignore)
4977 #ifdef md_flush_pending_output
4978 md_flush_pending_output ();
4982 if (exp.X_op != O_symbol)
4984 as_fatal (_("No symbol after .linkage"));
4988 p = frag_more (LKP_S_K_SIZE);
4989 memset (p, 0, LKP_S_K_SIZE);
4990 fix_new_exp (frag_now, p - frag_now->fr_literal, LKP_S_K_SIZE, &exp, 0,\
4991 BFD_RELOC_ALPHA_LINKAGE);
4993 demand_empty_rest_of_line ();
4999 s_alpha_code_address (ignore)
5005 #ifdef md_flush_pending_output
5006 md_flush_pending_output ();
5010 if (exp.X_op != O_symbol)
5012 as_fatal (_("No symbol after .code_address"));
5018 fix_new_exp (frag_now, p - frag_now->fr_literal, 8, &exp, 0,\
5019 BFD_RELOC_ALPHA_CODEADDR);
5021 demand_empty_rest_of_line ();
5027 s_alpha_fp_save (ignore)
5031 alpha_evax_proc.fp_save = tc_get_register (1);
5033 demand_empty_rest_of_line ();
5038 s_alpha_mask (ignore)
5043 if (get_absolute_expression_and_terminator (&val) != ',')
5045 as_warn (_("Bad .mask directive"));
5046 --input_line_pointer;
5050 alpha_evax_proc.imask = val;
5051 (void) get_absolute_expression ();
5053 demand_empty_rest_of_line ();
5059 s_alpha_fmask (ignore)
5064 if (get_absolute_expression_and_terminator (&val) != ',')
5066 as_warn (_("Bad .fmask directive"));
5067 --input_line_pointer;
5071 alpha_evax_proc.fmask = val;
5072 (void) get_absolute_expression ();
5074 demand_empty_rest_of_line ();
5080 s_alpha_end (ignore)
5085 c = get_symbol_end ();
5086 *input_line_pointer = c;
5087 demand_empty_rest_of_line ();
5088 alpha_evax_proc.symbol = 0;
5094 s_alpha_file (ignore)
5099 static char case_hack[32];
5101 extern char *demand_copy_string PARAMS ((int *lenP));
5103 sprintf (case_hack, "<CASE:%01d%01d>",
5104 alpha_flag_hash_long_names, alpha_flag_show_after_trunc);
5106 s = symbol_find_or_make (case_hack);
5107 symbol_get_bfdsym (s)->flags |= BSF_FILE;
5109 get_absolute_expression ();
5110 s = symbol_find_or_make (demand_copy_string (&length));
5111 symbol_get_bfdsym (s)->flags |= BSF_FILE;
5112 demand_empty_rest_of_line ();
5116 #endif /* OBJ_EVAX */
5118 /* Handle the .gprel32 pseudo op. */
5121 s_alpha_gprel32 (ignore)
5122 int ignore ATTRIBUTE_UNUSED;
5134 e.X_add_symbol = section_symbol (absolute_section);
5147 e.X_add_symbol = section_symbol (absolute_section);
5150 e.X_op = O_subtract;
5151 e.X_op_symbol = alpha_gp_symbol;
5159 if (alpha_auto_align_on && alpha_current_align < 2)
5160 alpha_align (2, (char *) NULL, alpha_insn_label, 0);
5161 if (alpha_current_align > 2)
5162 alpha_current_align = 2;
5163 alpha_insn_label = NULL;
5167 fix_new_exp (frag_now, p - frag_now->fr_literal, 4,
5168 &e, 0, BFD_RELOC_GPREL32);
5171 /* Handle floating point allocation pseudo-ops. This is like the
5172 generic vresion, but it makes sure the current label, if any, is
5173 correctly aligned. */
5176 s_alpha_float_cons (type)
5203 if (alpha_auto_align_on && alpha_current_align < log_size)
5204 alpha_align (log_size, (char *) NULL, alpha_insn_label, 0);
5205 if (alpha_current_align > log_size)
5206 alpha_current_align = log_size;
5207 alpha_insn_label = NULL;
5212 /* Handle the .proc pseudo op. We don't really do much with it except
5216 s_alpha_proc (is_static)
5217 int is_static ATTRIBUTE_UNUSED;
5225 /* Takes ".proc name,nargs" */
5227 name = input_line_pointer;
5228 c = get_symbol_end ();
5229 p = input_line_pointer;
5230 symbolP = symbol_find_or_make (name);
5233 if (*input_line_pointer != ',')
5236 as_warn (_("Expected comma after name \"%s\""), name);
5239 ignore_rest_of_line ();
5243 input_line_pointer++;
5244 temp = get_absolute_expression ();
5246 /* *symbol_get_obj (symbolP) = (signed char) temp; */
5247 as_warn (_("unhandled: .proc %s,%d"), name, temp);
5248 demand_empty_rest_of_line ();
5251 /* Handle the .set pseudo op. This is used to turn on and off most of
5252 the assembler features. */
5256 int x ATTRIBUTE_UNUSED;
5262 name = input_line_pointer;
5263 ch = get_symbol_end ();
5266 if (s[0] == 'n' && s[1] == 'o')
5271 if (!strcmp ("reorder", s))
5273 else if (!strcmp ("at", s))
5274 alpha_noat_on = !yesno;
5275 else if (!strcmp ("macro", s))
5276 alpha_macros_on = yesno;
5277 else if (!strcmp ("move", s))
5279 else if (!strcmp ("volatile", s))
5282 as_warn (_("Tried to .set unrecognized mode `%s'"), name);
5284 *input_line_pointer = ch;
5285 demand_empty_rest_of_line ();
5288 /* Handle the .base pseudo op. This changes the assembler's notion of
5289 the $gp register. */
5292 s_alpha_base (ignore)
5293 int ignore ATTRIBUTE_UNUSED;
5296 if (first_32bit_quadrant)
5298 /* not fatal, but it might not work in the end */
5299 as_warn (_("File overrides no-base-register option."));
5300 first_32bit_quadrant = 0;
5305 if (*input_line_pointer == '$')
5307 input_line_pointer++;
5308 if (*input_line_pointer == 'r')
5309 input_line_pointer++;
5312 alpha_gp_register = get_absolute_expression ();
5313 if (alpha_gp_register < 0 || alpha_gp_register > 31)
5315 alpha_gp_register = AXP_REG_GP;
5316 as_warn (_("Bad base register, using $%d."), alpha_gp_register);
5319 demand_empty_rest_of_line ();
5322 /* Handle the .align pseudo-op. This aligns to a power of two. It
5323 also adjusts any current instruction label. We treat this the same
5324 way the MIPS port does: .align 0 turns off auto alignment. */
5327 s_alpha_align (ignore)
5328 int ignore ATTRIBUTE_UNUSED;
5332 long max_alignment = 15;
5334 align = get_absolute_expression ();
5335 if (align > max_alignment)
5337 align = max_alignment;
5338 as_bad (_("Alignment too large: %d. assumed"), align);
5342 as_warn (_("Alignment negative: 0 assumed"));
5346 if (*input_line_pointer == ',')
5348 input_line_pointer++;
5349 fill = get_absolute_expression ();
5357 alpha_auto_align_on = 1;
5358 alpha_align (align, pfill, alpha_insn_label, 1);
5362 alpha_auto_align_on = 0;
5365 demand_empty_rest_of_line ();
5368 /* Hook the normal string processor to reset known alignment. */
5371 s_alpha_stringer (terminate)
5374 alpha_current_align = 0;
5375 alpha_insn_label = NULL;
5376 stringer (terminate);
5379 /* Hook the normal space processing to reset known alignment. */
5382 s_alpha_space (ignore)
5385 alpha_current_align = 0;
5386 alpha_insn_label = NULL;
5390 /* Hook into cons for auto-alignment. */
5393 alpha_cons_align (size)
5399 while ((size >>= 1) != 0)
5402 if (alpha_auto_align_on && alpha_current_align < log_size)
5403 alpha_align (log_size, (char *) NULL, alpha_insn_label, 0);
5404 if (alpha_current_align > log_size)
5405 alpha_current_align = log_size;
5406 alpha_insn_label = NULL;
5409 /* Here come the .uword, .ulong, and .uquad explicitly unaligned
5410 pseudos. We just turn off auto-alignment and call down to cons. */
5413 s_alpha_ucons (bytes)
5416 int hold = alpha_auto_align_on;
5417 alpha_auto_align_on = 0;
5419 alpha_auto_align_on = hold;
5422 /* Switch the working cpu type. */
5425 s_alpha_arch (ignored)
5426 int ignored ATTRIBUTE_UNUSED;
5429 const struct cpu_type *p;
5432 name = input_line_pointer;
5433 ch = get_symbol_end ();
5435 for (p = cpu_types; p->name; ++p)
5436 if (strcmp (name, p->name) == 0)
5438 alpha_target_name = p->name, alpha_target = p->flags;
5441 as_warn ("Unknown CPU identifier `%s'", name);
5444 *input_line_pointer = ch;
5445 demand_empty_rest_of_line ();
5449 /* print token expression with alpha specific extension. */
5452 alpha_print_token (f, exp)
5454 const expressionS *exp;
5464 expressionS nexp = *exp;
5465 nexp.X_op = O_register;
5466 print_expr (f, &nexp);
5471 print_expr (f, exp);
5478 /* The target specific pseudo-ops which we support. */
5480 const pseudo_typeS md_pseudo_table[] = {
5482 {"comm", s_alpha_comm, 0}, /* osf1 compiler does this */
5483 {"rdata", s_alpha_rdata, 0},
5485 {"text", s_alpha_text, 0},
5486 {"data", s_alpha_data, 0},
5488 {"sdata", s_alpha_sdata, 0},
5491 {"section", s_alpha_section, 0},
5492 {"section.s", s_alpha_section, 0},
5493 {"sect", s_alpha_section, 0},
5494 {"sect.s", s_alpha_section, 0},
5497 { "pdesc", s_alpha_pdesc, 0},
5498 { "name", s_alpha_name, 0},
5499 { "linkage", s_alpha_linkage, 0},
5500 { "code_address", s_alpha_code_address, 0},
5501 { "ent", s_alpha_ent, 0},
5502 { "frame", s_alpha_frame, 0},
5503 { "fp_save", s_alpha_fp_save, 0},
5504 { "mask", s_alpha_mask, 0},
5505 { "fmask", s_alpha_fmask, 0},
5506 { "end", s_alpha_end, 0},
5507 { "file", s_alpha_file, 0},
5508 { "rdata", s_alpha_section, 1},
5509 { "comm", s_alpha_comm, 0},
5510 { "link", s_alpha_section, 3},
5511 { "ctors", s_alpha_section, 4},
5512 { "dtors", s_alpha_section, 5},
5515 /* Frame related pseudos. */
5516 {"ent", s_alpha_ent, 0},
5517 {"end", s_alpha_end, 0},
5518 {"mask", s_alpha_mask, 0},
5519 {"fmask", s_alpha_mask, 1},
5520 {"frame", s_alpha_frame, 0},
5521 {"prologue", s_alpha_prologue, 0},
5522 {"file", s_alpha_file, 5},
5523 {"loc", s_alpha_loc, 9},
5524 {"stabs", s_alpha_stab, 's'},
5525 {"stabn", s_alpha_stab, 'n'},
5526 /* COFF debugging related pseudos. */
5527 {"begin", s_alpha_coff_wrapper, 0},
5528 {"bend", s_alpha_coff_wrapper, 1},
5529 {"def", s_alpha_coff_wrapper, 2},
5530 {"dim", s_alpha_coff_wrapper, 3},
5531 {"endef", s_alpha_coff_wrapper, 4},
5532 {"scl", s_alpha_coff_wrapper, 5},
5533 {"tag", s_alpha_coff_wrapper, 6},
5534 {"val", s_alpha_coff_wrapper, 7},
5536 {"prologue", s_ignore, 0},
5538 {"gprel32", s_alpha_gprel32, 0},
5539 {"t_floating", s_alpha_float_cons, 'd'},
5540 {"s_floating", s_alpha_float_cons, 'f'},
5541 {"f_floating", s_alpha_float_cons, 'F'},
5542 {"g_floating", s_alpha_float_cons, 'G'},
5543 {"d_floating", s_alpha_float_cons, 'D'},
5545 {"proc", s_alpha_proc, 0},
5546 {"aproc", s_alpha_proc, 1},
5547 {"set", s_alpha_set, 0},
5548 {"reguse", s_ignore, 0},
5549 {"livereg", s_ignore, 0},
5550 {"base", s_alpha_base, 0}, /*??*/
5551 {"option", s_ignore, 0},
5552 {"aent", s_ignore, 0},
5553 {"ugen", s_ignore, 0},
5554 {"eflag", s_ignore, 0},
5556 {"align", s_alpha_align, 0},
5557 {"double", s_alpha_float_cons, 'd'},
5558 {"float", s_alpha_float_cons, 'f'},
5559 {"single", s_alpha_float_cons, 'f'},
5560 {"ascii", s_alpha_stringer, 0},
5561 {"asciz", s_alpha_stringer, 1},
5562 {"string", s_alpha_stringer, 1},
5563 {"space", s_alpha_space, 0},
5564 {"skip", s_alpha_space, 0},
5565 {"zero", s_alpha_space, 0},
5567 /* Unaligned data pseudos. */
5568 {"uword", s_alpha_ucons, 2},
5569 {"ulong", s_alpha_ucons, 4},
5570 {"uquad", s_alpha_ucons, 8},
5573 /* Dwarf wants these versions of unaligned. */
5574 {"2byte", s_alpha_ucons, 2},
5575 {"4byte", s_alpha_ucons, 4},
5576 {"8byte", s_alpha_ucons, 8},
5579 /* We don't do any optimizing, so we can safely ignore these. */
5580 {"noalias", s_ignore, 0},
5581 {"alias", s_ignore, 0},
5583 {"arch", s_alpha_arch, 0},
5588 /* Build a BFD section with its flags set appropriately for the .lita,
5589 .lit8, or .lit4 sections. */
5592 create_literal_section (name, secp, symp)
5597 segT current_section = now_seg;
5598 int current_subsec = now_subseg;
5601 *secp = new_sec = subseg_new (name, 0);
5602 subseg_set (current_section, current_subsec);
5603 bfd_set_section_alignment (stdoutput, new_sec, 4);
5604 bfd_set_section_flags (stdoutput, new_sec,
5605 SEC_RELOC | SEC_ALLOC | SEC_LOAD | SEC_READONLY
5608 S_CLEAR_EXTERNAL (*symp = section_symbol (new_sec));
5613 /* @@@ GP selection voodoo. All of this seems overly complicated and
5614 unnecessary; which is the primary reason it's for ECOFF only. */
5623 vma = bfd_get_section_vma (foo, sec);
5624 if (vma && vma < alpha_gp_value)
5625 alpha_gp_value = vma;
5631 assert (alpha_gp_value == 0);
5633 /* Get minus-one in whatever width... */
5637 /* Select the smallest VMA of these existing sections. */
5638 maybe_set_gp (alpha_lita_section);
5640 /* These were disabled before -- should we use them? */
5641 maybe_set_gp (sdata);
5642 maybe_set_gp (lit8_sec);
5643 maybe_set_gp (lit4_sec);
5646 /* @@ Will a simple 0x8000 work here? If not, why not? */
5647 #define GP_ADJUSTMENT (0x8000 - 0x10)
5649 alpha_gp_value += GP_ADJUSTMENT;
5651 S_SET_VALUE (alpha_gp_symbol, alpha_gp_value);
5654 printf (_("Chose GP value of %lx\n"), alpha_gp_value);
5657 #endif /* OBJ_ECOFF */
5659 /* Called internally to handle all alignment needs. This takes care
5660 of eliding calls to frag_align if'n the cached current alignment
5661 says we've already got it, as well as taking care of the auto-align
5662 feature wrt labels. */
5665 alpha_align (n, pfill, label, force)
5669 int force ATTRIBUTE_UNUSED;
5671 if (alpha_current_align >= n)
5676 if (subseg_text_p (now_seg))
5677 frag_align_code (n, 0);
5679 frag_align (n, 0, 0);
5682 frag_align (n, *pfill, 0);
5684 alpha_current_align = n;
5686 if (label != NULL && S_GET_SEGMENT (label) == now_seg)
5688 symbol_set_frag (label, frag_now);
5689 S_SET_VALUE (label, (valueT) frag_now_fix ());
5692 record_alignment (now_seg, n);
5694 /* ??? If alpha_flag_relax && force && elf, record the requested alignment
5695 in a reloc for the linker to see. */
5698 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
5699 of an rs_align_code fragment. */
5702 alpha_handle_align (fragp)
5705 static char const unop[4] = { 0x00, 0x00, 0xe0, 0x2f };
5706 static char const nopunop[8] = {
5707 0x1f, 0x04, 0xff, 0x47,
5708 0x00, 0x00, 0xe0, 0x2f
5714 if (fragp->fr_type != rs_align_code)
5717 bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix;
5718 p = fragp->fr_literal + fragp->fr_fix;
5731 memcpy (p, unop, 4);
5737 memcpy (p, nopunop, 8);
5739 fragp->fr_fix += fix;
5743 /* The Alpha has support for some VAX floating point types, as well as for
5744 IEEE floating point. We consider IEEE to be the primary floating point
5745 format, and sneak in the VAX floating point support here. */
5746 #define md_atof vax_md_atof
5747 #include "config/atof-vax.c"